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
96,133
<p>I have uncovered another problem in the effort that we are making to port several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. See <a href="https://stackoverflow.com/questions/74372/how-to-overcome-an-incompatibility-between-the-ksh-on-linux-vs-that-installed-o">here</a> for the previous problem.</p>...
[ { "answer_id": 96857, "author": "pjz", "author_id": 8002, "author_profile": "https://Stackoverflow.com/users/8002", "pm_score": 0, "selected": false, "text": "<p>You do realize that [ is an alias (often a link, symbolic or hard) for <code>/usr/bin/test</code>, right? So perhaps the actu...
2008/09/18
[ "https://Stackoverflow.com/questions/96133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13029/" ]
I have uncovered another problem in the effort that we are making to port several hundreds of ksh scripts from AIX, Solaris and HPUX to Linux. See [here](https://stackoverflow.com/questions/74372/how-to-overcome-an-incompatibility-between-the-ksh-on-linux-vs-that-installed-o) for the previous problem. This code: ``` ...
Well after one year there seems to be no solution to my problem. I am adding this answer to say that I will have to live with it......
96,150
<p>I have an application that uploads an Excel .xls file to the file system, opens the file with an oledbconnection object using the .open() method on the object instance and then stores the data in a database. The upload and writing of the file to the file system works fine but I get an error when trying to open the ...
[ { "answer_id": 96166, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>Anything in the inner exception? Is this a 64-bit application? The OLEDB providers don't work in 64-bit. You have to have ...
2008/09/18
[ "https://Stackoverflow.com/questions/96150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18164/" ]
I have an application that uploads an Excel .xls file to the file system, opens the file with an oledbconnection object using the .open() method on the object instance and then stores the data in a database. The upload and writing of the file to the file system works fine but I get an error when trying to open the file...
While the permissions issue may be more common you can also encounter this error from Windows file system/Access Jet DB Engine connection limits, 64/255 I think. If you bust the 255 Access read/write concurrent connections or the 64(?) connection limit per process you can get this exact same error. At least I've come a...
96,153
<p>I am trying to figure out how to click a button on a web page programmatically.</p> <p>Specifically, I have a WinForm with a WebBrowser control. Once it navigates to the target ASP.NET login page I'm trying to work with, in the DocumentCompleted event handler I have the following coded:</p> <pre><code>HtmlDocumen...
[ { "answer_id": 96172, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 1, "selected": false, "text": "<p>You can try and invoke the Page_ClientValidate() method directly through the clientscript instead of clicking t...
2008/09/18
[ "https://Stackoverflow.com/questions/96153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16964/" ]
I am trying to figure out how to click a button on a web page programmatically. Specifically, I have a WinForm with a WebBrowser control. Once it navigates to the target ASP.NET login page I'm trying to work with, in the DocumentCompleted event handler I have the following coded: ``` HtmlDocument doc = webBrowser1.Do...
How does this work? Works for me ``` HtmlDocument doc = webBrowser1.Document; doc.All["userIDTextBox"].SetAttribute("Value", "user1"); doc.All["userPasswordTextBox"].SetAttribute("Value", "Password!"); doc.All["logonButton"].InvokeMember("Click"); ```
96,196
<p>The <strong>C</strong> preprocessor is justifiably feared and shunned by the C++ community. In-lined functions, consts and templates are usually a safer and superior alternative to a <code>#define</code>.</p> <p>The following macro: </p> <pre><code>#define SUCCEEDED(hr) ((HRESULT)(hr) &gt;= 0) </code></pre> <p>...
[ { "answer_id": 96230, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 5, "selected": false, "text": "<p>When you want to change the program flow (<code>return</code>, <code>break</code> and <code>continue</code>) code in a funct...
2008/09/18
[ "https://Stackoverflow.com/questions/96196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3848/" ]
The **C** preprocessor is justifiably feared and shunned by the C++ community. In-lined functions, consts and templates are usually a safer and superior alternative to a `#define`. The following macro: ``` #define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) ``` is in no way superior to the type safe: ``` inline bool suc...
As wrappers for debug functions, to automatically pass things like `__FILE__`, `__LINE__`, etc: ``` #ifdef ( DEBUG ) #define M_DebugLog( msg ) std::cout << __FILE__ << ":" << __LINE__ << ": " << msg #else #define M_DebugLog( msg ) #endif ``` Since C++20 the magic type [`std::source_location`](https://en.cppreferenc...
96,249
<p>Adding an element to the head of an alist (Associative list) is simple enough:</p> <pre><code>&gt; (cons '(ding . 53) '((foo . 42) (bar . 27))) ((ding . 53) (foo . 42) (bar . 27)) </code></pre> <p>Appending to the tail of an alist is a bit trickier though. After some experimenting, I produced this:</p> <pre><code...
[ { "answer_id": 96477, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>You don't append to an a-list. You cons onto an a-list.</p>\n\n<p>An a-list is logically a set of associations. You don't c...
2008/09/18
[ "https://Stackoverflow.com/questions/96249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18180/" ]
Adding an element to the head of an alist (Associative list) is simple enough: ``` > (cons '(ding . 53) '((foo . 42) (bar . 27))) ((ding . 53) (foo . 42) (bar . 27)) ``` Appending to the tail of an alist is a bit trickier though. After some experimenting, I produced this: ``` > (define (alist-append alist pair) `(,...
You don't append to an a-list. You cons onto an a-list. An a-list is logically a set of associations. You don't care about the order of elements in a set. All you care about is presence or absence of a particular element. In the case of an a-list, all you care about is whether there exists an association for a given t...
96,250
<p>My project has both client and server components in the same solution file. I usually have the debugger set to start them together when debugging, but it's often the case where I start the server up outside of the debugger so I can start and stop the client as needed when working on client-side only stuff. (this is...
[ { "answer_id": 96478, "author": "Jason Diller", "author_id": 2187, "author_profile": "https://Stackoverflow.com/users/2187", "pm_score": 4, "selected": true, "text": "<p>Ok. This appears to work from most UI (all?) contexts provided the solution is loaded: </p>\n\n<pre><code> Sub DebugTh...
2008/09/18
[ "https://Stackoverflow.com/questions/96250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187/" ]
My project has both client and server components in the same solution file. I usually have the debugger set to start them together when debugging, but it's often the case where I start the server up outside of the debugger so I can start and stop the client as needed when working on client-side only stuff. (this is muc...
Ok. This appears to work from most UI (all?) contexts provided the solution is loaded: ``` Sub DebugTheServer() DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate() DTE.ActiveWindow.Object.GetItem("Solution\ServerFolder\ServerProject").Select(vsUISelectionType.vsUISelectionTypeSelect) DTE....
96,264
<p>I have two code bases of an application. I need to copy all the files in all the directories with .java from the newer code base, to the older (so I can commit it to svn).</p> <p>How can I write a batch files to do this?</p>
[ { "answer_id": 96270, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 4, "selected": true, "text": "<p>XCOPY /D ?</p>\n\n<pre><code>xcopy c:\\olddir\\*.java c:\\newdir /D /E /Q /Y\n</code></pre>\n" }, { "answer_id": 96...
2008/09/18
[ "https://Stackoverflow.com/questions/96264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
I have two code bases of an application. I need to copy all the files in all the directories with .java from the newer code base, to the older (so I can commit it to svn). How can I write a batch files to do this?
XCOPY /D ? ``` xcopy c:\olddir\*.java c:\newdir /D /E /Q /Y ```
96,265
<p>I am programming a game on the iPhone. I am currently using NSTimer to trigger my game update/render. The problem with this is that (after profiling) I appear to lose a lot of time between updates/renders and this seems to be mostly to do with the time interval that I plug into NSTimer. </p> <p>So my question is...
[ { "answer_id": 224791, "author": "Galghamon", "author_id": 26511, "author_profile": "https://Stackoverflow.com/users/26511", "pm_score": 2, "selected": false, "text": "<p>I don't know about the iPhone in particular, but I may still be able to help:\nInstead of simply plugging in a fixed ...
2008/09/18
[ "https://Stackoverflow.com/questions/96265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25868/" ]
I am programming a game on the iPhone. I am currently using NSTimer to trigger my game update/render. The problem with this is that (after profiling) I appear to lose a lot of time between updates/renders and this seems to be mostly to do with the time interval that I plug into NSTimer. So my question is what is the ...
You can get a better performance with threads, try something like this: ``` - (void) gameLoop { while (running) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self renderFrame]; [pool release]; } } - (void) startLoop { running = YES; #ifdef THREADED_ANIMATION ...
96,285
<p>I'm fresh out of college and have been working in C++ for some time now. I understand all the basics of C++ and use them, but I'm having a hard time grasping more advanced topics like pointers and classes. I've read some books and tutorials and I understand the examples in them, but then when I look at some advanc...
[ { "answer_id": 96310, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 0, "selected": false, "text": "<p>Pretend a pointer is an array address.</p>\n\n<pre><code>x = 500; // memory address for hello;\nMEMORY[x] = \"hello...
2008/09/18
[ "https://Stackoverflow.com/questions/96285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117494/" ]
I'm fresh out of college and have been working in C++ for some time now. I understand all the basics of C++ and use them, but I'm having a hard time grasping more advanced topics like pointers and classes. I've read some books and tutorials and I understand the examples in them, but then when I look at some advanced re...
Pointers and classes aren't really advanced topics in C++. They are pretty fundamental. For me, pointers solidified when I started drawing boxes with arrows. Draw a box for an int. And int\* is now a separate box with an arrow pointing to the int box. So: ``` int foo = 3; // integer int* bar = &foo; ...
96,297
<h2>General</h2> <ul> <li>Follow the same standards for all tests.</li> <li>Be clear about what each test state is.</li> <li>Be specific about the expected behavior.</li> </ul> <h2>Examples</h2> <p>1) MethodName_StateUnderTest_ExpectedBehavior</p> <pre><code>Public void Sum_NegativeNumberAs1stParam_ExceptionThrown(...
[ { "answer_id": 96344, "author": "Munger", "author_id": 17661, "author_profile": "https://Stackoverflow.com/users/17661", "pm_score": -1, "selected": false, "text": "<p>As long as you follow a single practice, it doesn't really matter. Generally, I write a single unit test for a method th...
2008/09/18
[ "https://Stackoverflow.com/questions/96297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18170/" ]
General ------- * Follow the same standards for all tests. * Be clear about what each test state is. * Be specific about the expected behavior. Examples -------- 1) MethodName\_StateUnderTest\_ExpectedBehavior ``` Public void Sum_NegativeNumberAs1stParam_ExceptionThrown() Public void Sum_NegativeNumberAs2ndParam_...
I am pretty much with you on this one man. The naming conventions you have used are: * Clear about what each test state is. * Specific about the expected behaviour. What more do you need from a test name? Contrary to [Ray's answer](https://stackoverflow.com/questions/96297/naming-conventions-for-unit-tests#96476) I ...
96,313
<p>I've got a couple large checkouts where the .svn folder has become damaged so I'm getting and error, "Cleanup failed to process the following path.." And I can no longer commit or update files in that directory.</p> <p>I'd just delete and do the checkout again but the whole directory is over a gig.</p> <p>Is there...
[ { "answer_id": 96364, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 2, "selected": false, "text": "<p>I've hit this in the past and found no working solution except the \"nuclear option\" (i.e. delete the directory and...
2008/09/18
[ "https://Stackoverflow.com/questions/96313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1430/" ]
I've got a couple large checkouts where the .svn folder has become damaged so I'm getting and error, "Cleanup failed to process the following path.." And I can no longer commit or update files in that directory. I'd just delete and do the checkout again but the whole directory is over a gig. Is there a tool that will...
In case you have changes to the files, and cannot delete them, you can use the Subversion 1.5 feature that allows you to 'checkout with obstructions'. Just delete the .svn directory in this directory and: (you don't need to delete inside directories when using --depth files, thanks Eric) In case the broken directo...
96,326
<p>I need to attach a file with mailx but at the moment I am not having success.</p> <p><strong>Here's my code:</strong></p> <pre><code>subject="Something happened" to="somebody@somewhere.com" body="Attachment Test" attachment=/path/to/somefile.csv uuencode $attachment | mailx -s "$subject" "$to" &lt;&lt; EOF The m...
[ { "answer_id": 96616, "author": "Thomas Kammeyer", "author_id": 4410, "author_profile": "https://Stackoverflow.com/users/4410", "pm_score": 1, "selected": false, "text": "<p>Well, here are the first few problems you've got.</p>\n\n<ol>\n<li><p>You appear to be assuming that a mail client...
2008/09/18
[ "https://Stackoverflow.com/questions/96326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
I need to attach a file with mailx but at the moment I am not having success. **Here's my code:** ``` subject="Something happened" to="somebody@somewhere.com" body="Attachment Test" attachment=/path/to/somefile.csv uuencode $attachment | mailx -s "$subject" "$to" << EOF The message is ready to be sent with the foll...
You have to concat both the text of your message and the uuencoded attachment: ``` $ subject="Something happened" $ to="somebody@somewhere.com" $ body="Attachment Test" $ attachment=/path/to/somefile.csv $ $ cat >msg.txt <<EOF > The message is ready to be sent with the following file or link attachments: > > somefile....
96,340
<p>We have a suite of interlinked .Net 3.5 applications. Some are web sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync m...
[ { "answer_id": 96371, "author": "Kevin Pang", "author_id": 1574, "author_profile": "https://Stackoverflow.com/users/1574", "pm_score": 3, "selected": false, "text": "<p>Visual Studio has a relatively obscure feature that lets you add existing items as links, which should accomplish what ...
2008/09/18
[ "https://Stackoverflow.com/questions/96340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17765/" ]
We have a suite of interlinked .Net 3.5 applications. Some are web sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync manu...
We use file templates such as MyApp.config.template and MyWeb.config.template with NAnt properties for the bits that are different between environments. So the template file might look a bit like this: ``` <MyAppConfig> <DbConnString>${DbConnString}</DbConnString> <WebServiceUri uri="${WebServiceUri}" /> </MyA...
96,360
<p>I am trying to write a servlet that will send a XML file (xml formatted string) to another servlet via a POST. (Non essential xml generating code replaced with "Hello there")</p> <pre><code> StringBuilder sb= new StringBuilder(); sb.append("Hello there"); URL url = new URL("theservlet's URL"); HttpU...
[ { "answer_id": 96393, "author": "Craig B.", "author_id": 10780, "author_profile": "https://Stackoverflow.com/users/10780", "pm_score": 2, "selected": false, "text": "<p>Don't forget to use: </p>\n\n<pre><code>connection.setDoOutput( true)\n</code></pre>\n\n<p>if you intend on sending out...
2008/09/18
[ "https://Stackoverflow.com/questions/96360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27/" ]
I am trying to write a servlet that will send a XML file (xml formatted string) to another servlet via a POST. (Non essential xml generating code replaced with "Hello there") ``` StringBuilder sb= new StringBuilder(); sb.append("Hello there"); URL url = new URL("theservlet's URL"); HttpURLConnection c...
This kind of thing is much easier using a library like [HttpClient](http://hc.apache.org/httpclient-3.x/). There's even a [post XML code example](http://svn.apache.org/viewvc/httpcomponents/oac.hc3x/trunk/src/examples/PostXML.java?view=markup): ``` PostMethod post = new PostMethod(url); RequestEntity entity = new File...
96,377
<p>I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown below: </p> <pre><code>public class NotNullOrEmptyValidationRule : ValidationRule { public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (String.IsNullOrEmpty(valu...
[ { "answer_id": 96432, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 0, "selected": false, "text": "<p>There is a bug in Visual Studio and Expression Blend that causes this problem. What you need to do is make sure that ...
2008/09/18
[ "https://Stackoverflow.com/questions/96377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown below: ``` public class NotNullOrEmptyValidationRule : ValidationRule { public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (String.IsNullOrEmpty(value as String)) ...
i see your binding on the TextBox is set to a path of 'Text' - is that a field on whatever the datacontext of this textbox is? is the textbox actually getting a value put into it? also, if you put a breakpoint in your validation method, is that ever getting fired? you may want to lookup how to log failures in binding ...
96,390
<p>I have a SQL statement that looks like:</p> <pre><code>SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) </code></pre> <p>The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used <code>li...
[ { "answer_id": 96445, "author": "Forgotten Semicolon", "author_id": 1960, "author_profile": "https://Stackoverflow.com/users/1960", "pm_score": 4, "selected": true, "text": "<p>Check <a href=\"http://technet.microsoft.com/en-us/library/aa933232(v=sql.80).aspx\" rel=\"nofollow noreferrer\...
2008/09/18
[ "https://Stackoverflow.com/questions/96390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18196/" ]
I have a SQL statement that looks like: ``` SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '[A-Z][a-z]' OR [Phone] = 'N/A' OR [Phone] LIKE '[0]' ) ``` The part I'm having trouble with is the where statement with the "LIKEs". I've seen SQL statements where authors used `like` statements in the way I'm u...
Check [here](http://technet.microsoft.com/en-us/library/aa933232(v=sql.80).aspx). [] matches a range of characters. I think you want something like this: ``` SELECT [Phone] FROM [Table] WHERE ( [Phone] LIKE '%[A-Z]%' OR [Phone] LIKE '%[a-z]%' OR [Phone] = 'N/A' OR [Phone] LIKE '0' ) ```
96,414
<p>I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works:</p> <pre><code>InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); </code></pre> <p>The next step is this code:</p> <pre><code>HICON hIconLarge, hIconSmall; ICONINFO o...
[ { "answer_id": 96429, "author": "Lee H", "author_id": 18201, "author_profile": "https://Stackoverflow.com/users/18201", "pm_score": 2, "selected": false, "text": "<p>Setting up password-less publickey authentication with ssh would allow you to scp your files to any of your servers very q...
2008/09/18
[ "https://Stackoverflow.com/questions/96414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18192/" ]
I'm experimenting with adding icons to a shell extension. I have this code (sanitized for easy reading), which works: ``` InsertMenu(hmenu, index, MF_POPUP|MF_BYPOSITION, (UINT)hParentMenu, namestring); ``` The next step is this code: ``` HICON hIconLarge, hIconSmall; ICONINFO oIconInfo; ExtractIconEx("c:\\progra~1...
[Capistrano](http://capify.org/) is pretty handy for that. There's a few people using it ([1](http://www.simplisticcomplexity.com/2006/8/16/automated-php-deployment-with-capistrano/), [2](http://www.contentwithstyle.co.uk/Blog/178), [3](http://laurentbois.com/2008/08/05/use-capistrano-in-enterprise-for-php-and-ruby-on-...
96,428
<p>I have this string</p> <pre><code>'john smith~123 Street~Apt 4~New York~NY~12345' </code></pre> <p>Using JavaScript, what is the fastest way to parse this into</p> <pre><code>var name = "john smith"; var street= "123 Street"; //etc... </code></pre>
[ { "answer_id": 96452, "author": "Zach", "author_id": 9128, "author_profile": "https://Stackoverflow.com/users/9128", "pm_score": 11, "selected": true, "text": "<p>With JavaScript’s <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split\" r...
2008/09/18
[ "https://Stackoverflow.com/questions/96428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
I have this string ``` 'john smith~123 Street~Apt 4~New York~NY~12345' ``` Using JavaScript, what is the fastest way to parse this into ``` var name = "john smith"; var street= "123 Street"; //etc... ```
With JavaScript’s [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) function: ``` var input = 'john smith~123 Street~Apt 4~New York~NY~12345'; var fields = input.split('~'); var name = fields[0]; var street = fields[1]; // etc. ```
96,440
<p>I have a Flex application, which loads a SWF from CS3. The loaded SWF contains a text input called "myText". I can see this in the SWFLoader.content with no problems, but I don't know what type I should be treating it as in my Flex App. I thought the flex docs covered this but I can only find how to interact with an...
[ { "answer_id": 96536, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 0, "selected": false, "text": "<p>Flex and Flash SWFs are essentially the same, just built using different tools. I'm not sure if they share the same compone...
2008/09/18
[ "https://Stackoverflow.com/questions/96440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
I have a Flex application, which loads a SWF from CS3. The loaded SWF contains a text input called "myText". I can see this in the SWFLoader.content with no problems, but I don't know what type I should be treating it as in my Flex App. I thought the flex docs covered this but I can only find how to interact with anoth...
The `fl.*` hierarchy of classes is Flash CS3-only. It's the Flash Components 3 library (I believe it's called, I might be wrong). However, you don't need the class to work with the object. As long as you can get a reference to it in your code, which you seem to have, you can assign the reference to an untyped variable ...
96,448
<p>I need to import a large CSV file into an SQL server. I'm using this :</p> <pre><code>BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO </code></pre> <p>problem is all my fields are surrounded by quotes ("...
[ { "answer_id": 96474, "author": "K Richard", "author_id": 16771, "author_profile": "https://Stackoverflow.com/users/16771", "pm_score": 4, "selected": false, "text": "<p>Try <code>FIELDTERMINATOR='\",\"'</code></p>\n\n<p>Here is a great link to help with the first and last quote...look h...
2008/09/18
[ "https://Stackoverflow.com/questions/96448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
I need to import a large CSV file into an SQL server. I'm using this : ``` BULK INSERT CSVTest FROM 'c:\csvfile.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) GO ``` problem is all my fields are surrounded by quotes (" ") so a row actually looks...
I know this isn't a real solution but I use a dummy table for the import with nvarchar set for everything. Then I do an insert which strips out the " characters and does the conversions. It isn't pretty but it does the job.
96,463
<p>How do you access the response from the Request object in MooTools? I've been looking at the documentation and the MooTorial, but I can't seem to make any headway. Other Ajax stuff I've done with MooTools I haven't had to manipulate the response at all, so I've just been able to inject it straight into the document,...
[ { "answer_id": 96573, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 2, "selected": false, "text": "<p>The response content is returned to the anonymous function defined in onComplete.</p>\n\n<p>It can be accessed from t...
2008/09/18
[ "https://Stackoverflow.com/questions/96463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281/" ]
How do you access the response from the Request object in MooTools? I've been looking at the documentation and the MooTorial, but I can't seem to make any headway. Other Ajax stuff I've done with MooTools I haven't had to manipulate the response at all, so I've just been able to inject it straight into the document, bu...
I was able to find my answer on the [MooTools Group at Google](http://groups.google.com/group/mootools-users/browse_thread/thread/7ade43ef51c91922).
96,500
<p>Suppose I have the following code:</p> <pre><code>class some_class{}; some_class some_function() { return some_class(); } </code></pre> <p>This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever seen this in any kind of ...
[ { "answer_id": 96530, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 5, "selected": true, "text": "<p>No this is perfectly valid. This will also be more efficient as the compiler is actually able to optimise away the...
2008/09/18
[ "https://Stackoverflow.com/questions/96500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
Suppose I have the following code: ``` class some_class{}; some_class some_function() { return some_class(); } ``` This seems to work pretty well and saves me the trouble of having to declare a variable just to make a return value. But I don't think I've ever seen this in any kind of tutorial or reference. Is t...
No this is perfectly valid. This will also be more efficient as the compiler is actually able to optimise away the temporary.
96,541
<p>This isn't legal:</p> <pre><code>public class MyBaseClass { public MyBaseClass() {} public MyBaseClass(object arg) {} } public void ThisIsANoNo&lt;T&gt;() where T : MyBaseClass { T foo = new T("whoops!"); } </code></pre> <p>In order to do this, you have to do some reflection on the type object for T or you...
[ { "answer_id": 96557, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<pre><code>where T : MyBaseClass, new()\n</code></pre>\n\n<p>only works w/ parameterless public constructor. beyond that, bac...
2008/09/18
[ "https://Stackoverflow.com/questions/96541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This isn't legal: ``` public class MyBaseClass { public MyBaseClass() {} public MyBaseClass(object arg) {} } public void ThisIsANoNo<T>() where T : MyBaseClass { T foo = new T("whoops!"); } ``` In order to do this, you have to do some reflection on the type object for T or you have to use Activator.CreateInst...
You can't constrain T to have a particular constructor signature other than an empty constructor, but you can constrain T to have a factory method with the desired signature: ``` public abstract class MyBaseClass { protected MyBaseClass() {} protected abstract MyBaseClass CreateFromObject(object arg); } publi...
96,553
<p>Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses?</p> <p>For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate:</p> <pre><code>SELECT * FRO...
[ { "answer_id": 96572, "author": "Oskar", "author_id": 5472, "author_profile": "https://Stackoverflow.com/users/5472", "pm_score": 0, "selected": false, "text": "<p>Most databases support stored procedures to avoid this issue. If your code is fast enough to execute and easy to read, you d...
2008/09/18
[ "https://Stackoverflow.com/questions/96553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18210/" ]
Is it particularly bad to have a very, very large SQL query with lots of (potentially redundant) WHERE clauses? For example, here's a query I've generated from my web application with everything turned off, which should be the largest possible query for this program to generate: ``` SELECT * FROM 4e_magic_items INN...
Reading your query makes me want to play an RPG. This is definitely not too long. As long as they are well formatted, I'd say a practical limit is about 100 lines. After that, you're better off breaking subqueries into views just to keep your eyes from crossing. I've worked with some queries that are 1000+ lines, and...
96,579
<p>I'm writing an inner loop that needs to place <code>struct</code>s in contiguous storage. I don't know how many of these <code>struct</code>s there will be ahead of time. My problem is that STL's <code>vector</code> initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus th...
[ { "answer_id": 96601, "author": "nsanders", "author_id": 1244, "author_profile": "https://Stackoverflow.com/users/1244", "pm_score": 1, "selected": false, "text": "<p>Use the std::vector::reserve() method. It won't resize the vector, but it will allocate the space.</p>\n" }, { "...
2008/09/18
[ "https://Stackoverflow.com/questions/96579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6160/" ]
I'm writing an inner loop that needs to place `struct`s in contiguous storage. I don't know how many of these `struct`s there will be ahead of time. My problem is that STL's `vector` initializes its values to 0, so no matter what I do, I incur the cost of the initialization plus the cost of setting the `struct`'s membe...
`std::vector` must initialize the values in the array somehow, which means some constructor (or copy-constructor) must be called. The behavior of `vector` (or any container class) is undefined if you were to access the uninitialized section of the array as if it were initialized. The best way is to use `reserve()` and...
96,597
<p>My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on <a href="http://wiki.centos.org/AdditionalResources/Repositories/RPMF...
[ { "answer_id": 96662, "author": "Peter Stone", "author_id": 1806, "author_profile": "https://Stackoverflow.com/users/1806", "pm_score": 1, "selected": false, "text": "<p>If you install <a href=\"http://wiki.centos.org/AdditionalResources/Repositories/RPMForge\" rel=\"nofollow noreferrer\...
2008/09/18
[ "https://Stackoverflow.com/questions/96597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5570/" ]
My development server (CentOS 5) is running Subversion 1.4.2, and I wish to upgrade it to 1.5. I have read in various blogs and documents scattered around the web that this may be done by using RPMForge. I have followed the instructions found on [CentOS Wiki](http://wiki.centos.org/AdditionalResources/Repositories/RPMF...
What you are trying to do is to replace a "core" package (one which is contained in the CentOS repository) with a newer package from a "3rd party" repository (RPMForge), which is what the priorities plugin is designed to prevent. The RPMForge repository contains both additional packages not found in CentOS, as well as...
96,615
<p>So if I'm using branches that are remote (tracked) branches, and I want to get the lastest, I'm still unclear if I should be doing <code>git pull</code> or <code>git rebase</code>. I thought I had read that doing <code>git rebase</code> when working on a branch with other users, it can screw them up when they pull o...
[ { "answer_id": 96666, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p><code>git pull</code> does a merge if you've got commits that aren't in the remote branch. <code>git rebase</code> rewr...
2008/09/18
[ "https://Stackoverflow.com/questions/96615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14873/" ]
So if I'm using branches that are remote (tracked) branches, and I want to get the lastest, I'm still unclear if I should be doing `git pull` or `git rebase`. I thought I had read that doing `git rebase` when working on a branch with other users, it can screw them up when they pull or rebase. Is that true? Should we al...
Git pull is a combination of 2 commands * git fetch (syncs your local repo with the newest stuff on the remote) * git merge (merges the changes from the distant branch, if any, into your local tracking branch) git rebase is only a rough equivalent to git merge. It doesn't fetch anything remotely. In fact it doesn't d...
96,618
<p>Let's say I have data structures that're something like this:</p> <pre><code>Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of AttendenceRecord) End Clas...
[ { "answer_id": 96642, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 1, "selected": false, "text": "<p>In pure .Net I don't know of anything. There are <a href=\"http://www.imaputz.com/cssStuff/bigFourVersion.html\" rel=\...
2008/09/18
[ "https://Stackoverflow.com/questions/96618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18224/" ]
Let's say I have data structures that're something like this: ``` Public Class AttendenceRecord Public CourseDate As Date Public StudentsInAttendence As Integer End Class Public Class Course Public Name As String Public CourseID As String Public Attendance As List(Of AttendenceRecord) End Class ``` And I ...
You can get this functionality from the System.Windows.Forms.DataGridView control. When you create columns you can set them to be [frozen](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.frozen.aspx) which will then only scroll those columns to the right of the frozen column(s).
96,624
<p>I have an assembly which should <strong>not</strong> be used by any application other than the designated executable. Please give me some instructions to do so.</p>
[ { "answer_id": 96647, "author": "Charles Graham", "author_id": 7705, "author_profile": "https://Stackoverflow.com/users/7705", "pm_score": 1, "selected": false, "text": "<p>You might be able to set this in the Code Access Security policies on the assembly.</p>\n" }, { "answer_id"...
2008/09/18
[ "https://Stackoverflow.com/questions/96624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18198/" ]
I have an assembly which should **not** be used by any application other than the designated executable. Please give me some instructions to do so.
You can sign the assembly and the executable with the same key and then put a check in the constructor of the classes you want to protect: ``` public class NotForAnyoneElse { public NotForAnyoneElse() { if (typeof(NotForAnyoneElse).Assembly.GetName().GetPublicKeyToken() != Assembly.GetEntryAssembly().GetName().G...
96,661
<p>I have a query that I would like to filter in different ways at different times. The way I have done this right now by placing parameters in the criteria field of the relevant query fields, however there are many cases in which I do not want to filter on a given field but only on the other fields. Is there any way...
[ { "answer_id": 96782, "author": "theo", "author_id": 7870, "author_profile": "https://Stackoverflow.com/users/7870", "pm_score": 0, "selected": false, "text": "<p>I don't think you can. How are you running the query? </p>\n\n<p>I'd say if you need a query that has that many open variable...
2008/09/18
[ "https://Stackoverflow.com/questions/96661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
I have a query that I would like to filter in different ways at different times. The way I have done this right now by placing parameters in the criteria field of the relevant query fields, however there are many cases in which I do not want to filter on a given field but only on the other fields. Is there any way in w...
If you construct your query like so: ``` PARAMETERS ParamA Text ( 255 ); SELECT t.id, t.topic_id FROM SomeTable t WHERE t.id Like IIf(IsNull([ParamA]),"*",[ParamA]) ``` All records will be selected if the parameter is not filled in.
96,671
<p>I have a flash app (SWF) running Flash 8 embedded in an HTML page. How do I get flash to reload the parent HTML page it is embedded in? I've tried using ExternalInterface to call a JavaScript function to reload the page but that doesn't seem to work. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­</p>
[ { "answer_id": 96717, "author": "Alex Fort", "author_id": 12624, "author_profile": "https://Stackoverflow.com/users/12624", "pm_score": 2, "selected": false, "text": "<p>Try something like this:</p>\n\n<p><code>getURL(\"javascript:location.reload(true)\");</code></p>\n" }, { "ans...
2008/09/18
[ "https://Stackoverflow.com/questions/96671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a flash app (SWF) running Flash 8 embedded in an HTML page. How do I get flash to reload the parent HTML page it is embedded in? I've tried using ExternalInterface to call a JavaScript function to reload the page but that doesn't seem to work. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
Check the [ExternalInterface](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html) in Action Script. Using this you can call any JavaScript function in your code: ``` if (ExternalInterface.available) { var result = ExternalInterface.call("reload"); } ``` In the E...
96,718
<p>How do you organize your Extension Methods? Say if I had extensions for the object class and string class I'm tempted to separate these extension methods into classes IE:</p> <pre><code>public class ObjectExtensions { ... } public class StringExtensions { ... } </code></pre> <p>am I making this too compli...
[ { "answer_id": 96771, "author": "Geir-Tore Lindsve", "author_id": 4582, "author_profile": "https://Stackoverflow.com/users/4582", "pm_score": 2, "selected": false, "text": "<p>There are two ways that I organize the extension methods which I use,</p>\n\n<p>1) If the extension is specific ...
2008/09/18
[ "https://Stackoverflow.com/questions/96718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1980/" ]
How do you organize your Extension Methods? Say if I had extensions for the object class and string class I'm tempted to separate these extension methods into classes IE: ``` public class ObjectExtensions { ... } public class StringExtensions { ... } ``` am I making this too complicated or does this make se...
I organize extension methods using a combination of namespace and class name, and it's similar to the way you describe in the question. Generally I have some sort of "primary assembly" in my solution that provides the majority of the shared functionality (like extension methods). We'll call this assembly "Framework" f...
96,732
<p>I've got a situation where I have a DLL I'm creating that uses another third party DLL, but I would prefer to be able to build the third party DLL into my DLL instead of having to keep them both together if possible.</p> <p>This with is C# and .NET 3.5.</p> <p>The way I would like to do this is by storing the thir...
[ { "answer_id": 96791, "author": "Fostah", "author_id": 16524, "author_profile": "https://Stackoverflow.com/users/16524", "pm_score": 4, "selected": false, "text": "<p>There's a tool called IlMerge that can accomplish this: <a href=\"http://research.microsoft.com/~mbarnett/ILMerge.aspx\" ...
2008/09/18
[ "https://Stackoverflow.com/questions/96732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I've got a situation where I have a DLL I'm creating that uses another third party DLL, but I would prefer to be able to build the third party DLL into my DLL instead of having to keep them both together if possible. This with is C# and .NET 3.5. The way I would like to do this is by storing the third party DLL as an...
Once you've embedded the third-party assembly as a resource, add code to subscribe to the [`AppDomain.AssemblyResolve`](http://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx) event of the current domain during application start-up. This event fires whenever the Fusion sub-system of the CLR fails...
96,759
<p>I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file.</p> <pre><code>function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); wh...
[ { "answer_id": 96812, "author": "Jan Hančič", "author_id": 185527, "author_profile": "https://Stackoverflow.com/users/185527", "pm_score": 0, "selected": false, "text": "<p>The \"Usort\" function is your answer.<br>\n<a href=\"http://php.net/usort\" rel=\"nofollow noreferrer\">http://php...
2008/09/18
[ "https://Stackoverflow.com/questions/96759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1536217/" ]
I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. ``` function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); while ($line = fg...
You can use [array\_multisort()](http://php.net/manual/en/function.array-multisort.php) Try something like this: ``` foreach ($mdarray as $key => $row) { // replace 0 with the field's index/key $dates[$key] = $row[0]; } array_multisort($dates, SORT_DESC, $mdarray); ``` For PHP >= 5.5.0 just extract the co...
96,826
<p>Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with <code>"abc "</code> directly followed by anything other than <code>"defg"</code>. </p> <p>I've used <code>"[^defg]"</code> to match any single character other than d, e, f or g.</p> <p>My first instinct was to try <code>/ab...
[ { "answer_id": 96946, "author": "Lee H", "author_id": 18201, "author_profile": "https://Stackoverflow.com/users/18201", "pm_score": 1, "selected": false, "text": "<p>Here we go, this is a hairy one:</p>\n\n<pre><code>/\\%(\\%(.\\{-}\\)\\@&lt;=XXXXXX\\zs\\)*\n</code></pre>\n\n<p>(replace ...
2008/09/18
[ "https://Stackoverflow.com/questions/96826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5379/" ]
Pretty basic question, I'm trying to write a regex in Vim to match any phrase starting with `"abc "` directly followed by anything other than `"defg"`. I've used `"[^defg]"` to match any single character other than d, e, f or g. My first instinct was to try `/abc [^\(defg\)]` or `/abc [^\<defg\>]` but neither one of...
Here's the search string. ``` /abc \(defg\)\@! ``` The concept you're looking for is called a negative look-ahead assertion. Try this in vim for more info: ``` :help \@! ```
96,837
<p>This is a good candidate for the <a href="http://www.codinghorror.com/blog/archives/000818.html" rel="nofollow noreferrer">"Works on My Machine Certification Program"</a>.</p> <p>I have the following code for a LinkButton...</p> <pre><code>&lt;cc1:PopupDialog ID="pdFamilyPrompt" runat="server" CloseLink="false" Di...
[ { "answer_id": 96881, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 2, "selected": true, "text": "<p>Check the html that is emitted on production and make sure that it has the __doPostback() and that there are no ...
2008/09/18
[ "https://Stackoverflow.com/questions/96837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4624/" ]
This is a good candidate for the ["Works on My Machine Certification Program"](http://www.codinghorror.com/blog/archives/000818.html). I have the following code for a LinkButton... ``` <cc1:PopupDialog ID="pdFamilyPrompt" runat="server" CloseLink="false" Display="true"> <p>Do you wish to upgrade?</p> <asp:HyperLi...
Check the html that is emitted on production and make sure that it has the \_\_doPostback() and that there are no global methods watching click and canceling the event. Other than that if you think it could be related to validation you could try adding CausesValidation or whatever to false and see if that helps. Otherw...
96,848
<p>Is there any way to use a constant as a hash key?</p> <p>For example:</p> <pre><code>use constant X =&gt; 1; my %x = (X =&gt; 'X'); </code></pre> <p>The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.</p>
[ { "answer_id": 96869, "author": "nohat", "author_id": 3101, "author_profile": "https://Stackoverflow.com/users/3101", "pm_score": 7, "selected": true, "text": "<p><code>use constant</code> actually makes constant subroutines.</p>\n\n<p>To do what you want, you need to explicitly call the...
2008/09/18
[ "https://Stackoverflow.com/questions/96848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4406/" ]
Is there any way to use a constant as a hash key? For example: ``` use constant X => 1; my %x = (X => 'X'); ``` The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.
`use constant` actually makes constant subroutines. To do what you want, you need to explicitly call the sub: ``` use constant X => 1; my %x = ( &X => 'X'); ``` or ``` use constant X => 1; my %x = ( X() => 'X'); ```
96,871
<p>I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs. </p> <p>I'd really like to avoid having to hand-generate all ...
[ { "answer_id": 96907, "author": "Hallgrim", "author_id": 15454, "author_profile": "https://Stackoverflow.com/users/15454", "pm_score": 2, "selected": true, "text": "<pre><code>Bitmap image1 = ...\nBitmap image2 = ...\n\nBitmap combined = new Bitmap(image1.Width, image1.Height);\nusing (G...
2008/09/18
[ "https://Stackoverflow.com/questions/96871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5062/" ]
I'd like to make status icons for a C# WinForms TreeList control. The statuses are combinations of other statuses (eg. a user node might be inactive or banned or inactive and banned), and the status icon is comprised of non-overlapping, smaller glyphs. I'd really like to avoid having to hand-generate all the possibly...
``` Bitmap image1 = ... Bitmap image2 = ... Bitmap combined = new Bitmap(image1.Width, image1.Height); using (Graphics g = Graphics.FromImage(combined)) { g.DrawImage(image1, new Point(0, 0)); g.DrawImage(image2, new Point(0, 0); } imageList.Add(combined); ```
96,882
<p>I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image.</p> <p>I need to do this programmatically in a script, to be integrated in an existing build system (more of a pack system really, since it only create installers. The bu...
[ { "answer_id": 97025, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 5, "selected": false, "text": "<p>Don't go there. As a long term Mac developer, I can assure you, no solution is really working well. I tried so many soluti...
2008/09/18
[ "https://Stackoverflow.com/questions/96882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16909/" ]
I need to create a nice installer for a Mac application. I want it to be a disk image (DMG), with a predefined size, layout and background image. I need to do this programmatically in a script, to be integrated in an existing build system (more of a pack system really, since it only create installers. The builds are d...
After lots of research, I've come up with this answer, and I'm hereby putting it here as an answer for my own question, for reference: 1. Make sure that "Enable access for assistive devices" is checked in System Preferences>>Universal Access. It is required for the AppleScript to work. You may have to reboot after thi...
96,922
<p>The standard answer is that it's useful when you only need to write a few lines of code ...</p> <p>I have both languages integrated inside of Eclipse. Because Eclipse handles the compiling, interpreting, running etc. both "run" exactly the same.</p> <p>The Eclipse IDE for both is similar - instant "compilation", i...
[ { "answer_id": 96934, "author": "Lucas S.", "author_id": 7363, "author_profile": "https://Stackoverflow.com/users/7363", "pm_score": 0, "selected": false, "text": "<p>Syntax sugar.</p>\n" }, { "answer_id": 96935, "author": "Ben Hoffstein", "author_id": 4482, "author_p...
2008/09/18
[ "https://Stackoverflow.com/questions/96922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9922/" ]
The standard answer is that it's useful when you only need to write a few lines of code ... I have both languages integrated inside of Eclipse. Because Eclipse handles the compiling, interpreting, running etc. both "run" exactly the same. The Eclipse IDE for both is similar - instant "compilation", intellisense etc. ...
A quick example (from <http://coreygoldberg.blogspot.com/2008/09/python-vs-java-http-get-request.html>) : You have a back end in Java, and you need to perform HTTP GET resquests. Natively : ``` import java.net.*; import java.io.*; public class JGet { public static void main (String[] args) throws IOException {...
96,923
<p>What's the name of the circled UI element here? And how do I access it using keyboard shortcuts? Sometimes it's nearly impossible to get the mouse to focus on it.</p> <pre><code>catch (ItemNotFoundException e) { } </code></pre>
[ { "answer_id": 96937, "author": "Chris Shaffer", "author_id": 6744, "author_profile": "https://Stackoverflow.com/users/6744", "pm_score": 4, "selected": true, "text": "<p>I don't know the name, but the shortcuts are CTRL-period (.) and ALT-SHIFT-F10. Handy to know :)</p>\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/96923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15050/" ]
What's the name of the circled UI element here? And how do I access it using keyboard shortcuts? Sometimes it's nearly impossible to get the mouse to focus on it. ``` catch (ItemNotFoundException e) { } ```
I don't know the name, but the shortcuts are CTRL-period (.) and ALT-SHIFT-F10. Handy to know :)
96,945
<p>I am using Oracle 9 and JDBC and would like to encyrpt a clob as it is inserted into the DB. Ideally I'd like to be able to just insert the plaintext and have it encrypted by a stored procedure:</p> <pre><code>String SQL = "INSERT INTO table (ID, VALUE) values (?, encrypt(?))"; PreparedStatement ps = connection.pr...
[ { "answer_id": 97469, "author": "borjab", "author_id": 16206, "author_profile": "https://Stackoverflow.com/users/16206", "pm_score": 2, "selected": false, "text": "<p>There is an example in Oracle Documentation:</p>\n\n<p><a href=\"http://download.oracle.com/docs/cd/B10501_01/appdev.920/...
2008/09/18
[ "https://Stackoverflow.com/questions/96945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7867/" ]
I am using Oracle 9 and JDBC and would like to encyrpt a clob as it is inserted into the DB. Ideally I'd like to be able to just insert the plaintext and have it encrypted by a stored procedure: ``` String SQL = "INSERT INTO table (ID, VALUE) values (?, encrypt(?))"; PreparedStatement ps = connection.prepareStatement(...
I note you are on Oracle 9, but just for the record in Oracle 10g+ the dbms\_obfuscation\_toolkit was deprecated in favour of dbms\_crypto. [dbms\_crypto](http://68.142.116.68/docs/cd/B28359_01/appdev.111/b28419/d_crypto.htm#i1005082) does include CLOB support: ``` DBMS_CRYPTO.ENCRYPT( dst IN OUT NOCOPY BLOB, s...
96,952
<p>What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field? </p> <p>Field with value "00345ABC" would need to return "345ABC".</p>
[ { "answer_id": 96971, "author": "Chris Bartow", "author_id": 497, "author_profile": "https://Stackoverflow.com/users/497", "pm_score": 8, "selected": true, "text": "<p>You are looking for the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim\" rel=\"nor...
2008/09/18
[ "https://Stackoverflow.com/questions/96952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5446/" ]
What mysql functions are there (if any) to trim leading zeros from an alphanumeric text field? Field with value "00345ABC" would need to return "345ABC".
You are looking for the [trim() function](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_trim). Alright, here is your example ``` SELECT TRIM(LEADING '0' FROM myfield) FROM table ```
97,013
<p>Does anyone know is there a way to open a project in Eclipse in read-only mode? If there is a lot of similar projects open it is easy to make changes to a wrong one.</p>
[ { "answer_id": 97047, "author": "Martin OConnor", "author_id": 18233, "author_profile": "https://Stackoverflow.com/users/18233", "pm_score": 2, "selected": false, "text": "<p>One sub-optimal solution is to make the project directory read-only in the file system in the underlying OS. I'm ...
2008/09/18
[ "https://Stackoverflow.com/questions/97013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128/" ]
Does anyone know is there a way to open a project in Eclipse in read-only mode? If there is a lot of similar projects open it is easy to make changes to a wrong one.
Putting project in read-only mode is really useful, when you make another instance from the previous project. So you copy all files from old project, then make changes in the new instance. It's really simple to edit files from old project by mistake (they have the same names)! Serg if you use linux, I suggest to put a...
97,050
<p>Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act based on whether or not the iterator indicates ...
[ { "answer_id": 97076, "author": "gbjbaanb", "author_id": 13744, "author_profile": "https://Stackoverflow.com/users/13744", "pm_score": 3, "selected": false, "text": "<p>There will be barely any difference in speed between the 2, find will return an iterator, insert does the same and will...
2008/09/18
[ "https://Stackoverflow.com/questions/97050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16496/" ]
Assuming a map where you want to preserve existing entries. 20% of the time, the entry you are inserting is new data. Is there an advantage to doing std::map::find then std::map::insert using that returned iterator? Or is it quicker to attempt the insert and then act based on whether or not the iterator indicates the r...
The answer is you do neither. Instead you want to do something suggested by Item 24 of [Effective STL](https://rads.stackoverflow.com/amzn/click/com/0201749629) by [Scott Meyers](http://www.aristeia.com/): ``` typedef map<int, int> MapType; // Your map type may vary, just change the typedef MapType mymap; // Add e...
97,081
<p>Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by <em>pros</em> and <em>cons</em> coming from everyone.</p> <p>So, in case you have a class property you want to expose via two getters, one read/write, and the other, readonly (i.e. there ...
[ { "answer_id": 97117, "author": "William Keller", "author_id": 17095, "author_profile": "https://Stackoverflow.com/users/17095", "pm_score": 0, "selected": false, "text": "<p>While it appears your question only addresses one method, I'd be happy to give my input on style. Personally, for...
2008/09/18
[ "https://Stackoverflow.com/questions/97081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14089/" ]
Someone told me about a C++ style difference in their team. I have my own viewpoint on the subject, but I would be interested by *pros* and *cons* coming from everyone. So, in case you have a class property you want to expose via two getters, one read/write, and the other, readonly (i.e. there is no set method). There...
Well, for one thing, getAsConst *must* be called when the 'this' pointer is const -- not when you want to receive a const object. So, alongside any other issues, it's subtly misnamed. (You can still call it when 'this' is non-const, but that's neither here nor there.) Ignoring that, getAsConst earns you nothing, and p...
97,092
<p>What I am trying to achieve is a form that has a button on it that causes the Form to 'drop-down' and become larger, displaying more information. My current attempt is this:</p> <pre><code>private void btnExpand_Click(object sender, EventArgs e) { if (btnExpand.Text == "&gt;") { btnExpand.Text = "&l...
[ { "answer_id": 97689, "author": "Joel Lucsy", "author_id": 645, "author_profile": "https://Stackoverflow.com/users/645", "pm_score": 2, "selected": true, "text": "<p>As per the docs, use 0 to denote no maximum or minimum size. Tho, I just tried it and it didn't like 0 at all. So I used i...
2008/09/18
[ "https://Stackoverflow.com/questions/97092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
What I am trying to achieve is a form that has a button on it that causes the Form to 'drop-down' and become larger, displaying more information. My current attempt is this: ``` private void btnExpand_Click(object sender, EventArgs e) { if (btnExpand.Text == ">") { btnExpand.Text = "<"; _expand...
As per the docs, use 0 to denote no maximum or minimum size. Tho, I just tried it and it didn't like 0 at all. So I used int.MaxValue like you did and it worked. What version of the the framework you using?
97,097
<p>What is the C# version of VB.net's InputBox?</p>
[ { "answer_id": 97119, "author": "MADMap", "author_id": 17558, "author_profile": "https://Stackoverflow.com/users/17558", "pm_score": -1, "selected": false, "text": "<p>There is no such thing: I recommend to write it for yourself and use it whenever you need.</p>\n" }, { "answer_i...
2008/09/18
[ "https://Stackoverflow.com/questions/97097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
What is the C# version of VB.net's InputBox?
Add a reference to `Microsoft.VisualBasic`, `InputBox` is in the `Microsoft.VisualBasic.Interaction` namespace: ``` using Microsoft.VisualBasic; string input = Interaction.InputBox("Prompt", "Title", "Default", x_coordinate, y_coordinate); ``` Only the first argument for `prompt` is mandatory
97,113
<p>I have the following string:</p> <pre><code>cn=abcd,cn=groups,dc=domain,dc=com </code></pre> <p>Can a regular expression be used here to extract the string after the first <code>cn=</code> and before the first <code>,</code>? In the example above the answer should be <code>abcd</code>. </p>
[ { "answer_id": 97125, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 0, "selected": false, "text": "<p>Yeah, using perl/java syntax <code>cn=([^,]*),</code>. You'd then get the 1st group.</p>\n" }, { "answer_id": 9712...
2008/09/18
[ "https://Stackoverflow.com/questions/97113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17273/" ]
I have the following string: ``` cn=abcd,cn=groups,dc=domain,dc=com ``` Can a regular expression be used here to extract the string after the first `cn=` and before the first `,`? In the example above the answer should be `abcd`.
``` /cn=([^,]+),/ ``` most languages will extract the match as $1 or matches[1] If you can't for some reason wield subscripts, ``` $x =~ s/^cn=// $x =~ s/,.*$// ``` Thats a way to do it in 2 steps. If you were parsing it out of a log with sed ``` sed -n -r '/cn=/s/^cn=([^,]+),.*$/\1/p' < logfile > dumpf...
97,114
<p>In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but <a href="https://stackoverflow.com/questions/43711/whats-a-good-way-to-overwrite-datetimenow-during-testing#43718">one answer</a> suggested using conditional compilation, retaining static binding in the pr...
[ { "answer_id": 97174, "author": "plyawn", "author_id": 5964, "author_profile": "https://Stackoverflow.com/users/5964", "pm_score": 2, "selected": false, "text": "<p>I think it lessens the clarity for people reviewing the code. You shouldn't have to remember that there's a conditional tag...
2008/09/18
[ "https://Stackoverflow.com/questions/97114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14153/" ]
In a recent question on stubbing, many answers suggested C# interfaces or delegates for implementing stubs, but [one answer](https://stackoverflow.com/questions/43711/whats-a-good-way-to-overwrite-datetimenow-during-testing#43718) suggested using conditional compilation, retaining static binding in the production code....
Try to keep production code separate from test code. Maintain different folder hierarchies.. different solutions/projects. **Unless**.. you're in the world of legacy C++ Code. Here anything goes.. if conditional blocks help you get some of the code testable and you see a benefit.. By all means do it. But try to not l...
97,173
<p>I'm using freemarker, SiteMesh and Spring framework. For the pages I use ${requestContext.getMessage()} to get the message from message.properties. But for the decorators this doesn't work. How should I do to get the internationalization working for sitemesh?</p>
[ { "answer_id": 105142, "author": "mathd", "author_id": 16309, "author_profile": "https://Stackoverflow.com/users/16309", "pm_score": 2, "selected": false, "text": "<p>You have to use the <strong><em>fmt</em></strong> taglib.</p>\n\n<p>First, add the taglib for sitemesh and fmt on the fis...
2008/09/18
[ "https://Stackoverflow.com/questions/97173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8041/" ]
I'm using freemarker, SiteMesh and Spring framework. For the pages I use ${requestContext.getMessage()} to get the message from message.properties. But for the decorators this doesn't work. How should I do to get the internationalization working for sitemesh?
You have to use the ***fmt*** taglib. First, add the taglib for sitemesh and fmt on the fisrt line of the decorator. ``` <%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%> <%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page"%> <%@ taglib prefix="c" uri="http://jav...
97,193
<p>Is there a way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself?</p> <p>For example, something along these lines</p> <pre><code>class A { public void DoSomething() { StaticClass.Ex...
[ { "answer_id": 97267, "author": "Jason Punyon", "author_id": 6212, "author_profile": "https://Stackoverflow.com/users/6212", "pm_score": 1, "selected": false, "text": "<p>Just have ExecuteMethod take an object. Then you have the instance no matter what.</p>\n" }, { "answer_id": 9...
2008/09/18
[ "https://Stackoverflow.com/questions/97193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4299/" ]
Is there a way via System.Reflection, System.Diagnostics or other to get a reference to the actual instance that is calling a static method without passing it in to the method itself? For example, something along these lines ``` class A { public void DoSomething() { StaticClass.ExecuteMethod(); } ...
I do not believe you can. Even the StackTrace and StackFrame classes just give you naming information, not access to instances. I'm not sure exactly why you'd want to do this, but know that even if you could do it it would likely be very slow. A better solution would be to push the instance to a thread local context...
97,197
<p>The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object world.</p> <p>Does anybody have a more detailed explanation of the probl...
[ { "answer_id": 97223, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 5, "selected": false, "text": "<p>Suppose you have COMPANY and EMPLOYEE. COMPANY has many EMPLOYEES (i.e. EMPLOYEE has a field COMPANY_ID).</p>\n\n<p>I...
2008/09/18
[ "https://Stackoverflow.com/questions/97197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6120/" ]
The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object world. Does anybody have a more detailed explanation of the problem?
Let's say you have a collection of `Car` objects (database rows), and each `Car` has a collection of `Wheel` objects (also rows). In other words, `Car` → `Wheel` is a 1-to-many relationship. Now, let's say you need to iterate through all the cars, and for each one, print out a list of the wheels. The naive O/R impleme...
97,228
<p>Ok, here's the breakdown of my project: I have a web project with a "Scripts" subfolder. That folder contains a few javascript files and a copy of JSMin.exe along with a batch file that runs the JSMin.exe on a few of the files. I tried to set up a post build step of 'call "$(ProjectDir)Scripts\jsmin.bat"'. When ...
[ { "answer_id": 97284, "author": "Hallgrim", "author_id": 15454, "author_profile": "https://Stackoverflow.com/users/15454", "pm_score": 3, "selected": true, "text": "<p>If you have something in your custom build step that returns an error code, you can add:</p>\n\n<pre><code>exit 0\n</cod...
2008/09/18
[ "https://Stackoverflow.com/questions/97228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16149/" ]
Ok, here's the breakdown of my project: I have a web project with a "Scripts" subfolder. That folder contains a few javascript files and a copy of JSMin.exe along with a batch file that runs the JSMin.exe on a few of the files. I tried to set up a post build step of 'call "$(ProjectDir)Scripts\jsmin.bat"'. When I perfo...
If you have something in your custom build step that returns an error code, you can add: ``` exit 0 ``` as the last line of your build step. This will stop the build from failing.
97,276
<p>If I've got a time_t value from <code>gettimeofday()</code> or compatible in a Unix environment (e.g., Linux, BSD), is there a compact algorithm available that would be able to tell me the corresponding week number within the month?</p> <p>Ideally the return value would work in similar to the way <code>%W</code> be...
[ { "answer_id": 97377, "author": "Branan", "author_id": 13894, "author_profile": "https://Stackoverflow.com/users/13894", "pm_score": 1, "selected": false, "text": "<p>Assuming your first week is week 1:</p>\n\n<pre><code>int getWeekOfMonth()\n{\n time_t my_time;\n struct tm *ts;\n\n m...
2008/09/18
[ "https://Stackoverflow.com/questions/97276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I've got a time\_t value from `gettimeofday()` or compatible in a Unix environment (e.g., Linux, BSD), is there a compact algorithm available that would be able to tell me the corresponding week number within the month? Ideally the return value would work in similar to the way `%W` behaves in `strftime()` , except ...
Assuming your first week is week 1: ``` int getWeekOfMonth() { time_t my_time; struct tm *ts; my_time = time(NULL); ts = localtime(&my_time); return ((ts->tm_mday -1) / 7) + 1; } ``` For 0-index, drop the `+1` in the return statement.
97,283
<p>For example if the user is currently running VS2008 then I want the value VS2008.</p>
[ { "answer_id": 97517, "author": "Ozgur Ozcitak", "author_id": 976, "author_profile": "https://Stackoverflow.com/users/976", "pm_score": 5, "selected": true, "text": "<p>I am assuming you want to get the name of the process owning the currently focused window. With some P/Invoke:</p>\n\n<...
2008/09/18
[ "https://Stackoverflow.com/questions/97283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44972/" ]
For example if the user is currently running VS2008 then I want the value VS2008.
I am assuming you want to get the name of the process owning the currently focused window. With some P/Invoke: ``` // The GetForegroundWindow function returns a handle to the foreground window // (the window with which the user is currently working). [System.Runtime.InteropServices.DllImport("user32.dll")] private st...
97,312
<p>How do I find out what directory my console app is running in with C#?</p>
[ { "answer_id": 97330, "author": "Jakub Kotrla", "author_id": 16943, "author_profile": "https://Stackoverflow.com/users/16943", "pm_score": 1, "selected": false, "text": "<p>On windows (not sure about Unix etc.) it is the first argument in commandline.</p>\n\n<p>In C/C++ firts item in arg...
2008/09/18
[ "https://Stackoverflow.com/questions/97312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
How do I find out what directory my console app is running in with C#?
To get the directory where the .exe file is: ``` AppDomain.CurrentDomain.BaseDirectory ``` To get the current directory: ``` Environment.CurrentDirectory ```
97,324
<p>I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot about faults and except...
[ { "answer_id": 97676, "author": "Brennan", "author_id": 10366, "author_profile": "https://Stackoverflow.com/users/10366", "pm_score": 3, "selected": true, "text": "<p>If you are doing validation on the client and should have valid values once they are passed into the method (the web serv...
2008/09/18
[ "https://Stackoverflow.com/questions/97324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17697/" ]
I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot about faults and exceptions, ...
If you are doing validation on the client and should have valid values once they are passed into the method (the web service call) then I would throw an exception. It could be an exception indicating that a parameters is invalid with the name of the parameter. (see: ArgumentException) But you may not want to rely on t...
97,329
<p>Suppose I have a collection (be it an array, generic List, or whatever is the <strong>fastest</strong> solution to this problem) of a certain class, let's call it <code>ClassFoo</code>:</p> <pre><code>class ClassFoo { public string word; public float score; //... etc ... } </code></pre> <p>Assume ther...
[ { "answer_id": 97347, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 1, "selected": false, "text": "<p>var Answers = myList.Where(item => item.bar.StartsWith(query) || item.bar.EndsWith(query));</p>\n\n<p>that's th...
2008/09/18
[ "https://Stackoverflow.com/questions/97329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264/" ]
Suppose I have a collection (be it an array, generic List, or whatever is the **fastest** solution to this problem) of a certain class, let's call it `ClassFoo`: ``` class ClassFoo { public string word; public float score; //... etc ... } ``` Assume there's going to be like 50.000 items in the collectio...
With the constraint that the condition clause can be "anything", then you're limited to scanning the entire list and applying the condition. If there are limitations on the condition clause, then you can look at organizing the data to more efficiently handle the queries. For example, the code sample with the "byFirst...
97,338
<p>I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me?</p> <pre><code>gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) &gt;&gt;$(DEP) </code></pre>
[ { "answer_id": 97374, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stackoverflow.com/users/4761", "pm_score": 0, "selected": false, "text": "<p>If there is an argument to GCC to do this, I don't know what it is. We end up piping the dependency output through <a href...
2008/09/18
[ "https://Stackoverflow.com/questions/97338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
I'm using GCC to generate a dependency file, but my build rules put the output into a subdirectory. Is there a way to tell GCC to put my subdirectory prefix in the dependency file it generates for me? ``` gcc $(INCLUDES) -E -MM $(CFLAGS) $(SRC) >>$(DEP) ```
The answer is in the [GCC manual](http://gcc.gnu.org/onlinedocs/gcc-4.3.2/cpp/Invocation.html): use the `-MT` flag. > > `-MT target` > > > Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any directory components and any file suffix such a...
97,349
<p>We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizard. </p> <pre><code>&lt;Import Project="$(...
[ { "answer_id": 97486, "author": "Gregg", "author_id": 18266, "author_profile": "https://Stackoverflow.com/users/18266", "pm_score": 1, "selected": false, "text": "<p>If the targets should only be run when TFS is running the build and not on your local development machines, you can put yo...
2008/09/18
[ "https://Stackoverflow.com/questions/97349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18264/" ]
We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizard. ``` <Import Project="$(SolutionRoot)/lib...
The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj. If you move your targets file from under Solu...
97,370
<p>I have a macro which refreshes all fields in a document (the equivalent of doing an <kbd>F9</kbd> on the fields). I'd like to fire this macro automatically when the user saves the document.</p> <p>Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I on...
[ { "answer_id": 97486, "author": "Gregg", "author_id": 18266, "author_profile": "https://Stackoverflow.com/users/18266", "pm_score": 1, "selected": false, "text": "<p>If the targets should only be run when TFS is running the build and not on your local development machines, you can put yo...
2008/09/18
[ "https://Stackoverflow.com/questions/97370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9625/" ]
I have a macro which refreshes all fields in a document (the equivalent of doing an `F9` on the fields). I'd like to fire this macro automatically when the user saves the document. Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I only seem to find eve...
The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj. If you move your targets file from under Solu...
97,371
<p>I need to copy the newest file in a directory to a new location. So far I've found resources on the <a href="http://www.ss64.com/nt/forfiles.html" rel="noreferrer">forfiles</a> command, a <a href="https://stackoverflow.com/q/51837">date-related question</a> here, and another <a href="https://stackoverflow.com/q/5090...
[ { "answer_id": 97414, "author": "Robert Swisher", "author_id": 1852, "author_profile": "https://Stackoverflow.com/users/1852", "pm_score": 2, "selected": false, "text": "<p>I know you asked for Windows but thought I'd add this anyway,in Unix/Linux you could do:</p>\n\n<pre><code>cp `ls -...
2008/09/18
[ "https://Stackoverflow.com/questions/97371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5269/" ]
I need to copy the newest file in a directory to a new location. So far I've found resources on the [forfiles](http://www.ss64.com/nt/forfiles.html) command, a [date-related question](https://stackoverflow.com/q/51837) here, and another [related question](https://stackoverflow.com/q/50902). I'm just having a bit of tro...
Windows shell, one liner: ``` FOR /F "delims=" %%I IN ('DIR *.* /A-D /B /O:-D') DO COPY "%%I" <<NewDir>> & EXIT ```
97,391
<p>I have the following enum declared:</p> <pre><code> public enum TransactionTypeCode { Shipment = 'S', Receipt = 'R' } </code></pre> <p>How do I get the value 'S' from a TransactionTypeCode.Shipment or 'R' from TransactionTypeCode.Receipt ?</p> <p>Simply doing TransactionTypeCode.ToString() gives a string of the E...
[ { "answer_id": 97395, "author": "Andy", "author_id": 13505, "author_profile": "https://Stackoverflow.com/users/13505", "pm_score": 1, "selected": false, "text": "<p>I believe Enum.GetValues() is what you're looking for.</p>\n" }, { "answer_id": 97397, "author": "J D OConal", ...
2008/09/18
[ "https://Stackoverflow.com/questions/97391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I have the following enum declared: ``` public enum TransactionTypeCode { Shipment = 'S', Receipt = 'R' } ``` How do I get the value 'S' from a TransactionTypeCode.Shipment or 'R' from TransactionTypeCode.Receipt ? Simply doing TransactionTypeCode.ToString() gives a string of the Enum name "Shipment" or "Receipt" ...
Marking this as not correct, but I can't delete it. Try this: ``` string value = (string)TransactionTypeCode.Shipment; ```
97,402
<p>I've been trying to install PDT in Eclipse 3.4 for a few hours now and I'm not having any success.</p> <p>I have a previous installation of the Eclipse for Java EE developers (my main deal) distro and I just want to add the PDT to my install so I can also work on some of my websites in Eclipse. </p> <p>I've done ...
[ { "answer_id": 198709, "author": "WolfmanDragon", "author_id": 13491, "author_profile": "https://Stackoverflow.com/users/13491", "pm_score": 1, "selected": false, "text": "<p>If you have a list of all the plugins that you already have it may be faster and easier to go to <a href=\"http:/...
2008/09/18
[ "https://Stackoverflow.com/questions/97402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
I've been trying to install PDT in Eclipse 3.4 for a few hours now and I'm not having any success. I have a previous installation of the Eclipse for Java EE developers (my main deal) distro and I just want to add the PDT to my install so I can also work on some of my websites in Eclipse. I've done my best to follow ...
If you have a list of all the plugins that you already have it may be faster and easier to go to [YOXOS](http://www.yoxos.com/ondemand/) and download a new copy of eclipse with all the plugins already loaded. just remember to change your workspace if you do this.
97,435
<p>Suppose you have the following string:</p> <pre><code>white sand, tall waves, warm sun </code></pre> <p>It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun":</p> <pr...
[ { "answer_id": 97457, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 2, "selected": false, "text": "<p>This should catch both 'and' or ','</p>\n\n<pre><code>(?:\\sand|,)\\s\n</code></pre>\n" }, { "answer_id": 97458, ...
2008/09/18
[ "https://Stackoverflow.com/questions/97435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4287/" ]
Suppose you have the following string: ``` white sand, tall waves, warm sun ``` It's easy to write a regular expression that will match the delimiters, which the Java String.split() method can use to give you an array containing the tokens "white sand", "tall waves" and "warm sun": ``` \s*,\s* ``` Now say you hav...
This should be pretty resilient, and handle stuff like delimiters at the end of the string ("foo and bar and ", for example) ``` \s*(?:\band\b|,)\s* ```
97,447
<p>If I am writing a library and I have a function that needs to return a sequence of values, I could do something like:</p> <pre><code>std::vector&lt;int&gt; get_sequence(); </code></pre> <p>However, this requires the library user to use the std::vector&lt;> container rather than allowing them to use whatever contai...
[ { "answer_id": 97519, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 0, "selected": false, "text": "<p><code>std::list&lt;int&gt;</code> is slightly nicer, IMO. Note that this would not require an extra copy of the d...
2008/09/18
[ "https://Stackoverflow.com/questions/97447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78437/" ]
If I am writing a library and I have a function that needs to return a sequence of values, I could do something like: ``` std::vector<int> get_sequence(); ``` However, this requires the library user to use the std::vector<> container rather than allowing them to use whatever container they want to use. In addition, ...
Have get\_sequence return a (custom) `forward_iterator` class that generates the sequence on-demand. (It could also be a more advanced iterator type like `bidirectional_iterator` if that's practical for your sequence.) Then the user can copy the sequence into whatever container type they want. Or, they can just loop d...
97,459
<p>When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar.</p> <p>To see what I mean, click in your web browser's address bar. You'll notice the following behavior: </p> <ol> <li>Clicking in the textbox should select all the text if the textbox wasn't previously focused.</li> <...
[ { "answer_id": 97499, "author": "Jakub Kotrla", "author_id": 16943, "author_profile": "https://Stackoverflow.com/users/16943", "pm_score": 2, "selected": false, "text": "<p>Click event of textbox? Or even MouseCaptureChanged event works for me. - OK. doesn't work.</p>\n\n<p>So you have t...
2008/09/18
[ "https://Stackoverflow.com/questions/97459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
When a C# WinForms textbox receives focus, I want it to behave like your browser's address bar. To see what I mean, click in your web browser's address bar. You'll notice the following behavior: 1. Clicking in the textbox should select all the text if the textbox wasn't previously focused. 2. Mouse down and drag in ...
First of all, thanks for answers! 9 total answers. Thank you. Bad news: all of the answers had some quirks or didn't work quite right (or at all). I've added a comment to each of your posts. Good news: I've found a way to make it work. This solution is pretty straightforward and seems to work in all the scenarios (mo...
97,465
<p>Has anyone figured out how to use Crystal Reports with Linq to SQL?</p>
[ { "answer_id": 99193, "author": "Pascal Paradis", "author_id": 1291, "author_profile": "https://Stackoverflow.com/users/1291", "pm_score": 1, "selected": false, "text": "<p>Altough I haven't tried it myself it seems to be possible by using a combination of DataContext.LoadOptions to make...
2008/09/18
[ "https://Stackoverflow.com/questions/97465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11063/" ]
Has anyone figured out how to use Crystal Reports with Linq to SQL?
You can convert your LINQ result set to a `List`, you need not strictly use a `DataSet` as the reports `SetDataSource`, you can supply a Crystal Reports data with an `IEnumerable`. Since `List` inherits from `IEnumerable` you can set your reports' Data Source to a List, you just have to call the `.ToList()` method on y...
97,468
<p><a href="http://github.com/rails/ssl_requirement/tree/master/lib/ssl_requirement.rb" rel="nofollow noreferrer">Take a look at the ssl_requirement plugin.</a></p> <p>Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal ...
[ { "answer_id": 98697, "author": "Nathan de Vries", "author_id": 11109, "author_profile": "https://Stackoverflow.com/users/11109", "pm_score": 4, "selected": true, "text": "<p>I guess they believe that you should probably be using HTTPS (perhaps with a self-signed certificate) in developm...
2008/09/18
[ "https://Stackoverflow.com/questions/97468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076/" ]
[Take a look at the ssl\_requirement plugin.](http://github.com/rails/ssl_requirement/tree/master/lib/ssl_requirement.rb) Shouldn't it check to see if you're in production mode? We're seeing a redirect to https in development mode, which seems odd. Or is that the normal behavior for the plugin? I thought it behaved di...
I guess they believe that you should probably be using HTTPS (perhaps with a self-signed certificate) in development mode. If that's not the desired behaviour, there's nothing stopping you from special casing SSL behaviour in the development environment yourself: ``` class YourController < ApplicationController ssl_...
97,474
<p>I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: </p> <pre><code>..../xsl:template/xsl:choose/xsl:when </code></pre> <p>But that just returns the 'when' elements, not the exact attribute values I need.</p...
[ { "answer_id": 97500, "author": "Steve Cooper", "author_id": 6722, "author_profile": "https://Stackoverflow.com/users/6722", "pm_score": 2, "selected": false, "text": "<p>do you want <code>.../xsl:template/xsl:choose/xsl:when/@test</code></p>\n\n<p>If you want to actually get the value '...
2008/09/18
[ "https://Stackoverflow.com/questions/97474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10876/" ]
I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close: ``` ..../xsl:template/xsl:choose/xsl:when ``` But that just returns the 'when' elements, not the exact attribute values I need. Here is a snippet of my XML: ...
Steve Cooper answered the first part. For the second part, you can use: ``` .../xsl:template/xsl:choose/xsl:when[@test="@name='First Name'"]/xsl:call-template/@name ``` Which will match specifically the xsl:when in your above snippet. If you want it to match generally, then you can use: ``` .../xsl:template/xsl:cho...
97,480
<p>I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress?</p> <p>I understand there are problems with using ROW...
[ { "answer_id": 97579, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": -1, "selected": false, "text": "<p>A quick google search turns up this: \n<a href=\"http://bytes.com/forum/thread174440.html\" rel=\"nofollow noreferrer...
2008/09/18
[ "https://Stackoverflow.com/questions/97480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739/" ]
I have a Progress database that I'm performing an ETL from. One of the tables that I'm reading from does not have a unique key on it, so I need to access the ROWID to be able to uniquely identify the row. What is the syntax for accessing the ROWID in Progress? I understand there are problems with using ROWID for row i...
A quick caveat for my answer - it's nearly 10 years since I worked with [Progress](http://www.progress.com/) so my knowledge is probably more than a little out of date. Checking the [Progress Language Reference](http://www.psdn.com/library/servlet/KbServlet/download/1078-102-885/langref.pdf) [PDF] seems to show the tw...
97,505
<p>Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. </p> <p>In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I...
[ { "answer_id": 97579, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": -1, "selected": false, "text": "<p>A quick google search turns up this: \n<a href=\"http://bytes.com/forum/thread174440.html\" rel=\"nofollow noreferrer...
2008/09/18
[ "https://Stackoverflow.com/questions/97505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17145/" ]
Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings. In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I created a ma...
A quick caveat for my answer - it's nearly 10 years since I worked with [Progress](http://www.progress.com/) so my knowledge is probably more than a little out of date. Checking the [Progress Language Reference](http://www.psdn.com/library/servlet/KbServlet/download/1078-102-885/langref.pdf) [PDF] seems to show the tw...
97,506
<p><strong>This isn't a holy war, this isn't a question of "which is better".</strong></p> <p>What are the pros of using the following format for single statement if blocks.</p> <pre><code>if (x) print "x is true"; if(x) print "x is true"; </code></pre> <p>As opposed to</p> <pre><code>if (x) { print "x is tru...
[ { "answer_id": 97516, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 6, "selected": false, "text": "<p><strong>I strongly dislike any style that places the if's test and body on the same line.</strong></p>\n\n<p>This is...
2008/09/18
[ "https://Stackoverflow.com/questions/97506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4668/" ]
**This isn't a holy war, this isn't a question of "which is better".** What are the pros of using the following format for single statement if blocks. ``` if (x) print "x is true"; if(x) print "x is true"; ``` As opposed to ``` if (x) { print "x is true"; } if(x) { print "x is true"; } ``` **If you...
I find this: ``` if( true ) { DoSomething(); } else { DoSomethingElse(); } ``` better than this: ``` if( true ) DoSomething(); else DoSomethingElse(); ``` This way, if I (or someone else) comes back to this code later to add more code to one of the branches, I won't have to worry about forgetting ...
97,522
<p>What are all the valid self-closing elements (e.g. &lt;br/&gt;) in XHTML (as implemented by the major browsers)?</p> <p>I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See <a href="http://dusan.fora.si/blog/self-closi...
[ { "answer_id": 97543, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": -1, "selected": false, "text": "<p>&lt;hr /&gt; is another</p>\n" }, { "answer_id": 97575, "author": "e-satis", "author_id": 9951, "auth...
2008/09/18
[ "https://Stackoverflow.com/questions/97522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1335/" ]
What are all the valid self-closing elements (e.g. <br/>) in XHTML (as implemented by the major browsers)? I know that XHTML technically allows any element to be self-closed, but I'm looking for a list of those elements supported by all major browsers. See <http://dusan.fora.si/blog/self-closing-tags> for examples of ...
Every browser that supports XHTML (Firefox, Opera, Safari, [IE9](https://learn.microsoft.com/en-us/archive/blogs/ie/xhtml-in-ie9)) supports self-closing syntax on **every element**. `<div/>`, `<script/>`, `<br></br>` all should work just fine. If they don't, then you have *HTML* with inappropriately added XHTML DOCTYP...
97,565
<p>C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a "bit depth" field ...
[ { "answer_id": 97626, "author": "Colin Mackay", "author_id": 8152, "author_profile": "https://Stackoverflow.com/users/8152", "pm_score": 2, "selected": false, "text": "<p>I would say not to do that work in the construtor - A constructor should not do so much work, in my opinion. Use a fa...
2008/09/18
[ "https://Stackoverflow.com/questions/97565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1812999/" ]
C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,] pixels. I am dealing with proprietary image formats. The ImageData class takes a file location in the constructor, then switches on file extension to determine how to decode. In several of the image files, there is a "bit depth" field in the ...
To boil down your problem, you want to be able to have a class that has a **ushort[,] pixels** field (16-bits per pixel) sometimes and a **uint32[,] pixels** field (32-bits per pixel) some other times. There are a couple different ways to achieve this. You could create replacements for ushort / uint32 by making a Pixe...
97,578
<p>Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example:</p> <pre><code>&lt;a href="#" onclick="SelectSurveyItem('&lt;%itemid%&gt;', '&lt;%itemname%&gt;'); return false;"&gt;Select&lt;/a&gt; ...
[ { "answer_id": 97591, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 1, "selected": false, "text": "<p>Declare separate functions in the &lt;head&gt; section and invoke those in your onClick method. If you have lots you ...
2008/09/18
[ "https://Stackoverflow.com/questions/97578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10861/" ]
Maybe I'm just thinking about this too hard, but I'm having a problem figuring out what escaping to use on a string in some JavaScript code inside a link's onClick handler. Example: ``` <a href="#" onclick="SelectSurveyItem('<%itemid%>', '<%itemname%>'); return false;">Select</a> ``` The `<%itemid%>` and `<%itemname...
In JavaScript you can encode single quotes as "\x27" and double quotes as "\x22". Therefore, with this method you can, once you're inside the (double or single) quotes of a JavaScript string literal, use the \x27 \x22 with impunity without fear of any embedded quotes "breaking out" of your string. \xXX is for chars <...
97,586
<p>My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&amp;F.</p> <p>Can anyone provide an e...
[ { "answer_id": 97591, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 1, "selected": false, "text": "<p>Declare separate functions in the &lt;head&gt; section and invoke those in your onClick method. If you have lots you ...
2008/09/18
[ "https://Stackoverflow.com/questions/97586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15441/" ]
My boss loves VB (we work in a Java shop) because he thinks it's easy to learn and maintain. We want to replace some of the VB with java equivalents using the Eclipse SWT editor, because we think it is almost as easy to maintain. To sell this, we'd like to use an aerith style L&F. Can anyone provide an example of an S...
In JavaScript you can encode single quotes as "\x27" and double quotes as "\x22". Therefore, with this method you can, once you're inside the (double or single) quotes of a JavaScript string literal, use the \x27 \x22 with impunity without fear of any embedded quotes "breaking out" of your string. \xXX is for chars <...
97,637
<p>Anyone got a good explanation of "combinators" (Y-combinators etc. and <strong>NOT</strong> <a href="https://en.wikipedia.org/wiki/Y_Combinator_(company)" rel="noreferrer">the company</a>)?</p> <p>I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have...
[ { "answer_id": 97771, "author": "Jonathan Arkell", "author_id": 11052, "author_profile": "https://Stackoverflow.com/users/11052", "pm_score": 2, "selected": false, "text": "<p>This is a good <a href=\"https://web.archive.org/web/20160913141703/http://www.dreamsongs.com/NewFiles/WhyOfY.pd...
2008/09/18
[ "https://Stackoverflow.com/questions/97637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
Anyone got a good explanation of "combinators" (Y-combinators etc. and **NOT** [the company](https://en.wikipedia.org/wiki/Y_Combinator_(company)))? I'm looking for one for the practical programmer who understands recursion and higher-order functions, but doesn't have a strong theory or math background. (Note: that I...
Unless you're deeply into theory, you can regard the Y combinator as a neat trick with functions, like monads. Monads allow you to chain actions, the Y combinator allows you to define self-recursive functions. Python has built-in support for self-recursive functions, so you can define them without Y: ``` > def fun()...
97,640
<p>How do I get my project's runtime dependencies copied into the <code>target/lib</code> folder? </p> <p>As it is right now, after <code>mvn clean install</code> the <code>target</code> folder contains only my project's jar, but none of the runtime dependencies.</p>
[ { "answer_id": 97748, "author": "Eduard Wirch", "author_id": 17428, "author_profile": "https://Stackoverflow.com/users/17428", "pm_score": 2, "selected": false, "text": "<p>If you make your project a war or ear type maven will copy the dependencies.</p>\n" }, { "answer_id": 97837...
2008/09/18
[ "https://Stackoverflow.com/questions/97640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18320/" ]
How do I get my project's runtime dependencies copied into the `target/lib` folder? As it is right now, after `mvn clean install` the `target` folder contains only my project's jar, but none of the runtime dependencies.
This works for me: ```xml <project> ... <profiles> <profile> <id>qa</id> <build> <plugins> <plugin> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <phase>install</phase> <goals> ...
97,663
<p>Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc.</p> <p>However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right.</p> <p>I click on Windows|Preferences and type in ...
[ { "answer_id": 97691, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 3, "selected": false, "text": "<p>It's a known enhancement request. <a href=\"https://bugs.eclipse.org/bugs/show_bug.cgi?id=35779\" rel=\"noreferrer\">Bug...
2008/09/18
[ "https://Stackoverflow.com/questions/97663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
Programming PHP in Eclipse PDT is predominately a joy: code completion, templates, method jumping, etc. However, one thing that drives me crazy is that I can't get my lines in PHP files to word wrap so on long lines I'm typing out indefinitely to the right. I click on Windows|Preferences and type in "wrap" and get: ...
This has really been one of the most desired features in Eclipse. It's not just missing in PHP files-- it's missing in the IDE. Fortunately, from Google Summer of Code, we get this plug-in [Eclipse Word-Wrap](http://ahtik.com/blog/projects/eclipse-word-wrap/) To install it, add the following update site in Eclipse: [...
97,683
<p>Here is a snippet of CSS that I need explained:</p> <pre class="lang-css prettyprint-override"><code>#section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } </code></pre> <p>Ok so it's absolute positioning of an image, obviously.</p...
[ { "answer_id": 97702, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 0, "selected": false, "text": "<p>When position is absolute, top is vertical distance from the parent (probably the body tag, so 0 is the top edge of t...
2008/09/18
[ "https://Stackoverflow.com/questions/97683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
Here is a snippet of CSS that I need explained: ```css #section { width: 860px; background: url(/blah.png); position: absolute; top: 0; left: 50%; margin-left: -445px; } ``` Ok so it's absolute positioning of an image, obviously. 1. top is like padding from the top, right? 2. what does left ...
1. Top is the distance from the top of the html element or, if this is within another element with absolute position, from the top of that. 2. & 3. It depends on the width of the image but it might be for centering the image horizontally (if the width of the image is 890px). There are other ways to center an image hori...
97,694
<p>I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? </p> <p>So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same inde...
[ { "answer_id": 97720, "author": "Craig B.", "author_id": 10780, "author_profile": "https://Stackoverflow.com/users/10780", "pm_score": -1, "selected": false, "text": "<p>Try:</p>\n\n<p>set sw=2</p>\n\n<p>set ts=2</p>\n\n<p>set smartindent</p>\n" }, { "answer_id": 97723, "auth...
2008/09/18
[ "https://Stackoverflow.com/questions/97694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
I've been somewhat spoiled using Eclipse and java. I started using vim to do C coding in a linux environment, is there a way to have vim automatically do the proper spacing for blocks? So after typing a { the next line will have 2 spaces indented in, and a return on that line will keep it at the same indentation, and...
These two commands should do it: ``` :set autoindent :set cindent ``` For bonus points put them in a file named .vimrc located in your home directory on linux
97,733
<p>I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer :)</p> <p>I have an attribute that looks like:</p> <pre><code>public class L...
[ { "answer_id": 97773, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 1, "selected": false, "text": "<p>I believe if you change AttributeTargetAssemblies to \"PresentationFramework\", it might work. (Don't have PostSharp dow...
2008/09/18
[ "https://Stackoverflow.com/questions/97733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1473493/" ]
I'm working with PostSharp to intercept method calls to objects I don't own, but my aspect code doesn't appear to be getting called. The documentation seems pretty lax in the Silverlight area, so I'd appreciate any help you guys can offer :) I have an attribute that looks like: ``` public class LogAttribute : OnMetho...
**This is not possible with the present version of PostSharp.** PostSharp works by transforming assemblies prior to being loaded by the CLR. Right now, in order to do that, two things have to happen: * The assembly must be about to be loaded into the CLR; you only get one shot, and you have to take it at this point. ...
97,762
<p>I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click?</p> <p>The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by positio...
[ { "answer_id": 97783, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 0, "selected": false, "text": "<p>Shove them in a <a href=\"http://en.wikipedia.org/wiki/Quadtree\" rel=\"nofollow noreferrer\">quadtree</a>.</p>\n" ...
2008/09/18
[ "https://Stackoverflow.com/questions/97762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10293/" ]
I have a collection of non-overlapping rectangles that cover an enclosing rectangle. What is the best way to find the containing rectangle for a mouse click? The obvious answer is to have an array of rectangles and to search them in sequence, making the search O(n). Is there some way to order them by position so that ...
You can organize your rectangles in a quad or kd-tree. That gives you O(log n). That's the mainstream method. Another interesting data-structure for this problem are R-trees. These can be very efficient if you have to deal with lots of rectangles. <http://en.wikipedia.org/wiki/R-tree> And then there is the O(1) meth...
97,781
<p>Part of a new product I have been assigned to work on involves server-side conversion of the 'common' video formats to something that Flash can play.</p> <p>As far as I know, my only option is to convert to FLV. I have been giving ffmpeg a go around, but I'm finding a few WMV files that come out with garbled sound ...
[ { "answer_id": 97799, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 5, "selected": true, "text": "<p>Flash can play the following formats:</p>\n\n<pre><code>FLV with AAC or MP3 audio, and FLV1 (Sorenson Spark H.263), ...
2008/09/18
[ "https://Stackoverflow.com/questions/97781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2192/" ]
Part of a new product I have been assigned to work on involves server-side conversion of the 'common' video formats to something that Flash can play. As far as I know, my only option is to convert to FLV. I have been giving ffmpeg a go around, but I'm finding a few WMV files that come out with garbled sound (I've trie...
Flash can play the following formats: ``` FLV with AAC or MP3 audio, and FLV1 (Sorenson Spark H.263), VP6, or H.264 video. MP4 with AAC or MP3 audio, and H.264 video (mp4s must be hinted with qt-faststart or mp4box). ``` ffmpeg is an overall good conversion utility; mencoder works better with obscure and proprietary...
97,840
<p>I'm trying to configure a dedicated server that runs ASP.NET to send mail through the local IIS SMTP server but mail is getting stuck in the Queue folder and doesn't get delivered.</p> <p>I'm using this code in an .aspx page to test:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" %&gt; &lt;% new ...
[ { "answer_id": 97854, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 3, "selected": true, "text": "<p>I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP ...
2008/09/18
[ "https://Stackoverflow.com/questions/97840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2148/" ]
I'm trying to configure a dedicated server that runs ASP.NET to send mail through the local IIS SMTP server but mail is getting stuck in the Queue folder and doesn't get delivered. I'm using this code in an .aspx page to test: ``` <%@ Page Language="C#" AutoEventWireup="true" %> <% new System.Net.Mail.SmtpClient("lo...
I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP server. Less headaches. Looks like that's where you are having issues, from your SMTP to external servers, not asp.net to your SMTP. Just have your SMTP server set to send it to your ISP, or you can ...
97,857
<p>Suppose I have a stored procedure that manages its own transaction</p> <pre><code>CREATE PROCEDURE theProc AS BEGIN BEGIN TRANSACTION -- do some stuff IF @ThereIsAProblem ROLLBACK TRANSACTION ELSE COMMIT TRANSACTION END </code></pre> <p>If I call this proc from an existing transaction, the proc ca...
[ { "answer_id": 97931, "author": "Francesca", "author_id": 9842, "author_profile": "https://Stackoverflow.com/users/9842", "pm_score": 1, "selected": false, "text": "<p>use @@trancount to see if you're already in a transaction when entering</p>\n" }, { "answer_id": 97944, "aut...
2008/09/18
[ "https://Stackoverflow.com/questions/97857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8155/" ]
Suppose I have a stored procedure that manages its own transaction ``` CREATE PROCEDURE theProc AS BEGIN BEGIN TRANSACTION -- do some stuff IF @ThereIsAProblem ROLLBACK TRANSACTION ELSE COMMIT TRANSACTION END ``` If I call this proc from an existing transaction, the proc can ROLLBACK the external tr...
The syntax to do this probably varies by database. But in Transact-SQL what you do is check @@TRANCOUNT to see if you are in a transaction. If you are then you want to create a savepoint, and at the end you can just pass through the end of the function (believing a commit or rollback will happen later) or else rollback...
97,875
<p>I need a way to recursively delete a folder and its children.</p> <p>Is there a prebuilt tool for this, or do I need to write one?</p> <p><code>DEL /S</code> doesn't delete directories.</p> <p><code>DELTREE</code> was removed from Windows 2000+</p>
[ { "answer_id": 97891, "author": "Brian Mitchell", "author_id": 13716, "author_profile": "https://Stackoverflow.com/users/13716", "pm_score": 2, "selected": false, "text": "<p>rmdir /s dirname</p>\n" }, { "answer_id": 97895, "author": "Paige Ruten", "author_id": 813, "...
2008/09/18
[ "https://Stackoverflow.com/questions/97875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I need a way to recursively delete a folder and its children. Is there a prebuilt tool for this, or do I need to write one? `DEL /S` doesn't delete directories. `DELTREE` was removed from Windows 2000+
RMDIR or RD if you are using the classic Command Prompt (cmd.exe): ``` rd /s /q "path" ``` > > RMDIR [/S] [/Q] [drive:]path > > > RD [/S] [/Q] [drive:]path > > > /S Removes all directories and files in the specified directory in addition to the directory itself. **Used to remove a directory tree.** > > > /Q Q...
97,962
<p>A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submiss...
[ { "answer_id": 97995, "author": "Jason Wadsworth", "author_id": 11078, "author_profile": "https://Stackoverflow.com/users/11078", "pm_score": 1, "selected": false, "text": "<p>You could try setting the \"disabled\" flag on the input (type=submit) element, rather than just changing the st...
2008/09/18
[ "https://Stackoverflow.com/questions/97962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10788/" ]
A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submission...
If you've got jQuery handy, attach a click() event that disables the button after the initial submission - ``` $('input[type="submit"]').click(function(event){ event.preventDefault(); this.click(null); }); ``` that sort of thing.
97,971
<p>Having programmed through emacs and vi for years and years at this point, I have heard that using an IDE is a very good way of becoming more efficient.</p> <p>To that end, I have decided to try using Eclipse for a lot of coding and seeing how I get on.</p> <p>Are there any suggestions for easing the transition ove...
[ { "answer_id": 97985, "author": "William Keller", "author_id": 17095, "author_profile": "https://Stackoverflow.com/users/17095", "pm_score": 2, "selected": false, "text": "<p>If you've been using emacs/vi for years (although you listed both, so it seems like you may not be adapted fully ...
2008/09/18
[ "https://Stackoverflow.com/questions/97971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
Having programmed through emacs and vi for years and years at this point, I have heard that using an IDE is a very good way of becoming more efficient. To that end, I have decided to try using Eclipse for a lot of coding and seeing how I get on. Are there any suggestions for easing the transition over to an IDE. Obvi...
Eclipse is the best IDE I've used, even considering its quite large footprint and sluggishness on slow computers (like my work machine... Pentium III!). Rather than trying to 'ease the transition', I think it's better to jump right in and let yourself be overwhelmed by the bells and whistles and truly useful refactori...
97,976
<p>I have a datagridview that accepts a list(of myObject) as a datasource. I want to add a new row to the datagrid to add to the database. I get this done by getting the list... adding a blank myObject to the list and then reseting the datasource. I now want to set the focus to the second cell in the new row.</p> <p>T...
[ { "answer_id": 97986, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 0, "selected": false, "text": "<p>In WinForms, you should be able to set the </p>\n\n<pre><code>Me.dataEvidence.SelectedRows\n</code></pre>\n\n<p>property to th...
2008/09/18
[ "https://Stackoverflow.com/questions/97976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16820/" ]
I have a datagridview that accepts a list(of myObject) as a datasource. I want to add a new row to the datagrid to add to the database. I get this done by getting the list... adding a blank myObject to the list and then reseting the datasource. I now want to set the focus to the second cell in the new row. To CLARIFY ...
You can set the focus to a specific cell in a row but only if the SelectionMode on the DataGridView is set to CellSelect. If it is, simply do the following: ``` dataGridView.Rows[rowNumber].Cells[columnNumber].Selected = true; ```
97,987
<p>What's the best practice for using a <code>switch</code> statement vs using an <code>if</code> statement for 30 <code>unsigned</code> enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. I've abstracted the snippet...
[ { "answer_id": 98004, "author": "Alexandra Franks", "author_id": 16203, "author_profile": "https://Stackoverflow.com/users/16203", "pm_score": 4, "selected": false, "text": "<p>Compiler will optimise it anyway - go for the switch as it's the most readable.</p>\n" }, { "answer_id"...
2008/09/18
[ "https://Stackoverflow.com/questions/97987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8883/" ]
What's the best practice for using a `switch` statement vs using an `if` statement for 30 `unsigned` enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but are not critical. I've abstracted the snippet so don't hate me for the naming conv...
Use switch. In the worst case the compiler will generate the same code as a if-else chain, so you don't lose anything. If in doubt put the most common cases first into the switch statement. In the best case the optimizer may find a better way to generate the code. Common things a compiler does is to build a binary de...
98,033
<p>Several Linq.Enumerable functions take an <code>IEqualityComparer&lt;T&gt;</code>. Is there a convenient wrapper class that adapts a <code>delegate(T,T)=&gt;bool</code> to implement <code>IEqualityComparer&lt;T&gt;</code>? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but ...
[ { "answer_id": 98119, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 6, "selected": false, "text": "<p>I'm afraid there is no such wrapper out-of-box. However it's not hard to create one:</p>\n\n<pre><code>class Comparer&lt;T&gt;...
2008/09/18
[ "https://Stackoverflow.com/questions/98033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9990/" ]
Several Linq.Enumerable functions take an `IEqualityComparer<T>`. Is there a convenient wrapper class that adapts a `delegate(T,T)=>bool` to implement `IEqualityComparer<T>`? It's easy enough to write one (if your ignore problems with defining a correct hashcode), but I'd like to know if there is an out-of-the-box solu...
Ordinarily, I'd get this resolved by commenting @Sam on the answer (I've done some editing on the original post to clean it up a bit without altering the behavior.) The following is my riff of [@Sam's answer](https://stackoverflow.com/questions/98033/wrap-a-delegate-in-an-iequalitycomparer/270203#270203), with a [IMNS...
98,074
<p>I have a given certificate installed on my server. That certificate has valid dates, and seems perfectly valid in the Windows certificates MMC snap-in.</p> <p>However, when I try to read the certificate, in order to use it in an HttpRequest, I can't find it. Here is the code used:</p> <pre><code> X509Store stor...
[ { "answer_id": 98201, "author": "Tim Erickson", "author_id": 8787, "author_profile": "https://Stackoverflow.com/users/8787", "pm_score": 2, "selected": false, "text": "<p>I believe x509 certs are tied to a particular user. Could it be invalid because in the code you are accessing it as ...
2008/09/18
[ "https://Stackoverflow.com/questions/98074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18073/" ]
I have a given certificate installed on my server. That certificate has valid dates, and seems perfectly valid in the Windows certificates MMC snap-in. However, when I try to read the certificate, in order to use it in an HttpRequest, I can't find it. Here is the code used: ``` X509Store store = new X509Store(Sto...
Try verifying the certificate chain using the [X509Chain](http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509chain.aspx) class. This can tell you exactly why the certificate isn't considered valid. As erickson suggested, your X509Store may not have the trusted certificate from th...
98,096
<p>I've seen some people use <code>EXISTS (SELECT 1 FROM ...)</code> rather than <code>EXISTS (SELECT id FROM ...)</code> as an optimization--rather than looking up and returning a value, SQL Server can simply return the literal it was given.</p> <p>Is <code>SELECT(1)</code> always faster? Would Selecting a value fro...
[ { "answer_id": 98103, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 1, "selected": false, "text": "<p>Yes, because when you select a literal it does not need to read from disk (or even from cache).</p>\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/98096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18347/" ]
I've seen some people use `EXISTS (SELECT 1 FROM ...)` rather than `EXISTS (SELECT id FROM ...)` as an optimization--rather than looking up and returning a value, SQL Server can simply return the literal it was given. Is `SELECT(1)` always faster? Would Selecting a value from the table require work that Selecting a li...
For google's sake, I'll update this question with the same answer as this one ([Subquery using Exists 1 or Exists \*](https://stackoverflow.com/questions/1597442/subquery-using-exists-1-or-exists/)) since (currently) an incorrect answer is marked as accepted. Note the SQL standard actually says that EXISTS via \* is id...
98,122
<p>I am getting the following error when running a reporting services report.</p> <pre><code>Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE Exception information: Exception type: XmlException Exception message: For security reasons DTD is prohibited in this XML document. To enable DTD pr...
[ { "answer_id": 98558, "author": "Bart", "author_id": 16980, "author_profile": "https://Stackoverflow.com/users/16980", "pm_score": 1, "selected": false, "text": "<p>Check to see if your reporting server website has the correct local path folder. You might need to do an iisreset if it is...
2008/09/18
[ "https://Stackoverflow.com/questions/98122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am getting the following error when running a reporting services report. ``` Process name: w3wp.exe Account name: NT AUTHORITY\NETWORK SERVICE Exception information: Exception type: XmlException Exception message: For security reasons DTD is prohibited in this XML document. To enable DTD processing set t...
Check to see if your reporting server website has the correct local path folder. You might need to do an iisreset if it is not correct.
98,124
<p>Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year?</p> <pre><code>myDate = new Date(); year = myDate.getYear(); </code></pre> <p>year = 108?</p>
[ { "answer_id": 98129, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>It must return the number of years since the year 1900.</p>\n" }, { "answer_id": 98131, "author": "Nils Pipe...
2008/09/18
[ "https://Stackoverflow.com/questions/98124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6161/" ]
Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year? ``` myDate = new Date(); year = myDate.getYear(); ``` year = 108?
It's a [Y2K](http://en.wikipedia.org/wiki/Y2K) thing, only the years since 1900 are counted. There are potential compatibility issues now that `getYear()` has been deprecated in favour of `getFullYear()` - from [quirksmode](http://www.quirksmode.org/js/introdate.html): > > To make the matter even more complex, date....
98,135
<p>I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO_SETTINGS_MODULE environment variable?</p> <p>If I run the following code:</p> <pre><code>&gt;&gt;&gt; import djang...
[ { "answer_id": 98146, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "<p>Any particular reason you want to use Django's templates? Both <a href=\"http://jinja.pocoo.org/\" rel=\"noreferrer\...
2008/09/18
[ "https://Stackoverflow.com/questions/98135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
I want to use the Django template engine in my (Python) code, but I'm not building a Django-based web site. How do I use it without having a settings.py file (and others) and having to set the DJANGO\_SETTINGS\_MODULE environment variable? If I run the following code: ``` >>> import django.template >>> from django.te...
The solution is simple. It's actually [well documented](http://docs.djangoproject.com/en/dev/ref/templates/api/#configuring-the-template-system-in-standalone-mode), but not too easy to find. (I had to dig around -- it didn't come up when I tried a few different Google searches.) The following code works: ``` >>> from...
98,153
<p>I've found the standard hashing function on VS2005 is painfully slow when trying to achieve high performance look ups. What are some good examples of fast and efficient hashing algorithms that should void most collisions?</p>
[ { "answer_id": 98164, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 3, "selected": false, "text": "<p>That always depends on your data-set.</p>\n\n<p>I for one had surprisingly good results by using the CRC32 of t...
2008/09/18
[ "https://Stackoverflow.com/questions/98153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13646/" ]
I've found the standard hashing function on VS2005 is painfully slow when trying to achieve high performance look ups. What are some good examples of fast and efficient hashing algorithms that should void most collisions?
I worked with [Paul Larson](http://research.microsoft.com/~PALARSON/) of Microsoft Research on some hashtable implementations. He investigated a number of string hashing functions on a variety of datasets and found that a simple multiply by 101 and add loop worked surprisingly well. ``` unsigned int hash( const ch...