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
558,335
<p>Im getting an Exception when I try updating, Insert works perfectly.. so this is: A first chance exception of type 'System.InvalidCastException' occurred in System.Data.Linq.dll Another cue... is possible to insert in one table first and then update another table and finally submitchanges() all in same code-block? ...
[ { "answer_id": 558339, "author": "Todd Gamblin", "author_id": 9122, "author_profile": "https://Stackoverflow.com/users/9122", "pm_score": 1, "selected": false, "text": "<p>How about <a href=\"http://www.webdav.org/\" rel=\"nofollow noreferrer\">WebDAV</a>? This is what <a href=\"http://...
2009/02/17
[ "https://Stackoverflow.com/questions/558335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1388553/" ]
Im getting an Exception when I try updating, Insert works perfectly.. so this is: A first chance exception of type 'System.InvalidCastException' occurred in System.Data.Linq.dll Another cue... is possible to insert in one table first and then update another table and finally submitchanges() all in same code-block? I a...
A solution can be F\*EX, see <http://fex.rus.uni-stuttgart.de/>
558,344
<p>I have a ClickOnce application that is available online or offline. The program takes an argument. When online I pass the argument on the URL like so "url?argument", and it works well. Offline I start a process with the startmenu link to the application.</p> <p>Is it possible to pass an argument to my application v...
[ { "answer_id": 560057, "author": "codeConcussion", "author_id": 1321, "author_profile": "https://Stackoverflow.com/users/1321", "pm_score": 1, "selected": false, "text": "<p>No, you can't pass arguments from the Start Menu shortcut. If you find a way, let me know because I've been tryin...
2009/02/17
[ "https://Stackoverflow.com/questions/558344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a ClickOnce application that is available online or offline. The program takes an argument. When online I pass the argument on the URL like so "url?argument", and it works well. Offline I start a process with the startmenu link to the application. Is it possible to pass an argument to my application via this li...
I was able to get this to work by referencing the app as "%userprofile%\Desktop\Your Shortcut Name Here.appref-ms" Then, to pass the parms, pass them as a single, no space entity like so: arg1,arg2,arg3 The whole thing looks like this on the command line: ``` "%userprofile%\Desktop\Your Shortcut Name Here.appref-ms"...
558,366
<p>I am trying to debug a small operating system I have written in an university course in C++. At runtime somewhere one of my objects is getting corrupted. It seems like this happens due to accidentally writing to the wrong memory address. As I am unable to find the place where this happens from pure looking at the co...
[ { "answer_id": 558408, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "https://Stackoverflow.com/users/1084", "pm_score": 4, "selected": true, "text": "<p>You can put a watchpoint:</p>\n\n<pre><code>watch x\n</code></pre>\n\n<p>This will break when <code>x</code> is mod...
2009/02/17
[ "https://Stackoverflow.com/questions/558366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67498/" ]
I am trying to debug a small operating system I have written in an university course in C++. At runtime somewhere one of my objects is getting corrupted. It seems like this happens due to accidentally writing to the wrong memory address. As I am unable to find the place where this happens from pure looking at the code,...
You can put a watchpoint: ``` watch x ``` This will break when `x` is modified. `x` can be any type of variable. If you have: ``` class A; A x; ``` Then gdb will break whenever x is modified. You can actually put a watchpoint on any expression, and gdb will break when the expression changes. Be careful with this...
558,368
<p>How do i parse tokens from an input string. For example:</p> <pre><code>char *aString = "Hello world". </code></pre> <p>I want the output to be: </p> <blockquote> <p>"Hello" "world"</p> </blockquote>
[ { "answer_id": 558372, "author": "Todd Gamblin", "author_id": 9122, "author_profile": "https://Stackoverflow.com/users/9122", "pm_score": 3, "selected": false, "text": "<p>Take a look at <a href=\"http://www.opengroup.org/onlinepubs/000095399/functions/strtok.html\" rel=\"nofollow norefe...
2009/02/17
[ "https://Stackoverflow.com/questions/558368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67129/" ]
How do i parse tokens from an input string. For example: ``` char *aString = "Hello world". ``` I want the output to be: > > "Hello" "world" > > >
You are going to want to use `strtok` - [here is a good example.](http://www.java2s.com/Code/C/String/Truncatestringbydelimiterhowtousestrtok.htm)
558,423
<p>I have an ASP.NET web service which is receiving a byte array representing the contents of a <code>.pfx</code> file containing an X.509 certificate. The server-side code is using the <code>System.Security.Cryptography.X509Certificate2</code> constructor to load the certificate from the bytes:</p> <pre><code>X509Ce...
[ { "answer_id": 558466, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 2, "selected": false, "text": "<p>Try granting the ASP.NET account permissions to the following folder: <code>C:\\Documents And Settings\\All User...
2009/02/17
[ "https://Stackoverflow.com/questions/558423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7450/" ]
I have an ASP.NET web service which is receiving a byte array representing the contents of a `.pfx` file containing an X.509 certificate. The server-side code is using the `System.Security.Cryptography.X509Certificate2` constructor to load the certificate from the bytes: ``` X509Certificate2 native_cert = new X509Cert...
I just found the solution to this one myself: ``` X509KeyStorageFlags flags = X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet; X509Certificate2 cert = new X509Certificate2(pkcs12_buf, password, flags); ``` The trick here is to use the local key store `MachineKeySet` flag instead of the user pr...
558,439
<p>Given a class that is semantically supposed to be an object of a certain type, but also has multiple operations for operating <em>on</em> objects of its own type, what is the best way(pattern?) of organizing the class in this type of scenario? I find this to be a common occurrence when a developer creates objects bu...
[ { "answer_id": 558454, "author": "Christophe Herreman", "author_id": 17255, "author_profile": "https://Stackoverflow.com/users/17255", "pm_score": 3, "selected": true, "text": "<p>It's not very clear from your description, but it seems that the \"KillAllUsers\" and \"MainAllUsers\" metho...
2009/02/17
[ "https://Stackoverflow.com/questions/558439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67117/" ]
Given a class that is semantically supposed to be an object of a certain type, but also has multiple operations for operating *on* objects of its own type, what is the best way(pattern?) of organizing the class in this type of scenario? I find this to be a common occurrence when a developer creates objects but is think...
It's not very clear from your description, but it seems that the "KillAllUsers" and "MainAllUsers" methods are operating on a set of users. I would recommend creating a custom UserCollection that has these methods as instance methods or create them as statics and pass in a collection of users. In modern domain model te...
558,440
<p>I just recently started a new personal project, with a goal of having it able to scale from the start.</p> <p>I got a suggestion for the structure, to create something like this: </p> <pre><code>&lt;solution&gt; |-- project.client.sql.queries |-- project.admin.sql.queries |-- project.client.business.logic |-- proj...
[ { "answer_id": 558489, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Here is the best advice anyone can ever give you at this point in time:</p>\n\n<blockquote>\n <p>The crappy first version ...
2009/02/17
[ "https://Stackoverflow.com/questions/558440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57655/" ]
I just recently started a new personal project, with a goal of having it able to scale from the start. I got a suggestion for the structure, to create something like this: ``` <solution> |-- project.client.sql.queries |-- project.admin.sql.queries |-- project.client.business.logic |-- project.admin.business.logic |-...
Attach the database and create a linq to sql dbml file in your data project. When you initialise your dataservice class, pass in the connection string from web.config and set the connection string in your datacontext constructor. More info here: [Connection string hell in .NET / LINQ-SQL / ASP.NET](https://stackoverflo...
558,445
<p>I know how to do this with pure PHP but I need to do this without reloading the page. Is there anyway with jQuery to effectively pull back some database results (based on what a user has input in the first text field on a form) then populate some of the remaining fields with data pulled back from a db query?</p> <...
[ { "answer_id": 558479, "author": "jon skulski", "author_id": 47545, "author_profile": "https://Stackoverflow.com/users/47545", "pm_score": 3, "selected": false, "text": "<p>If you need to hit the database, you need to hit the web server again (for the most part).</p>\n\n<p>What you can d...
2009/02/17
[ "https://Stackoverflow.com/questions/558445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59975/" ]
I know how to do this with pure PHP but I need to do this without reloading the page. Is there anyway with jQuery to effectively pull back some database results (based on what a user has input in the first text field on a form) then populate some of the remaining fields with data pulled back from a db query? Essential...
Assuming this example HTML: ``` <input type="text" name="email" id="email" /> <input type="text" name="first_name" id="first_name" /> <input type="text" name="last_name" id="last_name" /> ``` You could have this javascript: ``` $("#email").bind("change", function(e){ $.getJSON("http://yourwebsite.com/lokup.php?em...
558,462
<h2>Background</h2> <p>I am writing a data access library using the ADO Entity Framework in Visual Studio 2008 SP1 using the .NET Framework 3.5 SP1. I am trying to create associations between two entities that are both derived from an abstract type. I am representing both entity inheritance hierarchies using <a href="...
[ { "answer_id": 591942, "author": "Zach Burlingame", "author_id": 2233, "author_profile": "https://Stackoverflow.com/users/2233", "pm_score": 4, "selected": true, "text": "<h2>Possible Workaround</h2>\n\n<ol>\n<li>Create a separate column for each association between derived types and mak...
2009/02/17
[ "https://Stackoverflow.com/questions/558462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2233/" ]
Background ---------- I am writing a data access library using the ADO Entity Framework in Visual Studio 2008 SP1 using the .NET Framework 3.5 SP1. I am trying to create associations between two entities that are both derived from an abstract type. I am representing both entity inheritance hierarchies using [Table Per...
Possible Workaround ------------------- 1. Create a separate column for each association between derived types and make each of these columns **nullable** 2. Create a foreign key between each of these new columns and the primary key table. 3. Map each association in your Entity Model to a specific, unique column and f...
558,474
<p>I'm learning C++ at the moment, and I'm coming across a lot of null-terminated strings. This has got me thinking, what makes more sense when declaring pointers:</p> <pre><code>char* string </code></pre> <p>or</p> <pre><code>char *string </code></pre> <p>? To me, the char* format makes more sense, because the type of...
[ { "answer_id": 558480, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 7, "selected": true, "text": "<p>In the following declaration:</p>\n\n<pre><code>char* string1, string2;\n</code></pre>\n\n<p><code>string1</code> is a ...
2009/02/17
[ "https://Stackoverflow.com/questions/558474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49376/" ]
I'm learning C++ at the moment, and I'm coming across a lot of null-terminated strings. This has got me thinking, what makes more sense when declaring pointers: ``` char* string ``` or ``` char *string ``` ? To me, the char\* format makes more sense, because the type of "string" is a pointer to a char, rather tha...
In the following declaration: ``` char* string1, string2; ``` `string1` is a character pointer, but `string2` is a single character only. For this reason, the declaration is usually formatted like: ``` char *string1, string2; ``` which makes it slightly clearer that the `*` applies to `string1` but not `string2`....
558,478
<p>I'd like to do something like this:</p> <pre><code>&gt;&gt; foo = @() functionCall1() functionCall2() </code></pre> <p>So that when I said:</p> <pre><code>&gt;&gt; foo() </code></pre> <p>It would execute <code>functionCall1()</code> and then execute <code>functionCall2()</code>. (I feel that I need something li...
[ { "answer_id": 558868, "author": "gnovice", "author_id": 52738, "author_profile": "https://Stackoverflow.com/users/52738", "pm_score": 7, "selected": true, "text": "<p>Trying to do everything via the command line without saving functions in m-files may be a complicated and messy endeavor...
2009/02/17
[ "https://Stackoverflow.com/questions/558478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62055/" ]
I'd like to do something like this: ``` >> foo = @() functionCall1() functionCall2() ``` So that when I said: ``` >> foo() ``` It would execute `functionCall1()` and then execute `functionCall2()`. (I feel that I need something like the [C , operator](http://www.eskimo.com/~scs/cclass/int/sx4db.html)) EDIT: `fu...
Trying to do everything via the command line without saving functions in m-files may be a complicated and messy endeavor, but here's one way I came up with... First, make your [anonymous functions](http://www.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html) and put their [handles](https://www.mathworks....
558,502
<p>We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file exist. </p> <p>How can we call the the properties file dynamicall...
[ { "answer_id": 558516, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 2, "selected": false, "text": "<p>Take a look at <code>ServletContext</code>'s <a href=\"http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet...
2009/02/17
[ "https://Stackoverflow.com/questions/558502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13491/" ]
We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file exist. How can we call the the properties file dynamically? **Give...
You must have a way of knowing the path of the property file which you can then wrap in a File and pass to the load() method of your properties object. If you run inside a Tomcat service you are not running as the user you installed it as,so you cannot derive the home directory. You most likely need to hardcode SOMETH...
558,515
<p>What is the best / most flexible way to have WCF output XHTML? If there is no "WCF Way" (tm) to do XHTML output - is there any common tooling out there for it? Or do I need to roll my own?</p>
[ { "answer_id": 558966, "author": "Tad Donaghe", "author_id": 1572436, "author_profile": "https://Stackoverflow.com/users/1572436", "pm_score": 1, "selected": false, "text": "<p>WCF is a component technology - you write interfaces and their implementations and then instruct WCF how to han...
2009/02/17
[ "https://Stackoverflow.com/questions/558515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13276/" ]
What is the best / most flexible way to have WCF output XHTML? If there is no "WCF Way" (tm) to do XHTML output - is there any common tooling out there for it? Or do I need to roll my own?
I don't believe there is an "official" WCF way to return XHTML, as of .NET 3.5 SP1. [Aaron Lerch suggested having WCF apply a default XSLT stylesheet in July 2007](http://www.aaronlerch.com/blog/2007/07/16/a-humble-wcf-feature-request-or-four/), but something like this hasn't yet been adopted by the WCF team. As othe...
558,539
<p>How do I make nested loops in Python (version 3.0)?</p> <p>I am trying to get the following loops to show me the products of two numbers:</p> <pre><code>def PrintProductsBelowNumber(number): number1 = 1 number2 = 1 while number1 &lt;= number: while number2 &lt;= number: print(number...
[ { "answer_id": 558552, "author": "Mike Boers", "author_id": 66502, "author_profile": "https://Stackoverflow.com/users/66502", "pm_score": 4, "selected": true, "text": "<p>Because you aren't setting number2 back to 1 after the inner loop completes the first time. number1 then increments, ...
2009/02/17
[ "https://Stackoverflow.com/questions/558539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41094/" ]
How do I make nested loops in Python (version 3.0)? I am trying to get the following loops to show me the products of two numbers: ``` def PrintProductsBelowNumber(number): number1 = 1 number2 = 1 while number1 <= number: while number2 <= number: print(number1, "*", number2, "=", numbe...
Because you aren't setting number2 back to 1 after the inner loop completes the first time. number1 then increments, but since number2 is still too high the inner loop doesn't run again. ``` def PrintProductsBelowNumber(number): number1 = 1 while number1 <= number: number2 = 1 while number2 <=...
558,546
<p>The application I'm working on has a single class that maintains a database connection. All members of this class are static to enforce a singleton-like pattern, so the actual connection logic is performed in a static initializer block:</p> <pre><code>public class HibernateUtil { private static final SessionFa...
[ { "answer_id": 558553, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<p>Maybe it shouldn't have been static in the first place.</p>\n" }, { "answer_id": 558581, "author": "Gareth Davi...
2009/02/17
[ "https://Stackoverflow.com/questions/558546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56333/" ]
The application I'm working on has a single class that maintains a database connection. All members of this class are static to enforce a singleton-like pattern, so the actual connection logic is performed in a static initializer block: ``` public class HibernateUtil { private static final SessionFactory sessionF...
Keep the static methods and let them delegate to corresponding instance methods of a default instance. For the secondary databases allow to create more instances by whatever means and access them via their instance methods. Then you can chip away at the callers of the static methods, and when they are all gone remov...
558,571
<p>I want to have a large HTML form broken up into several smaller sub-forms in a JQuery UI tabs layout. But I want to have one special "All" tab that has all of the sub-forms on that tab. So when a user clicks on the All tab, they can see and edit all of the form fields that are normally divided up on several tabs.<...
[ { "answer_id": 558650, "author": "jeroen", "author_id": 42139, "author_profile": "https://Stackoverflow.com/users/42139", "pm_score": 1, "selected": false, "text": "<p>Assuming you have the different tabs working / showing already, you can just loop through all elements (the blocks with ...
2009/02/17
[ "https://Stackoverflow.com/questions/558571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36680/" ]
I want to have a large HTML form broken up into several smaller sub-forms in a JQuery UI tabs layout. But I want to have one special "All" tab that has all of the sub-forms on that tab. So when a user clicks on the All tab, they can see and edit all of the form fields that are normally divided up on several tabs. How ...
Seems like you just need to group your fields in DIVs, and then have only one DIV visible at a time, unless the viewer has selected "All". This is a very quick mock-up, but should illustrate my point clearly. ``` <!-- Clicking a groupButton hides all groups, save for the href'd group --> <a href="#group1" class="group...
558,576
<p>I'd like to lay out a list such as the following in 2/3 evenly spaced columns</p> <pre><code>&lt;ul&gt; &lt;li&gt;one&lt;li&gt; &lt;li&gt;two&lt;li&gt; &lt;li&gt;three&lt;li&gt; &lt;li&gt;four&lt;li&gt; &lt;li&gt;five&lt;li&gt; &lt;li&gt;six&lt;li&gt; &lt;li&gt;seven&lt;li&gt; &lt;li&gt;eight&lt;li&...
[ { "answer_id": 558591, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://www.alistapart.com/articles/multicolumnlists\" rel=\"noreferrer\"><strong>This article</strong></a> from A Lis...
2009/02/17
[ "https://Stackoverflow.com/questions/558576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I'd like to lay out a list such as the following in 2/3 evenly spaced columns ``` <ul> <li>one<li> <li>two<li> <li>three<li> <li>four<li> <li>five<li> <li>six<li> <li>seven<li> <li>eight<li> <li>nine<li> </ul> ``` One solution is to separate the list into two lists and float one of them right, poss...
[**This article**](http://www.alistapart.com/articles/multicolumnlists) from A List Apart covers the commonly-accepted, close-to-best-practices-as-we-can-get methods for doing what you describe.
558,577
<p>I've got a really simple powershell script (see below). I've got installutil aliased using the following in my profile:</p> <pre><code>set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil </code></pre> <p>In powershell I simply:</p> <pre><code>installutil assemplylocation.dll </code></...
[ { "answer_id": 560030, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 1, "selected": false, "text": "<p>Did you run installutil as an elevated user? It writes information to protected portions of the registry. If you do ...
2009/02/17
[ "https://Stackoverflow.com/questions/558577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67545/" ]
I've got a really simple powershell script (see below). I've got installutil aliased using the following in my profile: ``` set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil ``` In powershell I simply: ``` installutil assemplylocation.dll ``` This returns successfully. (Install/Comm...
Turns out the issue was that I had a 32-bit cmdlet - but was only checking the 64-bit version of powershell ...
558,580
<p>I am trying to update tables with a has and belongs to many (HABTM) relationship.</p> <p>When my join table looked like this:</p> <pre><code>CREATE TABLE IF NOT EXISTS `items_labels` ( `item_id` int(11) NOT NULL, `label_id` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; </code></pre> <p>I use CakePHP,...
[ { "answer_id": 562942, "author": "neilcrookes", "author_id": 9968, "author_profile": "https://Stackoverflow.com/users/9968", "pm_score": 1, "selected": false, "text": "<p>CakePHP's model::save() method won't do this for you AFAIK. I think you have to use model::saveAll() and call it on t...
2009/02/17
[ "https://Stackoverflow.com/questions/558580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/74552/" ]
I am trying to update tables with a has and belongs to many (HABTM) relationship. When my join table looked like this: ``` CREATE TABLE IF NOT EXISTS `items_labels` ( `item_id` int(11) NOT NULL, `label_id` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; ``` I use CakePHP, so I could update the tables wit...
This should work: ``` Array ( [Item] => Array ( [id] => 1 ) [Label] => Array ( [Label] => Array ( [0] => Array ( [label_id] => 4 [user_id] => 1 ...
558,592
<p>I have an UpdatePanel with two ListBoxes in them. What I want to happen is that when the page loads the first ListBox fills with some data. When the user selects and item the second ListBox should be populated with the pertinent data.</p> <p>Here is what happens, the first ListBox is filled with data, the user se...
[ { "answer_id": 558633, "author": "achinda99", "author_id": 60824, "author_profile": "https://Stackoverflow.com/users/60824", "pm_score": 2, "selected": true, "text": "<p>Based on the information provided, my initial thoughts are that you are repopulating lbMagazines on page load, so that...
2009/02/17
[ "https://Stackoverflow.com/questions/558592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51709/" ]
I have an UpdatePanel with two ListBoxes in them. What I want to happen is that when the page loads the first ListBox fills with some data. When the user selects and item the second ListBox should be populated with the pertinent data. Here is what happens, the first ListBox is filled with data, the user selects an ite...
Based on the information provided, my initial thoughts are that you are repopulating lbMagazines on page load, so that by the time it gets to the event, the selecteditem/index is cleared.
558,610
<p>I am experimenting with C++ winsockets. I want to create a method with which I can find the server on the network, without knowing it's IP. To do this I simply loop my connect method through IP adresses 192.168.1.0 to 192.168.1.255. However, the time between each connect is quite large, the program tends to wait at ...
[ { "answer_id": 558632, "author": "anorm", "author_id": 1071362, "author_profile": "https://Stackoverflow.com/users/1071362", "pm_score": 2, "selected": false, "text": "<p>The long delay is caused by the socket's need to time out before returning to the caller. To reduce the total executi...
2009/02/17
[ "https://Stackoverflow.com/questions/558610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23163/" ]
I am experimenting with C++ winsockets. I want to create a method with which I can find the server on the network, without knowing it's IP. To do this I simply loop my connect method through IP adresses 192.168.1.0 to 192.168.1.255. However, the time between each connect is quite large, the program tends to wait at the...
The long delay is caused by the socket's need to time out before returning to the caller. To reduce the total execution time, you should make multiple worker threads that simultaneously connect to separate IP-addresses.
558,614
<p>How would I go about reordering divs without altering the HTML source code?</p> <p>example, I want divs to appear in order #div2, #div1, #div3, but in the HTML they are:</p> <pre><code>&lt;div id="#div1"&gt;&lt;/div&gt; &lt;div id="#div2"&gt;&lt;/div&gt; &lt;div id="#div3"&gt;&lt;/div&gt; </code></pre> <p>Tha...
[ { "answer_id": 558637, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 0, "selected": false, "text": "<p>Since you tagged jQuery, you could use javascript to <a href=\"http://docs.jquery.com/Manipulation/remove#expr\" rel=\...
2009/02/17
[ "https://Stackoverflow.com/questions/558614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67550/" ]
How would I go about reordering divs without altering the HTML source code? example, I want divs to appear in order #div2, #div1, #div3, but in the HTML they are: ``` <div id="#div1"></div> <div id="#div2"></div> <div id="#div3"></div> ``` Thanks!
There is no catch-all way of reordering elements with css. You can inverse their order horizontally by floating them all to the right. Or you can position them absolutely relative to the body or some other containing element - but that comes with severe limitations regarding the size of the elements, and positioning r...
558,615
<p>I'm trying to create an html table for order logs for customers. A customer is defined as (I've left out a lot of stuff):</p> <pre><code>public class Customer { public LazyList&lt;Order&gt; Orders { get; set; } } </code></pre> <p>The LazyList is set when fetching a Customer:</p> <pre><code>public Customer Ge...
[ { "answer_id": 558640, "author": "Alex Reitbort", "author_id": 11525, "author_profile": "https://Stackoverflow.com/users/11525", "pm_score": 3, "selected": true, "text": "<p>LazyList loads all data on first use, so you are loading all the orders in list on the Count call. Getting all dat...
2009/02/17
[ "https://Stackoverflow.com/questions/558615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create an html table for order logs for customers. A customer is defined as (I've left out a lot of stuff): ``` public class Customer { public LazyList<Order> Orders { get; set; } } ``` The LazyList is set when fetching a Customer: ``` public Customer GetCustomer(int custID) { Customer c = ......
LazyList loads all data on first use, so you are loading all the orders in list on the Count call. Getting all data from db, instantiating objects, etc. When you call \_repository.GetOrders().ByCustomerID(custID).Count(), it just counts the rows in database and returns one number.
558,617
<p>I'm trying to animate the drawing of a circle. Something the Shazaam app is doing while recording, but much simpler.<br> I've got this code in the drawRect: method to draw the circle:</p> <pre><code>CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(currentContext, 0.86, 0.86, 0...
[ { "answer_id": 558640, "author": "Alex Reitbort", "author_id": 11525, "author_profile": "https://Stackoverflow.com/users/11525", "pm_score": 3, "selected": true, "text": "<p>LazyList loads all data on first use, so you are loading all the orders in list on the Count call. Getting all dat...
2009/02/17
[ "https://Stackoverflow.com/questions/558617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67547/" ]
I'm trying to animate the drawing of a circle. Something the Shazaam app is doing while recording, but much simpler. I've got this code in the drawRect: method to draw the circle: ``` CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(currentContext, 0.86, 0.86, 0.86, 1.0); CGCo...
LazyList loads all data on first use, so you are loading all the orders in list on the Count call. Getting all data from db, instantiating objects, etc. When you call \_repository.GetOrders().ByCustomerID(custID).Count(), it just counts the rows in database and returns one number.
558,648
<p>I'm looking for a DOS script to delete all files and subdirectories in a root directory except for a set of batch files (*.bat) that are in the root directory. Any DOS jocks out there that know an easy way to do this?</p> <p><strong>Update</strong></p> <p>Thanks for your help everyone. This is where I'm at now (...
[ { "answer_id": 558662, "author": "Alex Reitbort", "author_id": 11525, "author_profile": "https://Stackoverflow.com/users/11525", "pm_score": 2, "selected": false, "text": "<p>Fixed based on @Ken's comment:</p>\n\n<pre><code>&gt;d:\n&gt;mkdir bats\n&gt;c:\n&gt;copy *.bat d:\\bats\n&gt;del...
2009/02/17
[ "https://Stackoverflow.com/questions/558648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47281/" ]
I'm looking for a DOS script to delete all files and subdirectories in a root directory except for a set of batch files (\*.bat) that are in the root directory. Any DOS jocks out there that know an easy way to do this? **Update** Thanks for your help everyone. This is where I'm at now (see below). I'm using Ken's sug...
YOu can set the attributes of the files you want to keep to readonly and hidden first, delete the rest, and then reset the attributes of the hidden, readonly files back. ``` attrib +r +s *.bat del *.* attrib -r -s *.bat ``` I used to do that quite often, and wrote a batch file that automated this: ``` @echo off @ i...
558,653
<p>I use expiring urls to hide the urls of images I use on my sites, so that they can only be hotlinked for the duration of the life of the hash (1 hour).</p> <p>I check the hash sent with the file url, against a hash on the server, if they match, the script calls the following code:</p> <pre><code>if (isset($_GET["h...
[ { "answer_id": 559202, "author": "Theo.T", "author_id": 64223, "author_profile": "https://Stackoverflow.com/users/64223", "pm_score": 0, "selected": false, "text": "<p>Would be interesting to know what runtime error the player script throws ?</p>\n\n<p>You may have more chances to make i...
2009/02/17
[ "https://Stackoverflow.com/questions/558653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I use expiring urls to hide the urls of images I use on my sites, so that they can only be hotlinked for the duration of the life of the hash (1 hour). I check the hash sent with the file url, against a hash on the server, if they match, the script calls the following code: ``` if (isset($_GET["hash"])) { $th...
You can't really hide a downloading URL very effectively. Safari, for example, exposes all resources downloaded via the Activity window. Just look for the item that is MB in size and that's your FLV file. The only way to keep people from ripping your FLVs is to use RTMP streaming, where they never get access to the fu...
558,657
<p>I was searching for "Undo/Redo algorithms" and found something marked as a duplicate, but the duplicate was a request for a "Undo Design Pattern". I'd really like an algorithm for this. I don't think I necessarily need a design pattern. </p> <p>Is there a fundamental difference between "Design Pattern" and "Algor...
[ { "answer_id": 558669, "author": "Bernard", "author_id": 61, "author_profile": "https://Stackoverflow.com/users/61", "pm_score": 0, "selected": false, "text": "<p>A design pattern would determine how you design an algorithm (or may have nothing to do with algorithms, but let's say we're ...
2009/02/17
[ "https://Stackoverflow.com/questions/558657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
I was searching for "Undo/Redo algorithms" and found something marked as a duplicate, but the duplicate was a request for a "Undo Design Pattern". I'd really like an algorithm for this. I don't think I necessarily need a design pattern. Is there a fundamental difference between "Design Pattern" and "Algorithm" or is ...
An algorithm is like a recipe: a step-by-step process for performing some activity. A design pattern is like a blueprint: an structured collection of objects and associations and actions to accomplish some goal.
558,666
<p>There are some tables that we want to do a search.<br> I couldn't understand why this error happens , please help.<br> I should be easy for experts,</p> <pre><code>SELECT * FROM passenger INNER JOIN [passenger-flylist] ppff ON ppp.[passenger-id] = ppff.[passenger-id] </code></pre> <p><strong>the Error :</strong><...
[ { "answer_id": 558682, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 4, "selected": true, "text": "<p>The problem is a missing alias ppp</p>\n\n<pre><code>SELECT * FROM passenger ppp\nINNER JOIN [passenger-flylist] ppff \nON...
2009/02/17
[ "https://Stackoverflow.com/questions/558666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50506/" ]
There are some tables that we want to do a search. I couldn't understand why this error happens , please help. I should be easy for experts, ``` SELECT * FROM passenger INNER JOIN [passenger-flylist] ppff ON ppp.[passenger-id] = ppff.[passenger-id] ``` **the Error :** > > Msg 4104, Level 16, State 1, Line 1...
The problem is a missing alias ppp ``` SELECT * FROM passenger ppp INNER JOIN [passenger-flylist] ppff ON ppp.[passenger-id] = ppff.[passenger-id] ```
558,670
<p>Lets say I have a table containing several hundred million rows that looks something like this:</p> <pre><code>memID | foo | bar | foobar 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah |...
[ { "answer_id": 558708, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 1, "selected": false, "text": "<p>If you are using SQL Server 2005 or 2008 you might want to investigate the <a href=\"http://msdn.microsoft.com/en-us/libr...
2009/02/17
[ "https://Stackoverflow.com/questions/558670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47540/" ]
Lets say I have a table containing several hundred million rows that looks something like this: ``` memID | foo | bar | foobar 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 1 | blah | blah | blah 2...
``` declare @startID int, @endID int, @rowsEach int select @startID = 0, @endID = 2, @rowsEach = 3 select * from ( select memID, foo, bar, foobar, row_number() over (partition by dense_rank order by dense_rank) [rank_row] from ( select memID, foo, bar, foobar, dense_rank() over (order by memID) [de...
558,683
<p>I was using UserVoice and noted that flash messages are like StackOverflow.</p> <p>Is there any common library to build something like this?</p> <pre><code> &lt;div class="uservoice-component"&gt; &lt;div id="flashes" class="has-layout"&gt; &lt;script type="text/javascript"&gt; //&lt;![CDATA[ setTimeout...
[ { "answer_id": 558834, "author": "Ryan Graham", "author_id": 62525, "author_profile": "https://Stackoverflow.com/users/62525", "pm_score": 1, "selected": false, "text": "<p>Not entirely sure what you're asking for. The example code you gave looks like <a href=\"http://jquery.com/\" rel=\...
2009/02/17
[ "https://Stackoverflow.com/questions/558683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55927/" ]
I was using UserVoice and noted that flash messages are like StackOverflow. Is there any common library to build something like this? ``` <div class="uservoice-component"> <div id="flashes" class="has-layout"> <script type="text/javascript"> //<![CDATA[ setTimeout("$$('.message').each(function(element){ n...
Not entirely sure what you're asking for. The example code you gave looks like [jQuery](http://jquery.com/) to me, which is a relatively standard library.
558,685
<p>In Flex 3.2, I'm creating a UITextField, then measuring text that I'm about to assign to that field's text property. I then use those metrics to set the size of the field. However, the calculated width is not wide enough to accommodate the text. Is there a different order to achieve proper measurement or am I see...
[ { "answer_id": 558837, "author": "James Hay", "author_id": 47339, "author_profile": "https://Stackoverflow.com/users/47339", "pm_score": 3, "selected": true, "text": "<p>I've had all sorts of trouble with measuring the width and heights of textFields before. It looks like you just want ...
2009/02/17
[ "https://Stackoverflow.com/questions/558685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In Flex 3.2, I'm creating a UITextField, then measuring text that I'm about to assign to that field's text property. I then use those metrics to set the size of the field. However, the calculated width is not wide enough to accommodate the text. Is there a different order to achieve proper measurement or am I seeing a ...
I've had all sorts of trouble with measuring the width and heights of textFields before. It looks like you just want to autosize the textField. Have you tried: ``` uiTextField.autoSize = TextFieldAutoSize.LEFT; ``` ???
558,719
<p>I want to show a random record from the database. I would like to be able to show X number of random records if I choose. Therefore I need to select the top X records from a randomly selected list of IDs</p> <p>(There will never be more than 500 records involved to choose from, unless the earth dramatically incre...
[ { "answer_id": 558749, "author": "Jason Punyon", "author_id": 6212, "author_profile": "https://Stackoverflow.com/users/6212", "pm_score": 3, "selected": true, "text": "<p>Why not use the Rand Function in an orderby in your database query? Then you don't have to get into randomizing etc ...
2009/02/17
[ "https://Stackoverflow.com/questions/558719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24229/" ]
I want to show a random record from the database. I would like to be able to show X number of random records if I choose. Therefore I need to select the top X records from a randomly selected list of IDs (There will never be more than 500 records involved to choose from, unless the earth dramatically increases in size...
Why not use the Rand Function in an orderby in your database query? Then you don't have to get into randomizing etc in code... Something like (I don't know if this is legal) ``` Select * from site_info Order by Rand() LIMIT N ``` where N is the number of records you want... **EDIT** Have you profiled your code ...
558,721
<p>Is it possible, other than what I'm doing because it doesn't seem to work, to do this? I want to be able to have subclasses that are under a class to use the CSS specifically for that class.subclass.</p> <p>CSS</p> <pre><code>.area1 { border:1px solid black; } .area1.item { color:red; } .area2 { border...
[ { "answer_id": 558730, "author": "Chad Birch", "author_id": 41665, "author_profile": "https://Stackoverflow.com/users/41665", "pm_score": 9, "selected": true, "text": "<p>Just need to add a space:</p>\n\n<pre><code>.area2 .item\n{\n ...\n}\n</code></pre>\n" }, { "answer_id": 5...
2009/02/17
[ "https://Stackoverflow.com/questions/558721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27908/" ]
Is it possible, other than what I'm doing because it doesn't seem to work, to do this? I want to be able to have subclasses that are under a class to use the CSS specifically for that class.subclass. CSS ``` .area1 { border:1px solid black; } .area1.item { color:red; } .area2 { border:1px solid blue; } .a...
Just need to add a space: ``` .area2 .item { ... } ```
558,729
<p>I was just interviewed with a question, and I'm curious what the answer ought to be. The problem was, essentially:</p> <p>Say you have an unsorted list of n integers. How do you find the k minimum values in this list? That is, if you have a list of [10, 11, 24, 12, 13] and are looking for the 2 minimum values, you'...
[ { "answer_id": 558752, "author": "dsimcha", "author_id": 23903, "author_profile": "https://Stackoverflow.com/users/23903", "pm_score": 4, "selected": true, "text": "<p>This is the <a href=\"http://en.wikipedia.org/wiki/Quick_select\" rel=\"nofollow noreferrer\">quickSelect</a> algorithm....
2009/02/17
[ "https://Stackoverflow.com/questions/558729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67558/" ]
I was just interviewed with a question, and I'm curious what the answer ought to be. The problem was, essentially: Say you have an unsorted list of n integers. How do you find the k minimum values in this list? That is, if you have a list of [10, 11, 24, 12, 13] and are looking for the 2 minimum values, you'd get [10,...
This is the [quickSelect](http://en.wikipedia.org/wiki/Quick_select) algorithm. It's basically a quick sort where you only recurse for one part of the array. Here's a simple implementation in Python, written for brevity and readability rather than efficiency. ``` def quickSelect(data, nLeast) : pivot = data[-1] ...
558,755
<p>I have the following groovy code :</p> <pre><code> class FileWalker { private String dir public static void onEachFile(String dir,IAction ia) { new File(dir).eachFileRecurse { ia.perform(it) } } } walker = new FileWalker() walker.onEachFile(args[0],new PrintAction()) </code...
[ { "answer_id": 559198, "author": "chanwit", "author_id": 60903, "author_profile": "https://Stackoverflow.com/users/60903", "pm_score": 0, "selected": false, "text": "<p>In scripting mode (or via \"groovyConsole\"), you need a declaration of walker with \"def\" before using it. A Groovy s...
2009/02/17
[ "https://Stackoverflow.com/questions/558755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I have the following groovy code : ``` class FileWalker { private String dir public static void onEachFile(String dir,IAction ia) { new File(dir).eachFileRecurse { ia.perform(it) } } } walker = new FileWalker() walker.onEachFile(args[0],new PrintAction()) ``` I noticed that...
You don't need a def in groovyConsole or in a groovy script. I consider it good programming practice to have it, but the language will work without it and add those types of variables to the scripts binding. I'm not sure about the rest of your code (as it won't compile as you've posted it). But you either have a reall...
558,756
<p>In functional languages there is often a <code>Maybe</code> monad which allows you to chain multiple calls on an object and have the entire expression return <code>None</code>/<code>null</code> if any part of the chain evaluates to nothing, rather than the typical <code>NullReferenceException</code> you'd get in C# ...
[ { "answer_id": 558792, "author": "Brian", "author_id": 18192, "author_profile": "https://Stackoverflow.com/users/18192", "pm_score": 1, "selected": false, "text": "<p>Chaining multiple calls on an object makes me fear violations of the <a href=\"http://en.wikipedia.org/wiki/Law_of_Demete...
2009/02/17
[ "https://Stackoverflow.com/questions/558756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13552/" ]
In functional languages there is often a `Maybe` monad which allows you to chain multiple calls on an object and have the entire expression return `None`/`null` if any part of the chain evaluates to nothing, rather than the typical `NullReferenceException` you'd get in C# by chaining calls where one object could be nul...
Chaining multiple calls on an object makes me fear violations of the [Law of Demeter](http://en.wikipedia.org/wiki/Law_of_Demeter). Thus, I am skeptical that this feature is a good idea, at least in terms of solving the specific problem you are using as an example.
558,776
<p>Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows?</p>
[ { "answer_id": 558804, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<p>The command-prompt started script has a parent process named <code>cmd.exe</code> (or a non-existent process, in case t...
2009/02/17
[ "https://Stackoverflow.com/questions/558776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4166/" ]
Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows?
Here is an example of how to obtain the parent process id and name of the current running script. As suggested by [Tomalak](https://stackoverflow.com/users/18771/tomalak) this can be used to detect if the script was started from the command prompt or by double clicking in explorer. ``` import win32pdh import os def g...
558,847
<p>I have a problem with an SQL database I'm creating. I'm trying to switch it over to use INNODB but I can't seem to get the syntax (or possibly logic) correct for cascading.</p> <p>Here's a <a href="http://pastebin.com/m7216314f" rel="nofollow noreferrer">part of the code erroring</a>. It does not like line 40.</p...
[ { "answer_id": 558859, "author": "notnot", "author_id": 65184, "author_profile": "https://Stackoverflow.com/users/65184", "pm_score": 2, "selected": false, "text": "<p>If <a href=\"http://www.databasejournal.com/features/mysql/article.php/1578331/Using-Fulltext-Indexes-in-MySQL---Part-1....
2009/02/17
[ "https://Stackoverflow.com/questions/558847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52116/" ]
I have a problem with an SQL database I'm creating. I'm trying to switch it over to use INNODB but I can't seem to get the syntax (or possibly logic) correct for cascading. Here's a [part of the code erroring](http://pastebin.com/m7216314f). It does not like line 40. Error output in the usual cryptic (to me at least)...
From [dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html](http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html) > > The default minimum value is four > characters; the default maximum is > version dependent. If you change > either value, you must rebuild your > FULLTEXT indexes. > > > The min...
558,853
<p>I have an object, a Timeline, that encapsulates a thread. Events can be scheduled on the timeline; the thread will wait until it is time to execute any event, execute it, and go back to sleep (for either (a) the time it takes to get to the next event or (b) indefinitely if there are no more events).</p> <p>The slee...
[ { "answer_id": 558874, "author": "Jeff Kotula", "author_id": 1382162, "author_profile": "https://Stackoverflow.com/users/1382162", "pm_score": 3, "selected": true, "text": "<p>I don't think it is unreasonable to require clients to Stop() the thread for shutdown at all. There are ways you...
2009/02/17
[ "https://Stackoverflow.com/questions/558853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2474/" ]
I have an object, a Timeline, that encapsulates a thread. Events can be scheduled on the timeline; the thread will wait until it is time to execute any event, execute it, and go back to sleep (for either (a) the time it takes to get to the next event or (b) indefinitely if there are no more events). The sleeping is ha...
I don't think it is unreasonable to require clients to Stop() the thread for shutdown at all. There are ways you can create threads whose continued execution will not stop the application from exiting (although I don't have the details off the top of my head). But expecting to launch and terminate a worker thread is no...
558,858
<p>I've got a search screen on which the user can specify any combination of first name, last name, semester, or course. I'm not sure how to optimally code the SQL Server 2005 stored procedure to handle these potentially optional parameters. What's the most efficient way? Separate procedures for each combination? Takin...
[ { "answer_id": 558872, "author": "markom", "author_id": 1269, "author_profile": "https://Stackoverflow.com/users/1269", "pm_score": 0, "selected": false, "text": "<p>I would do it with <strong>sp_executesql</strong> because the plan will be cached just for the first pattern, or the first...
2009/02/17
[ "https://Stackoverflow.com/questions/558858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/335036/" ]
I've got a search screen on which the user can specify any combination of first name, last name, semester, or course. I'm not sure how to optimally code the SQL Server 2005 stored procedure to handle these potentially optional parameters. What's the most efficient way? Separate procedures for each combination? Taking t...
The best solution is to utilize sp\_execute\_sql. For example: ``` --BEGIN SQL declare @sql nvarchar(4000) set @sql = 'select * from weblogs.dbo.vwlogs where Log_time between @BeginDate and @EndDate' + case when @UserName is null then '' else 'and client_user = @UserName' end sp_execute_sql @sql , @params = '@User...
558,860
<p>Suppose I have a function attached to one of my Excel sheets:</p> <pre><code>Public Function foo(bar As Integer) as integer foo = 42 End Function </code></pre> <p>How can I get the results of <code>foo</code> returned to a cell on my sheet? I've tried <code>"=foo(10)"</code>, but all it gives me is <code>"#NAM...
[ { "answer_id": 558873, "author": "chilltemp", "author_id": 28736, "author_profile": "https://Stackoverflow.com/users/28736", "pm_score": -1, "selected": false, "text": "<p>include the file name like this</p>\n\n<pre><code>=PERSONAL.XLS!foo(10)\n</code></pre>\n" }, { "answer_id": ...
2009/02/17
[ "https://Stackoverflow.com/questions/558860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/685/" ]
Suppose I have a function attached to one of my Excel sheets: ``` Public Function foo(bar As Integer) as integer foo = 42 End Function ``` How can I get the results of `foo` returned to a cell on my sheet? I've tried `"=foo(10)"`, but all it gives me is `"#NAME?"` I've also tried `=[filename]!foo(10) and [sheet...
Try following the directions [here](http://web.archive.org/web/20090220142331/http://exceltip.com/st/Writing_Your_First_VBA_Function_in_Excel/631.html) to make sure you're doing everything correctly, specifically about where to put it. ( `Insert->Module` ) I can confirm that opening up the VBA editor, using `Insert->M...
558,864
<p>I have a bunch of simple lookup tables cached in my asp.net application since the source data is on a seperate server from our main web architecture and it changes infrequently. I've been following answers here and various documentation and I have my initial load function call the following:</p> <pre><code>HttpCont...
[ { "answer_id": 558895, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 0, "selected": false, "text": "<p>My initial thought is that GetAllCheckLocations is throwing the exception or returning null.</p>\n" }, { "answer...
2009/02/17
[ "https://Stackoverflow.com/questions/558864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
I have a bunch of simple lookup tables cached in my asp.net application since the source data is on a seperate server from our main web architecture and it changes infrequently. I've been following answers here and various documentation and I have my initial load function call the following: ``` HttpContext.Current.Ca...
Does it still exception out when you don't give it a callback function? Seems more like the delegated function is having issues with null objects.
558,870
<pre><code>&lt;Document&gt; &lt;A&gt; &lt;B&gt; &lt;C&gt;&lt;/C&gt; &lt;/B&gt; &lt;/A&gt; &lt;E&gt; &lt;F&gt; &lt;C&gt;&lt;/C&gt; &lt;/F&gt; &lt;G&gt; &lt;C&gt;&lt;/C&gt; &lt;/G&gt; &lt;/E&gt; &lt;/Document&gt; </code></pre> <p>If i load the above XML into an XmlDocument and d...
[ { "answer_id": 558892, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<p>Simply: a leading // means \"at any level\" in the same <em>document</em> as the selected node.</p>\n\n<p>From the ...
2009/02/17
[ "https://Stackoverflow.com/questions/558870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21299/" ]
``` <Document> <A> <B> <C></C> </B> </A> <E> <F> <C></C> </F> <G> <C></C> </G> </E> </Document> ``` If i load the above XML into an XmlDocument and do a SelectSingleNode on A using the XPath query //C ``` XmlNode oNode = oDocument.SelectSingleNode("E"); XmlNodeList oNodeLis...
Simply: a leading // means "at any level" in the same *document* as the selected node. From the [spec](http://www.w3.org/TR/xpath): * //para selects all the para descendants of the document root and thus selects all para elements in the same document as the context node * .//para selects the para element descendants ...
558,885
<p>I want any request to <a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a>* to be redirected to <a href="http://www.example.com/" rel="nofollow noreferrer">http://www.example.com/</a>*.</p> <p>Where * is any arbitrary path.</p>
[ { "answer_id": 558887, "author": "nutcracker", "author_id": 19588, "author_profile": "https://Stackoverflow.com/users/19588", "pm_score": 3, "selected": true, "text": "<p>Use Apache's <a href=\"http://httpd.apache.org/docs/1.3/mod/mod_alias.html\" rel=\"nofollow noreferrer\">mod_alias</a...
2009/02/17
[ "https://Stackoverflow.com/questions/558885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19588/" ]
I want any request to <http://example.com/>\* to be redirected to <http://www.example.com/>\*. Where \* is any arbitrary path.
Use Apache's [mod\_alias](http://httpd.apache.org/docs/1.3/mod/mod_alias.html) module to do a permanent redirect like: ``` RedirectPermanent / "http://www.example.com/" ``` Place the redirect inside the blank subdomain's virtualhost block or root level `.htaccess` file. The trailing / on "<http://www.example.com/>"...
558,914
<p>I'd love some other opinions on what's more efficient in this code. Basically in the following code, there's a setInterval loop and I need 4 requirements to be true before the code runs in the loop. So in v.1 I wrote an if statement checking all 4. Worked fine.</p> <p>Then I switched to just using try/catch, with t...
[ { "answer_id": 558940, "author": "cdmckay", "author_id": 62571, "author_profile": "https://Stackoverflow.com/users/62571", "pm_score": 4, "selected": false, "text": "<p>Exceptions should be used for exceptional circumstances (i.e. things that you don't expect to happen normally). You sh...
2009/02/17
[ "https://Stackoverflow.com/questions/558914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
I'd love some other opinions on what's more efficient in this code. Basically in the following code, there's a setInterval loop and I need 4 requirements to be true before the code runs in the loop. So in v.1 I wrote an if statement checking all 4. Worked fine. Then I switched to just using try/catch, with the code I ...
Use the if statement. I don't know what the overhead is for a TRY/CATCH, but I suspect it's far greater than evaluating a boolean expression. To hit the TRY/CATCH you will have to: execute a statement, generate an error [with that associated overhead], log the error (presumably), made a stacktrace(presumably), and move...
558,916
<p>When i initialize an object using the new object initializers in C# I cannot use one of the properties within the class to perform a further action and I do not know why.</p> <p>My example code:</p> <pre><code>Person person = new Person { Name = "David", Age = "29" }; </code></pre> <p>Within the Person Class, x w...
[ { "answer_id": 558929, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 5, "selected": true, "text": "<p>The properties get set for Name and Age after the constructor 'public Person()' has finished running.</p>\n\n<pre>...
2009/02/17
[ "https://Stackoverflow.com/questions/558916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66005/" ]
When i initialize an object using the new object initializers in C# I cannot use one of the properties within the class to perform a further action and I do not know why. My example code: ``` Person person = new Person { Name = "David", Age = "29" }; ``` Within the Person Class, x will equal 0 (default): ``` publi...
The properties get set for Name and Age after the constructor 'public Person()' has finished running. ``` Person person = new Person { Name = "David", Age = "29" }; ``` is equivalent to ``` Person tempPerson = new Person() tempPerson.Name = "David"; tempPerson.Age = "29"; Person person = tempPerson; ``` So, in th...
558,920
<p>I'm creating a windows service and after installing the service, it stops and starts immediately, but it shouldn't be at all. Previously, I was getting errors that the service was not responding to the start command in a timely fashion, so I took the init code out and put it in a thread, and now I am here:</p> <pre...
[ { "answer_id": 558939, "author": "Alex Reitbort", "author_id": 11525, "author_profile": "https://Stackoverflow.com/users/11525", "pm_score": 2, "selected": false, "text": "<p>It might be stopped unexpectedly if your main thread terminates on exception.</p>\n" }, { "answer_id": 55...
2009/02/17
[ "https://Stackoverflow.com/questions/558920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48553/" ]
I'm creating a windows service and after installing the service, it stops and starts immediately, but it shouldn't be at all. Previously, I was getting errors that the service was not responding to the start command in a timely fashion, so I took the init code out and put it in a thread, and now I am here: ``` protect...
The problem turned out top be that the EventLog.WriteEntry was throwing an error because there was no EventSource associated with it. see <http://msdn.microsoft.com/en-us/library/xzwc042w.aspx>
558,926
<p>So far, I've had great success using PyAMF to communicate between my Flex front-end and my Django back-end. However, I believe I've encountered a bug. The following example (emphasis on the word "example") demonstrates the (potential) bug:</p> <p>My Flex app contains the following VO:</p> <pre><code>package mypr...
[ { "answer_id": 560919, "author": "thgie", "author_id": 56725, "author_profile": "https://Stackoverflow.com/users/56725", "pm_score": -1, "selected": false, "text": "<p>Not at all.</p>\n\n<p>Do you think the error is from Django or from Flex? You could first of all trace the AMF Object in...
2009/02/17
[ "https://Stackoverflow.com/questions/558926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
So far, I've had great success using PyAMF to communicate between my Flex front-end and my Django back-end. However, I believe I've encountered a bug. The following example (emphasis on the word "example") demonstrates the (potential) bug: My Flex app contains the following VO: ``` package myproject.model.vo { [B...
I just received the following response from PyAMF's lead developer. It's definitely a bug: > > This is a bug in the way the Django > adapter handles non models.fields.\* > properties. > > > If I do: > > > ``` import pyamf class Book(object): def _get_number_of_odd_pages(self): return 52 numberOfOddPag...
558,942
<p>I have a couple floats that are kinda big. They're around a 100 million.</p> <p>I would like this number to show like the following 123,456,789.01234</p> <p>I've found that I can use CONVERT if its a money datatype but this doesn't do the full trick (it leaves off some decimal places).</p> <p>I have to have comma...
[ { "answer_id": 559049, "author": "SWD", "author_id": 3034, "author_profile": "https://Stackoverflow.com/users/3034", "pm_score": 0, "selected": false, "text": "<p>if you are just displaying this as text you can do the following:</p>\n\n<p>oracle : </p>\n\n<pre><code>select to_char(12345...
2009/02/17
[ "https://Stackoverflow.com/questions/558942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
I have a couple floats that are kinda big. They're around a 100 million. I would like this number to show like the following 123,456,789.01234 I've found that I can use CONVERT if its a money datatype but this doesn't do the full trick (it leaves off some decimal places). I have to have commas on the left and five d...
``` DECLARE @f FLOAT SET @f = 123456789.01234 SELECT LEFT('$' + CONVERT(VARCHAR(20), CAST(@f AS MONEY), 1), LEN(@f) - 2) ``` this will cut it up to two places of decimal for formatting. You can change LEN(@f) - 2 to modify this setting.
558,954
<p>I can't seem to figure out why this does not work below. I need to bind the text box to a value from an inline expression. Seems like a simple thing right? But neither of these work. Any ideas? Thanks in advance.</p> <pre><code>&lt;asp:textbox id="tbName" runat="server" Text='&lt;%# Eval("test") %&gt;' /&gt; &lt;as...
[ { "answer_id": 558964, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;asp:textbox id=\"tbName\" runat=\"server\"&gt;&lt;%=\"test\"%&gt;&lt;/asp:textbox&gt;\n</code></pre>\n"...
2009/02/17
[ "https://Stackoverflow.com/questions/558954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56753/" ]
I can't seem to figure out why this does not work below. I need to bind the text box to a value from an inline expression. Seems like a simple thing right? But neither of these work. Any ideas? Thanks in advance. ``` <asp:textbox id="tbName" runat="server" Text='<%# Eval("test") %>' /> <asp:textbox id="tbName" runat="...
In the Page\_Load of you will have to make a call to Page.DataBind() for ``` <asp:textbox id="tbName" runat="server" Text='<%# Eval("test") %>' /> ``` to work. <%= %> is a shortened response.Write() and is never valid as an attribute, for any server tag. <%# %> can be used, only if the conatainer is databound (th...
558,974
<p>Lets say you are working in SQL 2005 with a copy of Northwind database installed. Your working on an ASP.NET application with an Employees "browse" page. At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown:</p> <blockquote> <p>[ALL]<br> Vice President, ...
[ { "answer_id": 559024, "author": "Alex Reitbort", "author_id": 11525, "author_profile": "https://Stackoverflow.com/users/11525", "pm_score": -1, "selected": false, "text": "<pre><code>criterion = ... // SELECT Title FROM Employees ORDER BY Title\ncriterion.SetResultTransformer(new NHibe...
2009/02/17
[ "https://Stackoverflow.com/questions/558974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
Lets say you are working in SQL 2005 with a copy of Northwind database installed. Your working on an ASP.NET application with an Employees "browse" page. At the top of the page you have a "Title" filter where you would like to display these 5 choices in a dropdown: > > [ALL] > > Vice President, Sales > > Sale...
See [nhibernate.info/doc/howto/various/get-unique-results-from-joined-queries.html](http://nhibernate.info/doc/howto/various/get-unique-results-from-joined-queries.html)
558,981
<p>I have an associative array in JavaScript:</p> <pre><code>var dictionary = { &quot;cats&quot;: [1,2,3,4,5], &quot;dogs&quot;: [6,7,8,9,10] }; </code></pre> <p>How do I get this dictionary's keys? I.e., I want</p> <pre><code>var keys = [&quot;cats&quot;, &quot;dogs&quot;]; </code></pre> <hr /> <p>Just to get ...
[ { "answer_id": 559002, "author": "JW.", "author_id": 4321, "author_profile": "https://Stackoverflow.com/users/4321", "pm_score": 9, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>var keys = [];\nfor (var key in dictionary) {\n if (dictionary.hasOwnProperty(key)) {\n keys....
2009/02/17
[ "https://Stackoverflow.com/questions/558981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have an associative array in JavaScript: ``` var dictionary = { "cats": [1,2,3,4,5], "dogs": [6,7,8,9,10] }; ``` How do I get this dictionary's keys? I.e., I want ``` var keys = ["cats", "dogs"]; ``` --- Just to get the terminology correct - there is no such thing as an 'associative array' in JavaScrip...
You can use: `Object.keys(obj)` Example: ```js var dictionary = { "cats": [1, 2, 37, 38, 40, 32, 33, 35, 39, 36], "dogs": [4, 5, 6, 3, 2] }; // Get the keys var keys = Object.keys(dictionary); console.log(keys); ``` See reference below for browser support. It is supported in Firefox 4.20, Chrome 5, and Interne...
558,996
<p>So I admit that I'm new to javascript and that I come from a C.+ background ("Hi, I'm Bob, I'm a class-based static language user", <em>chorus</em> "hi Bob!").</p> <p>I find that I often end up writing functions like:</p> <pre><code>function someFunc() { if (arguments.length === 0 ){ ... } else { ...
[ { "answer_id": 559022, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 2, "selected": false, "text": "<p>I don't know that I would do it this way, but it seems like it might make your code mildly less unmanageable:</p>\n\...
2009/02/17
[ "https://Stackoverflow.com/questions/558996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48202/" ]
So I admit that I'm new to javascript and that I come from a C.+ background ("Hi, I'm Bob, I'm a class-based static language user", *chorus* "hi Bob!"). I find that I often end up writing functions like: ``` function someFunc() { if (arguments.length === 0 ){ ... } else { ... } } ``` (wher...
Have a look at [this post](http://ejohn.org/blog/javascript-method-overloading/).
558,998
<p>I am trying to build a site with news links that can be voted, I have the following code:</p> <pre><code> case 'vote': require_once('auth/auth.php'); if(Auth::isUserLoggedIn()) { require_once('data/article.php'); require_once('i...
[ { "answer_id": 559020, "author": "Parrots", "author_id": 65763, "author_profile": "https://Stackoverflow.com/users/65763", "pm_score": 2, "selected": false, "text": "<p>Have a table that keeps track of a user's vote for an article (something like UserID,ArticleID,VoteTimeStamp). Then yo...
2009/02/17
[ "https://Stackoverflow.com/questions/558998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2170954/" ]
I am trying to build a site with news links that can be voted, I have the following code: ``` case 'vote': require_once('auth/auth.php'); if(Auth::isUserLoggedIn()) { require_once('data/article.php'); require_once('includes/helper...
make another table user\_votes for example with structure: user\_id int not null article\_id int not null primary key (user\_id, article\_id) in vote function first try to insert and if insert is successfull then increase $this->points
559,004
<p>I have a developer tool that modifies the local file system using php. These projects are often checked out from SVN. The issue that I would like to avoid is the moving / deleting / renaming of version controlled directoires - and the breakage that occurs to a checked out SVN when doing those alterations locally. ...
[ { "answer_id": 559054, "author": "omermuhammed", "author_id": 33121, "author_profile": "https://Stackoverflow.com/users/33121", "pm_score": 1, "selected": false, "text": "<p>Programmatically you may be better off just removing .svn folders. It probably is just one or two lines of code.</...
2009/02/17
[ "https://Stackoverflow.com/questions/559004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67599/" ]
I have a developer tool that modifies the local file system using php. These projects are often checked out from SVN. The issue that I would like to avoid is the moving / deleting / renaming of version controlled directoires - and the breakage that occurs to a checked out SVN when doing those alterations locally. Is ...
In your PHP file, you could use the `svn` commands via `exec()` ``` <?php $Output = ''; $ExitCode = 0; exec('svn mv "'.$Current.'" "'.$New.'"', $Output, $ExitCode); ``` `$Output` is the output of the command and `$ExitCode` will be `0` if the command was successful. Keep in mind however, that for security reasons t...
559,013
<p>We are planning to develop a Flex application that must make AMF calls to retrieve data from a secure server. However, we are not allowed to connect directly to that secure server with AMF. We can only make WSDL/SOAP or .net remoting calls to the secure server. Therefore, <strong>all instances of the flex applica...
[ { "answer_id": 559054, "author": "omermuhammed", "author_id": 33121, "author_profile": "https://Stackoverflow.com/users/33121", "pm_score": 1, "selected": false, "text": "<p>Programmatically you may be better off just removing .svn folders. It probably is just one or two lines of code.</...
2009/02/17
[ "https://Stackoverflow.com/questions/559013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5216/" ]
We are planning to develop a Flex application that must make AMF calls to retrieve data from a secure server. However, we are not allowed to connect directly to that secure server with AMF. We can only make WSDL/SOAP or .net remoting calls to the secure server. Therefore, **all instances of the flex application running...
In your PHP file, you could use the `svn` commands via `exec()` ``` <?php $Output = ''; $ExitCode = 0; exec('svn mv "'.$Current.'" "'.$New.'"', $Output, $ExitCode); ``` `$Output` is the output of the command and `$ExitCode` will be `0` if the command was successful. Keep in mind however, that for security reasons t...
559,061
<p>After programming in C for several years, I realized that I have been ignoring the C convention of returning zero from a function to indicate success. The convention seems semantically wrong to me, as zero is of course false. The problem is I like to name functions like <code>is_valid_foobar()</code>, and in orde...
[ { "answer_id": 559078, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 2, "selected": false, "text": "<p>I am not sure I agree that there is a convention of \"returning zero from a function to indicate success.\" </p>\n\n<p>AFAI...
2009/02/17
[ "https://Stackoverflow.com/questions/559061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10888/" ]
After programming in C for several years, I realized that I have been ignoring the C convention of returning zero from a function to indicate success. The convention seems semantically wrong to me, as zero is of course false. The problem is I like to name functions like `is_valid_foobar()`, and in order to accomodate t...
I'd say both are correct, for different purposes: If you're performing a simple go/no-go validation, e.g. is\_numeric(), then true and false work nicely. For something more elaborate, the 0==success paradigm is helpful in that it allows more than one error condition to be returned. In this case, the caller can simpl...
559,063
<p>I've attempted to create an abstracted control to manage some of the state in our application. However, I have run a foul of some CLS issues and was hoping that someone could provide some insight.</p> <p>I have an enumeration as such:</p> <pre><code>&lt;Flags()&gt; _ Public Enum FormState Read = 1 Edit = 2...
[ { "answer_id": 559135, "author": "Gavin Miller", "author_id": 33226, "author_profile": "https://Stackoverflow.com/users/33226", "pm_score": 1, "selected": false, "text": "<p>To remove the warnings add the following attributes so that the class, method and property look like this:</p>\n\n...
2009/02/17
[ "https://Stackoverflow.com/questions/559063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33226/" ]
I've attempted to create an abstracted control to manage some of the state in our application. However, I have run a foul of some CLS issues and was hoping that someone could provide some insight. I have an enumeration as such: ``` <Flags()> _ Public Enum FormState Read = 1 Edit = 2 Insert = 4 End Enum `...
Looking at your code, the enum seems to be part of a class called enumerators. The class is not listed in your code, but I'm assuming that you have full control over it. The class needs to be tagged with the CLS compliant attribute as well.
559,071
<p>I started using the jquery ui library to add some enhanced UI elements to the asp.net app. and have run into a minor bug/problem:</p> <p>I have a jquery UI dialog that is called when a button is clicked..the text for the dialog is all in a and is normaly hidden from the user, and then the jquery UI does its magic ...
[ { "answer_id": 559085, "author": "RSolberg", "author_id": 55747, "author_profile": "https://Stackoverflow.com/users/55747", "pm_score": 1, "selected": false, "text": "<p>Set the height on the control to zero. This way it renders to the screen at 0 height? This is somewhat of a guess by...
2009/02/17
[ "https://Stackoverflow.com/questions/559071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53686/" ]
I started using the jquery ui library to add some enhanced UI elements to the asp.net app. and have run into a minor bug/problem: I have a jquery UI dialog that is called when a button is clicked..the text for the dialog is all in a and is normaly hidden from the user, and then the jquery UI does its magic and uses th...
I set the style on the div to "display: none". The dialog changes this when it displays. ``` <div id="myCancelEventDialog" title="Cancel an Event or Meeting" style="display: none;"> <p>Are you sure you would like to cancel this event/meeting?</p> </div> ```
559,079
<p>I'm trying to use cURL with PHP and its giving me this error:</p> <p><em>"Failed to connect to 208.77.188.166: Operation not permitted"</em></p> <p>I'm pretty sure its a server issue - but just in case, here is my code: </p> <pre><code>&lt;?php $ch = curl_init(); $url ="http://www.example.com"; curl_setopt($ch,...
[ { "answer_id": 559125, "author": "Astra", "author_id": 5862, "author_profile": "https://Stackoverflow.com/users/5862", "pm_score": 0, "selected": false, "text": "<p>You should try using a version of curl installed on the server or on your workstation (command line version) and try to rep...
2009/02/17
[ "https://Stackoverflow.com/questions/559079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16924/" ]
I'm trying to use cURL with PHP and its giving me this error: *"Failed to connect to 208.77.188.166: Operation not permitted"* I'm pretty sure its a server issue - but just in case, here is my code: ``` <?php $ch = curl_init(); $url ="http://www.example.com"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, ...
It's possible that you need to enable `allow_url_fopen` ([reference](http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen)) -- you can do this in an .htaccess file if it's on apache. You can enable this by putting this in an .htaccess file: ``` php allow_url_fopen on ```
559,084
<p>I am currently working on a small project, where I need to send a potentially large file over the internet.</p> <p>After some debating I decided to go with the streaming option instead of a chunking approach. The files can potentially be very big, I don't really want to specify an exact upper bound, 2GB maybe 4GB, ...
[ { "answer_id": 559205, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>Well, a more natural approach might be to send the file in a sequence in mid-size chunks, with a final message to ...
2009/02/17
[ "https://Stackoverflow.com/questions/559084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5798/" ]
I am currently working on a small project, where I need to send a potentially large file over the internet. After some debating I decided to go with the streaming option instead of a chunking approach. The files can potentially be very big, I don't really want to specify an exact upper bound, 2GB maybe 4GB, who knows....
Well, a more natural approach might be to send the file in a sequence in mid-size chunks, with a final message to commit; this also makes it possible to resume from error. There is perhaps a slight DOS issue with fully open numbers...
559,096
<p><strong>I get a File via a HTTP-Upload and need to be sure its a pdf-file.</strong> Programing Language is Python, but this should not matter.</p> <p>I thought of the following solutions:</p> <ol> <li><p>Check if the first bytes of the string are &quot;%PDF&quot;. <em>This is not a good check but prevents the use fr...
[ { "answer_id": 559116, "author": "Cal Jacobson", "author_id": 62649, "author_profile": "https://Stackoverflow.com/users/62649", "pm_score": 2, "selected": false, "text": "<p>If you're on a Linux or OS X box, you could use <a href=\"http://en.wikipedia.org/wiki/Pdftotext\" rel=\"nofollow ...
2009/02/17
[ "https://Stackoverflow.com/questions/559096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61855/" ]
**I get a File via a HTTP-Upload and need to be sure its a pdf-file.** Programing Language is Python, but this should not matter. I thought of the following solutions: 1. Check if the first bytes of the string are "%PDF". *This is not a good check but prevents the use from uploading other files accidentally.* 2. Try ...
The two most commonly used PDF libraries for Python are: * [pyPdf](http://pybrary.net/pyPdf/) * [ReportLab](http://www.reportlab.org/downloads.html) Both are pure python so should be easy to install as well be cross-platform. With pyPdf it would probably be as simple as doing: ``` from pyPdf import PdfFileReader do...
559,112
<p>I have a text box that will have a <em>currency</em> string in it that I then need to convert that string to a double to perform some operations on it. </p> <p><code>"$1,100.00"</code> → <code>1100.00</code></p> <p>This needs to occur all client side. I have no choice but to leave the <em>currency</em> string as a...
[ { "answer_id": 559140, "author": "IEnumerator", "author_id": 34819, "author_profile": "https://Stackoverflow.com/users/34819", "pm_score": 2, "selected": false, "text": "<p>I know you've found a solution to your question, I just wanted to recommend that maybe you look at the following mo...
2009/02/17
[ "https://Stackoverflow.com/questions/559112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35585/" ]
I have a text box that will have a *currency* string in it that I then need to convert that string to a double to perform some operations on it. `"$1,100.00"` → `1100.00` This needs to occur all client side. I have no choice but to leave the *currency* string as a *currency* string as input but need to cast/convert ...
Remove all non dot / digits: ``` var currency = "-$4,400.50"; var number = Number(currency.replace(/[^0-9.-]+/g,"")); ```
559,134
<p>By Upper tens of thousands requests/second I want to see 60,000 -> +90,000 requests/second.</p> <p>My Setup consists of the following:</p> <p>user ---> web app --> message queue --> parser --> database?</p> <p>I should mention that the parser currently can parse/stuff around 18750 records/second using COPY so we ...
[ { "answer_id": 559151, "author": "ojrac", "author_id": 20760, "author_profile": "https://Stackoverflow.com/users/20760", "pm_score": 3, "selected": false, "text": "<p>For crazy-big scalability, you'll want to focus on two things:</p>\n\n<ul>\n<li>Sharding: Split your data set into groups...
2009/02/17
[ "https://Stackoverflow.com/questions/559134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39110/" ]
By Upper tens of thousands requests/second I want to see 60,000 -> +90,000 requests/second. My Setup consists of the following: user ---> web app --> message queue --> parser --> database? I should mention that the parser currently can parse/stuff around 18750 records/second using COPY so we are limited on that end ...
For crazy-big scalability, you'll want to focus on two things: * Sharding: Split your data set into groups that don't overlap. Have an easy, fast way to map from a request to a server. (Player starting with a-f, server 1; g-q, server 2... etc...) * Caching: Use Memcache to remember the output of some really common sel...
559,147
<p>What happens in jQuery when you <code>remove()</code> an element and <code>append()</code> it elsewhere?</p> <p>It appears that the events are unhooked - as if you were just inserting fresh html (which I guess is what happening). But its also possible my code has a bug in it - so I just wanted to verify this behavio...
[ { "answer_id": 559160, "author": "Scott Evernden", "author_id": 11397, "author_profile": "https://Stackoverflow.com/users/11397", "pm_score": 0, "selected": false, "text": "<p>use jQuery1.3.1 live() to bind events and you won't need to worry about this..</p>\n\n<p>Update: live events are...
2009/02/17
[ "https://Stackoverflow.com/questions/559147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
What happens in jQuery when you `remove()` an element and `append()` it elsewhere? It appears that the events are unhooked - as if you were just inserting fresh html (which I guess is what happening). But its also possible my code has a bug in it - so I just wanted to verify this behavior before I continue. If this i...
Yes, jQuery's approach with `remove()` is to unbind everything bound with jQuery's own `bind` (to prevent memory leaks). However, if you just want to move something in the DOM, you don't have to `remove()` it first. Just `append` to your heart's content, the event bindings *will* stick around :) For example, paste th...
559,150
<p>I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded. Most of the time this is done using the <code>window.onload</code> function.</p> <p><strong>My question is:</strong> </p> <ol> <li>Is this the best wa...
[ { "answer_id": 559161, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 7, "selected": true, "text": "<p><code>window.onload = function(){};</code> works, but as you might have noticed, <strong>it allows you to specify o...
2009/02/17
[ "https://Stackoverflow.com/questions/559150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66572/" ]
I develop Joomla websites/components/modules and plugins and every so often I require the ability to use JavaScript that triggers an event when the page is loaded. Most of the time this is done using the `window.onload` function. **My question is:** 1. Is this the best way to trigger JavaScript events on the page lo...
`window.onload = function(){};` works, but as you might have noticed, **it allows you to specify only 1 listener**. I'd say the better/newer way of doing this would be to use a framework, or to just to use a simple implementation of the native `addEventListener` and `attachEvent` (for IE) methods, which allows you to ...
559,155
<p>I'm developing an app with a Flex-based front end and a Spring/Hibernate back-end.</p> <p>To get Facebook integration working in the way I've got it currently, I need to read the cookies set in javascript on the front end on the back-end and do some validation during login to see whether the user is attempting to s...
[ { "answer_id": 559233, "author": "Jason Maskell", "author_id": 53813, "author_profile": "https://Stackoverflow.com/users/53813", "pm_score": 4, "selected": false, "text": "<p>This is kind of Flex/BlazeDS specific, but here's the solution I've come up with. Sorry if answering my own quest...
2009/02/17
[ "https://Stackoverflow.com/questions/559155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53813/" ]
I'm developing an app with a Flex-based front end and a Spring/Hibernate back-end. To get Facebook integration working in the way I've got it currently, I need to read the cookies set in javascript on the front end on the back-end and do some validation during login to see whether the user is attempting to spoof his F...
If FlexContext is not available: Solution 1: inside method (>= Spring 2.0 required) ``` HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()) .getRequest(); ``` Solution 2: inside bean (supported by >= 2.5, Spring 3.0 for singelton beans requir...
559,157
<p>I work in a mixed source control environment. We are still mostly on CVS, but newer projects are in SVN. However, I am finding it hard to get buy-in for SVN because TortoiseSVN doesn't work like TortoiseCVS. </p> <p>The 3 way merge has a lot of cognitive dissonance and while TortoiseCVS seems to always get the m...
[ { "answer_id": 559182, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 3, "selected": true, "text": "<p>Take a look at <a href=\"http://www.scootersoftware.com/\" rel=\"nofollow noreferrer\">BeyondCompare</a> and <a hr...
2009/02/17
[ "https://Stackoverflow.com/questions/559157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
I work in a mixed source control environment. We are still mostly on CVS, but newer projects are in SVN. However, I am finding it hard to get buy-in for SVN because TortoiseSVN doesn't work like TortoiseCVS. The 3 way merge has a lot of cognitive dissonance and while TortoiseCVS seems to always get the merges right, ...
Take a look at [BeyondCompare](http://www.scootersoftware.com/) and [Araxis Merge](http://www.araxis.com/merge/). They offer instructions on integrating them into TortoiseSVN as custom merge/diff tools.
559,174
<p>I am trying to display a 'Software Release' table in an asp.net dynamic data site. The Release table has a build number stored as three int fields (Major, Minor, Build). I'm using EntityFramework, so I have an EF model bound to my database schema. In my dynamic data site, I want the build number to show up as a si...
[ { "answer_id": 559760, "author": "HardCode", "author_id": 62477, "author_profile": "https://Stackoverflow.com/users/62477", "pm_score": 3, "selected": true, "text": "<p>I'm not sure if you are binding to a DataTable/DataSet returned from the database, or if you are binding to a Release o...
2009/02/17
[ "https://Stackoverflow.com/questions/559174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54847/" ]
I am trying to display a 'Software Release' table in an asp.net dynamic data site. The Release table has a build number stored as three int fields (Major, Minor, Build). I'm using EntityFramework, so I have an EF model bound to my database schema. In my dynamic data site, I want the build number to show up as a single ...
I'm not sure if you are binding to a DataTable/DataSet returned from the database, or if you are binding to a Release object itself. Nor which kind of control. If you are binding to a DataSet/DataTable, simply change your SQL to return the version as one field: ``` SELECT table1.Major + '.' + table1.Minor + '.' + tab...
559,179
<p>i am trying to compile my program which uses regex on linux. I built the boost library in the libs/regex/build by typing make -fgcc.mak which created a directory gcc which contains the following four files</p> <pre><code>boost_regex-gcc-1_35 boost_regex-gcc-d-1_35 libboost_regex-gcc-1_35.a libboost_regex-gc...
[ { "answer_id": 559191, "author": "greyfade", "author_id": 33345, "author_profile": "https://Stackoverflow.com/users/33345", "pm_score": 4, "selected": true, "text": "<p>Either add <code>libboost_regex-gcc-1_35.a</code> to your list of object files in your link step or add <code>-static -...
2009/02/17
[ "https://Stackoverflow.com/questions/559179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i am trying to compile my program which uses regex on linux. I built the boost library in the libs/regex/build by typing make -fgcc.mak which created a directory gcc which contains the following four files ``` boost_regex-gcc-1_35 boost_regex-gcc-d-1_35 libboost_regex-gcc-1_35.a libboost_regex-gcc-d-1_35.a ``` Now...
Either add `libboost_regex-gcc-1_35.a` to your list of object files in your link step or add `-static -lboost_regex-gcc-1_35` to the same. Also be sure that you have an `-I` switch pointing to your boost includes directory in your compile step. If the libraries are outside the typical search path (`/usr/lib` on \*nix),...
559,186
<p>The actually URL which my app uses is:</p> <pre><code>http://site.com/search.php?search=iPhone </code></pre> <p>but I would like it to be possible to achieve the same with </p> <pre><code>http://site.com/iPhone </code></pre> <p>I have no experience of rewrite rules, how can I set this up?</p> <p>The solution h...
[ { "answer_id": 559192, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "<p>You need to specify something like this in your .htaccess file:</p>\n\n<pre><code>RewriteEngine on\nRewriteR...
2009/02/17
[ "https://Stackoverflow.com/questions/559186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58068/" ]
The actually URL which my app uses is: ``` http://site.com/search.php?search=iPhone ``` but I would like it to be possible to achieve the same with ``` http://site.com/iPhone ``` I have no experience of rewrite rules, how can I set this up? The solution has worked but the new URL is displayed in the address ba...
Create a file called .htaccess in the root of your website and put this in it. ``` RewriteEngine on Options +FollowSymlinks RewriteBase / RewriteRule ^(.*) search.php?search=$1 [R] ``` Should do the trick. I would suggest however that you make it a bit more specific, so maybe require the user of a search directo...
559,189
<p>I'm just trying to do some simple validation in MVC RC and am getting an error. For the purposes of this question, I am <strong>not using the UpdateModel</strong>.</p> <p>Here is the code in the form:</p> <pre><code>&lt;%= Html.TextBox("UserId")%&gt; &lt;%= Html.ValidationMessage("UserId") %&gt; </code></pre> <p...
[ { "answer_id": 589320, "author": "Scott Hanselman", "author_id": 6380, "author_profile": "https://Stackoverflow.com/users/6380", "pm_score": 0, "selected": false, "text": "<p>You definitely don't need to call SetModelValue.</p>\n\n<p>Perhaps you just need your view to pull the Textbox fr...
2009/02/17
[ "https://Stackoverflow.com/questions/559189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47576/" ]
I'm just trying to do some simple validation in MVC RC and am getting an error. For the purposes of this question, I am **not using the UpdateModel**. Here is the code in the form: ``` <%= Html.TextBox("UserId")%> <%= Html.ValidationMessage("UserId") %> ``` If I add the following line in the controller, I will get ...
Call this extension method: ``` public static void AddModelError (this ModelStateDictionary modelState, string key, string errorMessage, string attemptedValue) { modelState.AddModelError (key, errorMessage); modelState.SetModelValue (key, new ValueProviderResult (attemptedValue, attemptedValue,...
559,204
<p>I want to take a .NET class (let's say FileInfo for the sake of discussion) and have it implement my interface. For example:</p> <pre><code>public interface IDeletable { void Delete(); } </code></pre> <p>Note that the FileInfo DOES have the Delete() method, so this interface could make sense.</p> <p>So that ...
[ { "answer_id": 559208, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 3, "selected": false, "text": "<p>Nope. You need the <a href=\"http://en.wikipedia.org/wiki/Wrapper_pattern\" rel=\"nofollow noreferrer\">Adapter ...
2009/02/17
[ "https://Stackoverflow.com/questions/559204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I want to take a .NET class (let's say FileInfo for the sake of discussion) and have it implement my interface. For example: ``` public interface IDeletable { void Delete(); } ``` Note that the FileInfo DOES have the Delete() method, so this interface could make sense. So that I can have code like this: ``` Fi...
Nope. You need the [Adapter pattern](http://en.wikipedia.org/wiki/Wrapper_pattern). This gives you a class that implements the interface you want, and "adapts" the framework class interface for you. This means your interface design doesn't even necessarily have to exactly match the framework class's interface. As Marc...
559,207
<p>I have created a fairly large Javascript app that works in Firefox and up until yesterday, IE. I've made quite a few changes and now I'm getting syntax errors in IE, but all is fine in Firefox. Obviously I have a trailing comma somewhere but I can't see it. IE's error message is less than helpful, not even telling m...
[ { "answer_id": 559230, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 1, "selected": false, "text": "<p>JS lint -> <a href=\"http://jslint.com/\" rel=\"nofollow noreferrer\">http://jslint.com/</a></p>\n" }, { "answer_...
2009/02/17
[ "https://Stackoverflow.com/questions/559207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1693/" ]
I have created a fairly large Javascript app that works in Firefox and up until yesterday, IE. I've made quite a few changes and now I'm getting syntax errors in IE, but all is fine in Firefox. Obviously I have a trailing comma somewhere but I can't see it. IE's error message is less than helpful, not even telling me w...
<http://www.jslint.com/> will catch those comma and semicolon problems. Example: ``` Error: Problem at line 1 character 17: Extra comma. var foo = ['bar',] Problem at line 1 character 19: Missing semicolon. var foo = ['bar',] ```
559,217
<p>I have a small program where I have been trying to create collections of a particular object I have created (Job).</p> <p>Regardless of whether I am using an array, collection or list, each time I add a new instance of the object to the array/collection/list, it overwrites all previous items with the same object.</...
[ { "answer_id": 559227, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>I suspect you are adding the same instance multiple times - i.e. (I'll use C# here...)</p>\n\n<pre><code>Job job = ...
2009/02/17
[ "https://Stackoverflow.com/questions/559217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67625/" ]
I have a small program where I have been trying to create collections of a particular object I have created (Job). Regardless of whether I am using an array, collection or list, each time I add a new instance of the object to the array/collection/list, it overwrites all previous items with the same object. For exampl...
I suspect you are adding the same instance multiple times - i.e. (I'll use C# here...) ``` Job job = new Job(); job.Name = "a"; list.Add(job); job.Name = "b"; list.Add(job); ``` What you have done is add 2 references to the same object to the list. What you should have done was: ``` Job job = new Job(); job.Name = ...
559,222
<p>I need to pass a variable that php is aware of to my javascript code and I'm wondering what the <em>correct</em> way to do this is.</p> <p>I already know that I could add this to the page generation:</p> <pre><code>&lt;script type="text/javascript"&gt; var someJSVariable = &lt;?php echo $somePHPVariable ?&gt; &lt;...
[ { "answer_id": 559248, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 1, "selected": false, "text": "<p>I love <a href=\"http://www.php.net/json_encode\" rel=\"nofollow noreferrer\"><code>json_encode()</code></a> for...
2009/02/17
[ "https://Stackoverflow.com/questions/559222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62084/" ]
I need to pass a variable that php is aware of to my javascript code and I'm wondering what the *correct* way to do this is. I already know that I could add this to the page generation: ``` <script type="text/javascript"> var someJSVariable = <?php echo $somePHPVariable ?> </script> ``` But I find this method to be...
If it's just 1 variable, I think this is the best solution. If you don't want to mix in JS into your normal view, make a separate view which will be rendered as .js file and then just include a link to that .js in your "real" view. If you need performance, some smart catching would be needed there. If there's more the...
559,240
<p>Take the example here:</p> <pre><code> public static IEnumerable&lt;BigInt&gt; EvenNumbers(IEnumerable&lt;BigInt&gt; numbers) { foreach (BigInt number in numbers) { if (number % 2 == 0) { yield return number; } } } </code></pre> <p>This w...
[ { "answer_id": 559245, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>\"return\" simply won't work here (since it would try to return a <code>BigInt</code>, and the method declares an <...
2009/02/17
[ "https://Stackoverflow.com/questions/559240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
Take the example here: ``` public static IEnumerable<BigInt> EvenNumbers(IEnumerable<BigInt> numbers) { foreach (BigInt number in numbers) { if (number % 2 == 0) { yield return number; } } } ``` This will return only the values which match...
"return" simply won't work here (since it would try to return a `BigInt`, and the method declares an `IEnumerable<BigInt>`. Jon Skeet has a good write-up of iterator blocks (what this is) in the **free** chapter 6 of [C# in Depth](http://www.manning.com/skeet/) (then buy the whole book - it really is worth it ;-p). --...
559,241
<p>I have an application that is locking on the GUI thread, and I've used WinDbg, along with the "!clrstack" command to get this stack trace, but I can't figure out where the issue is. All of these methods look like framework methods, and none are mine. Any help would be much appreciated. I apologize for the long lines...
[ { "answer_id": 559271, "author": "David", "author_id": 34208, "author_profile": "https://Stackoverflow.com/users/34208", "pm_score": 4, "selected": true, "text": "<p>It looks like this code isn't the true cause of the problem. See if one of these pages helps:</p>\n\n<ul>\n<li><a href=\"...
2009/02/17
[ "https://Stackoverflow.com/questions/559241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
I have an application that is locking on the GUI thread, and I've used WinDbg, along with the "!clrstack" command to get this stack trace, but I can't figure out where the issue is. All of these methods look like framework methods, and none are mine. Any help would be much appreciated. I apologize for the long lines `...
It looks like this code isn't the true cause of the problem. See if one of these pages helps: * [Mysterious Hang or The Great Deception of InvokeRequired](http://ikriv.com/en/prog/info/dotnet/MysteriousHang.html) * [OnUserPreferenceChanged Hang](http://krgreenlee.blogspot.com/2007/09/onuserpreferencechanged-hang.html)...
559,250
<p>I want to populate form fields with values from a database immediately after the user enters a value in the #sid field. Here is my jQuery/HTML example:</p> <pre><code>&lt;script src="jquery-1.3.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/JavaScript"&gt; $(document).ready(function() { $('#sid').bind("chang...
[ { "answer_id": 559264, "author": "Crescent Fresh", "author_id": 45433, "author_profile": "https://Stackoverflow.com/users/45433", "pm_score": 4, "selected": true, "text": "<p>Nice little injection attack waiting to happen there ;)</p>\n\n<p>Try changing</p>\n\n<pre><code>$.each(data.item...
2009/02/17
[ "https://Stackoverflow.com/questions/559250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59975/" ]
I want to populate form fields with values from a database immediately after the user enters a value in the #sid field. Here is my jQuery/HTML example: ``` <script src="jquery-1.3.1.min.js"></script> <script type="text/JavaScript"> $(document).ready(function() { $('#sid').bind("change", function(){ $.getJSON("te...
Nice little injection attack waiting to happen there ;) Try changing ``` $.each(data.items, ``` to: ``` $.each(data, ``` *Edit*: to answer your comment, I like to name my fields the same as the data key: ``` <input type="text" name="saffil" value="" /> <input type="text" name="sfirst" value="" /> var data = {s...
559,254
<p>I am new to regular expressions.</p> <p>Is it possible to match everything before a word that meets a certain criteria:</p> <p>E.g.</p> <p>THIS IS A TEST - - +++ This is a test</p> <p>I would like it to encounter a word that begins with an uppercase and the next character is lower case. This constitutes a proper...
[ { "answer_id": 559276, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 7, "selected": true, "text": "<p>Replace</p>\n\n<pre><code>^.*?(?=[A-Z][a-z])\n</code></pre>\n\n<p>with the empty string. This works for ASCII input. For...
2009/02/17
[ "https://Stackoverflow.com/questions/559254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39511/" ]
I am new to regular expressions. Is it possible to match everything before a word that meets a certain criteria: E.g. THIS IS A TEST - - +++ This is a test I would like it to encounter a word that begins with an uppercase and the next character is lower case. This constitutes a proper word. I would then like to del...
Replace ``` ^.*?(?=[A-Z][a-z]) ``` with the empty string. This works for ASCII input. For non-ASCII input (Unicode, other languages), different strategies apply. Explanation ``` .*? Everything, until (?= followed by [A-Z] one of A .. Z and [a-z] one of a .. z ) ``` The Java Unicode-enabled variant would ...
559,274
<p>Many times when I am watching others code I just want to find where and how a variable is defined. Normally what I do now is look for the type of the variable until I find the definition, that is very time consuming. And I guess that there are some tools that can help me in this rutinary situation. Any suggestion in...
[ { "answer_id": 559285, "author": "Diego Sevilla", "author_id": 62365, "author_profile": "https://Stackoverflow.com/users/62365", "pm_score": 4, "selected": true, "text": "<p><em>Edit</em>: OK, you say you're using C++. I'm editing my response. I would use the C preprocessor and then grep...
2009/02/17
[ "https://Stackoverflow.com/questions/559274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39160/" ]
Many times when I am watching others code I just want to find where and how a variable is defined. Normally what I do now is look for the type of the variable until I find the definition, that is very time consuming. And I guess that there are some tools that can help me in this rutinary situation. Any suggestion in so...
*Edit*: OK, you say you're using C++. I'm editing my response. I would use the C preprocessor and then grep for the variable. It will appear in the first place. ``` cpp -I...(preprocessor options here) file.cpp | grep variable ``` The C preprocessor will join all the includes that the program uses, and the definitio...
559,281
<p>I'm building a SharePoint (MOSS) publishing site for employee information on my company website. I have an employee content type and am using the Contact E-Mail Address site column to store an employee's email address. </p> <p>Want I'd like is the ability to encode email addresses at runtime to prevent the real e...
[ { "answer_id": 559383, "author": "Ric Tokyo", "author_id": 42019, "author_profile": "https://Stackoverflow.com/users/42019", "pm_score": 2, "selected": false, "text": "<p>If you make those employees members of the site, SharePoint takes care of this issue.</p>\n\n<p>You can send emails t...
2009/02/17
[ "https://Stackoverflow.com/questions/559281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67623/" ]
I'm building a SharePoint (MOSS) publishing site for employee information on my company website. I have an employee content type and am using the Contact E-Mail Address site column to store an employee's email address. Want I'd like is the ability to encode email addresses at runtime to prevent the real email address...
In the case that you are unable to put the users into AD, a [custom field control](http://msdn.microsoft.com/en-us/library/bb417414.aspx) will give you the ability to include the custom rendering (jquery) you require as well as the ability to enter the data as "normal" text. The custom field, once defined "just works"...
559,295
<p>When deallocing a refrence I've seen <code>release</code> and <code>dealloc</code> being used for example</p> <pre><code>-(void)dealloc { [foo release]; [nar dealloc]; [super dealloc]; } </code></pre> <p>My question is when is <code>release</code> to be used and when is <code>dealloc</code> to be used?</p> ...
[ { "answer_id": 559311, "author": "Chuck", "author_id": 50742, "author_profile": "https://Stackoverflow.com/users/50742", "pm_score": 7, "selected": true, "text": "<p>Never call <code>dealloc</code> except as <code>[super dealloc]</code> at the end of your class's <code>dealloc</code> met...
2009/02/18
[ "https://Stackoverflow.com/questions/559295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42303/" ]
When deallocing a refrence I've seen `release` and `dealloc` being used for example ``` -(void)dealloc { [foo release]; [nar dealloc]; [super dealloc]; } ``` My question is when is `release` to be used and when is `dealloc` to be used? Thanks
Never call `dealloc` except as `[super dealloc]` at the end of your class's `dealloc` method. The `release` method relinquishes ownership of an object. When a Cocoa object no longer has any owners, it may be deallocated — in which case it will automatically be sent a `dealloc` message. If you're going to program Cocoa...
559,296
<p>Are there existing JARs available to convert from JSON to XML?</p>
[ { "answer_id": 559347, "author": "Antonio", "author_id": 67637, "author_profile": "https://Stackoverflow.com/users/67637", "pm_score": 2, "selected": false, "text": "<p>You may want to try XStream. Take a look at <a href=\"http://x-stream.github.io/faq.html#JSON\" rel=\"nofollow noreferr...
2009/02/18
[ "https://Stackoverflow.com/questions/559296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
Are there existing JARs available to convert from JSON to XML?
Not a Java, but **a pure XSLT 2.0 implementation**: Have a look at the [**`f:json-document()`**](http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-json-document.xsl?view=markup&sortby=date) from the [**FXSL 2.x library**](http://fxsl.sf.net). Using this function it is extremely easy to incorporate JSon an...
559,331
<p>I have created a dialog box (cMyDialog). I am planning to duplicate cMyDialog and call it cMyDialog2. How can I do inheritance in MFC? I want cMyDialog2 to inherit all the IDDs from cMyDialog1 so that I do not have to copy and paste the code from cMyDialog1 to cMyDialog2. The purpose of cMyDialog2 is to inherit all ...
[ { "answer_id": 559362, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 4, "selected": true, "text": "<p>Yes you can inherit from a CDialog-derived class. You just need to add a few macros like DECLARE_DYNAMIC and a few oth...
2009/02/18
[ "https://Stackoverflow.com/questions/559331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have created a dialog box (cMyDialog). I am planning to duplicate cMyDialog and call it cMyDialog2. How can I do inheritance in MFC? I want cMyDialog2 to inherit all the IDDs from cMyDialog1 so that I do not have to copy and paste the code from cMyDialog1 to cMyDialog2. The purpose of cMyDialog2 is to inherit all the...
Yes you can inherit from a CDialog-derived class. You just need to add a few macros like DECLARE\_DYNAMIC and a few others to satisfy MFC. Here is an example. You can use this as a starting point: In the .h file: ``` class cMyDialog2 : public cMyDialog { DECLARE_DYNAMIC(cMyDialog2) pulic: cMyDialog2(); virtu...
559,335
<p>Firefox handles it fine, but Safari and IE7 silently fail and do not insert the element.</p> <pre><code>&lt;script type="text/javascript"&gt; var ul = document.getElementById('xg_navigation').getElementsByTagName('ul')[0]; ul.innerHTML = '&lt;li id="xg_tab_home" class="xg_subtab"&gt;&lt;a href="http://somedomai...
[ { "answer_id": 559341, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 2, "selected": false, "text": "<p>Yes, IE cannot access DOM elements until the document load is complete.</p>\n" }, { "answer_id": 559343, "aut...
2009/02/18
[ "https://Stackoverflow.com/questions/559335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62076/" ]
Firefox handles it fine, but Safari and IE7 silently fail and do not insert the element. ``` <script type="text/javascript"> var ul = document.getElementById('xg_navigation').getElementsByTagName('ul')[0]; ul.innerHTML = '<li id="xg_tab_home" class="xg_subtab"><a href="http://somedomain.com/">Some Text</a></li>' +...
Seems like you are manipulating the DOM before it has been loaded, try adding that snippet of code inside the `window.onload` listener: ``` <script type="text/javascript"> window.onload = function() { var ul = document.getElementById('xg_navigation').getElementsByTagName('ul')[0]; ul.innerHTML = '<li id="xg_ta...
559,361
<p>I need to create an inline formset which </p> <p>a) excludes some fields from <code>MyModel</code> being displayed altogether </p> <p>b) displays some some fields <code>MyModel</code> but prevents them from being editable.</p> <p>I tried using the code below, using <code>values()</code> in order to filter the que...
[ { "answer_id": 622441, "author": "Carl Meyer", "author_id": 3207, "author_profile": "https://Stackoverflow.com/users/3207", "pm_score": 3, "selected": false, "text": "<p>Is this a formset for use in the admin? If so, just set \"<a href=\"http://docs.djangoproject.com/en/dev/ref/contrib/...
2009/02/18
[ "https://Stackoverflow.com/questions/559361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to create an inline formset which a) excludes some fields from `MyModel` being displayed altogether b) displays some some fields `MyModel` but prevents them from being editable. I tried using the code below, using `values()` in order to filter the query set to just those values I wanted returned. However, t...
One thing that doesn't seem to be said in the documentation is that you can include a form inside your parameters for model formsets. So, for instance, let's say you have a person modelform, you can use it in a model formset by doing this ``` PersonFormSet = inlineformset_factory(User, Person, form=PersonForm, extra=6...
559,363
<p>How can I match a space character in a PHP regular expression?</p> <p>I mean like &quot;gavin schulz&quot;, the space in between the two words. I am using a regular expression to make sure that I only allow letters, number and a space. But I'm not sure how to find the space. This is what I have right now:</p> <pre><...
[ { "answer_id": 559372, "author": "Elsporko", "author_id": 34954, "author_profile": "https://Stackoverflow.com/users/34954", "pm_score": 3, "selected": false, "text": "<p>In Perl the switch is <code>\\s</code> (whitespace).</p>\n" }, { "answer_id": 559380, "author": "Suroot", ...
2009/02/18
[ "https://Stackoverflow.com/questions/559363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64785/" ]
How can I match a space character in a PHP regular expression? I mean like "gavin schulz", the space in between the two words. I am using a regular expression to make sure that I only allow letters, number and a space. But I'm not sure how to find the space. This is what I have right now: ``` $newtag = preg_replace("...
If you're looking for a space, that would be `" "` (one space). If you're looking for one or more, it's `" *"` (that's *two* spaces and an asterisk) or `" +"` (one space and a plus). If you're looking for common spacing, use `"[ X]"` or `"[ X][ X]*"` or `"[ X]+"` where `X` is the physical tab character (and each is p...
559,385
<p>Afternoon,</p> <p>Lets say I have gather a random selection of users:</p> <p>User.find(:all, :limit => 10, :order => "rand()")</p> <p>Now from these results, I want to see if the user with the ID of 3 was included in the results, what would be the best way of finding this out?</p> <p>I thought about Array.includ...
[ { "answer_id": 559390, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 2, "selected": false, "text": "<pre><code>assert random_users.include?(User.find 3), \"Not found!\"\n</code></pre>\n\n<p>Active record objects are con...
2009/02/18
[ "https://Stackoverflow.com/questions/559385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67113/" ]
Afternoon, Lets say I have gather a random selection of users: User.find(:all, :limit => 10, :order => "rand()") Now from these results, I want to see if the user with the ID of 3 was included in the results, what would be the best way of finding this out? I thought about Array.include? but that seems to be a dead ...
``` users = User.find(:all, :limit => 10, :order => "rand()") users.any? {|u| u.id == 3} ```
559,415
<p>Is there any easy LINQ expression to concatenate my entire <code>List&lt;string&gt;</code> collection items to a single <code>string</code> with a delimiter character?</p> <p>What if the collection is of custom objects instead of <code>string</code>? Imagine I need to concatenate on <code>object.Name</code>.</p>
[ { "answer_id": 559419, "author": "Sedat Kapanoglu", "author_id": 54937, "author_profile": "https://Stackoverflow.com/users/54937", "pm_score": 10, "selected": false, "text": "<pre class=\"lang-cs prettyprint-override\"><code>string result = String.Join(delimiter, list);\n</code></pre>\n<...
2009/02/18
[ "https://Stackoverflow.com/questions/559415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8091/" ]
Is there any easy LINQ expression to concatenate my entire `List<string>` collection items to a single `string` with a delimiter character? What if the collection is of custom objects instead of `string`? Imagine I need to concatenate on `object.Name`.
Warning - Serious Performance Issues ------------------------------------ Though this answer does produce the desired result, it suffers from poor performance compared to other answers here. Be very careful about deciding to use it --- By using LINQ, this should work; ``` string delimiter = ","; List<string> items ...
559,418
<p>Stylecop is telling me to use /// instead of // when I´m commenting. What is the semantic difference for those two and when should I use which one?</p>
[ { "answer_id": 559422, "author": "LDomagala", "author_id": 45719, "author_profile": "https://Stackoverflow.com/users/45719", "pm_score": 3, "selected": false, "text": "<p>Found it myself while going through further Stylecop rules:</p>\n\n<p>Use // when commentin</p>\n\n<p>Use /// when do...
2009/02/18
[ "https://Stackoverflow.com/questions/559418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45719/" ]
Stylecop is telling me to use /// instead of // when I´m commenting. What is the semantic difference for those two and when should I use which one?
// denotes your own personal comments, where /// denote comments that can contain special data, e.g. markup for interpretation by Visual Studio - like: ``` /// <summary> /// This class does something. /// </summary> class Bob { ... } ``` This will tell Visual Studio the summary of the Bob class, and that will th...
559,420
<p>I need to scrape(using scrAPI) 400+ web pages ruby, my actual code is very sequential:</p> <pre><code>data = urls.map {|url| scraper.scrape url } </code></pre> <p>Actually the code is a bit different (exception handling and stuff).</p> <p>How can I make it faster? How can I parallelize the downloads?</p>
[ { "answer_id": 559426, "author": "womble", "author_id": 60003, "author_profile": "https://Stackoverflow.com/users/60003", "pm_score": 3, "selected": false, "text": "<pre><code>th = []\ndata = []\ndlock = Mutex.new\n\nurls.each do |url|\n th &lt;&lt; Thread.new(url) do |url|\n d = scr...
2009/02/18
[ "https://Stackoverflow.com/questions/559420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to scrape(using scrAPI) 400+ web pages ruby, my actual code is very sequential: ``` data = urls.map {|url| scraper.scrape url } ``` Actually the code is a bit different (exception handling and stuff). How can I make it faster? How can I parallelize the downloads?
``` th = [] data = [] dlock = Mutex.new urls.each do |url| th << Thread.new(url) do |url| d = scraper.scrape url dlock.synchronize { data << d } end end th.each { |t| t.join } ``` Tada! (Caution; written from memory, not tested, may eat your kitten, etc) **Edit:** I figured someone must have written a ...
559,431
<p>I've got geodjango running using <a href="http://openlayers.org/" rel="noreferrer">openlayers</a> and <a href="http://www.openstreetmap.org/" rel="noreferrer">OpenStreetMaps</a> with the admin app.</p> <p>Now I want to write some views to display the data. Basically, I just want to add a list of points (seen in the...
[ { "answer_id": 569890, "author": "Joe Holloway", "author_id": 48837, "author_profile": "https://Stackoverflow.com/users/48837", "pm_score": 3, "selected": true, "text": "<p>I think your solution is workable and probably the easiest approach. Just templatize the javascript and use Django...
2009/02/18
[ "https://Stackoverflow.com/questions/559431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24718/" ]
I've got geodjango running using [openlayers](http://openlayers.org/) and [OpenStreetMaps](http://www.openstreetmap.org/) with the admin app. Now I want to write some views to display the data. Basically, I just want to add a list of points (seen in the admin) to the map. Geodjango appears to use a *special* [openlay...
I think your solution is workable and probably the easiest approach. Just templatize the javascript and use Django to inject your data points as the template is rendered. If you wanted to get fancier, you could have a Django view that served up the data points as JSON (application/json) and then use AJAX to call back...
559,436
<p>I have a large number of email addresses to validate. Initially I parse them with a regexp to throw out the completely crazy ones. I'm left with the ones that look sensible but still might contain errors. </p> <p>I want to find which addresses have valid domains, so given me@abcxyz.com I want to know if it's even p...
[ { "answer_id": 559479, "author": "Van Gale", "author_id": 34258, "author_profile": "https://Stackoverflow.com/users/34258", "pm_score": 5, "selected": true, "text": "<p>There is no DNS interface in the standard library so you will either have to roll your own or use a third party library...
2009/02/18
[ "https://Stackoverflow.com/questions/559436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46411/" ]
I have a large number of email addresses to validate. Initially I parse them with a regexp to throw out the completely crazy ones. I'm left with the ones that look sensible but still might contain errors. I want to find which addresses have valid domains, so given me@abcxyz.com I want to know if it's even possible to...
There is no DNS interface in the standard library so you will either have to roll your own or use a third party library. This is not a fast-changing concept though, so the external libraries are stable and well tested. The one I've used successful for the same task as your question is [PyDNS](http://pydns.sourceforge...
559,437
<p><strong>I have not marked this question Answered yet.<br> The current accepted answer got accepted automatically because of the Bounty Time-Limit</strong></p> <hr> <p><em>With reference to <a href="https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment">this pro...
[ { "answer_id": 559447, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 3, "selected": true, "text": "<p>The angle between the robots is arctan(x-distance, y-distance) (most platforms provide this 2-argument arctan that does the ...
2009/02/18
[ "https://Stackoverflow.com/questions/559437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44084/" ]
**I have not marked this question Answered yet. The current accepted answer got accepted automatically because of the Bounty Time-Limit** --- *With reference to [this programming game](https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment) I am currently buildi...
The angle between the robots is arctan(x-distance, y-distance) (most platforms provide this 2-argument arctan that does the angle adjustment for you. You then just have to check whether this angle is less than some number away from the current heading. --- **Edit 2020**: Here's a much more complete analysis based on ...
559,440
<p>Firstly, I'm pretty new to C++. I believe that <code>getline()</code> isn't a standard C function, so <code>#define _GNU_SOURCE</code> is required to use it. I'm now using C++ and g++ tells me that <code>_GNU_SOURCE</code> is already defined:</p> <pre><code>$ g++ -Wall -Werror parser.cpp parser.cpp:1:1: error: "_GN...
[ { "answer_id": 559451, "author": "Suroot", "author_id": 64626, "author_profile": "https://Stackoverflow.com/users/64626", "pm_score": 0, "selected": false, "text": "<p>I've always had to use one of the following in C++. Never had to declare _GNU_ anything before. I usually run in *nix ...
2009/02/18
[ "https://Stackoverflow.com/questions/559440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16658/" ]
Firstly, I'm pretty new to C++. I believe that `getline()` isn't a standard C function, so `#define _GNU_SOURCE` is required to use it. I'm now using C++ and g++ tells me that `_GNU_SOURCE` is already defined: ``` $ g++ -Wall -Werror parser.cpp parser.cpp:1:1: error: "_GNU_SOURCE" redefined <command-line>: error: this...
I think g++, from version 3, automagically defines `_GNU_SOURCE`. This is supported by your third line in the error stating that the first definition was done on the command line (with nary a `-D_GNU_SOURCE` in sight): ``` <command-line>: error: this is the location of the previous definition ``` If you don't want i...
559,441
<p>For a large project, would it make sense to have one datacontext which maps out your database, which you can interact with from your classes?</p> <p>Or would it make more sense to split this up into small datacontexts which are focused on the specific tasks within the database that will be required.</p> <p>I'm cur...
[ { "answer_id": 559667, "author": "Robert Paulson", "author_id": 14033, "author_profile": "https://Stackoverflow.com/users/14033", "pm_score": 4, "selected": true, "text": "<p>I'm assuming you're asking about design versus runtime pattern. I general I'd say <em>no</em>:</p>\n\n<p>While it...
2009/02/18
[ "https://Stackoverflow.com/questions/559441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53771/" ]
For a large project, would it make sense to have one datacontext which maps out your database, which you can interact with from your classes? Or would it make more sense to split this up into small datacontexts which are focused on the specific tasks within the database that will be required. I'm curious as to the pe...
I'm assuming you're asking about design versus runtime pattern. I general I'd say *no*: While it may be possible to partition your database into multiple data contexts, then that would be desirable if and only if there was zero overlap between the two contexts. *Overlap is Bad* e.g. you have a `WebsiteContext` and a...
559,453
<p>I have a method to add an XML node structure to the currently selected tree node. </p> <p>This appends the xml, and opens the parent node to display the newly added node. </p> <p>I then select the node by setting the selectedItem of the tree.</p> <p>I have an editing form that updates its values on the tree chang...
[ { "answer_id": 560046, "author": "dirkgently", "author_id": 66692, "author_profile": "https://Stackoverflow.com/users/66692", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Is there a way I can force the tree to dispatch a change event at this point?</p>\n</blockquote>\n\n...
2009/02/18
[ "https://Stackoverflow.com/questions/559453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67599/" ]
I have a method to add an XML node structure to the currently selected tree node. This appends the xml, and opens the parent node to display the newly added node. I then select the node by setting the selectedItem of the tree. I have an editing form that updates its values on the tree change event. When I set the ...
You could move the logic that is currently in your change event handler to a separate function, and then call that function directly: ``` private function changeHandler(event:ListEvent):void { doChangeLogic(); } private function doChangeLogic():void { //statements } public function addSelected(node:XML):void...
559,467
<p>Can anyone tell me the set of control characters for a PDF file, and how to escape them? I have a (non-deflated (inflated?)) PDF document that I would like to edit the text in, but I'm afraid of accidentally making some control sequence using parentheses and stuff.</p> <p>Thanks.</p>
[ { "answer_id": 559557, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 5, "selected": false, "text": "<p>Okay, I think I found it. On page 15 of the <a href=\"http://adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf\" re...
2009/02/18
[ "https://Stackoverflow.com/questions/559467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49485/" ]
Can anyone tell me the set of control characters for a PDF file, and how to escape them? I have a (non-deflated (inflated?)) PDF document that I would like to edit the text in, but I'm afraid of accidentally making some control sequence using parentheses and stuff. Thanks.
Okay, I think I found it. On page 15 of the [PDF 1.7 spec](http://adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf) (PDF link), it appears that the only characters I need to worry about are the parentheses and the backslash. ``` Sequence | Meaning --------------------------------------------- \n | LINE FEED (0Ah...
559,476
<p>I'm doing a little bit of ajax where I get a static html file that is actually changed on the disk from time to time. Of course IE has a problem where it wants to help out by caching the file which I don't want. I know how to fix this when grabbing a dynamic file: you just change the header in the dynamic file. B...
[ { "answer_id": 559569, "author": "Marcel", "author_id": 131, "author_profile": "https://Stackoverflow.com/users/131", "pm_score": 2, "selected": false, "text": "<p>At Apache level you can setup the expiry date of the document using the mod_expires module.</p>\n<p>From the documentation:<...
2009/02/18
[ "https://Stackoverflow.com/questions/559476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
I'm doing a little bit of ajax where I get a static html file that is actually changed on the disk from time to time. Of course IE has a problem where it wants to help out by caching the file which I don't want. I know how to fix this when grabbing a dynamic file: you just change the header in the dynamic file. But how...
If you can use `mod_expires` as Marcel suggested, you can always append a random request parameter. For example, instead of requesting `static_file.html` you can request `static_file.html?_=1231231231` and change that request parameter every time. [jQuery](http://jquery.com/) has a really simple way of doing this: ...