qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
552,555
<p>I have a project that compiles with some warnings. It's an iPhone project that uses some methods on NSDate, that are seemingly not the headers of the iPhone SDK, but work flawlessly none the less. When I call these methods I get warnings like:</p> <p><a href="http://beautifulpixel.com/assets/NSDate_Warnings-20090...
[ { "answer_id": 552581, "author": "epatel", "author_id": 842, "author_profile": "https://Stackoverflow.com/users/842", "pm_score": 3, "selected": true, "text": "<p>You can write a short interface extension early in you .m file to suppress these warnings</p>\n\n<p>Example:</p>\n\n<pre><cod...
2009/02/16
[ "https://Stackoverflow.com/questions/552555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62076/" ]
I have a project that compiles with some warnings. It's an iPhone project that uses some methods on NSDate, that are seemingly not the headers of the iPhone SDK, but work flawlessly none the less. When I call these methods I get warnings like: [NSDate warnings http://beautifulpixel.com/assets/NSDate\_Warnings-20090215...
You can write a short interface extension early in you .m file to suppress these warnings Example: ``` @interface NSDate (SuppressSomWarnings) - (void)dateWithNaturalLanguageString:(NSString*)_str; @end ```
552,628
<p>I want to run an update query against a production database and as good little developer I am trying to make it as safe as possible. I am looking to do the following</p> <pre><code>BEGIN TRANSACTION UPDATE table_x SET col_y = 'some_value' . . . IF (@@error &lt;&gt; 0) BEGIN ROLLBACK END ELSE BEG...
[ { "answer_id": 552670, "author": "Assaf Lavie", "author_id": 11208, "author_profile": "https://Stackoverflow.com/users/11208", "pm_score": 1, "selected": true, "text": "<p>I don't think this is necessary as there is the concept of implicit commit/rollback.</p>\n\n<p>From <a href=\"http:/...
2009/02/16
[ "https://Stackoverflow.com/questions/552628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62544/" ]
I want to run an update query against a production database and as good little developer I am trying to make it as safe as possible. I am looking to do the following ``` BEGIN TRANSACTION UPDATE table_x SET col_y = 'some_value' . . . IF (@@error <> 0) BEGIN ROLLBACK END ELSE BEGIN COMMIT END `...
I don't think this is necessary as there is the concept of implicit commit/rollback. From [MySQL docs](http://dev.mysql.com/doc/refman/5.1/en/innodb-implicit-commit.html): > > By default, MySQL starts the session > for each new connection with > autocommit mode enabled, so MySQL does > a commit after each SQL st...
552,629
<p>Is it possible to print the class name from within a static function?</p> <p>e.g ...</p> <pre><code>public class foo { static void printName() { // Print the class name e.g. foo } } </code></pre>
[ { "answer_id": 552632, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx\" rel=\"nofollow noreferrer\...
2009/02/16
[ "https://Stackoverflow.com/questions/552629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
Is it possible to print the class name from within a static function? e.g ... ``` public class foo { static void printName() { // Print the class name e.g. foo } } ```
You have three options to get the type (and therefore the name) of `YourClass` that work in a static function: 1. `typeof(YourClass)` - fast (0.043 microseconds) 2. `MethodBase.GetCurrentMethod().DeclaringType` - slow (2.3 microseconds) 3. `new StackFrame().GetMethod().DeclaringType` - slowest (17.2 microseconds) If ...
552,638
<p>I have a function which takes a reference to an object:</p> <pre><code>void move(Ball&amp; ball); </code></pre> <p>I have another function calling 'move()' which has a pointer to ball:</p> <pre><code>void foo(Ball* ball){ //call move() } </code></pre> <p>How is <code>foo()</code> supposed to pass ball to <code>...
[ { "answer_id": 552640, "author": "Fredrik Jansson", "author_id": 58237, "author_profile": "https://Stackoverflow.com/users/58237", "pm_score": 5, "selected": true, "text": "<p>The first one, move(*ball).</p>\n\n<p>the second one, move(ball) tries to pass the pointer and the third one, mo...
2009/02/16
[ "https://Stackoverflow.com/questions/552638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14316/" ]
I have a function which takes a reference to an object: ``` void move(Ball& ball); ``` I have another function calling 'move()' which has a pointer to ball: ``` void foo(Ball* ball){ //call move() } ``` How is `foo()` supposed to pass ball to `move()`? Should it be like: ``` move(*ball); ``` or: ``` move(ba...
The first one, move(\*ball). the second one, move(ball) tries to pass the pointer and the third one, move(&ball) tries to pass a pointer to a pointer.
552,652
<p>This is another question based on an answer that was given to me.</p> <p>What I need is the ability to do a system command line zip of large files based on what the web user selects and then prompt them or force a download. Can this be done?</p>
[ { "answer_id": 552677, "author": "Assaf Lavie", "author_id": 11208, "author_profile": "https://Stackoverflow.com/users/11208", "pm_score": 0, "selected": false, "text": "<p>How about <a href=\"http://www.gzip.org/\" rel=\"nofollow noreferrer\">gzip</a>?</p>\n" }, { "answer_id": 5...
2009/02/16
[ "https://Stackoverflow.com/questions/552652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is another question based on an answer that was given to me. What I need is the ability to do a system command line zip of large files based on what the web user selects and then prompt them or force a download. Can this be done?
This can definitely be done - in fact there are many different ways to do it. One way would be to use the PHP Zip extension (<http://www.php.net/manual/en/book.zip.php>) to make the file archive. Then, to let the user download the file, you'll need to set the headers of your download page, like so: ``` header("Cache-C...
552,659
<p>As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. </p> <p>As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. </p> <p>How does Git calculate the SHA1 digest? Does it do it ...
[ { "answer_id": 552721, "author": "Dale Hagglund", "author_id": 52210, "author_profile": "https://Stackoverflow.com/users/52210", "pm_score": 2, "selected": false, "text": "<p>Take a look at the man page for <a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-hash-object.html\" ...
2009/02/16
[ "https://Stackoverflow.com/questions/552659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52416/" ]
As I understand it when Git assigns a SHA1 hash to a file this SHA1 is unique to the file based on its contents. As a result if a file moves from one repository to another the SHA1 for the file remains the same as its contents have not changed. How does Git calculate the SHA1 digest? Does it do it on the full uncom...
This is how Git calculates the SHA1 for a file (or, in Git terms, a "blob"): ```sh sha1("blob " + filesize + "\0" + data) ``` So you can easily compute it yourself without having Git installed. Note that "\0" is the NULL-byte, not a two-character string. For example, the hash of an empty file: ```sh sha1("blob 0\0...
552,695
<p>Does anybody know how to switch off exception handling option in MSVC? I tried to set the option 'Enable C++ exceptions' to 'NO' and I got warning: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify <code>/EHsc</code>.</p> <p>I would like to switch off the exception handler, to...
[ { "answer_id": 552723, "author": "dirkgently", "author_id": 66692, "author_profile": "https://Stackoverflow.com/users/66692", "pm_score": 0, "selected": false, "text": "<p>Do you still have try/catch block(s) in your code?</p>\n\n<p>The first thing to do when you get stuck is look up the...
2009/02/16
[ "https://Stackoverflow.com/questions/552695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anybody know how to switch off exception handling option in MSVC? I tried to set the option 'Enable C++ exceptions' to 'NO' and I got warning: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify `/EHsc`. I would like to switch off the exception handler, too, but I don't know h...
Most likely you're including one or more standard C++ headers that contain try/catch. The most typical case would be `<iostream>` - you will get this error on a file which consists of a single line that just includes that. Any other stream header will also do, as will locales. If you look closely at the error message,...
552,718
<p>We are trying to use Log4Net to log from our IIS 6-deployed WCF Application. We are trying to log to a file, but can't seem to get the log files to be created, let alone see the logging output in them. The pertinent pieces of out web.config are:</p> <pre><code>&lt;sectionGroup name="common"&gt; &lt;section na...
[ { "answer_id": 552726, "author": "Ruben Bartelink", "author_id": 11635, "author_profile": "https://Stackoverflow.com/users/11635", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://live.sysinternals.com/tools/procmon.exe\" rel=\"noreferrer\">ProcessMonitor from SysInterna...
2009/02/16
[ "https://Stackoverflow.com/questions/552718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2455/" ]
We are trying to use Log4Net to log from our IIS 6-deployed WCF Application. We are trying to log to a file, but can't seem to get the log files to be created, let alone see the logging output in them. The pertinent pieces of out web.config are: ``` <sectionGroup name="common"> <section name="logging" type="Common...
Use [ProcessMonitor from SysInternals](http://live.sysinternals.com/tools/procmon.exe) to find out where permissions are being refused (Potentially you can determine the same info by attaching a debugger and trapping on exceptions, not in Just My Code) Are you sure that the process under which the service is running ...
552,724
<p>I want to check in linux bash whether a file was created more than x time ago.</p> <p>let's say the file is called text.txt and the time is 2 hours.</p> <pre><code> if [ what? ] then echo "old enough" fi </code></pre>
[ { "answer_id": 552739, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 4, "selected": false, "text": "<p>Creation time isn't stored.</p>\n\n<p>What are stored are three timestamps (generally, they can be turned off on ...
2009/02/16
[ "https://Stackoverflow.com/questions/552724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63051/" ]
I want to check in linux bash whether a file was created more than x time ago. let's say the file is called text.txt and the time is 2 hours. ``` if [ what? ] then echo "old enough" fi ```
Only for modification time ``` if test `find "text.txt" -mmin +120` then echo old enough fi ``` You can use `-cmin` for change or `-amin` for access time. As others pointed I don’t think you can track creation time.
552,731
<p>I read this <a href="http://www.codinghorror.com/blog/archives/001015.html" rel="nofollow noreferrer">post about card shuffling</a> and in many shuffling and sorting algorithms you need to swap two items in a list or array. But what does a good and efficient Swap method look like?</p> <p>Let's say for a <code>T[]</...
[ { "answer_id": 552742, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<p>Well, the code you have posted (<code>ref cards[n]</code>) can only work with an array (not a list) - but you would...
2009/02/16
[ "https://Stackoverflow.com/questions/552731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
I read this [post about card shuffling](http://www.codinghorror.com/blog/archives/001015.html) and in many shuffling and sorting algorithms you need to swap two items in a list or array. But what does a good and efficient Swap method look like? Let's say for a `T[]` and for a `List<T>`. How would you best implement a ...
Well, the code you have posted (`ref cards[n]`) can only work with an array (not a list) - but you would use simply (where `foo` and `bar` are the two values): ``` static void Swap(ref int foo, ref int bar) { int tmp = foo; foo = bar; bar = tmp; } ``` ~~Or possibly (if you want atomic):~~ ``` Interlocke...
552,736
<p>Is there any way in NHibernate that I can use the following Entities</p> <pre><code>public class Person { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList&lt;Pet&gt; Pets { get; set; } } public class Pet { public virtual int Id { get; set; } publ...
[ { "answer_id": 552869, "author": "bleevo", "author_id": 45909, "author_profile": "https://Stackoverflow.com/users/45909", "pm_score": 0, "selected": false, "text": "<p><a href=\"https://stackoverflow.com/questions/552805/c-reflection-generics\">C# Reflection &amp; Generics</a></p>\n\n<p>...
2009/02/16
[ "https://Stackoverflow.com/questions/552736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45909/" ]
Is there any way in NHibernate that I can use the following Entities ``` public class Person { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual IList<Pet> Pets { get; set; } } public class Pet { public virtual int Id { get; set; } public virtual string Na...
I modified your example just a bit (in line with many of the suggestions here): ``` public class Person { private IList<Pet> pets; protected Person() {} public Person(string name) { Name = name; pets = new List<Pet>(); } public virtual Guid Id { get; set; } public vir...
552,744
<p>I've recently become interested in algorithms and have begun exploring them by writing a naive implementation and then optimizing it in various ways.</p> <p>I'm already familiar with the standard Python module for profiling runtime (for most things I've found the timeit magic function in IPython to be sufficient), ...
[ { "answer_id": 552810, "author": "Hubert", "author_id": 29525, "author_profile": "https://Stackoverflow.com/users/29525", "pm_score": 8, "selected": true, "text": "<p>This one has been answered already here: <a href=\"https://stackoverflow.com/questions/110259/python-memory-profiler\">Py...
2009/02/16
[ "https://Stackoverflow.com/questions/552744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I've recently become interested in algorithms and have begun exploring them by writing a naive implementation and then optimizing it in various ways. I'm already familiar with the standard Python module for profiling runtime (for most things I've found the timeit magic function in IPython to be sufficient), but I'm al...
This one has been answered already here: [Python memory profiler](https://stackoverflow.com/questions/110259/python-memory-profiler) Basically you do something like that (cited from [Guppy-PE](http://guppy-pe.sourceforge.net/#Heapy)): ``` >>> from guppy import hpy; h=hpy() >>> h.heap() Partition of a set of 48477 obj...
552,756
<p>UPDATE: An alternative title for this could be: How do I call javascript from my silverlight 2.0 application.</p> <p>Here is a quick question for all you Silverlight gurus.</p> <p>I have a Silverlight app that displays a stopwatch countdown. The app is hosted in an ASP.Net web application, What I want it to do is...
[ { "answer_id": 552772, "author": "Blounty", "author_id": 33944, "author_profile": "https://Stackoverflow.com/users/33944", "pm_score": 1, "selected": false, "text": "<p>It is possible for a silverlight app to call out into javascript on the page which in turn could force your page refres...
2009/02/16
[ "https://Stackoverflow.com/questions/552756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5007/" ]
UPDATE: An alternative title for this could be: How do I call javascript from my silverlight 2.0 application. Here is a quick question for all you Silverlight gurus. I have a Silverlight app that displays a stopwatch countdown. The app is hosted in an ASP.Net web application, What I want it to do is when the stopwat...
[Apparently](http://timheuer.com/blog/archive/2008/03/09/calling-javascript-functions-from-silverlight-2.aspx) you can call a JS script from Silverlight using ``` HtmlPage.Window.CreateInstance ``` or ``` HtmlPage.Window.Invoke ``` The JavaScript to [refresh](http://www.quackit.com/javascript/javascript_refresh_...
552,762
<p>wondered if you could help me please? I have node in xml that is as followed</p> <blockquote>$LOG: 08880xbpnd $<br /> fhdsafidsfsd<br /> df<br /> sd<br /> fsd<br /> f<br /> sd<br /> fsd</blockquote> <p>I was wondering is there anyway to make all the text go on to one line so that it then can be passsed through to ...
[ { "answer_id": 552776, "author": "andynormancx", "author_id": 46354, "author_profile": "https://Stackoverflow.com/users/46354", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/ms256063(VS.85).aspx\" rel=\"noreferrer\">normalize-space()<...
2009/02/16
[ "https://Stackoverflow.com/questions/552762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66878/" ]
wondered if you could help me please? I have node in xml that is as followed > $LOG: 08880xbpnd $ > > fhdsafidsfsd > > df > > sd > > fsd > > f > > sd > > fsd I was wondering is there anyway to make all the text go on to one line so that it then can be passsed through to a javascript function? so ...
**Unfortunately, the [`normalize-space()`](http://www.w3.org/TR/xpath#function-normalize-space) function (used in the answer of andynormancx) does more than deleting newlines**. It deletes all leading and trailing whitespace and **it replaces any group of inner contigious whitespace with a single space character**. ...
552,766
<pre><code>for (i=0 ; i&lt;=10; i++) { .. .. } i=0; while(i&lt;=10) { .. .. i++; } </code></pre> <p>In for and while loop, which one is better, performance wise?</p>
[ { "answer_id": 552783, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "<p>(update)\nActually - there is one scenario where the <code>for</code> construct is more efficient; looping on an ar...
2009/02/16
[ "https://Stackoverflow.com/questions/552766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54271/" ]
``` for (i=0 ; i<=10; i++) { .. .. } i=0; while(i<=10) { .. .. i++; } ``` In for and while loop, which one is better, performance wise?
(update) Actually - there is one scenario where the `for` construct is more efficient; looping on an array. The compiler/JIT has optimisations for this scenario *as long as you use* `arr.Length` *in the condition*: ``` for(int i = 0 ; i < arr.Length ; i++) { Console.WriteLine(arr[i]); // skips bounds check } ``` ...
552,796
<p>In C# the Main class has string[] args parameter.</p> <p>What is that for and where does it get used?</p>
[ { "answer_id": 552798, "author": "andynormancx", "author_id": 46354, "author_profile": "https://Stackoverflow.com/users/46354", "pm_score": 4, "selected": false, "text": "<p>For passing in command line parameters. For example <code>args[0]</code> will give you the first command line para...
2009/02/16
[ "https://Stackoverflow.com/questions/552796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61976/" ]
In C# the Main class has string[] args parameter. What is that for and where does it get used?
From the [C# programming guide on MSDN](http://msdn.microsoft.com/en-us/library/cb20e19t.aspx): **The parameter of the Main method is a String array that represents the command-line arguments** So, if I had a program (MyApp.exe) like this: ``` class Program { static void Main(string[] args) { foreach (var ar...
552,818
<p><strong>"I am using flash as3, php and mysql"</strong></p> <p>What is the difference between:</p> <pre><code>$username = $_POST['username']; $password = md5( $_POST['password']); </code></pre> <p>and</p> <pre><code>$username = mysql_real_escape_string( $_POST['username']); $password = mysql_real_escape_...
[ { "answer_id": 552837, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 2, "selected": false, "text": "<p>You just need the <code>mysql_real_escape_string</code> if you want to use a string in a query that is then executed by t...
2009/02/16
[ "https://Stackoverflow.com/questions/552818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65379/" ]
**"I am using flash as3, php and mysql"** What is the difference between: ``` $username = $_POST['username']; $password = md5( $_POST['password']); ``` and ``` $username = mysql_real_escape_string( $_POST['username']); $password = mysql_real_escape_string(md5( $_POST['password'])); ``` I am sending and ...
Remember that mysql\_real\_escape\_string() needs an open database connection to work properly; if you're calling it before using mysql\_connect, it won't have the desired effect.
552,822
<p>I'm looking for some random crashes in an old c++ application. Using sysinternals process explorer, I noticed the app losing handles, and extracted the exact situation, where the program is losing handles to a very short piece of code.</p> <pre><code>DWORD WINAPI MyTestThread( void* PThread) { _endthreadex(0); r...
[ { "answer_id": 552944, "author": "zildjohn01", "author_id": 66341, "author_profile": "https://Stackoverflow.com/users/66341", "pm_score": 0, "selected": false, "text": "<p>Have you tried testing this with Win32's CreateThread? That could possibly narrow down the problem to the CRT.</p>\n...
2009/02/16
[ "https://Stackoverflow.com/questions/552822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
I'm looking for some random crashes in an old c++ application. Using sysinternals process explorer, I noticed the app losing handles, and extracted the exact situation, where the program is losing handles to a very short piece of code. ``` DWORD WINAPI MyTestThread( void* PThread) { _endthreadex(0); return 0; } in...
Check whether some DLL which is linked to your exe is doing something strange in its DLLMain in response to DLL\_THREAD\_ATTACH notifications.
552,828
<p>I have 10 threads writing thousands of small buffers (16-30 bytes each) to a huge file in random positions. Some of the threads throw OutOfMemoryException on FileStream.Write() opreation. </p> <p>What is causing the OutOfMemoryException ? What to look for?</p> <p>I'm using the FileStream like this (for every writt...
[ { "answer_id": 552856, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>Buffers aren't generally allocated inside the FileStream. Perhaps the problem is the line \"writing thousands of s...
2009/02/16
[ "https://Stackoverflow.com/questions/552828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I have 10 threads writing thousands of small buffers (16-30 bytes each) to a huge file in random positions. Some of the threads throw OutOfMemoryException on FileStream.Write() opreation. What is causing the OutOfMemoryException ? What to look for? I'm using the FileStream like this (for every written item - this co...
If ten threads are opening files as your code shows, then you have a maximum of ten undisposed FileStream objects at any one time. Yes, FileStream **does** have an internal buffer, the size of which you specify with "BigBufferSizeInBytes" in your code. Could you please disclose the exact value? If this is big enough (e...
552,857
<p>As far as I know, in C# all fields are private for default, if not marked otherwise.</p> <pre><code>class Foo { private string bar; } class Foo { string bar; } </code></pre> <p>I guess these two declarations are equal.</p> <p>So my question is: what for should I mark private variables as <code>private</code>...
[ { "answer_id": 552870, "author": "Damien", "author_id": 35454, "author_profile": "https://Stackoverflow.com/users/35454", "pm_score": 1, "selected": false, "text": "<p>Up to you. Do what's best for readability or makes sense in your case. I mark them as private just to make it clear thou...
2009/02/16
[ "https://Stackoverflow.com/questions/552857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41956/" ]
As far as I know, in C# all fields are private for default, if not marked otherwise. ``` class Foo { private string bar; } class Foo { string bar; } ``` I guess these two declarations are equal. So my question is: what for should I mark private variables as `private` if they already are private?
I've been on the fence for a while about this. I used to argue for leaving it implicit, but now I think I'm tipped over towards making it explicit. **Reasons for leaving it implicit:** * It means there's a bigger difference for non-private members (or anything with more access than the default); this highlights the d...
552,866
<p>I'm doing a lot of insert queries, and I think it would be best to write a subroutine for it. Something like <code>insertRow($table, @stuff_to_insert)</code>. But how can I make the subroutine dynamic when it comes to the <code>@stuff_to_insert</code>, which can be anything from 1-5 arguments?</p>
[ { "answer_id": 552893, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 1, "selected": false, "text": "<p>Something like:</p>\n\n<pre><code>sub insertRow\n{\n my $table = shift;\n my $placeholders = join(',', map { \"?...
2009/02/16
[ "https://Stackoverflow.com/questions/552866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm doing a lot of insert queries, and I think it would be best to write a subroutine for it. Something like `insertRow($table, @stuff_to_insert)`. But how can I make the subroutine dynamic when it comes to the `@stuff_to_insert`, which can be anything from 1-5 arguments?
The best solution is probably using a ORM system such as [DBIx::Class](http://search.cpan.org/dist/DBIx-Class/). They make handling SQL much easier. If you choose to stay on raw DBI, I would advice you to use prepared statements like this: ``` my $query = sprintf 'INSERT INTO %s VALUES(%s)', dbh->quote_identifier($ta...
552,880
<p>I have tried the following command unsuccessfully:</p> <pre><code>git push 12.12.12.123:/proj.git master </code></pre> <p>It asks my password, but each time it rejects it.</p> <p>I used the following commands to set up Git:</p> <pre><code>git --bare update-server-info chmod a+x hooks/post-update </code></pre> <...
[ { "answer_id": 552914, "author": "Luka Marinko", "author_id": 19814, "author_profile": "https://Stackoverflow.com/users/19814", "pm_score": 3, "selected": true, "text": "<p>you need to do git init in your repo</p>\n\n<p><a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-init.h...
2009/02/16
[ "https://Stackoverflow.com/questions/552880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54964/" ]
I have tried the following command unsuccessfully: ``` git push 12.12.12.123:/proj.git master ``` It asks my password, but each time it rejects it. I used the following commands to set up Git: ``` git --bare update-server-info chmod a+x hooks/post-update ``` The last command gives me this error: ``` chmod: Cann...
you need to do git init in your repo <http://www.kernel.org/pub/software/scm/git/docs/git-init.html> Here is nice and quick tuturial: <http://toolmantim.com/articles/setting_up_a_new_remote_git_repository> This is a bit longer once In short to set up git: ``` $ ssh myserver.com Welcome to myserver.com! $ mkdir /v...
552,904
<p>Unless I'm missing something obvious here, there is no way of disbabling one or more rows in a DataGrid. I would expect a disabledRows or disabledRowIndidices property on the DataGrid or List component but that doesn't seem to exist.</p> <p>I found a "rendererArray" property which is scoped to mx_internal and conta...
[ { "answer_id": 564144, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Alex Harui provides a good example with source here, <a href=\"http://blogs.adobe.com/aharui/2007/06/disabling_list_selecti...
2009/02/16
[ "https://Stackoverflow.com/questions/552904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17255/" ]
Unless I'm missing something obvious here, there is no way of disbabling one or more rows in a DataGrid. I would expect a disabledRows or disabledRowIndidices property on the DataGrid or List component but that doesn't seem to exist. I found a "rendererArray" property which is scoped to mx\_internal and contains all i...
To do this you will need some data for that row to signify that it is uneditable. Then when the "itemEditBeginning" then check the data or row index to enable/disable the default behavior with event.preventDefault ... ``` public function preventEditing(event:DataGridEvent):void { var status : Boolean = ArrayObj...
552,905
<p>Thanks for the three excellent answers which all identified my problem of using &quot;onclick = ...&quot; instead of &quot;observe( &quot;click&quot;,...&quot;</p> <p>But the award for Accepted Answer has to go to Paolo Bergantino for the mechanism of adding a class name to mark the dragged element, which saved me s...
[ { "answer_id": 552963, "author": "Noel Walters", "author_id": 53030, "author_profile": "https://Stackoverflow.com/users/53030", "pm_score": 0, "selected": false, "text": "<p>After some experiments I've come up with the following fix. </p>\n\n<p>But I'm less than happy with it as it seems...
2009/02/16
[ "https://Stackoverflow.com/questions/552905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53030/" ]
Thanks for the three excellent answers which all identified my problem of using "onclick = ..." instead of "observe( "click",..." But the award for Accepted Answer has to go to Paolo Bergantino for the mechanism of adding a class name to mark the dragged element, which saved me some more work! --- In my HTML I have ...
``` <script> document.observe("dom:loaded", function() { $$( ".thumbnail a img" ).each(function(img) { new Draggable(img, { revert: true, onEnd: function(draggable, event) { $(draggable.element).up('a').addClassName('been_dragged'); } }); }); ...
552,921
<p>I call <code>Bind()</code> and then <code>Listen()</code> on a System.Net.Sockets.Socket. None of these calls throw an exception.</p> <p>Later, I make a call to:</p> <pre><code>Socket.Select(myreadlist,mywritelist,myerrorlist,0); </code></pre> <p>with myreadlist and myerrorlist containing the socket in question. ...
[ { "answer_id": 553087, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": true, "text": "<p>I don't know C# but I do know UNIX sockets. My first thought was that you hadn't called accept() on the socket before ...
2009/02/16
[ "https://Stackoverflow.com/questions/552921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47901/" ]
I call `Bind()` and then `Listen()` on a System.Net.Sockets.Socket. None of these calls throw an exception. Later, I make a call to: ``` Socket.Select(myreadlist,mywritelist,myerrorlist,0); ``` with myreadlist and myerrorlist containing the socket in question. Select reports my socket as having had an error, by lea...
I don't know C# but I do know UNIX sockets. My first thought was that you hadn't called accept() on the socket before selecting for read but (and this is proof I know less about sockets than I thought) you can select in the listen state to see which sockets can be accepted. Oh well, we live and learn, even at my advanc...
552,922
<p>Getting the following error</p> <p>Multiple controls with the same ID 'ltlItemCode' were found. FindControl requires that controls have unique IDs.</p> <p>This Error does not happen on page loads but when I change the value of a drop down which has AutoPostBack="true".</p> <p>Code is </p> <pre><code> //Numb...
[ { "answer_id": 553487, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 2, "selected": false, "text": "<pre><code>\nItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl(\"ltlItemCode\") as Literal);\...
2009/02/16
[ "https://Stackoverflow.com/questions/552922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Getting the following error Multiple controls with the same ID 'ltlItemCode' were found. FindControl requires that controls have unique IDs. This Error does not happen on page loads but when I change the value of a drop down which has AutoPostBack="true". Code is ``` //Number of Services numberofServices =...
``` ItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl("ltlItemCode") as Literal); ``` I'm guessing that is the problem, it looks like you're adding the same control over and over, but I'm not sure. Try changing the .ID of that newly added Literal. Also, I've never used ["EnsureID()"](http:...
552,928
<p>My question is related to the iphone appstore deployment handles deployment for when different versions of the iphone request the application. Also, does one have to submit a build for each version i.e 2.0,2.1 and 2.2. I've developed for Windows mobile and redirected users to a certain url based on the windows mobil...
[ { "answer_id": 553487, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 2, "selected": false, "text": "<pre><code>\nItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl(\"ltlItemCode\") as Literal);\...
2009/02/16
[ "https://Stackoverflow.com/questions/552928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51630/" ]
My question is related to the iphone appstore deployment handles deployment for when different versions of the iphone request the application. Also, does one have to submit a build for each version i.e 2.0,2.1 and 2.2. I've developed for Windows mobile and redirected users to a certain url based on the windows mobile p...
``` ItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl("ltlItemCode") as Literal); ``` I'm guessing that is the problem, it looks like you're adding the same control over and over, but I'm not sure. Try changing the .ID of that newly added Literal. Also, I've never used ["EnsureID()"](http:...
552,933
<p>I'm getting a strange NHibernate exception when I try and create a SessionFactory. I've narrowed down the exception 'Unable to cast object of type 'NHibernate.Mapping.Bag' to type 'NHibernate.Mapping.IKeyValue' to the following mapping on the Company object:</p> <pre><code>&lt;bag name="Images" cascade="none"&gt; ...
[ { "answer_id": 553487, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 2, "selected": false, "text": "<pre><code>\nItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl(\"ltlItemCode\") as Literal);\...
2009/02/16
[ "https://Stackoverflow.com/questions/552933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29603/" ]
I'm getting a strange NHibernate exception when I try and create a SessionFactory. I've narrowed down the exception 'Unable to cast object of type 'NHibernate.Mapping.Bag' to type 'NHibernate.Mapping.IKeyValue' to the following mapping on the Company object: ``` <bag name="Images" cascade="none"> <key column="Compan...
``` ItemCodeCell.Controls.Add((Literal)additionalServices[cell - 1].FindControl("ltlItemCode") as Literal); ``` I'm guessing that is the problem, it looks like you're adding the same control over and over, but I'm not sure. Try changing the .ID of that newly added Literal. Also, I've never used ["EnsureID()"](http:...
552,951
<p>I've used JQuery to make the elements in a table draggable. (I've never used JQuery before this). It works fine, but is <em>very</em> slow. For example, from the moment I click and hold on an item, to the moment the cursor changes is about 2 seconds. This is on Firefox 3.0.6. Once the item is being dragged, there's ...
[ { "answer_id": 555185, "author": "Snapey", "author_id": 67167, "author_profile": "https://Stackoverflow.com/users/67167", "pm_score": 1, "selected": false, "text": "<p>I don't suppose its to do with addClasses ?\n<em>If set to false, will prevent the ui-droppable class from being added. ...
2009/02/16
[ "https://Stackoverflow.com/questions/552951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
I've used JQuery to make the elements in a table draggable. (I've never used JQuery before this). It works fine, but is *very* slow. For example, from the moment I click and hold on an item, to the moment the cursor changes is about 2 seconds. This is on Firefox 3.0.6. Once the item is being dragged, there's a shorter,...
The presence of so many drop targets seems to make the performance so slow. If possible, try setting the table as a single drop target and calculate the target table cell based on the position data in the drop event. Unfortunately, you will also lose the ability to apply styles to individual cells on dragOver and drag...
552,957
<p>Isn't that an inconsistent behavior? (PHP 5.2.6)</p> <pre><code>&lt;?php $a = new SimpleXMLElement('&lt;a/&gt;'); $a-&gt;addAttribute('b', 'One &amp; Two'); //$a-&gt;addChild('c', 'Three &amp; Four'); -- results in "unterminated entity reference" warning! $a-&gt;addChild('c', 'Three &amp;amp; Four'); $a-&gt;d = '...
[ { "answer_id": 552972, "author": "Michael Borgwardt", "author_id": 16883, "author_profile": "https://Stackoverflow.com/users/16883", "pm_score": 0, "selected": false, "text": "<p>I believe this is caused by the <a href=\"http://www.w3.org/TR/REC-xml/#AVNormalize\" rel=\"nofollow noreferr...
2009/02/16
[ "https://Stackoverflow.com/questions/552957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6430/" ]
Isn't that an inconsistent behavior? (PHP 5.2.6) ``` <?php $a = new SimpleXMLElement('<a/>'); $a->addAttribute('b', 'One & Two'); //$a->addChild('c', 'Three & Four'); -- results in "unterminated entity reference" warning! $a->addChild('c', 'Three &amp; Four'); $a->d = 'Five & Six'; print($a->asXML()); ``` Renders...
Just to make sure we're on the same page, you have three situations. 1. The insertion of an ampersand into an attribute using addAttribute 2. The insertion of an ampersand into an element using addChild 3. The insertion of an ampersand into an element by property overloading It's the discrepancy between 2 and 3 that ...
552,960
<p>Bleh; Knowing how to ask the question is always the hardest so I explain a little more.</p> <p>I'm using CAxWindow to create an IE window internally and passing in the URL via the string class argument:</p> <pre><code>CAxWindow wnd; m_hwndWebBrowser = wnd.Create(m_hWnd, rect, m_URI, WS_CHILD|WS_DISABLED, 0); </cod...
[ { "answer_id": 553471, "author": "Allen Rice", "author_id": 49885, "author_profile": "https://Stackoverflow.com/users/49885", "pm_score": 0, "selected": false, "text": "<p>Would it be possible to just wrap everything in a try / catch in the javascript code that is being displayed in the ...
2009/02/16
[ "https://Stackoverflow.com/questions/552960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24525/" ]
Bleh; Knowing how to ask the question is always the hardest so I explain a little more. I'm using CAxWindow to create an IE window internally and passing in the URL via the string class argument: ``` CAxWindow wnd; m_hwndWebBrowser = wnd.Create(m_hWnd, rect, m_URI, WS_CHILD|WS_DISABLED, 0); ``` It's part of an auto...
I found some projects on CodeProject that does something similar... <http://www.codeproject.com/KB/shell/popupblocker.aspx?fid=15235&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=51&select=646577> <http://www.codeproject.com/KB/shell/popupblocker2.aspx?df=100&forumid=15709&fr=51&select=548519#xx548519xx> And also...
552,979
<p>wonder if you could help me out with some Javascript. I have a string that is log message, and i'm waniting to grab a section out of this log and display that on it's own</p> <p>eg.(bear in mind the log section is not case sesitive and any letter can be any case, also could be placed anywhere withing the string)</p...
[ { "answer_id": 553081, "author": "Lieven Keersmaekers", "author_id": 52598, "author_profile": "https://Stackoverflow.com/users/52598", "pm_score": 0, "selected": false, "text": "<p>Matthew, </p>\n\n<p>the following regex should give you anything between <strong>$LOG:</strong> and <stron...
2009/02/16
[ "https://Stackoverflow.com/questions/552979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66878/" ]
wonder if you could help me out with some Javascript. I have a string that is log message, and i'm waniting to grab a section out of this log and display that on it's own eg.(bear in mind the log section is not case sesitive and any letter can be any case, also could be placed anywhere withing the string) **$LOG: 088...
I would use this regular expression: ``` /\$LOG:([^$]+)\$/i ``` So: ``` "$LOG: 08880xbpnd $ fhdsafidsfsd df sd fsd f sd fsd".match(/\$LOG:([^$]+)\$/i) ```
552,982
<p>Need to grant access to users without any role using Spring Security. Anyone how process authentication must be granted to access any URL. So can I do that by something like this or may be somehow else?</p> <pre><code>&lt;http auto-config='true'&gt; &lt;intercept-url pattern="/**" access="ALL" /&gt; &lt;interce...
[ { "answer_id": 553081, "author": "Lieven Keersmaekers", "author_id": 52598, "author_profile": "https://Stackoverflow.com/users/52598", "pm_score": 0, "selected": false, "text": "<p>Matthew, </p>\n\n<p>the following regex should give you anything between <strong>$LOG:</strong> and <stron...
2009/02/16
[ "https://Stackoverflow.com/questions/552982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58965/" ]
Need to grant access to users without any role using Spring Security. Anyone how process authentication must be granted to access any URL. So can I do that by something like this or may be somehow else? ``` <http auto-config='true'> <intercept-url pattern="/**" access="ALL" /> <intercept-url pattern="/login.jsp" f...
I would use this regular expression: ``` /\$LOG:([^$]+)\$/i ``` So: ``` "$LOG: 08880xbpnd $ fhdsafidsfsd df sd fsd f sd fsd".match(/\$LOG:([^$]+)\$/i) ```
552,987
<p>This is probably a silly mistake but I cant see it?! I have classes defining geometry and classes that render that geometry. Right now it is basic triangles and colours for each vertex. </p> <p>Here is the code defining said geometry objects data:</p> <pre><code>CGeometry* g = new CGeometry(); g-&gt;vertexes = new...
[ { "answer_id": 553030, "author": "sth", "author_id": 56338, "author_profile": "https://Stackoverflow.com/users/56338", "pm_score": 2, "selected": false, "text": "<p>The alpha values of your second and third color are set to zero, so they are fully transparent. The first color has alpha=1...
2009/02/16
[ "https://Stackoverflow.com/questions/552987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57482/" ]
This is probably a silly mistake but I cant see it?! I have classes defining geometry and classes that render that geometry. Right now it is basic triangles and colours for each vertex. Here is the code defining said geometry objects data: ``` CGeometry* g = new CGeometry(); g->vertexes = new double[3*3]; g->vertex...
Actually, I think I got it: you're only seeing a small portion of the bottom left corner of your triangle. You need to move away from it to view it entirely: your coordinates are too large.
552,988
<p>In Visual Studio 2005, how can I show a report in ReportViewer control directly on Print-preview mode?</p>
[ { "answer_id": 553072, "author": "lc.", "author_id": 44853, "author_profile": "https://Stackoverflow.com/users/44853", "pm_score": 6, "selected": true, "text": "<p>Use the <code>SetDisplayMode()</code> method:</p>\n\n<pre><code>MyReportViewer.SetDisplayMode(DisplayMode.PrintLayout);\n</c...
2009/02/16
[ "https://Stackoverflow.com/questions/552988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40441/" ]
In Visual Studio 2005, how can I show a report in ReportViewer control directly on Print-preview mode?
Use the `SetDisplayMode()` method: ``` MyReportViewer.SetDisplayMode(DisplayMode.PrintLayout); ```
552,989
<p>Simply,</p> <p>When creating a new aspx page in Visual studio, it automatically adds tags like these:</p> <pre><code>&lt;form id="form1" runat="server"&gt; </code></pre> <p>Are these form tags required to wrap the entire HTML output of the page? e.g.:</p> <pre><code>&lt;body&gt; &lt;form id="form1" runat="server...
[ { "answer_id": 553001, "author": "ctrlalt3nd", "author_id": 61545, "author_profile": "https://Stackoverflow.com/users/61545", "pm_score": 3, "selected": false, "text": "<p>The form tags just need to be placed around any ASP.NET server controls. If they only exist within the actual form o...
2009/02/16
[ "https://Stackoverflow.com/questions/552989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Simply, When creating a new aspx page in Visual studio, it automatically adds tags like these: ``` <form id="form1" runat="server"> ``` Are these form tags required to wrap the entire HTML output of the page? e.g.: ``` <body> <form id="form1" runat="server"> HTML GOES HERE </form> </body> ``` Or can they just be...
The form tags just need to be placed around any ASP.NET server controls. If they only exist within the actual form or you're not using any then it's ok to do so.
552,995
<p>I have a popup menu and I want one of the items to open a sub-menu with a dynamically created list (it's a list of user defined flags). Here's how I'm creating the menu items (<code>FlagAs</code> is the menu item I want to attach the sub-menu to):</p> <pre><code>lNewMenuItems: array[0..flagCount] of tMenuItem; for...
[ { "answer_id": 553049, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 3, "selected": true, "text": "<p>I tried the following in Delphi 2009 and it worked fine:</p>\n\n<pre><code>procedure TForm5.FormCreate(Sender: TObj...
2009/02/16
[ "https://Stackoverflow.com/questions/552995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38883/" ]
I have a popup menu and I want one of the items to open a sub-menu with a dynamically created list (it's a list of user defined flags). Here's how I'm creating the menu items (`FlagAs` is the menu item I want to attach the sub-menu to): ``` lNewMenuItems: array[0..flagCount] of tMenuItem; for I := 0 to flagCount do b...
I tried the following in Delphi 2009 and it worked fine: ``` procedure TForm5.FormCreate(Sender: TObject); var i : Integer; mis : array[0..3] of TMenuItem; begin for i := 0 to 3 do begin mis[i] := tMenuItem.Create(SubMenu); NewMenu(mis[i]); end; SubMenu.Add(mis); end; procedure TForm5.NewMenu(var mi...
552,996
<p>In my code I loop though <code>raw_input()</code> to see if the user has requested to quit. My app can quit before the user quits, but my problem is the app is still alive until I enter a key to return from the blocking function <code>raw_input()</code>. Can I do to force <code>raw_input()</code> to return by maybe ...
[ { "answer_id": 553290, "author": "Paolo Tedesco", "author_id": 15622, "author_profile": "https://Stackoverflow.com/users/15622", "pm_score": 2, "selected": false, "text": "<p>You might use a non-blocking function to read user input.<br>\nThis solution is windows-specific:</p>\n\n<pre><co...
2009/02/16
[ "https://Stackoverflow.com/questions/552996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In my code I loop though `raw_input()` to see if the user has requested to quit. My app can quit before the user quits, but my problem is the app is still alive until I enter a key to return from the blocking function `raw_input()`. Can I do to force `raw_input()` to return by maybe sending it a fake input? Could I ter...
You can use this time out function that wraps your function. Here's the recipe from: <http://code.activestate.com/recipes/473878/> ``` def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None): '''This function will spwan a thread and run the given function using the args, kwargs and return the ...
553,002
<p>I create a servercontrol for ASP.Net. For being short and precise I just list the things I do:</p> <p>(1) Call EnsureChildControls in OnInit</p> <p>(2) Create a dynamic table in CreateChildControls:</p> <pre><code>Table aTable = new Table(); aTable.ID = this.ID + "$" + T; TableRow aRow = new TableRow(); aRow.ID =...
[ { "answer_id": 553028, "author": "Paul Nearney", "author_id": 24071, "author_profile": "https://Stackoverflow.com/users/24071", "pm_score": 0, "selected": false, "text": "<p>Are you adding you table to the server controls .Controls collection, e.g.</p>\n\n<pre><code>this.Controls.Add(aTa...
2009/02/16
[ "https://Stackoverflow.com/questions/553002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66907/" ]
I create a servercontrol for ASP.Net. For being short and precise I just list the things I do: (1) Call EnsureChildControls in OnInit (2) Create a dynamic table in CreateChildControls: ``` Table aTable = new Table(); aTable.ID = this.ID + "$" + T; TableRow aRow = new TableRow(); aRow.ID = aTable.ID + "$R" + <COUNTER...
You will need to recreate the dynamically created LinkButton on Postback for it's associated EventHander to fire. Rather than explain the whole thing, I would highly recommend that you read Scott Mitchell's [classic article](https://web.archive.org/web/20211031102347/https://aspnet.4guysfromrolla.com/articles/092904-1....
553,003
<p>I have a view selection formula </p> <pre><code>SELECT @If( @Date(@Now) = @Date(@Created); @All; @False) </code></pre> <p>and I want it to select all documents from the past 7 days rather than just today's.</p>
[ { "answer_id": 553033, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 4, "selected": true, "text": "<pre><code>SELECT @If( @Date(@Now) &lt; @Date(@Adjust(@Created(), null, null, 7, null, null, null)); @All; @False)\n</...
2009/02/16
[ "https://Stackoverflow.com/questions/553003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66908/" ]
I have a view selection formula ``` SELECT @If( @Date(@Now) = @Date(@Created); @All; @False) ``` and I want it to select all documents from the past 7 days rather than just today's.
``` SELECT @If( @Date(@Now) < @Date(@Adjust(@Created(), null, null, 7, null, null, null)); @All; @False) ```
553,009
<p>i want to set a property that when the user clicks on X button in the title bar it check for some condition if all conditions are true then exit if no then do nothing and return to the form ..</p> <p>but i noticed that FormClosing property exit the application howevere are my conditions ... so how to do my scenario...
[ { "answer_id": 553033, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 4, "selected": true, "text": "<pre><code>SELECT @If( @Date(@Now) &lt; @Date(@Adjust(@Created(), null, null, 7, null, null, null)); @All; @False)\n</...
2009/02/16
[ "https://Stackoverflow.com/questions/553009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42782/" ]
i want to set a property that when the user clicks on X button in the title bar it check for some condition if all conditions are true then exit if no then do nothing and return to the form .. but i noticed that FormClosing property exit the application howevere are my conditions ... so how to do my scenario ?!? i'm ...
``` SELECT @If( @Date(@Now) < @Date(@Adjust(@Created(), null, null, 7, null, null, null)); @All; @False) ```
553,029
<p>As a precursor to writing a compiler I'm trying to understand the Windows (32-bit) Portable Executable format. In particular I'd like to see an example of a bare-bones executable which does nothing except load correctly, run and exit.</p> <p>I've tried writing and compiling a simple C main function which does nothi...
[ { "answer_id": 45528159, "author": "DrakoPensulo", "author_id": 8422336, "author_profile": "https://Stackoverflow.com/users/8422336", "pm_score": 2, "selected": false, "text": "<p>On Windows XP (x32) the smallest PE executable is 97 bytes. \nOn 32bit versions of Vista and 7 the smallest ...
2009/02/16
[ "https://Stackoverflow.com/questions/553029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
As a precursor to writing a compiler I'm trying to understand the Windows (32-bit) Portable Executable format. In particular I'd like to see an example of a bare-bones executable which does nothing except load correctly, run and exit. I've tried writing and compiling a simple C main function which does nothing but the...
As quoted from source ([Creating the smallest possible PE executable](http://archive.is/w01DO#selection-265.0-265.44)): 1 > * Smallest possible PE file: 97 bytes > * Smallest possible PE file on Windows 2000: 133 bytes > * Smallest PE file that downloads a file over WebDAV and executes it: 133 bytes > > The files abo...
553,031
<p>I would like to have a JUnit (or other) system where the enterprise beans can be tested in a mock environment so that all resources/beans and so on are injected locally. The enterprise beans should not have to accomplish this. All kinds of injection should be supported.</p> <ul> <li>I would like to have a maven plu...
[ { "answer_id": 553144, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 5, "selected": true, "text": "<p>Not necessarily the easiest way, but I managed to get this working using JBoss's embeddable EJB3.0 container, with major a...
2009/02/16
[ "https://Stackoverflow.com/questions/553031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4900/" ]
I would like to have a JUnit (or other) system where the enterprise beans can be tested in a mock environment so that all resources/beans and so on are injected locally. The enterprise beans should not have to accomplish this. All kinds of injection should be supported. * I would like to have a maven plugin for this s...
Not necessarily the easiest way, but I managed to get this working using JBoss's embeddable EJB3.0 container, with major assistance from [Java Persistence with Hibernate](http://www.manning.com/bauer2/) For a start, I don't know of maven plugins/dependencies for this, so I had to install my own locally: (1) Download ...
553,035
<p>I'm using <a href="http://www.squaredroot.com/post/2008/07/08/PagedList-Strikes-Back.aspx" rel="nofollow noreferrer">Troy Goode's paged List</a> in my project.<br> Normally you just feed it an IEnumerable, a startindex and an item count and it all works.<br> Now however I'm trying to feed it an IEnumerable I generat...
[ { "answer_id": 553048, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>It looks like it will accept <code>IQueryable&lt;T&gt;</code>, so just call <code>.AsQueryable()</code> on your <c...
2009/02/16
[ "https://Stackoverflow.com/questions/553035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I'm using [Troy Goode's paged List](http://www.squaredroot.com/post/2008/07/08/PagedList-Strikes-Back.aspx) in my project. Normally you just feed it an IEnumerable, a startindex and an item count and it all works. Now however I'm trying to feed it an IEnumerable I generate as follows: ``` private static IEnumera...
1) PagedList is going to iterate through your data at least twice by the looks of it - once to count it, and then once to fetch the right page. Make sure this doesn't screw things up - or consider caching in a list or some other "cheap" buffer to avoid having to query twice. 2) If you call `ToList()` on your yielded r...
553,038
<p>I use the following bit of code in my Django app:</p> <pre><code>pictures = gallery.picture_set.annotate( score=models.Sum( 'picturevote__value' ) ).order_by( '-score' ) </code></pre> <p>There is a table of galleries. In each of them are some pictures. When a user votes up or down a picture, a new row in 'picturev...
[ { "answer_id": 556390, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 5, "selected": true, "text": "<p>Prior to the introduction of annotations, you might have used <a href=\"http://docs.djangoproject.com/en/dev/ref/mo...
2009/02/16
[ "https://Stackoverflow.com/questions/553038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35903/" ]
I use the following bit of code in my Django app: ``` pictures = gallery.picture_set.annotate( score=models.Sum( 'picturevote__value' ) ).order_by( '-score' ) ``` There is a table of galleries. In each of them are some pictures. When a user votes up or down a picture, a new row in 'picturevote' is inserted and conne...
Prior to the introduction of annotations, you might have used [`extra`](http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none) to do something like this, which I *think* should return `0` in cases where there are no votes (if it ...
553,046
<h2>Intro</h2> <p>This question prompted by Marc Gravell's suggestion that I post new language feature suggestions to this site to gather general opinion on them.</p> <p>The idea is to gather if they might be helpful or maybe there is already another way to achieve what I am after.</p> <h2>Suggestion (Constrained Ty...
[ { "answer_id": 553077, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>It is more \"constrained variables\" than \"constrained types\" - but definitely interesting. As with generic cons...
2009/02/16
[ "https://Stackoverflow.com/questions/553046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
Intro ----- This question prompted by Marc Gravell's suggestion that I post new language feature suggestions to this site to gather general opinion on them. The idea is to gather if they might be helpful or maybe there is already another way to achieve what I am after. Suggestion (Constrained Types) ----------------...
I think, whilst superficially useful this sort of thing is better handled by one of the two: * Duck Typing via dynamic (coming in VS2010) for vastly more flexibility albeit removing type safety. * Generic composition Your original example requires neither and can be easily made to work like so: ``` public interface ...
553,063
<p>I've got a many-to-many relationship which I try to fetch eager:</p> <pre><code>*.CreateCriteria(typeof(Class1)) .SetFetchMode("Class2", FetchMode.Eager) .SetResultTransformer(new DistinctRootEntityResultTransformer()) .SetFirstResult(20) .SetMaxResult(10) .List&lt;Class1&gt;(); </code></pre> <p>I'd like to have r...
[ { "answer_id": 554536, "author": "Paco", "author_id": 13376, "author_profile": "https://Stackoverflow.com/users/13376", "pm_score": 0, "selected": false, "text": "<p>I did not actually try this, but it might work. </p>\n\n<pre><code> *.CreateCriteria(typeof(Class1))\n .SetFirstResult...
2009/02/16
[ "https://Stackoverflow.com/questions/553063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18729/" ]
I've got a many-to-many relationship which I try to fetch eager: ``` *.CreateCriteria(typeof(Class1)) .SetFetchMode("Class2", FetchMode.Eager) .SetResultTransformer(new DistinctRootEntityResultTransformer()) .SetFirstResult(20) .SetMaxResult(10) .List<Class1>(); ``` I'd like to have rows 20-30 returned, but instead ...
It is because the SetMaxResults method works at a 'low level'. I mean, SetMaxResults causes the SQL statement that is generated by NHibernate to contain a `TOP` or `LIMIT` clause. Ofcourse, this leads to those strange results when you're using an eager fetching-mode, since the eager fetchmode results in a JOIN. So, ...
553,067
<p>Say you have the following java bean:</p> <pre><code>public class MyBean { private List&lt;String&gt; names = new ArrayList&lt;String&gt;(); public void addName(String name) { names.add(name); fireNamesPropertyChange(name); } } </code></pre> <p>How would you normally implement a pr...
[ { "answer_id": 553078, "author": "Nick Fortescue", "author_id": 5346, "author_profile": "https://Stackoverflow.com/users/5346", "pm_score": 0, "selected": false, "text": "<p>For a swing GUI event I'd normally just use an <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/event...
2009/02/16
[ "https://Stackoverflow.com/questions/553067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51382/" ]
Say you have the following java bean: ``` public class MyBean { private List<String> names = new ArrayList<String>(); public void addName(String name) { names.add(name); fireNamesPropertyChange(name); } } ``` How would you normally implement a property change event for a collection? ...
Take a look at [Glazed Lists](http://publicobject.com/glazedlists/) library, which has support for observable collections. If I were to do it myself, I would likely create custom Listener interface with elementsAdded, elementsRemoved methods, or similar :-) (also depending on my needs)
553,073
<p>I have the following really simple code</p> <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt; &lt;ContentTemplate&gt; &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt; &lt;/asp:PlaceHolder&gt; ...
[ { "answer_id": 553145, "author": "d4nt", "author_id": 1039, "author_profile": "https://Stackoverflow.com/users/1039", "pm_score": 6, "selected": true, "text": "<p>In asp.net, the controls in the ASPX file are automatically generated on each postback. The controls you've created are not i...
2009/02/16
[ "https://Stackoverflow.com/questions/553073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21574/" ]
I have the following really simple code ``` <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="PlaceHolder1" runat="server"> </asp:PlaceHolder> <asp:Button ID="Button1" runat="server" Text="B...
In asp.net, the controls in the ASPX file are automatically generated on each postback. The controls you've created are not in the ASPX code so the framework does not create them for you. The first time you execute the Button1\_Click method, you add one extra control to the page. The second time you execute the Button1...
553,121
<p>Please suggest a method other than use of .htaccess..</p>
[ { "answer_id": 553134, "author": "Robin Day", "author_id": 40655, "author_profile": "https://Stackoverflow.com/users/40655", "pm_score": 1, "selected": false, "text": "<p>You can do a client side redirect using an index.html and a META Refresh tag.</p>\n\n<pre><code> &lt;html&gt;\n ...
2009/02/16
[ "https://Stackoverflow.com/questions/553121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Please suggest a method other than use of .htaccess..
It really is homework-due-day today. Theres httpd.conf (apache) <http://httpd.apache.org/docs/1.3/configuring.html> Or, forcing an "Error 301 - redirect". Or, you could put a meta-refresh in your webpage redirecting to the new webpage. e.g. <meta http-equiv="REFRESH" content="0;url=<http://www.the-domain-you-...
553,129
<p>Is it possible to add properties to my model that dont exist in the database?</p> <p>For example I have a calendar table, I want to retireve this data in my MVC controller then work out time left until each entry starts and return this to the view. So I would like another property in my calendar model to hold time ...
[ { "answer_id": 553134, "author": "Robin Day", "author_id": 40655, "author_profile": "https://Stackoverflow.com/users/40655", "pm_score": 1, "selected": false, "text": "<p>You can do a client side redirect using an index.html and a META Refresh tag.</p>\n\n<pre><code> &lt;html&gt;\n ...
2009/02/16
[ "https://Stackoverflow.com/questions/553129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66058/" ]
Is it possible to add properties to my model that dont exist in the database? For example I have a calendar table, I want to retireve this data in my MVC controller then work out time left until each entry starts and return this to the view. So I would like another property in my calendar model to hold time left which...
It really is homework-due-day today. Theres httpd.conf (apache) <http://httpd.apache.org/docs/1.3/configuring.html> Or, forcing an "Error 301 - redirect". Or, you could put a meta-refresh in your webpage redirecting to the new webpage. e.g. <meta http-equiv="REFRESH" content="0;url=<http://www.the-domain-you-...
553,131
<p>I have a dynamic amount of div's being returned from a query, all with the class #li. I want them all to fade in smoothly instead of just appear. So far I'm using this code:</p> <pre><code>function loadTables() { $.get("display.php", { server: Server, username: Username, password: Password, database...
[ { "answer_id": 553138, "author": "Kobi", "author_id": 7586, "author_profile": "https://Stackoverflow.com/users/7586", "pm_score": 3, "selected": true, "text": "<p>You cannot have the same id for multiple elements.<br>\nTry replacing id with class.</p>\n" }, { "answer_id": 553141,...
2009/02/16
[ "https://Stackoverflow.com/questions/553131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
I have a dynamic amount of div's being returned from a query, all with the class #li. I want them all to fade in smoothly instead of just appear. So far I'm using this code: ``` function loadTables() { $.get("display.php", { server: Server, username: Username, password: Password, database: Database, co...
You cannot have the same id for multiple elements. Try replacing id with class.
553,143
<p>How do you compile and execute a .cs file from a command-prompt window?</p>
[ { "answer_id": 553155, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 8, "selected": true, "text": "<p>CSC.exe is the CSharp compiler included in the .NET Framework and can be used to compile from the command prompt. The output ...
2009/02/16
[ "https://Stackoverflow.com/questions/553143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37740/" ]
How do you compile and execute a .cs file from a command-prompt window?
CSC.exe is the CSharp compiler included in the .NET Framework and can be used to compile from the command prompt. The output can be an executable ".exe", if you use "/target:exe", or a DLL; If you use /target:library, CSC.exe is found in the .NET Framework directory, e.g. for .NET 3.5, `c:\windows\Microsoft.NET\Frame...
553,147
<p>I have a resource file placed in the App_LocalResources folder <em>inside</em> the folder for a theme in App_Themes like so: \App_Themes\Theme1\App_LocalResources\Resources1.aspx.resx</p> <p>How can I access the resources in this file from a web form in my project, assuming the web form is called Resources1.aspx ha...
[ { "answer_id": 553155, "author": "Ash", "author_id": 5023, "author_profile": "https://Stackoverflow.com/users/5023", "pm_score": 8, "selected": true, "text": "<p>CSC.exe is the CSharp compiler included in the .NET Framework and can be used to compile from the command prompt. The output ...
2009/02/16
[ "https://Stackoverflow.com/questions/553147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33404/" ]
I have a resource file placed in the App\_LocalResources folder *inside* the folder for a theme in App\_Themes like so: \App\_Themes\Theme1\App\_LocalResources\Resources1.aspx.resx How can I access the resources in this file from a web form in my project, assuming the web form is called Resources1.aspx having Theme="T...
CSC.exe is the CSharp compiler included in the .NET Framework and can be used to compile from the command prompt. The output can be an executable ".exe", if you use "/target:exe", or a DLL; If you use /target:library, CSC.exe is found in the .NET Framework directory, e.g. for .NET 3.5, `c:\windows\Microsoft.NET\Frame...
553,149
<p>is there a way to convert from a .key file to a .pfx file? thank you.</p> <p>EDIT: I only have the .key file but my hosting provider says that I could convert it to .pfx with just that file.</p>
[ { "answer_id": 553165, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p>You could try this<br/>\n<a href=\"https://www.sslshopper.com/ssl-converter.html\" rel=\"noreferrer\">https://www.sslshoppe...
2009/02/16
[ "https://Stackoverflow.com/questions/553149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4264/" ]
is there a way to convert from a .key file to a .pfx file? thank you. EDIT: I only have the .key file but my hosting provider says that I could convert it to .pfx with just that file.
To check if your .key file has everything you need: ``` #check if file contains a valid certificate: openssl x509 -text -in file.key ``` It should print out certificate details. If it prints an error including the text "unable to load certificate", then your file is not sufficient. ``` #check if file contains a val...
553,150
<p>I have a WPF ListBox, and I've added some 'FooBar' objects as items (by code). FooBars aren't WPF objects, just dumb class with an overwritten ToString() function.</p> <p>Now, when I change a property which influences the ToString, I'd like to get the ListBox to update.</p> <ol> <li>How can I do this 'quick and di...
[ { "answer_id": 553183, "author": "Blounty", "author_id": 33944, "author_profile": "https://Stackoverflow.com/users/33944", "pm_score": 0, "selected": false, "text": "<p>If the collection object you use to store the items is an observablecollection&lt;> then this is handled for you. </p>\...
2009/02/16
[ "https://Stackoverflow.com/questions/553150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
I have a WPF ListBox, and I've added some 'FooBar' objects as items (by code). FooBars aren't WPF objects, just dumb class with an overwritten ToString() function. Now, when I change a property which influences the ToString, I'd like to get the ListBox to update. 1. How can I do this 'quick and dirty' (like repaint)....
Your type should implement `INotifyPropertyChanged` so that a collection can detect the changes. As Sam says, pass `string.Empty` as the argument. You *also* need to have the `ListBox`'s data source be a collection that provides change notification. This is done via the `INotifyCollectionChanged` interface (or the not...
553,157
<p>Seam will fire <a href="http://docs.jboss.org/seam/latest/reference/en-US/html/events.html#d0e5252" rel="nofollow noreferrer">different kinds of events</a> that relate to particular scopes, tasks, or processes and appends the name of the scope, task or process to the end of the event.</p> <p>How do I listen to all ...
[ { "answer_id": 899344, "author": "mtpettyp", "author_id": 98632, "author_profile": "https://Stackoverflow.com/users/98632", "pm_score": 3, "selected": true, "text": "<p>You can easily do this by replacing Seam's Events class with your own implementation. Then look for events that are ra...
2009/02/16
[ "https://Stackoverflow.com/questions/553157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13935/" ]
Seam will fire [different kinds of events](http://docs.jboss.org/seam/latest/reference/en-US/html/events.html#d0e5252) that relate to particular scopes, tasks, or processes and appends the name of the scope, task or process to the end of the event. How do I listen to all the events of a type? E.g. for any `<name>` I'...
You can easily do this by replacing Seam's Events class with your own implementation. Then look for events that are raised that start with a particular string: ``` @Scope(ScopeType.STATELESS) @BypassInterceptors @Name("org.jboss.seam.core.events") @Install(precedence=APPLICATION) public class Events extends org.jboss....
553,170
<p>Hi I'm wondering if anybody has had any experience querying a Team Foundation Server store to retrieve current work item information. It is my understanding that the information I require is stored in the TFSWarehouse Database.</p> <p>I'm well aware that there are APIs that provide this functionality and I've used ...
[ { "answer_id": 553268, "author": "Tristan Warner-Smith", "author_id": 29553, "author_profile": "https://Stackoverflow.com/users/29553", "pm_score": 3, "selected": true, "text": "<p>If you have access to the SQL database that hosts TFS, you can write a query that pulls this information ou...
2009/02/16
[ "https://Stackoverflow.com/questions/553170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52026/" ]
Hi I'm wondering if anybody has had any experience querying a Team Foundation Server store to retrieve current work item information. It is my understanding that the information I require is stored in the TFSWarehouse Database. I'm well aware that there are APIs that provide this functionality and I've used them mysel...
If you have access to the SQL database that hosts TFS, you can write a query that pulls this information out. The database you want to look at is TFSWarehouse. Below is a query that gets Work Item general information. ``` select System_Id as WorkItemId, System_Title as Title, System_State as Status, System_Reason as ...
553,172
<p>The following .NET 3.5 code, placed in an aspx file, will trigger a JavaScript error when the page is loaded (for users who have JavaScript enabled):</p> <pre><code>&lt;noscript&gt; &lt;asp:TextBox ID="txt" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;asp:RequiredFieldValidator ID="txt_RequiredFieldValidator"...
[ { "answer_id": 553221, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 0, "selected": false, "text": "<p>The javascript is looking for an element contained in the noscript? AFAIK there's no clean way to detect script suppor...
2009/02/16
[ "https://Stackoverflow.com/questions/553172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
The following .NET 3.5 code, placed in an aspx file, will trigger a JavaScript error when the page is loaded (for users who have JavaScript enabled): ``` <noscript> <asp:TextBox ID="txt" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="txt_RequiredFieldValidator" runat="server" ControlToVal...
You should add the following to the RequiredFieldValidator: ``` enableclientscript="false" ``` Seeing as you are using these in <noscript> tags, there is no point in supplying client side vaildation of the controls - they are only going to display if JS is turned off. This will force the validation to happen (autom...
553,192
<p>I was going to use jQuery to clone the input field when I click a button to make another field, but I was thinking of doing:</p> <p><code>Page One, Page Two, Page Three</code> &lt;- then send that as one <code>$_POST</code> to the server and have it take each page and break on the &quot;,&quot; comma then for each i...
[ { "answer_id": 553231, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 0, "selected": false, "text": "<p>explode and foreach sound good.</p>\n\n<p>But as Click Upvote indicated: is it for pagination? 'cause then there could ...
2009/02/16
[ "https://Stackoverflow.com/questions/553192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I was going to use jQuery to clone the input field when I click a button to make another field, but I was thinking of doing: `Page One, Page Two, Page Three` <- then send that as one `$_POST` to the server and have it take each page and break on the "," comma then for each insert in to my POSTS table. Any idea on how...
If you set the `name` attribute of the `input` element to the name of an array, e.g. `foo[]`, you'll be able to access it as such when processing the `$_POST` vars, e.g. ``` <input name="foo[]" type="text"/> <input name="foo[]" type="text"/> ``` becomes two iterations of: ``` foreach ($_POST['foo'] as $foo) { /...
553,203
<p>I have a ASP.NET MVC app that is using SQLite database through Entity Framework. Everything works on VS 2008's local development webserver.</p> <p>However, deploying the web app to my service provider causes this error:</p> <pre><code>[ArgumentException: Unable to find the requested .Net Framework Data Provider. ...
[ { "answer_id": 553243, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>Have you tried adding the required DLL(s) to your application's bin directory? You might want to look at Phil Haack...
2009/02/16
[ "https://Stackoverflow.com/questions/553203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54155/" ]
I have a ASP.NET MVC app that is using SQLite database through Entity Framework. Everything works on VS 2008's local development webserver. However, deploying the web app to my service provider causes this error: ``` [ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be install...
You're unlikely to be reading this anymore, but you're missing the following in your app.config (or, for you, web.config): ``` <configuration> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite" /> <add name="SQLite Data Provider" invariant="System.Data.SQLite" desc...
553,209
<p>See this MSDN post for some background: <a href="http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/417329cb-a6f6-45dd-9a56-98bb4aee74f9/" rel="nofollow noreferrer">Using metadata to call a target multiple times with different parameters</a></p> <p>The solution put forward was to use metadata in a Task's ...
[ { "answer_id": 553239, "author": "haqwin", "author_id": 62407, "author_profile": "https://Stackoverflow.com/users/62407", "pm_score": 3, "selected": true, "text": "<p>I sure see the problem here as </p>\n\n<pre><code>&lt;Exec Command=\"echo step 1 %(BuildFile.InstallerFileName)\" /&gt;\n...
2009/02/16
[ "https://Stackoverflow.com/questions/553209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15515/" ]
See this MSDN post for some background: [Using metadata to call a target multiple times with different parameters](http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/417329cb-a6f6-45dd-9a56-98bb4aee74f9/) The solution put forward was to use metadata in a Task's Output attribute to force the batching of the t...
I sure see the problem here as ``` <Exec Command="echo step 1 %(BuildFile.InstallerFileName)" /> ``` Will iterate again and again on the InstallerFileName output. I think you can call a custom target instead and that target go through each of your steps. Call this target from the main script with the MSBuild Task, ...
553,213
<p>I need to have a <code>static void* array[1024];</code> in a library and i need to have it set to NULL for every entries.</p> <p>My question is about the best way to set the entire array to NULL, is a <code>memset (array, NULL, sizeof (void*) * 1024)</code> the best solution?</p>
[ { "answer_id": 553217, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 0, "selected": false, "text": "<p>Nope, it's wrong. You aren't considering the size of each element.</p>\n\n<pre><code>memset(array, 0, sizeof(array)); // th...
2009/02/16
[ "https://Stackoverflow.com/questions/553213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61838/" ]
I need to have a `static void* array[1024];` in a library and i need to have it set to NULL for every entries. My question is about the best way to set the entire array to NULL, is a `memset (array, NULL, sizeof (void*) * 1024)` the best solution?
`static` pointers are automatically initialized to `NULL`. See C99:TC3 6.7.8, §10: > > If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate. If an object that has static storage duration is not initialized explicitly, then: > > > * if it has pointer type, it is ...
553,240
<pre><code>function onlyNumeric() { if (event.keyCode &lt; 48 || event.keyCode &gt; 57) { event.returnValue = false; } } onkeypress=onlyNumneric(); </code></pre> <p>In IE, this code is working fine. However, in Mozilla Firefox, the event is an undefined error.</p>
[ { "answer_id": 553251, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": false, "text": "<p>In FF/Mozilla the event is passed to your event handler as a parameter. Use something like the following to get aro...
2009/02/16
[ "https://Stackoverflow.com/questions/553240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` function onlyNumeric() { if (event.keyCode < 48 || event.keyCode > 57) { event.returnValue = false; } } onkeypress=onlyNumneric(); ``` In IE, this code is working fine. However, in Mozilla Firefox, the event is an undefined error.
In FF/Mozilla the event is passed to your event handler as a parameter. Use something like the following to get around the missing event argument in IE. ``` function onlyNumeric(e) { if (!e) { e = window.event; } ... } ``` You'll find that there are some other differences between the two a...
553,244
<p>I'm designing a multilingual application using .resx files.</p> <p>I have a few files like GlobalStrings.resx, GlobalStrings.es.resx, GlobalStrings.en.resx, etc. When I want to use this, I just need to set Thread.CurrentThread.CurrentCulture.</p> <p>The problem: I have a combobox with all the available languages, ...
[ { "answer_id": 553254, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": false, "text": "<p>I'm not sure about getting the languages, maybe you can scan your installation folder for dll-files, but setting ...
2009/02/16
[ "https://Stackoverflow.com/questions/553244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
I'm designing a multilingual application using .resx files. I have a few files like GlobalStrings.resx, GlobalStrings.es.resx, GlobalStrings.en.resx, etc. When I want to use this, I just need to set Thread.CurrentThread.CurrentCulture. The problem: I have a combobox with all the available languages, but I'm loading t...
Using what Rune Grimstad said I end up with this: ``` string executablePath = Path.GetDirectoryName(Application.ExecutablePath); string[] directories = Directory.GetDirectories(executablePath); foreach (string s in directories) { try { DirectoryInfo langDirectory = new DirectoryInfo(s); cmbLang...
553,246
<p>I have this in my HTML</p> <pre><code>&lt;a class="deleteLink" href="system/id"&gt;link&lt;/a&gt; </code></pre> <p>Then using jQuery, I run this in $(document.ready(function()</p> <pre><code>alert($("a.deleteLink").attr("href")); </code></pre> <p>Which shows <strong>system/id</strong></p> <p>But running this:</...
[ { "answer_id": 553274, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 2, "selected": false, "text": "<p>Now I see what you want to do.</p>\n\n<p>Try this:</p>\n\n<pre><code>alert( $(\"a.deleteLink\")[0].href );\n</code></pre...
2009/02/16
[ "https://Stackoverflow.com/questions/553246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62006/" ]
I have this in my HTML ``` <a class="deleteLink" href="system/id">link</a> ``` Then using jQuery, I run this in $(document.ready(function() ``` alert($("a.deleteLink").attr("href")); ``` Which shows **system/id** But running this: ``` alert($("a.deleteLink").href); ``` Shows **undefined** If I add an Id to t...
$("...") returns a jQuery object (also called "wrapped set"). The wrapped set does not have a href attribute. If you do this: ``` alert($("a.deleteLink")[0].href); ``` It should return the href attribute properly. When you deal with "myId", you're dealing with a DOM element object. Quite different to a wrapped set. ...
553,281
<p>Learning Common Lisp (using GNU CLISP 2.43) .. so might be a noob mistake. Example is the 'print prime numbers between x and y' </p> <pre><code>(defun is-prime (n) (if (&lt; n 2) (return-from is-prime NIL)) (do ((i 2 (1+ i))) ((= i n) T) (if (= (mod n i) 0) (return NIL)))) (defun next-prime...
[ { "answer_id": 553454, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 2, "selected": false, "text": "<p>You don't actually need the <code>gensym</code> here for avoiding variable capture, because you do not introduce any var...
2009/02/16
[ "https://Stackoverflow.com/questions/553281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
Learning Common Lisp (using GNU CLISP 2.43) .. so might be a noob mistake. Example is the 'print prime numbers between x and y' ``` (defun is-prime (n) (if (< n 2) (return-from is-prime NIL)) (do ((i 2 (1+ i))) ((= i n) T) (if (= (mod n i) 0) (return NIL)))) (defun next-prime-after (n) (do ...
Use `DO*` instead of `DO`. `DO` Initializes the bindings in a scope where they are *not* yet visible. `DO*` initializes the bindings in a scope where they *are* visible. In this particular case `var` needs to reference the other binding `loop-start`.
553,303
<p>How would I generate a random date that has to be between two other given dates?</p> <p>The function's signature should be something like this:</p> <pre><code>random_date("1/1/2008 1:30 PM", "1/1/2009 4:50 AM", 0.34) ^ ^ ^ date generated has date gene...
[ { "answer_id": 553320, "author": "Tom Alsberg", "author_id": 66034, "author_profile": "https://Stackoverflow.com/users/66034", "pm_score": 9, "selected": true, "text": "<p>Convert both strings to timestamps (in your chosen resolution, e.g. milliseconds, seconds, hours, days, whatever), s...
2009/02/16
[ "https://Stackoverflow.com/questions/553303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66950/" ]
How would I generate a random date that has to be between two other given dates? The function's signature should be something like this: ``` random_date("1/1/2008 1:30 PM", "1/1/2009 4:50 AM", 0.34) ^ ^ ^ date generated has date generated has a random n...
Convert both strings to timestamps (in your chosen resolution, e.g. milliseconds, seconds, hours, days, whatever), subtract the earlier from the later, multiply your random number (assuming it is distributed in the `range [0, 1]`) with that difference, and add again to the earlier one. Convert the timestamp back to dat...
553,306
<p>I want to replace a number with a character at runtime like this:</p> <p>Input:</p> <p><code>ask 1234 question</code></p> <p>Result:</p> <p><code>ask * question</code></p> <p>What is the best way to accomplish this?</p>
[ { "answer_id": 553318, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 1, "selected": false, "text": "<p>You could use a <a href=\"http://livedocs.adobe.com/flex/2/langref/RegExp.html\" rel=\"nofollow noreferrer\">regul...
2009/02/16
[ "https://Stackoverflow.com/questions/553306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57404/" ]
I want to replace a number with a character at runtime like this: Input: `ask 1234 question` Result: `ask * question` What is the best way to accomplish this?
Use a Regex to match a number and then do a string replace. Something along the lines of: ``` var str:String = "ask 1234 question"; // your string var pattern:RegExp = /\d+/ ; // a regular expression that matches numbers trace(str.replace(pattern, "*")); ``` Look up the flex 3.0 documentation for both String and Reg...
553,310
<p>Hi I need to generate a SHA over a 5 Gig file</p> <p>Do you know of a non string based Delphi library that can do this ?</p>
[ { "answer_id": 553319, "author": "Edouard A.", "author_id": 41363, "author_profile": "https://Stackoverflow.com/users/41363", "pm_score": 0, "selected": false, "text": "<p>There is a Delphi interface for OpenSSL, isn't there?</p>\n\n<p>That should provide you with better performances.</p...
2009/02/16
[ "https://Stackoverflow.com/questions/553310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
Hi I need to generate a SHA over a 5 Gig file Do you know of a non string based Delphi library that can do this ?
You should use [DCPcrypt v2](http://www.cityinthesky.co.uk/cryptography.html) and read your file buffered and feed the SHA hasher with the buffer until you've read the complete 5GB file. If you want to know how to read a large file buffered, see my answer [about a file copy using custom buffering](https://stackoverflo...
553,330
<p>Having seen how <a href="http://codeclimber.net.nz/archive/2009/02/10/how-to-use-ninject-to-inject-dependencies-into-asp.net-mvc.aspx" rel="noreferrer">NInject can do it</a> and <a href="http://www.jeremyskinner.co.uk/2008/11/08/dependency-injection-with-aspnet-mvc-action-filters/" rel="noreferrer">AutoFac can do it...
[ { "answer_id": 553405, "author": "mookid8000", "author_id": 6560, "author_profile": "https://Stackoverflow.com/users/6560", "pm_score": 5, "selected": true, "text": "<p>Make a generic attribute: MyFilterAttribute with ctor taking a Type as argument - i.e. something like this:</p>\n\n<pre...
2009/02/16
[ "https://Stackoverflow.com/questions/553330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11239/" ]
Having seen how [NInject can do it](http://codeclimber.net.nz/archive/2009/02/10/how-to-use-ninject-to-inject-dependencies-into-asp.net-mvc.aspx) and [AutoFac can do it](http://www.jeremyskinner.co.uk/2008/11/08/dependency-injection-with-aspnet-mvc-action-filters/) I'm trying to figure out how to inject dependencies in...
Make a generic attribute: MyFilterAttribute with ctor taking a Type as argument - i.e. something like this: ``` public class MyFilterAttribute : ActionFilterAttribute { public MyFilterAttribute(Type serviceType) { this.serviceType = serviceType; } public override void OnActionExecuting(FilterExecu...
553,331
<p>When I attempt to set an application role on a SqlConnection with <a href="http://msdn.microsoft.com/en-us/library/ms188908.aspx" rel="nofollow noreferrer">sp_setapprole</a> I sometimes get the following error in the Windows event log...</p> <blockquote> <p>The connection has been dropped because the principal th...
[ { "answer_id": 553405, "author": "mookid8000", "author_id": 6560, "author_profile": "https://Stackoverflow.com/users/6560", "pm_score": 5, "selected": true, "text": "<p>Make a generic attribute: MyFilterAttribute with ctor taking a Type as argument - i.e. something like this:</p>\n\n<pre...
2009/02/16
[ "https://Stackoverflow.com/questions/553331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4200/" ]
When I attempt to set an application role on a SqlConnection with [sp\_setapprole](http://msdn.microsoft.com/en-us/library/ms188908.aspx) I sometimes get the following error in the Windows event log... > > The connection has been dropped because the principal that opened it subsequently assumed a new security context...
Make a generic attribute: MyFilterAttribute with ctor taking a Type as argument - i.e. something like this: ``` public class MyFilterAttribute : ActionFilterAttribute { public MyFilterAttribute(Type serviceType) { this.serviceType = serviceType; } public override void OnActionExecuting(FilterExecu...
553,339
<p>I am trying to build a messaging system and for this i have the table definition below</p> <p>Message</p> <pre><code>Id From To Body ParentId // Subcollection, i want to get Asnwers (Message.ParentId== Message.Id) IsRead </code></pre> <p>and i have this in the Message.cs</p> <pre><code>IList&lt;Message&gt; Answe...
[ { "answer_id": 553606, "author": "tobinharris", "author_id": 1136215, "author_profile": "https://Stackoverflow.com/users/1136215", "pm_score": 1, "selected": false, "text": "<p>Before attempting an answer, I'd strongly recommend that you <strong>search the <a href=\"http://groups.google....
2009/02/16
[ "https://Stackoverflow.com/questions/553339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51734/" ]
I am trying to build a messaging system and for this i have the table definition below Message ``` Id From To Body ParentId // Subcollection, i want to get Asnwers (Message.ParentId== Message.Id) IsRead ``` and i have this in the Message.cs ``` IList<Message> Answers; ``` I have tried this but it gives me all th...
You want to map a tree ? Maybe this could help: [how to map a tree in nhibernate](http://web.archive.org/web/20090806071731/http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/05/14/how-to-map-a-tree-in-nhibernate.aspx)
553,346
<p>We host a WCF webservice on Windows Server 2003. This server only has 2 internal IP's. We want to expose the service externally. This is done through the firewall that maps an external IP to the service.</p> <p>So, I would need to modify the service to display that external IP for the internal links. This is not an...
[ { "answer_id": 569370, "author": "EnocNRoll - AnandaGopal Pardue", "author_id": 54289, "author_profile": "https://Stackoverflow.com/users/54289", "pm_score": 4, "selected": true, "text": "<h2>404 BadRequest Due to IIS Configuration...</h2>\n<p>If you are receiving a 404 BadRequest error ...
2009/02/16
[ "https://Stackoverflow.com/questions/553346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48417/" ]
We host a WCF webservice on Windows Server 2003. This server only has 2 internal IP's. We want to expose the service externally. This is done through the firewall that maps an external IP to the service. So, I would need to modify the service to display that external IP for the internal links. This is not an issue sin...
404 BadRequest Due to IIS Configuration... ------------------------------------------ If you are receiving a 404 BadRequest error from IIS after attempting to modify host headers in IIS, this is common, but there is a fix! Fix By Making IIS Configuration Changes --------------------------------------- [How can WCF s...
553,377
<p>I'm trying to call a ASP.NET web service from Javascript, and it won't recognize the Web Method, even when I fully qualify the name, I'm trying to figure out what is wrong.</p> <p>Here is the part of my web.config file:</p> <pre><code>&lt;httpHandlers&gt; &lt;remove verb="*" path="*.asmx"/&gt; &lt;...
[ { "answer_id": 553568, "author": "weiran", "author_id": 33137, "author_profile": "https://Stackoverflow.com/users/33137", "pm_score": 2, "selected": false, "text": "<p>If you set the <code>InlineScript</code> attribute on the <code>ServiceReference</code> element, it'll write out the Jav...
2009/02/16
[ "https://Stackoverflow.com/questions/553377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
I'm trying to call a ASP.NET web service from Javascript, and it won't recognize the Web Method, even when I fully qualify the name, I'm trying to figure out what is wrong. Here is the part of my web.config file: ``` <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate=...
If you set the `InlineScript` attribute on the `ServiceReference` element, it'll write out the JavaScript methods inline with the HTML so you can see exactly what you need to call or if you're calling the wrong thing: ``` <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReferen...
553,402
<p>I'm trying to give fadeout effect to a div &amp; delete that div(id = "notification"), when an image is clicked.</p> <p>This is how I'm doing that:</p> <pre><code>&lt;a onclick="$("#notification").fadeOut(300,function() { $("#notification").remove(); });" class="notificationClose "&gt;&lt;img src="close.png"/&gt;&...
[ { "answer_id": 553410, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 5, "selected": false, "text": "<p>Have you tried this?</p>\n\n<pre><code>$(\"#notification\").fadeOut(300, function(){ \n $(this).remove();\n});\n...
2009/02/16
[ "https://Stackoverflow.com/questions/553402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
I'm trying to give fadeout effect to a div & delete that div(id = "notification"), when an image is clicked. This is how I'm doing that: ``` <a onclick="$("#notification").fadeOut(300,function() { $("#notification").remove(); });" class="notificationClose "><img src="close.png"/></a> ``` This seems to not be workin...
Try this: ``` <a onclick='$("#notification").fadeOut(300, function() { $(this).remove(); });' class="notificationClose "><img src="close.png"/></a> ``` I think your double quotes around the `onclick` were making it not work. :) **EDIT**: As pointed out below, inline javascript is evil and you should probably take t...
553,404
<p>I use <a href="http://incubator.apache.org/lucene.net/" rel="noreferrer">Lucene.net</a> for indexing content &amp; documents etc.. on websites. The index is very simple and has this format:</p> <pre> LuceneId - unique id for Lucene (TypeId + ItemId) TypeId - the type of text (eg. page content, product, public doc...
[ { "answer_id": 607237, "author": "cherouvim", "author_id": 72478, "author_profile": "https://Stackoverflow.com/users/72478", "pm_score": 3, "selected": true, "text": "<p>I do [2], but one problem I have is that I cannot use different analyzers depending on the language. I've combined the...
2009/02/16
[ "https://Stackoverflow.com/questions/553404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14072/" ]
I use [Lucene.net](http://incubator.apache.org/lucene.net/) for indexing content & documents etc.. on websites. The index is very simple and has this format: ``` LuceneId - unique id for Lucene (TypeId + ItemId) TypeId - the type of text (eg. page content, product, public doc etc..) ItemId - the web page id, docu...
I do [2], but one problem I have is that I cannot use different analyzers depending on the language. I've combined the stopwords of the languages I want, but I lose the capability of more advanced stuff that the analyzer will offer such as stemming etc.
553,407
<p>How do I do string1 >= string2 in Linq to SQL?</p>
[ { "answer_id": 553428, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 4, "selected": true, "text": "<p>string1 &gt;= string2 is not supported in C# Linq To Sql. The String class does not override the &gt;= operator at all...
2009/02/16
[ "https://Stackoverflow.com/questions/553407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1154/" ]
How do I do string1 >= string2 in Linq to SQL?
string1 >= string2 is not supported in C# Linq To Sql. The String class does not override the >= operator at all. It only overrides the != and == operators. You can verify this by trying to compile the following method ``` public static void Example() { int val = "foo" >= "bar"; } ``` If you want to compare to Str...
553,416
<p>I'm initiating an email create, by calling the code below, and adding an attachment to it.</p> <p>I want the user to be able to type in the receipient, and modify the contents of the message, so I'm not sending it immediately.</p> <p>Why do I get a RangeError the 2nd time the method is called?<br> (The first time ...
[ { "answer_id": 553529, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>I'm trying it with this little snippet, and it works flawlessly:</p>\n\n<pre><code>var objO = new ActiveXObject('Outloo...
2009/02/16
[ "https://Stackoverflow.com/questions/553416", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13911/" ]
I'm initiating an email create, by calling the code below, and adding an attachment to it. I want the user to be able to type in the receipient, and modify the contents of the message, so I'm not sending it immediately. Why do I get a RangeError the 2nd time the method is called? (The first time it works correctly...
Won't work outside of IE, the user needs to have Outlook on the machine and an account configured on it. Are you sure you want to send an email this way?
553,443
<p>Lets say I have something called Stuff in my database, with a property called Id. From the user I get a sequence of selected Range objects (or rather I create them from their input) with the Ids they want. A stripped down version of that struct looks like this:</p> <pre><code>public struct Range&lt;T&gt; : IEquatab...
[ { "answer_id": 553457, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>The use with generics is problematic, since C# doesn't support operators on generics - meaning you'd have to write ...
2009/02/16
[ "https://Stackoverflow.com/questions/553443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39321/" ]
Lets say I have something called Stuff in my database, with a property called Id. From the user I get a sequence of selected Range objects (or rather I create them from their input) with the Ids they want. A stripped down version of that struct looks like this: ``` public struct Range<T> : IEquatable<Range<T>>, IEqual...
The use with generics is problematic, since C# doesn't support operators on generics - meaning you'd have to write the expression manually. And as we've already seen, string works differently. But for the rest, how about something like (untested): (**edited** for multiple ranges) ``` public static IQueryable<TSou...
553,449
<p>This is has been bugging me for quite some time.</p> <pre><code>&gt;&gt; nil.id (irb):2: warning: Object#id will be deprecated; use Object#object_id =&gt; 4 </code></pre> <p>Why would nil.id be 4? (or nil.object_id if you want to be picky about deprecations)</p>
[ { "answer_id": 553455, "author": "dagvl", "author_id": 25262, "author_profile": "https://Stackoverflow.com/users/25262", "pm_score": 6, "selected": true, "text": "<p>This is because nil is an object created when the language initializes, and that object's id happens to always be 4.</p>\n...
2009/02/16
[ "https://Stackoverflow.com/questions/553449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16204/" ]
This is has been bugging me for quite some time. ``` >> nil.id (irb):2: warning: Object#id will be deprecated; use Object#object_id => 4 ``` Why would nil.id be 4? (or nil.object\_id if you want to be picky about deprecations)
This is because nil is an object created when the language initializes, and that object's id happens to always be 4. For more information about why the id happens to be 4, see [this](http://neeraj.name/blog/articles/662-why-the-id-of-nil-is-4-in-ruby) blog post.
553,463
<p>I'm currently coding a French website. There's a schedule page, where a link on the side can be used to load another day's schedule.</p> <p>Here's the JS I'm using to do this:</p> <pre><code> &lt;script type="text/javascript"&gt; function load(y) { $.get(y,function(d) { $("#replace").htm...
[ { "answer_id": 553472, "author": "yoavf", "author_id": 1011, "author_profile": "https://Stackoverflow.com/users/1011", "pm_score": 6, "selected": true, "text": "<p>UTF-8 is supposed to handle all accents and foreign chars - why not use it on your data source? </p>\n\n<p><strong>EDIT</str...
2009/02/16
[ "https://Stackoverflow.com/questions/553463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50548/" ]
I'm currently coding a French website. There's a schedule page, where a link on the side can be used to load another day's schedule. Here's the JS I'm using to do this: ``` <script type="text/javascript"> function load(y) { $.get(y,function(d) { $("#replace").html(d); mod(); ...
UTF-8 is supposed to handle all accents and foreign chars - why not use it on your data source? **EDIT** [[Archive copy of the test file.](https://web.archive.org/web/20090220110811/http://blog.yoavfarhi.com/test.html)] with your data Everything should be UTF-8 in the first place. I loaded the files in notepad++...
553,466
<p>I used the command <code>tar -x file.tar.gz</code> and, for one reason or anything it failed. Then I get stuck being able to type anything in, but not being able to run any more commands. Pressing enter just gives me a new line. I don't know how to break out of it either (escape etc doesn't work). The only way I can...
[ { "answer_id": 553470, "author": "claf", "author_id": 61838, "author_profile": "https://Stackoverflow.com/users/61838", "pm_score": 3, "selected": true, "text": "<p>Try hitting CTRL+C :) This will cancel/kill/stop the running command!</p>\n\n<p>But the best way to untar is to use -v to v...
2009/02/16
[ "https://Stackoverflow.com/questions/553466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66381/" ]
I used the command `tar -x file.tar.gz` and, for one reason or anything it failed. Then I get stuck being able to type anything in, but not being able to run any more commands. Pressing enter just gives me a new line. I don't know how to break out of it either (escape etc doesn't work). The only way I can get back work...
Try hitting CTRL+C :) This will cancel/kill/stop the running command! But the best way to untar is to use -v to verbose the output : ``` tar -zxvf yourfile.tar.gz ``` With that, you'll perhaps see that your file just take more time than you thought unarchiving ;)
553,480
<p>Is this pattern for mutual exclusion as safe as I think it is? If so, what do you call it?</p> <pre><code>lock (_lock) { if (_flag) return; else _flag = true; } try { //critical code... } finally { _flag = false; } </code></pre> <p>I want to ensure the critical section, but without the other thread...
[ { "answer_id": 553493, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 3, "selected": false, "text": "<p>Have you looked at <a href=\"http://msdn.microsoft.com/en-us/library/4tssbxcw.aspx\" rel=\"nofollow noreferrer\">...
2009/02/16
[ "https://Stackoverflow.com/questions/553480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7038/" ]
Is this pattern for mutual exclusion as safe as I think it is? If so, what do you call it? ``` lock (_lock) { if (_flag) return; else _flag = true; } try { //critical code... } finally { _flag = false; } ``` I want to ensure the critical section, but without the other threads piling up waiting to acq...
No, that is not safe. If you want to ensure mutually exclusive without blocking, you can use Monitor.TryEnter: ``` if (Monitor.TryEnter(lockObj, 0)) { // got the lock ! try { // code } finally { // release the lock Monitor.Exit(lockObj); } } ```
553,515
<p>The option "RETURNS NULL ON NULL INPUT" for a scalar UDF (see <a href="http://msdn.microsoft.com/en-us/library/ms186755(SQL.90).aspx" rel="noreferrer">CREATE FUNCTION</a>) stops the function body executing if the parameter is null and simply returns NULL.</p> <p>That is, it short circuits.</p> <p>Does anyone know ...
[ { "answer_id": 553583, "author": "Kristen", "author_id": 65703, "author_profile": "https://Stackoverflow.com/users/65703", "pm_score": 2, "selected": false, "text": "<blockquote>\n <blockquote>\n <p>Does anyone know how it handles multiple parameters?</p>\n </blockquote>\n</blockquo...
2009/02/16
[ "https://Stackoverflow.com/questions/553515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27535/" ]
The option "RETURNS NULL ON NULL INPUT" for a scalar UDF (see [CREATE FUNCTION](http://msdn.microsoft.com/en-us/library/ms186755(SQL.90).aspx)) stops the function body executing if the parameter is null and simply returns NULL. That is, it short circuits. Does anyone know how it handles multiple parameters? It would...
**Yes**, a function that specifies `RETURNS NULL ON NULL INPUT` will short-circuit if **any** of its parameters are `NULL`. The [documentation](http://msdn.microsoft.com/en-us/library/ms186755.aspx) does suggest this, although it's unclear and appears to be referring only to CLR functions. (I think this is Microsoft's...
553,521
<p>According to how Silverlight TwoWay binding works, when I change the data in the FirstName field, it should change the value in CheckFirstName field.</p> <p>Why is this not the case?</p> <h2>ANSWER:</h2> <p>Thank you Jeff, that was it, for others: here is <a href="http://tanguay.info/web/index.php?pg=codeExamples...
[ { "answer_id": 553643, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "<p>Your <code>Customer</code> type has to support <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmode...
2009/02/16
[ "https://Stackoverflow.com/questions/553521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
According to how Silverlight TwoWay binding works, when I change the data in the FirstName field, it should change the value in CheckFirstName field. Why is this not the case? ANSWER: ------- Thank you Jeff, that was it, for others: here is [the full solution with downloadable code](http://tanguay.info/web/index.php...
Your `Customer` type has to support [`INotifyPropertyChanged`](http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(VS.95).aspx) in order for the binding to know when your `FirstName` property value has changed. This [tutorial](http://www.silverlight.net/learn/data-networking/binding/si...
553,533
<p>In Visual Studio 2005, how can I load a font from a file and use it on a RDLC report?</p> <p>I know how to load a font from a file thanks to <a href="https://stackoverflow.com/questions/544972/load-fonts-from-file-on-a-c-application">this</a> question, but i'm not able to use it in a RDLC report.</p>
[ { "answer_id": 632682, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 0, "selected": false, "text": "<p>It seems that the only way is to install the font on windows and use it like any other font available on system.</p>\n"...
2009/02/16
[ "https://Stackoverflow.com/questions/553533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40441/" ]
In Visual Studio 2005, how can I load a font from a file and use it on a RDLC report? I know how to load a font from a file thanks to [this](https://stackoverflow.com/questions/544972/load-fonts-from-file-on-a-c-application) question, but i'm not able to use it in a RDLC report.
If you only need the font for a heading or two, or for a barcode column then you can make a column on the dataset of Image type, and premake the images as text to bitmaps ``` // From dreaming in code /// <summary> /// Function for converting text to a Bitmap object /// </summary> /// <param name="width">Width of the i...
553,540
<p>I'm using a custom attribute inherited from an attribute class. I'm using it like this:</p> <pre><code>[MyCustomAttribute("CONTROL")] [MyCustomAttribute("ALT")] [MyCustomAttribute("SHIFT")] [MyCustomAttribute("D")] public void setColor() { } </code></pre> <p>But the "Duplicate 'MyCustomAttribute' attribute" error...
[ { "answer_id": 553551, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 9, "selected": true, "text": "<p>Stick an <code>AttributeUsage</code> attribute onto your Attribute class (yep, that's mouthful) and set <code>Allo...
2009/02/16
[ "https://Stackoverflow.com/questions/553540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60200/" ]
I'm using a custom attribute inherited from an attribute class. I'm using it like this: ``` [MyCustomAttribute("CONTROL")] [MyCustomAttribute("ALT")] [MyCustomAttribute("SHIFT")] [MyCustomAttribute("D")] public void setColor() { } ``` But the "Duplicate 'MyCustomAttribute' attribute" error is shown. How can I cr...
Stick an `AttributeUsage` attribute onto your Attribute class (yep, that's mouthful) and set `AllowMultiple` to `true`: ``` [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public sealed class MyCustomAttribute: Attribute ```
553,543
<p>Can I have nested try-catch blocks? For example:</p> <pre><code> void f() { try { //Some code try { //Some code } catch(ExceptionA a) { //Some specific exception handling } //Some code } catch(...) { ...
[ { "answer_id": 553556, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 1, "selected": false, "text": "<p>Yes, you can.</p>\n" }, { "answer_id": 553559, "author": "ouster", "author_id": 66982, "author_profile"...
2009/02/16
[ "https://Stackoverflow.com/questions/553543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46418/" ]
Can I have nested try-catch blocks? For example: ``` void f() { try { //Some code try { //Some code } catch(ExceptionA a) { //Some specific exception handling } //Some code } catch(...) { //Some exce...
Yes perfectly legal. Though it would be best to move inner ones into another method so it looks cleaner and your method(s) are smaller
553,544
<p>In web applications user login information is usually stored in a session but how about windows applications? Is using a singleton the right thing to do? Should I just use a static property?</p> <p>Lets say that I store the login information in a static property ApplicationController. LoggedInUser. When a user logs...
[ { "answer_id": 553553, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 2, "selected": true, "text": "<p>Injection is a good answer. You'll probably find other things useful to put in an <code>ApplicationController</code>,...
2009/02/16
[ "https://Stackoverflow.com/questions/553544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66988/" ]
In web applications user login information is usually stored in a session but how about windows applications? Is using a singleton the right thing to do? Should I just use a static property? Lets say that I store the login information in a static property ApplicationController. LoggedInUser. When a user logs in succes...
Injection is a good answer. You'll probably find other things useful to put in an `ApplicationController`, and it makes it easy to unit-test.
553,546
<p>I would like to be able to get a list of all Spring application contexts from the web applications running in my servlet container. This so so that I can re-initialise the contexts without restarting or reloading my container or webapps.</p> <p>Is this possible? If so, how? Is there anyway to get a list of all the ...
[ { "answer_id": 553624, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 0, "selected": false, "text": "<p>There used to be and it was called [getServlets](<a href=\"http://java.sun.com/products/servlet/2.2/javadoc/javax/s...
2009/02/16
[ "https://Stackoverflow.com/questions/553546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48611/" ]
I would like to be able to get a list of all Spring application contexts from the web applications running in my servlet container. This so so that I can re-initialise the contexts without restarting or reloading my container or webapps. Is this possible? If so, how? Is there anyway to get a list of all the servlet co...
**[Edit: This doesn't really help, as each web.xml would have to have the same listener]** You could have a [ServletContextAttributeListener](http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContextAttributeListener.html) listen out for insertions of the standard [WebApplicationContext](http://static.springf...
553,587
<p>I have a method that gets a nested array as parameter:</p> <pre><code>Number[][] data </code></pre> <p>where Number is my very simple class that inherits from INotifyPropertyChange.</p> <p>And then i have a statement like this:</p> <pre><code>double[] max = (double[])data.Select(crArray =&gt; crArray.Select( cr...
[ { "answer_id": 553604, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 1, "selected": false, "text": "<p>Usually this type of behaviour means that your source code files are not up to date. Try deleting all .bin and .pdb file...
2009/02/16
[ "https://Stackoverflow.com/questions/553587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61731/" ]
I have a method that gets a nested array as parameter: ``` Number[][] data ``` where Number is my very simple class that inherits from INotifyPropertyChange. And then i have a statement like this: ``` double[] max = (double[])data.Select(crArray => crArray.Select( cr => cr.ValueNorm ).Max()); ``` When I'm tryin...
Are you sure that the Select method returns an array? Casting + generics = code smell Try this: ``` double[] max = data .Select(crArray => crArray.Select( cr => cr.ValueNorm ).Max()) .ToArray(); ``` --- Conversion Method - (ToArray) allocates a new array and populates it. Bound by the restrictions of methods. ...
553,597
<p>I'm trying to bind the following enum</p> <pre><code>public enum CertificateTypes : byte { None = 0, Original = 1, AuthenticatedCopy = 2, Numbered = 3 } </code></pre> <p>to a <code>tinyint</code> column on the database. However, when creating the SelectListItems and calling, for instance, <code>Per...
[ { "answer_id": 553673, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>I really doubt that calling <code>ToString()</code> on an enum returns xml... can you clarify what <em>is</em> hap...
2009/02/16
[ "https://Stackoverflow.com/questions/553597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5646/" ]
I'm trying to bind the following enum ``` public enum CertificateTypes : byte { None = 0, Original = 1, AuthenticatedCopy = 2, Numbered = 3 } ``` to a `tinyint` column on the database. However, when creating the SelectListItems and calling, for instance, `Person.CertificateTypes.Original.ToString() I...
If you want automagically you can use ``` var enumValues = Enum.GetValues(typeof(CertificateTypes)).Cast<CertificateTypes>().Select(e => (byte)e); var selectList = new SelectList(enumValues); ``` Problem here is you're only going to get the bytes, so you would probably need to select a new type something like... ``...
553,611
<p>I'm trying to convert from <code>System.Windows.Controls.Image</code> to <code>byte[]</code> and I didnt know which method from Image class could help in this scenary, by the way I really dont know what should I do, cause in my LINQ model the field appears as <code>Binary</code> type, I have to change this if I want...
[ { "answer_id": 553853, "author": "gix", "author_id": 54825, "author_profile": "https://Stackoverflow.com/users/54825", "pm_score": 4, "selected": false, "text": "<p>I don't know how your Image is declared, but suppose we have this XAML declaration:</p>\n\n<pre><code>&lt;Image x:Name=\"im...
2009/02/16
[ "https://Stackoverflow.com/questions/553611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388553/" ]
I'm trying to convert from `System.Windows.Controls.Image` to `byte[]` and I didnt know which method from Image class could help in this scenary, by the way I really dont know what should I do, cause in my LINQ model the field appears as `Binary` type, I have to change this if I want to save it like a `byte[]` type? I...
Real Solution... if want to save jpg images from an System.Windows.Control.Image when your database mapped field on your ORM is Byte[] / byte[] / Bynary ``` public byte[] getJPGFromImageControl(BitmapImage imageC) { MemoryStream memStream = new MemoryStream(); JpegBitmapEncoder encoder = n...
553,626
<p>The problem is the following: We are creating an instance of a class testObject and fill a var with a double.</p> <p>A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var_dump.</p> <p>Can anyone help us out. M...
[ { "answer_id": 553853, "author": "gix", "author_id": 54825, "author_profile": "https://Stackoverflow.com/users/54825", "pm_score": 4, "selected": false, "text": "<p>I don't know how your Image is declared, but suppose we have this XAML declaration:</p>\n\n<pre><code>&lt;Image x:Name=\"im...
2009/02/16
[ "https://Stackoverflow.com/questions/553626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60143/" ]
The problem is the following: We are creating an instance of a class testObject and fill a var with a double. A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var\_dump. Can anyone help us out. My colleagues and...
Real Solution... if want to save jpg images from an System.Windows.Control.Image when your database mapped field on your ORM is Byte[] / byte[] / Bynary ``` public byte[] getJPGFromImageControl(BitmapImage imageC) { MemoryStream memStream = new MemoryStream(); JpegBitmapEncoder encoder = n...
553,628
<p>I seem to manage the same task many times beforehand; but currently I got thoroughly stuck at the simplest thing and it have made mequite irritated</p> <p>I need to assign javascript to ASP.Net linkbutton (or hyperlink, does not matter) What seems to be easier? </p> <p>Billion times I did it with code like like t...
[ { "answer_id": 553671, "author": "Jakob Christensen", "author_id": 64161, "author_profile": "https://Stackoverflow.com/users/64161", "pm_score": 1, "selected": false, "text": "<p>The ASP.NET controls Button and LinkButton will always do postbacks. The javascript that you might add using...
2009/02/16
[ "https://Stackoverflow.com/questions/553628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I seem to manage the same task many times beforehand; but currently I got thoroughly stuck at the simplest thing and it have made mequite irritated I need to assign javascript to ASP.Net linkbutton (or hyperlink, does not matter) What seems to be easier? Billion times I did it with code like like that ``` /...
You could use the LinkButton control and add a javascript function call to OnClientClick. This will be called before the clientside validation and before the postback (obviously). Should you need to execute this after validation but before the postback then you could call the clientside validation manually in your OnCl...
553,648
<p>I would like to schedule a daily task : every day at 7 AM, I want an email to be sent (without human intervention).</p> <p>I'm working on the RoR framework and I'm wondering what is the best way to do that?</p> <p>I've heard about BackgrounDRB, OpenWFEru scheduler or things based on Cron, but I'm a newbie and don'...
[ { "answer_id": 553695, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 1, "selected": false, "text": "<p>Add a class method to one of your models that will handle this for you. Now try to execute that method using the ru...
2009/02/16
[ "https://Stackoverflow.com/questions/553648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67001/" ]
I would like to schedule a daily task : every day at 7 AM, I want an email to be sent (without human intervention). I'm working on the RoR framework and I'm wondering what is the best way to do that? I've heard about BackgrounDRB, OpenWFEru scheduler or things based on Cron, but I'm a newbie and don't understand whic...
Another option is to create a rake task that is run by a cron job. To do this, create a file `some_file.rake` and put it in your `lib/tasks` folder. Your file might look like this: Rails 2.x: ``` task :send_daily_mail, :needs => :environment do Model.send_daily_mail end ``` Rails 3.x: ``` task :send_daily_mai...
553,649
<p>I'm "developing" a test plan in Mercury/HP QuickTest Pro 9.1, in which I must extract a list of all links in an E-mail and perform logic against each of them.</p> <p>In this case, I am using Webmail, so the message will appear as a web page; though I hope to use Outlook later to replicate a more realistic UX.</p> ...
[ { "answer_id": 555340, "author": "Sam Warwick", "author_id": 3873, "author_profile": "https://Stackoverflow.com/users/3873", "pm_score": 3, "selected": true, "text": "<p>You can call the <code>ChildObjects</code> method to return a collection of child objects of a given type. For example...
2009/02/16
[ "https://Stackoverflow.com/questions/553649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11112/" ]
I'm "developing" a test plan in Mercury/HP QuickTest Pro 9.1, in which I must extract a list of all links in an E-mail and perform logic against each of them. In this case, I am using Webmail, so the message will appear as a web page; though I hope to use Outlook later to replicate a more realistic UX. I am a Develop...
You can call the `ChildObjects` method to return a collection of child objects of a given type. For example, to get a list of all the Link objects on the Google home page: ``` set oDesc = Description.Create() oDesc("micclass").Value = "Link" set links = Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc...
553,669
<p>EDIT: Just realised that the reason for the additional results is down to another line in the query! Don't think I have enough rep to close this question.</p> <p>I'm editing some existing SQL code which is searching a Lotus Notes DB.</p> <p>I have this line:</p> <pre><code>@Contains(Title; "blah blah 1.5") </code...
[ { "answer_id": 553693, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<p>I think you simply need to test for equality, instead of using a full text search operator:</p>\n\n<pre><code>WHERE Tit...
2009/02/16
[ "https://Stackoverflow.com/questions/553669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/849/" ]
EDIT: Just realised that the reason for the additional results is down to another line in the query! Don't think I have enough rep to close this question. I'm editing some existing SQL code which is searching a Lotus Notes DB. I have this line: ``` @Contains(Title; "blah blah 1.5") ``` and I want to return only th...
I'm assuming by your example you're actually editing a Lotus Notes search formula and not a SQL query. The SQL format for the CONTAINS function doesn't use semicolons to separate parameters, and does not have an @ sign in the function name. Going with that assumption, you'll want to change the search formula to be si...
553,672
<p>I am a bit of a beginner with javascript and I can't think of a way around the folowing problem. I am using Mootools in this example, though this is not a Mootools question:</p> <pre><code>for (var i = 0; i &lt; 5; i++) { myElement[i].addEvent('click', function () { otherFunction(i); }); } </code></pre> <p>Whe...
[ { "answer_id": 553728, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 1, "selected": false, "text": "<p>I agree with the comment questioning why you need five click handlers for a single element, but to accomplish what you des...
2009/02/16
[ "https://Stackoverflow.com/questions/553672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
I am a bit of a beginner with javascript and I can't think of a way around the folowing problem. I am using Mootools in this example, though this is not a Mootools question: ``` for (var i = 0; i < 5; i++) { myElement[i].addEvent('click', function () { otherFunction(i); }); } ``` Whenever someone clicks on myEle...
Your code is an example of a closure - the anonymous function references the last value of *i* as it is effectively preserving that outer scope for later use when the function is called. Here's one way you could fix it: ``` function getClickHandler(i) { return function () { otherFunction(i); } } for (var i = 0; ...