qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
370,664 | <p>I have a two classes:</p>
<pre><code>public class Question
{
public IList<Answer> Answers { get; set; }
}
public class Answer
{ .. }
</code></pre>
<p>In my Linq2Sql designer, there's two L2S objects on designer, with the correct 0<->many arrow between them. Kewl.</p>
<p>I'm not sure how i can retrie... | [
{
"answer_id": 370671,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": true,
"text": "<p>If your LINQ to SQL classes have a relationship between them, then an \"Answers\" property should have been generated ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I have a two classes:
```
public class Question
{
public IList<Answer> Answers { get; set; }
}
public class Answer
{ .. }
```
In my Linq2Sql designer, there's two L2S objects on designer, with the correct 0<->many arrow between them. Kewl.
I'm not sure how i can retrieve these questions/answers in a single cal... | If your LINQ to SQL classes have a relationship between them, then an "Answers" property should have been generated on the "Question" LINQ to SQL class. So you should be able to simply do this:
```
return from q in _db.Questions
select new Question
{
Title = q.Title,
Answers = q.Ans... |
370,678 | <p>I just have started to learn Haskell and combine reading books and tutorials with solving problems from Project Euler. I have stuck on <a href="http://projecteuler.net/index.php?section=problems&id=27" rel="nofollow noreferrer">Problem 27</a> because I get "C stack overflow" error using this code: </p>
<p><stro... | [
{
"answer_id": 371390,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know why <a href=\"https://stackoverflow.com/users/34509/litb\">litb</a> put his answer into a comment inste... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I just have started to learn Haskell and combine reading books and tutorials with solving problems from Project Euler. I have stuck on [Problem 27](http://projecteuler.net/index.php?section=problems&id=27) because I get "C stack overflow" error using this code:
**euler.hs**
```
divisors n = [x | x <- [1..n `div` 2],... | A "stack overflow" error means that the chain of function calls in your program (from the entry function down to the currently executing function) has grown too large. Most compilers and runtimes implement the call chain as a stack data structure—each element is a "stack frame" containing the local variables and contex... |
370,694 | <p>I am working on some batch file.
I need to read name from some text file. Let me explain it</p>
<p>I have one file <code>File.txt</code>, which has entry like <code>FirstName=John</code>.
Now my batch file should read text <code>John</code> from the file and I should be able store <code>John</code> in some variable... | [
{
"answer_id": 370715,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<pre><code>@echo off\nsetlocal\nfor /F \"tokens=1,2 delims==\" %%a in (File.txt) do set Title=%%b\necho %Title%\n</code></pre>\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on some batch file.
I need to read name from some text file. Let me explain it
I have one file `File.txt`, which has entry like `FirstName=John`.
Now my batch file should read text `John` from the file and I should be able store `John` in some variable too.
But with following code, if I use `delims==`,I ... | ```
@echo off
setlocal
for /F "tokens=1,2 delims==" %%a in (File.txt) do set Title=%%b
echo %Title%
```
Does extract the first name value into `Title`... but only for the last line containing `Firstname`!
```
@echo off
setlocal
for /F "tokens=1,2 delims==" %%a in (File.txt) do (
set t=%t% %%b
)
echo %t:Firstname... |
370,695 | <p>I have a java class which fires custom java events. The structure of the code is the following:</p>
<pre><code>public class AEvent extends EventObject {
...
}
public interface AListener extends EventListener {
public void event1(AEvent event);
}
public class A {
public synchronized void addAListener(AListe... | [
{
"answer_id": 370703,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 5,
"selected": true,
"text": "<p>I don't see a reason why <code>BListener</code> should extend <code>AListener</code>.</p>\n\n<p>Do you really want... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21348/"
] | I have a java class which fires custom java events. The structure of the code is the following:
```
public class AEvent extends EventObject {
...
}
public interface AListener extends EventListener {
public void event1(AEvent event);
}
public class A {
public synchronized void addAListener(AListener l) {
..
... | I don't see a reason why `BListener` should extend `AListener`.
Do you really want to force everyone interested in `B` events to also implement `event1()`?
Also you can't add `addAListener()`, since a derived class can not reduce the visibility of a method that's present in the parent class. Also, you shouldn't need ... |
370,707 | <p>I fail to understand why this code won't compile</p>
<pre><code>ExecutorService executor = new ScheduledThreadPoolExecutor(threads);
class DocFeeder implements Callable<Boolean> {....}
...
List<DocFeeder> list = new LinkedList<DocFeeder>();
list.add(new DocFeeder(1));
...
executor.invokeAll(lis... | [
{
"answer_id": 370721,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": false,
"text": "<p>That code compiles perfectly fine with Java 6, but fails to compile with Java 5 giving</p>\n\n<pre>Foo.java:9: ca... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4038/"
] | I fail to understand why this code won't compile
```
ExecutorService executor = new ScheduledThreadPoolExecutor(threads);
class DocFeeder implements Callable<Boolean> {....}
...
List<DocFeeder> list = new LinkedList<DocFeeder>();
list.add(new DocFeeder(1));
...
executor.invokeAll(list);
```
The error msg is:
``... | Just to expand on saua's answer a little...
In Java 5, the method was declared as:
```
invokeAll(Collection<Callable<T>> tasks)
```
In Java 6, the method is declared as:
```
invokeAll(Collection<? extends Callable<T>> tasks)
```
The wildcarding difference is very important - because `List<DocFeeder>` *is* a `C... |
370,710 | <p>Apologies for the long post, but I wonder if I could get some more eyeballs on this before I submit a bug report to Sun.</p>
<p>JVM: 6u11<br>
O/S: Windows XP SP3<br>
Hardware: AMD Athlon 64 X2 4600+ @ 2.41GHz, with 3.25 GB RAM.</p>
<p>I believe I have encountered a fault in the JVM where no thread is given a monit... | [
{
"answer_id": 370806,
"author": "hakan",
"author_id": 3993,
"author_profile": "https://Stackoverflow.com/users/3993",
"pm_score": 1,
"selected": false,
"text": "<p>Are you sure thread RelayedMessages-0000000001 gets notified? It is normal for the other threads to be blocked as the first... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8946/"
] | Apologies for the long post, but I wonder if I could get some more eyeballs on this before I submit a bug report to Sun.
JVM: 6u11
O/S: Windows XP SP3
Hardware: AMD Athlon 64 X2 4600+ @ 2.41GHz, with 3.25 GB RAM.
I believe I have encountered a fault in the JVM where no thread is given a monitor. In the followin... | The provided thread trace is complete with respect to the lock in question. Two other people I work with agree that a JVM fault is clearly indicated, as do the programmers at jProfiler (ej-technologies). |
370,716 | <p>I have written jQuery code, in files <code>Main.html</code> and <code>ajax.php</code>. The <code>ajax.php</code> file returns the link of images to <code>Main.html</code>.</p>
<p>Now in <code>Main.html</code>, I have Image1, Image2, Image3, etc.</p>
<p>My <code>Main.html</code> file:</p>
<pre><code><html>
... | [
{
"answer_id": 370758,
"author": "Russ Cam",
"author_id": 1831,
"author_profile": "https://Stackoverflow.com/users/1831",
"pm_score": 1,
"selected": false,
"text": "<p>It sounds like you might want to take a look at the <a href=\"http://leandrovieira.com/projects/jquery/lightbox/\" rel=\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I have written jQuery code, in files `Main.html` and `ajax.php`. The `ajax.php` file returns the link of images to `Main.html`.
Now in `Main.html`, I have Image1, Image2, Image3, etc.
My `Main.html` file:
```
<html>
...
# ajax.php Call
...
# Return fields from Ajax.php
</html>
```
My ajax.php file
... | File `ajax.php` output must return the below [HTML](http://en.wikipedia.org/wiki/HTML):
```
<a href="#" class="imageLink" title="fid1"><img src="src1" id="fid1" alt="Name1" style="display:none;" /><span>Click To View image1</span></a>
<a href="#" class="imageLink" title="fid2"><img src="src2" id="fid2" alt="Name2" st... |
370,717 | <p>I have a job to enter survey results (in paper form) to excel.
I've never written any macro in Office :(</p>
<p>Here I what I basically need:</p>
<ol>
<li>I have predefined columns (|A|B|...|AG|AH|)</li>
<li>All surveys are grouped into groups. All surveys from same group have few (like predefined) same columns. I... | [
{
"answer_id": 371143,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": true,
"text": "<p>It seems to me you need a small userform with just a textbox, a range to show the order of data entry, say:</p>\n\n<p>Gr... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35425/"
] | I have a job to enter survey results (in paper form) to excel.
I've never written any macro in Office :(
Here I what I basically need:
1. I have predefined columns (|A|B|...|AG|AH|)
2. All surveys are grouped into groups. All surveys from same group have few (like predefined) same columns. It's always same columns th... | It seems to me you need a small userform with just a textbox, a range to show the order of data entry, say:
Group A | E | D | F | G
And a little code to go with the form, say:
```
Dim LastCol As Integer
Dim CurRow As Integer
Private Sub UpdateCells()
Dim Col As Variant
Dim ColumnOrder As Range
'Range that specifie... |
370,718 | <p>Is it possible to access a USB drive or Flash card without using the drive letter that Windows assigns it? I thought I read somewhere that the Volume GUID or something can be used but will that allow me to open it up in explorer once I identify it? The reason this is important to me is because there may not be enoug... | [
{
"answer_id": 370731,
"author": "andypaxo",
"author_id": 46575,
"author_profile": "https://Stackoverflow.com/users/46575",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using NTFS, You can create 'volume mount points' in Windows. (Similar to *NIX, if you have used that).</p>\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to access a USB drive or Flash card without using the drive letter that Windows assigns it? I thought I read somewhere that the Volume GUID or something can be used but will that allow me to open it up in explorer once I identify it? The reason this is important to me is because there may not be enough d... | Use MOUNTVOL by itself to get the drive ID.

Here you go:
```
MOUNTVOL C:\USB: \\?\Volume{ebc79032-5270-11d8-a724-806d6172696f}\
OR Winkey+R (Start-Run) \\?\Volume{ebc79032-5270-11d8-a724-806d6172696f}\
``` |
370,720 | <p>I have the following construction:</p>
<pre><code>typedef struct bucket {
char *key;
ENTRY *data;
struct bucket *next;
} bucket;
typedef struct {
size_t size;
bucket **table;
} hash_table;
</code></pre>
<p>But I have no idea how to allocate memory for that. I tried: </p>
<pre><code>hash_table... | [
{
"answer_id": 370726,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>hash_table</code> will always be only <code>sizeof(hash_table)</code> bytes big. The <code>table</code>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43960/"
] | I have the following construction:
```
typedef struct bucket {
char *key;
ENTRY *data;
struct bucket *next;
} bucket;
typedef struct {
size_t size;
bucket **table;
} hash_table;
```
But I have no idea how to allocate memory for that. I tried:
```
hash_table* ht = malloc(sizeof(hash_table)*101)... | Not quite. Assuming this is C, you probably want to make a function:
```
hash_table* init_table(size_t size) {
size_t i;
hash_table* ht = (hash_table*)malloc(sizeof(hash_table));
if (ht == NULL) return NULL;
ht->size = size;
ht->table = (bucket**)malloc(sizeof(bucket*)*size);
if (ht->tab... |
370,722 | <p>i'm begginner in java,
i have textarea and i have set only verticle scrollbar to that textarea.i'm appending data for every 1 minute to textarea,problem is when new data appends to the textarea scrollbar will move up.To see the new data,every time i have to drag the scroll bar, that is not the requirment.i want scro... | [
{
"answer_id": 370726,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>hash_table</code> will always be only <code>sizeof(hash_table)</code> bytes big. The <code>table</code>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i'm begginner in java,
i have textarea and i have set only verticle scrollbar to that textarea.i'm appending data for every 1 minute to textarea,problem is when new data appends to the textarea scrollbar will move up.To see the new data,every time i have to drag the scroll bar, that is not the requirment.i want scrollb... | Not quite. Assuming this is C, you probably want to make a function:
```
hash_table* init_table(size_t size) {
size_t i;
hash_table* ht = (hash_table*)malloc(sizeof(hash_table));
if (ht == NULL) return NULL;
ht->size = size;
ht->table = (bucket**)malloc(sizeof(bucket*)*size);
if (ht->tab... |
370,730 | <p>I've been having a major issue... well maybe not major, but I've been trying to figure this out since yesterday lunchtime.<br>
I have the following code:</p>
<pre><code>Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Data!R7C1:R5000C40").CreatePivotTable Ta... | [
{
"answer_id": 371178,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": "<p>Just guessing ... Is ActiveWorkbook still ok? Have you tried using a named workbook?</p>\n"
},
{
"answer_id": 3... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42389/"
] | I've been having a major issue... well maybe not major, but I've been trying to figure this out since yesterday lunchtime.
I have the following code:
```
Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
"Data!R7C1:R5000C40").CreatePivotTable TableDestination:... | Fixed it (earlier, Remou pointed out that posting the answer is a good thing).
I messed up a bit.
My data was dynamic, on every reload another set. In my testing set, everything went awesomely fine. Then, as I loaded a new set, values changed, labels were added, others were left out... one of my pivot tables became... |
370,754 | <p>In a C# Windows.Forms project I have a control that does not supply the KeyPressed event (It’s a COM control – ESRI map). </p>
<p>It only supplies the KeyUp and KeyDown events, containing the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx" rel="noreferrer">KeyEventArgs</a> s... | [
{
"answer_id": 372390,
"author": "Martin Plante",
"author_id": 4898,
"author_profile": "https://Stackoverflow.com/users/4898",
"pm_score": 0,
"selected": false,
"text": "<p>Look at <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.keysconverter.aspx\" rel=\"nofollow ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38265/"
] | In a C# Windows.Forms project I have a control that does not supply the KeyPressed event (It’s a COM control – ESRI map).
It only supplies the KeyUp and KeyDown events, containing the [KeyEventArgs](http://msdn.microsoft.com/en-us/library/system.windows.forms.keyeventargs.aspx) structure.
How can I convert the infor... | The trick is to use a set of user32.dll functions: [GetWindowThreadProcessId](http://msdn.microsoft.com/en-us/library/ms633522(VS.85).aspx), [GetKeyboardLayout](http://msdn.microsoft.com/en-us/library/ms646296.aspx), [GetKeyboardState](http://msdn.microsoft.com/en-us/library/ms646299(VS.85).aspx) and [ToUnicodeEx](http... |
370,768 | <p>Requirements:</p>
<ul>
<li>Must be able to use C strings as well as C++ strings</li>
<li>Fast</li>
<li>No maps</li>
<li>No templates</li>
<li>No direct lookup, i.e. index might be out of bounds.</li>
<li>Index is not consecutive</li>
<li>Enums and strings contained in one header file</li>
<li>Only instantiate what ... | [
{
"answer_id": 370805,
"author": "Patrick",
"author_id": 38892,
"author_profile": "https://Stackoverflow.com/users/38892",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I can't do a direct mapping since one application might be feeding me values which are >out of range fo... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46583/"
] | Requirements:
* Must be able to use C strings as well as C++ strings
* Fast
* No maps
* No templates
* No direct lookup, i.e. index might be out of bounds.
* Index is not consecutive
* Enums and strings contained in one header file
* Only instantiate what you use.
This is what I have come up with so far:
```
- test.... | Here is what I settled on. Using this technique all you need to do is to include a header file. You will only instantiate what you use. You could also store a perfect hash table instead of just Idx & pStr. This approach does not work in C.
file: e2str.hh
```
struct Mapper_s
{
int Idx;
const char *pStr;
};
#d... |
370,783 | <p>My master page has a contentplaceholder in the head tag.</p>
<p>Because I want my page's title to represent the function of the current page and because I want the title to be translated in the user's language I have added a title tag in the page's head's contentplaceholder. All jolly and good except that now there... | [
{
"answer_id": 370792,
"author": "BlackMael",
"author_id": 19377,
"author_profile": "https://Stackoverflow.com/users/19377",
"pm_score": 0,
"selected": false,
"text": "<p>There is an attribute in the @Page directive called Title for setting the title of the page. It is also available ac... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | My master page has a contentplaceholder in the head tag.
Because I want my page's title to represent the function of the current page and because I want the title to be translated in the user's language I have added a title tag in the page's head's contentplaceholder. All jolly and good except that now there appears a... | I ran into the same problem and [found a solution](http://blogs.lotterypost.com/speednet/2007/07/aspnet-tip-how-to-prevent-the-title-tag-fro.htm) that seems to work. It's pretty hacky but at the same time pretty simple. Just add another title tag in the head, put a runat="server" attribute inside it and then set it's v... |
370,801 | <p>When reading data from the Input file I noticed that the ¥ symbom was not being read by the StreamReader. Mozilla Firefox showed the input file type as Western (ISO-8859-1).</p>
<p>After playing around with the encoding parameters I found it worked successfully for the following values:</p>
<pre><code>System.Text.... | [
{
"answer_id": 370811,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>Code page 1252 isn't quite the same as ISO-Latin-1. If you want ISO-Latin-1, use <code>Encoding.GetEncoding(28591)</co... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41766/"
] | When reading data from the Input file I noticed that the ¥ symbom was not being read by the StreamReader. Mozilla Firefox showed the input file type as Western (ISO-8859-1).
After playing around with the encoding parameters I found it worked successfully for the following values:
```
System.Text.Encoding.GetEncoding(... | Code page 1252 isn't quite the same as ISO-Latin-1. If you want ISO-Latin-1, use `Encoding.GetEncoding(28591)`. However, I'd expect them to be the same for this code point (U+00A5). UTF-7 is completely different (and almost never what you want to use).
`Encoding.Default` is *not* safe - it's a really bad idea in most ... |
370,812 | <p>I am using a class <code>Foo</code> that provides these methods:</p>
<pre><code>String overloadedMethod(Object)
String overloadedMethod(Goo)
</code></pre>
<p>Since Java statically dispatches on the non-receiver argument, I cannot just pass my <code>value</code> (which is an <code>Object</code>, but might have dyna... | [
{
"answer_id": 370815,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 3,
"selected": true,
"text": "<p>Of course you could always use reflection to find the most specific version of the method that applies, but that c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45018/"
] | I am using a class `Foo` that provides these methods:
```
String overloadedMethod(Object)
String overloadedMethod(Goo)
```
Since Java statically dispatches on the non-receiver argument, I cannot just pass my `value` (which is an `Object`, but might have dynamic type `Goo`) and rely on the JVM to dynamically choose t... | Of course you could always use reflection to find the most specific version of the method that applies, but that could get hairy real quick.
But if those two calls result in entirely different behaviour, then Foo is either designed to be used in a visitor pattern (i.e. with double dispatch) or it is broken. |
370,817 | <p>I've thrown myself headfirst into C# and .Net 2.0 using Linq, and I'm having a few problems debugging some of the problems, namely the following:</p>
<p>I have a ComboBox control (<code>cmbObjects</code>) I want to populate with a set of objects retrieved using Linq. I've written a helper method to populate a <code... | [
{
"answer_id": 374133,
"author": "Klemen Slavič",
"author_id": 46588,
"author_profile": "https://Stackoverflow.com/users/46588",
"pm_score": 1,
"selected": true,
"text": "<p>Okay, it seems the <code>DataSource</code> becomes invalid if you try to add a <code>null</code> value. The soluti... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46588/"
] | I've thrown myself headfirst into C# and .Net 2.0 using Linq, and I'm having a few problems debugging some of the problems, namely the following:
I have a ComboBox control (`cmbObjects`) I want to populate with a set of objects retrieved using Linq. I've written a helper method to populate a `List<T>` generic:
```
cl... | Okay, it seems the `DataSource` becomes invalid if you try to add a `null` value. The solution was to just add the items via a simple `foreach` loop with an empty string at the start instead of assigning the `List<>`. |
370,818 | <p>I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way. </p>
<p>I did think of using MessageFormat - but its supposed t... | [
{
"answer_id": 370824,
"author": "GaryF",
"author_id": 1035,
"author_profile": "https://Stackoverflow.com/users/1035",
"pm_score": 3,
"selected": false,
"text": "<p>I tend to use Spring's Named JDBC Parameters so I can write a standard string like \"select * from blah where colX=':someVa... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] | I want to build an SQL string to do database manipulation (updates, deletes, inserts, selects, that sort of thing) - instead of the awful string concat method using millions of "+"'s and quotes which is unreadable at best - there must be a better way.
I did think of using MessageFormat - but its supposed to be used f... | First of all consider using query parameters in prepared statements:
```
PreparedStatement stm = c.prepareStatement("UPDATE user_table SET name=? WHERE id=?");
stm.setString(1, "the name");
stm.setInt(2, 345);
stm.executeUpdate();
```
The other thing that can be done is to keep all queries in properties file. For ex... |
370,837 | <p>I have an application written in Delphi 7 which does not require an admin privilages to run. </p>
<p>For some reason I am able to save files to c:\windows and c:\windows\system32 from within the application even though the application <b>has not requested UAC elevation</b>. I am logged in as an admin with <b>UAC t... | [
{
"answer_id": 370856,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I am running as an admin with UAC turned on.</p>\n</blockquote>\n\n<p>Do you mean that you are log... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/922/"
] | I have an application written in Delphi 7 which does not require an admin privilages to run.
For some reason I am able to save files to c:\windows and c:\windows\system32 from within the application even though the application **has not requested UAC elevation**. I am logged in as an admin with **UAC turned on** and ... | This is a feature of UAC to make old applications compatible with Vista. It redirects any request to write to a system folder that the user lacks permission to a local folder.
They are stored under "AppData\Local\VirtualStore" folder under the current user's profile.
There is a group policy setting to disable this fea... |
370,839 | <p>I'm using Linq To Sql to fill up a listbox with Segment objects, where Segment is designer created/ORM generated class.</p>
<pre><code><Window x:Class="ICTemplates.Window1"
...
xmlns:local="clr-namespace:ICTemplates"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<... | [
{
"answer_id": 371876,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 0,
"selected": false,
"text": "<p>This is just a guess, but could it be because the context is set to an IQueryable? If you set the DataContext to a single... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | I'm using Linq To Sql to fill up a listbox with Segment objects, where Segment is designer created/ORM generated class.
```
<Window x:Class="ICTemplates.Window1"
...
xmlns:local="clr-namespace:ICTemplates"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<DataTemplate x:Key="MyTemplat... | Ze Mistake is here
```
<DataTemplate DataType="x:Type local:Segment"> <!-- doesn't work -->
```
should be
```
<DataTemplate DataType="{x:Type local:Segment}">
```
Came home... made a toy-sample and it worked with this change. Gotta try that @ work tomorrow. Sheesh.. for want of 2 curlies..
**Update**: Found ou... |
370,840 | <p>Silly question, but I'm unable to figure out..</p>
<p>I tried the following in Ruby:</p>
<pre><code>irb(main):020:0> JSON.load('[1,2,3]').class
=> Array
</code></pre>
<p>This seems to work. While neither</p>
<pre><code>JSON.load('1').class
</code></pre>
<p>nor this </p>
<pre><code>JSON.load('{1}').class
... | [
{
"answer_id": 370853,
"author": "a2800276",
"author_id": 27408,
"author_profile": "https://Stackoverflow.com/users/27408",
"pm_score": 2,
"selected": false,
"text": "<p>I'd say it's a bug:</p>\n\n<pre><code>>> JSON.parse(1.to_json)\nJSON::ParserError: A JSON text must at least con... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44232/"
] | Silly question, but I'm unable to figure out..
I tried the following in Ruby:
```
irb(main):020:0> JSON.load('[1,2,3]').class
=> Array
```
This seems to work. While neither
```
JSON.load('1').class
```
nor this
```
JSON.load('{1}').class
```
works. Any ideas? | I'd ask the guys who programmed the library. AFAIK, `1` isn't a valid JSON object, and neither is `{1}` but `1` is what the library itself generates for the fixnum 1.
You'd need to do: `{"number" : 1}` to be valid json. The bug is that
```
a != JSON.parse(JSON.generate(a))
``` |
370,850 | <p>I have a PHP file, Test.php, and it has two functions:</p>
<pre><code><?php
echo displayInfo();
echo displayDetails();
?>
</code></pre>
<p>JavaScript:</p>
<pre><code><html>
...
<script type="text/javascript">
$.ajax({
type:'POST',
url: 'display.ph... | [
{
"answer_id": 370882,
"author": "Klemen Slavič",
"author_id": 46588,
"author_profile": "https://Stackoverflow.com/users/46588",
"pm_score": 4,
"selected": true,
"text": "<p>If I understand correctly, you'd like for the <code>a</code> link to cancel navigation, but fire the AJAX function... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I have a PHP file, Test.php, and it has two functions:
```
<?php
echo displayInfo();
echo displayDetails();
?>
```
JavaScript:
```
<html>
...
<script type="text/javascript">
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: f... | If I understand correctly, you'd like for the `a` link to cancel navigation, but fire the AJAX function?
In that case:
```
$("#mylink").click(function() {
$.ajax({ type: "POST", url: "another.php", data: {id: "somedata"}, function(data) {
$("#response").html(data);
});
return false;
});
``` |
370,852 | <p>Anytime I have to handle dates/times in java it makes me sad </p>
<p>I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.</p>
<p>"Exception ... | [
{
"answer_id": 370877,
"author": "Guillaume",
"author_id": 23704,
"author_profile": "https://Stackoverflow.com/users/23704",
"pm_score": 2,
"selected": false,
"text": "<p>My guess is that you mixed java.util.Date and java.sql.Date ...</p>\n"
},
{
"answer_id": 370880,
"author"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Anytime I have to handle dates/times in java it makes me sad
I'm trying to parse a string and turn it into a date object to insert in a preparepared statement. I've been trying to get this working but am having no luck. I also get the helpful error message when I go to compile the class.
"Exception in thread "main" ... | [PreparedStatement.setDate](http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html#setDate(int,%20java.sql.Date)) takes a [java.sql.Date](http://java.sun.com/javase/6/docs/api/java/sql/Date.html), not a [java.util.Date](http://java.sun.com/javase/6/docs/api/java/util/Date.html).
(Out of interest, how co... |
370,859 | <p>The question is in the title, why :</p>
<pre><code>return double.IsNaN(0.6d) && double.IsNaN(x);
</code></pre>
<p>Instead of</p>
<pre><code>return (0.6d).IsNaN && x.IsNaN;
</code></pre>
<p>I ask because when implementing custom structs that have a special value with the same meaning as NaN I tend... | [
{
"answer_id": 370873,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>Interesting question; don't know the answer - but if it really bugs you, you could declare an extension method, but... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46594/"
] | The question is in the title, why :
```
return double.IsNaN(0.6d) && double.IsNaN(x);
```
Instead of
```
return (0.6d).IsNaN && x.IsNaN;
```
I ask because when implementing custom structs that have a special value with the same meaning as NaN I tend to prefer the second.
Additionally the performance of the prope... | Interesting question; don't know the answer - but if it really bugs you, you could declare an extension method, but it would still use the stack etc.
```
static bool IsNaN(this double value)
{
return double.IsNaN(value);
}
static void Main()
{
double x = 123.4;
bool isNan = x.IsNaN();
}
```
It would be ... |
370,878 | <p>Does anyone know how to get a service ticket from the Key Distribution Center (KDC) using the Java GSS-API?</p>
<p>I have a thick-client-application that first authenticates via JAAS using the Krb5LoginModule to fetch the TGT from the ticket cache (background: Windows e.g. uses a kerberos implementation and stores ... | [
{
"answer_id": 377108,
"author": "Roland Schneider",
"author_id": 16515,
"author_profile": "https://Stackoverflow.com/users/16515",
"pm_score": 5,
"selected": true,
"text": "<p>My understanding of getting the service ticket was wrong. I do not need to get the credentials from the service... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16515/"
] | Does anyone know how to get a service ticket from the Key Distribution Center (KDC) using the Java GSS-API?
I have a thick-client-application that first authenticates via JAAS using the Krb5LoginModule to fetch the TGT from the ticket cache (background: Windows e.g. uses a kerberos implementation and stores the ticket... | My understanding of getting the service ticket was wrong. I do not need to get the credentials from the service - this is not possible on the client, because the client really doesn't have a TGT for the server and therefore doesn't have the rights to get the service credentials.
What's just missing here is to create a ... |
370,884 | <p>I understand that you can use forms authentication to grant/deny access to certain pages based on the criteria of your choosing.</p>
<p>However I wish to go in a little more specific than that and say, have different buttons appear for users based on thier permissions.</p>
<p>I know I could do something like</p>
... | [
{
"answer_id": 370933,
"author": "Davide Vosti",
"author_id": 1812,
"author_profile": "https://Stackoverflow.com/users/1812",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same issue a while ago for a WPF application. It could work for ASP.NET as well.</p>\n\n<p>For every \"but... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | I understand that you can use forms authentication to grant/deny access to certain pages based on the criteria of your choosing.
However I wish to go in a little more specific than that and say, have different buttons appear for users based on thier permissions.
I know I could do something like
```
if(((User)ViewDat... | Use role-based authentication, then set roles appropriately. Then you can do things like:
```
if (ViewContext.HttpContext.User.IsInRole("vEmployee") {
```
The advantage of this is that it's core ASP.NET functionality -- not even MVC-specific -- so it's going to work with every possible membership provider.
Then you... |
370,913 | <p>I have been playing with the Linq to Sql and I was wondering if it was possible to get a single result out? For example, I have the following:</p>
<pre><code>using(DataClassContext context = new DataClassContext())
{
var customer = from c in context.table
where c.ID = textboxvalue
... | [
{
"answer_id": 370924,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 2,
"selected": false,
"text": "<pre><code>var customer = context.table.SingleOrDefault(c => c.ID == textboxvalue);\n</code></pre>\n"
},
{
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36243/"
] | I have been playing with the Linq to Sql and I was wondering if it was possible to get a single result out? For example, I have the following:
```
using(DataClassContext context = new DataClassContext())
{
var customer = from c in context.table
where c.ID = textboxvalue
select c;... | Yes, it's possible.
```
using(DataClassContext context = new DataClassContext())
{
var customer = (from c in context.table
where c.ID = textboxvalue
select c).SingleOrDefault();
}
```
This way you get 1 result or null if there isn't any result.
You can also use `Single()`, which throws an exception when there isn't... |
370,925 | <p>I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at <a href="https://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency">Unit testing code with a file system dependency</a> but it does not answer my question.</p>
<p... | [
{
"answer_id": 370950,
"author": "Alexandre",
"author_id": 9025,
"author_profile": "https://Stackoverflow.com/users/9025",
"pm_score": 0,
"selected": false,
"text": "<p>I think you should create two files: one with zero length, and other with some data in it. \nThen, you should have a te... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32313/"
] | I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at [Unit testing code with a file system dependency](https://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency) but it does not answer my question.
The method I am test... | **Edit** I answered before you added C# to the question (or I missed it...) so my answer is a little java-esque, but the principles are the same...
---
Your thought about a wrapper around file IO is a good one. This is one such example, but anything similar could do:
```
interface FileProvider {
public Reader ge... |
370,944 | <p>I am using a DropDownList as </p>
<pre><code><asp:DropDownList
ID="ddlLocationName"
runat="server"
DataValueField="Guid"
DataTextField="LocationName"
AppendDataBoundItems="false"
AutoPostBack="false"
onchange="LocationChange()"
></asp:DropDownList>
</code></pre>
<p>and when I selec... | [
{
"answer_id": 370980,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 2,
"selected": false,
"text": "<p>The DataValueField will populate the html <code><option /></code> tags value property, while the DataTextFie... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] | I am using a DropDownList as
```
<asp:DropDownList
ID="ddlLocationName"
runat="server"
DataValueField="Guid"
DataTextField="LocationName"
AppendDataBoundItems="false"
AutoPostBack="false"
onchange="LocationChange()"
></asp:DropDownList>
```
and when I select item from dropdown the DataTextField... | The DataValueField will populate the html `<option />` tags value property, while the DataTextField will populate the text property.
When you *don't* specify a DataValueField the DataTextField is used for both (and vice-versa IIRC).
So in JavaScript you'll want to have the following (**note - I'm using the MS AJAX sh... |
370,954 | <p>I have a KTextEdit, filled with some text. </p>
<p>When I put lots of text, the KTextEdit will be scrolled automatically to the end (obviously). </p>
<p>My question is: how can I scroll to the start (viz to the first line of the KTextEdit) ?!?</p>
| [
{
"answer_id": 370988,
"author": "user11323",
"author_id": 11323,
"author_profile": "https://Stackoverflow.com/users/11323",
"pm_score": 0,
"selected": false,
"text": "<p>The simplest way i can think of is:</p>\n\n<pre><code>KTextEdit *kte;\n...\nkte->append(\"some huge text\");\nkte-... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] | I have a KTextEdit, filled with some text.
When I put lots of text, the KTextEdit will be scrolled automatically to the end (obviously).
My question is: how can I scroll to the start (viz to the first line of the KTextEdit) ?!? | Looks like you use
```
QTextCursor cursor = edit->textCursor();
cursor.setPosition(0);
edit->setTextCursor(cursor);
```
Not tested, but looks fine. Found another, shorter way:
```
edit->moveCursor(QTextCursor::Start);
``` |
370,962 | <p>The question is in Java why can't I define an abstract static method? for example</p>
<pre><code>abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
</code></pre>
| [
{
"answer_id": 370966,
"author": "GaryF",
"author_id": 1035,
"author_profile": "https://Stackoverflow.com/users/1035",
"pm_score": 7,
"selected": false,
"text": "<p>You can't override a static method, so making it abstract would be meaningless. Moreover, a static method in an abstract cl... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] | The question is in Java why can't I define an abstract static method? for example
```
abstract class foo {
abstract void bar( ); // <-- this is ok
abstract static void bar2(); //<-- this isn't why?
}
``` | The `abstract` annotation to a method indicates that the method MUST be overriden in a subclass.
In Java, a `static` member (method or field) cannot be overridden by subclasses (this is not necessarily true in other object oriented languages, see SmallTalk.) A `static` member may be **hidden**, but that is fundamental... |
370,978 | <p>I have an application that uses a cron like job to update a set of data. The update process happens once a minute and doesn't last long. A servlet exposes this data set to the users. My problem is that during the update process, the servlet requests should block and wait for the process to complete. </p>
<p>In bott... | [
{
"answer_id": 370995,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 0,
"selected": false,
"text": "<p>You need to synchronize access on the data.</p>\n\n<pre><code>public void updateData() {\n synchronized (updateLock) {... | 2008/12/16 | [
"https://Stackoverflow.com/questions/370978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24054/"
] | I have an application that uses a cron like job to update a set of data. The update process happens once a minute and doesn't last long. A servlet exposes this data set to the users. My problem is that during the update process, the servlet requests should block and wait for the process to complete.
In bottom line I ... | Take a look at this article: [Read / Write Locks in Java](http://tutorials.jenkov.com/java-concurrency/read-write-locks.html)
The only drawback I can see in this example is the notifyAll() waking all waiting threads.
It does, however, give priority to write lock requests. |
371,005 | <p>I have a class</p>
<pre><code>public class Broker
{
public Broker(string[] hosts, string endPoint, string port, Type remoteType)
{
}
}
</code></pre>
<p>Which I want to configure using Unity XML Configuration, I can configure it using code in C# as follows already, where "container" is my Unity containe... | [
{
"answer_id": 398214,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 1,
"selected": false,
"text": "<p>Have you defined the type in the configuration file:</p>\n\n<pre><code><unity>\n<typeAliases>\n <ty... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a class
```
public class Broker
{
public Broker(string[] hosts, string endPoint, string port, Type remoteType)
{
}
}
```
Which I want to configure using Unity XML Configuration, I can configure it using code in C# as follows already, where "container" is my Unity container
```
contain... | Have you defined the type in the configuration file:
```
<unity>
<typeAliases>
<typeAlias alias="IMyBrokeredObject" type="MyAssembly.IMyBrokeredObject, MyAssembly" />
</typeAliases>
<containers>
<container>
<types>
<!-- Views -->
<type type="IMyBrokeredObject" mapTo="MyAssembly.MyBr... |
371,018 | <p>I using the Win32 API and C/C++. I have a HFONT and want to use it to create a new HFONT. The new font should use the exact same font metrics except that it should be bold. Something like:</p>
<pre><code>HFONT CreateBoldFont(HFONT hFont) {
LOGFONT lf;
GetLogicalFont(hFont, &lf);
lf.lfWeight = FW_BOL... | [
{
"answer_id": 371052,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 6,
"selected": true,
"text": "<p>You want to use the <a href=\"http://msdn.microsoft.com/en-us/library/dd144904%28v=vs.85%29.aspx\" rel=\"noreferrer\">GetOb... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20398/"
] | I using the Win32 API and C/C++. I have a HFONT and want to use it to create a new HFONT. The new font should use the exact same font metrics except that it should be bold. Something like:
```
HFONT CreateBoldFont(HFONT hFont) {
LOGFONT lf;
GetLogicalFont(hFont, &lf);
lf.lfWeight = FW_BOLD;
return Crea... | You want to use the [GetObject function](http://msdn.microsoft.com/en-us/library/dd144904%28v=vs.85%29.aspx).
```
GetObject ( hFont, sizeof(LOGFONT), &lf );
``` |
371,026 | <p>What's the shortest way to get an Iterator over a range of Integers in Java? In other words, implement the following:</p>
<pre><code>/**
* Returns an Iterator over the integers from first to first+count.
*/
Iterator<Integer> iterator(Integer first, Integer count);
</code></pre>
<p>Something like</p>
<pre><... | [
{
"answer_id": 371034,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 3,
"selected": true,
"text": "<p>Straight-forward implementation of your homework:</p>\n\n<pre><code>List<Integer> ints = new ArrayList<Integer>... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18722/"
] | What's the shortest way to get an Iterator over a range of Integers in Java? In other words, implement the following:
```
/**
* Returns an Iterator over the integers from first to first+count.
*/
Iterator<Integer> iterator(Integer first, Integer count);
```
Something like
```
(first..first+count).iterator()
``` | Straight-forward implementation of your homework:
```
List<Integer> ints = new ArrayList<Integer>();
for (int i = 0; i < count; i++) {
ints.add(first + i);
}
``` |
371,032 | <p>I am developing a program that continually sends a stream of data in the background and I want to allow the user to set a cap for both upload and download limit.</p>
<p>I have read up on the <a href="http://en.wikipedia.org/wiki/Token_bucket" rel="noreferrer">token bucket</a> and <a href="http://en.wikipedia.org/wi... | [
{
"answer_id": 29456717,
"author": "0xDEADBEEF",
"author_id": 909365,
"author_profile": "https://Stackoverflow.com/users/909365",
"pm_score": 2,
"selected": false,
"text": "<p>I came up with a different implementation of the ThrottledStream-Class mentioned by arul. My version uses a Wait... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9479/"
] | I am developing a program that continually sends a stream of data in the background and I want to allow the user to set a cap for both upload and download limit.
I have read up on the [token bucket](http://en.wikipedia.org/wiki/Token_bucket) and [leaky bucket](http://en.wikipedia.org/wiki/Leaky_bucket) alghorhithms, a... | Based on @0xDEADBEEF's solution I created the following (testable) solution based on Rx schedulers:
```
public class ThrottledStream : Stream
{
private readonly Stream parent;
private readonly int maxBytesPerSecond;
private readonly IScheduler scheduler;
private readonly IStopwatch stopwatch;
priv... |
371,055 | <p>I am trying to modify the below program to ensure each msg is converted to utf-8 using Encode::decode(), but I am unsure of how and where to place this to make it work.</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UT... | [
{
"answer_id": 371063,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 6,
"selected": true,
"text": "<p>MSDN says:</p>\n\n<blockquote>\n <p>This delegate is used by the\n Array.ForEach method and the\n List.ForEach method to... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am trying to modify the below program to ensure each msg is converted to utf-8 using Encode::decode(), but I am unsure of how and where to place this to make it work.
```
#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UTF-8)');
my $file = s... | MSDN says:
>
> This delegate is used by the
> Array.ForEach method and the
> List.ForEach method to perform an
> action on each element of the array or
> list.
>
>
>
Except that, you can use it as a generic delegate that takes 1-3 parameters without returning any value. |
371,059 | <p>Here is my query:</p>
<pre><code> Select Top 10 CS.CaseStudyID,
CS.Title,
CSI.ImageFileName
From CaseStudy CS
Left Join CaseStudyImage CSI On CS.CaseStudyID = CSI.CaseStudyID
And CSI.CSImageID in(
Select Min(CSImageID) -- >not really satisfactory
From CaseStudyImage
Group By CaseStudyID
... | [
{
"answer_id": 371061,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 0,
"selected": false,
"text": "<p><code>ORDER BY RAND() LIMIT 1</code>?</p>\n"
},
{
"answer_id": 371065,
"author": "Vincent Ramdhanie",
"au... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11394/"
] | Here is my query:
```
Select Top 10 CS.CaseStudyID,
CS.Title,
CSI.ImageFileName
From CaseStudy CS
Left Join CaseStudyImage CSI On CS.CaseStudyID = CSI.CaseStudyID
And CSI.CSImageID in(
Select Min(CSImageID) -- >not really satisfactory
From CaseStudyImage
Group By CaseStudyID
)
Order By CS.C... | You can use ranking function and newid() to create randomize order with grouping.
```
WITH CSI AS (
SELECT CSI.CaseStudyID, CSI.ImageFileName,
ROW_NUMBER() OVER(PARTITION BY CSI.CaseStudyID ORDER BY newid()) AS RowNumber
FROM CaseStudyImage CSI
)
SELECT TOP (10) CS.CaseStudyID, CS.Title, CSI.ImageFileN... |
371,064 | <p>I have unsorted map of key value pairs.</p>
<pre><code>input = {
"xa" => "xavalue",
"ab" => "abvalue",
"aa" => "aavalue",
"ba" => "bavalue",
}
</code></pre>
<p>Now I want to sort them by the key and cluster them into sections by the first character of the key. Similar to this:</p>
<pre><code>o... | [
{
"answer_id": 371234,
"author": "ttepasse",
"author_id": 46657,
"author_profile": "https://Stackoverflow.com/users/46657",
"pm_score": 1,
"selected": false,
"text": "<p>I'm a pythonista but i've tried anyway:</p>\n\n<pre><code>class Hash\n def clustered\n clustered = Hash.new\n s... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33165/"
] | I have unsorted map of key value pairs.
```
input = {
"xa" => "xavalue",
"ab" => "abvalue",
"aa" => "aavalue",
"ba" => "bavalue",
}
```
Now I want to sort them by the key and cluster them into sections by the first character of the key. Similar to this:
```
output1 = {
"a" => {
"aa" => "aavalue",
... | As far as I know, there isn't the notion of a sorted hash/map in Ruby, so you're limited to good old arrays for this one. You may want to start from this code:
```
output = input.inject({}) { |acc, pair|
letter = pair.first[0].chr
acc[letter] ||= {}
acc[letter][pair.first] = pair.last
acc
}.sort
```
This wil... |
371,072 | <p>I have the code pasted below, which servers as the core of a small ajax application. This was working fine previously, with makewindows actually displaying a popup containing the rsult of artcile_desc. I seem to have an error before that function however, as now only the actual php code is outputted. This is not a p... | [
{
"answer_id": 371122,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "<p>Mmm, if the JavaScript displays PHP code, that means the server no longer knows that something.php must run the PHP inte... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I have the code pasted below, which servers as the core of a small ajax application. This was working fine previously, with makewindows actually displaying a popup containing the rsult of artcile\_desc. I seem to have an error before that function however, as now only the actual php code is outputted. This is not a pro... | Firstly, any time you encode anything to a particular notation, you should convert the 'special characters' before doing so, just in case it breaks the notation.
```
child1.document.write("<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']), ENT_QUOTES); ?>");
```
Should read:
```
child1.document.write("... |
371,079 | <p>I have a problem with the jQuery-UI dialog in my ASP.NET form:</p>
<pre><code>$("#pnlReceiverDialog").dialog({
autoOpen:false,
modal: true,
height:220,
width:500,
resizable :false,
overlay: { opacity: 0.5,background: "black" },
buttons: {
"Cancel": function() {
$(this).dialog("close");
... | [
{
"answer_id": 381095,
"author": "Vitor Silva",
"author_id": 1842864,
"author_profile": "https://Stackoverflow.com/users/1842864",
"pm_score": 2,
"selected": false,
"text": "<p>I know that you probably already checked that the object name is the one that you wrote (ctl00$phContent$ctl00$... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem with the jQuery-UI dialog in my ASP.NET form:
```
$("#pnlReceiverDialog").dialog({
autoOpen:false,
modal: true,
height:220,
width:500,
resizable :false,
overlay: { opacity: 0.5,background: "black" },
buttons: {
"Cancel": function() {
$(this).dialog("close");
},
"Ok"... | I know that you probably already checked that the object name is the one that you wrote (ctl00$phContent$ctl00$LetterLocation$pupNewReceiver) but the first thing that i would do is to double or triple check it...
i once spent almost a day in a similar situation where the only thing that was wrong was the object name ... |
371,107 | <p>Different iPhones have different published memory 4GB, 8GB and 16GB. The touch can have 32GB. My understanding is this is the off-line memory (disk alike). </p>
<p>How much actual fast ram is there in the device available for my Cocoa Application? </p>
<p>Is there a preconfigured virtual amount?</p>
| [
{
"answer_id": 371117,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 6,
"selected": false,
"text": "<h1>iPhone</h1>\n<ul>\n<li>iPhone (June 2007): 128MB</li>\n<li>iPhone 3G (July 2008): 128MB</li>\n<li>iPhone 3GS (June 2009): ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31762/"
] | Different iPhones have different published memory 4GB, 8GB and 16GB. The touch can have 32GB. My understanding is this is the off-line memory (disk alike).
How much actual fast ram is there in the device available for my Cocoa Application?
Is there a preconfigured virtual amount? | Currently released Apple iOS devices have the following amounts of working memory:
```
iPhone = 128 MB
iPhone 3G = 128 MB
iPhone 3GS = 256 MB
iPhone 4 = 512 MB
iPhone 4S = 512 MB
iPhone 5 = 1024 MB
iPhone 5S = ... |
371,109 | <p><strong>UPDATE</strong> </p>
<p>I have combined various answers from here into a 'definitive' answer on a <a href="https://stackoverflow.com/questions/1747235/weak-event-handler-model-for-use-with-lambdas/1747236#1747236">new question</a>.</p>
<p><strong>Original question</strong></p>
<p>In my code I have an even... | [
{
"answer_id": 371150,
"author": "Rory",
"author_id": 8479,
"author_profile": "https://Stackoverflow.com/users/8479",
"pm_score": 3,
"selected": false,
"text": "<p>If you retain a reference to the anonymous delegate and then remove it when the controls are removed from the form that shou... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | **UPDATE**
I have combined various answers from here into a 'definitive' answer on a [new question](https://stackoverflow.com/questions/1747235/weak-event-handler-model-for-use-with-lambdas/1747236#1747236).
**Original question**
In my code I have an event publisher, which exists for the whole lifetime of the appli... | I know that this question is ancient, but hell - I found it, and I figure that others might as well. I'm trying to resolve a related issue, and might have some insight.
You mentioned Dustin Campbell's WeakEventHandler - it indeed cannot work with anonymous methods by design. I was trying to fiddle something together ... |
371,112 | <p>Using the CRM views, is there a way to retrieve a list of all of the activities linked to a specific account?</p>
<p>I want it to retrieve not only those associated with the account directly, but also those associated with the account's contacts, cases, etc. I am trying to replicate the list generated when you clic... | [
{
"answer_id": 398242,
"author": "brendan",
"author_id": 225,
"author_profile": "https://Stackoverflow.com/users/225",
"pm_score": 1,
"selected": true,
"text": "<p>I've used something like this. Effectively I build a table var with all the guids of the items I want to search (in my case... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44938/"
] | Using the CRM views, is there a way to retrieve a list of all of the activities linked to a specific account?
I want it to retrieve not only those associated with the account directly, but also those associated with the account's contacts, cases, etc. I am trying to replicate the list generated when you click the Acti... | I've used something like this. Effectively I build a table var with all the guids of the items I want to search (in my case accounts and contacts) then I query AcitivtyParty for all activities where they are a party on the activity - then over to Activity to get the details.
```
Declare @account_guid varchar(200)
Sele... |
371,115 | <p>I have a bunch of log files. I need to find out how many times a string occurs in all files.</p>
<pre><code>grep -c string *
</code></pre>
<p>returns</p>
<pre><code>...
file1:1
file2:0
file3:0
...
</code></pre>
<p>Using a pipe I was able to get only files that have one or more occurrences:</p>
<pre><code>grep -... | [
{
"answer_id": 371124,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 5,
"selected": false,
"text": "<p>Instead of using -c, just pipe it to wc -l.</p>\n\n<pre><code>grep string * | wc -l\n</code></pre>\n\n<p>This will list... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17469/"
] | I have a bunch of log files. I need to find out how many times a string occurs in all files.
```
grep -c string *
```
returns
```
...
file1:1
file2:0
file3:0
...
```
Using a pipe I was able to get only files that have one or more occurrences:
```
grep -c string * | grep -v :0
...
file4:5
file5:1
file6:2
...
``... | ```
cat * | grep -c string
``` |
371,133 | <p>I have a class that contains a list of objects. What's the best way to run some code in the class when the list is modified?</p>
<pre><code>class MyManagerClass
{
ArrayList list = new ArrayList(); // will likely be a different collection class
private OnItemAddedToList(object o)
{
// how to call... | [
{
"answer_id": 371163,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of using the ArrayList from System.Collections you should consider using the ArrayList from the <a href=\"http... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27667/"
] | I have a class that contains a list of objects. What's the best way to run some code in the class when the list is modified?
```
class MyManagerClass
{
ArrayList list = new ArrayList(); // will likely be a different collection class
private OnItemAddedToList(object o)
{
// how to call this?
}
... | The method I've been using so far is to make a private collection class derived from `System.Collections.ObjectModel.Collection<T>`, and call the methods directly in the overrides:
```
class MyManagerClass
{
private class MyCollection : System.Collections.ObjectModel.Collection<object>
{
private MyMana... |
371,140 | <p>I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.</p>
<p>Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "wscript setup.vbs". The run of the first cmd command ... | [
{
"answer_id": 371198,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 2,
"selected": false,
"text": "<p>Is the script code already in a file? If so,</p>\n\n<p>You can use the TYPE command to send the script to a file:</p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46635/"
] | I'm using WinRAR SFX module to create an installation, and use its presetup option to run some preliminary tests.
Since wscript can only accept vbs file, and not the script itself, I first run "cmd /c echo {...script code...} > setup.vbs", and then I run "wscript setup.vbs". The run of the first cmd command opens a br... | Is the script code already in a file? If so,
You can use the TYPE command to send the script to a file:
```
TYPE [script_file] > setup.vbs
```
or COPY the script file:
```
COPY [script_file] setup.vbs
```
If the script code is in the body of your `cmd`, you can use the `START` command to run the `cmd` without a ... |
371,147 | <p>So I've got a form in my Rails app which uses a custom FormBuilder to give me some custom field tags</p>
<pre><code><% form_for :staff_member, @staff_member, :builder => MyFormBuilder do |f| %>
[...]
<%= render :partial => "staff_members/forms/personal_details", :locals => {:f => f, :skill_... | [
{
"answer_id": 405444,
"author": "nakajima",
"author_id": 39589,
"author_profile": "https://Stackoverflow.com/users/39589",
"pm_score": 1,
"selected": false,
"text": "<p>You could instantiate a new instance of your form builder in the controller, though it feels sort of lousy to me:</p>\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31582/"
] | So I've got a form in my Rails app which uses a custom FormBuilder to give me some custom field tags
```
<% form_for :staff_member, @staff_member, :builder => MyFormBuilder do |f| %>
[...]
<%= render :partial => "staff_members/forms/personal_details", :locals => {:f => f, :skill_groups => @skill_groups, :staff_mem... | Use `fields_for` inside your partial. It performs a similar task but without wrapping the form tags. See the [API docs](http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001386). |
371,153 | <p>I am using the program below to sort and eventually print out email messages. Some messages may contain attachments or HTML code, which would not be good for printing. Is there an easy way to strip attachments and strip HTML but not the text formatted by HTML from the messages?</p>
<pre><code>#!/usr/bin/perl
use wa... | [
{
"answer_id": 371179,
"author": "Nietzche-jou",
"author_id": 39892,
"author_profile": "https://Stackoverflow.com/users/39892",
"pm_score": 1,
"selected": false,
"text": "<p>The stripping-HTML aspect is explained in FAQ #9 (or the first item from <code>perldoc -q html</code>). Briefly, ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am using the program below to sort and eventually print out email messages. Some messages may contain attachments or HTML code, which would not be good for printing. Is there an easy way to strip attachments and strip HTML but not the text formatted by HTML from the messages?
```
#!/usr/bin/perl
use warnings;
use st... | `Mail::Message::isMultipart` will tell you whether a given message has any attachments.
`Mail::Message::parts` will give you a list of the mail parts.
Thus:
```
if ( $msg->isMultipart ) {
foreach my $part ( $msg->parts ) {
if ( $part->contentType eq 'text/html' ) {
# deal with html here.
... |
371,155 | <p>I'm using Python 2.5. The DLL I imported is created using the CLR. The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working. I think "all strings returned from CLR are returned as Unicode".</p>
| [
{
"answer_id": 371200,
"author": "sastanin",
"author_id": 25450,
"author_profile": "https://Stackoverflow.com/users/25450",
"pm_score": 3,
"selected": true,
"text": "<p>Could you post your error message?\nCould you post what type of object you have (<code>type(yourvar)</code>)?</p>\n\n<p... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46646/"
] | I'm using Python 2.5. The DLL I imported is created using the CLR. The DLL function is returning a string. I'm trying to apply "partition" attribute to it. I'm not able to do it. Even the partition is not working. I think "all strings returned from CLR are returned as Unicode". | Could you post your error message?
Could you post what type of object you have (`type(yourvar)`)?
Please check if you have a `partition(sep)` method for this object (`dir(yourvar)`).
Applying `partition` method should look like:
```
>>> us=u"Привет, Unicode String!"
>>> us.partition(' ')
(u'\u041f\u0440\u0438\u0432\... |
371,174 | <p>I often find linq being problematic when working with custom collection object.
They are often defened as</p>
<p>The base collection</p>
<pre><code>abstract class BaseCollection<T> : List<T> { ... }
</code></pre>
<p>the collections is defined as</p>
<pre><code>class PruductCollection : BaseCollection... | [
{
"answer_id": 371221,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<p>The problem is that LINQ, through extension methods on <code>IEnumerable<T></code>, knows how to build Arrays, ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24821/"
] | I often find linq being problematic when working with custom collection object.
They are often defened as
The base collection
```
abstract class BaseCollection<T> : List<T> { ... }
```
the collections is defined as
```
class PruductCollection : BaseCollection<Product> { ... }
```
Is there a better way to add res... | The problem is that LINQ, through extension methods on `IEnumerable<T>`, knows how to build Arrays, Lists, and Dictionaries, it doesn't know how to build your custom collection. You could have your custom collection have a constructor that takes an `IEnumerable<T>` or you could write you. The former would allow you to ... |
371,204 | <p>I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:</p>
<pre><code>Dim record As New Record(1)
' Field 0 intentionally left blank
' Field 1 ... | [
{
"answer_id": 654840,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>If you want a dialog to show up that contains the message, you must do it yourself. </p>\n\n<p>Here's some code I use to d... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23369/"
] | I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:
```
Dim record As New Record(1)
' Field 0 intentionally left blank
' Field 1 contains error... | MSI can do this, but you need to OR in some extra values for the messageType argument.
eg.
```
Record record = new Record();
record.FormatString = string.Format("Something has gone wrong!");
session.Message(
InstallMessage.Error | (InstallMessage) ( MessageBoxIcon.Error ) |
(InstallMessage) MessageBoxButtons... |
371,209 | <p>How can I blur a whole page using CSS?
Other elements such as images are allowed.</p>
| [
{
"answer_id": 371226,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 0,
"selected": false,
"text": "<p>Whatever you are trying to do, if it's not just for fun, don't do it :)</p>\n\n<p>I think you'd have to loop all element... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I blur a whole page using CSS?
Other elements such as images are allowed. | This is working in Firefox and WebKit using the `filter: blur(radius)`. See [Can I Use: CSS filters](http://caniuse.com/#feat=css-filters) for which browsers can support this.
```
.blurredElement {
/* Any browser which supports CSS3 */
filter: blur(1px);
/* Firefox version 34 and earlier */
filter: ... |
371,227 | <p>Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?</p>
<p>I have changed my web.config's connectin string to </p>
<pre><code><remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory... | [
{
"answer_id": 371290,
"author": "John_",
"author_id": 26081,
"author_profile": "https://Stackoverflow.com/users/26081",
"pm_score": 2,
"selected": false,
"text": "<ol>\n<li><p>Run aspnet_regsql.exe from your Framework 2.0 folder, mine is:</p>\n\n<p>C:\\WINDOWS\\Microsoft.NET\\Framework\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there anyway to change the ASPNETDB and also using SQLExpress (2005) user instance ?
I have changed my web.config's connectin string to
```
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Kooft.mdf;
User Instanc... | 1. Run aspnet\_regsql.exe from your Framework 2.0 folder, mine is:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
2. Go through the wizard and choose the database that you wish to add the AspNetDB tables too.
3. Set the connectionstring to connect to your database e.g. (Anything in square brackets may possibly need cha... |
371,237 | <p>In F#, you can generate a set of numbers, just by saying [1..100].</p>
<p>I want to do something similar in C#. This is what I have come up with so far:</p>
<pre><code>public static int[] To(this int start, int end)
{
var result = new List<int>();
for(int i = start; i <= end; i++)
result.... | [
{
"answer_id": 371245,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 4,
"selected": true,
"text": "<p>Enumerable.Range(1, 100);</p>\n"
},
{
"answer_id": 371251,
"author": "lc.",
"author_id": 44853,
"au... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36687/"
] | In F#, you can generate a set of numbers, just by saying [1..100].
I want to do something similar in C#. This is what I have come up with so far:
```
public static int[] To(this int start, int end)
{
var result = new List<int>();
for(int i = start; i <= end; i++)
result.Add(i);
return result.ToArr... | Enumerable.Range(1, 100); |
371,246 | <p>I have a very simple Update statement that will update mail server settings and network credentials info... Query works fine when I run it in Access but C# keeps giving me the error stating that my SQL Syntax is wrong ... I have a dataaccess layer (dal class) and Update instance method pasted belows ... But the prob... | [
{
"answer_id": 371258,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>First off - don't use <code>string.Format</code> here. Use parameters, and add parameters to the command. Right no... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a very simple Update statement that will update mail server settings and network credentials info... Query works fine when I run it in Access but C# keeps giving me the error stating that my SQL Syntax is wrong ... I have a dataaccess layer (dal class) and Update instance method pasted belows ... But the problem... | Trying wrapping your field names in [ ]. I have had problems in the past with certain field names such as a username and password and count, etc, being recognized as reserved words and screwing up the sql giving me an error. |
371,266 | <p>I've found this piece of code on <a href="http://www.koders.com/csharp/fidACD7502AA845419FF59B7DA804D3C8FCA0E40138.aspx?s=basecodegeneratorwithsite#L76" rel="nofollow noreferrer">Koders</a>:</p>
<pre><code>private ServiceProvider SiteServiceProvider
{
get
{
if (serviceProvider == null)
{
... | [
{
"answer_id": 371286,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 5,
"selected": true,
"text": "<p>It's possible that the ServiceProvider overrides the !=/== operator, so that for an <em>invalid</em> state the comparison t... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] | I've found this piece of code on [Koders](http://www.koders.com/csharp/fidACD7502AA845419FF59B7DA804D3C8FCA0E40138.aspx?s=basecodegeneratorwithsite#L76):
```
private ServiceProvider SiteServiceProvider
{
get
{
if (serviceProvider == null)
{
serviceProvider = new ServiceProvider(site... | It's possible that the ServiceProvider overrides the !=/== operator, so that for an *invalid* state the comparison to null returns true.
Looks strange anyway. |
371,268 | <p>using the Code Snippet for sending email in VB.Net I have successfully sent an email from my local machine, but when I Upload it to my server I get a message that the email failed. We have a national relay server that is running SMTP and I am pointed at that server in both instances. The only differance that jump ... | [
{
"answer_id": 371298,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 1,
"selected": false,
"text": "<p>You should not need an smtp server on the server if you specify the relay server. Double check that My.Settings.EmailServe... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] | using the Code Snippet for sending email in VB.Net I have successfully sent an email from my local machine, but when I Upload it to my server I get a message that the email failed. We have a national relay server that is running SMTP and I am pointed at that server in both instances. The only differance that jump out a... | You shouldn't need SMTP running locally, as the VB.Net code should just be using basic TCP/IP to communicate directly to the relay server.
It would be useful to see the error message, it is possible that the server does not have access to port 25 on the relay server (eg. due to the firewall configuration). Note that y... |
371,272 | <p>Rails introduced some core extensions to Ruby like <code>3.days.from_now</code> which returns, as you'd expect a date three days in the future. With extension methods in C# we can now do something similar:</p>
<pre><code>static class Extensions
{
public static TimeSpan Days(this int i)
{
return new ... | [
{
"answer_id": 371291,
"author": "mackenir",
"author_id": 25457,
"author_profile": "https://Stackoverflow.com/users/25457",
"pm_score": 3,
"selected": false,
"text": "<p>Personally I like int.To, I am ambivalent about int.Days, and I dislike TimeSpan.FromNow.</p>\n\n<p>I dislike what I s... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27782/"
] | Rails introduced some core extensions to Ruby like `3.days.from_now` which returns, as you'd expect a date three days in the future. With extension methods in C# we can now do something similar:
```
static class Extensions
{
public static TimeSpan Days(this int i)
{
return new TimeSpan(i, 0, 0, 0, 0);
... | I like extension methods a lot but I do feel that when they are used outside of LINQ that they improve readability at the expense of maintainability.
Take `3.Days().FromNow()` as an example. This is wonderfully expressive and anyone could read this code and tell you exactly what it does. That is a truly beautiful thin... |
371,279 | <p>I've got the following Linq2Sql and it's doing more than one round trip for my 'SELECT' statement. I'm not sure why. First the code, then the explanation:-</p>
<pre><code>from p in db.Questions
select new Models.Question
{
Title = p.Title,
TagList = (from t in p.QuestionTags
select t.Tag.Name... | [
{
"answer_id": 371297,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>This might be one of the cases where LINQ by itself isn't enough. Have you considered writing this logic as a UDF ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I've got the following Linq2Sql and it's doing more than one round trip for my 'SELECT' statement. I'm not sure why. First the code, then the explanation:-
```
from p in db.Questions
select new Models.Question
{
Title = p.Title,
TagList = (from t in p.QuestionTags
select t.Tag.Name).ToList()
}
... | The ToList() is definitely holding you back. You should do a ToList() on the whole query.
Another thing that I think you can do is use "let". I think in this case, it can create a delayed execution and be included in the expression tree, but YMMV.
```
from p in db.Questions
let Tags = (from t in p.QuestionTags
... |
371,300 | <p>In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel s... | [
{
"answer_id": 371343,
"author": "bangroot",
"author_id": 45693,
"author_profile": "https://Stackoverflow.com/users/45693",
"pm_score": 4,
"selected": true,
"text": "<p>Not positive in NHibernate, but in Hibernate, there are two special properties that are always referenced id and class.... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/414376/"
] | In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes like FTPChannelSpecification, EMailChannelSpecification and WebserviceChannelSpecification. Now I want to create an HQL query which contains a where clause that narrows down the result to certain types of channel spec... | Not positive in NHibernate, but in Hibernate, there are two special properties that are always referenced id and class. So, for your particular case, I'd do
```
from CommunicationChannelSpecifications spec where spec.class in (?)
``` |
371,302 | <p>I would like to implement a post build event that performs the following actions</p>
<ol>
<li>A relative path copy of the DLL output (1 file, not all the debug jazz)</li>
<li>A register the output DLL to GAC</li>
</ol>
<p>How is this done?</p>
| [
{
"answer_id": 371332,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 5,
"selected": true,
"text": "<p>Does that do you want?</p>\n\n<pre><code>copy $(TargetPath) $(TargetDir)..\\..\\someFolder\\myoutput.dll\nregasm $(... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41291/"
] | I would like to implement a post build event that performs the following actions
1. A relative path copy of the DLL output (1 file, not all the debug jazz)
2. A register the output DLL to GAC
How is this done? | Does that do you want?
```
copy $(TargetPath) $(TargetDir)..\..\someFolder\myoutput.dll
regasm $(TargetPath)
```
(Entered into the field for post-build step under project properties) |
371,322 | <p>I have to read invoice ascii files that are structured in a really convoluted way, for example:</p>
<pre><code>55651108 3090617.10.0806:46:32101639Example Company Construction Company Example Road. 9 9524 Example City
</code></pre>
<p>There's actually additional stuff in there, bu... | [
{
"answer_id": 371339,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that a template describing the entity names and the value types is good one. Something like a \"schema\"... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] | I have to read invoice ascii files that are structured in a really convoluted way, for example:
```
55651108 3090617.10.0806:46:32101639Example Company Construction Company Example Road. 9 9524 Example City
```
There's actually additional stuff in there, but I don't want to confuse ... | "If the input was somewhat structured and well defined, how would you guard against future changes in its structure. How would you design and implement a reader?"
You must define the layout in a way you can flexibly pick it apart.
Here's a python version
```
class Field( object ):
def __init__( self, name, size ... |
371,328 | <p>Given the following class</p>
<pre><code>public class Foo
{
public int FooId { get; set; }
public string FooName { get; set; }
public override bool Equals(object obj)
{
Foo fooItem = obj as Foo;
if (fooItem == null)
{
return false;
}
return fooI... | [
{
"answer_id": 371348,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 12,
"selected": true,
"text": "<p>Yes, it is important if your item will be used as a key in a dictionary, or <code>HashSet<T></code>, etc - s... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2469/"
] | Given the following class
```
public class Foo
{
public int FooId { get; set; }
public string FooName { get; set; }
public override bool Equals(object obj)
{
Foo fooItem = obj as Foo;
if (fooItem == null)
{
return false;
}
return fooItem.FooId == t... | Yes, it is important if your item will be used as a key in a dictionary, or `HashSet<T>`, etc - since this is used (in the absence of a custom `IEqualityComparer<T>`) to group items into buckets. If the hash-code for two items does not match, they may *never* be considered equal ([Equals](https://learn.microsoft.com/en... |
371,329 | <p>I've several textboxes. I would like to make the Enter button act as Tab. So that when I will be in one textbox, pressing Enter will move me to the next one. Could you please tell me how to implement this approach without adding any code inside textbox class (no override and so on if possible)?</p>
| [
{
"answer_id": 371351,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": -1,
"selected": false,
"text": "<p>Taking a wild guess:</p>\n\n<pre><code>// on enter event handler\nparentForm.GetNextControl().Focus();\n</code></pre>\n"
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38940/"
] | I've several textboxes. I would like to make the Enter button act as Tab. So that when I will be in one textbox, pressing Enter will move me to the next one. Could you please tell me how to implement this approach without adding any code inside textbox class (no override and so on if possible)? | Here is the code that I usually use.
It must be on KeyDown event.
```
if (e.KeyData == Keys.Enter)
{
e.SuppressKeyPress = true;
SelectNextControl(ActiveControl, true, true, true, true);
}
```
**UPDATE**
Other way is sending "TAB" key! And overriding the method make it so easier :)
```
protected override bo... |
371,333 | <p>What is the Ruby idiomatic way for retrieving a single character from a string as a one-character string? There is the <code>str[n]</code> method of course, but (as of Ruby 1.8) it returns a character code as a fixnum, not a string. How do you get to a single-character string?</p>
| [
{
"answer_id": 371341,
"author": "Thiago Arrais",
"author_id": 17801,
"author_profile": "https://Stackoverflow.com/users/17801",
"pm_score": 0,
"selected": false,
"text": "<pre><code>'abc'[1].chr # => \"b\"\n</code></pre>\n"
},
{
"answer_id": 371342,
"author": "Thiago Arra... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17801/"
] | What is the Ruby idiomatic way for retrieving a single character from a string as a one-character string? There is the `str[n]` method of course, but (as of Ruby 1.8) it returns a character code as a fixnum, not a string. How do you get to a single-character string? | In Ruby 1.9, it's easy. In Ruby 1.9, Strings are encoding-aware sequences of characters, so you can just index into it and you will get a single-character string out of it:
```
'µsec'[0] => 'µ'
```
However, in Ruby 1.8, Strings are sequences of bytes and thus completely unaware of the encoding. If you index into a s... |
371,337 | <p>An image set as the background of a DIV is displayed in IE, but not in Firefox.</p>
<p>CSS example:</p>
<pre><code>div.something {
background:transparent url(../images/table_column.jpg) repeat scroll 0 0;
}
</code></pre>
<p>(The issue is described in many places but haven't seen any conclusive explanation or fix.... | [
{
"answer_id": 371367,
"author": "Kablam",
"author_id": 42389,
"author_profile": "https://Stackoverflow.com/users/42389",
"pm_score": 0,
"selected": false,
"text": "<p>You could try this:</p>\n\n<pre><code>div.something {\nbackground: transparent url(../images/table_column.jpg);\n}\n</co... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46665/"
] | An image set as the background of a DIV is displayed in IE, but not in Firefox.
CSS example:
```
div.something {
background:transparent url(../images/table_column.jpg) repeat scroll 0 0;
}
```
(The issue is described in many places but haven't seen any conclusive explanation or fix.) | Sorry this got huge, but it covers two possibilities that consistently happen to me.
Possibility 1
-------------
You may find the path to the CSS file isn't correct. For example:
Say I have the following file structure:
```
public/
css/
global.css
images/
background.jpg
something/
... |
371,372 | <p>I am using ruby on rails with a MySQL backend. I have a table called notes and here is the migration I use to create it:</p>
<pre><code>def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :title
t.text :body
t.timestamps
end
execute "alter table notes ADD FULLTEXT(t... | [
{
"answer_id": 371408,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": true,
"text": "<p>I'm just guessing here, but the documentation states: </p>\n\n<blockquote>\n <p>A natural language search interpr... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | I am using ruby on rails with a MySQL backend. I have a table called notes and here is the migration I use to create it:
```
def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :title
t.text :body
t.timestamps
end
execute "alter table notes ADD FULLTEXT(title, body)"
end
... | I'm just guessing here, but the documentation states:
>
> A natural language search interprets
> the search string as a phrase in
> natural human language (a phrase in
> free text). There are no special
> operators. The stopword list applies.
> In addition, words that are present in
> 50% or more of the rows a... |
371,384 | <p>What is the best way to print stuff from c#/.net?</p>
<p>The question is in regard to single pages as well as to reports containing lots of pages. </p>
<p>It would be great to get a list of the most common printing libs containing the main features and gotchas of each of them.</p>
<p>[Update] for standard windows... | [
{
"answer_id": 371399,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 4,
"selected": true,
"text": "<p>For reports, I use the RDLC control.</p>\n\n<p>For everything else, I use the inherent printing objects within .N... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] | What is the best way to print stuff from c#/.net?
The question is in regard to single pages as well as to reports containing lots of pages.
It would be great to get a list of the most common printing libs containing the main features and gotchas of each of them.
[Update] for standard windows clients (or servers), n... | For reports, I use the RDLC control.
For everything else, I use the inherent printing objects within .NET.
**Edit**
The inherent printing objects are all found in the System.Drawing.Printing namespace. When you use the PrintDialog or the PrintPreviewDialog in a WinForms (or WPF) application, it is to these objects th... |
371,386 | <p>Having an odd problems with ASP MVC deployed on IIS6 (Windows 2003). I've simplified the controller code to the below;</p>
<pre><code><AcceptVerbs(HttpVerbs.Get)> _
Public Function CloseBatches() As ActionResult
ViewData("Title") = "Close Batches"
ViewData("Message") = Session("Message")
Return Vi... | [
{
"answer_id": 371407,
"author": "Jesper Blad Jensen",
"author_id": 11559,
"author_profile": "https://Stackoverflow.com/users/11559",
"pm_score": 0,
"selected": false,
"text": "<p>I don't really know about what problem you are facing, but try to use TempData instead of Session.</p>\n"
... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Having an odd problems with ASP MVC deployed on IIS6 (Windows 2003). I've simplified the controller code to the below;
```
<AcceptVerbs(HttpVerbs.Get)> _
Public Function CloseBatches() As ActionResult
ViewData("Title") = "Close Batches"
ViewData("Message") = Session("Message")
Return View()
End Function
<... | Change your code as follows:
```
<AcceptVerbs(HttpVerbs.Get)> _
Public Function CloseBatches() As ActionResult
ViewData("Title") = "Close Batches"
Return View()
End Function
<AcceptVerbs(HttpVerbs.Post)> _
Public Function CloseBatches(ByVal RequestId As String) As ActionResult
TempData("Message") = "Yadda... |
371,398 | <p>This is what reflector gives:</p>
<pre><code>public int Int1 { get; set; }
public string StringA { get; set; }
// Fields
[CompilerGenerated]
private int <Int1>k__BackingField;
[CompilerGenerated]
private string <StringA>k__BackingField;
</code></pre>
<p>The problem is that C# specification doesn't exp... | [
{
"answer_id": 371525,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "<p>I don't think MS should specify a name - I think it's more reasonable to avoid binary serialization, which is always g... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21645/"
] | This is what reflector gives:
```
public int Int1 { get; set; }
public string StringA { get; set; }
// Fields
[CompilerGenerated]
private int <Int1>k__BackingField;
[CompilerGenerated]
private string <StringA>k__BackingField;
```
The problem is that C# specification doesn't explicitly specify how backing fields for... | I don't think MS should specify a name - I think it's more reasonable to avoid binary serialization, which is always going to be somewhat brittle in my opinion. (Java serialization is similarly brittle.) If it relies on field names (and there may be a way of getting round that by attributing your properties - I'm not s... |
371,404 | <p>I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it.</p>
<p... | [
{
"answer_id": 371430,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": -1,
"selected": false,
"text": "<p>Not in C#, but may be a good place to start:</p>\n\n<p><a href=\"http://www.datastrat.com/Code/DocDatabase.txt\" rel=\... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1121861/"
] | I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it.
Where are... | Procedures are what you're looking for:
```
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
DataTable queries = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Procedures, null);
conn.Close();
```
This will give you a DataTable with the following columns in it (among others):
PROCEDURE\_NAME: ... |
371,418 | <p>I've recently found out about protocol buffers and was wondering if they could be applied to my specific problem.</p>
<p>Basically I have some CSV data that I need to convert to a more compact format for storage as some of the files are several gig. </p>
<p>Each field in the CSV has a header, and there are only tw... | [
{
"answer_id": 371482,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>Well, protobuf-net (my version) is based on regular .NET types, so no (since it won't cope with different schemas ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] | I've recently found out about protocol buffers and was wondering if they could be applied to my specific problem.
Basically I have some CSV data that I need to convert to a more compact format for storage as some of the files are several gig.
Each field in the CSV has a header, and there are only two types, strings ... | Well, it's certainly representable. Something like:
```
message CsvFile {
repeated CsvHeader header = 1;
repeated CsvRow row = 2;
}
message CsvHeader {
require string name = 1;
require ColumnType type = 2;
}
enum ColumnType {
DECIMAL = 1;
STRING = 2;
}
message CsvRow {
repeated CsvValue ... |
371,419 | <p>I have a function that expects real numbers (either integers or floats) as its input, and I'm trying to validate this input before doing mathematical operations on it.</p>
<p>My first instinct is to cast inputs as floats from within a try-except block.</p>
<pre><code>try:
myinput = float(input)
except:
raise... | [
{
"answer_id": 371436,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe you can use a combination of <code>assert</code> and <code>isinstance</code> statements.\nSomething like the follow... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8027/"
] | I have a function that expects real numbers (either integers or floats) as its input, and I'm trying to validate this input before doing mathematical operations on it.
My first instinct is to cast inputs as floats from within a try-except block.
```
try:
myinput = float(input)
except:
raise ValueError("input is... | To quote myself from [How much input validation should I be doing on my python functions/methods?](https://stackoverflow.com/questions/367560/how-much-input-validation-should-i-be-doing-on-my-python-functionsmethods#368072):
>
> For calculations like sum, factorial etc, pythons built-in type checks will do fine. The ... |
371,439 | <p>Normally when you update an object in linq2sql you get the object from a datacontext and use the same datacontext to save the object, right?</p>
<p>What's the best way to update a object that hasn't been retreived by that datacontext that you use to perform the save operation, i.e. I'm using flourinefx to pass data... | [
{
"answer_id": 371492,
"author": "Matt",
"author_id": 17803,
"author_profile": "https://Stackoverflow.com/users/17803",
"pm_score": 2,
"selected": false,
"text": "<p>I think you have 2 options here:</p>\n\n<p>1) Attach the object to the DataContext on which you will do your save\n2) Us... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40939/"
] | Normally when you update an object in linq2sql you get the object from a datacontext and use the same datacontext to save the object, right?
What's the best way to update a object that hasn't been retreived by that datacontext that you use to perform the save operation, i.e. I'm using flourinefx to pass data between f... | To update an existing but disconnected object, you need to "attach" it do the data context. This will re-use the existing primary key etc. You can control how to handle changes- i.e. treat as dirty, or treat as clean and track future changes, etc.
The Attach method is on the table - i.e.
```
ctx.Customers.Attach(cust... |
371,445 | <p>We have followed the approach below to get the data from multiple results using LINQ To SQL</p>
<pre><code>CREATE PROCEDURE dbo.GetPostByID
(
@PostID int
)
AS
SELECT *
FROM Posts AS p
WHERE p.PostID = @PostID
SELECT c.*
FROM Categories AS c
JOIN PostCategories A... | [
{
"answer_id": 371576,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://weblogs.asp.net/scottgu/about.aspx\" rel=\"noreferrer\">Scott Guthrie</a> (the guy who runs the ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We have followed the approach below to get the data from multiple results using LINQ To SQL
```
CREATE PROCEDURE dbo.GetPostByID
(
@PostID int
)
AS
SELECT *
FROM Posts AS p
WHERE p.PostID = @PostID
SELECT c.*
FROM Categories AS c
JOIN PostCategories AS pc
ON ... | [Scott Guthrie](http://weblogs.asp.net/scottgu/about.aspx) (the guy who runs the .Net dev teams at MS) covered how to do this on his blog some months ago much better than I ever could, **[link here](http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx)**. On ... |
371,464 | <p>I have a non-visual component which manages other visual controls. </p>
<p>I need to have a reference to the form that the component is operating on, but i don't know how to get it.</p>
<p>I am unsure of adding a constructor with the parent specified as control, as i want the component to work by just being dropp... | [
{
"answer_id": 371559,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 3,
"selected": false,
"text": "<p>I use a recursive call to walk up the control chain. Add this to your control.</p>\n\n<pre><code>public Form ParentF... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1500/"
] | I have a non-visual component which manages other visual controls.
I need to have a reference to the form that the component is operating on, but i don't know how to get it.
I am unsure of adding a constructor with the parent specified as control, as i want the component to work by just being dropped into the design... | [It is important to understand that the ISite technique below only works at design time. Because ContainerControl is public and gets assigned a value VisualStudio will write initialization code that sets it at run-time. Site is set at run-time, but you can't get ContainerControl from it]
[Here's an article](http://www... |
371,468 | <p>I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebi... | [
{
"answer_id": 516534,
"author": "CodeChef",
"author_id": 21786,
"author_profile": "https://Stackoverflow.com/users/21786",
"pm_score": 4,
"selected": true,
"text": "<p>@arilanto - I include this script after my jquery scripts. Performance wise, it's not the best solution, but it is a q... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21786/"
] | I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of concept application. This page uses the ASP.NET AJAX UpdatePanel to do partial page updates. The page allows a user to drop an item into a trashcan div, which will invoke a postback that deletes a record from the database, then rebinds... | @arilanto - I include this script after my jquery scripts. Performance wise, it's not the best solution, but it is a quick easy work around.
```
function IESafeOffsetParent(elem)
{
try
{
return elem.offsetParent;
}
catch(e)
{
return document.body;
}
}
// The Offset Method
... |
371,471 | <p>I am trying to get some <code>JavaScript</code> to programmatically adjust a HTML <code>img</code> tag's width to display various sized images correctly.</p>
<p>I have a fixed width <code>img</code> tag at <code>800px</code> to display an image, this is the max width.</p>
<p>If the image is wider then <code>800px<... | [
{
"answer_id": 371504,
"author": "bezmax",
"author_id": 43677,
"author_profile": "https://Stackoverflow.com/users/43677",
"pm_score": 2,
"selected": false,
"text": "<p>Use the IE6 css+javascript hack:</p>\n\n<pre><code>.dynamic_img {\n width: expression(document.body.clientWidth <=... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14260/"
] | I am trying to get some `JavaScript` to programmatically adjust a HTML `img` tag's width to display various sized images correctly.
I have a fixed width `img` tag at `800px` to display an image, this is the max width.
If the image is wider then `800px` I want to display it at `800px` wide;
If the image is less than ... | I have never seen a safari in work, but you can try changing your onload event to this:
```
onload="resize_image(self.id);return true"
```
It could be that without a return value, safari thinks that this object should not be loaded. |
371,497 | <p>Is there any way (in Javascript) to download a remote website (i.e. like with Curl), read it into a string variable and further process it?</p>
| [
{
"answer_id": 371524,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": "<p>You can only download a file from the same domain, as per the <a href=\"http://en.wikipedia.org/wiki/Same_origin_... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there any way (in Javascript) to download a remote website (i.e. like with Curl), read it into a string variable and further process it? | You can only download a file from the same domain, as per the [Same Origin Policy](http://en.wikipedia.org/wiki/Same_origin_policy). You can download content from the same domain though, using the XMLHTTPRequest object:
```
var xhReq = createXMLHttpRequest();
xhReq.open("GET", "page.html", true);
xhReq.onreadystate... |
371,503 | <p>Why is ++i is l-value and i++ not?</p>
| [
{
"answer_id": 371533,
"author": "Renaud Bompuis",
"author_id": 3811,
"author_profile": "https://Stackoverflow.com/users/3811",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Regarding LValue</strong></p>\n\n<ul>\n<li><p>In <code>C</code> (and Perl for instance), <em>neither</em> ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | Why is ++i is l-value and i++ not? | Well as another answerer pointed out already the reason why `++i` is an lvalue is to pass it to a reference.
```
int v = 0;
int const & rcv = ++v; // would work if ++v is an rvalue too
int & rv = ++v; // would not work if ++v is an rvalue
```
The reason for the second rule is to allow to initialize a reference using... |
371,513 | <p>We have a database that persist our metadata and data.</p>
<p>Our metadata is produced buy a dedicated team, using a Web application on the development server, and is a critical part of our application.</p>
<p>Then the customer generates data according to this metadata.</p>
<p>We already version the database schema,... | [
{
"answer_id": 371533,
"author": "Renaud Bompuis",
"author_id": 3811,
"author_profile": "https://Stackoverflow.com/users/3811",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Regarding LValue</strong></p>\n\n<ul>\n<li><p>In <code>C</code> (and Perl for instance), <em>neither</em> ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2797/"
] | We have a database that persist our metadata and data.
Our metadata is produced buy a dedicated team, using a Web application on the development server, and is a critical part of our application.
Then the customer generates data according to this metadata.
We already version the database schema, and all schema chang... | Well as another answerer pointed out already the reason why `++i` is an lvalue is to pass it to a reference.
```
int v = 0;
int const & rcv = ++v; // would work if ++v is an rvalue too
int & rv = ++v; // would not work if ++v is an rvalue
```
The reason for the second rule is to allow to initialize a reference using... |
371,546 | <pre><code>select Table1.colID, Table1.colName,
(select * from Table2 where Table2.colID = Table1.colID) as NestedRows
from Table1
</code></pre>
<p>The above query gives you this error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery... | [
{
"answer_id": 371575,
"author": "DCNYAM",
"author_id": 30419,
"author_profile": "https://Stackoverflow.com/users/30419",
"pm_score": 0,
"selected": false,
"text": "<p>You would be better off using an INNER JOIN between the two tables and simply selecting the rows you want from each tabl... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29519/"
] | ```
select Table1.colID, Table1.colName,
(select * from Table2 where Table2.colID = Table1.colID) as NestedRows
from Table1
```
The above query gives you this error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used.....
Can anybo... | Because the subquery in a select clause must be "inserted" into a column value in every row of the result set from the outer query. You cannot put a set of values into a single cell (a single column of a single row) of the result set.
You need to use an inner join. the multiple rows returned by joined table will be o... |
371,551 | <p>When I try to build my projects in Visual Studio 2008, web sites won't build anymore, they hang on this stage: </p>
<pre><code>------ Build started: Project: C:\...\Web\, Configuration: Debug Any CPU ------
Validating Web Site
Building directory '/Web/Admin/Secure/'.
Building directory '/Web/Admin/'.
Building direc... | [
{
"answer_id": 371580,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 2,
"selected": false,
"text": "<p>I have had a similar problem problem before. </p>\n\n<p>I fixed it by making a new solution file and adding the proje... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33137/"
] | When I try to build my projects in Visual Studio 2008, web sites won't build anymore, they hang on this stage:
```
------ Build started: Project: C:\...\Web\, Configuration: Debug Any CPU ------
Validating Web Site
Building directory '/Web/Admin/Secure/'.
Building directory '/Web/Admin/'.
Building directory '/Web/Stu... | This can also often happen in the event that you have a 3rd party control that is not licensed\registered properly. It may be attempting to display a warning\registration UI that is not making it to focus. We have had this issue on our build servers alot. |
371,554 | <p>I have the following code:</p>
<pre><code>if ($_POST['submit'] == "Next") {
foreach($_POST['info'] as $key => $value) {
echo $value;
}
}
</code></pre>
<p>How do I get the foreach function to start from the 2nd key in the array?</p>
| [
{
"answer_id": 371560,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 2,
"selected": false,
"text": "<p>in loop:</p>\n\n<pre><code>if ($key == 0) //or whatever\n continue;\n</code></pre>\n"
},
{
"answer_id": 3715... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37667/"
] | I have the following code:
```
if ($_POST['submit'] == "Next") {
foreach($_POST['info'] as $key => $value) {
echo $value;
}
}
```
How do I get the foreach function to start from the 2nd key in the array? | For reasonably small arrays, use [array\_slice](http://fr.php.net/manual/en/function.array-slice.php) to create a second one:
```
foreach(array_slice($_POST['info'],1) as $key=>$value)
{
echo $value;
}
``` |
371,571 | <p>I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is deleting entire subdirectories. Anyone have any ideas on this? Below is the batch file. </p>
<pre><code>rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink
del D:\DP-Production... | [
{
"answer_id": 371582,
"author": "Vincent Van Den Berghe",
"author_id": 39259,
"author_profile": "https://Stackoverflow.com/users/39259",
"pm_score": 5,
"selected": true,
"text": "<p>Put filenames between double quotes... (e.g. \"D:\\My Program\\test.exe\")</p>\n"
},
{
"answer_id... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is deleting entire subdirectories. Anyone have any ideas on this? Below is the batch file.
```
rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink
del D:\DP-Production\Administrative\... | Put filenames between double quotes... (e.g. "D:\My Program\test.exe") |
371,572 | <p>I am novice in sharepoint programming. I have a following code:</p>
<pre><code>SPWorkflowTask task = some_getter();
task["Status"] = "Canceled";
task.Update();
</code></pre>
<p>and I am getting SPException:</p>
<pre><code>Microsoft.SharePoint.SPException: "This task is currently locked by a running workflow ... | [
{
"answer_id": 371587,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": -1,
"selected": false,
"text": "<p>You can not modify a Workflow Task from outside the workflow sadly. You somehow have to tell the workflow to modify the... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361/"
] | I am novice in sharepoint programming. I have a following code:
```
SPWorkflowTask task = some_getter();
task["Status"] = "Canceled";
task.Update();
```
and I am getting SPException:
```
Microsoft.SharePoint.SPException: "This task is currently locked by a running workflow and cannot be edited."
at Microsoft.S... | here is an expert comment on this problem : <http://geek.hubkey.com/2007/09/locked-workflow.html>
And, if you have edited the columns on the task list, this link may help : <http://social.msdn.microsoft.com/Forums/en-US/sharepointworkflow/thread/8ec834b6-5408-4079-bdfb-b88d341b36bf/>
hope this helps |
371,591 | <p>I am trying to get simple jQuery to execute on my Content page with no luck below is what I am trying to do:</p>
<pre><code><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script t... | [
{
"answer_id": 371603,
"author": "Kieron",
"author_id": 5791,
"author_profile": "https://Stackoverflow.com/users/5791",
"pm_score": 6,
"selected": true,
"text": "<p>It may be that the JQuery file can't be found, try this for the script reference:</p>\n\n<pre><code><script src=\"<%=... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3111/"
] | I am trying to get simple jQuery to execute on my Content page with no luck below is what I am trying to do:
```
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(do... | It may be that the JQuery file can't be found, try this for the script reference:
```
<script src="<%= Url.Content ("~/Scripts/jquery-1.2.6.js") %>" type="text/javascript"></script>
```
The Url.Content will build the correct path regardless of whether the app is running in the root or a sub-directory.
Also, if you'... |
371,604 | <p>Following on from <a href="https://stackoverflow.com/questions/371418/can-you-represent-csv-data-in-googles-protocol-buffer-format">this</a> question, what would be the best way to represent a System.Decimal object in a Protocol Buffer?</p>
| [
{
"answer_id": 371690,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Marc and I have very vague plans to come up with a \"common PB message\" library such that you can represent pretty c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] | Following on from [this](https://stackoverflow.com/questions/371418/can-you-represent-csv-data-in-googles-protocol-buffer-format) question, what would be the best way to represent a System.Decimal object in a Protocol Buffer? | Well, protobuf-net will simply handle this for you; it runs off the properties of types, and has full support for `decimal`. Since there is no direct way of expressing `decimal` in proto, it won't (currently) generate a `decimal` property from a ".proto" file, but it would be a nice tweak to recognise some common type ... |
371,606 | <p>i am trying to fix a site I am helping a friend with, and in IE it is displaying the navigation bar like it is stacking on top of each other.</p>
<p>Is that a part of the double float bug, I tried adding display:inline, but I still have that problem.</p>
<p>URL: <a href="http://www.flanels.com/RadiantecHOME.html" ... | [
{
"answer_id": 371690,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Marc and I have very vague plans to come up with a \"common PB message\" library such that you can represent pretty c... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i am trying to fix a site I am helping a friend with, and in IE it is displaying the navigation bar like it is stacking on top of each other.
Is that a part of the double float bug, I tried adding display:inline, but I still have that problem.
URL: <http://www.flanels.com/RadiantecHOME.html>
CSS: <http://www.flane... | Well, protobuf-net will simply handle this for you; it runs off the properties of types, and has full support for `decimal`. Since there is no direct way of expressing `decimal` in proto, it won't (currently) generate a `decimal` property from a ".proto" file, but it would be a nice tweak to recognise some common type ... |
371,607 | <p>I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang...</p>
<p>There are two versions of that function, one which expects (Writer, String) and one which just expects (String)....</p>
<p><a href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#e... | [
{
"answer_id": 371614,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 0,
"selected": false,
"text": "<p>What exactly is the compiler error message?</p>\n\n<p>is it possible that you're using a different version of... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46698/"
] | I'm trying to use the StringEscapeUtils.escapeXML() function from org.apache.commons.lang...
There are two versions of that function, one which expects (Writer, String) and one which just expects (String)....
<http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String... | The error message is telling you that you are passing an Object into the method, not a String.
If you are sure that the Object is a String, then you'll need to cast it to a String first.
If this doesn't work, please post the actual code that is giving you trouble. |
371,608 | <p>GCC 3.4.5 (MinGW version) produces a warning: parameter has incomplete type for line 2 of the following C code:</p>
<pre><code>struct s;
typedef void (* func_t)(struct s _this);
struct s { func_t method; int dummy_member; };
</code></pre>
<p>Is there a way to fix this (or at least hide the warning) without changin... | [
{
"answer_id": 371623,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 0,
"selected": false,
"text": "<p>Hiding warnings is generally pretty easy - just look at the help for your particular compiler.</p>\n\n<p><a href=\"http://d... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48015/"
] | GCC 3.4.5 (MinGW version) produces a warning: parameter has incomplete type for line 2 of the following C code:
```
struct s;
typedef void (* func_t)(struct s _this);
struct s { func_t method; int dummy_member; };
```
Is there a way to fix this (or at least hide the warning) without changing the method argument's si... | The warning seems to be a bug with the current MinGW version of gcc. Contrary to what Adam said, it *is* valid C99 - section 6.7.5.3, paragraph 12 explicitly allows this:
>
> If the function declarator is not part of a definition of that function, parameters may have incomplete type and may use the [\*] notation in t... |
371,637 | <p>I am trying to use the following code, which I have not been able to test yet, because I get the following errors:</p>
<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use Text::Wrap;
use Mail::Box::Manager;
use HTML::Obliterate qw(extirpate_html);
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding... | [
{
"answer_id": 371658,
"author": "Tuminoid",
"author_id": 40657,
"author_profile": "https://Stackoverflow.com/users/40657",
"pm_score": 3,
"selected": true,
"text": "<p>So line 36 seems to be</p>\n\n<pre><code>print MYFILE wrap(\"\", \"\", <<\"\");\n</code></pre>\n\n<p>which means ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I am trying to use the following code, which I have not been able to test yet, because I get the following errors:
```
#!/usr/bin/perl
use warnings;
use strict;
use Text::Wrap;
use Mail::Box::Manager;
use HTML::Obliterate qw(extirpate_html);
open (MYFILE, '>>data.txt');
binmode(MYFILE, ':encoding(UTF-8)');
my $file ... | So line 36 seems to be
```
print MYFILE wrap("", "", <<"");
```
which means perl will wrap the following text until there is terminator `""` (I never use confusing item like this, I always use END or UNTIL\_END for simplicity.)
That terminator is then found on line 45 (the empty line), meaning next thing it process... |
371,638 | <p>I'm in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here's the scenario.</p>
<p>Say you have three options to drill down into, each one having its own REST-based resource. I can either lazily load each one w... | [
{
"answer_id": 371646,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 1,
"selected": false,
"text": "<p>I personally look at what is being done, I will ususally use an asyc request to ensure that the UI doesn't bloc... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I'm in the design stage for an app which will utilize a REST web service and sort of have a dilemma in as far as using asynchronous vs synchronous vs threading. Here's the scenario.
Say you have three options to drill down into, each one having its own REST-based resource. I can either lazily load each one with a sync... | I don't think that there's a "right" answer. It seems that you understand the compromises involved and you just need to make your design around those.
A few extra random points: sometimes your application forces a particular approach. For example, many of the convenience (i.e., synchronous) methods won't allow authent... |
371,644 | <p>In a mysqli prepared statement, a NULL gets turned into '' (in the case of a string) or 0 (in the case of an integer). I would like to store it as a true NULL. Is there any way of doing this?</p>
| [
{
"answer_id": 371782,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "<p>The comments to the <a href=\"http://php.net/mysqli-stmt-bind-param\" rel=\"nofollow noreferrer\">PHP documentation on ... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1902010/"
] | In a mysqli prepared statement, a NULL gets turned into '' (in the case of a string) or 0 (in the case of an integer). I would like to store it as a true NULL. Is there any way of doing this? | It's possible to bind a true NULL value to the prepared statements (read [this](http://www.php.net/manual/en/mysqli-stmt.bind-param.php#96148)).
>
> You can, in fact, use mysqli\_bind\_parameter to pass a NULL value to the database. simply create a variable and store the NULL value (see the manpage for it) to the var... |
371,656 | <p>Are there any O/R mappers out there that will automatically create or modify the database schema when you update the business objects? After looking around it seems that most libraries work the other way by creating business object from the database schema.</p>
<p>The reason I'd like to have that capability is that... | [
{
"answer_id": 371677,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.hibernate.org/343.html\" rel=\"nofollow noreferrer\">NHibernate</a> can generate the dat... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46703/"
] | Are there any O/R mappers out there that will automatically create or modify the database schema when you update the business objects? After looking around it seems that most libraries work the other way by creating business object from the database schema.
The reason I'd like to have that capability is that I am plan... | [SubSonic](http://subsonicproject.com/) does what you need. It has a migration class to be use with sonic commander. I modified the code and put it in the startup of my apps, and have it check for version difference and upgrade automatically.
This is how you need to setup it up:
1. You need to add the versioned migra... |
371,686 | <p>After an upgrade to BIRT 2.3.1 have a tons of logs:</p>
<pre><code>org.eclipse.birt.report.model.metadata.ChoicePropertyType validateXml
SEVERE: Not allowed choice any
</code></pre>
<p>Any thoughts how to rid of them will be appreciated.</p>
| [
{
"answer_id": 371701,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 1,
"selected": false,
"text": "<p>You can use any GUI client for Git that you want to use. You only have to revert to the command line when you want to int... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19347/"
] | After an upgrade to BIRT 2.3.1 have a tons of logs:
```
org.eclipse.birt.report.model.metadata.ChoicePropertyType validateXml
SEVERE: Not allowed choice any
```
Any thoughts how to rid of them will be appreciated. | [This page](http://www.syntevo.com/git-svn/index.html) seems to indicate that [SmartGit](http://www.syntevo.com/smartgit/index.html) can do what you want. As far as I can tell, you have to do the initial init/clone from cmd/bash though. |
371,702 | <p>I have made some code which exports some details of a journal article to a reference manager called <a href="http://www.endnote.com/enhome.asp" rel="nofollow noreferrer">Endnote</a></p>
<p>The format of which is a list of items like below (an author):</p>
<pre><code>%A Schortgen Frédérique
</code></pre>
<p>Unfort... | [
{
"answer_id": 371736,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "<p>It looks like Endnote isn't expecting UTF-8. Do you have details of what Endnote <em>does</em> expect? You may find th... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3193/"
] | I have made some code which exports some details of a journal article to a reference manager called [Endnote](http://www.endnote.com/enhome.asp)
The format of which is a list of items like below (an author):
```
%A Schortgen Frédérique
```
Unfortunately, I am having some encoding problems somewhere, as when endnote... | It looks like Endnote isn't expecting UTF-8. Do you have details of what Endnote *does* expect? You may find that using Encoding.GetEncoding(1252) or Encoding.GetEncoding(28591) (which are Western codepage 1252 and ISO-8859-1 respectively) might work.
Btw, you're setting Response.ContentType twice. That sounds unlikel... |
371,708 | <p>I have two classes that each need an instance of each other to function. Ordinarily if an object needs another object to run, I like to pass it in the constructor. But I can't do that in this case, because one object has to be instantiated before the other, and so therefore the second object does not exist to be p... | [
{
"answer_id": 371726,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "<p>In a circular construction scenario I'd use a factory class/factory method. I would normally make the construction l... | 2008/12/16 | [
"https://Stackoverflow.com/questions/371708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | I have two classes that each need an instance of each other to function. Ordinarily if an object needs another object to run, I like to pass it in the constructor. But I can't do that in this case, because one object has to be instantiated before the other, and so therefore the second object does not exist to be passed... | It's time to take a look at MVC. :-) When you have a model-view-controller situation, the consensus is that the model shouldn't be aware of the view-controller (MVC often plays out as M-VC), but the view is invariably aware of the model.
If the model needs to tell the view something, it does so by notifying its listen... |