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
45,600
<p>The <a href="http://dev.jquery.com/view/trunk/ui/demos/functional/#ui.dialog" rel="nofollow noreferrer">demos</a> for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found ...
[ { "answer_id": 45752, "author": "David McLaughlin", "author_id": 3404, "author_profile": "https://Stackoverflow.com/users/3404", "pm_score": 1, "selected": false, "text": "<p>After playing with this in Firebug, if you add a z-index attribute greater than 1004 to your default div, id of \...
2008/09/05
[ "https://Stackoverflow.com/questions/45600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
The [demos](http://dev.jquery.com/view/trunk/ui/demos/functional/#ui.dialog) for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found that I can't control any input element c...
I think it is because you have the classes different. `<div id="SERVICE03_DLG" class="flora">` (flora) `<div id="SERVICE03_DLG" class="ui-dialog">` (custom) Even with the flora theme, you would still use the ui-dialog class to define it as a dialog. I've done modals before and I've never even defined a class in...
45,604
<p>C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance:</p> <pre><code>List&lt;int&gt; myInts = new List&lt;int&gt; {0,1,1, 2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765}; //this statement is clunky List&lt;string&gt; myStrings = myInts. ...
[ { "answer_id": 45612, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Why doesn't C# support this class level generic type inference?</p>\n</blockquote>\n\n<p>Because th...
2008/09/05
[ "https://Stackoverflow.com/questions/45604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance: ``` List<int> myInts = new List<int> {0,1,1, 2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765}; //this statement is clunky List<string> myStrings = myInts. Select<int,string>( i => i.ToStr...
Actually, your question isn't bad. I've been toying with a generic programming language for last few years and although I've never come around to actually develop it (and probably never will), I've thought a lot about generic type inference and one of my top priorities has always been to allow the construction of class...
45,611
<p>I have a database with a few dozen tables interlinked with foreign keys. Under normal circumstances, I want the default <code>ON DELETE RESTRICT</code> behavior for those constraints. But when trying to share a snapshot of the database with a consultant, I needed to remove some sensitive data. I wish that my memory ...
[ { "answer_id": 45893, "author": "Tony Lenzi", "author_id": 4513, "author_profile": "https://Stackoverflow.com/users/4513", "pm_score": 0, "selected": false, "text": "<p>You may want to look into using <a href=\"http://www.postgresql.org/docs/8.2/static/ddl-schemas.html\" rel=\"nofollow n...
2008/09/05
[ "https://Stackoverflow.com/questions/45611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a database with a few dozen tables interlinked with foreign keys. Under normal circumstances, I want the default `ON DELETE RESTRICT` behavior for those constraints. But when trying to share a snapshot of the database with a consultant, I needed to remove some sensitive data. I wish that my memory of a `DELETE F...
You do not need to dump and restore. You should be able to just drop the constraint, rebuild it with cascade, do your deletes, drop it again, and the rebuild it with restrict. ``` CREATE TABLE "header" ( header_id serial NOT NULL, CONSTRAINT header_pkey PRIMARY KEY (header_id) ); CREATE TABLE detail ( header_id...
45,613
<p>What could be the problem with reversing the array of DOM objects as in the following code:</p> <pre><code>var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); </code></pre> <p>In Firefox 3, when I call the <code>reverse()</code> method...
[ { "answer_id": 45622, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 1, "selected": false, "text": "<p>Your first line is irrelevant, since it doesn't coerce the assignment to the variable, javascript works the other ...
2008/09/05
[ "https://Stackoverflow.com/questions/45613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4723/" ]
What could be the problem with reversing the array of DOM objects as in the following code: ``` var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); ``` In Firefox 3, when I call the `reverse()` method the script stops executing and shows...
Because getElementsByTag name actually returns a NodeList structure. It has similar array like indexing properties for syntactic convenience, but it is *not* an array. For example, the set of entries is actually constantly being dynamically updated - if you add a new img tag under myDivHolderId, it will automatically a...
45,623
<p>In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful.</p> <p>Would it make sense to have the listening socket as ...
[ { "answer_id": 45630, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 5, "selected": true, "text": "<p>If you can afford the threading, try this (keep in mind I've left out some details like exception handling and playing nice ...
2008/09/05
[ "https://Stackoverflow.com/questions/45623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739/" ]
In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful. Would it make sense to have the listening socket as a serverso...
If you can afford the threading, try this (keep in mind I've left out some details like exception handling and playing nice with threads). You may want to look into `SocketChannels` and/or NIO async sockets / selectors. This should get you started. ``` boolean finished = false; int port = 10000; ServerSocket server = ...
45,624
<p>I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name?</p> <p>I know how to change author after commit but how to change before? Installing apache/svnserver is not an option. </p>
[ { "answer_id": 45668, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>As far as I know, TortoiseSVN does not offer any way to do this.</p>\n\n<p>Presumably it's not seen as a big issue, since fi...
2008/09/05
[ "https://Stackoverflow.com/questions/45624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/501/" ]
I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name? I know how to change author after commit but how to change before? Installing apache/svnserver is not an option.
Yes, it's possible. *TortoiseSVN* and the [*svn*](http://subversion.tigris.org/) command line client share the same settings location in your profile folder. So you may simply checkout one version using *svn.exe*: ``` $ svn co --username different_user_name file:///C:/path/to/your/repo ``` ... and Subversion will h...
45,626
<p>I have a basic CRUD form that uses PageMethods to update the user details, however the Validators don't fire off, I think I need to manually initialize the validators and check whether the validation has passed in my javascript save method. Any ideas on how to do this?</p>
[ { "answer_id": 45892, "author": "Sara Chipps", "author_id": 4140, "author_profile": "https://Stackoverflow.com/users/4140", "pm_score": 0, "selected": false, "text": "<p>what are you using for development? VS 2008 supposedly has better JS debugging, haven't tried it yet. </p>\n\n<p>For A...
2008/09/05
[ "https://Stackoverflow.com/questions/45626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2808/" ]
I have a basic CRUD form that uses PageMethods to update the user details, however the Validators don't fire off, I think I need to manually initialize the validators and check whether the validation has passed in my javascript save method. Any ideas on how to do this?
Ok so I finally solved this: You need to call `Page_ClientValidate()` in your Save javascript method and If it returns true continue with the save, the `Page_ClientValidate()` initiates the client side validators, See code below: ``` function Save() { var clientValidationPassed =Page_ClientValidate(); ...
45,634
<p>How do you rewrite this in Linq?</p> <pre><code>SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) </code></pre> <p>So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query.</p>
[ { "answer_id": 45648, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 4, "selected": true, "text": "<pre><code>from a in TableA \nwhere (from b in TableB \n join c in TableC on b.id equals c.id\n where .. select...
2008/09/05
[ "https://Stackoverflow.com/questions/45634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
How do you rewrite this in Linq? ``` SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) ``` So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query.
``` from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where .. select b.id) .Contains(a.Id) select new { a.Id, a.Name } ```
45,642
<p>I was wondering if there is an open source library or algorithm that can expand a non-numeric range. For example, if you have <code>1A</code> to <code>9A</code> you should get </p> <pre><code>1A, 2A, 3A, 4A, 5A, 6A, 7A, 8A, 9A. </code></pre> <p>I've tried Googling for this and the best I could come up with were R...
[ { "answer_id": 45701, "author": "Gariig", "author_id": 1210, "author_profile": "https://Stackoverflow.com/users/1210", "pm_score": 0, "selected": false, "text": "<p>I was trying to leave it somewhat open because the number of possibilities is staggering. I believe this one of those ques...
2008/09/05
[ "https://Stackoverflow.com/questions/45642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1210/" ]
I was wondering if there is an open source library or algorithm that can expand a non-numeric range. For example, if you have `1A` to `9A` you should get ``` 1A, 2A, 3A, 4A, 5A, 6A, 7A, 8A, 9A. ``` I've tried Googling for this and the best I could come up with were Regex that would expand numerics with dashes (1-3 ...
As noted by others, it would be useful to be more specific. I don't think you can expect there to be a library that will generate ranges according to any arbitrary order on string you can come up with. If you can simply define what the successor of any given string is, then the solutions is quite easy. That is, if you...
45,653
<p>We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something tha...
[ { "answer_id": 45735, "author": "seanyboy", "author_id": 1726, "author_profile": "https://Stackoverflow.com/users/1726", "pm_score": 2, "selected": true, "text": "<p>Quickbooks talks .NET quite easily. You'll need the QuickBooks SDK 7.0 and a copy of Visual Studio.NET, but after that it'...
2008/09/05
[ "https://Stackoverflow.com/questions/45653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that d...
Quickbooks talks .NET quite easily. You'll need the QuickBooks SDK 7.0 and a copy of Visual Studio.NET, but after that it's very easy to do anything with Quickbooks. ``` Imports QBFC7Lib Sub AttachToDB() If isAttachedtoQB Then Exit Sub Lasterror = "Unknown QuickBooks Error" Try QbSession = New Q...
45,658
<p>I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the foll...
[ { "answer_id": 63430, "author": "gnobal", "author_id": 7748, "author_profile": "https://Stackoverflow.com/users/7748", "pm_score": 3, "selected": true, "text": "<p>I found the following code in the Google Gears code, <a href=\"http://code.google.com/p/gears/source/browse/trunk/gears/base...
2008/09/05
[ "https://Stackoverflow.com/questions/45658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4735/" ]
I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the followi...
I found the following code in the Google Gears code, [here](http://code.google.com/p/gears/source/browse/trunk/gears/base/ie/activex_utils.cc?r=2157). I copied the functions I think you need to here. The one you need is at the bottom (GetHtmlWindow2), but the other two are needed as well. Hopefully I didn't miss anythi...
45,732
<p>I have an object graph serialized to xaml. A rough sample of what it looks like is:</p> <pre><code>&lt;MyObject xmlns.... &gt; &lt;MyObject.TheCollection&gt; &lt;PolymorphicObjectOne .../&gt; &lt;HiImPolymorphic ... /&gt; &lt;/MyObject.TheCollection&gt; &lt;/MyObject&gt; </code></pre> <p>I...
[ { "answer_id": 45745, "author": "hakan", "author_id": 3993, "author_profile": "https://Stackoverflow.com/users/3993", "pm_score": 1, "selected": false, "text": "<p>I am not exactly sure about it but I believe GacRemove should do the same thing as gacutil /u. So, it should be the path of...
2008/09/05
[ "https://Stackoverflow.com/questions/45732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an object graph serialized to xaml. A rough sample of what it looks like is: ``` <MyObject xmlns.... > <MyObject.TheCollection> <PolymorphicObjectOne .../> <HiImPolymorphic ... /> </MyObject.TheCollection> </MyObject> ``` I want to use Linq to XML in order to extract the serialized obj...
I am using the `GacInstall` to publish my assemblies, however once installed into the gac, I sometimes delete my ‘temporary’ copy of the assemblies. And then, if I ever wanted to uninstall the assemblies from the gac I do not have the files at the original path. This is causing a problem since I cannot seem to get the...
45,769
<p>I'm curious about everyones practices when it comes to using or distributing libraries for an application that you write.</p> <p>First of all, when developing your application do you link the debug or release version of the libraries? (For when you run your application in debug mode)</p> <p>Then when you run your ...
[ { "answer_id": 46120, "author": "Henk", "author_id": 4613, "author_profile": "https://Stackoverflow.com/users/4613", "pm_score": 2, "selected": false, "text": "<p>I would first determine what requirements are needed from the library:</p>\n\n<ol>\n<li>Debug/Release</li>\n<li>Unicode suppo...
2008/09/05
[ "https://Stackoverflow.com/questions/45769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4225/" ]
I'm curious about everyones practices when it comes to using or distributing libraries for an application that you write. First of all, when developing your application do you link the debug or release version of the libraries? (For when you run your application in debug mode) Then when you run your app in release mo...
I would first determine what requirements are needed from the library: 1. Debug/Release 2. Unicode support 3. And so on.. With that determined you can then create configurations for each combination required by yourself or other library users. When compiling and linking it is very important that you keep that librar...
45,779
<p>How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired?</p> <p>It would seem using Reflection this isn't possible and I would ...
[ { "answer_id": 45795, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 0, "selected": false, "text": "<p>What you want can be achieved using dependency injection. For example <a href=\"http://msdn.microsoft.com/en-us/library/aa4804...
2008/09/05
[ "https://Stackoverflow.com/questions/45779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1111/" ]
How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired? It would seem using Reflection this isn't possible and I would like to av...
You can compile expression trees to use void methods without any arguments as event handlers for events of any type. To accommodate other event handler types, you have to map the event handler's parameters to the events somehow. ``` using System; using System.Linq; using System.Linq.Expressions; using System.Refl...
45,783
<p>My team is currently trying to automate the deployment of our .Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually.</p> <p>We require a solution that will enable us to:</p> <pre><code>- Compile the application - Version ...
[ { "answer_id": 45799, "author": "Jordi Bunster", "author_id": 4272, "author_profile": "https://Stackoverflow.com/users/4272", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.nongnu.org/fab/\" rel=\"nofollow noreferrer\">Fabric</a>. Seems small, simple, procedural. Writ...
2008/09/05
[ "https://Stackoverflow.com/questions/45783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4734/" ]
My team is currently trying to automate the deployment of our .Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually. We require a solution that will enable us to: ``` - Compile the application - Version the application with ...
Thank you all for your kind suggestions. We checked them all out, but after careful consideration we decided to roll our own with a combination of CruiseControl, NAnt, MSBuild and MSDeploy. This article has some great information: [Integrating MSBuild with CruiseControl.NET](http://dougrohm.com/blog/post/2006/01/29/In...
45,796
<p>Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content: </p> <ul> <li>Development team adding code. </li> <li>Business team adding simple web pages. </li> </ul> <p>For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project: </p> ...
[ { "answer_id": 45808, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "<p>Since the extensions will be ASPX, ASP.NET will pick up the request... you can write an HttpModule that checks for p...
2008/09/05
[ "https://Stackoverflow.com/questions/45796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/308/" ]
Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content: * Development team adding code. * Business team adding simple web pages. For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project: > > Root: for pages of development team ...
I don't have any way to test this right now, but I think you can use the -f flag on RewriteCond to check if a file exists, in either directory. ``` RewriteCond %{REQUEST_FILENAME} -!f RewriteCond Content/%{REQUEST_FILENAME} -f RewriteRule (.*) Content/(.*) ``` Something like that might do what you're after, too.
45,803
<ol> <li>Video podcast</li> <li>???</li> <li>Audio only mp3 player</li> </ol> <p>I'm looking for somewhere which will extract audio from video, but instead of a single file, for an on going video podcast.</p> <p>I would most like a website which would suck in the RSS and spit out an RSS (I'm thinking of something lik...
[ { "answer_id": 45810, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 0, "selected": false, "text": "<p>How to extract audio from video to MP3:</p>\n\n<p><a href=\"http://www.dvdvideosoft.com/guides/dvd/extract-audio-from-video-t...
2008/09/05
[ "https://Stackoverflow.com/questions/45803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4737/" ]
1. Video podcast 2. ??? 3. Audio only mp3 player I'm looking for somewhere which will extract audio from video, but instead of a single file, for an on going video podcast. I would most like a website which would suck in the RSS and spit out an RSS (I'm thinking of something like Feedburner), though would settle for ...
You could automate this using the open source command line tool ffmpeg. Parse the RSS to get the video files, fetch them over the net if needed, then spit each one out to a command line like this: ``` ffmpeg -i episode1.mov -ab 128000 episode1.mp3 ``` The -ab switch sets the output bit rate to 128 kbits/s on the aud...
45,813
<p>Is there a way with WPF to get an array of elements under the mouse on a MouseMove event?</p>
[ { "answer_id": 45817, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 2, "selected": false, "text": "<p>Can you use the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper.hittest.aspx\" rel=\"...
2008/09/05
[ "https://Stackoverflow.com/questions/45813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3291/" ]
Is there a way with WPF to get an array of elements under the mouse on a MouseMove event?
From "[WPF Unleashed](https://web.archive.org/web/20081205070201/http://adamnathan.net/wpf/)", page 383: > > Visual hit testing can inform you > about *all* `Visual`s that intersect a > location, [...] you must use [...] the > `[VisualTreeHelper.]HitTest` method that accepts a > `HitTestResultCallback` delegate. Befo...
45,824
<p>I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. </p> <p>I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated...
[ { "answer_id": 45825, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 0, "selected": false, "text": "<p>The reason Stack Overflow has accurate view counts is that it only count each view/user once.</p>\n\n<p>Third-party hit count...
2008/09/05
[ "https://Stackoverflow.com/questions/45824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3404/" ]
I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated and inacc...
An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request. For example, in the page... <http://www.example.com/examp...
45,827
<p>How do you automatically set the focus to a textbox when a web page loads?</p> <p>Is there an HTML tag to do it or does it have to be done via Javascript?</p>
[ { "answer_id": 45833, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 4, "selected": false, "text": "<p>You need to use javascript:</p>\n\n<pre><code>&lt;BODY onLoad=\"document.getElementById('myButton').focus();\"&gt;\n</code></...
2008/09/05
[ "https://Stackoverflow.com/questions/45827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
How do you automatically set the focus to a textbox when a web page loads? Is there an HTML tag to do it or does it have to be done via Javascript?
If you're using jquery: ``` $(function() { $("#Box1").focus(); }); ``` or prototype: ``` Event.observe(window, 'load', function() { $("Box1").focus(); }); ``` or plain javascript: ``` window.onload = function() { document.getElementById("Box1").focus(); }; ``` though keep in mind that this will replace o...
45,861
<p>I am using <a href="http://code.google.com/p/js2-mode/" rel="noreferrer">js2-mode</a> to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2.</p>
[ { "answer_id": 46174, "author": "Peter S. Housel", "author_id": 949, "author_profile": "https://Stackoverflow.com/users/949", "pm_score": 6, "selected": true, "text": "<p>Do you have</p>\n\n<pre>\n(setq-default indent-tabs-mode nil)\n</pre>\n\n<p>in your .emacs? It works fine for me in e...
2008/09/05
[ "https://Stackoverflow.com/questions/45861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4748/" ]
I am using [js2-mode](http://code.google.com/p/js2-mode/) to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2.
Do you have ``` (setq-default indent-tabs-mode nil) ``` in your .emacs? It works fine for me in emacs 23.0.60.1 when I do that. js2-mode uses the standard emacs function indent-to, which respects indent-tabs-mode, to do its indenting.
45,888
<p>I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's <code>text</code>, <code>value</code>, and <code>selected</code> properties, but I don't think that javascript's built in <code>Array.sort()</code> would work correctly.</p>
[ { "answer_id": 45890, "author": "travis", "author_id": 1414, "author_profile": "https://Stackoverflow.com/users/1414", "pm_score": 3, "selected": false, "text": "<p>Well, in IE6 it seems to sort on the nested array's [0] item:</p>\n\n<pre><code>function sortSelect(selectToSort) {\n va...
2008/09/05
[ "https://Stackoverflow.com/questions/45888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1414/" ]
I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's `text`, `value`, and `selected` properties, but I don't think that javascript's built in `Array.sort()` would work correctly.
Extract options into a temporary array, sort, then rebuild the list: ``` var my_options = $("#my_select option"); var selected = $("#my_select").val(); my_options.sort(function(a,b) { if (a.text > b.text) return 1; if (a.text < b.text) return -1; return 0 }) $("#my_select").empty().append( my_options ); ...
45,898
<p>In an application that I'm writing I have some code like this:</p> <pre><code>NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString* myurl = @"http://www.somewebsite.com/method?a=%d"; NSURL* url = [NSURL URLWithString:myurl]; [ws openURL:url]; </code></pre> <p>The main difference being that <em>myurl</em> co...
[ { "answer_id": 45905, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 2, "selected": false, "text": "<p>I think the behaviour here is correct, because %d is not a valid component of a URL (% is the escape, but expects two ...
2008/09/05
[ "https://Stackoverflow.com/questions/45898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2998/" ]
In an application that I'm writing I have some code like this: ``` NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString* myurl = @"http://www.somewebsite.com/method?a=%d"; NSURL* url = [NSURL URLWithString:myurl]; [ws openURL:url]; ``` The main difference being that *myurl* comes from somewhere outside my con...
I'm not sure if this is exactly what you're looking for, but there is a method in NSString that will sanitize a URL: [stringByAddingPercentEscapesUsingEncoding:](https://developer.apple.com/documentation/foundation/nsstring/1415058-stringbyaddingpercentescapesusin)
45,904
<p><strong>Situation:</strong></p> <p>I have a simple <em>XML</em> document that contains image information. I need to transform it into <em>HTML</em>. However, I can't see where the open tag is and when I use the <em>XSL</em> code below, it shows the following error message: </p> <blockquote> <p>"Cannot write an a...
[ { "answer_id": 45909, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 2, "selected": false, "text": "<p>Never mind -- I'm an idiot. I just needed <b>\n&lt;xsl:value-of select=\"/root/Image/node()\"/&gt;</b></p>\n" }, { ...
2008/09/05
[ "https://Stackoverflow.com/questions/45904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
**Situation:** I have a simple *XML* document that contains image information. I need to transform it into *HTML*. However, I can't see where the open tag is and when I use the *XSL* code below, it shows the following error message: > > "Cannot write an attribute node when no element start tag is open." > > > *...
Just to clarify the problem here - the error is in the following bit of code: ``` <xsl:attribute name="src"> <xsl:copy-of select="/root/Image/node()"/> </xsl:attribute> ``` The instruction xsl:copy-of takes a node or node-set and makes a copy of it - outputting a node or node-set. However an attribute cannot con...
45,908
<p>After answering on <a href="https://stackoverflow.com/questions/45650/common-files-in-visual-studio-solution#45664">this question</a> I thought it would be nice to collect some tips &amp; tricks for working with MSVS solutions and projects. </p> <p>Here is my list: </p> <ul> <li><p>How to avoid saving new projec...
[ { "answer_id": 45995, "author": "Craig", "author_id": 2894, "author_profile": "https://Stackoverflow.com/users/2894", "pm_score": 2, "selected": false, "text": "<p>I like changing the default location that new projects are saved to. </p>\n\n<p>Tools->Options (Select Projects and Solutio...
2008/09/05
[ "https://Stackoverflow.com/questions/45908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1196/" ]
After answering on [this question](https://stackoverflow.com/questions/45650/common-files-in-visual-studio-solution#45664) I thought it would be nice to collect some tips & tricks for working with MSVS solutions and projects. Here is my list: * How to avoid saving new projects automatically to reduce garbage in fil...
First rule of working with Visual Studio: * **Install [ReSharper](http://www.jetbrains.com/resharper/)**
45,924
<p>My users are having an intermittent error when using a Windows Forms application built in VB.NET 3.5. Apparently when they click on the form and the form re-paints, a red 'X' will be painted over the MenuStrip control and the app will crash with the following error. </p> <p>Has anyone seen this before? Can someone ...
[ { "answer_id": 45995, "author": "Craig", "author_id": 2894, "author_profile": "https://Stackoverflow.com/users/2894", "pm_score": 2, "selected": false, "text": "<p>I like changing the default location that new projects are saved to. </p>\n\n<p>Tools->Options (Select Projects and Solutio...
2008/09/05
[ "https://Stackoverflow.com/questions/45924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4770/" ]
My users are having an intermittent error when using a Windows Forms application built in VB.NET 3.5. Apparently when they click on the form and the form re-paints, a red 'X' will be painted over the MenuStrip control and the app will crash with the following error. Has anyone seen this before? Can someone point me i...
First rule of working with Visual Studio: * **Install [ReSharper](http://www.jetbrains.com/resharper/)**
45,941
<p>I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it.</p> <p>So, can someone give me a quick overview of how to track merg...
[ { "answer_id": 45978, "author": "Chris Zwiryk", "author_id": 734, "author_profile": "https://Stackoverflow.com/users/734", "pm_score": 3, "selected": true, "text": "<h3>Usage</h3>\n\n<p>Merge tracking is managed by the client and stored in a property (<a href=\"http://subversion.tigris.o...
2008/09/05
[ "https://Stackoverflow.com/questions/45941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it. So, can someone give me a quick overview of how to track merges in a bra...
### Usage Merge tracking is managed by the client and stored in a property ([svn:mergeinfo](http://subversion.tigris.org/merge-tracking/design.html)). To use merge tracking you just merge as usual but without the revision range: ``` svn merge trunkURL ``` The client will take care of reading the properties to see ...
45,953
<p>I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete.</p> <p>Any suggestions would be much appreciated.</p>
[ { "answer_id": 45962, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 2, "selected": false, "text": "<p>Can you arrange to fork off a separate process, and then run your copy in the background? It's been a while since I di...
2008/09/05
[ "https://Stackoverflow.com/questions/45953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1071/" ]
I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete. Any suggestions would be much appreciated.
Assuming this is running on a Linux machine, I've always handled it like this: ``` exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); ``` This launches the command `$cmd`, redirects the command output to `$outputfile`, and writes the process id to `$pidfile`. That lets you easily monitor wh...
45,964
<p>How do I multiply 10 to an <code>Integer</code> object and get back the <code>Integer</code> object?</p> <p>I am looking for the neatest way of doing this.</p> <p>I would probably do it this way: Get int from <code>Integer</code> object, multiply it with the other int and create another Integer object with this in...
[ { "answer_id": 45973, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 3, "selected": false, "text": "<p>The string approach is amusing, but almost certainly a bad way to do it.</p>\n\n<p>Getting the int value of an Integer...
2008/09/05
[ "https://Stackoverflow.com/questions/45964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4406/" ]
How do I multiply 10 to an `Integer` object and get back the `Integer` object? I am looking for the neatest way of doing this. I would probably do it this way: Get int from `Integer` object, multiply it with the other int and create another Integer object with this int value. Code will be something like ... ``` in...
With Java 5's [autoboxing](http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html), you can simply do: ``` Integer a = new Integer(2); // or even just Integer a = 2; a *= 10; System.out.println(a); ```
45,988
<p>In a C# .NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using <code>System.Windows.Forms.FolderBrowserDialog</code> but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of ...
[ { "answer_id": 45994, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 1, "selected": false, "text": "<p>Unfortunately there are no dialogs other than FolderBrowserDialog for folder selection. You need to create this dialog yoursel...
2008/09/05
[ "https://Stackoverflow.com/questions/45988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1367/" ]
In a C# .NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using `System.Windows.Forms.FolderBrowserDialog` but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC p...
Don't create it yourself! It's been done. You can use [FolderBrowserDialogEx](http://dotnetzip.codeplex.com/SourceControl/changeset/view/29832#432677) - a re-usable derivative of the built-in FolderBrowserDialog. This one allows you to type in a path, even a UNC path. You can also browse for computers or printers with...
45,991
<p>I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow.</p> <p>What is the best way to convert <code>==Heading==</code> to <code>&lt;h2&gt;Heading&lt;/h2&gt;</code>, ...
[ { "answer_id": 45998, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 3, "selected": true, "text": "<p>It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanit...
2008/09/05
[ "https://Stackoverflow.com/questions/45991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/681/" ]
I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow. What is the best way to convert `==Heading==` to `<h2>Heading</h2>`, or `--bold--` to `<b>bold</b>`? Can this be...
It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanitise the input to ensure you don't create any [cross site scripting](http://en.wikipedia.org/wiki/Cross-site_scripting) vulnerabilities. That said, you could probably do something pretty simple as you ...
46,003
<p>How can I change default <a href="http://msdn.microsoft.com/en-us/library/3a7hkh29.aspx" rel="nofollow noreferrer">Generate Method Stub</a> behavior in Visaul Studio to generate method with body</p> <pre><code>throw new NotImplementedException(); </code></pre> <p>instead of </p> <pre><code>throw new Exception("Th...
[ { "answer_id": 46016, "author": "Sam Wessel", "author_id": 4734, "author_profile": "https://Stackoverflow.com/users/4734", "pm_score": 4, "selected": true, "text": "<p>Taken from: <a href=\"http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx\" rel=\"noreferrer\">http://blogs.msdn...
2008/09/05
[ "https://Stackoverflow.com/questions/46003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361/" ]
How can I change default [Generate Method Stub](http://msdn.microsoft.com/en-us/library/3a7hkh29.aspx) behavior in Visaul Studio to generate method with body ``` throw new NotImplementedException(); ``` instead of ``` throw new Exception("The method or operation is not implemented."); ```
Taken from: <http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx> > > Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that i...
46,004
<p>We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return t...
[ { "answer_id": 46014, "author": "Matt Sheppard", "author_id": 797, "author_profile": "https://Stackoverflow.com/users/797", "pm_score": 0, "selected": false, "text": "<p>The load should just be a normal GET request, and the saving of new data should be a POST to the URL which currently h...
2008/09/05
[ "https://Stackoverflow.com/questions/46004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the ...
If you're submitting the data via plain HTML, you're restricted to doing a POST based form. The URI that the POST request is sent to **should not** be the URI for the resource being modified. You should either POST to a collection resource that ADDs a newly created resource each time (with the URI for the new resource ...
46,029
<p>If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into?</p...
[ { "answer_id": 46035, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 3, "selected": false, "text": "<p>I'd return some type of ValidationSummary for each one... or an IList depending on how you want to structure it.</p>...
2008/09/05
[ "https://Stackoverflow.com/questions/46029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1108/" ]
If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into? Spec...
Just an update on this: I decided to go with the [Decorator pattern](http://en.wikipedia.org/wiki/Decorator_pattern). That is, I have one 'generic' table class that implements an `IValidateableTable` interface (which contains `validate()` method). Then, I created several validation decorators (that also `implement IVal...
46,030
<p>So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem t...
[ { "answer_id": 46092, "author": "Dean Hill", "author_id": 3106, "author_profile": "https://Stackoverflow.com/users/3106", "pm_score": 5, "selected": true, "text": "<p>I also had trouble activating and bringing a window to the foreground. Here is the code that eventually worked for me. I'...
2008/09/05
[ "https://Stackoverflow.com/questions/46030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1358/" ]
So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem that...
I also had trouble activating and bringing a window to the foreground. Here is the code that eventually worked for me. I'm not sure if it will solve your problem. Basically, call ShowWindow() then SetForegroundWindow(). ``` using System.Diagnostics; using System.Runtime.InteropServices; // Sets the window to be fore...
46,034
<p>My work has a financial application, written in <code>VB.NET</code> with <code>SQL</code>, that several users can be working on at the same time.</p> <p>At some point, one user might decide to Post the batch of entries that they (and possibly other people) are currently working on.</p> <p>Obviously, I no longer wa...
[ { "answer_id": 46054, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 0, "selected": false, "text": "<p>add </p>\n\n<pre><code>with (rowlock)\n</code></pre>\n\n<p>to your SQL query</p>\n\n<p><a href=\"http://www.sql-server-perfo...
2008/09/05
[ "https://Stackoverflow.com/questions/46034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My work has a financial application, written in `VB.NET` with `SQL`, that several users can be working on at the same time. At some point, one user might decide to Post the batch of entries that they (and possibly other people) are currently working on. Obviously, I no longer want any other users to **add**, **edit**...
If you are using Oracle you would **Select for update** on the rows you are locking. here is an example ``` SELECT address1 , city, country FROM location FOR UPDATE; ```
46,079
<p>Details:</p> <ul> <li>Only disable after user clicks the submit button, but before the posting back to the server</li> <li>ASP.NET Webforms (.NET 1.1)</li> <li>Prefer jQuery (if any library at all)</li> <li>Must be enabled if form reloads (i.e. credit card failed)</li> </ul> <p>This isn't a necessity that I do thi...
[ { "answer_id": 46082, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 1, "selected": false, "text": "<p>in JQuery:</p>\n\n<pre><code>$('#SubmitButtonID').click(function() { this.disabled = true; });\n</code></pre>\n" }, { ...
2008/09/05
[ "https://Stackoverflow.com/questions/46079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1446/" ]
Details: * Only disable after user clicks the submit button, but before the posting back to the server * ASP.NET Webforms (.NET 1.1) * Prefer jQuery (if any library at all) * Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without ...
For all submit buttons, via JQuery, it'd be: ``` $('input[type=submit]').click(function() { this.disabled = true; }); ``` Or it might be more useful to do so on form submission: ``` $('form').submit(function() { $('input[type=submit]', this).attr("disabled","disabled"); }); ``` But I think we could give a bet...
46,080
<p>I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it?</p> <p>(My current strategy has been to copy the file into the new folder and check it in and then delete the file fr...
[ { "answer_id": 46083, "author": "Commodore Jaeger", "author_id": 4659, "author_profile": "https://Stackoverflow.com/users/4659", "pm_score": 8, "selected": true, "text": "<p>Subversion has native support for moving files.</p>\n\n<pre><code>svn move SOURCE DESTINATION\n</code></pre>\n\n<p...
2008/09/05
[ "https://Stackoverflow.com/questions/46080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file into the new folder and check it in and then delete the file from the cur...
Subversion has native support for moving files. ``` svn move SOURCE DESTINATION ``` See the online help (svn help move) for more information.
46,096
<p>I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"?</p> <pre><code>var selectVar = arrayVar.Select( (a,i) =&gt; new { Line = a }); var selectVar = from s in arrayVar select new ...
[ { "answer_id": 46104, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 3, "selected": true, "text": "<ul>\n<li>First - calling an extension method. \nThis style of coding is called \"<a href=\"http://www.martinfowler.com/bliki/Flue...
2008/09/05
[ "https://Stackoverflow.com/questions/46096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"? ``` var selectVar = arrayVar.Select( (a,i) => new { Line = a }); var selectVar = from s in arrayVar select new { Line = s }; ``...
* First - calling an extension method. This style of coding is called "[fluent interface](http://www.martinfowler.com/bliki/FluentInterface.html)" as you mentioned. * Second method is called [language integrated query](http://en.wikipedia.org/wiki/Language_Integrated_Query)
46,124
<p>I've seen people doing things like this in their HTML:</p> <pre><code>&lt;!--[if IE]&gt; &lt;link rel="stylesheet" href="ie.css" type="text/css" /&gt; &lt;![endif]--&gt; </code></pre> <p>Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement?<...
[ { "answer_id": 46126, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 5, "selected": true, "text": "<p>This works across all browsers because anything except IE sees <code>&lt;!--IGNORED COMMENT--&gt;</code>. Only IE reads the co...
2008/09/05
[ "https://Stackoverflow.com/questions/46124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
I've seen people doing things like this in their HTML: ``` <!--[if IE]> <link rel="stylesheet" href="ie.css" type="text/css" /> <![endif]--> ``` Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement? **Edit** Thanks [Ross](https://stackoverfl...
This works across all browsers because anything except IE sees `<!--IGNORED COMMENT-->`. Only IE reads the comment if it contains a conditional clause. Have a look at [this article](http://www.quirksmode.org/css/condcom.html) You can also specify which version of IE. For example: ``` <!--[if IE 8]> <link rel="stylesh...
46,125
<p>I want to do this: </p> <blockquote> <p>//*fu</p> </blockquote> <p>which returns all nodes whose name ends in <strong>fu</strong>, such as <code>&lt;tarfu /&gt;</code> and <code>&lt;snafu /&gt;</code>, but not <code>&lt;fubar /&gt;</code></p>
[ { "answer_id": 46141, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 6, "selected": true, "text": "<p>Do something like:</p>\n\n<pre><code>//*[ends-with(name(), 'fu')]\n</code></pre>\n\n<p>For a good XPath reference, ...
2008/09/05
[ "https://Stackoverflow.com/questions/46125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to do this: > > //\*fu > > > which returns all nodes whose name ends in **fu**, such as `<tarfu />` and `<snafu />`, but not `<fubar />`
Do something like: ``` //*[ends-with(name(), 'fu')] ``` For a good XPath reference, check out [W3Schools](http://www.w3schools.com/xml/xsl_functions.asp).
46,130
<p>I have a list of <code>Foo</code>. Foo has properties <code>Bar</code> and <code>Lum</code>. Some <code>Foo</code>s have identical values for <code>Bar</code>. How can I use lambda/linq to group my <code>Foo</code>s by <code>Bar</code> so I can iterate over each grouping's <code>Lum</code>s?</p>
[ { "answer_id": 46142, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "<pre><code>var q = from x in list\n group x by x.Bar into g\n select g;\n\nforeach (var group in q)\n{\n Console...
2008/09/05
[ "https://Stackoverflow.com/questions/46130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1946/" ]
I have a list of `Foo`. Foo has properties `Bar` and `Lum`. Some `Foo`s have identical values for `Bar`. How can I use lambda/linq to group my `Foo`s by `Bar` so I can iterate over each grouping's `Lum`s?
[Deeno](https://stackoverflow.com/questions/46130/how-do-i-group-in-memory-lists#46317), Enjoy: ``` var foos = new List<Foo> { new Foo{Bar = 1,Lum = 1}, new Foo{Bar = 1,Lum = 2}, new Foo{Bar = 2,Lum = 3}, }; // Using language integrated queries: var q = from foo in foos group foo by foo.Bar into gr...
46,136
<p>I have a large codebase that targetted Flash 7, with a <em>lot</em> of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code.</p> <p>The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would...
[ { "answer_id": 46184, "author": "lilserf", "author_id": 4545, "author_profile": "https://Stackoverflow.com/users/4545", "pm_score": 4, "selected": true, "text": "<p>Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3:</p>\n\n<h3>Package naming</h3>...
2008/09/05
[ "https://Stackoverflow.com/questions/46136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1409/" ]
I have a large codebase that targetted Flash 7, with a *lot* of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code. The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the cu...
Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3: ### Package naming ``` class your.package.YourClass { } ``` becomes ``` package your.package { class YourClass { } } ``` ### Imports are required You must explicitly import any outside classes used -- referr...
46,146
<p>Looking for a string to pass to String#matches(String) that will match IPv4, and another to match IPv6.</p>
[ { "answer_id": 46168, "author": "Kevin Wong", "author_id": 4792, "author_profile": "https://Stackoverflow.com/users/4792", "pm_score": 4, "selected": false, "text": "<pre><code>public static final String IPV4_REGEX = \"\\\\A(25[0-5]|2[0-4]\\\\d|[0-1]?\\\\d?\\\\d)(\\\\.(25[0-5]|2[0-4]\\\\...
2008/09/05
[ "https://Stackoverflow.com/questions/46146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4792/" ]
Looking for a string to pass to String#matches(String) that will match IPv4, and another to match IPv6.
``` public static final String IPV4_REGEX = "\\A(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\z"; public static final String IPV6_HEX4DECCOMPRESSED_REGEX = "\\A((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?) ::((?:[0-9A-Fa-f]{1,4}:)*)(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0...
46,155
<p>I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?</p>
[ { "answer_id": 46170, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 7, "selected": false, "text": "<p>JavaScript can match a regular expression:</p>\n<pre><code>emailAddress.match( / some_regex /);\n</code></pre>\n<p>H...
2008/09/05
[ "https://Stackoverflow.com/questions/46155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72/" ]
I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?
Using [regular expressions](http://en.wikipedia.org/wiki/Regular_expression) is probably the best way. You can see a bunch of tests [here](http://jsfiddle.net/ghvj4gy9/embedded/result,js/) (taken from [chromium](https://cs.chromium.org/chromium/src/third_party/blink/web_tests/fast/forms/resources/ValidityState-typeMism...
46,189
<p>I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ?</p>
[ { "answer_id": 46206, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 3, "selected": true, "text": "<pre><code>var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3, ..., newprop = newProperty}\n</code></...
2008/09/05
[ "https://Stackoverflow.com/questions/46189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ?
``` var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3, ..., newprop = newProperty} ```
46,219
<p>If I have a </p> <pre><code>&lt;input id="uploadFile" type="file" /&gt; </code></pre> <p>tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user.</p> <p>In FF, I just do:</p> <pre><code>var selected = document.getElementById("uploadBox").files.length &gt; 0; </cod...
[ { "answer_id": 46242, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 8, "selected": true, "text": "<p>This works in IE (and FF, I believe):</p>\n\n<pre><code>if(document.getElementById(\"uploadBox\").value != \"\") {\n ...
2008/09/05
[ "https://Stackoverflow.com/questions/46219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/698/" ]
If I have a ``` <input id="uploadFile" type="file" /> ``` tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user. In FF, I just do: ``` var selected = document.getElementById("uploadBox").files.length > 0; ``` But that doesn't work in IE.
This works in IE (and FF, I believe): ``` if(document.getElementById("uploadBox").value != "") { // you have a file } ```
46,220
<p>I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging. Essentially my app displays an image and when touched plays a short sound. When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it cr...
[ { "answer_id": 46357, "author": "amrox", "author_id": 4468, "author_profile": "https://Stackoverflow.com/users/4468", "pm_score": 6, "selected": true, "text": "<p>(This isn't really iPhone specific - the same thing will happen in regular Cocoa).</p>\n\n<p>NSUnknownKeyException is a commo...
2008/09/05
[ "https://Stackoverflow.com/questions/46220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2293/" ]
I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging. Essentially my app displays an image and when touched plays a short sound. When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crash...
(This isn't really iPhone specific - the same thing will happen in regular Cocoa). NSUnknownKeyException is a common error when using [Key-Value Coding](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/KeyValueCoding.html) to access a key that the object doesn't have. Th...
46,282
<p>I am using a class library which represents some of its configuration in .xml. The configuration is read in using the <code>XmlSerializer</code>. Fortunately, the classes which represent the .xml use the <code>XmlAnyElement</code> attribute at which allows me to extend the configuration data for my own purposes with...
[ { "answer_id": 46378, "author": "Ed Schwehm", "author_id": 1206, "author_profile": "https://Stackoverflow.com/users/1206", "pm_score": 5, "selected": true, "text": "<p>So you need to have your class contain custom configuration information, then serialize that class to XML, then make tha...
2008/09/05
[ "https://Stackoverflow.com/questions/46282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599/" ]
I am using a class library which represents some of its configuration in .xml. The configuration is read in using the `XmlSerializer`. Fortunately, the classes which represent the .xml use the `XmlAnyElement` attribute at which allows me to extend the configuration data for my own purposes without modifying the origina...
So you need to have your class contain custom configuration information, then serialize that class to XML, then make that serialized XML into an XML node: is that right? Could you just take the string created by the XMLSerializer and wrap that in it's own XML tags? ``` XmlSerializer xs = new XmlSerializer(typeof(MyCo...
46,324
<p>I'm going to guess that the answer is "no" based on the below error message (and <a href="http://archives.postgresql.org/pgsql-sql/2004-08/msg00076.php" rel="noreferrer">this Google result</a>), but is there anyway to perform a cross-database query using PostgreSQL?</p> <pre><code>databaseA=# select * from database...
[ { "answer_id": 46336, "author": "stimms", "author_id": 361, "author_profile": "https://Stackoverflow.com/users/361", "pm_score": 5, "selected": false, "text": "<p>I have run into this before an came to the same conclusion about cross database queries as you. What I ended up doing was us...
2008/09/05
[ "https://Stackoverflow.com/questions/46324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I'm going to guess that the answer is "no" based on the below error message (and [this Google result](http://archives.postgresql.org/pgsql-sql/2004-08/msg00076.php)), but is there anyway to perform a cross-database query using PostgreSQL? ``` databaseA=# select * from databaseB.public.someTableName; ERROR: cross-data...
*Note: As the original asker implied, if you are setting up two databases on the same machine you probably want to make two [schemas](https://www.postgresql.org/docs/current/static/ddl-schemas.html) instead - in that case you don't need anything special to query across them.* `postgres_fdw` -------------- Use [`postg...
46,338
<p>I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication i...
[ { "answer_id": 46356, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 5, "selected": true, "text": "<p>In general, you don't want to create objects inside an object. That's a bad habit, instead, write a clear API and inject a mod...
2008/09/05
[ "https://Stackoverflow.com/questions/46338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication insi...
In general, you don't want to create objects inside an object. That's a bad habit, instead, write a clear API and inject a model into your model. ``` <?php // in your controller $model1 = new Model1(); $model2 = new Model2(); $model2->setWhatever($model1); ?> ```
46,346
<p>Any ideas on how to implement tab completion for a .NET (C#) Console Application? And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: </p> <pre><code> string line = string.Empty; while (line != "exit") { ...
[ { "answer_id": 46352, "author": "Andrew Burns", "author_id": 3683, "author_profile": "https://Stackoverflow.com/users/3683", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.console.readkey.aspx\" rel=\"nofollow noreferrer\">Console.R...
2008/09/05
[ "https://Stackoverflow.com/questions/46346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
Any ideas on how to implement tab completion for a .NET (C#) Console Application? And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: ``` string line = string.Empty; while (line != "exit") { //do som...
Take a look at this code from the Mono project <http://tirania.org/blog/archive/2008/Aug-26.html> I played with it some the other day. It does a lot of command line editingy, but I don't think it does line completion.
46,347
<p>Is there a clean way to redirect all attempts to going to an HTTP:// version of a site to its HTTPS:// equivalent?</p>
[ { "answer_id": 46418, "author": "slipsec", "author_id": 1635, "author_profile": "https://Stackoverflow.com/users/1635", "pm_score": -1, "selected": false, "text": "<p>I think by 'cleanly' you mean like with a 300 redirect. Config for a lot of servers &amp; languages <a href=\"http://www...
2008/09/05
[ "https://Stackoverflow.com/questions/46347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2312/" ]
Is there a clean way to redirect all attempts to going to an HTTP:// version of a site to its HTTPS:// equivalent?
I think the cleanest way is as described [here on IIS-aid.com](http://www.iis-aid.com/articles/how_to_guides/redirect_http_to_https_iis_7). It's web.config only and so if you change server you don't have to remember all the steps you went through with the 403.4 custom error page or other special permissions, it just wo...
46,350
<p>After lots of attempts and search I have never found a satisfactory way to do it with CSS2.</p> <p>A simple way to accomplish it is to wrap it into a handy <code>&lt;table&gt;</code> as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks?</p> <p><div class="snip...
[ { "answer_id": 46364, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 2, "selected": false, "text": "<p>This is going to be the lamest answer, but it works:</p>\n\n<p><a href=\"http://www.w3schools.com/TAGS/tag_center.as...
2008/09/05
[ "https://Stackoverflow.com/questions/46350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4264/" ]
After lots of attempts and search I have never found a satisfactory way to do it with CSS2. A simple way to accomplish it is to wrap it into a handy `<table>` as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks? ```css table { margin: 0 auto; } ``` ```html ...
@Jason, yep, `<center>` works. Good times. I'll propose the following, though: ```css body { text-align: center; } .my-centered-content { margin: 0 auto; /* Centering */ display: inline; } ``` ```html <div class="my-centered-content"> <p>test</p> <p>test</p> </div> ``` **EDIT** @Santi, a block-le...
46,354
<p>I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine:</p> <pre><code>SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') </code></pre> <p>But if I try to add:</p> <pre><code>WHERE "Value" &gt; 0 </code></pre> <p>I get an error</p> <blockquote> <p>In...
[ { "answer_id": 46375, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 0, "selected": false, "text": "<p>Oh, bummer. I just saw, you select AS FOO. Don't you need a HAVING claus in this case?</p>\n\n<pre><code>SELECT whatever AS v...
2008/09/05
[ "https://Stackoverflow.com/questions/46354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1807/" ]
I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine: ``` SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') ``` But if I try to add: ``` WHERE "Value" > 0 ``` I get an error > > Invalid column name 'Value' > > > Any ideas what I might be doing wr...
This should work: ``` SELECT A.Value FROM ( SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') ) AS a WHERE a.Value > 0 ``` It's not that Value is a reserved word, the problem is that it's a column alias, not the column name. By making it an inline view, "Value" becomes the column name and can t...
46,365
<p>We have a SQL Server 2005 SP2 machine running a large number of databases, all of which contain full-text catalogs. Whenever we try to drop one of these databases or rebuild a full-text index, the drop or rebuild process hangs indefinitely with a MSSEARCH wait type. The process can’t be killed, and a server reboot i...
[ { "answer_id": 49073, "author": "Booji Boy", "author_id": 1433, "author_profile": "https://Stackoverflow.com/users/1433", "pm_score": 1, "selected": false, "text": "<p>Have you tried running process monitor and when it hangs and see what the underlying error is? Using process moniter you...
2008/09/05
[ "https://Stackoverflow.com/questions/46365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4803/" ]
We have a SQL Server 2005 SP2 machine running a large number of databases, all of which contain full-text catalogs. Whenever we try to drop one of these databases or rebuild a full-text index, the drop or rebuild process hangs indefinitely with a MSSEARCH wait type. The process can’t be killed, and a server reboot is r...
Here's a suggestion. I don't have any corrupted databases but you can try this: ``` declare @t table (name nvarchar(128)) insert into @t select name from sys.databases --where is_fulltext_enabled while exists(SELECT * FROM @t) begin declare @name nvarchar(128) select @name = name from @t declare @SQL nva...
46,377
<p>What is the syntax for placing constraints on multiple types? The basic example:</p> <pre><code>class Animal&lt;SpeciesType&gt; where SpeciesType : Species </code></pre> <p>I would like to place constraints on both types in the following definition such that <code>SpeciesType</code> must inherit from <code>Specie...
[ { "answer_id": 46384, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 7, "selected": true, "text": "<pre><code>public class Animal&lt;SpeciesType,OrderType&gt;\n where SpeciesType : Species\n where OrderType : Order\n{\n...
2008/09/05
[ "https://Stackoverflow.com/questions/46377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
What is the syntax for placing constraints on multiple types? The basic example: ``` class Animal<SpeciesType> where SpeciesType : Species ``` I would like to place constraints on both types in the following definition such that `SpeciesType` must inherit from `Species` and `OrderType` must inherit from `Order`: ``...
``` public class Animal<SpeciesType,OrderType> where SpeciesType : Species where OrderType : Order { } ```
46,385
<p>What's the best way to delete all rows from a table in sql but to keep n number of rows on the top? </p>
[ { "answer_id": 46386, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 7, "selected": true, "text": "<pre><code>DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table)\n</code></pre>\n\n<p><strong>Edit:</strong> </p>\n...
2008/09/05
[ "https://Stackoverflow.com/questions/46385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/298/" ]
What's the best way to delete all rows from a table in sql but to keep n number of rows on the top?
``` DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table) ``` **Edit:** Chris brings up a good performance hit since the TOP 10 query would be run for each row. If this is a one time thing, then it may not be as big of a deal, but if it is a common thing, then I did look closer at it.
46,387
<p>I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option.</p> <p><a href="http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1" rel="nofollow noreferrer">http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1</a></p> <p>There is a version 1.2, already...
[ { "answer_id": 46405, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": true, "text": "<p>Is the number of extra bytes you need equal to the number of lines in the file? I ask because perhaps its possible that so...
2008/09/05
[ "https://Stackoverflow.com/questions/46387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4527/" ]
I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option. <http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1> There is a version 1.2, already tested and get the same issue. The post looks something like this. ``` Host: foo.appspot.com User-Agent: ...
Is the number of extra bytes you need equal to the number of lines in the file? I ask because perhaps its possible that somehow carriage-returns are being introduced but not counted.
46,425
<p>I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why?</p> <pre><code>(defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (&gt; x elem) (setf xst (remove elem xs)))) xst)) </code...
[ { "answer_id": 46437, "author": "Ben Collins", "author_id": 3279, "author_profile": "https://Stackoverflow.com/users/3279", "pm_score": 4, "selected": true, "text": "<p>I think it's this line that's not right:</p>\n\n<pre><code>(setf xst (remove elem xs))))\n</code></pre>\n\n<p>The first...
2008/09/05
[ "https://Stackoverflow.com/questions/46425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2450/" ]
I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why? ``` (defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (> x elem) (setf xst (remove elem xs)))) xst)) ```
I think it's this line that's not right: ``` (setf xst (remove elem xs)))) ``` The first argument to `setf` is the place, followed by the value. It looks like you have it backwards (and `xst` is either `nil` or uninitialized). You might find it easier to do this: ``` (defun biggerElems (x xs) (remove-if (lambda ...
46,454
<p>I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?</p>
[ { "answer_id": 46463, "author": "Oded", "author_id": 1583, "author_profile": "https://Stackoverflow.com/users/1583", "pm_score": 2, "selected": false, "text": "<p>I would use the AutoScrollOffset property and set it the the bottom left of the WebBrowser control, so something like:</p>\n\...
2008/09/05
[ "https://Stackoverflow.com/questions/46454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1385358/" ]
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?
Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was ``` webCtrl.Document.Window.ScrollTo(0, int.MaxValue); ```
46,482
<p>Is there an easy way to read an entire Access file (.mdb) into a DataSet in .NET (specifically C# or VB)?</p> <p>Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet?</p>
[ { "answer_id": 46490, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 2, "selected": false, "text": "<p>You should be able to access it using an <a href=\"http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnect...
2008/09/05
[ "https://Stackoverflow.com/questions/46482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1108/" ]
Is there an easy way to read an entire Access file (.mdb) into a DataSet in .NET (specifically C# or VB)? Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet?
Thanks for the suggestions. I was able to use those samples to put together this code, which seems to achieve what I'm looking for. ``` Using cn = New OleDbConnection(connectionstring) cn.Open() Dim ds As DataSet = new DataSet() Dim Schema As DataTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New ...
46,483
<p>What are the differences between <code>htmlspecialchars()</code> and <code>htmlentities()</code>. When should I use one or the other?</p>
[ { "answer_id": 46491, "author": "Thomas Owens", "author_id": 572, "author_profile": "https://Stackoverflow.com/users/572", "pm_score": 10, "selected": true, "text": "<p>From the PHP documentation for <a href=\"http://us2.php.net/htmlentities\" rel=\"noreferrer\">htmlentities</a>:</p>\n\n...
2008/09/05
[ "https://Stackoverflow.com/questions/46483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4137/" ]
What are the differences between `htmlspecialchars()` and `htmlentities()`. When should I use one or the other?
From the PHP documentation for [htmlentities](http://us2.php.net/htmlentities): > > This function is identical to `htmlspecialchars()` in all ways, except with `htmlentities()`, all characters which have HTML character entity equivalents are translated into these entities. > > > From the PHP documentation for [h...
46,489
<p>In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using <code>ClientScriptManager.GetWebResourceUrl()</code>. However, in some of my js files, I have references to other static assets like image urls. I would like to make those ass...
[ { "answer_id": 47242, "author": "Jon", "author_id": 4764, "author_profile": "https://Stackoverflow.com/users/4764", "pm_score": 3, "selected": true, "text": "<p>I'd suggest that you emit the web resources as a dynamic javascript associative array.</p>\n\n<p>Server side code:</p>\n\n<pre>...
2008/09/05
[ "https://Stackoverflow.com/questions/46489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67/" ]
In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using `ClientScriptManager.GetWebResourceUrl()`. However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resource...
I'd suggest that you emit the web resources as a dynamic javascript associative array. Server side code: ``` StringBuilder script = new StringBuilder(); script.Append("var imgResources = {};"); script.AppendFormat("imgResources['{0}'] = '{1}';", "drophint", Page.ClientScript.GetWebResourceUrl(Page.GetType()...
46,495
<p>Why can't you do this and is there are work around?</p> <p>You get this error.</p> <p>Msg 2714, Level 16, State 1, Line 13 There is already an object named '#temptable' in the database.</p> <pre><code>declare @x int set @x = 1 if (@x = 0) begin select 1 as Value into #temptable end else begin select 2 as...
[ { "answer_id": 46527, "author": "Craig", "author_id": 2894, "author_profile": "https://Stackoverflow.com/users/2894", "pm_score": 0, "selected": false, "text": "<p>I am going to guess that the issue is that you haven't created the #temptable.</p>\n\n<p>Sorry I can't be more detailed but ...
2008/09/05
[ "https://Stackoverflow.com/questions/46495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2184/" ]
Why can't you do this and is there are work around? You get this error. Msg 2714, Level 16, State 1, Line 13 There is already an object named '#temptable' in the database. ``` declare @x int set @x = 1 if (@x = 0) begin select 1 as Value into #temptable end else begin select 2 as Value into #temptable end ...
This is a two-part question and while Kev Fairchild provides a good answer to the second question he totally ignores the first - *why is the error produced?* The answer lies in the way the preprocessor works. This ``` SELECT field-list INTO #symbol ... ``` is resolved into a parse-tree that is directly equivalent t...
46,532
<p>If I have an XElement that has child elements, and if I remove a child element from the parent, removing all references between the two, will the child XElement have the same namespaces as the parent?</p> <p>In other words, if I have the following XML:</p> <pre><code>&lt;parent xmlns:foo="abc"&gt; &lt;foo:chil...
[ { "answer_id": 46637, "author": "xanadont", "author_id": 1886, "author_profile": "https://Stackoverflow.com/users/1886", "pm_score": 1, "selected": false, "text": "<p>Sure. Ultimately the image comes from a URL of some sort. Do a view-source on the web page and see what that URL looks ...
2008/09/05
[ "https://Stackoverflow.com/questions/46532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I have an XElement that has child elements, and if I remove a child element from the parent, removing all references between the two, will the child XElement have the same namespaces as the parent? In other words, if I have the following XML: ``` <parent xmlns:foo="abc"> <foo:child /> </parent> ``` and I rem...
Sure. Ultimately the image comes from a URL of some sort. Do a view-source on the web page and see what that URL looks like. With a certain amount of reverse-engineering, usage of System.Web.UI.HtmlTextWriter, perhaps an HttpHandler, etc. you should be able to get what you want.
46,571
<p>I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding <code>&lt;cfqueryparam</code>> tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfque...
[ { "answer_id": 47197, "author": "Adam Tuttle", "author_id": 751, "author_profile": "https://Stackoverflow.com/users/751", "pm_score": 7, "selected": true, "text": "<p>@Joel, I have to disagree.</p>\n\n<pre><code>select a,b,c\nfrom Foo\nwhere name like &lt;cfqueryparam cfsqltype=\"columnT...
2008/09/05
[ "https://Stackoverflow.com/questions/46571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3271/" ]
I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding `<cfqueryparam`> tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfqueryparam with the LI...
@Joel, I have to disagree. ``` select a,b,c from Foo where name like <cfqueryparam cfsqltype="columnType" value="%#variables.someName#%" /> ``` 1. Never suggest to someone that they should "select star." Bad form! Even for an example! (Even copied from the question!) 2. The query is pre-compiled and you should inclu...
46,582
<p>We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET.</p> <p>I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple ...
[ { "answer_id": 46611, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 2, "selected": false, "text": "<p>PostbackUrl can be set on your asp button to post to a different page.</p>\n\n<p>if you need to do it in codebehind, try Ser...
2008/09/05
[ "https://Stackoverflow.com/questions/46582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET. I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple other page,...
Doing this requires understanding how HTTP redirects work. When you use `Response.Redirect()`, you send a response (to the browser that made the request) with [HTTP Status Code 302](http://en.wikipedia.org/wiki/HTTP_302), which tells the browser where to go next. By definition, the browser will make that via a `GET` re...
46,585
<p>From what I can gather, there are three categories:</p> <ol> <li>Never use <code>GET</code> and use <code>POST</code></li> <li>Never use <code>POST</code> and use <code>GET</code></li> <li>It doesn't matter which one you use.</li> </ol> <p>Am I correct in assuming those three cases? If so, what are some examples f...
[ { "answer_id": 46591, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 3, "selected": false, "text": "<p>Use GET when you want the URL to reflect the state of the page. This is useful for viewing dynamically generated pages, ...
2008/09/05
[ "https://Stackoverflow.com/questions/46585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
From what I can gather, there are three categories: 1. Never use `GET` and use `POST` 2. Never use `POST` and use `GET` 3. It doesn't matter which one you use. Am I correct in assuming those three cases? If so, what are some examples from each case?
Use `POST` for destructive actions such as creation (I'm aware of the irony), editing, and deletion, because you can't hit a `POST` action in the address bar of your browser. Use `GET` when it's safe to allow a person to call an action. So a URL like: ``` http://myblog.org/admin/posts/delete/357 ``` Should bring you...
46,586
<p>Everyone is aware of Dijkstra's <a href="http://portal.acm.org/citation.cfm?doid=362947" rel="noreferrer">Letters to the editor: go to statement considered harmful</a> (also <a href="http://www.cs.utexas.edu/%7EEWD/transcriptions/EWD02xx/EWD215.html" rel="noreferrer">here</a> .html transcript and <a href="http://www...
[ { "answer_id": 46597, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 3, "selected": false, "text": "<p>The original paper should be thought of as \"Unconditional GOTO Considered Harmful\". It was in particular advocatin...
2008/09/05
[ "https://Stackoverflow.com/questions/46586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
Everyone is aware of Dijkstra's [Letters to the editor: go to statement considered harmful](http://portal.acm.org/citation.cfm?doid=362947) (also [here](http://www.cs.utexas.edu/%7EEWD/transcriptions/EWD02xx/EWD215.html) .html transcript and [here](http://www.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF) .pdf) and there ...
The following statements are generalizations; while it is always possible to plead exception, it usually (in my experience and humble opinion) isn't worth the risks. 1. Unconstrained use of memory addresses (either GOTO or raw pointers) provides too many opportunities to make easily avoidable mistakes. 2. The more way...
46,636
<p>What's the best way to copy a file from a network share to the local file system using a Windows batch file? Normally, I would use "net use *" but using this approach how can I get the drive letter?</p>
[ { "answer_id": 46640, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 5, "selected": true, "text": "<p>Can you just use the full UNC path to the file?</p>\n\n<pre><code>copy \\\\myserver\\myshare\\myfolder\\myfile.txt c:\\myfi...
2008/09/05
[ "https://Stackoverflow.com/questions/46636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4778/" ]
What's the best way to copy a file from a network share to the local file system using a Windows batch file? Normally, I would use "net use \*" but using this approach how can I get the drive letter?
Can you just use the full UNC path to the file? ``` copy \\myserver\myshare\myfolder\myfile.txt c:\myfiles ```
46,663
<p>Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute the application. Answers with any of using Hotmail, Yahoo or GMail are acceptable.</p>
[ { "answer_id": 46676, "author": "Ryan Farley", "author_id": 1627, "author_profile": "https://Stackoverflow.com/users/1627", "pm_score": 0, "selected": false, "text": "<p>An easy route would be to have the gmail account configured/enabled for POP3 access. This would allow you to send out ...
2008/09/05
[ "https://Stackoverflow.com/questions/46663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
Is it possible to send an email from my Java application using a GMail account? I have configured my company mail server with Java app to send email, but that's not going to cut it when I distribute the application. Answers with any of using Hotmail, Yahoo or GMail are acceptable.
First download the [JavaMail API](https://java.net/projects/javamail/pages/Home) and make sure the relevant jar files are in your classpath. Here's a full working example using GMail. ``` import java.util.*; import javax.mail.*; import javax.mail.internet.*; public class Main { private static String USER_NAME =...
46,704
<p>For the following HTML:</p> <pre><code>&lt;form name=&quot;myForm&quot;&gt; &lt;label&gt;One&lt;input name=&quot;area&quot; type=&quot;radio&quot; value=&quot;S&quot; /&gt;&lt;/label&gt; &lt;label&gt;Two&lt;input name=&quot;area&quot; type=&quot;radio&quot; value=&quot;R&quot; /&gt;&lt;/label&gt; &l...
[ { "answer_id": 46715, "author": "Adam Cuzzort", "author_id": 4760, "author_profile": "https://Stackoverflow.com/users/4760", "pm_score": 1, "selected": false, "text": "<pre><code>$(function() {\n $('input[@type=\"radio\"]').click(radioClicks);\n});\n</code></pre>\n" }, { "answ...
2008/09/05
[ "https://Stackoverflow.com/questions/46704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
For the following HTML: ``` <form name="myForm"> <label>One<input name="area" type="radio" value="S" /></label> <label>Two<input name="area" type="radio" value="R" /></label> <label>Three<input name="area" type="radio" value="O" /></label> <label>Four<input name="area" type="radio" value="U" /><...
``` $( function() { $("input:radio") .click(radioClicks) .filter("[value='S']") .attr("checked", "checked"); }); ```
46,718
<p>I'm just curious how most people make their ASP.NET pages printer-friendly? Do you create a separate printer-friendly version of the ASPX page, use CSS or something else? How do you handle situations like page breaks and wide tables?</p> <p>Is there one elegant solution that works for the majority of the cases? </p...
[ { "answer_id": 46724, "author": "Ryan Farley", "author_id": 1627, "author_profile": "https://Stackoverflow.com/users/1627", "pm_score": 5, "selected": true, "text": "<p>You basically make another CSS file that hide things or gives simpler \"printer-friendly\" style to things then add tha...
2008/09/05
[ "https://Stackoverflow.com/questions/46718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3329/" ]
I'm just curious how most people make their ASP.NET pages printer-friendly? Do you create a separate printer-friendly version of the ASPX page, use CSS or something else? How do you handle situations like page breaks and wide tables? Is there one elegant solution that works for the majority of the cases?
You basically make another CSS file that hide things or gives simpler "printer-friendly" style to things then add that with a `media="print"` so that it only applies to print media (when it is printed) ``` <link rel="stylesheet" type="text/css" media="print" href="print.css" /> ```
46,719
<p>I have a regex call that I need help with.</p> <p>I haven't posted my regex, because it is not relevant here. What I want to be able to do is, during the Replace, I also want to modify the ${test} portion by doing a Html.Encode on the entire text that is effecting the regex.</p> <p>Basically, wrap the entire text ...
[ { "answer_id": 46722, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "<p>Don't use Regex.Replace in this case... use..</p>\n\n<pre><code>foreach(Match in Regex.Matches(...))\n{\n //do y...
2008/09/05
[ "https://Stackoverflow.com/questions/46719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
I have a regex call that I need help with. I haven't posted my regex, because it is not relevant here. What I want to be able to do is, during the Replace, I also want to modify the ${test} portion by doing a Html.Encode on the entire text that is effecting the regex. Basically, wrap the entire text that is within th...
Heres an implementation of this I've used to pick out special replace strings from content and localize them. ``` protected string FindAndTranslateIn(string content) { return Regex.Replace(content, @"\{\^(.+?);(.+?)?}", new MatchEvaluator(TranslateHandler), RegexOptions.IgnoreCase); ...
46,777
<p>I want to run a web application on php and mysql, using the CakePHP framework. And to keep the threshold of using the site at a very low place, I want to not use the standard login with username/password. (And I don't want to hassle my users with something like OpenID either. Goes to user type.)</p> <p>So I'm think...
[ { "answer_id": 46792, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 2, "selected": false, "text": "<p>You'll need some sort of CronJob/Timer Service that checks the Mailbox regularly and then acts on it. Alternatively, you ...
2008/09/05
[ "https://Stackoverflow.com/questions/46777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4013/" ]
I want to run a web application on php and mysql, using the CakePHP framework. And to keep the threshold of using the site at a very low place, I want to not use the standard login with username/password. (And I don't want to hassle my users with something like OpenID either. Goes to user type.) So I'm thinking that t...
I have used the [pop3 php class](http://www.phpclasses.org/browse/file/3.html) with great success (there is also a [Pear POP3 module](http://pear.php.net/package/Net_POP3)). Using the pop3 class looks something like this: ``` require ('pop3.php'); $pop3 = new pop3_class(); $pop3->hostname = MAILHOST; $pop3->Open(); ...
46,827
<p>Visual Studio 2005 doesn't provide an interface for creating relationships between tables in a SQL Server CE database (I'm using version 3.0) and you can't open a Compact Edition DB using Management Studio as far as I know. Any ideas?</p>
[ { "answer_id": 46832, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 7, "selected": true, "text": "<p>Unfortunately there is currently no designer support (unlike for SQL Server 2005) for building relationships between tables in...
2008/09/05
[ "https://Stackoverflow.com/questions/46827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1943/" ]
Visual Studio 2005 doesn't provide an interface for creating relationships between tables in a SQL Server CE database (I'm using version 3.0) and you can't open a Compact Edition DB using Management Studio as far as I know. Any ideas?
Unfortunately there is currently no designer support (unlike for SQL Server 2005) for building relationships between tables in SQL Server CE. To build relationships you need to use SQL commands such as: ``` ALTER TABLE Orders ADD CONSTRAINT FK_Customer_Order FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId) `...
46,841
<p>Occasionally, on a ASP (classic) site users will get this error:</p> <pre><code>[DBNETLIB][ConnectionRead (recv()).]General network error. </code></pre> <p>Seems to be random and not connected to any particular page. The SQL server is separated from the web server and my guess is that every once and a while the "...
[ { "answer_id": 47080, "author": "Grzegorz Gierlik", "author_id": 1483, "author_profile": "https://Stackoverflow.com/users/1483", "pm_score": 0, "selected": false, "text": "<p>I'd seen this error many times. It could be caused by many things including network errors too :).</p>\n\n<p>But ...
2008/09/05
[ "https://Stackoverflow.com/questions/46841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4835/" ]
Occasionally, on a ASP (classic) site users will get this error: ``` [DBNETLIB][ConnectionRead (recv()).]General network error. ``` Seems to be random and not connected to any particular page. The SQL server is separated from the web server and my guess is that every once and a while the "link" goes down between the...
Using the same setup as yours (ie separate web and database server), I've seen it from time to time and it has always been a connection problem between the servers - typically when the database server is being rebooted but sometimes when there's a comms problem somewhere in the system. I've not seen it triggered by any...
46,842
<p>What is the best way to determine duplicate records in a SQL Server table?</p> <p>For instance, I want to find the last duplicate email received in a table (table has primary key, receiveddate and email fields).</p> <p>Sample data:</p> <pre><code>1 01/01/2008 [email protected] 2 02/01/2008 [email protected] 3 01/1...
[ { "answer_id": 46843, "author": "Rob Rolnick", "author_id": 4798, "author_profile": "https://Stackoverflow.com/users/4798", "pm_score": 0, "selected": false, "text": "<p>Couldn't you join the list on the e-mail field and then see what nulls you get in your result?</p>\n\n<p>Or better yet...
2008/09/05
[ "https://Stackoverflow.com/questions/46842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the best way to determine duplicate records in a SQL Server table? For instance, I want to find the last duplicate email received in a table (table has primary key, receiveddate and email fields). Sample data: ``` 1 01/01/2008 [email protected] 2 02/01/2008 [email protected] 3 01/12/2008 [email protected] ```
something like this ``` select email ,max(receiveddate) as MaxDate from YourTable group by email having count(email) > 1 ```
46,863
<p>How do I concatenate together two strings, of unknown length, in COBOL? So for example:</p> <pre><code>WORKING-STORAGE. FIRST-NAME PIC X(15) VALUE SPACES. LAST-NAME PIC X(15) VALUE SPACES. FULL-NAME PIC X(31) VALUE SPACES. </code></pre> <p>If <code>FIRST-NAME = 'JOHN '</code> and <...
[ { "answer_id": 46899, "author": "Eric H", "author_id": 4650, "author_profile": "https://Stackoverflow.com/users/4650", "pm_score": 2, "selected": false, "text": "<p>At first glance, the solution is to use reference modification to STRING together the two strings, including the space. The...
2008/09/05
[ "https://Stackoverflow.com/questions/46863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4650/" ]
How do I concatenate together two strings, of unknown length, in COBOL? So for example: ``` WORKING-STORAGE. FIRST-NAME PIC X(15) VALUE SPACES. LAST-NAME PIC X(15) VALUE SPACES. FULL-NAME PIC X(31) VALUE SPACES. ``` If `FIRST-NAME = 'JOHN '` and `LAST-NAME = 'DOE '`, how can I get: ``` FULL-N...
I believe the following will give you what you desire. ``` STRING FIRST-NAME DELIMITED BY " ", " ", LAST-NAME DELIMITED BY SIZE INTO FULL-NAME. ```
46,898
<p>If I have an object implementing the <code>Map</code> interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map?</p> <p>Will the ordering of elements depend on the specific map implementation that I have for the interface?</p>
[ { "answer_id": 46905, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 8, "selected": false, "text": "<p>Yes, the order depends on the specific Map implementation.</p>\n\n<p><a href=\"https://stackoverflow.com/questions/46898/...
2008/09/05
[ "https://Stackoverflow.com/questions/46898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4807/" ]
If I have an object implementing the `Map` interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of elements depend on the specific map implementation that I have for the interface?
```java Map<String, String> map = ... for (Map.Entry<String, String> entry : map.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue()); } ``` On Java 10+: ```java for (var entry : map.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue()); } ```
46,907
<pre><code>INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]') </code></pre> <p>I've got an Access table that has five fields: id, ename, position, phone, and email...each one is plain text field with 50 characters, save fo...
[ { "answer_id": 46916, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 0, "selected": false, "text": "<p>The spacing of \"Web Developer / Network Assistant\" looks a little wonky, maybe there is a hidden character in there...
2008/09/05
[ "https://Stackoverflow.com/questions/46907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4252/" ]
``` INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]') ``` I've got an Access table that has five fields: id, ename, position, phone, and email...each one is plain text field with 50 characters, save for position which is...
I beleive "position" is a reserved word. Try... INSERT into tblExcel (ename, [position], phone, email) VALUES (... [Reserved Words](http://office.microsoft.com/en-us/access/HP010322491033.aspx)
46,909
<p>I have a situation where I might have multiple instances of a program running at once, and it's important that just one specific function not be executing in more than one of these instances at once.</p> <p>Is this the proper way to use a mutex to prevent this from happening?</p> <pre><code>lock (this.GetType()) {...
[ { "answer_id": 46928, "author": "Jonathan Webb", "author_id": 1518, "author_profile": "https://Stackoverflow.com/users/1518", "pm_score": 3, "selected": false, "text": "<p>TheSeeker is correct.</p>\n\n<p>Jeff Richter's advice in <a href=\"http://books.google.com/books?id=C-V_AAAACAAJ&amp...
2008/09/05
[ "https://Stackoverflow.com/questions/46909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I have a situation where I might have multiple instances of a program running at once, and it's important that just one specific function not be executing in more than one of these instances at once. Is this the proper way to use a mutex to prevent this from happening? ``` lock (this.GetType()) { _log.Info("Doing...
You said multiple instances of one application, so we're talking about two program.exe's running, right? The lock statement won't lock across multiple programs, just within the program. If you want a true Mutex, look at the [System.Threading.Mutex](https://learn.microsoft.com/en-us/dotnet/api/system.threading.mutex) ob...
46,915
<p>As a follow up to this question: <a href="https://stackoverflow.com/questions/46873/developing-a-online-exam-application-how-do-i-prevent-cheaters">Developing a online exam application, how do I prevent cheaters?</a></p> <p>Can I detect when Flex application looses its focus? that is if a user has clicked onto anot...
[ { "answer_id": 47161, "author": "Raleigh Buckner", "author_id": 1153, "author_profile": "https://Stackoverflow.com/users/1153", "pm_score": 4, "selected": true, "text": "<p>The key part of the code at that link is the </p>\n\n<pre><code>systemManager.stage.addEventListener(Event.DEACTIVA...
2008/09/05
[ "https://Stackoverflow.com/questions/46915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
As a follow up to this question: [Developing a online exam application, how do I prevent cheaters?](https://stackoverflow.com/questions/46873/developing-a-online-exam-application-how-do-i-prevent-cheaters) Can I detect when Flex application looses its focus? that is if a user has clicked onto another application or op...
The key part of the code at that link is the ``` systemManager.stage.addEventListener(Event.DEACTIVATE,deactivate); ``` The Flash player send outs activate and deactivate events when the focus enters and leaves the player. All you need to do is create a listenr for them and react appropriately. A more clear exampl...
46,924
<p>Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first given a list of keyword, and must then answer if another given word was in the list. </p> <p>In an imperative language, I would store the keywords in a tree (one node per character). Then, when receiving a word to test...
[ { "answer_id": 46948, "author": "Rob Rolnick", "author_id": 4798, "author_profile": "https://Stackoverflow.com/users/4798", "pm_score": 0, "selected": false, "text": "<p>I imagine you'd want something like a tree with a list of children, as described <a href=\"http://csus.cs.mcgill.ca/wi...
2008/09/05
[ "https://Stackoverflow.com/questions/46924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4177/" ]
Suppose I want to implement a reasonably efficient 'keyword recognition algorithm', that is first given a list of keyword, and must then answer if another given word was in the list. In an imperative language, I would store the keywords in a tree (one node per character). Then, when receiving a word to test, I would ...
I think what you mean is a character per node... sort of like a simple hash tree scheme for keyword lookup. Assuming this or even another kind of tree... imagine doing something like this (in pseudo-LISP): ``` (defun buildtree (wordlist) ...code to build tree recursively returns the tree...) (define lookup (tree word)...
46,933
<p>I'm having some inheritance issues as I've got a group of inter-related abstract classes that need to all be overridden together to create a client implementation. Ideally I would like to do something like the following:</p> <pre><code>abstract class Animal { public Leg GetLeg() {...} } abstract class Leg { } ...
[ { "answer_id": 46935, "author": "shsteimer", "author_id": 292, "author_profile": "https://Stackoverflow.com/users/292", "pm_score": 2, "selected": false, "text": "<p>GetLeg() must return Leg to be an override. Your Dog class however, can still return DogLeg objects since they are a chil...
2008/09/05
[ "https://Stackoverflow.com/questions/46933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
I'm having some inheritance issues as I've got a group of inter-related abstract classes that need to all be overridden together to create a client implementation. Ideally I would like to do something like the following: ``` abstract class Animal { public Leg GetLeg() {...} } abstract class Leg { } class Dog : Ani...
The short answer is that GetLeg is invariant in its return type. The long answer can be found here: [Covariance and contravariance](http://blogs.msdn.com/ericlippert/archive/2007/10/16/covariance-and-contravariance-in-c-part-one.aspx) I'd like to add that while inheritance is usually the first abstraction tool that mo...
46,981
<p>I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event.</p> <p>The data structure and the service logic are al...
[ { "answer_id": 47294, "author": "Jonathan Parker", "author_id": 4504, "author_profile": "https://Stackoverflow.com/users/4504", "pm_score": 1, "selected": false, "text": "<p>Have you tried implementing <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropert...
2008/09/05
[ "https://Stackoverflow.com/questions/46981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580/" ]
I have an Image control with it's source bound to a property on an object(string url to an image). After making a service call, i update the data object with a new URL. The exception is thrown after it leaves my code, after invoking the PropertyChanged event. The data structure and the service logic are all done in a ...
``` System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => {...}); ``` Also look [here.](https://stackoverflow.com/questions/1924408/invalid-cross-thread-access-issue/1925827#1925827)
47,007
<p>A question that occasionally arises is what is the best way to determine the changelist that you last synced to in Perforce. This is often needed for things like injecting the changelist number into the revision info by the automatic build system.</p>
[ { "answer_id": 47012, "author": "Greg Whitfield", "author_id": 2102, "author_profile": "https://Stackoverflow.com/users/2102", "pm_score": 5, "selected": false, "text": "<p>Just to answer this myself in keeping with Jeff's suggestion of using Stackoverflow as a place to keep technical sn...
2008/09/05
[ "https://Stackoverflow.com/questions/47007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2102/" ]
A question that occasionally arises is what is the best way to determine the changelist that you last synced to in Perforce. This is often needed for things like injecting the changelist number into the revision info by the automatic build system.
I recommend the opposite for automatic build systems: you should first get the latest changelist from the server using: ``` p4 changes -s submitted -m1 ``` then sync to that change and record it in the revision info. The reason is as follows. Although [Perforce recommends the following](https://portal.perforce.com/s...
47,022
<p>I've somehow managed to get an SVN repository into a bad state. I've moved a directory and now I can't commit it in its new location.</p> <p>As far as <code>svn status</code> is concerned, the directory is unknown (the name of the directory is <code>type</code>).</p> <pre> $ svn status ? type </pre> <p>When ...
[ { "answer_id": 47030, "author": "crashmstr", "author_id": 1441, "author_profile": "https://Stackoverflow.com/users/1441", "pm_score": 2, "selected": false, "text": "<p>Did you start by just copying/moving the directory with OS commands, or did you start with SVN stuff? If you just copied...
2008/09/05
[ "https://Stackoverflow.com/questions/47022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I've somehow managed to get an SVN repository into a bad state. I've moved a directory and now I can't commit it in its new location. As far as `svn status` is concerned, the directory is unknown (the name of the directory is `type`). ``` $ svn status ? type ``` When I try to add the directory, the server say...
It looks to me like `type` was created by some Subversion-aware copy command, then moved into the current directory using a Subversion-unaware copy. In my experience, this sort of thing typically occurs when package refactoring operations have been chained together in Eclipse without commits in between. Typically, Subv...
47,045
<p>Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this? </p>
[ { "answer_id": 47049, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 10, "selected": true, "text": "<pre><code>// Store the formatted string in 'result'\nString result = String.format(\"%4d\", i * j);\n\n// Write the re...
2008/09/05
[ "https://Stackoverflow.com/questions/47045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4498/" ]
Printf got added to Java with the 1.5 release but I can't seem to find how to send the output to a string rather than a file (which is what sprintf does in C). Does anyone know how to do this?
``` // Store the formatted string in 'result' String result = String.format("%4d", i * j); // Write the result to standard output System.out.println( result ); ``` See [format](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)) and its [syntax](http://docs...
47,052
<p>I'm looking to convert a SQL like statement on the fly to the equivalent regex i.e. </p> <pre><code>LIKE '%this%' LIKE 'Sm_th' LIKE '[C-P]arsen' </code></pre> <p>What's the best approach to doing this?</p> <p>P.S. I'm looking to do this on the .Net Framework (C#).</p>
[ { "answer_id": 47075, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": -1, "selected": false, "text": "<p>I found a Perl module called <a href=\"http://search.cpan.org/dist/Regexp-Wildcards/lib/Regexp/Wildcards.pm\" rel=\...
2008/09/05
[ "https://Stackoverflow.com/questions/47052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4843/" ]
I'm looking to convert a SQL like statement on the fly to the equivalent regex i.e. ``` LIKE '%this%' LIKE 'Sm_th' LIKE '[C-P]arsen' ``` What's the best approach to doing this? P.S. I'm looking to do this on the .Net Framework (C#).
The following Regex converts an SQL like pattern into a Regex pattern with the help of a [`MatchEvaluator`](http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx) delegate. It correctly handles square bracket blocks and escapes special Regex characters. ``` string regexPattern = "^...
47,066
<p>I am writing a C program in Linux. Commands like execv() require a path in the form of a C string. Is there a command that will return the current path in the form of a C-style string?</p>
[ { "answer_id": 47071, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html\" rel=\"nofollow noreferrer\">getcwd()<...
2008/09/05
[ "https://Stackoverflow.com/questions/47066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/159/" ]
I am writing a C program in Linux. Commands like execv() require a path in the form of a C string. Is there a command that will return the current path in the form of a C-style string?
[getcwd()](http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html): > > ### *SYNOPSIS* > > > > ``` > #include <unistd.h> > > char *getcwd(char *buf, size_t size); > > ``` > > ### *DESCRIPTION* > > > The *getcwd()* function shall place an absolute pathname of the current working directory in the a...
47,078
<p>We are currently using the ExtJS tree view in an application - a requirement has arisen requiring a user to select multiple nodes (which the tree view supports currently through a pluggable selection model) - but you can not then drag the multiple selections to another part of the tree.</p> <p>Does anyone know of a...
[ { "answer_id": 48901, "author": "Candidasa", "author_id": 5010, "author_profile": "https://Stackoverflow.com/users/5010", "pm_score": 2, "selected": false, "text": "<p>Check out this post in the ExtJS forum that details how you can enable multi-select in a Javascript tree.</p>\n\n<p><a h...
2008/09/05
[ "https://Stackoverflow.com/questions/47078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4843/" ]
We are currently using the ExtJS tree view in an application - a requirement has arisen requiring a user to select multiple nodes (which the tree view supports currently through a pluggable selection model) - but you can not then drag the multiple selections to another part of the tree. Does anyone know of an ajax con...
Got the same issue. I just found the solution : ``` ..new Ext.tree.TreePanel({ ... selModel : new Ext.tree.MultiSelectionModel() ... }) ```
47,089
<p>About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over http I would response.redirect("<a href="https://example.com" rel="nore...
[ { "answer_id": 47095, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 9, "selected": true, "text": "<p>Please use <a href=\"https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security\" rel=\"noreferrer\">HSTS</a> (HTTP St...
2008/09/05
[ "https://Stackoverflow.com/questions/47089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4846/" ]
About 6 months ago I rolled out a site where every request needed to be over https. The only way at the time I could find to ensure that every request to a page was over https was to check it in the page load event. If the request was not over http I would response.redirect("<https://example.com>") Is there a better w...
Please use [HSTS](https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security) (HTTP Strict Transport Security) from <http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx> ``` <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <r...
47,104
<p>Can anyone explain this behavior or how to get around it?</p> <p>If you execute this query:</p> <pre><code>select * from TblA left join freetexttable ( TblB, *, 'query' ) on TblA.ID = [Key] inner join DifferentDbCatalog.dbo.TblC on TblA.ID = TblC.TblAID </code></pre> <p>It will be very very very slow.</p> <p>If...
[ { "answer_id": 47109, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Index the field you use to perform the join.</p>\n\n<p>A good rule of thumb is to assign an index to any commonly referenced...
2008/09/05
[ "https://Stackoverflow.com/questions/47104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4407/" ]
Can anyone explain this behavior or how to get around it? If you execute this query: ``` select * from TblA left join freetexttable ( TblB, *, 'query' ) on TblA.ID = [Key] inner join DifferentDbCatalog.dbo.TblC on TblA.ID = TblC.TblAID ``` It will be very very very slow. If you change that query to use two inner ...
A general rule of thumb is that OUTER JOINs cause the number of rows in a result set to *increase,* while INNER JOINs cause the number of rows in a result set to *decrease.* Of course, there are plenty of scenarios where the opposite is true as well, but it's more likely to work this way than not. What you want to do f...
47,107
<p>Is there a way to disallow publishing of debug builds with ClickOnce?</p> <p>I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while. </p> <p>We're publishing the build from within Visual Studio.</p>
[ { "answer_id": 865822, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 3, "selected": false, "text": "<p>One thing you can do is add a condition to the .csproj or .vbproj file that MSBuild will check when doing a b...
2008/09/05
[ "https://Stackoverflow.com/questions/47107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3641/" ]
Is there a way to disallow publishing of debug builds with ClickOnce? I only want to allow release builds through, but right now human error causes a debug build to slip through once in a while. We're publishing the build from within Visual Studio.
I have started to modify the .csproj files to include the following code to throw an error for debug deploys, effectively preventing the deploy from happening: ``` <!-- The following makes sure we don’t try to publish a configuration that defines the DEBUG constant --> <Target Name="BeforePublish"> <Error Conditio...
47,144
<p>In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments...
[ { "answer_id": 47147, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 3, "selected": true, "text": "<p>The situations under which a ThreadAbortException will be generated can be complex. A better option might be to ask why ...
2008/09/06
[ "https://Stackoverflow.com/questions/47144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4850/" ]
In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments, i...
The situations under which a ThreadAbortException will be generated can be complex. A better option might be to ask why you are using ThreadAbortExceptions at all. A better pattern would be to simply use a flag to indicate to the running thread that it should abort, and then test the flag regularly while it is working...
47,169
<p>I'd like to enable/disable some other controls based on how many items are in my <code>ListView</code> control. I can't find any event that would do this, either on the <code>ListView</code> itself or on the <code>ListViewItemCollection</code>. Maybe there's a way to generically watch any collection in C# for change...
[ { "answer_id": 47178, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 0, "selected": false, "text": "<p>I can't find any events that you could use. Perhaps you could subclass ListViewItemCollection, and raise your own event wh...
2008/09/06
[ "https://Stackoverflow.com/questions/47169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3191/" ]
I'd like to enable/disable some other controls based on how many items are in my `ListView` control. I can't find any event that would do this, either on the `ListView` itself or on the `ListViewItemCollection`. Maybe there's a way to generically watch any collection in C# for changes? I'd be happy with other events t...
@Domenic Not too sure, Never quite got that far in the thought process. Another solution might be to extend ListView, and when adding and removing stuff, instead of calling .items.add, and items.remove, you call your other functions. It would still be possible to add and remove without events being raised, but with ...
47,207
<p>Can i print out a url <code>/admin/manage/products/add</code> of a certain view in a template?</p> <p>Here is the rule i want to create a link for</p> <pre><code>(r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}), </code></pre> <p>I would like to have /manage/products/add in ...
[ { "answer_id": 47212, "author": "Peter Hoffmann", "author_id": 720, "author_profile": "https://Stackoverflow.com/users/720", "pm_score": 2, "selected": false, "text": "<p>If you use <a href=\"https://docs.djangoproject.com/en/1.2/topics/http/urls/#naming-url-patterns\" rel=\"nofollow nor...
2008/09/06
[ "https://Stackoverflow.com/questions/47207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
Can i print out a url `/admin/manage/products/add` of a certain view in a template? Here is the rule i want to create a link for ``` (r'^manage/products/add/$', create_object, {'model': Product, 'post_save_redirect': ''}), ``` I would like to have /manage/products/add in a template without hardcoding it. How can i ...
You can use `get_absolute_url`, but that will only work for a particular object. Since your object hasn't been created yet, it won't work in this case. You want to use [named URL patterns](https://docs.djangoproject.com/en/1.2/topics/http/urls/#naming-url-patterns). Here's a quick intro: Change the line in your urls....
47,239
<p>Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by...
[ { "answer_id": 47251, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 1, "selected": false, "text": "<p>For complex types, you can recursively convert each one that you come across into a table of its own and then attempt ...
2008/09/06
[ "https://Stackoverflow.com/questions/47239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4550/" ]
Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by han...
It's really late, and I only spent about 10 minutes on this, so its extremely sloppy, however it does work and will give you a good jumping off point: ``` using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace TableGenerator { class Program { static void ...