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
94,305
<p>Lets say I have the option of identifying a code path to take on the basis of a string comparison or else iffing the type:</p> <p>Which is quicker and why?</p> <pre><code>switch(childNode.Name) { case "Bob": break; case "Jill": break; case "Marko": break; } if(childNode is Bob) { } e...
[ { "answer_id": 94319, "author": "moonshadow", "author_id": 11834, "author_profile": "https://Stackoverflow.com/users/11834", "pm_score": 2, "selected": false, "text": "<p>The switch() will compile out to code equivalent to a set of else ifs. The string comparisons will be much slower tha...
2008/09/18
[ "https://Stackoverflow.com/questions/94305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143/" ]
Lets say I have the option of identifying a code path to take on the basis of a string comparison or else iffing the type: Which is quicker and why? ``` switch(childNode.Name) { case "Bob": break; case "Jill": break; case "Marko": break; } if(childNode is Bob) { } elseif(childNode is Ji...
Greg's profile results are great for the exact scenario he covered, but interestingly, the relative costs of the different methods change dramatically when considering a number of different factors including the number of types being compared, and the relative frequency and any patterns in the underlying data. The sim...
94,331
<p>I use the recent Ganymede release of Eclipse, specifically the distro for Java EE and web developers. I have installed a few additional plugins (e.g. Subclipse, Spring, FindBugs) and removed all the Mylyn plugins. </p> <p>I don't do anything particularly heavy-duty within Eclipse such as starting an app server or c...
[ { "answer_id": 94376, "author": "Magsol", "author_id": 13604, "author_profile": "https://Stackoverflow.com/users/13604", "pm_score": 2, "selected": false, "text": "<p>Eclipse by itself is pretty bloated, and the more plugins you add only exacerbates the situation. It's still my favorite...
2008/09/18
[ "https://Stackoverflow.com/questions/94331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I use the recent Ganymede release of Eclipse, specifically the distro for Java EE and web developers. I have installed a few additional plugins (e.g. Subclipse, Spring, FindBugs) and removed all the Mylyn plugins. I don't do anything particularly heavy-duty within Eclipse such as starting an app server or connecting ...
I don't know about Eclipse specifically, I use IntelliJ which also suffers from memory growth (whether you're actively using it or not!). Anyway, in IntelliJ, I couldn't eliminate the problem, but I did slow down the memory growth by playing with the runtime VM options. You could try resetting these in Eclipse and see ...
94,342
<p>I have a string which contain tags in the form <code>&lt; tag &gt;</code>. Is there an easy way for me to programmatically replace instances of these tags with special ascii characters? e.g. replace a tag like <code>"&lt; tab &gt;"</code> with the ascii equivelent of <code>'/t'</code>?</p>
[ { "answer_id": 94350, "author": "ddc0660", "author_id": 16027, "author_profile": "https://Stackoverflow.com/users/16027", "pm_score": 1, "selected": false, "text": "<p>Regex patterns should do the trick.</p>\n" }, { "answer_id": 94366, "author": "Ferruccio", "author_id": ...
2008/09/18
[ "https://Stackoverflow.com/questions/94342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
I have a string which contain tags in the form `< tag >`. Is there an easy way for me to programmatically replace instances of these tags with special ascii characters? e.g. replace a tag like `"< tab >"` with the ascii equivelent of `'/t'`?
``` string s = "...<tab>..."; s = s.Replace("<tab>", "\t"); ```
94,372
<p>I am building a quiz and i need to calculate the total time taken to do the quiz. and i need to display the time taken in HH::MM::SS..any pointers?</p>
[ { "answer_id": 94427, "author": "Brian", "author_id": 1750627, "author_profile": "https://Stackoverflow.com/users/1750627", "pm_score": 3, "selected": true, "text": "<p>new Date().time returns the time in milliseconds.</p>\n\n<pre><code>var nStart:Number = new Date().time;\n\n// Some tim...
2008/09/18
[ "https://Stackoverflow.com/questions/94372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16458/" ]
I am building a quiz and i need to calculate the total time taken to do the quiz. and i need to display the time taken in HH::MM::SS..any pointers?
new Date().time returns the time in milliseconds. ``` var nStart:Number = new Date().time; // Some time passes var nMillisElapsed:Number = new Date().time - nStart; var strTime:String = Math.floor(nMillisElapsed / (1000 * 60 * 60)) + "::" + (Math.floor(nMillisElapsed / (1000 * 60)) % 60) + "::" + (Math.floo...
94,382
<p>I'm using gvim on Windows.</p> <p>In my _vimrc I've added:</p> <pre><code>set shell=powershell.exe set shellcmdflag=-c set shellpipe=&gt; set shellredir=&gt; function! Test() echo system("dir -name") endfunction command! -nargs=0 Test :call Test() </code></pre> <p>If I execute this function (:Test) I see nons...
[ { "answer_id": 94697, "author": "Mark Schill", "author_id": 9482, "author_profile": "https://Stackoverflow.com/users/9482", "pm_score": 2, "selected": false, "text": "<p>Try replacing </p>\n\n<pre><code>\"dir \\*vim\\*\"\n</code></pre>\n\n<p>with </p>\n\n<pre><code> \" -command { dir \\*...
2008/09/18
[ "https://Stackoverflow.com/questions/94382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4407/" ]
I'm using gvim on Windows. In my \_vimrc I've added: ``` set shell=powershell.exe set shellcmdflag=-c set shellpipe=> set shellredir=> function! Test() echo system("dir -name") endfunction command! -nargs=0 Test :call Test() ``` If I execute this function (:Test) I see nonsense characters (non number/letter ASC...
It is a bit of a hack, but the following works in Vim 7.2. Notice, I am running Powershell within a CMD session. ``` if has("win32") set shell=cmd.exe set shellcmdflag=/c\ powershell.exe\ -NoLogo\ -NoProfile\ -NonInteractive\ -ExecutionPolicy\ RemoteSigned set shellpipe=| set shellredir=> endif functi...
94,445
<p>I'm generating a self-signed SSL certificate to protect my server's admin section, and I keep getting this message from OpenSSL:</p> <blockquote> <p>unable to write 'random state'</p> </blockquote> <p>What does this mean?</p> <p>This is on an Ubuntu server. I have upgraded libssl to fix <a href="http://www.ubun...
[ { "answer_id": 94458, "author": "Ville Laurikari", "author_id": 7446, "author_profile": "https://Stackoverflow.com/users/7446", "pm_score": 10, "selected": true, "text": "<p>In practice, the most common reason for this happening seems to be that the .rnd file in your home directory is ow...
2008/09/18
[ "https://Stackoverflow.com/questions/94445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965/" ]
I'm generating a self-signed SSL certificate to protect my server's admin section, and I keep getting this message from OpenSSL: > > unable to write 'random state' > > > What does this mean? This is on an Ubuntu server. I have upgraded libssl to fix [the recent security vulnerability](http://www.ubuntu.com/usn/u...
In practice, the most common reason for this happening seems to be that the .rnd file in your home directory is owned by root rather than your account. The quick fix: ``` sudo rm ~/.rnd ``` For more information, here's the entry from the [OpenSSL FAQ](http://www.openssl.org/support/faq.html#USER2): > > Sometimes t...
94,456
<p>I have an instance of a <code>System.Drawing.Bitmap</code> and would like to make it available to my WPF app in the form of a <code>System.Windows.Media.Imaging.BitmapImage</code>.</p> <p>What would be the best approach for this?</p>
[ { "answer_id": 94474, "author": "Hallgrim", "author_id": 15454, "author_profile": "https://Stackoverflow.com/users/15454", "pm_score": 3, "selected": false, "text": "<p>The easiest thing is if you can make the WPF bitmap from a file directly.</p>\n\n<p>Otherwise you will have to use Syst...
2008/09/18
[ "https://Stackoverflow.com/questions/94456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2723/" ]
I have an instance of a `System.Drawing.Bitmap` and would like to make it available to my WPF app in the form of a `System.Windows.Media.Imaging.BitmapImage`. What would be the best approach for this?
Thanks to Hallgrim, here is the code I ended up with: ``` ScreenCapture = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( bmp.GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(width, height)); ``` I also ended up binding to a BitmapSource ins...
94,488
<p>More specifically, when the exception contains custom objects which may or may not themselves be serializable.</p> <p>Take this example:</p> <pre><code>public class MyException : Exception { private readonly string resourceName; private readonly IList&lt;string&gt; validationErrors; public MyException...
[ { "answer_id": 94511, "author": "David Hill", "author_id": 1181217, "author_profile": "https://Stackoverflow.com/users/1181217", "pm_score": 0, "selected": false, "text": "<p>Mark the class with [Serializable], although I'm not sure how well a IList member will be handled by the serializ...
2008/09/18
[ "https://Stackoverflow.com/questions/94488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5975/" ]
More specifically, when the exception contains custom objects which may or may not themselves be serializable. Take this example: ``` public class MyException : Exception { private readonly string resourceName; private readonly IList<string> validationErrors; public MyException(string resourceName, IList...
Base implementation, without custom properties ---------------------------------------------- ***SerializableExceptionWithoutCustomProperties.cs:*** ``` namespace SerializableExceptions { using System; using System.Runtime.Serialization; [Serializable] // Important: This attribute is NOT inherited fr...
94,490
<p>I need to read selected files, matching on the file name, from a remote zip archive using Python. I don't want to save the full zip to a temporary file (it's not that large, so I can handle everything in memory).</p> <p>I've already written the code and it works, and I'm answering this myself so I can search for it...
[ { "answer_id": 94491, "author": "Marcel Levy", "author_id": 676, "author_profile": "https://Stackoverflow.com/users/676", "pm_score": 4, "selected": true, "text": "<p>Here's how I did it (grabbing all files ending in \".ranks\"):</p>\n\n<pre><code>import urllib2, cStringIO, zipfile\n\ntr...
2008/09/18
[ "https://Stackoverflow.com/questions/94490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676/" ]
I need to read selected files, matching on the file name, from a remote zip archive using Python. I don't want to save the full zip to a temporary file (it's not that large, so I can handle everything in memory). I've already written the code and it works, and I'm answering this myself so I can search for it later. Bu...
Here's how I did it (grabbing all files ending in ".ranks"): ``` import urllib2, cStringIO, zipfile try: remotezip = urllib2.urlopen(url) zipinmemory = cStringIO.StringIO(remotezip.read()) zip = zipfile.ZipFile(zipinmemory) for fn in zip.namelist(): if fn.endswith(".ranks"): ranks_...
94,502
<p>I have a simple database table called "Entries":</p> <pre><code>class CreateEntries &lt; ActiveRecord::Migration def self.up create_table :entries do |t| t.string :firstName t.string :lastName #etc. t.timestamps end end def self.down drop_table :entries end end </code></...
[ { "answer_id": 94519, "author": "Brian", "author_id": 15901, "author_profile": "https://Stackoverflow.com/users/15901", "pm_score": 6, "selected": true, "text": "<p>There is a plugin called FasterCSV that handles this wonderfully.</p>\n" }, { "answer_id": 94520, "author": "kc...
2008/09/18
[ "https://Stackoverflow.com/questions/94502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
I have a simple database table called "Entries": ``` class CreateEntries < ActiveRecord::Migration def self.up create_table :entries do |t| t.string :firstName t.string :lastName #etc. t.timestamps end end def self.down drop_table :entries end end ``` How do I write a han...
There is a plugin called FasterCSV that handles this wonderfully.
94,528
<p>In other words may one use <code>/&lt;tag[^&gt;]*&gt;.*?&lt;\/tag&gt;/</code> regex to match the <code>tag</code> html element which does not contain nested <code>tag</code> elements?</p> <p>For example (lt.html):</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stric...
[ { "answer_id": 94544, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 0, "selected": false, "text": "<pre><code>yeah except /&lt;tag[^&gt;]*&gt;.*?&lt;\\/tag&gt;/\n</code></pre>\n\n<p>Will not match a single ...
2008/09/18
[ "https://Stackoverflow.com/questions/94528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4279/" ]
In other words may one use `/<tag[^>]*>.*?<\/tag>/` regex to match the `tag` html element which does not contain nested `tag` elements? For example (lt.html): ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>greater than sign in attribute value<...
Yes, it is allowed (W3C Validator accepts it, only issues a warning). Unescaped `<` and `>` are also allowed inside comments, so such simple regexp can be fooled. If BeautifulSoup doesn't handle this, it could be a bug or perhaps a conscious design decision to make it more resilient to missing closing quotes in attri...
94,542
<p>I have a handful of projects that all use one project for the data model. Each of these projects has its own applicationContext.xml file with a bunch of repetitive data stuff within it.</p> <p>I'd like to have a modelContext.xml file and another for my ui.xml, etc.</p> <p>Can I do this?</p>
[ { "answer_id": 94586, "author": "enricopulatzo", "author_id": 9883, "author_profile": "https://Stackoverflow.com/users/9883", "pm_score": 2, "selected": false, "text": "<p>Yes, you can do this via the import element.</p>\n\n<pre><code>&lt;import resource=\"services.xml\"/&gt;\n</code></p...
2008/09/18
[ "https://Stackoverflow.com/questions/94542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I have a handful of projects that all use one project for the data model. Each of these projects has its own applicationContext.xml file with a bunch of repetitive data stuff within it. I'd like to have a modelContext.xml file and another for my ui.xml, etc. Can I do this?
From the [Spring Docs (v 2.5.5 Section 3.2.2.1.)](http://static.springframework.org/spring/docs/2.5.5/reference/beans.html#beans-definition): > > It can often be useful to split up > container definitions into multiple > XML files. One way to then load an > application context which is > configured from all these...
94,556
<p>We've got a multiproject we're trying to run Cobertura test coverage reports on as part of our mvn site build. I can get Cobertura to run on the child projects, but it erroneously reports 0% coverage, even though the reports still highlight the lines of code that were hit by the unit tests. </p> <p>We are using mvn...
[ { "answer_id": 94586, "author": "enricopulatzo", "author_id": 9883, "author_profile": "https://Stackoverflow.com/users/9883", "pm_score": 2, "selected": false, "text": "<p>Yes, you can do this via the import element.</p>\n\n<pre><code>&lt;import resource=\"services.xml\"/&gt;\n</code></p...
2008/09/18
[ "https://Stackoverflow.com/questions/94556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/765/" ]
We've got a multiproject we're trying to run Cobertura test coverage reports on as part of our mvn site build. I can get Cobertura to run on the child projects, but it erroneously reports 0% coverage, even though the reports still highlight the lines of code that were hit by the unit tests. We are using mvn 2.0.8. I ...
From the [Spring Docs (v 2.5.5 Section 3.2.2.1.)](http://static.springframework.org/spring/docs/2.5.5/reference/beans.html#beans-definition): > > It can often be useful to split up > container definitions into multiple > XML files. One way to then load an > application context which is > configured from all these...
94,582
<p>Say I have some javascript that if run in a browser would be typed like this...</p> <pre><code>&lt;script type="text/javascript" src="http://someplace.net/stuff.ashx"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var stuff = null; stuff = new TheStuff('myStuff'); &lt;/script&gt; </code></pre> ...
[ { "answer_id": 96911, "author": "Stephen Deken", "author_id": 7154, "author_profile": "https://Stackoverflow.com/users/7154", "pm_score": 2, "selected": false, "text": "<p>It seems like you're asking:</p>\n\n<blockquote>\n <p>How can I get <code>ScriptEngine</code> to evaluate the conte...
2008/09/18
[ "https://Stackoverflow.com/questions/94582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17978/" ]
Say I have some javascript that if run in a browser would be typed like this... ``` <script type="text/javascript" src="http://someplace.net/stuff.ashx"></script> <script type="text/javascript"> var stuff = null; stuff = new TheStuff('myStuff'); </script> ``` ... and I want to use the javax.script package...
It seems like you're asking: > > How can I get `ScriptEngine` to evaluate the contents of a URL instead of just a string? > > > Is that accurate? `ScriptEngine` doesn't provide a facility for downloading and evaluating the contents of a URL, but it's fairly easy to do. `ScriptEngine` allows you to pass in a `Rea...
94,594
<p>I'm implementing a simple service using datagrams over unix local sockets (AF_UNIX address family, i.e. <strong>not UDP</strong>). The server is bound to a public address, and it receives requests just fine. Unfortunately, when it comes to answering back, <code>sendto</code> fails unless the client is bound too. ...
[ { "answer_id": 95090, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": -1, "selected": false, "text": "<p>I'm not so sure I understand your question completely, but here is a datagram implementation of an echo server I ...
2008/09/18
[ "https://Stackoverflow.com/questions/94594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12274/" ]
I'm implementing a simple service using datagrams over unix local sockets (AF\_UNIX address family, i.e. **not UDP**). The server is bound to a public address, and it receives requests just fine. Unfortunately, when it comes to answering back, `sendto` fails unless the client is bound too. (the common error is `Transpo...
I assume that you are running Linux; I don't know if this advice applies to SunOS or any UNIX. First, the answer: after the socket() and before the connect() or first sendto(), try adding this code: ``` struct sockaddr_un me; me.sun_family = AF_UNIX; int result = bind(fd, (void*)&me, sizeof(short)); ``` Now, the e...
94,612
<p>To elaborate .. a) A table (BIGTABLE) has a capacity to hold a million rows with a primary Key as the ID. (random and unique) b) What algorithm can be used to arrive at an ID that has not been used so far. This number will be used to insert another row into table BIGTABLE.</p> <p>Updated the question with more deta...
[ { "answer_id": 94639, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 0, "selected": false, "text": "<p>If ID is purely random, there is no algorithm to find an unused ID in a similarly random fashion without brute forcing....
2008/09/18
[ "https://Stackoverflow.com/questions/94612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17987/" ]
To elaborate .. a) A table (BIGTABLE) has a capacity to hold a million rows with a primary Key as the ID. (random and unique) b) What algorithm can be used to arrive at an ID that has not been used so far. This number will be used to insert another row into table BIGTABLE. Updated the question with more details.. C) T...
The question is of course: why do you want a random ID? One case where I encountered a similar requirement, was for client IDs of a webapp: the client identifies himself with his client ID (stored in a cookie), so it has to be hard to brute force guess another client's ID (because that would allow hijacking his data)....
94,632
<p>I have an ASP.NET page which has a script manager on it.</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager EnablePageMethods="true" ID="scriptManager2" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>The page ov...
[ { "answer_id": 94704, "author": "Jared", "author_id": 1980, "author_profile": "https://Stackoverflow.com/users/1980", "pm_score": 4, "selected": true, "text": "<p>I can compile your code sample fine, you should check your designer file to make sure everything is ok.</p>\n\n<p>EDIT: the o...
2008/09/18
[ "https://Stackoverflow.com/questions/94632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
I have an ASP.NET page which has a script manager on it. ``` <form id="form1" runat="server"> <div> <asp:ScriptManager EnablePageMethods="true" ID="scriptManager2" runat="server"> </asp:ScriptManager> </div> </form> ``` The page overrides an abstract property to return the ScriptManager in or...
I can compile your code sample fine, you should check your designer file to make sure everything is ok. EDIT: the only other thing I can think of is that this is some sort of reference problem. Is your System.Web.Extensions reference using the correct version for your targeted framework? (should be 3.5.0.0 for .net 3....
94,667
<p>How can I bind an array parameter in the HQL editor of the HibernateTools plugin? The query parameter type list does not include arrays or collections.</p> <p>For example:<br> <code>Select * from Foo f where f.a in (:listOfValues)</code>.<br> How can I bind an array to that listOfValues?</p>
[ { "answer_id": 119294, "author": "boutta", "author_id": 15108, "author_profile": "https://Stackoverflow.com/users/15108", "pm_score": 1, "selected": false, "text": "<p>You probably cannot. Hibernate replaces the objects it gets out of the database with it's own objects (kind of proxies)....
2008/09/18
[ "https://Stackoverflow.com/questions/94667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12905/" ]
How can I bind an array parameter in the HQL editor of the HibernateTools plugin? The query parameter type list does not include arrays or collections. For example: `Select * from Foo f where f.a in (:listOfValues)`. How can I bind an array to that listOfValues?
You probably cannot. Hibernate replaces the objects it gets out of the database with it's own objects (kind of proxies). I would strongly assume Hibernate cannot do that with an array. So if you want to bind the array-data put it into a List on access by Hibernate. As an example one could do: ``` select * from Foo f ...
94,674
<p>How come this doesn't work (operating on an empty select list <code>&lt;select id="requestTypes"&gt;&lt;/select&gt;</code></p> <pre><code>$(function() { $.getJSON("/RequestX/GetRequestTypes/", showRequestTypes); } ); function showRequestTypes(data, textStatus) { $.each(data, ...
[ { "answer_id": 94686, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 3, "selected": false, "text": "<p>By default, jQuery selectors return the jQuery object. Add this to get the DOM element returned:</p>\n\n<pre><code> v...
2008/09/18
[ "https://Stackoverflow.com/questions/94674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17729/" ]
How come this doesn't work (operating on an empty select list `<select id="requestTypes"></select>` ``` $(function() { $.getJSON("/RequestX/GetRequestTypes/", showRequestTypes); } ); function showRequestTypes(data, textStatus) { $.each(data, function() { var...
`$("#requestTypes")` returns a jQuery object that contains all the selected elements. You are attempting to call the `add()` method of an individual element, but instead you are calling the `add()` method of the jQuery object, which does something very different. In order to access the DOM element itself, you need to ...
94,689
<p>I am new to asp and have a deadline in the next few days. i receive the following xml from within a webservice response.</p> <pre><code>print("&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;user_data&gt; &lt;execution_status&gt;0&lt;/execution_status&gt; &lt;row_count&gt;1&lt;/row_count&gt; &lt;txn_id&gt;stuetd67...
[ { "answer_id": 94712, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 4, "selected": true, "text": "<p>You need to read about MSXML parser. Here is a link to a good all-in-one example <a href=\"http://oreilly.com/pub/h...
2008/09/18
[ "https://Stackoverflow.com/questions/94689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11612/" ]
I am new to asp and have a deadline in the next few days. i receive the following xml from within a webservice response. ``` print("<?xml version="1.0" encoding="UTF-8"?> <user_data> <execution_status>0</execution_status> <row_count>1</row_count> <txn_id>stuetd678</txn_id> <person_info> <attribute name="firstname"...
You need to read about MSXML parser. Here is a link to a good all-in-one example <http://oreilly.com/pub/h/466> Some reading on XPath will help as well. You could get all the information you need in MSDN. Stealing the code from [Luke](https://stackoverflow.com/users/17602/luke) excellent reply for aggregation purpose...
94,757
<p>I have a web application where there are number of Ajax components which refresh themselves every so often inside a page (it's a dashboard of sorts).</p> <p>Now, I want to add functionality to the page so that when there is no Internet connectivity, the current content of the page doesn't change and a message appea...
[ { "answer_id": 94808, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 4, "selected": false, "text": "<pre><code>navigator.onLine\n</code></pre>\n\n<p>That should do what you're asking.</p>\n\n<p>You probably want to check that i...
2008/09/18
[ "https://Stackoverflow.com/questions/94757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
I have a web application where there are number of Ajax components which refresh themselves every so often inside a page (it's a dashboard of sorts). Now, I want to add functionality to the page so that when there is no Internet connectivity, the current content of the page doesn't change and a message appears on the ...
One way to handle this might be to extend the XmlHTTPRequest object with an explicit timeout method, then use that to determine if you're working in offline mode (that is, for browsers that don't support navigator.onLine). Here's how I implemented Ajax timeouts on one site (a site that uses the [Prototype](http://proto...
94,866
<p>Running sp_attach_single_file_db gives this error:</p> <pre><code>The log scan number (10913:125:2) passed to log scan in database 'myDB' is not valid </code></pre> <p>Isn't it supposed to re-create the log file? </p> <p>How else would I be able to attach/repair that .mdf file?</p>
[ { "answer_id": 94947, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 0, "selected": false, "text": "<p>I don't know of an add-on (I use <a href=\"http://www.rememberthemilk.com/\" rel=\"nofollow noreferrer\">Remember Th...
2008/09/18
[ "https://Stackoverflow.com/questions/94866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1427/" ]
Running sp\_attach\_single\_file\_db gives this error: ``` The log scan number (10913:125:2) passed to log scan in database 'myDB' is not valid ``` Isn't it supposed to re-create the log file? How else would I be able to attach/repair that .mdf file?
How about the [**FogBugz add-in**](http://our.fogbugz.com/default.asp?W984) for Visual Studio 2005 and 2008? This requires a [FogBugz](http://www.fogcreek.com/FogBugz/) account hosted either locally or by Fog Creek. A free Student and Startup version is [available](https://shop.fogcreek.com/FogBugz/default.asp?sCatego...
94,906
<p>I'm running a SQL query on SQL Server 2005, and in addition to 2 columns being queried from the database, I'd also like to return 1 column of random numbers along with them. I tried this:</p> <pre><code>select column1, column2, floor(rand() * 10000) as column3 from table1 </code></pre> <p>Which kinda works, but t...
[ { "answer_id": 94951, "author": "Adam", "author_id": 13320, "author_profile": "https://Stackoverflow.com/users/13320", "pm_score": 1, "selected": false, "text": "<p>You need to use a UDF</p>\n\n<p>first:</p>\n\n<pre><code>CREATE VIEW vRandNumber\nAS\nSELECT RAND() as RandNumber\n</code><...
2008/09/18
[ "https://Stackoverflow.com/questions/94906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8409/" ]
I'm running a SQL query on SQL Server 2005, and in addition to 2 columns being queried from the database, I'd also like to return 1 column of random numbers along with them. I tried this: ``` select column1, column2, floor(rand() * 10000) as column3 from table1 ``` Which kinda works, but the problem is that this qu...
I realize this is an older post... but you don't need a view. ``` select column1, column2, ABS(CAST(CAST(NEWID() AS VARBINARY) AS int)) % 10000 as column3 from table1 ```
94,912
<p>We currently have code like this:</p> <pre><code>Dim xDoc = XDocument.Load(myXMLFilePath) </code></pre> <p>The only way we know how to do it currently is by using a file path and impersonation (since this file is on a secured network path).</p> <p>I've looked at <a href="http://msdn.microsoft.com/en-us/library/sy...
[ { "answer_id": 94922, "author": "paulwhit", "author_id": 7301, "author_profile": "https://Stackoverflow.com/users/7301", "pm_score": 4, "selected": true, "text": "<p>I would suggest using a WebRequest to get a stream and load the stream into the document.</p>\n" }, { "answer_id":...
2008/09/18
[ "https://Stackoverflow.com/questions/94912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7072/" ]
We currently have code like this: ``` Dim xDoc = XDocument.Load(myXMLFilePath) ``` The only way we know how to do it currently is by using a file path and impersonation (since this file is on a secured network path). I've looked at [XDocument.Load on MSDN](http://msdn.microsoft.com/en-us/library/system.xml.linq.xdo...
I would suggest using a WebRequest to get a stream and load the stream into the document.
94,930
<p>I have a table with game scores, allowing multiple rows per account id: <code>scores (id, score, accountid)</code>. I want a list of the top 10 scorer ids and their scores.</p> <p>Can you provide an sql statement to select the top 10 scores, but only one score per account id? </p> <p>Thanks!</p>
[ { "answer_id": 94958, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>select top 10 username, \n max(score) \nfrom usertable \ngroup by username \norde...
2008/09/18
[ "https://Stackoverflow.com/questions/94930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13636/" ]
I have a table with game scores, allowing multiple rows per account id: `scores (id, score, accountid)`. I want a list of the top 10 scorer ids and their scores. Can you provide an sql statement to select the top 10 scores, but only one score per account id? Thanks!
First limit the selection to the highest score for each account id. Then take the top ten scores. ``` SELECT TOP 10 AccountId, Score FROM Scores s1 WHERE AccountId NOT IN (SELECT AccountId s2 FROM Scores WHERE s1.AccountId = s2.AccountId and s1.Score > s2.Score) ORDER BY Score DESC ```
94,932
<p>Our CF server occasionally stops processing mail. This is problematic, as many of our clients depend on it. </p> <p>We found suggestions online that mention zero-byte files in the undeliverable folder, so I created a task that removes them every three minutes. However, the stoppage has occurred again.</p> <p>I ...
[ { "answer_id": 95355, "author": "Patrick McElhaney", "author_id": 437, "author_profile": "https://Stackoverflow.com/users/437", "pm_score": 2, "selected": false, "text": "<p>Have you tried just bypassing the queue altogether? (In CF Admin, under Mail Spool settings, uncheck \"Spool mail ...
2008/09/18
[ "https://Stackoverflow.com/questions/94932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12267/" ]
Our CF server occasionally stops processing mail. This is problematic, as many of our clients depend on it. We found suggestions online that mention zero-byte files in the undeliverable folder, so I created a task that removes them every three minutes. However, the stoppage has occurred again. I am looking for sugge...
What we ended up doing: I wrote two scheduled tasks. The first checked to see if there were any messages in the queue folder older than *n* minues (currently set to 30). The second reset the queue every night during low usage. Unfortunately, we never really discovered why the queue would come off the rails, but it on...
94,934
<p>I'd like to create a &quot;universal&quot; debug logging function that inspects the JS namespace for well-known logging libraries.</p> <p>For example, currently, it supports Firebug's console.log:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippe...
[ { "answer_id": 94944, "author": "Teifion", "author_id": 1384652, "author_profile": "https://Stackoverflow.com/users/1384652", "pm_score": -1, "selected": false, "text": "<p>Myself, I am a firm believer in the following:</p>\n\n<pre><code>alert('Some message/variables');\n</code></pre>\n"...
2008/09/18
[ "https://Stackoverflow.com/questions/94934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4465/" ]
I'd like to create a "universal" debug logging function that inspects the JS namespace for well-known logging libraries. For example, currently, it supports Firebug's console.log: ```js var console = window['console']; if (console && console.log) { console.log(message); } ``` Obviously, this only w...
I personally use Firebug/Firebug Lite and on IE let Visual Studio do the debugging. None of these do any good when a visitor is using some insane browser though. You really need to get your client side javascript to log its errors to your server. Take a look at the power point presentation I've linked to below. It has ...
94,935
<p>Apparently xrange is faster but I have no idea why it's faster (and no proof besides the anecdotal so far that it is faster) or what besides that is different about</p> <pre><code>for i in range(0, 20): for i in xrange(0, 20): </code></pre>
[ { "answer_id": 94953, "author": "Oko", "author_id": 9402, "author_profile": "https://Stackoverflow.com/users/9402", "pm_score": -1, "selected": false, "text": "<p>See this <a href=\"http://avinashv.net/2008/05/pythons-range-and-xrange/\" rel=\"nofollow noreferrer\">post</a> to find diffe...
2008/09/18
[ "https://Stackoverflow.com/questions/94935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
Apparently xrange is faster but I have no idea why it's faster (and no proof besides the anecdotal so far that it is faster) or what besides that is different about ``` for i in range(0, 20): for i in xrange(0, 20): ```
**In Python 2.x:** * `range` creates a list, so if you do `range(1, 10000000)` it creates a list in memory with `9999999` elements. * `xrange` is a sequence object that evaluates lazily. **In Python 3:** * `range` does the equivalent of Python 2's `xrange`. To get the list, you have to explicitly use `list(range(......
94,959
<p>I have a couple of triggers on a table that I want to keep <strong><em>separate</em></strong> and would like to priortize them.</p> <p>I could have just one trigger and do the logic there, but I was wondering if there was an easier/logical way of accomplishing this of having it in a pre-defined order ?</p>
[ { "answer_id": 94973, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 4, "selected": true, "text": "<p>Use sp_settriggerorder. You can specify the first and last trigger to fire depending on the operation.</p>\n\n<p><a ...
2008/09/18
[ "https://Stackoverflow.com/questions/94959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5853/" ]
I have a couple of triggers on a table that I want to keep ***separate*** and would like to priortize them. I could have just one trigger and do the logic there, but I was wondering if there was an easier/logical way of accomplishing this of having it in a pre-defined order ?
Use sp\_settriggerorder. You can specify the first and last trigger to fire depending on the operation. [sp\_settriggerorder on MSDN](http://msdn.microsoft.com/en-us/library/ms186762.aspx) From the above link: **A. Setting the firing order for a DML trigger** The following example specifies that trigger uSalesO...
94,977
<p>In C# and in Java (and possibly other languages as well), variables declared in a "try" block are not in scope in the corresponding "catch" or "finally" blocks. For example, the following code does not compile:</p> <pre><code>try { String s = "test"; // (more code...) } catch { Console.Out.WriteLine(s); //J...
[ { "answer_id": 94998, "author": "Burkhard", "author_id": 12860, "author_profile": "https://Stackoverflow.com/users/12860", "pm_score": 6, "selected": false, "text": "<p>How could you be sure, that you reached the declaration part in your catch block? What if the instantiation throws the ...
2008/09/18
[ "https://Stackoverflow.com/questions/94977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12484/" ]
In C# and in Java (and possibly other languages as well), variables declared in a "try" block are not in scope in the corresponding "catch" or "finally" blocks. For example, the following code does not compile: ``` try { String s = "test"; // (more code...) } catch { Console.Out.WriteLine(s); //Java fans: think...
Two things: 1. Generally, Java has just 2 levels of scope: global and function. But, try/catch is an exception (no pun intended). When an exception is thrown and the exception object gets a variable assigned to it, that object variable is only available within the "catch" section and is destroyed as soon as the catch ...
94,999
<p>I am looking for a command in Unix that returns the status of a process(active, dead, sleeping, waiting for another process, etc.)</p> <p>is there any available?<br> A shell script maybe?</p>
[ { "answer_id": 95063, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 0, "selected": false, "text": "<p>Playing with ps options doesn't give you what you need?</p>\n" }, { "answer_id": 96154, "author": "Brian Mit...
2008/09/18
[ "https://Stackoverflow.com/questions/94999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15884/" ]
I am looking for a command in Unix that returns the status of a process(active, dead, sleeping, waiting for another process, etc.) is there any available? A shell script maybe?
Try *pflags <pid>*, which will give you per-thread status information. Example: ``` root@weetbix # pflags $$ 3384: bash data model = _ILP32 flags = ORPHAN|MSACCT|MSFORK /1: flags = ASLEEP waitid(0x7,0x0,0xffbfefc0,0xf) sigmask = 0x00020000,0x00000000 ``` Also check out the manpage for *pflag...
95,005
<p>If I want to inject a globally scoped array variable into a page's client-side javascript during a full page postback, I can use:</p> <pre><code>this.Page.ClientScript.RegisterArrayDeclaration("WorkCalendar", "\"" + date.ToShortDateString() + "\""); </code></pre> <p>to declare and populate a client-side javascript...
[ { "answer_id": 95081, "author": "typemismatch", "author_id": 13714, "author_profile": "https://Stackoverflow.com/users/13714", "pm_score": 1, "selected": true, "text": "<p>You could also update a hidden label inside the update panel which allows you to write out any javascript you like. ...
2008/09/18
[ "https://Stackoverflow.com/questions/95005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2637/" ]
If I want to inject a globally scoped array variable into a page's client-side javascript during a full page postback, I can use: ``` this.Page.ClientScript.RegisterArrayDeclaration("WorkCalendar", "\"" + date.ToShortDateString() + "\""); ``` to declare and populate a client-side javascript array on the page. Nice a...
You could also update a hidden label inside the update panel which allows you to write out any javascript you like. I would suggest though using web services or even page methods to fetch the data you need instead of using update panels. Example: myLabel.Text = "...."; ... put your logic in this or you can add [WebMet...
95,061
<p>How can I tell Activerecord to not load blob columns unless explicitly asked for? There are some pretty large blobs in my legacy DB that must be excluded for 'normal' Objects.</p>
[ { "answer_id": 95413, "author": "Mike Tunnicliffe", "author_id": 13956, "author_profile": "https://Stackoverflow.com/users/13956", "pm_score": 2, "selected": false, "text": "<p>I believe you can ask AR to load specific columns in your invocation to find:</p>\n\n<pre><code>MyModel.find(id...
2008/09/18
[ "https://Stackoverflow.com/questions/95061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I tell Activerecord to not load blob columns unless explicitly asked for? There are some pretty large blobs in my legacy DB that must be excluded for 'normal' Objects.
I just ran into this using rail 3. Fortunately it wasn't that difficult to solve. I set a `default_scope` that removed the particular columns I didn't want from the result. For example, in the model I had there was an xml text field that could be quite long that wasn't used in most views. ``` default_scope select((co...
95,074
<p>I have noticed that setting row height in DataGridView control is slow. Is there a way to make it faster?</p>
[ { "answer_id": 95291, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 1, "selected": false, "text": "<p>If you can, try setting the height before you bind the control.</p>\n\n<p>If you can't do that, try making the control hid...
2008/09/18
[ "https://Stackoverflow.com/questions/95074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18046/" ]
I have noticed that setting row height in DataGridView control is slow. Is there a way to make it faster?
What's caused similar layout delays for myself was related to the **AutoSizeRowsMode** and **AutoSizeColumnsMode** ``` DataGridView1.AutoSizeRowsMode = None ``` will likely fix it. Also try **[ColumnHeadersHeightSizeMode](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.columnheadersheights...
95,089
<p>Trying the easy approach:</p> <blockquote> <p>sqlite2 mydb.db .dump | sqlite3 mydb-new.db</p> </blockquote> <p>I got this error:</p> <blockquote> <p>SQL error near line 84802: no such column: Ð</p> </blockquote> <p>In that line the script is this:</p> <blockquote> <p>INSERT INTO vehiculo VALUES(127548,'21...
[ { "answer_id": 95292, "author": "levhita", "author_id": 7946, "author_profile": "https://Stackoverflow.com/users/7946", "pm_score": 0, "selected": false, "text": "<p>I tried to do it without windows intervention:</p>\n<blockquote>\n<p>*by calling sqlite2 on old.db, and send the dump dire...
2008/09/18
[ "https://Stackoverflow.com/questions/95089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7946/" ]
Trying the easy approach: > > sqlite2 mydb.db .dump | sqlite3 mydb-new.db > > > I got this error: > > SQL error near line 84802: no such column: Ð > > > In that line the script is this: > > INSERT INTO vehiculo VALUES(127548,'21K0065217',**Ñ**,'PA007808',65217,279,1989,3,468,'1998-07-30 00:00:00.000000','...
> > Simply open the v2 database with the sqlite3 binary CLI, and then save it. The database file will be transparently migrated to v3. > > > It doesn't work. ``` $sqlite3 db2 SQLite version 3.6.16 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> .tables Error: file is encrypted or...
95,105
<p>Convert.ToString() only allows base values of 2, 8, 10, and 16 for some odd reason; is there some obscure way of providing any base between 2 and 16?</p>
[ { "answer_id": 95116, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": -1, "selected": false, "text": "<pre><code>string foo = Convert.ToString(myint,base);\n</code></pre>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library...
2008/09/18
[ "https://Stackoverflow.com/questions/95105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9913/" ]
Convert.ToString() only allows base values of 2, 8, 10, and 16 for some odd reason; is there some obscure way of providing any base between 2 and 16?
Probably to eliminate someone typing a 7 instead of an 8, since the uses for arbitrary bases are few (But not non-existent). Here is an example method that can do arbitrary base conversions. You can use it if you like, no restrictions. ``` string ConvertToBase(int value, int toBase) { if (toBase < 2 || toBase > ...
95,112
<p>I have a long running process in VB6 that I want to finish before executing the next line of code. How can I do that? Built-in function? Can I control how long to wait?</p> <p>Trivial example:</p> <pre><code>Call ExternalLongRunningProcess Call DoOtherStuff </code></pre> <p>How do I delay 'DoOtherStuff'?</p>
[ { "answer_id": 95128, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 0, "selected": false, "text": "<p>Break your code up into 2 processes. Run the first, then run your \"long running process\", then run the second proc...
2008/09/18
[ "https://Stackoverflow.com/questions/95112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
I have a long running process in VB6 that I want to finish before executing the next line of code. How can I do that? Built-in function? Can I control how long to wait? Trivial example: ``` Call ExternalLongRunningProcess Call DoOtherStuff ``` How do I delay 'DoOtherStuff'?
VB.Net: I would use a [WaitOne](http://msdn.microsoft.com/en-us/library/kzy257t0.aspx) event handle. VB 6.0: I've seen a DoEvents Loop. ``` Do If isSomeCheckCondition() Then Exit Do DoEvents Loop ``` Finally, You could just sleep: ``` Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long...
95,134
<p>I'm using the following code to query a database from my jsp, but I'd like to know more about what's happening behind the scenes.</p> <p>These are my two primary questions.</p> <p>Does the tag access the ResultSet directly, or is the query result being stored in a datastructure in memory?</p> <p>When is the conne...
[ { "answer_id": 95813, "author": "Will Hartung", "author_id": 13663, "author_profile": "https://Stackoverflow.com/users/13663", "pm_score": 1, "selected": false, "text": "<p>The key thing here is this: javax.servlet.jsp.jstl.sql.Result</p>\n\n<p>That's what JSTL uses as the result of a SQ...
2008/09/18
[ "https://Stackoverflow.com/questions/95134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I'm using the following code to query a database from my jsp, but I'd like to know more about what's happening behind the scenes. These are my two primary questions. Does the tag access the ResultSet directly, or is the query result being stored in a datastructure in memory? When is the connection closed? ``` <%@ t...
Observations based on the source for org.apache.taglibs.standard.tag.common.sql.QueryTagSupport The taglib traverses through the ResultSet and puts all of the data in arrays, Maps, and Lists. So, everything is loaded into memory before you even start looping. The connection is opened when the query start tag is encou...
95,181
<p>I have:</p> <pre><code>class MyClass extends MyClass2 implements Serializable { //... } </code></pre> <p>In MyClass2 is a property that is not serializable. How can I serialize (and de-serialize) this object?</p> <p>Correction: MyClass2 is, of course, not an interface but a class.</p>
[ { "answer_id": 95208, "author": "Mike Deck", "author_id": 1247, "author_profile": "https://Stackoverflow.com/users/1247", "pm_score": 5, "selected": false, "text": "<p>MyClass2 is just an interface so techinicaly it has no properties, only methods. That being said if you have instance v...
2008/09/18
[ "https://Stackoverflow.com/questions/95181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12860/" ]
I have: ``` class MyClass extends MyClass2 implements Serializable { //... } ``` In MyClass2 is a property that is not serializable. How can I serialize (and de-serialize) this object? Correction: MyClass2 is, of course, not an interface but a class.
As someone else noted, chapter 11 of Josh Bloch's [Effective Java](https://rads.stackoverflow.com/amzn/click/com/0321356683) is an indispensible resource on Java Serialization. A couple points from that chapter pertinent to your question: * assuming you want to serialize the state of the non-serializable field in MyC...
95,183
<p>How do I create an index on the date part of DATETIME field?</p> <pre><code>mysql&gt; SHOW COLUMNS FROM transactionlist; +-------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------...
[ { "answer_id": 95248, "author": "nathan", "author_id": 16430, "author_profile": "https://Stackoverflow.com/users/16430", "pm_score": 0, "selected": false, "text": "<p>What does 'explain' say? (run EXPLAIN SELECT * FROM transactionlist where date(TranDateTime) = '2008-08-17')</p>\n\n<p>If...
2008/09/18
[ "https://Stackoverflow.com/questions/95183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
How do I create an index on the date part of DATETIME field? ``` mysql> SHOW COLUMNS FROM transactionlist; +-------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------+------+---...
If I remember correctly, that will run a whole table scan because you're passing the column through a function. MySQL will obediently run the function for each and every column, bypassing the index since the query optimizer can't really know the results of the function. What I would do is something like: ``` SELECT *...
95,192
<p>Our CruiseControl system checks out from starteam. I've noticed that it is sometimes not checking out new versions of files, only added files.</p> <p>Does anyone know why this is?</p>
[ { "answer_id": 95353, "author": "dgvid", "author_id": 9897, "author_profile": "https://Stackoverflow.com/users/9897", "pm_score": 1, "selected": false, "text": "<p>I cannot say <em>why</em> this happens, but for what it's worth, we avoid the problem entirely by having StarTeam delete all...
2008/09/18
[ "https://Stackoverflow.com/questions/95192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
Our CruiseControl system checks out from starteam. I've noticed that it is sometimes not checking out new versions of files, only added files. Does anyone know why this is?
I cannot say *why* this happens, but for what it's worth, we avoid the problem entirely by having StarTeam delete all of the local files before checking-out. We get *all* of the files that way. We use the following StarTeam arguments in our NAnt script: ``` delete-local -q -p &quot;${starteam_project_root}&quot; -is -...
95,213
<p>Simple example: I want to have some items on a page (like divs or table rows), and I want to let the user click on them to select them. That seems easy enough in jQuery. To save which items a user clicks on with no server-side post backs, I was thinking a cookie would be a simple way to get this done.</p> <ol> <li>...
[ { "answer_id": 95241, "author": "Ian", "author_id": 4396, "author_profile": "https://Stackoverflow.com/users/4396", "pm_score": 3, "selected": false, "text": "<p>Take a look at the <a href=\"http://plugins.jquery.com/cookie/\" rel=\"nofollow noreferrer\">Cookie Plugin</a> for jQuery.</p>...
2008/09/18
[ "https://Stackoverflow.com/questions/95213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5619/" ]
Simple example: I want to have some items on a page (like divs or table rows), and I want to let the user click on them to select them. That seems easy enough in jQuery. To save which items a user clicks on with no server-side post backs, I was thinking a cookie would be a simple way to get this done. 1. Is this assum...
The default JavaScript "API" for setting a cookie is as easy as: ``` document.cookie = 'mycookie=valueOfCookie;expires=DateHere;path=/' ``` Use the jQuery cookie plugin like: ``` $.cookie('mycookie', 'valueOfCookie') ```
95,218
<p>Here's something I haven't been able to fix, and I've looked <strong>everywhere</strong>. Perhaps someone here will know!</p> <p>I have a table called dandb_raw, with three columns in particular: dunsId (PK), name, and searchName. I also have a trigger that acts on this table:</p> <pre><code>SET ANSI_NULLS ON GO S...
[ { "answer_id": 95610, "author": "Cervo", "author_id": 16219, "author_profile": "https://Stackoverflow.com/users/16219", "pm_score": 1, "selected": false, "text": "<p>What is companies_contactInfo_updateTerritories? The actual reference mentions procedure \"companies_contactInfo_updateTe...
2008/09/18
[ "https://Stackoverflow.com/questions/95218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40352/" ]
Here's something I haven't been able to fix, and I've looked **everywhere**. Perhaps someone here will know! I have a table called dandb\_raw, with three columns in particular: dunsId (PK), name, and searchName. I also have a trigger that acts on this table: ``` SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER...
I think David and Cervo combined have hit on the problem here. I'm pretty sure part of what was happening was that we were using #newMatches in multiple triggers. When one trigger changed some rows, it would fire another trigger, which would attempt to use the connection scoped #newMatches. As a result, it would try ...
95,222
<p>I found this link <a href="http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/" rel="noreferrer">http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/</a>, but there isn't a lot of description around it, aside that it's "simple".</p> <p>Ideally, I'd like an extension to CcMode that can do it, or at least ...
[ { "answer_id": 95494, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 5, "selected": true, "text": "<p>Add the following code to your ~/.emacs file.</p>\n\n<pre><code>(autoload 'glsl-mode \"glsl-mode\" nil t)\n(add-to-li...
2008/09/18
[ "https://Stackoverflow.com/questions/95222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13894/" ]
I found this link <http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/>, but there isn't a lot of description around it, aside that it's "simple". Ideally, I'd like an extension to CcMode that can do it, or at least a mode that can handle auto-styling and has similar shortcuts to CcMode. If there isn't one, any...
Add the following code to your ~/.emacs file. ``` (autoload 'glsl-mode "glsl-mode" nil t) (add-to-list 'auto-mode-alist '("\\.vert\\'" . glsl-mode)) (add-to-list 'auto-mode-alist '("\\.frag\\'" . glsl-mode)) ``` Put the file <http://artis.imag.fr/~Xavier.Decoret/resources/glsl-mode/glsl-mode.el> somewhere on your em...
95,257
<p>I just want a quick way (and preferably not using a while loop)of createing a table of every date between date @x and date @y so I can left outer join to some stats tables, some of which will have no records for certain days in between, allowing me to mark missing days with a 0</p>
[ { "answer_id": 95271, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": -1, "selected": false, "text": "<p>Just: WHERE col > start-date AND col &lt; end-date</p>\n" }, { "answer_id": 95300, "author": "Charles Graham", ...
2008/09/18
[ "https://Stackoverflow.com/questions/95257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
I just want a quick way (and preferably not using a while loop)of createing a table of every date between date @x and date @y so I can left outer join to some stats tables, some of which will have no records for certain days in between, allowing me to mark missing days with a 0
Strictly speaking this doesn't exactly answer your question, but its pretty neat. Assuming you can live with specifying the number of days after the start date, then using a Common Table Expression gives you: ``` WITH numbers ( n ) AS ( SELECT 1 UNION ALL SELECT 1 + n FROM numbers WHERE n < 500 ) ...
95,277
<p>I'd like to be able to create a parameterized query in MS Access 2003 and feed the values of certain form elements to that query and then get the corresponding resultset back and do some basic calculations with them. I'm coming up short in figuring out how to get the parameters of the query to be populated by the fo...
[ { "answer_id": 96047, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 1, "selected": false, "text": "<p>Here is a snippet of code. It updates a table using the parameter txtHospital:</p>\n\n<pre><code>Set db = CurrentDb\n\nS...
2008/09/18
[ "https://Stackoverflow.com/questions/95277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16562/" ]
I'd like to be able to create a parameterized query in MS Access 2003 and feed the values of certain form elements to that query and then get the corresponding resultset back and do some basic calculations with them. I'm coming up short in figuring out how to get the parameters of the query to be populated by the form ...
References to the controls on the form can be used directly in Access queries, though it's important to define them as parameters (otherwise, results in recent versions of Access can be unpredictable where they were once reliable). For instance, if you want to filter a query by the LastName control on MyForm, you'd us...
95,286
<p>I have the following configuration, but I have not able to find any documentation on how to set a maximum backup files on date rolling style. I know that you can do this with size rolling style by using the maxSizeRollBackups.</p> <pre><code>&lt;appender name="AppLogFileAppender" type="log4net.Appender.RollingFile...
[ { "answer_id": 95390, "author": "wcm", "author_id": 2173, "author_profile": "https://Stackoverflow.com/users/2173", "pm_score": 2, "selected": false, "text": "<p>Not sure exactly what you need. Below is an extract from one of my lo4net.config files:</p>\n\n<pre><code> &lt;appender name...
2008/09/18
[ "https://Stackoverflow.com/questions/95286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4191/" ]
I have the following configuration, but I have not able to find any documentation on how to set a maximum backup files on date rolling style. I know that you can do this with size rolling style by using the maxSizeRollBackups. ``` <appender name="AppLogFileAppender" type="log4net.Appender.RollingFileAppender"> <fi...
You can't. from [log4net SDK Reference RollingFileAppender Class](https://logging.apache.org/log4net/release/sdk/html/T_log4net_Appender_RollingFileAppender.htm) > > **CAUTION** > > > A maximum number of backup files when rolling on date/time boundaries is not supported. > > >
95,305
<p>Most of my users have email addresses associated with their profile in <code>/etc/passwd</code>. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field.</p> <p>Can somebody give me a <strong>regex to grab just the email address</strong...
[ { "answer_id": 95338, "author": "Ray Hayes", "author_id": 7093, "author_profile": "https://Stackoverflow.com/users/7093", "pm_score": 4, "selected": true, "text": "<p>What about:</p>\n\n<blockquote>\n <p>,([^@]+@[^,:]+)</p>\n</blockquote>\n\n<p>Where the group contains the email address...
2008/09/18
[ "https://Stackoverflow.com/questions/95305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3764/" ]
Most of my users have email addresses associated with their profile in `/etc/passwd`. They are always in the 5th field, which I can grab, but they appear at different places within a comma-separated list in the 5th field. Can somebody give me a **regex to grab just the email address** (delimeted by commas) from a line...
What about: > > ,([^@]+@[^,:]+) > > > Where the group contains the email address. **[Updated based upon comment that address doesn't always get terminated by a comma]**
95,361
<p>I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include "blah.h"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets overwritten. I know there is a place t...
[ { "answer_id": 95618, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 0, "selected": false, "text": "<p>I'm not completely sure why you're trying to do, but modifying the resource files manually probably isn't a good idea.</p>\n...
2008/09/18
[ "https://Stackoverflow.com/questions/95361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm programming in C++ on Visual Studio 2005. My question deals with .rc files. You can manually place include directives like (#include "blah.h"), at the top of an .rc file. But that's bad news since the first time someone opens the .rc file in the resource editor, it gets overwritten. I know there is a place to make ...
Add your #include to the file in the normal way, but also add it to one the three "TEXTINCLUDE" sections in the file, like so: ``` 2 TEXTINCLUDE BEGIN "#include ""windows.h""\r\n" "#include ""blah.h\r\n" "\0" END ``` Note the following details: * Each line is contained in quotes * Use pairs of quotes...
95,364
<p>I have a LINQ to SQL generated class with a readonly property:</p> <pre><code>&lt;Column(Name:="totalLogins", Storage:="_TotalLogins", DbType:="Int", UpdateCheck:=UpdateCheck.Never)&gt; _ Public ReadOnly Property TotalLogins() As System.Nullable(Of Integer) Get Return Me._TotalLogins End Get End Pr...
[ { "answer_id": 96076, "author": "chrissie1", "author_id": 2936, "author_profile": "https://Stackoverflow.com/users/2936", "pm_score": 0, "selected": false, "text": "<pre><code>Make a second property that is protected or internal(?) \n\n&lt;Column(Name:=\"totalLogins\", Storage:=\"_TotalL...
2008/09/18
[ "https://Stackoverflow.com/questions/95364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11991/" ]
I have a LINQ to SQL generated class with a readonly property: ``` <Column(Name:="totalLogins", Storage:="_TotalLogins", DbType:="Int", UpdateCheck:=UpdateCheck.Never)> _ Public ReadOnly Property TotalLogins() As System.Nullable(Of Integer) Get Return Me._TotalLogins End Get End Property ``` This pr...
Set the existing TotalLogins property as either private or protected and remove the readonly attribute. You may also want to rename it e.g. InternalTotalLogins. Then create a new property by hand in the partial class that exposes it publically as a read-only property: ``` Public ReadOnly Property TotalLogins() As Sys...
95,378
<p>What is a tool or technique that can be used to perform spell checks upon a whole source code base and its associated resource files?</p> <p>The spell check should be <em>source code aware</em> meaning that it would stick to checking string literals in the code and not the code itself. Bonus points if the spell ch...
[ { "answer_id": 96076, "author": "chrissie1", "author_id": 2936, "author_profile": "https://Stackoverflow.com/users/2936", "pm_score": 0, "selected": false, "text": "<pre><code>Make a second property that is protected or internal(?) \n\n&lt;Column(Name:=\"totalLogins\", Storage:=\"_TotalL...
2008/09/18
[ "https://Stackoverflow.com/questions/95378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9925/" ]
What is a tool or technique that can be used to perform spell checks upon a whole source code base and its associated resource files? The spell check should be *source code aware* meaning that it would stick to checking string literals in the code and not the code itself. Bonus points if the spell checker understands ...
Set the existing TotalLogins property as either private or protected and remove the readonly attribute. You may also want to rename it e.g. InternalTotalLogins. Then create a new property by hand in the partial class that exposes it publically as a read-only property: ``` Public ReadOnly Property TotalLogins() As Sys...
95,389
<p>If a class defined an annotation, is it somehow possible to force its subclass to define the same annotation?</p> <p>For instance, we have a simple class/subclass pair that share the <code>@Author @interface.</code> What I'd like to do is force each further subclass to define the same <code>@Author</code> annotatio...
[ { "answer_id": 95467, "author": "Rasmus Faber", "author_id": 5542, "author_profile": "https://Stackoverflow.com/users/5542", "pm_score": 2, "selected": false, "text": "<p>I am quite sure that this is impossible to do at compile time.</p>\n\n<p>However, this is an obvious task for a \"uni...
2008/09/18
[ "https://Stackoverflow.com/questions/95389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18058/" ]
If a class defined an annotation, is it somehow possible to force its subclass to define the same annotation? For instance, we have a simple class/subclass pair that share the `@Author @interface.` What I'd like to do is force each further subclass to define the same `@Author` annotation, preventing a `RuntimeExceptio...
You can do that with JSR 269, at compile time. See : <http://today.java.net/pub/a/today/2006/06/29/validate-java-ee-annotations-with-annotation-processors.html#pluggable-annotation-processing-api> Edit 2020-09-20: Link is dead, archived version here : <https://web.archive.org/web/20150516080739/http://today.java.net/p...
95,419
<p>Had a conversation with a coworker the other day about this.</p> <p>There's the obvious using a constructor, but what are the other ways there?</p>
[ { "answer_id": 95428, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://en.wikipedia.org/wiki/Clone_(Java_method)\" rel=\"noreferrer\">Cloning</a> and <a href=\"http://e...
2008/09/18
[ "https://Stackoverflow.com/questions/95419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1247/" ]
Had a conversation with a coworker the other day about this. There's the obvious using a constructor, but what are the other ways there?
There are four different ways to create objects in java: **A**. Using `new` keyword This is the most common way to create an object in java. Almost 99% of objects are created in this way. ``` MyObject object = new MyObject(); ``` **B**. Using `Class.forName()` If we know the name of the class & if it has a p...
95,432
<p>I'd like to create a hotkey to search for files <strong>under a specific folder</strong> in Windows XP; I'm using AutoHotkey to create this shortcut.</p> <p>Problem is that I need to know a command-line statement to run in order to open the standard Windows "Find Files/Folders" dialog. I've googled for a while and ...
[ { "answer_id": 95450, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": -1, "selected": false, "text": "<p>Why don't you try bashing F3? :)</p>\n" }, { "answer_id": 95497, "author": "DustinB", "author_id": 7888, ...
2008/09/18
[ "https://Stackoverflow.com/questions/95432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1766670/" ]
I'd like to create a hotkey to search for files **under a specific folder** in Windows XP; I'm using AutoHotkey to create this shortcut. Problem is that I need to know a command-line statement to run in order to open the standard Windows "Find Files/Folders" dialog. I've googled for a while and haven't found any page ...
from <http://www.pcreview.co.uk/forums/thread-1468270.php> ``` @echo off echo CreateObject("Shell.Application").FindFiles >%temp%\myff.vbs cscript.exe //Nologo %temp%\myff.vbs del %temp%\myff.vbs ```
95,492
<p>Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT?</p> <p>Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array?</p>
[ { "answer_id": 95539, "author": "dreeves", "author_id": 4234, "author_profile": "https://Stackoverflow.com/users/4234", "pm_score": 6, "selected": true, "text": "<p>This is the simplest way to get unix time:</p>\n\n<pre><code>use Time::Local;\ntimelocal($second,$minute,$hour,$day,$month-...
2008/09/18
[ "https://Stackoverflow.com/questions/95492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT? Bonus question: If given the date/time as a string, how would you first parse it into the (y,m,d,h,m,s) array?
This is the simplest way to get unix time: ``` use Time::Local; timelocal($second,$minute,$hour,$day,$month-1,$year); ``` Note the reverse order of the arguments and that January is month 0. For many more options, see the [DateTime](https://metacpan.org/pod/DateTime) module from CPAN. As for parsing, see the [Date...
95,500
<p>While refactoring code and ridding myself of all those #defines that we're now taught to hate, I came across this beauty used to calculate the number of elements in a structure:</p> <pre><code>#define STRUCTSIZE(s) (sizeof(s) / sizeof(*s)) </code></pre> <p>Very useful as it is but can it be converted into an inlin...
[ { "answer_id": 95518, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 1, "selected": false, "text": "<ul>\n<li>function, no template function, yes</li>\n<li>template, I think so (but C++</li>\n<li>templates are not my thing)</li>\...
2008/09/18
[ "https://Stackoverflow.com/questions/95500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
While refactoring code and ridding myself of all those #defines that we're now taught to hate, I came across this beauty used to calculate the number of elements in a structure: ``` #define STRUCTSIZE(s) (sizeof(s) / sizeof(*s)) ``` Very useful as it is but can it be converted into an inline function or template? O...
As been stated, the code actually work out the number of elements in an array, not struct. I would just write out the sizeof() division explicitly when I want it. If I were to make it a function, I would want to make it clear in its definition that it's expecting an array. ``` template<typename T,int SIZE> inline size...
95,510
<p>I need my application to behave differently depending on whether Vista UAC is enabled or not. How can my application detect the state of UAC on the user's computer?</p>
[ { "answer_id": 95533, "author": "Mark Schill", "author_id": 9482, "author_profile": "https://Stackoverflow.com/users/9482", "pm_score": 2, "selected": false, "text": "<p>Check for the registry value at HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System</p>\n\n<p>The Ena...
2008/09/18
[ "https://Stackoverflow.com/questions/95510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17037/" ]
I need my application to behave differently depending on whether Vista UAC is enabled or not. How can my application detect the state of UAC on the user's computer?
This registry key should tell you: ``` HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System ``` Value `EnableLUA (DWORD)` `1` enabled / `0` or missing disabled But that assumes you have the rights to read it. Programmatically you can try to read the user's token and guess if it's an admin running with ...
95,543
<p>I am trying to merge a directory in subversion, but I get the following error when I do so:</p> <pre><code>svn: Working copy '[directory name]' not locked' </code></pre> <p>I tried deleting the working directory and doing a fresh update, but that did not solve the issue. I also did a cleanup on the directory. </p>...
[ { "answer_id": 95560, "author": "EmmEff", "author_id": 9188, "author_profile": "https://Stackoverflow.com/users/9188", "pm_score": 2, "selected": false, "text": "<p>Check out this blog posting (<a href=\"http://news.e-scribe.com/145\" rel=\"nofollow noreferrer\">Obscure \"svn mv\" proble...
2008/09/18
[ "https://Stackoverflow.com/questions/95543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215086/" ]
I am trying to merge a directory in subversion, but I get the following error when I do so: ``` svn: Working copy '[directory name]' not locked' ``` I tried deleting the working directory and doing a fresh update, but that did not solve the issue. I also did a cleanup on the directory. Does anyone know how to fix ...
Check out this blog posting ([Obscure "svn mv" problem solved](http://news.e-scribe.com/145))... I typically just remove the directory and grab fresh sources.
95,547
<p>Should I catch exceptions for logging purposes?</p> <pre> public foo(..) { try { ... } catch (Exception ex) { Logger.Error(ex); throw; } } </pre> <p>If I have this in place in each of my layers (DataAccess, Business and WebService) it means the exception is logged several times.</p> <p>...
[ { "answer_id": 95573, "author": "ripper234", "author_id": 11236, "author_profile": "https://Stackoverflow.com/users/11236", "pm_score": 6, "selected": true, "text": "<p>Definitely not. You should find the correct place to <strong>handle</strong> the exception (actually do something, like...
2008/09/18
[ "https://Stackoverflow.com/questions/95547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15771/" ]
Should I catch exceptions for logging purposes? ``` public foo(..) { try { ... } catch (Exception ex) { Logger.Error(ex); throw; } } ``` If I have this in place in each of my layers (DataAccess, Business and WebService) it means the exception is logged several times. Does it make sense t...
Definitely not. You should find the correct place to **handle** the exception (actually do something, like catch-and-not-rethrow), and then log it. You can and should include the entire stack trace of course, but following your suggestion would litter the code with try-catch blocks.
95,554
<p>I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime_types.rb but that didn't work. Any suggestions?</p> <p>Thanks.</p>
[ { "answer_id": 95863, "author": "Mike Tunnicliffe", "author_id": 13956, "author_profile": "https://Stackoverflow.com/users/13956", "pm_score": 2, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>render :json =&gt; var_containing_my_json, :content_type =&gt; 'text/x-json'\n</code></p...
2008/09/18
[ "https://Stackoverflow.com/questions/95554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
I want to override the JSON MIME type ("application/json") in Rails to ("text/x-json"). I tried to register the MIME type again in mime\_types.rb but that didn't work. Any suggestions? Thanks.
This should work (in an initializer, plugin, or some similar place): ``` Mime.send(:remove_const, :JSON) Mime::Type.register "text/x-json", :json ```
95,578
<ul> <li>I have an Oracle database backup file (.dmp) that was created with <code>expdp</code>.</li> <li>The .dmp file was an export of an entire database.</li> <li>I need to restore 1 of the schemas from within this dump file.</li> <li>I don't know the names of the schemas inside this dump file.</li> <li>To use <code>...
[ { "answer_id": 100024, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 3, "selected": false, "text": "<p>Assuming that you do not have the log file from the expdp job that generated the file in the first place, the easie...
2008/09/18
[ "https://Stackoverflow.com/questions/95578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12923/" ]
* I have an Oracle database backup file (.dmp) that was created with `expdp`. * The .dmp file was an export of an entire database. * I need to restore 1 of the schemas from within this dump file. * I don't know the names of the schemas inside this dump file. * To use `impdp` to import the data I need the name of the sc...
If you open the DMP file with an editor that can handle big files, you might be able to locate the areas where the schema names are mentioned. Just be sure not to change anything. It would be better if you opened a copy of the original dump.
95,600
<p>The documentation indicates that the error: option function will make available: XHR instance, a status message string (in this case always error) and an optional exception object returned from the XHR instance (Book: JQuery in Action)</p> <p>Using the following (in the $.ajax call) I was able to determine I had a ...
[ { "answer_id": 95947, "author": "Tomasz Tybulewicz", "author_id": 17405, "author_profile": "https://Stackoverflow.com/users/17405", "pm_score": 0, "selected": false, "text": "<p>Are you sure that response is correct? Parse error mean that there is sth wrong with data being evaluted in li...
2008/09/18
[ "https://Stackoverflow.com/questions/95600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
The documentation indicates that the error: option function will make available: XHR instance, a status message string (in this case always error) and an optional exception object returned from the XHR instance (Book: JQuery in Action) Using the following (in the $.ajax call) I was able to determine I had a "parsererr...
Looking at the jQuery source code, there are four returned statuses, in additon to **success**: * **timeout** - when your specified timeout is exceeded * **error** - http error, like 404 * **notmodified** - when requested resource was not modified since last request * **parsererror** - when an xml/json response is bad
95,625
<p>Basically, we have a rule setup to run a script when a code word is detected in the body of an incoming message. The script will append the current subject header with a word in front. For example, Before: "Test Message", After: "Dept - Test Message". Any ideas?</p>
[ { "answer_id": 95695, "author": "Matt", "author_id": 17849, "author_profile": "https://Stackoverflow.com/users/17849", "pm_score": 0, "selected": false, "text": "<p>Not tested:</p>\n\n<pre><code>mailItem.Subject = \"Dept - \" &amp; mailItem.Subject\nmailItem.Save \n</code></pre>\n" }, ...
2008/09/18
[ "https://Stackoverflow.com/questions/95625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Basically, we have a rule setup to run a script when a code word is detected in the body of an incoming message. The script will append the current subject header with a word in front. For example, Before: "Test Message", After: "Dept - Test Message". Any ideas?
Or if you need an entire script: Do the Run a script with the MailItem as the parameter. ``` Sub RewriteSubject(MyMail As MailItem) Dim mailId As String Dim outlookNS As Outlook.NameSpace Dim myMailItem As Outlook.MailItem mailId = MyMail.EntryID Set outlookNS = Application.GetNamespace("MAPI") ...
95,631
<p>Suppose I want to open a file in an existing Emacs session using <code>su</code> or <code>sudo</code>, without dropping down to a shell and doing <code>sudoedit</code> or <code>sudo emacs</code>. One way to do this is</p> <pre><code>C-x C-f /sudo::/path/to/file </code></pre> <p>but this requires an expensive <a hr...
[ { "answer_id": 95758, "author": "JBB", "author_id": 12332, "author_profile": "https://Stackoverflow.com/users/12332", "pm_score": 0, "selected": false, "text": "<p>Ugh. Perhaps you could open a shell in Emacs and exec sudo emacs. </p>\n\n<p>The problem is that you presumably don't just w...
2008/09/18
[ "https://Stackoverflow.com/questions/95631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
Suppose I want to open a file in an existing Emacs session using `su` or `sudo`, without dropping down to a shell and doing `sudoedit` or `sudo emacs`. One way to do this is ``` C-x C-f /sudo::/path/to/file ``` but this requires an expensive [round-trip through SSH](http://www.gnu.org/software/tramp/). Is there a mo...
The nice thing about Tramp is that you only pay for that round-trip to SSH when you open the first file. Sudo then caches your credentials, and Emacs saves a handle, so that subsequent sudo-opened files take much less time. I haven't found the extra time it takes to save burdening, either. It's fast enough, IMO.
95,642
<p>Long story short, I have a substantial Python application that, among other things, does outcalls to "losetup", "mount", etc. on Linux. Essentially consuming system resources that must be released when complete.</p> <p>If my application crashes, I want to ensure these system resources are properly released.</p> <...
[ { "answer_id": 95659, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 2, "selected": false, "text": "<p>Application wide handler is fine. They are great for logging. Just make sure that the application wide one is durable and ...
2008/09/18
[ "https://Stackoverflow.com/questions/95642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9188/" ]
Long story short, I have a substantial Python application that, among other things, does outcalls to "losetup", "mount", etc. on Linux. Essentially consuming system resources that must be released when complete. If my application crashes, I want to ensure these system resources are properly released. Does it make sen...
I like top-level exception handlers in general (regardless of language). They're a great place to cleanup resources that may not be immediately related to resources consumed inside the method that throws the exception. It's also a fantastic place to **log** those exceptions if you have such a framework in place. Top-l...
95,683
<p>I have a .NET 3.5 (target framework) web application. I have some code that looks like this:</p> <pre><code>public string LogPath { get; private set; } public string ErrorMsg { get; private set; } </code></pre> <p>It's giving me this compilation error for these lines:</p> <pre><code>"must declare a body because ...
[ { "answer_id": 95716, "author": "Nikki9696", "author_id": 456669, "author_profile": "https://Stackoverflow.com/users/456669", "pm_score": -1, "selected": false, "text": "<p>It is, as long as you put <strong>abstract</strong> in front, or implement the methods.</p>\n\n<pre><code>public ab...
2008/09/18
[ "https://Stackoverflow.com/questions/95683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13348/" ]
I have a .NET 3.5 (target framework) web application. I have some code that looks like this: ``` public string LogPath { get; private set; } public string ErrorMsg { get; private set; } ``` It's giving me this compilation error for these lines: ``` "must declare a body because it is not marked abstract or extern." ...
add to web.config ``` <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> <providerOption name="CompilerVersion" value="v3.5" /> ...
95,700
<p>I am looking to build a multi-threaded text import facility (generally CSV into SQL Server 2005) and would like to do this in VB.NET but I am not against C#. I have VS 2008 trial and just dont know where to begin. Can anyone point me in the direction of where I can look at and play with the source of a <em>VERY</...
[ { "answer_id": 95721, "author": "nathaniel", "author_id": 11947, "author_profile": "https://Stackoverflow.com/users/11947", "pm_score": 2, "selected": false, "text": "<p>This is a great article:</p>\n\n<p><a href=\"http://www.devx.com/DevX/10MinuteSolution/20365\" rel=\"nofollow noreferr...
2008/09/18
[ "https://Stackoverflow.com/questions/95700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14728/" ]
I am looking to build a multi-threaded text import facility (generally CSV into SQL Server 2005) and would like to do this in VB.NET but I am not against C#. I have VS 2008 trial and just dont know where to begin. Can anyone point me in the direction of where I can look at and play with the source of a *VERY* simple mu...
The referenced *DevX* article is from 2001 and .Net Framework 1.1, but today .Net Framework 2.0 provides the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(VS.95).aspx) class. This is the recommended threading class if your application includes a foreground UI componen...
95,727
<p>Let's say we have <code>0.33</code>, we need to output <code>1/3</code>. <br /> If we have <code>0.4</code>, we need to output <code>2/5</code>.</p> <p>The idea is to make it human-readable to make the user understand "<strong>x parts out of y</strong>" as a better way of understanding data.</p> <p>I know that per...
[ { "answer_id": 95778, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 4, "selected": false, "text": "<p>You might want to read <a href=\"https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html\" rel=\"nofollow noreferr...
2008/09/18
[ "https://Stackoverflow.com/questions/95727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4869/" ]
Let's say we have `0.33`, we need to output `1/3`. If we have `0.4`, we need to output `2/5`. The idea is to make it human-readable to make the user understand "**x parts out of y**" as a better way of understanding data. I know that percentages is a good substitute but I was wondering if there was a simple way t...
I have found David Eppstein's [find rational approximation to given real number](http://www.ics.uci.edu/%7Eeppstein/numth/frap.c) C code to be exactly what you are asking for. Its based on the theory of continued fractions and very fast and fairly compact. I have used versions of this customized for specific numerator...
95,731
<p>Ran into this problem today, posting in case someone else has the same issue.</p> <pre><code>var execBtn = document.createElement('input'); execBtn.setAttribute("type", "button"); execBtn.setAttribute("id", "execBtn"); execBtn.setAttribute("value", "Execute"); execBtn.setAttribute("onclick", "runCommand();"); </cod...
[ { "answer_id": 95801, "author": "Lark", "author_id": 8804, "author_profile": "https://Stackoverflow.com/users/8804", "pm_score": 1, "selected": false, "text": "<p>Did you try:</p>\n\n<pre>\n execBtn.setAttribute(\"onclick\", function() { runCommand() });\n</pre>\n" }, { "answe...
2008/09/18
[ "https://Stackoverflow.com/questions/95731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13289/" ]
Ran into this problem today, posting in case someone else has the same issue. ``` var execBtn = document.createElement('input'); execBtn.setAttribute("type", "button"); execBtn.setAttribute("id", "execBtn"); execBtn.setAttribute("value", "Execute"); execBtn.setAttribute("onclick", "runCommand();"); ``` Turns out to ...
to make this work in both FF and IE you must write both ways: ``` button_element.setAttribute('onclick','doSomething();'); // for FF button_element.onclick = function() {doSomething();}; // for IE ``` thanks to [this post](http://mcarthurgfx.com/blog/article/assigning-onclick-with-new-element-breaks-in-ie)....
95,760
<p>In order to distribute a function I've written that depends on other functions I've written that have their own dependencies and so on without distributing every m-file I have ever written, I need to figure out what the full list of dependencies is for a given m-file. Is there a built-in/freely downloadable way to d...
[ { "answer_id": 97072, "author": "Azim J", "author_id": 4612, "author_profile": "https://Stackoverflow.com/users/4612", "pm_score": 6, "selected": true, "text": "<p>For newer releases of Matlab (eg 2007 or 2008) you could use the built in functions:</p>\n\n<ol>\n<li>mlint</li>\n<li>depend...
2008/09/18
[ "https://Stackoverflow.com/questions/95760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17231/" ]
In order to distribute a function I've written that depends on other functions I've written that have their own dependencies and so on without distributing every m-file I have ever written, I need to figure out what the full list of dependencies is for a given m-file. Is there a built-in/freely downloadable way to do t...
For newer releases of Matlab (eg 2007 or 2008) you could use the built in functions: 1. mlint 2. dependency report and 3. coverage report Another option is to use Matlab's profiler. The command is profile, it can also be used to track dependencies. To use profile, you could do ``` >> profile on % turn profiling o...
95,767
<p>We'd like a trace in our application logs of these exceptions - by default Java just outputs them to the console.</p>
[ { "answer_id": 95823, "author": "Karl", "author_id": 17613, "author_profile": "https://Stackoverflow.com/users/17613", "pm_score": 0, "selected": false, "text": "<p>There are two ways:</p>\n\n<ol>\n<li>/* Install a Thread.UncaughtExceptionHandler on the EDT */</li>\n<li>Set a system prop...
2008/09/18
[ "https://Stackoverflow.com/questions/95767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18117/" ]
We'd like a trace in our application logs of these exceptions - by default Java just outputs them to the console.
There is a distinction between uncaught exceptions in the EDT and outside the EDT. [Another question has a solution for both](https://stackoverflow.com/questions/75218/how-can-i-detect-when-an-exceptions-been-thrown-globally-in-java#75439) but if you want just the EDT portion chewed up... ``` class AWTExceptionHandle...
95,820
<p>Let's say I have an array, and I know I'm going to be doing a lot of "Does the array contain X?" checks. The efficient way to do this is to turn that array into a hash, where the keys are the array's elements, and then you can just say <pre>if($hash{X}) { ... }</pre></p> <p>Is there an easy way to do this array-to-...
[ { "answer_id": 95826, "author": "raldi", "author_id": 7598, "author_profile": "https://Stackoverflow.com/users/7598", "pm_score": 8, "selected": true, "text": "<pre><code>%hash = map { $_ =&gt; 1 } @array;\n</code></pre>\n\n<p>It's not as short as the \"@hash{@array} = ...\" solutions, b...
2008/09/18
[ "https://Stackoverflow.com/questions/95820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
Let's say I have an array, and I know I'm going to be doing a lot of "Does the array contain X?" checks. The efficient way to do this is to turn that array into a hash, where the keys are the array's elements, and then you can just say ``` if($hash{X}) { ... } ``` Is there an easy way to do this array-to-hash convers...
``` %hash = map { $_ => 1 } @array; ``` It's not as short as the "@hash{@array} = ..." solutions, but those ones require the hash and array to already be defined somewhere else, whereas this one can take an anonymous array and return an anonymous hash. What this does is take each element in the array and pair it up ...
95,824
<p>I'm looking for a way to do a substring replace on a string in LaTeX. What I'd like to do is build a command that I can call like this:</p> <pre><code>\replace{File,New} </code></pre> <p>and that would generate something like</p> <pre><code>\textbf{File}$\rightarrow$\textbf{New} </code></pre> <p>This is a simpl...
[ { "answer_id": 95959, "author": "Brent.Longborough", "author_id": 9634, "author_profile": "https://Stackoverflow.com/users/9634", "pm_score": -1, "selected": false, "text": "<p>OK, I withdraw this answer. Thanks for clarifying the question.</p>\n\n<hr>\n\n<p>I suspect this may not be wha...
2008/09/18
[ "https://Stackoverflow.com/questions/95824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1322/" ]
I'm looking for a way to do a substring replace on a string in LaTeX. What I'd like to do is build a command that I can call like this: ``` \replace{File,New} ``` and that would generate something like ``` \textbf{File}$\rightarrow$\textbf{New} ``` This is a simple example, but I'd like to be able to put formatti...
The general case is rather more tricky (when you're not using commas as separators), but the example you gave can be coded without too much trouble with some knowledge of the LaTeX internals. ``` \documentclass[12pt]{article} \makeatletter \newcommand\formatnice[1]{% \let\@formatsep\@formatsepinit \@for\@ii:=#1\do...
95,834
<p>I have a Windows Workflow application that uses classes I've written for COM automation. I'm opening Word and Excel from my classes using COM.</p> <p>I'm currently implementing IDisposable in my COM helper and using Marshal.ReleaseComObject(). However, if my Workflow fails, the Dispose() method isn't being called a...
[ { "answer_id": 96672, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 2, "selected": true, "text": "<p>I can not see what failure you have that does not calls the Dispose() method. I made a test with a sequential workflow that c...
2008/09/18
[ "https://Stackoverflow.com/questions/95834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
I have a Windows Workflow application that uses classes I've written for COM automation. I'm opening Word and Excel from my classes using COM. I'm currently implementing IDisposable in my COM helper and using Marshal.ReleaseComObject(). However, if my Workflow fails, the Dispose() method isn't being called and the Wor...
I can not see what failure you have that does not calls the Dispose() method. I made a test with a sequential workflow that contains only a code activity which just throws an exception and the Dispose() method of my workflow is called twice (this is because of the standard WorkflowTerminated event handler). Check the f...
95,842
<p>The name of a temporary table such as #t1 can be determined using </p> <pre><code>select @TableName = [Name] from tempdb.sys.tables where [Object_ID] = object_id('tempDB.dbo.#t1') </code></pre> <p>How can I find the name of a table valued variable, i.e. one declared by</p> <pre><code>declare @t2 as table (a int)...
[ { "answer_id": 95874, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": -1, "selected": true, "text": "<p>I don't believe you can, as table variables are created in memory not in tempdb.</p>\n" }, { "answer_id": 96...
2008/09/18
[ "https://Stackoverflow.com/questions/95842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18116/" ]
The name of a temporary table such as #t1 can be determined using ``` select @TableName = [Name] from tempdb.sys.tables where [Object_ID] = object_id('tempDB.dbo.#t1') ``` How can I find the name of a table valued variable, i.e. one declared by ``` declare @t2 as table (a int) ``` the purpose is to be able to g...
I don't believe you can, as table variables are created in memory not in tempdb.
95,850
<p>I'm looking for the total <a href="http://en.wikipedia.org/wiki/Commit_charge" rel="nofollow noreferrer">commit charge</a>.</p>
[ { "answer_id": 96094, "author": "JustinD", "author_id": 12063, "author_profile": "https://Stackoverflow.com/users/12063", "pm_score": 1, "selected": false, "text": "<p>Here's an example using WMI:</p>\n\n<pre><code>strComputer = \".\"\n\nSet objSWbemServices = GetObject(\"winmgmts:\\\\\"...
2008/09/18
[ "https://Stackoverflow.com/questions/95850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
I'm looking for the total [commit charge](http://en.wikipedia.org/wiki/Commit_charge).
``` public static long GetCommitCharge() { var p = new System.Diagnostics.PerformanceCounter("Memory", "Committed Bytes"); return p.RawValue; } ```
95,858
<p>I have a web application that is dynamically loading PDF files for viewing in the browser. Currently, it uses "innerHTML" to replace a div with the PDF Object. This works.</p> <p>But, is there a better way to get the ID of the element and set the "src" or "data" parameter for the Object / Embed and have it instan...
[ { "answer_id": 96296, "author": "Lark", "author_id": 8804, "author_profile": "https://Stackoverflow.com/users/8804", "pm_score": 1, "selected": false, "text": "<p>I am not sure if this will work, as I have not tried this out in my projects.</p>\n\n<p>(Looking at your JS, I believe you ar...
2008/09/18
[ "https://Stackoverflow.com/questions/95858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a web application that is dynamically loading PDF files for viewing in the browser. Currently, it uses "innerHTML" to replace a div with the PDF Object. This works. But, is there a better way to get the ID of the element and set the "src" or "data" parameter for the Object / Embed and have it instantly load up ...
I am not sure if this will work, as I have not tried this out in my projects. (Looking at your JS, I believe you are using jQuery. If not, please correct me) Once you have populated the divPDF with the object you might try the code below: ``` $("objPDF").attr({ data: "dir/to/newPDF" }); ``` Again, I am not sur...
95,866
<p>I have a simple table comments <code>(id INT, revision INT, comment VARCHAR(140))</code> with some content like this:</p> <pre><code>1|1|hallo1| 1|2|hallo2| 1|3|hallo3| 2|1|hallo1| 2|2|hallo2| </code></pre> <p>I'm searching for an SQL statement which will return each comment with the highest revision:</p> <pre><...
[ { "answer_id": 95914, "author": "nathaniel", "author_id": 11947, "author_profile": "https://Stackoverflow.com/users/11947", "pm_score": 3, "selected": false, "text": "<ol>\n<li><p>Make sure you have your indexes set up appropriately. Indexing on id, revision would be good.</p></li>\n<li...
2008/09/18
[ "https://Stackoverflow.com/questions/95866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a simple table comments `(id INT, revision INT, comment VARCHAR(140))` with some content like this: ``` 1|1|hallo1| 1|2|hallo2| 1|3|hallo3| 2|1|hallo1| 2|2|hallo2| ``` I'm searching for an SQL statement which will return each comment with the highest revision: ``` 1|3|hallo3| 2|2|hallo2| ``` I've come up w...
Here's one way that with appropriate indexing will not be heinously slow and it doesn't use a subselect: ``` SELECT comments.ID, comments.revision, comments.comment FROM comments LEFT OUTER JOIN comments AS maxcomments ON maxcomments.ID= comments.ID AND maxcomments.revision > comments.revision WHERE maxcomments.revi...
95,875
<p>How do I see if a certain object has been loaded, and if not, how can it be loaded, like the following?</p> <pre><code>if (!isObjectLoaded(someVar)) { someVar= loadObject(); } </code></pre>
[ { "answer_id": 95898, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 1, "selected": false, "text": "<p><code>typeof(obj)</code> would return \"object\" for an object of a class among other possible values.</p>\n" }, {...
2008/09/18
[ "https://Stackoverflow.com/questions/95875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
How do I see if a certain object has been loaded, and if not, how can it be loaded, like the following? ``` if (!isObjectLoaded(someVar)) { someVar= loadObject(); } ```
If it is an object then you should just be able to check to see if it is [null](http://javascript.about.com/od/reference/g/rnull.htm) or [undefined](http://javascript.about.com/od/reference/g/sundefined.htm) and then load it if it is. ``` if (myObject === null || myObject === undefined) { myObject = loadObject(); }...
95,890
<p>When someone talks about a variables storage class specifier, what are they talking about?<br> They also often talk about variable linkage in the same context, what is that?</p>
[ { "answer_id": 95927, "author": "Benoit", "author_id": 10703, "author_profile": "https://Stackoverflow.com/users/10703", "pm_score": 6, "selected": true, "text": "<p>The storage class specifier controls the <em>storage</em> and the <em>linkage</em> of your variables. These are two concep...
2008/09/18
[ "https://Stackoverflow.com/questions/95890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
When someone talks about a variables storage class specifier, what are they talking about? They also often talk about variable linkage in the same context, what is that?
The storage class specifier controls the *storage* and the *linkage* of your variables. These are two concepts that are different. C specifies the following specifiers for variables: auto, extern, register, static. **Storage** The storage duration determines how long your variable will live in ram. There are thr...
95,895
<p>I have two <code>DateTime</code> objects: <code>StartDate</code> and <code>EndDate</code>. I want to make sure <code>StartDate</code> is before <code>EndDate</code>. How is this done in C#?</p>
[ { "answer_id": 95921, "author": "Ryan Rinaldi", "author_id": 2278, "author_profile": "https://Stackoverflow.com/users/2278", "pm_score": 5, "selected": false, "text": "<pre><code>if(StartDate &lt; EndDate)\n{}\n</code></pre>\n\n<p>DateTime supports normal comparision operators.</p>\n" ...
2008/09/18
[ "https://Stackoverflow.com/questions/95895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
I have two `DateTime` objects: `StartDate` and `EndDate`. I want to make sure `StartDate` is before `EndDate`. How is this done in C#?
``` if (StartDate < EndDate) // code ``` if you just want the dates, and not the time ``` if (StartDate.Date < EndDate.Date) // code ```
95,910
<p>Given this class</p> <pre><code>class Foo { // Want to find _bar with reflection [SomeAttribute] private string _bar; public string BigBar { get { return this._bar; } } } </code></pre> <p>I want to find the private item _bar that I will mark with a attribute. Is that possible? </...
[ { "answer_id": 95937, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 2, "selected": false, "text": "<p>Yes, however you will need to set your Binding flags to search for private fields (if your looking for the member outside ...
2008/09/18
[ "https://Stackoverflow.com/questions/95910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469/" ]
Given this class ``` class Foo { // Want to find _bar with reflection [SomeAttribute] private string _bar; public string BigBar { get { return this._bar; } } } ``` I want to find the private item \_bar that I will mark with a attribute. Is that possible? I have done this with prope...
Use `BindingFlags.NonPublic` and `BindingFlags.Instance` flags ``` FieldInfo[] fields = myType.GetFields( BindingFlags.NonPublic | BindingFlags.Instance); ```
95,912
<p>My Vista application needs to know whether the user has launched it "as administrator" (elevated) or as a standard user (non-elevated). How can I detect that at run time? </p>
[ { "answer_id": 95918, "author": "Andrei Belogortseff", "author_id": 17037, "author_profile": "https://Stackoverflow.com/users/17037", "pm_score": 5, "selected": true, "text": "<p>The following C++ function can do that:</p>\n\n<pre class=\"lang-cpp prettyprint-override\"><code>HRESULT Get...
2008/09/18
[ "https://Stackoverflow.com/questions/95912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17037/" ]
My Vista application needs to know whether the user has launched it "as administrator" (elevated) or as a standard user (non-elevated). How can I detect that at run time?
The following C++ function can do that: ```cpp HRESULT GetElevationType( __out TOKEN_ELEVATION_TYPE * ptet ); /* Parameters: ptet [out] Pointer to a variable that receives the elevation type of the current process. The possible values are: TokenElevationTypeDefault - This value indicates that either UA...
95,950
<p>On my desktop I have written a small Pylons app that connects to Oracle. I'm now trying to deploy it to my server which is running Win2k3 x64. (My desktop is 32-bit XP) The Oracle installation on the server is also 64-bit.</p> <p>I was getting errors about loading the OCI dll, so I installed the 32 bit client int...
[ { "answer_id": 96016, "author": "Moe", "author_id": 3051, "author_profile": "https://Stackoverflow.com/users/3051", "pm_score": 2, "selected": false, "text": "<p>sys.path is python's internal representation of the PYTHONPATH, it sounds to me like you want to modify the PATH.</p>\n\n<p>I'...
2008/09/18
[ "https://Stackoverflow.com/questions/95950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1566663/" ]
On my desktop I have written a small Pylons app that connects to Oracle. I'm now trying to deploy it to my server which is running Win2k3 x64. (My desktop is 32-bit XP) The Oracle installation on the server is also 64-bit. I was getting errors about loading the OCI dll, so I installed the 32 bit client into `C:\oracle...
sys.path is python's internal representation of the PYTHONPATH, it sounds to me like you want to modify the PATH. I'm not sure that this will work, but you can try: ``` import os os.environ['PATH'] += os.pathsep + "C:\\oracle32\\bin" ```
95,954
<p>Suppose we have:</p> <pre><code>interface Foo { bool Func(int x); } class Bar: Foo { bool Func(int x) { return (x&gt;0); } } class Baz: Foo { bool Func(int x) { return (x&lt;0); } } </code></pre> <p>Now we can toss around Bar and Baz as a Foos and call their Func methods.</p> <p>Delegate...
[ { "answer_id": 95975, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 2, "selected": false, "text": "<p>No, delegates are for method pointers. Then you can make sure that the signature of the method associated w/ the delegate ...
2008/09/18
[ "https://Stackoverflow.com/questions/95954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264/" ]
Suppose we have: ``` interface Foo { bool Func(int x); } class Bar: Foo { bool Func(int x) { return (x>0); } } class Baz: Foo { bool Func(int x) { return (x<0); } } ``` Now we can toss around Bar and Baz as a Foos and call their Func methods. Delegates simplify this a little bit: ``` dele...
There is a slight difference, delegates can access the member variables of classes in which, they are defined. In C# (unlike Java) all inner class are consider to be static. Therefore if you are using an interface to manage a callback, e.g. an ActionListener for a button. The implementing inner class needs to be passed...
95,956
<p>using C++Builder 2007, the FindFirstFile and FindNextFile functions doesn't seem to be able to find some files on 64-bit versions of Vista and XP. My test application is 32-bit.</p> <p>If I use them to iterate through the folder C:\Windows\System32\Drivers they only find a handful of files although there are 185 wh...
[ { "answer_id": 96012, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 0, "selected": false, "text": "<p>Are you sure it is looking in the same directory as the dir command? They don't seem to have any files in common.</p>\n\...
2008/09/18
[ "https://Stackoverflow.com/questions/95956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18145/" ]
using C++Builder 2007, the FindFirstFile and FindNextFile functions doesn't seem to be able to find some files on 64-bit versions of Vista and XP. My test application is 32-bit. If I use them to iterate through the folder C:\Windows\System32\Drivers they only find a handful of files although there are 185 when I issue...
Is there redirection going on? See the remarks on Wow64DisableWow64FsRedirection <http://msdn.microsoft.com/en-gb/library/aa365743.aspx>
95,967
<p>Simple question, how do you list the primary key of a table with T-SQL? I know how to get indexes on a table, but can't remember how to get the PK.</p>
[ { "answer_id": 95982, "author": "boes", "author_id": 17746, "author_profile": "https://Stackoverflow.com/users/17746", "pm_score": 2, "selected": false, "text": "<p>The system stored procedure <code>sp_help</code> will give you the information. Execute the following statement:</p>\n\n<pr...
2008/09/18
[ "https://Stackoverflow.com/questions/95967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/736/" ]
Simple question, how do you list the primary key of a table with T-SQL? I know how to get indexes on a table, but can't remember how to get the PK.
``` SELECT Col.Column_Name from INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab, INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col WHERE Col.Constraint_Name = Tab.Constraint_Name AND Col.Table_Name = Tab.Table_Name AND Tab.Constraint_Type = 'PRIMARY KEY' AND Col.Table_Name = '<your table name>' ```
95,988
<p>I'm inserting multiple records into a table A from another table B. Is there a way to get the identity value of table A record and update table b record with out doing a cursor?</p> <pre><code>Create Table A (id int identity, Fname nvarchar(50), Lname nvarchar(50)) Create Table B (Fname nvarchar(50), Lname nvarcha...
[ { "answer_id": 96021, "author": "Matt", "author_id": 17849, "author_profile": "https://Stackoverflow.com/users/17849", "pm_score": 0, "selected": false, "text": "<p>If you always want this behavior, you could put an AFTER INSERT trigger on TableA that will update table B.</p>\n" }, {...
2008/09/18
[ "https://Stackoverflow.com/questions/95988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2526/" ]
I'm inserting multiple records into a table A from another table B. Is there a way to get the identity value of table A record and update table b record with out doing a cursor? ``` Create Table A (id int identity, Fname nvarchar(50), Lname nvarchar(50)) Create Table B (Fname nvarchar(50), Lname nvarchar(50), NewId i...
MBelly is right on the money - But then the trigger will always try and update table B even if that's not required (Because you're also inserting from table C?). Darren is also correct here, you can't get multiple identities back as a result set. Your options are using a cursor and taking the identity for each row you...
96,003
<p>Let's say I have two models, Classes and People. A Class might have one or two People as instructors, and twenty people as students. So, I need to have multiple relationships between the models -- one where it's 1->M for instructors, and one where it's 1->M for students.</p> <p>Edit: Instructors and Students <em>mu...
[ { "answer_id": 96055, "author": "kch", "author_id": 13989, "author_profile": "https://Stackoverflow.com/users/13989", "pm_score": 5, "selected": true, "text": "<p>There are many options here, but assuming instructors are always instructors and students are always students, you can use in...
2008/09/18
[ "https://Stackoverflow.com/questions/96003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/722/" ]
Let's say I have two models, Classes and People. A Class might have one or two People as instructors, and twenty people as students. So, I need to have multiple relationships between the models -- one where it's 1->M for instructors, and one where it's 1->M for students. Edit: Instructors and Students *must* be the sa...
There are many options here, but assuming instructors are always instructors and students are always students, you can use inheritance: ``` class Person < ActiveRecord::Base; end # btw, model names are singular in rails class Student < Person; end class Instructor < Person; end ``` then ``` class Course < ActiveRe...
96,027
<p>For example, given a type param method i'm looking for something like the part in bold</p> <blockquote> <p>void MyMethod&lt; T >() {<br> if ( <strong>typeof(T).Implements( <em>IMyInterface</em> )</strong> ) {</p> <pre><code> //Do something </code></pre> <p>else</p> <pre><code> //Do something else ...
[ { "answer_id": 96057, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.type.isassignablefrom.aspx\" rel=\"noreferrer\">Type.IsAss...
2008/09/18
[ "https://Stackoverflow.com/questions/96027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10136/" ]
For example, given a type param method i'm looking for something like the part in bold > > void MyMethod< T >() { > > if ( **typeof(T).Implements( *IMyInterface* )** ) > { > > > > ``` > //Do something > > ``` > > else > > > > ``` > //Do something else > > ``` > > } > > > Anwers using C# 3.0...
[Type.IsAssignableFrom](http://msdn.microsoft.com/en-us/library/system.type.isassignablefrom.aspx) ``` if(typeof(IMyInterface).IsAssignableFrom(typeof(T))) { // something } else { // something else } ```
96,029
<p>I have an ASP.Net page that will be hosted on a couple different servers, and I want to get the URL of the page (or even better: the site where the page is hosted) as a string for use in the code-behind. Any ideas?</p>
[ { "answer_id": 96052, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 2, "selected": false, "text": "<p>Request.Url.Host</p>\n" }, { "answer_id": 96063, "author": "Mikey", "author_id": 13347, "auth...
2008/09/18
[ "https://Stackoverflow.com/questions/96029", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
I have an ASP.Net page that will be hosted on a couple different servers, and I want to get the URL of the page (or even better: the site where the page is hosted) as a string for use in the code-behind. Any ideas?
Use this: ``` Request.Url.AbsoluteUri ``` That will get you the full path (including <http://..>.)
96,042
<p>I'm working on the creation of an ActiveX EXE using VB6, and the only example I got is all written in Delphi.</p> <p>Reading the example code, I noticed there are some functions whose signatures are followed by the <strong>safecall</strong> keyword. Here's an example:</p> <pre><code>function AddSymbol(ASymbol: Ol...
[ { "answer_id": 96231, "author": "Francesca", "author_id": 9842, "author_profile": "https://Stackoverflow.com/users/9842", "pm_score": 5, "selected": true, "text": "<p>Safecall passes parameters from right to left, instead of the pascal or register (default) from left to right </p>\n\n<p...
2008/09/18
[ "https://Stackoverflow.com/questions/96042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/431/" ]
I'm working on the creation of an ActiveX EXE using VB6, and the only example I got is all written in Delphi. Reading the example code, I noticed there are some functions whose signatures are followed by the **safecall** keyword. Here's an example: ``` function AddSymbol(ASymbol: OleVariant): WordBool; safecall; ```...
Safecall passes parameters from right to left, instead of the pascal or register (default) from left to right With safecall, the procedure or function removes parameters from the stack upon returning (like pascal, but not like cdecl where it's up to the caller) Safecall implements exception 'firewalls'; esp on Win3...
96,054
<p>I have huge 3D arrays of numbers in my .NET application. I need to convert them to a 1D array to pass it to a COM library. Is there a way to convert the array without making a copy of all the data?</p> <p>I can do the conversion like this, but then I use twice the ammount of memory which is an issue in my applicati...
[ { "answer_id": 96081, "author": "Yes - that Jake.", "author_id": 5287, "author_profile": "https://Stackoverflow.com/users/5287", "pm_score": 3, "selected": false, "text": "<p>Unfortunately, C# arrays aren't guaranteed to be in contiguous memory like they are in closer-to-the-metal langua...
2008/09/18
[ "https://Stackoverflow.com/questions/96054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15454/" ]
I have huge 3D arrays of numbers in my .NET application. I need to convert them to a 1D array to pass it to a COM library. Is there a way to convert the array without making a copy of all the data? I can do the conversion like this, but then I use twice the ammount of memory which is an issue in my application: ``` ...
I don't believe the way C# stores that data in memory would make it feasible the same way a simple cast in C would. Why not use a 1d array to begin with and perhaps make a class for the type so you can access it in your program as if it were a 3d array?
96,059
<p>Suppose I want to store many small configuration objects in XML, and I don't care too much about the format. The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/beans/XMLDecoder.html" rel="nofollow noreferrer">XMLDecoder</a> class built into the JDK would work, and from what I hear, <a href="http://xstream.cod...
[ { "answer_id": 96148, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 1, "selected": false, "text": "<p>If you are planning on storing all those configuration objects in a single file, and that file will be quite large, b...
2008/09/18
[ "https://Stackoverflow.com/questions/96059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3474/" ]
Suppose I want to store many small configuration objects in XML, and I don't care too much about the format. The [XMLDecoder](http://java.sun.com/j2se/1.5.0/docs/api/java/beans/XMLDecoder.html) class built into the JDK would work, and from what I hear, [XStream](http://xstream.codehaus.org/) works in a similar way. Wh...
I really like the [XStream](http://xstream.codehaus.org/) library. It does a really good job of outputting fairly simple xml as a result of a provided Java object. It works great for reproducing the object back from the xml as well. And, one of our 3rd party libraries already depended on it anyway. * We chose to use i...
96,066
<p>I'm trying to incorporate some JavaScript unit testing into my automated build process. Currently JSUnit works well with JUnit, but it seems to be abandonware and lacks good support for Ajax, debugging, and timeouts.</p> <p>Has anyone had any luck automating (with <a href="https://en.wikipedia.org/wiki/Apache_Ant" r...
[ { "answer_id": 96115, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 2, "selected": false, "text": "<p>Look into <a href=\"http://developer.yahoo.com/yui/yuitest/\" rel=\"nofollow noreferrer\">YUITest</a></p>\n" }, { ...
2008/09/18
[ "https://Stackoverflow.com/questions/96066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18146/" ]
I'm trying to incorporate some JavaScript unit testing into my automated build process. Currently JSUnit works well with JUnit, but it seems to be abandonware and lacks good support for Ajax, debugging, and timeouts. Has anyone had any luck automating (with [Ant](https://en.wikipedia.org/wiki/Apache_Ant)) a unit testi...
There are many JavaScript unit test framework out there (JSUnit, scriptaculous, ...), but JSUnit is the only one I know that may be used with an automated build. If you are doing 'true' unit test you should not need AJAX support. For example, if you are using an [RPC](https://en.wikipedia.org/wiki/Remote_procedure_cal...
96,086
<p>I've had a lot of trouble trying to come up with the best way to properly follow TDD principles while developing UI in JavaScript. What's the best way to go about this?</p> <p>Is it best to separate the visual from the functional? Do you develop the visual elements first, and then write tests and then code for fu...
[ { "answer_id": 96221, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 0, "selected": false, "text": "<p>This is the primary reason I switched to the Google Web Toolkit ... I develop and test in Java and have a reasonable...
2008/09/18
[ "https://Stackoverflow.com/questions/96086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18146/" ]
I've had a lot of trouble trying to come up with the best way to properly follow TDD principles while developing UI in JavaScript. What's the best way to go about this? Is it best to separate the visual from the functional? Do you develop the visual elements first, and then write tests and then code for functionality?
I've done some TDD with Javascript in the past, and what I had to do was make the distinction between Unit and Integration tests. Selenium will test your overall site, with the output from the server, its post backs, ajax calls, all of that. But for unit testing, none of that is important. What you want is just the UI...
96,107
<p>I'm working with an mpeg stream that uses a IBBP... GOP sequence. The <code>(DTS,PTS)</code> values returned for the first 4 AVPackets are as follows: <code>I=(0,3) B=(1,1) B=(2,2) P=(3,6)</code></p> <p>The PTS on the I frame looks like it is legit, but then the PTS on the B frames cannot be right, since the B fram...
[ { "answer_id": 96939, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Ok, scratch my previous confused reply.</p>\n\n<p>For a IBBPBBI movie, you'd expect the PTSes to look like this (in decoding...
2008/09/18
[ "https://Stackoverflow.com/questions/96107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18156/" ]
I'm working with an mpeg stream that uses a IBBP... GOP sequence. The `(DTS,PTS)` values returned for the first 4 AVPackets are as follows: `I=(0,3) B=(1,1) B=(2,2) P=(3,6)` The PTS on the I frame looks like it is legit, but then the PTS on the B frames cannot be right, since the B frames shouldn't be displayed before...
I think I finally figured out what's going on based on a comment made in <http://www.dranger.com/ffmpeg/tutorial05.html>: > > ffmpeg reorders the packets so that the DTS of the packet being processed by avcodec\_decode\_video() will *always be the same* as the PTS of the frame it returns > > > Translation: If I f...
96,113
<p>I got a call from a tester about a machine that was failing our software. When I examined the problem machine, I quickly realized the problem was fairly low level: Inbound network traffic works fine. Basic outbound command like ping and ssh are working fine, but anything involving the <code>connect()</code> call is ...
[ { "answer_id": 96158, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 1, "selected": false, "text": "<p>Is the firewall turned off?</p>\n" }, { "answer_id": 96163, "author": "axk", "author_id": 578, "author_p...
2008/09/18
[ "https://Stackoverflow.com/questions/96113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1565/" ]
I got a call from a tester about a machine that was failing our software. When I examined the problem machine, I quickly realized the problem was fairly low level: Inbound network traffic works fine. Basic outbound command like ping and ssh are working fine, but anything involving the `connect()` call is failing with "...
I would check firewall configuration on that machine. It is possible for iptables (I guess your SUSE has iptables firewall) to be setup to let trough only ping ICMP packets.
96,114
<p>I'm currently modifying a Java script in Rational Functional Tester and I'm trying to tell RFT to wait for an object with a specified set of properties to appear. Specifically, I want to wait until a table with X number of rows appear. The only way I have been able to do it so far is to add a verification point that...
[ { "answer_id": 164822, "author": "Tom E", "author_id": 9267, "author_profile": "https://Stackoverflow.com/users/9267", "pm_score": 2, "selected": false, "text": "<p>No, there is not a built-in waitForProperty() type of method, so you cannot do something simple like tableObject.waitForPro...
2008/09/18
[ "https://Stackoverflow.com/questions/96114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17601/" ]
I'm currently modifying a Java script in Rational Functional Tester and I'm trying to tell RFT to wait for an object with a specified set of properties to appear. Specifically, I want to wait until a table with X number of rows appear. The only way I have been able to do it so far is to add a verification point that ju...
No, there is not a built-in waitForProperty() type of method, so you cannot do something simple like tableObject.waitForProperty("rowCount", x); Your options are to use a verification point as you already are doing (if it ain't broke...) or to roll your own synchronization point using a do/while loop and the find() me...
96,123
<pre><code>Shell ("explorer.exe www.google.com") </code></pre> <p>is how I'm currently opening my products ad page after successful install. However I think it would look much nicer if I could do it more like Avira does, or even a popup where there are no address bar links etc. Doing this via an inbrowser link is eas...
[ { "answer_id": 164822, "author": "Tom E", "author_id": 9267, "author_profile": "https://Stackoverflow.com/users/9267", "pm_score": 2, "selected": false, "text": "<p>No, there is not a built-in waitForProperty() type of method, so you cannot do something simple like tableObject.waitForPro...
2008/09/18
[ "https://Stackoverflow.com/questions/96123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` Shell ("explorer.exe www.google.com") ``` is how I'm currently opening my products ad page after successful install. However I think it would look much nicer if I could do it more like Avira does, or even a popup where there are no address bar links etc. Doing this via an inbrowser link is easy enough ``` <a hre...
No, there is not a built-in waitForProperty() type of method, so you cannot do something simple like tableObject.waitForProperty("rowCount", x); Your options are to use a verification point as you already are doing (if it ain't broke...) or to roll your own synchronization point using a do/while loop and the find() me...