qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
242,565 | <p>I have MainViewController calling WebViewController (From UICatalog sample application)
In WebViewController I make some function setValue(){...} to set some value passed as parameter to the variable (NSString *value) from WebViewController.h but when I try from MainViewController something like WebViewController targetViewController...
targetViewController.setValue(value), it says: "<strong>error: request for member 'setValue' in something not s structure or union</strong>"...</p>
| [
{
"answer_id": 242638,
"author": "Kendall Helmstetter Gelner",
"author_id": 6330,
"author_profile": "https://Stackoverflow.com/users/6330",
"pm_score": 1,
"selected": false,
"text": "targetViewController.value = whatever;\n"
},
{
"answer_id": 242839,
"author": "Ben Gottlieb",... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16066/"
] |
242,568 | <p>By default, .NET application's configuration file is named after "exe file name".config. I'm wondering whether it is possible to have one application's configuration specified dynamically.</p>
<p>For example, the built application is "foo.exe". At runtime, the config file is "foo.exe.config". Is it possible to have it accept command line arguments to use other config file. So, the application can use other configuration like below.</p>
<blockquote>
<p>foo.exe /config:bar.config</p>
</blockquote>
<p>bar.config is used as config file insteand of foo.exe.config.</p>
| [
{
"answer_id": 242612,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 2,
"selected": false,
"text": "static void DisplayMappedExeConfigurationFileSections()\n{\n // Get the application configuration file path.\n string... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
242,570 | <p>I need to copy the content of a window (BitBlt) which is hidden, to another window. The problem is that once I hide the source window, the device context I got isn't painted anymore.</p>
| [
{
"answer_id": 242809,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 1,
"selected": false,
"text": "WM_PRINT"
},
{
"answer_id": 242837,
"author": "elifiner",
"author_id": 15109,
"author_profile":... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
242,577 | <p>I've tried reading a JPG file using the <code>StreamReader</code> class' <code>ReadToEnd()</code> method which returns a string.</p>
<p>For some reason though, when I write this string out to a file, it doesn't open.</p>
<p>Is something lost when reading data into a string?</p>
| [
{
"answer_id": 242583,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "byte[]"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] |
242,579 | <p>I have a long URL with tons of parameters that I want to open in the default browser from Java on a Windows system using</p>
<pre><code>Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+url)
</code></pre>
<p>For short URLs like "<a href="http://www.google.com" rel="nofollow noreferrer">http://www.google.com</a>" this works fine. But for long URLs (say, 2000 characters), this simply does absolutely nothing at all: no exception or anything of the sort, it is simply ignored.</p>
<p>Is there a character limit a) for a Runtime.exec command or b) for the rundll32 url.dll command? If so, what is the limit?</p>
| [
{
"answer_id": 244342,
"author": "John Gardner",
"author_id": 13687,
"author_profile": "https://Stackoverflow.com/users/13687",
"pm_score": 0,
"selected": false,
"text": "MAX_PATH"
},
{
"answer_id": 248384,
"author": "James Van Huis",
"author_id": 31828,
"author_profi... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
242,600 | <p>This is probably a simple question but how can I best use an AJAX loader in ASP.NET to provide a loading dialog whilst the page is being built?</p>
<p>I currently have an UpdatePanel with an associated UpdateProgressPanel which contains the loading message and gif in a ProgressTemplate. </p>
<p>Currently I have a page that onLoad() goes and gets the business entities and then displays them. While it is doing this I would like to display an AJAX loader. </p>
<p>Would it be better to have nothing in the page load and have a hidden button that is triggered onLoadComplete or unLoad() which would then wait for the button click method to complete displaying the UpdateProgressPanel? </p>
| [
{
"answer_id": 2891484,
"author": "Shripad Krishna",
"author_id": 277537,
"author_profile": "https://Stackoverflow.com/users/277537",
"pm_score": 0,
"selected": false,
"text": "div"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] |
242,602 | <p>Is it possible to make a POST request from Ruby with open-uri?</p>
| [
{
"answer_id": 242637,
"author": "Martin Kenny",
"author_id": 6111,
"author_profile": "https://Stackoverflow.com/users/6111",
"pm_score": 6,
"selected": true,
"text": "open-uri"
},
{
"answer_id": 8495402,
"author": "Venkat D.",
"author_id": 67655,
"author_profile": "h... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8338/"
] |
242,608 | <p>Is it possible to disable the browsers vertical and horizontal scrollbars using jQuery or javascript?</p>
| [
{
"answer_id": 242615,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 6,
"selected": false,
"text": "<body style=\"overflow: hidden\">\n"
},
{
"answer_id": 242684,
"author": "Alexander Prokofyev",
"author_id"... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17447/"
] |
242,609 | <p>As everyone knows, sometimes developers have to document stuff. Or capture some stuff for filing bug reports. </p>
<p>My question is in MS Windows.</p>
<p>I'm trying to capture the context menu (the popup menu that appears after right-clicking an item) of several areas of an application. Pressing <kbd>Alt</kbd> to start the <kbd>Alt</kbd>+<kbd>PrintScreen</kbd> process closes the context menu.</p>
<p>(Only pressing <kbd>PrintScreen</kbd> helps, but it's painful to remove the non-window areas everytime).</p>
<p>BONUS: For capturing menus, <kbd>Alt</kbd> also closes the menu. However, if you use the <kbd>Alt</kbd> key to open the menu in the first place, it works:</p>
<ol>
<li>Press <kbd>Alt</kbd>+<kbd>F</kbd> (for opening the "File"
menu), don't release <kbd>Alt</kbd></li>
<li>Press <kbd>PrintScreen</kbd></li>
<li>Tada!</li>
</ol>
| [
{
"answer_id": 26074872,
"author": "Smile4ever",
"author_id": 1798408,
"author_profile": "https://Stackoverflow.com/users/1798408",
"pm_score": 0,
"selected": false,
"text": "scrot -d 5 'contextmenuincluded.png' -e 'mv $f ~'\n"
},
{
"answer_id": 38007326,
"author": "claudio",... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26374/"
] |
242,614 | <p>A classic ASP.NET app - AppSrv + MS SQL DB. Both servers are heavy-lifters 8 cores, 20 GB of RAM. When load testing, the throughput goes somewhere to 400 VirtualUsers (according to LoadRunner) with CPU being approximately 30% utilized an DB server primarily idling - response times go dramatically up, to the point of unresponsive.</p>
<p>The usual suspects, such as Max Pool being exhausted and conn limit on ASP.NET set are not at fault: Max Pool is set to 200 and about 80 conns are used; conn limit is set to 0. </p>
<p>I ran with ANTS profiler the code and it showed that Thread blocking did not contribute significantly. </p>
<p>Ideas very very welcome!</p>
| [
{
"answer_id": 242631,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 1,
"selected": true,
"text": "An Application Pool -> Performance -> \nWeb Garden -> Max Number of worker processes\n"
},
{
"answer_id": 243460,
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29573/"
] |
242,617 | <p>Posting a stack overflow question on stackoverflow.com, how amusing :-)</p>
<p>I'm running some recursive Ruby code and I get the: <code>"Stack level too deep (SystemStackError)"</code></p>
<p>(I'm quite sure the code works, that I'm not in an infinite recursive death spiral, but that is not the point anyway)</p>
<p>Is there anyway to change the allowed stack depth/size for my Ruby app?</p>
<p>I don't quite get it if this is a restriction in Ruby, since the error says "Stack level", which gives me the impression that Ruby somehow counts 'levels' of stack, or if it simply means that the stack is full.</p>
<p>I have tried running this program under both Vista and Ubuntu with same result.
Under Ubuntu i tried changing the stack size with 'ulimit -s' from 8192 to 16000, but that didn't change anything.</p>
<p>Edit:
Thanks for the feedback.<br>
I do realize that using a recursive function perhaps isn't the most robust way to go.
But that isn't the point either.
I simply wonder if there is a way to increase the stack size.. period.
And as I mentioned i did try running ulimit -s 16000 before running the ruby script.. with no improvement.. Am I using it wrong?</p>
<p>Edit2:
I was in fact having an infinite recursion in an edge case of the code. <br>The truncated ruby stack trace when you get the <code>"Stack level too deep"</code> error is a bit misleading. <br>When having a recursive behavior involving several functions, you get the impression that the numbers of recursions is much lower than it actually is. In this example one might thing that it crashes after little bit more than 190 calls, but it is actually around 15000 calls</p>
<pre><code>tst.rb:8:in `p': stack level too deep (SystemStackError)
from tst.rb:8:in `bar'
from tst.rb:12:in `bar'
from tst.rb:19:in `foo'
from tst.rb:10:in `bar'
from tst.rb:19:in `foo'
from tst.rb:10:in `bar'
from tst.rb:19:in `foo'
from tst.rb:10:in `bar'
... 190 levels...
from tst.rb:19:in `foo'
from tst.rb:10:in `bar'
from tst.rb:19:in `foo'
from tst.rb:22
</code></pre>
<p>-Andreas</p>
| [
{
"answer_id": 244348,
"author": "Honza",
"author_id": 8621,
"author_profile": "https://Stackoverflow.com/users/8621",
"pm_score": 4,
"selected": false,
"text": "def recursive(params)\n if some_conditions(params)\n recursive(update_params(params))\n end\nend\n\nrecursive(starting_p... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28625/"
] |
242,621 | <p>I'm having trouble running a complex query against our company LDAP server. I'm using the following Perl script:</p>
<pre><code>use Data::Dumper;
use Net::LDAP;
die "Can't connect to LDAP-Server: $@\n"
unless $ldap = Net::LDAP->new( 'xLDAPx' );
foreach my $filter ( 'ou=Personal', 'ou=BAR', 'ou=Personal,ou=BAR', 'ou=Personal,ou=FOO,o=FOO,dc=foo,dc=com' )
{
$mesg = $ldap->search( base => "o=FOO,dc=foo,dc=com", filter => $filter );
print Dumper($mesg), "\n\n";
}
</code></pre>
<p>While the first two filters work (as in returning the expected values) the last and complex one doesn't. It returns an empty array. What really puzzles me is that exactly the same query string works when I use it with a tool like the Softerra LDAP Browser. </p>
<p>I have also tried the same query using PHP's <code>ldap_search</code> & co, no avail.</p>
<p>Can somebody shed some light on this?</p>
<p>Thanks for reading</p>
<p>holli</p>
<p>Edit:
This is the structure of the server:</p>
<pre><code>Server
ou=FOO
ou=...
ou=Personal
uid=something
</code></pre>
<p>I need a list of uids.</p>
| [
{
"answer_id": 242779,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 4,
"selected": true,
"text": "(&(ou=Personal)(ou=FOO)(o=FOO)(dc=foo)(dc=com))"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18606/"
] |
242,627 | <pre><code>today1 = new Date();
today2 = Date.parse("2008-28-10");
</code></pre>
<p>To compare the time (millisecond) values of these I have to do the following, because today2 is just a number.</p>
<pre><code>if (today1.getTime() == today2)
</code></pre>
<p>Why is this?</p>
| [
{
"answer_id": 242632,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 2,
"selected": false,
"text": "var newDate = new Date();\nnewDate.setFullYear(2008,9,28);\n"
},
{
"answer_id": 242679,
"author": "Tomalak"... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] |
242,629 | <p>Whilst investigating a memory leak I discovered that it was caused by calling NewRow() on a Table inside a loop many times. However the DataRow created was never added to the Table Rows collection and the Table Rows Count never got above zero.</p>
<p>My question is why does this use up more memory every time NewRow is called even though the newly created DataRow never gets added to the Rows collection and the DataRow returned from NewRow is always assigned to the same local variable (thereby apparently discarding the last new row).</p>
<p>Please ignore the issue of why the code is creating DataRows that don't get added to the table!</p>
| [
{
"answer_id": 51299108,
"author": "Ден Денис",
"author_id": 5945461,
"author_profile": "https://Stackoverflow.com/users/5945461",
"pm_score": 0,
"selected": false,
"text": " var table = new DataTable();\n while (true)\n {\n var newRow = table.NewRow();\n table.Row... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1127460/"
] |
242,640 | <p>I wanna see if there is an approach to pack a few plugins together as a meta plugin that install everything together automatically, works like a project template.</p>
<p>Why not a script? Because I want to put it in github so I don't have to worry about it when I am not with my own PC :) but of coz a script based solution is welcomed too.</p>
| [
{
"answer_id": 243330,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 1,
"selected": false,
"text": "plugins = %w{\n http://url_to_plugin_1\n http://url_to_plugin_2\n http://url_to_plugin_3\n http://url_to_plugin_... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] |
242,646 | <p>How can I use vimdiff to view the differences described in a diff file?</p>
| [
{
"answer_id": 242680,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 2,
"selected": false,
"text": "vimdiff original_file patched_file\n"
},
{
"answer_id": 244766,
"author": "ephemient",
"author_id": 20713,
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14437/"
] |
242,647 | <p>I have one aspx page with some controls.
Also i have one DIV which is dynamically populated from AJAX call.
This AJAX call return couple of controls, for example HtmlInputText1 and HtmlInputText2.</p>
<p>When page is submitted, I can get values from this controls through Request.Form.
If possible access to the attributes of this control on pege code behind (for example HtmlInputText1.Height, etc). </p>
<p>I think that is impossible, but I am not sure.
I can use hidden field. Is any other way?</p>
| [
{
"answer_id": 242692,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 2,
"selected": true,
"text": "<script language=\"javascript\" type=\"text/javascript\">\nfunction changeValue() {\n var txtControlClient = document.get... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17465/"
] |
242,648 | <p>The size of the generated hash and the speed of the algorithm are not important. I'm really only interested in it being the most secure option. I don't want to use any third party libraries either.</p>
<p>The version of the .NET framework I'm using if 3.5 if that makes any difference.</p>
| [
{
"answer_id": 11828962,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 4,
"selected": false,
"text": "SHA512"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6369/"
] |
242,665 | <p>I'm trying to set up a basic test of HMAC-SHA-256 hashing but I'm having problems with the engine setup. Ideally I would like to set up only the HMAC-SHA-algorithm but so far I haven't even gotten the general case where load all the algorithms to work. Currently I'm getting segfaults on the row where I try to set the default digests.</p>
<p>Also, I'm regularly a Java guy, so don't hesitate to point out any mistakes in the code.</p>
<pre><code>#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
unsigned char* key = (unsigned char*) "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";
unsigned char* data = (unsigned char*) "4869205468657265";
unsigned char* expected = (unsigned char*) "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7";
unsigned char* result;
HMAC_CTX* ctx;
ENGINE* e;
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
ENGINE_set_default_digests(e);
HMAC_CTX_init(ctx);
HMAC_Init_ex(ctx, key, 40, EVP_sha256(), e);
result = HMAC(NULL, NULL, 40, data, 16, NULL, NULL);
HMAC_CTX_cleanup(ctx);
ENGINE_finish(e);
ENGINE_free(e);
if (strcmp((char*) result, (char*) expected) == 0) {
printf("Test ok\n");
} else {
printf("Got %s instead of %s\n", result, expected);
}
}
</code></pre>
<p>EDIT: The program has now evolved to the following, but I'm still segfaulting at <code>HMAC_Init_ex</code>:</p>
<pre><code>unsigned char* key = (unsigned char*) "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b";
unsigned char* data = (unsigned char*) "4869205468657265";
unsigned char* expected = (unsigned char*) "b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7";
unsigned char* result;
unsigned int result_len = 64;
HMAC_CTX ctx;
ENGINE* e;
result = (unsigned char*) malloc(sizeof(char) * result_len);
e = (ENGINE*) ENGINE_new();
ENGINE_load_builtin_engines();
ENGINE_register_all_complete();
ENGINE_set_default_digests(e);
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, key, 16, EVP_sha256(), e);
HMAC_Update(&ctx, data, 40);
HMAC_Final(&ctx, result, &result_len);
HMAC_CTX_cleanup(&ctx);
ENGINE_finish(e);
ENGINE_free(e);
</code></pre>
| [
{
"answer_id": 242687,
"author": "Martin Kenny",
"author_id": 6111,
"author_profile": "https://Stackoverflow.com/users/6111",
"pm_score": 0,
"selected": false,
"text": "e"
},
{
"answer_id": 244310,
"author": "Fylke",
"author_id": 30059,
"author_profile": "https://Stac... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30059/"
] |
242,695 | <p>I have seen C# code that uses the <code>@</code> to tell the compiler the string has newlines in it and that it should be all in one line.
Is there something like that for C/C++?</p>
<p>Like if I want to put something like:</p>
<p>73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450</p>
<p>In a string I don't want to place it all in one line but just put it like that and have the compiler know that that is only one line.</p>
| [
{
"answer_id": 242702,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "\"73167176531330624919225119674426574742355349194934\"\n\"96983520312774506326239578318016984801869478851843\" \n\"85861... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] |
242,697 | <p>For a load test of my application (under Linux), I'm looking for a tool that outputs data on stdout at a specific rate (like 100 bytes/s), so that I can pipe the output to netcat which sends it to my application. Some option for dd would be ideal, but I didn't find anything so far. It doesn't really matter what kind of data is printed (NUL bytes are OK). Any hints?</p>
| [
{
"answer_id": 242703,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "sleep"
},
{
"answer_id": 242799,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://S... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148773/"
] |
242,698 | <p>I am trying to write a replacement regular expression to surround all words in quotes except the words AND, OR and NOT. </p>
<p>I have tried the following for the match part of the expression:</p>
<pre><code>(?i)(?<word>[a-z0-9]+)(?<!and|not|or)
</code></pre>
<p>and </p>
<pre><code>(?i)(?<word>[a-z0-9]+)(?!and|not|or)
</code></pre>
<p>but neither work. The replacement expression is simple and currently surrounds all words.</p>
<pre><code>"${word}"
</code></pre>
<p>So </p>
<blockquote>
<p>This and This not That</p>
</blockquote>
<p>becomes </p>
<blockquote>
<p>"This" and "This" not "That"</p>
</blockquote>
| [
{
"answer_id": 242716,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "(?<!\\b(?:and| or|not))\\b(?!(?:and|or|not)\\b)\n"
},
{
"answer_id": 242730,
"author": "Marc Gravell",
"aut... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33/"
] |
242,701 | <p>Which SQL statement is faster?</p>
<pre><code>SELECT TOP 2 c1.Price, c2.Price, ..... c49.Price, c50.Price
FROM Table1 AS c1, Table2 AS c2, ..... Table49 AS c49, Table50 AS c50
WHERE c1.Date = c2.Date AND c2.Date = c3.Date ..... c49.Date = c50.Date
ORDER BY c1.ID DESC
OR
SELECT TOP 2 c1.Price, c2.Price, ..... c49.Price, c50.Price
FROM (Table1 AS c1
INNER JOIN (Table2 AS c2
........
INNER JOIN (Table49 AS c49
INNER JOIN Table50 AS c50
ON c49.Date = c50.Date)
........
ON c2.FullDate__ = c3.FullDate__)
ON c1.FullDate__ = c2.FullDate__)
ORDER BY c1.ID DESC";
</code></pre>
<p>Basically I need to extract 2 rows from each table to produce a summary periodically.
Which statement is faster?</p>
| [
{
"answer_id": 242732,
"author": "Ruben",
"author_id": 26919,
"author_profile": "https://Stackoverflow.com/users/26919",
"pm_score": 0,
"selected": false,
"text": "select * \n from A a \n join B b on b.x = a.y \n where b.z = 'ok';\n"
},
{
"answer_id": 245154,... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32012/"
] |
242,711 | <p>I think this must be simple but I can't get it right...</p>
<p>I have an MxM triangular matrix, the coefficients of which are stored in a vector, row by row.
For example:</p>
<pre><code>M = [ m00 m01 m02 m03 ]
[ m11 m12 m13 ]
[ m22 m23 ]
[ m33 ]
</code></pre>
<p>is stored as </p>
<pre><code>coef[ m00 m01 m02 m03 m11 m12 m13 m22 m23 m33 ]
</code></pre>
<p>Now I'm looking for a non-recursive algorithm that gives me for matrix size <code>M</code> and coefficient array index <code>i</code></p>
<pre><code>unsigned int row_index(i,M)
</code></pre>
<p>and </p>
<pre><code>unsigned int column_index(i,M)
</code></pre>
<p>of the matrix element that it refers to. So,
<code>row_index(9,4) == 3</code>, <code>column_index(7,4) == 2</code> etc. if the index counting is zero-based.</p>
<p>EDIT: Several replies using an iteration have been given. Does anyone know of algebraic expressions?</p>
| [
{
"answer_id": 242919,
"author": "João Augusto",
"author_id": 6909,
"author_profile": "https://Stackoverflow.com/users/6909",
"pm_score": 0,
"selected": false,
"text": "unsigned int row_index(int i, int m)\n{\n int iCurrentRow = 0;\n int iTotalItems = 0;\n for(int j = m; j > 0; ... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] |
242,718 | <p>How do you split a string?</p>
<p>Lets say i have a string "dog, cat, mouse,bird"</p>
<p>My actual goal is to insert each of those animals into a listBox, so they would become items in a list box.</p>
<p>but i think i get the idea on how to insert those items if i know how to split the string. or does anyone know a better way to do this?</p>
<p>im using asp c#</p>
| [
{
"answer_id": 242724,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 4,
"selected": true,
"text": " string[] tokens = text.Split(',');\n\n for (int i = 0; i < tokens.Length; i++)\n {\n yourListBox.Add(new Li... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23491/"
] |
242,728 | <p>I've been involved in developing coding standards which were quite elaborate. My own experience is that it was hard to enforce if you don't have proper processes to maintain it and strategies to uphold it.</p>
<p>Now I'm working in, and leading, an environment even less probable to have processes and follow-up strategies in quite a while. Still I want to uphold some minimum level of respectable code. So I thought I would get good suggestions here, and we might together produce a reasonable light-weight subset of the most important coding standard practices for others to use as reference.</p>
<p>So, to emphasize the essence here:</p>
<h2> <strong>What elements of a C++ coding standard are the most crucial to uphold?</strong></h2>
<ul>
<li><h2>Answering/voting rules</h2>
<ul>
<li><p>1 candidate per answer, preferably with a <strong>brief</strong> motivation.</p></li>
<li><p><strong>Vote down</strong> candidates which focuses on style and subjective formatting guidelines. This is not to indicate them as unimportant, only that they are less relevant in this context. </p></li>
<li><p><strong>Vote down</strong> candidates focusing on how to comment/document code. This is a larger subject which might even deserve its own post.</p></li>
<li><p><strong>Vote up</strong> candidates that clearly facilitates safer code, which minimizes the risk of enigmatic bugs, which increases maintainability, etc.</p></li>
<li><p><strong>Don't cast your vote</strong> in any direction on candidates you are uncertain about. Even if they sound reasonable and smart, or on the contrary "something surely nobody would use", your vote should be based on clear understanding and experience.</p></li>
</ul></li>
</ul>
| [
{
"answer_id": 242815,
"author": "Frederik Slijkerman",
"author_id": 12416,
"author_profile": "https://Stackoverflow.com/users/12416",
"pm_score": 1,
"selected": false,
"text": "if (bla) {\n for (int i = 0; i < n; ++i)\n foo();\n}\n"
},
{
"answer_id": 242821,
"author": "F... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] |
242,744 | <p>Recently developers highlighted that it is bit hard for them to keep track of which document has been updated. And they thus suggested that using SVN to keep track of document changes will be better as they will be able to know if document if being updated when doing checking out of the project. </p>
<p>But i also highlighted the several cons that may occur</p>
<ul>
<li>Binary file using up alot of diskspace everytime word, excel document is commited</li>
<li>Checkout a project will take much more time although we can separate the documents into another project in the repository</li>
<li>It will take time to teach personnel on how to use SVN.</li>
</ul>
<p>Another feature is that for these kind of functional documents, it should be locked while editing.</p>
<p>Anyone have any idea on how to go about it? Or what are the pros and cons to it. Please feel free to share with me.</p>
| [
{
"answer_id": 242757,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "svn:needs-lock"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25368/"
] |
242,745 | <p>When I add the textBox.TextChanged to watch list I get a message saying <pre>The event 'System.Windows.Forms.Control.TextChanged'
can only appear on the left hand side of += or -=</pre></p>
<p>Is there any way to check what event's are called on text change?</p>
| [
{
"answer_id": 242757,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "svn:needs-lock"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1534/"
] |
242,749 | <p>My account is in the securityadmin role and I cannot grant myself sysadmin permission. I wish to gain access to a database so I can add my account to a particular role within it. <br />
As I don't yet have access to the database I can't use the UI.</p>
<p>Does anyone know if this is possible and what SQL commands will achieve this in SQL Server 2005? <br />Thanks!</p>
| [
{
"answer_id": 242778,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 0,
"selected": false,
"text": "EXEC sp_addsrvrolemember 'BUILTIN\\Administrators', 'sysadmin'\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] |
242,752 | <p>I'm looking to force my application to shut down, and return an Exit code. Had a look on MSDN and I can see that in WPF the Application has a Shutdown method which takes an error code as a parameter, but there doesn't appear to be one for System.Windows.Forms.Application.</p>
<p>I can see Application.Exit() but not a way to pass back an error code.</p>
<p>Does anyone know off-hand if this is possible?</p>
<p>Thanks</p>
| [
{
"answer_id": 242762,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 2,
"selected": false,
"text": "System.Environment.ExitCode = 1\nApplication.Exit()\n"
},
{
"answer_id": 242783,
"author": "Hallgrim",
"aut... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] |
242,756 | <p>There is div named "dvUsers". there is an anchor tag "lnkUsers".</p>
<p>When one clicks on anchortag, the div must open like a popup div just below it.</p>
<p>Also the divs relative position should be maintained at window resize and all.
How to do that using javascript/jquery?</p>
| [
{
"answer_id": 242788,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function(){ $(\"#lnkUsers\").click(function(){ $(\"#dvUser\").show(\"slow\"); });\n"
},
{
"answer... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17447/"
] |
242,766 | <p>Recently I've been seeing a lot of this:</p>
<pre><code><a href='http://widget-site-example.com/example.html'>
<img src='http://widget-site-example.com/ross.jpg' alt='Ross&#39;s Widget' />
</a>
</code></pre>
<p>Is it valid to use single quotes in HTML? As I've highlighted above it's also problematic because you have to escape apostrophes.</p>
| [
{
"answer_id": 242784,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 6,
"selected": false,
"text": "String.Format(\"<a href='{0}'>{1}</a>\", Url, Desc)\n"
},
{
"answer_id": 242790,
"author": "Dean Rather",
"aut... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] |
242,771 | <p>How can I create an Oracle stored procedure which accepts a variable number of parameter values used to feed a IN clause?</p>
<p>This is what I am trying to achieve. I do not know how to declare in PLSQL for passing a variable list of primary keys of the rows I want to update.</p>
<pre><code>FUNCTION EXECUTE_UPDATE
( <parameter_list>
value IN int)
RETURN int IS
BEGIN
[...other statements...]
update table1 set col1 = col1 - value where id in (<parameter_list>)
RETURN SQL%ROWCOUNT ;
END;
</code></pre>
<p>Also, I would like to call this procedure from C#, so it must be compatible with .NET capabilities. </p>
<p>Thanks,
Robert</p>
| [
{
"answer_id": 242776,
"author": "RB.",
"author_id": 15393,
"author_profile": "https://Stackoverflow.com/users/15393",
"pm_score": -1,
"selected": false,
"text": "CREATE Function dbo.CsvToInt ( @Array varchar(1000)) \nreturns @IntTable table \n (IntValue nvarchar(100))\nAS\nbegin\n\n ... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5970/"
] |
242,772 | <p>Is it possible to change the destination port of a UDP packet using iptables?</p>
<p>I'm trying to get an SNMP agent to send out traps on 1620 instead of 162. Unfortunately so far I've only managed to change the source port:</p>
<blockquote>
<p>iptables -t nat -A POSTROUTING -p udp
--dport 162 -j SNAT --to :1620</p>
</blockquote>
| [
{
"answer_id": 243116,
"author": "PiedPiper",
"author_id": 19315,
"author_profile": "https://Stackoverflow.com/users/19315",
"pm_score": 3,
"selected": false,
"text": "iptables -t nat -A OUTPUT -p udp --dport 162 -j DNAT --to-destination <dest-ip>:1620\n"
},
{
"answer_id": 286566... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1466/"
] |
242,792 | <p>I need to write a regular expression that finds javascript files that match </p>
<pre><code><anypath><slash>js<slash><anything>.js
</code></pre>
<p>For example, it should work for both :</p>
<ul>
<li>c:\mysite\js\common.js (Windows)</li>
<li>/var/www/mysite/js/common.js (UNIX)</li>
</ul>
<p>The problem is that the file separator in Windows is not being properly escaped :</p>
<pre><code>pattern = Pattern.compile(
"^(.+?)" +
File.separator +
"js" +
File.separator +
"(.+?).js$" );
</code></pre>
<p>Throwing </p>
<pre><code>java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence
</code></pre>
<p>Is there any way to use a common regular expression that works in both Windows and UNIX systems ?</p>
| [
{
"answer_id": 242803,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "Pattern.quote(File.separator)"
},
{
"answer_id": 242806,
"author": "heijp06",
"author_id": 1793417,
"au... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] |
242,812 | <p>I've created a series of radio button controls in C#. <code>(radCompany, radProperty etc.)</code><br>
I've set their group name to be the same (282_Type) so they function as a list of radio buttons. </p>
<p>How do I retrieve the name <code>(like: ct100$m$dfgadjkfasdghasdkjfg$282_Type)</code> in c# so I can use this in a Javascript method i'm creating?</p>
<p>The values output are: </p>
<pre><code>Radion Button 1
id="ct223423432243_radCompany" name="ct100$sdfsdf$sdfsdf$282_Type"
Radion Button 2
id="ct223423432243_radProperty" name="ct100$sdfsdf$sdfsdf$282_Type"
</code></pre>
| [
{
"answer_id": 242835,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "var x = $('[name=radioGroup]:checked').val();\n"
},
{
"answer_id": 6702310,
"author": "Dallas Morrison",
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13911/"
] |
242,813 | <p><code>console.log("double");</code> vs. <code>console.log('single');</code></p>
<p>I see more and more JavaScript libraries out there using single quotes when handling strings. What are the reasons to use one over the other?</p>
<p>I thought they're pretty much interchangeable.</p>
| [
{
"answer_id": 242833,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 11,
"selected": true,
"text": "alert('Say \"Hello\"');\nalert(\"Say 'Hello'\");\n"
},
{
"answer_id": 244842,
"author": "Gareth",
"author_id":... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28150/"
] |
242,822 | <p>Why would someone use <code>WHERE 1=1 AND <conditions></code> in a SQL clause (Either SQL obtained through concatenated strings, either view definition)</p>
<p>I've seen somewhere that this would be used to protect against SQL Injection, but it seems very weird.</p>
<p>If there is injection <code>WHERE 1 = 1 AND injected OR 1=1</code> would have the same result as <code>injected OR 1=1</code>.</p>
<p>Later edit: What about the usage in a view definition?</p>
<hr>
<p>Thank you for your answers.</p>
<p>Still,
I don't understand why would someone use this construction for defining a view, or use it inside a stored procedure.</p>
<p>Take this for example:</p>
<pre><code>CREATE VIEW vTest AS
SELECT FROM Table WHERE 1=1 AND table.Field=Value
</code></pre>
| [
{
"answer_id": 242831,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 10,
"selected": true,
"text": "and <condition>\n"
},
{
"answer_id": 242867,
"author": "Eduardo Molteni",
"author_id": 2385,
"author_... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23795/"
] |
242,841 | <p>Do you think there is a big difference in for...in and for loops? What kind of "for" do you prefer to use and why?</p>
<p>Let's say we have an array of associative arrays:</p>
<pre><code>var myArray = [{'key': 'value'}, {'key': 'value1'}];
</code></pre>
<p>So we can iterate:</p>
<pre><code>for (var i = 0; i < myArray.length; i++)
</code></pre>
<p>And:</p>
<pre><code>for (var i in myArray)
</code></pre>
<p>I don't see a big difference. Are there any performance issues?</p>
| [
{
"answer_id": 242888,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 10,
"selected": true,
"text": "for (var i = 0; i < a.length; i++)\n //do stuff with a[i]\n"
},
{
"answer_id": 242893,
"author": "Gene... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17375/"
] |
242,908 | <p>Due to the nature of the live server I deploy to, my mail settings are using deliveryMethod="PickupDirectoryFromIis". I'm using log4net to send logs via email and I need find a way of getting it to do the same thing.</p>
<p>I can see from the docs that there is an SmtpPickupDirAppender, which has a pickupDir setting. If I set this to whatever pickup directory IIS uses, I'm sure everything will work OK. However what I really want is to just tell log4net to use IIS's setting and leave it there. That way if it ever changes we won't have to change the log4net config too, something we're likely to forget. Is there a way to do this?</p>
| [
{
"answer_id": 242964,
"author": "Leandro López",
"author_id": 22695,
"author_profile": "https://Stackoverflow.com/users/22695",
"pm_score": 0,
"selected": false,
"text": "SmtpClient.DeliveryMethod"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/242908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12277/"
] |
242,913 | <p>We can see in a directory files ordered by Name in Windows Explorer.</p>
<p>If I try the same thing in the Windows command prompt it orders by name differently - <em>correctly</em>:</p>
<pre><code>dir *.jpg /ON /B
cubierta.jpg
pag00.jpg
pag06.jpg
pag08.jpg
pag09.jpg
pag100.jpg
pag101.jpg
pag102.jpg
pag103.jpg
pag104.jpg
pag105.jpg
pag106.jpg
pag107.jpg
pag108.jpg
pag109.jpg
pag11.jpg, etc, etc, etc, ...
</code></pre>
<p>Is there a way to get <code>dir</code> to order by Name where it reads the numbers as a human would do?</p>
| [
{
"answer_id": 243575,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "sort"
},
{
"answer_id": 352087,
"author": "ian_scho",
"author_id": 15530,
"author_profile": "https://Stac... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15530/"
] |
242,914 | <p>Is it possible in plain JPA or JPA+Hibernate extensions to declare a composite key, where an element of the composite key is a sequence?</p>
<p>This is my composite class:</p>
<pre><code>@Embeddable
public class IntegrationEJBPk implements Serializable {
//...
@ManyToOne(cascade = {}, fetch = FetchType.EAGER)
@JoinColumn(name = "APPLICATION")
public ApplicationEJB getApplication() {
return application;
}
@Column(name = "ENTITY", unique = false, nullable = false, insertable = true, updatable = true)
public String getEntity() {
return entity;
}
@GeneratedValue(strategy = GenerationType.AUTO, generator = "INTEGRATION_ID_GEN")
@SequenceGenerator(name = "INTEGRATION_ID_GEN", sequenceName = "OMP_INTEGRATION_CANONICAL_SEQ")
@Column(name = "CANONICAL_ID", unique = false, nullable = false, insertable = true, updatable = true)
public String getCanonicalId() {
return canonicalId;
}
@Column(name = "NATIVE_ID", unique = false, nullable = false, insertable = true, updatable = true)
public String getNativeId() {
return nativeId;
}
@Column(name = "NATIVE_KEY", unique = false, nullable = false, insertable = true, updatable = true)
public String getNativeKey() {
return nativeKey;
}
//...
}
</code></pre>
<p>I already supply the values for <code>application</code>, <code>entity</code>, <code>nativeId</code> and <code>nativeKey</code>. I want to construct an entity like the one below:</p>
<pre><code>IntegrationEJB i1 = new IntegrationEJB();
i1.setIntegrationId(new IntegrationEJBPk());
i1.getIntegrationId().setApplication(app1);
i1.getIntegrationId().setEntity("Entity");
i1.getIntegrationId().setNativeId("Nid");
i1.getIntegrationId().setNativeKey("NK");
</code></pre>
<p>And when I call <code>em.persist(i1</code>), I want that the <code>canonicalId</code> is generated and the integration is inserted.</p>
<p>Is this possible? If so, what's the simple way? (I prefer not to use application-provided keys or native sql).</p>
| [
{
"answer_id": 244051,
"author": "sakana",
"author_id": 28921,
"author_profile": "https://Stackoverflow.com/users/28921",
"pm_score": 1,
"selected": false,
"text": "@TableGenerator(name = \"canonicalKeys\", allocationSize = 1, initialValue = 1)\n@GeneratedValue(strategy = GenerationType.... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22992/"
] |
242,926 | <p>I know there are already a few questions regarding recommendations for C++ unit test frameworks, but all the answers did not help as they just recommend one of the frameworks but do not provide any information about a (feature) comparison.</p>
<p>I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has anybody done any comparison yet?</p>
| [
{
"answer_id": 3565689,
"author": "Wernight",
"author_id": 167897,
"author_profile": "https://Stackoverflow.com/users/167897",
"pm_score": 7,
"selected": false,
"text": "#include <gtest/gtest.h>\n\nTEST(MyTestSuitName, MyTestCaseName) {\n int actual = 1;\n EXPECT_GT(actual, 0);\n ... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32030/"
] |
242,975 | <p>I have a problem, and was hoping I could rely on some of the experience here for advice and a push in the right direction. I have an MS Access file made by propietary software. I only want to take half the columns from this table, and import into new(not yet setup)mysql database.</p>
<p>I have no idea how to do this or what the best way is. New data will be obtained each night, and again imported, as an automatic task.</p>
<p>One of the columns in the access database is a url to a jpeg file, I want to download this file and import into the database as a BLOB type automatically.</p>
<p>Is there a way to do this automatically? This will be on a windows machine, so perhaps it could be scripted with WSH?</p>
| [
{
"answer_id": 243069,
"author": "Luis Melgratti",
"author_id": 17032,
"author_profile": "https://Stackoverflow.com/users/17032",
"pm_score": 4,
"selected": true,
"text": "#!/bin/bash\n\nMDBFILE=\"Data.mdb\"\n\nOPTIONS=\"-H -D %y-%m-%d\"\nmdb-export $OPTIONS $MDBFILE TableName_1 > outp... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
242,992 | <p>Does the HTML "select" element have an on select event? what exactly is the name of the event?</p>
| [
{
"answer_id": 242993,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 7,
"selected": true,
"text": "onchange"
},
{
"answer_id": 242999,
"author": "Ryan McCue",
"author_id": 2575,
"author_profile": "... | 2008/10/28 | [
"https://Stackoverflow.com/questions/242992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13370/"
] |
243,021 | <p>I have a VS2005 windows service where I have the need to use 'useUnsafeHeaderParsing' as per documentation from MSDN.</p>
<p>As this is a library used within my windows service, I do not have a web.config to add httpwebrequest element and set useUnsafeHeaderParsing to true.</p>
<p>How would I go about achieving this in code. I tried <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxnetcom/thread/ff098248-551c-4da9-8ba5-358a9f8ccc57/" rel="nofollow noreferrer">this</a> and <a href="http://wiki.lessthandot.com/index.php/Setting_unsafeheaderparsing" rel="nofollow noreferrer">this</a> but that was a no go.</p>
| [
{
"answer_id": 3191915,
"author": "Aaronontheweb",
"author_id": 377476,
"author_profile": "https://Stackoverflow.com/users/377476",
"pm_score": 3,
"selected": false,
"text": "private static bool SetUseUnsafeHeaderParsing(bool b)\n {\n Assembly a = Assembly.GetAssembly(typeof(Sy... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,022 | <p>I'm building an application that needs to run through an XML feed but I'm having a little trouble with getting certain elements.</p>
<p>I'm using the <a href="http://twitter.com/statuses/public_timeline.rss" rel="nofollow noreferrer">Twitter feed</a> and want to run through all the <code><item></code> elements. I can connect fine and get the content from the feed but I can't figure out how to select only the <code>item</code> elements when I'm loopuing through <code>reader.Read();</code>.</p>
<p>Thanks for your help!</p>
| [
{
"answer_id": 3191915,
"author": "Aaronontheweb",
"author_id": 377476,
"author_profile": "https://Stackoverflow.com/users/377476",
"pm_score": 3,
"selected": false,
"text": "private static bool SetUseUnsafeHeaderParsing(bool b)\n {\n Assembly a = Assembly.GetAssembly(typeof(Sy... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] |
243,027 | <p>I've got this ASP.NET drop down control that displays other textbox controls when the value is not UK (this is to help find UK addresses using postcodes). When UK is reselected I will like to hide the other controls. I've enabled view state and AutoPostBack to true. I have an <code>onSelectedIndexChanged</code> event that only gets fired once (when the dropdown value changes to a different country as by default it's UK).</p>
<p>I'll like to have the <code>OnSelectedIndexChanged</code> to fire every time the value is different, but this isn't the case.</p>
<p>P.S. Here's the code snippet.</p>
<pre><code><asp:DropDownList runat="server" ID="Country2" AutoPostBack="True" OnSelectedIndexChanged="Country2_SelectedIndexChanged" DataSource="<%# RegionList %>" DataTextField="Name" DataValueField="Code" CssClass="dropdown country"></asp:DropDownList>
protected void Country2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList d = (DropDownList)sender;
addressEntry.CountryPrePostBack_SelectedIndexChanged(d.SelectedItem.Value);
}
</code></pre>
| [
{
"answer_id": 243047,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 0,
"selected": false,
"text": "this.dropDownList.SelectedIndexChanged += new EventHandler(dropDownList_SelectedIndexChanged);\n"
},
{
"answe... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,035 | <p>I have two tables, one stores the products and quantity we have bought, the other stores the sells. The current stock is therefore the sum of all the quantity columns in the bought table minus the number of rows in the sells table. How can this be expressed in MySQL. Remember that there are many different products.</p>
<p><strong>EDIT:</strong>
To make it harder, I have another requirement. I have the bought table, the sold table, but I also have the products table. I want a list of all the products, and I want to know the quantity available of each product. The problem with the current answers is that they only return the products that we have sold or bought already. I want all the products.</p>
| [
{
"answer_id": 243063,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 4,
"selected": true,
"text": "\nSELECT inv_t.product_id, inventory_total-nvl(sales_total,0)\nFROM \n (SELECT product_id, sum(quantity) as inventory_to... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585/"
] |
243,037 | <p>This problem has several of us stumped in the office. We are all new to deploying ASP.NET apps to a web farm, and I am fresh out of ideas.</p>
<p>We have a web farm, and the application is copied on to all of them.
However, we are having a problem..</p>
<p>An exception is being thrown when trying to get settings from <code>appSettings</code>. Upon further investigation, it turns out the node is actually not using the local <code>Web.Config</code> but it falling back to the <code>Web.Config</code> in the .NET framework folder (we have proved this by adding keys there, which appear on a test page).</p>
<p>I must be missing something, because my understanding is that so long as the file is there, IIS should use that! One of the servers seems to work fine!</p>
<p>Here's a list of what we have confirmed:</p>
<ul>
<li>The config file is in the app directory.</li>
<li>Said file's content is correct.</li>
<li>When viewing the file from IIS > Site > Properties > ASP.NET > Edit Config the correct content is shown.</li>
</ul>
<p>However, at run-time the file that is used is the global one (<code>windows\ms .net\framework\v2\config\web.config</code>).</p>
<p>Anyone have any suggestions as to what may be going wrong? Appreciate all the help I can get!</p>
<p>Thanks.</p>
<p>Rob</p>
| [
{
"answer_id": 243048,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 3,
"selected": false,
"text": "<httpModules>\n <remove name=\"ErrorLog\"/>\n</httpModules>\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
243,045 | <p>What does Java do with long variables while performing addition?</p>
<p>Wrong version 1:</p>
<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = speeds.size() + estimated; // time = 21; string concatenation??
</code></pre>
<p>Wrong version 2:</p>
<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long time = estimated + speeds.size(); // time = 12; string concatenation??
</code></pre>
<p>Correct version:</p>
<pre><code>Vector speeds = ... //whatever, speeds.size() returns 2
long estimated = 1l;
long size = speeds.size();
long time = size + estimated; // time = 3; correct
</code></pre>
<p>I don't get it, why Java concatenate them.</p>
<p>Can anybody help me, why two primitive variables are concatenated?</p>
<p>Greetings, guerda</p>
| [
{
"answer_id": 243054,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "import java.util.*;\n\npublic class Test\n{\n public static void main(String[] args)\n {\n Vector speeds = n... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32043/"
] |
243,057 | <p>I'm using a Response.Redirect to redirect users to another server to download a file, and the other server is checking the header to ensure it came from the correct server... however it seems Response.Redirect strips the headers from the Response.</p>
<p>Does anybody know how i can add the headers back? I've tried:</p>
<pre><code>Response.AddHeader("Referer", "www.domain.com");
</code></pre>
<p>But the receiving page tests false when i check if the Referrer header is set. </p>
<p>Any suggestions how i can get this working, other than displaying a button for the user to click on (i'd like to keep the url hidden from the user as much as possible).</p>
| [
{
"answer_id": 243260,
"author": "Martin Brown",
"author_id": 20553,
"author_profile": "https://Stackoverflow.com/users/20553",
"pm_score": 1,
"selected": false,
"text": "Response.Redirect(\"url?Referer=\" + Server.UrlEncode(Request.UrlReferrer));\n"
},
{
"answer_id": 247518,
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21969/"
] |
243,060 | <p>Emacs does not recognize my correct Python path. I think it is a general problem with Emacs not recognizing my environment variables. I have GNU Emacs 22.1.1 (i386-apple-darwin8.9.1, Carbon Version 1.6.0) of 2007-06-17 installed.</p>
<p>I have set <code>PYTHONPATH</code> in my <code>~/.bashrc</code>. Maybe I should set it somewhere else?</p>
| [
{
"answer_id": 243239,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 6,
"selected": true,
"text": ".bashrc"
},
{
"answer_id": 42206188,
"author": "Christophe Van Neste",
"author_id": 3940298,
"author... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2007483/"
] |
243,068 | <p>How can I create EPS files in C#? Are there any opensource libraries available or do I have to resort to <a href="http://www.adobe.com/devnet/postscript/pdfs/5002.EPSF_Spec.pdf" rel="noreferrer">the spec</a> and do it by hand?</p>
| [
{
"answer_id": 243239,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 6,
"selected": true,
"text": ".bashrc"
},
{
"answer_id": 42206188,
"author": "Christophe Van Neste",
"author_id": 3940298,
"author... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25571/"
] |
243,072 | <p>When a user logs in to my site I want a css styled button to appear (this could be anything really, i.e. some special news text item etc), how can you do this via masterpages in asp.net? Or is there some other way you do this?</p>
| [
{
"answer_id": 243084,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 3,
"selected": true,
"text": " <asp:LoginView>\n <AnonymousTemplate>\n Nothing Displayed\n </AnonymousTemplate>\n ... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5175/"
] |
243,074 | <p>I'm wondering what are the recommended ways to handle situations where, in memory managed code, object didn't belong to any particular owner, i.e. objects released themselves. One such example could be a subclass of NSWindowController, which configures, displays and manages input and output of a single window. The controller object displays a window and releases itself later at some point (usually when the window or sheet it manages is closed). AppKit provides couple examples as well: NSAnimation retains itself in startAnimation and releases itself when the animation is done. Another example is NSWindow, which can be configured to release itself when closed. </p>
<p>When implementing these "self-owned" objects myself, I see at least three different GC-safe patterns, but all of them have some drawbacks. </p>
<p>a). Using CFRetain/CFRelease.</p>
<p>Self-owned object calls CFRetain on self before it starts its operation (e.g. in the window controller example before the window is displayed). It then calls CFRelease() on self when it's done (e.g. in the window controller example after the window is closed). </p>
<p>Pros: User of the object doesn't have to worry about memory management.<br>
Cons: A bit ugly, since requires use of memory management functions, although we're using GC in pure ObjC code. If CFRelease() isn't called, leak may be hard to locate.</p>
<p>b). Avoiding self-ownership idiom with static data structure.</p>
<p>Object adds itself into a data structure (e.g. a static mutable array) before it starts its operation and removes itself from there when it's done. </p>
<p>Pros: User of the object doesn't have to worry about memory management. No calls to memory management functions. Objects have explicit owner. Potential leaks are easy to locate.<br>
Cons: Locking is needed if objects may be created from different threads. Extra data structure.</p>
<p>c). Avoiding self-ownership idiom by requiring the user of object to save a reference to the object (e.g. into an ivar).</p>
<p>Pros: No calls to memory management functions. Objects have explicit owner.<br>
Cons: User of the object has to keep a reference even if it doesn't need the object anymore. Extra ivars.</p>
<p>What pattern would you use to handle these cases?</p>
| [
{
"answer_id": 244237,
"author": "Jens Ayton",
"author_id": 6443,
"author_profile": "https://Stackoverflow.com/users/6443",
"pm_score": 3,
"selected": false,
"text": "CFRetain(foo)"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32045/"
] |
243,082 | <p>Let's say I have a <strong>Base</strong> class and several <strong>Derived</strong> classes. Is there any way to cast an object to one of the derived classes without the need to write something like this :</p>
<pre><code>
string typename = typeid(*object).name();
if(typename == "Derived1") {
Derived1 *d1 = static_cast< Derived1*>(object);
}
else if(typename == "Derived2") {
Derived2 *d2 = static_cast < Derived2*>(object);
}
...
else {
...
}
</code></pre>
| [
{
"answer_id": 243111,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 1,
"selected": false,
"text": "dynamic_cast"
},
{
"answer_id": 243115,
"author": "fhe",
"author_id": 4445,
"author_profile": "https://... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] |
243,083 | <p>What is a strongly typed dataset? (.net)</p>
| [
{
"answer_id": 243096,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 4,
"selected": false,
"text": "EmployeeDataset ds = ...\nEmployeeRow row = ds.Employees.Rows[0];\nrow.Name = \"Joe\";\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,097 | <p>I have a unit test where I have statically defined a quite large byte array (over 8000 bytes) as the byte data of a file I don't want to read every time I run my unit test.</p>
<pre><code>private static final byte[] FILE_DATA = new byte[] {
12,-2,123,................
}
</code></pre>
<p>This compiles fine within Eclipse, but when compiling via Ant script I get the following error:</p>
<pre><code>[javac] C:\workspace\CCUnitTest\src\UnitTest.java:72: code too large
[javac] private static final byte[] FILE_DATA = new byte[] {
[javac] ^
</code></pre>
<p>Any ideas why and how I can avoid this?</p>
<hr>
<p><strong>Answer</strong>: Shimi's answer did the trick. I moved the byte array out to a separate class and it compiled fine. Thanks!</p>
| [
{
"answer_id": 244100,
"author": "Cem Catikkas",
"author_id": 3087,
"author_profile": "https://Stackoverflow.com/users/3087",
"pm_score": 0,
"selected": false,
"text": "@BeforeClass"
},
{
"answer_id": 22637216,
"author": "Josh",
"author_id": 82505,
"author_profile": "... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
243,120 | <p>Is it possible to get a list of control events that are going to fire before they happen, say inside the <code>Page_Load</code> handler?</p>
<p>For example if a button was clicked can I figure this out before the <code>button_click</code> event handler is called?</p>
| [
{
"answer_id": 243181,
"author": "tpower",
"author_id": 18107,
"author_profile": "https://Stackoverflow.com/users/18107",
"pm_score": 0,
"selected": false,
"text": "Page.Request.Form[\"__EVENTTARGET\"]\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18107/"
] |
243,124 | <p>Here is the problem: we have lots of Javascripts and lots of CSS files, which we'd rather be serving minified. Minification is easy: set up the YUI Compressor, run an Ant task, and it spits out minified files, which we save beside the originals.</p>
<p>So we end up with the following directory structure somewhere inside our DocumentRoot:</p>
<pre>
/
/js
/min
foo-min.js
bar-min.js
foo.js
bar.js
quux.js
/css
...
</pre>
<p>Now what we need is that Apache serve files from the <strong>min</strong> subdirectory, <em>and fallback to serving uncompressed files</em>, if their minified versions are not available. The last issue is the one I cannot solve.</p>
<p>For example: suppose we have a request to <strong>example.com/js/foo.js</strong> — in this case Apache should send contents of <strong>/js/min/foo-min.js</strong>. There is no minified <strong>quux.js</strong>, so request to <strong>/js/quux.js</strong> returns <strong>/js/quux.js</strong> itself, not 404. Finally, if there is no <strong>/js/fred.js</strong>, it should end up with 404.</p>
<p>Actually, I'm setting build scripts in such a way that unminified files are not deployed on the production server, but this configuration still might be useful on an integration server and on development machines.</p>
| [
{
"answer_id": 243135,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 0,
"selected": false,
"text": "ant productionDeploy"
},
{
"answer_id": 243154,
"author": "Ignacio Vazquez-Abrams",
"author_id": 20862,
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6573/"
] |
243,132 | <p>I have a key that appears to be an empty string, however using <code>unset($array[""]);</code> does not remove the key/value pair. I don't see another function that does what I want, so I'm guessing it's more complicated that just calling a function.</p>
<p>The line for the element on a print_r is <code>[] => 1</code>, which indicates to me that the key is the empty string.</p>
<p>Using var_export, the element is listed as <code>'' => 1</code>.</p>
<p>Using var_dump, the element is listed as <code>[""]=>int(1)</code>.</p>
<p>So far, I have tried all of the suggested methods of removal, but none have removed the element. I have tried <code>unset($array[""]);</code>, <code>unset($array['']);</code>, and <code>unset($array[null]);</code> with no luck.</p>
| [
{
"answer_id": 243141,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 1,
"selected": false,
"text": "foreach ($array as $index => $value) {\n echo $index;\n echo ' is ';\n echo gettype($index);\n echo \"\\n... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
243,152 | <p>The thing is I've been using the <a href="http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx" rel="noreferrer">lock statement</a> to protect a critical part of my code, but now, I realize I could allow concurrent execution of that critical code is some conditions are met.<br>
Is there a way to condition the lock?</p>
| [
{
"answer_id": 243168,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 4,
"selected": true,
"text": "Action doThatThing = someMethod;\n\nif (condition)\n{\n lock(thatThing)\n {\n doThatThing();\n }\n}\nelse\n{\n doThatTh... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23893/"
] |
243,170 | <p>I'll try to explain my scenario as best i can;</p>
<p>At each application <em>tick</em> I query the current state of the keyboard and mouse and wrap them in individual classes and data structures. For the keyboard it's an array of my <em>Keys</em> enum (one item for each of the keys that are currently pressed) and for the mouse it's a class containing coordinate delta's and bools for each buttons pressed.</p>
<p>I also have a rudimentary state machine managed via a state manager class which maintains the stack and marshalls the states.</p>
<p>All I want to know is, how best to pass the input (snapshots) to the individual states my app can be in at any one time?</p>
<p>I would like to process as much of the input as possible away from the individual states, so as to reduce repeating logic within the states.</p>
<p>Or would it be better to keep the input snapshots as pure as possible and pass them to the states so they can keep they're input-specific-logic hidden?</p>
<p><strong>Note</strong><br/>
This structure is similiar to how I imagine a game would work, and although this application is not a game it does need to be processed as quickly as possible.</p>
| [
{
"answer_id": 243549,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 1,
"selected": false,
"text": "KeyboardState state = Keyboard.GetState();\n"
},
{
"answer_id": 244129,
"author": "Nicholas Mancuso",
"author_... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17540/"
] |
243,173 | <p>I'm having an issue with a USB project using <code>LIB-USB</code>. The USB device is based on a PIC18F4550 and has a single control endpoint. The PC front-end is written in MSVC and uses Lib-Usb 1.12.</p>
<p>On the PC end, the program begins by setting the configuration, claiming the interface, then sending (and receiving) control messages (vendor specific), all successfully. After what seems like a random # of bytes have been transferred (anywhere between 100 and 2000) the transfer halts with an <strong>error rc=-5</strong> returned from the usb_control_msg call.</p>
<p>On the PC-end, the calls look like this:</p>
<pre><code>ret = usb_set_configuration(udev, 1);
ret = usb_claim_interface(udev, 0);
ret = usb_control_msg(udev, USB_TYPE_VENDOR|USB_RECIP_DEVICE, CMD_RESET, 0, 0, buffer, 0, 100);
ret = usb_control_msg(udev, 0xC0, GET_FIFO_DATA, 0, 0, buffer, 8, 100);
</code></pre>
<p>The last call, which actually acquires data from the USB device, runs many times in succession but always dies after a random number of bytes (100 to 2000 in total) are transferred in this way. Changing the pipe to EP1 does the same thing with the same error eventually appearing.</p>
<p>On the USB device (PIC) end the descriptor is very simple, having only the EP0 pipe, and looks like this:</p>
<pre><code>Device
db 0x12, DEVICE ; bLength, bDescriptorType
db 0x10, 0x01 ; bcdUSB (low byte), bcdUSB (high byte)
db 0x00, 0x00 ; bDeviceClass, bDeviceSubClass
db 0x00, MAX_PACKET_SIZE ; bDeviceProtocol, bMaxPacketSize
db 0xD8, 0x04 ; idVendor (low byte), idVendor (high byte)
db 0x01, 0x00 ; idProduct (low byte), idProduct (high byte)
db 0x00, 0x00 ; bcdDevice (low byte), bcdDevice (high byte)
db 0x01, 0x02 ; iManufacturer, iProduct
db 0x00, NUM_CONFIGURATIONS ; iSerialNumber (none), bNumConfigurations
Configuration1
db 0x09, CONFIGURATION ; bLength, bDescriptorType
db 0x12, 0x00 ; wTotalLength (low byte), wTotalLength (high byte)
db NUM_INTERFACES, 0x01 ; bNumInterfaces, bConfigurationValue
db 0x00, 0xA0 ; iConfiguration (none), bmAttributes
db 0x32, 0x09 ; bMaxPower (100 mA), bLength (Interface1 descriptor starts here)
db INTERFACE, 0x00 ; bDescriptorType, bInterfaceNumber
db 0x00, 0x00 ; bAlternateSetting, bNumEndpoints (excluding EP0)
db 0xFF, 0x00 ; bInterfaceClass (vendor specific class code), bInterfaceSubClass
db 0xFF, 0x00 ; bInterfaceProtocol (vendor specific protocol used), iInterface (none)
</code></pre>
<p>The actual framework is that of Bradley Minch's in assembly language. </p>
<p>If anyone has encountered this type of problem before I'd love to hear about it as I've tried just about everything to solve it including using a different pipe (EP1, with the same results), checking the UOWN bit on the PIC before writing to the pipe, handshaking with the PC host (where the PC must send a vendor-specific command first before the datsa is written) but to no avail.</p>
| [
{
"answer_id": 243748,
"author": "Ilya",
"author_id": 6807,
"author_profile": "https://Stackoverflow.com/users/6807",
"pm_score": 1,
"selected": false,
"text": "vendor_class_request(): request failed: status: 0xc0000001, urb-status: 0xc000000c"
},
{
"answer_id": 252480,
"auth... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,193 | <p>I have a set of tables that are used to track bills. These tables are loaded from an SSIS process that runs weekly.</p>
<p>I am in the process of creating a second set of tables to track adjustments to the bills that are made via the web. Some of our clients hand key their bills and all of those entries need to be backed up on a more regular schedule (the SSIS fed data can always be imported again so it isn't backed up).</p>
<p>Is there a best practice for this type of behavior? I'm looking at implementing a DDL trigger that will parse the ALTER TABLE call and change the table being called. This is somewhat painful, and I'm curious if there is a better way.</p>
| [
{
"answer_id": 252233,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 1,
"selected": true,
"text": "-- Create pvt and pvtWeb as test tables\nCREATE TABLE [dbo].[pvt](\n [VendorID] [int] NULL,\n [Emp1] [int] NUL... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11780/"
] |
243,200 | <p>I'm looking to improve my PHP coding and am wondering what PHP-specific techniques other programmers use to improve productivity or workaround PHP limitations.</p>
<p>Some examples:</p>
<ol>
<li><p>Class naming convention to handle namespaces: <code>Part1_Part2_ClassName</code> maps to file <code>Part1/Part2/ClassName.php</code></p></li>
<li><p><code>if ( count($arrayName) ) // handles $arrayName being unset or empty</code></p></li>
<li><p>Variable function names, e.g. <code>$func = 'foo'; $func($bar); // calls foo($bar);</code></p></li>
</ol>
| [
{
"answer_id": 243254,
"author": "changelog",
"author_id": 5646,
"author_profile": "https://Stackoverflow.com/users/5646",
"pm_score": 3,
"selected": false,
"text": "ini_set('display_errors', '1');\nerror_reporting(E_ALL);"
},
{
"answer_id": 243337,
"author": "Lucas Oman",
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4890/"
] |
243,215 | <p>Did someone ever used a BIRT report in a desktop application. I'm comming from the .NET environment and there you can use Crystal Reports to show reports in desktop apps. Is this possible with BIRT too, without having to set up a server environment?</p>
<p>Can you give me some advice how to reach this goal?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 243222,
"author": "paul",
"author_id": 11249,
"author_profile": "https://Stackoverflow.com/users/11249",
"pm_score": 2,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<classpath>\n <classpathentry kind=\"src\" path=\"src\"/>\n <classpathentry... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,217 | <p>I keep it in single line, if it's short. Lately I've been using this style for longer or nested ternary operator expressions. A contrived example:</p>
<pre><code>$value = ( $a == $b )
? 'true value # 1'
: ( $a == $c )
? 'true value # 2'
: 'false value';
</code></pre>
<p>Personally which style you use, or find most readable?</p>
<p><strong>Edit:</strong> <em>(on when to use ternary-operator)</em></p>
<p>I usually avoid using more than 2 levels deep ternary operator. I tend prefer 2 levels deep ternary operator over 2 level if-else, when I'm echoing variables in PHP template scripts.</p>
| [
{
"answer_id": 243229,
"author": "biozinc",
"author_id": 30698,
"author_profile": "https://Stackoverflow.com/users/30698",
"pm_score": 5,
"selected": false,
"text": "if else if else\n"
},
{
"answer_id": 243240,
"author": "John Rudy",
"author_id": 14048,
"author_profil... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1897/"
] |
243,218 | <p>I think in this case there is no need to declare a public constructor since the class is not accessible outside the package anyway. But is there some hidden impact when the class has only package private constructor?</p>
| [
{
"answer_id": 243276,
"author": "Denis R.",
"author_id": 32015,
"author_profile": "https://Stackoverflow.com/users/32015",
"pm_score": 2,
"selected": false,
"text": "public"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446104/"
] |
243,232 | <p>Inside my page, I have the following:</p>
<pre><code><aspe:UpdatePanel runat="server" ID="updatePanel">
<ContentTemplate>
<local:KeywordSelector runat="server" ID="ksKeywords" />
</ContentTemplate>
</aspe:UpdatePanel>
</code></pre>
<p>The <code>KeywordSelector</code> control is a control I define in the same assembly and <code>local</code> is mapped to its namespace.</p>
<p>The control is made up of several other controls and is defined as such:</p>
<pre><code><%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="KeywordSelector.ascx.cs"
Inherits="Keywords.KeywordSelector" %>
</code></pre>
<p>and has quite a few server controls of its own, all defined as members in the <code>.designer.cs</code> file.</p>
<p>However, <strong>during no part of the control's lifecycle does it have any child control objects nor does it produce HTML</strong>:</p>
<ol>
<li>All of the members defined in the <code>.designer.cs</code> file are <code>null</code>.</li>
<li>Calls to <code>HasControls</code> return <code>false</code>.</li>
<li>Calls to <code>EnsureChildControls</code> do nothing.</li>
<li>The <code>Controls</code> collection is empty.</li>
</ol>
<p>Removing the <code>UpdatePanel</code> did no good. I tried to reproduce it in a clean page with a new <code>UserControl</code> and the same thing happens.</p>
<p>I am using ASP.NET over .NET Framework 3.5 SP1 with the integrated web server.</p>
<p>What am I missing here?</p>
<p><strong>Update #1:</strong> Following Rob's comment, I looked into <code>OnInit</code> and found that the <code>UserControl</code> does not detect that it has any child controls. Moreover, <code>CreateControlCollection</code> is never called!</p>
| [
{
"answer_id": 243493,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 6,
"selected": true,
"text": "<add tagPrefix=\"local\" tagName=\"KeywordSelector\" src=\"~/KeywordSelector.ascx\" />"
},
{
"answer_id": 2... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4979/"
] |
243,237 | <p>I am using a ASP/.Net webpage and i want to upload a pdf file into a SQL Database as a binary I am uping the build in upload control, can you please suggest a way of doing this. I also need to no how to read the pdf back and display it in a web browser. I will be using linq to upload and query my sql database.</p>
| [
{
"answer_id": 243250,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 2,
"selected": false,
"text": "VARBINARY(MAX)"
},
{
"answer_id": 243431,
"author": "Leandro López",
"author_id": 22695,
"autho... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,242 | <p>I had the following piece of code (simplified for this question):</p>
<pre><code>struct StyleInfo
{
int width;
int height;
};
typedef int (StyleInfo::*StyleInfoMember);
void AddStyleInfoMembers(std::vector<StyleInfoMember>& members)
{
members.push_back(&StyleInfo::width);
members.push_back(&StyleInfo::height);
}
</code></pre>
<p>Now, we had to restructure this a bit, and we did something like this:</p>
<pre><code>struct Rectangle
{
int width;
int height;
};
struct StyleInfo
{
Rectangle size;
};
typedef int (StyleInfo::*StyleInfoMember);
void AddStyleInfoMembers(std::vector<StyleInfoMember>& members)
{
members.push_back(&StyleInfo::size::width);
members.push_back(&StyleInfo::size::height);
}
</code></pre>
<p>If this all looks like a stupid thing to do, or if you feel there's a good opportunity to apply BOOST here for some reason, I must warn you that I really simplified it all down to the problem at hand:</p>
<blockquote>
<p>error C3083: 'size': the symbol to the left of a '::' must be a type</p>
</blockquote>
<p>The point I'm trying to make is that I don't know what the correct syntax is to use here. It might be that "StyleInfo" is not the correct type of take the address from to begin with, but in my project I can fix that sort of thing (there's a whole framework there). I simply don't know how to point to this member-within-a-member.</p>
| [
{
"answer_id": 243396,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 1,
"selected": false,
"text": "typedef Rectangle (StyleInfo::*StyleInfoMember);\ntypedef int (Rectangle::*RectangleMember);\n"
},
{
"answer_... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/455874/"
] |
243,252 | <p>We're doing a lot of large, but straightforward forms for a fairly big project (about 600 users using it throughout the day - that's big for me at least ;-) ).</p>
<p>The forms have a lot of question/answer type sections, so it's natural for some people to type a sentence, while others type a novel. <strong>How beneficial would it be to put a character limit on some of these fields <em>really</em>?</strong></p>
<p>(Please include references or citations, if necessary/possible - Thanks!)</p>
| [
{
"answer_id": 243287,
"author": "dl__",
"author_id": 28565,
"author_profile": "https://Stackoverflow.com/users/28565",
"pm_score": 1,
"selected": false,
"text": "Type - Maximum Length -Storage\nTINYBLOB, TINYTEXT 255 Length+1 bytes\nBLOB, TEXT ... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25538/"
] |
243,266 | <p>Core Animation allows for custom animations by implementing the actionForKey method in your CALayer based class:</p>
<pre><code>- (id<CAAction>)actionForKey:(NSString *)key {
// Custom animations
return [super actionForKey:key];
}
</code></pre>
<p>I can then create an animation and return it for the <code>onOrderIn</code> action (i.e. when the layer is added to another layer). This works just fine. If I do the same for <code>onOrderOut</code> (i.e. the layer is removed from its superlayer), the returned animation is ignored, and the default animation is applied instead.</p>
<p>My goal is to zoom the layer in (<code>onOrderIn</code>) and out (<code>onOrderOut</code>):</p>
<pre><code>- (id<CAAction>)actionForKey:(NSString *)key {
if ([key isEqualToString:@"onOrderIn"] || [key isEqualToString:@"onOrderOut"]) {
CABasicAnimation *a = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
a.duration = 0.25;
a.removedOnCompletion = NO;
a.fillMode = kCAFillModeBoth;
if ([key isEqualToString:@"onOrderIn"]) {
a.fromValue = [NSNumber numberWithFloat:0.0];
a.toValue = [NSNumber numberWithFloat:1.0];
} else {
a.fromValue = [NSNumber numberWithFloat:1.0];
a.toValue = [NSNumber numberWithFloat:0.0];
}
return a;
}
return [super actionForKey:key];
}
</code></pre>
<p>Zooming in works, zooming out does not. Instead the default fade out animation is used. </p>
<p>The code might contain some typos, as I'm typing this on another machine.</p>
<p>Can anyone help?</p>
| [
{
"answer_id": 245089,
"author": "Colin Barrett",
"author_id": 23106,
"author_profile": "https://Stackoverflow.com/users/23106",
"pm_score": 0,
"selected": false,
"text": "key"
},
{
"answer_id": 1285044,
"author": "tjw",
"author_id": 11029,
"author_profile": "https://... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9454/"
] |
243,267 | <p>I'm looking for an efficient way of searching through a dataset to see if an item exists. I have an arraylist of ~6000 items and I need to determine which of those doesn't exist in the dataset by comparing each item within the arraylist with data in a particular column of the dataset.</p>
<p>I attempted to loop through each item in the dataset for each in the arraylist but that took forever. I then attempted to use the RowFilter method below. None of which looks to be efficient. Any help is greatly appreciated, as you can tell I'm not much of a programmer...</p>
<p>example:</p>
<pre><code>Dim alLDAPUsers As ArrayList
alLDAPUsers = clsLDAP.selectAllStudents
Dim curStu, maxStu As Integer
maxStu = alLDAPUsers.Count
For curStu = 0 To maxStu - 1
Dim DomainUsername As String = ""
DomainUsername = alLDAPUsers.Item(curStu).ToString
Dim filteredView As DataView
filteredView = dsAllStudents.Tables(0).DefaultView
filteredView.RowFilter = ""
filteredView.RowFilter = "szvausr_un = '" & DomainUsername & "'"
Dim returnedrows As Integer = filteredView.Count
If returnedrows = 0 Then
'' Delete the user...
End If
Next
</code></pre>
| [
{
"answer_id": 243309,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "Dim LDAPUsers As List(Of String) = clsLDAP.selectAllStudents\n\nFor Each DomainUsername As String in LDAPUsers\n D... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32059/"
] |
243,269 | <p>Windows Mobile pops up a "busy wheel" - a rotating colour disk - when things are happening . I can't find in the documentation how this is done - can someone point me in the right direction?</p>
<p>We have a situation where we need to prompt the user to say we're doing stuff for a while, but we don't know how long it will take. So we can't do a progress bar, hence the proposal to use this busy wheel.</p>
| [
{
"answer_id": 243282,
"author": "SmacL",
"author_id": 22564,
"author_profile": "https://Stackoverflow.com/users/22564",
"pm_score": 2,
"selected": false,
"text": "void DoSomethingSlow()\n{\n CWaitCursor cw;\n.\n.\n.\n.\n}\n"
},
{
"answer_id": 243304,
"author": "ctacke",
... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21755/"
] |
243,274 | <p>I was wondering how to unit test abstract classes, and classes that extend abstract classes.</p>
<p>Should I test the abstract class by extending it, stubbing out the abstract methods, and then test all the concrete methods? Then only test the methods I override, and test the abstract methods in the unit tests for objects that extend my abstract class?</p>
<p>Should I have an abstract test case that can be used to test the methods of the abstract class, and extend this class in my test case for objects that extend the abstract class?</p>
<p>Note that my abstract class has some concrete methods.</p>
| [
{
"answer_id": 243451,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public abstract class MyBase{\n /*...*/\n public abstract void VoidMethod(object param1);\n public abstract object MethodWi... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3050/"
] |
243,277 | <p>My SQL is rusty -- I have a simple requirement to calculate the sum of the greater of two column values:</p>
<pre><code>CREATE TABLE [dbo].[Test]
(
column1 int NOT NULL,
column2 int NOT NULL
);
insert into Test (column1, column2) values (2,3)
insert into Test (column1, column2) values (6,3)
insert into Test (column1, column2) values (4,6)
insert into Test (column1, column2) values (9,1)
insert into Test (column1, column2) values (5,8)
</code></pre>
<p>In the absence of the GREATEST function in SQL Server, I can get the larger of the two columns with this:</p>
<pre><code>select column1, column2, (select max(c)
from (select column1 as c
union all
select column2) as cs) Greatest
from test
</code></pre>
<p>And I was hoping that I could simply sum them thus:</p>
<pre><code>select sum((select max(c)
from (select column1 as c
union all
select column2) as cs))
from test
</code></pre>
<p>But no dice:</p>
<pre><code>Msg 130, Level 15, State 1, Line 7
Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
</code></pre>
<p>Is this possible in T-SQL without resorting to a procedure/temp table?</p>
<p>UPDATE: Eran, thanks - I used this approach. My final expression is a little more complicated, however, and I'm wondering about performance in this case:</p>
<pre><code>SUM(CASE WHEN ABS(column1 * column2) > ABS(column3 * column4)
THEN column5 * ABS(column1 * column2) * column6
ELSE column5 * ABS(column3 * column4) * column6 END)
</code></pre>
| [
{
"answer_id": 243292,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 1,
"selected": false,
"text": "SELECT\n 'LargerValue' = CASE \n WHEN SUM(c1) >= SUM(c2) THEN SUM(c1)\n ELSE SUM(c... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18482/"
] |
243,293 | <p>A while back I asked about instantiating a HttpContext object. Now that I have learnt what I didn't know, what confuses me is that you cannot say HttpContext ctx = new HttpContext(); because the object does not have a constructor.</p>
<p>But doesn't every class need a constructor? In C#, if you don't provide one, the compiler automatically provides a default cstr for you.</p>
<p>Also, if I have a string (example: "Hello There!") and I say Convert.ToBoolean("Hello"), or any string, how does this work? What happens behind the scenes? I guess a book like CLR Via C# would be handy in this case.</p>
<p>What am I missing?</p>
| [
{
"answer_id": 243317,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Class A{\npublic static readonly A Instance = new A();\n\nprivate A()\n{\n}\n\n}\n"
},
{
"answer_id": 243321,
"aut... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30004/"
] |
243,298 | <p>I'm launching a Weblogic application inside Eclipse via the BEA Weblogic Server v9.2 runtime environment. If this were running straight from the command-line, I'd do a ctrl-BREAK to force a thread dump. Is there a way to do it in Eclipse?</p>
| [
{
"answer_id": 243698,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 6,
"selected": true,
"text": "jstack 7088"
},
{
"answer_id": 9745282,
"author": "Alper Akture",
"author_id": 1138137,
"author_profile"... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18995/"
] |
243,322 | <p>State should include at least the following:</p>
<ul>
<li>All settings set via
SetStreamResource()</li>
<li>Indices</li>
</ul>
<p>I have a class whose Draw() function will call SetStreamResource, set Indices and eventually call DrawIndexedPrimitive(). I would like to restore the device state before Draw() returns.</p>
<p>I am looking for something along the lines of GDI's SaveDC()/RestoreDC().</p>
| [
{
"answer_id": 253742,
"author": "Agnel Kurian",
"author_id": 45603,
"author_profile": "https://Stackoverflow.com/users/45603",
"pm_score": 1,
"selected": false,
"text": "Microsoft::DirectX::Direct3D::Device::BeginStateBlock\nMicrosoft::DirectX::Direct3D::Device::EndStateBlock\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45603/"
] |
243,344 | <p>In my Page_Load event of codebehind file, I am loading data in to a datatable.In my .aspx page I am having some inline coding,I want to display some data from this datatable.But when i am running the program,It is showing an error like "Error 64 Use of unassigned local variable 'dtblChild' "
dtblChild is my DataTable Object</p>
<p>Is Page_Load in codebehind executes after loading the form elements ?</p>
| [
{
"answer_id": 243382,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<% %>"
},
{
"answer_id": 243416,
"author": "Community",
"author_id": -1,
"author_profile": "https:... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,347 | <p>I launch my program in C#, which then calls some unmanaged C++. </p>
<p>When I break on a line in the unmanaged C++, the 'New Data Breakpoint' menu item is grayed out.</p>
<p>Is there anyway around this?</p>
| [
{
"answer_id": 34708528,
"author": "Mojtaba Rezaeian",
"author_id": 2721611,
"author_profile": "https://Stackoverflow.com/users/2721611",
"pm_score": 2,
"selected": false,
"text": "If (Condition)\n System.Diagnostics.Debugger.Break()\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14841/"
] |
243,351 | <p>Is it ever OK to use <code>Environment.TickCount</code>to calculate time spans?</p>
<pre><code>int start = Environment.TickCount;
// Do stuff
int duration = Environment.TickCount - start;
Console.WriteLine("That took " + duration " ms");
</code></pre>
<p>Because <code>TickCount</code> is signed and will rollover after 25 days (it takes 50 days to hit all 32 bits, but you have to scrap the signed bit if you want to make any sense of the math), it seems like it's too risky to be useful. </p>
<p>I'm using <code>DateTime.Now</code> instead. Is this the best way to do this?</p>
<pre><code>DateTime start = DateTime.Now;
// Do stuff
TimeSpan duration = DateTime.Now - start;
Console.WriteLine("That took " + duration.TotalMilliseconds + " ms");
</code></pre>
| [
{
"answer_id": 243357,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 7,
"selected": true,
"text": " Stopwatch stopWatch = Stopwatch.StartNew();\n Thread.Sleep(10000);\n stopWatch.Stop();\n // Get the elapsed time... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27414/"
] |
243,355 | <p>Is there a way to quickly list which sites are on which IP address in IIS 7? </p>
<p>If I remember correctly you could sort a view of domains by IP in IIS 6 which was a big help to me in seeing which IPs I had available.</p>
| [
{
"answer_id": 243370,
"author": "Kieron",
"author_id": 5791,
"author_profile": "https://Stackoverflow.com/users/5791",
"pm_score": 2,
"selected": false,
"text": "MachineName = \"localhost\"\nIIsObjectPath = \"IIS://\" & MachineName & \"/w3svc\"\n\nWScript.Echo \"Checking : \" & IISObjec... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] |
243,363 | <p>Can someone explain the structure of a Pid in Erlang?</p>
<p>Pids looks like this: <code><A.B.C></code>, e.g. <code><0.30.0></code> , but I would like to know what is the meaning of these three "bits": <code>A</code>, <code>B</code> and <code>C</code>.</p>
<p><code>A</code> seems to be always <code>0</code> on a local node, but this value changes when the Pid's owner is located on another node.</p>
<p>Is it possible to directly send a message on a remote node using only the Pid? Something like that: <code><4568.30.0> ! Message</code>, without having to explicitly specify the name of the registered process and the node name (<code> {proc_name, Node} ! Message</code>)?</p>
| [
{
"answer_id": 243668,
"author": "Jon Gretar",
"author_id": 5601,
"author_profile": "https://Stackoverflow.com/users/5601",
"pm_score": 4,
"selected": false,
"text": "<nodeid,serial,creation>"
},
{
"answer_id": 262179,
"author": "archaelus",
"author_id": 9040,
"author... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15539/"
] |
243,365 | <p>I was just reading this <a href="https://stackoverflow.com/questions/243082/c-casting-programmatically-can-it-be-done">thread</a> and it occurred to me that there is one seemingly-valid use of that pattern the OP is asking about. I know I've used it before to implement dynamic creation of objects. As far as I know, there is no better solution in C++, but I was wondering if any gurus out there know of a better way. Generally, I run into this situation when I need to create one of several subclasses of an object based one something unknown at compile time (such as based on a config file). I use the object polymorphically once it is created.</p>
<p>There's another related situation when you're using a message-passing scheme (usually over TCP/IP) where each message is an object. I like to implement that pattern as letting each message serialize itself into some serialization stream interface, which works well and is fairly clean on the sending end, but on the receiver, I always find myself examining a header on the message to determine the type, then constructing an appropriate message object using the pattern from the linked article, then having it deserialize itself from the stream. Sometimes I implement it so that the construction and deserialization happen at the same time as part of the constructor, which seems more RAII, but that's small consolation for the mess of if/else statements figuring out the type.</p>
<p>Any better solutions out there? If you're going to suggest a 3rd party library, it should be free (and ideally open source) and I'd appreciate it if you could explain how the library accomplishes this feat.</p>
| [
{
"answer_id": 243405,
"author": "SpoonMeiser",
"author_id": 1577190,
"author_profile": "https://Stackoverflow.com/users/1577190",
"pm_score": 2,
"selected": false,
"text": "Base* Base::get_object(std::string type)\n{\n if (type == \"derived1\") return new Derived1;\n if (type == \... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10861/"
] |
243,368 | <p>How do I programmatically reset the Excel <code>Find and Replace</code> dialog box parameters to defaults ("Find what", "Replace with", "Within", "Search", "Look in", "Match case", "Match entire cell contents")?</p>
<p>I am using <code>Application.FindFormat.Clear</code> and <code>Application.ReplaceFormat.Clear</code> to reset find and replace cell formats.</p>
<p>Interestingly, after using <code>expression.Replace(FindWhat, ReplaceWhat, After, MatchCase, WholeWords)</code>, the <code>FindWhat</code> string shows in the <code>Find and Replace</code> dialog box but not the <code>ReplaceWhat</code> parameter.</p>
| [
{
"answer_id": 2061040,
"author": "DaveParillo",
"author_id": 167483,
"author_profile": "https://Stackoverflow.com/users/167483",
"pm_score": 3,
"selected": false,
"text": "Sub ResetFind()\n Dim r As Range\n\n On Error Resume Next 'just in case there is no active cell\n Set r =... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,375 | <p>I have written a CGI script that creates an image dynamically using GET data. To include this image in my webpage, I am using the following code:</p>
<pre><code><img src="image.py?text=xxxxxxxxxxxxxx">
</code></pre>
<p>The problem is that I expect in the future the "text" field will get very long and the URL will become too large. From Googling around there doesn't seem to be a fixed limit on URL length (ie. depends on the browser, server, proxy, etc.) Is there a better way to do this? </p>
<p>If it matters, I am working with Django and Python and I cannot use any client-side scripting (ie. JavaScript).</p>
<p>Cheers,
Ben</p>
| [
{
"answer_id": 243521,
"author": "fuentesjr",
"author_id": 10708,
"author_profile": "https://Stackoverflow.com/users/10708",
"pm_score": 1,
"selected": false,
"text": "<img src=\"render_img.py?row_id=0122\">"
},
{
"answer_id": 243860,
"author": "Community",
"author_id": -... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27478/"
] |
243,383 | <p>I was reading about parsers and parser generators and found this statement in wikipedia's LR parsing -page:</p>
<blockquote>
<p>Many programming languages can be parsed using some variation of an LR parser. One notable exception is C++.</p>
</blockquote>
<p>Why is it so? What particular property of C++ causes it to be impossible to parse with LR parsers?</p>
<p>Using google, I only found that C can be perfectly parsed with LR(1) but C++ requires LR(∞). </p>
| [
{
"answer_id": 243447,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 8,
"selected": true,
"text": "int(x), y, *const z;\n"
},
{
"answer_id": 1004737,
"author": "Ira Baxter",
"author_id": 120163,
"autho... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21711/"
] |
243,385 | <p>I'm pretty new to the Spring Framework, I've been playing around with it and putting a few samples apps together for the purposes of evaluating Spring MVC for use in an upcoming company project. So far I really like what I see in Spring MVC, seems very easy to use and encourages you to write classes that are very unit test-friendly.</p>
<p>Just as an exercise, I'm writing a main method for one of my sample/test projects. One thing I'm unclear about is the exact differences between <code>BeanFactory</code> and <code>ApplicationContext</code> - which is appropriate to use in which conditions?</p>
<p>I understand that <code>ApplicationContext</code> extends <code>BeanFactory</code>, but if I'm just writing a simple main method, do I need the extra functionality that <code>ApplicationContext</code> provides? And just exactly what kind of extra functionality does <code>ApplicationContext</code> provide?</p>
<p>In addition to answering "which should I use in a main() method", are there any standards or guidelines as far as which implementation I should use in such a scenario? Should my main() method be written to depend on the bean/application configuration to be in XML format - is that a safe assumption, or am I locking the user into something specific?</p>
<p>And does this answer change in a web environment - if any of my classes needed to be aware of Spring, are they more likely to need <code>ApplicationContext</code>?</p>
<p>Thanks for any help. I know a lot of these questions are probably answered in the reference manual, but I'm having a hard time finding a clear breakdown of these two interfaces and the pros/cons of each without reading thru the manual with a fine-tooth comb.</p>
| [
{
"answer_id": 2347229,
"author": "srinivas reddy",
"author_id": 282661,
"author_profile": "https://Stackoverflow.com/users/282661",
"pm_score": 4,
"selected": false,
"text": "ApplicationContext"
},
{
"answer_id": 2349891,
"author": "Lyle",
"author_id": 80144,
"author... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4249/"
] |
243,388 | <p>I <del>understand (I think) the basic idea behind RESTful-ness. Use HTTP methods semantically - GET gets, PUT puts, DELETE deletes, etc... Right?</del> thought I understood the idea behind REST, but I think I'm confusing that with the details of an HTTP implementation. What is the driving idea behind rest, why is this becoming an important thing? Have people actually been using it for a long time, in a corner of the internets that my flashlight never shined upon?
<hr/>
The Google talk mentions Atom Publishing Protocols having a lot of synergy with RESTful implementations. Any thoughts on that?</p>
| [
{
"answer_id": 1081615,
"author": "pbreitenbach",
"author_id": 42048,
"author_profile": "https://Stackoverflow.com/users/42048",
"pm_score": 7,
"selected": true,
"text": "POST /user\nfname=John&lname=Doe&age=25\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] |
243,408 | <p>This is the error, it's basically a security warning</p>
<p><a href="http://img357.imageshack.us/img357/7992/visualstudiowarninggr4.jpg" rel="nofollow noreferrer">Warning message http://img357.imageshack.us/img357/7992/visualstudiowarninggr4.jpg</a></p>
<p>(And here's the text grabbed off the dialog box)
Security Warning for WindowsApplication4 __________________________I
The WindowsApplication4 project file has been customized and could present a security risk by executing custom
build steps when opened in Microsoft Visual Studio. If this project came from an untrustwoithy source, it could
cause damage to your computer or compromise your private information.
More Details
Project load options
0 Load project for browsing
Opens the project in Microsoft Visual Studio with increased security. This option allows you to browse the
contents of the project, but some functionality, such as IntelliSense, is restricted, When a project is loaded
for browsing, actions such as building, cleaning, publishing, or opening designers could still remain unsafe.
Load project normally
Opens the project normally in Microsoft Visual Studio. Use this option if you trust the source and
understand the potential risks involved. Microsoft Visual Studio does not restrict any project
functionality and will not prompt you again for this project.
Ask me for every project in this solution
OK L Cancel</p>
<p>When click the more details button get this:</p>
<p>Microsoft Visual Studio ______
An item referring to the file was found in the project file
“C:\Users\mgriffiths\Documents\Visual Studio
2008\ProjectATemp\Win dowsApplication4\WindowsApplicdtion4\W in
dowsApplication4.vbproj”. Since this file is located within a system
directory, root directory, or network share, it could be harmful to write
to this file.
OK</p>
| [
{
"answer_id": 10699178,
"author": "Slappy",
"author_id": 765955,
"author_profile": "https://Stackoverflow.com/users/765955",
"pm_score": 2,
"selected": false,
"text": "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\<VS_VERSION>\\MSBuild\\SafeImports]\n\"<YOUR_NAME>\"=\"<PATH\\T... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,409 | <p>I need to set the fetch mode on my hibernate mappings to be eager in some cases, and lazy in others. I have my default (set through the hbm file) as lazy="true". How do I override this setting in code? MyClass has a set defined of type MyClass2 for which I want to set the FetchMode to EAGER.</p>
<p>Currently, I have something like:</p>
<pre><code>Session s = HibernateUtil.getSessionFactory().openSession();
MyClass c = (MyClass)session.get(MyClass.class, myClassID);
</code></pre>
| [
{
"answer_id": 243488,
"author": "Mat Mannion",
"author_id": 6282,
"author_profile": "https://Stackoverflow.com/users/6282",
"pm_score": 4,
"selected": true,
"text": "Criteria crit = session.createCriteria(MyClass.class);\ncrit.add(Restrictions.eq(\"id\", myClassId));\ncrit.setFetchMode(... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] |
243,417 | <p>How do you pass "this" to the constructor for ObjectDataProvider in XAML.</p>
<p>Lets say my presenter class is:</p>
<pre><code>public class ApplicationPresenter(IView view){}
</code></pre>
<p>and that my UserControl implements IView.</p>
<p>What do I pass to the ConstructorParameters in the code below so that the UserControl can create the ApplicationPresenter using the default constructor? </p>
<pre><code><ObjectDataProvider x:Key="ApplicationPresenterDS"
ObjectType="{x:Type Fenix_Presenters:ApplicationPresenter}"
ConstructorParameters="{ ?? what goes here ??}" d:IsDataSource="True" />
</code></pre>
<p>I only need to do this so that I can use Blend 2. I know that I can do this in the code behind, but if I do I can't instantiate the class from within Blend. I also know that I can create a parameterless constructor for ApplicationPresenter and pass it a dummy class that implements IView, but I would rather do this in markup if at all possible.</p>
<p>My code behind at the moment is:</p>
<pre><code>public MyUserControl()
{
InitializeComponent();
DataContext = new ApplicationPresenter(this);
}
</code></pre>
| [
{
"answer_id": 243429,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 0,
"selected": false,
"text": "x:Name=\"myUserCotrol\"\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30046/"
] |
243,459 | <p>How would I expose an <em>Objective-C</em> method within JavaScript when using the <em>iPhone SDK</em> when using the <code>UIWebView</code>?</p>
<p>Any help would be appreciated!</p>
| [
{
"answer_id": 243505,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 6,
"selected": true,
"text": "-webView:shouldStartLoadWithRequest:navigationType:"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46304/"
] |
243,464 | <p>I was mapping a relation using something like the following </p>
<pre><code><map name="Foo" cascade="all-delete-orphan" lazy="false">
<key column="FooId"/>
<index column="FooType" type="Domain.Enum.FooType, Domain"/>
<element column ="FooStatus" type="Domain.Enum.FooStatus, Domain"/>
</map>
</code></pre>
<p>The class is like this</p>
<pre><code>namespace Domain {
public class Enum {
public enum FooType {
Foo1,
Foo2,
...
Foo50}
public enum FooStatus {
NotNeeded,
NeededFor1,
NeededFor2,
NeededFor3,
NiceToHave}
}
}
</code></pre>
<p>Can I do this using Fluent Nhibernate?
If not can I map a class mixing Fluent and XML?</p>
| [
{
"answer_id": 247036,
"author": "Nikelman",
"author_id": 32388,
"author_profile": "https://Stackoverflow.com/users/32388",
"pm_score": 0,
"selected": false,
"text": "namespace Domain \n{\npublic virtual IDictionary<FooType, FooStatus> MyFoo { set; get; }\n}\n"
}
] | 2008/10/28 | [
"https://Stackoverflow.com/questions/243464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
243,469 | <p>I have a .Net app that will allow the users to attach files to a SQL Server 2005 database. I want to limit the filesize to 10MB, so from what I can tell, I have to declare the datatype varbinary(max), since the max size I can actually specify is 8000 bytes. But the ~2GB filesize varbinary(max) allows seems like overkill. Is there a way for me to limit it at 10MB in the database, or do I just need to check that they're not trying to attach something larger on the frontend.</p>
| [
{
"answer_id": 243495,
"author": "mohammedn",
"author_id": 29268,
"author_profile": "https://Stackoverflow.com/users/29268",
"pm_score": 0,
"selected": false,
"text": "</configuration>\n </system.web>\n <httpRuntime maxRequestLength=\"60000\"/>\n </system.web>\n</configuration>\... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30415/"
] |
243,489 | <p>I am doing an Financial Winforms application and am having some trouble with the controls.</p>
<p>My customer needs to insert decimal values all over the place (Prices, Discounts etc) and I'd like to avoid some of the repeating validation.</p>
<p>So I immediately tried the MaskedTextBox that would fit my needs (with a Mask like "€ 00000.00"), if it weren't for the focus and the length of the mask.</p>
<p>I can't predict how big the numbers are my customer is going to enter into the app. </p>
<p>I also can't expect him to start everything with 00 to get to the comma. Everything should be keyboard-friendly.</p>
<p>Am I missing something or is there simply no way (beyond writing a custom control) to achieve this with the standard Windows Forms controls?</p>
| [
{
"answer_id": 243536,
"author": "Abel Gaxiola",
"author_id": 31191,
"author_profile": "https://Stackoverflow.com/users/31191",
"pm_score": 4,
"selected": true,
"text": " protected override void OnKeyPress(KeyPressEventArgs e)\n {\n if (!char.IsNumber(e.KeyChar) & (Keys)e.Ke... | 2008/10/28 | [
"https://Stackoverflow.com/questions/243489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21699/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.