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
433,846
<p>How do I access a Control in the <code>LayoutTemplate</code> of a <code>ListView</code> control?</p> <p>I need to get to <code>litControlTitle</code> and set its <code>Text</code> attribute.</p> <pre><code>&lt;asp:ListView ID="lv" runat="server"&gt; &lt;LayoutTemplate&gt; &lt;asp:Literal ID="litControlTitle"...
[ { "answer_id": 433879, "author": "tanathos", "author_id": 51295, "author_profile": "https://Stackoverflow.com/users/51295", "pm_score": 6, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>((Literal)lv.FindControl(\"litControlTitle\")).Text = \"Your text\";\n</code></pre>\n" },...
2009/01/11
[ "https://Stackoverflow.com/questions/433846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12252/" ]
How do I access a Control in the `LayoutTemplate` of a `ListView` control? I need to get to `litControlTitle` and set its `Text` attribute. ``` <asp:ListView ID="lv" runat="server"> <LayoutTemplate> <asp:Literal ID="litControlTitle" runat="server" /> <asp:PlaceHolder ID="itemPlaceHolder" runat="server" /> ...
Try this: ``` ((Literal)lv.FindControl("litControlTitle")).Text = "Your text"; ```
433,850
<p>Are these two equivalent?</p> <p>char * aString = "This is a string.";</p> <p>char aString[] = "This is a string.";</p> <p>From my understanding, C++ stores strings by their addresses, so the pointer is getting a valid address. I assume the strings are also stored as type char? But how does it know how much memor...
[ { "answer_id": 433859, "author": "Aif", "author_id": 51760, "author_profile": "https://Stackoverflow.com/users/51760", "pm_score": -1, "selected": false, "text": "<p>Yes, in C language type *foo is equivalent to type foo[].</p>\n\n<p>Static variables are allocated at load-time on the dat...
2009/01/11
[ "https://Stackoverflow.com/questions/433850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Are these two equivalent? char \* aString = "This is a string."; char aString[] = "This is a string."; From my understanding, C++ stores strings by their addresses, so the pointer is getting a valid address. I assume the strings are also stored as type char? But how does it know how much memory to allocate for the s...
``` char * aString = "This is a string."; ``` It's making a pointer `aString` point to a statically allocated char array containing `"This is a string."`. The string is *not* writable, even though the type of the pointer might suggest you could write to it. See the answer in the link below, for reasons to avoid it an...
433,853
<p>As the question says, what are some common/major issues that C++ programmers face when switching to Java? I am looking for some broad topic names or examples and day to day adjustments that engineers had to make. I can then go and do an in-depth reading on this. </p> <p>I am specifically interested in opinions of e...
[ { "answer_id": 433864, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 2, "selected": false, "text": "<p>Getting used to having a garbage collector. Not being able to rely on a destructor to clean up resources that the GC d...
2009/01/11
[ "https://Stackoverflow.com/questions/433853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33121/" ]
As the question says, what are some common/major issues that C++ programmers face when switching to Java? I am looking for some broad topic names or examples and day to day adjustments that engineers had to make. I can then go and do an in-depth reading on this. I am specifically interested in opinions of engineers w...
* In C++ you'd use destructors to clean up file descriptors, database connections and the like. The naive equivalent is to use finalizers. Don't. Ever. Instead use this pattern: ``` OutputStream os; try { os = ... // do stuff } finally { try { os.close(); } catch (Exception e) { } } ``` You'll end up doing s...
433,860
<p>I'm trying to work through this <a href="http://guides.rubyonrails.org/routing_outside_in.html" rel="noreferrer">guide to Rails routing</a>, but I got stuck in section <a href="http://guides.rubyonrails.org/routing_outside_in.html#_urls_and_paths" rel="noreferrer">3.3</a>:</p> <blockquote> <p>Creating a RESTful r...
[ { "answer_id": 433904, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 2, "selected": false, "text": "<p>I think this may be what you are looking for ... <a href=\"http://topfunky.com/clients/peepcode/REST-cheatsheet.pd...
2009/01/11
[ "https://Stackoverflow.com/questions/433860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
I'm trying to work through this [guide to Rails routing](http://guides.rubyonrails.org/routing_outside_in.html), but I got stuck in section [3.3](http://guides.rubyonrails.org/routing_outside_in.html#_urls_and_paths): > > Creating a RESTful route will also make available a pile of helpers within your application > >...
You have several questions in there, most of which have already been answered by people below. The answer to one that wasn't fully addressed however, is: yes you can use the script/console to see where your routes go. Just type in `app.[route_helper]` and it will respond with the path. For example `app.users_path` wil...
433,881
<p>Consider these 3 table structures. Which will perform these queries the best.</p> <h2>Structure 1 - TagID as int with a join table</h2> <pre><code>Article ------- ArticleID int Article_Tag ------------ ArticleTagID int ArticleID int TagID int Tag --- TagID int TagText varchar(50) </code></pre> <h2>Structure 2 -...
[ { "answer_id": 433900, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": false, "text": "<p>Using <code>TagText</code> as the primary key would have the advantage that you could get an articles tags with few...
2009/01/11
[ "https://Stackoverflow.com/questions/433881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
Consider these 3 table structures. Which will perform these queries the best. Structure 1 - TagID as int with a join table -------------------------------------------- ``` Article ------- ArticleID int Article_Tag ------------ ArticleTagID int ArticleID int TagID int Tag --- TagID int TagText varchar(50) ``` Stru...
It depends if you ever want to be able to change the tag-text globally. You could, of course, issue a wide `UPDATE` on `Article_Tag`, but if you need to be able to do this, then being able to just update the value in `Tag` would be simpler. Some servers offer automatic updates (such as `ON UPDATE CASCADE` in SQL Server...
433,903
<p>Is there a MySQL command to count the number of rows in a table, and if so, what is it?</p>
[ { "answer_id": 433906, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 6, "selected": true, "text": "<p>MySQL <a href=\"http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html\" rel=\"noreferrer\">COUNT()</a> functio...
2009/01/11
[ "https://Stackoverflow.com/questions/433903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
Is there a MySQL command to count the number of rows in a table, and if so, what is it?
MySQL [COUNT()](http://dev.mysql.com/doc/refman/5.1/en/counting-rows.html) function ``` SELECT COUNT(*) FROM table ```
433,907
<p>I am creating a free version of my iPhone game. I want to have a button inside the free version that takes people to the paid version in the app store. If I use a standard link</p> <p><a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&amp;mt=8" rel="noreferrer">http://itunes.apple....
[ { "answer_id": 434040, "author": "matt", "author_id": 53997, "author_profile": "https://Stackoverflow.com/users/53997", "pm_score": 5, "selected": false, "text": "<p>Simply change 'itunes' to 'phobos' in the app link.</p>\n\n<p><a href=\"http://phobos.apple.com/WebObjects/MZStore.woa/wa/...
2009/01/11
[ "https://Stackoverflow.com/questions/433907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53997/" ]
I am creating a free version of my iPhone game. I want to have a button inside the free version that takes people to the paid version in the app store. If I use a standard link <http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300136119&mt=8> the iPhone opens Safari first, and then the app store. I h...
**Edited on 2016-02-02** Starting from iOS 6 [SKStoreProductViewController](https://developer.apple.com/library/prerelease/ios/documentation/StoreKit/Reference/SKITunesProductViewController_Ref/index.html) class was introduced. You can link an app without leaving your app. Code snippet in **Swift 3.x/2.x** and **Objec...
433,918
<p>I recently started to learn about LINQ and came across the <code>OrderBy</code> extension method. This initially excited me because the syntax seemed much nicer than the <code>Sort</code> method that we use all over the place for Generic Lists.</p> <p>For example, when sorting a list of languages, we normally do so...
[ { "answer_id": 433932, "author": "Øyvind Skaar", "author_id": 49194, "author_profile": "https://Stackoverflow.com/users/49194", "pm_score": 2, "selected": false, "text": "<p>I think it is because <code>list</code> is not passed by ref. Thus setting the <code>list</code> variable to anoth...
2009/01/11
[ "https://Stackoverflow.com/questions/433918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5609/" ]
I recently started to learn about LINQ and came across the `OrderBy` extension method. This initially excited me because the syntax seemed much nicer than the `Sort` method that we use all over the place for Generic Lists. For example, when sorting a list of languages, we normally do something like: ``` neutralCultur...
That's the behaviour I would expect. Imagine if such a thing were possible: ``` var c = myCustomer; myCustomer.DoStuff(); if (c == myCustomer) // returns false!!! ``` Simply calling a method on an object (which is what an extension method looks like to the user of your framework) shouldn't change which instance the ...
433,919
<p>I am writing some UI tests using Selenium and i have a JavaScript Tree control, using the Dojo toolkit. </p> <p>I have implemented a context menu for each node of the tree using the examples that Dojo provide, but I need the Selenium test to "invoke" the right click on the tree node, but I cannot get this to work. ...
[ { "answer_id": 433995, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 3, "selected": false, "text": "<p>Great question!</p>\n\n<p>I did some research, and it seems like you can fire a mouse event like <a href=\"http://lifescal...
2009/01/11
[ "https://Stackoverflow.com/questions/433919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26310/" ]
I am writing some UI tests using Selenium and i have a JavaScript Tree control, using the Dojo toolkit. I have implemented a context menu for each node of the tree using the examples that Dojo provide, but I need the Selenium test to "invoke" the right click on the tree node, but I cannot get this to work. The tests ...
try this instead, reason what things didn't quite work is that the context menu is in fact bound to the oncontextmenu event. ``` function contextMenuClick(element){ var evt = element.ownerDocument.createEvent('MouseEvents'); var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE evt.initMouseEvent('c...
433,933
<pre><code>SELECT * FROM friends WHERE (user1 = $userid OR user2 = $userid) AND accepted = 1 </code></pre> <p>how would a JOIN look like if I want to get lets say user2's information from table "users"?</p> <pre><code>table friends: `id` int(11) NOT NULL auto_increment, `user1` int(11) NOT NULL, `user2` int(11)...
[ { "answer_id": 433944, "author": "Deniss Kozlovs", "author_id": 53948, "author_profile": "https://Stackoverflow.com/users/53948", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT u.*, f.* FROM friends f \nJOIN users u ON u.id=f.user2 \nWHERE (f.user1= $userid OR f.user2=$user...
2009/01/11
[ "https://Stackoverflow.com/questions/433933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` SELECT * FROM friends WHERE (user1 = $userid OR user2 = $userid) AND accepted = 1 ``` how would a JOIN look like if I want to get lets say user2's information from table "users"? ``` table friends: `id` int(11) NOT NULL auto_increment, `user1` int(11) NOT NULL, `user2` int(11) NOT NULL, `date` datetime N...
``` SELECT u.*, f.* FROM friends f JOIN users u ON u.id=f.user2 WHERE (f.user1= $userid OR f.user2=$userid) AND f.accepted = 1 ```
433,945
<p>I was wondering if there is something similar to Java's <code>JFileChooser</code> for Python?</p> <p><code>JFileChooser</code> is a graphical front end to choose a file.</p> <p>Preferably something that is already with Python. Maybe with Tkinter.</p>
[ { "answer_id": 433964, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 1, "selected": false, "text": "<p>That would depend on your windowing toolkit. wxWidgets provides the <a href=\"http://docs.wxwidgets.org/stable/wx_wxfile...
2009/01/11
[ "https://Stackoverflow.com/questions/433945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
I was wondering if there is something similar to Java's `JFileChooser` for Python? `JFileChooser` is a graphical front end to choose a file. Preferably something that is already with Python. Maybe with Tkinter.
For something that doesn't require wxPython and sticks with the standard Python libs, you can use the tkFileDialog.askopenfilename() method: ``` #!/usr/bin/python from Tkinter import * from tkFileDialog import askopenfilename root = Tk() root.withdraw() print askopenfilename() ```
433,958
<p>I need to format a decimal value into a string where I always display at lease 2 decimals and at most 4. </p> <p>So for example</p> <pre><code>"34.49596" would be "34.4959" "49.3" would be "49.30" </code></pre> <p>Can this be done using the String.format command?<br> Or is there an easier/better way to do this i...
[ { "answer_id": 433962, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 1, "selected": false, "text": "<p>You want java.text.DecimalFormat</p>\n" }, { "answer_id": 433963, "author": "cagcowboy", "author_id": 1...
2009/01/11
[ "https://Stackoverflow.com/questions/433958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47508/" ]
I need to format a decimal value into a string where I always display at lease 2 decimals and at most 4. So for example ``` "34.49596" would be "34.4959" "49.3" would be "49.30" ``` Can this be done using the String.format command? Or is there an easier/better way to do this in Java.
You want java.text.DecimalFormat. ``` DecimalFormat df = new DecimalFormat("0.00##"); String result = df.format(34.4959); ```
433,965
<pre><code> #include &lt;iostream&gt; using namespace std; class Base { public: Base(){cout &lt;&lt;"Base"&lt;&lt;endl;} virtual ~Base(){cout&lt;&lt;"~Base"&lt;&lt;endl;} virtual void foo(){ cout&lt;&lt;"foo base"&lt;&lt;endl;} }; class Derived: private Base { public: Derived()...
[ { "answer_id": 433980, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>Why its not possible to create Derived object with base pointer????</p>\n</blockquote>\n\n<p>Becaus...
2009/01/11
[ "https://Stackoverflow.com/questions/433965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33411/" ]
``` #include <iostream> using namespace std; class Base { public: Base(){cout <<"Base"<<endl;} virtual ~Base(){cout<<"~Base"<<endl;} virtual void foo(){ cout<<"foo base"<<endl;} }; class Derived: private Base { public: Derived(){cout<<"Derived"<<endl;} virtual ~Derived...
> > Why its not possible to create Derived object with base pointer???? > > > Because the base is `private`. This explicitly forbids treating your class as a `Base` instance from the outside. Seen from the outside, your class `Derived` is *not* a subclass of `Base`, only from inside the class itself. The same cou...
433,972
<p>Consider the tables: (<code>-&gt;</code> denotes a SQL defined relationship)</p> <pre><code>USER (userid, username, imageid-&gt;IMAGE.imageid) EVENT (eventid, userid-&gt;USER.userid, description) IMAGE (imageid, location) </code></pre> <p>Say I have a view (let's call it <code>vw_UserInfo</code>) defined as the fo...
[ { "answer_id": 434076, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 0, "selected": false, "text": "<p>Relationships enforce data integrity, they have nothing to do with quick selection of data. That is the realm of ...
2009/01/11
[ "https://Stackoverflow.com/questions/433972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52551/" ]
Consider the tables: (`->` denotes a SQL defined relationship) ``` USER (userid, username, imageid->IMAGE.imageid) EVENT (eventid, userid->USER.userid, description) IMAGE (imageid, location) ``` Say I have a view (let's call it `vw_UserInfo`) defined as the following query. ``` SELECT u.*, i.* FROM users u INNER JO...
No, because views (at least in SQL Server) are not really part of the constraints system (the existence or non-existence of a view should not affect the performance of any query not referencing the view). Indexed views (materialized views), however, might be able to contribute to performance. I'm not sure which, if any...
434,013
<p>Ugh ok I'm terrible at explaining things, so I'll just give you the quotes and links first:</p> <p><a href="http://sqlzoo.net/3.htm" rel="nofollow noreferrer">Problem 4b</a> (near bottom):</p> <blockquote> <p>4b. List the film title and the leading actor for all of 'Julie Andrews' films.</p> <blockquote> ...
[ { "answer_id": 434045, "author": "John MacIntyre", "author_id": 29043, "author_profile": "https://Stackoverflow.com/users/29043", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT title, name\n FROM casting JOIN movie\n ON casting.movieid = movie.id\n JO...
2009/01/11
[ "https://Stackoverflow.com/questions/434013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19825/" ]
Ugh ok I'm terrible at explaining things, so I'll just give you the quotes and links first: [Problem 4b](http://sqlzoo.net/3.htm) (near bottom): > > 4b. List the film title and the leading actor for all of 'Julie Andrews' films. > > > > > > > movie(id, title, yr, score, votes, director) > > > > actor(id, nam...
There are wonderful ways of doing this with subqueries, but it appears that t this point in the tutorial you're only working with JOINs. The following is how you would do it with only JOINs: ``` SELECT movie.title, a2.name FROM actor AS a1 JOIN casting AS c1 ON (a1.id = c1.actorid) JOIN movie ON (c1.movieid ...
434,038
<p>Redirecting command output:</p> <p>For example:</p> <pre><code>echo "Foo `./print_5_As.rb`" </code></pre> <p>would echo "Foo AAAAA"</p>
[ { "answer_id": 434087, "author": "matli", "author_id": 23896, "author_profile": "https://Stackoverflow.com/users/23896", "pm_score": 5, "selected": false, "text": "<p>In CMD.EXE there is no direct equivalent. But you can use the FOR command to achieve what you want.</p>\n\n<p>Do somethin...
2009/01/11
[ "https://Stackoverflow.com/questions/434038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Redirecting command output: For example: ``` echo "Foo `./print_5_As.rb`" ``` would echo "Foo AAAAA"
The PowerShell syntax is based on the POSIX ksh syntax (and interestingly *not* on any of Microsoft's languages like CMD.EXE, VBScript or Visual Basic for Applications), so many things work pretty much the same as in Bash. In your case, command substitution is done with ``` echo "Foo $(./print_5_As.rb)" ``` in both ...
434,039
<p>I have written a program that will etablish a network connection with a remote computer using TCPClient I am using it to transfer files in 100k chunks to a remote .net application and it inturn then writes them to the HardDrive. All file transfers work good except when it comes to ZIP files - it is curious to note t...
[ { "answer_id": 434049, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 0, "selected": false, "text": "<p>It might be that you are overwriting (instead of appending to) the existing file with each chunk received? Therefore the fi...
2009/01/11
[ "https://Stackoverflow.com/questions/434039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
I have written a program that will etablish a network connection with a remote computer using TCPClient I am using it to transfer files in 100k chunks to a remote .net application and it inturn then writes them to the HardDrive. All file transfers work good except when it comes to ZIP files - it is curious to note that...
Well, you haven't shown any code so it's kinda tricky to say exactly what's wrong. The *usual* mistake is to assume that Stream.Read reads all the data you ask it to instead of realising that it might read less, but that the amount it *actually* read is the return value. In other words, the code shouldn't be: ``` by...
434,051
<p>I have a data service that takes a byte array. I then have a web page that attempts to send a file to that data service. If the file is small (say 50kb) then everything functions as expected, however if the file is large (anything over 100kb) I get a "BadRequest" error message on the save change call for the data ...
[ { "answer_id": 447403, "author": "mapache", "author_id": 41422, "author_profile": "https://Stackoverflow.com/users/41422", "pm_score": 3, "selected": false, "text": "<p>The maximum size of the request which a WCF service can process is controlled by the MaxReceivedMessageSize property on...
2009/01/11
[ "https://Stackoverflow.com/questions/434051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25719/" ]
I have a data service that takes a byte array. I then have a web page that attempts to send a file to that data service. If the file is small (say 50kb) then everything functions as expected, however if the file is large (anything over 100kb) I get a "BadRequest" error message on the save change call for the data servi...
The maximum size of the request which a WCF service can process is controlled by the MaxReceivedMessageSize property on the WCF binding. The default value is 65536 ,exceeding which you get the 400 response code. In the web.config of the web site hosting the service , add the following node in the section. ``` <syst...
434,098
<p>Recently there have been a few attackers trying malicious things on my server so I've decided to somewhat "track" them even though I know they won't get very far.</p> <p>Now, I have an entire directory containing the server logs and I need a way to search through every file in the directory, and return a filename i...
[ { "answer_id": 434103, "author": "ng.", "author_id": 21896, "author_profile": "https://Stackoverflow.com/users/21896", "pm_score": 2, "selected": false, "text": "<p>This will get the file names you are looking for in perl, and probably do it much faster than running and doing a perl rege...
2009/01/12
[ "https://Stackoverflow.com/questions/434098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36457/" ]
Recently there have been a few attackers trying malicious things on my server so I've decided to somewhat "track" them even though I know they won't get very far. Now, I have an entire directory containing the server logs and I need a way to search through every file in the directory, and return a filename if a string...
Can you use [grep](http://en.wikipedia.org/wiki/Grep) instead?
434,108
<pre><code> private void CreateNewControl() { List&lt;Control&gt; list = new List&lt;Control&gt;(); TableLayoutPanel layout = new TableLayoutPanel(); layout.Dock = DockStyle.Fill; this.Controls.Add(layout); layout.ColumnCount = 3; la...
[ { "answer_id": 434116, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 2, "selected": false, "text": "<p>In general, what I do is:</p>\n\n<ul>\n<li>Use the IDE in a 'prototype' project, to create a form with the controls in t...
2009/01/12
[ "https://Stackoverflow.com/questions/434108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` private void CreateNewControl() { List<Control> list = new List<Control>(); TableLayoutPanel layout = new TableLayoutPanel(); layout.Dock = DockStyle.Fill; this.Controls.Add(layout); layout.ColumnCount = 3; layout.GrowStyle = Ta...
In general, what I do is: * Use the IDE in a 'prototype' project, to create a form with the controls in the positions that I want * Look at the source code created by the IDE (in the *MyFormName*`.Designer.cs` file) to see what source code is generated by the IDE to creat these controls * Create my own form in my real...
434,126
<p>I'm trying to write a class in <strong>Delphi 2007</strong> that uses a <strong>ActiveX</strong> library. The class will catch an event that the ActiveX library has to expose its own event that adds some information to the ActiveX library's event.</p> <p>The bottom line is that when I assign my own procedure to th...
[ { "answer_id": 434169, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 4, "selected": true, "text": "<p>The first thing to check is that the thing you're trying to assign to the event property is a <em>method</em>. It ne...
2009/01/12
[ "https://Stackoverflow.com/questions/434126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35229/" ]
I'm trying to write a class in **Delphi 2007** that uses a **ActiveX** library. The class will catch an event that the ActiveX library has to expose its own event that adds some information to the ActiveX library's event. The bottom line is that when I assign my own procedure to the ActiveX library's event that I want...
The first thing to check is that the thing you're trying to assign to the event property is a *method*. It needs to be a procedure or function that belongs to a class; it can't be a standalone subroutine. Next, note that merely confirming that the *names* of the types match isn't enough. Delphi allows redefining an id...
434,127
<p>I have the following file file:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript" src="/Prototype.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function load_content() { new Ajax.PeriodicalUpdater('content', '/UpdatedContent/, { method: 'p...
[ { "answer_id": 434169, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 4, "selected": true, "text": "<p>The first thing to check is that the thing you're trying to assign to the event property is a <em>method</em>. It ne...
2009/01/12
[ "https://Stackoverflow.com/questions/434127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
I have the following file file: ``` <html> <head> <title></title> <script type="text/javascript" src="/Prototype.js"></script> <script type="text/javascript"> function load_content() { new Ajax.PeriodicalUpdater('content', '/UpdatedContent/, { method: 'post', frequency: 5 }); //var fileref = document...
The first thing to check is that the thing you're trying to assign to the event property is a *method*. It needs to be a procedure or function that belongs to a class; it can't be a standalone subroutine. Next, note that merely confirming that the *names* of the types match isn't enough. Delphi allows redefining an id...
434,128
<p>Since a lot of these sites found on google use mathematical notation and I have no idea what any of it means I want to make a feedforward neural network like this:</p> <pre><code> n1 i1 n3 n2 o1 i2 n4 n3 </code></pre> <p>Now can someone explain to me how to find the value of o1? How ...
[ { "answer_id": 434169, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 4, "selected": true, "text": "<p>The first thing to check is that the thing you're trying to assign to the event property is a <em>method</em>. It ne...
2009/01/12
[ "https://Stackoverflow.com/questions/434128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53224/" ]
Since a lot of these sites found on google use mathematical notation and I have no idea what any of it means I want to make a feedforward neural network like this: ``` n1 i1 n3 n2 o1 i2 n4 n3 ``` Now can someone explain to me how to find the value of o1? How is it possible to make a ne...
The first thing to check is that the thing you're trying to assign to the event property is a *method*. It needs to be a procedure or function that belongs to a class; it can't be a standalone subroutine. Next, note that merely confirming that the *names* of the types match isn't enough. Delphi allows redefining an id...
434,138
<p>I want to create a query which has more than 3-4 Expression.Or ? But Expression.Or just let me to add two Expressions inside it.</p> <pre><code>if (!string.IsNullOrEmpty(keyword)) query .Add(Expression.Or( Expression.Like("Name", keyword, MatchMode.An...
[ { "answer_id": 434166, "author": "Mauricio Scheffer", "author_id": 21239, "author_profile": "https://Stackoverflow.com/users/21239", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://elliottjorgensen.com/nhibernate-api-ref/NHibernate.Expression/Disjunction.html\" rel=\"no...
2009/01/12
[ "https://Stackoverflow.com/questions/434138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51734/" ]
I want to create a query which has more than 3-4 Expression.Or ? But Expression.Or just let me to add two Expressions inside it. ``` if (!string.IsNullOrEmpty(keyword)) query .Add(Expression.Or( Expression.Like("Name", keyword, MatchMode.Anywhere), ...
Use [Disjunction](http://elliottjorgensen.com/nhibernate-api-ref/NHibernate.Expression/Disjunction.html) instead of Or.
434,140
<p>I have a struct like this:</p> <pre><code>class Items { private: struct item { unsigned int a, b, c; }; item* items[MAX_ITEMS]; } </code></pre> <p>Say I wanted to 'delete' an item, like so:</p> <pre><code>items[5] = NULL; </code></pre> <p>And I created a new item on that same spot later:...
[ { "answer_id": 434144, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 0, "selected": false, "text": "<p>C++ isn't my strong suit, but I'm pretty sure you'd be leaking the memory if you set the pointer to <code>NULL</code>.</...
2009/01/12
[ "https://Stackoverflow.com/questions/434140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51133/" ]
I have a struct like this: ``` class Items { private: struct item { unsigned int a, b, c; }; item* items[MAX_ITEMS]; } ``` Say I wanted to 'delete' an item, like so: ``` items[5] = NULL; ``` And I created a new item on that same spot later: ``` items[5] = new item; ``` Would I still ne...
You need to call `delete` before setting it to NULL. (Setting it to NULL isn't required, it just helps reduce bugs if you accidentally try to dereference the pointer after deleting it.) Remember that every time you use `new`, you will need to use `delete` later on the same pointer. Never use one without the other. Al...
434,204
<p>I am a bit of a newbie when it comes to Linq to SQL but I hope you can help out. I've written the following Linq to SQL statement with Extension Methods:</p> <pre><code>Cedb.ClassEvents.Where(c =&gt; c.ClassID == 1).Select(c =&gt; c).Single() </code></pre> <p>Where Cedb is the Datacontext, ClassEvents is a table ...
[ { "answer_id": 434234, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 1, "selected": false, "text": "<p>You don't need to do both a Select and a Single, in fact, you don't even need the Where, you can get away with (se...
2009/01/12
[ "https://Stackoverflow.com/questions/434204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15592/" ]
I am a bit of a newbie when it comes to Linq to SQL but I hope you can help out. I've written the following Linq to SQL statement with Extension Methods: ``` Cedb.ClassEvents.Where(c => c.ClassID == 1).Select(c => c).Single() ``` Where Cedb is the Datacontext, ClassEvents is a table (for classes and events being hel...
Slace - and any other interested parties. The cause of the "Invalid Cast Exception" error was a change in the underlying data model. A smallint field had been changed to bit. Thus, when the system tried to map the query results onto the "ClassEvent" data structure, the conflict between the model (which had not been upd...
434,213
<p>I know this maybe a basic question but I just can't seem to find the answer anywhere.</p> <p>I have a class like this</p> <pre><code>Table&lt;T&gt; {} </code></pre> <p>then I have some code that uses the above class that I would like to comment I would like to be able to do something like:</p> <pre><code>/// &lt...
[ { "answer_id": 434214, "author": "Tim Howland", "author_id": 4276, "author_profile": "https://Stackoverflow.com/users/4276", "pm_score": 2, "selected": false, "text": "<p>try using an &amp;lt; instead of a &lt;</p>\n" }, { "answer_id": 434215, "author": "Tamas Czinege", "...
2009/01/12
[ "https://Stackoverflow.com/questions/434213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I know this maybe a basic question but I just can't seem to find the answer anywhere. I have a class like this ``` Table<T> {} ``` then I have some code that uses the above class that I would like to comment I would like to be able to do something like: ``` /// <summary> /// blah blah blah Table<String> /// </summ...
You need to use XML entities (sort of escape sequences): &lt; for < and &gt; for >. Intellisense will display < as and > correctly. **EDIT**: Here's a cheat sheet listing of all of the XML entities: ``` &lt; for < &gt; for > &amp; for & &quot; for " &apos; for ' ```
434,248
<p>Is there a way, in Linux, Windows, or preferably Mac OS X to take a bunch of PDF files and "chain them" into one "booklet" without owning Acrobat and preferably without doing this manually?</p> <p>I have TexShop, MikTex and the like installed, if any of their utilities help.</p>
[ { "answer_id": 434257, "author": "Michael MacDonald", "author_id": 53466, "author_profile": "https://Stackoverflow.com/users/53466", "pm_score": 0, "selected": false, "text": "<p>Have a look at <a href=\"http://multivalent.sourceforge.net/Tools/\" rel=\"nofollow noreferrer\">Multivalent ...
2009/01/12
[ "https://Stackoverflow.com/questions/434248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
Is there a way, in Linux, Windows, or preferably Mac OS X to take a bunch of PDF files and "chain them" into one "booklet" without owning Acrobat and preferably without doing this manually? I have TexShop, MikTex and the like installed, if any of their utilities help.
ghostcript method: ``` gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf ... ``` from: [How to concatenate PDFs without pain](http://ansuz.sooke.bc.ca/software/pdf-append.php) [ImageMagick](http://www.imagemagick.org/) method: ``` convert file1.pdf file2.pdf ...
434,250
<p>It was hinted in a <a href="https://stackoverflow.com/questions/433525/choosing-asp-net-over-php-or-perl#433610">comment to an answer to this question</a> that PHP can not reverse Unicode strings. </p> <blockquote> <p>As for Unicode, it works in PHP because most apps process it as binary. Yes, PHP is 8-bit cl...
[ { "answer_id": 434251, "author": "OIS", "author_id": 36175, "author_profile": "https://Stackoverflow.com/users/36175", "pm_score": 2, "selected": false, "text": "<p>The answer</p>\n\n<pre><code>function mb_strrev($text, $encoding = null)\n{\n $funcParams = array($text);\n if ($enco...
2009/01/12
[ "https://Stackoverflow.com/questions/434250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36175/" ]
It was hinted in a [comment to an answer to this question](https://stackoverflow.com/questions/433525/choosing-asp-net-over-php-or-perl#433610) that PHP can not reverse Unicode strings. > > As for Unicode, it works in PHP > because most apps process it as > binary. Yes, PHP is 8-bit clean. Try > the equivalent of...
Grapheme functions handle UTF-8 string more correctly than mbstring and PCRE functions/ Mbstring and PCRE may break characters. You can see the defference between them by executing the following code. ``` function str_to_array($string) { $length = grapheme_strlen($string); $ret = []; for ($i = 0; $i < $le...
434,255
<p>Alright so here is the deal. I am trying to make a application that's a GUI application yet has no GUI. So when the application starts, it has a small form with a login screen (I have done this part). </p> <p>This the code for the <code>main()</code> in which the form runs but as soon as it is closed, I dispose of ...
[ { "answer_id": 434262, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 1, "selected": true, "text": "<p>If you want to make the foreground thread wait you can use a WaitHandle.</p>\n\n<p><a href=\"http://msdn.microsoft....
2009/01/12
[ "https://Stackoverflow.com/questions/434255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50312/" ]
Alright so here is the deal. I am trying to make a application that's a GUI application yet has no GUI. So when the application starts, it has a small form with a login screen (I have done this part). This the code for the `main()` in which the form runs but as soon as it is closed, I dispose of it. ``` static void...
If you want to make the foreground thread wait you can use a WaitHandle. <http://msdn.microsoft.com/en-us/library/system.threading.waithandle.aspx>
434,272
<p>Having a weird problem here. Everybody knows that if you use web.config's <code>customErrors</code> section to make a custom error page, that you should set your <code>Response.StatusCode</code> to whatever is appropriate. For example, if I make a custom 404 page and name it 404.aspx, I could put <code>&lt;% Respons...
[ { "answer_id": 434294, "author": "nullnvoid", "author_id": 43475, "author_profile": "https://Stackoverflow.com/users/43475", "pm_score": 0, "selected": false, "text": "<p>By default IIS 7 uses detailed custom error messages so I would assume that Response.StatusCode will equal 404.XX rat...
2009/01/12
[ "https://Stackoverflow.com/questions/434272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22505/" ]
Having a weird problem here. Everybody knows that if you use web.config's `customErrors` section to make a custom error page, that you should set your `Response.StatusCode` to whatever is appropriate. For example, if I make a custom 404 page and name it 404.aspx, I could put `<% Response.StatusCode = 404 %>` in the con...
Set existingResponse to PassThrough in system.webServer/httpErrors section: ``` <system.webServer> <httpErrors existingResponse="PassThrough" /> </system.webServer> ``` Default value of existingResponse property is Auto: > > Auto tells custom error module to do the **right** thing. Actual error text seen ...
434,276
<p>I am building a basic profiler for an open source project. One requirement is to measure execution time of a method. While this is easy enough, I have to do it without knowing the method or its containing class until runtime. The way to invoke the profiler will be when the user will invoke the profiler from the IDE ...
[ { "answer_id": 434320, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 2, "selected": true, "text": "<p>Maybe you need</p>\n\n<pre><code>t.GetType().GetMethod(s)\n</code></pre>\n" }, { "answer_id": 434357, "aut...
2009/01/12
[ "https://Stackoverflow.com/questions/434276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
I am building a basic profiler for an open source project. One requirement is to measure execution time of a method. While this is easy enough, I have to do it without knowing the method or its containing class until runtime. The way to invoke the profiler will be when the user will invoke the profiler from the IDE in ...
Maybe you need ``` t.GetType().GetMethod(s) ```
434,283
<p>I'd like to be able to replace things in a file with a regular expression using the following scheme:</p> <p>I have an array:</p> <pre><code>$data = array( 'title' =&gt; 'My Cool Title', 'content' =&gt; '' ) </code></pre> <p>I also have a template (for clarity's sake, we'll assume the below is assigned to a v...
[ { "answer_id": 434299, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": true, "text": "<p>With a little work before hand you can do it with a single <code>preg_replace</code> call:</p>\n\n<pre><code>$repla...
2009/01/12
[ "https://Stackoverflow.com/questions/434283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
I'd like to be able to replace things in a file with a regular expression using the following scheme: I have an array: ``` $data = array( 'title' => 'My Cool Title', 'content' => '' ) ``` I also have a template (for clarity's sake, we'll assume the below is assigned to a variable *$template*) ``` <html> <title...
With a little work before hand you can do it with a single `preg_replace` call: ``` $replacements = array(); foreach ($data as $search => $replacement) { $replacements["/<% $search %>/"] = $replacement; } $endMarkup = preg_replace( array_keys($replacements), array_values($replacements), $template);...
434,284
<p>I'm interested in using db4o as my persistence mechanism in my Desktop application but I'm concerned about a couple things.</p> <p><strong>1st concern: Accidentally clipping very complex object graphs.</strong> </p> <p>Say I have a tree with a height of 10 and I fetch the root, how does it handle me storing the ro...
[ { "answer_id": 434299, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": true, "text": "<p>With a little work before hand you can do it with a single <code>preg_replace</code> call:</p>\n\n<pre><code>$repla...
2009/01/12
[ "https://Stackoverflow.com/questions/434284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I'm interested in using db4o as my persistence mechanism in my Desktop application but I'm concerned about a couple things. **1st concern: Accidentally clipping very complex object graphs.** Say I have a tree with a height of 10 and I fetch the root, how does it handle me storing the root object again? From my unde...
With a little work before hand you can do it with a single `preg_replace` call: ``` $replacements = array(); foreach ($data as $search => $replacement) { $replacements["/<% $search %>/"] = $replacement; } $endMarkup = preg_replace( array_keys($replacements), array_values($replacements), $template);...
434,286
<p>Is there any terminal command that can be used to achieve this?</p> <p>I know <code>xcodebuild install -configuration</code> can compile our xcodeproj from terminal without launching from Xcode, however the compilation files are under iOS but not in the iPhone simulator. I'm hoping one of you smart-folks can help m...
[ { "answer_id": 487607, "author": "DavidG", "author_id": 25893, "author_profile": "https://Stackoverflow.com/users/25893", "pm_score": 3, "selected": false, "text": "<p>Hey, i found out that you can do it with:</p>\n\n<pre><code>xcodebuild -configuration Release -sdk iphonesimulator2.2\n<...
2009/01/12
[ "https://Stackoverflow.com/questions/434286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there any terminal command that can be used to achieve this? I know `xcodebuild install -configuration` can compile our xcodeproj from terminal without launching from Xcode, however the compilation files are under iOS but not in the iPhone simulator. I'm hoping one of you smart-folks can help me out.
Hey, i found out that you can do it with: ``` xcodebuild -configuration Release -sdk iphonesimulator2.2 ``` This makes a simulator build with version 2.2 ( you can use `xcodebuild -showsdks` to list what u have avail ). I'm stuck with a problem of trying to get it to launch on the phone. xcodebuild -install doesn't ...
434,287
<p>I have a Python script which takes as input a list of integers, which I need to work with four integers at a time. Unfortunately, I don't have control of the input, or I'd have it passed in as a list of four-element tuples. Currently, I'm iterating over it this way:</p> <pre><code>for i in range(0, len(ints), 4): ...
[ { "answer_id": 434303, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": -1, "selected": false, "text": "<p>There doesn't seem to be a pretty way to do this. <a href=\"http://code.activestate.com/recipes/425397/\" rel=\...
2009/01/12
[ "https://Stackoverflow.com/questions/434287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46387/" ]
I have a Python script which takes as input a list of integers, which I need to work with four integers at a time. Unfortunately, I don't have control of the input, or I'd have it passed in as a list of four-element tuples. Currently, I'm iterating over it this way: ``` for i in range(0, len(ints), 4): # dummy op ...
Modified from the [Recipes](https://docs.python.org/library/itertools.html#itertools-recipes) section of Python's [`itertools`](http://docs.python.org/library/itertools.html) docs: ``` from itertools import zip_longest def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return zip_longest(*a...
434,289
<p><strong>rowCount</strong> returns 0 when query.SetFirstResult is different from 0 ?</p> <p>if the result of pageIndex x pageSize = 0 // it gives me the rowCount but when it is not equal to 0, countCriteria gives me 0 instead of rowCount.</p> <p>What can i do ?</p> <p>Thanks in advance</p>
[ { "answer_id": 434303, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": -1, "selected": false, "text": "<p>There doesn't seem to be a pretty way to do this. <a href=\"http://code.activestate.com/recipes/425397/\" rel=\...
2009/01/12
[ "https://Stackoverflow.com/questions/434289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51734/" ]
**rowCount** returns 0 when query.SetFirstResult is different from 0 ? if the result of pageIndex x pageSize = 0 // it gives me the rowCount but when it is not equal to 0, countCriteria gives me 0 instead of rowCount. What can i do ? Thanks in advance
Modified from the [Recipes](https://docs.python.org/library/itertools.html#itertools-recipes) section of Python's [`itertools`](http://docs.python.org/library/itertools.html) docs: ``` from itertools import zip_longest def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return zip_longest(*a...
434,336
<p>I'm using <a href="http://www.projectatomic.com/2008/04/jquery-flickr/" rel="nofollow noreferrer">jquery.flickr-1.0.js</a> to search flickr for images in my application. The problem i'm facing is that sometimes it takes a few seconds for flickr to respond with results and i want to load a spinning gif in place of m...
[ { "answer_id": 434351, "author": "tsimon", "author_id": 1685, "author_profile": "https://Stackoverflow.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>I'm not familiar with the flickr() method you reference above, but generally the approach to these sorts of things is that...
2009/01/12
[ "https://Stackoverflow.com/questions/434336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48973/" ]
I'm using [jquery.flickr-1.0.js](http://www.projectatomic.com/2008/04/jquery-flickr/) to search flickr for images in my application. The problem i'm facing is that sometimes it takes a few seconds for flickr to respond with results and i want to load a spinning gif in place of my search button 'btnRefresh' until the r...
the flickr plugin supports a callback property in its options. So, you could just display the spinner before calling flickr and then in the callback hide it. ``` jQuery(function(){ jQuery(".btnRefresh").livequery('click', function(){ $("#spinner").show(); var number = $(this).attr("id"); ...
434,353
<p>Given two dictionaries, <code>d1</code> and <code>d2</code>, and an integer <code>l</code>, I want to find all keys <code>k</code> in <code>d1</code> such that either <code>d2[k]&lt;l</code> or <code>k not in l</code>. I want to output the keys and the corresponding values in <code>d2</code>, except if <code>d2</cod...
[ { "answer_id": 434378, "author": "daniel", "author_id": 19741, "author_profile": "https://Stackoverflow.com/users/19741", "pm_score": 2, "selected": false, "text": "<p>You can simplify this by using a defaultdict. Calling __getitem__ on a defaultdict will return the \"default\" value.</p...
2009/01/12
[ "https://Stackoverflow.com/questions/434353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44511/" ]
Given two dictionaries, `d1` and `d2`, and an integer `l`, I want to find all keys `k` in `d1` such that either `d2[k]<l` or `k not in l`. I want to output the keys and the corresponding values in `d2`, except if `d2` does not contain the key, I want to print 0. For instance, if `d1` is ``` a: 1 b: 1 c: 1 d: 1 ``` ...
Yours is actually fine -- you could simplify it to ``` for k in d1: if d2.get(k, 0) < l: print k, d2.get(k, 0) ``` which is (to me) pythonic, and is pretty much a direct "translation" into code of your description. If you want to avoid the double lookup, you could do ``` for k in d1: val = d2.get(k,...
434,359
<p>I've been doing a project at work recently focused on an almost entirely client-driven web site. Obviously Javascript is used heavily, and I've been using jQuery on top of it which has turned out to be an absolute pleasure to work with.</p> <p>One of the things that has surprised me in this is how much I like the ...
[ { "answer_id": 434365, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>C# 3.0 has something similar in that you can both instantiate an object using a default constructor and assign prope...
2009/01/12
[ "https://Stackoverflow.com/questions/434359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25968/" ]
I've been doing a project at work recently focused on an almost entirely client-driven web site. Obviously Javascript is used heavily, and I've been using jQuery on top of it which has turned out to be an absolute pleasure to work with. One of the things that has surprised me in this is how much I like the JSON object...
The canonical example is Lisp: in Lisp, the language isn't even defined in terms of text, it is defined in terms of data structures. There really is not difference between code and data: code is just a list whose first element is interpreted as an operation and the rest as operands. Writing a program is just writing l...
434,367
<p>I have this code below and the "if ((DateTime)DataReader[0] > DateTime.Now)" condition returns false even if the datetime in the database is greater than the datetimenow.</p> <p>I used this code before and it use to work I never changed any thing.</p> <p>So the question is why does the condition return false?</p> ...
[ { "answer_id": 434371, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 1, "selected": false, "text": "<p>I would suggest having a variable &amp; using that to compare it with DateTime.Now</p>\n\n<pre>\n<code>\nwhile (Dat...
2009/01/12
[ "https://Stackoverflow.com/questions/434367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have this code below and the "if ((DateTime)DataReader[0] > DateTime.Now)" condition returns false even if the datetime in the database is greater than the datetimenow. I used this code before and it use to work I never changed any thing. So the question is why does the condition return false? Thanks, Simon ``` ...
This is the actual answer: You do not need/have/should to compare DateTime with >, <, == or != operators. Instead you can use the Compare and CompareTo methods of the DateTime class. [Compare](http://msdn.microsoft.com/en-us/library/system.datetime.compare.aspx): Compares two instances of DateTime and returns an inte...
434,374
<p>Alright, <a href="http://sqlzoo.net/1a.htm" rel="nofollow noreferrer">this one</a> (3a; sample problem with provided answer) has got me scratching my head:</p> <blockquote> <p><strong>bbc(name, region, area, population, gdp)</strong><br> <em>3a. Find the largest country in each region:</em></p> </blockquote> <...
[ { "answer_id": 434397, "author": "hhafez", "author_id": 42303, "author_profile": "https://Stackoverflow.com/users/42303", "pm_score": 6, "selected": true, "text": "<p>Have you considered using <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#nanoTime()\" rel=\"nore...
2009/01/12
[ "https://Stackoverflow.com/questions/434374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19825/" ]
Alright, [this one](http://sqlzoo.net/1a.htm) (3a; sample problem with provided answer) has got me scratching my head: > > **bbc(name, region, area, population, gdp)** > > *3a. Find the largest country in each region:* > > > ``` SELECT region, name, population FROM bbc x WHERE population >= ALL (SELECT ...
Have you considered using [System.nanoTime()](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#nanoTime())? It is only meaningful in working out elapsed time between two events. Since the documentation states that it is not related to any system or wall time I believe it could be used in your sitatuion.
434,379
<p>If I have a text field with SWT, how can I get the field to fill to 100% or some specified width.</p> <p>For example, this text field will only reach for so much horizontally.</p> <pre><code>public class Tmp { public static void main (String [] args) { Display display = new Display (); Shell sh...
[ { "answer_id": 434380, "author": "alxp", "author_id": 19513, "author_profile": "https://Stackoverflow.com/users/19513", "pm_score": 2, "selected": false, "text": "<p>Most sites don't change the slug for the reason that if a user edits her title it shouldn't break any links to the post th...
2009/01/12
[ "https://Stackoverflow.com/questions/434379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
If I have a text field with SWT, how can I get the field to fill to 100% or some specified width. For example, this text field will only reach for so much horizontally. ``` public class Tmp { public static void main (String [] args) { Display display = new Display (); Shell shell = new Shell (disp...
I kinda like the way stackoverflow does it. Which is to put *both* the ID and the slug into the url. Now the slug no longer has to be unique. I believe hulu.com does it this way as well. I think it's a practical solution to the problem.
434,414
<p>What is the most evil or dangerous code fragment you have ever seen in a production environment at a company? I've never encountered production code that I would consider to be deliberately malicious and evil, so I'm quite curious to see what others have found.</p> <p>The most dangerous code I have ever seen was a...
[ { "answer_id": 434418, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 5, "selected": false, "text": "<p>The Windows installer.</p>\n" }, { "answer_id": 434422, "author": "MOZILLA", "author_id": 38997,...
2009/01/12
[ "https://Stackoverflow.com/questions/434414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38332/" ]
What is the most evil or dangerous code fragment you have ever seen in a production environment at a company? I've never encountered production code that I would consider to be deliberately malicious and evil, so I'm quite curious to see what others have found. The most dangerous code I have ever seen was a stored pro...
**Warning: Long scary post ahead** I've written about one application I've worked on before [here](https://stackoverflow.com/questions/193982/what-is-your-best-funniest-annoying-performance-tuning-experience#384225) and [here](https://stackoverflow.com/questions/417279/double-reversals-on-technology-decisions#417743)...
434,469
<p>How can I clear current session data (cookies, cached data, auth sessions, etc) without restarting the application?</p> <p>Update: I'm talking about WebBrowser control in Windows.Forms, not the ASP.Net session.</p>
[ { "answer_id": 612849, "author": "Ilya Tchivilev", "author_id": 15029, "author_profile": "https://Stackoverflow.com/users/15029", "pm_score": 0, "selected": false, "text": "<p>You have to realise that the way \"session state\" is tracked, from the point of view of a web server, is by giv...
2009/01/12
[ "https://Stackoverflow.com/questions/434469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54045/" ]
How can I clear current session data (cookies, cached data, auth sessions, etc) without restarting the application? Update: I'm talking about WebBrowser control in Windows.Forms, not the ASP.Net session.
To clear session (such as HttpOnly cookies), you can use InternetSetOption() from wininet.dll. ``` private const int INTERNET_OPTION_END_BROWSER_SESSION = 42; [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLen...
434,480
<p>Is it possible to pass parts of a linq Query into a function? I want create a common interface for my DAL that always uses the same query interface. For example, </p> <pre><code>List&lt;T&gt; Get(Join j, Where w, Select s){ return currentDataContext&lt;T&gt;.Join(j).Where(w).Select(s).ToList(); } </c...
[ { "answer_id": 434532, "author": "Abram Simon", "author_id": 46204, "author_profile": "https://Stackoverflow.com/users/46204", "pm_score": 0, "selected": false, "text": "<p>You could use <a href=\"http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynami...
2009/01/12
[ "https://Stackoverflow.com/questions/434480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16628/" ]
Is it possible to pass parts of a linq Query into a function? I want create a common interface for my DAL that always uses the same query interface. For example, ``` List<T> Get(Join j, Where w, Select s){ return currentDataContext<T>.Join(j).Where(w).Select(s).ToList(); } ``` Is this sort of thing pos...
Well, the "join" is tricky, because it is very hard to express a join - but things like where / select / orderby are pretty easy... Really, it is just a case of combining the various LINQ methods on `IQueryable<T>`, which generally accept `Expression<Func<...>>` for some combination. So a basic select with an optional...
434,522
<p>I have the below code in stdafx.h.</p> <pre><code>using namespace std; typedef struct { DWORD address; DWORD size; char file[64]; DWORD line; } ALLOC_INFO; typedef list&lt;ALLOC_INFO*&gt; AllocList; //AllocList *allocList; </code></pre> <p>Without the commented code (last line), it compi...
[ { "answer_id": 434529, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "<p>Don't put <em>definitions</em> in header files, just <em>declarations</em>. Declarations specify that something exists...
2009/01/12
[ "https://Stackoverflow.com/questions/434522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15152/" ]
I have the below code in stdafx.h. ``` using namespace std; typedef struct { DWORD address; DWORD size; char file[64]; DWORD line; } ALLOC_INFO; typedef list<ALLOC_INFO*> AllocList; //AllocList *allocList; ``` Without the commented code (last line), it compiles just fine. But when I add th...
Don't put *definitions* in header files, just *declarations*. Declarations specify that something exists while definitions actually define them (by allocating space). For example `typedef`, `extern` and function prototypes are all declarations, while things like `struct`, `int` and function bodies are definitions. Wha...
434,546
<p>I have the option of writing two different formats for a database structure:</p> <pre><code>Article ------- ArticleID int FK Article_Tags ------------ ArticleTagID int FK ArticleID int FK TagText varchar(50) </code></pre> <p>or</p> <pre><code>Article ------- ArticleID int PK Article_Tags ------------ ArticleTag...
[ { "answer_id": 434551, "author": "nullnvoid", "author_id": 43475, "author_profile": "https://Stackoverflow.com/users/43475", "pm_score": 1, "selected": false, "text": "<p>Option 2 with some modifications. Assuming you're limiting input to the values contained in the tag table you're the...
2009/01/12
[ "https://Stackoverflow.com/questions/434546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26/" ]
I have the option of writing two different formats for a database structure: ``` Article ------- ArticleID int FK Article_Tags ------------ ArticleTagID int FK ArticleID int FK TagText varchar(50) ``` or ``` Article ------- ArticleID int PK Article_Tags ------------ ArticleTagID int PK ArticleID int FK TagText va...
I would go with ``` Article ------- ArticleID int PK Article_Tags ------------ ArticleTagID int PK ArticleID int FK TagId int FK Tag --- TagId int identity(1,1) PK TagText varchar(50) ``` There really is no reason to denormalize this from get go. (your first and second versions are not normalized) Having tags ...
434,548
<p>What would be a better approach to compare two floating point values - using Epsilon or a Big Decimal comparison with scaling?</p> <p>For instance, your data would range from 0.00 - 49,999.99?</p>
[ { "answer_id": 434551, "author": "nullnvoid", "author_id": 43475, "author_profile": "https://Stackoverflow.com/users/43475", "pm_score": 1, "selected": false, "text": "<p>Option 2 with some modifications. Assuming you're limiting input to the values contained in the tag table you're the...
2009/01/12
[ "https://Stackoverflow.com/questions/434548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37740/" ]
What would be a better approach to compare two floating point values - using Epsilon or a Big Decimal comparison with scaling? For instance, your data would range from 0.00 - 49,999.99?
I would go with ``` Article ------- ArticleID int PK Article_Tags ------------ ArticleTagID int PK ArticleID int FK TagId int FK Tag --- TagId int identity(1,1) PK TagText varchar(50) ``` There really is no reason to denormalize this from get go. (your first and second versions are not normalized) Having tags ...
434,571
<p>I have a query :</p> <blockquote> <pre><code>select score, count(1) as 'NumStudents' from testresults where testid = 'mytestid' group by score order by score </code></pre> </blockquote> <p>where testresults table contains the performances of students in a test. A sample result looks like the following, assuming ma...
[ { "answer_id": 434577, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 1, "selected": false, "text": "<p>The most obvious way would be to create a table named \"Scores\" and left outer join your table to it.</p>\n\n<p>SELECT ...
2009/01/12
[ "https://Stackoverflow.com/questions/434571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
I have a query : > > > ``` > select score, count(1) as 'NumStudents' from testresults where testid = 'mytestid' > group by score order by score > > ``` > > where testresults table contains the performances of students in a test. A sample result looks like the following, assuming maximum marks of the test is 10. ...
SQL is good at working with sets of data values in the database, but not so good at sets of data values that are *not* in the database. The best workaround is to keep one small table for the values you need to range over: ``` CREATE TABLE ScoreValues (score int); INSERT INTO ScoreValues (score) VALUES (0), (1), (2...
434,581
<p>I am having the sample code like this.</p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author padmaja */ import java.io.*; class Test{ public static void main(String arg[]){ try{ String command = "cmd /C start C:/excel.bat"...
[ { "answer_id": 434606, "author": "Rahul", "author_id": 24424, "author_profile": "https://Stackoverflow.com/users/24424", "pm_score": 0, "selected": false, "text": "<p>One option is to use taskkill command (<a href=\"http://technet.microsoft.com/en-us/library/bb491009.aspx\" rel=\"nofollo...
2009/01/12
[ "https://Stackoverflow.com/questions/434581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am having the sample code like this. ``` /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author padmaja */ import java.io.*; class Test{ public static void main(String arg[]){ try{ String command = "cmd /C start C:/excel.bat"; Runtim...
Once the Excel sheet is opened, the end-user will interact with it, right? How will you know it is ok to close it? If you are only starting Excel for some macros that run on load, you might be able to exit in that macro itself.
434,583
<p>I wish to draw an image based on computed pixel values, as a means to visualize some data. Essentially, I wish to take a 2-dimensional matrix of color triplets and render it. </p> <p>Do note that this is not image processing, since I'm not transforming an existing image nor doing any sort of whole-image transformat...
[ { "answer_id": 434801, "author": "Mapad", "author_id": 28165, "author_profile": "https://Stackoverflow.com/users/28165", "pm_score": 1, "selected": false, "text": "<p>I think you use PIL to generate an image file on the disk, and you later load it with an image reader software.</p>\n\n<p...
2009/01/12
[ "https://Stackoverflow.com/questions/434583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37984/" ]
I wish to draw an image based on computed pixel values, as a means to visualize some data. Essentially, I wish to take a 2-dimensional matrix of color triplets and render it. Do note that this is not image processing, since I'm not transforming an existing image nor doing any sort of whole-image transformations, and ...
If you have `numpy` and `scipy` available (and if you are manipulating large arrays in Python, I would recommend them), then the [`scipy.misc.pilutil.toimage`](https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.toimage.html) function is very handy. A simple example: ``` import numpy as np import scipy.mis...
434,585
<p>I have a CMS with a WYSIWYG editor which produces pretty good xhtml. Based on this fact, I think a HTML parser might be slightly overkill for this small job.</p> <p>I am intending to use regular expressions but so far have been unable to get mine to match what I'm after.</p> <p>I'm using PHP5.</p> <p>I need to ma...
[ { "answer_id": 434590, "author": "alex", "author_id": 31671, "author_profile": "https://Stackoverflow.com/users/31671", "pm_score": 0, "selected": false, "text": "<p>I think I just figured it out</p>\n\n<pre><code>preg_match_all('/&lt;(p|ul|ol)&gt;(.*)&lt;\\/(p|ul|ol)&gt;/iU', $content, ...
2009/01/12
[ "https://Stackoverflow.com/questions/434585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
I have a CMS with a WYSIWYG editor which produces pretty good xhtml. Based on this fact, I think a HTML parser might be slightly overkill for this small job. I am intending to use regular expressions but so far have been unable to get mine to match what I'm after. I'm using PHP5. I need to match the content of the 3...
This should work as long as you don't have nested p/ul/ol tags: ``` preg_match_all("<(?:p|ul|ol)>(.*?)</(?:p|ul|ol)>", $string, $matches) ``` `?:` prevents anything in the parens from being included in `$matches` and `.*?` prevents the regex from matching past the end of another tag.
434,597
<p>I need to be able to open a document using its default application in Windows and Mac OS. Basically, I want to do the same thing that happens when you double-click on the document icon in Explorer or Finder. What is the best way to do this in Python?</p>
[ { "answer_id": 434612, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 8, "selected": true, "text": "<p><code>open</code> and <code>start</code> are command-interpreter things for Mac OS/X and Windows respectively, to...
2009/01/12
[ "https://Stackoverflow.com/questions/434597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
I need to be able to open a document using its default application in Windows and Mac OS. Basically, I want to do the same thing that happens when you double-click on the document icon in Explorer or Finder. What is the best way to do this in Python?
`open` and `start` are command-interpreter things for Mac OS/X and Windows respectively, to do this. To call them from Python, you can either use `subprocess` module or `os.system()`. Here are considerations on which package to use: 1. You can call them via `os.system`, which works, but... **Escaping:** `os.system...
434,599
<p>Imagine this function:</p> <pre><code>void SoundManager::playSource(ALuint sourceID, float offset) { alSourceStop(sourceID); ALint iTotal = 0; ALint iCurrent = 0; ALint uiBuffer = 0; alGetSourcei(sourceID, AL_BUFFER, &amp;uiBuffer); alGetBufferi(uiBuffer, AL_SIZE, &amp;iTotal); iCurrent...
[ { "answer_id": 434677, "author": "mcccclean", "author_id": 49697, "author_profile": "https://Stackoverflow.com/users/49697", "pm_score": 4, "selected": true, "text": "<p>Solved!</p>\n\n<p>Even though the API claims that setting the offsets works on sources in any state, the problem was I...
2009/01/12
[ "https://Stackoverflow.com/questions/434599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49697/" ]
Imagine this function: ``` void SoundManager::playSource(ALuint sourceID, float offset) { alSourceStop(sourceID); ALint iTotal = 0; ALint iCurrent = 0; ALint uiBuffer = 0; alGetSourcei(sourceID, AL_BUFFER, &uiBuffer); alGetBufferi(uiBuffer, AL_SIZE, &iTotal); iCurrent = iTotal * offset; ...
Solved! Even though the API claims that setting the offsets works on sources in any state, the problem was I should have been calling `alSourceRewind` instead of `alSourceStop` at the start. It seems setting offsets only works on sources in the `AL_INITIAL` state.
434,604
<p>I need to do something like this:</p> <pre><code>&lt;script type="text/javascript"&gt; token_url = "http://example.com/your_token_url"; &lt;/script&gt; </code></pre> <p>I'm using the Beta version of MVC, but I can't figure out how to get the absolute url of an action. I'd like to do something like this:</p> <...
[ { "answer_id": 435008, "author": "Charlino", "author_id": 10202, "author_profile": "https://Stackoverflow.com/users/10202", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if there is a built in way to do it, but you could roll your own HtmlHelper method.</p>\n\n<p>Something l...
2009/01/12
[ "https://Stackoverflow.com/questions/434604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16872/" ]
I need to do something like this: ``` <script type="text/javascript"> token_url = "http://example.com/your_token_url"; </script> ``` I'm using the Beta version of MVC, but I can't figure out how to get the absolute url of an action. I'd like to do something like this: ``` <%= Url.AbsoluteAction("Action","Contro...
Click [here](http://www.captaincodeman.com/2010/02/03/absolute-urls-using-mvc-without-extension-methods/) for more information, but esentially there is no need for extension methods. It's already baked in, just not in a very intuitive way. ``` Url.Action("Action", null, null, Request.Url.Scheme); ```
434,608
<p>I am having trouble setting up passive FTP on IIS 6. I used this instruction: <a href="http://www.velikan.net/iis-passive-ftp/" rel="nofollow noreferrer">http://www.velikan.net/iis-passive-ftp/</a></p> <p>When I tried to upload a file through the FTP, I got the error: </p> <pre><code>425 Can't open data connection...
[ { "answer_id": 435008, "author": "Charlino", "author_id": 10202, "author_profile": "https://Stackoverflow.com/users/10202", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if there is a built in way to do it, but you could roll your own HtmlHelper method.</p>\n\n<p>Something l...
2009/01/12
[ "https://Stackoverflow.com/questions/434608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20067/" ]
I am having trouble setting up passive FTP on IIS 6. I used this instruction: <http://www.velikan.net/iis-passive-ftp/> When I tried to upload a file through the FTP, I got the error: ``` 425 Can't open data connection. : /index.html ``` The interesting thing is that from the server, I can see the index.html file ...
Click [here](http://www.captaincodeman.com/2010/02/03/absolute-urls-using-mvc-without-extension-methods/) for more information, but esentially there is no need for extension methods. It's already baked in, just not in a very intuitive way. ``` Url.Action("Action", null, null, Request.Url.Scheme); ```
434,620
<p>I have this class called Table:</p> <pre><code>class Table { public string Name { get { return this.wrapper.Eval(//some command); //wrapper is pass in by the ctor and is a COM object. } } } </code></pre> <p>which is used in this class:</p> <pre><code>cl...
[ { "answer_id": 434646, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 2, "selected": true, "text": "<p>Beyond the fact that there is usually no <em>one</em> perfect testing solution, I'd first go for mocking the COM obj...
2009/01/12
[ "https://Stackoverflow.com/questions/434620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I have this class called Table: ``` class Table { public string Name { get { return this.wrapper.Eval(//some command); //wrapper is pass in by the ctor and is a COM object. } } } ``` which is used in this class: ``` class Map { public Map MapTable(Table...
Beyond the fact that there is usually no *one* perfect testing solution, I'd first go for mocking the COM object: there should be a interface available and you'll probably want to test everything "above" it. If the `Table` contains non-trivial code (e.g. within the `Eval()`; anything with conditionals; or e.g. parsing...
434,626
<p>We have a C# application that connects to a FTP server, downloads some files, disconnects, and after a certain amount of time (selected by the user through the UI) reconnects and repeats the process. We implemented this using BackgroundWorker, but we noticed that after running for a longer time, the program stopped ...
[ { "answer_id": 434712, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 4, "selected": true, "text": "<p>If I'm understanding you correctly this <code>while(!stopped)</code> loop is the loop that is running for several...
2009/01/12
[ "https://Stackoverflow.com/questions/434626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54068/" ]
We have a C# application that connects to a FTP server, downloads some files, disconnects, and after a certain amount of time (selected by the user through the UI) reconnects and repeats the process. We implemented this using BackgroundWorker, but we noticed that after running for a longer time, the program stopped log...
If I'm understanding you correctly this `while(!stopped)` loop is the loop that is running for several hours? If that is the case, where are you terminating your ftp connection if anywhere? The only time you close it in the code you've posted is if an exception is thrown, otherwise you simply dereference the object and...
434,631
<p>Does any one know how to make a file upload control in javascript. For example, one using a texbox and a button.</p> <hr> <p><strong>Dupe of</strong> <a href="https://stackoverflow.com/questions/408735/javascript-file-uploads">Javascript file uploads</a></p>
[ { "answer_id": 434637, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 2, "selected": false, "text": "<p>Plain HTML:</p>\n\n<pre><code>&lt;input type=\"file\" /&gt;\n</code></pre>\n\n<p>To programmatically create one using javas...
2009/01/12
[ "https://Stackoverflow.com/questions/434631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51109/" ]
Does any one know how to make a file upload control in javascript. For example, one using a texbox and a button. --- **Dupe of** [Javascript file uploads](https://stackoverflow.com/questions/408735/javascript-file-uploads)
Plain HTML: ``` <input type="file" /> ``` To programmatically create one using javascript: ``` var el = document.createElement('input'); el.type = 'file'; document.body.appendChild(el); ```
434,636
<p>I have a console application written in Delphi. I saw that I can have global variables by assigning them to unit scopes, but in a console application I don't use units (from what I've understood it's forms-only).</p>
[ { "answer_id": 434645, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 5, "selected": true, "text": "<p>Nope, a unit is not equivalent to a form.</p>\n\n<p>A unit is a module which contains part of your program. Each fo...
2009/01/12
[ "https://Stackoverflow.com/questions/434636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25316/" ]
I have a console application written in Delphi. I saw that I can have global variables by assigning them to unit scopes, but in a console application I don't use units (from what I've understood it's forms-only).
Nope, a unit is not equivalent to a form. A unit is a module which contains part of your program. Each form is a separate unit but a unit does not have to contain a form. Each unit has an interface section and a implementation section. The declarations in the interface section are visible to all units that use the un...
434,641
<p>When I extract files from a ZIP file created with the Python <a href="http://docs.python.org/library/zipfile.html" rel="noreferrer"><code>zipfile</code></a> module, all the files are not writable, read only etc.</p> <p>The file is being created and extracted under Linux and Python 2.5.2.</p> <p>As best I can tell,...
[ { "answer_id": 434651, "author": "Evan Fosmark", "author_id": 49701, "author_profile": "https://Stackoverflow.com/users/49701", "pm_score": 4, "selected": false, "text": "<p>Look at this: <a href=\"https://stackoverflow.com/questions/279945/set-permissions-on-a-compressed-file-in-python\...
2009/01/12
[ "https://Stackoverflow.com/questions/434641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
When I extract files from a ZIP file created with the Python [`zipfile`](http://docs.python.org/library/zipfile.html) module, all the files are not writable, read only etc. The file is being created and extracted under Linux and Python 2.5.2. As best I can tell, I need to set the `ZipInfo.external_attr` property for ...
This seems to work (thanks Evan, putting it here so the line is in context): ``` buffer = "path/filename.zip" # zip filename to write (or file-like object) name = "folder/data.txt" # name of file inside zip bytes = "blah blah blah" # contents of file inside zip zip = zipfile.ZipFile(buffer, "w", zipfile.Z...
434,657
<p>Do we need to be careful when comparing a double value against zero?</p> <pre><code>if ( someAmount &lt;= 0){ ..... } </code></pre>
[ { "answer_id": 434698, "author": "WiseTechi", "author_id": 52374, "author_profile": "https://Stackoverflow.com/users/52374", "pm_score": 3, "selected": false, "text": "<p>Depending on how your <code>someAmount</code> is computed, you may expect some odd behaviour with float/doubles</p>\n...
2009/01/12
[ "https://Stackoverflow.com/questions/434657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Do we need to be careful when comparing a double value against zero? ``` if ( someAmount <= 0){ ..... } ```
If you want to be really careful you can test whether it is within some epsilon of zero with something like ``` double epsilon = 0.0000001; if ( f <= ( 0 - epsilon ) ) { .. } else if ( f >= ( 0 + epsilon ) ) { .. } else { /* f "equals" zero */ } ``` Or you can simply round your doubles to some specified precis...
434,664
<p>I have an application that runs as a collection of OSGi bundles. I start it using a very small wrapper that embeds the Felix framework. The necessity of that wrapper irks me a little, as does the fact that it depends on Felix (whereas the application itself could run just as well in, say, Equinox), so I want to get ...
[ { "answer_id": 457819, "author": "jassuncao", "author_id": 1009, "author_profile": "https://Stackoverflow.com/users/1009", "pm_score": 1, "selected": false, "text": "<p>Probably not. I think the standard Felix launcher does some command line validation and only accepts the bundle cache d...
2009/01/12
[ "https://Stackoverflow.com/questions/434664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
I have an application that runs as a collection of OSGi bundles. I start it using a very small wrapper that embeds the Felix framework. The necessity of that wrapper irks me a little, as does the fact that it depends on Felix (whereas the application itself could run just as well in, say, Equinox), so I want to get rid...
If you use bnd(tools) you can use its launcher. It registers the command line arguments as a service property 'launcher.arguments'. This works extremely well when you combine it with the bnd package command. This command takes a bnd project or a bndrun file describing the running environment (bundles, properties, fram...
434,688
<p>How can I detect and remove a USB flash disk programatically using delphi?</p> <p>I have seen some of the examples in this website, but they lack clear explanation on how to go about it!</p> <p>Please examples will really help!</p>
[ { "answer_id": 435075, "author": "mghie", "author_id": 30568, "author_profile": "https://Stackoverflow.com/users/30568", "pm_score": 3, "selected": false, "text": "<p>This is a quick and dirty translation of <a href=\"http://support.microsoft.com/default.aspx?scid=kb;en-us;165721\" rel=\...
2009/01/12
[ "https://Stackoverflow.com/questions/434688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20894/" ]
How can I detect and remove a USB flash disk programatically using delphi? I have seen some of the examples in this website, but they lack clear explanation on how to go about it! Please examples will really help!
This is a quick and dirty translation of [this sample code](http://support.microsoft.com/default.aspx?scid=kb;en-us;165721) to remove a drive, from support.microsoft.com. It does however work only for users with admin permissions on my system. For more information on working with USB devices in general follow the link...
434,694
<p>I have this code:</p> <pre><code>var $msg = jQuery('&lt;div&gt;&lt;/div&gt;') .hide() .appendTo(document.body) ; if ($msg.is(":hidden")) { console.log("hidden"); } else { console.log("visible"); } </code></pre> <p>When run, it logs <code>"hidden"</code> on Firefox, but <code>"visible"</code> on Goo...
[ { "answer_id": 434696, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 3, "selected": true, "text": "<p>Have you tried hiding after appending it to body?</p>\n\n<pre><code>$(function() {\n var $msg = jQuery('&lt;div&g...
2009/01/12
[ "https://Stackoverflow.com/questions/434694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have this code: ``` var $msg = jQuery('<div></div>') .hide() .appendTo(document.body) ; if ($msg.is(":hidden")) { console.log("hidden"); } else { console.log("visible"); } ``` When run, it logs `"hidden"` on Firefox, but `"visible"` on Google Chrome. Is this a bug, or am I doing something wrong?
Have you tried hiding after appending it to body? ``` $(function() { var $msg = jQuery('<div>hello</div>').appendTo(document.body).hide(); if ($msg.is(":hidden")) { console.log("hidden"); } else { console.log("visible"); } }); // $() ``` worked for me on both browsers.
434,700
<p>By default when Django runs against sqlite backend it creates a new in memory database for a test. That means for every class that derives from unittest.TestCase, I get a new database. Can this be changed so that it is cleared before every test method is run?</p> <p>Example: I am testing a manager class that provid...
[ { "answer_id": 435087, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 0, "selected": false, "text": "<p>Why not do the following? This accomplishes what you need without a significant change to your code.</p>\n\n<pre><code>...
2009/01/12
[ "https://Stackoverflow.com/questions/434700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3105/" ]
By default when Django runs against sqlite backend it creates a new in memory database for a test. That means for every class that derives from unittest.TestCase, I get a new database. Can this be changed so that it is cleared before every test method is run? Example: I am testing a manager class that provides additio...
Use `django.test.TestCase` not `unittest.TestCase`. And it works in all major versions of Django!
434,702
<p>I'm porting an existing (mostly) cross-platform application to WinCE 4.2. The current entry point for the function is </p> <pre><code>int main(int argc, char *argv[]){} </code></pre> <p>I would like to keep this part as-is, and have the WinCE entry point simply call it. I believe something like the following sho...
[ { "answer_id": 434716, "author": "Kevin Loney", "author_id": 13834, "author_profile": "https://Stackoverflow.com/users/13834", "pm_score": 2, "selected": false, "text": "<p>Your general idea is correct however your conversion of lpCmdLine is likely to cause you some issues. Consider the ...
2009/01/12
[ "https://Stackoverflow.com/questions/434702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34910/" ]
I'm porting an existing (mostly) cross-platform application to WinCE 4.2. The current entry point for the function is ``` int main(int argc, char *argv[]){} ``` I would like to keep this part as-is, and have the WinCE entry point simply call it. I believe something like the following should work: ``` int WINAPI Wi...
Thank you both for your helpful answers. I wrote the following, which works as well as we need it for now. Only our code will be calling this executable, and never with quotes, although that wouldn't be too hard to add. Also, it might not do well if there is more than one space between arguments, but again, we don't ha...
434,715
<p>I am using the following method for reading Csv file content:</p> <pre><code> /// &lt;summary&gt; /// Reads data from a CSV file to a datatable /// &lt;/summary&gt; /// &lt;param name="filePath"&gt;Path to the CSV file&lt;/param&gt; /// &lt;returns&gt;Datatable filled with data read from the CSV ...
[ { "answer_id": 434719, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>Well, a very good and well-used streaming CSV reader <a href=\"http://www.codeproject.com/KB/database/CsvReader.as...
2009/01/12
[ "https://Stackoverflow.com/questions/434715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18631/" ]
I am using the following method for reading Csv file content: ``` /// <summary> /// Reads data from a CSV file to a datatable /// </summary> /// <param name="filePath">Path to the CSV file</param> /// <returns>Datatable filled with data read from the CSV file</returns> public DataTable ReadCsv(...
Try using `CharacterSet=UNICODE` in your schema.ini file. Although this is not [documented on MSDN](http://msdn.microsoft.com/en-us/library/ms709353.aspx) it works according to this [thread on Microsoft Forums](http://social.microsoft.com/Forums/en-US/vblanguage/thread/0ab1db1a-bfc4-48b6-b31e-33242abf18b2).
434,718
<p>How do I programmatically determine the availability of a port in a given machine using Java?</p> <p>i.e given a port number, determine whether it is already being used or not?.</p>
[ { "answer_id": 434731, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 5, "selected": false, "text": "<p>If you're not too concerned with performance, you could always try listening on a port using the <a href=\"http:...
2009/01/12
[ "https://Stackoverflow.com/questions/434718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54075/" ]
How do I programmatically determine the availability of a port in a given machine using Java? i.e given a port number, determine whether it is already being used or not?.
This is the [implementation](http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinder.java?view=markup#l130) coming from the Apache [camel](http://camel.apache.org/) project: ``` /** * Checks to see if a specific port is available. * * @param port the po...
434,724
<p>I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL.</p> <p>There will be some classes, which will be used through out the application. There will be some scripts which will use those classes.</p> <p>Any good article, tutorial, architecture on how to organize files for a web site?</p> ...
[ { "answer_id": 434752, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 1, "selected": false, "text": "<p>Here are two good articles on PHP projects using Smarty and how to setup the file structure for them:</p>\n\n<p><a...
2009/01/12
[ "https://Stackoverflow.com/questions/434724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48625/" ]
I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL. There will be some classes, which will be used through out the application. There will be some scripts which will use those classes. Any good article, tutorial, architecture on how to organize files for a web site? P.S. It should contai...
Just remember PHP libraries and template files should not be directly accessible over the web server. You can make class names like My\_Db\_Table and load them with [\_\_autoload](http://us.php.net/manual/en/language.oop5.autoload.php). ``` /project - /config - /html - - /css - - /images - - /js - - /subdirs for php...
434,737
<p>The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.</p>
[ { "answer_id": 434747, "author": "Ali Ersöz", "author_id": 4215, "author_profile": "https://Stackoverflow.com/users/4215", "pm_score": 4, "selected": false, "text": "<p>You should first convert it to List;</p>\n\n<pre><code>IQueryable&lt;int&gt; foo = new SomeQueryable&lt;int&lt;();\nLis...
2009/01/12
[ "https://Stackoverflow.com/questions/434737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The IQueryable results is queried from my db using LINQ, How do I add a new record to the IQueryable result.
Do you want to add it to the database, or just to the list of results that other things like databinding will use? If it's the former, you'll need to use the normal add operation for whatever kind of LINQ you're using, but to the table representation rather than the IQueryable. Queries only read data. If it's the lat...
434,761
<pre><code>MyClass[] array; List&lt;MyClass&gt; list; </code></pre> <p>What are the scenarios when one is preferable over the other? And why?</p>
[ { "answer_id": 434765, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 10, "selected": true, "text": "<p>It is rare, in reality, that you would want to use an array. Definitely use a <code>List&lt;T&gt;</code> any time ...
2009/01/12
[ "https://Stackoverflow.com/questions/434761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32688/" ]
``` MyClass[] array; List<MyClass> list; ``` What are the scenarios when one is preferable over the other? And why?
It is rare, in reality, that you would want to use an array. Definitely use a `List<T>` any time you want to add/remove data, since resizing arrays is expensive. If you know the data is fixed length, and you want to micro-optimise for some **very specific** reason (after benchmarking), then an array may be useful. `Li...
434,762
<p>I ran into a particularly annoying issue. I have a LinqToSql project up and running..</p> <p>A X.dbml file has three dependent files an X.cs, X.dbml.layout and X.designer.cs<br> Now when I drop an additional table into the designer surface and rename the table, I get an property value is invalid 'unspecified error'...
[ { "answer_id": 434769, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 0, "selected": false, "text": "<p>(Posting as a KB)\n<a href=\"http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3738879&amp;SiteID=1&amp;pageid=0\" rel=...
2009/01/12
[ "https://Stackoverflow.com/questions/434762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
I ran into a particularly annoying issue. I have a LinqToSql project up and running.. A X.dbml file has three dependent files an X.cs, X.dbml.layout and X.designer.cs Now when I drop an additional table into the designer surface and rename the table, I get an property value is invalid 'unspecified error'. Weird....
Also, this has been raised as a [Connect Bug](https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361577), that they've marked as "Fixed in a later release", when ever that comes out. There are also a couple of other workarounds: If you have a partial class, make sure that any using state...
434,763
<p>To be truly standards-compliant, must all functions in C (except for main) have a prototype, even if they are only used after their definition in the same translation unit?</p>
[ { "answer_id": 434812, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p>No, functions do not always need a prototype. The only requirement is that a function be \"declared\" before you use it. Th...
2009/01/12
[ "https://Stackoverflow.com/questions/434763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43496/" ]
To be truly standards-compliant, must all functions in C (except for main) have a prototype, even if they are only used after their definition in the same translation unit?
It depends on what you mean by 'truly standards compliant'. However, the short answer is "it is a good idea to ensure that all functions have a prototype in scope before being used". A more qualified answer notes that if the function accepts variable arguments (notably the `printf()` family of functions), then a proto...
434,776
<p>I'm using ASP.NET MVC Framwork and trying to grok the ASP Membership 3.5 stuff. </p> <p>What is the best way to add the first administrator user <a href="http://en.wikipedia.org/wiki/Chicken_or_the_egg" rel="nofollow noreferrer">without having to log in</a>? I've been staring at the <a href="http://www.codeplex.com...
[ { "answer_id": 434798, "author": "Richard L", "author_id": 51017, "author_profile": "https://Stackoverflow.com/users/51017", "pm_score": 2, "selected": false, "text": "<p>Depends on what memebership provider your are using.. \nIf your using a SQL memembershipprovider you should be able t...
2009/01/12
[ "https://Stackoverflow.com/questions/434776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
I'm using ASP.NET MVC Framwork and trying to grok the ASP Membership 3.5 stuff. What is the best way to add the first administrator user [without having to log in](http://en.wikipedia.org/wiki/Chicken_or_the_egg)? I've been staring at the [membership starter kit's source](http://www.codeplex.com/MvcMembership) withou...
A simple solution (especially or rather only for dev. purposes) by doing it in a "setup" action: ``` if (!Roles.RoleExists("Administrator")) { Roles.CreateRole("Administrator"); } if (Membership.GetUser("Admin") == null) { Membership.CreateUser("Admin", "Admin"); Roles.AddUserToRole("Admin", "Administrator...
434,815
<p>Here are two questions related to modifying the data source for strongly typed dataset connection string.</p> <p>When my app is deployed, a light weight database ( in the form of Microsoft Access) is deployed to the Application Data folder. I have a strongly typed dataset that is wrapped around that. So the questio...
[ { "answer_id": 434826, "author": "Richard L", "author_id": 51017, "author_profile": "https://Stackoverflow.com/users/51017", "pm_score": 4, "selected": true, "text": "<p>When you deploy an Windows Forms application you could have an app.config file. </p>\n\n<p>yourproject.exe gives you a...
2009/01/12
[ "https://Stackoverflow.com/questions/434815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
Here are two questions related to modifying the data source for strongly typed dataset connection string. When my app is deployed, a light weight database ( in the form of Microsoft Access) is deployed to the Application Data folder. I have a strongly typed dataset that is wrapped around that. So the question is how t...
When you deploy an Windows Forms application you could have an app.config file. yourproject.exe gives you a yourproject.exe.config file, which is the app.config file.
434,829
<p>$query = mysql_query("SELECT * FROM news WHERE id = '{$_GET['id']}'"); $news = mysql_fetch_assoc($query);</p> <p>$sql84 = mysql_query("SELECT username FROM users WHERE id = '".$news['user_id']."'") or exit(mysql_error()); $author = mysql_fetch_array($sql84);</p> <p>is there i better way of doing this? a join maybe...
[ { "answer_id": 434834, "author": "Deniss Kozlovs", "author_id": 53948, "author_profile": "https://Stackoverflow.com/users/53948", "pm_score": 0, "selected": false, "text": "<pre><code>$query = mysql_query(\"SELECT n.*, u.* FROM news n LEFT JOIN users u ON u.id=n.user_id WHERE n.id = \".i...
2009/01/12
[ "https://Stackoverflow.com/questions/434829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
$query = mysql\_query("SELECT \* FROM news WHERE id = '{$\_GET['id']}'"); $news = mysql\_fetch\_assoc($query); $sql84 = mysql\_query("SELECT username FROM users WHERE id = '".$news['user\_id']."'") or exit(mysql\_error()); $author = mysql\_fetch\_array($sql84); is there i better way of doing this? a join maybe? how t...
It seems like you want something like this: (Edited to add error checking) ``` $q = "select username from news, users where news.user_id=users.id and news.id=".$_GET['id'].");"; $query = mysql_query($q) or die(mysql_error()); ``` Ben
434,832
<p>I'm trying to make some kind of shape in wpf, which does resize itself to the content (which should be text). Unfortunately, the stretch property isn't the right thing, since I want only the width of the Shape resized and <strong>without</strong> the borders (pls copy bottom example in xamlpad to see for yourself) o...
[ { "answer_id": 435118, "author": "Sam Meldrum", "author_id": 16005, "author_profile": "https://Stackoverflow.com/users/16005", "pm_score": 1, "selected": false, "text": "<p>You could try using a transform to change the size of the rectangle rather than binding the rectangle's width direc...
2009/01/12
[ "https://Stackoverflow.com/questions/434832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41407/" ]
I'm trying to make some kind of shape in wpf, which does resize itself to the content (which should be text). Unfortunately, the stretch property isn't the right thing, since I want only the width of the Shape resized and **without** the borders (pls copy bottom example in xamlpad to see for yourself) of this shape str...
I use a set of classes named ViewboxPath, ViewboxLine, ViewboxPolyline, etc that change the stretch semantics of Shape to be a little more tractable. I'm not sure I understood your question, so I don't know if my technique will solve your problem or not. As I read it, either you want control over the stretching, which...
434,839
<p>Where do you like to catch exceptions and why?</p> <p>I'm interested in seeing where people find it useful to put their try/catch blocks in the hope that some general patterns might emerge. I'll post my two example answers in C++ but any language is fine.</p> <p>One location and reason per answer please. Thanks....
[ { "answer_id": 434841, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I always put a catch in main() as a catch of last resort:</p>\n\n<pre><code>int main( int argc, char** argv ) {\n try {\...
2009/01/12
[ "https://Stackoverflow.com/questions/434839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Where do you like to catch exceptions and why? I'm interested in seeing where people find it useful to put their try/catch blocks in the hope that some general patterns might emerge. I'll post my two example answers in C++ but any language is fine. One location and reason per answer please. Thanks.
I try to catch ONLY those exceptions that I can deal with. I HATE code like this: ``` String s="12"; Integer i; try { i = Integer.parseInt(s); } catch(ParseException pe) { System.out.println("hihihihihihihi!!!); } ``` What I especially hate is that what this ...
434,840
<p>I'd like to display a comparison page so user can compare the properties of several objects in my database. Any number of objects can be compared. I'd also like it to be bookmarkable (so a 'get').</p> <p>How should I structure my URL / route for the controller? </p> <p>Something like /foo_compare/1_5_22 where I sp...
[ { "answer_id": 434900, "author": "aivarsak", "author_id": 53698, "author_profile": "https://Stackoverflow.com/users/53698", "pm_score": 2, "selected": false, "text": "<pre><code>a) url_for(:controller =&gt; \"my_controlelr\",:action =&gt; \"compare\", :id =&gt; [1,2,3,4]) becomes \"id\"=...
2009/01/12
[ "https://Stackoverflow.com/questions/434840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16779/" ]
I'd like to display a comparison page so user can compare the properties of several objects in my database. Any number of objects can be compared. I'd also like it to be bookmarkable (so a 'get'). How should I structure my URL / route for the controller? Something like /foo\_compare/1\_5\_22 where I split the ids in...
I'd prefer ``` /compare?a=1&b=5&c=22 ``` The 1\_5\_22 is just fugly, and I think that ``` /compare/1/5/22 ``` is a very non-RESTful route.
434,851
<p>I noticed today (after ~8 years of happily hacking away at bash) that there is no trivial way to 'delete by date' using ´rm'. The solution is therefore to pipe stuff around a combination of commands like rm, ls, find, awk and sed.</p> <p>Say for example I wanted to delete every file in the working directory from 20...
[ { "answer_id": 434860, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 4, "selected": false, "text": "<p>I would combine find and rm (without pipe)</p>\n\n<pre><code>find . ...bunch of find criterias to select certain files (...
2009/01/12
[ "https://Stackoverflow.com/questions/434851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54086/" ]
I noticed today (after ~8 years of happily hacking away at bash) that there is no trivial way to 'delete by date' using ´rm'. The solution is therefore to pipe stuff around a combination of commands like rm, ls, find, awk and sed. Say for example I wanted to delete every file in the working directory from 2009, what w...
Some versions of find support the -delete option, making it even more efficient... ``` find . -maxdepth 1 -type f -ctime -12 -delete; ``` Check your find man page (this has worked on most recent releases of Ubuntu for me)
434,864
<p>I'm writing an application where a user provides a connection string manually and I'm wondering if there is any way that I could validate the connection string - I mean check if it's correct and if the database exists.</p>
[ { "answer_id": 434868, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 8, "selected": true, "text": "<p>You could try to connect? For quick (offline) validation, perhaps use <code>DbConnectionStringBuilder</code> to par...
2009/01/12
[ "https://Stackoverflow.com/questions/434864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
I'm writing an application where a user provides a connection string manually and I'm wondering if there is any way that I could validate the connection string - I mean check if it's correct and if the database exists.
You could try to connect? For quick (offline) validation, perhaps use `DbConnectionStringBuilder` to parse it... ``` DbConnectionStringBuilder csb = new DbConnectionStringBuilder(); csb.ConnectionString = "rubb ish"; // throws ``` But to check whether the db exists, you'll need to try to connect. Simplest if...
434,865
<p>I have doubt in renaming java files... My application has to rename the incoming file which is mdb,dbf,xls,xml,etc. format. I used the following source code.</p> <p>eg:</p> <pre><code>String filename = "D:/sample.mdb"; File filediriden = new File(filename); String[] filetype = filename.split("\\."); System.out.pri...
[ { "answer_id": 434878, "author": "Thilo", "author_id": 14955, "author_profile": "https://Stackoverflow.com/users/14955", "pm_score": 2, "selected": false, "text": "<pre><code>boolean rename = filediriden.renameTo(newfilediriden);\nif(filediriden.isFile()){\n</code></pre>\n\n<p>After you ...
2009/01/12
[ "https://Stackoverflow.com/questions/434865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51659/" ]
I have doubt in renaming java files... My application has to rename the incoming file which is mdb,dbf,xls,xml,etc. format. I used the following source code. eg: ``` String filename = "D:/sample.mdb"; File filediriden = new File(filename); String[] filetype = filename.split("\\."); System.out.println("Filetype :"+fil...
``` boolean rename = filediriden.renameTo(newfilediriden); if(filediriden.isFile()){ ``` After you rename the file, the old File object (*filediriden*) still points to the old name, which no longer exists. You want to check using the new File object (*newfilediriden*). ``` filetype[1] ``` Also, there could be file...
434,873
<p>I have come across what must be a common problem. When I have an event which may be subscribed to by several different classes, an exception thrown by one of these classes will kill the callback chain; as I do not know a priori in what order the callback is carried out, this can result in unpredictable state changes...
[ { "answer_id": 434881, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>If you simply invoke a delegate, it will call all the target methods in order. You need to use <code>GetInvocationL...
2009/01/12
[ "https://Stackoverflow.com/questions/434873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
I have come across what must be a common problem. When I have an event which may be subscribed to by several different classes, an exception thrown by one of these classes will kill the callback chain; as I do not know a priori in what order the callback is carried out, this can result in unpredictable state changes fo...
If you simply invoke a delegate, it will call all the target methods in order. You need to use `GetInvocationList` if you want to execute them individually - for example: * to check `Cancel` after each * to capture the return value of each * to continue after failure of an individual target As for the best way to use...
434,890
<p>String's in C# are immutable and threadsafe. But what when you have a public getter property? Like this:</p> <pre><code>public String SampleProperty{ get; private set; } </code></pre> <p>If we have two threads and the first is calling 'get' and the second is calling 'set' at the "same" time, what will happ...
[ { "answer_id": 434913, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "<p>A reference-type field's get/set (ldfld/stfld) is (IIRC) guaranteed to be atomic, so there shouldn't be any risk o...
2009/01/12
[ "https://Stackoverflow.com/questions/434890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43532/" ]
String's in C# are immutable and threadsafe. But what when you have a public getter property? Like this: ``` public String SampleProperty{ get; private set; } ``` If we have two threads and the first is calling 'get' and the second is calling 'set' at the "same" time, what will happen? IMHO the set must mad...
Most of the answers are using the word "atomic" as if atomic changes are all that are needed. They're not, usually. This has been mentioned in the comments, but not usually in the answers - that's the only reason for me providing this answer. (The point about locking at a coarser granularity, to allow things like appe...
434,895
<p>I want to have a managerial report after executing tests from NUnit. By looking into NUnit, It seems as it generates the output in XML format. Plz any one can give suggesttion of how to accomplish this. </p>
[ { "answer_id": 434913, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "<p>A reference-type field's get/set (ldfld/stfld) is (IIRC) guaranteed to be atomic, so there shouldn't be any risk o...
2009/01/12
[ "https://Stackoverflow.com/questions/434895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to have a managerial report after executing tests from NUnit. By looking into NUnit, It seems as it generates the output in XML format. Plz any one can give suggesttion of how to accomplish this.
Most of the answers are using the word "atomic" as if atomic changes are all that are needed. They're not, usually. This has been mentioned in the comments, but not usually in the answers - that's the only reason for me providing this answer. (The point about locking at a coarser granularity, to allow things like appe...
434,897
<p>The if keyword in the following statement is underlined in green by ReSharper:</p> <pre><code>if (readOnlyFields.Contains(propertyName)) return false; return base.CanWriteProperty(propertyName); </code></pre> <p>ReSharper suggests the following change: </p> <pre><code>return !readOnlyFields.Contains(propertyName...
[ { "answer_id": 434905, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 2, "selected": false, "text": "<p>On the quick fix menu (Alt+Enter), there's a \"Correction options\" (or something like that). You can turn this s...
2009/01/12
[ "https://Stackoverflow.com/questions/434897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45704/" ]
The if keyword in the following statement is underlined in green by ReSharper: ``` if (readOnlyFields.Contains(propertyName)) return false; return base.CanWriteProperty(propertyName); ``` ReSharper suggests the following change: ``` return !readOnlyFields.Contains(propertyName) && base.CanWriteProperty(prope...
Neither one is better in the sense that either one will perform better than the other. (Any difference is going to be entirely negligible.) Certain coding conventions suggest that you use one return statement per function so that it's easy to understand it's flow. It's not a hard and fast rule though and in this case ...
434,899
<p>My OPS is XP and service pack 3 installed.I cant install vs2008 service pack1,In log file i see 'Visual C++ 2008 SP1 Design-Time Components for x86 - KB947888' cant be installed. Error code is 1603.Last part of Installation file is here. </p> <pre> Returning IDOK. INSTALLMESSAGE_ERROR [Error 1335. The cabinet...
[ { "answer_id": 434947, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 0, "selected": false, "text": "<p>If you downloaded SP1, download again. It might also be that you don't have enough RAM in your machine for the ins...
2009/01/12
[ "https://Stackoverflow.com/questions/434899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My OPS is XP and service pack 3 installed.I cant install vs2008 service pack1,In log file i see 'Visual C++ 2008 SP1 Design-Time Components for x86 - KB947888' cant be installed. Error code is 1603.Last part of Installation file is here. ``` Returning IDOK. INSTALLMESSAGE_ERROR [Error 1335. The cabinet file 'pa...
I was getting a similar error and the problem is that the iso file, even when corrupted (by an unstable download for instance) can still be uncompressed and/or mounted/burnt successfully. I re-downloaded the iso, mounted the new one and installed with no problems... I then observed a difference in the md5 hash of the f...
434,904
<p>I am trying to pass a number to my JavaScript function, but actually a wrong value is getting passed. I am giving the entire code here:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function test(num) { /*It should alert as 01004 or 1004 but to my surprise it's alerting as 516!*/ al...
[ { "answer_id": 434912, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 3, "selected": false, "text": "<p>The leading zero is probably making it think the number is octal.</p>\n\n<p>UPDATE: Thanks to @Paul Dixon for jogging my...
2009/01/12
[ "https://Stackoverflow.com/questions/434904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42372/" ]
I am trying to pass a number to my JavaScript function, but actually a wrong value is getting passed. I am giving the entire code here: ``` <html> <head> <script type="text/javascript"> function test(num) { /*It should alert as 01004 or 1004 but to my surprise it's alerting as 516!*/ alert(num); } </script> </head> <b...
A numeric literal that starts with a zero is interpreted as octal, so writing 01004 is *exactly* the same as writing 516. Some other answers suggesting using parseInt inside the function to convert the octal value to decimal. This wont help, as the numeric value 516 is passed to the function. If you ask parseInt to g...
434,923
<p>I am using CruiseControl .NET with the Subversion source control plugin to automatically build our project.</p> <p>Some of the projects are automatically checking for modifications, but occasionally the check fails and CruiseControl .NET marks the project with an "Exception":</p> <pre><code>ThoughtWorks.CruiseCont...
[ { "answer_id": 436261, "author": "Jeffrey Fredrick", "author_id": 35894, "author_profile": "https://Stackoverflow.com/users/35894", "pm_score": 1, "selected": false, "text": "<p>Kinda of a kludge but could you create a project that runs on demand and does an svn cleanup?</p>\n\n<p>I know...
2009/01/12
[ "https://Stackoverflow.com/questions/434923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42272/" ]
I am using CruiseControl .NET with the Subversion source control plugin to automatically build our project. Some of the projects are automatically checking for modifications, but occasionally the check fails and CruiseControl .NET marks the project with an "Exception": ``` ThoughtWorks.CruiseControl.Core.CruiseContro...
The new Cruise Control.Net 1.4.4 server has two additional properties on the Subversion Source Control Block. See [CCNET Documentation - Subversion Source Control Block](http://confluence.public.thoughtworks.org/display/CCNET/Subversion+Source+Control+Block) The cleanUp and revert properties does what you want.
434,933
<p>In a 32-bit .NET app, I can use this OLEDB connection string to connect to a CSV file via ADO.NET:</p> <pre><code>"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\foo;" </code></pre> <p>or this ODBC one:</p> <pre><code>"Driver={{Microsoft Text Driver (*.txt; *.csv)}};Dbq=c:\foo" </code></pre> <p>However there ap...
[ { "answer_id": 435881, "author": "Matt", "author_id": 19802, "author_profile": "https://Stackoverflow.com/users/19802", "pm_score": 0, "selected": false, "text": "<p>I ended up having to convert my application to 32-bit because I was having the same problem, although with accessing a Mic...
2009/01/12
[ "https://Stackoverflow.com/questions/434933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6725/" ]
In a 32-bit .NET app, I can use this OLEDB connection string to connect to a CSV file via ADO.NET: ``` "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\foo;" ``` or this ODBC one: ``` "Driver={{Microsoft Text Driver (*.txt; *.csv)}};Dbq=c:\foo" ``` However there apparently arent 64-bit versions of either the OLED...
It's not a driver, but I've been pleased with Sebastien Lorion's CSV reader. Note that I've never used it in a 64-bit environment, but I'm not aware of any compatibility issues. <http://www.codeproject.com/KB/database/CsvReader.aspx>
434,935
<p>I want to access MySQL through ruby on a shared linux server. I figure I need to use the DBI module, but I can't seem to access it. I installed it as follows:</p> <pre><code>gem install -r dbi </code></pre> <p>It couldn't install it in the normal location, since I'm on a shared server and don't have permission:</p...
[ { "answer_id": 434965, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 3, "selected": true, "text": "<p>I found the answer. I needed to specify LOAD_PATH on the command line as:</p>\n\n<pre><code>ruby -I$HOME/.gem/ruby/1.8/gems/...
2009/01/12
[ "https://Stackoverflow.com/questions/434935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
I want to access MySQL through ruby on a shared linux server. I figure I need to use the DBI module, but I can't seem to access it. I installed it as follows: ``` gem install -r dbi ``` It couldn't install it in the normal location, since I'm on a shared server and don't have permission: ``` WARNING: Installing to...
I found the answer. I needed to specify LOAD\_PATH on the command line as: ``` ruby -I$HOME/.gem/ruby/1.8/gems/dbi-0.4.1/lib/ dbi_test.r ``` I had been setting LOAD\_PATH as a standard UNIX environment variable. D'oh!
434,940
<p>How do you generate paper-prints from a web application?</p> <p>Specifically I am thinking about more complex paper documents like diplomas, invoices and contracts. Variable number of pages with frames, tables, logos and headers/footers.</p> <p>Today I use custom forms and CSS for certain things and iTextSharp for...
[ { "answer_id": 434946, "author": "aivarsak", "author_id": 53698, "author_profile": "https://Stackoverflow.com/users/53698", "pm_score": 2, "selected": false, "text": "<p>IMHO for fixed format printing PDF if the answer</p>\n" }, { "answer_id": 434954, "author": "James B", ...
2009/01/12
[ "https://Stackoverflow.com/questions/434940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35400/" ]
How do you generate paper-prints from a web application? Specifically I am thinking about more complex paper documents like diplomas, invoices and contracts. Variable number of pages with frames, tables, logos and headers/footers. Today I use custom forms and CSS for certain things and iTextSharp for others (I work w...
Creating documents from scratch with iTextSharp can be very time consuming. As an alternative, you can create (or reuse) PDF "template" documents by adding form fields to them (if necessary). The easiest way to do this is with a full version of Adobe Acrobat, but you can also add fillable form fields using nothing but ...
434,948
<p>On Delphi 2009, on a new VCL project: </p> <pre><code>procedure TForm1.FormCreate(Sender: TObject); var Handle: THandle; begin Handle := loadlibrary('oci.dll'); if Handle &lt;&gt; 0 then begin try ShowMessage('Success'); finally FreeLibrary(Handle); en...
[ { "answer_id": 434952, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>If the dependent DLL is in the same directory... make sure your startup directory is it.</p>\n\n<p>This happens to me all t...
2009/01/12
[ "https://Stackoverflow.com/questions/434948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53242/" ]
On Delphi 2009, on a new VCL project: ``` procedure TForm1.FormCreate(Sender: TObject); var Handle: THandle; begin Handle := loadlibrary('oci.dll'); if Handle <> 0 then begin try ShowMessage('Success'); finally FreeLibrary(Handle); end; end else ...
The usual problem with LoadLibrary failing is that the required DLL is not in the [DLL search path.](http://msdn.microsoft.com/en-us/library/7d83bc18(VS.80).aspx) It's possible that D2009 is not searching the same folders for some reason. To make sure, you should get more details of the error, using something like... ...
434,959
<p>I've made a web application that has the following architecture: Every form is a UserControl, there is just one actual page (Default.aspx), and a parameter in the URL specifies which UserControl to load. The UserControl is loaded in an UpdatePanel so that it can enjoy full AJAX-iness.</p> <p>There is also an elabor...
[ { "answer_id": 435006, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if you meant Page.Error on your main page wasn't working or on the user controls themselves. If you...
2009/01/12
[ "https://Stackoverflow.com/questions/434959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41360/" ]
I've made a web application that has the following architecture: Every form is a UserControl, there is just one actual page (Default.aspx), and a parameter in the URL specifies which UserControl to load. The UserControl is loaded in an UpdatePanel so that it can enjoy full AJAX-iness. There is also an elaborate messag...
The full answer is in my blog post - [Unhide Exceptions Hidden By AJAX](http://blog.digitaltools.com/post/2010/02/03/Unhide-Exceptions-Hidden-By-AJAX.aspx). I do use AsyncPostBackError() to change the error message from the generic "Exception has been thrown by the target of an invocation" to the real error message. ...
434,968
<p>I have a C code base and need to programmatically identify all of the global variables used. I think that gcc can be made to produce a memory map file but don't know how and this might let me see which variables are global? Any help would be appreciated.</p> <p>Cheers</p>
[ { "answer_id": 434987, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "<p>Why do you need to know this? For a lot of purposes, static data (whether at file or function scope) should be grouped...
2009/01/12
[ "https://Stackoverflow.com/questions/434968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23435/" ]
I have a C code base and need to programmatically identify all of the global variables used. I think that gcc can be made to produce a memory map file but don't know how and this might let me see which variables are global? Any help would be appreciated. Cheers
You can extract such information from your object files with `nm`. ``` nm *.o | grep OBJT | grep GLOB ``` **EDIT** Command above is for Solaris' nm (SUNWbtool package). For portability, `nm` has a parameter to choose the output format: ``` nm -f [posix|bsd|sysv] *.o ```
435,003
<p>I want to make a UI virtualization via the datasource.</p> <p>The idea is to "Filter" what i send to the UI (a listbox in my case).</p> <p>I noticed that the ItemsSource (an observable collection) is read once and that changing the Filter does not trigger refreshing...</p> <p>I don't understand why Thanks Jonatha...
[ { "answer_id": 435033, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 0, "selected": false, "text": "<p>What filter are you talking about? If you are a CollectionView and then binding to that then there won't be a ch...
2009/01/12
[ "https://Stackoverflow.com/questions/435003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to make a UI virtualization via the datasource. The idea is to "Filter" what i send to the UI (a listbox in my case). I noticed that the ItemsSource (an observable collection) is read once and that changing the Filter does not trigger refreshing... I don't understand why Thanks Jonathan --- I'll try to be m...
The `CollectionViewSource` itself supports filtering via its `Filter` property. Why don't you put your filtering logic in there?
435,005
<p>i have a tiny little problem with xslt, js and html entities, eg. within a template:</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;xsl:value-of select="/some/node"/&gt; for (var i = 0; i &amp;lt; 5; i++) { // ^^^ js error } &lt;/script&gt; &lt;script type="text/javascript"...
[ { "answer_id": 435014, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 1, "selected": false, "text": "<p>The <code>CDATA</code> blocks should have worked; they always have for me. What's your <code>disable-output-escaping</co...
2009/01/12
[ "https://Stackoverflow.com/questions/435005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1532/" ]
i have a tiny little problem with xslt, js and html entities, eg. within a template: ``` <script type="text/javascript"> <xsl:value-of select="/some/node"/> for (var i = 0; i &lt; 5; i++) { // ^^^ js error } </script> <script type="text/javascript"> <xsl:value-of select="/some/node"...
ok. long story, short answer: it seems that with **some libxslt versions** the xslt processor leaves the content of a <script/> element unescaped when using the html output method, **with others not** ... therefore the following is recommended: ``` <script type="text/javascript"> <xsl:value-of select="/some/node...
435,019
<p>I want to use a masterpagefile (the site's one if this makes sense) in my SharePoint 12 hive/template/layouts/TelephoneBookList/test.aspx file. However, whenever I add MasterPageFile="~/_layouts/simple.master" or something like that to my test.aspx page, I get a sharepoint error page and the following in the log fil...
[ { "answer_id": 435501, "author": "SchaeferFFM", "author_id": 39948, "author_profile": "https://Stackoverflow.com/users/39948", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<p>Leave the MasterPageFile declaration at it's default (~/_layouts/simple.master) and override On...
2009/01/12
[ "https://Stackoverflow.com/questions/435019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to use a masterpagefile (the site's one if this makes sense) in my SharePoint 12 hive/template/layouts/TelephoneBookList/test.aspx file. However, whenever I add MasterPageFile="~/\_layouts/simple.master" or something like that to my test.aspx page, I get a sharepoint error page and the following in the log file:...
Try this: Leave the MasterPageFile declaration at it's default (~/\_layouts/simple.master) and override OnPreInit in your custom code. ``` protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); this.MasterPageFile = SPContext.Current.Web.MasterUrl; } ```