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
150,522
<p>Using Restlet I needed to serve some simple static content in the same context as my web service. I've configured the component with a <code>Directory</code>, but in testing, I've found it will only serve 'index.html', everything else results in a 404.</p> <pre><code>router.attach("/", new Directory(context, new Re...
[ { "answer_id": 151642, "author": "Dan Lenski", "author_id": 20789, "author_profile": "https://Stackoverflow.com/users/20789", "pm_score": 3, "selected": false, "text": "<p>Best thing I can think of is to encode it yourself. How about this subroutine?</p>\n\n<pre><code>from urllib2 impor...
2008/09/29
[ "https://Stackoverflow.com/questions/150522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/758/" ]
Using Restlet I needed to serve some simple static content in the same context as my web service. I've configured the component with a `Directory`, but in testing, I've found it will only serve 'index.html', everything else results in a 404. ``` router.attach("/", new Directory(context, new Reference(baseRef, "./conte...
Best thing I can think of is to encode it yourself. How about this subroutine? ``` from urllib2 import Request, urlopen from binascii import b2a_base64 def b64open(url, postdata): req = Request(url, b2a_base64(postdata), headers={'Content-Transfer-Encoding': 'base64'}) return urlopen(req) conn = b64open("http://...
150,532
<p>Similar to <a href="https://stackoverflow.com/questions/5415/convert-bytes-to-floating-point-numbers-in-python">this</a> question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python.</p> <p>I first read all ten bytes into a string. I then want to par...
[ { "answer_id": 150541, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>I was going to recommend the <code>struct</code> package but then you said you had tried it. Try this:</p>\n\n<pre><co...
2008/09/29
[ "https://Stackoverflow.com/questions/150532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
Similar to [this](https://stackoverflow.com/questions/5415/convert-bytes-to-floating-point-numbers-in-python) question, I am trying to read in an ID3v2 tag header and am having trouble figuring out how to get individual bytes in python. I first read all ten bytes into a string. I then want to parse out the individual ...
If you have a string, with 2 bytes that you wish to interpret as a 16 bit integer, you can do so by: ``` >>> s = '\0\x02' >>> struct.unpack('>H', s) (2,) ``` Note that the > is for big-endian (the largest part of the integer comes first). This is the format id3 tags use. For other sizes of integer, you use differen...
150,535
<p>How do you remove the jagged edges from a wide button in internet explorer? For example:</p> <p><img src="https://i.stack.imgur.com/em5K0.gif" alt="alt text"></p>
[ { "answer_id": 150545, "author": "brad", "author_id": 208, "author_profile": "https://Stackoverflow.com/users/208", "pm_score": 2, "selected": false, "text": "<p>As a workaround, you can remove the blank spaces on each end of the button, which has the effect of decreasing the jagged edge...
2008/09/29
[ "https://Stackoverflow.com/questions/150535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
How do you remove the jagged edges from a wide button in internet explorer? For example: ![alt text](https://i.stack.imgur.com/em5K0.gif)
You can also eliminate Windows XP's styling of buttons (and every other version of Windows) by setting the `background-color` and/or `border-color` on your buttons. Try the following styles: ``` background-color: black; color: white; border-color: red green blue yellow; ``` You can of course make this much more ple...
150,539
<p>I've used asp.net profiles (using the AspNetSqlProfileProvider) for holding small bits of information about my users. I started to wonder how it would handle a robust profile for a large number of users. Does anyone have experience using this on a large website with large numbers of simultaneous users? What are the ...
[ { "answer_id": 150545, "author": "brad", "author_id": 208, "author_profile": "https://Stackoverflow.com/users/208", "pm_score": 2, "selected": false, "text": "<p>As a workaround, you can remove the blank spaces on each end of the button, which has the effect of decreasing the jagged edge...
2008/09/29
[ "https://Stackoverflow.com/questions/150539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
I've used asp.net profiles (using the AspNetSqlProfileProvider) for holding small bits of information about my users. I started to wonder how it would handle a robust profile for a large number of users. Does anyone have experience using this on a large website with large numbers of simultaneous users? What are the per...
You can also eliminate Windows XP's styling of buttons (and every other version of Windows) by setting the `background-color` and/or `border-color` on your buttons. Try the following styles: ``` background-color: black; color: white; border-color: red green blue yellow; ``` You can of course make this much more ple...
150,543
<p>In C, is it possible to forward the invocation of a variadic function? As in,</p> <pre><code>int my_printf(char *fmt, ...) { fprintf(stderr, "Calling printf with fmt %s", fmt); return SOMEHOW_INVOKE_LIBC_PRINTF; } </code></pre> <p>Forwarding the invocation in the manner above obviously isn't strictly neces...
[ { "answer_id": 150560, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 2, "selected": false, "text": "<p>Use vfprintf:</p>\n\n<pre><code>int my_printf(char *fmt, ...) {\n va_list va;\n int ret;\n\n va_start(va, fm...
2008/09/29
[ "https://Stackoverflow.com/questions/150543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23600/" ]
In C, is it possible to forward the invocation of a variadic function? As in, ``` int my_printf(char *fmt, ...) { fprintf(stderr, "Calling printf with fmt %s", fmt); return SOMEHOW_INVOKE_LIBC_PRINTF; } ``` Forwarding the invocation in the manner above obviously isn't strictly necessary in this case (since y...
If you don't have a function analogous to `vfprintf` that takes a `va_list` instead of a variable number of arguments, **you can't do it**. See [<http://c-faq.com/varargs/handoff.html>](http://c-faq.com/varargs/handoff.html). Example: ```c void myfun(const char *fmt, va_list argp) { vfprintf(stderr, fmt, argp); }...
150,544
<p>In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a standard try...catch get it?</p>
[ { "answer_id": 150550, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": -1, "selected": false, "text": "<p>If you use a </p>\n\n<pre><code>try\n{\n\n}\ncatch(Exception ex)\n{\n\n}\n</code></pre>\n\n<p>it will catch AL...
2008/09/29
[ "https://Stackoverflow.com/questions/150544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
In C# code can you catch a native exception thrown from deep in some unmanaged library? If so do you need to do anything differently to catch it or does a standard try...catch get it?
You can use [Win32Exception](http://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.aspx) and use its NativeErrorCode property to handle it appropriately. ``` // http://support.microsoft.com/kb/186550 const int ERROR_FILE_NOT_FOUND = 2; const int ERROR_ACCESS_DENIED = 5; const int ERROR_NO_APP_A...
150,548
<p>Despite the rather clear <a href="http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary620.html" rel="noreferrer">documentation</a> which says that <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#parseFloat()" rel="noreferrer">parseFloat()</...
[ { "answer_id": 150558, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 5, "selected": true, "text": "<p>Because comparing anything to NaN is always false. Use isNaN() instead.</p>\n" }, { "answer_id": 150559, ...
2008/09/29
[ "https://Stackoverflow.com/questions/150548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
Despite the rather clear [documentation](http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary620.html) which says that [parseFloat()](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/package.html#parseFloat()) can return NaN as a value, when I write a block like: `...
Because comparing anything to NaN is always false. Use isNaN() instead.
150,552
<p>I will preface this question by saying, I do not think it is solvable. I also have a workaround, I can create a stored procedure with an OUTPUT to accomplish this, it is just easier to code the sections where I need this checksum using a function.</p> <p>This code will not work because of the <code>Exec SP_ExecuteS...
[ { "answer_id": 150567, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 2, "selected": false, "text": "<p>You can get around this by calling an extended stored procedure, with all the attendant hassle and security problems....
2008/09/29
[ "https://Stackoverflow.com/questions/150552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23601/" ]
I will preface this question by saying, I do not think it is solvable. I also have a workaround, I can create a stored procedure with an OUTPUT to accomplish this, it is just easier to code the sections where I need this checksum using a function. This code will not work because of the `Exec SP_ExecuteSQL @SQL` calls....
It "ordinarily" can't be done as SQL Server treats functions as deterministic, which means that for a given set of inputs, it should always return the same outputs. A stored procedure or dynamic sql can be non-deterministic because it can change external state, such as a table, which is relied on. Given that in SQL se...
150,606
<p>I have a website laid out in tables. (a long mortgage form)</p> <p>in each table cell is one HTML object. (text box, radio buttons, etc)</p> <p>What can I do so when each table cell is "tabbed" into it highlights the cell with a very light red (not to be obtrusive, but tell the user where they are)?</p>
[ { "answer_id": 150629, "author": "roenving", "author_id": 23142, "author_profile": "https://Stackoverflow.com/users/23142", "pm_score": 0, "selected": false, "text": "<p>Possibly:</p>\n\n<pre><code>&lt;script type=\"text/javascript\"&gt;\n//getParent(startElement,\"tagName\");\nfunction ...
2008/09/29
[ "https://Stackoverflow.com/questions/150606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a website laid out in tables. (a long mortgage form) in each table cell is one HTML object. (text box, radio buttons, etc) What can I do so when each table cell is "tabbed" into it highlights the cell with a very light red (not to be obtrusive, but tell the user where they are)?
This is the table I tested my code on: ``` <table id="myTable"> <tr> <td><input type="text" value="hello" /></td> <td><input type="checkbox" name="foo" value="2" /></td> <td><input type="button" value="hi" /></td> </tr> </table> ``` Here is the code that worked: ``` // here is a cross-browser compat...
150,610
<p>The problem itself is simple, but I can't figure out a solution that does it in one query, and here's my "abstraction" of the problem to allow for a simpler explanation:</p> <p><strong>I will let my original explenation stand, but here's a set of sample data and the result i expect:</strong></p> <p>Ok, so here's s...
[ { "answer_id": 150624, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": -1, "selected": false, "text": "<p>You can use joins instead of the exists and this may improve the query plan in cases where the optimizer is not smar...
2008/09/29
[ "https://Stackoverflow.com/questions/150610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/452521/" ]
The problem itself is simple, but I can't figure out a solution that does it in one query, and here's my "abstraction" of the problem to allow for a simpler explanation: **I will let my original explenation stand, but here's a set of sample data and the result i expect:** Ok, so here's some sample data, i separated p...
This is fairly similar to what you wrote, but should be fairly speedy as NOT EXISTS is more efficient, in this case, than NOT IN... ``` mysql> select * from foo; +----+-----+ | id | col | +----+-----+ | 1 | Bar | | 1 | Foo | | 2 | Foo | | 3 | Bar | | 4 | Bar | | 4 | Foo | +----+-----+ SELECT id , col...
150,622
<p>I'm trying to do this</p> <pre><code>SELECT `Name`,`Value` FROM `Constants` WHERE `Name` NOT IN ('Do not get this one'|'or this one'); </code></pre> <p>But it doesn't seem to work.</p> <p>How do I get all the values, except for a select few, without doing this:</p> <pre><code>SELECT `Name`,`Value` FROM `Constan...
[ { "answer_id": 150627, "author": "jkramer", "author_id": 12523, "author_profile": "https://Stackoverflow.com/users/12523", "pm_score": 2, "selected": false, "text": "<p>It's <code>IN('foo', 'bar')</code>, with a comma, not a pipe.</p>\n" }, { "answer_id": 150628, "author": "O...
2008/09/29
[ "https://Stackoverflow.com/questions/150622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
I'm trying to do this ``` SELECT `Name`,`Value` FROM `Constants` WHERE `Name` NOT IN ('Do not get this one'|'or this one'); ``` But it doesn't seem to work. How do I get all the values, except for a select few, without doing this: ``` SELECT `Name`,`Value` FROM `Constants` WHERE `Name` != 'Do not get this one' ...
You should put the constants in a table and then do a select statement from that table. If you absolutely don't want a permanent table you can use a temp table. And if don't want to do that, you can use the IN syntax: NOT IN ('one', 'two')
150,645
<p>The MSDN states that the method returns</p> <blockquote> <p>true if the method is successfully queued; NotSupportedException is thrown if the work item is not queued.</p> </blockquote> <p>For testing purposes how to get the method to return <code>false</code>? Or it is just a "suboptimal" class design?</p>
[ { "answer_id": 150655, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 1, "selected": false, "text": "<p>This is probably a case of \"reserved for future use\". You may want to treat it as failure, but it'll be hard to test.<...
2008/09/29
[ "https://Stackoverflow.com/questions/150645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23372/" ]
The MSDN states that the method returns > > true if the method is successfully > queued; NotSupportedException is > thrown if the work item is not queued. > > > For testing purposes how to get the method to return `false`? Or it is just a "suboptimal" class design?
In looking at the source code in Reflector, it seems the only part of the code that could return "false" is a call to the following: ``` [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool AdjustThreadsInPool(uint QueueLength); ```
150,646
<p>I'm trying to create a new Excel file using jxl, but am having a hard time finding examples in their API documentation and online.</p>
[ { "answer_id": 150677, "author": "kolrie", "author_id": 14540, "author_profile": "https://Stackoverflow.com/users/14540", "pm_score": 0, "selected": false, "text": "<p>Not sure if you need to stick with JXL, but the best library for handling Excel files is <a href=\"http://poi.apache.org...
2008/09/29
[ "https://Stackoverflow.com/questions/150646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2628/" ]
I'm trying to create a new Excel file using jxl, but am having a hard time finding examples in their API documentation and online.
After messing around awhile longer I finally found something that worked and saw there still wasn't a solution posted here yet, so here's what I found: ``` try { String fileName = "file.xls"; WritableWorkbook workbook = Workbook.createWorkbook(new File(fileName)); workbook.createSheet("Sheet1", 0); wor...
150,687
<p>I would like to subscribe to the ItemCommand event of a Reorderlist I have on my page. The front end looks like this...</p> <pre><code>&lt;cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand"&gt; ... &lt...
[ { "answer_id": 151417, "author": "Fung", "author_id": 8280, "author_profile": "https://Stackoverflow.com/users/8280", "pm_score": 1, "selected": false, "text": "<p>Since your ImageButton's <code>CommandName=\"delete\"</code> you should be hooking up to the DeleteCommand event instead of ...
2008/09/29
[ "https://Stackoverflow.com/questions/150687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to subscribe to the ItemCommand event of a Reorderlist I have on my page. The front end looks like this... ``` <cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand"> ... <asp:ImageButton ID="btn...
this works: ``` <cc2:ReorderList ID="rlEvents" runat="server" AllowReorder="True" CssClass="reorderList" DataKeyField="EventId" DataSourceID="odsEvents" PostBackOnReorder="False" SortOrderField="EventOrder" OnDeleteCommand="rlEvents_DeleteCommand"> ... <asp:ImageButton ID="btnDeleteEvent" runat="server...
150,690
<p><strong>Problem:</strong></p> <p>Given a list of strings, find the substring which, if subtracted from the beginning of all strings where it matches and replaced by an escape byte, gives the shortest total length.</p> <p><strong>Example:</strong></p> <p><code>"foo"</code>, <code>"fool"</code>, <code>"bar"</code><...
[ { "answer_id": 150709, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 1, "selected": false, "text": "<p>I would try starting by sorting the list. Then you simply go from string to string comparing the first character to the n...
2008/09/29
[ "https://Stackoverflow.com/questions/150690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23423/" ]
**Problem:** Given a list of strings, find the substring which, if subtracted from the beginning of all strings where it matches and replaced by an escape byte, gives the shortest total length. **Example:** `"foo"`, `"fool"`, `"bar"` The result is: "foo" as the base string with the strings `"\0"`, `"\0l"`, `"bar"` ...
Use a forest of prefix trees (trie)... ``` f_2 b_1 / | o_2 a_1 | | o_2 r_1 | l_1 ``` then, we can find the best result, and guarantee it, by maximizing `(depth * frequency)` which will be replaced with your escape character. You can optimize the search by doing a branch and bound depth...
150,695
<p>It seems like Sql Reporting Services Server logs information in several places including web server logs and logging tables in the database. Where are all the locations SSRS logs to, and what type of errors are logged in each place?</p>
[ { "answer_id": 150896, "author": "Tomas", "author_id": 23360, "author_profile": "https://Stackoverflow.com/users/23360", "pm_score": 5, "selected": true, "text": "<p>As far as I know SSRS logs to the Event Log, the filesystem and its own database.</p>\n\n<p>The database is typically the ...
2008/09/29
[ "https://Stackoverflow.com/questions/150695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1644/" ]
It seems like Sql Reporting Services Server logs information in several places including web server logs and logging tables in the database. Where are all the locations SSRS logs to, and what type of errors are logged in each place?
As far as I know SSRS logs to the Event Log, the filesystem and its own database. The database is typically the most easily available one. You just login to the ReportServer database and execute ``` select * from executionlog ``` This only logs the executions though. If you want more information you can go to the ...
150,726
<p>I was wondering how to use <code>cin</code> so that if the user does not enter in any value and just pushes <code>ENTER</code> that <code>cin</code> will recognize this as valid input.</p>
[ { "answer_id": 150749, "author": "Thorsten79", "author_id": 19734, "author_profile": "https://Stackoverflow.com/users/19734", "pm_score": 2, "selected": false, "text": "<p>Does cin.<a href=\"http://www.cplusplus.com/reference/iostream/istream/getline.html\" rel=\"nofollow noreferrer\">ge...
2008/09/29
[ "https://Stackoverflow.com/questions/150726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I was wondering how to use `cin` so that if the user does not enter in any value and just pushes `ENTER` that `cin` will recognize this as valid input.
You will probably want to try `std::getline`: ``` #include <iostream> #include <string> std::string line; std::getline( std::cin, line ); if( line.empty() ) ... ```
150,731
<p>I would like to write some data to a file in Ruby. What is the best way to do that?</p>
[ { "answer_id": 150740, "author": "thesmallprint", "author_id": 12765, "author_profile": "https://Stackoverflow.com/users/12765", "pm_score": -1, "selected": false, "text": "<pre><code>filey = File.new(\"/path/to/the/file\", APPEND)\nfiley.puts \"stuff to write\"\n</code></pre>\n" }, ...
2008/09/29
[ "https://Stackoverflow.com/questions/150731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
I would like to write some data to a file in Ruby. What is the best way to do that?
``` File.open("a_file", "w") do |f| f.write "some data" end ``` You can also use `f << "some data"` or `f.puts "some data"` according to personal taste/necessity to have newlines. Change the `"w"` to `"a"` if you want to append to the file instead of truncating with each open.
150,750
<p>It's clear that a search performance of the generic <code>HashSet&lt;T&gt;</code> class is higher than of the generic <code>List&lt;T&gt;</code> class. Just compare the hash-based key with the linear approach in the <code>List&lt;T&gt;</code> class.</p> <p>However calculating a hash key may itself take some CPU cyc...
[ { "answer_id": 150766, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "<p>It depends. If the exact answer really matters, do some profiling and find out. If you're sure you'll never hav...
2008/09/29
[ "https://Stackoverflow.com/questions/150750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23372/" ]
It's clear that a search performance of the generic `HashSet<T>` class is higher than of the generic `List<T>` class. Just compare the hash-based key with the linear approach in the `List<T>` class. However calculating a hash key may itself take some CPU cycles, so for a small amount of items the linear search can be ...
A lot of people are saying that once you get to the size where speed is actually a concern that `HashSet<T>` will always beat `List<T>`, but that depends on what you are doing. Let's say you have a `List<T>` that will only ever have on average 5 items in it. Over a large number of cycles, if a single item is added or ...
150,760
<p>Let me first say that being able to take 17 million records from a flat file, pushing to a DB on a remote box and having it take 7 minutes is amazing. SSIS truly is fantastic. But now that I have that data up there, how do I remove duplicates?</p> <p>Better yet, I want to take the flat file, remove the duplicates f...
[ { "answer_id": 150872, "author": "Timothy Lee Russell", "author_id": 12919, "author_profile": "https://Stackoverflow.com/users/12919", "pm_score": 3, "selected": false, "text": "<p>I would suggest using SSIS to copy the records to a temporary table, then create a task that uses Select Di...
2008/09/29
[ "https://Stackoverflow.com/questions/150760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
Let me first say that being able to take 17 million records from a flat file, pushing to a DB on a remote box and having it take 7 minutes is amazing. SSIS truly is fantastic. But now that I have that data up there, how do I remove duplicates? Better yet, I want to take the flat file, remove the duplicates from the fl...
Use the Sort Component. Simply choose which fields you wish to sort your loaded rows by and in the bottom left corner you'll see a check box to remove duplicates. This box removes any rows which are duplicates based on the sort criteria only so in the example below the rows would be considered duplicate if we only sor...
150,762
<p>I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be</p> <pre><code>mshta.dll foobar.dll somethingelse.dll </code></pre> <p>The directory I'm interested in is <code>X:\Windows\System32\</code>, so...
[ { "answer_id": 150807, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 1, "selected": false, "text": "<p>In Windows:</p>\n\n<pre><code>\ntype file.txt >NUL 2>NUL\nif ERRORLEVEL 1 then echo \"file doesn't exist\"\n</cod...
2008/09/29
[ "https://Stackoverflow.com/questions/150762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5616/" ]
I have a file that lists filenames, each on it's own line, and I want to test if each exists in a particular directory. For example, some sample lines of the file might be ``` mshta.dll foobar.dll somethingelse.dll ``` The directory I'm interested in is `X:\Windows\System32\`, so I want to see if the following files...
In cmd.exe, the **FOR /F %***variable* **IN (** *filename* **) DO** *command* should give you what you want. This reads the contents of *filename* (and they could be more than one filenames) one line at a time, placing the line in %variable (more or less; do a HELP FOR in a command prompt). If no one else supplies a co...
150,814
<p>This is somewhat of a follow-up to an answer <a href="https://stackoverflow.com/questions/26536/active-x-control-javascript">here</a>.</p> <p>I have a custom ActiveX control that is raising an event ("ReceiveMessage" with a "msg" parameter) that needs to be handled by Javascript in the web browser. Historically we'...
[ { "answer_id": 152724, "author": "Raelshark", "author_id": 19678, "author_profile": "https://Stackoverflow.com/users/19678", "pm_score": 5, "selected": true, "text": "<p>I was able to get this working using the following script block format, but I'm still curious if this is the best way:...
2008/09/29
[ "https://Stackoverflow.com/questions/150814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19678/" ]
This is somewhat of a follow-up to an answer [here](https://stackoverflow.com/questions/26536/active-x-control-javascript). I have a custom ActiveX control that is raising an event ("ReceiveMessage" with a "msg" parameter) that needs to be handled by Javascript in the web browser. Historically we've been able to use t...
I was able to get this working using the following script block format, but I'm still curious if this is the best way: ``` <script for="MyControl" event="ReceiveMessage(msg)"> alert(msg); </script> ```
150,845
<p>I'm having issues creating an ActionLink using Preview 5. All the docs I can find describe the older generic version.</p> <p>I'm constructing links on a list of jobs on the page /jobs. Each job has a guid, and I'd like to construct a link to /jobs/details/{guid} so I can show details about the job. My jobs contr...
[ { "answer_id": 150871, "author": "Kevin Pang", "author_id": 1574, "author_profile": "https://Stackoverflow.com/users/1574", "pm_score": 1, "selected": false, "text": "<p>Have you defined a route to handle this in your Global.asax.cs file? The default route is {controller}/{action}/{id}....
2008/09/29
[ "https://Stackoverflow.com/questions/150845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having issues creating an ActionLink using Preview 5. All the docs I can find describe the older generic version. I'm constructing links on a list of jobs on the page /jobs. Each job has a guid, and I'd like to construct a link to /jobs/details/{guid} so I can show details about the job. My jobs controller has an ...
Give this a shot: ``` <%= Html.ActionLink(job.Name, "Details", new { guid = job.JobId}); %> ``` Where "guid" is the actual name of the parameter in your route. This instructs the routing engine that you want to place the value of the job.JobId property into the route definition's guid parameter.
150,881
<p>We are sending out Word documents via email (automated system, not by hand). The email is sent to the user, and CC'd to me.</p> <p>We are getting reports that some users are having the attachments come through corrupted, though when we open the copy that is CC'd to me, it opens fine.</p> <p>When the user forwards ...
[ { "answer_id": 150898, "author": "Asaf R", "author_id": 6827, "author_profile": "https://Stackoverflow.com/users/6827", "pm_score": 1, "selected": false, "text": "<p>If you use Windows I suggest using Visual Studio. There's a free Express Edition <a href=\"http://www.microsoft.com/expres...
2008/09/29
[ "https://Stackoverflow.com/questions/150881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2192/" ]
We are sending out Word documents via email (automated system, not by hand). The email is sent to the user, and CC'd to me. We are getting reports that some users are having the attachments come through corrupted, though when we open the copy that is CC'd to me, it opens fine. When the user forwards us the copy they ...
I have always been fond of [Code::Blocks](http://www.codeblocks.org) It's a wonderful C/C++ IDE, with several helpful addons. As for a compiler I've always used MingW but I hear [DigitalMars C/C++](http://www.digitalmars.com) compiler is good.
150,886
<p>I'm currently trying to debug a customer's issue with an FTP upload feature in one of our products. The feature allows customers to upload files (&lt; 1MB) to a central FTP server for further processing. The FTP client code was written in-house in VB.NET.</p> <p>The customer reports that they receive "Connection fo...
[ { "answer_id": 150894, "author": "Mostlyharmless", "author_id": 12881, "author_profile": "https://Stackoverflow.com/users/12881", "pm_score": 0, "selected": false, "text": "<p>I dont think the ISP would try to kill a 500KB file transfer. Im no expert in either socket thingy or on ISPs......
2008/09/29
[ "https://Stackoverflow.com/questions/150886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17862/" ]
I'm currently trying to debug a customer's issue with an FTP upload feature in one of our products. The feature allows customers to upload files (< 1MB) to a central FTP server for further processing. The FTP client code was written in-house in VB.NET. The customer reports that they receive "Connection forcibly closed...
Do a search for Comcast and BitTorrent. Here's [one article](http://www.alternet.org/columnists/story/69779/).
150,891
<p>I have a table with rowID, longitude, latitude, businessName, url, caption. This might look like:</p> <pre><code>rowID | long | lat | businessName | url | caption 1 20 -20 Pizza Hut yum.com null </code></pre> <p>How do I delete all of the duplicates, but only keep the one that has a URL (first...
[ { "answer_id": 150967, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 3, "selected": true, "text": "<p>Here's my looping technique. This will probably get voted down for not being mainstream - and I'm cool with that.</p>\n\n<p...
2008/09/29
[ "https://Stackoverflow.com/questions/150891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
I have a table with rowID, longitude, latitude, businessName, url, caption. This might look like: ``` rowID | long | lat | businessName | url | caption 1 20 -20 Pizza Hut yum.com null ``` How do I delete all of the duplicates, but only keep the one that has a URL (first priority), or keep the on...
Here's my looping technique. This will probably get voted down for not being mainstream - and I'm cool with that. ``` DECLARE @LoopVar int DECLARE @long int, @lat int, @businessname varchar(30), @winner int SET @LoopVar = (SELECT MIN(rowID) FROM Locations) WHILE @LoopVar is not null BEGIN --initialize the...
150,900
<p>I am creating a Windows Forms control derived from UserControl to be embedded in a WPF app. I have generally followed the procedures given in <a href="http://www.codeproject.com/KB/WPF/WPFOpenGL.aspx?display=Print" rel="nofollow noreferrer">this link</a>.</p> <pre><code>public ref class CTiledImgViewControl : publi...
[ { "answer_id": 151143, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 3, "selected": true, "text": "<p>The <code>OnPaint</code> won't normally get called in a <code>UserControl</code> unless you set the appropriate style...
2008/09/29
[ "https://Stackoverflow.com/questions/150900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
I am creating a Windows Forms control derived from UserControl to be embedded in a WPF app. I have generally followed the procedures given in [this link](http://www.codeproject.com/KB/WPF/WPFOpenGL.aspx?display=Print). ``` public ref class CTiledImgViewControl : public UserControl { ... virtual void OnPaint( PaintEve...
The `OnPaint` won't normally get called in a `UserControl` unless you set the appropriate style when it is constructed using the `SetStyle` method. You need to set the `UserPaint` style to true for the `OnPaint` to get called. ``` SetStyle(ControlStyles::UserPaint, true); ``` ### Update I recently encountered this ...
150,901
<p>Anyone know a good Regex expression to drop in the ValidationExpression to be sure that my users are only entering ASCII characters? </p> <pre><code>&lt;asp:RegularExpressionValidator id="myRegex" runat="server" ControlToValidate="txtName" ValidationExpression="???" ErrorMessage="Non-ASCII Characters" Display="Dyn...
[ { "answer_id": 150925, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 0, "selected": false, "text": "<p>If you want to map the possible 0x00 - 0xff ASCII values you can use this regular expression (.NET).</p>\n\n<pre><...
2008/09/29
[ "https://Stackoverflow.com/questions/150901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Anyone know a good Regex expression to drop in the ValidationExpression to be sure that my users are only entering ASCII characters? ``` <asp:RegularExpressionValidator id="myRegex" runat="server" ControlToValidate="txtName" ValidationExpression="???" ErrorMessage="Non-ASCII Characters" Display="Dynamic" /> ```
One thing you may want to watch out for is the lower part of the ASCII table has a lot of control characters which can cause funky results. Here's the expression I use to only allow "non-funky" characters: ``` ^([^\x0d\x0a\x20-\x7e\t]*)$ ```
150,902
<p>How can an object be loaded via Hibernate based on a field value of a member object? For example, suppose the following classes existed, with a one-to-one relationship between bar and foo:</p> <pre><code>Foo { Long id; } Bar { Long id; Foo aMember; } </code></pre> <p>How could one use Hibernate Criter...
[ { "answer_id": 150973, "author": "laz", "author_id": 8753, "author_profile": "https://Stackoverflow.com/users/8753", "pm_score": 3, "selected": true, "text": "<p>You can absolutely use Criteria in an efficient manner to accomplish this:</p>\n\n<pre><code>session.createCriteria(Bar.class)...
2008/09/29
[ "https://Stackoverflow.com/questions/150902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can an object be loaded via Hibernate based on a field value of a member object? For example, suppose the following classes existed, with a one-to-one relationship between bar and foo: ``` Foo { Long id; } Bar { Long id; Foo aMember; } ``` How could one use Hibernate Criteria to load Bar if you only...
You can absolutely use Criteria in an efficient manner to accomplish this: ``` session.createCriteria(Bar.class). createAlias("aMember", "a"). add(Restrictions.eq("a.id", fooId)); ``` ought to do the trick.
150,941
<p>Just found this out, so i am answering my own question :)</p> <p>Use a comma where you would normally use a colon. This can be a problem for named instances, as you seem to need to specify the port even if it is the default port 1433.</p> <p>Example:</p> <pre><code>Provider=SQLOLEDB;Data Source=192.168.200.123,14...
[ { "answer_id": 150975, "author": "BlackWasp", "author_id": 21862, "author_profile": "https://Stackoverflow.com/users/21862", "pm_score": 4, "selected": true, "text": "<p>I always check out <a href=\"http://www.connectionstrings.com/\" rel=\"noreferrer\">http://www.connectionstrings.com/<...
2008/09/29
[ "https://Stackoverflow.com/questions/150941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23616/" ]
Just found this out, so i am answering my own question :) Use a comma where you would normally use a colon. This can be a problem for named instances, as you seem to need to specify the port even if it is the default port 1433. Example: ``` Provider=SQLOLEDB;Data Source=192.168.200.123,1433; Initial Catalog=Northwin...
I always check out <http://www.connectionstrings.com/>. It is a brilliant resource for connection strings.
150,953
<p>I get the following error when attempting to install <a href="http://docs.rubygems.org/" rel="nofollow noreferrer">RubyGems</a>. I've tried Googling but have had no luck there. Has anybody encountered and resolved this issue before?</p> <pre><code> C:\rubygems-1.3.0> ruby setup.rb . . install -c -m 0644 rubygems/val...
[ { "answer_id": 150976, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 3, "selected": true, "text": "<p>I assume you're not trying to install under cygwin; that install is meant for unix-like operating systems. Edit: (Actu...
2008/09/29
[ "https://Stackoverflow.com/questions/150953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1969/" ]
I get the following error when attempting to install [RubyGems](http://docs.rubygems.org/). I've tried Googling but have had no luck there. Has anybody encountered and resolved this issue before? ``` C:\rubygems-1.3.0> ruby setup.rb . . install -c -m 0644 rubygems/validator.rb C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/...
I assume you're not trying to install under cygwin; that install is meant for unix-like operating systems. Edit: (Actually, from the log above it looks like there is some Windows-specific stuff being run... perhaps you're running into a UAC protection issue?) If you just use the [Windows ruby one-click installer](http...
150,977
<p>What is the best way to replace all '&amp;lt' with <code>&amp;lt;</code> in a given database column? Basically perform <code>s/&amp;lt[^;]/&amp;lt;/gi</code></p> <p>Notes:</p> <ul> <li>must work in <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005" rel="noreferrer">MS SQL Server</a> 2000</...
[ { "answer_id": 151072, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 5, "selected": true, "text": "<p>Some hacking required but we can do this with <strong>LIKE</strong>, <strong>PATINDEX</strong>, <strong>LEFT</stron...
2008/09/29
[ "https://Stackoverflow.com/questions/150977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/80/" ]
What is the best way to replace all '&lt' with `&lt;` in a given database column? Basically perform `s/&lt[^;]/&lt;/gi` Notes: * must work in [MS SQL Server](http://en.wikipedia.org/wiki/Microsoft_SQL_Server#SQL_Server_2005) 2000 * Must be repeatable (and not end up with `&lt;;;;;;;;;;`)
Some hacking required but we can do this with **LIKE**, **PATINDEX**, **LEFT** AND **RIGHT** and good old string concatenation. ``` create table test ( id int identity(1, 1) not null, val varchar(25) not null ) insert into test values ('&lt; <- ok, &lt <- nok') while 1 = 1 begin update test set v...
150,998
<p>In my ActionScript3 class, can I have a property with a getter and setter?</p>
[ { "answer_id": 151108, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 5, "selected": true, "text": "<p>Ok, well you can just use the basic getter/setter syntax for any property of your AS3 class. For example</p>\n\n<pr...
2008/09/29
[ "https://Stackoverflow.com/questions/150998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14131/" ]
In my ActionScript3 class, can I have a property with a getter and setter?
Ok, well you can just use the basic getter/setter syntax for any property of your AS3 class. For example ``` package { public class PropEG { private var _prop:String; public function get prop():String { return _prop; } public function set prop(value:String):void { ...
151,000
<p>I've got a class named <code>BackgroundWorker</code> that has a thread constantly running. To turn this thread off, an instance variable named <code>stop</code> to needs to be <code>true</code>. </p> <p>To make sure the thread is freed when the class is done being used, I've added <code>IDisposable</code> and a fin...
[ { "answer_id": 151022, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 0, "selected": false, "text": "<p>Is the \"stop\" instance variable a property? If not, there's no particular point in setting it during the finali...
2008/09/29
[ "https://Stackoverflow.com/questions/151000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
I've got a class named `BackgroundWorker` that has a thread constantly running. To turn this thread off, an instance variable named `stop` to needs to be `true`. To make sure the thread is freed when the class is done being used, I've added `IDisposable` and a finalizer that invokes `Dispose()`. Assuming that `stop =...
Your code is fine, although locking in a finalizer is somewhat "scary" and I would avoid it - if you get a deadlock... I am not 100% certain what would happen but it would not be good. However, if you are safe this should not be a problem. Mostly. The internals of garbage collection are painful and I hope you never hav...
151,005
<p>How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?</p>
[ { "answer_id": 151014, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 6, "selected": false, "text": "<p>You actually might want to check out the interop classes available in C# (e.g. <code>Microsoft.Office.Interop.Excel</code...
2008/09/29
[ "https://Stackoverflow.com/questions/151005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19242/" ]
How can I create an Excel spreadsheet with C# without requiring Excel to be installed on the machine that's running the code?
You can use a library called ExcelLibrary. It's a free, open source library posted on Google Code: [ExcelLibrary](https://code.google.com/archive/p/excellibrary/) This looks to be a port of the PHP ExcelWriter that you mentioned above. It will not write to the new .xlsx format yet, but they are working on adding that...
151,026
<pre><code>sqlite&gt; DELETE FROM mails WHERE (`id` = 71); SQL error: database is locked </code></pre> <p>How do I unlock the database so this will work?</p>
[ { "answer_id": 151040, "author": "Heat Miser", "author_id": 3484, "author_profile": "https://Stackoverflow.com/users/3484", "pm_score": 4, "selected": false, "text": "<p>the SQLite db files are just files, so the first step would be to make sure it isn't read-only. The other thing to do...
2008/09/29
[ "https://Stackoverflow.com/questions/151026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/823/" ]
``` sqlite> DELETE FROM mails WHERE (`id` = 71); SQL error: database is locked ``` How do I unlock the database so this will work?
In windows you can try this program <http://www.nirsoft.net/utils/opened_files_view.html> to find out the process is handling db file. Try closed that program for unlock database In Linux and macOS you can do something similar, for example, if your locked file is development.db: > > $ fuser development.db > > > ...
151,030
<p>When I load <code>script/console</code>, sometimes I want to play with the output of a controller or a view helper method.</p> <p>Are there ways to:</p> <ul> <li>simulate a request?</li> <li>call methods from a controller instance on said request?</li> <li>test helper methods, either via said controller instance o...
[ { "answer_id": 151285, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 6, "selected": false, "text": "<p>Here's one way to do this through the console:</p>\n\n<pre><code>&gt;&gt; foo = ActionView::Base.new\n=&gt; #&lt;...
2008/09/29
[ "https://Stackoverflow.com/questions/151030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
When I load `script/console`, sometimes I want to play with the output of a controller or a view helper method. Are there ways to: * simulate a request? * call methods from a controller instance on said request? * test helper methods, either via said controller instance or another way?
To call helpers, use the `helper` object: ``` $ ./script/console >> helper.number_to_currency('123.45') => "R$ 123,45" ``` If you want to use a helper that's not included by default (say, because you removed `helper :all` from `ApplicationController`), just include the helper. ``` >> include BogusHelper >> helper.b...
151,034
<p>I've been using Eclipse pretty regularly for several years now, but I admit to not having explored all the esoterica it has to offer, particularly in the areas of what formatting features the editors offer.</p> <p>The main thing I miss from (X)emacs is the "align-regex" command, which let me take several lines into...
[ { "answer_id": 151134, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 4, "selected": true, "text": "<p>You can set the formatter to do this:</p>\n\n<p>Preferences -> Java -> Code Style -> Formatter. Click 'Edit' on the profile (...
2008/09/29
[ "https://Stackoverflow.com/questions/151034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6421/" ]
I've been using Eclipse pretty regularly for several years now, but I admit to not having explored all the esoterica it has to offer, particularly in the areas of what formatting features the editors offer. The main thing I miss from (X)emacs is the "align-regex" command, which let me take several lines into a region ...
You can set the formatter to do this: Preferences -> Java -> Code Style -> Formatter. Click 'Edit' on the profile (you may need to make a new one since you can't edit the default). In the indentation section select 'Align fields with columns'. Then, in your code `CTRL`+`SHIFT`+`F` will run that formatter. That will...
151,046
<p>I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following:</p> <pre><code>for (iter = someMap.begin(); iter != someMap.end(); ++iter) { bool last_iteration; // do something for all iterations if (!last_iteration)...
[ { "answer_id": 151073, "author": "Torlack", "author_id": 5243, "author_profile": "https://Stackoverflow.com/users/5243", "pm_score": 4, "selected": false, "text": "<p>This seems like the simplest:</p>\n\n<pre><code>bool last_iteration = iter == (--someMap.end());\n</code></pre>\n" }, ...
2008/09/29
[ "https://Stackoverflow.com/questions/151046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I'm trying to figure out the best way to determine whether I'm in the last iteration of a loop over a map in order to do something like the following: ``` for (iter = someMap.begin(); iter != someMap.end(); ++iter) { bool last_iteration; // do something for all iterations if (!last_iteration) { // ...
Canonical? I can't claim that, but I'd suggest ``` final_iter = someMap.end(); --final_iter; if (iter != final_iter) ... ``` **Edited** to correct as suggested by **[KTC](https://stackoverflow.com/questions/151046/c-last-loop-iteration-stl-map-iterator#151104).** (Thanks! Sometimes you go too quick and mess up on t...
151,051
<p>In .NET, under which circumstances should I use <code>GC.SuppressFinalize()</code>?</p> <p>What advantage(s) does using this method give me?</p>
[ { "answer_id": 151058, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": -1, "selected": false, "text": "<p>That method must be called on the <code>Dispose</code> method of objects that implements the <code>IDisposable</code...
2008/09/29
[ "https://Stackoverflow.com/questions/151051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
In .NET, under which circumstances should I use `GC.SuppressFinalize()`? What advantage(s) does using this method give me?
`SuppressFinalize` should only be called by a class that has a finalizer. It's informing the Garbage Collector (GC) that `this` object was cleaned up fully. The recommended `IDisposable` pattern when you have a finalizer is: ``` public class MyClass : IDisposable { private bool disposed = false; protected vi...
151,066
<p>I have a Ruby/Rails app that has two or three main "sections". When a user visits that section, I wish to display some sub-navigation. All three sections use the same layout, so I can't "hard code" the navigation into the layout.</p> <p>I can think of a few different methods to do this. I guess in order to help peo...
[ { "answer_id": 151071, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 3, "selected": false, "text": "<ol start=\"3\">\n<li><strong>Partial render</strong>. This is very similar to the helper method except perhaps the layo...
2008/09/29
[ "https://Stackoverflow.com/questions/151066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2590/" ]
I have a Ruby/Rails app that has two or three main "sections". When a user visits that section, I wish to display some sub-navigation. All three sections use the same layout, so I can't "hard code" the navigation into the layout. I can think of a few different methods to do this. I guess in order to help people vote I...
You can easily do this using partials, assuming each section has it's own controller. Let's say you have three sections called **Posts**, **Users** and **Admin**, each with it's own controller: `PostsController`, `UsersController` and `AdminController`. In each corresponding `views` directory, you declare a `_subnav....
151,079
<p>My app generates PDFs for user consumption. The "Content-Disposition" http header is set as mentioned <a href="https://stackoverflow.com/questions/74019/specifying-filename-for-dynamic-pdf-in-aspnet">here</a>. This is set to "inline; filename=foo.pdf", which should be enough for Acrobat to give "foo.pdf" as the fi...
[ { "answer_id": 151196, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 0, "selected": false, "text": "<p>You could always have two links. One that opens the document inside the browser, and another to download it (usi...
2008/09/29
[ "https://Stackoverflow.com/questions/151079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9365/" ]
My app generates PDFs for user consumption. The "Content-Disposition" http header is set as mentioned [here](https://stackoverflow.com/questions/74019/specifying-filename-for-dynamic-pdf-in-aspnet). This is set to "inline; filename=foo.pdf", which should be enough for Acrobat to give "foo.pdf" as the filename when savi...
Part of the problem is that the relevant [RFC 2183](http://greenbytes.de/tech/webdav/rfc2183.html) doesn't really state what to do with a disposition type of "inline" and a filename. Also, as far as I can tell, the only UA that actually uses the filename for type=inline is Firefox (see [test case](http://greenbytes.de...
151,083
<p>Having this route:</p> <pre><code>map.foo 'foo/*path', :controller =&gt; 'foo', :action =&gt; 'index' </code></pre> <p>I have the following results for the <code>link_to</code> call</p> <pre><code>link_to "Foo", :controller =&gt; 'foo', :path =&gt; 'bar/baz' # &lt;a href="/foo/bar%2Fbaz"&gt;Foo&lt;/a&gt; </code><...
[ { "answer_id": 151239, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 3, "selected": true, "text": "<p>Instead of passing path a string, give it an array.</p>\n\n<pre><code>link_to \"Foo\", :controller =&gt; 'foo', :p...
2008/09/29
[ "https://Stackoverflow.com/questions/151083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
Having this route: ``` map.foo 'foo/*path', :controller => 'foo', :action => 'index' ``` I have the following results for the `link_to` call ``` link_to "Foo", :controller => 'foo', :path => 'bar/baz' # <a href="/foo/bar%2Fbaz">Foo</a> ``` Calling `url_for` or `foo_url` directly, even with `:escape => false`, giv...
Instead of passing path a string, give it an array. ``` link_to "Foo", :controller => 'foo', :path => %w(bar baz) # <a href="/foo/bar/baz">Foo</a> ``` If you didn't have the route in your routes file, this same link\_to would instead create this: ``` # <a href="/foo?path[]=bar&path[]=baz">Foo</a> ``` The only pla...
151,099
<p>I have two tables that are joined together. </p> <p>A has many B</p> <p>Normally you would do: </p> <pre><code>select * from a,b where b.a_id = a.id </code></pre> <p>To get all of the records from a that has a record in b. </p> <p>How do I get just the records in a that does not have anything in b?</p>
[ { "answer_id": 151102, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 8, "selected": true, "text": "<pre><code>select * from a where id not in (select a_id from b)\n</code></pre>\n\n<p>Or like some other people on this th...
2008/09/29
[ "https://Stackoverflow.com/questions/151099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
I have two tables that are joined together. A has many B Normally you would do: ``` select * from a,b where b.a_id = a.id ``` To get all of the records from a that has a record in b. How do I get just the records in a that does not have anything in b?
``` select * from a where id not in (select a_id from b) ``` Or like some other people on this thread says: ``` select a.* from a left outer join b on a.id = b.a_id where b.a_id is null ```
151,100
<p>I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have an entity, <code>User</code>, which I have mapped to a table <code>USERS</code> in the DB using Hibernate. I want to have an image associated with this entity, which I plan to store as a <code>BLOB</code> in the DB. I also want to di...
[ { "answer_id": 151136, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 0, "selected": false, "text": "<p>If you want to display the user image directly with their properties perhaps you can consider embedding the image ...
2008/09/29
[ "https://Stackoverflow.com/questions/151100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3973/" ]
I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have an entity, `User`, which I have mapped to a table `USERS` in the DB using Hibernate. I want to have an image associated with this entity, which I plan to store as a `BLOB` in the DB. I also want to display the image on a webpage along w...
Yes your suggested solution will work. Given that you are working in a Java environment storing the images in the database is the best way to go. If you are running in a single server environment with an application server that will let you deploy in an exploded format technically you could store the images on disk but...
151,124
<p>Which one should I use?</p> <pre><code>catch (_com_error e) </code></pre> <p>or </p> <pre><code>catch (_com_error&amp; e) </code></pre>
[ { "answer_id": 151126, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 6, "selected": true, "text": "<p>The second. Here is my attempt at quoting Sutter</p>\n\n<p>\"Throw by value, catch by reference\"</p>\n\n<blockquote>\...
2008/09/29
[ "https://Stackoverflow.com/questions/151124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
Which one should I use? ``` catch (_com_error e) ``` or ``` catch (_com_error& e) ```
The second. Here is my attempt at quoting Sutter "Throw by value, catch by reference" > > Learn to `catch` properly: Throw exceptions by value (not pointer) and > catch them by reference (usually to `const`). This is the combination > that meshes best with exception semantics. When rethrowing the same > exception...
151,152
<p>I'm using spring 2.5, and am using annotations to configure my controllers. My controller works fine if I do not implement any additional interfaces, but the spring container doesn't recognize the controller/request mapping when I add interface implementations.</p> <p>I can't figure out why adding an interface imp...
[ { "answer_id": 185587, "author": "abarax", "author_id": 24390, "author_profile": "https://Stackoverflow.com/users/24390", "pm_score": 0, "selected": false, "text": "<p>I think you'll find that the problem is to do with inheritance and using annotations, they do not mix well. </p>\n\n<p>...
2008/09/29
[ "https://Stackoverflow.com/questions/151152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9955/" ]
I'm using spring 2.5, and am using annotations to configure my controllers. My controller works fine if I do not implement any additional interfaces, but the spring container doesn't recognize the controller/request mapping when I add interface implementations. I can't figure out why adding an interface implementation...
*layne*, you described the problem as happening when your controller class implements an interface, but in the code sample you provided, the problem occurs when your controller class extends another class of yours, `ValidatingController`. Perhaps the parent class also defines some Spring annotations, and the Spring co...
151,195
<p>I have a bunch of tasks in a MySQL database, and one of the fields is "deadline date". Not every task has to have to a deadline date.</p> <p>I'd like to use SQL to sort the tasks by deadline date, but put the ones without a deadline date in the back of the result set. As it is now, the null dates show up first, the...
[ { "answer_id": 151202, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT foo, bar, due_date FROM tablename\nORDER BY CASE ISNULL(due_date, 0)\nWHEN 0 THEN 1 ELSE 0 END, due_date\n...
2008/09/29
[ "https://Stackoverflow.com/questions/151195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a bunch of tasks in a MySQL database, and one of the fields is "deadline date". Not every task has to have to a deadline date. I'd like to use SQL to sort the tasks by deadline date, but put the ones without a deadline date in the back of the result set. As it is now, the null dates show up first, then the rest...
Here's a solution using only standard SQL, not ISNULL(). That function is not standard SQL, and may not work on other brands of RDBMS. ``` SELECT * FROM myTable WHERE ... ORDER BY CASE WHEN myDate IS NULL THEN 1 ELSE 0 END, myDate; ```
151,199
<p>If I have two dates (ex. <code>'8/18/2008'</code> and <code>'9/26/2008'</code>), what is the best way to get the number of days between these two dates?</p>
[ { "answer_id": 151211, "author": "Dana", "author_id": 7856, "author_profile": "https://Stackoverflow.com/users/7856", "pm_score": 11, "selected": true, "text": "<p>If you have two date objects, you can just subtract them, which computes a <a href=\"https://docs.python.org/3/library/datet...
2008/09/29
[ "https://Stackoverflow.com/questions/151199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
If I have two dates (ex. `'8/18/2008'` and `'9/26/2008'`), what is the best way to get the number of days between these two dates?
If you have two date objects, you can just subtract them, which computes a [`timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta) object. ``` from datetime import date d0 = date(2008, 8, 18) d1 = date(2008, 9, 26) delta = d1 - d0 print(delta.days) ``` The relevant section of the docs: <ht...
151,204
<p>I have a folder, '/var/unity/conf' with some properties files in it, and I'd like the Caucho's Resin JVM to have that directory on the classpath.</p> <p>What is the best way to modifiy resin.conf so that Resin knows to add this directory to the classpath?</p>
[ { "answer_id": 151663, "author": "Vugluskr", "author_id": 16826, "author_profile": "https://Stackoverflow.com/users/16826", "pm_score": 1, "selected": false, "text": "<p>cd %RESIN_HOME%/lib | \nln -s /var/unity/conf/....</p>\n" }, { "answer_id": 1176542, "author": "Mike", ...
2008/09/29
[ "https://Stackoverflow.com/questions/151204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18320/" ]
I have a folder, '/var/unity/conf' with some properties files in it, and I'd like the Caucho's Resin JVM to have that directory on the classpath. What is the best way to modifiy resin.conf so that Resin knows to add this directory to the classpath?
With Resin 3.1.6 and above, use ``` <server-default> ... <jvm-classpath>/var/unity/conf/...</jvm-classpath> ... </server-default> ``` (I know, very late to the game, I was searching for the answer to this myself and found this post here, as well as the solution, so thought I'd add back to the collective)...
151,210
<p>So I just interviewed two people today, and gave them "tests" to see what their skills were like. Both are entry level applicants, one of which is actually still in college. Neither applicant saw anything wrong with the following code.</p> <p>I do, obviously or I wouldn't have picked those examples. <strong>Do yo...
[ { "answer_id": 151221, "author": "jussij", "author_id": 14738, "author_profile": "https://Stackoverflow.com/users/14738", "pm_score": 0, "selected": false, "text": "<p><strong>Question #1</strong> </p>\n\n<pre><code> boolean active = true;\n</code></pre>\n\n<p><strong>Question #2</stron...
2008/09/29
[ "https://Stackoverflow.com/questions/151210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17145/" ]
So I just interviewed two people today, and gave them "tests" to see what their skills were like. Both are entry level applicants, one of which is actually still in college. Neither applicant saw anything wrong with the following code. I do, obviously or I wouldn't have picked those examples. **Do you think these ques...
I don't typically throw code at someone interviewing for a position and say "what's wrong?", mainly because I'm not convinced it really finds me the best candidate. Interviews are sometimes stressful and a bit overwhelming and coders aren't always on their A-game. Regarding the questions, honestly I think that if I di...
151,231
<p>I need to get the actual local network IP address of the computer (e.g. 192.168.0.220) from my program using C# and .NET 3.5. I can't just use 127.0.0.1 in this case.</p> <p>How can I accomplish this?</p>
[ { "answer_id": 151237, "author": "PostMan", "author_id": 18405, "author_profile": "https://Stackoverflow.com/users/18405", "pm_score": 6, "selected": true, "text": "<p>In <a href=\"http://www.devcity.net/Articles/62/1/gethostbyname.aspx\" rel=\"nofollow noreferrer\" title=\"Article by Jo...
2008/09/29
[ "https://Stackoverflow.com/questions/151231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I need to get the actual local network IP address of the computer (e.g. 192.168.0.220) from my program using C# and .NET 3.5. I can't just use 127.0.0.1 in this case. How can I accomplish this?
In [*How to get IP addresses in .NET with a host name*](http://www.devcity.net/Articles/62/1/gethostbyname.aspx "Article by John Spano, Published 1 Dec 2002") by John Spano, it says to add the `System.Net` namespace, and use the following code: > > > ``` > //To get the local IP address > string sHostName = Dns.GetH...
151,238
<p>It seems that I've never got this to work in the past. Currently, I KNOW it doesn't work.</p> <p>But we start up our Java process:</p> <pre><code>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6002 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false </code...
[ { "answer_id": 151626, "author": "Craig Day", "author_id": 5193, "author_profile": "https://Stackoverflow.com/users/5193", "pm_score": 4, "selected": false, "text": "<p>Are you running on Linux? Perhaps the management agent is binding to localhost:</p>\n\n<p><a href=\"http://java.sun.com...
2008/09/29
[ "https://Stackoverflow.com/questions/151238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13663/" ]
It seems that I've never got this to work in the past. Currently, I KNOW it doesn't work. But we start up our Java process: ``` -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=6002 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false ``` I can telnet to the p...
I have a solution for this: If your **Java process is running on Linux behind a firewall** and you want to start **JConsole / Java VisualVM / Java Mission Control** on Windows on your local machine to connect it to the **JMX Port of your Java process**. You need access to your linux machine via SSH login. All Communi...
151,303
<p>Using the <code>AddHandler</code> method, if I never use <code>RemoveHandler</code>, will that lead to memory leaks in some conditions and situations? I'm not so sure about the truth of this.</p> <p>And are there other causes to memory leaks that are solely available in VB as opposed to C#?</p>
[ { "answer_id": 151306, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 1, "selected": false, "text": "<p>If object a is suscribed to the object b event then object b will not be collected until object a is collected.</p>\n...
2008/09/30
[ "https://Stackoverflow.com/questions/151303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8505/" ]
Using the `AddHandler` method, if I never use `RemoveHandler`, will that lead to memory leaks in some conditions and situations? I'm not so sure about the truth of this. And are there other causes to memory leaks that are solely available in VB as opposed to C#?
*Well usually it doesn't.. but the possibility exists.* When you subscribe to an event, you basically give a delegate (a func pointer if you will) to your method to the event publisher, who holds on to it as long as you do not unsubscribe with the -= operator. So take for example, the case where you spawn a child f...
151,338
<p>How can I add an instance variable to a defined class at <b>runtime</b>, and later get and set its value from outside of the class?</p> <p>I'm looking for a metaprogramming solution that allows me to modify the class instance at runtime instead of modifying the source code that originally defined the class. A few ...
[ { "answer_id": 151354, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 6, "selected": false, "text": "<p>Ruby provides methods for this, <code>instance_variable_get</code> and <code>instance_variable_set</code>. (<a hr...
2008/09/30
[ "https://Stackoverflow.com/questions/151338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
How can I add an instance variable to a defined class at **runtime**, and later get and set its value from outside of the class? I'm looking for a metaprogramming solution that allows me to modify the class instance at runtime instead of modifying the source code that originally defined the class. A few of the solutio...
You can use attribute accessors: ``` class Array attr_accessor :var end ``` Now you can access it via: ``` array = [] array.var = 123 puts array.var ``` --- Note that you can also use `attr_reader` or `attr_writer` to define just getters or setters or you can define them manually as such: ``` class Array at...
151,348
<p>Why is NodeList undefined in IE6/7?</p> <pre><code>&lt;form action="/" method="post" id="testform"&gt; &lt;input type="checkbox" name="foobar[]" value="1" id="" /&gt; &lt;input type="checkbox" name="foobar[]" value="2" id="" /&gt; &lt;input type="checkbox" name="foobar[]" value="3" id="" /&gt; &lt;/...
[ { "answer_id": 151412, "author": "Jeremy DeGroot", "author_id": 20820, "author_profile": "https://Stackoverflow.com/users/20820", "pm_score": 0, "selected": false, "text": "<p>I would just use something that always evaluates to a certain type. Then you just do a true/false type check to...
2008/09/30
[ "https://Stackoverflow.com/questions/151348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8369/" ]
Why is NodeList undefined in IE6/7? ``` <form action="/" method="post" id="testform"> <input type="checkbox" name="foobar[]" value="1" id="" /> <input type="checkbox" name="foobar[]" value="2" id="" /> <input type="checkbox" name="foobar[]" value="3" id="" /> </form> <script type="text/javascript" cha...
"[Duck Typing](http://en.wikipedia.org/wiki/Duck_typing)" should always work: ``` ... if (typeof el.length == 'number' && typeof el.item == 'function' && typeof el.nextNode == 'function' && typeof el.reset == 'function') { alert("I'm a NodeList"); } ```
151,362
<p>For posting AJAX forms in a form with many parameters, I am using a solution of creating an <code>iframe</code>, posting the form to it by POST, and then accessing the <code>iframe</code>'s content. specifically, I am accessing the content like this:</p> <pre><code>$("some_iframe_id").get(0).contentWindow.document...
[ { "answer_id": 151374, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": 0, "selected": false, "text": "<p>Basically, this error occurs when the document in frame and outside of ii have different domains. So to prevent cr...
2008/09/30
[ "https://Stackoverflow.com/questions/151362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
For posting AJAX forms in a form with many parameters, I am using a solution of creating an `iframe`, posting the form to it by POST, and then accessing the `iframe`'s content. specifically, I am accessing the content like this: ``` $("some_iframe_id").get(0).contentWindow.document ``` I tested it and it worked. ...
Solved it by myself! The problem was, that even though the correct response was being sent (verified with Fiddler), it was being sent with an HTTP 500 error code (instead of 200). So it turns out, that if a response is sent with an error code, IE replaces the content of the `iframe` with an error message loaded from ...
151,369
<p>Given an HTML page that has a complex table-based layout and many tags that are duplicated and wasteful, e.g.:</p> <pre><code>td align="left" class="tableformat" width="65%" style="border-bottom:1px solid #ff9600; border-right:1px solid #ff9600; background-color:#FDD69E" nowrap etc. </code></pre> <p>Are there tool...
[ { "answer_id": 151466, "author": "TimB", "author_id": 4193, "author_profile": "https://Stackoverflow.com/users/4193", "pm_score": 2, "selected": false, "text": "<p>I'm not aware of specific tools, only the generic ones of caffeine and <a href=\"http://getfirebug.com/\" rel=\"nofollow nor...
2008/09/30
[ "https://Stackoverflow.com/questions/151369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10116/" ]
Given an HTML page that has a complex table-based layout and many tags that are duplicated and wasteful, e.g.: ``` td align="left" class="tableformat" width="65%" style="border-bottom:1px solid #ff9600; border-right:1px solid #ff9600; background-color:#FDD69E" nowrap etc. ``` Are there tools to aide the task of refa...
I agree with [TimB](https://stackoverflow.com/questions/151369/tools-for-refactoring-table-based-html-layouts-to-css#151466) in that automated tools are going to have trouble doing this, in particular making the relational jumps to combine and abstract CSS in the most efficient way. If you are presenting tabular data,...
151,392
<p>Does anyone know any good tool that I can use to perform stress tests on a video streaming server? I need to test how well my server handles 5,000+ connections. </p>
[ { "answer_id": 151571, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "<p>start downloading 5000+ files of the same type with different connections. Don't really need to play them, because esse...
2008/09/30
[ "https://Stackoverflow.com/questions/151392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23637/" ]
Does anyone know any good tool that I can use to perform stress tests on a video streaming server? I need to test how well my server handles 5,000+ connections.
One option is to use VLC. You can specify a url on the command line. (see [here](http://wiki.videolan.org/VLC_command-line_help) for details). You could then write a brief shell script to open up all 5000 connections. eg. the following perl script (very quick hack - check before running, might cause explosions etc.) ...
151,407
<p>Under Linux, my C++ application is using fork() and execv() to launch multiple instances of OpenOffice so as to view some powerpoint slide shows. This part works.</p> <p>Next I want to be able to move the OpenOffice windows to specific locations on the display. I can do that with the XMoveResizeWindow() function bu...
[ { "answer_id": 151512, "author": "Tanktalus", "author_id": 23512, "author_profile": "https://Stackoverflow.com/users/23512", "pm_score": 1, "selected": false, "text": "<p>Are you sure you have the process ID of each instance? My experience with OOo has been that trying to run a second i...
2008/09/30
[ "https://Stackoverflow.com/questions/151407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5324/" ]
Under Linux, my C++ application is using fork() and execv() to launch multiple instances of OpenOffice so as to view some powerpoint slide shows. This part works. Next I want to be able to move the OpenOffice windows to specific locations on the display. I can do that with the XMoveResizeWindow() function but I need t...
The only way I know to do this is to traverse the tree of windows until you find what you're looking for. Traversing isn't hard (just see what xwininfo -root -tree does by looking at xwininfo.c if you need an example). But how do you identify the window you are looking for? **Some** applications set a window property ...
151,413
<p>I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. I've got all the generated c# proxies (which are derived from Microsoft.Web.Services2.WebServicesClientProtocol), i'm applying the certificate but when i call a method i get an error:</p> <pre><code>System.Net.WebException : The r...
[ { "answer_id": 151416, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 0, "selected": false, "text": "<p>hmm are those other clients also using C#/.NET?</p>\n\n<p>Method not allowed --> could this be a REST service, instead of...
2008/09/30
[ "https://Stackoverflow.com/questions/151413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10793/" ]
I've got a siluation where i need to access a SOAP web service with WSE 2.0 security. I've got all the generated c# proxies (which are derived from Microsoft.Web.Services2.WebServicesClientProtocol), i'm applying the certificate but when i call a method i get an error: ``` System.Net.WebException : The request failed ...
Ok, found what the problem was. I was trying to call a .wsdl url instead of .asmx url. Doh!
151,414
<p>Here is the directory layout that was installed with Leopard. What is the "A" directory and why the "Current" directory in addition to the "CurrentJDK"?</p> <p>It seems like you can easily switch the current JDK by move the CurrentJDK link, but then the contents under Current and A will be out of sync.</p> <pre> ...
[ { "answer_id": 151463, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 4, "selected": true, "text": "<p>The (<code>A</code>, <code>Current</code> symbolic-linked to <code>A</code>) is part of the structure of a Mac OS X fra...
2008/09/30
[ "https://Stackoverflow.com/questions/151414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21176/" ]
Here is the directory layout that was installed with Leopard. What is the "A" directory and why the "Current" directory in addition to the "CurrentJDK"? It seems like you can easily switch the current JDK by move the CurrentJDK link, but then the contents under Current and A will be out of sync. ``` lrwxr-xr-x 1 ro...
The (`A`, `Current` symbolic-linked to `A`) is part of the structure of a Mac OS X framework, which `JavaVM.framework` is. This framework may have C or Objective-C code in it, in addition to the actual JVM installations. Thus it could potentially be linked against from some C or Objective-C code in addition to containi...
151,418
<p>I have a function pointer defined by:</p> <pre><code>typedef void (*EventFunction)(int nEvent); </code></pre> <p>Is there a way to handle that function with a specific instance of a C++ object?</p> <pre><code>class A { private: EventFunction handler; public: void SetEvent(EventFunction func) { handler = ...
[ { "answer_id": 151427, "author": "markets", "author_id": 4662, "author_profile": "https://Stackoverflow.com/users/4662", "pm_score": 1, "selected": false, "text": "<p>Unfortunately, the EventFunction type cannot point to a function of B, because it is not the correct type. You could make...
2008/09/30
[ "https://Stackoverflow.com/questions/151418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4592/" ]
I have a function pointer defined by: ``` typedef void (*EventFunction)(int nEvent); ``` Is there a way to handle that function with a specific instance of a C++ object? ``` class A { private: EventFunction handler; public: void SetEvent(EventFunction func) { handler = func; } void EventOne() { handle...
I highly recommend Don Clugston's excellent FastDelegate library. It provides all the things you'd expect of a real delegate and compiles down to a few ASM instructions in most cases. The accompanying article is a good read on member function pointers as well. <http://www.codeproject.com/KB/cpp/FastDelegate.aspx>
151,448
<p>Bearing in mind this is for <strong>classic asp</strong></p> <p>Which is better, all HTML contained within Response.Write Statements or inserting variables into HTML via &lt;%= %>.<br> Eg </p> <pre><code>Response.Write "&lt;table&gt;" &amp; vbCrlf Response.Write "&lt;tr&gt;" &amp;vbCrLf Response.Write "&lt;td cla...
[ { "answer_id": 151454, "author": "Jon P", "author_id": 4665, "author_profile": "https://Stackoverflow.com/users/4665", "pm_score": 4, "selected": false, "text": "<p>From a personal preference point of view I prefer the &lt;%= %> method as I feel it provides a better separation variable c...
2008/09/30
[ "https://Stackoverflow.com/questions/151448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4665/" ]
Bearing in mind this is for **classic asp** Which is better, all HTML contained within Response.Write Statements or inserting variables into HTML via <%= %>. Eg ``` Response.Write "<table>" & vbCrlf Response.Write "<tr>" &vbCrLf Response.Write "<td class=""someClass"">" & someVariable & "</td>" & vbCrLf Response....
First, The most important factor you should be looking at is ease of maintenance. You could buy a server farm with the money and time you would otherwise waste by having to decipher a messy web site to maintain it. In any case, it doesn't matter. At the end of the day, all ASP does is just execute a script! The ASP pa...
151,521
<p>I'm a LINQ to XML newbie, and a KML newbie as well; so bear with me. </p> <p>My goal is to extract individual Placemarks from a KML file. My KML begins thusly:</p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;Document xmlns="http://earth.google.com/kml/2.0"&gt; ...
[ { "answer_id": 151561, "author": "Bruce Murdock", "author_id": 23650, "author_profile": "https://Stackoverflow.com/users/23650", "pm_score": 0, "selected": false, "text": "<p>You may need to add a namespace to the XElement name</p>\n\n<pre><code>Dim ns as string = \"http://earth.google.c...
2008/09/30
[ "https://Stackoverflow.com/questions/151521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I'm a LINQ to XML newbie, and a KML newbie as well; so bear with me. My goal is to extract individual Placemarks from a KML file. My KML begins thusly: ```xml <?xml version="1.0" encoding="utf-8"?> <Document xmlns="http://earth.google.com/kml/2.0"> <name>Concessions</name> <visibility>1</visibility> <Folder> ...
Thanks to spoon16 and Bruce Murdock for pointing me in the right direction. The code that spoon16 posted works, but forces you to concatenate the namespace with every single element name, which isn't as clean as I'd like. I've done a bit more searching and I've figured out how this is supposed to be done - this is sup...
151,545
<p>I need to get the fully expanded hostname of the host that my Ruby script is running on. In Perl I've used Sys::Hostname::Long with good results. Google seems to suggest I should use Socket.hostname in ruby, but that's returning just the nodename, not the full hostname.</p>
[ { "answer_id": 151570, "author": "dvorak", "author_id": 19235, "author_profile": "https://Stackoverflow.com/users/19235", "pm_score": 4, "selected": false, "text": "<p>This seems to work:</p>\n\n<pre><code>hostname = Socket.gethostbyname(Socket.gethostname).first \n</code></pre>\n" }, ...
2008/09/30
[ "https://Stackoverflow.com/questions/151545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19235/" ]
I need to get the fully expanded hostname of the host that my Ruby script is running on. In Perl I've used Sys::Hostname::Long with good results. Google seems to suggest I should use Socket.hostname in ruby, but that's returning just the nodename, not the full hostname.
This seems to work: ``` hostname = Socket.gethostbyname(Socket.gethostname).first ```
151,555
<p>I'm creating a Firefox extension for demo purposes. I to call a specific JavaScript function in the document from the extension. I wrote this in my HTML document (not inside extension, but a page that is loaded by Firefox):</p> <pre><code>document.funcToBeCalled = function() { // function body }; </code></pre> ...
[ { "answer_id": 151786, "author": "scottru", "author_id": 8192, "author_profile": "https://Stackoverflow.com/users/8192", "pm_score": 0, "selected": false, "text": "<p>You can do it, but you need to have control over the page and be able to raise the privilege level for the script. <a hre...
2008/09/30
[ "https://Stackoverflow.com/questions/151555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
I'm creating a Firefox extension for demo purposes. I to call a specific JavaScript function in the document from the extension. I wrote this in my HTML document (not inside extension, but a page that is loaded by Firefox): ``` document.funcToBeCalled = function() { // function body }; ``` Then, the extension wil...
It is for security reasons that you have limited access to the content page from extension. See [XPCNativeWrapper](http://developer.mozilla.org/en/docs/XPCNativeWrapper) and [Safely accessing content DOM from chrome](http://developer.mozilla.org/en/Safely_accessing_content_DOM_from_chrome), If you control the page, th...
151,587
<p>I'm a huge fan of bzr and I'm glad they're working on tortoise for it, but currently it's WAY too slow to be useful. The icons are almost always incorrect and when I load a directory in explorer with a lot of branches it locks up my entire system for anywhere from 10 seconds to 2 minutes. I look forward to trying ...
[ { "answer_id": 151911, "author": "Jason Anderson", "author_id": 5142, "author_profile": "https://Stackoverflow.com/users/5142", "pm_score": 2, "selected": false, "text": "<p>According to the <a href=\"http://bazaar.launchpad.net/~amduser29/tortoisebzr/trunk/annotate/270?file_id=readme.to...
2008/09/30
[ "https://Stackoverflow.com/questions/151587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14651/" ]
I'm a huge fan of bzr and I'm glad they're working on tortoise for it, but currently it's WAY too slow to be useful. The icons are almost always incorrect and when I load a directory in explorer with a lot of branches it locks up my entire system for anywhere from 10 seconds to 2 minutes. I look forward to trying it ag...
I think you can do: ``` regsvr32 /u tbzrshellext_x86.dll ``` I also killed tbzrcachew.exe in memory, but since, like enobrev, I couldn't find it with AutoRuns, I will suppose it is the shell extension that runs this cache. Will know for sure when I will reboot my computer... I agree that currently these icons are ...
151,590
<p>How do you detect if <code>Socket#close()</code> has been called on a socket on the remote side?</p>
[ { "answer_id": 152116, "author": "WMR", "author_id": 2844, "author_profile": "https://Stackoverflow.com/users/2844", "pm_score": 7, "selected": true, "text": "<p>The <code>isConnected</code> method won't help, it will return <code>true</code> even if the remote side has closed the socket...
2008/09/30
[ "https://Stackoverflow.com/questions/151590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4792/" ]
How do you detect if `Socket#close()` has been called on a socket on the remote side?
The `isConnected` method won't help, it will return `true` even if the remote side has closed the socket. Try this: ``` public class MyServer { public static final int PORT = 12345; public static void main(String[] args) throws IOException, InterruptedException { ServerSocket ss = ServerSocketFactory....
151,594
<p>You can have different naming convention for class members, static objects, global objects, and structs. Some of the examples of them are as below.</p> <pre><code>_member m_member </code></pre> <p>or in Java case, the usage of <code>this.member</code>.</p> <p>But is there any good technique or naming convention f...
[ { "answer_id": 151597, "author": "kafuchau", "author_id": 22371, "author_profile": "https://Stackoverflow.com/users/22371", "pm_score": 1, "selected": true, "text": "<p>We tend to use an l_ prefix in our functions for \"local.\" And, that's worked pretty well.</p>\n" }, { "answer...
2008/09/30
[ "https://Stackoverflow.com/questions/151594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17382/" ]
You can have different naming convention for class members, static objects, global objects, and structs. Some of the examples of them are as below. ``` _member m_member ``` or in Java case, the usage of `this.member`. But is there any good technique or naming convention for function variables scope that conveys whe...
We tend to use an l\_ prefix in our functions for "local." And, that's worked pretty well.
151,677
<p>I'm looking for a tool that will, in bulk, add a license header to some source files, some of which already have the header. Is there a tool out there that will insert a header, if it is not already present?</p> <p><em>Edit: I am intentionally not marking an answer to this question, since answers are basically all...
[ { "answer_id": 151684, "author": "Silver Dragon", "author_id": 9440, "author_profile": "https://Stackoverflow.com/users/9440", "pm_score": 4, "selected": false, "text": "<p>Python 2 solution, modify for your own need</p>\n<p>Features:</p>\n<ul>\n<li>handles UTF headers (important for mos...
2008/09/30
[ "https://Stackoverflow.com/questions/151677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5897/" ]
I'm looking for a tool that will, in bulk, add a license header to some source files, some of which already have the header. Is there a tool out there that will insert a header, if it is not already present? *Edit: I am intentionally not marking an answer to this question, since answers are basically all environment-s...
``` #!/bin/bash for i in *.cc # or whatever other pattern... do if ! grep -q Copyright $i then cat copyright.txt $i >$i.new && mv $i.new $i fi done ```
151,682
<pre><code> &lt;my:DataGridTemplateColumn CanUserResize="False" Width="150" Header="{Binding MeetingName, Source={StaticResource LocStrings}}" SortMemberPath="MeetingName"&gt; &lt;/my:DataGridTemplateColumn&gt; </code></pre> <p>I have the above column in a Silver...
[ { "answer_id": 151879, "author": "Adam Kinney", "author_id": 1973, "author_profile": "https://Stackoverflow.com/users/1973", "pm_score": 6, "selected": true, "text": "<p>You can't Bind to Header because it's not a FrameworkElement. You can make the text dynamic by modifying the Header T...
2008/09/30
[ "https://Stackoverflow.com/questions/151682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23663/" ]
``` <my:DataGridTemplateColumn CanUserResize="False" Width="150" Header="{Binding MeetingName, Source={StaticResource LocStrings}}" SortMemberPath="MeetingName"> </my:DataGridTemplateColumn> ``` I have the above column in a Silverlight grid control. But it is g...
You can't Bind to Header because it's not a FrameworkElement. You can make the text dynamic by modifying the Header Template like this: ``` xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Win...
151,686
<p><strong><em>Note</strong>: The code in this question is part of <a href="http://www.codeplex.com/desleeper" rel="noreferrer">deSleeper</a> if you want the full source.</em></p> <p>One of the things I wanted out of commands was a baked design for asynchronous operations. I wanted the button pressed to disable while...
[ { "answer_id": 151735, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 1, "selected": false, "text": "<p>As I answered in your other question, you probably still want to bind to this synchronously and then launch the comm...
2008/09/30
[ "https://Stackoverflow.com/questions/151686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5504/" ]
***Note***: The code in this question is part of [deSleeper](http://www.codeplex.com/desleeper) if you want the full source. One of the things I wanted out of commands was a baked design for asynchronous operations. I wanted the button pressed to disable while the command was executing, and come back when complete. I ...
I've been able to refine the original sample down and have some advice for anyone else running into similar situations. First, consider if BackgroundWorker will meet the needs. I still use AsyncCommand often to get the automatic disable function, but if many things could be done with BackgroundWorker. But by wrapping...
151,687
<p>I'm developing an embedded system which currently boots linux with console output on serial port 1 (using the console boot param from the boot loader). However, eventually we will be using this serial port. What is the best solution for the kernel console output? /dev/null? Can it be put on a pty somehow so that...
[ { "answer_id": 151735, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 1, "selected": false, "text": "<p>As I answered in your other question, you probably still want to bind to this synchronously and then launch the comm...
2008/09/30
[ "https://Stackoverflow.com/questions/151687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20889/" ]
I'm developing an embedded system which currently boots linux with console output on serial port 1 (using the console boot param from the boot loader). However, eventually we will be using this serial port. What is the best solution for the kernel console output? /dev/null? Can it be put on a pty somehow so that we cou...
I've been able to refine the original sample down and have some advice for anyone else running into similar situations. First, consider if BackgroundWorker will meet the needs. I still use AsyncCommand often to get the automatic disable function, but if many things could be done with BackgroundWorker. But by wrapping...
151,691
<p>We have built a custom application, for internal use, that accesses TFS. We use the Microsoft libraries for this (e.g Microsoft.TeamFoundation.dll).</p> <p>When this application is deployed to PCs that already have Team Explorer or VS installed, everything is fine. When it’s deployed to PCs that don’t have this i...
[ { "answer_id": 151706, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 1, "selected": false, "text": "<p>Try this list:</p>\n<p><a href=\"https://web.archive.org/web/20160829113142/http://geekswithblogs.net/jjulian/archive/20...
2008/09/30
[ "https://Stackoverflow.com/questions/151691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10309/" ]
We have built a custom application, for internal use, that accesses TFS. We use the Microsoft libraries for this (e.g Microsoft.TeamFoundation.dll). When this application is deployed to PCs that already have Team Explorer or VS installed, everything is fine. When it’s deployed to PCs that don’t have this installed, it...
The "officially supported" way of writing an application that uses the TFS Object Model is to have Team Explorer installed on the machine. This is especially important for servicing purposes - i.e. making sure that when a service pack for VSTS is applied to the client machine then the TFS API's get upgraded as well. Th...
151,700
<p>I'm finding the WPF command parameters to be a limitation. Perhaps that's a sign that I'm using them for the wrong purpose, but I'm still giving it a try before I scrap and take a different tack.</p> <p>I put together a system for <a href="https://stackoverflow.com/questions/151686/asynchrnonous-wpf-commands">exec...
[ { "answer_id": 151722, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 0, "selected": false, "text": "<p>You need something that will allow you to request the proper object. Perhaps you need an object just for storing the...
2008/09/30
[ "https://Stackoverflow.com/questions/151700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5504/" ]
I'm finding the WPF command parameters to be a limitation. Perhaps that's a sign that I'm using them for the wrong purpose, but I'm still giving it a try before I scrap and take a different tack. I put together a system for [executing commands asynchronously](https://stackoverflow.com/questions/151686/asynchrnonous-wp...
Let me point you to my open source project Caliburn. You can find it at [here](http://caliburn.codeplex.com/). The feature that would most help solve your problem is documented briefly [here](http://caliburn.codeplex.com/Wiki/View.aspx?title=Action%20Basics&referringTitle=Table%20Of%20Contents.)
151,701
<p>Our company runs a web site (oursite.com) with affiliate partners who send us traffic. In some cases, we set up our affiliates with their own subdomain (affiliate.oursite.com), and they display selected content from our site on their site (affiliate.com) using an iframe.</p> <p>Example of a page on their site:</p> ...
[ { "answer_id": 152389, "author": "Silver Dragon", "author_id": 9440, "author_profile": "https://Stackoverflow.com/users/9440", "pm_score": 5, "selected": true, "text": "<ol>\n<li><p>You have to append the Google Analytics tracking code to the end of <code>example_page.html</code>. The co...
2008/09/30
[ "https://Stackoverflow.com/questions/151701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15088/" ]
Our company runs a web site (oursite.com) with affiliate partners who send us traffic. In some cases, we set up our affiliates with their own subdomain (affiliate.oursite.com), and they display selected content from our site on their site (affiliate.com) using an iframe. Example of a page on their site: ``` <html> <h...
1. You have to append the Google Analytics tracking code to the end of `example_page.html`. The content between the `<iframe>` - `</iframe>` tag only displays for browsers, which do not support that specific tag. 2. Should you need to merge the results from the subdomains, there's an excellent article on Google's help ...
151,721
<p>Given a pretty basic source tree structure like the following:</p> <pre> trunk ------- QA |-------- Stage |------- Prod |------ </pre> <p>And an environment which mirrors that (Dev, QA, Staging and Production servers) - how do you all manage automated or manual code promotion? Do you use a CI se...
[ { "answer_id": 151734, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 3, "selected": true, "text": "<p>You want absolutely no possibility of the production code not being identical to the one QA tested, so you should use ...
2008/09/30
[ "https://Stackoverflow.com/questions/151721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4083/" ]
Given a pretty basic source tree structure like the following: ``` trunk ------- QA |-------- Stage |------- Prod |------ ``` And an environment which mirrors that (Dev, QA, Staging and Production servers) - how do you all manage automated or manual code promotion? Do you use a CI server to build...
You want absolutely no possibility of the production code not being identical to the one QA tested, so you should use binaries. You should also tag the sources used to create each build, so if needed you can reproduce the build in a dev environment. At least if you make a mistake at this point, the consequences won't ...
151,752
<p>I've created some fairly simple XAML, and it works perfectly (at least in KAXML). The storyboards run perfectly when called from within the XAML, but when I try to access them from outside I get the error:</p> <pre><code>'buttonGlow' name cannot be found in the name scope of 'System.Windows.Controls.Button'. </cod...
[ { "answer_id": 154114, "author": "cplotts", "author_id": 22294, "author_profile": "https://Stackoverflow.com/users/22294", "pm_score": 2, "selected": false, "text": "<p>I think just had this problem.</p>\n\n<p>Let me refer you to my blog entry on the matter: <a href=\"http://www.cplotts....
2008/09/30
[ "https://Stackoverflow.com/questions/151752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
I've created some fairly simple XAML, and it works perfectly (at least in KAXML). The storyboards run perfectly when called from within the XAML, but when I try to access them from outside I get the error: ``` 'buttonGlow' name cannot be found in the name scope of 'System.Windows.Controls.Button'. ``` I am loading t...
Finally found it. When you call Begin on storyboards that reference elements in the ControlTemplate, you must pass in the control template as well. Changing: ``` pressedButtonStoryboard.Begin(_xamlButton); ``` To: ``` pressedButtonStoryboard.Begin(_xamlButton, _xamlButton.Template); ``` Fixed everything.
151,769
<p>Originally there was the DAL object which my BO's called for info and then passed to UI. Then I started noticing reduced code in UI and there were Controller classes. What's the decent recomendation.</p> <p>I currently structure mine</p> <pre><code>Public Class OrderDAL Private _id Integer Private _order ...
[ { "answer_id": 151799, "author": "Dan Blair", "author_id": 1327, "author_profile": "https://Stackoverflow.com/users/1327", "pm_score": 0, "selected": false, "text": "<p>Well your application shouldn't be instantiating seperate versions of the data acces layer, so you have that under cont...
2008/09/30
[ "https://Stackoverflow.com/questions/151769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
Originally there was the DAL object which my BO's called for info and then passed to UI. Then I started noticing reduced code in UI and there were Controller classes. What's the decent recomendation. I currently structure mine ``` Public Class OrderDAL Private _id Integer Private _order as Order Public ...
I've used your solution in the past, and the only problem I faced is that "Shared" or "static" methods don't support inheritance. When your application grows, you might very well need to support different types of "OrderControllers". The estabilished way of supporting different OrderControllers would be, in theory, to...
151,777
<p>I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example:</p> <pre class="lang-java prettyprint-override"><code>package com.android.hello; import android.app.Activity; import android.os.Bundle; import...
[ { "answer_id": 151822, "author": "Dave L.", "author_id": 3093, "author_profile": "https://Stackoverflow.com/users/3093", "pm_score": 9, "selected": false, "text": "<p>The <code>savedInstanceState</code> is only for saving state associated with a current instance of an Activity, for examp...
2008/09/30
[ "https://Stackoverflow.com/questions/151777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
I've been working on the Android SDK platform, and it is a little unclear how to save an application's state. So given this minor re-tooling of the 'Hello, Android' example: ```java package com.android.hello; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAnd...
You need to override `onSaveInstanceState(Bundle savedInstanceState)` and write the application state values you want to change to the `Bundle` parameter like this: ``` @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); // Save UI state changes to ...
151,778
<p>I'm making a mini ORM for a Java program I'm writing... there is a class for each table in my db, all inheriting from <code>ModelBase</code>.</p> <p><code>ModelBase</code> is abstract &amp; provides a bunch of static methods for finding &amp; binding objects from the db, for example:</p> <pre><code>public static A...
[ { "answer_id": 151791, "author": "asterite", "author_id": 20459, "author_profile": "https://Stackoverflow.com/users/20459", "pm_score": 0, "selected": false, "text": "<p>If you are passing a Class to findAll, why can't you pass a class to getSelectSQL in ModelBase?</p>\n" }, { "a...
2008/09/30
[ "https://Stackoverflow.com/questions/151778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16925/" ]
I'm making a mini ORM for a Java program I'm writing... there is a class for each table in my db, all inheriting from `ModelBase`. `ModelBase` is abstract & provides a bunch of static methods for finding & binding objects from the db, for example: ``` public static ArrayList findAll(Class cast_to_class) { //build t...
Albeit, I totally agree in the point of "Static is the wrong thing to be using here", I kind of understand what you're trying to address here. Still instance behavior should be the way to work, but if you insist this is what I would do: Starting from your comment "I need to create an instance of it just to get a strin...
151,800
<p>Given a database field named "widget_ids", containing data like "67/797/124/" or "45/", where the numbers are slash separated widget_ids... how would you make an update statement with SQL that would say: "if the widget_ids of the row with id X contains the text "somenumber/" do nothing, otherwise append "somenumber/...
[ { "answer_id": 151829, "author": "Logan", "author_id": 3518, "author_profile": "https://Stackoverflow.com/users/3518", "pm_score": 4, "selected": true, "text": "<p>Updates are kind of like if-thens themselves, and there is also if-then support of some sort in most SQL implementations. A ...
2008/09/30
[ "https://Stackoverflow.com/questions/151800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14278/" ]
Given a database field named "widget\_ids", containing data like "67/797/124/" or "45/", where the numbers are slash separated widget\_ids... how would you make an update statement with SQL that would say: "if the widget\_ids of the row with id X contains the text "somenumber/" do nothing, otherwise append "somenumber/...
Updates are kind of like if-thens themselves, and there is also if-then support of some sort in most SQL implementations. A simple solution might be: ``` update <tablename> set widget_id = widget_id + "somenumber/" where row_id = X and widget_id not like "%/somenumber/%" and widget_id not like "somenumber/...
151,841
<p>I'd like to document what high-level (i.e. C++ not inline assembler ) functions or macros are available for Compare And Swap (CAS) atomic primitives... </p> <p>E.g., WIN32 on x86 has a family of functions <code>_InterlockedCompareExchange</code> in the <code>&lt;_intrin.h&gt;</code> header.</p>
[ { "answer_id": 151847, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": true, "text": "<p>I'll let others list the various platform-specific APIs, but for future reference in C++09 you'll get the </p>\n\n<...
2008/09/30
[ "https://Stackoverflow.com/questions/151841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
I'd like to document what high-level (i.e. C++ not inline assembler ) functions or macros are available for Compare And Swap (CAS) atomic primitives... E.g., WIN32 on x86 has a family of functions `_InterlockedCompareExchange` in the `<_intrin.h>` header.
I'll let others list the various platform-specific APIs, but for future reference in C++09 you'll get the ``` atomic_compare_exchange() ``` operation in the new "Atomic operations library".
151,846
<p>This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then t...
[ { "answer_id": 152094, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 2, "selected": false, "text": "<p>Check out the <a href=\"http://www.devx.com/opensource/Article/37773/1954\" rel=\"nofollow noreferrer\"><code>win32gu...
2008/09/30
[ "https://Stackoverflow.com/questions/151846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3176/" ]
This isn't as malicious as it sounds, I want to get the current size of their windows, not look at what is in them. The purpose is to figure out that if every other window is fullscreen then I should start up like that too. Or if all the other processes are only 800x600 despite there being a huge resolution then that i...
Using hints from [WindowMover article](http://www.devx.com/opensource/Article/37773/1954) and [Nattee Niparnan's blog post](http://our.obor.us/?q=node/42) I managed to create this: ``` import win32con import win32gui def isRealWindow(hWnd): '''Return True iff given window is a real Windows application window.''' ...
151,850
<p>In many languages, assignments are legal in conditions. I never understood the reason behind this. Why would you write:</p> <pre><code>if (var1 = var2) { ... } </code></pre> <p>instead of:</p> <pre><code>var1 = var2; if (var1) { ... } </code></pre> <p>?</p>
[ { "answer_id": 151855, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": false, "text": "<p>It can be useful if you're calling a function that returns either data to work on or a flag to indicate an error (...
2008/09/30
[ "https://Stackoverflow.com/questions/151850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
In many languages, assignments are legal in conditions. I never understood the reason behind this. Why would you write: ``` if (var1 = var2) { ... } ``` instead of: ``` var1 = var2; if (var1) { ... } ``` ?
It's more useful for loops than *if* statements. ``` while(var = GetNext()) { ...do something with 'var' } ``` Which would otherwise have to be written ``` var = GetNext(); while(var) { ...do something var = GetNext(); } ```
151,872
<p>I have a form where i have used Infragistics windows grid control to display the data. In this, i have placed a button on one of the cell. I want to set its visibility either True or False based on the row condition. I have handled the <strong>InitializeRow</strong> event of <strong>UltraWinGrid</strong> control a...
[ { "answer_id": 152634, "author": "Christoffer Lette", "author_id": 11808, "author_profile": "https://Stackoverflow.com/users/11808", "pm_score": 2, "selected": false, "text": "<pre><code>UltraGridRow row = ...\n\nrow.Cells[buttonCellIndex].Hidden = true;\n</code></pre>\n\n<p>(I'm using t...
2008/09/30
[ "https://Stackoverflow.com/questions/151872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a form where i have used Infragistics windows grid control to display the data. In this, i have placed a button on one of the cell. I want to set its visibility either True or False based on the row condition. I have handled the **InitializeRow** event of **UltraWinGrid** control and able to disable the button...
``` UltraGridRow row = ... row.Cells[buttonCellIndex].Hidden = true; ``` (I'm using the `UltraGrid` in Infragistics NetAdvantage for Windows Forms 2008 Vol. 2 CLR 2.0.)
151,874
<p>I am working with web Dynpro java.. I have created a stateless session bean wherein I have created business methods for inserting and retrieving records from my dictionary table. My table has two fields of <code>java.sql.Date</code> type The web service that i have created is working fine for <code>insertRecords()...
[ { "answer_id": 152645, "author": "kolrie", "author_id": 14540, "author_profile": "https://Stackoverflow.com/users/14540", "pm_score": 2, "selected": false, "text": "<p>Did you try getTimestamp() instead of getDate()? What is the error you get when you attempt to get it as a date?</p>\n" ...
2008/09/30
[ "https://Stackoverflow.com/questions/151874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working with web Dynpro java.. I have created a stateless session bean wherein I have created business methods for inserting and retrieving records from my dictionary table. My table has two fields of `java.sql.Date` type The web service that i have created is working fine for `insertRecords()`, but for `showReco...
Did you try getTimestamp() instead of getDate()? What is the error you get when you attempt to get it as a date?
151,917
<p>What is the best way to free resources (in this case unlock the ReadWriteLock) when leaving the scope ? How to cover all possible ways (return, break, exceptions etc)?</p>
[ { "answer_id": 151932, "author": "Michael Barker", "author_id": 6365, "author_profile": "https://Stackoverflow.com/users/6365", "pm_score": 5, "selected": true, "text": "<p>A try/finally block is the closest thing that you can get to this behaviour:</p>\n\n<pre><code>Lock l = new Lock();...
2008/09/30
[ "https://Stackoverflow.com/questions/151917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18174/" ]
What is the best way to free resources (in this case unlock the ReadWriteLock) when leaving the scope ? How to cover all possible ways (return, break, exceptions etc)?
A try/finally block is the closest thing that you can get to this behaviour: ``` Lock l = new Lock(); l.lock(); // Call the lock before calling try. try { // Do some processing. // All code must go in here including break, return etc. return something; } finally { l.unlock(); } ```
151,929
<p>I'm using the <code>mechanize</code> module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it throws for various errors.</p> <p>I j...
[ { "answer_id": 151935, "author": "Alexander Kojevnikov", "author_id": 712, "author_profile": "https://Stackoverflow.com/users/712", "pm_score": 1, "selected": false, "text": "<p>I found this in their docs:</p>\n\n<blockquote>\n <p>One final thing to note is that there\n are some catch-...
2008/09/30
[ "https://Stackoverflow.com/questions/151929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I'm using the `mechanize` module to execute some web queries from Python. I want my program to be error-resilient and handle all kinds of errors (wrong URLs, 403/404 responsese) gracefully. However, I can't find in mechanize's documentation the errors / exceptions it throws for various errors. I just call it with: ``...
``` $ perl -0777 -ne'print qq($1) if /__all__ = \[(.*?)\]/s' __init__.py | grep Error 'BrowserStateError', 'ContentTooShortError', 'FormNotFoundError', 'GopherError', 'HTTPDefaultErrorHandler', 'HTTPError', 'HTTPErrorProcessor', 'LinkNotFoundError', 'LoadError', 'ParseError', 'RobotExclusionError', 'URLError', ``` ...
151,936
<p>I have some code where I'm returning an array of objects.</p> <p>Here's a simplified example:</p> <pre><code>string[] GetTheStuff() { List&lt;string&gt; s = null; if( somePredicate() ) { s = new List&lt;string&gt;(); // imagine we load some data or something } return (s == null) ? ne...
[ { "answer_id": 151939, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "<p>I would guess that an empty array uses only the space needed to allocate the object pointer itself.</p>\n\n<p>From me...
2008/09/30
[ "https://Stackoverflow.com/questions/151936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
I have some code where I'm returning an array of objects. Here's a simplified example: ``` string[] GetTheStuff() { List<string> s = null; if( somePredicate() ) { s = new List<string>(); // imagine we load some data or something } return (s == null) ? new string[0] : s.ToArray...
Even if it's being called "hundreds and hundreds" of times, I'd say it's a premature optimization. If the result is clearer as an empty array, use that. Now for the actual answer: yes, an empty array takes some memory. It has the normal object overhead (8 bytes on x86, I believe) and 4 bytes for the count. I don't kno...
151,945
<p>Emacs puts backup files named <code>foo~</code> everywhere and I don't like having to remember to delete them. Also, if I edit a file that has a hard link somewhere else in the file system, the hard link points to the backup when I'm done editing, and that's confusing and awful. How can I either eliminate these ba...
[ { "answer_id": 151946, "author": "jfm3", "author_id": 11138, "author_profile": "https://Stackoverflow.com/users/11138", "pm_score": 10, "selected": true, "text": "<p>If you've ever been saved by an Emacs backup file, you\nprobably want more of them, not less of them. It is annoying\ntha...
2008/09/30
[ "https://Stackoverflow.com/questions/151945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11138/" ]
Emacs puts backup files named `foo~` everywhere and I don't like having to remember to delete them. Also, if I edit a file that has a hard link somewhere else in the file system, the hard link points to the backup when I'm done editing, and that's confusing and awful. How can I either eliminate these backup files, or h...
If you've ever been saved by an Emacs backup file, you probably want more of them, not less of them. It is annoying that they go in the same directory as the file you're editing, but that is easy to change. You can make all backup files go into a directory by putting something like the following in your `.emacs`. ```l...
151,963
<p>Is it possible to get the route/virtual url associated with a controller action or on a view? I saw that Preview 4 added LinkBuilder.BuildUrlFromExpression helper, but it's not very useful if you want to use it on the master, since the controller type can be different. Any thoughts are appreciated.</p>
[ { "answer_id": 153199, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "<p>You can use &lt;%= Url.Action(action, controller, values) %> to build the URL from within the master page.</p>\n\n<...
2008/09/30
[ "https://Stackoverflow.com/questions/151963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3085/" ]
Is it possible to get the route/virtual url associated with a controller action or on a view? I saw that Preview 4 added LinkBuilder.BuildUrlFromExpression helper, but it's not very useful if you want to use it on the master, since the controller type can be different. Any thoughts are appreciated.
You can get that data from ViewContext.RouteData. Below are some examples for how to access (and use) that information: /// These are added to my viewmasterpage, viewpage, and viewusercontrol base classes: ``` public bool IsController(string controller) { if (ViewContext.RouteData.Values["controller"] != null) ...
151,969
<p>In PHP 5, what is the difference between using <code>self</code> and <code>$this</code>?</p> <p>When is each appropriate?</p>
[ { "answer_id": 151975, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 4, "selected": false, "text": "<p>According to <em><a href=\"http://www.php.net/manual/en/language.oop5.static.php\" rel=\"nofollow noreferrer\">Static Key...
2008/09/30
[ "https://Stackoverflow.com/questions/151969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4682/" ]
In PHP 5, what is the difference between using `self` and `$this`? When is each appropriate?
Short Answer ============ > > Use `$this` to refer to the current > object. Use `self` to refer to the > current class. In other words, use > `$this->member` for non-static members, > use `self::$member` for static members. > > > Full Answer =========== Here is an example of **correct** usage of `$this` and ...
151,979
<p>Have a look at this very simple example WPF program:</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"&gt; &lt;GroupBox&gt; ...
[ { "answer_id": 151999, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 2, "selected": false, "text": "<p>If you change the GroupBox's BorderBrush, it works!</p>\n\n<pre><code>&lt;GroupBox BorderBrush=\"{x:Null}\"&gt;\n</co...
2008/09/30
[ "https://Stackoverflow.com/questions/151979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615/" ]
Have a look at this very simple example WPF program: ``` <Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <GroupBox> <GroupBox.Header> ...
It appears to be a subtle bug in the control template for the GroupBox. I found by editing the default template for the GroupBox and moving the Border named 'Header' to the last item in the control templates Grid element, the issue resolves itself. The reason is that the one of the other Border elements with a Templa...
152,005
<p>What is currying?</p> <p>How can currying be done in C++?</p> <p>Please Explain binders in STL container?</p>
[ { "answer_id": 152020, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "<p>In short, currying takes a function <code>f(x, y)</code> and given a fixed <code>Y</code>, gives a new function <code>g...
2008/09/30
[ "https://Stackoverflow.com/questions/152005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
What is currying? How can currying be done in C++? Please Explain binders in STL container?
In short, currying takes a function `f(x, y)` and given a fixed `Y`, gives a new function `g(x)` where ``` g(x) == f(x, Y) ``` This new function may be called in situations where only one argument is supplied, and passes the call on to the original `f` function with the fixed `Y` argument. The binders in the STL al...
152,006
<p>I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML.</p> <p>Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml?</p>
[ { "answer_id": 152009, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 8, "selected": true, "text": "<pre><code>header('Content-type: application/xml');\n</code></pre>\n\n<p>More information available at the PHP documentation fo...
2008/09/30
[ "https://Stackoverflow.com/questions/152006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7021/" ]
I've got a php script. Most of the time the script returns html, which is working fine, but on one occasion (parameter ?Format=XML) the script returns XML instead of HTML. Is there any way to change the returned mime type of the php output on the fly from text/html to text/xml or application/xml?
``` header('Content-type: application/xml'); ``` More information available at the PHP documentation for [`header()`](http://php.net/manual/en/function.header.php)
152,016
<p>What is the most reliable way to find out CPU architecture when compiling C or C++ code? As far as I can tell, different compilers have their own set of non-standard preprocessor definitions (<code>_M_X86</code> in MSVS, <code>__i386__</code>, <code>__arm__</code> in GCC, etc).</p> <p>Is there a <em>standard</em> w...
[ { "answer_id": 152032, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "<p>There's nothing standard. Brian Hook documented a bunch of these in his \"Portable Open Source Harness\", and eve...
2008/09/30
[ "https://Stackoverflow.com/questions/152016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23643/" ]
What is the most reliable way to find out CPU architecture when compiling C or C++ code? As far as I can tell, different compilers have their own set of non-standard preprocessor definitions (`_M_X86` in MSVS, `__i386__`, `__arm__` in GCC, etc). Is there a *standard* way to detect the architecture I'm building for? If...
There's no inter-compiler standard, but each compiler tends to be quite consistent. You can build a header for yourself that's something like this: ``` #if MSVC #ifdef _M_X86 #define ARCH_X86 #endif #endif #if GCC #ifdef __i386__ #define ARCH_X86 #endif #endif ``` There's not much point to a comprehensive list, bec...
152,019
<p>.Net 3.5 doesn't support tuples. Too bad, But not sure whether the future version of .net will support tuples or not? </p>
[ { "answer_id": 152026, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": 6, "selected": false, "text": "<pre><code>#region tuples\n\n public class Tuple&lt;T&gt;\n {\n public Tuple(T first)\n {\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/152019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
.Net 3.5 doesn't support tuples. Too bad, But not sure whether the future version of .net will support tuples or not?
I've just read this article from the MSDN Magazine: [Building Tuple](http://msdn.microsoft.com/en-us/magazine/dd942829.aspx) Here are excerpts: > > The upcoming 4.0 release of Microsoft > .NET Framework introduces a new type > called System.Tuple. System.Tuple is a > fixed-size collection of > heterogeneously ty...
152,022
<p>Any time I try to publish my Portal project on a Websphere Portal 6.1 Server, I get the following error message:</p> <pre><code>Portal project publishing is not supported on WebSphere Portal v6.1 Server </code></pre> <p>Is that really true or have I done something wrong?</p> <p>I'm trying to deploy a portal proje...
[ { "answer_id": 160715, "author": "olore", "author_id": 1691, "author_profile": "https://Stackoverflow.com/users/1691", "pm_score": 2, "selected": true, "text": "<p>Not sure this will help, but:</p>\n\n<blockquote>\n <p>Limitation: Although the WebSphere\n Portal installer contains an a...
2008/09/30
[ "https://Stackoverflow.com/questions/152022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7966/" ]
Any time I try to publish my Portal project on a Websphere Portal 6.1 Server, I get the following error message: ``` Portal project publishing is not supported on WebSphere Portal v6.1 Server ``` Is that really true or have I done something wrong? I'm trying to deploy a portal project, with the underlying goal of p...
Not sure this will help, but: > > Limitation: Although the WebSphere > Portal installer contains an advanced > option to install an empty portal, > Portal Designer relies on > administration portlets for setting > access control; therefore, publishing > a portal project to an empty portal is > not supported. >...