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
30,188
<p>I am trying to set a <code>javascript</code> <code>date</code> so that it can be submitted via <code>JSON</code> to a <code>.NET</code> type, but when attempting to do this, <code>jQuery</code> sets the <code>date</code> to a full <code>string</code>, what format does it have to be in to be converted to a <code>.NET...
[ { "answer_id": 30241, "author": "Timothy Fries", "author_id": 3163, "author_profile": "https://Stackoverflow.com/users/3163", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://support.microsoft.com/kb/320687\" rel=\"nofollow noreferrer\" title=\"KB Article 320687\">Microsoft ...
2008/08/27
[ "https://Stackoverflow.com/questions/30188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993/" ]
I am trying to set a `javascript` `date` so that it can be submitted via `JSON` to a `.NET` type, but when attempting to do this, `jQuery` sets the `date` to a full `string`, what format does it have to be in to be converted to a `.NET` type? ``` var regDate = student.RegistrationDate.getMonth() + "/" + student.Regist...
[Microsoft KB Article 320687](http://support.microsoft.com/kb/320687 "KB Article 320687") has a detailed answer to this question. Basically, you override the WndProc method to return HTCAPTION to the WM\_NCHITTEST message when the point being tested is in the client area of the form -- which is, in effect, telling Win...
30,211
<p>Is the ZIP compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript?</p> <p>I realize that this is possible using <a href="http://en.wikipedia.org/wiki/WinZip" rel="noreferrer">WinZip</a>,...
[ { "answer_id": 30369, "author": "brian newman", "author_id": 3210, "author_profile": "https://Stackoverflow.com/users/3210", "pm_score": 1, "selected": false, "text": "<p>There are both zip and unzip executables (as well as a boat load of other useful applications) in the UnxUtils packag...
2008/08/27
[ "https://Stackoverflow.com/questions/30211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1414/" ]
Is the ZIP compression that is built into Windows XP/Vista/2003/2008 able to be scripted at all? What executable would I have to call from a BAT/CMD file? or is it possible to do it with VBScript? I realize that this is possible using [WinZip](http://en.wikipedia.org/wiki/WinZip), [7-Zip](http://en.wikipedia.org/wiki/...
There are VBA methods to [zip](http://www.rondebruin.nl/win/s7/win001.htm) and [unzip](http://www.rondebruin.nl/win/s7/win002.htm) using the windows built in compression as well, which should give some insight as to how the system operates. You may be able to build these methods into a scripting language of your choice...
30,222
<p>I am writing a query in which I have to get the data for only the last year. What is the best way to do this?</p> <pre><code>SELECT ... FROM ... WHERE date &gt; '8/27/2007 12:00:00 AM' </code></pre>
[ { "answer_id": 30229, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 9, "selected": true, "text": "<p>The following adds -1 years to the current date:</p>\n\n<pre><code>SELECT ... From ... WHERE date &gt; DATEADD(year,-1,GE...
2008/08/27
[ "https://Stackoverflow.com/questions/30222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
I am writing a query in which I have to get the data for only the last year. What is the best way to do this? ``` SELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM' ```
The following adds -1 years to the current date: ``` SELECT ... From ... WHERE date > DATEADD(year,-1,GETDATE()) ```
30,230
<p>I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P</p> <p>I googled around and it seems like the default behavior should be for enter (or control-enter) to...
[ { "answer_id": 30246, "author": "juan", "author_id": 1782, "author_profile": "https://Stackoverflow.com/users/1782", "pm_score": 0, "selected": false, "text": "<p>I suspect it's (like you say) some custom javascript code.</p>\n\n<p>The original asp.net control works fine... you are going...
2008/08/27
[ "https://Stackoverflow.com/questions/30230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2462/" ]
I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P I googled around and it seems like the default behavior should be for enter (or control-enter) to insert a ...
It turns out this is a bug with Firefox + ASP.NET where the generated javascript for the defaultButton stuff doesn't work in Firefox. I had to put a replacement for the WebForm\_FireDefatultButton function as described [here](http://forums.asp.net/t/1294544.aspx): ``` function WebForm_FireDefaultButton(event, target) ...
30,239
<p>I have an images folder with a png in it. I would like to set a MenuItem's icon to that png. How do I write this in procedural code?</p>
[ { "answer_id": 30285, "author": "Timothy Fries", "author_id": 3163, "author_profile": "https://Stackoverflow.com/users/3163", "pm_score": 7, "selected": true, "text": "<pre><code>menutItem.Icon = new System.Windows.Controls.Image \n { \n Source = new BitmapImage(new Uri(\...
2008/08/27
[ "https://Stackoverflow.com/questions/30239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
I have an images folder with a png in it. I would like to set a MenuItem's icon to that png. How do I write this in procedural code?
``` menutItem.Icon = new System.Windows.Controls.Image { Source = new BitmapImage(new Uri("images/sample.png", UriKind.Relative)) }; ```
30,286
<p>I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a property on one of the user controls like</p> <pre><code>myUserControl.SomeProperty = someValue; </code></pre> <p>I get a <code>NullReferenceException</code>. When I debug, I found out that <code>myUserControl</code> is null. How is it poss...
[ { "answer_id": 30301, "author": "Jay Mooney", "author_id": 733, "author_profile": "https://Stackoverflow.com/users/733", "pm_score": 4, "selected": true, "text": "<p>Where are you trying to access the property? If you are in onInit, the control may not be loaded yet.</p>\n" }, { ...
2008/08/27
[ "https://Stackoverflow.com/questions/30286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a property on one of the user controls like ``` myUserControl.SomeProperty = someValue; ``` I get a `NullReferenceException`. When I debug, I found out that `myUserControl` is null. How is it possible that a user control handle is null? How do ...
Where are you trying to access the property? If you are in onInit, the control may not be loaded yet.
30,288
<p>Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single dimension arrays are the same?</p>
[ { "answer_id": 30292, "author": "Jason", "author_id": 3242, "author_profile": "https://Stackoverflow.com/users/3242", "pm_score": 4, "selected": false, "text": "<p>There's a very simple way of comparing two arrays using CFML's underlying java. According to a recent blog by Rupesh Kumar o...
2008/08/27
[ "https://Stackoverflow.com/questions/30288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3242/" ]
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single dimension arrays are the same?
Assuming all of the values in the array are simple values, the easiest thing might be to convert the arrays to lists and just do string compares. ``` <cfif arrayToList(arrayA) IS arrayToList(arrayB)> Arrays are equal! </cfif> ``` Not as elegant as other solutions offered, but dead simple.
30,297
<p>I just requested a hotfix from support.microsoft.com and put in my email address, but I haven't received the email yet. The splash page I got after I requested the hotfix said:</p> <blockquote> <p><strong>Hotfix Confirmation</strong></p> <p>We will send these hotfixes to the following e-mail address:</p> <pre><code>...
[ { "answer_id": 30652, "author": "Joseph Bui", "author_id": 3275, "author_profile": "https://Stackoverflow.com/users/3275", "pm_score": 2, "selected": false, "text": "<p>Divide your services by resource requirements at the very least. For example, if you are running a photo album site, se...
2008/08/27
[ "https://Stackoverflow.com/questions/30297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179/" ]
I just requested a hotfix from support.microsoft.com and put in my email address, but I haven't received the email yet. The splash page I got after I requested the hotfix said: > > **Hotfix Confirmation** > > > We will send these hotfixes to the following e-mail address: > > > > ``` > (my correct email address)...
Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer l...
30,302
<p>I'd like to ignore multiple wildcard routes. With asp.net mvc preview 4, they ship with:</p> <pre><code>RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); </code></pre> <p>I'd also like to add something like:</p> <pre><code>RouteTable.Routes.IgnoreRoute("Content/{*pathInfo}"); </code></pre> <p>but tha...
[ { "answer_id": 30353, "author": "Brad Wilson", "author_id": 1554, "author_profile": "https://Stackoverflow.com/users/1554", "pm_score": 3, "selected": false, "text": "<p>This can be quite tricky.</p>\n\n<p>When attempting to figure out how to map route data into a route, the system curre...
2008/08/27
[ "https://Stackoverflow.com/questions/30302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3085/" ]
I'd like to ignore multiple wildcard routes. With asp.net mvc preview 4, they ship with: ``` RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ``` I'd also like to add something like: ``` RouteTable.Routes.IgnoreRoute("Content/{*pathInfo}"); ``` but that seems to break some of the helpers that generate...
There are two possible solutions here. 1. Add a constraint to the ignore route to make sure that only requests that should be ignored would match that route. Kinda kludgy, but it should work. ``` RouteTable.Routes.IgnoreRoute("{folder}/{*pathInfo}", new {folder="content"}); ``` 2. What is in your content directory? ...
30,307
<p>I'm doing some PHP stuff on an Ubuntu server.</p> <p>The path I'm working in is <strong>/mnt/dev-windows-data/Staging/mbiek/test_list</strong> but the PHP call <code>getcwd()</code> is returning <strong>/mnt/dev-windows/Staging/mbiek/test_list</strong> (notice how it's dev-windows instead of dev-windows-data).</p> ...
[ { "answer_id": 30313, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 2, "selected": true, "text": "<p>Which file are you calling the getcwd() in and is that file is included into the one you are running (e.g. running index.php, ...
2008/08/27
[ "https://Stackoverflow.com/questions/30307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
I'm doing some PHP stuff on an Ubuntu server. The path I'm working in is **/mnt/dev-windows-data/Staging/mbiek/test\_list** but the PHP call `getcwd()` is returning **/mnt/dev-windows/Staging/mbiek/test\_list** (notice how it's dev-windows instead of dev-windows-data). There aren't any symbolic links anywhere. Are ...
Which file are you calling the getcwd() in and is that file is included into the one you are running (e.g. running index.php, including startup.php which contains gwtcwd()). Is the file you are running in /dev-windows/ or /dev-windows-data/? It works on the file you are actually running. --- Here's an example of my ...
30,310
<p>I'd like to have dashes separate words in my URLs. So instead of:</p> <pre><code>/MyController/MyAction </code></pre> <p>I'd like:</p> <pre><code>/My-Controller/My-Action </code></pre> <p>Is this possible?</p>
[ { "answer_id": 30559, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 1, "selected": false, "text": "<p>You could write a custom route that derives from the Route class GetRouteData to strip dashes, but when you call the APIs to...
2008/08/27
[ "https://Stackoverflow.com/questions/30310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3085/" ]
I'd like to have dashes separate words in my URLs. So instead of: ``` /MyController/MyAction ``` I'd like: ``` /My-Controller/My-Action ``` Is this possible?
You can use the ActionName attribute like so: ``` [ActionName("My-Action")] public ActionResult MyAction() { return View(); } ``` Note that you will then need to call your View file "My-Action.cshtml" (or appropriate extension). You will also need to reference "my-action" in any Html.ActionLink methods. There i...
30,321
<p>I am looking for a method of storing Application Messages, such as</p> <ul> <li>"You have logged in successfully"</li> <li>"An error has occurred, please call the helpdesk on x100"</li> <li>"You do not have the authority to reset all system passwords" etc</li> </ul> <p>So that "when" the users decide they don't li...
[ { "answer_id": 30325, "author": "Tundey", "author_id": 1453, "author_profile": "https://Stackoverflow.com/users/1453", "pm_score": 2, "selected": false, "text": "<ul>\n<li>Put the strings in an xml file and use a filewatcher to check for updates to the file</li>\n<li>Put the strings in a...
2008/08/27
[ "https://Stackoverflow.com/questions/30321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982/" ]
I am looking for a method of storing Application Messages, such as * "You have logged in successfully" * "An error has occurred, please call the helpdesk on x100" * "You do not have the authority to reset all system passwords" etc So that "when" the users decide they don't like the wording of messages I don't have to...
In your Web.config, under appSettings, change it to: ``` <appSettings file="StringKeys.config"> ``` Then, create your StringKeys.config file and have all your keys in it. You can still use the AppSettings area in the main web.config for any real application related keys.
30,346
<p>Header, footer and sidebars have fixed position. In the center a content area with both scroll bars. No outer scroll bars on the browser. I have a layout that works in IE7 and FF. I need to add IE6 support. How can I make this work?</p> <p>Here is an approximation of my current CSS.</p> <pre class="lang-html prettyp...
[ { "answer_id": 30360, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 4, "selected": true, "text": "<p>Might be overkill for your project, but <a href=\"http://dean.edwards.name/IE7/\" rel=\"noreferrer\">Dean Edwards' I...
2008/08/27
[ "https://Stackoverflow.com/questions/30346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3211/" ]
Header, footer and sidebars have fixed position. In the center a content area with both scroll bars. No outer scroll bars on the browser. I have a layout that works in IE7 and FF. I need to add IE6 support. How can I make this work? Here is an approximation of my current CSS. ```html <!DOCTYPE html PUBLIC "-//W3C...
Might be overkill for your project, but [Dean Edwards' IE7 javascript adds support for fixed positioning to IE6](http://dean.edwards.name/IE7/).
30,354
<p>In one of my VB6 forms, I create several other Form objects and store them in member variables.</p> <pre><code>Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm </code></pre> <p>I notice that I'm leaking memory whenever this (parent) form is created and ...
[ { "answer_id": 30378, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 2, "selected": false, "text": "<p>Strictly speaking never, but it gives the garbage collector a strong hint to clean things up.</p>\n\n<p>As a rule: ...
2008/08/27
[ "https://Stackoverflow.com/questions/30354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/863/" ]
In one of my VB6 forms, I create several other Form objects and store them in member variables. ``` Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm ``` I notice that I'm leaking memory whenever this (parent) form is created and destroyed. Is it necessary...
@Matt Dillard - Did setting these to nothing fix your memory leak? VB6 doesn't have a formal garbage collector, more along the lines of what @Konrad Rudolph said. Actually calling unload on your forms seems to me to be the best way to ensure that the main form is cleaned up and that each subform cleans up their actio...
30,494
<p>Here is my code, which takes two version identifiers in the form "1, 5, 0, 4" or "1.5.0.4" and determines which is the newer version.</p> <p>Suggestions or improvements, please!</p> <pre><code> /// &lt;summary&gt; /// Compares two specified version strings and returns an integer that /// indicates thei...
[ { "answer_id": 30508, "author": "Craig", "author_id": 2894, "author_profile": "https://Stackoverflow.com/users/2894", "pm_score": 1, "selected": false, "text": "<p>Well, since you only have a four element array you may just want ot unroll the recursion to save time. Passing arrays as ar...
2008/08/27
[ "https://Stackoverflow.com/questions/30494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
Here is my code, which takes two version identifiers in the form "1, 5, 0, 4" or "1.5.0.4" and determines which is the newer version. Suggestions or improvements, please! ``` /// <summary> /// Compares two specified version strings and returns an integer that /// indicates their relationship to one anoth...
The [System.Version](http://msdn.microsoft.com/en-us/library/system.version.aspx) class does not support versions with commas in it, so the solution presented by [Darren Kopp](https://stackoverflow.com/questions/30494#30510) is not sufficient. Here is a version that is as simple as possible (but no simpler). It uses ...
30,529
<p>How could i implement Type-Safe Enumerations in Delphi in a COM scenario ? Basically, i'd like to replace a set of primitive constants of a enumeration with a set of static final object references encapsulated in a class ? . In Java, we can do something like:</p> <pre><code>public final class Enum { public sta...
[ { "answer_id": 30654, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 2, "selected": false, "text": "<p>What is wrong with native Delphi enums? They are type safe.</p>\n\n<pre><code>type\n TMyEnum = (Item1, Item2, Item3...
2008/08/27
[ "https://Stackoverflow.com/questions/30529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2015/" ]
How could i implement Type-Safe Enumerations in Delphi in a COM scenario ? Basically, i'd like to replace a set of primitive constants of a enumeration with a set of static final object references encapsulated in a class ? . In Java, we can do something like: ``` public final class Enum { public static final Enum...
Now you have provided us with some more clues about the nature of your question, namely mentioning COM, I think I understand what you mean. COM can marshal only a subset of the types Delphi knows between a COM server and client. You can define enums in the TLB editor, but these are all of the type TOleEnum which basica...
30,539
<p>I'm looking for a good way to enumerate all the Video codecs on a Windows XP/Vista machine.</p> <p>I need present the user with a set of video codecs, including the compressors and decompressors. The output would look something like</p> <pre> Available Decoders DiVX Version 6.0 XVID Motion JPEG CompanyX's MPEG-2 ...
[ { "answer_id": 30596, "author": "Christopher", "author_id": 3186, "author_profile": "https://Stackoverflow.com/users/3186", "pm_score": 4, "selected": true, "text": "<p>This is best handled by DirectShow.</p>\n\n<p>DirectShow is currently a part of the platform SDK.</p>\n\n<pre><code>HRE...
2008/08/27
[ "https://Stackoverflow.com/questions/30539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2813/" ]
I'm looking for a good way to enumerate all the Video codecs on a Windows XP/Vista machine. I need present the user with a set of video codecs, including the compressors and decompressors. The output would look something like ``` Available Decoders DiVX Version 6.0 XVID Motion JPEG CompanyX's MPEG-2 Decoder Windows ...
This is best handled by DirectShow. DirectShow is currently a part of the platform SDK. ``` HRESULT extractFriendlyName( IMoniker* pMk, std::wstring& str ) { assert( pMk != 0 ); IPropertyBag* pBag = 0; HRESULT hr = pMk->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pBag ); if( FAILED( hr ) || pBag == 0 ) ...
30,540
<p>This error just started popping up all over our site.</p> <p><strong><em>Permission denied to call method to Location.toString</em></strong></p> <p>I'm seeing google posts that suggest that this is related to flash and our crossdomain.xml. What caused this to occur and how do you fix?</p>
[ { "answer_id": 30561, "author": "Grey Panther", "author_id": 1265, "author_profile": "https://Stackoverflow.com/users/1265", "pm_score": 4, "selected": true, "text": "<p>Are you using javascript to communicate between frames/iframes which point to different domains? This is not permitted...
2008/08/27
[ "https://Stackoverflow.com/questions/30540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940/" ]
This error just started popping up all over our site. ***Permission denied to call method to Location.toString*** I'm seeing google posts that suggest that this is related to flash and our crossdomain.xml. What caused this to occur and how do you fix?
Are you using javascript to communicate between frames/iframes which point to different domains? This is not permitted by the JS "same origin/domain" security policy. Ie, if you have ``` <iframe name="foo" src="foo.com/script.js"> <iframe name="bar" src="bar.com/script.js"> ``` And the script on bar.com tries to acc...
30,563
<p>I have one field that I need to sum lets say named items However that field can be part of group a or b In the end I need to have all of the items summed for group a and group b</p> <p>when I say grouped I mean there is a LEFT OUTER JOIN to another table the previous table has a type for the items and the one being...
[ { "answer_id": 30578, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": true, "text": "<p>Maybe I'm not understanding the complexity of what you're asking but... shouldn't this do?</p>\n\n<pre><code>SELECT ...
2008/08/27
[ "https://Stackoverflow.com/questions/30563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
I have one field that I need to sum lets say named items However that field can be part of group a or b In the end I need to have all of the items summed for group a and group b when I say grouped I mean there is a LEFT OUTER JOIN to another table the previous table has a type for the items and the one being joined ha...
Maybe I'm not understanding the complexity of what you're asking but... shouldn't this do? ``` SELECT groupname, SUM(value) FROM items WHERE groupname IN ('a', 'b') GROUP BY groupname ``` And if you don't care which of a or b the item belongs to then this will do: ``` SELECT SUM(value) FROM items WHERE groupname IN...
30,569
<p>Does anyone have the secret formula to resizing transparent images (mainly GIFs) <em>without</em> ANY quality loss - what so ever?</p> <p>I've tried a bunch of stuff, the closest I get is not good enough.</p> <p>Take a look at my main image:</p> <p><a href="http://www.thewallcompany.dk/test/main.gif" rel="norefer...
[ { "answer_id": 30581, "author": "Jonathan", "author_id": 3251, "author_profile": "https://Stackoverflow.com/users/3251", "pm_score": 2, "selected": false, "text": "<p>I think the problem is that you're doing a scan line-based resize, which is going to lead to jaggies no matter how hard y...
2008/08/27
[ "https://Stackoverflow.com/questions/30569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2972/" ]
Does anyone have the secret formula to resizing transparent images (mainly GIFs) *without* ANY quality loss - what so ever? I've tried a bunch of stuff, the closest I get is not good enough. Take a look at my main image: <http://www.thewallcompany.dk/test/main.gif> And then the scaled image: <http://www.thewallcom...
If there's no requirement on preserving file type after scaling I'd recommend the following approach. ``` using (Image src = Image.FromFile("main.gif")) using (Bitmap dst = new Bitmap(100, 129)) using (Graphics g = Graphics.FromImage(dst)) { g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = Interp...
30,571
<p>In Maven, dependencies are usually set up like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt; &lt;groupId&gt;wonderful-inc&lt;/groupId&gt; &lt;artifactId&gt;dream-library&lt;/artifactId&gt; &lt;version&gt;1.2.3&lt;/version&gt; &lt;/dependency&gt; </code></pre> <p>Now, if you ar...
[ { "answer_id": 30590, "author": "Martin Klinke", "author_id": 1793, "author_profile": "https://Stackoverflow.com/users/1793", "pm_score": 4, "selected": false, "text": "<p>Are you possibly depending on development versions that obviously change a lot during development? </p>\n\n<p>Instea...
2008/08/27
[ "https://Stackoverflow.com/questions/30571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1709/" ]
In Maven, dependencies are usually set up like this: ```xml <dependency> <groupId>wonderful-inc</groupId> <artifactId>dream-library</artifactId> <version>1.2.3</version> </dependency> ``` Now, if you are working with libraries that have frequent releases, constantly updating the <version> tag can be somewhat a...
***NOTE:*** *The mentioned `LATEST` and `RELEASE` metaversions [have been dropped **for plugin dependencies** in Maven 3 "for the sake of reproducible builds"](https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes#Maven3.xCompatibilityNotes-PluginMetaversionResolution), over 6 years ago. (The...
30,585
<p>Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project?</p> <p>If so, is there a preferred flavor of CruiseControl (CruiseControl.rb or just regular CruiseControl) that would be easier to do this with. </p> <p>I currently have a Ruby rake file that has steps for doing building and running...
[ { "answer_id": 30705, "author": "Chris Blackwell", "author_id": 1329401, "author_profile": "https://Stackoverflow.com/users/1329401", "pm_score": 4, "selected": true, "text": "<p>Yes, you just run xcode builds via the command line (xcodebuild) which makes it simple to target from CC via ...
2008/08/27
[ "https://Stackoverflow.com/questions/30585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2813/" ]
Has anyone ever set up Cruise Control to build an OS X Cocoa/Objective-C project? If so, is there a preferred flavor of CruiseControl (CruiseControl.rb or just regular CruiseControl) that would be easier to do this with. I currently have a Ruby rake file that has steps for doing building and running tests, and wante...
Yes, you just run xcode builds via the command line (xcodebuild) which makes it simple to target from CC via an ant `<exec>`. I've been using just regular CC, not the ruby version and it works fine. Here's a barebones example: ``` <project name="cocoathing" default="build"> <target name="build"> <exec executable...
30,627
<p>I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. </p> <p>I've decided to explore the option having the same program, that currently recieves a single format XML document, re...
[ { "answer_id": 30673, "author": "Vinnie", "author_id": 2890, "author_profile": "https://Stackoverflow.com/users/2890", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://java.sun.com/developer/technicalArticles/WebServices/jaxb/\" rel=\"nofollow noreferrer\"><strong>JAXB</str...
2008/08/27
[ "https://Stackoverflow.com/questions/30627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/828/" ]
I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. I've decided to explore the option having the same program, that currently recieves a single format XML document, receive two a...
As I understand it, the problem is that you don't know what format the document is prior to parsing. You could use a delegate pattern. I'm assuming you're not validating against a DTD/XSD/etcetera and that it is OK for the DefaultHandler to have state. ``` public class DelegatingHandler extends DefaultHandler { p...
30,660
<p>I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicati...
[ { "answer_id": 30701, "author": "Leigh Caldwell", "author_id": 3267, "author_profile": "https://Stackoverflow.com/users/3267", "pm_score": 2, "selected": false, "text": "<p>First, do you really want to ignore errors? If you get an error, it is likely that the data is not in sync any more...
2008/08/27
[ "https://Stackoverflow.com/questions/30660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/547/" ]
I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicating-...
Yes, with --slave-skip-errors=xxx in my.cnf, where xxx is 'all' or a comma sep list of error codes.
30,686
<p>How can you get the version information from a <code>.dll</code> or <code>.exe</code> file in PowerShell?</p> <p>I am specifically interested in <code>File Version</code>, though other version information (that is, <code>Company</code>, <code>Language</code>, <code>Product Name</code>, etc.) would be helpful as wel...
[ { "answer_id": 30702, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 3, "selected": false, "text": "<pre><code>[System.Diagnostics.FileVersionInfo]::GetVersionInfo(\"Path\\To\\File.dll\")\n</code></pre>\n" }, { "answe...
2008/08/27
[ "https://Stackoverflow.com/questions/30686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2495/" ]
How can you get the version information from a `.dll` or `.exe` file in PowerShell? I am specifically interested in `File Version`, though other version information (that is, `Company`, `Language`, `Product Name`, etc.) would be helpful as well.
Since PowerShell can call [.NET](https://en.wikipedia.org/wiki/.NET_Framework) classes, you could do the following: ``` [System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion ``` Or as [noted here](https://web.archive.org/web/20081004113553/https://kamhungsoh.com/blog/2008/01/powershell-fil...
30,710
<p>I've heard that unit testing is "totally awesome", "really cool" and "all manner of good things" but 70% or more of my files involve database access (some read and some write) and I'm not sure how to write a unit test for these files.</p> <p>I'm using PHP and Python but I think it's a question that applies to most/...
[ { "answer_id": 30715, "author": "Sean Chambers", "author_id": 2993, "author_profile": "https://Stackoverflow.com/users/2993", "pm_score": 5, "selected": false, "text": "<p>Ideally, your objects should be persistent ignorant. For instance, you should have a &quot;data access layer&quot;, ...
2008/08/27
[ "https://Stackoverflow.com/questions/30710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
I've heard that unit testing is "totally awesome", "really cool" and "all manner of good things" but 70% or more of my files involve database access (some read and some write) and I'm not sure how to write a unit test for these files. I'm using PHP and Python but I think it's a question that applies to most/all langua...
I would suggest mocking out your calls to the database. Mocks are basically objects that look like the object you are trying to call a method on, in the sense that they have the same properties, methods, etc. available to caller. But instead of performing whatever action they are programmed to do when a particular meth...
30,754
<p>Reading <a href="https://stackoverflow.com/questions/437/what-is-your-solution-to-the-fizzbuzz-problem">this question</a> I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way). </p> <pre><code>100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n* </code></pre> <p>Obviously this is an inte...
[ { "answer_id": 30760, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 3, "selected": false, "text": "<p>I always start with the most readable version I can think of. If performance is a problem, I refactor. If the rea...
2008/08/27
[ "https://Stackoverflow.com/questions/30754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2695/" ]
Reading [this question](https://stackoverflow.com/questions/437/what-is-your-solution-to-the-fizzbuzz-problem) I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way). ``` 100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n* ``` Obviously this is an intellectual example without real (I hope...
My process for situations where I think performance may be an issue: 1. Make it work. 2. Make it clear. 3. Test the performance. 4. If there are meaningful performance issues: refactor for speed. Note that this does not apply to higher-level design decisions that are more difficult to change at a later stage.
30,781
<p>What are the ways to retrieve data submitted to the web server from a form in the client HTML in ASP.NET?</p>
[ { "answer_id": 30784, "author": "Adam", "author_id": 1341, "author_profile": "https://Stackoverflow.com/users/1341", "pm_score": 0, "selected": false, "text": "<p>In VB.NET</p>\n\n<p>For POST requests:</p>\n\n<pre><code>value = Request.Form(\"formElementID\")\n</code></pre>\n\n<p>For GET...
2008/08/27
[ "https://Stackoverflow.com/questions/30781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
What are the ways to retrieve data submitted to the web server from a form in the client HTML in ASP.NET?
You can also search through both the Form and QueryString collections at the same time so that the data will be found regardless of the the request method. ``` value = Request("formElementID") ```
30,800
<p>What is the best approach to make sure you only need to authenticate once when using an API built on WCF?</p> <p>My current bindings and behaviors are listed below</p> <pre><code> &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="wsHttp"&gt; &lt;security mode="Transpor...
[ { "answer_id": 34177, "author": "Ubiguchi", "author_id": 2562, "author_profile": "https://Stackoverflow.com/users/2562", "pm_score": 1, "selected": false, "text": "<p>While I hate to give an answer I'm not 100% certain of, the lack of responses so far makes me think a potentially correct...
2008/08/27
[ "https://Stackoverflow.com/questions/30800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2701/" ]
What is the best approach to make sure you only need to authenticate once when using an API built on WCF? My current bindings and behaviors are listed below ``` <bindings> <wsHttpBinding> <binding name="wsHttp"> <security mode="TransportWithMessageCredential"> ...
If you're on an intranet, Windows authentication can be handled for "free" by configuration alone. If this isn't appropriate, token services work just fine, but for some situations they may be just too much. The application I'm working on needed bare-bones authentication. Our server and client run inside a (very sec...
30,847
<p>How does one go about authoring a <em><strong>Regular Expression</strong></em> that matches against all strings that are valid URIs, while failing to match against all strings that are invalid URIs?</p> <p>To be specific about what I am referencing when I say URI, I have added a link below for the most current URI R...
[ { "answer_id": 30852, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 1, "selected": false, "text": "<p>Are there some specific URIs you care about or are you trying to find a single regex that validates <a href=\"http://rfc.n...
2008/08/27
[ "https://Stackoverflow.com/questions/30847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/80/" ]
How does one go about authoring a ***Regular Expression*** that matches against all strings that are valid URIs, while failing to match against all strings that are invalid URIs? To be specific about what I am referencing when I say URI, I have added a link below for the most current URI RFC standard. It defines the e...
This site looks promising: <http://snipplr.com/view/6889/regular-expressions-for-uri-validationparsing/> They propose following regex: ``` /^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(/?...
30,856
<p>How do I write the results from a mysql query to file? I just need something quick. Output can be CSV, XML, HTML, etc.</p>
[ { "answer_id": 30868, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 5, "selected": true, "text": "<pre><code>SELECT a,b,a+b \n FROM test_table\n INTO OUTFILE '/tmp/result.txt'\n FIELDS TERMINATED BY ',' OPTIONALLY ENC...
2008/08/27
[ "https://Stackoverflow.com/questions/30856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2363/" ]
How do I write the results from a mysql query to file? I just need something quick. Output can be CSV, XML, HTML, etc.
``` SELECT a,b,a+b FROM test_table INTO OUTFILE '/tmp/result.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' ``` (the docs show INTO OUTFILE up in the SELECT .. portion which may work as well, but I've never tried it that way) <http://dev.mysql.com/doc/refman/5.0/en/select.h...
30,861
<p>Given a username and a password for a domain user, what would be the best way to authenticate that user programatically?</p>
[ { "answer_id": 31665, "author": "David J. Sokol", "author_id": 1390, "author_profile": "https://Stackoverflow.com/users/1390", "pm_score": 3, "selected": false, "text": "<p>You can use some hacks to <strong>authenticate</strong> only.</p>\n\n<pre><code>Try\n Dim directoryEntry as New ...
2008/08/27
[ "https://Stackoverflow.com/questions/30861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194/" ]
Given a username and a password for a domain user, what would be the best way to authenticate that user programatically?
It appears that .NET 3.5 added a new namespace to deal with this issue - System.DirectoryServices.AccountManagement. Code sample is below: ``` Private Function ValidateExternalUser(ByVal username As String, ByVal password As String) As Boolean Using context As PrincipalContext = New PrincipalContext(ContextType.Do...
30,877
<p>I actually have an answer to my question but it is not parallelized so I am interested in ways to improve the algorithm. Anyway it might be useful as-is for some people.</p> <pre><code>int Until = 20000000; BitArray PrimeBits = new BitArray(Until, true); /* * Sieve of Eratosthenes * PrimeBits is a simple BitArra...
[ { "answer_id": 31268, "author": "Pete Kirkham", "author_id": 1527, "author_profile": "https://Stackoverflow.com/users/1527", "pm_score": 2, "selected": false, "text": "<p>Parallelisation aside, you don't want to be calculating sqrt(Until) on every iteration. You also can assume multiples...
2008/08/27
[ "https://Stackoverflow.com/questions/30877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3063/" ]
I actually have an answer to my question but it is not parallelized so I am interested in ways to improve the algorithm. Anyway it might be useful as-is for some people. ``` int Until = 20000000; BitArray PrimeBits = new BitArray(Until, true); /* * Sieve of Eratosthenes * PrimeBits is a simple BitArray where all bi...
You might save some time by cross-referencing your bit array with a doubly-linked list, so you can more quickly advance to the next prime. Also, in eliminating later composites once you hit a new prime p for the first time - the first composite multiple of p remaining will be p\*p, since everything before that has alr...
30,879
<p>Is there a pattern using Linq to dynamically create a filter?</p> <p>I have the need to create custom filtering on a list, in the past I would just dynamically create the SQL...it doesn't seem like this is possible with Linq.</p>
[ { "answer_id": 30887, "author": "Geoff", "author_id": 1097, "author_profile": "https://Stackoverflow.com/users/1097", "pm_score": 5, "selected": true, "text": "<p>Check out the <a href=\"http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-li...
2008/08/27
[ "https://Stackoverflow.com/questions/30879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2858/" ]
Is there a pattern using Linq to dynamically create a filter? I have the need to create custom filtering on a list, in the past I would just dynamically create the SQL...it doesn't seem like this is possible with Linq.
Check out the [Dynamic Linq Library](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx) from ScottGu's blog: For example, below is a standard type-safe LINQ to SQL VB query that retrieves data from a Northwind database and displays it in a ASP.NET GridView ...
30,928
<p>[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right i...
[ { "answer_id": 31336, "author": "Jared Updike", "author_id": 2543, "author_profile": "https://Stackoverflow.com/users/2543", "pm_score": -1, "selected": false, "text": "<p>Can't you just use the same control I'm Stack Overflow uses (that we're all typing into)---WMD, and just store the M...
2008/08/27
[ "https://Stackoverflow.com/questions/30928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1600/" ]
[We have a Windows Forms database front-end application that, among other things, can be used as a CMS; clients create the structure, fill it, and then use a ASP.NET WebForms-based site to present the results to publicly on the Web. For added flexibility, they are sometimes forced to input actual HTML markup right into...
I think the best approach for this is to combine 1. [Converting Markdown to HTML](https://stackoverflow.com/q/460483/1366033) & 2. [Displaying HTML in WinForms](https://stackoverflow.com/a/12724381/1366033) The most up to date Markdown Library seems to be [**markdig**](https://github.com/lunet-io/markdig) which you ...
30,931
<p>I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files.</p> <p>How can I register a file extension and associate it with my application on Linux? I'm looking for a way that is standard (works with GNOME and KDE based systems) and can be done autom...
[ { "answer_id": 30939, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>1) in linux this is a function of your desktop environment rather than the os itself.<br>\n2) GNOME and KDE have dif...
2008/08/27
[ "https://Stackoverflow.com/questions/30931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3306/" ]
I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files. How can I register a file extension and associate it with my application on Linux? I'm looking for a way that is standard (works with GNOME and KDE based systems) and can be done automatic when ...
Use `xdg-utils` from [freedesktop.org Portland](http://portland.freedesktop.org/wiki/). Register the icon for the MIME type: ```sh xdg-icon-resource install --context mimetypes --size 48 myicon-file-type.png x-application-mytype ``` Create a configuration file ([freedesktop Shared MIME documentation](http://standar...
30,985
<p>I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two?</p> <p>table def:</p> <pre><code>CREATE TABLE feed_tbl ( code varchar(15), name varchar(40...
[ { "answer_id": 31043, "author": "wcm", "author_id": 2173, "author_profile": "https://Stackoverflow.com/users/2173", "pm_score": 0, "selected": false, "text": "<p>I would use a minor variation in the second <code>union</code>:</p>\n\n<pre><code>where (ISNULL(feed_tbl.name, 'NONAME') &lt;&...
2008/08/27
[ "https://Stackoverflow.com/questions/30985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/292/" ]
I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two? table def: ``` CREATE TABLE feed_tbl ( code varchar(15), name varchar(40), status char(1), upd...
UNION will remove duplicates, so just UNION the two together, then search for anything with more than one entry. Given "code" as a primary key, you can say: *edit 0: modified to include differences in the PK field itself* *edit 1: if you use this in real life, be sure to list the actual column names. Dont use dot-sta...
30,998
<p>I like to use static functions in C++ as a way to categorize them, like C# does.</p> <pre><code>Console::WriteLine("hello") </code></pre> <p>Is this good or bad? If the functions are used often I guess it doesn't matter, but if not do they put pressure on memory?</p> <p>What about <code>static const</code>?</p>
[ { "answer_id": 31004, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": false, "text": "<p>I'm all for using static <strong>functions</strong>. These just make sense especially when organized into modules (<co...
2008/08/27
[ "https://Stackoverflow.com/questions/30998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2566/" ]
I like to use static functions in C++ as a way to categorize them, like C# does. ``` Console::WriteLine("hello") ``` Is this good or bad? If the functions are used often I guess it doesn't matter, but if not do they put pressure on memory? What about `static const`?
> > but is it good or bad > > > The first adjective that comes to mind is "unnecessary". C++ has free functions and namespaces, so why would you need to make them static functions in a class? The use of static methods in uninstantiable classes in C# and Java *is a workaround* because those languages don't have f...
31,007
<p>I build up an array of strings with</p> <pre><code>string[] parts = string.spilt(" "); </code></pre> <p>And get an array with X parts in it, I would like to get a copy of the array of strings starting at element </p> <pre><code>parts[x-2] </code></pre> <p>Other than the obvious brute force approach (make a new a...
[ { "answer_id": 31023, "author": "Ryan Farley", "author_id": 1627, "author_profile": "https://Stackoverflow.com/users/1627", "pm_score": -1, "selected": false, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.array.copy(VS.80).aspx\" rel=\"nofollow noreferrer\">Arr...
2008/08/27
[ "https://Stackoverflow.com/questions/31007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2723/" ]
I build up an array of strings with ``` string[] parts = string.spilt(" "); ``` And get an array with X parts in it, I would like to get a copy of the array of strings starting at element ``` parts[x-2] ``` Other than the obvious brute force approach (make a new array and insert strings), is there a more elegant...
How about Array.Copy? <http://msdn.microsoft.com/en-us/library/aa310864(VS.71).aspx> > > Array.Copy Method (Array, Int32, Array, Int32, Int32) > > > Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. The leng...
31,031
<p>What's the best way to allow a user to browse for a file in C#?</p>
[ { "answer_id": 31036, "author": "Ryan Farley", "author_id": 1627, "author_profile": "https://Stackoverflow.com/users/1627", "pm_score": 5, "selected": true, "text": "<pre><code>using (OpenFileDialog dlg = new OpenFileDialog())\n{\n dlg.Title = \"Select a file\";\n if (dlg.ShowDialo...
2008/08/27
[ "https://Stackoverflow.com/questions/31031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/177/" ]
What's the best way to allow a user to browse for a file in C#?
``` using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "Select a file"; if (dlg.ShowDialog()== DialogResult.OK) { //do something with dlg.FileName } } ```
31,044
<p>How can I check the existence of an element in jQuery?</p> <p>The current code that I have is this:</p> <pre><code>if ($(selector).length &gt; 0) { // Do something } </code></pre> <p>Is there a more elegant way to approach this? Perhaps a plugin or a function?</p>
[ { "answer_id": 31047, "author": "Jake McGraw", "author_id": 302, "author_profile": "https://Stackoverflow.com/users/302", "pm_score": 10, "selected": false, "text": "<p>Yes!</p>\n\n<pre><code>jQuery.fn.exists = function(){ return this.length &gt; 0; }\n\nif ($(selector).exists()) {\n ...
2008/08/27
[ "https://Stackoverflow.com/questions/31044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/302/" ]
How can I check the existence of an element in jQuery? The current code that I have is this: ``` if ($(selector).length > 0) { // Do something } ``` Is there a more elegant way to approach this? Perhaps a plugin or a function?
In JavaScript, everything is 'truthy' or 'falsy', and for numbers `0` means `false`, everything else `true`. So you could write: ``` if ($(selector).length) ``` You don't need that `>0` part.
31,051
<p>So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag.</p> <p>The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. </p> <...
[ { "answer_id": 31300, "author": "hova", "author_id": 2170, "author_profile": "https://Stackoverflow.com/users/2170", "pm_score": 2, "selected": true, "text": "<p>Ok, I've solved my own problem.<br>\nTo get that \"authdata\" string, you need to configure your client to how you need to aut...
2008/08/27
[ "https://Stackoverflow.com/questions/31051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2170/" ]
So we're trying to set up replicated repositories using PlasticSCM, one in the US, and one in Australia and running into a bit of a snag. The US configuration is Active Directory, the AU configuration is User/Password. This in itself is not a big deal, I've already set up the SID translation table. The problem is wi...
Ok, I've solved my own problem. To get that "authdata" string, you need to configure your client to how you need to authenticate. Then navigate to c:[users directory][username]\Local Settings\Application Data\plastic. Pick up the client.conf and extract the string from the SecurityConfig element in the XML.
31,053
<p>How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#?</p> <p>I know to do it using plan <code>String.Replace</code>, like:</p> <pre><code>myStr.Replace(&quot;\n&quot;, &quot;\r\n&quot;); myStr.Replace(&quot;\r\r\n&quot;, &quot;\r\n&quot;); </code></pre> <p>However, t...
[ { "answer_id": 31056, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 7, "selected": true, "text": "<p>Will this do?</p>\n\n<pre><code>[^\\r]\\n\n</code></pre>\n\n<p>Basically it matches a '\\n' that is preceded with a charact...
2008/08/27
[ "https://Stackoverflow.com/questions/31053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838/" ]
How can I replace lone instances of \n with \r\n (LF alone with CRLF) using a regular expression in C#? I know to do it using plan `String.Replace`, like: ``` myStr.Replace("\n", "\r\n"); myStr.Replace("\r\r\n", "\r\n"); ``` However, this is inelegant, and would destroy any "\r+\r\n" already in the text (although t...
Will this do? ``` [^\r]\n ``` Basically it matches a '\n' that is preceded with a character that is not '\r'. If you want it to detect lines that start with just a single '\n' as well, then try ``` ([^\r]|$)\n ``` Which says that it should match a '\n' but only those that is the first character of a line or thos...
31,057
<p>I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.</p>
[ { "answer_id": 31063, "author": "Mark Struzinski", "author_id": 1284, "author_profile": "https://Stackoverflow.com/users/1284", "pm_score": 9, "selected": true, "text": "<p>I found the answer here: <a href=\"http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carria...
2008/08/27
[ "https://Stackoverflow.com/questions/31057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
I didn't see any similar questions asked on this topic, and I had to research this for something I'm working on right now. Thought I would post the answer for it in case anyone else had the same question.
I found the answer here: <http://blog.sqlauthority.com/2007/08/22/sql-server-t-sql-script-to-insert-carriage-return-and-new-line-feed-in-code/> You just concatenate the string and insert a `CHAR(13)` where you want your line break. Example: ``` DECLARE @text NVARCHAR(100) SET @text = 'This is line 1.' + CHAR(13) + ...
31,088
<p>I'm trying to set up an inheritance hierarchy similar to the following:</p> <pre><code>abstract class Vehicle { public string Name; public List&lt;Axle&gt; Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } cl...
[ { "answer_id": 31110, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 4, "selected": true, "text": "<p>Use more generics</p>\n\n<pre><code>abstract class Vehicle&lt;T&gt; where T : Axle\n{\n public string Name;\n publi...
2008/08/27
[ "https://Stackoverflow.com/questions/31088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
I'm trying to set up an inheritance hierarchy similar to the following: ``` abstract class Vehicle { public string Name; public List<Axle> Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } class MotorcycleAxle :...
Use more generics ``` abstract class Vehicle<T> where T : Axle { public string Name; public List<T> Axles; } class Motorcycle : Vehicle<MotorcycleAxle> { } class Car : Vehicle<CarAxle> { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } class MotorcycleAxle : Axle { publ...
31,096
<p>I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes).</p> <p>I'm using:</p> <pre><code>Process.GetCurrentProcess().PrivateMemorySize64 </code></pre> <p>However, the Process object has several different properties that let me read the memory space used: P...
[ { "answer_id": 31164, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 5, "selected": true, "text": "<p>If you want to know how much the GC uses try:</p>\n\n<pre><code>GC.GetTotalMemory(true)\n</code></pre>\n\n<p>If you w...
2008/08/27
[ "https://Stackoverflow.com/questions/31096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I'm trying to find out how much memory my own .Net server process is using (for monitoring and logging purposes). I'm using: ``` Process.GetCurrentProcess().PrivateMemorySize64 ``` However, the Process object has several different properties that let me read the memory space used: Paged, NonPaged, PagedSystem, NonP...
If you want to know how much the GC uses try: ``` GC.GetTotalMemory(true) ``` If you want to know what your process uses from Windows (VM Size column in TaskManager) try: ``` Process.GetCurrentProcess().PrivateMemorySize64 ``` If you want to know what your process has in RAM (as opposed to in the pagefile) (Mem U...
31,097
<p>Visual Basic code does not render correctly with <a href="https://code.google.com/archive/p/google-code-prettify" rel="nofollow noreferrer">prettify.js</a> from Google.</p> <p>on Stack Overflow:</p> <pre><code>Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As ...
[ { "answer_id": 31860, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 4, "selected": true, "text": "<p>/EDIT: I've rewritten the whole posting.</p>\n\n<p>Below is a pretty complete solution to the VB highlighting proble...
2008/08/27
[ "https://Stackoverflow.com/questions/31097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
Visual Basic code does not render correctly with [prettify.js](https://code.google.com/archive/p/google-code-prettify) from Google. on Stack Overflow: ``` Partial Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ...
/EDIT: I've rewritten the whole posting. Below is a pretty complete solution to the VB highlighting problem. If SO has got nothing better, *please* use it. VB syntax highlighting is definitely wanted. I've also added a code example with some complex code literals that gets highlighted correctly. However, I haven't ev...
31,127
<p>When running a Java app from eclipse my ImageIcon shows up just fine.</p> <p>But after creating a jar the path to the image obviously gets screwed up.</p> <p>Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this?</p> <p>I'd like to distribute a ...
[ { "answer_id": 31146, "author": "Tim Frey", "author_id": 1471, "author_profile": "https://Stackoverflow.com/users/1471", "pm_score": 5, "selected": false, "text": "<p>You can try something like:</p>\n\n<pre><code>InputStream stream = this.getClass().getClassLoader().getResourceAsStream(\...
2008/08/27
[ "https://Stackoverflow.com/questions/31127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
When running a Java app from eclipse my ImageIcon shows up just fine. But after creating a jar the path to the image obviously gets screwed up. Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this? I'd like to distribute a single jar file if possib...
To create an `ImageIcon` from an image file within the same jars your code is loaded: ``` new javax.swing.ImageIcon(getClass().getResource("myimage.jpeg")) ``` `Class.getResource` returns a URL of a resource (or `null`!). `ImageIcon` has a constructors that load from a URL. To construct a URL for a resource in a ja...
31,129
<p>I want to return <code>StudentId</code> to use elsewhere outside of the <em>scope</em> of the <code>$.getJSON()</code></p> <pre><code>j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here </code></pre> <p>I would imagine this has to do with scoping, but it doesn't ...
[ { "answer_id": 31153, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 6, "selected": true, "text": "<p>Yeah, my previous answer does not work because I didn't pay any attention to your code. :)</p>\n\n<p>The problem is t...
2008/08/27
[ "https://Stackoverflow.com/questions/31129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2993/" ]
I want to return `StudentId` to use elsewhere outside of the *scope* of the `$.getJSON()` ``` j.getJSON(url, data, function(result) { var studentId = result.Something; }); //use studentId here ``` I would imagine this has to do with scoping, but it doesn't seem to work the same way *c#* does
Yeah, my previous answer does not work because I didn't pay any attention to your code. :) The problem is that the anonymous function is a callback function - i.e. getJSON is an async operation that will return at some indeterminate point in time, so even if the scope of the variable were outside of that anonymous fun...
31,192
<p>We're in the process of redesigning the customer-facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures, for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this poin...
[ { "answer_id": 31209, "author": "Iain Holder", "author_id": 1122, "author_profile": "https://Stackoverflow.com/users/1122", "pm_score": 1, "selected": false, "text": "<p>You're going from classic ASP to ASP with 3.5 without just re-writing? Skillz. I've had to deal with some legacy ASP...
2008/08/27
[ "https://Stackoverflow.com/questions/31192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1302/" ]
We're in the process of redesigning the customer-facing section of our site in .NET 3.5. It's been going well so far, we're using the same workflow and stored procedures, for the most part, the biggest changes are the UI, the ORM (from dictionaries to LINQ), and obviously the language. Most of the pages to this point h...
Believe me, I know *exactly* where you are coming from.. I am currently migrating a large app from ASP classic to .NET.. And I am still learning ASP.NET! :S (yes, I am terrified!). The main things I have kept in my mind is this: * I dont stray *too* far from the current design (i.e. no massive "lets rip ALL of this o...
31,201
<p>I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this?</p>
[ { "answer_id": 31216, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 4, "selected": false, "text": "<p>Use <code>EnclosingClass.this</code></p>\n" }, { "answer_id": 31218, "author": "Frank Krueger", "autho...
2008/08/27
[ "https://Stackoverflow.com/questions/31201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this?
I just found this recently. Use `OuterClassName.this`. ``` class Outer { void foo() { new Thread() { public void run() { Outer.this.bar(); } }.start(); } void bar() { System.out.println("BAR!"); } } ``` **Updated** If you just want the o...
31,215
<p>I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply...
[ { "answer_id": 31220, "author": "Zack Peterson", "author_id": 83, "author_profile": "https://Stackoverflow.com/users/83", "pm_score": 4, "selected": true, "text": "<p>You might consider using custom types.</p>\n\n<p>For example, create LogonName and BadgeNumber classes.</p>\n\n<p>Then yo...
2008/08/27
[ "https://Stackoverflow.com/questions/31215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1865/" ]
I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply to any...
You might consider using custom types. For example, create LogonName and BadgeNumber classes. Then your function declarations look like... ``` public Person(LogonName ln) { this.Load(ln.ToString()); } public Person(BadgeNumber bn) { //load logic here... } ``` Such a solution might give you a good place to...
31,221
<p>I have a method that where I want to redirect the user back to a login page located at the root of my web application.</p> <p>I'm using the following code:</p> <pre><code>Response.Redirect("~/Login.aspx?ReturnPath=" + Request.Url.ToString()); </code></pre> <p>This doesn't work though. My assumption was that ASP....
[ { "answer_id": 31248, "author": "Marshall", "author_id": 1302, "author_profile": "https://Stackoverflow.com/users/1302", "pm_score": -1, "selected": false, "text": "<p>What about using</p>\n\n<pre><code>Response.Redirect(String.Format(\"http://{0}/Login.aspx?ReturnPath={1}\", Request.Ser...
2008/08/27
[ "https://Stackoverflow.com/questions/31221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1226/" ]
I have a method that where I want to redirect the user back to a login page located at the root of my web application. I'm using the following code: ``` Response.Redirect("~/Login.aspx?ReturnPath=" + Request.Url.ToString()); ``` This doesn't work though. My assumption was that ASP.NET would automatically resolve th...
> > I think you need to drop the "~/" and replace it with just "/", I believe / is the root > > > **STOP RIGHT THERE!** :-) unless you want to hardcode your web app so that it can only be installed at the root of a web site. "~/" ***is*** the correct thing to use, but the reason that your original code didn't wo...
31,226
<p>I am writing a basic word processing application and am trying to settle on a native "internal" format, the one that my code parses in order to render to the screen. I'd like this to be XML so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever.</p> <p>When searching for existing st...
[ { "answer_id": 31234, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": -1, "selected": false, "text": "<p>XML is an <em>external</em> format, not <em>internal</em>.</p>\n\n<p>What's wrong with <a href=\"http://www.w3.org/TR...
2008/08/27
[ "https://Stackoverflow.com/questions/31226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3044/" ]
I am writing a basic word processing application and am trying to settle on a native "internal" format, the one that my code parses in order to render to the screen. I'd like this to be XML so that I can, in the future, just write XSLT to convert it to ODF or XHTML or whatever. When searching for existing standards to...
As you are sure about needing to represent the *presentational* side of things, it may be worth looking at the [XSL-FO](http://www.w3.org/TR/xsl/) W3C Recommendation. This is a full-blown page description language and the (deeply unfashionable) other half of the better-known XSLT. Clearly the whole thing is anything b...
31,238
<p>What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like :</p> <pre><code>&lt;class1 prop1="foo" prop2="...
[ { "answer_id": 31244, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>Reflection is what you want. Reflection + TypeConverter. Don't have much more time to explain, but just google those, and ...
2008/08/27
[ "https://Stackoverflow.com/questions/31238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/634/" ]
What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like : ``` <class1 prop1="foo" prop2="bar"/> ``` and ...
It may be easier to serialise the classes to/from xml, you can then simply pass the XmlReader (which is reading your config file) to the deserializer and it will do the rest for you.. [This is a pretty good article on serialization](http://www.diranieh.com/NETSerialization/XMLSerialization.htm) Edit ---- One thing I...
31,249
<p>Using WPF, I have a TreeView control that I want to set its ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere.</p> <pre><code>myTreeViewControl.ItemTemplate = ?? </code></pre>
[ { "answer_id": 31260, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": true, "text": "<p>If the template is defined in your &lt;Window.Resources&gt; section directly:</p>\n\n<pre><code>myTreeViewControl.ItemT...
2008/08/27
[ "https://Stackoverflow.com/questions/31249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
Using WPF, I have a TreeView control that I want to set its ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere. ``` myTreeViewControl.ItemTemplate = ?? ```
If the template is defined in your <Window.Resources> section directly: ``` myTreeViewControl.ItemTemplate = this.Resources["SomeTemplate"] as DataTemplate; ``` If it's somewhere deep within your window, like in a <Grid.Resources> section or something, I think this'll work: ``` myTreeViewControl.ItemTemplate = this...
31,285
<p>I am using VMWare tools for Ubuntu Hardy, but for some reason <code>vmware-install.pl</code> finds fault with my LINUX headers. The error message says that the "address space size" doesn't match.</p> <p>To try and remediate, I have resorted to <code>vmware-any-any-update117</code>, and am now getting the following ...
[ { "answer_id": 31468, "author": "Fernando Barrocal", "author_id": 2274, "author_profile": "https://Stackoverflow.com/users/2274", "pm_score": 2, "selected": false, "text": "<p>This error ofter occurs because incompatibility of VMWare Tools Version and recent Kernels (You can test it usin...
2008/08/27
[ "https://Stackoverflow.com/questions/31285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
I am using VMWare tools for Ubuntu Hardy, but for some reason `vmware-install.pl` finds fault with my LINUX headers. The error message says that the "address space size" doesn't match. To try and remediate, I have resorted to `vmware-any-any-update117`, and am now getting the following error instead: ``` In file incl...
Check out this link as it helped me install the tools in one of my vms. <http://diamondsw.dyndns.org/Home/Et_Cetera/Entries/2008/4/25_Linux_2.6.24_and_VMWare.html>
31,297
<p>I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. </p> <p>The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service...
[ { "answer_id": 31724, "author": "Shaun Austin", "author_id": 1120, "author_profile": "https://Stackoverflow.com/users/1120", "pm_score": 0, "selected": false, "text": "<p>Not an expert with this stuff but it looks like the first 3 parts of the address are being masked out. Is it possible...
2008/08/27
[ "https://Stackoverflow.com/questions/31297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130097/" ]
I developed a program in a mobile device (Pocket PC 2003) to access a web service, the web service is installed on a Windows XP SP2 PC with IIS, the PC has the IP 192.168.5.2. The device obtains from the wireless network the IP 192.168.5.118 and the program works OK, it calls the method from the web service and execu...
This looks like a network issue, unless there's an odd bug in .Net CF that doesn't allow you to traverse subnets in certain situations (I can find no evidence of such a thing from googling). Can you get any support from the network/IT team? Also, have you tried it from a different subnet? I.e. not the same as the XP m...
31,312
<p>I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars.</p> <ol> <li>? => causes the variable not t...
[ { "answer_id": 31448, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 0, "selected": false, "text": "<p>Can you provide a code sample?</p>\n\n<p>More likely than not you'll just need to escape your HTML entities using <a h...
2008/08/27
[ "https://Stackoverflow.com/questions/31312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
I am working on a rails project. Using the tag observe\_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars. 1. ? => causes the variable not to be found i...
This is an escaping issue (as stated by others). You'll want to change your observe\_field :with statement to something like: ``` :with => "'postbody=' + encodeURIComponent(value)" ``` Then in your controller: ``` def textile_to_html text = URI.unescape(params['postbody']) ... ```
31,320
<p>What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in <code>puts Time.now</code> calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.</p>
[ { "answer_id": 31359, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 3, "selected": false, "text": "<p>Use the Benchmark standard library and the various tests available in Rails (unit, functional, integration). Here's an e...
2008/08/27
[ "https://Stackoverflow.com/questions/31320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/757/" ]
What is the best way to profile a controller action in Ruby on Rails. Currently I am using the brute-force method of throwing in `puts Time.now` calls between what I think will be a bottleneck. But that feels really, really dirty. There has got to be a better way.
I picked up this technique a while back and have found it quite handy. When it's in place, you can add `?profile=true` to any URL that hits a controller. Your action will run as usual, but instead of delivering the rendered page to the browser, it'll send a detailed, nicely formatted ruby-prof page that shows where yo...
31,326
<p>I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there.</p> <p>We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credent...
[ { "answer_id": 31334, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": -1, "selected": false, "text": "<p>Hopefully this will be useful until someone actually comes along with an explicit answer - <a href=\"http://forums....
2008/08/27
[ "https://Stackoverflow.com/questions/31326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/71/" ]
I have a few internal .net web application here that require users to "log out" of them. I know this may seem moot on an Intranet application, but nonetheless it is there. We are using Windows authentication for our Intranet apps, so we tie in to our Active Directory with Basic Authentication and the credentials get s...
I've come up with a fix that seems fairly consistent but is hacky and [I'm still not happy with it](https://stackoverflow.com/questions/6277919). It does work though :-) 1) Redirect them to a Logoff page 2) On that page fire a script to ajax load another page with dummy credentials (sample in jQuery): ``` $j.ajax({...
31,346
<p>The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?</p>
[ { "answer_id": 31454, "author": "Jonas Follesø", "author_id": 1199387, "author_profile": "https://Stackoverflow.com/users/1199387", "pm_score": 3, "selected": true, "text": "<p>Yeah - In a way you're both asking and answering the question yourself... But that is one of the two options I ...
2008/08/27
[ "https://Stackoverflow.com/questions/31346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners?
Yeah - In a way you're both asking and answering the question yourself... But that is one of the two options I can think of. The reasons that might be a problem is that you lose some of the features/control you get from the MediaElement control. Another option is to do this: 1. Add your MediaElement to your page. 2. D...
31,366
<p>I am performing a find and replace on the line feed character (<code>&amp;#10;</code>) and replacing it with the paragraph close and paragraph open tags using the following code:</p> <pre><code>&lt;xsl:template match="/STORIES/STORY"&gt; &lt;component&gt; &lt;xsl:if test="boolean(ARTICLEBODY)"&gt; ...
[ { "answer_id": 31517, "author": "Mike Haboustak", "author_id": 2146, "author_profile": "https://Stackoverflow.com/users/2146", "pm_score": 1, "selected": false, "text": "<p>Given the XPath functions that you're calling which I don't remember having the luxury of in my MSXSL work, it look...
2008/08/27
[ "https://Stackoverflow.com/questions/31366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/274/" ]
I am performing a find and replace on the line feed character (`&#10;`) and replacing it with the paragraph close and paragraph open tags using the following code: ``` <xsl:template match="/STORIES/STORY"> <component> <xsl:if test="boolean(ARTICLEBODY)"> <p> <xsl:call-templat...
`disable-output-escaping` isn't evil in itself, but there are only few cases where you should use it and this isn't one of them. In XSLT you work with trees, not markup string. Here's an XSTL 1.0 solution: ``` <xsl:template match="/STORIES/STORY"> <component> <xsl:if test="ARTICLEBODY"> <xsl:call-template ...
31,380
<p>I currently use the following function to do a simple HTTP GET.</p> <pre><code>public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); ...
[ { "answer_id": 31392, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 1, "selected": false, "text": "<p>You are correct, if you use BufferedReader for reading HTTP content and headers you will want InputStreamReader so you can...
2008/08/28
[ "https://Stackoverflow.com/questions/31380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
I currently use the following function to do a simple HTTP GET. ``` public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { ...
In this case, I would do as you are doing (use a byte array for buffering and not one of the stream buffers). There are exceptions, though. One place you see buffers (output this time) is in the servlet API. Data isn't written to the underlying stream until *flush()* is called, allowing you to buffer output but then d...
31,394
<p>I see many similar questions, however I want to find the Username of the currently logged in user using Java.</p> <p>Its probably something like:</p> <pre><code>System.getProperty(current.user); </code></pre> <p>But, I'm not quite sure.</p>
[ { "answer_id": 31401, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 6, "selected": true, "text": "<p>You're actually really close. This is what you're looking for:</p>\n\n<pre><code>System.getProperty(\"user.name\")\n</cod...
2008/08/28
[ "https://Stackoverflow.com/questions/31394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
I see many similar questions, however I want to find the Username of the currently logged in user using Java. Its probably something like: ``` System.getProperty(current.user); ``` But, I'm not quite sure.
You're actually really close. This is what you're looking for: ``` System.getProperty("user.name") ```
31,415
<p>Using regular expressions, what is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter):</p> <pre><code>&lt;html&gt; &lt;head&gt; [snip] &lt;meta name="generator" value="thevalue i'm looking for" /&gt; [snip] </code></pre>
[ { "answer_id": 31432, "author": "Mike Haboustak", "author_id": 2146, "author_profile": "https://Stackoverflow.com/users/2146", "pm_score": 4, "selected": true, "text": "<p>Depends on how sophisticated of an Http request you need to build (authentication, etc). Here's one simple way I've ...
2008/08/28
[ "https://Stackoverflow.com/questions/31415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
Using regular expressions, what is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter): ``` <html> <head> [snip] <meta name="generator" value="thevalue i'm looking for" /> [snip] ```
Depends on how sophisticated of an Http request you need to build (authentication, etc). Here's one simple way I've seen used in the past. ``` StringBuilder html = new StringBuilder(); java.net.URL url = new URL("http://www.google.com/"); BufferedReader input = null; try { input new BufferedReader( new In...
31,424
<p>When creating a criteria in NHibernate I can use</p> <p>Restriction.In() or<br> Restriction.InG()</p> <p>What is the difference between them?</p>
[ { "answer_id": 31428, "author": "Sean Chambers", "author_id": 2993, "author_profile": "https://Stackoverflow.com/users/2993", "pm_score": 0, "selected": false, "text": "<p>Restriction.In definately creates a subquery with whatever criteria you pass to the .In() method, but not sure what ...
2008/08/28
[ "https://Stackoverflow.com/questions/31424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
When creating a criteria in NHibernate I can use Restriction.In() or Restriction.InG() What is the difference between them?
InG is the generic equivalent of In (for collections) The signatures of the methods are as follows (only the ICollection In overload is shown): ``` In(string propertyName, ICollection values) ``` vs. ``` InG<T>(string propertyName, ICollection<T> values) ``` Looking at NHibernate's source code (trunk) it seems t...
31,462
<p>Without the use of any external library, what is the simplest way to fetch a website's HTML content into a String?</p>
[ { "answer_id": 31463, "author": "pek", "author_id": 2644, "author_profile": "https://Stackoverflow.com/users/2644", "pm_score": 7, "selected": true, "text": "<p>I'm currently using this:</p>\n\n<pre><code>String content = null;\nURLConnection connection = null;\ntry {\n connection = ne...
2008/08/28
[ "https://Stackoverflow.com/questions/31462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
Without the use of any external library, what is the simplest way to fetch a website's HTML content into a String?
I'm currently using this: ``` String content = null; URLConnection connection = null; try { connection = new URL("http://www.google.com").openConnection(); Scanner scanner = new Scanner(connection.getInputStream()); scanner.useDelimiter("\\Z"); content = scanner.next(); scanner.close(); }catch ( Exception e...
31,465
<p>When you get a badge or aren't logged in to stack overflow there's a groovy little notification bar at the top of the page that lets you know there's something going on.</p> <p>I know the SOflow team use JQuery, but I was wondering if anyone knew of an implementation of the same style of notification system in asp....
[ { "answer_id": 31463, "author": "pek", "author_id": 2644, "author_profile": "https://Stackoverflow.com/users/2644", "pm_score": 7, "selected": true, "text": "<p>I'm currently using this:</p>\n\n<pre><code>String content = null;\nURLConnection connection = null;\ntry {\n connection = ne...
2008/08/28
[ "https://Stackoverflow.com/questions/31465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
When you get a badge or aren't logged in to stack overflow there's a groovy little notification bar at the top of the page that lets you know there's something going on. I know the SOflow team use JQuery, but I was wondering if anyone knew of an implementation of the same style of notification system in asp.net AJAX. ...
I'm currently using this: ``` String content = null; URLConnection connection = null; try { connection = new URL("http://www.google.com").openConnection(); Scanner scanner = new Scanner(connection.getInputStream()); scanner.useDelimiter("\\Z"); content = scanner.next(); scanner.close(); }catch ( Exception e...
31,498
<p>I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using <code>default(T)</code>. When you call default on a value type or a string, it initializes it to a reasonable value (such as empty string). When you call <code>default(T)</code> on an object, it returns nul...
[ { "answer_id": 31512, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": false, "text": "<pre><code>if (typeof(T).IsValueType || typeof(T) == typeof(String))\n{\n return default(T);\n}\nelse\n{\n return Act...
2008/08/28
[ "https://Stackoverflow.com/questions/31498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/67/" ]
I have a generic class that should allow any type, primitive or otherwise. The only problem with this is using `default(T)`. When you call default on a value type or a string, it initializes it to a reasonable value (such as empty string). When you call `default(T)` on an object, it returns null. For various reasons we...
Keep in mind that default(string) is null, not string.Empty. You may want a special case in your code: ``` if (typeof(T) == typeof(String)) return (T)(object)String.Empty; ```
31,500
<p>If I have a query like:</p> <pre><code>Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) </code></pre> <p>and I have an index on the <code>EmployeeTypeId</code> field, does SQL server still use that index?</p>
[ { "answer_id": 31504, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 3, "selected": false, "text": "<p>Usually it would, unless the IN clause covers too much of the table, and then it will do a table scan. Best way to find ou...
2008/08/28
[ "https://Stackoverflow.com/questions/31500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
If I have a query like: ``` Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) ``` and I have an index on the `EmployeeTypeId` field, does SQL server still use that index?
Yeah, that's right. If your `Employee` table has 10,000 records, and only 5 records have `EmployeeTypeId` in (1,2,3), then it will most likely use the index to fetch the records. However, if it finds that 9,000 records have the `EmployeeTypeId` in (1,2,3), then it would most likely just do a table scan to get the corre...
31,551
<p>Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment:</p> <pre><code>UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra, dbo.Rates rb WHERE ra.ResourceID = rb.ResourceID AND ra.PriceSched = 't8' AND r...
[ { "answer_id": 835999, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": false, "text": "<pre><code>UPDATE ra \n SET ra.ItemValue = rb.ItemValue\n FROM dbo.Rates ra\n INNER JOIN dbo.Rates rb\n ON ra.Resou...
2008/08/28
[ "https://Stackoverflow.com/questions/31551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2027/" ]
Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment: ``` UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra, dbo.Rates rb WHERE ra.ResourceID = rb.ResourceID AND ra.PriceSched = 't8' AND rb.PriceSched ...
``` UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra INNER JOIN dbo.Rates rb ON ra.ResourceID = rb.ResourceID WHERE ra.PriceSched = 't8' AND rb.PriceSched = 't9'; ``` This might help in improving performance.
31,561
<p>Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) whic...
[ { "answer_id": 31603, "author": "Alasdair", "author_id": 2654, "author_profile": "https://Stackoverflow.com/users/2654", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm\" rel=\"nofollow noreferrer\">Map</a> is more ge...
2008/08/28
[ "https://Stackoverflow.com/questions/31561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3326/" ]
Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, of...
[Map](http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm) is more general than mapcar, for example you could do the following rather than using mapcar: ``` (map 'list #'function listvar) ``` How do I keep scheme and CL separate in my head? I guess when you know both languages well enough you just know w...
31,567
<p>I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin ...
[ { "answer_id": 31576, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 0, "selected": false, "text": "<p>Is your type not public, if so, call the overload that takes in a boolean:</p>\n\n<pre><code>Activator.CreateInstance(type, ...
2008/08/28
[ "https://Stackoverflow.com/questions/31567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1880/" ]
I'm trying to wrap my head around reflection, so I decided to add plugin capability to a program that I'm writing. The only way to understand a concept is to get your fingers dirty and write the code, so I went the route of creating a simple interface library consisting of the IPlugin and IHost interfaces, a plugin imp...
I'm just guessing here because from your code it's not obvious where do you have definition of IPlugin interface but if you can't cast in your host application then you are probably having IPlugin interface in your host assembly and then at the same time in your plugin assembly. This won't work. The easiest thing is t...
31,584
<p>For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the <a href="http://en.wikipedia.org/wiki/Builder_pattern" rel="noreferrer">Builder pattern</a> in <em>Effective Java</em> that is kinda the same).</p> <p>Basically, all setter met...
[ { "answer_id": 31589, "author": "Bernard", "author_id": 61, "author_profile": "https://Stackoverflow.com/users/61", "pm_score": 2, "selected": false, "text": "<p>I wouldn't do it myself, because to me it muddies what a particular method does, and the method-chaining is of limited use to ...
2008/08/28
[ "https://Stackoverflow.com/questions/31584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the [Builder pattern](http://en.wikipedia.org/wiki/Builder_pattern) in *Effective Java* that is kinda the same). Basically, all setter methods return the object itself so then you ca...
@pek Chained invocation is one of proposals for Java 7. It says that if a method return type is void, it should implicitly return **this**. If you're interested in this topic, there is a bunch of links and a simple example on [Alex Miller's Java 7 page](http://tech.puredanger.com/java7#chained).
31,672
<p>I've recently come to maintain a large amount of scientific calculation-intensive FORTRAN code. I'm having difficulties getting a handle on all of the, say, nuances, of a forty year old language, despite google &amp; two introductory level books. The code is rife with "performance enhancing improvements". Does an...
[ { "answer_id": 31687, "author": "tuxedo", "author_id": 3286, "author_profile": "https://Stackoverflow.com/users/3286", "pm_score": 3, "selected": false, "text": "<p>Well, in one sense, you're lucky, 'cause Fortran doesn't have much in the way of subtle flow-of-control constructs or inher...
2008/08/28
[ "https://Stackoverflow.com/questions/31672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1390/" ]
I've recently come to maintain a large amount of scientific calculation-intensive FORTRAN code. I'm having difficulties getting a handle on all of the, say, nuances, of a forty year old language, despite google & two introductory level books. The code is rife with "performance enhancing improvements". Does anyone have ...
You kind of have to get a "feel" for what programmers had to do back in the day. The vast majority of the code I work with is older than I am and ran on machines that were "new" when my parents were in high school. Common FORTRAN-isms I deal with, that hurt readability are: * Common blocks * Implicit variables * Two ...
31,673
<p>Wifi support on Vista is fine, but <a href="http://msdn.microsoft.com/en-us/library/bb204766.aspx" rel="nofollow noreferrer">Native Wifi on XP</a> is half baked. <a href="http://msdn.microsoft.com/en-us/library/aa504121.aspx" rel="nofollow noreferrer">NDIS 802.11 Wireless LAN Miniport Drivers</a> only gets you part ...
[ { "answer_id": 31687, "author": "tuxedo", "author_id": 3286, "author_profile": "https://Stackoverflow.com/users/3286", "pm_score": 3, "selected": false, "text": "<p>Well, in one sense, you're lucky, 'cause Fortran doesn't have much in the way of subtle flow-of-control constructs or inher...
2008/08/28
[ "https://Stackoverflow.com/questions/31673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2514/" ]
Wifi support on Vista is fine, but [Native Wifi on XP](http://msdn.microsoft.com/en-us/library/bb204766.aspx) is half baked. [NDIS 802.11 Wireless LAN Miniport Drivers](http://msdn.microsoft.com/en-us/library/aa504121.aspx) only gets you part of the way there (e.g. network scanning). From what I've read (and tried), th...
You kind of have to get a "feel" for what programmers had to do back in the day. The vast majority of the code I work with is older than I am and ran on machines that were "new" when my parents were in high school. Common FORTRAN-isms I deal with, that hurt readability are: * Common blocks * Implicit variables * Two ...
31,693
<p>I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc.</p> <p>So, what are the main differences between C++, C#, Java in generics? Pros/cons of each?</p>
[ { "answer_id": 31696, "author": "travis", "author_id": 1414, "author_profile": "https://Stackoverflow.com/users/1414", "pm_score": 2, "selected": false, "text": "<p>Wikipedia has great write-ups comparing both <a href=\"http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java#Generics...
2008/08/28
[ "https://Stackoverflow.com/questions/31693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
I mostly use Java and generics are relatively new. I keep reading that Java made the wrong decision or that .NET has better implementations etc. etc. So, what are the main differences between C++, C#, Java in generics? Pros/cons of each?
I'll add my voice to the noise and take a stab at making things clear: C# Generics allow you to declare something like this. ----------------------------------------------------- ``` List<Person> foo = new List<Person>(); ``` and then the compiler will prevent you from putting things that aren't `Person` into the l...
31,701
<p>I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. </p> <p>Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the ...
[ { "answer_id": 31696, "author": "travis", "author_id": 1414, "author_profile": "https://Stackoverflow.com/users/1414", "pm_score": 2, "selected": false, "text": "<p>Wikipedia has great write-ups comparing both <a href=\"http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java#Generics...
2008/08/28
[ "https://Stackoverflow.com/questions/31701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2785/" ]
I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the front?
I'll add my voice to the noise and take a stab at making things clear: C# Generics allow you to declare something like this. ----------------------------------------------------- ``` List<Person> foo = new List<Person>(); ``` and then the compiler will prevent you from putting things that aren't `Person` into the l...
31,708
<p>I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms).</p> <p>Simplified code:</p> <pre><code>Dictionary&lt;Guid, Record&gt; dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec =&gt; rec.Name == "foo"); myListView.DataBind(); </code></p...
[ { "answer_id": 31710, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>var matches = dict.Values.Where(rec =&gt; rec.Name == \"foo\").ToList();\n</code></pre>\n\n...
2008/08/28
[ "https://Stackoverflow.com/questions/31708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/202/" ]
I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: ``` Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); ``` I thought that would work but in f...
Try this: ``` var matches = dict.Values.Where(rec => rec.Name == "foo").ToList(); ``` Be aware that that will essentially be creating a new list from the original Values collection, and so any changes to your dictionary won't automatically be reflected in your bound control.
31,794
<p>In .net frameworks 1.1, I use </p> <pre><code>System.Configuration.ConfigurationSettings.AppSettings["name"]; </code></pre> <p>for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this:</p> <pre><code>System.Configu...
[ { "answer_id": 31796, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 4, "selected": true, "text": "<p>You have to reference the System.configuration assembly (note the lowercase)</p>\n\n<p>I don't know why this assembly...
2008/08/28
[ "https://Stackoverflow.com/questions/31794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2121/" ]
In .net frameworks 1.1, I use ``` System.Configuration.ConfigurationSettings.AppSettings["name"]; ``` for application settings. But in .Net 2.0, it says ConfigurationSettings is obsolete and to use ConfigurationManager instead. So I swapped it out with this: ``` System.Configuration.ConfigurationManager.AppSetting...
You have to reference the System.configuration assembly (note the lowercase) I don't know why this assembly is not added by default to new projects on Visual Studio, but I find myself having the same problem every time I start a new project. I always forget to add the reference.
31,818
<p>How can I find out which Service Pack is installed on my copy of SQL Server?</p>
[ { "answer_id": 31820, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 5, "selected": true, "text": "<p>From TechNet: <a href=\"https://gallery.technet.microsoft.com/Determining-which-version-af0f16f6\" rel=\"noreferrer\"...
2008/08/28
[ "https://Stackoverflow.com/questions/31818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3353/" ]
How can I find out which Service Pack is installed on my copy of SQL Server?
From TechNet: [Determining which version and edition of SQL Server Database Engine is running](https://gallery.technet.microsoft.com/Determining-which-version-af0f16f6) ``` -- SQL Server 2000/2005 SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') -- SQL Server 6.5/7...
31,849
<p>It seems that it is impossible to capture the keyboard event normally used for copy when running a Flex application in the browser or as an AIR app, presumably because the browser or OS is intercepting it first.</p> <p>Is there a way to tell the browser or OS to let the event through?</p> <p>For example, on an Adv...
[ { "answer_id": 32086, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 3, "selected": true, "text": "<p>I did a test where I listened for key up events on the stage and noticed that (on my Mac) I could capture control-c, control-v...
2008/08/28
[ "https://Stackoverflow.com/questions/31849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3023/" ]
It seems that it is impossible to capture the keyboard event normally used for copy when running a Flex application in the browser or as an AIR app, presumably because the browser or OS is intercepting it first. Is there a way to tell the browser or OS to let the event through? For example, on an AdvancedDataGrid I h...
I did a test where I listened for key up events on the stage and noticed that (on my Mac) I could capture control-c, control-v, etc. just fine, but anything involving command (the  key) wasn't captured until I released the command key, and then ctrlKey was false (even though the docs says that ctrlKey should be true f...
31,854
<p>Disclaimer: Near zero with marshalling concepts..</p> <p>I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer.<br> <strong>What are the right set of attributes I need to decorate my struct definition ?</strong> </p> <pre><code...
[ { "answer_id": 32138, "author": "Andrew", "author_id": 1948, "author_profile": "https://Stackoverflow.com/users/1948", "pm_score": 1, "selected": false, "text": "<p>The answer depends on what the native definitions are that you are trying to marshal too. You haven't provided enough info...
2008/08/28
[ "https://Stackoverflow.com/questions/31854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
Disclaimer: Near zero with marshalling concepts.. I have a struct B that contains a string + an array of structs C. I need to send this across the giant interop chasm to a COM - C++ consumer. **What are the right set of attributes I need to decorate my struct definition ?** ``` [ComVisible (true)] [StructLayout(L...
[C++: The Most Powerful Language for .NET Framework Programming](http://msdn.microsoft.com/en-us/library/ms379617%28VS.80%29.aspx#vs05cplus_topic12) I was about to approach a project that needed to marshal structured data across the C++/C# boundary, but I found what could be a better way (especially if you know C++ an...
31,868
<p>What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?</p> <p><strong>Following the two initial answers...</strong></p> <ul> <li><p>We definitely need to use the Web Service layer as we will be making these calls from remot...
[ { "answer_id": 32499, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 1, "selected": false, "text": "<p>From a colleage at work:</p>\n<blockquote>\n<p>Lazy way: your Windows WebDAV filesystem interface. It is bad as a pr...
2008/08/28
[ "https://Stackoverflow.com/questions/31868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3362/" ]
What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes? **Following the two initial answers...** * We definitely need to use the Web Service layer as we will be making these calls from remote client applications. * The WebDAV m...
Example of using the WSS "Copy" Web service to upload a document to a library... ``` public static void UploadFile2007(string destinationUrl, byte[] fileData) { // List of desination Urls, Just one in this example. string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) }; // Empty Field Informat...
31,870
<p>What is the best way to include an html entity in XSLT?</p> <pre><code>&lt;xsl:template match="/a/node"&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:text&gt;&amp;nbsp;&lt;/xsl:text&gt; &lt;/xsl:template&gt; </code></pre> <p>this one returns a <strong>XsltParseError</strong></p>
[ { "answer_id": 31873, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 8, "selected": true, "text": "<p>You can use CDATA section</p>\n\n<pre><code>&lt;xsl:text disable-output-escaping=\"yes\"&gt;&lt;![CDATA[&amp;nbsp;]]&gt;&lt;/xs...
2008/08/28
[ "https://Stackoverflow.com/questions/31870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1532/" ]
What is the best way to include an html entity in XSLT? ``` <xsl:template match="/a/node"> <xsl:value-of select="."/> <xsl:text>&nbsp;</xsl:text> </xsl:template> ``` this one returns a **XsltParseError**
You can use CDATA section ``` <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text> ``` or you can describe &nbsp in local DTD: ``` <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]> ``` or just use `&#160;` instead of `&nbsp;`
31,871
<p>Ok, I have a strange exception thrown from my code that's been bothering me for ages.</p> <pre><code>System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall at System.Net.Sockets.Socket.Accept() at System.Net.Sockets.TcpListener.AcceptTcpClient() </code></pr...
[ { "answer_id": 34373, "author": "TimK", "author_id": 2348, "author_profile": "https://Stackoverflow.com/users/2348", "pm_score": 7, "selected": true, "text": "<p>Is it possible that the serverSocket is being closed from another thread? That will cause this exception.</p>\n" }, { ...
2008/08/28
[ "https://Stackoverflow.com/questions/31871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
Ok, I have a strange exception thrown from my code that's been bothering me for ages. ``` System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall at System.Net.Sockets.Socket.Accept() at System.Net.Sockets.TcpListener.AcceptTcpClient() ``` MSDN isn't terribly...
Is it possible that the serverSocket is being closed from another thread? That will cause this exception.
31,913
<p>I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it</p> <p>I was looking for a way to separate clearly some softwares internals from their representation in c++</p> <p>I have a generic parameter class (to be later stored in a container) that can ...
[ { "answer_id": 31944, "author": "graham.reeds", "author_id": 342, "author_profile": "https://Stackoverflow.com/users/342", "pm_score": 0, "selected": false, "text": "<p>If I understand this correctly...</p>\n\n<p>We had a object that could use different hardware options. To facilitate th...
2008/08/28
[ "https://Stackoverflow.com/questions/31913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3373/" ]
I'm sorry if my question is so long and technical but I think it's so important other people will be interested about it I was looking for a way to separate clearly some softwares internals from their representation in c++ I have a generic parameter class (to be later stored in a container) that can contain any kind ...
For a generic implementation of [Vistor](http://en.wikipedia.org/wiki/Visitor_pattern), I'd suggest the [Loki Visitor](http://loki-lib.sourceforge.net/index.php?n=Pattern.Visitor), part of the [Loki library](http://loki-lib.sourceforge.net/index.php?n=Main.HomePage).
31,930
<p>I've developed my own delivery extension for Reporting Services 2005, to integrate this with our SaaS marketing solution.</p> <p>It takes the subscription, and takes a snapshot of the report with a custom set of parameters. It then renders the report, sends an e-mail with a link and the report attached as XLS.</p> ...
[ { "answer_id": 31960, "author": "Rowan", "author_id": 2087, "author_profile": "https://Stackoverflow.com/users/2087", "pm_score": 5, "selected": true, "text": "<p>Some tips:\nUnderstand the JSF request <a href=\"http://www.java-samples.com/showtutorial.php?tutorialid=470\" rel=\"nofollow...
2008/08/28
[ "https://Stackoverflow.com/questions/31930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2972/" ]
I've developed my own delivery extension for Reporting Services 2005, to integrate this with our SaaS marketing solution. It takes the subscription, and takes a snapshot of the report with a custom set of parameters. It then renders the report, sends an e-mail with a link and the report attached as XLS. Everything wo...
Some tips: Understand the JSF request [lifecycle](http://www.java-samples.com/showtutorial.php?tutorialid=470) and where your various pieces of code fit in it. Especially find out why your model values will not be updated if there are validation errors. Choose a tag library and then stick with it. Take your time to de...
31,931
<p>I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.</p> <p>It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way. </p> <p>What's th...
[ { "answer_id": 31938, "author": "liammclennan", "author_id": 2785, "author_profile": "https://Stackoverflow.com/users/2785", "pm_score": 3, "selected": false, "text": "<pre><code>var today = new Date();\nvar yesterday = new Date().setDate(today.getDate() -1);\n</code></pre>\n" }, { ...
2008/08/28
[ "https://Stackoverflow.com/questions/31931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/916/" ]
I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'. It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way. What's the simplest way of d...
```js var d = new Date(); d.setDate(d.getDate() - 1); console.log(d); ```
32,000
<p>I'm basically trying to figure out the simplest way to perform your basic insert operation in C#.NET using the SqlClient namespace. </p> <p>I'm using <code>SqlConnection</code> for my db link, I've already had success executing some reads, and I want to know the simplest way to insert data. I'm finding what seem to...
[ { "answer_id": 32005, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": true, "text": "<pre><code>using (var conn = new SqlConnection(yourConnectionString))\n{\n var cmd = new SqlCommand(\"insert into Foo v...
2008/08/28
[ "https://Stackoverflow.com/questions/32000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1344/" ]
I'm basically trying to figure out the simplest way to perform your basic insert operation in C#.NET using the SqlClient namespace. I'm using `SqlConnection` for my db link, I've already had success executing some reads, and I want to know the simplest way to insert data. I'm finding what seem to be pretty verbose me...
``` using (var conn = new SqlConnection(yourConnectionString)) { var cmd = new SqlCommand("insert into Foo values (@bar)", conn); cmd.Parameters.AddWithValue("@bar", 17); conn.Open(); cmd.ExecuteNonQuery(); } ```
32,001
<p>I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. </p> <p>If, however, before X seconds has elapsed, I decide that the event should occu...
[ { "answer_id": 32008, "author": "Brian Matthews", "author_id": 1969, "author_profile": "https://Stackoverflow.com/users/1969", "pm_score": 1, "selected": false, "text": "<p>Do you need to schedule a recurring task? In that case I recommend you consider using <a href=\"http://opensymphony...
2008/08/28
[ "https://Stackoverflow.com/questions/32001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/142/" ]
I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. If, however, before X seconds has elapsed, I decide that the event should occur after Y ...
According to the [`Timer`](http://java.sun.com/javase/6/docs/api/java/util/Timer.html) documentation, in Java 1.5 onwards, you should prefer the [`ScheduledThreadPoolExecutor`](http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html) instead. (You may like to create this executor usi...
32,003
<p>Im searching a tool which allows me to specify some folders as "bookmarks" and than access them on the commandline (on Windows XP) via a keyword. Something like:</p> <pre><code>C:\&gt; go home D:\profiles\user\home\&gt; go svn-project1 D:\projects\project1\svn\branch\src\&gt; </code></pre> <p>I'm currently using a...
[ { "answer_id": 32007, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "<p>With PowerShell you could add the folders as variables in your profile.ps1 file, like:</p>\n\n<pre><code>$vids=\"C:\\U...
2008/08/28
[ "https://Stackoverflow.com/questions/32003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1462/" ]
Im searching a tool which allows me to specify some folders as "bookmarks" and than access them on the commandline (on Windows XP) via a keyword. Something like: ``` C:\> go home D:\profiles\user\home\> go svn-project1 D:\projects\project1\svn\branch\src\> ``` I'm currently using a bunch of batch files, but editing ...
What you are looking for is called DOSKEY You can use the doskey command to create macros in the command interpreter. For example: ``` doskey mcd=mkdir "$*"$Tpushd "$*" ``` creates a new command "mcd" that creates a new directory and then changes to that directory (I prefer "pushd" to "cd" in this case because it ...
32,027
<p>I'm new to NAnt but have some experience with Ant and CruiseControl.</p> <p>What I want to do is have my SVN project include all tools needed (like NUnit and Mocks etc) so I can check out onto a fresh machine and build. This strategy is outlined by J.P Boodhoo <a href="http://blog.jpboodhoo.com/NAntStarterSeries.as...
[ { "answer_id": 32317, "author": "RobertTheGrey", "author_id": 1107, "author_profile": "https://Stackoverflow.com/users/1107", "pm_score": 4, "selected": true, "text": "<p>This shouldn't be a particularly difficult excercise. We do some fairly similar stuff on one of my projects since hal...
2008/08/28
[ "https://Stackoverflow.com/questions/32027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3024/" ]
I'm new to NAnt but have some experience with Ant and CruiseControl. What I want to do is have my SVN project include all tools needed (like NUnit and Mocks etc) so I can check out onto a fresh machine and build. This strategy is outlined by J.P Boodhoo [here.](http://blog.jpboodhoo.com/NAntStarterSeries.aspx) So far...
This shouldn't be a particularly difficult excercise. We do some fairly similar stuff on one of my projects since half of it runs on Java using Ant to run relevant targets, and the other half is .Net (C#) for the UI. The projects get run on windows machines for development, but the servers (Java) run linux, but in the ...
32,041
<p>Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations.</p> <p>It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performa...
[ { "answer_id": 32046, "author": "sparkes", "author_id": 269, "author_profile": "https://Stackoverflow.com/users/269", "pm_score": 0, "selected": false, "text": "<p>Use <a href=\"http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&amp;ixPost=63500\" rel=\"nofollow noreferrer\"...
2008/08/28
[ "https://Stackoverflow.com/questions/32041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1772/" ]
Is it possible for the compiler to remove statements used for debugging purposes (such as logging) from production code? The debug statements would need to be marked somehow, maybe using annotations. It's easy to set a property (debug = true) and check it at each debug statement, but this can reduce performance. It wo...
Two recommendations. **First:** for real logging, use a modern logging package like log4j or java's own built in logging. Don't worry about performance so much, the logging level check is on the order of nanoseconds. (it's an integer comparison). And if you have more than a single log statement, guard the whole block...
32,044
<p>I have a tree structure in memory that I would like to render in HTML using a Django template. </p> <pre><code>class Node(): name = "node name" children = [] </code></pre> <p>There will be some object <code>root</code> that is a <code>Node</code>, and <code>children</code> is a list of <code>Node</code>s. <cod...
[ { "answer_id": 32125, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 6, "selected": true, "text": "<p>I think the canonical answer is: \"Don't\".</p>\n\n<p>What you should probably do instead is unravel the thing in y...
2008/08/28
[ "https://Stackoverflow.com/questions/32044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3154/" ]
I have a tree structure in memory that I would like to render in HTML using a Django template. ``` class Node(): name = "node name" children = [] ``` There will be some object `root` that is a `Node`, and `children` is a list of `Node`s. `root` will be passed in the content of the template. I have found [this]...
I think the canonical answer is: "Don't". What you should probably do instead is unravel the thing in your *view* code, so it's just a matter of iterating over (in|de)dents in the template. I think I'd do it by appending indents and dedents to a list while recursing through the tree and then sending that "travelogue" ...
32,058
<p>I have a simple web service operation like this one:</p> <pre><code> [WebMethod] public string HelloWorld() { throw new Exception("HelloWorldException"); return "Hello World"; } </code></pre> <p>And then I have a client application that consumes the web service and then calls the ope...
[ { "answer_id": 32508, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 4, "selected": true, "text": "<p>Unfortunately I don't think this is possible.</p>\n\n<p>The exception you are raising in your web service code is being e...
2008/08/28
[ "https://Stackoverflow.com/questions/32058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3379/" ]
I have a simple web service operation like this one: ``` [WebMethod] public string HelloWorld() { throw new Exception("HelloWorldException"); return "Hello World"; } ``` And then I have a client application that consumes the web service and then calls the operation. Obviously it will ...
Unfortunately I don't think this is possible. The exception you are raising in your web service code is being encoded into a Soap Fault, which then being passed as a string back to your client code. What you are seeing in the SoapException message is simply the text from the Soap fault, which is not being converted b...
32,059
<p>Let's say I have four tables: <code>PAGE</code>, <code>USER</code>, <code>TAG</code>, and <code>PAGE-TAG</code>:</p> <pre><code>Table | Fields ------------------------------------------ PAGE | ID, CONTENT TAG | ID, NAME USER | ID, NAME PAGE-TAG | ID, PAGE-ID, TAG-ID, USER-ID </code></p...
[ { "answer_id": 32070, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 2, "selected": false, "text": "<p>This might work:</p>\n\n<pre><code>select page.content, count(page-tag.tag-id) as tagcount\nfrom page inner join page...
2008/08/28
[ "https://Stackoverflow.com/questions/32059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
Let's say I have four tables: `PAGE`, `USER`, `TAG`, and `PAGE-TAG`: ``` Table | Fields ------------------------------------------ PAGE | ID, CONTENT TAG | ID, NAME USER | ID, NAME PAGE-TAG | ID, PAGE-ID, TAG-ID, USER-ID ``` And let's say I have four pages: ``` PAGE#1 'Content page 1' ...
OK, so the key difference between this and kristof's answer is that you only want a count of 1 to show against page 1, because it has been tagged only with one tag from the set (even though two separate users both tagged it). I would suggest this: ``` SELECT page.ID, page.content, count(*) AS uniquetags FROM ( SE...
32,085
<p>In XLST how would you find out the length of a node-set?</p>
[ { "answer_id": 32092, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 5, "selected": true, "text": "<pre><code>&lt;xsl:variable name=\"length\" select=\"count(nodeset)\"/&gt;\n</code></pre>\n" }, { "answer_id": 32217, ...
2008/08/28
[ "https://Stackoverflow.com/questions/32085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In XLST how would you find out the length of a node-set?
``` <xsl:variable name="length" select="count(nodeset)"/> ```
32,100
<p>What is the simplest SQL query to find the second largest integer value in a specific column? </p> <p>There are maybe duplicate values in the column.</p>
[ { "answer_id": 32108, "author": "Magnar", "author_id": 1123, "author_profile": "https://Stackoverflow.com/users/1123", "pm_score": 3, "selected": false, "text": "<p>The easiest would be to get the second value from this result set in the application:</p>\n<pre><code>SELECT DISTINCT value...
2008/08/28
[ "https://Stackoverflow.com/questions/32100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
What is the simplest SQL query to find the second largest integer value in a specific column? There are maybe duplicate values in the column.
``` SELECT MAX( col ) FROM table WHERE col < ( SELECT MAX( col ) FROM table ) ```