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
154,597
<p>Note, I realize that this has been addressed <a href="https://stackoverflow.com/questions/944/unhandled-exception-handler-in-net-11">here</a>. That post discusses exception handling in .NET 1.1 while implying that there is a better solution for >.NET 2.0 so this question is specifically about the more recent .NET v...
[ { "answer_id": 154626, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>caveat: not familiar with 3.5 yet, there may be a better answer ...</p>\n\n<p>...but my understanding is that by t...
2008/09/30
[ "https://Stackoverflow.com/questions/154597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
Note, I realize that this has been addressed [here](https://stackoverflow.com/questions/944/unhandled-exception-handler-in-net-11). That post discusses exception handling in .NET 1.1 while implying that there is a better solution for >.NET 2.0 so this question is specifically about the more recent .NET versions. I hav...
For Windows Forms threads (which call Application.Run()), assign a ThreadException handler at the beginning of Main(). Also, I found it was necessary to call SetUnhandledExceptionMode: ``` Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic); Application.ThreadException += ShowUnhandledException; Ap...
154,625
<p>I've noticed that sometimes wrapper scripts will use <code>${1:+"$@"}</code> for the parameters rather than just <code>"$@"</code>.</p> <p>For example, <a href="http://svn.macosforge.org/repository/macports/trunk/dports/editors/vim-app/files/gvim.sh" rel="noreferrer">http://svn.macosforge.org/repository/macports/tr...
[ { "answer_id": 154637, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 2, "selected": false, "text": "<p>From the bash man page:</p>\n\n<pre><code> ${parameter:+word}\n Use Alternate Value. If parameter is null o...
2008/09/30
[ "https://Stackoverflow.com/questions/154625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've noticed that sometimes wrapper scripts will use `${1:+"$@"}` for the parameters rather than just `"$@"`. For example, <http://svn.macosforge.org/repository/macports/trunk/dports/editors/vim-app/files/gvim.sh> uses ``` exec "$binary" $opts ${1:+"$@"} ``` Can anyone break `${1:+"$@"}` down into English and expla...
'Hysterical Raisins', aka Historical Reasons. The explanation from JesperE (or the Bash man page on [shell parameter expansion](https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion)) is accurate for what it does: * If `$1` exists and is not an empty string, then substitute the quoted list of a...
154,630
<p>Other than <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall" rel="nofollow noreferrer">-Wall</a>, what other warnings have people found useful?</p> <p><em><a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html" rel="nofollow noreferrer">Options to Request or Suppress War...
[ { "answer_id": 154638, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 1, "selected": false, "text": "<p>It would be the option <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-pedantic-errors-1\" rel...
2008/09/30
[ "https://Stackoverflow.com/questions/154630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9831/" ]
Other than [-Wall](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall), what other warnings have people found useful? *[Options to Request or Suppress Warnings](http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html)*
I routinely use: ```none gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual \ -Wstrict-prototypes -Wmissing-prototypes ``` This set catches a lot for people unused to it (people whose code I get to compile with those flags for the first time); it seldom gives me a problem (though [-Wcast-qual...
154,636
<p>At the moment we use <a href="http://www.hsqldb.org/" rel="noreferrer">HSQLDB</a> as an embedded database, but we search for a database with less memory footprint as the data volume grows.</p> <p><a href="http://developers.sun.com/javadb/" rel="noreferrer">Derby / JavaDB</a> is not an option at the moment because i...
[ { "answer_id": 155237, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 6, "selected": true, "text": "<p>From the download, I see that the file tutorial.html has this </p>\n\n<pre><code>import org.h2.tools.Server;\n...\n// sta...
2008/09/30
[ "https://Stackoverflow.com/questions/154636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13209/" ]
At the moment we use [HSQLDB](http://www.hsqldb.org/) as an embedded database, but we search for a database with less memory footprint as the data volume grows. [Derby / JavaDB](http://developers.sun.com/javadb/) is not an option at the moment because it stores properties globally in the system properties. So we thoug...
From the download, I see that the file tutorial.html has this ``` import org.h2.tools.Server; ... // start the TCP Server Server server = Server.createTcpServer(args).start(); ... // stop the TCP Server server.stop(); ```
154,652
<p>Is anyone out there still using DataFlex? If so, what are you favorite tips and tricks for this venerable 4GL?</p>
[ { "answer_id": 155555, "author": "seanyboy", "author_id": 1726, "author_profile": "https://Stackoverflow.com/users/1726", "pm_score": 3, "selected": true, "text": "<p>It all depends on the version of DF you're using, but here's a couple: </p>\n\n<ol>\n<li>Do not use \"While\" when traver...
2008/09/30
[ "https://Stackoverflow.com/questions/154652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
Is anyone out there still using DataFlex? If so, what are you favorite tips and tricks for this venerable 4GL?
It all depends on the version of DF you're using, but here's a couple: 1. Do not use "While" when traversing record sets. Always use repeat. (see example at bottom) 2. The dataflex newsgroups (news.dataaccess.com) is the best place to ask questions. 3. Other useful sites include <http://sture.dk/wasp> and <http://www...
154,655
<p>We have a VXML project that a 3rd party parses to provide us with a phone navigation system. We require them to enter an id code to leave a message, which is later reviewed by our company.</p> <p>We currently have this working as follows:</p> <pre><code>Response.Cache.SetCacheability(HttpCacheability.NoCache); Str...
[ { "answer_id": 154684, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 2, "selected": true, "text": "<p>Yes, just write directly to the Response <code>Output</code> (IO.StreamWriter) or <code>OutputStream</code> (IO.Strea...
2008/09/30
[ "https://Stackoverflow.com/questions/154655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23902/" ]
We have a VXML project that a 3rd party parses to provide us with a phone navigation system. We require them to enter an id code to leave a message, which is later reviewed by our company. We currently have this working as follows: ``` Response.Cache.SetCacheability(HttpCacheability.NoCache); Stream m = new MemoryStr...
Yes, just write directly to the Response `Output` (IO.StreamWriter) or `OutputStream` (IO.Stream): ``` XmlTextWriter XML_Writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, HttpContext.Current.Response.Encoding); //... XML_Writer.Flush(); ```
154,672
<p>I asked a question about Lua perfromance, and on of the <a href="https://stackoverflow.com/questions/124455/how-do-you-pre-size-an-array-in-lua#152894">responses</a> asked:</p> <blockquote> <p>Have you studied general tips for keeping Lua performance high? i.e. know table creation and rather reuse a table than cr...
[ { "answer_id": 324931, "author": "Robert Gould", "author_id": 15124, "author_profile": "https://Stackoverflow.com/users/15124", "pm_score": 1, "selected": false, "text": "<p>Keep tables short, the larger the table the longer the search time.\nAnd in the same line iterating over numerical...
2008/09/30
[ "https://Stackoverflow.com/questions/154672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
I asked a question about Lua perfromance, and on of the [responses](https://stackoverflow.com/questions/124455/how-do-you-pre-size-an-array-in-lua#152894) asked: > > Have you studied general tips for keeping Lua performance high? i.e. know table creation and rather reuse a table than create a new one, use of 'local p...
In response to some of the other answers and comments: It is true that as a programmer you should generally avoid premature optimization. *But*. This is not so true for scripting languages where the compiler does not optimize much -- or at all. So, whenever you write something in Lua, and that is executed very often,...
154,680
<p>How would I create the equivalent Linq To Objects query?</p> <pre><code>SELECT MIN(CASE WHEN p.type = "In" THEN p.PunchTime ELSE NULL END ) AS EarliestIn, MAX(CASE WHEN p.type = "Out" THEN p.PunchTime ELSE NULL END ) AS LatestOUt FROM Punches p </code></pre>
[ { "answer_id": 154710, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>You can't efficiently select multiple aggregates in vanilla LINQ to Objects. You can perform multiple queries, of cour...
2008/09/30
[ "https://Stackoverflow.com/questions/154680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6819/" ]
How would I create the equivalent Linq To Objects query? ``` SELECT MIN(CASE WHEN p.type = "In" THEN p.PunchTime ELSE NULL END ) AS EarliestIn, MAX(CASE WHEN p.type = "Out" THEN p.PunchTime ELSE NULL END ) AS LatestOUt FROM Punches p ```
You can't efficiently select multiple aggregates in vanilla LINQ to Objects. You can perform multiple queries, of course, but that may well be inefficient depending on your data source. I have a framework which copes with this which I call "Push LINQ" - it's only a hobby (for me and Marc Gravell) but we believe it wor...
154,686
<p>I've got a stock Debian Etch system, using Exim4. The domains are mostly local but there are some that are remote. To handle the delivery of remote mail I use the Debian configuration file:</p> <pre><code> /etc/exim4/hubbed_hosts </code></pre> <p>This file lists the domain names, and remote MX machines to delive...
[ { "answer_id": 154711, "author": "manicmethod", "author_id": 12098, "author_profile": "https://Stackoverflow.com/users/12098", "pm_score": 1, "selected": false, "text": "<p>make a new transport that specifies the port</p>\n\n<pre><code>remote_hub_2525:\ndriver = smtp\nport = 2525\n</code...
2008/09/30
[ "https://Stackoverflow.com/questions/154686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got a stock Debian Etch system, using Exim4. The domains are mostly local but there are some that are remote. To handle the delivery of remote mail I use the Debian configuration file: ``` /etc/exim4/hubbed_hosts ``` This file lists the domain names, and remote MX machines to deliver to. For example: ``` e...
I was hoping for something a little more dynamic - and this solution works: ``` port = ${if exists{/etc/exim4/ports.list}\ {${lookup{$domain}lsearch{/etc/exim4/ports.list}\ {$value}{25}}}{25}} ``` Then a simple file may have a list of ports on a per-domain basis: ``` example.org: 252...
154,697
<p>I'm trying to retrieve numeric values from a <code>DataGridView</code>. So far, the only way I've found is to retrieve them as a string and convert them to numeric.</p> <pre><code>Convert.ToDouble(MyGrid.SelectedRows[0].Cells[0].Value.ToString()); </code></pre> <p>There must be an easier way. The cell is originall...
[ { "answer_id": 154825, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 0, "selected": false, "text": "<p>What is the error you are getting? <code>Convert.ToDouble</code> has an overloaded method that takes an object, so yo...
2008/09/30
[ "https://Stackoverflow.com/questions/154697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to retrieve numeric values from a `DataGridView`. So far, the only way I've found is to retrieve them as a string and convert them to numeric. ``` Convert.ToDouble(MyGrid.SelectedRows[0].Cells[0].Value.ToString()); ``` There must be an easier way. The cell is originally populated from a `DataSet` with a n...
With `DataGridViewCell` you can just cast the `.Value` to your known type; the following is a complete example that shows this happening (using double) from a `DataTable` (like your example). Additionally, `Convert.To{blah}(...)` and `Convert.ChangeType(...)` might be helpful. ``` using System.Data; using System.Windo...
154,706
<p>Unfortunately, there seems to be no string.Split(string separator), only string.Split(char speparator).</p> <p>I want to break up my string based on a multi-character separator, a la VB6. Is there an easy (that is, not by referencing Microsoft.VisualBasic or having to learn RegExes) way to do this in c#?</p> <p>E...
[ { "answer_id": 154712, "author": "leora", "author_id": 4653, "author_profile": "https://Stackoverflow.com/users/4653", "pm_score": 1, "selected": false, "text": "<p>the regex for spliting string is extremely simple so i would go with that route.</p>\n\n<p><a href=\"http://msdn.microsoft....
2008/09/30
[ "https://Stackoverflow.com/questions/154706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
Unfortunately, there seems to be no string.Split(string separator), only string.Split(char speparator). I want to break up my string based on a multi-character separator, a la VB6. Is there an easy (that is, not by referencing Microsoft.VisualBasic or having to learn RegExes) way to do this in c#? EDIT: Using .NET Fr...
`String.Split()` has other overloads. Some of them take `string[]` arguments. ``` string original = "first;&second;&third"; string[] splitResults = original.Split( new string[] { ";&" }, StringSplitOptions.None ); ```
154,708
<p>Ok, Regex wizards. I want to be able to search through my logfile and find any sessions with the word 'error' in it and then return the entire session log entry.</p> <p>I know I can do this with a string/array but I'd like to learn how to do it with Regex but here's the question. If I decide to do this with Regex ...
[ { "answer_id": 154743, "author": "Kyle", "author_id": 2237619, "author_profile": "https://Stackoverflow.com/users/2237619", "pm_score": 3, "selected": false, "text": "<p><p>It looks as if your sessions are delimited by blank lines (in addition to the start/end markers). If that's the ca...
2008/09/30
[ "https://Stackoverflow.com/questions/154708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
Ok, Regex wizards. I want to be able to search through my logfile and find any sessions with the word 'error' in it and then return the entire session log entry. I know I can do this with a string/array but I'd like to learn how to do it with Regex but here's the question. If I decide to do this with Regex do I [have ...
What I did was to run the entire log into a string then went through line by line and added each line to a third variable until the line contained "--End of Session--". I then added that line to the 3rd var as well and then searched that 3rd var for the word "error". If it contained it, I added the 3rd var to a forth a...
154,718
<p>My web application sends email fairly often, and it sends 3 kinds of emails: initiated by user, in response to an event in the system, and in automatic response to an email received by the application.</p> <p>I would like to make sure that the third type of email does not get stuck in an endless loop of auto-respon...
[ { "answer_id": 154750, "author": "Robert Deml", "author_id": 9516, "author_profile": "https://Stackoverflow.com/users/9516", "pm_score": -1, "selected": false, "text": "<p>How about configuring a white list on your email account?</p>\n\n<p>I would assume that any email key words could ge...
2008/09/30
[ "https://Stackoverflow.com/questions/154718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3140/" ]
My web application sends email fairly often, and it sends 3 kinds of emails: initiated by user, in response to an event in the system, and in automatic response to an email received by the application. I would like to make sure that the third type of email does not get stuck in an endless loop of auto-responders talki...
[RFC 2076](http://www.faqs.org/rfcs/rfc2076.html) discourages the use of the precedence header. as you have noted, many clients will just filter that off (especially the precedence: junk variety). it may be better to use a null path to avoid auto responder wars: ``` Return-Path: <> ``` Ultimately you could use prior...
154,754
<p>I would find out the <em>floppy inserted state</em>:</p> <ul> <li>no floppy inserted</li> <li>unformatted floppy inserted</li> <li>formatted floppy inserted</li> </ul> <p>Can this determined using "WMI" in the System.Management namespace?</p> <p>If so, can I generate events when the <em>floppy inserted state</em>...
[ { "answer_id": 163970, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 2, "selected": false, "text": "<p>This comes from <a href=\"http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx\" rel=\"nofollow noreferrer\">Scr...
2008/09/30
[ "https://Stackoverflow.com/questions/154754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14841/" ]
I would find out the *floppy inserted state*: * no floppy inserted * unformatted floppy inserted * formatted floppy inserted Can this determined using "WMI" in the System.Management namespace? If so, can I generate events when the *floppy inserted state* changes?
Using Bob Kings idea I wrote the following method. It works great on CD's, removable drives, regular drives. However for a floppy it always return "Not Available". ``` public static void TestFloppy( char driveLetter ) { using( var searcher = new ManagementObjectSearcher( @"SELECT * FROM Win32_LogicalDis...
154,762
<p>I need to create XML in Perl. From what I read, <a href="http://search.cpan.org/dist/XML-LibXML" rel="noreferrer">XML::LibXML</a> is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is <a href="http://search.cpan.org/dist/XML-Writer" rel="noreferr...
[ { "answer_id": 155010, "author": "Yanick", "author_id": 10356, "author_profile": "https://Stackoverflow.com/users/10356", "pm_score": 6, "selected": true, "text": "<p>XML::Writer is still maintained (at least, as of February of this year), and it's indeed one of the favorite Perl XML wri...
2008/09/30
[ "https://Stackoverflow.com/questions/154762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
I need to create XML in Perl. From what I read, [XML::LibXML](http://search.cpan.org/dist/XML-LibXML) is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is [XML::Writer](http://search.cpan.org/dist/XML-Writer) still maintained? Does anyone like/use it?...
XML::Writer is still maintained (at least, as of February of this year), and it's indeed one of the favorite Perl XML writers out there. As for describing the syntax, one is better to look at the module's documentation (the link is already in the question). To wit: ``` use XML::Writer; my $writer = new XML::Writer(...
154,780
<p>I have a set of callback classes that I use for handling callbacks with variable numbers of parameters. Right now I have about 6 different instances of it to handle differing numbers of arguments. Is there a way to make one instance than can handle a variable number of arguments?? Ultimately I would love to have eac...
[ { "answer_id": 154833, "author": "jwfearn", "author_id": 10559, "author_profile": "https://Stackoverflow.com/users/10559", "pm_score": 4, "selected": true, "text": "<p>Not yet in the language itself but C++0x will have support for <a href=\"http://en.wikipedia.org/wiki/C%2B%2B0x#Variadi...
2008/09/30
[ "https://Stackoverflow.com/questions/154780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
I have a set of callback classes that I use for handling callbacks with variable numbers of parameters. Right now I have about 6 different instances of it to handle differing numbers of arguments. Is there a way to make one instance than can handle a variable number of arguments?? Ultimately I would love to have each p...
Not yet in the language itself but C++0x will have support for [variadic templates](http://en.wikipedia.org/wiki/C%2B%2B0x#Variadic_templates).
154,802
<p>Given the following:</p> <pre><code>&amp;row-&gt;count </code></pre> <p>Would &amp;(row->count) be evaluated or (&amp;row)->count be evaluated in C++?</p> <p>EDIT: Here's a great <a href="http://www.cppreference.com/wiki/operator_precedence" rel="nofollow noreferrer">link</a> for C++ precedence.</p>
[ { "answer_id": 154811, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 1, "selected": false, "text": "<p>This is already asked. But <a href=\"http://www.cppreference.com/wiki/operator_precedence\" rel=\"nofollow norefer...
2008/09/30
[ "https://Stackoverflow.com/questions/154802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18170/" ]
Given the following: ``` &row->count ``` Would &(row->count) be evaluated or (&row)->count be evaluated in C++? EDIT: Here's a great [link](http://www.cppreference.com/wiki/operator_precedence) for C++ precedence.
[&(row->count)](http://www.cppreference.com/wiki/operator_precedence)
154,826
<p>My Techie Bretheren (and Sisteren, of course!),</p> <p>I have a LinqToSql data model that has the following entities: <a href="http://danimal.acsysinteractive.com/images/advisor.jpg" rel="nofollow noreferrer">data model http://danimal.acsysinteractive.com/images/advisor.jpg</a></p> <p>I need to retrieve all adviso...
[ { "answer_id": 154992, "author": "BKimmel", "author_id": 13776, "author_profile": "https://Stackoverflow.com/users/13776", "pm_score": 0, "selected": false, "text": "<p>Funny enough, if you just need \"basic-level\" security, you can set it up in the Excel sheet itself:<br><br>Go to the ...
2008/09/30
[ "https://Stackoverflow.com/questions/154826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
My Techie Bretheren (and Sisteren, of course!), I have a LinqToSql data model that has the following entities: [data model http://danimal.acsysinteractive.com/images/advisor.jpg](http://danimal.acsysinteractive.com/images/advisor.jpg) I need to retrieve all advisors for a specific office, ordered by their sequence wi...
Maybe use [Google Docs](http://docs.google.com/) to share the document. That would be as turn-key as it gets. :)
154,837
<p>We have an "engine" that loads dlls dynamically (whatever is located in a certain directory) and calls Workflow classes from them by way of reflection.</p> <p>We now have some new Workflows that require access to a database, so I figured that I would put a config file in the dll directory.</p> <p>But for some reas...
[ { "answer_id": 154914, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>Funny, where I'm at we're doing something very similar and the config file loads just fine. In our case I think ea...
2008/09/30
[ "https://Stackoverflow.com/questions/154837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23597/" ]
We have an "engine" that loads dlls dynamically (whatever is located in a certain directory) and calls Workflow classes from them by way of reflection. We now have some new Workflows that require access to a database, so I figured that I would put a config file in the dll directory. But for some reason my Workflows j...
If your code sample for reading the AppSettings is in your DLL, then it will attempt to read the config file for the application and not the config file for the DLL. This is because you're using Reflection to execute the code.
154,842
<p>I posted an answer to <a href="https://stackoverflow.com/questions/154706">this question</a>, including a very short rant at the end about how String.Split() should accept IEnumerable&lt;string> rather than string[]. </p> <p>That got me thinking. What if the base Object class from which everything else inherits pr...
[ { "answer_id": 154890, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 0, "selected": false, "text": "<p><strong>the index operator ([]) isn't part of the contract of IEnumerable&lt;T&gt;</strong>\nAfter looking at the code i...
2008/09/30
[ "https://Stackoverflow.com/questions/154842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
I posted an answer to [this question](https://stackoverflow.com/questions/154706), including a very short rant at the end about how String.Split() should accept IEnumerable<string> rather than string[]. That got me thinking. What if the base Object class from which everything else inherits provided a default implemen...
``` public static IEnumerable<object> ToEnumerable(this object someObject) { return System.Linq.Enumerable.Repeat(someObject, 1); } ```
154,845
<p>I have a DataRow and I am getting one of the elements which is a Amount with a dollar sign. I am calling a toString on it. Is there another method I can call on it to remove the dollar sign if present. </p> <p><strong>So something like:</strong></p> <p><em>dr.ToString.Substring(1, dr.ToString.Length);</em></p> <p...
[ { "answer_id": 154857, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 5, "selected": true, "text": "<pre><code>Convert.ToString(dr(columnName)).Replace(\"$\", String.Empty)\n</code></pre>\n\n<p>--\nIf you are working wit...
2008/09/30
[ "https://Stackoverflow.com/questions/154845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
I have a DataRow and I am getting one of the elements which is a Amount with a dollar sign. I am calling a toString on it. Is there another method I can call on it to remove the dollar sign if present. **So something like:** *dr.ToString.Substring(1, dr.ToString.Length);* But more conditionally in case the dollar s...
``` Convert.ToString(dr(columnName)).Replace("$", String.Empty) ``` -- If you are working with a data table, then you have to unbox the value (by default its Object) to a string, so you are already creating a string, and then another with the replacement. There is really no other way to get around it, but you will on...
154,846
<p>I'm looking for a way to create an online form that will update an Access database that has just a few tables. Does anyone know of a simple solution for this?</p>
[ { "answer_id": 154857, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 5, "selected": true, "text": "<pre><code>Convert.ToString(dr(columnName)).Replace(\"$\", String.Empty)\n</code></pre>\n\n<p>--\nIf you are working wit...
2008/09/30
[ "https://Stackoverflow.com/questions/154846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6958/" ]
I'm looking for a way to create an online form that will update an Access database that has just a few tables. Does anyone know of a simple solution for this?
``` Convert.ToString(dr(columnName)).Replace("$", String.Empty) ``` -- If you are working with a data table, then you have to unbox the value (by default its Object) to a string, so you are already creating a string, and then another with the replacement. There is really no other way to get around it, but you will on...
154,862
<p>How can I convert a JavaScript string value to be in all lower case letters?</p> <p>Example: <code>&quot;Your Name&quot;</code> to <code>&quot;your name&quot;</code></p>
[ { "answer_id": 154882, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 5, "selected": false, "text": "<p>Yes, any string in JavaScript has a <code>toLowerCase()</code> method that will return a new string that is the old stri...
2008/09/30
[ "https://Stackoverflow.com/questions/154862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5440/" ]
How can I convert a JavaScript string value to be in all lower case letters? Example: `"Your Name"` to `"your name"`
``` var lowerCaseName = "Your Name".toLowerCase(); ```
154,900
<p>I was wrestling with some Perl that uses hash references.</p> <p>In the end it turned out that my problem was the line:</p> <pre><code>$myhash{$key} |= {}; </code></pre> <p>That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value".</p> <p>Dereferencing this and trying to use it ...
[ { "answer_id": 154916, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>my %myhash;\n$myhash{$key} ||= {};\n</code></pre>\n\n<p>You can't declare a hash <em>element<...
2008/09/30
[ "https://Stackoverflow.com/questions/154900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7512/" ]
I was wrestling with some Perl that uses hash references. In the end it turned out that my problem was the line: ``` $myhash{$key} |= {}; ``` That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value". Dereferencing this and trying to use it as a hash reference, however, resulted i...
The reason you're seeing an error about using a string as a hash reference is because you're using the wrong operator. `|=` means "bitwise-or-assign." In other words, ``` $foo |= $bar; ``` is the same as ``` $foo = $foo | $bar ``` What's happening in your example is that your new anonymous hash reference is g...
154,902
<p>I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error:</p> <pre><code>a.c: In function `goUpDir': a.c:44: parse error before `c...
[ { "answer_id": 154930, "author": "Leahn Novash", "author_id": 5954, "author_profile": "https://Stackoverflow.com/users/5954", "pm_score": 3, "selected": true, "text": "<p>If you are compiling pure C, variables must be declared on the beggining of the functions. I mention this because mos...
2008/09/30
[ "https://Stackoverflow.com/questions/154902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I wrote a program in C with Ubuntu Linux and now I need to port it over to a UNIX machine (or what I believe to be a UNIX box). It compiles fine on my Ubuntu with GCC but when I try to compile it with GCC on the UNIX box, it gives this error: ``` a.c: In function `goUpDir': a.c:44: parse error before `char' a.c:45: `n...
If you are compiling pure C, variables must be declared on the beggining of the functions. I mention this because most people compile their C programs using C++ compilers, which offers then some resources not normally available to pure C compilers, the most common example being the // comment lines.
154,993
<p>I have an application where the contents of e-mails that get sent are stored in a .resx file.<br> This is an ASP.Net application, the .resx file lives in /App_GlobalResources </p> <p>When I need to send an e-mail, i'm reading this using: </p> <pre><code> HttpContext.GetGlobalResourceObject("MailContents", "EmailI...
[ { "answer_id": 155027, "author": "Caerbanog", "author_id": 23190, "author_profile": "https://Stackoverflow.com/users/23190", "pm_score": -1, "selected": false, "text": "<p>Something is not right with your placement of resources.</p>\n\n<p>Either your resource belongs to the website and s...
2008/09/30
[ "https://Stackoverflow.com/questions/154993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I have an application where the contents of e-mails that get sent are stored in a .resx file. This is an ASP.Net application, the .resx file lives in /App\_GlobalResources When I need to send an e-mail, i'm reading this using: ``` HttpContext.GetGlobalResourceObject("MailContents", "EmailID").ToString ``` Now...
I think I answered my own question... There's a ResXResourceReader class. I couldn't find it because it's in the Windows Forms namespace, which is not included in my current DLL references. Unfortunately, this will only let me iterate through results, so i'll implement some cute caching (read: memoization) over it....
155,022
<p>What is the easiest way to find out how much memory an object uses in .NET?</p> <p>Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types.</p> <p>Some related posts:</p> <ul> <li><a href="https://stackoverflow.co...
[ { "answer_id": 155042, "author": "McKenzieG1", "author_id": 3776, "author_profile": "https://Stackoverflow.com/users/3776", "pm_score": 2, "selected": false, "text": "<p>Asked and answered here: <a href=\"https://stackoverflow.com/questions/51540/determine-how-much-memory-a-class-uses#51...
2008/09/30
[ "https://Stackoverflow.com/questions/155022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15985/" ]
What is the easiest way to find out how much memory an object uses in .NET? Preferably without having to resort to a third party tool. Marshal.SizeOf or the sizeof operator look useful but only work with a restricted range of types. Some related posts: * [Object Memory Analysis in .NET](https://stackoverflow.com/que...
you could also do something like this: ``` int startMem = GC.GetTotalMemory(true); YourClass c = new YourClass(); int endMem = GC.GetTotalMemory(true); int usedMeme = endMem - startMem; ```
155,046
<p>I have two drop down menus that I want populated with identical data depending on what is selected on the parent drop down menu. Right now, I am using a javascript library that populates one child drop down menu based on a parent, but I need to have two drop down menus populated simultaneously.</p> <p>This javascri...
[ { "answer_id": 155056, "author": "mspmsp", "author_id": 21724, "author_profile": "https://Stackoverflow.com/users/21724", "pm_score": 0, "selected": false, "text": "<p>In the event handler you have for your parent drop down, you are probably having some other code populate that child dro...
2008/09/30
[ "https://Stackoverflow.com/questions/155046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23597/" ]
I have two drop down menus that I want populated with identical data depending on what is selected on the parent drop down menu. Right now, I am using a javascript library that populates one child drop down menu based on a parent, but I need to have two drop down menus populated simultaneously. This javascript library...
Reading the document you list, it seems there's a section that allows you to specify multiple child components from the parent: ``` To create the DynamicOptionList object, pass the names of the fields that are dependent on each other, with the parent field first. Create the object by passing field names var dol = ne...
155,065
<p>I am trying to implement a custom "broken image" icon to appear if I cannot load an image. To accomplish this, I used the brokenImageSkin parameter, but it renders the image at its true resolution, which ends up cutting off the image if the size of the control is constrained.</p> <pre><code> &lt;mx:Image broken...
[ { "answer_id": 155214, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 2, "selected": true, "text": "<p>I see that in this example,\n<a href=\"http://blog.flexexamples.com/2008/03/02/setting-a-custom-broken-image-skin-for-th...
2008/09/30
[ "https://Stackoverflow.com/questions/155065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5126/" ]
I am trying to implement a custom "broken image" icon to appear if I cannot load an image. To accomplish this, I used the brokenImageSkin parameter, but it renders the image at its true resolution, which ends up cutting off the image if the size of the control is constrained. ``` <mx:Image brokenImageSkin="@Embed(...
I see that in this example, <http://blog.flexexamples.com/2008/03/02/setting-a-custom-broken-image-skin-for-the-image-control-in-flex/#more-538>, there is an IO error event where you could set the width and height of the image.
155,071
<p>Do you have a simple debounce routine handy to deal with a single switch input?</p> <p>This is a simple bare metal system without any OS.</p> <p>I would like to avoid a looping construct with a specific count, as the processor speed might fluctuate.</p>
[ { "answer_id": 155103, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 1, "selected": false, "text": "<p>To debounce, you want to ignore any switch up that lasts under a certain threshold. You can set a hardware timer on ...
2008/09/30
[ "https://Stackoverflow.com/questions/155071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
Do you have a simple debounce routine handy to deal with a single switch input? This is a simple bare metal system without any OS. I would like to avoid a looping construct with a specific count, as the processor speed might fluctuate.
I think you could learn a lot about this here: <http://www.ganssle.com/debouncing.pdf> Your best bet is always to do this in hardware if possible, but there are some thoughts on software in there as well. Simple example code from TFA: ```cpp #define CHECK_MSEC 5 // Read hardware every 5 msec #define PRESS_MSEC 10 //...
155,074
<p>I'm a newbie when it comes to SQL. When creating a stored procedure with parameters as such:</p> <pre><code>@executed bit, @failure bit, @success bit, @testID int, @time float = 0, @name varchar(200) = '', @description varchar(200) =...
[ { "answer_id": 155082, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>A better approach would be to change the CommandText to just the name of the SP, and the CommandType to StoredProce...
2008/09/30
[ "https://Stackoverflow.com/questions/155074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13688/" ]
I'm a newbie when it comes to SQL. When creating a stored procedure with parameters as such: ``` @executed bit, @failure bit, @success bit, @testID int, @time float = 0, @name varchar(200) = '', @description varchar(200) = '', @executio...
A better approach would be to change the CommandText to just the name of the SP, and the CommandType to StoredProcedure - then the parameters will work much more cleanly: ``` cmd.CommandText = "insert_test_result"; cmd.CommandType = CommandType.StoredProcedure; ``` This also allows simpler passing by name, rather th...
155,080
<p>I can get rootmenuitemlefthtml and rootmenuitemrighthtml to emit but not separator. Tried CDATA wrapping and setting SeparatorCssClass. I just want pipes between root menu items.</p> <pre><code>&lt;dnn:SOLPARTMENU runat="server" id="dnnSOLPARTMENU" Separator="&lt;![CDATA[|]]&gt;" SeparatorCssClass="MainMenu_Separat...
[ { "answer_id": 173792, "author": "Joe Brinkman", "author_id": 4820, "author_profile": "https://Stackoverflow.com/users/4820", "pm_score": 2, "selected": false, "text": "<p>While not a direct answer - you might want to shift to the DotNetNuke menu rather than using SolPart. SolPart is no...
2008/09/30
[ "https://Stackoverflow.com/questions/155080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489/" ]
I can get rootmenuitemlefthtml and rootmenuitemrighthtml to emit but not separator. Tried CDATA wrapping and setting SeparatorCssClass. I just want pipes between root menu items. ``` <dnn:SOLPARTMENU runat="server" id="dnnSOLPARTMENU" Separator="<![CDATA[|]]>" SeparatorCssClass="MainMenu_SeparatorCSS" usearrow...
While not a direct answer - you might want to shift to the DotNetNuke menu rather than using SolPart. SolPart is no longer officially supported and development work on this menu ceased almost two years ago. Jon Henning, the author of SolPart, wrote the DotNetNuke menu from the ground up and tried to address many of the...
155,087
<p>Before you start firing at me, I'm NOT looking to do this, but someone in <a href="https://stackoverflow.com/questions/154698/how-can-i-keep-a-class-from-being-inherited-in-c">another post</a> said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some ...
[ { "answer_id": 155126, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 1, "selected": false, "text": "<p>It <strong><em>MIGHT</em></strong> (would increase the size if I could). According to the guys on freenode, it would in...
2008/09/30
[ "https://Stackoverflow.com/questions/155087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
Before you start firing at me, I'm NOT looking to do this, but someone in [another post](https://stackoverflow.com/questions/154698/how-can-i-keep-a-class-from-being-inherited-in-c) said it was possible. How is it possible? I've never heard of inheriting from anything using reflection. But I've seen some strange things...
Without virtual functions to override, there's not much point in subclassing a sealed class. If you try write a sealed class with a virtual function in it, you get the following compiler error: ``` // error CS0549: 'Seal.GetName()' is a new virtual member in sealed class 'Seal' ``` However, you can get virtual func...
155,101
<p>When I parse my xml file (variable f) in this method, I get an error </p> <blockquote> <p>C:\Documents and Settings\joe\Desktop\aicpcudev\OnlineModule\map.dtd (The system cannot find the path specified)</p> </blockquote> <p>I know I do not have the dtd, nor do I need it. How can I parse this File object into a ...
[ { "answer_id": 155118, "author": "Edward Z. Yang", "author_id": 23845, "author_profile": "https://Stackoverflow.com/users/23845", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I know I do not have the dtd, nor do I need it.</p>\n</blockquote>\n\n<p>I am suspicious of this...
2008/09/30
[ "https://Stackoverflow.com/questions/155101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
When I parse my xml file (variable f) in this method, I get an error > > C:\Documents and Settings\joe\Desktop\aicpcudev\OnlineModule\map.dtd (The system cannot find the path specified) > > > I know I do not have the dtd, nor do I need it. How can I parse this File object into a Document object while ignoring DT...
A similar approach to the one suggested by [@anjanb](https://stackoverflow.com/questions/155101/make-documentbuilderparse-ignore-dtd-references#155330) ``` builder.setEntityResolver(new EntityResolver() { @Override public InputSource resolveEntity(String publicId, String systemId) t...
155,105
<p>I am getting the following error when I put class files in subfolders of my App_Code folder:</p> <p>errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?)</p> <p>This class is not in a namespace at all. Any ideas?</p>
[ { "answer_id": 155111, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Is it possible that you haven't set the folder as an application in IIS (or your web server)? If not, then the App...
2008/09/30
[ "https://Stackoverflow.com/questions/155105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18926/" ]
I am getting the following error when I put class files in subfolders of my App\_Code folder: errorCS0246: The type or namespace name 'MyClassName' could not be found (are you missing a using directive or an assembly reference?) This class is not in a namespace at all. Any ideas?
You need to add codeSubDirectories to your compilation element in web.config ``` <configuration> <system.web> <compilation> <codeSubDirectories> <add directoryName="View"/> </codeSubDirectories> </compilation> </system.web> </configuration> ```
155,152
<p>I'm building a form with php/mysql. I've got a table with a list of locations and sublocations. Each sublocation has a parent location. A column "parentid" references another locationid in the same table. I now want to load these values into a dropdown in the following manner:</p> <pre><code>--Location 1 ----Subloc...
[ { "answer_id": 155159, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 1, "selected": false, "text": "<p>Are you looking for something like the <a href=\"http://www.w3schools.com/TAGS/tag_optgroup.asp\" rel=\"nofollow noreferrer...
2008/09/30
[ "https://Stackoverflow.com/questions/155152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22837/" ]
I'm building a form with php/mysql. I've got a table with a list of locations and sublocations. Each sublocation has a parent location. A column "parentid" references another locationid in the same table. I now want to load these values into a dropdown in the following manner: ``` --Location 1 ----Sublocation 1 ----Su...
NOTE: This is only psuedo-code.. I didn't try running it, though you should be able to adjust the concepts to what you need. ``` $parentsql = "SELECT parentid, parentname FROM table"; $result = mysql_query($parentsql); print "<select>"; while($row = mysql_fetch_assoc($result)){ $childsql = "SELECT childID, chi...
155,164
<p>I am getting the following error:</p> <pre><code>Open OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. HRESULT error code:0×80020009 Exception occurred. </code></pre> <p>I have tried following the directions <a hr...
[ { "answer_id": 155211, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "<p>Usually a authentication/permissions error.</p>\n\n<p>Is the SQL Server on the same box as the web server, review the...
2008/09/30
[ "https://Stackoverflow.com/questions/155164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/453046/" ]
I am getting the following error: ``` Open OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied. HRESULT error code:0×80020009 Exception occurred. ``` I have tried following the directions [here](http://wiki.rubyonrails....
My specifc issue I believe was related to having to many mixed systems installed on my laptop. I had Visual Studio 2005 and 2008 componets and SQL Server Managment Standard loaded with SQL Server Express Edition as well as various other componets that might have effected the stability of my envirnomnet. Once I reloaded...
155,188
<p>I have one text input and one button (see below). How can I use JavaScript to <strong>trigger the button's click event</strong> when the <kbd>Enter</kbd> key is pressed inside the text box?</p> <p>There is already a different submit button on my current page, so I can't simply make the button a submit button. And, ...
[ { "answer_id": 155193, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 6, "selected": false, "text": "<p>Make the button a submit element, so it'll be automatic.</p>\n\n<pre><code>&lt;input type = \"submit\"\n id = \...
2008/09/30
[ "https://Stackoverflow.com/questions/155188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23947/" ]
I have one text input and one button (see below). How can I use JavaScript to **trigger the button's click event** when the `Enter` key is pressed inside the text box? There is already a different submit button on my current page, so I can't simply make the button a submit button. And, I *only* want the `Enter` key to...
In jQuery, the following would work: ``` $("#id_of_textbox").keyup(function(event) { if (event.keyCode === 13) { $("#id_of_button").click(); } }); ``` ```js $("#pw").keyup(function(event) { if (event.keyCode === 13) { $("#myButton").click(); } }); $("#myButton").click(function()...
155,191
<p>I have written something that uses the following includes:</p> <pre><code>#include &lt;math.h&gt; #include &lt;time.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;windows.h&gt; #include &lt;commctrl.h&gt; </code></pre> <p>This code works fine on 2 machines with the Platform SDK installed, bu...
[ { "answer_id": 155200, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 0, "selected": false, "text": "<p>I suspect it is trying to find a version of common controls that isn't installed. You may need a manifest file to ma...
2008/09/30
[ "https://Stackoverflow.com/questions/155191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23942/" ]
I have written something that uses the following includes: ``` #include <math.h> #include <time.h> #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <commctrl.h> ``` This code works fine on 2 machines with the Platform SDK installed, but doesn't run (neither debug nor release versions) on clean in...
Use Dependency Walker. Download and install from <http://www.dependencywalker.com/> (just unzip to install). Then load up your executable. The tool will highlight which DLL is missing. Then you can find the redistributable pack which you need to ship with your executable. If you use VS2005, most cases will be covered ...
155,203
<p>What is a good error handling practice for an asp.net site? Examples? Thanks!</p>
[ { "answer_id": 155223, "author": "Max Schmeling", "author_id": 3226, "author_profile": "https://Stackoverflow.com/users/3226", "pm_score": 2, "selected": false, "text": "<p>One practice that I find to be especially useful is to create a generic error page, and then set your defaultRedire...
2008/09/30
[ "https://Stackoverflow.com/questions/155203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is a good error handling practice for an asp.net site? Examples? Thanks!
As with any .net project I find the best way is to only catch specific error types if they are may to happen on the given page. For example you could catch Format Exceptions for a users given input (just incase JavaScript validation fails and you have not use tryparse) but always leave the catching of the top level E...
155,209
<p>I'm trying to get my multithreading understanding locked down. I'm doing my best to teach myself, but some of these issues need clarification. </p> <p>I've gone through three iterations with a piece of code, experimenting with locking.</p> <p>In this code, the only thing that needs locking is this.managerThreadPri...
[ { "answer_id": 155225, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>1) Before you even start the other thread, you don't have to worry about shared access to it at all.</p>\n\n<p>2) Yes...
2008/09/30
[ "https://Stackoverflow.com/questions/155209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
I'm trying to get my multithreading understanding locked down. I'm doing my best to teach myself, but some of these issues need clarification. I've gone through three iterations with a piece of code, experimenting with locking. In this code, the only thing that needs locking is this.managerThreadPriority. First, th...
1) Before you even start the other thread, you don't have to worry about shared access to it at all. 2) Yes, you should lock *all* access to shared mutable data. (If it's immutable, no locking is required.) 3) Don't use GetHashCode() to indicate a thread ID. Use Thread.ManagedThreadId. I know, there are books which r...
155,220
<p>We are trying to update our classic asp search engine to protect it from SQL injection. We have a VB 6 function which builds a query dynamically by concatenating a query together based on the various search parameters. We have converted this to a stored procedure using dynamic sql for all parameters except for the...
[ { "answer_id": 155332, "author": "Rikalous", "author_id": 4271, "author_profile": "https://Stackoverflow.com/users/4271", "pm_score": 2, "selected": false, "text": "<p>You may not like to hear this, but it might be better for you to go back to dynamically constructing your SQL query in c...
2008/09/30
[ "https://Stackoverflow.com/questions/155220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23918/" ]
We are trying to update our classic asp search engine to protect it from SQL injection. We have a VB 6 function which builds a query dynamically by concatenating a query together based on the various search parameters. We have converted this to a stored procedure using dynamic sql for all parameters except for the keyw...
You may not like to hear this, but it might be better for you to go back to dynamically constructing your SQL query in code before issuing against the database. If you use parameter placeholders in the SQL string you get the protection against SQL injection attacks. Example: ``` string sql = "SELECT Name, Title FROM...
155,234
<p>I have a cluster of three mongrels running under nginx, and I deploy the app using Capistrano 2.4.3. When I "cap deploy" when there is a running system, the behavior is: </p> <ol> <li>The app is deployed. The code is successfully updated. </li> <li><p>In the cap deploy output, there is this: </p> <ul> <li>executin...
[ { "answer_id": 155401, "author": "salt.racer", "author_id": 757, "author_profile": "https://Stackoverflow.com/users/757", "pm_score": 0, "selected": false, "text": "<p>I hate to be so basic, but it sounds like the pid files are still hanging around when it is trying to start. Make sure t...
2008/09/30
[ "https://Stackoverflow.com/questions/155234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13472/" ]
I have a cluster of three mongrels running under nginx, and I deploy the app using Capistrano 2.4.3. When I "cap deploy" when there is a running system, the behavior is: 1. The app is deployed. The code is successfully updated. 2. In the cap deploy output, there is this: * executing "sudo -p 'sudo password: ' mon...
You can explicitly tell the mongrel\_cluster recipes to remove the pid files before a start by adding the following in your capistrano recipes: ``` # helps keep mongrel pid files clean set :mongrel_clean, true ``` This causes it to pass the --clean option to mongrel\_cluster\_ctl. I went back and looked at one of m...
155,243
<p>As a follow up to a <a href="https://stackoverflow.com/questions/151590/java-how-do-detect-a-remote-side-socket-close">recent question</a>, I wonder why it is impossible in Java, without attempting reading/writing on a TCP socket, to detect that the socket has been gracefully closed by the peer? This seems to be the...
[ { "answer_id": 155328, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 4, "selected": false, "text": "<p>The underlying sockets API doesn't have such a notification. </p>\n\n<p>The sending TCP stack won't send the FIN bit...
2008/09/30
[ "https://Stackoverflow.com/questions/155243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16724/" ]
As a follow up to a [recent question](https://stackoverflow.com/questions/151590/java-how-do-detect-a-remote-side-socket-close), I wonder why it is impossible in Java, without attempting reading/writing on a TCP socket, to detect that the socket has been gracefully closed by the peer? This seems to be the case regardle...
I have been using Sockets often, mostly with Selectors, and though not a Network OSI expert, from my understanding, calling `shutdownOutput()` on a Socket actually sends something on the network (FIN) that wakes up my Selector on the other side (same behaviour in C language). Here you have **detection**: actually detec...
155,246
<p>I have a test environment for a database that I want to reload with new data at the start of a testing cycle. I am not interested in rebuilding the entire database- just simply "re-setting" the data. </p> <p>What is the best way to remove all the data from all the tables using TSQL? Are there system stored procedur...
[ { "answer_id": 155270, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "<p>This is <em>one</em> way to do it... there are likely 10 others that are better/more efficient, but it sounds like ...
2008/09/30
[ "https://Stackoverflow.com/questions/155246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
I have a test environment for a database that I want to reload with new data at the start of a testing cycle. I am not interested in rebuilding the entire database- just simply "re-setting" the data. What is the best way to remove all the data from all the tables using TSQL? Are there system stored procedures, views,...
For SQL 2005, ``` EXEC sp_MSForEachTable 'TRUNCATE TABLE ?' ``` Couple more links for [2000](http://www.databasejournal.com/scripts/article.php/2226781) and [2005/2008](http://www.keithrull.com/2007/09/07/HowToTruncateMultipleTablesInSQLServerAndTheMagicOfSpMSforeachtable.aspx)..
155,260
<p>I have been learning about the basics of C# but haven't come across a good explanation of what this is:</p> <pre><code>var l = new List&lt;string&gt;(); </code></pre> <p>I don't know what the <code>&lt;string&gt;</code> is doing or if it's the <code>List</code> that is doing the magic. I have also seen objects bee...
[ { "answer_id": 155280, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 1, "selected": false, "text": "<p>This is .NET Generics. The type within the &lt; > denotes the type of element contained in the list.</p>\n\n<p>wit...
2008/09/30
[ "https://Stackoverflow.com/questions/155260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22459/" ]
I have been learning about the basics of C# but haven't come across a good explanation of what this is: ``` var l = new List<string>(); ``` I don't know what the `<string>` is doing or if it's the `List` that is doing the magic. I have also seen objects been thrown within the `< >` tags. Can someone explain this to...
That is the generic syntax for C#. The basic concept is that it allows you to use a Type placeholder and substitute the actual real type in at compile time. For example, the old way: ``` ArrayList foos = new Arraylist(); foos.Add("Test"); ``` worked by making ArrayList store a list of System.Objects (The base type...
155,279
<p>I have an AdvancedDataGrid that uses customer grouping of data. Not all of the groups will be at the same level in the hierarchy, and groups can contain both groups and members. We have a sort callback, but it's not being called except for groups at the leaf-most levels. See code below for an example -- expand all o...
[ { "answer_id": 156283, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 0, "selected": false, "text": "<p>This has something to do with the logic of the SortCompareFunction.</p>\n\n<p>Put <code>dob:\"01/01/1970\"</code> for...
2008/09/30
[ "https://Stackoverflow.com/questions/155279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22809/" ]
I have an AdvancedDataGrid that uses customer grouping of data. Not all of the groups will be at the same level in the hierarchy, and groups can contain both groups and members. We have a sort callback, but it's not being called except for groups at the leaf-most levels. See code below for an example -- expand all of t...
It seems as if the first row contains null data or an empty string, and the advanceddatagrid is set to use grouped data, then the sort function doesn't get called. it's a bit of a hack, yes, but if you can put in an unrealistic (say 1/1/1770), constant piece of data that you could insert at the database/file read/data...
155,291
<p>I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything.</p> <p>I'd rather not use Disabled, since I want the checked check boxes to be submitted with the rest of the form, I just don't want the client to be able t...
[ { "answer_id": 155301, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 9, "selected": false, "text": "<p><code>READONLY</code> doesn't work on checkboxes as it prevents you from editing a field's <em>value</em>, but with a che...
2008/09/30
[ "https://Stackoverflow.com/questions/155291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything. I'd rather not use Disabled, since I want the checked check boxes to be submitted with the rest of the form, I just don't want the client to be able to change t...
`READONLY` doesn't work on checkboxes as it prevents you from editing a field's *value*, but with a checkbox you're actually editing the field's *state* (on || off) From [faqs.org](http://www.faqs.org/docs/htmltut/forms/_INPUT_DISABLED.html): > > It's important to understand that READONLY merely prevents the user fr...
155,303
<p>How do I go from this string: "ThisIsMyCapsDelimitedString"</p> <p>...to this string: "This Is My Caps Delimited String"</p> <p>Fewest lines of code in VB.net is preferred but C# is also welcome.</p> <p>Cheers!</p>
[ { "answer_id": 155331, "author": "Max Schmeling", "author_id": 3226, "author_profile": "https://Stackoverflow.com/users/3226", "pm_score": 0, "selected": false, "text": "<p>There's probably a more elegant solution, but this is what I come up with off the top of my head:</p>\n\n<pre><code...
2008/09/30
[ "https://Stackoverflow.com/questions/155303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17235/" ]
How do I go from this string: "ThisIsMyCapsDelimitedString" ...to this string: "This Is My Caps Delimited String" Fewest lines of code in VB.net is preferred but C# is also welcome. Cheers!
I made this a while ago. It matches each component of a CamelCase name. ``` /([A-Z]+(?=$|[A-Z][a-z])|[A-Z]?[a-z]+)/g ``` For example: ``` "SimpleHTTPServer" => ["Simple", "HTTP", "Server"] "camelCase" => ["camel", "Case"] ``` To convert that to just insert spaces between the words: ``` Regex.Replace(s, "([a-z](?...
155,306
<p>I have a textarea with many lines of input, and a JavaScript event fires that necessitates I scroll the textarea to line 345.</p> <p><code>scrollTop</code> sort of does what I want, except as far as I can tell it's pixel level, and I want something that operates on a line level. What also complicates things is that...
[ { "answer_id": 155404, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 5, "selected": true, "text": "<p>You can stop wrapping with the wrap attribute. It is not part of HTML 4, but most browsers support it.<br />\nYou can com...
2008/09/30
[ "https://Stackoverflow.com/questions/155306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23845/" ]
I have a textarea with many lines of input, and a JavaScript event fires that necessitates I scroll the textarea to line 345. `scrollTop` sort of does what I want, except as far as I can tell it's pixel level, and I want something that operates on a line level. What also complicates things is that, afaik once again, i...
You can stop wrapping with the wrap attribute. It is not part of HTML 4, but most browsers support it. You can compute the height of a line by dividing the height of the area by its number of rows. ``` <script type="text/javascript" language="JavaScript"> function Jump(line) { var ta = document.getElementById("Te...
155,308
<p>I'm trying to get a PHP site working in IIS on Windows Server with MySQL.</p> <p>I'm getting this error…</p> <p>Fatal error: Call to undefined function mysql_connect() in C:\inetpub...\adodb\drivers\adodb-mysql.inc.php on line 363</p> <hr /> <p>Update…</p> <p>This link outlines the steps I followed to install PHP on...
[ { "answer_id": 155316, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<p>Check out phpinfo to see if the mysql functions are compiled with your PHP</p>\n\n<pre><code>&lt;?php\n phpinfo...
2008/09/30
[ "https://Stackoverflow.com/questions/155308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
I'm trying to get a PHP site working in IIS on Windows Server with MySQL. I'm getting this error… Fatal error: Call to undefined function mysql\_connect() in C:\inetpub...\adodb\drivers\adodb-mysql.inc.php on line 363 --- Update… This link outlines the steps I followed to install PHP on my server: [How do I get...
I found the solution: [How do I install MySQL modules within PHP?](https://stackoverflow.com/questions/158279/how-do-i-install-mysql-modules-within-php#160746)
155,311
<p>I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++?</p> <p>I would like to pass it two parameters and do not need a result.</p>
[ { "answer_id": 155339, "author": "KeyserSoze", "author_id": 14116, "author_profile": "https://Stackoverflow.com/users/14116", "pm_score": 0, "selected": false, "text": "<p>Perhaps you want to emit a signal?</p>\n\n<p>I really liked Qt's signals and slots functionality, and I know Boost h...
2008/09/30
[ "https://Stackoverflow.com/questions/155311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
I would like invoke a function call in a one shot manner. What's the best way to do this in Boost / C++? I would like to pass it two parameters and do not need a result.
Well you can spin up a thread and then never join it again. Something like: ``` boost::thread some_thread(&SomeFunction, param1, param2); ``` Once the some\_thread variable goes out of scope, the thread of execution will be detached and will not be able to be joined again. It's a waste to spin up a thread unless the...
155,314
<p>I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail.</p> <p>Something along these lines should work: </p> <pre><code>// filename examples: "test.avi", "test.dvr-ms" // position is from 0 to 100 percent (0.0 to 1.0) // returns a bitmap byte[] GetVide...
[ { "answer_id": 155320, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 3, "selected": false, "text": "<p>This project will do the trick for AVIs: <a href=\"http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx\" ...
2008/09/30
[ "https://Stackoverflow.com/questions/155314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail. Something along these lines should work: ``` // filename examples: "test.avi", "test.dvr-ms" // position is from 0 to 100 percent (0.0 to 1.0) // returns a bitmap byte[] GetVideoThumbnail(string fil...
I ended up rolling my own stand alone class (with the single method I described), the source can be [viewed here](https://gist.github.com/2823028). [Media browser is](http://www.mediabrowser.tv) GPL but I am happy for the code I wrote for that file to be Public Domain. Keep in mind it uses interop from the [directshow....
155,321
<p>I'm trying to build a mapping table to associate the IDs of new rows in a table with those that they're copied from. The OUTPUT INTO clause seems perfect for that, but it doesn't seem to behave according to the documentation. </p> <p>My code:</p> <pre><code>DECLARE @Missing TABLE (SrcContentID INT PRIMARY KEY ) IN...
[ { "answer_id": 156352, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 5, "selected": true, "text": "<p>I've verified that the problem is that you can only use <code>INSERTED</code> columns. The documentation seems to ind...
2008/09/30
[ "https://Stackoverflow.com/questions/155321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10082/" ]
I'm trying to build a mapping table to associate the IDs of new rows in a table with those that they're copied from. The OUTPUT INTO clause seems perfect for that, but it doesn't seem to behave according to the documentation. My code: ``` DECLARE @Missing TABLE (SrcContentID INT PRIMARY KEY ) INSERT INTO @Missing ...
I've verified that the problem is that you can only use `INSERTED` columns. The documentation seems to indicate that you can use `from_table_name`, but I can't seem to get it to work (The multi-part identifier "m.ContentID" could not be bound.): ``` TRUNCATE TABLE main SELECT * FROM incoming SELECT * FROM main DECL...
155,334
<p>The application uses Oracle DataAccess ver. 1.1. , VS 2008, .Net Framework 3.5 w/SP1</p> <pre><code>OracleConnection connection = new OracleConnection(ConnectionStringLogon); connection.Open(); OracleParameter selectParam = new OracleParameter(":applicationName", OracleDbType.Varchar2, 256); selectParam.Value = a...
[ { "answer_id": 155335, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "<p>The closest I can think of is doing something similar with <a href=\"http://www.shunra.com/vedesktop.aspx\" rel=\"no...
2008/09/30
[ "https://Stackoverflow.com/questions/155334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The application uses Oracle DataAccess ver. 1.1. , VS 2008, .Net Framework 3.5 w/SP1 ``` OracleConnection connection = new OracleConnection(ConnectionStringLogon); connection.Open(); OracleParameter selectParam = new OracleParameter(":applicationName", OracleDbType.Varchar2, 256); selectParam.Value = applicationName;...
if you're using apache you may want to take a look at [apache ab](http://httpd.apache.org/docs/2.0/programs/ab.html)
155,371
<p>I want to use XMLHttpRequest in JavaScript to POST a form that includes a file type input element so that I can avoid page refresh and get useful XML back.</p> <p>I can submit the form without page refresh, using JavaScript to set the target attribute on the form to an iframe for MSIE or an object for Mozilla, but ...
[ { "answer_id": 155429, "author": "helios", "author_id": 9686, "author_profile": "https://Stackoverflow.com/users/9686", "pm_score": 0, "selected": false, "text": "<p>I don't see why iframe (an invisible one) implies XHTML and not ANY content. If you use an iframe you can set the onreadys...
2008/09/30
[ "https://Stackoverflow.com/questions/155371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14405/" ]
I want to use XMLHttpRequest in JavaScript to POST a form that includes a file type input element so that I can avoid page refresh and get useful XML back. I can submit the form without page refresh, using JavaScript to set the target attribute on the form to an iframe for MSIE or an object for Mozilla, but this has t...
You can construct the 'multipart/form-data' request yourself (read more about it at <http://www.faqs.org/rfcs/rfc2388.html>) and then use the `send` method (ie. xhr.send(your-multipart-form-data)). Similarly, but easier, in Firefox 4+ (also in Chrome 5+ and Safari 5+) you can use the [FormData](http://hacks.mozilla.org...
155,375
<p>I'm working with a datagrid and adapter that correspond with an MSAccess table through a stored query (named "UpdatePaid", 3 paramaters as shown below) like so:</p> <pre><code> OleDbCommand odc = new OleDbCommand("UpdatePaid", connection); OleDbParameter param; odc.CommandType = CommandType.StoredProce...
[ { "answer_id": 155561, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 0, "selected": false, "text": "<p>I don't use it with SqlDbCommand. It seems as a bug to me that it's <em>required</em>. It should only be <em>nice to have...
2008/09/30
[ "https://Stackoverflow.com/questions/155375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13776/" ]
I'm working with a datagrid and adapter that correspond with an MSAccess table through a stored query (named "UpdatePaid", 3 paramaters as shown below) like so: ``` OleDbCommand odc = new OleDbCommand("UpdatePaid", connection); OleDbParameter param; odc.CommandType = CommandType.StoredProcedure; par...
This is called, oddly enough, a prepared statement, and they're actually really nice. Basically what happens is you either create or get a sql statement (insert, delete, update) and instead of passing actual values, you pass "?" as a place holder. This is all well and good, except what we want is our values to get pass...
155,388
<p>Suppose that I have interface MyInterface and 2 classes A, B which implement MyInterface.<br> I declared 2 objects: <code>MyInterface a = new A()</code> , and <code>MyInterface b = new B()</code>.<br> When I try to pass to a function - function <code>doSomething(A a){}</code> I am getting an error.</p> <p>This is m...
[ { "answer_id": 155411, "author": "Max Schmeling", "author_id": 3226, "author_profile": "https://Stackoverflow.com/users/3226", "pm_score": 2, "selected": false, "text": "<p>I'm unclear on what you're actually asking, but the problem is that you don't have a method that takes a parameter ...
2008/09/30
[ "https://Stackoverflow.com/questions/155388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23968/" ]
Suppose that I have interface MyInterface and 2 classes A, B which implement MyInterface. I declared 2 objects: `MyInterface a = new A()` , and `MyInterface b = new B()`. When I try to pass to a function - function `doSomething(A a){}` I am getting an error. This is my code: ``` public interface MyInterface {} ...
Can you not just have a method on the interface which each class implements? Or do you not have control of the interface? This would provide both polymorphism and avoid the need to define any external methods. I believe this is the intention of an interface, it allows a client to treat all classes implementing it in ...
155,391
<p>What is the difference between a BitmapFrame and BitmapImage in WPF? Where would you use each (ie. why would you use a BitmapFrame rather than a BitmapImage?)</p>
[ { "answer_id": 155433, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 5, "selected": true, "text": "<p>You should stick to using the abstract class <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.media.im...
2008/09/30
[ "https://Stackoverflow.com/questions/155391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
What is the difference between a BitmapFrame and BitmapImage in WPF? Where would you use each (ie. why would you use a BitmapFrame rather than a BitmapImage?)
You should stick to using the abstract class [BitmapSource](http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx) if you need to get at the bits, or even [ImageSource](http://msdn.microsoft.com/en-us/library/system.windows.media.imagesource.aspx) if you just want to draw it. The imple...
155,427
<p>I have a form element that I want to address via javascript, but it doesn't like the syntax.</p> <pre><code>&lt;form name="mycache"&gt; &lt;input type="hidden" name="cache[m][2]"&gt; &lt;!-- ... --&gt; &lt;/form&gt; </code></pre> <p>I want to be able to say:</p> <pre><code>document.mycache.cache[m][2] </code>...
[ { "answer_id": 155437, "author": "Chris Pietschmann", "author_id": 7831, "author_profile": "https://Stackoverflow.com/users/7831", "pm_score": 3, "selected": true, "text": "<p>UPDATE: Actually, I was wrong, you can use [ or ] characters as part of a form elements id and/or name attribute...
2008/09/30
[ "https://Stackoverflow.com/questions/155427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14253/" ]
I have a form element that I want to address via javascript, but it doesn't like the syntax. ``` <form name="mycache"> <input type="hidden" name="cache[m][2]"> <!-- ... --> </form> ``` I want to be able to say: ``` document.mycache.cache[m][2] ``` but obviously I need to indicate that `cache[m][2]` is the who...
UPDATE: Actually, I was wrong, you can use [ or ] characters as part of a form elements id and/or name attribute. Here's some code that proves it: ``` <html> <body> <form id="form1"> <input type='test' id='field[m][2]' name='field[m][2]' value='Chris'/> <input type='button' value='Test' onclick='showtest();'/> <s...
155,435
<p>In JavaScript, you can do this:</p> <pre><code>var a = null; var b = "I'm a value"; var c = null; var result = a || b || c; </code></pre> <p>And 'result' will get the value of 'b' because JavaScript short-circuits the 'or' operator.</p> <p>I want a one-line idiom to do this in ColdFusion and the best I can come u...
[ { "answer_id": 155529, "author": "Peter Boughton", "author_id": 9360, "author_profile": "https://Stackoverflow.com/users/9360", "pm_score": 4, "selected": true, "text": "<p>ColdFusion doesn't have nulls.</p>\n\n<p>Your example is basing the choice on which item is an empty string.</p>\n\...
2008/09/30
[ "https://Stackoverflow.com/questions/155435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13958/" ]
In JavaScript, you can do this: ``` var a = null; var b = "I'm a value"; var c = null; var result = a || b || c; ``` And 'result' will get the value of 'b' because JavaScript short-circuits the 'or' operator. I want a one-line idiom to do this in ColdFusion and the best I can come up with is: ``` <cfif LEN(c) GT 0...
ColdFusion doesn't have nulls. Your example is basing the choice on which item is an empty string. If that is what you're after, and all your other values are simple values, you can do this: ``` <cfset result = ListFirst( "#a#,#b#,#c#" )/> ``` (Which works because the standard list functions ignore empty elements....
155,449
<p>Right now I have the following in my <code>.vimrc</code>:</p> <pre><code>au BufWritePost *.c,*.cpp,*.h !ctags -R </code></pre> <p>There are a few problems with this:</p> <ol> <li>It's slow -- regenerates tags for files that haven't changed since the last tag generation.</li> <li>I have to push the enter button <e...
[ { "answer_id": 155477, "author": "zigdon", "author_id": 4913, "author_profile": "https://Stackoverflow.com/users/4913", "pm_score": 2, "selected": false, "text": "<p>How about having ctags scheduled to run via crontab? If your project tree is fairly stable in it's structure, that should...
2008/09/30
[ "https://Stackoverflow.com/questions/155449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
Right now I have the following in my `.vimrc`: ``` au BufWritePost *.c,*.cpp,*.h !ctags -R ``` There are a few problems with this: 1. It's slow -- regenerates tags for files that haven't changed since the last tag generation. 2. I have to push the enter button *again* after writing the file because of an inevitable...
`au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &` The downside is that you won't have a useful tags file until it completes. As long as you're on a \*nix system it should be ok to do multiple writes before the previous ctags has completed, but you should test that. On a Windows system it won't put it in the backgrou...
155,458
<p>I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data.</p> <p>Here is the code :</p> <pre><code> if (region != null) { .... } </code></pre> <p>This is working but when looping and looping sometime the region object is NOT null (I can see data inside it in ...
[ { "answer_id": 155464, "author": "skb", "author_id": 14101, "author_profile": "https://Stackoverflow.com/users/14101", "pm_score": 2, "selected": false, "text": "<p>This can sometimes happen when you have multiple threads working with the same data. If this is the case, you can use a lo...
2008/09/30
[ "https://Stackoverflow.com/questions/155458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
I need to do a comparaison between an object and NULL. When the object is not NULL I fill it with some data. Here is the code : ``` if (region != null) { .... } ``` This is working but when looping and looping sometime the region object is NOT null (I can see data inside it in debug mode). In step-by-step when...
Is the == and/or != operator overloaded for the region object's class? Now that you've posted the code for the overloads: The overloads should probably look like the following (code taken from postings made by [Jon Skeet](https://stackoverflow.com/questions/155458/c-object-is-not-null-but-myobject-null-still-return-f...
155,460
<p>I'm using LINQ to SQL and C#. I have two LINQ classes: User and Network. </p> <p>User has UserID (primary key) and NetworkID</p> <p>Network has NetworkID (primary key) and an AdminID (a UserID)</p> <p>The following code works fine:</p> <pre><code>user.Network.AdminID = 0; db.SubmitChanges(); </code></pre> <p>...
[ { "answer_id": 155641, "author": "CodeRedick", "author_id": 17145, "author_profile": "https://Stackoverflow.com/users/17145", "pm_score": 3, "selected": true, "text": "<p>I just ran a quick test and it works fine for me. </p>\n\n<p>I hate to ask this, but are you sure the if statement e...
2008/09/30
[ "https://Stackoverflow.com/questions/155460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23971/" ]
I'm using LINQ to SQL and C#. I have two LINQ classes: User and Network. User has UserID (primary key) and NetworkID Network has NetworkID (primary key) and an AdminID (a UserID) The following code works fine: ``` user.Network.AdminID = 0; db.SubmitChanges(); ``` However, if I access the AdminID before making th...
I just ran a quick test and it works fine for me. I hate to ask this, but are you sure the if statement ever returns true? It could be you're just not hitting the code which changes the value. Other than that we might need more info. What are the properties of that member? Have you traced into the set statement to e...
155,462
<p>In Ruby:</p> <pre><code>for i in A do # some code end </code></pre> <p>is the same as: </p> <pre><code>A.each do |i| # some code end </code></pre> <p><code>for</code> is not a kernel method:</p> <ul> <li>What exactly is "<code>for</code>" in ruby</li> <li>Is there a way to use other keywords to do simila...
[ { "answer_id": 155513, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 4, "selected": false, "text": "<p><code>for</code> is just syntax sugar for the <code>each</code> method. This can be seen by running this code:</p>\n\n<...
2008/09/30
[ "https://Stackoverflow.com/questions/155462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14167/" ]
In Ruby: ``` for i in A do # some code end ``` is the same as: ``` A.each do |i| # some code end ``` `for` is not a kernel method: * What exactly is "`for`" in ruby * Is there a way to use other keywords to do similar things? Something like: ``` total = sum i in I {x[i]} ``` mapping to: ``` total ...
It's almost syntax sugar. One difference is that, while `for` would use the scope of the code around it, `each` creates a separate scope within its block. Compare the following: ``` for i in (1..3) x = i end p x # => 3 ``` versus ``` (1..3).each do |i| x = i end p x # => undefined local variable or method `x' f...
155,504
<p>I had a look in the reference doc, and Spring seems to have pretty good support for sending mail. However, I need to login to a mail account, read the messages, and download any attachments. Is downloading mail attachments supported by the Spring mail API?</p> <p>I know you can do this with the Java Mail API, but i...
[ { "answer_id": 155523, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 0, "selected": false, "text": "<p>Thus far, I've only used the JavaMail APIs (and I've been reasonably happy with them for my purposes). If the full...
2008/09/30
[ "https://Stackoverflow.com/questions/155504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I had a look in the reference doc, and Spring seems to have pretty good support for sending mail. However, I need to login to a mail account, read the messages, and download any attachments. Is downloading mail attachments supported by the Spring mail API? I know you can do this with the Java Mail API, but in the past...
Here's the class that I use for downloading e-mails (with attachment handling). You'll have to glance by some of the stuff it's doing (like ignore the logging classes and database writes). I've also re-named some of the packages for ease of reading. The general idea is that all attachments are saved as individual file...
155,507
<p>How exactly can I create a new directory using Emacs? What commands do I use? (If possible, please provide an example)</p>
[ { "answer_id": 155510, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 9, "selected": true, "text": "<ul>\n<li><p>to create the directory <code>dir/to/create</code>, type:</p>\n\n<pre><code>M-x make-directory RET dir/to/create RET...
2008/09/30
[ "https://Stackoverflow.com/questions/155507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
How exactly can I create a new directory using Emacs? What commands do I use? (If possible, please provide an example)
* to create the directory `dir/to/create`, type: ``` M-x make-directory RET dir/to/create RET ``` * to create directories `dir/parent1/node` and `dir/parent2/node`, type: ``` M-! mkdir -p dir/parent{1,2}/node RET ``` It assumes that Emacs's inferior shell is `bash`/`zsh` or other compatible shell. * or in a `Dired...
155,517
<p>Is it possible to cancel out of a long running process in VB6.0 without using DoEvents?</p> <p>For example:</p> <pre><code>for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end if next Sub btnCancel_Click() cancel = true End Sub </code></pre> <p>I assu...
[ { "answer_id": 155527, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 3, "selected": false, "text": "<p>Is the \"for\" loop running in the GUI thread? If so, yes, you'll need a DoEvents. You may want to use a sepa...
2008/09/30
[ "https://Stackoverflow.com/questions/155517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5019/" ]
Is it possible to cancel out of a long running process in VB6.0 without using DoEvents? For example: ``` for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end if next Sub btnCancel_Click() cancel = true End Sub ``` I assume I need a "DoEvents" before the...
Nope, you got it right, you definitely want DoEvents in your loop. If you put the `DoEvents` in your main loop and find that slows down processing too much, try calling the Windows API function `GetQueueStatus` (which is much faster than DoEvents) to quickly determine if it's even necessary to call DoEvents. `GetQueue...
155,532
<p>Are there any good methods for getting ASP.NET 2.0 to validate under the XHTML 1.0 Strict (or Transitional) DTD? I'm interested to hear some ideas before I hack up the core of the HTTP response.</p> <p>One major problem is the form tag itself, this is the output I got from W3C when I tried to validate:</p> <pre><...
[ { "answer_id": 155553, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 2, "selected": false, "text": "<p>Its possible to change the output of ASP.NET controls using techniques like the <a href=\"http://www.asp.net/CssAdapters/\" r...
2008/09/30
[ "https://Stackoverflow.com/questions/155532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12252/" ]
Are there any good methods for getting ASP.NET 2.0 to validate under the XHTML 1.0 Strict (or Transitional) DTD? I'm interested to hear some ideas before I hack up the core of the HTTP response. One major problem is the form tag itself, this is the output I got from W3C when I tried to validate: ``` Line 13, Column 1...
ASP.NET 2.0 and above can indeed output Strict (or Transitional) XHTML. This will resolve your 'there is no attribute "name"' validation error, amongst other things. To set this up, update your Web.config file with something like: ``` <system.web> ... other configuration goes here ... <xhtmlConformance mode="S...
155,540
<p>I'm writing a scheduler or sorts. It's basically a table with a list of exes (like "C:\a.exe") and a console app that looks at the records in the table every minute or so and runs the tasks that haven't been run yet.</p> <p>I run the tasks like this:</p> <pre><code>System.Diagnostics.Process p = new System.Diagno...
[ { "answer_id": 155554, "author": "Kenny Mann", "author_id": 18217, "author_profile": "https://Stackoverflow.com/users/18217", "pm_score": 3, "selected": false, "text": "<p>I think you're looking for Process.ExitCode, assuming the process returns one.\nYou may need to use WaitForExit() th...
2008/09/30
[ "https://Stackoverflow.com/questions/155540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
I'm writing a scheduler or sorts. It's basically a table with a list of exes (like "C:\a.exe") and a console app that looks at the records in the table every minute or so and runs the tasks that haven't been run yet. I run the tasks like this: ``` System.Diagnostics.Process p = new System.Diagnostics.Process(); p.Sta...
You can catch the [Win32Exception](http://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.aspx) to check if [Process.Start()](http://msdn.microsoft.com/en-us/library/e8zac0ca.aspx) failed due to the file not existing or execute access is denied. But you can not catch exceptions thrown by the proc...
155,544
<p>I need to create a unique ID for a given location, and the location's ID must be sequential. So its basically like a primary key, except that it is also tied to the locationID. So 3 different locations will all have ID's like 1,2,3,4,5,...,n</p> <p>What is the best way to do this? I also need a safe way of getti...
[ { "answer_id": 155557, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 1, "selected": false, "text": "<p>You'll want to wrap both the code to find the next ID and the code to save the row in the same transaction. You ...
2008/09/30
[ "https://Stackoverflow.com/questions/155544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
I need to create a unique ID for a given location, and the location's ID must be sequential. So its basically like a primary key, except that it is also tied to the locationID. So 3 different locations will all have ID's like 1,2,3,4,5,...,n What is the best way to do this? I also need a safe way of getting the nextI...
One of the ways I've seen this done is by creating a table mapping the location to the next ID. ``` CREATE TABLE LocationID { Location varchar(32) PRIMARY KEY, NextID int DEFAULT(1) } ``` Inside your stored procedure you can do an update and grab the current value while also incrementing the value: ``` ... ...
155,584
<p>I need a way to allow each letter of a word to rotate through 3 different colors. I know of some not so clean ways I can do this with asp.NET, but I'm wondering if there might be a cleaner CSS/JavaScript solution that is more search engine friendly.</p> <p>The designer is including <a href="http://stlartworks.effic...
[ { "answer_id": 155595, "author": "Brendan Kidwell", "author_id": 13958, "author_profile": "https://Stackoverflow.com/users/13958", "pm_score": 3, "selected": false, "text": "<p>On the server-side you can do this easily enough without annoying search engines AFAIK.</p>\n\n<pre><code>// Th...
2008/09/30
[ "https://Stackoverflow.com/questions/155584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4318/" ]
I need a way to allow each letter of a word to rotate through 3 different colors. I know of some not so clean ways I can do this with asp.NET, but I'm wondering if there might be a cleaner CSS/JavaScript solution that is more search engine friendly. The designer is including [a file like this](http://stlartworks.effic...
Here is some JavaScript. ```js var message = "The quick brown fox."; var colors = new Array("#ff0000","#00ff00","#0000ff"); // red, green, blue for (var i = 0; i < message.length; i++){ document.write("<span style=\"color:" + colors[(i % colors.length)] + ";\">" + message[i] + "</span>"); } ```
155,586
<p>We use the DesignSurface and all that good IDesignerHost goodness in our own designer. The designed forms are then persisted in our own bespoke format and all that works great. WE also want to export the forms to a text-based format (which we've done as it isn't that difficult).</p> <p>However, we also want to impo...
[ { "answer_id": 155595, "author": "Brendan Kidwell", "author_id": 13958, "author_profile": "https://Stackoverflow.com/users/13958", "pm_score": 3, "selected": false, "text": "<p>On the server-side you can do this easily enough without annoying search engines AFAIK.</p>\n\n<pre><code>// Th...
2008/09/30
[ "https://Stackoverflow.com/questions/155586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23234/" ]
We use the DesignSurface and all that good IDesignerHost goodness in our own designer. The designed forms are then persisted in our own bespoke format and all that works great. WE also want to export the forms to a text-based format (which we've done as it isn't that difficult). However, we also want to import that te...
Here is some JavaScript. ```js var message = "The quick brown fox."; var colors = new Array("#ff0000","#00ff00","#0000ff"); // red, green, blue for (var i = 0; i < message.length; i++){ document.write("<span style=\"color:" + colors[(i % colors.length)] + ";\">" + message[i] + "</span>"); } ```
155,649
<p>What's the best way to add the coordinates of a circle to an array in JavaScript? So far I've only been able to do a half circle, but I need a formula that returns the whole circle to two different arrays: <code>xValues</code> and <code>yValues</code>. (I'm trying to get the coordinates so I can animate an object al...
[ { "answer_id": 155653, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 1, "selected": false, "text": "<p>If you already have half a circle, just mirror the points to get the other half<br>\nmake sure you do this in the right or...
2008/09/30
[ "https://Stackoverflow.com/questions/155649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281/" ]
What's the best way to add the coordinates of a circle to an array in JavaScript? So far I've only been able to do a half circle, but I need a formula that returns the whole circle to two different arrays: `xValues` and `yValues`. (I'm trying to get the coordinates so I can animate an object along a path.) **Here's wh...
Your loop should be set up like this instead: ``` for (var i = 0; i < steps; i++) { xValues[i] = (centerX + radius * Math.cos(2 * Math.PI * i / steps)); yValues[i] = (centerY + radius * Math.sin(2 * Math.PI * i / steps)); } ``` * Start your loop at 0 * Step through the entire 2 \* PI range, not just PI. * Yo...
155,669
<p>I have Flex based consumer <a href="http://www.rollingrazor.com" rel="nofollow noreferrer">website</a> where I would like to change various look and feel type settings based on random and other criteria, and then track these through to what results in the most sales. </p> <p>For instance I might completely switch o...
[ { "answer_id": 627904, "author": "David Pokluda", "author_id": 223, "author_profile": "https://Stackoverflow.com/users/223", "pm_score": 2, "selected": false, "text": "<p>Ok, this is very tricky. The reason for me to say that is because you are asking for two things:</p>\n\n<ul>\n<li>rel...
2008/10/01
[ "https://Stackoverflow.com/questions/155669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have Flex based consumer [website](http://www.rollingrazor.com) where I would like to change various look and feel type settings based on random and other criteria, and then track these through to what results in the most sales. For instance I might completely switch out the homepage, show different things dependin...
Ok, this is very tricky. The reason for me to say that is because you are asking for two things: * relaxed repository schema so that you can store various data and change what gets saved dynamically later * fixed database schema so that you can query data effectively The solution will be a compromise. You have to und...
155,681
<p>I have saved input from a textarea element to a TEXT column in MySQL. I'm using PHP to pull that data out of the database and want to display it in a p element while still showing the whitespace that the user entered (e.g. multiple spaces and newlines). I've tried a pre tag but it doesn't obey the width set in the...
[ { "answer_id": 155698, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 5, "selected": true, "text": "<p>You can cause the text inside the <code>pre</code> to wrap by using the following CSS</p>\n\n<pre><code>pre {\n w...
2008/10/01
[ "https://Stackoverflow.com/questions/155681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23976/" ]
I have saved input from a textarea element to a TEXT column in MySQL. I'm using PHP to pull that data out of the database and want to display it in a p element while still showing the whitespace that the user entered (e.g. multiple spaces and newlines). I've tried a pre tag but it doesn't obey the width set in the cont...
You can cause the text inside the `pre` to wrap by using the following CSS ``` pre { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Expl...
155,685
<p>I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.)</p> <p>For example, if my data looks like this:</p> <pre><code>&lt;root&gt; &lt;thing1 a1="a" a2="b"&gt;one&...
[ { "answer_id": 155728, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>You can do an XPathSelectElement with the path (don't quote me, been to the bar; will clean up in the morn) /root/thing2[@a...
2008/10/01
[ "https://Stackoverflow.com/questions/155685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14842/" ]
I need to replace the contents of a node in an XElement hierarchy when the element name and all the attribute names and values match an input element. (If there is no match, the new element can be added.) For example, if my data looks like this: ``` <root> <thing1 a1="a" a2="b">one</thing1> <thing2 a1="a" a2="a">...
This will match any given element with exact tag name and attribute name/value pairs: ``` public static void ReplaceOrAdd(this XElement source, XElement node) { var q = from x in source.Elements() where x.Name == node.Name && x.Attributes().All(a =>node.Attributes().Any(b =>a.Name==b.Name &...
155,712
<p>Here's my problem - I have some code like this:</p> <pre><code>&lt;mx:Canvas width="300" height="300"&gt; &lt;mx:Button x="800" /&gt; &lt;/mx:Canvas&gt; </code></pre> <p>So the problem is that the Button inside the canvas has an x property way in excess of the Canvas's width - since it's a child of the Canvas...
[ { "answer_id": 155817, "author": "Paul Mignard", "author_id": 3435, "author_profile": "https://Stackoverflow.com/users/3435", "pm_score": 4, "selected": true, "text": "<p>I figured it out - apparently the Container has a property called clipContent - here's the description from Adobe:</p...
2008/10/01
[ "https://Stackoverflow.com/questions/155712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
Here's my problem - I have some code like this: ``` <mx:Canvas width="300" height="300"> <mx:Button x="800" /> </mx:Canvas> ``` So the problem is that the Button inside the canvas has an x property way in excess of the Canvas's width - since it's a child of the Canvas, the Canvas masks it and creates some scrol...
I figured it out - apparently the Container has a property called clipContent - here's the description from Adobe: *Whether to apply a clip mask if the positions and/or sizes of this container's children extend outside the borders of this container. If false, the children of this container remain visible when they are...
155,739
<p>I have a requirement to implement an "Unsaved Changes" prompt in an ASP .Net application. If a user modifies controls on a web form, and attempts to navigate away before saving, a prompt should appear warning them that they have unsaved changes, and give them the option to cancel and stay on the current page. The ...
[ { "answer_id": 155760, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 4, "selected": false, "text": "<p>In the .aspx page, you need a Javascript function to tell whether or not the form info is \"dirty\"</p>\n\n<pre><code>&lt;s...
2008/10/01
[ "https://Stackoverflow.com/questions/155739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/637/" ]
I have a requirement to implement an "Unsaved Changes" prompt in an ASP .Net application. If a user modifies controls on a web form, and attempts to navigate away before saving, a prompt should appear warning them that they have unsaved changes, and give them the option to cancel and stay on the current page. The promp...
Using jQuery: ``` var _isDirty = false; $("input[type='text']").change(function(){ _isDirty = true; }); // replicate for other input types and selects ``` Combine with `onunload`/`onbeforeunload` methods as required. From the comments, the following references all input fields, without duplicating code: ``` $(':...
155,740
<p>I am working on an application that will sport a web-based point of sale interface.</p> <p>The point of sale PC (I am not sure as of now whether it will run on Linux or Windows) must have a fiscal printer attached to it, but like any web app, it is the server which processes all stuff. Both server and PoS machines ...
[ { "answer_id": 155782, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 1, "selected": false, "text": "<p>I did something similar to this a couple of yrs. ago. But in my case the server and the PC where in the same lan. Is y...
2008/10/01
[ "https://Stackoverflow.com/questions/155740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22116/" ]
I am working on an application that will sport a web-based point of sale interface. The point of sale PC (I am not sure as of now whether it will run on Linux or Windows) must have a fiscal printer attached to it, but like any web app, it is the server which processes all stuff. Both server and PoS machines are on the...
I did something similar to this a couple of yrs. ago. But in my case the server and the PC where in the same lan. Is your PoS within the lan? If so, I'll explain it to you. In the mean time, if you have the "little app" covered you can take a look at the following: <http://java.sun.com/j2se/1.4.2/docs/api/javax/print...
155,792
<p>I'm working on a method that accepts an expression tree as a parameter, along with a type (or instance) of a class.</p> <p>The basic idea is that this method will add certain things to a collection that will be used for validation.</p> <pre><code>public interface ITestInterface { //Specify stuff here. } private...
[ { "answer_id": 155828, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": true, "text": "<p>Collecting PropertyInfo objects from Expression.Body seems similar to <a href=\"https://stackoverflow.com/questions/12...
2008/10/01
[ "https://Stackoverflow.com/questions/155792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10853/" ]
I'm working on a method that accepts an expression tree as a parameter, along with a type (or instance) of a class. The basic idea is that this method will add certain things to a collection that will be used for validation. ``` public interface ITestInterface { //Specify stuff here. } private static void DoSome...
Collecting PropertyInfo objects from Expression.Body seems similar to [my solution](https://stackoverflow.com/questions/123088/possible-pitfalls-of-using-this-extension-method-based-shorthand#144982) to another question.
155,797
<p>ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. </p> <p>Does anyone have any ideas how I could get around this problem?</p>
[ { "answer_id": 155804, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Any time I can't mock something (I prefer MoQ over Rhino, but that's beside the point) I have to code around it.</p>\n\n<p>...
2008/10/01
[ "https://Stackoverflow.com/questions/155797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
ADO.NET has the notorious DataRow class which you cannot instantiate using new. This is a problem now that I find a need to mock it using Rhino Mocks. Does anyone have any ideas how I could get around this problem?
I'm curious as to why you need to mock the DataRow. Sometimes you can get caught up doing mocking and forget that it can be just as prudent to use the real thing. If you are passing around data rows then you can simply instantiate one with a helper method and use that as a return value on your mock. ``` SetupResult.Fo...
155,848
<p>I need to create an access (mdb) database without using the ADOX interop assembly. </p> <p>How can this be done?</p>
[ { "answer_id": 155851, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 5, "selected": true, "text": "<p>Before I throw away this code, it might as well live on stackoverflow </p>\n\n<p>Something along these lines seems t...
2008/10/01
[ "https://Stackoverflow.com/questions/155848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I need to create an access (mdb) database without using the ADOX interop assembly. How can this be done?
Before I throw away this code, it might as well live on stackoverflow Something along these lines seems to do the trick: ``` if (!File.Exists(DB_FILENAME)) { var cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_FILENAME; // Use a late bound COM object to create a new catalog. This is so we avo...
155,852
<p>I have created a non-visual component in C# which is designed as a placeholder for meta-data on a form.<br> The component has a property which is a collection of custom objects, this object is marked as Serializable and implements the GetObjectData for serilizing and public constuctor for deserilizing.<br></p> <p>I...
[ { "answer_id": 155889, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 2, "selected": false, "text": "<p>You might want to try the alternate approach of getting everything to serialize as generated code. To do that is very...
2008/10/01
[ "https://Stackoverflow.com/questions/155852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
I have created a non-visual component in C# which is designed as a placeholder for meta-data on a form. The component has a property which is a collection of custom objects, this object is marked as Serializable and implements the GetObjectData for serilizing and public constuctor for deserilizing. In the resx fi...
I have since discovered where I was going wrong. The component I was implementing a custom collection (inherited from CollectionBase), I changed this to a List and added the DesignerSerializationVisibility(DesignerSerializationVisibility.Content) attribute to the List property, this list is also read-only. This would...
155,864
<p>I have a controller with an action method as follows:</p> <pre><code>public class InventoryController : Controller { public ActionResult ViewStockNext(int firstItem) { // Do some stuff } } </code></pre> <p>And when I run it I get an error stating:</p> <blockquote> <p>The parameters dictionar...
[ { "answer_id": 155895, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 8, "selected": true, "text": "<p>Your routing needs to be set up along the lines of <code>{controller}/{action}/{firstItem}</code>. If you left the r...
2008/10/01
[ "https://Stackoverflow.com/questions/155864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11908/" ]
I have a controller with an action method as follows: ``` public class InventoryController : Controller { public ActionResult ViewStockNext(int firstItem) { // Do some stuff } } ``` And when I run it I get an error stating: > > The parameters dictionary does not contain a valid value of type 'S...
Your routing needs to be set up along the lines of `{controller}/{action}/{firstItem}`. If you left the routing as the default `{controller}/{action}/{id}` in your `global.asax.cs` file, then you will need to pass in `id`. ``` routes.MapRoute( "Inventory", "Inventory/{action}/{firstItem}", new { controller...
155,869
<p>The Interwebs are no help on this one. We're encoding data in ColdFusion using <code>serializeJSON</code> and trying to decode it in PHP using <code>json_decode</code>. Most of the time, this is working fine, but in some cases, <code>json_decode</code> returns <code>NULL</code>. We've looked for the obvious culprits...
[ { "answer_id": 155914, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 1, "selected": false, "text": "<p>can you replicate this issue reliably? and if so can you post sample data that returns null? i'm sure you know this, but for...
2008/10/01
[ "https://Stackoverflow.com/questions/155869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
The Interwebs are no help on this one. We're encoding data in ColdFusion using `serializeJSON` and trying to decode it in PHP using `json_decode`. Most of the time, this is working fine, but in some cases, `json_decode` returns `NULL`. We've looked for the obvious culprits, but `serializeJSON` seems to be formatting th...
You could try operating in UTF-8 and also letting PHP know that fact. I had an issue with PHP's `json_decode` not being able to decode a UTF-8 JSON string (with some "weird" characters other than the curly quotes that you have). My solution was to hint PHP that I was working in UTF-8 mode by inserting a Content-Type m...
155,891
<p>Can't seem to rename an existing Verity collection in ColdFusion without deleting, recreating, and rebuilding the collection. Problem is, I have some very large collections I'd rather not have to delete and rebuild from scratch. Any one have a handy trick for this conundrum?</p>
[ { "answer_id": 158948, "author": "Ben Doom", "author_id": 12267, "author_profile": "https://Stackoverflow.com/users/12267", "pm_score": 2, "selected": false, "text": "<p>I don't believe that there is an easy way to rename a Verity collection. You can always use </p>\n\n<pre><code>&lt;cf...
2008/10/01
[ "https://Stackoverflow.com/questions/155891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10750/" ]
Can't seem to rename an existing Verity collection in ColdFusion without deleting, recreating, and rebuilding the collection. Problem is, I have some very large collections I'd rather not have to delete and rebuild from scratch. Any one have a handy trick for this conundrum?
For the Verity part (without considering ColdFusion), it's easy enough to detach a collection, rename it, and reattach it again: ``` rcadmin> indexdetach Server Alias:YourDocserver Index Alias:CollectionName Index Type [(c)ollection,(t)ree,(p)arametric,(r)ecommendation]:c Save changes? [y|n]:y <<Return>> SUCCESS rcad...
155,908
<p>I have defined tomcat:catalina:5.5.23 as a dependency to the cargo plugin, however I still get the following exception:</p> <pre><code>java.lang.ClassNotFoundException: org.apache.catalina.Connector at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Metho...
[ { "answer_id": 169029, "author": "Hugo", "author_id": 972, "author_profile": "https://Stackoverflow.com/users/972", "pm_score": 1, "selected": false, "text": "<p>Side note:\nYou can start jetty which is similar to tomcat. (Servlets will be available at <a href=\"http://localhost:8080/\" ...
2008/10/01
[ "https://Stackoverflow.com/questions/155908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2767300/" ]
I have defined tomcat:catalina:5.5.23 as a dependency to the cargo plugin, however I still get the following exception: ``` java.lang.ClassNotFoundException: org.apache.catalina.Connector at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net...
Side note: You can start jetty which is similar to tomcat. (Servlets will be available at <http://localhost:8080/> artefact-name) ``` mvn jetty6:run ``` You would have to add to your pom: ``` <project> <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> ...
155,911
<p>During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well.</p> <p>There is constant debate in our teams about how failing tests should be managed:</p> <ol> <li><p>Comment out failing test case...
[ { "answer_id": 155918, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 1, "selected": false, "text": "<p>I tend to leave these in, with an <a href=\"http://www.nunit.org/index.php?p=ignore&amp;r=2.2\" rel=\"nofollow noref...
2008/10/01
[ "https://Stackoverflow.com/questions/155911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22489/" ]
During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well. There is constant debate in our teams about how failing tests should be managed: 1. Comment out failing test cases with a REVISIT or TODO...
I would leave your test cases in. In my experience, commenting out code with something like ``` // TODO: fix test case ``` is akin to doing: ``` // HAHA: you'll never revisit me ``` In all seriousness, as you get closer to shipping, the desire to revisit TODO's in code tends to fade, especially with things like ...
155,912
<p>Calling <code>Validate()</code> on an <strong>XmlDocument</strong> requires passing in a <code>ValidationEventHandler</code> delegate. That event function gets a <code>ValidationEventArgs</code> parameter which in turn has an <code>Exception</code> property of the type <code>XmlSchemaException</code>. Whew!</p> <...
[ { "answer_id": 155925, "author": "Micah", "author_id": 17744, "author_profile": "https://Stackoverflow.com/users/17744", "pm_score": 3, "selected": true, "text": "<p>Because the Validate method takes the ValidationEventHandler delegate, it is left up to the developer to decide what to do...
2008/10/01
[ "https://Stackoverflow.com/questions/155912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
Calling `Validate()` on an **XmlDocument** requires passing in a `ValidationEventHandler` delegate. That event function gets a `ValidationEventArgs` parameter which in turn has an `Exception` property of the type `XmlSchemaException`. Whew! My current code looks like this: ``` ValidationEventHandler onValidationError...
Because the Validate method takes the ValidationEventHandler delegate, it is left up to the developer to decide what to do with the excpetion. What you are doing is correct.
155,920
<p>I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $_SESSIO...
[ { "answer_id": 155941, "author": "vIceBerg", "author_id": 17766, "author_profile": "https://Stackoverflow.com/users/17766", "pm_score": 3, "selected": false, "text": "<p>Use <code>phpinfo()</code> and check the <code>session.*</code> settings.</p>\n\n<p>Maybe the information is stored in...
2008/10/01
[ "https://Stackoverflow.com/questions/155920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13556/" ]
I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $\_SESSION[...
Thanks for all the helpful info. It turns out that my host changed servers and started using a different session save path other than /var/php\_sessions which didn't exist anymore. A solution would have been to declare `ini_set(' session.save_path','SOME WRITABLE PATH');` in all my script files but that would have been...
155,930
<p>I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build.</p> <p>Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of ...
[ { "answer_id": 155946, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 4, "selected": true, "text": "<p>If you're writing this for modern distros, you can use <code>xdg-open</code>:</p>\n\n<pre><code>$ xdg-open http://go...
2008/10/01
[ "https://Stackoverflow.com/questions/155930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build. Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of it each ti...
If you're writing this for modern distros, you can use `xdg-open`: ``` $ xdg-open http://google.com/ ``` If you're on an older version you'll have to use a desktop-specific command like `gnome-open` or `exo-open`.
155,932
<p>I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession.</p>
[ { "answer_id": 155937, "author": "Michael Ratanapintha", "author_id": 1879, "author_profile": "https://Stackoverflow.com/users/1879", "pm_score": 3, "selected": false, "text": "<p>If you have an NT-family Windows (one with <code>cmd.exe</code> as the shell), try <a href=\"http://technet....
2008/10/01
[ "https://Stackoverflow.com/questions/155932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5132/" ]
I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession.
I needed to process the entire line as a whole. Here is what I found to work. ``` for /F "tokens=*" %%A in (myfile.txt) do [process] %%A ``` The tokens keyword with an asterisk (\*) will pull all text for the entire line. If you don't put in the asterisk it will only pull the first word on the line. I assume it has ...
155,934
<p>What GNU/Linux command-line tool would I use for performing a search and replace on a file? </p> <p>Can the search text, and replacement, be specified in a regex format?</p>
[ { "answer_id": 155939, "author": "Michael Cramer", "author_id": 1496728, "author_profile": "https://Stackoverflow.com/users/1496728", "pm_score": 5, "selected": false, "text": "<p>Perl was invented for this:</p>\n\n<pre><code>perl -pi -e 's/foo/bar/g;' *.txt\n</code></pre>\n\n<p>Any norm...
2008/10/01
[ "https://Stackoverflow.com/questions/155934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2045/" ]
What GNU/Linux command-line tool would I use for performing a search and replace on a file? Can the search text, and replacement, be specified in a regex format?
``` sed 's/a.*b/xyz/g;' old_file > new_file ``` [GNU sed](http://www.gnu.org/software/sed/) (which you probably have) is even more versatile: ``` sed -r --in-place 's/a(.*)b/x\1y/g;' your_file ``` Here is a brief explanation of those options: > > **-i[SUFFIX], --in-place[=SUFFIX]** > edit files in place (makes b...
155,959
<p>The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources?</p> <pre><code>using (OleDbConnection conn = new OleDbConnec...
[ { "answer_id": 155961, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": true, "text": "<p>The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?)<...
2008/10/01
[ "https://Stackoverflow.com/questions/155959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2669/" ]
The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources? ``` using (OleDbConnection conn = new OleDbConnection(connectionS...
The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?) You are opening way too many connections, way too fast... Some tips: * Avoid round trips by not opening a new connection for every single command, and perform the inserts using a single connectio...
155,964
<p>I know about the <a href="http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html" rel="noreferrer">HIG</a> (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).</...
[ { "answer_id": 155966, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 6, "selected": false, "text": "<p>Golden Rule: If you <code>alloc</code> then you <code>release</code>!</p>\n\n<p>UPDATE: Unless you are using ARC</p>\...
2008/10/01
[ "https://Stackoverflow.com/questions/155964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21804/" ]
I know about the [HIG](http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html) (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).
There are a few things I have started to do that I do not think are standard: 1) With the advent of properties, I no longer use "\_" to prefix "private" class variables. After all, if a variable can be accessed by other classes shouldn't there be a property for it? I always disliked the "\_" prefix for making code ugl...
155,977
<p>I have the following markup, and I want to make the <code>All</code> radio button checked.</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;input type="radio" value="All" name="Foo"/&gt;All&lt;/li&gt; &lt;li&gt;&lt;input type="radio" value="New" name="Foo"/&gt;New&lt;/li&gt; &lt;li&gt;&lt;input type="radio" valu...
[ { "answer_id": 156027, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 7, "selected": true, "text": "<p>The following HTML file shows how you can do this:</p>\n\n<pre><code>&lt;html&gt;\n &lt;head&gt;\n &lt;script type...
2008/10/01
[ "https://Stackoverflow.com/questions/155977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/410357/" ]
I have the following markup, and I want to make the `All` radio button checked. ``` <ul> <li><input type="radio" value="All" name="Foo"/>All</li> <li><input type="radio" value="New" name="Foo"/>New</li> <li><input type="radio" value="Removed" name="Foo"/>Removed</li> <li><input type="radio" value="Upda...
The following HTML file shows how you can do this: ``` <html> <head> <script type="text/javascript" src="jquery-1.2.6.pack.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("a").click(function(event){ $("input[name='Foo'][value='All']").attr('checked','chec...
155,996
<p>I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box.</p> <p>The code is not doing anything special. In fact, here is the line that invokes the message box from within an MDI Child form:</p> <pre...
[ { "answer_id": 156039, "author": "DaveK", "author_id": 4244, "author_profile": "https://Stackoverflow.com/users/4244", "pm_score": 2, "selected": false, "text": "<p>Remove the <code>MessageBoxOptions.DefaultDesktopOnly</code> parameter and it will work correctly.</p>\n\n<p><code>DefaultD...
2008/10/01
[ "https://Stackoverflow.com/questions/155996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10224/" ]
I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box. The code is not doing anything special. In fact, here is the line that invokes the message box from within an MDI Child form: ``` MessageBox.Sho...
Remove the last parameter, `MessageBoxOptions.DefaultDesktopOnly`. From [MSDN](http://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxoptions(VS.80).aspx): > > DefaultDesktopOnly will cause the > application that raised the MessageBox > to lose focus. The MessageBox that is > displayed will not u...
155,998
<p>Given this:</p> <pre><code>Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() &gt; g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub </code></pre> <p>I want to be able to say this (as I would in Delphi)...
[ { "answer_id": 156008, "author": "DaveK", "author_id": 4244, "author_profile": "https://Stackoverflow.com/users/4244", "pm_score": 3, "selected": true, "text": "<p>Use the 'AddHandler' and 'AddressOf' keywords to add a handler to the Tick event.</p>\n\n<pre>\nAddHandler timeReminder.Tick...
2008/10/01
[ "https://Stackoverflow.com/questions/155998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
Given this: ``` Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() > g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub ``` I want to be able to say this (as I would in Delphi): ``` timReminder.Tick = tim...
Use the 'AddHandler' and 'AddressOf' keywords to add a handler to the Tick event. ``` AddHandler timeReminder.Tick, AddressOf timeReminder_Tick ```
156,009
<p>Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great time to learn Perl, because all I know at the moment is C/C++ and Ja...
[ { "answer_id": 156020, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 3, "selected": false, "text": "<p>A simple one-liner is</p>\n\n<pre><code>perl -nae 'print \"$F[0] $F[1]\\n\";'\n</code></pre>\n\n<p>you can change t...
2008/10/01
[ "https://Stackoverflow.com/questions/156009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3879/" ]
Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great time to learn Perl, because all I know at the moment is C/C++ and Java....
The one-liner is great, if you're not writing more Perl to handle the result. More generally though, in the context of a larger Perl program, you would either write a custom regular expression, for example: ``` if($line =~ m/(\S+)\s+(\S+)/) { $ip = $1; $hostname = $2; } ``` ... or you would use the *split...