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 |
|---|---|---|---|---|---|---|
317,619 | <p>When ever I think I can use the yield keyword, I take a step back and look at how it will impact my project. I always end up returning a collection instead of yeilding because I feel the overhead of maintaining the state of the yeilding method doesn't buy me much. In almost all cases where I am returning a collectio... | [
{
"answer_id": 317636,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 5,
"selected": false,
"text": "<p>Note that with yield, you are iterating over the collection once, but when you build a list, you'll be iterating o... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] | When ever I think I can use the yield keyword, I take a step back and look at how it will impact my project. I always end up returning a collection instead of yeilding because I feel the overhead of maintaining the state of the yeilding method doesn't buy me much. In almost all cases where I am returning a collection I... | I recently had to make a representation of mathematical expressions in the form of an Expression class. When evaluating the expression I have to traverse the tree structure with a post-order treewalk. To achieve this I implemented IEnumerable<T> like this:
```
public IEnumerator<Expression<T>> GetEnumerator()
{
if... |
317,621 | <p>I have a ComboBox inside of a cell of a DataGridView Row on a Windows form. I need the following to happen: </p>
<ol>
<li>click on the ComboBox</li>
<li>pick a value</li>
<li>recalculate a total & display inside of a lable that is sitting
outside of the DataGridView.</li>
</ol>
<p>Currently, the followin... | [
{
"answer_id": 317658,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 3,
"selected": true,
"text": "<p>Add a handler to the CellClick event of the DataGridView that looks a bit like:</p>\n\n<pre><code>private void vehicl... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29990/"
] | I have a ComboBox inside of a cell of a DataGridView Row on a Windows form. I need the following to happen:
1. click on the ComboBox
2. pick a value
3. recalculate a total & display inside of a lable that is sitting
outside of the DataGridView.
Currently, the following is happening:
1. Click on the ComboBox
2. Cl... | Add a handler to the CellClick event of the DataGridView that looks a bit like:
```
private void vehicleTypeGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if ( e.RowIndex == - 1 ) return; //Header Cell clicked -> ignore it.
vehicleTypeGridView.BeginEdit ( true );
var control = vehicleType... |
317,647 | <p>I've attempted to use the EstimatedSize value during creation of an uninstaller registry key for an app I've developed, unfortunately the value I specify does not appear in the Add/Remove Program list next to my program's entry. I've tried to find the proper procedure for using this value but to no avail. Anyone h... | [
{
"answer_id": 318141,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 1,
"selected": false,
"text": "<p>What kind of installer did you use? MSI? </p>\n\n<p>Windows Installer will determine and set this value during ins... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40662/"
] | I've attempted to use the EstimatedSize value during creation of an uninstaller registry key for an app I've developed, unfortunately the value I specify does not appear in the Add/Remove Program list next to my program's entry. I've tried to find the proper procedure for using this value but to no avail. Anyone have a... | I figured out that changing the value of EstimatedSize under
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{my-guid-value}
```
does not have any direct effect. This value is cached in the following key:
```
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Management\ARP... |
317,649 | <p>The scenario is:</p>
<ol>
<li>svn cp or mv some file</li>
<li>modify that file</li>
<li>svn diff > mypatch</li>
</ol>
<p>On other machine (same working copy, but no changes):</p>
<ol start="4">
<li>Try to apply mypatch.</li>
<li>Fail -> tries to modify unexistant file.</li>
</ol>
<p>How can I make svn diff produ... | [
{
"answer_id": 319853,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 6,
"selected": false,
"text": "<p>With subversion, you can specify which diff binary to use, and parameters to pass to it. See <a href=\"http://svnbook.red-... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | The scenario is:
1. svn cp or mv some file
2. modify that file
3. svn diff > mypatch
On other machine (same working copy, but no changes):
4. Try to apply mypatch.
5. Fail -> tries to modify unexistant file.
How can I make svn diff produce patch-appliable patch, or cleanly apply patch produced by svn diff in this c... | With subversion, you can specify which diff binary to use, and parameters to pass to it. See [the manual](http://svnbook.red-bean.com/en/1.1/re09.html) on svn diff.
You'd want to produce a regular patch file from a svn diff, so you'd want the svn diff to look like a normal diff. Try this:
```
svn diff --diff-cmd /usr... |
317,678 | <p>Sometimes, while I am debugging a c# application, I will hit a break point and when I try to continue, step or step into, it just does nothing. The yellow line highlighting the current line goes away, but it never reaches the next line. The app is still frozen like I am on a breakpoint and I can do nothing but hit... | [
{
"answer_id": 317709,
"author": "John Sibly",
"author_id": 1078,
"author_profile": "https://Stackoverflow.com/users/1078",
"pm_score": 1,
"selected": false,
"text": "<p>What sort of code are you debugging? </p>\n\n<p>When you \"step into\" are you calling your own .NET code, or calling ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19038/"
] | Sometimes, while I am debugging a c# application, I will hit a break point and when I try to continue, step or step into, it just does nothing. The yellow line highlighting the current line goes away, but it never reaches the next line. The app is still frozen like I am on a breakpoint and I can do nothing but hit the ... | I've seen stalling problems where the debugger is trying to evaluate the variables shown in the Auto/Local windows. If the evaluation is complicated then it can cause significant stalls.
You can turn the auto-evaluation off through Tools|Options and it does make a big difference. |
317,679 | <p>Which one is recommended considering readability, memory usage, other reasons?</p>
<p><strong>1.</strong></p>
<pre><code>String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(s... | [
{
"answer_id": 317693,
"author": "Julien Oster",
"author_id": 40111,
"author_profile": "https://Stackoverflow.com/users/40111",
"pm_score": 1,
"selected": false,
"text": "<p>Personally, I prefer the second one. It's less cluttered and I don't have to keep track of those temporary variabl... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37740/"
] | Which one is recommended considering readability, memory usage, other reasons?
**1.**
```
String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(strSomething2);
String strSomeRe... | I would probably go in-between:
```
String strSomething1 = doSomeValidation(someObject.getSomeProperties1());
String strSomething2 = doSomeValidation(someObject.getSomeProperties2());
someObject.setSomeProperties(strSomething1 + strSomething2);
```
Option #2 seems like a lot to do in one line. It's readable, but tak... |
317,684 | <p>Hi I have a view with several User Controls and I pass ViewData to all of them, I would like to know how you would determine the element count by specifying the string key.
I understand that you cannot use comparison to an integer because ViewData is an object but I have it setup this way for explaining my question.... | [
{
"answer_id": 317720,
"author": "CodeClimber",
"author_id": 4724,
"author_profile": "https://Stackoverflow.com/users/4724",
"pm_score": 4,
"selected": true,
"text": "<p>If I understood your question correctly, you want to get the count out of an element stored inside the ViewData.\nThe ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24130/"
] | Hi I have a view with several User Controls and I pass ViewData to all of them, I would like to know how you would determine the element count by specifying the string key.
I understand that you cannot use comparison to an integer because ViewData is an object but I have it setup this way for explaining my question. I ... | If I understood your question correctly, you want to get the count out of an element stored inside the ViewData.
The only way to achieve this is by casting it to IEnumerable or IList and then call the Count method. |
317,687 | <p>I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g.</p>
<pre><code>@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
</code></pre>
<p>In the Spring XML file, there's a <a href="http://static.spr... | [
{
"answer_id": 318188,
"author": "Dónal",
"author_id": 2648,
"author_profile": "https://Stackoverflow.com/users/2648",
"pm_score": 3,
"selected": false,
"text": "<p>A possible solutions is to declare a second bean which reads from the same properties file:</p>\n\n<pre><code><bean id=\... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have a bunch of Spring beans which are picked up from the classpath via annotations, e.g.
```
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
```
In the Spring XML file, there's a [PropertyPlaceholderConfigurer](http://static.spring... | You can do this in Spring 3 using EL support. Example:
```
@Value("#{systemProperties.databaseName}")
public void setDatabaseName(String dbName) { ... }
@Value("#{strategyBean.databaseKeyGenerator}")
public void setKeyGenerator(KeyGenerator kg) { ... }
```
`systemProperties` is an implicit object and `strategyBean`... |
317,733 | <p>I'm trying to redirect the java compiler output to a file.
I thought it's supposed to be:</p>
<pre><code>javac file.java > log.txt
</code></pre>
<p>or something. Instead, I see all the output on the terminal and nothing in log.txt!</p>
<p>Also, if I want to log errors too, do I do</p>
<pre><code>javac file.j... | [
{
"answer_id": 317752,
"author": "Julien Oster",
"author_id": 40111,
"author_profile": "https://Stackoverflow.com/users/40111",
"pm_score": 5,
"selected": true,
"text": "<pre><code>javac file.java 2> log.txt\n</code></pre>\n\n<p>The reason is that you have <em>two</em> output file des... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31301/"
] | I'm trying to redirect the java compiler output to a file.
I thought it's supposed to be:
```
javac file.java > log.txt
```
or something. Instead, I see all the output on the terminal and nothing in log.txt!
Also, if I want to log errors too, do I do
```
javac file.java 2>&1 > log.txt
```
? | ```
javac file.java 2> log.txt
```
The reason is that you have *two* output file descriptors instead of one. The usual one is stdout, which you can redirect with > and it's supposed to be used for resulting output. The second one, stderr, is meant for human readable output like warnings, errors, current status etc., ... |
317,759 | <p>I have a .NET assembly which I am accessing from VBScript (classic ASP) via COM interop. One class has an indexer (a.k.a. default property) which I got working from VBScript by adding the following attribute to the indexer: <code>[DispId(0)]</code>. It works in most cases, but not when accessing the class as a membe... | [
{
"answer_id": 317851,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>WAG here... Have you examined your assembly with <a href=\"http://www.microsoft.com/downloads/details.aspx?familyid=5233b70... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14934/"
] | I have a .NET assembly which I am accessing from VBScript (classic ASP) via COM interop. One class has an indexer (a.k.a. default property) which I got working from VBScript by adding the following attribute to the indexer: `[DispId(0)]`. It works in most cases, but not when accessing the class as a member of another o... | I stumbled upon this exact problem a few days ago. I couldn't find a reasonable explanation as to why it doesn't work.
After spending long hours trying different workarounds, I think I finally found something that seems to work, and is not so dirty. What I did is implement the accessor to the collection in the contain... |
317,760 | <p>I know on client side (javascript) you can use windows.location.hash but could not find anyway to access from the server side. I'm using asp.net.</p>
| [
{
"answer_id": 317769,
"author": "Julien Oster",
"author_id": 40111,
"author_profile": "https://Stackoverflow.com/users/40111",
"pm_score": 5,
"selected": false,
"text": "<p>That's because the browser doesn't transmit that part to the server, sorry.</p>\n"
},
{
"answer_id": 31858... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4191/"
] | I know on client side (javascript) you can use windows.location.hash but could not find anyway to access from the server side. I'm using asp.net. | We had a situation where we needed to persist the URL hash across ASP.Net post backs. As the browser does not send the hash to the server by default, the only way to do it is to use some Javascript:
1. When the form submits, grab the hash (`window.location.hash`) and store it in a server-side hidden input field Put th... |
317,762 | <p>I get this error during checkout:</p>
<pre><code>cvs checkout: warning: new-born file.java has disappeared
cvs [checkout aborted]: cannot make directory : No such file or directory
cvs status: cannot rewrite CVS/Entries.Backup: Permission denied
</code></pre>
<p>I'm sure I have the proper permissions to this folde... | [
{
"answer_id": 317876,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 2,
"selected": false,
"text": "<p><code>new-born</code> refers to a file that has been <code>add</code>-ed but not <code>commit</code>-ted yet, or that ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31301/"
] | I get this error during checkout:
```
cvs checkout: warning: new-born file.java has disappeared
cvs [checkout aborted]: cannot make directory : No such file or directory
cvs status: cannot rewrite CVS/Entries.Backup: Permission denied
```
I'm sure I have the proper permissions to this folder and it happens even when... | `new-born` refers to a file that has been `add`-ed but not `commit`-ted yet, or that `CVS` is having trouble getting the file written locally.
My guess would be that there is a `.cvs` directory present that records an `add` but the file has since been deleted.
The additional errors you're seeing relate to permissions... |
317,780 | <p>I have a MySQL table consisting of:</p>
<pre><code>CREATE TABLE `url_list` (
`id` int(10) unsigned NOT NULL auto_increment,
`crc32` int(10) unsigned NOT NULL,
`url` varchar(512) NOT NULL,
PRIMARY KEY (`id`),
KEY `crc32` (`crc32`)
);
</code></pre>
<p>When inserting data into a related table I need to loo... | [
{
"answer_id": 317842,
"author": "Adriano Varoli Piazza",
"author_id": 22184,
"author_profile": "https://Stackoverflow.com/users/22184",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://blogs.msdn.com/miah/archive/2008/02/17/sql-if-exists-update-else-insert.aspx\" rel=\"nof... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a MySQL table consisting of:
```
CREATE TABLE `url_list` (
`id` int(10) unsigned NOT NULL auto_increment,
`crc32` int(10) unsigned NOT NULL,
`url` varchar(512) NOT NULL,
PRIMARY KEY (`id`),
KEY `crc32` (`crc32`)
);
```
When inserting data into a related table I need to lookup the primary key from t... | I would recommend ditching the `id` column and the `crc32` because they're not necessary.
You can use an `MD5()` hash to provide a fixed-length, virtually unique value computed from the lengthy URL data, and then use that hash as the primary key.
```
CREATE TABLE `url_list` (
`url_hash` BINARY(16) NOT NULL PRIMARY ... |
317,784 | <p>I am iterating though a TreeSet and printing it out:</p>
<pre><code>while (it.hasNext()) {
System.out.println(it.next());
}
</code></pre>
<p>output:</p>
<pre><code>after
explorers
giant
hoping
internet
into
.
.
.
virtual
world
</code></pre>
<p>However, I would like to <i>only</i> print out those strings who's... | [
{
"answer_id": 317792,
"author": "Julien Grenier",
"author_id": 23051,
"author_profile": "https://Stackoverflow.com/users/23051",
"pm_score": 2,
"selected": false,
"text": "<p>seems like an homework but anyhow,\nthe \"[^m-z]\" means NOT m-z</p>\n\n<p>try putting the \"^\" outside the \"[... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am iterating though a TreeSet and printing it out:
```
while (it.hasNext()) {
System.out.println(it.next());
}
```
output:
```
after
explorers
giant
hoping
internet
into
.
.
.
virtual
world
```
However, I would like to *only* print out those strings who's first character is within the range m-z. I have been ... | First of all, your regular expression is wrong. You want
```
"^[m-z]"
```
Second of all, you don't show the code you're using to do the matching.
Third: If you're willing to do something besides regular expressions and iteration, you should look into SortedSet.tailSet. That's probably what your teacher wants. |
317,794 | <p>I am trying to see if Reg-Free COM is something we can use in our web application to ease deployment of legacy COM components. However, before I get onto looking into things like using it for Interop situations, I can't get a simple test to work. Here's what I have done :-</p>
<p>1) Create a new VB ActiveX DLL proj... | [
{
"answer_id": 318396,
"author": "Tim Farley",
"author_id": 4425,
"author_profile": "https://Stackoverflow.com/users/4425",
"pm_score": 2,
"selected": false,
"text": "<p>Your code sample appears to be the manifest for the COM object DLL. Do you have a manifest for the main program too? ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24109/"
] | I am trying to see if Reg-Free COM is something we can use in our web application to ease deployment of legacy COM components. However, before I get onto looking into things like using it for Interop situations, I can't get a simple test to work. Here's what I have done :-
1) Create a new VB ActiveX DLL project. Left ... | If you reference a .dll in your application, click on the referenced dll under references in your project, look at the properties and set Isolated to TRUE.
This will include the .dll in your project and your application will use the copy of the .dll included in your project.
To see a working Example of this look here... |
317,801 | <p>I need to create a new file handle so that any write operations to that handle get written to disk immediately. </p>
<p>Extra info: The handle will be the inherited STDOUT of a child process, so I need any output from that process to immediately be written to disk.</p>
<p>Studying the <code>CreateFile</code> docum... | [
{
"answer_id": 318204,
"author": "Tim Lesher",
"author_id": 14942,
"author_profile": "https://Stackoverflow.com/users/14942",
"pm_score": 5,
"selected": true,
"text": "<p>I've been bitten by this, too, in the context of crash logging.</p>\n\n<p><code>FILE_FLAG_WRITE_THROUGH</code> only g... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11545/"
] | I need to create a new file handle so that any write operations to that handle get written to disk immediately.
Extra info: The handle will be the inherited STDOUT of a child process, so I need any output from that process to immediately be written to disk.
Studying the `CreateFile` documentation, the `FILE_FLAG_WRI... | I've been bitten by this, too, in the context of crash logging.
`FILE_FLAG_WRITE_THROUGH` only guarantees that the data you're sending gets sent to the *filesystem* before `WriteFile` returns; it doesn't guarantee that it's actually sent to the physical device. So, for example, if you execute a `ReadFile` after a `Wri... |
317,822 | <p>How can we write an update sql statement that would update records and the 'set' value changes every time?</p>
<p>For example:
If we have records like this</p>
<pre><code>SomeNumber SomeV CurCode WhatCodeShouldBe
200802754 432 B08 B09
200802754 432 B08 B09
200802754 432 B08 B09
200808388 714 64B C00
200804119 270 ... | [
{
"answer_id": 317832,
"author": "Julien Oster",
"author_id": 40111,
"author_profile": "https://Stackoverflow.com/users/40111",
"pm_score": 0,
"selected": false,
"text": "<p><code>UPDATE yourtable SET CurCode = WhatCodeShouldBe</code></p>\n"
},
{
"answer_id": 317833,
"author"... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can we write an update sql statement that would update records and the 'set' value changes every time?
For example:
If we have records like this
```
SomeNumber SomeV CurCode WhatCodeShouldBe
200802754 432 B08 B09
200802754 432 B08 B09
200802754 432 B08 B09
200808388 714 64B C00
200804119 270 64B C00
```
I wish ... | ```
update a
set
3rdColumn = b.2ndColumn
from
tableA a
inner join tableB b
on a.linkToB = b.linkToA
```
That is based on [your new comments](https://stackoverflow.com/questions/317822/update-with-changing-set-value#317942) |
317,828 | <p>Each of these variables has an integer value. But this syntax is not valid for some reason:</p>
<pre><code><xsl:when test="$nextAnswerListItemPos < $nextQuestionStemPos" >
</code></pre>
| [
{
"answer_id": 317839,
"author": "Julien Oster",
"author_id": 40111,
"author_profile": "https://Stackoverflow.com/users/40111",
"pm_score": 7,
"selected": true,
"text": "<p>You have to use <code>&lt;</code> instead of <code><</code> and <code>&gt;</code> instead of <code>><... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5653/"
] | Each of these variables has an integer value. But this syntax is not valid for some reason:
```
<xsl:when test="$nextAnswerListItemPos < $nextQuestionStemPos" >
``` | You have to use `<` instead of `<` and `>` instead of `>`, because those are reserved characters. |
317,835 | <p>Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior? </p>
<p><strong>Edit:</strong>
Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.</p>
<p>I have classes which are doing C-st... | [
{
"answer_id": 317884,
"author": "Robert Elwell",
"author_id": 23102,
"author_profile": "https://Stackoverflow.com/users/23102",
"pm_score": -1,
"selected": false,
"text": "<p>I'm pretty sure what you're looking for is \"protected\" or \"private\", depending on your use case.</p>\n\n<p>I... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26566/"
] | Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior?
**Edit:**
Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.
I have classes which are doing C-style system calls on the back e... | PHP doesn't support any friend-like declarations. It's possible to simulate this using the PHP5 \_\_get and \_\_set methods and inspecting a backtrace for only the allowed friend classes, although the code to do it is kind of clumsy.
There's some [sample code](http://bugs.php.net/bug.php?id=34044) and discussion on th... |
317,857 | <p>I have a bash script which will be run on a Mac via ssh. The script requires a particular network drive to already be mounted. On the Mac, I mount this drive by opening a folder "JPLemme" on that drive in Finder. This mounts the drive until the Mac goes to sleep at night.</p>
<p>Obviously, Finder isn't available vi... | [
{
"answer_id": 318611,
"author": "Philip Regan",
"author_id": 11976,
"author_profile": "https://Stackoverflow.com/users/11976",
"pm_score": 3,
"selected": true,
"text": "<p>Your network volume should have a domain attached to it of some kind. So, \"JPLemme.domain.com\". I use the followi... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1019/"
] | I have a bash script which will be run on a Mac via ssh. The script requires a particular network drive to already be mounted. On the Mac, I mount this drive by opening a folder "JPLemme" on that drive in Finder. This mounts the drive until the Mac goes to sleep at night.
Obviously, Finder isn't available via ssh, so ... | Your network volume should have a domain attached to it of some kind. So, "JPLemme.domain.com". I use the following chunk of code to get onto a network volume that is password protected:
```
tell application "Finder"
try
set theServer to mount volume "smb://path/to/volume" as username "YourUserNam... |
317,869 | <p>I'm aiming to create a set of objects, each of which has a unique identifier. If an object already exists with that identifier, I want to use the existing object. Otherwise I want to create a new one. I'm trying not to use the word Singleton, because I know it's a dirty word here...</p>
<p>I can use a factory metho... | [
{
"answer_id": 317897,
"author": "Wouter Lievens",
"author_id": 7927,
"author_profile": "https://Stackoverflow.com/users/7927",
"pm_score": 3,
"selected": true,
"text": "<p>The static method is defined on the parent class, and it's called statically as well. So, there's no way of knowing... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7512/"
] | I'm aiming to create a set of objects, each of which has a unique identifier. If an object already exists with that identifier, I want to use the existing object. Otherwise I want to create a new one. I'm trying not to use the word Singleton, because I know it's a dirty word here...
I can use a factory method:
```
... | The static method is defined on the parent class, and it's called statically as well. So, there's no way of knowing in the method that you've called it on the subclass. The java compiler probably even resolves the call statically to a call to the parent class.
So you will need to either reimplement the static method i... |
317,874 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/200574/linq-equivalent-of-foreach-for-ienumerablet">LINQ equivalent of foreach for IEnumerable<T></a> </p>
</blockquote>
<p>The linq extension methods for ienumerable are very handy ... but not that usefu... | [
{
"answer_id": 317910,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 2,
"selected": false,
"text": "<p>The ForEach method on <code>List<T></code> does this. You could wrap your collection in a list and then use th... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] | >
> **Possible Duplicate:**
>
> [LINQ equivalent of foreach for IEnumerable<T>](https://stackoverflow.com/questions/200574/linq-equivalent-of-foreach-for-ienumerablet)
>
>
>
The linq extension methods for ienumerable are very handy ... but not that useful if all you want to do is apply some computation to each... | Shedding a little more light on why:
LINQ is functional in nature. It is used to query data and return results. A LINQ query shouldn't be altering the state of the application (with some exceptions like caching). Because foreach doesn't return any results, it doesn't have many uses that don't involve altering the stat... |
317,879 | <p>I wrote a windows service a few months ago that would ping a Sharepoint list using _vti_bin/lists.asmx function GetListItemChanges. It was working fine until a few weeks ago when my company upgraded our Sharepoint instance to SP1.<br>
Now whenever my service attempts to access Sharepoint I receive an 401.1 authenti... | [
{
"answer_id": 318014,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Do you have proxies on your internal network?</p>\n\n<p>I'm thinking along the lines of double-hop, and that Basic Auth is ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40686/"
] | I wrote a windows service a few months ago that would ping a Sharepoint list using \_vti\_bin/lists.asmx function GetListItemChanges. It was working fine until a few weeks ago when my company upgraded our Sharepoint instance to SP1.
Now whenever my service attempts to access Sharepoint I receive an 401.1 authenticat... | Based upon the information provided, I doubt this is a programming error. Can you get access to the IIS Manager interface on the server hosting the SharePoint site? If so, check the valid authentication technologies permitted. Are anonymous connections allowed? Is Windows Integrated Authentication enabled? HTTP Basic a... |
317,893 | <p>For some reason my code won't work.</p>
<pre><code> from tan in TANS
where tan.ID.ToString().Count() != 1
select tan
</code></pre>
<p>I want to select all IDs that are duplicates in a table so I am using the count != 1 and I get this error.</p>
<p>NotSupportedException: Sequence operators not supported... | [
{
"answer_id": 317939,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 5,
"selected": true,
"text": "<p><code>tan.ID.ToString()</code> is a string, not a collection so you can't apply Count().</p>\n\n<p>I believe you wa... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] | For some reason my code won't work.
```
from tan in TANS
where tan.ID.ToString().Count() != 1
select tan
```
I want to select all IDs that are duplicates in a table so I am using the count != 1 and I get this error.
NotSupportedException: Sequence operators not supported for type 'System.String'
Help p... | `tan.ID.ToString()` is a string, not a collection so you can't apply Count().
I believe you want something like: (This syntax is wrong, but close)
```
from tan in TANS
group tan by tan.ID into dups
where dups.Count() > 1
select dups.Key;
```
Update (after 5 years minus 5 days): (It's a bit weird to Google a problem... |
317,916 | <p>I need to be able to see if a form input in PHP is numeric. If it is not numeric, the website should redirect. I have tried is_numeric() but it does not seem to work.</p>
<p>Code examples will be nice.</p>
<p>I am developing a shopping cart that accepts an integer value for the quantity. I am trying this: </p>
... | [
{
"answer_id": 317931,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 3,
"selected": false,
"text": "<p>You should probably explain what you mean by \"numeric\" - integral, floating point, exponential notation etc? <a href=\"http... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to be able to see if a form input in PHP is numeric. If it is not numeric, the website should redirect. I have tried is\_numeric() but it does not seem to work.
Code examples will be nice.
I am developing a shopping cart that accepts an integer value for the quantity. I am trying this:
```
if(!is_numeric($qu... | ```
if(!is_numeric($quantity == 0)){
//redirect($data['referurl']."/badinput");
echo "is not numeric";
```
What you have here are two nested conditions.
Let's say $quantity is 1.
The first condition evaluates 1 == 0 and returns FALSE.
The second condition checks if FALSE is numeric an... |
317,921 | <p>I'm just beginning to learn ASP.NET MVC and I've run into a question. I'm trying to determine whether I should use HtmlHelper to create client controls or if I should just roll my own. My gut wants to lean towards just rolling my own because it gives me total control - and use jQuery to decorate and add cross-brows... | [
{
"answer_id": 318055,
"author": "TravisO",
"author_id": 35116,
"author_profile": "https://Stackoverflow.com/users/35116",
"pm_score": 1,
"selected": false,
"text": "<p>The real question you need to ask yourself is, do you need total control, do you just need a working control that gets ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24908/"
] | I'm just beginning to learn ASP.NET MVC and I've run into a question. I'm trying to determine whether I should use HtmlHelper to create client controls or if I should just roll my own. My gut wants to lean towards just rolling my own because it gives me total control - and use jQuery to decorate and add cross-browswer ... | The more they add to HtmlHelper the more I end up using them myself.
Take a look at these posts from ScottGu:
[MVC Preview 5](http://weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form-posting-scenarios.aspx)
and
[MVC Beta](http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-releas... |
317,927 | <p>I am using FxCop and I would like to find all the methods or variables without an access modifier explicitly defined. For example:</p>
<pre><code>class MyClass
{
int myInt = 0;
internal MyClass()
{
}
}
</code></pre>
<p>I would like FxCop to warn me that I didn't specify what access modifier will be ap... | [
{
"answer_id": 317954,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 3,
"selected": true,
"text": "<p>FxCop analyses the compiled code, which has access modifiers applied. You need to use a tool like <a href=\"http://co... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I am using FxCop and I would like to find all the methods or variables without an access modifier explicitly defined. For example:
```
class MyClass
{
int myInt = 0;
internal MyClass()
{
}
}
```
I would like FxCop to warn me that I didn't specify what access modifier will be applied to the variable "myI... | FxCop analyses the compiled code, which has access modifiers applied. You need to use a tool like [StyleCop](http://code.msdn.microsoft.com/sourceanalysis) to detect coding syntax issues such as not explicitly declaring access modifiers. |
317,963 | <p>Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P.</p>
<p>What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task?</p>
| [
{
"answer_id": 317979,
"author": "Brian C. Lane",
"author_id": 27461,
"author_profile": "https://Stackoverflow.com/users/27461",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the <a href=\"http://scipy.org/\" rel=\"nofollow noreferrer\">sciPy Project</a>, it should have wh... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/844/"
] | Say we have normal distribution n(x): mean=0 and \int\_{-a}^{a} n(x) = P.
What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task? | The standard deviation of a mean-zero gaussian distribution with Pr(-a < X < a) = P is
```
a/(sqrt(2)*inverseErf(P))
```
which is the expression you're looking for, where inverseErf is the inverse of the error function (commonly known as erf).
For C, the Gnu Scientific Library (GSL) is a good resource. However it o... |
317,973 | <p>I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept.</p>
<p>Heres the dependency property:</p>
<pre><code>public string Problem
{
get { return (string)GetValue(ProblemProperty); }
set { SetValue(ProblemProperty, value); }
}
public st... | [
{
"answer_id": 318006,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 4,
"selected": false,
"text": "<p>The problem your having is definitely related to your DataContext. The {Binding} extension needs to know where the proper... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28197/"
] | I have just realized I've been coercing binding/dependency properties and not really fundamentally understanding the concept.
Heres the dependency property:
```
public string Problem
{
get { return (string)GetValue(ProblemProperty); }
set { SetValue(ProblemProperty, value); }
}
public static readonly Depende... | The problem your having is definitely related to your DataContext. The {Binding} extension needs to know where the property lives that you are binding to. The default location it looks at is the elements DataContext which by default is always set to the DataContext of it's parent element. If you walk the DataContext up... |
317,997 | <p>Delphi sometimes adds {$R *.res} in front of the unit path in the .dpr file uses clauses, then I get a duplicated resources warning when trying to compile.</p>
<p>Anyone knows why the hell Delphi does that? I'm using Delphi 2009 but this happens since Delphi 2007 (maybe 2006 too)</p>
| [
{
"answer_id": 318264,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 2,
"selected": false,
"text": "<p>It is very annoying, happens without any obvious reasons and cannot be prevented from happening - as far as I know :(</p>\n"... | 2008/11/25 | [
"https://Stackoverflow.com/questions/317997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] | Delphi sometimes adds {$R \*.res} in front of the unit path in the .dpr file uses clauses, then I get a duplicated resources warning when trying to compile.
Anyone knows why the hell Delphi does that? I'm using Delphi 2009 but this happens since Delphi 2007 (maybe 2006 too) | Perhaps posting your .dpr would help illustrate your problem. My project files look like this and give me no problem:
```
program Example;
{$R *.res}
uses
Unit1 in 'Unit1.pas' {frmUnit1};
begin
Application.Initialize;
Application.CreateForm(TfrmUnit1, frmUnit1);
Application.Run;
end.
``` |
318,018 | <p>In the admin section of a website i am building i would like to put together a dashboard page, or 'quick look' type page where the most recent changes/additions/etc in several different areas can be viewed.</p>
<p>I was thinking the best way to do this would be to use partials and have each partial contain the mark... | [
{
"answer_id": 318082,
"author": "capotej",
"author_id": 1263,
"author_profile": "https://Stackoverflow.com/users/1263",
"pm_score": 3,
"selected": true,
"text": "<p>Partials are definitely the way to go, especially when you can pass in arbitrary data into them to make them do stuff. To ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | In the admin section of a website i am building i would like to put together a dashboard page, or 'quick look' type page where the most recent changes/additions/etc in several different areas can be viewed.
I was thinking the best way to do this would be to use partials and have each partial contain the markup for the... | Partials are definitely the way to go, especially when you can pass in arbitrary data into them to make them do stuff. To answer your logic separation issue specifically, you would use:
```
<%= render :partial => "name_of_partial", :locals => { :some_var => @data_from_model } %>
```
Then, inside your partial, you'd... |
318,019 | <p>This is a weird problem I have started having recently. My team is developing a COTS application and we have a few people with their hands in the code. A few weeks ago, I received an error message when trying to debug (and run the compiled EXE):</p>
<blockquote>
<p>"Windows cannot access the specified
device, p... | [
{
"answer_id": 318050,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 3,
"selected": true,
"text": "<p>You say that you have several developers working on the project, so I wonder whether they experience this problem a... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39420/"
] | This is a weird problem I have started having recently. My team is developing a COTS application and we have a few people with their hands in the code. A few weeks ago, I received an error message when trying to debug (and run the compiled EXE):
>
> "Windows cannot access the specified
> device, path, or file. You m... | You say that you have several developers working on the project, so I wonder whether they experience this problem as well.
If it is only happening on your machine than I would not go searching for a problem inside the code (the refactoring that you did seems quite unrelated to the error so I guess the reason why it w... |
318,056 | <p>Not sure what's going on here.</p>
<p>I have a DateTime object, and when I try:</p>
<pre><code>String.Format( "{0:dd/MM/yyyy}", _date)
</code></pre>
<p>the value returned is:</p>
<pre><code>"24-05-1967"
</code></pre>
<p>What I want is</p>
<pre><code>"24/05/1967"
</code></pre>
<p>Can anyone explain why my form... | [
{
"answer_id": 318099,
"author": "Oppositional",
"author_id": 2029,
"author_profile": "https://Stackoverflow.com/users/2029",
"pm_score": 3,
"selected": false,
"text": "<p>You likely want to use the <em>ToString()</em> method of your DateTime object to get the string representation you a... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4782/"
] | Not sure what's going on here.
I have a DateTime object, and when I try:
```
String.Format( "{0:dd/MM/yyyy}", _date)
```
the value returned is:
```
"24-05-1967"
```
What I want is
```
"24/05/1967"
```
Can anyone explain why my format string is being ignored?
A bit more background:
This is a web app which st... | The / is actually the date separator for your specific culture which could be -, in other words, the format string is not ignored but actually used correctly. Look at what CultureInfo is associated with the running thread:
```
System.Threading.Thread.CurrentThread.CurrentCulture
```
If you try this:
```
String.Form... |
318,064 | <p>How do I setup a class that represents an interface? Is this just an abstract base class?</p>
| [
{
"answer_id": 318084,
"author": "bradtgmurray",
"author_id": 1546,
"author_profile": "https://Stackoverflow.com/users/1546",
"pm_score": 8,
"selected": false,
"text": "<p>Make a class with pure virtual methods. Use the interface by creating another class that overrides those virtual met... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5618/"
] | How do I setup a class that represents an interface? Is this just an abstract base class? | To expand on the answer by [bradtgmurray](https://stackoverflow.com/questions/318064/how-do-you-declare-an-interface-in-c#318084), you may want to make one exception to the pure virtual method list of your interface by adding a virtual destructor. This allows you to pass pointer ownership to another party without expos... |
318,066 | <p>When executing the following (complete) SQL query on Microsoft SQL Server 2000:</p>
<pre><code>SELECT B.ARTIFACTTNS, B.ARTIFACTNAME, B.ARTIFACTTYPE, B.INITIALBYTES, B.TIMESTAMP1, B.FILENAME, B.BACKINGCLASS,
B.CHARENCODING, B.APPNAME, B.COMPONENTTNS, B.COMPONENTNAME, B.SCAMODULENAME, B.SCACOMPONENTNAME
FROM... | [
{
"answer_id": 318089,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": true,
"text": "<p>Because <code>ARTIFACTTYPE</code> can refer to either <code>A.ARTIFACTTYPE</code> or <code>B.ARTIFACTTYPE</code> a... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] | When executing the following (complete) SQL query on Microsoft SQL Server 2000:
```
SELECT B.ARTIFACTTNS, B.ARTIFACTNAME, B.ARTIFACTTYPE, B.INITIALBYTES, B.TIMESTAMP1, B.FILENAME, B.BACKINGCLASS,
B.CHARENCODING, B.APPNAME, B.COMPONENTTNS, B.COMPONENTNAME, B.SCAMODULENAME, B.SCACOMPONENTNAME
FROM (SELECT DISTI... | Because `ARTIFACTTYPE` can refer to either `A.ARTIFACTTYPE` or `B.ARTIFACTTYPE` and the server needs to know which one you want, just change it to `A.ARTIFACTTYPE` and you should be okay in this case.
To clarify, you need to specify the alias prefix any time the column name is ambiguous. It isn't bad practice to alway... |
318,068 | <p>I am working on an If statement and I want to satisfy two conditions to ignore the loop. This seemed easy at first, but now... I don't know. this is my dilemma...</p>
<pre><code>if((radButton1.checked == false)&&(radButton2.checked == false))
{
txtTitle.Text = "go to work";
}
</code></pre>
<p>The dil... | [
{
"answer_id": 318078,
"author": "gbarry",
"author_id": 19512,
"author_profile": "https://Stackoverflow.com/users/19512",
"pm_score": 5,
"selected": true,
"text": "<p>No, it requires them to both be false to <em>execute</em> the statement.</p>\n"
},
{
"answer_id": 318081,
"au... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on an If statement and I want to satisfy two conditions to ignore the loop. This seemed easy at first, but now... I don't know. this is my dilemma...
```
if((radButton1.checked == false)&&(radButton2.checked == false))
{
txtTitle.Text = "go to work";
}
```
The dilemma is "go to work" is not executed... | No, it requires them to both be false to *execute* the statement. |
318,069 | <p>Let's say we're tracking the end-user IP for a web service:</p>
<pre><code>ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
End If
</code></pre>
<p>I've read that this is the best method of retrieving end-user IP because it works even for users on... | [
{
"answer_id": 318093,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 4,
"selected": true,
"text": "<p><code>REMOTE_ADDR</code> is generated by the web server based on the connection from the client. <code>HTTP_X_FORWARD... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19471/"
] | Let's say we're tracking the end-user IP for a web service:
```
ip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip = Request.ServerVariables("REMOTE_ADDR")
End If
```
I've read that this is the best method of retrieving end-user IP because it works even for users on a transparent proxy.
If ... | `REMOTE_ADDR` is generated by the web server based on the connection from the client. `HTTP_X_FORWARDED_FOR` is based on a HTTP header sent by the client.
You can't trust input from the client, particularly input that is easily faked, such as HTTP headers. Clients can stick **anything** into that `HTTP_X_FORWARDED_FOR... |
318,087 | <p>I'm trying to map a joined-subclass scenario using Fluent NHibernate.
I have a class Entity defined in the namespace Core, and a class
SubClass : Entity in the namespace SomeModule</p>
<p>Now I obviously don't want class Entity to know about its derived
types, the SomeModules namespace references Core - not the oth... | [
{
"answer_id": 324038,
"author": "Magnus Bertilsson",
"author_id": 41395,
"author_profile": "https://Stackoverflow.com/users/41395",
"pm_score": 0,
"selected": false,
"text": "<p>Hello did some thing like it a few days ago.</p>\n\n<pre><code>public class EntityMap : ClassMap<Entity>... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7147/"
] | I'm trying to map a joined-subclass scenario using Fluent NHibernate.
I have a class Entity defined in the namespace Core, and a class
SubClass : Entity in the namespace SomeModule
Now I obviously don't want class Entity to know about its derived
types, the SomeModules namespace references Core - not the other way
aro... | I think the API has changed since this question was asked, but this works for me:
```
public class SomeSubclassMap : SubclassMap<SomeSubclass> {
public SomeSubclassMap()
{
KeyColumn("SomeKeyColumnID");
Map(x => x.SomeSubClassProperty);
...
}
}
```
I believe KeyColumn is only requi... |
318,090 | <p>Simple question:</p>
<p>How do I do this on one line:</p>
<pre><code>my $foo = $bar->{baz};
fizz(\$foo);
</code></pre>
<p>I've tried \$bar->{baz}, \${$bar->{baz}}, and numerous others. Is this even possible?</p>
<p>-fREW</p>
<p><strong>Update</strong>: Ok, the hashref is coming from DBI and I am passing the... | [
{
"answer_id": 318136,
"author": "Ralf",
"author_id": 39645,
"author_profile": "https://Stackoverflow.com/users/39645",
"pm_score": 0,
"selected": false,
"text": "<p>I am not even sure what you are doing.\nYou also should put quotes around baz.</p>\n\n<p>Now let's consider that you assig... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | Simple question:
How do I do this on one line:
```
my $foo = $bar->{baz};
fizz(\$foo);
```
I've tried \$bar->{baz}, \${$bar->{baz}}, and numerous others. Is this even possible?
-fREW
**Update**: Ok, the hashref is coming from DBI and I am passing the scalar ref into template toolkit. I guess now that I look more ... | ```
\$bar->{baz}
```
should work.
E.g.:
```
my $foo;
$foo->{bar} = 123;
my $bar = \$foo->{bar};
$$bar = 456;
print "$foo->{bar}\n"; # prints "456"
```
In answer to the update in the OP, you can do:
```
\@$row{qw(body data)};
```
This is not the same as \@array, which would create one reference to an array... |
318,095 | <p>During a recent load test, I've been getting some strange "Index Out of Range Exception" </p>
<p>Stack trace: </p>
<pre><code> at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode pa... | [
{
"answer_id": 318151,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>Just a guess: have you disabled EventValidation on the site? Sounds like something is trying to create a manual p... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18907/"
] | During a recent load test, I've been getting some strange "Index Out of Range Exception"
Stack trace:
```
at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)
... | If someone initiates a post, the application starts sending the post with all 500KBs of viewstate. Half way through postback, the user gets bored and clicks something else. The browser cuts off the postback with just part of the viewstate. The server throws an error that says the viewstate is borked. I would guess this... |
318,096 | <p>I have a generic list of objects in C#, for example sake, here's what the object might be.</p>
<pre><code>public class Thing {
public string Name { get; set; }
public DateTime EditDate { get; set; }
}
var things = new List<Thing>();
</code></pre>
<p>Now I want to call:</p>
<pre><code>thing.Sort((t1... | [
{
"answer_id": 318111,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "<p>List has a <a href=\"http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx\" rel=\"nofollow noreferrer\">sort function</a> th... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I have a generic list of objects in C#, for example sake, here's what the object might be.
```
public class Thing {
public string Name { get; set; }
public DateTime EditDate { get; set; }
}
var things = new List<Thing>();
```
Now I want to call:
```
thing.Sort((t1, t2) => t1.EditDate.CompareTo(t2.EditDate)... | You can create a somewhat more complex lambda, such as:
```
things.Sort((t1, t2) =>
{
if (t1 == null)
{
return (t2 == null) ? 0 : -1;
}
if (t2 == null)
{
return 1;
}
return t1.EditDate.CompareTo(t2.EditDate);
});
```
`EndDate` cannot be `null` as it is a value type. However, if you had a specific value... |
318,113 | <p>I have a list control in Flex that has been data bound to an e4x xml object from an HTTPService. </p>
<p>I would now like to have a button that clears the list, how can I do this?</p>
<p>I have tried:</p>
<pre>
<code>
list.dataProvider = null;
</code>
</pre>
<p>which does not seem to work, I have also tried:</p>... | [
{
"answer_id": 365202,
"author": "Mike Sickler",
"author_id": 16534,
"author_profile": "https://Stackoverflow.com/users/16534",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have any experience crowd-sourcing translations, but my advice would be to find some dependable freelance ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a list control in Flex that has been data bound to an e4x xml object from an HTTPService.
I would now like to have a button that clears the list, how can I do this?
I have tried:
```
list.dataProvider = null;
```
which does not seem to work, I have also tried:
```
list.dataProvider = {};
```
which cle... | If your software is open source you can use [Launchpad](http://launchpad.net) for translating. |
318,128 | <p>As I continue my quest of learning functional programming, I've come
to wonder if there may be alternatives to my default "procedural" way
of thinking. To be more specific, I'm looking at a function I
wrote. Here is what it does:</p>
<pre><code>Swap two elements of an unordered list of numbers, such that one of the... | [
{
"answer_id": 365202,
"author": "Mike Sickler",
"author_id": 16534,
"author_profile": "https://Stackoverflow.com/users/16534",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have any experience crowd-sourcing translations, but my advice would be to find some dependable freelance ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] | As I continue my quest of learning functional programming, I've come
to wonder if there may be alternatives to my default "procedural" way
of thinking. To be more specific, I'm looking at a function I
wrote. Here is what it does:
```
Swap two elements of an unordered list of numbers, such that one of the elements
i... | If your software is open source you can use [Launchpad](http://launchpad.net) for translating. |
318,129 | <p>Sometimes software installers force you to scroll to the end of the EULA before the “I agree” box is enabled. How can I produce the same effect on a web page?</p>
| [
{
"answer_id": 318130,
"author": "Jeremy Stein",
"author_id": 9702,
"author_profile": "https://Stackoverflow.com/users/9702",
"pm_score": 4,
"selected": true,
"text": "<pre><code><html>\n <head>\n <script type=\"text/javascript\">\n function setupPa... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9702/"
] | Sometimes software installers force you to scroll to the end of the EULA before the “I agree” box is enabled. How can I produce the same effect on a web page? | ```
<html>
<head>
<script type="text/javascript">
function setupPage() {
var agreement = document.getElementById("agreetext");
var visibleHeight = agreement.clientHeight;
var scrollableHeight = agreement.scrollHeight;
if (scrollable... |
318,157 | <p>I'm trying to get distinct results using the Criteria API in NHibernate. I know this is possible using HQL, but I would prefer to do this using the Criteria API, because the rest of my app is written using only this method. I <a href="http://forum.hibernate.org/viewtopic.php?t=941669," rel="noreferrer">found this fo... | [
{
"answer_id": 318196,
"author": "Juanma",
"author_id": 3730,
"author_profile": "https://Stackoverflow.com/users/3730",
"pm_score": 6,
"selected": true,
"text": "<p>Cannot see the forum post at this moment (broken link?), so maybe this is not the answer, but you can add a DistinctRootEnt... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1284/"
] | I'm trying to get distinct results using the Criteria API in NHibernate. I know this is possible using HQL, but I would prefer to do this using the Criteria API, because the rest of my app is written using only this method. I [found this forum post](http://forum.hibernate.org/viewtopic.php?t=941669,), but haven't been ... | Cannot see the forum post at this moment (broken link?), so maybe this is not the answer, but you can add a DistinctRootEntityResultTransformer:
```
session.CreateCriteria(typeof(Product)
.Add(...)
.SetResultTransformer(new DistinctEntityRootTransformer())
``` |
318,158 | <p>I am trying to set the margin of an object from JavaScript. I am able to do it in Opera & Firefox, but the code doesn't work in Internet Explorer.</p>
<p>Here is the JavaScript I have:</p>
<pre class="lang-js prettyprint-override"><code>function SetTopMargin (ObjectID, Value)
{
document.getElementById(Ob... | [
{
"answer_id": 318174,
"author": "phihag",
"author_id": 35070,
"author_profile": "https://Stackoverflow.com/users/35070",
"pm_score": 6,
"selected": true,
"text": "<p>[Updated in 2016] On all current browsers (including IE8+), your code</p>\n\n<pre><code>document.getElementById(ObjectId)... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/126280/"
] | I am trying to set the margin of an object from JavaScript. I am able to do it in Opera & Firefox, but the code doesn't work in Internet Explorer.
Here is the JavaScript I have:
```js
function SetTopMargin (ObjectID, Value)
{
document.getElementById(ObjectID).style.marginTop = Value.toString() + "px";
}
```
An... | [Updated in 2016] On all current browsers (including IE8+), your code
```
document.getElementById(ObjectId).style.marginTop = Value.ToString() + 'px';
```
works fine.
On *very old* IE (< 8) versions, you must use this non-standard contraption instead:
```
document.getElementById(ObjectId).style.setAttribute(
'm... |
318,198 | <p>I'm generating titles out of a few other fields, and want the "right" way to do:</p>
<pre><code>Me.Title.Value = Join(Array([Conference], [Speaker], partstr), " - ")
</code></pre>
<p>Except any of [conference], [speaker] or partstr might be null, and I don't want the extra "-"'s. Are there any functions that'll m... | [
{
"answer_id": 318253,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": 3,
"selected": true,
"text": "<p>Nope - you'll have to check each one and then cleanup at the end</p>\n\n<pre><code>Dim Temp As String\n\nIf Not IsNull([Conf... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12874/"
] | I'm generating titles out of a few other fields, and want the "right" way to do:
```
Me.Title.Value = Join(Array([Conference], [Speaker], partstr), " - ")
```
Except any of [conference], [speaker] or partstr might be null, and I don't want the extra "-"'s. Are there any functions that'll make this job straightforwar... | Nope - you'll have to check each one and then cleanup at the end
```
Dim Temp As String
If Not IsNull([Conference]) Then
Temp = Temp & [Conference] & " - "
End If
If Not IsNull([Speaker]) Then
Temp = Temp & [Speaker] & " - "
End If
If Not IsNull(partstr) Then
Temp = Temp & partstr & " - "
End If
If Temp > ""... |
318,208 | <p>Is it possible to cast an object in Java to a combined generic type?</p>
<p>I have a method like:</p>
<pre><code>public static <T extends Foo & Bar> void doSomething(T object) {
//do stuff
}
</code></pre>
<p>Calling this method is no problem if I have a class that implements both interfaces (Foo &am... | [
{
"answer_id": 318325,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 4,
"selected": false,
"text": "<p>Unfortunately, there is no legal cast that you can make to satisfy this situation. There must be a single type known to ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15355/"
] | Is it possible to cast an object in Java to a combined generic type?
I have a method like:
```
public static <T extends Foo & Bar> void doSomething(T object) {
//do stuff
}
```
Calling this method is no problem if I have a class that implements both interfaces (Foo & Bar).
The problem is when I need to call th... | Java 8 introduces the possibility of [casting with additional bounds](http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.16). You can cast an `Object` as a `class` with multiple `interfaces` (or just as multiple `interfaces`).
So this:
```
doSomething((Problematic cast) o);
```
simply becomes to th... |
318,210 | <p>I'm trying to assert that one object is "equal" to another object. </p>
<p>The objects are just instances of a class with a bunch of public properties. Is there an easy way to have NUnit assert equality based on the properties?</p>
<p>This is my current solution but I think there may be something better:</p>
<pre... | [
{
"answer_id": 318223,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 7,
"selected": true,
"text": "<p>Override .Equals for your object and in the unit test you can then simply do this:</p>\n\n<pre><code>Assert.AreEqua... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29/"
] | I'm trying to assert that one object is "equal" to another object.
The objects are just instances of a class with a bunch of public properties. Is there an easy way to have NUnit assert equality based on the properties?
This is my current solution but I think there may be something better:
```
Assert.AreEqual(LeftO... | Override .Equals for your object and in the unit test you can then simply do this:
```
Assert.AreEqual(LeftObject, RightObject);
```
Of course, this might mean you just move all the individual comparisons to the .Equals method, but it would allow you to reuse that implementation for multiple tests, and probably make... |
318,215 | <p>is it possible to create something like <a href="https://web.archive.org/web/20200805044711/http://geekswithblogs.net/AzamSharp/archive/2008/02/24/119946.aspx" rel="nofollow noreferrer">this</a> i ASP.NET MVC beta 1</p>
<p>i have tried but the</p>
<pre><code>override bool OnPreAction(string actionName,
... | [
{
"answer_id": 318280,
"author": "Rune",
"author_id": 40348,
"author_profile": "https://Stackoverflow.com/users/40348",
"pm_score": 4,
"selected": true,
"text": "<p>In the blogpost you are referring to, the author states that </p>\n\n<blockquote>\n <p>One way to solve this problem is by... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31296/"
] | is it possible to create something like [this](https://web.archive.org/web/20200805044711/http://geekswithblogs.net/AzamSharp/archive/2008/02/24/119946.aspx) i ASP.NET MVC beta 1
i have tried but the
```
override bool OnPreAction(string actionName,
System.Reflection.MethodInfo methodInfo)
... | In the blogpost you are referring to, the author states that
>
> One way to solve this problem is by using the attribute based security as shown on this post. But then you will have to decorate your actions with the security attribute which is not a good idea.
>
>
>
I think it's a perfectly fine way to go about ... |
318,239 | <p>How do I set environment variables from Java? I see that I can do this for subprocesses using <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html" rel="noreferrer"><code>ProcessBuilder</code></a>. I have several subprocesses to start, though, so I'd rather modify the current process's en... | [
{
"answer_id": 318247,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": -1,
"selected": false,
"text": "<p>You can pass parameters into your initial java process with -D:</p>\n\n<pre><code>java -cp <classpath> -Dkey1=value... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | How do I set environment variables from Java? I see that I can do this for subprocesses using [`ProcessBuilder`](http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html). I have several subprocesses to start, though, so I'd rather modify the current process's environment and let the subprocesses inherit ... | >
> (Is it because this is Java and therefore I shouldn't be doing evil nonportable obsolete things like touching my environment?)
>
>
>
I think you've hit the nail on the head.
A possible way to ease the burden would be to factor out a method
```
void setUpEnvironment(ProcessBuilder builder) {
Map<String, S... |
318,246 | <p>how do i define a named_scope to return all the records that were created within the last 7 days, and then how do i use that named scope in a controller?</p>
| [
{
"answer_id": 318346,
"author": "TonyLa",
"author_id": 1295,
"author_profile": "https://Stackoverflow.com/users/1295",
"pm_score": 0,
"selected": false,
"text": "<p>You need to pass named_scope a proc so it will be evaluated every time the call to named_scope is run. Otherwise if you s... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | how do i define a named\_scope to return all the records that were created within the last 7 days, and then how do i use that named scope in a controller? | I would recommend watching the [Railscast Episode on named\_scope](http://railscasts.com/episodes/108).
Ideally, the code you're looking for would be:
```
named_scope :recent,
lambda { |*args| {:conditions => ["created_at > ?", (args.first || 7.days.ago)]} }
```
This will allow you to pass a parameter to the n... |
318,265 | <p>I'm trying to launch another process from a service (it's a console app that collects some data and writes it to the registry) but for some reason I can't get it to launch properly.</p>
<p>I basics of what I'm am trying to do is as follows:</p>
<ol>
<li>Launch the process</li>
<li>Wait for the process to finish</l... | [
{
"answer_id": 318314,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 3,
"selected": true,
"text": "<p><code>WaitForSingleObject</code> and <code>GetExitCodeProcess</code> expect the process handle itself, not a pointer... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I'm trying to launch another process from a service (it's a console app that collects some data and writes it to the registry) but for some reason I can't get it to launch properly.
I basics of what I'm am trying to do is as follows:
1. Launch the process
2. Wait for the process to finish
3. Retrieve the return code ... | `WaitForSingleObject` and `GetExitCodeProcess` expect the process handle itself, not a pointer to the process handle. Remove the ampersands.
Also, check the return values and call `GetLastError` when they fail. That will help you diagnose future problems. Never assume an API function will always succeed.
Once you cal... |
318,288 | <p>When I use the <code>MouseUp</code> event, I can get it to fire with a mouse right-click. But <code>MouseLeftButtonUp</code> won't fire with either click!</p>
<pre class="lang-xml prettyprint-override"><code><Button MouseLeftButtonUp="btnNewConfig_MouseUp" Name="btnNewConfig">
<StackPanel Orientation=... | [
{
"answer_id": 318304,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 6,
"selected": true,
"text": "<p>Looks like <code>Button</code> control is eating up that event Since <code>Button.Click</code> is actually a combination ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] | When I use the `MouseUp` event, I can get it to fire with a mouse right-click. But `MouseLeftButtonUp` won't fire with either click!
```xml
<Button MouseLeftButtonUp="btnNewConfig_MouseUp" Name="btnNewConfig">
<StackPanel Orientation="Horizontal">
<Image Source="Icons\new.ico" Height="24" Width="24" Margi... | Looks like `Button` control is eating up that event Since `Button.Click` is actually a combination of `LeftButtonDown` event and `LeftButtonUp` event.
But you can subscribe to the tunneled event **`PreviewMouseLeftButtonUp`** on the `Button` instead of `LeftButtonUp`. |
318,303 | <p>When I try to use the code below I get a duplicate variable error because variables are immutable. How do I set the smaller of the two variables (<code>$nextSubPartPos</code> and <code>$nextQuestionStemPos</code>) as my new variable (<code>$nextQuestionPos</code>)?</p>
<pre><code> <xsl:variable name="nex... | [
{
"answer_id": 318309,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 0,
"selected": false,
"text": "<p>Variables in XSLT are immutable. This has tripped me up so many times.</p>\n"
},
{
"answer_id": 318318,
... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5653/"
] | When I try to use the code below I get a duplicate variable error because variables are immutable. How do I set the smaller of the two variables (`$nextSubPartPos` and `$nextQuestionStemPos`) as my new variable (`$nextQuestionPos`)?
```
<xsl:variable name="nextQuestionPos"/>
<xsl:choose>
<x... | Don't close the xsl:variable node in the first line. That is, take the / out of it, then put an `</xsl:variable>` after `</xsl:choose>`. Next, change the `<xsl:variable>` nodes inside the choose to `<xsl:value-of>` nodes.
That is, you want to set the value of the variable with the choose. There are two ways to set the... |
318,311 | <p>I have a table with a credit and debit column.</p>
<p>I need to get the highest balance out of that, and I think a stored procedure is the way to do it, but I have no idea how.</p>
<p>I need to start with the first row, add the debits, subtract the credits and store the value A.</p>
<p>Second row is A+debit-credi... | [
{
"answer_id": 318331,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": -1,
"selected": false,
"text": "<p>May</p>\n\n<pre><code>select max(debit-credit) from yourtable\n</code></pre>\n\n<p>work?</p>\n\n<p>Try to test it.</p>\n... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13704/"
] | I have a table with a credit and debit column.
I need to get the highest balance out of that, and I think a stored procedure is the way to do it, but I have no idea how.
I need to start with the first row, add the debits, subtract the credits and store the value A.
Second row is A+debit-credit=B; A = max(A,B)
Repeat... | It seems to me that you'd want the running total to be `A+credit-debit` but switch them if needed.
```
SET @balance := 0;
SET @high := 0;
SELECT @high := GREATEST(@balance := @balance+credit-debit, @high) FROM mytable;
SELECT @high;
```
**edit:** In response to your comment about forming a stored function from this.... |
318,347 | <p>Edit: Warning - I now realize that the following technique is generally regarded as a bad idea because it creates hidden dependencies for the sake of looking neat.</p>
<hr>
<p>I recently discovered that you can use the StackTrace to infer information about the caller of a method.</p>
<p>This enables you to create... | [
{
"answer_id": 318359,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 4,
"selected": true,
"text": "<p>There's two reasons why not to do this:</p>\n\n<ul>\n<li>It's slow</li>\n<li>It's creates a brittle solution.</li>\n<... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] | Edit: Warning - I now realize that the following technique is generally regarded as a bad idea because it creates hidden dependencies for the sake of looking neat.
---
I recently discovered that you can use the StackTrace to infer information about the caller of a method.
This enables you to create a seemingly "cool... | There's two reasons why not to do this:
* It's slow
* It's creates a brittle solution.
If you wanted to do this, you'd better off using a tool that supports Aspect Oriented Programming, such as Castle's Dynamic Proxy. |
318,356 | <p>I am doing a join on two tables. One is a user's table and the other a list of premium users. I need to have the premium members show up first in my query. However, just because they are in the premium user table doesn't mean they are still a premium member - there is an IsActive field that also needs to be checked.... | [
{
"answer_id": 318369,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "<pre><code>ORDER BY COALESCE(PremiumUsers.IsActive, 0) DESC\n</code></pre>\n\n<p>That will group the NULLs with not-act... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] | I am doing a join on two tables. One is a user's table and the other a list of premium users. I need to have the premium members show up first in my query. However, just because they are in the premium user table doesn't mean they are still a premium member - there is an IsActive field that also needs to be checked.
S... | ```
ORDER BY COALESCE(PremiumUsers.IsActive, 0) DESC
```
That will group the NULLs with not-actives. |
318,387 | <p>I have the following method in my code:</p>
<pre><code>private bool GenerateZipFile(List<FileInfo> filesToArchive, DateTime archiveDate)
{
try
{
using (ZipOutputStream zipStream = new ZipOutputStream(File.Create(GetZipFileName(archiveDate))))
{
zipStream.SetLevel(9); // max... | [
{
"answer_id": 318435,
"author": "Tinister",
"author_id": 34715,
"author_profile": "https://Stackoverflow.com/users/34715",
"pm_score": 2,
"selected": false,
"text": "<p>I had a similar problem which I solved by specifying the <code>CompressionMethod</code> and <code>CompressedSize</code... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I have the following method in my code:
```
private bool GenerateZipFile(List<FileInfo> filesToArchive, DateTime archiveDate)
{
try
{
using (ZipOutputStream zipStream = new ZipOutputStream(File.Create(GetZipFileName(archiveDate))))
{
zipStream.SetLevel(9); // maximum compression.
... | I used to use SharpZipLib until I switched to [DotNetZip](http://www.codeplex.com/DotNetZip) You may want to check it out as an alternative.
Example:
```
try
{
using (ZipFile zip = new ZipFile("MyZipFile.zip")
{
zip.AddFile("c:\\photos\\personal\\7440-N49th.png");
zip.AddFile("c:\\Desktop\\... |
318,388 | <p>I am trying to debug an intermittent error on the iPhone, a crash with a trace that looks like:</p>
<pre><code>objc_message_send
__invoking__
[NSInvocation invoke]
HandleDelegateSource
MainRunLoop
....
</code></pre>
<p>When GDB stops, I'd like to be able to determine details about what selector the system is attem... | [
{
"answer_id": 736366,
"author": "lothar",
"author_id": 44434,
"author_profile": "https://Stackoverflow.com/users/44434",
"pm_score": 1,
"selected": false,
"text": "<p>If you look at the reference information for <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/ObjCRunt... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6330/"
] | I am trying to debug an intermittent error on the iPhone, a crash with a trace that looks like:
```
objc_message_send
__invoking__
[NSInvocation invoke]
HandleDelegateSource
MainRunLoop
....
```
When GDB stops, I'd like to be able to determine details about what selector the system is attempting to be invoked - I've... | A simple final answer - in GDB you can simply view the register with the name of the selector being called (theSelector parameter in lothar's answer). It's a C string, so you observe it using one of the following commands (depending on if you are running in the simulator or the device):
```
Simulator: display /s $ecx
... |
318,434 | <p>Any good converter for GB, Big5, Unicode?</p>
<p>Convert GB to Unicode, Unicode to GB, Big5 to Unicode, Unicode to Big5, GB to Big5.</p>
| [
{
"answer_id": 318521,
"author": "huaiyuan",
"author_id": 16240,
"author_profile": "https://Stackoverflow.com/users/16240",
"pm_score": 2,
"selected": true,
"text": "<p>iconv should be able to do the job. It's part of the GNU C Library.</p>\n\n<pre><code>http://en.wikipedia.org/wiki/Ico... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/206630/"
] | Any good converter for GB, Big5, Unicode?
Convert GB to Unicode, Unicode to GB, Big5 to Unicode, Unicode to Big5, GB to Big5. | iconv should be able to do the job. It's part of the GNU C Library.
```
http://en.wikipedia.org/wiki/Iconv
http://www.gnu.org/software/libiconv/
``` |
318,449 | <p>I have a set of radio buttons where a selection is required. In addition, there is an optional text box that shows up next to one of the selections.</p>
<p>What would be the best way to make it clear what is required and what is optional?</p>
<pre><code><strong>User Availability:</strong><br>
&l... | [
{
"answer_id": 318460,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 1,
"selected": true,
"text": "<p>Assuming \"mm/dd/yyy\" is the textbox, I'd put the this text in the textbox, with it being cleared when the user clicks o... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | I have a set of radio buttons where a selection is required. In addition, there is an optional text box that shows up next to one of the selections.
What would be the best way to make it clear what is required and what is optional?
```
<strong>User Availability:</strong><br>
<input value="Available" type="radio"> Ava... | Assuming "mm/dd/yyy" is the textbox, I'd put the this text in the textbox, with it being cleared when the user clicks or otherwise sets focus on the textbox:
(date) (optional) |
318,462 | <p>I have a .NET (C#) multi-threaded application and I want to know if a certain method runs inside the Finalizer thread. </p>
<p>I've tried using Thread.CurrentThread.Name but it doesn't work (returns null).</p>
<p>Anyone knows how can I query the current thread to discover if it's the Finalizer thread?</p>
| [
{
"answer_id": 318509,
"author": "Carl Serrander",
"author_id": 40272,
"author_profile": "https://Stackoverflow.com/users/40272",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think that is possible even using the debugging APIs, see <a href=\"http://blogs.msdn.com/jmstall/archiv... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11361/"
] | I have a .NET (C#) multi-threaded application and I want to know if a certain method runs inside the Finalizer thread.
I've tried using Thread.CurrentThread.Name but it doesn't work (returns null).
Anyone knows how can I query the current thread to discover if it's the Finalizer thread? | The best way to identify a thread is through its managed id:
```
Thread.CurrentThread.ManagedThreadId;
```
Since a finalizer always runs in the GC's thread you can create a finalizer that will save the thread id (or the thread object) in a static valiable.
Sample:
```
public class ThreadTest {
public static Th... |
318,473 | <p>I have a couple of tables which are used to log user activity for an application. The tables looks something like this (pseudo code from memory, may not be syntactically correct):</p>
<pre><code>create table activity (
sessionid uniqueidentifier not null,
created smalldatetime not null default getutcdate()
);
... | [
{
"answer_id": 318494,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": true,
"text": "<p>There's probably more efficient ways to do this as well, but this is closest to your original:</p>\n\n<pre><code>trunc... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34942/"
] | I have a couple of tables which are used to log user activity for an application. The tables looks something like this (pseudo code from memory, may not be syntactically correct):
```
create table activity (
sessionid uniqueidentifier not null,
created smalldatetime not null default getutcdate()
);
create table a... | There's probably more efficient ways to do this as well, but this is closest to your original:
```
truncate table activity_summary;
insert into activity_summary (sessionid, first_activity_desc, last_activity_summary)
select a.sessionid
,(select top 1 ad.activity_desc from activity_detail AS ad where ad.sessionid = a.... |
318,475 | <p>I was trying the ASP.NET login control tutorial and everything works well. However, I do not know how to have the Log-in control use my own database (SQL Server 2005) instead of using it's mdf file. I also have no idea where this file was created from since it doesn't show up at all on my solution. Any literature th... | [
{
"answer_id": 318508,
"author": "GregD",
"author_id": 38317,
"author_profile": "https://Stackoverflow.com/users/38317",
"pm_score": 1,
"selected": false,
"text": "<p>A few excellent references for asp.net login controls:</p>\n\n<p><a href=\"http://www.sitepoint.com/article/asp-net-2-sec... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32812/"
] | I was trying the ASP.NET login control tutorial and everything works well. However, I do not know how to have the Log-in control use my own database (SQL Server 2005) instead of using it's mdf file. I also have no idea where this file was created from since it doesn't show up at all on my solution. Any literature that ... | When you use ASP.NET's Membership features, you need to specify a provider. In the machine.config file (which lives in C:\WINDOWS\Microsoft.NET\Framework\[version]\CONFIG) a default provider is specified that uses a local .mdf file in the app\_data folder. Since you don't want that, you can override it in your app's we... |
318,488 | <p>How do you build a hierarchical set of tags with data in PHP?</p>
<p>For example, a nested list:</p>
<pre><code><div>
<ul>
<li>foo
</li>
<li>bar
<ul>
<li>sub-bar
</li>
</ul>
... | [
{
"answer_id": 318605,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 0,
"selected": false,
"text": "<p>You mean something like</p>\n\n<pre><code>function array_to_list(array $array, $width = 3, $type = 'ul', $separator = ' ', ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1892/"
] | How do you build a hierarchical set of tags with data in PHP?
For example, a nested list:
```
<div>
<ul>
<li>foo
</li>
<li>bar
<ul>
<li>sub-bar
</li>
</ul>
</li>
</ul>
</div>
```
This would be build from flat data like t... | *Edit: Added formatting*
As already said in the comments, your data structure is somewhat strange. Instead of using text manipulation (like OIS), I prefer DOM:
```
<?php
$nested_array = array();
$nested_array[] = array('name' => 'foo', 'depth' => 0);
$nested_array[] = array('name' => 'bar', 'depth' => 0);
$nested_ar... |
318,489 | <p>I wrote a raw TCP client for HTTP/HTTPS requests, however I'm having problems with chunked encoding responses. HTTP/1.1 is requirement therefore I should support it.</p>
<p><em>Raw TCP is a business requirement that I need to keep, therefore I can't switch to .NET HTTPWebRequest/HTTPWebResponse</em> However if ther... | [
{
"answer_id": 318601,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 4,
"selected": true,
"text": "<p>The best place to start is the <a href=\"ftp://ftp.isi.edu/in-notes/rfc2616.txt\" rel=\"nofollow noreferrer\">http 1.1 sp... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] | I wrote a raw TCP client for HTTP/HTTPS requests, however I'm having problems with chunked encoding responses. HTTP/1.1 is requirement therefore I should support it.
*Raw TCP is a business requirement that I need to keep, therefore I can't switch to .NET HTTPWebRequest/HTTPWebResponse* However if there is way to conve... | The best place to start is the [http 1.1 specification](ftp://ftp.isi.edu/in-notes/rfc2616.txt), which lays out how chunking works. Specifically section 3.6.1.
>
> 3.6.1 Chunked Transfer Coding
>
>
> The chunked encoding modifies the
> body of a message in order to
>
> transfer it as a series of chunks,
> eac... |
318,500 | <p>In other languages you can use strings as keys -</p>
<p>PHP:</p>
<pre><code>$array['string'] = 50;
$array['anotherstring'] = 150;
</code></pre>
<p>Is this possible in VBA?</p>
| [
{
"answer_id": 318519,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": false,
"text": "<p>Have you considered the Dictionary object?</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/aa164502(office.... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11839/"
] | In other languages you can use strings as keys -
PHP:
```
$array['string'] = 50;
$array['anotherstring'] = 150;
```
Is this possible in VBA? | In VBA you can create a Collection object. Items in the collection can be accessed by index (Long integer) or by a string key. |
318,511 | <p>I've got a structure as follows:</p>
<pre><code>typedef struct
{
std::wstring DevAgentVersion;
std::wstring SerialNumber;
} DeviceInfo;
</code></pre>
<p>But when I try to use it I get all sorts of memory allocation errors.</p>
<p>If I try to pass it into a function like this:</p>
<pre><code>GetDeviceInf... | [
{
"answer_id": 318520,
"author": "Marcin",
"author_id": 22724,
"author_profile": "https://Stackoverflow.com/users/22724",
"pm_score": 4,
"selected": true,
"text": "<p>You should use <code>new</code> instead of <code>malloc</code>, to assure the constructor gets called for the <code>Devic... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I've got a structure as follows:
```
typedef struct
{
std::wstring DevAgentVersion;
std::wstring SerialNumber;
} DeviceInfo;
```
But when I try to use it I get all sorts of memory allocation errors.
If I try to pass it into a function like this:
```
GetDeviceInfo(DeviceInfo *info);
```
I will get a runt... | You should use `new` instead of `malloc`, to assure the constructor gets called for the `DeviceInfo` and its contained `wstring`s.
```
DeviceInfo *info = new DeviceInfo;
```
In general, it's best to avoid using `malloc` in C++.
Also, make sure to `delete` the pointer when you're done using it.
Edit: Of course if y... |
318,528 | <p>I am using SQL Advantage and need to know what the SQL is to identify the triggers associated with a table. I don't have the option to use another tool so the good old fashioned SQL solution is the ideal answer.</p>
| [
{
"answer_id": 319924,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 4,
"selected": false,
"text": "<pre>select *\nfrom sysobjects\nwhere type = 'TR'</pre>\n\n<p>Taken from <a href=\"https://web.archive.org/web/1/http://articl... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7329/"
] | I am using SQL Advantage and need to know what the SQL is to identify the triggers associated with a table. I don't have the option to use another tool so the good old fashioned SQL solution is the ideal answer. | I also found out that
```
sp_depends <object_name>
```
will show you a lot of information about a table, including all triggers associated with it. Using that, along with Ray's query can make it much easier to find the triggers. Combined with this query from Ray's linked article:
```
sp_helptext <trigger_name>
`... |
318,530 | <p>Is it possible to create and initialise a <a href="http://msdn.microsoft.com/en-us/library/6918612z(VS.80).aspx" rel="noreferrer"><code>System.Collections.Generic.Dictionary</code></a> object with String key/value pairs in one statement?</p>
<p>I'm thinking along the lines of the constructor for an array of Strings... | [
{
"answer_id": 318574,
"author": "Kasprzol",
"author_id": 5957,
"author_profile": "https://Stackoverflow.com/users/5957",
"pm_score": 3,
"selected": false,
"text": "<p>Try this syntax:</p>\n\n<pre><code>Dictionary<string, double> dict = new Dictionary<string, double>()\n{\n ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] | Is it possible to create and initialise a [`System.Collections.Generic.Dictionary`](http://msdn.microsoft.com/en-us/library/6918612z(VS.80).aspx) object with String key/value pairs in one statement?
I'm thinking along the lines of the constructor for an array of Strings..
e.g.
```
Private mStringArray As String() = ... | I don't think there is a way to do this out of the box in VB.NET 2, however you can extend the generic dictionary to make it work the way you want it to.
The console app below illustrates this:
```
Imports System.Collections.Generic
Module Module1
Sub Main()
Dim items As New FancyDictionary(Of Integer,... |
318,531 | <p>I want to pass in the tType of a class to a function, and the class object to a generic function.</p>
<p>I need to be able to cast to that Type (of class) so I can access the class's methods.</p>
<p>Something like:</p>
<pre><code>void GenericFunction(Object obj, Type type)
{
(type)obj.someContainer.Add(1);
}
... | [
{
"answer_id": 318548,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 0,
"selected": false,
"text": "<p>Can you use generics in your method call? Something like:</p>\n\n<pre><code>void GenericFunction<T>(Object ob... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33082/"
] | I want to pass in the tType of a class to a function, and the class object to a generic function.
I need to be able to cast to that Type (of class) so I can access the class's methods.
Something like:
```
void GenericFunction(Object obj, Type type)
{
(type)obj.someContainer.Add(1);
}
```
Would implementing an ... | Here's three ways to go about what you're asking:
```
public interface ICanReport
{ void Report(); }
public class SomeThing : ICanReport
{
public void Report()
{ Console.WriteLine("I'm SomeThing"); }
}
public class SomeOtherThing : ICanReport
{
public void Report()
{ Console.WriteLine("I'm SomeOtherT... |
318,540 | <p>I have a BlackBerry app running in the background that needs to know when a "Missed call" system dialog is brought up by the system, and programmatically close it without user intervention. How can I do that?</p>
<p>I could actually almost know when the dialog is brought up, i.e. a little later I programmatically e... | [
{
"answer_id": 324286,
"author": "Alexander",
"author_id": 16724,
"author_profile": "https://Stackoverflow.com/users/16724",
"pm_score": 1,
"selected": false,
"text": "<p>(Haven't tried this myself) Your app could periodically poll the system for the foreground app. Once it's the Phone a... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39680/"
] | I have a BlackBerry app running in the background that needs to know when a "Missed call" system dialog is brought up by the system, and programmatically close it without user intervention. How can I do that?
I could actually almost know when the dialog is brought up, i.e. a little later I programmatically end the cal... | Key press injection for device *Close* button looks like this:
```
KeyEvent inject = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
inject.post();
```
Don't forget to set permissions for device release:
Options => Advanced Options => Applications => [Your Application] =>Edit Default permissions =>Interactio... |
318,542 | <p>The attached code example (pseudo code) compiles, but throws this Run-Time Error:</p>
<pre><code>TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Con... | [
{
"answer_id": 319967,
"author": "Niels Bosma",
"author_id": 40939,
"author_profile": "https://Stackoverflow.com/users/40939",
"pm_score": 0,
"selected": false,
"text": "<p>tried this:</p>\n\n<pre><code>selectedChild=\"{this[targetViewName]}\">\n</code></pre>\n\n<p>/Niels</p>\n"
},
... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31298/"
] | The attached code example (pseudo code) compiles, but throws this Run-Time Error:
```
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\Container.as:2409... | when selectedChild is fired the viewStack doesn't have any children added so it throws a NullPointerException:
The following will work:
```
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.core.C... |
318,551 | <p>there was a somewhat detailed thread (228684) on how to globally (using extern struct) declare a structure that could be seen in more than 1 c++ file, but I can not figure out exactly how to do it (there was a lot of discussion about do this, do that, maybe do this, try this, etc...). </p>
<p>couuld someone please ... | [
{
"answer_id": 318558,
"author": "David Nehme",
"author_id": 14167,
"author_profile": "https://Stackoverflow.com/users/14167",
"pm_score": 3,
"selected": false,
"text": "<p>It's called a header file.</p>\n\n<p>in your header file (call it foo.h)</p>\n\n<pre><code>#ifndef FOO_H\n#define F... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | there was a somewhat detailed thread (228684) on how to globally (using extern struct) declare a structure that could be seen in more than 1 c++ file, but I can not figure out exactly how to do it (there was a lot of discussion about do this, do that, maybe do this, try this, etc...).
couuld someone please post a ver... | It's called a header file.
in your header file (call it foo.h)
```
#ifndef FOO_H
#define FOO_H
class X {
};
#endif
```
Then, in any C files you have
```
#include "foo.h"
X x;
```
For C++ it's more common/preferred to use class, but you can use struct as well. The extern keyword generally refers to variables, not... |
318,552 | <p>I have a collection of collections, all the child collections have the same number of elements. The parent collection does nothing other than hold the child collections.</p>
<pre><code>[0] [Child_0] [ID: 1]
[0] [Child_0] [Amount: 4]
[0] [Child_1] [ID: 2]
[0] [Child_1] [Amount: 7]
[1] [Child_0] [ID: 1]
[1] [Child_0]... | [
{
"answer_id": 318662,
"author": "Rohan West",
"author_id": 38686,
"author_profile": "https://Stackoverflow.com/users/38686",
"pm_score": 2,
"selected": false,
"text": "<p>you may be able to us this as a guide</p>\n\n<pre><code> var items = new[] \n { \n new { ID... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a collection of collections, all the child collections have the same number of elements. The parent collection does nothing other than hold the child collections.
```
[0] [Child_0] [ID: 1]
[0] [Child_0] [Amount: 4]
[0] [Child_1] [ID: 2]
[0] [Child_1] [Amount: 7]
[1] [Child_0] [ID: 1]
[1] [Child_0] [Amount: 2]
[... | It sounds like a simple selectmany, group and average should do the job; here I'm using anonymous types and arrays purely for convenience of typing...
```
// the data
var outer = new[] {
new[] {
new {ID=1,Amount=4}, // [0] [Child_0] [ID: 1, Amount: 4]
new {ID... |
318,553 | <p>I have the following in my .emacs file:</p>
<pre><code> (defun c++-mode-untabify ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-min))
(if (search-forward "\t" nil t)
(un... | [
{
"answer_id": 318710,
"author": "Boojum",
"author_id": 37555,
"author_profile": "https://Stackoverflow.com/users/37555",
"pm_score": 3,
"selected": false,
"text": "<p>The documentation in my Emacs says that make-local-hook is now obsolete as of 21.1, since add-hook now takes an optional... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9199/"
] | I have the following in my .emacs file:
```
(defun c++-mode-untabify ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-min))
(if (search-forward "\t" nil t)
(untabify (1- (po... | write-contents-hooks is also obsolete. This is what you're after:
```
(add-hook 'c++-mode-hook
'(lambda ()
(add-hook 'before-save-hook
(lambda ()
(untabify (point-min) (point-max))))))
```
This is distilled from what I use, which does a few other things and is a... |
318,556 | <p>Is there a way to get drop_receiving_element to not generate "// ..</p>
| [
{
"answer_id": 318825,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 1,
"selected": false,
"text": "<p>The code for the <code>drop_receiving_element</code> is</p>\n\n<pre><code>def drop_receiving_element(element_id, opti... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to get drop\_receiving\_element to not generate "// .. | The code for the `drop_receiving_element` is
```
def drop_receiving_element(element_id, options = {})
javascript_tag(drop_receiving_element_js(element_id, options).chop!)
end
```
`javascript_tag` is what adds the script tags, so it looks like you should just be able to leave those out, and enter this yourself.
``... |
318,564 | <p>Not every website exposes their data well, with XML feeds, APIs, etc</p>
<p>How could I go about extracting information from a website? For example:</p>
<pre><code>...
<div>
<div>
<span id="important-data">information here</span>
</div>
</div>
...
</code></pre>
<p>I com... | [
{
"answer_id": 318575,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.manageability.org/blog/stuff/screen-scraping-tools-written-in-java\" rel=\"nofollow noreferrer... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33167/"
] | Not every website exposes their data well, with XML feeds, APIs, etc
How could I go about extracting information from a website? For example:
```
...
<div>
<div>
<span id="important-data">information here</span>
</div>
</div>
...
```
I come from a background of Java programming and coding with Apache XMLBea... | There are several Open Source HTML Parsers out there for Java.
I have used [JTidy](http://jtidy.sourceforge.net/) in the past, and have had good luck with it. It will give you a DOM of the html page, and you should be able to grab the tags you need from there. |
318,567 | <p>I have a database that hold's a user's optional profile. In the profile I have strings, char (for M or F) and ints.</p>
<p>I ran into an issue where I try to put the sex of the user into the property of my Profile object, and the application crashes because it doesn't know how to handle a returned null value.</p>
... | [
{
"answer_id": 318585,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 0,
"selected": false,
"text": "<p>I would do it pretty much like you did. I would write a function for it:</p>\n\n<p>Something that does:</p>\n\n<pre><c... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298/"
] | I have a database that hold's a user's optional profile. In the profile I have strings, char (for M or F) and ints.
I ran into an issue where I try to put the sex of the user into the property of my Profile object, and the application crashes because it doesn't know how to handle a returned null value.
I've tried cas... | rotard's answer (use `Is<ColumnName>Null()`) only works for typed data sets.
For untyped data sets, you have to use one of the patterns in the following code. If this code isn't definitive, let me know and I'll edit it until it is. This is an extremely common question that there should really be only one right answer... |
318,571 | <p>Using MySQL syntax and having a table with a row like:</p>
<pre><code>mydate DATETIME NULL,
</code></pre>
<p>Is there a way to do something like:</p>
<pre><code>... WHERE mydate<='2008-11-25';
</code></pre>
<p>I'm trying but not really getting it to work.</p>
| [
{
"answer_id": 318597,
"author": "fmsf",
"author_id": 26004,
"author_profile": "https://Stackoverflow.com/users/26004",
"pm_score": 5,
"selected": true,
"text": "<p>Nevermind found an answer. Ty the same for anyone who was willing to reply.</p>\n\n<pre><code>WHERE DATEDIFF(mydata,'2008-1... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26004/"
] | Using MySQL syntax and having a table with a row like:
```
mydate DATETIME NULL,
```
Is there a way to do something like:
```
... WHERE mydate<='2008-11-25';
```
I'm trying but not really getting it to work. | Nevermind found an answer. Ty the same for anyone who was willing to reply.
```
WHERE DATEDIFF(mydata,'2008-11-20') >=0;
``` |
318,590 | <p>I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code). </p>
<p>Should I code this sequentially with a bunch of functions taking <strong>very ... | [
{
"answer_id": 318598,
"author": "Joe Phillips",
"author_id": 20471,
"author_profile": "https://Stackoverflow.com/users/20471",
"pm_score": 3,
"selected": false,
"text": "<p>Write it sequentially and then refactor if there's something you think you can reuse or would make it clearer.</p>... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40785/"
] | I'm refactoring a 500-lines of C++ code in main() for solving a differential equation. I'd like to encapsulate the big ideas of our solver into smaller functions (i.e. "SolvePotential(...)" instead of 50 lines of numerics code).
Should I code this sequentially with a bunch of functions taking **very long** parameters... | Neither. "Move all my code from one single function to one single class" is not OOP. One of the fundamental rules of OOP is that a class should have *one single area of responsibility*.
This is not a single responsibility, it is around 15:
```
SolverPotential::solve(){
SolvePotential::interpolate()
SolverPotential::co... |
318,612 | <p>I have a HTML table that's generated in a JSP by the displaytag tag library. I would like to suppress any zeros that appear in the table, i.e. they should be replaced by a blank cell. Is there any straightforward way to achieve this?</p>
| [
{
"answer_id": 318838,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": -1,
"selected": false,
"text": "<p>To my knowledge there isn't an \"straightforward\" way of handling this. The only data-related config property ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have a HTML table that's generated in a JSP by the displaytag tag library. I would like to suppress any zeros that appear in the table, i.e. they should be replaced by a blank cell. Is there any straightforward way to achieve this? | I discovered that this can be achieved using a custom implementation of ColumnDecorator.
```
public class SuppressZeroDecorator implements DisplaytagColumnDecorator {
/* (non-Javadoc)
* @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(java.lang.Object, javax.servlet.jsp.PageContext, org.displ... |
318,630 | <p>I am creating a jQuery plugin.</p>
<p>How do I get the real image width and height with Javascript in Safari?</p>
<p>The following works with Firefox 3, IE7 and Opera 9:</p>
<pre><code>var pic = $("img")
// need to remove these in of case img-element has set width and height
pic.removeAttr("width");
pic.removeA... | [
{
"answer_id": 318694,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": false,
"text": "<p>this works for me (safari 3.2), by firing from within the <code>window.onload</code> event:</p>\n\n<pre><code>$(window).load... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27623/"
] | I am creating a jQuery plugin.
How do I get the real image width and height with Javascript in Safari?
The following works with Firefox 3, IE7 and Opera 9:
```
var pic = $("img")
// need to remove these in of case img-element has set width and height
pic.removeAttr("width");
pic.removeAttr("height");
var pic_real... | Webkit browsers set the height and width property after the image is loaded. Instead of using timeouts, I'd recommend using an image's onload event. Here's a quick example:
```
var img = $("img")[0]; // Get my img elem
var pic_real_width, pic_real_height;
$("<img/>") // Make in memory copy of image to avoid css issues... |
318,632 | <p>I'm running into a problem trying to anchor a textbox to a form on all 4 sides. I added a textbox to a form and set the Multiline property to True and the Anchor property to Left, Right, Up, and Down so that the textbox will expand and shrink with the form at run time. I also have a few other controls above and be... | [
{
"answer_id": 318696,
"author": "Greg D",
"author_id": 6932,
"author_profile": "https://Stackoverflow.com/users/6932",
"pm_score": 2,
"selected": false,
"text": "<p>Does the form snap back to the expected layout when you resize it after it's been initialized weirdly? Also, have you set... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22392/"
] | I'm running into a problem trying to anchor a textbox to a form on all 4 sides. I added a textbox to a form and set the Multiline property to True and the Anchor property to Left, Right, Up, and Down so that the textbox will expand and shrink with the form at run time. I also have a few other controls above and below t... | The textbox I originally posted about was not inherited from a baseclass form (although it was added to a custom User Control class; I probably should have mentioned that earlier), but I recently ran into the same problem on a totally unrelated set of controls that were inherited from a baseclass form. It's easy to bla... |
318,644 | <p>I am new with Linq and I would like to sort some data that are in the BindingList. Once I did my Linq query, I need to use back the BindingList collection to bind my data.</p>
<pre><code> var orderedList = //Here is linq query
return (BindingList<MyObject>)orderedList;
</code></pre>
<p>This compiled but fai... | [
{
"answer_id": 318650,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 5,
"selected": true,
"text": "<pre><code>new BindingList<MyObject>(orderedList.ToList())\n</code></pre>\n"
},
{
"answer_id": 538957,
"au... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | I am new with Linq and I would like to sort some data that are in the BindingList. Once I did my Linq query, I need to use back the BindingList collection to bind my data.
```
var orderedList = //Here is linq query
return (BindingList<MyObject>)orderedList;
```
This compiled but fails in execution, what is the tri... | ```
new BindingList<MyObject>(orderedList.ToList())
``` |
318,649 | <p>Ok, so after spending a good portion of a day debugging a stupid typing mistake inside a piece of code I am curious as to why the specific actions occured rather than an exception.</p>
<p>First of all the problem code.</p>
<pre><code>Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.Instant... | [
{
"answer_id": 318863,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 2,
"selected": false,
"text": "<p>Some possible solutions^W ways of dealing with this situation:</p>\n\n<ol>\n<li>Fix the ulimit!!!</li>\n<li>Accept ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13279/"
] | Ok, so after spending a good portion of a day debugging a stupid typing mistake inside a piece of code I am curious as to why the specific actions occured rather than an exception.
First of all the problem code.
```
Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
Dim hl As ... | Google has a library for generating coredumps from inside a running process called [google-coredumper](http://code.google.com/p/google-coredumper/). This should ignore ulimit and other mechanisms.
The documentation for the call that generates the core file is [here](http://code.google.com/p/google-coredumper/wiki/Wri... |
318,666 | <p>I understand that any init... method initializes a new object and that NSString stringWithString makes a copy of the parameter string as a new object. I also understand that being the objects' owner, I can control the release/deallocation of any objects that I allocate. What I don't understand is when would I use th... | [
{
"answer_id": 318674,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 2,
"selected": false,
"text": "<p>The difference between initWithString and stringWithString is that stringWithString returns an auto-released pointer. This m... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9711/"
] | I understand that any init... method initializes a new object and that NSString stringWithString makes a copy of the parameter string as a new object. I also understand that being the objects' owner, I can control the release/deallocation of any objects that I allocate. What I don't understand is when would I use the s... | >
> What I don't understand is when would I use the stringWithString method since any local variable assigned that way would have it's memory "owned" by NSString instead of the local class.
>
>
>
What? No.
The rules are simple:
* Any object returned by `alloc`, `copy`, `copyWithZone`, or `new` has a retain count... |
318,675 | <p>Is there a way to allow a flex application to have a dynamic height while embedded in an HTML wrapper?</p>
<p>I want the Flex application to grow in height in a way that it will not cause vertical scroll bars.</p>
| [
{
"answer_id": 318684,
"author": "Ryan Guill",
"author_id": 7186,
"author_profile": "https://Stackoverflow.com/users/7186",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately no, I think the only way you could do this is to get rid of the html wrapper in the first place. HTH.</... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | Is there a way to allow a flex application to have a dynamic height while embedded in an HTML wrapper?
I want the Flex application to grow in height in a way that it will not cause vertical scroll bars. | I'm not sure I fully understand the question, are you trying to get the aplication to have a size larger than the browser's view port? If so, then as @hasseg commented and @RickDT mentioned, you can set the Application's horizontalScrollPolicy and/or verticalScrollPolicy properties to "off"?
If you're simply trying to... |
318,700 | <p>I am working with a set of data that I have converted to a list of dictionaries</p>
<p>For example one item in my list is </p>
<pre><code>{'reportDate': u'R20070501', 'idnum': u'1078099', 'columnLabel': u'2005',
'actionDate': u'C20070627', 'data': u'76,000', 'rowLabel': u'Sales of Bananas'}
</code></pre>
<p>Per ... | [
{
"answer_id": 318719,
"author": "rebra",
"author_id": 2282296,
"author_profile": "https://Stackoverflow.com/users/2282296",
"pm_score": 1,
"selected": false,
"text": "<p>Python does not retain order in dictionaries.<br>\nHowever, there is the <a href=\"http://docs.python.org/2/library/c... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30105/"
] | I am working with a set of data that I have converted to a list of dictionaries
For example one item in my list is
```
{'reportDate': u'R20070501', 'idnum': u'1078099', 'columnLabel': u'2005',
'actionDate': u'C20070627', 'data': u'76,000', 'rowLabel': u'Sales of Bananas'}
```
Per request
The second item in my l... | So what's wrong with pickle? If you structure your data as a list of dicts, then everything should work as you want it to (if I understand your problem).
```
>>> import pickle
>>> d1 = {1:'one', 2:'two', 3:'three'}
>>> d2 = {1:'eleven', 2:'twelve', 3:'thirteen'}
>>> d3 = {1:'twenty-one', 2:'twenty-two', 3:'twenty-thre... |
318,715 | <p>My webpage is suffering from two IE6 rendering bugs. Each of them have workarounds, but unfortunately said workarounds are incompatible with each other.</p>
<p><a href="http://www.control-v.net/stackoverflow/318715.html" rel="nofollow noreferrer">Here's a minimized test case</a>. The behavior in Firefox/Safari is t... | [
{
"answer_id": 319214,
"author": "cdeszaq",
"author_id": 20770,
"author_profile": "https://Stackoverflow.com/users/20770",
"pm_score": -1,
"selected": false,
"text": "<p>While it may be the wrong solution, and probably way overkill, jQuery can do modal popups similar to this and works on... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4160/"
] | My webpage is suffering from two IE6 rendering bugs. Each of them have workarounds, but unfortunately said workarounds are incompatible with each other.
[Here's a minimized test case](http://www.control-v.net/stackoverflow/318715.html). The behavior in Firefox/Safari is the desired/correct one. IE7 is unknown, since I... | There are a myriad of implementation as to how to avoid the massive issues with ie6 (and below) conformity. The only one that has actually worked for me (to a great extent even) is Dean Edward's solution.
Try to insert the following line in your main header:
```
<!--[if lt IE 8]><script src="http://ie7-js.googlecode... |
318,716 | <p>I just launched my <a href="http://www.dudlers.com" rel="noreferrer">tiny webapp</a> on my humble dedicated server (Win2003)... running ASP.NET MVC, LINQ2SQL, SQL Express 2005, and IIS6 (setup with <a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68e... | [
{
"answer_id": 318726,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>Sounds like maybe a race condition, or perhaps a <em>rare</em> bug that is only <em>correlated</em> with high traff... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2721/"
] | I just launched my [tiny webapp](http://www.dudlers.com) on my humble dedicated server (Win2003)... running ASP.NET MVC, LINQ2SQL, SQL Express 2005, and IIS6 (setup with [wildcard mapping](http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true))
Th... | We had a similar problem with LINQ that we get "Unable to cast object of type 'System.Int32' to type 'System.String'" and "Specified cast is not valid."
Examples of stacktraces
```
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
at System.Data.SqlClient.SqlBuffer.... |
318,742 | <p>I was using jQuery plugins to create a rounded corner for my <code><li></code>, but it was not working on a lot of browsers and didn't support mouse over.</p>
<p>I am wondering what is the best way to use two images (left corner and right corner) as the left and right side with using <code><li></code>.<... | [
{
"answer_id": 318754,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": -1,
"selected": true,
"text": "<p>You could put Divs inside your li's like so:</p>\n\n<pre><code><li>\n <div class=\"lefcorner\"></div&... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was using jQuery plugins to create a rounded corner for my `<li>`, but it was not working on a lot of browsers and didn't support mouse over.
I am wondering what is the best way to use two images (left corner and right corner) as the left and right side with using `<li>`. | You could put Divs inside your li's like so:
```
<li>
<div class="lefcorner"></div>
<div class='liContent'>Foo</div>
<div class='rightcorner'></div>
</li>
```
That way you will both keep your semantics and will also have the cross-browser support of styling DIVs. |
318,756 | <p>Lets say you have a:</p>
<pre><code>List<string> los = new List<string>();
</code></pre>
<p>In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these:</p>
<pre><code>String.Join(String.Empty, los.ToArray());
StringBuilder buil... | [
{
"answer_id": 318773,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 8,
"selected": false,
"text": "<p>I would go with option A:</p>\n\n<pre><code>String.Join(String.Empty, los.ToArray());\n</code></pre>\n\n<p>My reasoning i... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28717/"
] | Lets say you have a:
```
List<string> los = new List<string>();
```
In this crazy functional world we live in these days which one of these would be best for creating one string by concatenating these:
```
String.Join(String.Empty, los.ToArray());
StringBuilder builder = new StringBuilder();
los.ForEach(s => build... | I would go with option A:
```
String.Join(String.Empty, los.ToArray());
```
My reasoning is because the Join method was written for that purpose. In fact if you look at Reflector, you'll see that unsafe code was used to really optimize it. The other two also WORK, but I think the Join function was written for this p... |
318,761 | <p>As we all know, when we derive a class and use polymorphism, someone, somewhere needs to know what class to instanciate. We can use factories, a big switch statement, if-else-if, etc. I just learnt from Bill K this is called Dependency Injection.</p>
<p><strong>My Question: Is it good practice to use reflection and... | [
{
"answer_id": 318786,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 2,
"selected": false,
"text": "<p>My vote is that the reflection method is nicer. With that method, adding a new file format only modifies one part of th... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42/"
] | As we all know, when we derive a class and use polymorphism, someone, somewhere needs to know what class to instanciate. We can use factories, a big switch statement, if-else-if, etc. I just learnt from Bill K this is called Dependency Injection.
**My Question: Is it good practice to use reflection and attributes as t... | My personal preference is neither - when there is a mapping of classes to some arbitrary string, a configuration file is the place to do it IMHO. This way, you **never** need to modify the code - especially if you use a dynamic loading mechanism to add new dynamic libraries.
In general, I always prefer some method th... |
318,766 | <p>Here's the purpose of my console program: Make a web request > Save results from web request > Use QueryString to get next page from web request > Save those results > Use QueryString to get next page from web request, etc.</p>
<p>So here's some pseudocode for how I set the code up.</p>
<pre><code> for (int i = 0;... | [
{
"answer_id": 318824,
"author": "JB King",
"author_id": 8745,
"author_profile": "https://Stackoverflow.com/users/8745",
"pm_score": 0,
"selected": false,
"text": "<p>That URL doesn't quite make sense to me unless you are using MVC or something that can interpret the querystring correctl... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/557/"
] | Here's the purpose of my console program: Make a web request > Save results from web request > Use QueryString to get next page from web request > Save those results > Use QueryString to get next page from web request, etc.
So here's some pseudocode for how I set the code up.
```
for (int i = 0; i < 3; i++)
... | Have you tried creating a new WebRequest object for each time during the loop, it could be the Create() method isn't adequately flushing out all of its old data.
Another thing to check is that the ResponseStream is adequately flushed out before the next loop iteration. |
318,776 | <p>I have following POJOs:</p>
<pre><code>class Month {
long id;
String description;
List<Day> days; // always contains 29, 30 or 31 elements
}
class Day {
byte nr; // possible values are 1-31
String info;
}
</code></pre>
<p>Is there a way to store these objects into following DB structure ... | [
{
"answer_id": 340018,
"author": "Vilmantas Baranauskas",
"author_id": 11662,
"author_profile": "https://Stackoverflow.com/users/11662",
"pm_score": 0,
"selected": false,
"text": "<p>Here is one solution I found:</p>\n\n<pre><code>class Month {\n long id;\n String description;\n\n ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11662/"
] | I have following POJOs:
```
class Month {
long id;
String description;
List<Day> days; // always contains 29, 30 or 31 elements
}
class Day {
byte nr; // possible values are 1-31
String info;
}
```
Is there a way to store these objects into following DB structure using JPA+Hibernate:
Table MONT... | If you can't change your pojo's or table structure you are a bit screwed. If you can then a simple annotated pojo will work.
```
class Month {
@Id
private long id;
private String description;
@OneToMany(mappedBy="month",fetchType=Lazy)
private List<Day> days;
}
```
---- Surrogate key required DB cha... |
318,777 | <p>I am trying to map a virtual keycode to a char.</p>
<p>My code uses ProcessCmdKey to listen to WM_KEYDOWN which gives me access to the key pressed. For example, when I press single quote I get a key of 222 which I want to have it mapped to keychar 39 which represents... you guessed it... single quote.</p>
<p>My de... | [
{
"answer_id": 320878,
"author": "Horas",
"author_id": 12333,
"author_profile": "https://Stackoverflow.com/users/12333",
"pm_score": 5,
"selected": false,
"text": "<p>Yes, I did use the <code>MapVirtualKey</code> method. But I was expecting more details on how to use it: what <code>DllIm... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12333/"
] | I am trying to map a virtual keycode to a char.
My code uses ProcessCmdKey to listen to WM\_KEYDOWN which gives me access to the key pressed. For example, when I press single quote I get a key of 222 which I want to have it mapped to keychar 39 which represents... you guessed it... single quote.
My dev context is:
- ... | Isn't that what the [System.Windows.Form.KeysConverter](http://msdn.microsoft.com/en-us/library/system.windows.forms.keysconverter.aspx) class is for?
```
KeysConverter kc = new KeysConverter();
string keyChar = kc.ConvertToString(keyData);
``` |
318,789 | <p>Please note - I am not looking for the "right" way to open/read a file, or the way I should open/read a file every single time. I am just interested to find out what way most people use, and maybe learn a few new methods at the same time :)*</p>
<p>A very common block of code in my Perl programs is opening a file a... | [
{
"answer_id": 318822,
"author": "JSBձոգչ",
"author_id": 8078,
"author_profile": "https://Stackoverflow.com/users/8078",
"pm_score": 7,
"selected": true,
"text": "<p>There are no universal standards, but there are reasons to prefer one or another. My preferred form is this:</p>\n\n<pre><... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40619/"
] | Please note - I am not looking for the "right" way to open/read a file, or the way I should open/read a file every single time. I am just interested to find out what way most people use, and maybe learn a few new methods at the same time :)\*
A very common block of code in my Perl programs is opening a file and readin... | There are no universal standards, but there are reasons to prefer one or another. My preferred form is this:
```
open( my $input_fh, "<", $input_file ) || die "Can't open $input_file: $!";
```
The reasons are:
* You report errors immediately. (Replace "die" with "warn" if that's what you want.)
* Your filehandle is... |
318,793 | <p>Here are the errors:</p>
<pre>
$ perl ftper.pl
Use of uninitialized value $id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $id in hash el... | [
{
"answer_id": 318929,
"author": "Michael Carman",
"author_id": 8233,
"author_profile": "https://Stackoverflow.com/users/8233",
"pm_score": 3,
"selected": true,
"text": "<p>The error messages themselves are straightforward enough:</p>\n<blockquote>\n<p>Use of uninitialized value $id in h... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34531/"
] | Here are the errors:
```
$ perl ftper.pl
Use of uninitialized value $id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $id in hash element at /usr/lib/perl5/vendor_perl/5.1
/i686-cygwin/Tk/After.pm line 39.
se of uninitialized value $id in hash element at... | The error messages themselves are straightforward enough:
>
> Use of uninitialized value $id in hash element at ...Tk/After.pm line 39.
>
>
> Use of uninitialized value $id in delete at ...Tk/After.pm line 87.
>
>
>
* "Use of uninitialized value" means that you used a value with a value of `undef` (undefined).
... |