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
202,547
<p>I am writing a command-line tool for Windows that uses libcurl to download files from the internet.</p> <p>Obviously, the downloading doesn't work when the user is behind a proxy server, because the proxy needs to be configured. I want to keep my tool as simple as possible however, and not have to burden the user w...
[ { "answer_id": 202608, "author": "justin.m.chase", "author_id": 12958, "author_profile": "https://Stackoverflow.com/users/12958", "pm_score": 1, "selected": false, "text": "<p>There are registry keys for these values that you could get to directly of course. You could also do this in .NE...
2008/10/14
[ "https://Stackoverflow.com/questions/202547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2474/" ]
I am writing a command-line tool for Windows that uses libcurl to download files from the internet. Obviously, the downloading doesn't work when the user is behind a proxy server, because the proxy needs to be configured. I want to keep my tool as simple as possible however, and not have to burden the user with having...
The function you're looking for is WinHttpGetIEProxyConfigForCurrentUser(), which is documented at <http://msdn.microsoft.com/en-us/library/aa384096(VS.85).aspx>. This function is used by Firefox and Opera to get their proxy settings by default, although you can override them per-browser. Don't do that, though. The rig...
202,552
<p>How do you get a pointer to the .text section of memory for a program from within that program? I also need the length of the section to do a "Flash to Memory" compare as part of a continuous selftest that runs in the background.</p> <p>The toolset automatically generates the linker .cmd file for the tools I'm usi...
[ { "answer_id": 202572, "author": "Robert Deml", "author_id": 9516, "author_profile": "https://Stackoverflow.com/users/9516", "pm_score": 2, "selected": false, "text": "<p>You need to put \"variables\" in the linker script.</p>\n\n<p>In one of my projects I have this in one of my sections...
2008/10/14
[ "https://Stackoverflow.com/questions/202552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134597/" ]
How do you get a pointer to the .text section of memory for a program from within that program? I also need the length of the section to do a "Flash to Memory" compare as part of a continuous selftest that runs in the background. The toolset automatically generates the linker .cmd file for the tools I'm using, and the...
You need to put "variables" in the linker script. In one of my projects I have this in one of my sections: ``` __FlashStart = .; ``` In the C program I have this: ``` extern unsigned long int _FlashStart; unsigned long int address = (unsigned long int)&_FlashStart; ```
202,560
<p>So I understand what a static method or field is, I am just wondering when to use them. That is, when writing code what design lends itself to using static methods and fields. </p> <p>One common pattern is to use static methods as a static factory, but this could just as easily be done by overloading a constructor....
[ { "answer_id": 202577, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 5, "selected": true, "text": "<p>It gives a better idea of the intent when you use a static factory -- it also lets you have different factories that ta...
2008/10/14
[ "https://Stackoverflow.com/questions/202560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/322/" ]
So I understand what a static method or field is, I am just wondering when to use them. That is, when writing code what design lends itself to using static methods and fields. One common pattern is to use static methods as a static factory, but this could just as easily be done by overloading a constructor. Correct? ...
It gives a better idea of the intent when you use a static factory -- it also lets you have different factories that take the same argument types but have a different meaning. For example, imagine if Bitmap had LoadFromResource(string) -- it would not be possible to have two constructors that both took string. **EDIT*...
202,605
<p>What is the best or most concise method for returning a string repeated an arbitrary amount of times?</p> <p>The following is my best shot so far:</p> <pre><code>function repeat(s, n){ var a = []; while(a.length &lt; n){ a.push(s); } return a.join(''); } </code></pre>
[ { "answer_id": 202626, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<pre><code>function repeat(s, n) { var r=\"\"; for (var a=0;a&lt;n;a++) r+=s; return r;}\n</code></pre>\n" }, { ...
2008/10/14
[ "https://Stackoverflow.com/questions/202605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
What is the best or most concise method for returning a string repeated an arbitrary amount of times? The following is my best shot so far: ``` function repeat(s, n){ var a = []; while(a.length < n){ a.push(s); } return a.join(''); } ```
Good news! [`String.prototype.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) is [now a part of JavaScript](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-string.prototype.repeat). ``` "yo".repeat(2); // returns: "yoyo" ``` The method is support...
202,609
<p>This is what I currently have:</p> <pre><code>CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON SOMETABLE FOR EACH ROW DECLARE v_emplid varchar2(10); BEGIN SELECT personnum into v_emplid FROM PERSON WHERE PERSONID = :new.EMPLOYEEID; dbms_output.put(v_emplid); /* INSERT INTO SOMEOTHERTABLE USING ...
[ { "answer_id": 202621, "author": "HLGEM", "author_id": 9034, "author_profile": "https://Stackoverflow.com/users/9034", "pm_score": -1, "selected": false, "text": "<p>I would not use a select statment in a trigger ever. Insert into the table rather than a select into. Once the table alrea...
2008/10/14
[ "https://Stackoverflow.com/questions/202609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20836/" ]
This is what I currently have: ``` CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON SOMETABLE FOR EACH ROW DECLARE v_emplid varchar2(10); BEGIN SELECT personnum into v_emplid FROM PERSON WHERE PERSONID = :new.EMPLOYEEID; dbms_output.put(v_emplid); /* INSERT INTO SOMEOTHERTABLE USING v_emplid and s...
1) There must be something else to your example because that sure seems to work for me ``` SQL> create table someTable( employeeid number ); Table created. SQL> create table person( personid number, personnum varchar2(10) ); Table created. SQL> ed Wrote file afiedt.buf 1 CREATE OR REPLACE TRIGGER MYTRIGGER 2...
202,610
<p>I have two scripts that often need to be run with the same parameter:</p> <pre><code>$ populate.ksh 9241 &amp;&amp; check.ksh 9241 </code></pre> <p>When I need to change the parameter (<strong>9241</strong> in this example), I can go back and edit the line in history. But since I need to change the number in two ...
[ { "answer_id": 202611, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 1, "selected": false, "text": "<p>One solution is to simply create a wrapper script (<em>populate_check.ksh</em>) that calls the scripts in turn:</p>\n...
2008/10/14
[ "https://Stackoverflow.com/questions/202610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
I have two scripts that often need to be run with the same parameter: ``` $ populate.ksh 9241 && check.ksh 9241 ``` When I need to change the parameter (**9241** in this example), I can go back and edit the line in history. But since I need to change the number in two places, I sometimes make a typo. I'd like to be ...
In bash: ``` !!:gs/9241/9243/ ``` Yes, it uses `gs///`, not `s///g`. :-) (zigdon's answer uses the last command starting with `pop`, such as `populate.sh`. My answer uses the last command, full stop. Choose which works for you.)
202,630
<p>How do I determine if an object reference is null in C# w/o throwing an exception if it is null?</p> <p>i.e. If I have a class reference being passed in and I don't know if it is null or not.</p>
[ { "answer_id": 202642, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 0, "selected": false, "text": "<pre><code>(YourObject != Null)\n</code></pre>\n\n<p>you can compare to null?</p>\n\n<p>If it's null instead of...
2008/10/14
[ "https://Stackoverflow.com/questions/202630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/177/" ]
How do I determine if an object reference is null in C# w/o throwing an exception if it is null? i.e. If I have a class reference being passed in and I don't know if it is null or not.
What Robert said, but for that particular case I like to express it with a guard clause like this, rather than nest the whole method body in an if block: ``` void DoSomething( MyClass value ) { if ( value == null ) return; // I might throw an ArgumentNullException here, instead value.Method(); } ```
202,644
<p>e.g, Is the user playing a movie full screen, or looking at powerpoint in full screen mode?</p> <p>I could have sworn I saw a IsFullScreenInteractive API before, but can't find it now</p>
[ { "answer_id": 202680, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 2, "selected": false, "text": "<p>Use GetForegroundWindow to get a handle to the window the user is working with. GetClientRect will give the dimensio...
2008/10/14
[ "https://Stackoverflow.com/questions/202644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
e.g, Is the user playing a movie full screen, or looking at powerpoint in full screen mode? I could have sworn I saw a IsFullScreenInteractive API before, but can't find it now
Here's how I've solved this problem: ``` using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Runtime.InteropServices; namespace Test { class Program { static void Main(string[] args) { Console.WriteLine(IsForegroundWwindowFullSc...
202,662
<p>I have a VB6 dll that is trying to create a COM object using the following line of code:</p> <pre><code>Set CreateObj = CreateObject("OPSValuer.OPSValue") </code></pre> <p>However this fails with the error "Object variable or With block variable not set".</p> <p>I can see OPSValuer.OPSValue in dcomcnfg and it app...
[ { "answer_id": 202876, "author": "DMKing", "author_id": 10887, "author_profile": "https://Stackoverflow.com/users/10887", "pm_score": 2, "selected": false, "text": "<p>It's possible that the class you are trying to instantiate is not installed correctly or is missing some dependencies. ...
2008/10/14
[ "https://Stackoverflow.com/questions/202662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3012/" ]
I have a VB6 dll that is trying to create a COM object using the following line of code: ``` Set CreateObj = CreateObject("OPSValuer.OPSValue") ``` However this fails with the error "Object variable or With block variable not set". I can see OPSValuer.OPSValue in dcomcnfg and it appears to be registered fine. Does ...
DMKing is right about OleView. Also try looking at the control in [Dependency Walker](http://www.dependencywalker.com/), any missing dependencies should come quickly to the surface. Since this is a DCom component there also may be something failing in the components constructor, if anything fails in the constructor y...
202,663
<p>I am testing an application that checks if a file exists across a network. In my testing, I am purposefully pulling the network plug so the file will not be found. The problem is this causes my app to go unresponsive for at least 15 seconds. I have used both the FileExists() and GetAttr() functions in VB6. Does anyo...
[ { "answer_id": 202672, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 0, "selected": false, "text": "<p>I'm not sure you can handle this much more gracefully - if the network is having problems it can take a while for ...
2008/10/14
[ "https://Stackoverflow.com/questions/202663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27689/" ]
I am testing an application that checks if a file exists across a network. In my testing, I am purposefully pulling the network plug so the file will not be found. The problem is this causes my app to go unresponsive for at least 15 seconds. I have used both the FileExists() and GetAttr() functions in VB6. Does anyone ...
Unfortunately, VB doesn't make this easy, but luckily the Win32 API does, and it's quite simple to call Win32 functions from within VB. For the LAN/WAN, you can use a combination of the following Win32 API calls to tell you whether the remote connection exists without having to deal with a network time-out: ``` Priva...
202,685
<p>I truly love VIM - it's one of only a handful of applications I've every come across that make you feel warm and fuzzy inside. However, for PHP development, I still use PDT Eclipse although I would love to switch. </p> <p>The reason I can't quite at the moment is the CTRL+SPACE code-assist functionality that I re...
[ { "answer_id": 202725, "author": "user27987", "author_id": 27987, "author_profile": "https://Stackoverflow.com/users/27987", "pm_score": 0, "selected": false, "text": "<p>Code assist it's a new feature of VIM 7\n[Ctrl+x] [Ctrl+o] will auto complete your code or open a popup of options</p...
2008/10/14
[ "https://Stackoverflow.com/questions/202685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25517/" ]
I truly love VIM - it's one of only a handful of applications I've every come across that make you feel warm and fuzzy inside. However, for PHP development, I still use PDT Eclipse although I would love to switch. The reason I can't quite at the moment is the CTRL+SPACE code-assist functionality that I rely on so muc...
Vim has [OmniCompletion](http://vimdoc.sourceforge.net/htmldoc/version7.html#new-omni-completion) built in, you should add this to your .vimrc: ``` filetype plugin on au FileType php set omnifunc=phpcomplete#CompletePHP ``` In addition I recommend you this plugins: * [VTreeExplorer](http://www.vim.org/scripts/scrip...
202,699
<p>What is the best way to create a clone of a DTO? There is not an ICloneable interface or a BinaryFormatter class in Silverlight. Is reflection the only way?</p>
[ { "answer_id": 216976, "author": "Craig Nicholson", "author_id": 28305, "author_profile": "https://Stackoverflow.com/users/28305", "pm_score": 0, "selected": false, "text": "<p>I believe the standard cloning functionality was left out to keep it simple and lightweight. I believe you coul...
2008/10/14
[ "https://Stackoverflow.com/questions/202699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4231/" ]
What is the best way to create a clone of a DTO? There is not an ICloneable interface or a BinaryFormatter class in Silverlight. Is reflection the only way?
Here is the code we came up with for cloning. This works in Silverlight 2 & 3. ``` Public Shared Function Clone(Of T)(ByVal source As T) As T Dim serializer As New DataContractSerializer(GetType(T)) Using ms As New MemoryStream serializer.WriteObject(ms, source) ms.Seek(0, SeekOrigin.Begin) ...
202,718
<p>Is there a good method for writing C / C++ function headers with default parameters that are function calls? </p> <p>I have some header with the function:</p> <pre><code>int foo(int x, int y = 0); </code></pre> <p>I am working in a large code base where many functions call this function and depend on this default...
[ { "answer_id": 202734, "author": "Lev", "author_id": 7224, "author_profile": "https://Stackoverflow.com/users/7224", "pm_score": 3, "selected": false, "text": "<p>Yes. What you've written works.</p>\n" }, { "answer_id": 202738, "author": "Dima", "author_id": 13313, "a...
2008/10/14
[ "https://Stackoverflow.com/questions/202718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3022/" ]
Is there a good method for writing C / C++ function headers with default parameters that are function calls? I have some header with the function: ``` int foo(int x, int y = 0); ``` I am working in a large code base where many functions call this function and depend on this default value. This default value now ne...
Go figure! It does work. [Default arguments in C++ functions](http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/cplr237.htm)
202,723
<p>This is something I've always wondered, and I can't find any mention of it anywhere online. When a shop from, say Japan, writes code, would I be able to read it in English? Or do languages, like C, PHP, anything, have Japanese translations that they write?</p> <p>I guess what I'm asking is does every single coder i...
[ { "answer_id": 202742, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 2, "selected": false, "text": "<p>i've seen VBA translated into spanish-like commands. it's one of the ugliest things ever seen. i would be ashamed to ha...
2008/10/14
[ "https://Stackoverflow.com/questions/202723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50/" ]
This is something I've always wondered, and I can't find any mention of it anywhere online. When a shop from, say Japan, writes code, would I be able to read it in English? Or do languages, like C, PHP, anything, have Japanese translations that they write? I guess what I'm asking is does every single coder in the worl...
If I understood well the question actually is: "does every single coder in the world know enough English to use the exact same reserved words as I do?" Well.. English is not the subject here but programming language reserved words. I mean, when I started about 10 yrs ago, I didn't have any clue of English, and still I...
202,740
<p>Can I set timeouts for JSP pages in tomcat either on a per page or server level?</p>
[ { "answer_id": 202795, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 3, "selected": true, "text": "<p>For server level, you can try this.<br>\nyou have to change <code>catalina.bat</code> / <code>catalina.sh</code> file<br>...
2008/10/14
[ "https://Stackoverflow.com/questions/202740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14481/" ]
Can I set timeouts for JSP pages in tomcat either on a per page or server level?
For server level, you can try this. you have to change `catalina.bat` / `catalina.sh` file ``` jvm OPTIONS : -Dsun.net.client.defaultConnectTimeout=60000 -Dsun.net.client.defaultReadTimeout=60000 ```
202,750
<p>I mean, is there a coded language with human style coding? For example:</p> <pre><code>Create an object called MyVar and initialize it to 10; Take MyVar and call MyMethod() with parameters. . . </code></pre> <p>I know it's not so useful, but it can be interesting to create such a grammar.</p>
[ { "answer_id": 202763, "author": "Robert P", "author_id": 18097, "author_profile": "https://Stackoverflow.com/users/18097", "pm_score": 3, "selected": false, "text": "<p>Perl, some people claim.</p>\n\n<pre><code>print \"hello!\" and open my $File, '&lt;', $path or die \"Couldn't open th...
2008/10/14
[ "https://Stackoverflow.com/questions/202750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68336/" ]
I mean, is there a coded language with human style coding? For example: ``` Create an object called MyVar and initialize it to 10; Take MyVar and call MyMethod() with parameters. . . ``` I know it's not so useful, but it can be interesting to create such a grammar.
[COBOL](http://en.wikipedia.org/wiki/Cobol) is a lot like that. ``` SET MYVAR TO 10. EXECUTE MYMETHOD with 10, MYVAR. ``` Another sample from Wikipedia: ``` ADD YEARS TO AGE. MULTIPLY PRICE BY QUANTITY GIVING COST. SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST. ``` Oddly enough though, despite its design to be re...
202,777
<p>I'm creating a invoice crystal report for sage mas 500 AR module. In it, I'm attempting to add the <code>tarinvoice.balance</code> field with the following formula: </p> <pre><code>if {tarPrintInvcHdrWrk.Posted} = 1 then ToText({tarInvoice.Balance}) </code></pre> <p>I'm assuming that when the <code>{tarPrintI...
[ { "answer_id": 202882, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 2, "selected": false, "text": "<p>I believe the conditional statement fails immediately if you encounter a NULL, so your formula needs to test <stro...
2008/10/14
[ "https://Stackoverflow.com/questions/202777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28014/" ]
I'm creating a invoice crystal report for sage mas 500 AR module. In it, I'm attempting to add the `tarinvoice.balance` field with the following formula: ``` if {tarPrintInvcHdrWrk.Posted} = 1 then ToText({tarInvoice.Balance}) ``` I'm assuming that when the `{tarPrintInvcHdrWrk.Posted} = 1` conditional stateme...
I believe the conditional statement fails immediately if you encounter a NULL, so your formula needs to test **IsNull({tarPrintInvcHdrWrk.Posted})** before it tests equality with "1".
202,786
<p>I need to merge a forked project. Unfortunately, the CVS $Id lines are different so the merge tools I tried report that all the files are different (and 95% of them have only this line different)</p> <p>Is there a merge tool that can be configured to ignore line comparison results based on a pattern ?</p> <p>[edi...
[ { "answer_id": 202826, "author": "Ilya", "author_id": 6807, "author_profile": "https://Stackoverflow.com/users/6807", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.grigsoft.com/wincmp3.htm\" rel=\"nofollow noreferrer\">CompareIT</a> allow to use <a href=\"http://www....
2008/10/14
[ "https://Stackoverflow.com/questions/202786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to merge a forked project. Unfortunately, the CVS $Id lines are different so the merge tools I tried report that all the files are different (and 95% of them have only this line different) Is there a merge tool that can be configured to ignore line comparison results based on a pattern ? [edit] I discovered t...
I use meld, which can use regex filters to ignore. It has some preset ones you can select including CVS keywords. The regex it uses for that BTW is: ``` \$\w+(:[^\n$]+)?\$ ``` You can get meld on any linux distro or download from here: <http://meld.sourceforge.net/> I'm not sure how it's supported on windos, but I d...
202,790
<p>I have an <strong>"ldquo"</strong>, <strong>"rdquo"</strong> and several other entities under my RSS feed. Seems like if I add</p> <pre><code>&lt;!DOCTYPE rss [ &lt;!ENTITY % HTMLspec PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"&gt; %HTMLspec; </code><...
[ { "answer_id": 203765, "author": "cowgod", "author_id": 6406, "author_profile": "https://Stackoverflow.com/users/6406", "pm_score": 2, "selected": false, "text": "<p>it doesn't seem likely that many feed readers will know what to do with that. i would recommend sticking with numbered en...
2008/10/14
[ "https://Stackoverflow.com/questions/202790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an **"ldquo"**, **"rdquo"** and several other entities under my RSS feed. Seems like if I add ``` <!DOCTYPE rss [ <!ENTITY % HTMLspec PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"> %HTMLspec; ``` below the **xml** tag and above the **rss** tag the...
it doesn't seem likely that many feed readers will know what to do with that. i would recommend sticking with numbered entity references. for example, change `&ldquo;` to `&#8220;`. you can get the full entity reference [right here from w3c](http://www.w3.org/TR/REC-html40/sgml/entities.html). additionally, you can re...
202,792
<p>I'm using a whole bunch of CALayers, creating a tile-based image not unlike GoogleMaps (different versions of the same image with more/less detail).</p> <p>The code I'm using to do this is:</p> <pre><code>UIImage* image = [self loadImage:obj.fileName zoomLevel:obj.zoomLevel]; [CATransaction setValue:(id)kCFBoolean...
[ { "answer_id": 202933, "author": "heckj", "author_id": 19477, "author_profile": "https://Stackoverflow.com/users/19477", "pm_score": 3, "selected": true, "text": "<p>There's not a big performance boost - if anything it's the other way around. By going throuh UIImage to load up your image...
2008/10/14
[ "https://Stackoverflow.com/questions/202792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28019/" ]
I'm using a whole bunch of CALayers, creating a tile-based image not unlike GoogleMaps (different versions of the same image with more/less detail). The code I'm using to do this is: ``` UIImage* image = [self loadImage:obj.fileName zoomLevel:obj.zoomLevel]; [CATransaction setValue:(id)kCFBooleanTrue ...
There's not a big performance boost - if anything it's the other way around. By going throuh UIImage to load up your images, you'll get all the benefits of caching that it does for you and it'll be a very speedy critter to use with your various CALayers.
202,813
<p>Probably a really simple one this - I'm starting out with C# and need to add values to an array, for example:</p> <pre><code>int[] terms; for(int runs = 0; runs &lt; 400; runs++) { terms[] = runs; } </code></pre> <p>For those who have used PHP, here's what I'm trying to do in C#:</p> <pre><code>$arr = array(...
[ { "answer_id": 202830, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 3, "selected": false, "text": "<p>You have to allocate the array first:</p>\n\n<pre><code>int [] terms = new int[400]; // allocate an array of 400 ints\nfor(...
2008/10/14
[ "https://Stackoverflow.com/questions/202813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
Probably a really simple one this - I'm starting out with C# and need to add values to an array, for example: ``` int[] terms; for(int runs = 0; runs < 400; runs++) { terms[] = runs; } ``` For those who have used PHP, here's what I'm trying to do in C#: ``` $arr = array(); for ($i = 0; $i < 10; $i++) { $ar...
You can do this way - ``` int[] terms = new int[400]; for (int runs = 0; runs < 400; runs++) { terms[runs] = value; } ``` Alternatively, you can use Lists - the advantage with lists being, you don't need to know the array size when instantiating the list. ``` List<int> termsList = new List<int>(); for (int runs...
202,860
<p>I know this sounds like a really obvious question, but it's proving harder to figure out than I thought. I'm developing in Flash 8/ActionScript 2.0.</p> <p>I have a label component, and I'm dynamically assigning it text from an xml document. For example:</p> <pre><code>label.text = "&lt;b&gt;" + xml_node.firstChil...
[ { "answer_id": 202960, "author": "Simon", "author_id": 24039, "author_profile": "https://Stackoverflow.com/users/24039", "pm_score": 0, "selected": false, "text": "<p>I can't say for sure but I think you probably need to set the fontSize style of the Label. </p>\n" }, { "answer_...
2008/10/14
[ "https://Stackoverflow.com/questions/202860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/557/" ]
I know this sounds like a really obvious question, but it's proving harder to figure out than I thought. I'm developing in Flash 8/ActionScript 2.0. I have a label component, and I'm dynamically assigning it text from an xml document. For example: ``` label.text = "<b>" + xml_node.firstChild + "</b>"; ``` This succ...
Thanks for everyone's input! After reading David Arno's post, I figured it out. Here's what I was doing. ``` label.text = "<b><font size=24>" + xml_node.firstChild + "</font></b>"; ``` Here's what works: ``` //note the 'single quotes' around the 24 label.text = "<b><font size='24'>" + xml_node.firstChild + "</font>...
202,871
<p>I use MyGeneration along with nHibernate to create the basic POCO objects and XML mapping files. I have heard some people say they think code generators are not a good idea. What is the current best thinking? Is it just that code generation is bad when it generates thousands of lines of not understandable code?</p>
[ { "answer_id": 202879, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 3, "selected": false, "text": "<p>My stance is that code generators are not bad, but MANY uses of them are.</p>\n\n<p>If you are using a code gen...
2008/10/14
[ "https://Stackoverflow.com/questions/202871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I use MyGeneration along with nHibernate to create the basic POCO objects and XML mapping files. I have heard some people say they think code generators are not a good idea. What is the current best thinking? Is it just that code generation is bad when it generates thousands of lines of not understandable code?
Code generated by a code-generator should not (as a generalisation) be used in a situation where it is subsequently edited by human intervention. Some systems such the wizards on various incarnations of Visual C++ generated code that the programmer was then expected to edit by hand. This was not popular as it required ...
202,907
<p>i'm having a problem to create a text_field without a method association. Maybe i even don't need it :-)</p> <p>I have two radio_buttons associated to the same method:</p> <pre><code>&lt;%= radio_button :comment, :author, "anonymous" %&gt; Anonymous &lt;br&gt; &lt;%= radio_button :comment, :author, "real_name" %&g...
[ { "answer_id": 202970, "author": "Avdi", "author_id": 20487, "author_profile": "https://Stackoverflow.com/users/20487", "pm_score": 4, "selected": true, "text": "<p>If you want to generate a text_field without an associated object/method, use <a href=\"http://api.rubyonrails.com/classes/...
2008/10/14
[ "https://Stackoverflow.com/questions/202907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
i'm having a problem to create a text\_field without a method association. Maybe i even don't need it :-) I have two radio\_buttons associated to the same method: ``` <%= radio_button :comment, :author, "anonymous" %> Anonymous <br> <%= radio_button :comment, :author, "real_name" %> Name <br> ``` What i would like ...
If you want to generate a text\_field without an associated object/method, use [`text_field_tag`](http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001701)
202,912
<p>I have some hierarchical data - each entry has an id and a (nullable) parent entry id. I want to retrieve all entries in the tree under a given entry. This is in a SQL Server 2005 database. I am querying it with LINQ to SQL in C# 3.5.</p> <p>LINQ to SQL does not support <a href="http://msdn.microsoft.com/en-us/libr...
[ { "answer_id": 202929, "author": "Ilya Ryzhenkov", "author_id": 18575, "author_profile": "https://Stackoverflow.com/users/18575", "pm_score": 2, "selected": false, "text": "<p>In MS SQL 2008 you could use <a href=\"http://msdn.microsoft.com/en-us/library/bb677290.aspx\" rel=\"nofollow no...
2008/10/14
[ "https://Stackoverflow.com/questions/202912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5599/" ]
I have some hierarchical data - each entry has an id and a (nullable) parent entry id. I want to retrieve all entries in the tree under a given entry. This is in a SQL Server 2005 database. I am querying it with LINQ to SQL in C# 3.5. LINQ to SQL does not support [Common Table Expressions](http://msdn.microsoft.com/en...
I would set up a view and an associated table-based function based on the CTE. My reasoning for this is that, while you could implement the logic on the application side, this would involve sending the intermediate data over the wire for computation in the application. Using the DBML designer, the view translates into ...
202,914
<p>I have a storyboard(1) that does some basic animations in 2 seconds. I want the storyboard(1) to do all the property animations I have set it up to do (this all works fine). But at 3 seconds into the storyboard(1) I want to begin storyboard(2) and exit storyboard(1) without user interaction at all.</p> <p>Only th...
[ { "answer_id": 205118, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 3, "selected": false, "text": "<p>Normally in order to control animations during the timeline you would use \"keyframes\". Keyframe animations...
2008/10/14
[ "https://Stackoverflow.com/questions/202914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27494/" ]
I have a storyboard(1) that does some basic animations in 2 seconds. I want the storyboard(1) to do all the property animations I have set it up to do (this all works fine). But at 3 seconds into the storyboard(1) I want to begin storyboard(2) and exit storyboard(1) without user interaction at all. Only thing I've see...
Well I came up with a solution. I just spawned a new thread to wait for 3 seconds and then did an Invoke call to run the storyboard from that thread. ``` Dim board As Storyboard = New Storyboard board = DirectCast(TryFindResource("DoSplit"), Storyboard) If board IsNot Nothing Then board.Begin(Me, T...
202,962
<p>How do I connect to a MSSQL database using Perl's DBI module in Windows?</p>
[ { "answer_id": 202973, "author": "culix", "author_id": 28037, "author_profile": "https://Stackoverflow.com/users/28037", "pm_score": 3, "selected": false, "text": "<p>Couldn't find this anywhere reliable. Use Perl code similar to</p>\n\n<pre><code>use DBI;\nmy $dbs = \"dbi:ODBC:DRIVER={S...
2008/10/14
[ "https://Stackoverflow.com/questions/202962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28037/" ]
How do I connect to a MSSQL database using Perl's DBI module in Windows?
Use DBD::ODBC. If you just create a data source with the Control Panel -> System Management -> ODBC Data Sources -> System Data Source or User Data Source (those are the names as I remember them, but my XP isn't in English, so I can't check), then all you have to do is use the name of that data source in the DBI connec...
202,971
<p>I've built a simple application that applies grid-lines to an image or just simple colors for use as desktop wallpaper. The idea is that the desktop icons can be arranged within the grid. The problem is that depending on more things than I understand the actual spacing in pixels seems to be different from system to ...
[ { "answer_id": 202992, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>They might also be a size problem due to scaling algorithm if the requested size of the icon is not available.<br>\n(since a...
2008/10/14
[ "https://Stackoverflow.com/questions/202971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
I've built a simple application that applies grid-lines to an image or just simple colors for use as desktop wallpaper. The idea is that the desktop icons can be arranged within the grid. The problem is that depending on more things than I understand the actual spacing in pixels seems to be different from system to sys...
there are a 1001 ways to get/set this (but I only know 2) :-D Windows Register: ``` HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics ``` values are **IconSpacing** and **IconVerticalSpacing** by code: `using System.Management;` public string GetWinIconSpace() { ``` ManagementObjectSearcher searcher = new ...
202,990
<p>Suppose I have a dataset with those two immortal tables: Employee &amp; Order <br/> <strong>Emp</strong> -> ID, Name <br/> <strong>Ord</strong> -> Something, Anotherthing, EmpID <br/> And relation <strong>Rel</strong>: Ord (EmpID) -> Emp (ID) <br/></p> <p>It works great in standard master/detail scenario <br/> (sho...
[ { "answer_id": 207805, "author": "Enrico Campidoglio", "author_id": 26396, "author_profile": "https://Stackoverflow.com/users/26396", "pm_score": 0, "selected": false, "text": "<p>Assuming that you are using a strongly-typed DataSet, in order to bind the TextBox to the 'EmpRow.Name' prop...
2008/10/14
[ "https://Stackoverflow.com/questions/202990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27956/" ]
Suppose I have a dataset with those two immortal tables: Employee & Order **Emp** -> ID, Name **Ord** -> Something, Anotherthing, EmpID And relation **Rel**: Ord (EmpID) -> Emp (ID) It works great in standard master/detail scenario (show employees, follow down the relation, show related orders), ...
If you want to synchronize the contents of multiple controls, you will need to have them share the same binding source through the **DataContext** set on a common parent control. Here is an example: ``` <StackPanel> <StackPanel.Resources> <ObjectDataProvider x:Key="ds" ObjectType="{x:Type mynamespace:MyDat...
203,030
<p>I want to get a list of files in a directory, but I want to sort it such that the oldest files are first. My solution was to call File.listFiles and just resort the list based on File.lastModified, but I was wondering if there was a better way.</p> <p>Edit: My current solution, as suggested, is to use an anonymous...
[ { "answer_id": 203057, "author": "Dan Dyer", "author_id": 5171, "author_profile": "https://Stackoverflow.com/users/5171", "pm_score": 8, "selected": true, "text": "<p>I think your solution is the only sensible way. The only way to get the list of files is to use <a href=\"http://java.su...
2008/10/14
[ "https://Stackoverflow.com/questions/203030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4828/" ]
I want to get a list of files in a directory, but I want to sort it such that the oldest files are first. My solution was to call File.listFiles and just resort the list based on File.lastModified, but I was wondering if there was a better way. Edit: My current solution, as suggested, is to use an anonymous Comparator...
I think your solution is the only sensible way. The only way to get the list of files is to use [File.listFiles()](http://java.sun.com/javase/6/docs/api/java/io/File.html#listFiles()) and the documentation states that this makes no guarantees about the order of the files returned. Therefore you need to write a [Compara...
203,058
<p>I have a C application that I've created in VS2008. I am creating a mock creation function that overrides function references in a struct. However if I try and do this in a straight forward fashion with something like:</p> <pre><code>void *ptr = &amp;(*env)-&gt;GetVersion; *ptr = &lt;address of new function&gt; </c...
[ { "answer_id": 203074, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 1, "selected": false, "text": "<p>Last time I played with void* &amp; C under visual studio, VS didn't play nicely. \nHere are some information datap...
2008/10/14
[ "https://Stackoverflow.com/questions/203058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7122/" ]
I have a C application that I've created in VS2008. I am creating a mock creation function that overrides function references in a struct. However if I try and do this in a straight forward fashion with something like: ``` void *ptr = &(*env)->GetVersion; *ptr = <address of new function> ``` then I get a "error C210...
Then how about: ``` void **ptr = (void **) &(*env)->GetVersion; *ptr = <address of new function> ``` The right way to do this is to work with the type system, avoid all the casting and declare actual pointers to functions like: ``` typedef int (*fncPtr)(void); fncPtr *ptr = &(*env)->GetVersion; *ptr = NewFunction; ...
203,090
<p>Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using <code>date</code>. See @npocmaka's <a href="https://stackoverflow.com/a/19799236/8479">https://stackoverflow.com/a/19799236/8479...
[ { "answer_id": 203099, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 3, "selected": false, "text": "<p>This is what I've used:</p>\n\n<pre><code>::Date Variables - replace characters that are not legal as part of file...
2008/10/14
[ "https://Stackoverflow.com/questions/203090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8479/" ]
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using `date`. See @npocmaka's <https://stackoverflow.com/a/19799236/8479> --- What's a Windows command line statement(s) I can use to g...
See *[Windows Batch File (.bat) to get current date in MMDDYYYY format](http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/)*: ``` @echo off For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (se...
203,096
<p>I created an Interop user control in VS2005. When the user control is shown inside VB6, it does not pickup/use the XP styles (The buttons and the tabs look like VB6 buttons/tabs). </p> <p>How do I get the XP styles to work with my control while it is in VB6?</p>
[ { "answer_id": 203099, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 3, "selected": false, "text": "<p>This is what I've used:</p>\n\n<pre><code>::Date Variables - replace characters that are not legal as part of file...
2008/10/14
[ "https://Stackoverflow.com/questions/203096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
I created an Interop user control in VS2005. When the user control is shown inside VB6, it does not pickup/use the XP styles (The buttons and the tabs look like VB6 buttons/tabs). How do I get the XP styles to work with my control while it is in VB6?
See *[Windows Batch File (.bat) to get current date in MMDDYYYY format](http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/)*: ``` @echo off For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b) For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (se...
203,113
<p>I have a JS function that may occasionally get used on some pages. It is dependent on another JS file (swfObject.js), but I'd like to avoid having to include this file all over the place, as thats a wasted request most of the time.</p> <p>Instead, I'd like to create a generic function that can inject a script refer...
[ { "answer_id": 203134, "author": "Jim Fiorato", "author_id": 650, "author_profile": "https://Stackoverflow.com/users/650", "pm_score": 0, "selected": false, "text": "<p>Checkout the YUI Loader utility. It's super handy, unobtrusive javascript for loading scripts on-demand.</p>\n\n<p>Her...
2008/10/14
[ "https://Stackoverflow.com/questions/203113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I have a JS function that may occasionally get used on some pages. It is dependent on another JS file (swfObject.js), but I'd like to avoid having to include this file all over the place, as thats a wasted request most of the time. Instead, I'd like to create a generic function that can inject a script reference into ...
If you're using a higher level framework such as JQuery, you could check out the `$.getScript(url, callback)` function.
203,126
<p>Here is an example of polymorphism from <a href="http://www.cplusplus.com/doc/tutorial/polymorphism.html" rel="noreferrer">http://www.cplusplus.com/doc/tutorial/polymorphism.html</a> (edited for readability):</p> <pre><code>// abstract base class #include &lt;iostream&gt; using namespace std; class Polygon { p...
[ { "answer_id": 203135, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 2, "selected": false, "text": "<p>Disregarding aspects of binding, it's not actually the compiler that determines this.</p>\n\n<p>It is the C++ runtime t...
2008/10/14
[ "https://Stackoverflow.com/questions/203126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
Here is an example of polymorphism from <http://www.cplusplus.com/doc/tutorial/polymorphism.html> (edited for readability): ``` // abstract base class #include <iostream> using namespace std; class Polygon { protected: int width; int height; public: void set_values(int a, int b) { widt...
Each object (that belongs to a class with at least one virtual function) has a pointer, called a `vptr`. It points to the `vtbl` of its actual class (which each class with virtual functions has at least one of; possibly more than one for some multiple-inheritance scenarios). The `vtbl` contains a bunch of pointers, on...
203,147
<p>Here's another C#/.NET question based merely on curiousity more than an immediate <em>need</em> ...</p> <p>If you had a <code>Socket</code> instance and you wanted to wrap it in the higher-level <code>TcpClient</code> class, is that possible and how would you do it?</p> <p>Conversely if you have an instance of <co...
[ { "answer_id": 203153, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 2, "selected": false, "text": "<p>From TcpClient to Socket is very easy. <code>tcpClientInstance.Client</code> is the underlying Socket instance.</p>\n" ...
2008/10/14
[ "https://Stackoverflow.com/questions/203147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
Here's another C#/.NET question based merely on curiousity more than an immediate *need* ... If you had a `Socket` instance and you wanted to wrap it in the higher-level `TcpClient` class, is that possible and how would you do it? Conversely if you have an instance of `TcpClient`, is it possible to get the underlying...
> > If you had a Socket instance and you > wanted to wrap it in the higher-level > TcpClient class, is that possible and > how would you do it? > > > ``` Socket socket = ...; TcpClient client = new TcpClient(); client.Client = socket; ``` > > Conversely if you have an instance of > TcpClient, is it possible...
203,151
<p>I have a report that uses a TChart that I am maintaining. One of the TLineSeries that gets added automatically gets assigned the color clWhite, which is too close to the background (clBtnFace). </p> <p>If I change it, then the next series that gets added takes clWhite. So short of going back and changing it afte...
[ { "answer_id": 203236, "author": "Anya Shenanigans", "author_id": 17833, "author_profile": "https://Stackoverflow.com/users/17833", "pm_score": 2, "selected": false, "text": "<p>Near as I can tell from the TeeCharts module; no you can't specify a color that it should not be as it ships.<...
2008/10/14
[ "https://Stackoverflow.com/questions/203151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/255/" ]
I have a report that uses a TChart that I am maintaining. One of the TLineSeries that gets added automatically gets assigned the color clWhite, which is too close to the background (clBtnFace). If I change it, then the next series that gets added takes clWhite. So short of going back and changing it after all the oth...
OK not one to give up easily, I did some more searching. There is a unit variable called **ColorPalette** of type *TColorArray* in the *TeeProcs* unit. If I find and replace white with a different color that fixes it. There may be an instance copy of it. I'll keep looking since that would be preferred. To revert the *...
203,161
<p>Im just writing a small Ajax framework for re-usability in small projects and i've hit a problem. Basically i get a '<code>NS_ERROR_ILLEGAL_VALUE</code>' error while sending the request and i've no idea what is happening.</p> <p>The HTML Page (trimmed but shows the error)</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-...
[ { "answer_id": 204039, "author": "Sergey Ilinsky", "author_id": 23815, "author_profile": "https://Stackoverflow.com/users/23815", "pm_score": 4, "selected": true, "text": "<p>The exception \"Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)\" is caused by an illegal va...
2008/10/14
[ "https://Stackoverflow.com/questions/203161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
Im just writing a small Ajax framework for re-usability in small projects and i've hit a problem. Basically i get a '`NS_ERROR_ILLEGAL_VALUE`' error while sending the request and i've no idea what is happening. The HTML Page (trimmed but shows the error) ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "h...
The exception "Component returned failure code: 0x80070057 (NS\_ERROR\_ILLEGAL\_VALUE)" is caused by an illegal value being passed into the call of open method. Looking through your code I found misspelling: ``` this.RequestedMethod = p_RequestMethod; this.DestinationURL = p_DestinationURL; this.XMLHttpRequestObjec...
203,171
<p>How can I include a bookmarklet in a Markdown parsed document? Is there any "tag" for markdown that basically says "don't parse this"??</p> <p>For example you could have something like:</p> <pre><code>&lt;a href="javascript:function my_bookmarklet() {alert('Hello World');} my_bookma...
[ { "answer_id": 203179, "author": "stevemegson", "author_id": 25028, "author_profile": "https://Stackoverflow.com/users/25028", "pm_score": 4, "selected": true, "text": "<p>Markdown will leave any HTML alone, so you can just enter</p>\n\n<pre><code>&lt;a href=\"javascript:function my_book...
2008/10/14
[ "https://Stackoverflow.com/questions/203171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
How can I include a bookmarklet in a Markdown parsed document? Is there any "tag" for markdown that basically says "don't parse this"?? For example you could have something like: ``` <a href="javascript:function my_bookmarklet() {alert('Hello World');} my_bookmarklet();">Hello</a> ```...
Markdown will leave any HTML alone, so you can just enter ``` <a href="javascript:function my_bookmarklet() {alert('Hello World');} my_bookmarklet();">Hello</a> ``` ~~and get Hello.~~ *Edit: No longer works on SO, which is a good thing* You can also escape special characters with a b...
203,180
<p>Say I have my sources in my src/ tree (and possibly in my test/ tree). Say I would like to compile only <em>part</em> of that tree. The reasons why I might want to do that are various. Just as an example, I might want to create the smallest possible jar (without including certain classes), or I might want the fastes...
[ { "answer_id": 203472, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 0, "selected": false, "text": "<p>Actually, ant only <em>checks</em> everything, if you run a compile twice in a row you will notice the second is much q...
2008/10/14
[ "https://Stackoverflow.com/questions/203180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25891/" ]
Say I have my sources in my src/ tree (and possibly in my test/ tree). Say I would like to compile only *part* of that tree. The reasons why I might want to do that are various. Just as an example, I might want to create the smallest possible jar (without including certain classes), or I might want the fastest compile ...
Why are you excluding as well as including? If you have at least one include, then files are only compiled if they're explicitly included. So this should work: ``` <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="classpath" includes="src/path/to/MyClass.java" /> ``` Or more flexibly: ``` <jav...
203,189
<p>I am intercepting Win32 API calls a native dll or exe is doing from C# using some kind of hooking. In this particular case I am interested in DrawText() in user32.dll. It is declared like this in Win32 API:</p> <pre><code>INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags) </code></pre> ...
[ { "answer_id": 203233, "author": "Tony Lee", "author_id": 5819, "author_profile": "https://Stackoverflow.com/users/5819", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://www.pinvoke.net/default.aspx/user32.DrawText\" rel=\"noreferrer\">http://www.pinvoke.net/default.aspx/u...
2008/10/14
[ "https://Stackoverflow.com/questions/203189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am intercepting Win32 API calls a native dll or exe is doing from C# using some kind of hooking. In this particular case I am interested in DrawText() in user32.dll. It is declared like this in Win32 API: ``` INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags) ``` The LPRECT struct has t...
<http://www.pinvoke.net/default.aspx/user32.DrawText>
203,194
<p>I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing the request url on the server side (in order to keep my app secret secret). I'm then sending the url over to the browser to be request using <code>jQuery.getJSON()</code>.</p> <p>Facebook requires that I send a copy of...
[ { "answer_id": 203247, "author": "Duncan", "author_id": 25035, "author_profile": "https://Stackoverflow.com/users/25035", "pm_score": 2, "selected": false, "text": "<p>You can pass the JSONP option to $.ajaxSetup that will allow you to fix the function name that gets called, the docs rea...
2008/10/14
[ "https://Stackoverflow.com/questions/203194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10419/" ]
I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing the request url on the server side (in order to keep my app secret secret). I'm then sending the url over to the browser to be request using `jQuery.getJSON()`. Facebook requires that I send a copy of all of my request pa...
The use of `jQuery.getScript` turned out to be close to -- but not quite -- the answer. Using getScript eliminates jQuery's need to add the dynamically named anonymous function to the request params (though it will still do that if you go ahead and pass it an anonymous function as in the above code). However, the defau...
203,198
<p>I have a bit of code where I am looping through all the select boxes on a page and binding a <code>.hover</code> event to them to do a bit of twiddling with their width on <code>mouse on/off</code>.</p> <p>This happens on page ready and works just fine.</p> <p>The problem I have is that any select boxes I add via ...
[ { "answer_id": 203220, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": false, "text": "<p>You can add events to objects when you create them. If you are adding the same events to multiple objects at different time...
2008/10/14
[ "https://Stackoverflow.com/questions/203198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
I have a bit of code where I am looping through all the select boxes on a page and binding a `.hover` event to them to do a bit of twiddling with their width on `mouse on/off`. This happens on page ready and works just fine. The problem I have is that any select boxes I add via Ajax or DOM after the initial loop won'...
**As of jQuery 1.7** you should use [`jQuery.fn.on`](https://api.jquery.com/on/#on-events-selector-data-handler) with the selector parameter filled: ``` $(staticAncestors).on(eventName, dynamicChild, function() {}); ``` *Explanation:* This is called event delegation and works as followed. The event is attached to a...
203,199
<p>I tried but I guess Message Box only works with win forms. What is the best alternative to use in web forms?</p>
[ { "answer_id": 203205, "author": "Patrick McElhaney", "author_id": 437, "author_profile": "https://Stackoverflow.com/users/437", "pm_score": 2, "selected": false, "text": "<pre><code>result = confirm('Yes or no question here.')\n</code></pre>\n" }, { "answer_id": 203210, "aut...
2008/10/14
[ "https://Stackoverflow.com/questions/203199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
I tried but I guess Message Box only works with win forms. What is the best alternative to use in web forms?
You can use `confirm` for yes/no questions and `alert` for "OK" messages in JavaScript. The other alternative is to use JavaScript to pop up a new window that looks and acts like a message box. Modality in this case varied by browser. In Internet Explorer, the method ``` window.showModalDialog(url,name,params) ``` ...
203,207
<p>I got a program with a fscanf like this:</p> <p>fscanf(stdin, "%d %d,....</p> <p>I got many fscanf and files that I'd like to test, the files are like this</p> <p>10485770 15 51200000 -2 10 10 10485760 10485760 10 10485760 10485760 10 10485760 10485760</p> <p>Well my question is how can I tell to the program o...
[ { "answer_id": 203216, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Try freopen. Eg.</p>\n\n<pre><code>freopen( \"somefile.txt\", \"r\", stdin );\n</code></pre>\n" }, { "answer_id": 2...
2008/10/14
[ "https://Stackoverflow.com/questions/203207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I got a program with a fscanf like this: fscanf(stdin, "%d %d,.... I got many fscanf and files that I'd like to test, the files are like this 10485770 15 51200000 -2 10 10 10485760 10485760 10 10485760 10485760 10 10485760 10485760 Well my question is how can I tell to the program or the compiler to take the inpu...
Try freopen. Eg. ``` freopen( "somefile.txt", "r", stdin ); ```
203,246
<p>What is the best way to keep a console application open as long as the CancelKeyPress event has not been fired?</p> <p>I would prefer to not use Console.Read or Console.ReadLine as I do not want to accept input. I just want to enable the underlying application to print to the console event details as they are fire...
[ { "answer_id": 203258, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>There is already a handler bound to CancelKeyPress that terminates your application, the only reason to hook to it is if ...
2008/10/14
[ "https://Stackoverflow.com/questions/203246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
What is the best way to keep a console application open as long as the CancelKeyPress event has not been fired? I would prefer to not use Console.Read or Console.ReadLine as I do not want to accept input. I just want to enable the underlying application to print to the console event details as they are fired. Then onc...
I'm assuming that "gracefully shut down the application" is the part you are struggling with here. Otherwise your application will automatically exit on ctrl-c. You should change the title. Here's a quick demo of what I think you need. It could be refined a bit more with use of locking and Monitors for notification. I...
203,274
<p>Usually when I build a site, I put all the CSS into one file, and all the properties that relate to a set of elements are defined at once. Like this:</p> <pre><code>#myElement { color: #fff; background-color: #000; padding: 10px; border: 1px solid #ccc; font-size: 14pt; } .myClass { font-si...
[ { "answer_id": 203298, "author": "William", "author_id": 9193, "author_profile": "https://Stackoverflow.com/users/9193", "pm_score": 3, "selected": true, "text": "<p>The browser will have to find all the definitions and then add them up and override the different properties based on the ...
2008/10/15
[ "https://Stackoverflow.com/questions/203274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Usually when I build a site, I put all the CSS into one file, and all the properties that relate to a set of elements are defined at once. Like this: ``` #myElement { color: #fff; background-color: #000; padding: 10px; border: 1px solid #ccc; font-size: 14pt; } .myClass { font-size: 12pt; ...
The browser will have to find all the definitions and then add them up and override the different properties based on the latest definition. So there will be a slight overhead. That being said it would be rather minimal and not very noticeable even on hardware 5 years old. The browsers are quite efficient at it these ...
203,294
<p>I have two NSURLConnections. The second one depends on the content of the first, so handling the data received from the connection will be different for the two connections. </p> <p>I'm just picking up Objective-C and I would like to know what the proper way to implement the delegates is.</p> <p>Right now I'm usin...
[ { "answer_id": 203356, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "<p>delegates are implemented as standard NSObject-descended objects. </p>\n\n<p>You can point both connections to the s...
2008/10/15
[ "https://Stackoverflow.com/questions/203294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3415/" ]
I have two NSURLConnections. The second one depends on the content of the first, so handling the data received from the connection will be different for the two connections. I'm just picking up Objective-C and I would like to know what the proper way to implement the delegates is. Right now I'm using: ``` NSURL *u...
In your sample, you alloc a DownloadDelegate object without ever init'ing it. ```` DownloadDelegate *dd = [DownloadDelegate alloc]; ```` This is dangerous. Instead: ```` DownloadDelegate *dd = [[DownloadDelegate alloc] init]; ```` Also, it's not *strictly* necessary to declare your delegate response met...
203,302
<p>I have a table of items, each of which has a date associated with it. If I have the date associated with one item, how do I query the database with SQL to get the 'previous' and 'subsequent' items in the table?</p> <p>It is not possible to simply add (or subtract) a value, as the dates do not have a regular gap bet...
[ { "answer_id": 203310, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 2, "selected": false, "text": "<p>Firstly, this should work (the ORDER BY is important):</p>\n\n<pre><code>select min(a)\nfrom theTable\nwhere a ...
2008/10/15
[ "https://Stackoverflow.com/questions/203302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10019/" ]
I have a table of items, each of which has a date associated with it. If I have the date associated with one item, how do I query the database with SQL to get the 'previous' and 'subsequent' items in the table? It is not possible to simply add (or subtract) a value, as the dates do not have a regular gap between them....
My own attempt at the set solution, based on TheSoftwareJedi. First question: ``` select date from test where date = 8 union all select max(date) from test where date < 8 union all select min(date) from test where date > 8 order by date; ``` Second question: While debugging this, I used the data set: ``` (key:dat...
203,316
<p>I have a table in my database which stores a tree structure. Here are the relevant fields:</p> <pre><code>mytree (id, parentid, otherfields...) </code></pre> <p>I want to find all the leaf nodes (that is, any record whose <code>id</code> is not another record's <code>parentid</code>)</p> <p>I've tried this:</p> ...
[ { "answer_id": 203323, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 3, "selected": false, "text": "<p>No clue why your query didn't work. Here's the identical thing in left outer join syntax - try it this way?</p...
2008/10/15
[ "https://Stackoverflow.com/questions/203316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have a table in my database which stores a tree structure. Here are the relevant fields: ``` mytree (id, parentid, otherfields...) ``` I want to find all the leaf nodes (that is, any record whose `id` is not another record's `parentid`) I've tried this: ``` SELECT * FROM mytree WHERE `id` NOT IN (SELECT DISTINCT...
Your query didn't work because the sub-query includes `NULL`. The following slight modification works for me: ``` SELECT * FROM `mytree` WHERE `id` NOT IN ( SELECT DISTINCT `parentid` FROM `mytree` WHERE `parentid` IS NOT NULL) ```
203,336
<p>How would one create a Singleton class using PHP5 classes?</p>
[ { "answer_id": 203359, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 9, "selected": true, "text": "<pre><code>/**\n * Singleton class\n *\n */\nfinal class UserFactory\n{\n private static $inst = null;\n\n // Prevent clo...
2008/10/15
[ "https://Stackoverflow.com/questions/203336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26210/" ]
How would one create a Singleton class using PHP5 classes?
``` /** * Singleton class * */ final class UserFactory { private static $inst = null; // Prevent cloning and de-serializing private function __clone(){} private function __wakeup(){} /** * Call this method to get singleton * * @return UserFactory */ public static functio...
203,358
<p>I want to set a style on the first and last TabItems in a TabControl, and have them updated as the visibility of the TabItems is changed. I can't see a way to do so with triggers.</p> <p>What we're after looks like this:</p> <pre>| > > > |</pre> <p>And the visibility of TabItems are determined by binding.</p> <...
[ { "answer_id": 204455, "author": "Dave", "author_id": 28197, "author_profile": "https://Stackoverflow.com/users/28197", "pm_score": 1, "selected": false, "text": "<p>Sorry can you explain this a little better so far i have interpreted your question as so:</p>\n\n<p>Apply a specific style...
2008/10/15
[ "https://Stackoverflow.com/questions/203358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28074/" ]
I want to set a style on the first and last TabItems in a TabControl, and have them updated as the visibility of the TabItems is changed. I can't see a way to do so with triggers. What we're after looks like this: ``` | > > > | ``` And the visibility of TabItems are determined by binding. I do have it working in co...
Sorry can you explain this a little better so far i have interpreted your question as so: Apply a specific style when the visibility changes on the tab items at the beginning and end of the tab control - ie if it scrolls out of view then change the style? If this is so then, as you add your TabItems (either programma...
203,377
<p>How do you get the max value of an enum?</p>
[ { "answer_id": 203389, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 9, "selected": true, "text": "<p>Enum.GetValues() seems to return the values in order, so you can do something like this:</p>\n\n<pre><code>// given th...
2008/10/15
[ "https://Stackoverflow.com/questions/203377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/438/" ]
How do you get the max value of an enum?
Enum.GetValues() seems to return the values in order, so you can do something like this: ``` // given this enum: public enum Foo { Fizz = 3, Bar = 1, Bang = 2 } // this gets Fizz var lastFoo = Enum.GetValues(typeof(Foo)).Cast<Foo>().Last(); ``` **Edit** For those not willing to read through the commen...
203,383
<p>I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc..</p> <p>So I'm trying to name this array / structure:</p> <pre><code>$nameMe = array( '392' =&gt; TRUE, '234' =&gt; TRUE, '754' =&gt; TRUE, '464' =&gt; TRUE, ); </code></pre...
[ { "answer_id": 203395, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>propertyNameable, IspropertyNameable.</p>\n" }, { "answer_id": 203401, "author": "Paul Tomblin", "a...
2008/10/15
[ "https://Stackoverflow.com/questions/203383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc.. So I'm trying to name this array / structure: ``` $nameMe = array( '392' => TRUE, '234' => TRUE, '754' => TRUE, '464' => TRUE, ); ``` and it's used to check if that id has a...
``` $hasProperty[$id] ``` or ``` $isSomething[$id] ``` What is the property exactly? ``` $isOdd[$id] $isWriteable[$id] $hasAssociatedFile[$id] ```
203,384
<p>Various programs can do stuff only when you haven't used the computer for a while (eg screensaver, Google Desktop indexing, etc).</p> <p>How do they know when it has been inactive? Is there some function in Windows that tells you how long it has been inactive, or do you have to use some kind of keyboard/mouse hook ...
[ { "answer_id": 203404, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://dataerror.blogspot.com/2005/02/detect-windows-idle-time.html\" rel=\"noreferrer\">Google is your friend</...
2008/10/15
[ "https://Stackoverflow.com/questions/203384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4495/" ]
Various programs can do stuff only when you haven't used the computer for a while (eg screensaver, Google Desktop indexing, etc). How do they know when it has been inactive? Is there some function in Windows that tells you how long it has been inactive, or do you have to use some kind of keyboard/mouse hook to track a...
EDIT: changed answer, providing text and detail behind Shy's answer (which should be and was accepted). Feel free to merge and delete this one. [GetLastInputInfo](http://pinvoke.net/default.aspx/user32/GetLastInputInfo.html) Function The GetLastInputInfo function retrieves the time of the last input event. Pasted her...
203,397
<p>Is there a way to change the context sensitive help in Visual Studio so that it will only search against the text under the caret instead of a compilation error in your code?</p> <p>More info: After you compile and receive a compilation error(underlined), placing the caret within the underlined text and pressing <kb...
[ { "answer_id": 203436, "author": "Hapkido", "author_id": 27646, "author_profile": "https://Stackoverflow.com/users/27646", "pm_score": 0, "selected": false, "text": "<p>If I remember, after you compile, the default selected window is the message (error list) one. If you hit <kbd>F1</kbd...
2008/10/15
[ "https://Stackoverflow.com/questions/203397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
Is there a way to change the context sensitive help in Visual Studio so that it will only search against the text under the caret instead of a compilation error in your code? More info: After you compile and receive a compilation error(underlined), placing the caret within the underlined text and pressing `F1` will ta...
The only solution I've found is to fix the compile error ;-) A workaround is to **use the 'Dynamic Help' window** (from the help menu, or `CTRL`-`F1`, `D`), the compile error is top of the list but the usual item will be listed next. For those that don't understand the question, here's a trivial, unrealistic example:...
203,399
<p>I'm running a MySQL database locally for development, but deploying to Heroku which uses Postgres. Heroku handles almost everything, but my case-insensitive Like statements become case sensitive. I could use iLike statements, but my local MySQL database can't handle that.</p> <p>What is the best way to write a case...
[ { "answer_id": 203419, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 7, "selected": true, "text": "<pre><code>select * from foo where upper(bar) = upper(?);\n</code></pre>\n\n<p>If you set the parameter to upper case in...
2008/10/15
[ "https://Stackoverflow.com/questions/203399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23885/" ]
I'm running a MySQL database locally for development, but deploying to Heroku which uses Postgres. Heroku handles almost everything, but my case-insensitive Like statements become case sensitive. I could use iLike statements, but my local MySQL database can't handle that. What is the best way to write a case insensiti...
``` select * from foo where upper(bar) = upper(?); ``` If you set the parameter to upper case in the caller, you can avoid the second function call.
203,425
<p>What's the ASP equivalent to PHP's <code>.=</code> when concatenating strings? I'm referring to asp NOT asp.net.</p> <p>I meant to specify that I'm in a for-loop. So I want to know the equivalent for <code>.=</code> (in php) not standard concatenation.</p> <p><em>Example:</em></p> <pre><code>For Each Item In Requ...
[ { "answer_id": 203429, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": false, "text": "<p>In VBScript:</p>\n\n<pre><code>Variable = Variable &amp; \"something more\"\n</code></pre>\n\n<p>In JScript I believe you...
2008/10/15
[ "https://Stackoverflow.com/questions/203425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What's the ASP equivalent to PHP's `.=` when concatenating strings? I'm referring to asp NOT asp.net. I meant to specify that I'm in a for-loop. So I want to know the equivalent for `.=` (in php) not standard concatenation. *Example:* ``` For Each Item In Request.Form If (Item = "service") then For x=1 ...
In VBScript: ``` Variable = Variable & "something more" ``` In JScript I believe you can use: ``` variable += "something more"; ``` Specifically: ``` service = service & "&service=" & Request.Form(Item)(x) ``` assuming you want your result to look something like... ``` &service=blah1&service=blah2&service=bla...
203,442
<p>Hey All, I have been working on this problem for a while and the usual google searches are not helping :(</p> <p>I have a production database in SQL 2000. I want to copy it over the top of a training database to refresh it. I want this to be something that is scheduled to happen once a week to keep the training dat...
[ { "answer_id": 203482, "author": "Hector Sosa Jr", "author_id": 12829, "author_profile": "https://Stackoverflow.com/users/12829", "pm_score": 0, "selected": false, "text": "<p>Somehow the dbo.vwEstAssetStationAddress table is not being found by your DTS package. Unfortunately, the messag...
2008/10/15
[ "https://Stackoverflow.com/questions/203442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6014/" ]
Hey All, I have been working on this problem for a while and the usual google searches are not helping :( I have a production database in SQL 2000. I want to copy it over the top of a training database to refresh it. I want this to be something that is scheduled to happen once a week to keep the training database up-t...
I feel stupid, but am posting the answer I just found for posterity (and so all you helpful fellows can stop stressing on my behalf. Even though I had selected all the user tables, views, stored procedures and user defined functions to copy, I hadn't selected "Include all dependant objects". I had assumed that if you ...
203,456
<p>I can get the executable location from the process, how do I get the icon from file?</p> <p>Maybe use windows api LoadIcon(). I wonder if there is .NET way...</p>
[ { "answer_id": 203490, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": "<pre><code>Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n</code></pre>\n" }, { "a...
2008/10/15
[ "https://Stackoverflow.com/questions/203456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44972/" ]
I can get the executable location from the process, how do I get the icon from file? Maybe use windows api LoadIcon(). I wonder if there is .NET way...
``` Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName); ```
203,468
<p>Ok, so I'm looking for a bit of architecture guidance, my team is getting a chance to re-cast certain decisions with a new feature that we're building, and I wanted to see what SO thought :-) There are of course certain things that we're not changing, so the solution would have to fit in this model. Namely, that we...
[ { "answer_id": 203490, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 6, "selected": true, "text": "<pre><code>Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n</code></pre>\n" }, { "a...
2008/10/15
[ "https://Stackoverflow.com/questions/203468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
Ok, so I'm looking for a bit of architecture guidance, my team is getting a chance to re-cast certain decisions with a new feature that we're building, and I wanted to see what SO thought :-) There are of course certain things that we're not changing, so the solution would have to fit in this model. Namely, that we've ...
``` Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName); ```
203,469
<p>How do you use enums in Oracle using SQL only? (No PSQL)</p> <p>In MySQL you can do:</p> <pre><code>CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') ); </code></pre> <p>What would be a similar way to do this in Oracle?</p>
[ { "answer_id": 203547, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 7, "selected": true, "text": "<p>Reading a bit about the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/enum.html\" rel=\"noreferrer\">MySQL enum</...
2008/10/15
[ "https://Stackoverflow.com/questions/203469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
How do you use enums in Oracle using SQL only? (No PSQL) In MySQL you can do: ``` CREATE TABLE sizes ( name ENUM('small', 'medium', 'large') ); ``` What would be a similar way to do this in Oracle?
Reading a bit about the [MySQL enum](http://dev.mysql.com/doc/refman/5.0/en/enum.html), I'm guessing the closest equivalent would be a simple check constraint ``` CREATE TABLE sizes ( name VARCHAR2(10) CHECK( name IN ('small','medium','large') ) ); ``` but that doesn't allow you to reference the value by the index...
203,473
<p>I have a Crystal Report that looks like:</p> <p><em>Date | Person | Ticket | Summary <br> Date | Person | Ticket | Summary <br> Date | Person | Ticket | Summary</em> </p> <p>I would like it to look like: </p> <p><em>Date <br> Person | Ticket | Summary <br> Person | Ticket | Summary <br><br> Date <br> Person | Ti...
[ { "answer_id": 203547, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 7, "selected": true, "text": "<p>Reading a bit about the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/enum.html\" rel=\"noreferrer\">MySQL enum</...
2008/10/15
[ "https://Stackoverflow.com/questions/203473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8900/" ]
I have a Crystal Report that looks like: *Date | Person | Ticket | Summary Date | Person | Ticket | Summary Date | Person | Ticket | Summary* I would like it to look like: *Date Person | Ticket | Summary Person | Ticket | Summary Date Person | Ticket | Summary* All values are pulled from a...
Reading a bit about the [MySQL enum](http://dev.mysql.com/doc/refman/5.0/en/enum.html), I'm guessing the closest equivalent would be a simple check constraint ``` CREATE TABLE sizes ( name VARCHAR2(10) CHECK( name IN ('small','medium','large') ) ); ``` but that doesn't allow you to reference the value by the index...
203,475
<p>In my code, I am creating a collection of objects which will be accessed by various threads in a fashion that is only safe if the objects are immutable. When an attempt is made to insert a new object into my collection, I want to test to see if it is immutable (if not, I'll throw an exception).</p> <p>One thing I c...
[ { "answer_id": 203500, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 3, "selected": false, "text": "<p>Basically no. </p>\n\n<p>You could build a giant white-list of accepted classes but I think the less crazy way would be to j...
2008/10/15
[ "https://Stackoverflow.com/questions/203475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14570/" ]
In my code, I am creating a collection of objects which will be accessed by various threads in a fashion that is only safe if the objects are immutable. When an attempt is made to insert a new object into my collection, I want to test to see if it is immutable (if not, I'll throw an exception). One thing I can do is t...
There is no reliable way to detect if a class is immutable. This is because there are so many ways a property of a class might be altered and you can't detect all of them via reflection. The only way to get close to this is: * Only allow final properties of types that are immutable (primitive types and classes you kn...
203,477
<p>I'm using KML and the GGeoXml object to overlay some shapes on an embedded Google map. The placemarks in the KML file have some custom descriptive information that shows up in the balloons.</p> <pre><code>&lt;Placemark&gt; &lt;name /&gt; &lt;description&gt; &lt;![CDATA[ &lt;div class=&quo...
[ { "answer_id": 203621, "author": "Eric Wendelin", "author_id": 25066, "author_profile": "https://Stackoverflow.com/users/25066", "pm_score": 0, "selected": false, "text": "<p>My first guess is that you're running into an issue with CSS specificity. There is a good article on it at <a hre...
2008/10/15
[ "https://Stackoverflow.com/questions/203477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I'm using KML and the GGeoXml object to overlay some shapes on an embedded Google map. The placemarks in the KML file have some custom descriptive information that shows up in the balloons. ``` <Placemark> <name /> <description> <![CDATA[ <div class="MapPopup"> <h6>Concessio...
As suggested I've gone in with Firebug to see what's going on. It looks like Google is doing two obnoxious things: 1. It's stripping out all class attributes from my HTML. 2. It's throwing all kinds of hard-coded styles around. Here's my HTML along with the first couple of wrappers inserted by Google: ``` <div style...
203,520
<p>I have what must be a typical catch-22 problem. I have a .NET WinForm control that contains a textbox and a checkbox. Both controls are data bound to properties on a data class instance. The textbox is for price, the check box to indicate that the price is a price override. Also on the data class is a property t...
[ { "answer_id": 203580, "author": "Chris Roland", "author_id": 27975, "author_profile": "https://Stackoverflow.com/users/27975", "pm_score": 0, "selected": false, "text": "<p>Have you considered handling the TextBox <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.co...
2008/10/15
[ "https://Stackoverflow.com/questions/203520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5496/" ]
I have what must be a typical catch-22 problem. I have a .NET WinForm control that contains a textbox and a checkbox. Both controls are data bound to properties on a data class instance. The textbox is for price, the check box to indicate that the price is a price override. Also on the data class is a property that hol...
I would suggest not handling the logic in the form code, but rather in the data class. All you need in the form is a couple of lines to set up the data binding. The data class can then take care of the rest: Form ``` Private _dc As DataClass Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)...
203,528
<p>When I build XML up from scratch with <code>XmlDocument</code>, the <code>OuterXml</code> property already has everything nicely indented with line breaks. However, if I call <code>LoadXml</code> on some very "compressed" XML (no line breaks or indention) then the output of <code>OuterXml</code> stays that way. So...
[ { "answer_id": 203533, "author": "DocMax", "author_id": 6234, "author_profile": "https://Stackoverflow.com/users/6234", "pm_score": 6, "selected": false, "text": "<p>As adapted from <a href=\"http://blogs.msdn.com/erikaehrli/archive/2005/11/16/IndentXMLFilesandDocuments.aspx\" rel=\"nore...
2008/10/15
[ "https://Stackoverflow.com/questions/203528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
When I build XML up from scratch with `XmlDocument`, the `OuterXml` property already has everything nicely indented with line breaks. However, if I call `LoadXml` on some very "compressed" XML (no line breaks or indention) then the output of `OuterXml` stays that way. So ... What is the simplest way to get beautified ...
Based on the other answers, I looked into [`XmlTextWriter`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.xmltextwriter) and came up with the following helper method: ``` static public string Beautify(this XmlDocument doc) { StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new Xml...
203,548
<p>I've been getting this undefined symbol building with this command line:</p> <pre><code>$ gcc test.cpp Undefined symbols: "___gxx_personality_v0", referenced from: etc... </code></pre> <p>test.cpp is simple and should build fine. What is the deal?</p>
[ { "answer_id": 203550, "author": "ryan_s", "author_id": 13728, "author_profile": "https://Stackoverflow.com/users/13728", "pm_score": 7, "selected": true, "text": "<p>Use</p>\n\n<pre><code>g++ test.cpp\n</code></pre>\n\n<p>instead, since this is c++ code.</p>\n\n<hr>\n\n<p>Or, if you <em...
2008/10/15
[ "https://Stackoverflow.com/questions/203548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13728/" ]
I've been getting this undefined symbol building with this command line: ``` $ gcc test.cpp Undefined symbols: "___gxx_personality_v0", referenced from: etc... ``` test.cpp is simple and should build fine. What is the deal?
Use ``` g++ test.cpp ``` instead, since this is c++ code. --- Or, if you *really* want to use `gcc`, add `-lstdc++` to the command line, like so: ``` gcc test.cpp -lstdc++ ``` Running `md5` against the `a.out` produced under each scenario shows that it's the same output. But, yeah, `g++` probably makes your wo...
203,589
<p>I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure.</p> <p>Here is what is in the console:</p> <pre><code>*** Assertion failure in -[...
[ { "answer_id": 203663, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": true, "text": "<p>If you've got UILabels in your xib file, they may be somehow corrupt, or you may have set a font to them that doesn't...
2008/10/15
[ "https://Stackoverflow.com/questions/203589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
I have an iPhone app that compiles and runs fine in the Simulator on my laptop. Now, I try to build and run the same code in the Simulator on an iMac, and it starts up and lets me click a button, but then I get an assertion failure. Here is what is in the console: ``` *** Assertion failure in -[UILabel setFont:], /So...
If you've got UILabels in your xib file, they may be somehow corrupt, or you may have set a font to them that doesn't exist on both your machines (you can use command-T when editing a UILabel to bring up the font picker; not sure it's possible to set a non-iPhone font, but it may be). Otherwise, try removing UILabels f...
203,591
<p>My SQL is a bit rusty -- is there a SQL way to project an input table that looks something like this:</p> <pre><code>Name SlotValue Slots ---- --------- ----- ABC 3 1 ABC 4 2 ABC ...
[ { "answer_id": 203608, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p><img src=\"https://www.lemurproject.org/images/VS_Net_AdditionalIncludes.jpg\" alt=\"alt text\"></p>\n" }, { "answer...
2008/10/15
[ "https://Stackoverflow.com/questions/203591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18482/" ]
My SQL is a bit rusty -- is there a SQL way to project an input table that looks something like this: ``` Name SlotValue Slots ---- --------- ----- ABC 3 1 ABC 4 2 ABC 6 ...
![alt text](https://www.lemurproject.org/images/VS_Net_AdditionalIncludes.jpg)
203,605
<p>I'm looking for a way to match only fully composed characters in a Unicode string.</p> <p>Is <code>[:print:]</code> dependent upon locale in any regular expression implementation that incorporates this character class? For example, will it match Japanese character 'あ', since it is not a control character, or is <co...
[ { "answer_id": 203606, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 2, "selected": false, "text": "<p>Yes, those expressions are locale dependant.</p>\n" }, { "answer_id": 203623, "author": "Adam Rose...
2008/10/15
[ "https://Stackoverflow.com/questions/203605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10320/" ]
I'm looking for a way to match only fully composed characters in a Unicode string. Is `[:print:]` dependent upon locale in any regular expression implementation that incorporates this character class? For example, will it match Japanese character 'あ', since it is not a control character, or is `[:print:]` always going...
``` echo あ| perl -nle 'BEGIN{binmode STDIN,":utf8"} print"[$_]"; print /[[:print:]]/ ? "YES" : "NO"' ``` This mostly works, though it generates a warning about a wide character. But it gives you the idea: you must be sure you're dealing with a real unicode string (check utf8::is\_utf8). Or just check [perlunicode](ht...
203,618
<ul> <li>What rules do you use to name your variables?</li> <li>Where are single letter vars allowed?</li> <li>How much info do you put in the name?</li> <li>How about for example code?</li> <li>What are your preferred meaningless variable names? (after foo &amp; bar)</li> <li>Why are they spelled <a href="http://en.wi...
[ { "answer_id": 203632, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 0, "selected": false, "text": "<p>I would say try to name them as clearly as possible. Never use single letter variables and only use 'foo' and 'bar' if ...
2008/10/15
[ "https://Stackoverflow.com/questions/203618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
* What rules do you use to name your variables? * Where are single letter vars allowed? * How much info do you put in the name? * How about for example code? * What are your preferred meaningless variable names? (after foo & bar) * Why are they spelled ["foo" and "bar"](http://en.wikipedia.org/wiki/Foobar) rather than ...
``` function startEditing(){ if (user.canEdit(currentDocument)){ editorControl.setEditMode(true); setButtonDown(btnStartEditing); } } ``` Should read like a narrative work.
203,620
<p>I need ideas on how to go about table layout problem. I want to set different width of the columns dependent on the picked language.</p>
[ { "answer_id": 203626, "author": "Nrj", "author_id": 11614, "author_profile": "https://Stackoverflow.com/users/11614", "pm_score": 1, "selected": false, "text": "<p>Use if-else inside scriplet based on the currently selected language and place appropriate \"td\" tags.</p>\n\n<p>Hope this...
2008/10/15
[ "https://Stackoverflow.com/questions/203620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
I need ideas on how to go about table layout problem. I want to set different width of the columns dependent on the picked language.
A variable switch, such as: ``` <% dim columnWidth if session("lang") = "eng" then columnWidth = 50 else columnWidth = 100 end if %> <table> <tr> <td width="<%= columnWidth %>px">[content]</td> </tr> </table> ``` For c#, the code would be: ``` <% private int columnWidth; if (session("lang")...
203,629
<p>Has anyone used OSGi and JSF together?</p> <p>I ask because JSF uses class-loader magic to find custom components. From a tutorial (emphasis mine):</p> <blockquote> <p>This configuration file will end up being META-INF/faces-config.xml in the .jar file that represents this component. <strong>JSF will look ...
[ { "answer_id": 203626, "author": "Nrj", "author_id": 11614, "author_profile": "https://Stackoverflow.com/users/11614", "pm_score": 1, "selected": false, "text": "<p>Use if-else inside scriplet based on the currently selected language and place appropriate \"td\" tags.</p>\n\n<p>Hope this...
2008/10/15
[ "https://Stackoverflow.com/questions/203629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
Has anyone used OSGi and JSF together? I ask because JSF uses class-loader magic to find custom components. From a tutorial (emphasis mine): > > This configuration file will end up > being META-INF/faces-config.xml in the > .jar file that represents this > component. **JSF will look for such a > file name in eac...
A variable switch, such as: ``` <% dim columnWidth if session("lang") = "eng" then columnWidth = 50 else columnWidth = 100 end if %> <table> <tr> <td width="<%= columnWidth %>px">[content]</td> </tr> </table> ``` For c#, the code would be: ``` <% private int columnWidth; if (session("lang")...
203,677
<p>Just got a question about generics, why doesn't this compile when using a generic List? If its not possible, anyway around it? Much appreciate any answer.</p> <pre><code>// Interface used in the ServiceAsync inteface. public interface BaseObject { public String getId(); } // Class that implements the interface...
[ { "answer_id": 203741, "author": "Aaron", "author_id": 3752, "author_profile": "https://Stackoverflow.com/users/3752", "pm_score": 2, "selected": false, "text": "<p>The '?' in generic types can be pretty confusing. Honestly I'm not sure why this won't compile. It has to do with using the...
2008/10/15
[ "https://Stackoverflow.com/questions/203677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28108/" ]
Just got a question about generics, why doesn't this compile when using a generic List? If its not possible, anyway around it? Much appreciate any answer. ``` // Interface used in the ServiceAsync inteface. public interface BaseObject { public String getId(); } // Class that implements the interface public class ...
This has got to do with the subtyping rules for parametrized types. I'll explain it in three steps: Non-nested case --------------- When you have the following subtype relation (where `<:` is the symbol for "is a subtype of"): ``` _ModelDto <: BaseObject ``` The following relation does **not** hold: ``` List<_Mod...
203,695
<p>When you create an instance of a class with the <code>new</code> operator, memory gets allocated on the heap. When you create an instance of a struct with the <code>new</code> operator where does the memory get allocated, on the heap or on the stack ?</p>
[ { "answer_id": 203698, "author": "Esteban Araya", "author_id": 781, "author_profile": "https://Stackoverflow.com/users/781", "pm_score": 3, "selected": false, "text": "<p>As with all value types, structs always go where they were <em>declared</em>.</p>\n\n<p>See this question <a href=\"h...
2008/10/15
[ "https://Stackoverflow.com/questions/203695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18709/" ]
When you create an instance of a class with the `new` operator, memory gets allocated on the heap. When you create an instance of a struct with the `new` operator where does the memory get allocated, on the heap or on the stack ?
Okay, let's see if I can make this any clearer. Firstly, Ash is right: the question is *not* about where value type *variables* are allocated. That's a different question - and one to which the answer isn't just "on the stack". It's more complicated than that (and made even more complicated by C# 2). I have an [articl...
203,707
<p>The following two forms of jQuery selectors seem to do the same thing:</p> <ul> <li>$("div > ul.posts") </li> <li>$("div ul.posts")</li> </ul> <p>which is to select all the "ul" elements of class "posts" under "div" elements.</p> <p>Is there any difference?</p>
[ { "answer_id": 203710, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": false, "text": "<p>The first only selects ul.posts whose parentNode is div.</p>\n\n<p>The second would also select:</p>\n\n<pre><co...
2008/10/15
[ "https://Stackoverflow.com/questions/203707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6225/" ]
The following two forms of jQuery selectors seem to do the same thing: * $("div > ul.posts") * $("div ul.posts") which is to select all the "ul" elements of class "posts" under "div" elements. Is there any difference?
Concerning `$("div > ul.posts")`, only direct descendants of `DIV`s will be selected. ``` <div> <ul class="posts"> <!--SELECTED--> <li>List Item</li> <ul class="posts"> <!--NOT SELECTED--> <li>Sub list item</li> </ul> </ul> <fieldset> <ul class="posts"> <!--NOT ...
203,739
<pre><code>&quot;foo&quot; instanceof String //=&gt; false &quot;foo&quot; instanceof Object //=&gt; false true instanceof Boolean //=&gt; false true instanceof Object //=&gt; false false instanceof Boolean //=&gt; false false instanceof Object //=&gt; false 12.21 instanceof Number //=&gt; false /foo/ instanceof RegE...
[ { "answer_id": 203757, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 10, "selected": true, "text": "<p>Primitives are a different kind of type than objects created from within Javascript. From the <a href=\"http://deve...
2008/10/15
[ "https://Stackoverflow.com/questions/203739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15031/" ]
``` "foo" instanceof String //=> false "foo" instanceof Object //=> false true instanceof Boolean //=> false true instanceof Object //=> false false instanceof Boolean //=> false false instanceof Object //=> false 12.21 instanceof Number //=> false /foo/ instanceof RegExp //=> true // the tests against Object really...
Primitives are a different kind of type than objects created from within Javascript. From the [Mozilla API docs](http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator): ``` var color1 = new String("green"); color1 instanceof String; // returns true var color2 = "...
203,754
<p>I have a thread running in the background that is reading events from an input device in a blocking fashion, now when I exit the application I want to clean up the thread properly, but I can't just run a pthread_join() because the thread would never exit due to the blocking IO.</p> <p>How do I properly solve that s...
[ { "answer_id": 203819, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 2, "selected": false, "text": "<p>I think, as you said, the only way would be to send a signal then catch and deal with it appropriately. Alternatives ...
2008/10/15
[ "https://Stackoverflow.com/questions/203754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28113/" ]
I have a thread running in the background that is reading events from an input device in a blocking fashion, now when I exit the application I want to clean up the thread properly, but I can't just run a pthread\_join() because the thread would never exit due to the blocking IO. How do I properly solve that situation?...
Old question which could very well get a new answer as things have evolved and a new technology is now available to *better* handle signals in threads. Since Linux kernel 2.6.22, the system offers a new function called `signalfd()` which can be used to open a file descriptor for a given set of Unix signals (outside of...
203,771
<p>I have been using CPPUnit as a unit testing framework and am now trying to use it in an automated build and package system. However a problem holding me back is that if a crash occurs during the running of the unit tests, e.g. a null pointer dereferencing, it halts the remainder of the automation.</p> <p>Is there ...
[ { "answer_id": 203774, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "<p>In C/C++, the best way to recover from errors like that is to run each test in a separate process and then monitor ...
2008/10/15
[ "https://Stackoverflow.com/questions/203771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10247/" ]
I have been using CPPUnit as a unit testing framework and am now trying to use it in an automated build and package system. However a problem holding me back is that if a crash occurs during the running of the unit tests, e.g. a null pointer dereferencing, it halts the remainder of the automation. Is there any way for...
You're automating the execution of your cppunit-based unit-tests during your build process, right ? If you were trying to use CppUnit to execute the build process, I would be tempted to say don't do that ! Could you tell us what is stopping the build process when the unit tests crash ? And what are your unit tests s...
203,787
<p>I have an object, that is facing a particular direction with (for instance) a 45 degree field of view, and a limit view range. I have done all the initial checks (Quadtree node, and distance), but now I need to check if a particular object is within that view cone, (In this case to decide only to follow that object ...
[ { "answer_id": 203802, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 4, "selected": true, "text": "<p>Compute the angle between your view direction (understood as a vector) and the vector that starts at you and...
2008/10/15
[ "https://Stackoverflow.com/questions/203787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24793/" ]
I have an object, that is facing a particular direction with (for instance) a 45 degree field of view, and a limit view range. I have done all the initial checks (Quadtree node, and distance), but now I need to check if a particular object is within that view cone, (In this case to decide only to follow that object if ...
Compute the angle between your view direction (understood as a vector) and the vector that starts at you and ends at the object. If it falls under FieldOfView/2, you can view the object. That angle is: ``` arccos(scalarProduct(viewDirection, (object - you)) / (norm(viewDirection)*norm(object - you))). ```
203,807
<p>I have a VB application which extracts data and creates 3 CSV files (a.csv, b.csv, c.csv). Then I use another Excel spreadsheet (import.xls) to import all the data from the above CSV files into this sheet.</p> <p>import.xls file has a macro which opens the CSV files one by one and copies the data. The problem I am ...
[ { "answer_id": 203812, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "<p>When I run into this problem I usually write out the dates as yyyy-mm-dd which Excel will interpret unambiguously.</p>...
2008/10/15
[ "https://Stackoverflow.com/questions/203807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12178/" ]
I have a VB application which extracts data and creates 3 CSV files (a.csv, b.csv, c.csv). Then I use another Excel spreadsheet (import.xls) to import all the data from the above CSV files into this sheet. import.xls file has a macro which opens the CSV files one by one and copies the data. The problem I am facing is ...
You can use the **Format** VBA function: ``` Format(DateText, "dd/mm/yyyy") ``` That will format it how ever you like. For a more permanant solution, try changing your regional settings in windows itself, Excel uses this for its date formatting. Start -> Settings -> Control Panel -> Regional Options. Make sure t...
203,809
<p>This might be a little hard to explain, but I will try.</p> <p>I want to display a list of categories (stored in 1 table), and number of domains associated with each category (stored in another table). </p> <p>The monkey wrench in this case is that each domain has a set of records associated with it (which are sto...
[ { "answer_id": 203815, "author": "AquilaX", "author_id": 17734, "author_profile": "https://Stackoverflow.com/users/17734", "pm_score": 0, "selected": false, "text": "<p>Something like this?</p>\n\n<pre><code>SELECT c.name, count(d.id)\nFROM categories c\nJOIN domains d ON c.id = d.cid\nJ...
2008/10/15
[ "https://Stackoverflow.com/questions/203809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This might be a little hard to explain, but I will try. I want to display a list of categories (stored in 1 table), and number of domains associated with each category (stored in another table). The monkey wrench in this case is that each domain has a set of records associated with it (which are stored in a 3rd tabl...
``` SELECT Categories.Name,count(DISTINCT categories.name) FROM Categories JOIN Domains ON Categories.ID=Domains.CID JOIN Records ON Records.DID=Domains.ID GROUP BY Categories.Name ``` Tested with following setup: ``` CREATE TABLE Categories (Name nvarchar(50), ID int NOT NULL IDENTITY(1,1)) CREATE TABLE Domains (N...
203,823
<p>One of classes in my program uses some third-party library. Library object is a private member of my class:</p> <pre><code>// My.h #include &lt;3pheader.h&gt; class My { ... private: 3pObject m_object; } </code></pre> <p>The problem with this - any other unit in my program that use...
[ { "answer_id": 203828, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<p>The Private Implementation (PIMPL) pattern:</p>\n\n<p><a href=\"http://www.codeproject.com/KB/tips/PIMPL.aspx\" rel=\"nofol...
2008/10/15
[ "https://Stackoverflow.com/questions/203823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18174/" ]
One of classes in my program uses some third-party library. Library object is a private member of my class: ``` // My.h #include <3pheader.h> class My { ... private: 3pObject m_object; } ``` The problem with this - any other unit in my program that uses My class should be configured ...
Use the "pimpl" idiom: ``` // header class My { class impl; std::auto_ptr<impl> _impl; }; // cpp #include <3pheader.h> class My::impl { 3pObject _object; }; ```
203,844
<p>I have a form with multiple fields that I'm validating (some with methods added for custom validation) with Jörn Zaeffere's excellent jQuery Validation plugin. How do you circumvent validation with specified submit controls (in other words, fire validation with some submit inputs, but do not fire validation with oth...
[ { "answer_id": 203989, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 9, "selected": true, "text": "<p>You can add a CSS class of <code>cancel</code> to a submit button to suppress the validation</p>\n\n<p>e.g</p>\n\n<pre><...
2008/10/15
[ "https://Stackoverflow.com/questions/203844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9344/" ]
I have a form with multiple fields that I'm validating (some with methods added for custom validation) with Jörn Zaeffere's excellent jQuery Validation plugin. How do you circumvent validation with specified submit controls (in other words, fire validation with some submit inputs, but do not fire validation with others...
You can add a CSS class of `cancel` to a submit button to suppress the validation e.g ``` <input class="cancel" type="submit" value="Save" /> ``` See the jQuery Validator documentation of this feature here: [Skipping validation on submit](https://jqueryvalidation.org/reference#link-skipping-validation-on-submit) -...
203,854
<p>Example. 123456, and we want the third from the right ('4') out.</p> <p>The idea in practise is to access each digit seperately (ie. 6 5 4 3 2 1).</p> <p>C/C++/C# preferred.</p>
[ { "answer_id": 203864, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": -1, "selected": false, "text": "<p>In C you could do something like the following, where n=0 would indicate the rightmost digit</p>\n\n<pre><code>char nthD...
2008/10/15
[ "https://Stackoverflow.com/questions/203854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24661/" ]
Example. 123456, and we want the third from the right ('4') out. The idea in practise is to access each digit seperately (ie. 6 5 4 3 2 1). C/C++/C# preferred.
A more efficient implementation might be something like this: ``` char nthdigit(int x, int n) { while (n--) { x /= 10; } return (x % 10) + '0'; } ``` This saves the effort of converting all digits to string format if you only want one of them. And, you don't have to allocate space for the convert...
203,859
<p>Markdown is a great tool for formatting plain text into pretty html, but it doesn't turn plain-text links into URLs automatically. Like this one:</p> <p><a href="http://www.google.com/" rel="noreferrer">http://www.google.com/</a></p> <p>How do I get markdown to add tags to URLs when I format a block of text?</p>
[ { "answer_id": 203870, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>This isn't a feature of Markdown -- what you should do is run a post-processor against the text looking for a URL-l...
2008/10/15
[ "https://Stackoverflow.com/questions/203859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/432/" ]
Markdown is a great tool for formatting plain text into pretty html, but it doesn't turn plain-text links into URLs automatically. Like this one: <http://www.google.com/> How do I get markdown to add tags to URLs when I format a block of text?
I couldn't get superjoe30's regular expression to compile, so I adapted his solution to convert plain URLs (within Markdown text) to be Markdown compatible. The modified filter: ``` urlfinder = re.compile('^(http:\/\/\S+)') urlfinder2 = re.compile('\s(http:\/\/\S+)') @register.filter('urlify_markdown') def urlify_mar...
203,890
<p>How do I generate an audio sine or square wave of a given frequency?</p> <p>I am hoping to do this to calibrate equipment, so how precise would these waves be?</p>
[ { "answer_id": 203917, "author": "Mark Heath", "author_id": 7532, "author_profile": "https://Stackoverflow.com/users/7532", "pm_score": 6, "selected": true, "text": "<p>You can use <a href=\"http://codeplex.com/naudio\" rel=\"noreferrer\">NAudio</a> and create a derived WaveStream that o...
2008/10/15
[ "https://Stackoverflow.com/questions/203890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
How do I generate an audio sine or square wave of a given frequency? I am hoping to do this to calibrate equipment, so how precise would these waves be?
You can use [NAudio](http://codeplex.com/naudio) and create a derived WaveStream that outputs sine or square waves which you could output to the soundcard or write to a [WAV](http://en.wikipedia.org/wiki/WAV) file. If you used 32-bit floating point samples you could write the values directly out of the sin function wit...
203,911
<p>I am using Java API and XPath to parse my XML. I have XML like this:</p> <pre><code>&lt;animals&gt; &lt;dog&gt; &lt;looks&gt;dangerous &lt;/looks&gt; &lt;bites&gt; hard &lt;/bites&gt; &lt;growls&gt; yes &lt;/growls&gt; &lt;/dog&gt; &lt;cat&gt;nothing special&lt;/cat&gt; &lt;/animals&gt; </code>...
[ { "answer_id": 203938, "author": "rslite", "author_id": 15682, "author_profile": "https://Stackoverflow.com/users/15682", "pm_score": 2, "selected": false, "text": "<p>If you use /animals/dog you will get back the 'dog' node with all the child nodes. Printing the inner xml of that node s...
2008/10/15
[ "https://Stackoverflow.com/questions/203911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25458/" ]
I am using Java API and XPath to parse my XML. I have XML like this: ``` <animals> <dog> <looks>dangerous </looks> <bites> hard </bites> <growls> yes </growls> </dog> <cat>nothing special</cat> </animals> ``` I would like an XPath condition to print ``` <dog> <looks>dangerous </looks> <bi...
If you use /animals/dog you will get back the 'dog' node with all the child nodes. Printing the inner xml of that node should give you what you need.
203,918
<p>Been creating a simple program using VBA that I can use to review vocabulary in Chinese.</p> <p>I've gotten a fair bit working so far, but have run into a huge problem with inputting a macron-character such as "ā" (unicode 257). The specific application I am working on right now involves changing the contents of t...
[ { "answer_id": 203942, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>I don't have ms-office installed on my machine to try it.<br>\nHowever, you can use StrConv function with parameter...
2008/10/15
[ "https://Stackoverflow.com/questions/203918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Been creating a simple program using VBA that I can use to review vocabulary in Chinese. I've gotten a fair bit working so far, but have run into a huge problem with inputting a macron-character such as "ā" (unicode 257). The specific application I am working on right now involves changing the contents of the text-box...
You can use ChrW to generate Unicode characters: ``` Mid(strclip, markloc, 1) = ChrW(257) ```
203,930
<p>Kinda long title, but anyways...</p> <p>I've been looking at these examples, specifically on the parts on writing and reading the size of the message to the byte streams<br> <a href="http://doc.trolltech.com/4.4/network-fortuneclient-client-cpp.html" rel="nofollow noreferrer">http://doc.trolltech.com/4.4/network-fo...
[ { "answer_id": 203934, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "<p>Instead of <code>data.Length</code>, try:</p>\n\n<pre><code>writer.Write(chr(data.Length) + data);\n</code></pre>\n\n<...
2008/10/15
[ "https://Stackoverflow.com/questions/203930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15067/" ]
Kinda long title, but anyways... I've been looking at these examples, specifically on the parts on writing and reading the size of the message to the byte streams <http://doc.trolltech.com/4.4/network-fortuneclient-client-cpp.html> <http://doc.trolltech.com/4.4/network-fortuneserver-server-cpp.html> But I can't...
Generally you would send the length first. Both ends should agree on what a length looks like - for example, you might be happy to use fixed 4-byte length prefix as binary: ``` byte[] data = ... int len = data.Length; byte[] prefix = Bitconverter.GetBytes(len); stream.Write(prefix, 0, prefix.Length); // fixed ...
203,969
<p>How do you get an instance of the actionscript class <code>Class</code> from an instance of that class?</p> <p>In Python, this would be <code>x.__class__</code>; in Java, <code>x.getClass();</code>.</p> <p>I'm aware that <a href="http://actionscript.org/forums/showthread.php3?t=120135#td_post_545693" rel="noreferr...
[ { "answer_id": 204003, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 4, "selected": false, "text": "<p>Any reason you couldn't do this?</p>\n\n<pre><code>var s:Sprite = new flash.display.Sprite();\n\nvar className:String =...
2008/10/15
[ "https://Stackoverflow.com/questions/203969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13564/" ]
How do you get an instance of the actionscript class `Class` from an instance of that class? In Python, this would be `x.__class__`; in Java, `x.getClass();`. I'm aware that [certain terrible hacks](http://actionscript.org/forums/showthread.php3?t=120135#td_post_545693) exist to do this, but I'm looking for a built-i...
You can get it through the 'constructor' property of the base Object class. i.e.: ``` var myClass:Class = Object(myObj).constructor; ```
203,984
<p>I have an <code>ArrayList&lt;String&gt;</code>, and I want to remove repeated strings from it. How can I do this?</p>
[ { "answer_id": 203992, "author": "jonathan-stafford", "author_id": 27587, "author_profile": "https://Stackoverflow.com/users/27587", "pm_score": 11, "selected": true, "text": "<p>If you don't want duplicates in a <code>Collection</code>, you should consider why you're using a <code>Colle...
2008/10/15
[ "https://Stackoverflow.com/questions/203984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25778/" ]
I have an `ArrayList<String>`, and I want to remove repeated strings from it. How can I do this?
If you don't want duplicates in a `Collection`, you should consider why you're using a `Collection` that allows duplicates. The easiest way to remove repeated elements is to add the contents to a `Set` (which will not allow duplicates) and then add the `Set` back to the `ArrayList`: ``` Set<String> set = new HashSet<>...
203,990
<p>I'm writing a C++ client which is using libcurl for communicating with a PHP script.</p> <p>The communication should be session based, and thus the first task is to login and make the PHP script set up a session.</p> <p>I'm not used to working with sessions either from C++ or PHP. I basically know that it has to d...
[ { "answer_id": 204023, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": -1, "selected": false, "text": "<p>A session in PHP has the purpose of preserving some state over several requests, since HTTP in itself is stateless. To ge...
2008/10/15
[ "https://Stackoverflow.com/questions/203990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
I'm writing a C++ client which is using libcurl for communicating with a PHP script. The communication should be session based, and thus the first task is to login and make the PHP script set up a session. I'm not used to working with sessions either from C++ or PHP. I basically know that it has to do with cookies an...
As far as I understand it, CURL will handle session cookies automatically for you if you enable cookies, as long as you reuse your CURL handle for each request in the session: ``` CURL *Handle = curl_easy_init(); // Read cookies from a previous session, as stored in MyCookieFileName. curl_easy_setopt( Handle, CURLOPT...
204,007
<p>I get this error:-</p> <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1</p> <p>whenever I tried something like this:-</p> <pre><code>mysql&gt; source /home/user1/sql/ddl.sql mysql&gt; source /home/user1/sql/inse...
[ { "answer_id": 204016, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>Your input files may contain a <a href=\"http://en.wikipedia.org/wiki/Byte_Order_Mark\" rel=\"nofollow noreferrer\">Un...
2008/10/15
[ "https://Stackoverflow.com/questions/204007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18500/" ]
I get this error:- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' at line 1 whenever I tried something like this:- ``` mysql> source /home/user1/sql/ddl.sql mysql> source /home/user1/sql/insert.sql mysql> source /home/user1/s...
A possibility is that the SQL files were written in Unicode with a [BOM](https://en.wikipedia.org/wiki/Byte_Order_Mark), which MySQL cannot interpret. That would explain the symptoms. A solution is to open them in a decent editor and save them back without it. Example in VIM: Force BOM removal ``` :set nobomb ``...
204,017
<p>I have a Python script that needs to execute an external program, but for some reason fails.</p> <p>If I have the following script:</p> <pre><code>import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); </code></pre> <p>Then it fails with the following error:</p> <blockquote> <p>'C:\Temp\a' is not r...
[ { "answer_id": 204024, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "<p>I suspect it's the same problem as when you use shortcuts in Windows... Try this:</p>\n\n<pre><code>import os;...
2008/10/15
[ "https://Stackoverflow.com/questions/204017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
I have a Python script that needs to execute an external program, but for some reason fails. If I have the following script: ``` import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); ``` Then it fails with the following error: > > 'C:\Temp\a' is not recognized as an internal or external command, oper...
[`subprocess.call`](http://docs.python.org/2/library/subprocess.html#using-the-subprocess-module) will avoid problems with having to deal with quoting conventions of various shells. It accepts a list, rather than a string, so arguments are more easily delimited. i.e. ``` import subprocess subprocess.call(['C:\\Temp\\a...
204,032
<p>I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'.</p> <p>Is there any way to make this work? I currently have a structure resembling this:</p> <p>pseudo code:</p> ...
[ { "answer_id": 204114, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 0, "selected": false, "text": "<p>did you specify in your service behavior config? it seems like some information is missing in this stackt...
2008/10/15
[ "https://Stackoverflow.com/questions/204032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'. Is there any way to make this work? I currently have a structure resembling this: pseudo code: ``` Person: IEnumerab...
As a note, you need to learn how to use the WCF logging utilities: [Logging info.](http://msdn.microsoft.com/en-us/library/ms730064.aspx) [Config Editor](http://msdn.microsoft.com/en-us/library/ms732009.aspx) (makes it a snap to setup). [Trace viewer.](http://msdn.microsoft.com/en-us/library/ms732023.aspx) Totally a...
204,040
<p>REBOL has no built-in way to perform list comprehensions. However, REBOL has a powerful facility (known as <code>parse</code>) that can be used to create domain-specific languages (DSLs). I've used <code>parse</code> to create such a mini-DSL for list comprehensions. In order to interpret the expression, the block c...
[ { "answer_id": 501616, "author": "igowen", "author_id": 53924, "author_profile": "https://Stackoverflow.com/users/53924", "pm_score": 2, "selected": false, "text": "<p>Because list comprehensions can be thought of as analogous to map, you might think about calling it something like \"lis...
2008/10/15
[ "https://Stackoverflow.com/questions/204040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27779/" ]
REBOL has no built-in way to perform list comprehensions. However, REBOL has a powerful facility (known as `parse`) that can be used to create domain-specific languages (DSLs). I've used `parse` to create such a mini-DSL for list comprehensions. In order to interpret the expression, the block containing the comprehensi...
How about `select`? `select [(a * b) for a in 1x100 for b in 4x10 where (all [odd? a odd? b])]`
204,050
<p>I know a role name and want to find all users in this role. How do I acheive this in SQL Server 2000 (in the SQL script, not in Management Studio or other tool)?</p>
[ { "answer_id": 204105, "author": "Tim", "author_id": 10363, "author_profile": "https://Stackoverflow.com/users/10363", "pm_score": 3, "selected": true, "text": "<p>You can use the following stored procedures:</p>\n\n<p>For fixed server roles, the stored procedure is <a href=\"http://msdn...
2008/10/15
[ "https://Stackoverflow.com/questions/204050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23714/" ]
I know a role name and want to find all users in this role. How do I acheive this in SQL Server 2000 (in the SQL script, not in Management Studio or other tool)?
You can use the following stored procedures: For fixed server roles, the stored procedure is [sp\_helpsrvrolemember](http://msdn.microsoft.com/en-us/library/ms188772.aspx): ``` exec sp_helpsrvrolemember 'role' ``` For general roles, the stored procedure is [sp\_helprolemember](http://msdn.microsoft.com/en-us/librar...
204,075
<p>I know many people who use computers every day, who do not know how to select multiple items in a HTML select box/list. I don't want to use this control in my pages any more:</p> <pre><code>Please pick 3 options: &lt;select name="categories" size="10" multiple="yes"&gt; </code></pre> <p>So what user-friendly alter...
[ { "answer_id": 204088, "author": "Guvante", "author_id": 16800, "author_profile": "https://Stackoverflow.com/users/16800", "pm_score": 3, "selected": true, "text": "<p>You could just use a manual list of items (Say as simple links), that have Javascript onclick behavior that deselects/se...
2008/10/15
[ "https://Stackoverflow.com/questions/204075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11461/" ]
I know many people who use computers every day, who do not know how to select multiple items in a HTML select box/list. I don't want to use this control in my pages any more: ``` Please pick 3 options: <select name="categories" size="10" multiple="yes"> ``` So what user-friendly alternatives do you suggest? Perhaps ...
You could just use a manual list of items (Say as simple links), that have Javascript onclick behavior that deselects/selects manually. Basically by changing the css class between two values, and checking these css (Or some other attribute) during submission to determine the selections. This would allow the user to si...