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
226,896
<p>I am currently trying to create an Exception handler built into my windows service that, on an unhandled exception, sends a message to another program. I have built the method and gotten the communication working, but it seems that every time my program throws the error, (I have a raise call in the code to force it...
[ { "answer_id": 227079, "author": "gabr", "author_id": 4997, "author_profile": "https://Stackoverflow.com/users/4997", "pm_score": 0, "selected": false, "text": "<p>Interesting.</p>\n\n<p>Custom exception handler is called if you run the app in Delphi IDE (tried with 2007) but not if you ...
2008/10/22
[ "https://Stackoverflow.com/questions/226896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16059/" ]
I am currently trying to create an Exception handler built into my windows service that, on an unhandled exception, sends a message to another program. I have built the method and gotten the communication working, but it seems that every time my program throws the error, (I have a raise call in the code to force it.) w...
You are missing a call to [SetErrorMode()](http://msdn.microsoft.com/en-us/library/ms680621(VS.85).aspx): ``` SetErrorMode(SEM_NOGPFAULTERRORBOX); ``` This is needed to prevent the OS [unhandled exception filter](http://msdn.microsoft.com/en-us/library/ms681401(VS.85).aspx) from showing a dialog box / displaying the...
226,910
<p>I find it curious that the most obvious way to create <code>Date</code> objects in Java has been deprecated and appears to have been "substituted" with a not so obvious to use lenient calendar.</p> <p>How do you check that a date, given as a combination of day, month, and year, is a valid date?</p> <p>For instance...
[ { "answer_id": 226920, "author": "AdamC", "author_id": 16476, "author_profile": "https://Stackoverflow.com/users/16476", "pm_score": 6, "selected": true, "text": "<p>The current way is to use the calendar class. It has the <a href=\"http://docs.oracle.com/javase/7/docs/api/java/util/Cal...
2008/10/22
[ "https://Stackoverflow.com/questions/226910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26595/" ]
I find it curious that the most obvious way to create `Date` objects in Java has been deprecated and appears to have been "substituted" with a not so obvious to use lenient calendar. How do you check that a date, given as a combination of day, month, and year, is a valid date? For instance, 2008-02-31 (as in yyyy-mm-...
The current way is to use the calendar class. It has the [setLenient](http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#setLenient%28boolean%29) method that will validate the date and throw and exception if it is out of range as in your example. Forgot to add: If you get a calendar instance and set the...
226,931
<p>I believe this is a common question / problem but have not been able to find a good clean concise answer.</p> <p><strong>The Problem</strong></p> <p>How to map entities that appear to have an inheritance relationship:</p> <pre><code>Company Supplier Manufacturer Customer </code></pre> <p>However, a Supplie...
[ { "answer_id": 227933, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 3, "selected": true, "text": "<p>You probably want to consider using the Roles. So a Role will have a set of Persons. Or a Person will have a s...
2008/10/22
[ "https://Stackoverflow.com/questions/226931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30469/" ]
I believe this is a common question / problem but have not been able to find a good clean concise answer. **The Problem** How to map entities that appear to have an inheritance relationship: ``` Company Supplier Manufacturer Customer ``` However, a Supplier can be a Manufacturer. or ``` Person Doctor P...
You probably want to consider using the Roles. So a Role will have a set of Persons. Or a Person will have a set of Roles or both. This would probably imply that there is an Association class that maps persons to roles. Define a Person class with all properties that are common to people. Then define a Role super clas...
226,953
<p>If I have hundreds/thousands of client computers WCP'ing to my server, should I respond with a '200 OK' type message stating that I received the data and stored it in the db successfully?</p> <p>Is this already built-into WCF?</p>
[ { "answer_id": 227011, "author": "Whisk", "author_id": 908, "author_profile": "https://Stackoverflow.com/users/908", "pm_score": 1, "selected": false, "text": "<p>There's 2 ways you could do this - return a value from your wcf call indicating success or failure, or assume success and use...
2008/10/22
[ "https://Stackoverflow.com/questions/226953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I have hundreds/thousands of client computers WCP'ing to my server, should I respond with a '200 OK' type message stating that I received the data and stored it in the db successfully? Is this already built-into WCF?
There are three messaging patterns mentioned here: 1. Synchronous request-response 2. Asynchronous send (fire and forget with one-way service) 3. Asynchronous request-response (duplex service call with one-way service) All three display different messaging behaviour, and the pattern to be used should be chosen based ...
226,977
<p>I can't seem to grok the concept of "loose coupling." I suppose it doesn't help that the word "loose" usually has a negative connotation, so I always forget that loose coupling is a <em>good</em> thing.</p> <p>Will somebody please show some "before" and "after" code (or pseudocode) that illustrates this concept?</p...
[ { "answer_id": 226995, "author": "Tom", "author_id": 20, "author_profile": "https://Stackoverflow.com/users/20", "pm_score": 4, "selected": false, "text": "<h2>Definition</h2>\n\n<p>Essentially, coupling is how much a given object or set of object relies on another object or another set ...
2008/10/22
[ "https://Stackoverflow.com/questions/226977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30454/" ]
I can't seem to grok the concept of "loose coupling." I suppose it doesn't help that the word "loose" usually has a negative connotation, so I always forget that loose coupling is a *good* thing. Will somebody please show some "before" and "after" code (or pseudocode) that illustrates this concept?
Consider a simple shopping cart application that uses a `CartContents` class to keep track of the items in the shopping cart and an `Order` class for processing a purchase. The `Order` needs to determine the total value of the contents in the cart, it might do that like so: **Tightly Coupled Example:** ```cs public c...
226,978
<p>What is the best way to sync up two lists each of which may contain items not in the other? As shown the lists are not sorted - although if necessary sorting them first would not be an issue.</p> <pre><code>List 1 = a,b,c,e List 2 = b,e,c,d </code></pre> <p>Using the lists above, I'm looking for a solution that w...
[ { "answer_id": 227292, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>Here are some notes on using a disconnected recordset.</p>\n\n<pre><code>Const adVarChar = 200 'the SQL datatype is va...
2008/10/22
[ "https://Stackoverflow.com/questions/226978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30473/" ]
What is the best way to sync up two lists each of which may contain items not in the other? As shown the lists are not sorted - although if necessary sorting them first would not be an issue. ``` List 1 = a,b,c,e List 2 = b,e,c,d ``` Using the lists above, I'm looking for a solution that will write out to a spreadsh...
Here are some notes on using a disconnected recordset. ``` Const adVarChar = 200 'the SQL datatype is varchar 'Create arrays fron the lists asL1 = Split("a,b,c,", ",") asL2 = Split("b,e,c,d", ",") 'Create a disconnected recordset Set rs = CreateObject("ADODB.RECORDSET") rs.Fields.append "Srt", adVarChar, 25 rs.Fiel...
226,980
<p>I have a Google Map that suddenly stopped working for no apparent reason (I hadn't touched the code for months, but the wrapper code from our CMS may have changed without Corporate telling me).</p> <p><a href="http://www.democratandchronicle.com/section/builder" rel="nofollow noreferrer">http://www.democratandchron...
[ { "answer_id": 227397, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<p>Try forcing JavaScript to make a new variable out of your HTML:</p>\n\n<pre><code>GEvent.addListener...
2008/10/22
[ "https://Stackoverflow.com/questions/226980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1902010/" ]
I have a Google Map that suddenly stopped working for no apparent reason (I hadn't touched the code for months, but the wrapper code from our CMS may have changed without Corporate telling me). <http://www.democratandchronicle.com/section/builder> (sorry about the nasty HTML outside the map, most of that comes from o...
This resolved itself. I suspect an update to the API broke something for a version or two.
226,981
<p>I have an <code>IList&lt;T&gt;</code> that I need to sort, and I would rather not copy the list if possible. I've noticed that <code>ArrayList</code> has an <code>Adapter</code> static method that wraps the passed list without copying it, but this takes an <code>IList</code> and I have an <code>IList&lt;T&gt;</code...
[ { "answer_id": 226992, "author": "Mike C.", "author_id": 3799, "author_profile": "https://Stackoverflow.com/users/3799", "pm_score": 5, "selected": true, "text": "<p>From the blog of Paul Fox, I recommend the post \"How to sort an IList\": <a href=\"http://foxsys.blogspot.com/2007/06/how...
2008/10/22
[ "https://Stackoverflow.com/questions/226981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9323/" ]
I have an `IList<T>` that I need to sort, and I would rather not copy the list if possible. I've noticed that `ArrayList` has an `Adapter` static method that wraps the passed list without copying it, but this takes an `IList` and I have an `IList<T>`. Is it safe to cast from a `System.Collections.Generic.IList<T>` to a...
From the blog of Paul Fox, I recommend the post "How to sort an IList": <http://foxsys.blogspot.com/2007/06/how-to-sort-generic-ilist.html> Just in case that blog goes away in the future, I'll copy the post here: --- **How to sort a generic IList** Update You can read and updated post about [sorting generic IList ...
227,007
<p>In Java, given a timestamp, how to reset the time part alone to 00:00:00 so that the timestamp represents the midnight of that particular day ?</p> <p>In T-SQL, this query will do to achieve the same, but I don't know how to do this in Java.</p> <p><code>SELECT CAST( FLOOR( CAST(GETDATE() AS FLOAT ) ) AS DATETIME)...
[ { "answer_id": 227044, "author": "thoroughly", "author_id": 8943, "author_profile": "https://Stackoverflow.com/users/8943", "pm_score": 3, "selected": false, "text": "<p>Assuming your \"timestamp\" is a java.util.Date, which is represented as the number of milliseconds since the beginnin...
2008/10/22
[ "https://Stackoverflow.com/questions/227007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
In Java, given a timestamp, how to reset the time part alone to 00:00:00 so that the timestamp represents the midnight of that particular day ? In T-SQL, this query will do to achieve the same, but I don't know how to do this in Java. `SELECT CAST( FLOOR( CAST(GETDATE() AS FLOAT ) ) AS DATETIME) AS 'DateTimeAtMidnigh...
You can go Date->Calendar->set->Date: ``` Date date = new Date(); // timestamp now Calendar cal = Calendar.getInstance(); // get calendar instance cal.setTime(date); // set cal to date cal.set(Calendar.HOUR_OF_DAY, 0); // set hour to midnight cal.set(Cale...
227,030
<p>I'm writing a class that renders some content in WPF, and I want to give the user control over how the content is rendered. The rendering is mostly stroking lines, so I decided to look to the System.Windows.Forms.Shapes.Line class to get an idea of what properties I might want to implement. This led me to implemen...
[ { "answer_id": 228704, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 3, "selected": true, "text": "<p>It is very safe and useful to borrow DPs... Read the <a href=\"http://www.drwpf.com/blog/Home/tabid/36/EntryID/20/Defa...
2008/10/22
[ "https://Stackoverflow.com/questions/227030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2547/" ]
I'm writing a class that renders some content in WPF, and I want to give the user control over how the content is rendered. The rendering is mostly stroking lines, so I decided to look to the System.Windows.Forms.Shapes.Line class to get an idea of what properties I might want to implement. This led me to implement mos...
It is very safe and useful to borrow DPs... Read the [following](http://www.drwpf.com/blog/Home/tabid/36/EntryID/20/Default.aspx) post by Dr WPF about the subject! Here is a few of the "tips" he provide: * You should always know what the owner class does with any property you borrow. * You should pay attention to def...
227,066
<p>I typically use extension methods very sparingly. When I do feel compelled to write an extension method, I sometimes want to overload the method. My question is, what are your thoughts on extension methods calling other extension methods? Bad practice? It feels wrong, but I can't really define why.</p> <p>For examp...
[ { "answer_id": 227103, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": false, "text": "<p>I personally don't see a problem with it, the second scenario I think feels more wrong....</p>\n" }, { ...
2008/10/22
[ "https://Stackoverflow.com/questions/227066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
I typically use extension methods very sparingly. When I do feel compelled to write an extension method, I sometimes want to overload the method. My question is, what are your thoughts on extension methods calling other extension methods? Bad practice? It feels wrong, but I can't really define why. For example, the se...
I would have to say that DRY controls here. Personally, I see nothing wrong with an extension method calling another extension method, especially if that other extension is contained within the same assembly. All-in-all, the method calls are just translated by the compiler from: ``` extended.ExtensionMethod(foo); ```...
227,078
<p>I'd love to create a "back" left-arrow-bezel button in a <code>UIToolbar</code>.</p> <p>As far as I can tell, the only way to get one of these is to leave <code>UINavigationController</code> at default settings and it uses one for the left bar item. But there's no way I can find to create one as a <code>UIBarButton...
[ { "answer_id": 227135, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 0, "selected": false, "text": "<p>Well, you don't have to have a different button for every size, you can use <code>[UIImage stretchableImageWithLeft...
2008/10/22
[ "https://Stackoverflow.com/questions/227078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30480/" ]
I'd love to create a "back" left-arrow-bezel button in a `UIToolbar`. As far as I can tell, the only way to get one of these is to leave `UINavigationController` at default settings and it uses one for the left bar item. But there's no way I can find to create one as a `UIBarButtonItem`, so I can't make one in a stand...
I used the following psd that I derived from <http://www.teehanlax.com/blog/?p=447> <http://www.chrisandtennille.com/pictures/backbutton.psd> I then just created a custom UIView that I use in the customView property of the toolbar item. Works well for me. --- *Edit:* [As pointed out by *PrairieHippo*](https://stac...
227,081
<p>I have ListView with Grouping Items. Grouping uses custom GroupStyle (Expander). I would like to have check box which will Expand and collapse all groups when. It works fine untill I click manually on the group header and expand or collapse that group. After clicking that particular group stops to respond on che...
[ { "answer_id": 227580, "author": "justin.m.chase", "author_id": 12958, "author_profile": "https://Stackoverflow.com/users/12958", "pm_score": 0, "selected": false, "text": "<p>It looks like the binding is broken since it's set to be OneWay with the checkbox, then if you click any of the ...
2008/10/22
[ "https://Stackoverflow.com/questions/227081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30038/" ]
I have ListView with Grouping Items. Grouping uses custom GroupStyle (Expander). I would like to have check box which will Expand and collapse all groups when. It works fine untill I click manually on the group header and expand or collapse that group. After clicking that particular group stops to respond on check box ...
I found solution for the problem. What needs to be done is specify Mode=TwoWay and UpdateSourceTrigger=Explicit, so this way it is not breaking Binding and everything works fine. Bellow is an example of working code. ``` <Window xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://...
227,083
<p>I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from i...
[ { "answer_id": 227123, "author": "mdb", "author_id": 8562, "author_profile": "https://Stackoverflow.com/users/8562", "pm_score": 5, "selected": true, "text": "<p>\"Copying bytes of memory\" is something that .NET isn't particularly suited for (and VB.NET even less so). So, unless switchi...
2008/10/22
[ "https://Stackoverflow.com/questions/227083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1862/" ]
I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from it's ...
"Copying bytes of memory" is something that .NET isn't particularly suited for (and VB.NET even less so). So, unless switching to C is an option for you, a function call is pretty much unavoidable for this. BitConverter is a well-thought-out, tested function. Of course, you can avoid it by doing something like (in C#)...
227,101
<p>I have somewhat of a staging server on the public internet running copies of the production code for a few websites. I'd really not like it if the staging sites get indexed. </p> <p>Is there a way I can modify my httpd.conf on the staging server to block search engine crawlers? </p> <p>Changing the robots.txt wo...
[ { "answer_id": 227119, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<p>Try <a href=\"http://www.evolt.org/article/Using_Apache_to_stop_bad_robots/18/15126/\" rel=\"nofollow noreferrer\">Using A...
2008/10/22
[ "https://Stackoverflow.com/questions/227101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24988/" ]
I have somewhat of a staging server on the public internet running copies of the production code for a few websites. I'd really not like it if the staging sites get indexed. Is there a way I can modify my httpd.conf on the staging server to block search engine crawlers? Changing the robots.txt wouldn't really work ...
Create a robots.txt file with the following contents: ``` User-agent: * Disallow: / ``` Put that file somewhere on your staging server; your directory root is a great place for it (e.g. `/var/www/html/robots.txt`). Add the following to your httpd.conf file: ``` # Exclude all robots <Location "/robots.txt"> Set...
227,121
<p>Is there a way to cast a user control as a specific user control so I have access to it's public properties? Basicly I'm foreaching through a placeholder's controls collection and I'm trying to access the user control's public properties.</p> <pre><code>foreach(UserControl uc in plhMediaBuys.Controls) { uc.Pulb...
[ { "answer_id": 227127, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 3, "selected": false, "text": "<pre><code>foreach(UserControl uc in plhMediaBuys.Controls)\n{\n if (uc is MySpecificType)\n {\n return (uc as MySpecific...
2008/10/22
[ "https://Stackoverflow.com/questions/227121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18785/" ]
Is there a way to cast a user control as a specific user control so I have access to it's public properties? Basicly I'm foreaching through a placeholder's controls collection and I'm trying to access the user control's public properties. ``` foreach(UserControl uc in plhMediaBuys.Controls) { uc.PulblicPropertyIWa...
``` foreach(UserControl uc in plhMediaBuys.Controls) { MyControl c = uc as MyControl; if (c != null) { c.PublicPropertyIWantAccessTo; } } ```
227,129
<p>I am trying to dynamically load the contents of a div tag with a .cfm page that contains a cfchart in png format. When the user clicks on a link, I am using the load function to put the .cfm page into the div.</p> <pre><code>$("#bank").bind("click", function(){ $("#chartx").load("bank.cfm"); }); </code></pre> ...
[ { "answer_id": 227178, "author": "Wyatt", "author_id": 26626, "author_profile": "https://Stackoverflow.com/users/26626", "pm_score": 0, "selected": false, "text": "<p>Have you tried jQuery.get? Maybe something like:</p>\n\n<pre><code>$(\"#bank\").bind(\"click\", function(){\n $.get(\"...
2008/10/22
[ "https://Stackoverflow.com/questions/227129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30485/" ]
I am trying to dynamically load the contents of a div tag with a .cfm page that contains a cfchart in png format. When the user clicks on a link, I am using the load function to put the .cfm page into the div. ``` $("#bank").bind("click", function(){ $("#chartx").load("bank.cfm"); }); ``` I can get this to come ...
Weirdest thing, but the cfdebug information in the classic style appended on the page is what causes it to break.
227,132
<p>Is it possible to use the asp templating engine (With the partial code-behind class, dynamic &lt;% ... %> blocks and such) to generate non HTML? I want to have a clean and maintainable way to generate code dynamically. (Specifically, I want to generate LaTeX code populated with values from a database.) </p> <p>Curr...
[ { "answer_id": 227154, "author": "Jason Z", "author_id": 2470, "author_profile": "https://Stackoverflow.com/users/2470", "pm_score": 0, "selected": false, "text": "<p>I don't see why not. Someone I knew at a former job created a database wrapper generator using ASP.NET pages and the rep...
2008/10/22
[ "https://Stackoverflow.com/questions/227132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26626/" ]
Is it possible to use the asp templating engine (With the partial code-behind class, dynamic <% ... %> blocks and such) to generate non HTML? I want to have a clean and maintainable way to generate code dynamically. (Specifically, I want to generate LaTeX code populated with values from a database.) Currently my LaTe...
The T4 templating that comes with Visual Studio 2008 natively or with Visual Studio 2005 SDK, you can pretty much generate anything you want. You can have more info on the following links: * [Scott Hanselman's Blog](https://www.hanselman.com/blog/t4-text-template-transformation-toolkit-code-generation-best-kept-visua...
227,140
<p>I have need to write an application which uses a speech recognition engine -- either the built in vista one, or a third party one -- that can display a word or phrase, and recognise when the user reads it (or an approximation of it). I also need to be able to switch quickly between languages, without changing the l...
[ { "answer_id": 227162, "author": "Jorge Córdoba", "author_id": 2695, "author_profile": "https://Stackoverflow.com/users/2695", "pm_score": 3, "selected": false, "text": "<p>If the engine is what you're asking about then I've found (beware, I'm just listing, I haven't tried any of them):<...
2008/10/22
[ "https://Stackoverflow.com/questions/227140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6389/" ]
I have need to write an application which uses a speech recognition engine -- either the built in vista one, or a third party one -- that can display a word or phrase, and recognise when the user reads it (or an approximation of it). I also need to be able to switch quickly between languages, without changing the langu...
A similar question was asked on Joel on Software a while back. You can use the [System.Speech.Recognition](http://msdn.microsoft.com/en-us/library/system.speech.recognition.aspx) namespace to do this...with some limitations. Add System.Speech (should be in the GAC) to your project. Here's some sample code for a WinForm...
227,148
<p>I am a support engineer and our company's product allows XSLT transforms to customize outputs.</p> <p>I made a xsl transform for this purpose. It works well for source files of typical size (several 100k), but occasionally a really huge (10M) source file will come by. In such case, the output is not generated even ...
[ { "answer_id": 227197, "author": "Marco", "author_id": 30480, "author_profile": "https://Stackoverflow.com/users/30480", "pm_score": 3, "selected": false, "text": "<p>I'm not familiar with the .NET implementations, but there are a few things you can do in general to speed up processing o...
2008/10/22
[ "https://Stackoverflow.com/questions/227148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24233/" ]
I am a support engineer and our company's product allows XSLT transforms to customize outputs. I made a xsl transform for this purpose. It works well for source files of typical size (several 100k), but occasionally a really huge (10M) source file will come by. In such case, the output is not generated even if I let i...
> > To detect when to start a new section, I did this: > > > > ``` > <xsl:if test="@TheFirstCol>preceding-sibling::*[1]/@TheFirstCol" > > ``` > > Could this be causing a lot or re-iteration? > > > Definitely. The algorithm you've chosen is O(N2) and would be very slow with sufficient number of siblings, regar...
227,187
<p>I have a console application that require to use some code that need administrator level. I have read that I need to add a Manifest file myprogram.exe.manifest that look like that :</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt; &lt;assembly xmlns=&quot;urn...
[ { "answer_id": 259146, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 4, "selected": true, "text": "<p>You need to embed the UAC manifest as an embedded Win32 resource. See <a href=\"http://blogs.msdn.com/shawnfa/...
2008/10/22
[ "https://Stackoverflow.com/questions/227187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
I have a console application that require to use some code that need administrator level. I have read that I need to add a Manifest file myprogram.exe.manifest that look like that : ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <...
You need to embed the UAC manifest as an embedded Win32 resource. See [Adding a UAC Manifest to Managed Code](http://blogs.msdn.com/shawnfa/archive/2006/04/06/568563.aspx). In short, you use a Windows SDK command line tool to embed it into your executable. You can automate this as a post-build step by placing the fol...
227,208
<p>I am working on interactive SVG/AJAX interfaces where elements are created and repositioned on-the-fly by users. I'd like to support the ability for users to export their current view to a PNG image and/or an SVG document. I'd really like the SVG document to be as simple as possible (without a lot of nested transfor...
[ { "answer_id": 227754, "author": "savetheclocktower", "author_id": 25720, "author_profile": "https://Stackoverflow.com/users/25720", "pm_score": 4, "selected": false, "text": "<p>I'm assuming you need this to work only in browsers that support SVG.</p>\n\n<p>Firefox, Safari, and Opera pr...
2008/10/22
[ "https://Stackoverflow.com/questions/227208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30238/" ]
I am working on interactive SVG/AJAX interfaces where elements are created and repositioned on-the-fly by users. I'd like to support the ability for users to export their current view to a PNG image and/or an SVG document. I'd really like the SVG document to be as simple as possible (without a lot of nested transforms)...
I'm assuming you need this to work only in browsers that support SVG. Firefox, Safari, and Opera provide the non-standard `XMLSerializer` API, so you could do something like this: ``` var svg = document.getElementById('svg_root'); // or whatever you call it var serializer = new XMLSerializer(); var str = serializer.s...
227,210
<p>I've spent most of the day making what are basically some housekeeping changes to the codebase of one of our projects (replacing all <code>System.out.println()</code> calls with log4j).</p> <p>I'm kind of curious how many lines of code I've updated with this set of changes.</p> <p>Is there anyway with <code>cvs di...
[ { "answer_id": 227251, "author": "sanxiyn", "author_id": 18382, "author_profile": "https://Stackoverflow.com/users/18382", "pm_score": 2, "selected": false, "text": "<p>You can simply pipe output of cvs diff to diffstat.</p>\n" }, { "answer_id": 227296, "author": "Rob Wells",...
2008/10/22
[ "https://Stackoverflow.com/questions/227210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I've spent most of the day making what are basically some housekeeping changes to the codebase of one of our projects (replacing all `System.out.println()` calls with log4j). I'm kind of curious how many lines of code I've updated with this set of changes. Is there anyway with `cvs diff` or another command to get an ...
Filter out extra lines from the diff output and then count the lines. For example, grep only lines starting with < or > ``` cvs diff -b -B -R | egrep '^<|>' | wc -l ```
227,215
<p>What's the best performing way to convert a DataRowCollection instance to a DataRow[]?</p>
[ { "answer_id": 227269, "author": "Jared", "author_id": 7388, "author_profile": "https://Stackoverflow.com/users/7388", "pm_score": 3, "selected": false, "text": "<p>This is kind of obvious, but:</p>\n\n<p><code>DataRowCollection.CopyTo(DataRow[] array, Int32 offset)</code> ?</p>\n\n<p>It...
2008/10/22
[ "https://Stackoverflow.com/questions/227215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What's the best performing way to convert a DataRowCollection instance to a DataRow[]?
``` DataRow[] rows = dt.Select(); ``` Assuming you still have access to the datatable.
227,225
<p>So like most new .NET developers you start of passing DataSets everywhere and although things do the job it doesn't seem right. </p> <p>The next progression is usually to create entity objects that extend a DAL base class so you have i.e. </p> <pre><code>public class User : UserDAL { //User specific methods } ...
[ { "answer_id": 227256, "author": "Brian Hasden", "author_id": 28926, "author_profile": "https://Stackoverflow.com/users/28926", "pm_score": 2, "selected": true, "text": "<p>I came to the same conclusion. The load usually doesn't make sense in the entity because once you have an instance,...
2008/10/22
[ "https://Stackoverflow.com/questions/227225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425/" ]
So like most new .NET developers you start of passing DataSets everywhere and although things do the job it doesn't seem right. The next progression is usually to create entity objects that extend a DAL base class so you have i.e. ``` public class User : UserDAL { //User specific methods } public class UserDAL ...
I came to the same conclusion. The load usually doesn't make sense in the entity because once you have an instance, you're either creating a new entity or you've already got a loaded entity. I've been using entities with Save (create and update) and Delete for years now without any issues. That being said, it's usually...
227,282
<p>I'm working on a programming problem which boils down to a set of an equation and inequality:</p> <pre><code>x[0]*a[0] + x[1]*a[1] + ... x[n]*a[n] &gt;= D x[0]*b[0] + x[1]*b[1] + ... x[n]*b[n] = C </code></pre> <p>I want to solve for the values of <code>X</code> that will give the absolute minimum of <code>C</cod...
[ { "answer_id": 227306, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 2, "selected": false, "text": "<p>It looks like this is a <a href=\"http://en.wikipedia.org/wiki/Linear_programming\" rel=\"nofollow noreferrer\">linear...
2008/10/22
[ "https://Stackoverflow.com/questions/227282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1266/" ]
I'm working on a programming problem which boils down to a set of an equation and inequality: ``` x[0]*a[0] + x[1]*a[1] + ... x[n]*a[n] >= D x[0]*b[0] + x[1]*b[1] + ... x[n]*b[n] = C ``` I want to solve for the values of `X` that will give the absolute minimum of `C`, given the input `D` and lists and `A` and `B` c...
This looks like a [linear programming](http://en.wikipedia.org/wiki/Linear_programming) problem. The [Simplex algorithm](http://en.wikipedia.org/wiki/Simplex_algorithm) normally gives good results. It basically walks the boundaries of the subspace delimited by the inequalities, looking for the optimum. Think of it vis...
227,287
<p>I know how to find a method in java using a fixed string,</p> <pre><code>someClass.getMethod("foobar", argTypes); </code></pre> <p>but is there a way to use a regular expression rather than a fixed string to find a method on a given class? </p> <p>An example of the usage might be if I wanted to find a method that...
[ { "answer_id": 227300, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "<p>You should apply your regexp on <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredMethods()\"...
2008/10/22
[ "https://Stackoverflow.com/questions/227287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599/" ]
I know how to find a method in java using a fixed string, ``` someClass.getMethod("foobar", argTypes); ``` but is there a way to use a regular expression rather than a fixed string to find a method on a given class? An example of the usage might be if I wanted to find a method that was called either "foobar" or "f...
You should apply your regexp on [getDeclaredMethods](http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getDeclaredMethods())() reflection method (or GetMethods() if you want only the public ones). [Warning: both methods will throw a SecurityException if there is a security manager.] You apply it on each na...
227,288
<p><a href="http://developer.yahoo.com/yui/compressor/" rel="nofollow noreferrer">YUI Compressor</a> does not accept wildcard parameters, so I cannot run it like this: </p> <pre><code>C:&gt;java -jar yuicompressor.jar *.js </code></pre> <p>But I have over 500 files and would rather not have to create a batch file li...
[ { "answer_id": 227336, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 5, "selected": true, "text": "<p>I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dir...
2008/10/22
[ "https://Stackoverflow.com/questions/227288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28098/" ]
[YUI Compressor](http://developer.yahoo.com/yui/compressor/) does not accept wildcard parameters, so I cannot run it like this: ``` C:>java -jar yuicompressor.jar *.js ``` But I have over 500 files and would rather not have to create a batch file like this: ``` C:>java -jar yuicompressor.jar file1.js -o deploy\fil...
I might go for a makefile (I think it would probably be more maintainable long term), but if you want a quick-n-dirty Windows batch command something like the following should work: ``` for %%a in (*.js) do @java -jar yuicompressor.jar "%%a" -o "deploy\%%a" ```
227,305
<p>I am building up a view with various text and image elements.</p> <p>I want to display some text in the view with a blurry copy of the text behind it, but not just a text shadow.</p> <p>How do I apply Gaussian blurred text onto a UIImage or layer?</p>
[ { "answer_id": 228176, "author": "Colin Barrett", "author_id": 23106, "author_profile": "https://Stackoverflow.com/users/23106", "pm_score": 0, "selected": false, "text": "<p>On the desktop, no question, you'd use CoreImage to do this.</p>\n\n<p>On the phone though, I don't think there e...
2008/10/22
[ "https://Stackoverflow.com/questions/227305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30342/" ]
I am building up a view with various text and image elements. I want to display some text in the view with a blurry copy of the text behind it, but not just a text shadow. How do I apply Gaussian blurred text onto a UIImage or layer?
Take a look at Apple's GLImageProcessing iPhone sample. It does some blurring, among other things. The relevant code includes: ``` static void blur(V2fT2f *quad, float t) // t = 1 { GLint tex; V2fT2f tmpquad[4]; float offw = t / Input.wide; float offh = t / Input.high; int i; glGetIntegerv(GL...
227,312
<p>Currently we are using prototype and jQuery as our js frameworks. Right now, jQuery is set to $j() to prevent conflicts from prototype.</p> <p>In the past, we've used a lot of prototype's Element.down(), Element.next(), and Element.previous() to traverse the DOM. However, I need a simple way to retrieve the last ch...
[ { "answer_id": 227323, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 1, "selected": false, "text": "<p>Try this it has always worked for me in jQuery</p>\n\n<pre><code>var lastChild = $(\"#parent :last-child\");\n</code></p...
2008/10/22
[ "https://Stackoverflow.com/questions/227312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5203/" ]
Currently we are using prototype and jQuery as our js frameworks. Right now, jQuery is set to $j() to prevent conflicts from prototype. In the past, we've used a lot of prototype's Element.down(), Element.next(), and Element.previous() to traverse the DOM. However, I need a simple way to retrieve the last child elemen...
Guys, note that the selector functions return arrays of elements (not single elements), so you must adddress the element in the result array by index: [0]. Code in prototype ``` //if you only have the id of the parent var lastChild = $$("#parent :last-child")[0]; //or //if you have the actual DOM element var lastChi...
227,351
<p>I want to expose the functionality of an SAP program (transaction) as a BAPI. I need to call a report and supply range filters such that the GUI is bypassed.</p> <p>Does anyone have a working example of the SUBMIT ... WITH ... ABAP construct, or other suggestions on how to accomplish what I need to do?</p>
[ { "answer_id": 231587, "author": "Esti", "author_id": 25687, "author_profile": "https://Stackoverflow.com/users/25687", "pm_score": 2, "selected": false, "text": "<p>Here is a working example:</p>\n\n<pre><code>SUBMIT SAPF140 \n TO SAP-SPOOL \"optional\"\n S...
2008/10/22
[ "https://Stackoverflow.com/questions/227351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26652/" ]
I want to expose the functionality of an SAP program (transaction) as a BAPI. I need to call a report and supply range filters such that the GUI is bypassed. Does anyone have a working example of the SUBMIT ... WITH ... ABAP construct, or other suggestions on how to accomplish what I need to do?
Here is a working example: ``` SUBMIT SAPF140 TO SAP-SPOOL "optional" SPOOL PARAMETERS print_parameters "optional" WITHOUT SPOOL DYNPRO "optional (hides the spool pop-up)" VIA JOB jobname NUMBER l_number "optional" AND RETURN ...
227,357
<p>I have a master page, with a help link in the top menu. This link should contain the a dynamic bookmark from the current page, so that the user scrolls to the help for the page he is currently seeing.</p> <pre><code>&lt;a href="help.aspx#[NameOfCurentPage]"&gt;Help&lt;/a&gt; </code></pre> <p>How would you implemen...
[ { "answer_id": 227369, "author": "Kris", "author_id": 18565, "author_profile": "https://Stackoverflow.com/users/18565", "pm_score": 1, "selected": false, "text": "<p>i haven't written a line of c# in over three months but you could hook up an event in the masterpage (OnLoad) and set the ...
2008/10/22
[ "https://Stackoverflow.com/questions/227357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8547/" ]
I have a master page, with a help link in the top menu. This link should contain the a dynamic bookmark from the current page, so that the user scrolls to the help for the page he is currently seeing. ``` <a href="help.aspx#[NameOfCurentPage]">Help</a> ``` How would you implement this?
Another thing you could do is reference the master page through the content page itself. To make it easier on myself, I create a publicly accessible method in the master page itself: ``` Public Sub SetNavigationPage(ByVal LinkName As String) DirectCast(Me.FindControl(MenuName), HyperLink).NavigateUrl = "help.aspx#...
227,376
<p>I need to round a value up to the nearest multiple of 2.5.</p> <p>For example:<br> 6 --> 7.5<br> 7.6 --> 10<br> etc. </p> <p>This seems like the best way to do this?</p> <pre><code> Function RoundToIncrement(ByVal originalNumber As Decimal, ByVal increment As Decimal) As Decimal Dim num = Math.Round(o...
[ { "answer_id": 227384, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 6, "selected": true, "text": "<p>Divide the number by 2.5, round up to the nearest integer, then multiply the result by 2.5.</p>\n\n<p>You're close.</p>\n\n<...
2008/10/22
[ "https://Stackoverflow.com/questions/227376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I need to round a value up to the nearest multiple of 2.5. For example: 6 --> 7.5 7.6 --> 10 etc. This seems like the best way to do this? ``` Function RoundToIncrement(ByVal originalNumber As Decimal, ByVal increment As Decimal) As Decimal Dim num = Math.Round(originalNumber / increment, Midpo...
Divide the number by 2.5, round up to the nearest integer, then multiply the result by 2.5. You're close. ``` Function RoundToIncrement(ByVal orignialNumber As Decimal, ByVal increment As Decimal) As Decimal Return Math.Ceiling( orignialNumber / increment ) * increment End Function ``` Math.Ceiling will always ...
227,380
<p>Consider the following code:</p> <pre><code>abstract class SomeClassX&lt;T&gt; { // blah } class SomeClassY: SomeClassX&lt;int&gt; { // blah } class SomeClassZ: SomeClassX&lt;long&gt; { // blah } </code></pre> <p>I want a collection of SomeClassX&lt;T&gt;'s, however, this isn't possible since SomeClassX&lt...
[ { "answer_id": 227384, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 6, "selected": true, "text": "<p>Divide the number by 2.5, round up to the nearest integer, then multiply the result by 2.5.</p>\n\n<p>You're close.</p>\n\n<...
2008/10/22
[ "https://Stackoverflow.com/questions/227380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30521/" ]
Consider the following code: ``` abstract class SomeClassX<T> { // blah } class SomeClassY: SomeClassX<int> { // blah } class SomeClassZ: SomeClassX<long> { // blah } ``` I want a collection of SomeClassX<T>'s, however, this isn't possible since SomeClassX<int> != SomeClassX<long> and List<SomeClassX<>> isn'...
Divide the number by 2.5, round up to the nearest integer, then multiply the result by 2.5. You're close. ``` Function RoundToIncrement(ByVal orignialNumber As Decimal, ByVal increment As Decimal) As Decimal Return Math.Ceiling( orignialNumber / increment ) * increment End Function ``` Math.Ceiling will always ...
227,383
<p>How do I programmatically return the maximum of two integers without using any comparison operators and without using <code>if</code>, <code>else</code>, etc?</p>
[ { "answer_id": 227393, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 2, "selected": false, "text": "<p>return (a > b ? a : b);</p>\n\n<p>or</p>\n\n<pre><code>int max(int a, int b)\n{\n int x = (a - b) &gt;&gt; 3...
2008/10/22
[ "https://Stackoverflow.com/questions/227383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
How do I programmatically return the maximum of two integers without using any comparison operators and without using `if`, `else`, etc?
max: // Will put MAX(a,b) into a ``` a -= b; a &= (~a) >> 31; a += b; ``` And: int a, b; min: // Will put MIN(a,b) into a ``` a -= b; a &= a >> 31; a += b; ``` from [here](http://web.archive.org/web/20130821015554/http://bob.allegronetwork.com/prog/tricks.html).
227,417
<p>I've run across the following line in a VB6 application.</p> <pre><code>mobjParentWrkBk.ExcelWorkBook.Application.Selection.Insert Shift:=xlToRight </code></pre> <p>Unfortunately Google and other search engines have not been very useful as they seem to omit the := part. </p> <p>What would be a C# equivalent?</p>
[ { "answer_id": 227431, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 5, "selected": true, "text": "<p>This is Visual Basic syntax for optional named parameters. The <code>Insert</code> function has a parameter named <cod...
2008/10/22
[ "https://Stackoverflow.com/questions/227417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14177/" ]
I've run across the following line in a VB6 application. ``` mobjParentWrkBk.ExcelWorkBook.Application.Selection.Insert Shift:=xlToRight ``` Unfortunately Google and other search engines have not been very useful as they seem to omit the := part. What would be a C# equivalent?
This is Visual Basic syntax for optional named parameters. The `Insert` function has a parameter named `Shift`, which is being specified. C#, as far as I know, doesn't have an equivalent for optional named parameters. Instead, you'd need to call the `Insert` method, specifying `Type.Missing` for all parameters other t...
227,428
<p>I am planning a PHP application that needs to store date/times in an MSSQL database. (For the curious, it is a calendar application.) What is the preferred format to store this information?</p> <p>MSSQL has its own datetime data type, which works well in the database itself and is very readable. However, there aren...
[ { "answer_id": 227451, "author": "Kris", "author_id": 18565, "author_profile": "https://Stackoverflow.com/users/18565", "pm_score": 3, "selected": false, "text": "<p>I'd recommend the same as i do for all dates in any db engine, the db native type. (DATETIME)</p>\n\n<p>Just use \"YYYY-MM...
2008/10/22
[ "https://Stackoverflow.com/questions/227428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18986/" ]
I am planning a PHP application that needs to store date/times in an MSSQL database. (For the curious, it is a calendar application.) What is the preferred format to store this information? MSSQL has its own datetime data type, which works well in the database itself and is very readable. However, there aren't any MSS...
I would store the dates in the MS-SQL format to assist in using the date manipulation functions in T-SQL to their fullest. It's easier to write and read ``` SELECT * FROM Foo WHERE DateDiff(d,field1,now()) < 1 ``` Than to try and perform the equivalent operation by manipulating integers To convert a MsSQL date into...
227,430
<p>Here is my function (<strong>updated</strong>):</p> <pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length &gt; maxLength Then Strin...
[ { "answer_id": 227445, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": true, "text": "<p>Why not do this?</p>\n\n<pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String\n Return ...
2008/10/22
[ "https://Stackoverflow.com/questions/227430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
Here is my function (**updated**): ``` Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length > maxLength Then String.Format("{0}...{1}", URL.Subs...
Why not do this? ``` Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 29) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length > maxLength Then Return String.Format("{0}...{1}", URL.Substring(0, ma...
227,434
<p>I have an XML schema that includes multiple addresses:</p> <pre><code>&lt;xs:element name="personal_address" maxOccurs="1"&gt; &lt;!-- address fields go here --&gt; &lt;/xs:element&gt; &lt;xs:element name="business_address" maxOccurs="1"&gt; &lt;!-- address fields go here --&gt; &lt;/xs:element&gt; </code></pre...
[ { "answer_id": 227522, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": true, "text": "<p>I think you are on the right tracks. I think its more to do with XML namespaces. Try the following:</p>\n\n<pre><code>&lt;...
2008/10/22
[ "https://Stackoverflow.com/questions/227434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
I have an XML schema that includes multiple addresses: ``` <xs:element name="personal_address" maxOccurs="1"> <!-- address fields go here --> </xs:element> <xs:element name="business_address" maxOccurs="1"> <!-- address fields go here --> </xs:element> ``` Within each address element, I include a "US State" enum...
I think you are on the right tracks. I think its more to do with XML namespaces. Try the following: ``` <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/foo" xmlns:tns="http://www.example.org/foo" elementFormDefault="quali...
227,438
<p>I'm attempting to determine the row length in bytes of a table by executing the following stored procedure:</p> <pre><code>CREATE TABLE #tmp ( [ID] int, Column_name varchar(640), Type varchar(640), Computed varchar(640), Length int, Prec int, Scale int, Nullable varchar(640), TrimTrailing...
[ { "answer_id": 227463, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 0, "selected": false, "text": "<p>I can't help you with creating a temp table to store sp_help information, but I can help you with calculating row len...
2008/10/22
[ "https://Stackoverflow.com/questions/227438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21826/" ]
I'm attempting to determine the row length in bytes of a table by executing the following stored procedure: ``` CREATE TABLE #tmp ( [ID] int, Column_name varchar(640), Type varchar(640), Computed varchar(640), Length int, Prec int, Scale int, Nullable varchar(640), TrimTrailingBlanks varchar...
How doing it this way instead? ``` CREATE TABLE tblShowContig ( ObjectName CHAR (255), ObjectId INT, IndexName CHAR (255), IndexId INT, Lvl INT, CountPages INT, CountRows INT, MinRecSize INT, MaxRecSize INT, AvgRecSize INT, ForRecCount INT, Extents INT, ExtentSwitch...
227,440
<p>I have a Rails application that in the erb code, I use a select box. What I would like to do is reload the page passing the sort parameter. My controller already handles it, but I don't know how to reload the page with the selected value from my select box. Here is my code:</p> <pre><code>&lt;% @options = {:latest ...
[ { "answer_id": 227829, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 3, "selected": true, "text": "<p>Have you considered using an ajax call on your list box? If you have a method on your controller that returns just the ...
2008/10/22
[ "https://Stackoverflow.com/questions/227440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18642/" ]
I have a Rails application that in the erb code, I use a select box. What I would like to do is reload the page passing the sort parameter. My controller already handles it, but I don't know how to reload the page with the selected value from my select box. Here is my code: ``` <% @options = {:latest => 'lastest' , :a...
Have you considered using an ajax call on your list box? If you have a method on your controller that returns just the sorted list, based on sort parameter, then you could do: ``` <% @options = {:latest => 'lastest' , :alphabetical => 'alphabetical', :pricelow => 'price-low', :pricehigh =>'pricehigh'} %> <%= select_ta...
227,447
<p>When I use this code to output some XML I parsed (and modified) with <code>XmlParser</code></p> <pre><code>XmlParser parser = new XmlParser() def root = parser.parseText(feedUrl.toURL().text) def writer = new StringWriter() new XmlNodePrinter(new PrintWriter(writer)).print(root) println writer.toString() </code></p...
[ { "answer_id": 228593, "author": "Ted Naleid", "author_id": 8912, "author_profile": "https://Stackoverflow.com/users/8912", "pm_score": 2, "selected": true, "text": "<p>It looks like it's denormalizing the output and including the namespace context along with the nodes that actually need...
2008/10/22
[ "https://Stackoverflow.com/questions/227447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2031/" ]
When I use this code to output some XML I parsed (and modified) with `XmlParser` ``` XmlParser parser = new XmlParser() def root = parser.parseText(feedUrl.toURL().text) def writer = new StringWriter() new XmlNodePrinter(new PrintWriter(writer)).print(root) println writer.toString() ``` the namespace declarations on...
It looks like it's denormalizing the output and including the namespace context along with the nodes that actually need the namespace context. For example, the webpage for this question comes in with creativeCommons namespace embedded: ``` <feed xmlns="http://www.w3.org/2005/Atom" xmlns:creativeCommons="http://backen...
227,449
<p>I'm fairly new to JavaScript. </p> <p>Given a local machine's folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called.</p> <p>Thank you very much in advance.</p>
[ { "answer_id": 227458, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 1, "selected": false, "text": "<p>You cannot do this via Javascript in a browser as the JS doesn't have that kind of access to the file system fr...
2008/10/22
[ "https://Stackoverflow.com/questions/227449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm fairly new to JavaScript. Given a local machine's folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called. Thank you very much in advance.
Here is a little script to get you started with FileSystemObject in conjuction with JScript: ``` var fso = new ActiveXObject("Scripting.FileSystemObject"); var shell = new ActiveXObject("WScript.Shell"); var path = "%ProgramFiles%"; var programFiles = fso.GetFolder(shell.ExpandEnvironmentStrings(path)); var subFol...
227,457
<p>I'm writing a query to summarize some data. I have a flag in the table that is basically boolean, so I need some sums and counts based on one value of it, and then the same thing for the other value, like so:</p> <pre><code>select location ,count(*) ,sum(duration) from my.table where type = 'X' and locati...
[ { "answer_id": 227475, "author": "George Eadon", "author_id": 30530, "author_profile": "https://Stackoverflow.com/users/30530", "pm_score": 3, "selected": false, "text": "<p>Your example with the join doesn't make a lot of sense. You're doing a Cartesian product between A and B. Is this ...
2008/10/22
[ "https://Stackoverflow.com/questions/227457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13791/" ]
I'm writing a query to summarize some data. I have a flag in the table that is basically boolean, so I need some sums and counts based on one value of it, and then the same thing for the other value, like so: ``` select location ,count(*) ,sum(duration) from my.table where type = 'X' and location = @location ...
``` select location ,Sum(case when type = 'X' then 1 else 0 end) as xCount ,Sum(case when type = 'Y' then 1 else 0 end) as YCount ,Sum(case when type = 'X' then duration else 0 end) as xCountDuration ,Sum(case when type = 'Y' then duration else 0 end) as YCountDuration from my.table where location = @locat...
227,459
<p>How do I get the <a href="http://en.wikipedia.org/wiki/ASCII" rel="noreferrer">ASCII</a> value of a character as an <code>int</code> in Python?</p>
[ { "answer_id": 227466, "author": "Jacob Krall", "author_id": 3140, "author_profile": "https://Stackoverflow.com/users/3140", "pm_score": 6, "selected": false, "text": "<p>You are looking for:</p>\n\n<pre><code>ord()\n</code></pre>\n" }, { "answer_id": 227472, "author": "Matt ...
2008/10/22
[ "https://Stackoverflow.com/questions/227459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
How do I get the [ASCII](http://en.wikipedia.org/wiki/ASCII) value of a character as an `int` in Python?
From [here](http://mail.python.org/pipermail/python-win32/2005-April/003100.html): > > The function **`ord()`** gets the int value > of the char. And in case you want to > convert back after playing with the > number, function **`chr()`** does the trick. > > > ``` >>> ord('a') 97 >>> chr(97) 'a' >>> chr(ord('a') ...
227,461
<p>I want to do some basic filtering on a file. Read it, do processing, write it back. </p> <p>I'm not looking for "golfing", but want the simplest and most elegant method to achieve this. I came up with:</p> <pre><code>from __future__ import with_statement filename = "..." # or sys.argv... with open(filename) as f...
[ { "answer_id": 227721, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 2, "selected": false, "text": "<p>This seems to work:</p>\n\n<pre><code>with open(filename, \"r+\") as f:\n new_txt = process(f.read())\n ...
2008/10/22
[ "https://Stackoverflow.com/questions/227461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
I want to do some basic filtering on a file. Read it, do processing, write it back. I'm not looking for "golfing", but want the simplest and most elegant method to achieve this. I came up with: ``` from __future__ import with_statement filename = "..." # or sys.argv... with open(filename) as f: new_txt = # ......
Actually an easier way using fileinput is to use the inplace parameter: ``` import fileinput for line in fileinput.input (filenameToProcess, inplace=1): process (line) ``` If you use the inplace parameter it will redirect stdout to your file, so that if you do a print it will write back to your file. This examp...
227,470
<p>I have a search form on each of my pages. If I use form helper, it defaults to <code>$_POST</code>. I'd like the search term to show up in the URI:</p> <pre><code>http://example.com/search/KEYWORD </code></pre> <p>I've been on Google for about an hour, but to no avail. I've only found articles on how <code>$_GET</...
[ { "answer_id": 227494, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": -1, "selected": false, "text": "<p>I don't know much about CodeIgniter, but it's PHP, so shouldn't <code>$_GET</code> still be available to you? You co...
2008/10/22
[ "https://Stackoverflow.com/questions/227470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
I have a search form on each of my pages. If I use form helper, it defaults to `$_POST`. I'd like the search term to show up in the URI: ``` http://example.com/search/KEYWORD ``` I've been on Google for about an hour, but to no avail. I've only found articles on how `$_GET` is basically disabled, because of the nati...
There's a better fix if you're dealing with people without JS enabled. **View:** ``` <?php echo form_open('ad/pre_search');?> <input type="text" name="keyword" /> </form> ``` **Controller** ``` <?php function pre_search() { redirect('ad/search/.'$this->input->post('keyword')); } functi...
227,485
<p>I have a little demonstration below of a peculiar problem.</p> <pre><code>using System; using System.Windows.Forms; namespace WindowsApplication1 { public class TestForm : Form { private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; priv...
[ { "answer_id": 227520, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": -1, "selected": false, "text": "<p>Not sure if I understand the problem.\nBut, you might use textbox's resize event to capture the width change OR fo...
2008/10/22
[ "https://Stackoverflow.com/questions/227485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
I have a little demonstration below of a peculiar problem. ``` using System; using System.Windows.Forms; namespace WindowsApplication1 { public class TestForm : Form { private System.Windows.Forms.TabControl tabControl1; private System.Windows.Forms.TabPage tabPage1; private System.Win...
Firstly, thanks for the complete program - it made it *much* easier to work out what was going on! While the textbox isn't visible, it isn't resized. When you select tabPage1, the Selected event fires *before* the controls become visible and the textbox gets laid out again. Now, that's why it's happening - but what's...
227,486
<p>Does anyone know how to programmaticly find out where the java classloader actually loads the class from? </p> <p>I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a <a href="https://stackoverflow.com/questions/226280/eclipse-class-versi...
[ { "answer_id": 227492, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": -1, "selected": false, "text": "<p>Assuming that you're working with a class named <code>MyClass</code>, the following should work:</p>\n\n<pre><cod...
2008/10/22
[ "https://Stackoverflow.com/questions/227486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25920/" ]
Does anyone know how to programmaticly find out where the java classloader actually loads the class from? I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a [problem](https://stackoverflow.com/questions/226280/eclipse-class-version-bug "pro...
Here's an example: ``` package foo; public class Test { public static void main(String[] args) { ClassLoader loader = Test.class.getClassLoader(); System.out.println(loader.getResource("foo/Test.class")); } } ``` This printed out: ``` file:/C:/Users/Jon/Test/foo/Test.class ```
227,500
<p>I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this:</p> <pre><code>&lt;jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.website.PageBean" /&gt; &lt;c:set...
[ { "answer_id": 227511, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 2, "selected": false, "text": "<p>To access the property of a bean using EL you simply name the property (not invoke the method). So lets say y...
2008/10/22
[ "https://Stackoverflow.com/questions/227500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18265/" ]
I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this: ``` <jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.website.PageBean" /> <c:set var="pageDividers" val...
When using the dot operator for property access in JSTL, `${pageDividers.size}` (no **()** needed) results in a call to a method named `getSize()`. Since java.util.List offers a method called `size()` (rather than `getSize()`) you won't be able to access the list length by using that code. --- In order to access t...
227,519
<p>I am writing a tool to help students learn regular expressions. I will probably be writing it in Java.</p> <p>The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough.</p> <p>But I want to support several different regex "flav...
[ { "answer_id": 227534, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 1, "selected": false, "text": "<p>Alternatively, you could use <a href=\"http://jakarta.apache.org/oro/\" rel=\"nofollow noreferrer\">Jakarta ORO</a>?</p>\...
2008/10/22
[ "https://Stackoverflow.com/questions/227519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17312/" ]
I am writing a tool to help students learn regular expressions. I will probably be writing it in Java. The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough. But I want to support several different regex "flavors" such as: * ...
Alternatively, you could use [Jakarta ORO](http://jakarta.apache.org/oro/)? This supports the following regex 'flavors': * Perl5 compatible regular expressions * AWK-like regular expressions * glob expressions
227,552
<p>I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." </p> <p>I checked the line and the lines around it and everything seems fine-parentheses, ...
[ { "answer_id": 227561, "author": "Manu", "author_id": 2133, "author_profile": "https://Stackoverflow.com/users/2133", "pm_score": 3, "selected": false, "text": "<p>Look for a string which contains an unescaped single qoute that may be inserted by some server side code.</p>\n" }, { ...
2008/10/22
[ "https://Stackoverflow.com/questions/227552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1227001/" ]
I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal." I checked the line and the lines around it and everything seems fine-parentheses, braces, an...
Most browsers seem to have problems with code like this: ``` var foo = "</script>"; ``` In Firefox, Opera and IE8 this results in an unterminated string literal error. Can be pretty nasty when serializing html code which includes scripts.
227,575
<p>Here is a snippet of the code :</p> <pre><code>HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(request.RawUrl); WebRequest.DefaultWebProxy = null;//Ensure that we will not loop by going again in the proxy HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); string charSet = response.Ch...
[ { "answer_id": 227598, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>Firstly, the easier way of writing that code is to use a StreamReader and ReadToEnd:</p>\n\n<pre><code>HttpWebRequest ...
2008/10/22
[ "https://Stackoverflow.com/questions/227575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
Here is a snippet of the code : ``` HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(request.RawUrl); WebRequest.DefaultWebProxy = null;//Ensure that we will not loop by going again in the proxy HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); string charSet = response.CharacterSet; E...
Firstly, the easier way of writing that code is to use a StreamReader and ReadToEnd: ``` HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(myURL); using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse()) { using (Stream resStream = response.GetResponseStream()) { StreamR...
227,581
<p>I have a WPF app that makes use of a Winforms User Control that I have created using C++/CLI. When my app goes to parse the XAML for my main window, it throws an exception. The information appears to be somewhat abbreviated, but it says:</p> <pre><code>A first chance exception of type 'System.Windows.Markup.XamlPar...
[ { "answer_id": 229060, "author": "EFrank", "author_id": 28572, "author_profile": "https://Stackoverflow.com/users/28572", "pm_score": 4, "selected": true, "text": "<p>I have experienced problems like that (but not with the exact same error message). It seems as if WPF cannot instantiate ...
2008/10/22
[ "https://Stackoverflow.com/questions/227581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
I have a WPF app that makes use of a Winforms User Control that I have created using C++/CLI. When my app goes to parse the XAML for my main window, it throws an exception. The information appears to be somewhat abbreviated, but it says: ``` A first chance exception of type 'System.Windows.Markup.XamlParseException' o...
I have experienced problems like that (but not with the exact same error message). It seems as if WPF cannot instantiate your Winforms User Control. The challenge is to find out why. Here are my suggestions that you could try: 1. Check if you have enabled unmanaged debugging (in Project Properties -> Debug) 2. Find o...
227,590
<p>For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at <pre> [[UIDevice mainDevice] uniqueIdentifier]<br> and [[NSUserDefaults standardDefaults] stringForKey:@"SBFormattedPhoneNu...
[ { "answer_id": 227606, "author": "Niniki", "author_id": 4155, "author_profile": "https://Stackoverflow.com/users/4155", "pm_score": 0, "selected": false, "text": "<p>Haven't done iphone work, but how about taking a hash of something unique to the phone ... oh, say the phone number?</p>\n...
2008/10/22
[ "https://Stackoverflow.com/questions/227590", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30541/" ]
For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I'd like to send some unique phone id. Looked at ``` [[UIDevice mainDevice] uniqueIdentifier] and [[NSUserDefaults standardDefaults] stringForKey:@"SBFormattedPhoneNumber"]...
What errors are you getting? `[[UIDevice currentDevice] uniqueIdentifier]` (*edited to fix API, thanks Martin!*) is the officially recommended way of doing this.
227,596
<p>This has been bugging me, I can't get my head around it. I will use the foodstuffs analogy to try and simplify my probelm.</p> <p>1000 members of the public where asked to pick a variety from each of 13 categories of footstuff. These selections were then stored in a mysql database against their name.</p> <pre><cod...
[ { "answer_id": 227779, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>partial answer:</p>\n\n<ul>\n<li>compose a linear set of selections by sorting and concatenating</li>\n<li>comparing then b...
2008/10/22
[ "https://Stackoverflow.com/questions/227596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This has been bugging me, I can't get my head around it. I will use the foodstuffs analogy to try and simplify my probelm. 1000 members of the public where asked to pick a variety from each of 13 categories of footstuff. These selections were then stored in a mysql database against their name. ``` e.g. billy mar...
Assuming you have a simple layout, then you would have something like this (I'll restrict myself to three of the categories): ``` PersonId What_Milk What_Bread What_Cheese 1 Semi Wheat Swiss 2 Skimmed Rolls French 3 Soy Brown Smelly 4 Low Fat Whea...
227,608
<p>Is there a simple way to parse a date that may be in MM/DD/yyyy, or M/D/yyyy, or some combination? i.e. the zero is optional before a single digit day or month.</p> <p>To do it manually, one could use:</p> <pre><code>String[] dateFields = dateString.split("/"); int month = Integer.parseInt(dateFields[0]); int day ...
[ { "answer_id": 227625, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 4, "selected": false, "text": "<p>Yep, use setLenient:</p>\n\n<pre><code>DateFormat df = new SimpleDateFormat(\"MM/dd/yyyy\");\ndf.setLenient(true);\nSyste...
2008/10/22
[ "https://Stackoverflow.com/questions/227608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2046/" ]
Is there a simple way to parse a date that may be in MM/DD/yyyy, or M/D/yyyy, or some combination? i.e. the zero is optional before a single digit day or month. To do it manually, one could use: ``` String[] dateFields = dateString.split("/"); int month = Integer.parseInt(dateFields[0]); int day = Integer.parseInt(da...
Looks like my problem was using "MM/DD/yyyy" when I should have used "MM/dd/yyyy". Uppercase **D** is "Day in year", while lowercase **d** is "Day in month". ``` new SimpleDateFormat("MM/dd/yyyy").parse(dateString); ``` Does the job. Also, "M/d/y" works interchangeably. A closer reading of the [SimpleDateFormat API ...
227,612
<p>I am inserting a column in a DataGridView programmatically (i.e., not bound to any data tables/databases) as follows:</p> <pre><code>int lastIndex = m_DGV.Columns.Count - 1; // Count = 4 in this case DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)m_DGV.Columns[lastIndex]; m_DGV.Columns.RemoveAt(lastInd...
[ { "answer_id": 227683, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": true, "text": "<p>I suspect this is because the order of the columns in the DataGridView do not necessarily dictate the display order, thoug...
2008/10/22
[ "https://Stackoverflow.com/questions/227612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22252/" ]
I am inserting a column in a DataGridView programmatically (i.e., not bound to any data tables/databases) as follows: ``` int lastIndex = m_DGV.Columns.Count - 1; // Count = 4 in this case DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)m_DGV.Columns[lastIndex]; m_DGV.Columns.RemoveAt(lastIndex); m_DGV.Col...
I suspect this is because the order of the columns in the DataGridView do not necessarily dictate the display order, though without explicitly being assigned by default the order of the columns dictate the DisplayIndex property values. That is why there is a DisplayIndex property, so you may add columns to the collecti...
227,613
<p>How do I copy a directory including sub directories excluding files or directories that match a certain regex on a Windows system?</p>
[ { "answer_id": 227636, "author": "Niniki", "author_id": 4155, "author_profile": "https://Stackoverflow.com/users/4155", "pm_score": 1, "selected": false, "text": "<p>I don't know how to do an exclusion with a copy, but you could work something up along the lines of:</p>\n\n<pre><code>ls ...
2008/10/22
[ "https://Stackoverflow.com/questions/227613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
How do I copy a directory including sub directories excluding files or directories that match a certain regex on a Windows system?
I'd do something like this: ``` use File::Copy; sub copy_recursively { my ($from_dir, $to_dir, $regex) = @_; opendir my($dh), $from_dir or die "Could not open dir '$from_dir': $!"; for my $entry (readdir $dh) { next if $entry =~ /$regex/; my $source = "$from_dir/$entry"; my $destina...
227,624
<p>I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously?</p>
[ { "answer_id": 227638, "author": "Haacked", "author_id": 598, "author_profile": "https://Stackoverflow.com/users/598", "pm_score": 10, "selected": true, "text": "<p>In your action method, return Json(object) to return JSON to your page.</p>\n\n<pre><code>public ActionResult SomeActionMet...
2008/10/22
[ "https://Stackoverflow.com/questions/227624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30544/" ]
I am trying to create controller actions which will return either JSON or partial html depending upon a parameter. What is the best way to get the result returned to an MVC page asynchronously?
In your action method, return Json(object) to return JSON to your page. ``` public ActionResult SomeActionMethod() { return Json(new {foo="bar", baz="Blech"}); } ``` Then just call the action method using Ajax. You could use one of the helper methods from the ViewPage such as ``` <%= Ajax.ActionLink("SomeActionM...
227,627
<p>I have this 'simplified' fortran code</p> <pre><code>real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(J,I) = B(J,I) end do end do </code></pre> <p>One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses d...
[ { "answer_id": 227649, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "<p>Are you sure your FORTRAN guys did things right? </p>\n\n<p>The code snippet you originally posted is already acc...
2008/10/22
[ "https://Stackoverflow.com/questions/227627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
I have this 'simplified' fortran code ``` real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(J,I) = B(J,I) end do end do ``` One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses data efficiently in row ord...
In C, multi-dimensional arrays work like this: ``` #define array_length(a) (sizeof(a)/sizeof((a)[0])) float a[100][200]; a[x][y] == ((float *)a)[array_length(a[0])*x + y]; ``` In other words, they're really flat arrays and `[][]` is just syntactic sugar. Suppose you do this: ``` #define at(a, i, j) ((typeof(**(a))...
227,634
<p>I am copying a repository by using svnsync and am receiving this error on the same revision every time.</p> <blockquote> <p>Transmitting file data ...svnsync: REPORT of '<a href="https://svn1.avlux.net/xxxxxx.net" rel="nofollow noreferrer">https://svn1.avlux.net/xxxxxx.net</a>': Could not read response body: Secu...
[ { "answer_id": 228427, "author": "Mike Deck", "author_id": 1247, "author_profile": "https://Stackoverflow.com/users/1247", "pm_score": 3, "selected": true, "text": "<p>Are you just trying to copy the repo once or are you trying to setup an ongoing mirroring scheme?</p>\n\n<p>If it's the ...
2008/10/22
[ "https://Stackoverflow.com/questions/227634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5233/" ]
I am copying a repository by using svnsync and am receiving this error on the same revision every time. > > Transmitting file data ...svnsync: REPORT of '<https://svn1.avlux.net/xxxxxx.net>': Could not read response body: Secure connection truncated <https://svn1.avlux.net>) > > > It is a large revision and I don...
Are you just trying to copy the repo once or are you trying to setup an ongoing mirroring scheme? If it's the former you could let sync go until it fails, then do a diff between the revision it failed on and the previous revision and output that to a file. So if the rev that failed was 135 it would be something like t...
227,667
<p>What type of exception is caught by the beanshell catch(ex): Exception or Throwable?.</p> <p>Example:</p> <pre><code>try { .... } catch (ex) { } </code></pre>
[ { "answer_id": 227911, "author": "Bill K", "author_id": 12943, "author_profile": "https://Stackoverflow.com/users/12943", "pm_score": 2, "selected": false, "text": "<p>Throwable is a superclass (essentially) of Exception--anything that Exception catches will also be caught by Throwable. ...
2008/10/22
[ "https://Stackoverflow.com/questions/227667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What type of exception is caught by the beanshell catch(ex): Exception or Throwable?. Example: ``` try { .... } catch (ex) { } ```
That loosely typed catch will catch everything "[Throwable](http://java.sun.com/javase/6/docs/api/java/lang/Throwable.html)." That will include [Errors](http://java.sun.com/javase/6/docs/api/java/lang/Error.html), [Exceptions](http://java.sun.com/javase/6/docs/api/java/lang/Exception.html) and their myriad children. Yo...
227,674
<p>I've got a few very short audio clips (less than a second long) to be played on various events (button hover, click, etc). However, there is usually a significant lag between the action and the actual playing of the sound. I have tried both embedding the sound in the .swf, and loading it externally at the start, b...
[ { "answer_id": 228384, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 2, "selected": false, "text": "<p>Well, my first-blush answer is that when I've done things like this, normally I find that sound files have a certain am...
2008/10/22
[ "https://Stackoverflow.com/questions/227674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9330/" ]
I've got a few very short audio clips (less than a second long) to be played on various events (button hover, click, etc). However, there is usually a significant lag between the action and the actual playing of the sound. I have tried both embedding the sound in the .swf, and loading it externally at the start, but bo...
It's a little thing but: ``` function playSound( name:String ):void { for( var nameSrc:String in soundArray ) { if( name == nameSrc ) { var channel:SoundChannel = soundArray[ name ].play(); return; } } } ``` Should be: ``` function playSound(name:String):void { if(so...
227,701
<p>I can't for the life of me find a form that doesn't email the results that you submit.</p> <p>I'm looking to find a form that I can have users enter simple data that i can then spit back out at them in different arrangements. If they submit First and Last, I'll spit out, amongst other things, FirstLast@domain.com. ...
[ { "answer_id": 227707, "author": "Leigh Caldwell", "author_id": 3267, "author_profile": "https://Stackoverflow.com/users/3267", "pm_score": 0, "selected": false, "text": "<p>What language/platform/environment are you working in?</p>\n\n<p>I guess you might be looking for a hosted script ...
2008/10/22
[ "https://Stackoverflow.com/questions/227701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I can't for the life of me find a form that doesn't email the results that you submit. I'm looking to find a form that I can have users enter simple data that i can then spit back out at them in different arrangements. If they submit First and Last, I'll spit out, amongst other things, FirstLast@domain.com. I'm willin...
Form: ``` <form action="process.php" method="post"> First: <input type="text" name="first" /> Last: <input type="text" name="last" /> <input type="submit" /> </form> ``` Next page: ``` <?php $first = $_POST['first']; $last = $_POST['last'] echo $first . "." . $last . "@domain.com"; ?> ``` See <http...
227,708
<p>I would like to apply some logic to a page containing a CheckBoxList control when the user checks or unchecks individual checkbox items. Say, for instance to dynamically show or hide a related control.</p> <p>I came up with a way using ASP.Net 2.0 callback mechanism (AJAX) with a combination of client-side Javascri...
[ { "answer_id": 228448, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>I'd do a couple of things. One, I'd figure out a way to pass the value that needs to be passed back to the client-si...
2008/10/22
[ "https://Stackoverflow.com/questions/227708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18865/" ]
I would like to apply some logic to a page containing a CheckBoxList control when the user checks or unchecks individual checkbox items. Say, for instance to dynamically show or hide a related control. I came up with a way using ASP.Net 2.0 callback mechanism (AJAX) with a combination of client-side Javascript and ser...
I'd do a couple of things. One, I'd figure out a way to pass the value that needs to be passed back to the client-side onclick handler. Depending on how you are populating your CheckBoxList, this might be as simple as adding an "onclick" attribute to the ListItem for that checkbox that calls your function with the same...
227,711
<p>I found <a href="http://www.jenitennison.com/xslt/grouping/muenchian.html" rel="noreferrer">this page</a> describing the Muenchian method, but I think I'm applying it wrong.</p> <p>Consider that this would return a set of ages:</p> <pre><code>/doc/class/person/descriptive[(@name='age')]/value </code></pre> <block...
[ { "answer_id": 227765, "author": "JacobE", "author_id": 30056, "author_profile": "https://Stackoverflow.com/users/30056", "pm_score": 1, "selected": false, "text": "<p>Aren't you missing a reference to 'descriptive' right after the preceding-value? Some thing like the following:</p>\n\n<...
2008/10/22
[ "https://Stackoverflow.com/questions/227711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/525/" ]
I found [this page](http://www.jenitennison.com/xslt/grouping/muenchian.html) describing the Muenchian method, but I think I'm applying it wrong. Consider that this would return a set of ages: ``` /doc/class/person/descriptive[(@name='age')]/value ``` > > 1..2..2..2..3..3..4..7 > > > But I would like a nodeset...
Here's an example: ``` <root> <item type='test'>A</item> <item type='test'>B</item> <item type='test'>C</item> <item type='test'>A</item> <item type='other'>A</item> <item type='test'>B</item> <item type='other'>D</item> <item type=''>A</item> </root> ``` And the XPath: ``` //precedi...
227,729
<p>I am a self taught vb6 programmer who uses DAO. Below is an example of a typical piece of code that I could churn out:</p> <pre><code>Sub cmdMultiplier_Click() 'Button on form, user interface ' dim Rec1 as recordset dim strSQL as string strSQL = "select * from tblCustomers where ID = " &amp; CurrentCustome...
[ { "answer_id": 227764, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>What is the purpose of the button?</p>\n\n<p>My first steps would be:</p>\n\n<ul>\n<li>extract the part accessing the datab...
2008/10/22
[ "https://Stackoverflow.com/questions/227729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6164/" ]
I am a self taught vb6 programmer who uses DAO. Below is an example of a typical piece of code that I could churn out: ``` Sub cmdMultiplier_Click() 'Button on form, user interface ' dim Rec1 as recordset dim strSQL as string strSQL = "select * from tblCustomers where ID = " & CurrentCustomerID 'inline SQL '...
a trivial example, yes, but with all the basic elements - they just belong in 3 different classes (see below). The main reason for this is the "separation of concerns" principle, i.e. the GUI is only concerned with GUI things, the Biz Logic layer is only concerned with the business rules, and the data-access layer is o...
227,731
<p>I need to do some large integer math. Are there any classes or structs out there that represent a 128-bit integer and implement all of the usual operators?</p> <p>BTW, I realize that <code>decimal</code> can be used to represent a 96-bit int.</p>
[ { "answer_id": 227757, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "<p>No, there's nothing in .NET &lt;= 3.5. I'm hoping/expecting that <a href=\"https://web.archive.org/web/20070120081853...
2008/10/22
[ "https://Stackoverflow.com/questions/227731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
I need to do some large integer math. Are there any classes or structs out there that represent a 128-bit integer and implement all of the usual operators? BTW, I realize that `decimal` can be used to represent a 96-bit int.
**It's here in [System.Numerics](https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger?view=net-6.0)**. "The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds." ``` var i = System.Numerics.BigInteger.Parse("10000000000...
227,762
<p>I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building.</p> <p>The processor is the AMD186ES. I am not working with the OS - just baremetal stuff. I need to generate real-mode 16-bit ...
[ { "answer_id": 227786, "author": "Simon Howard", "author_id": 24806, "author_profile": "https://Stackoverflow.com/users/24806", "pm_score": 4, "selected": false, "text": "<p>Your best bet is probably <a href=\"http://www.openwatcom.org/index.php/Main_Page\" rel=\"noreferrer\">OpenWatcom<...
2008/10/22
[ "https://Stackoverflow.com/questions/227762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
I am working on an embedded systems project and have run into an issue of the compiler being programatically embedded in the Paradigm C++ IDE. I would like to be able to automate building. The processor is the AMD186ES. I am not working with the OS - just baremetal stuff. I need to generate real-mode 16-bit 8086 machi...
I am currently using gnu `as` (part of binutils and the assembler used for gcc) and I have successfully been assembling 16bit assembly code with the following: ``` as <file> ld --oformat binary -Ttext 0x0 -e start <file> ``` with my assembly files starting out with: ``` .code16 .globl start .text start: ``` since...
227,775
<p>Let's say I have a class in my web app called class "Foo". It has an initialise() method that is called when the bean is created using Spring. The initialise() method then tries to load an external service and assign it to a field. If the service could not be contacted, the field will be set to null. </p> <pre>...
[ { "answer_id": 227812, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 0, "selected": false, "text": "<p>Yes, you will have a sync problem.</p>\n\n<p>Lets assume you have single servlet:</p>\n\n<pre><code>public class FooServl...
2008/10/22
[ "https://Stackoverflow.com/questions/227775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30563/" ]
Let's say I have a class in my web app called class "Foo". It has an initialise() method that is called when the bean is created using Spring. The initialise() method then tries to load an external service and assign it to a field. If the service could not be contacted, the field will be set to null. ``` private Serv...
*toolkit*'s answer is correct. To solve the problem, just declare your Foo's initialise() method to be synchronized. You could refactor Foo as: ``` private Service service; public synchronized void initialise() { if (service == null) { // load external service // set field to the loaded service if...
227,790
<p>So I'm teaching myself Python, and I'm having an issue with lists. I want to pass my function a list and pop items off it while retaining the original list. How do I make python "instance" the passed list rather that passing a pointer to the original one?</p> <p>Example:</p> <pre><code>def burninate(b): c = []...
[ { "answer_id": 227802, "author": "mhawke", "author_id": 21945, "author_profile": "https://Stackoverflow.com/users/21945", "pm_score": 3, "selected": false, "text": "<p>You can call <code>burninate()</code> with a copy of the list like this:</p>\n\n<p><code>d = burninate(a[:])</code></p>\...
2008/10/22
[ "https://Stackoverflow.com/questions/227790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5625/" ]
So I'm teaching myself Python, and I'm having an issue with lists. I want to pass my function a list and pop items off it while retaining the original list. How do I make python "instance" the passed list rather that passing a pointer to the original one? Example: ``` def burninate(b): c = [] for i in range(3...
As other answers have suggested, you can provide your function with a copy of the list. As an alternative, your function could take a copy of the argument: ``` def burninate(b): c = [] b = list(b) for i in range(3): c.append(b.pop()) return c ``` Basically, you need to be clear in your mind ...
227,807
<p>I have a Rails app that sets a cookie and does a redirect to another server once the user is logged in. However, the cookie that the Rails app sets isn't seen by the server for some reason. I've tried setting http_only to false but I still can't even see the cookie unless the domain is the same as my Rails app. Here...
[ { "answer_id": 227878, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 4, "selected": true, "text": "<p>What are the redirecting and redirected-to servers? You can only set ‘domain’ to the current hostname or a parent domain...
2008/10/22
[ "https://Stackoverflow.com/questions/227807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
I have a Rails app that sets a cookie and does a redirect to another server once the user is logged in. However, the cookie that the Rails app sets isn't seen by the server for some reason. I've tried setting http\_only to false but I still can't even see the cookie unless the domain is the same as my Rails app. Here's...
What are the redirecting and redirected-to servers? You can only set ‘domain’ to the current hostname or a parent domain, so if you're on a.example.com and you're redirecting to b.example.com, you have to set ‘domain’ to .example.com, *not* b.example.com as implied in the code snippet. (And open domains like the .com ...
227,820
<p>I was just writing some quick code and noticed this complier error </p> <blockquote> <p>Using the iteration variable in a lambda expression may have unexpected results.<br> Instead, create a local variable within the loop and assign it the value of the iteration variable.</p> </blockquote> <p>I know what it me...
[ { "answer_id": 227832, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 3, "selected": false, "text": "<p>Assuming you mean C# here.</p>\n\n<p>It's because of the way the compiler implements closures. Using an iteration va...
2008/10/22
[ "https://Stackoverflow.com/questions/227820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I was just writing some quick code and noticed this complier error > > Using the iteration variable in a lambda expression may have unexpected results. > > Instead, create a local variable within the loop and assign it the value of the iteration variable. > > > I know what it means and I can easily fix it, n...
Consider this code: ```cs List<Action> actions = new List<Action>(); for (int i = 0; i < 10; i++) { actions.Add(() => Console.WriteLine(i)); } foreach (Action action in actions) { action(); } ``` What would you expect this to print? The obvious answer is 0...9 - but actually it prints 10, ten times. It's b...
227,856
<p>It seems that the decision to make your objects fully cognizant of their roles within the system, and still avoid having too many dependencies within the domain model on the database, and service layers?</p> <p>For example: Say that I've got an entity with a revision history, and several "lookup tables" that the da...
[ { "answer_id": 227874, "author": "Manu", "author_id": 2133, "author_profile": "https://Stackoverflow.com/users/2133", "pm_score": 0, "selected": false, "text": "<p>Try the \"repository pattern\" and \"Domain driven design\". DDD suggests to define certain entities as Aggregate-roots of o...
2008/10/22
[ "https://Stackoverflow.com/questions/227856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21973/" ]
It seems that the decision to make your objects fully cognizant of their roles within the system, and still avoid having too many dependencies within the domain model on the database, and service layers? For example: Say that I've got an entity with a revision history, and several "lookup tables" that the data referen...
Really really good question. I have spent quite a bit of time thinking about such topics. You demonstrate great insight by noting the tension between an expressive domain model and separation of concerns. This is much like the tension in the question I asked about [Tell Don't Ask and Single Responsibility Principle](h...
227,897
<p>I just finished a test as part of a job interview, and one question stumped me, even using Google for reference. I'd like to see what the StackOverflow crew can do with it:</p> <blockquote> <p>The <code>memset_16aligned</code> function requires a 16-byte aligned pointer passed to it, or it will crash.</p> <p>a) How ...
[ { "answer_id": 227900, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 10, "selected": true, "text": "<h3>Original answer</h3>\n\n<pre><code>{\n void *mem = malloc(1024+16);\n void *ptr = ((char *)mem+16) &amp...
2008/10/22
[ "https://Stackoverflow.com/questions/227897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63/" ]
I just finished a test as part of a job interview, and one question stumped me, even using Google for reference. I'd like to see what the StackOverflow crew can do with it: > > The `memset_16aligned` function requires a 16-byte aligned pointer passed to it, or it will crash. > > > a) How would you allocate 1024 byt...
### Original answer ``` { void *mem = malloc(1024+16); void *ptr = ((char *)mem+16) & ~ 0x0F; memset_16aligned(ptr, 0, 1024); free(mem); } ``` ### Fixed answer ``` { void *mem = malloc(1024+15); void *ptr = ((uintptr_t)mem+15) & ~ (uintptr_t)0x0F; memset_16aligned(ptr, 0, 1024); free...
227,907
<p>I am trying to debug an ActiveResource call that is not working.</p> <p>What's the best way to view the HTTP response to the request ActiveResource is making?</p>
[ { "answer_id": 227908, "author": "Luke Francl", "author_id": 17965, "author_profile": "https://Stackoverflow.com/users/17965", "pm_score": 0, "selected": false, "text": "<p>Maybe the best way is to use a traffic sniffer.</p>\n\n<p>(Which would totally work...except in my case the traffic...
2008/10/22
[ "https://Stackoverflow.com/questions/227907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965/" ]
I am trying to debug an ActiveResource call that is not working. What's the best way to view the HTTP response to the request ActiveResource is making?
It's easy. Just look at the response that comes back. :) Two options: * You have the source file on your computer. Edit it. Put a `puts response.inspect` at the appropriate place. Remember to remove it. * Ruby has open classes. Find the right method and redefine it to do exactly what you want, or use aliases and call...
227,909
<p>I could use some advice on tracking down the cause of memory leaks in C#. I understand what is a memory leak and I get why they occur in C# but I'm wondering what tools/strategies have you used in the past to resolve them?</p> <p>I am using .NET Memory Profiler and I've found that one of my huge main objects is sta...
[ { "answer_id": 227966, "author": "Daniel Earwicker", "author_id": 27423, "author_profile": "https://Stackoverflow.com/users/27423", "pm_score": 5, "selected": false, "text": "<p>Break into the debugger and then type this into the Immediate window:</p>\n\n<pre><code>.load C:\\Windows\\Mic...
2008/10/22
[ "https://Stackoverflow.com/questions/227909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
I could use some advice on tracking down the cause of memory leaks in C#. I understand what is a memory leak and I get why they occur in C# but I'm wondering what tools/strategies have you used in the past to resolve them? I am using .NET Memory Profiler and I've found that one of my huge main objects is staying in me...
Break into the debugger and then type this into the Immediate window: ``` .load C:\Windows\Microsoft.NET\Framework\v2.0.50727\sos.dll ``` The path to sos.dll varies. The way to find out the correct path is to look for mscorwks.dll in the Modules pane. Wherever that is loaded from is the correct path for sos.dll. Th...
227,924
<p>I can't see the 'Collection of Repositories" page after adding authentication and access rules to svn. 'guest' can navigate to mydomain.com/svn/public and admin can see both svn/public and svn/private, but none of the users can see /svn. </p> <p>Is it possible to have 'guest' access mydomain.com/svn and only see ...
[ { "answer_id": 228955, "author": "Karl R", "author_id": 22934, "author_profile": "https://Stackoverflow.com/users/22934", "pm_score": 0, "selected": false, "text": "<p>Using &lt; location /svn/ > fixed it, all repos are now visible from /svn/ and if a guest clicks on 'private' it locks t...
2008/10/22
[ "https://Stackoverflow.com/questions/227924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22934/" ]
I can't see the 'Collection of Repositories" page after adding authentication and access rules to svn. 'guest' can navigate to mydomain.com/svn/public and admin can see both svn/public and svn/private, but none of the users can see /svn. Is it possible to have 'guest' access mydomain.com/svn and only see a /public li...
This may not be what you're looking for, but we've stopped using the collection of repositories page altogether. Instead we use websvn: <http://websvn.tigris.org/> screenshot: <http://chrison.net/content/binary/websvn2.png> (not my screenshot) with the Calm theme. Access is granted through Apache's DAV module, using t...
227,928
<p>I'm building an open source project that uses python and c++ in Windows. I came to the following error message:</p> <pre><code> ImportError: No module named win32con </code></pre> <p>The same happened in a "prebuilt" code that it's working ( except in my computer :P ) </p> <p>I think this is kind of "popular" mo...
[ { "answer_id": 227930, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 6, "selected": true, "text": "<p>This module contains constants related to Win32 programming. It is not part of the Python 2.6 release, but should ...
2008/10/22
[ "https://Stackoverflow.com/questions/227928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
I'm building an open source project that uses python and c++ in Windows. I came to the following error message: ``` ImportError: No module named win32con ``` The same happened in a "prebuilt" code that it's working ( except in my computer :P ) I think this is kind of "popular" module in python because I've saw s...
This module contains constants related to Win32 programming. It is not part of the Python 2.6 release, but should be part of the download of the pywin32 project. **Edit:** I imagine that the executable is an installation program, though the last time I downloaded pywin32 it was just a zip file.
227,935
<p>In response to a rightMouse event I want to call a function that displays a context menu, runs it, and responds to the selected menu item. In Windows I can use TrackPopupMenu with the TPM_RETURNCMD flag.</p> <p>What is the easiest way to implement this in Cocoa? It seems NSMenu:popUpContextMenu wants to post an e...
[ { "answer_id": 227975, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "<p>The 'proper' way to do this in Cocoa is to have your menu item's target and action perform the required method. Howe...
2008/10/22
[ "https://Stackoverflow.com/questions/227935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8761/" ]
In response to a rightMouse event I want to call a function that displays a context menu, runs it, and responds to the selected menu item. In Windows I can use TrackPopupMenu with the TPM\_RETURNCMD flag. What is the easiest way to implement this in Cocoa? It seems NSMenu:popUpContextMenu wants to post an event to the...
It appears that popUpContextMenu is already synchronous. Since I didn't see a way to use NSMenu without having it send a notification to an NSView I came up with a scheme that instantiates a temporary NSView. The goal is to display a popup menu and return the selected item in the context of a single function call. Foll...
227,939
<p>We're using HAProxy as a load balancer at the moment, and it regularly makes requests to the downstream boxes to make sure they're alive using an OPTIONS request:</p> <blockquote> <p>OPTIONS /index.html HTTP/1.0</p> </blockquote> <p>I'm working with getting nginx set up as a reverse proxy with caching (using nca...
[ { "answer_id": 4662858, "author": "Mark Rose", "author_id": 438631, "author_profile": "https://Stackoverflow.com/users/438631", "pm_score": 2, "selected": false, "text": "<p>In the httpchk option, you can specify the HTTP method like this:</p>\n\n<pre><code>httpchk GET http://example.com...
2008/10/22
[ "https://Stackoverflow.com/questions/227939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30575/" ]
We're using HAProxy as a load balancer at the moment, and it regularly makes requests to the downstream boxes to make sure they're alive using an OPTIONS request: > > OPTIONS /index.html HTTP/1.0 > > > I'm working with getting nginx set up as a reverse proxy with caching (using ncache). For some reason, nginx is ...
I'm probably late, but I had the same problem, and found two solutions to it. First is tricking Nginx that a 405 status is actually a 200 OK and then proxy\_pass it to your HAProxy like this: ``` error_page 405 =200 @405; location @405 { root /; proxy_pass http://yourproxy:8080; } ``` The second solution is...
227,950
<p>I need to compare 2 strings as equal such as these:</p> <blockquote> <p>Lubeck == Lübeck</p> </blockquote> <p>In JavaScript.</p> <p>Why? Well, I have an auto-completion field that's going out to a Java service using Lucene, where place names are stored naturally (as Lübeck), but also indexed as normalized text,...
[ { "answer_id": 228006, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 7, "selected": true, "text": "<pre><code>/**\n * Creates a RegExp that matches the words in the search string.\n * Case and accent insensitive.\n...
2008/10/22
[ "https://Stackoverflow.com/questions/227950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459/" ]
I need to compare 2 strings as equal such as these: > > Lubeck == Lübeck > > > In JavaScript. Why? Well, I have an auto-completion field that's going out to a Java service using Lucene, where place names are stored naturally (as Lübeck), but also indexed as normalized text, ``` import sun.text.Normalizer; oDoc...
``` /** * Creates a RegExp that matches the words in the search string. * Case and accent insensitive. */ function make_pattern(search_string) { // escape meta characters search_string = search_string.replace(/([|()[{.+*?^$\\])/g,"\\$1"); // split into words var words = search_string.split(/\s+/); ...
227,973
<p>I've got an application that needs quite a bit of data (1000s of records) to do appropriate testing. The only way I've found to get a decent set of testable, sensible data is to use a <strong>subset of my production DB</strong>. I've converted this to YAML fixtures in the normal `test/fixtures' location.</p> <p>T...
[ { "answer_id": 228944, "author": "Cameron McCloud", "author_id": 25484, "author_profile": "https://Stackoverflow.com/users/25484", "pm_score": 0, "selected": false, "text": "<p>The first thing I'd say is: what are you testing in that example? If it's an ordinary AR has_many association, ...
2008/10/22
[ "https://Stackoverflow.com/questions/227973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
I've got an application that needs quite a bit of data (1000s of records) to do appropriate testing. The only way I've found to get a decent set of testable, sensible data is to use a **subset of my production DB**. I've converted this to YAML fixtures in the normal `test/fixtures' location. This works, but now I have...
Magic numbers in tests aren't an anti-pattern. Your tests need to be so dead-simple that you don't need to *test* them. This means you'll have some magic numbers. This means that your tests will break when you change small bits of functionality. This is good. Fixtures have [some problems](http://www.floehopper.org/art...
227,994
<p>We have the following simple Stored Procedure that runs as an overnight SQL server agent job. Usually it runs in 20 minutes, but recently the MatchEvent and MatchResult tables have grown to over 9 million rows each. This has resulted in the store procedure taking over 2 hours to run, with all 8GB of memory on our SQ...
[ { "answer_id": 228003, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>Looking at the code above, why do you need a temp table?</p>\n\n<pre>\n<code>\nDELETE FROM MatchEvent WHERE\nMatchI...
2008/10/23
[ "https://Stackoverflow.com/questions/227994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17765/" ]
We have the following simple Stored Procedure that runs as an overnight SQL server agent job. Usually it runs in 20 minutes, but recently the MatchEvent and MatchResult tables have grown to over 9 million rows each. This has resulted in the store procedure taking over 2 hours to run, with all 8GB of memory on our SQL b...
There's probably a lot of stuff going on here, and it's not all your query. First, I agree with the other posters. Try to rewrite this without a temp table if at all possible. But assuming that you need a temp table here, you have a BIG problem in that you have no PK defined on it. It's vastly going to expand the am...
228,005
<p>I was wondering if there was an alternative to <code>itoa()</code> for converting an integer to a string because when I run it in visual Studio I get warnings, and when I try to build my program under Linux, I get a compilation error.</p>
[ { "answer_id": 228010, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 6, "selected": false, "text": "<p><a href=\"http://www.boost.org/doc/libs/1_36_0/libs/conversion/lexical_cast.htm\" rel=\"noreferrer\">boost::lexic...
2008/10/23
[ "https://Stackoverflow.com/questions/228005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29326/" ]
I was wondering if there was an alternative to `itoa()` for converting an integer to a string because when I run it in visual Studio I get warnings, and when I try to build my program under Linux, I get a compilation error.
In C++11 you can use [`std::to_string`](http://en.cppreference.com/w/cpp/string/basic_string/to_string): ``` #include <string> std::string s = std::to_string(5); ``` If you're working with prior to C++11, you could use C++ streams: ``` #include <sstream> int i = 5; std::string s; std::stringstream out; out << i; ...
228,025
<p>How do you insert/update a column through Linq To SQL and Linq To SQL use the default values? In particular I'm concerned with a timestamp field.</p> <p>I've tried setting that column to readonly and autogenerated, so it stopped trying to put in DateTime.MinValue, but it doesn't seem to be updating on updates.</p>...
[ { "answer_id": 228080, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 3, "selected": true, "text": "<p>The database default value would only insert the value on creating the row. It would do nothing for update, unless...
2008/10/23
[ "https://Stackoverflow.com/questions/228025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4050/" ]
How do you insert/update a column through Linq To SQL and Linq To SQL use the default values? In particular I'm concerned with a timestamp field. I've tried setting that column to readonly and autogenerated, so it stopped trying to put in DateTime.MinValue, but it doesn't seem to be updating on updates.
The database default value would only insert the value on creating the row. It would do nothing for update, unless you want to add a triggger. Alternately, you can add a partial method to your DataContext class. Add a new file you your project: ``` public partial class YourDatabaseDataContext { partial void Inser...
228,036
<p>I have the following problem using template instantiation [*]. </p> <p>file <strong>foo.h</strong></p> <pre><code>class Foo { public: template &lt;typename F&gt; void func(F f) private: int member_; }; </code></pre> <p>file <strong>foo.cc</strong></p> <pre><code>template &lt;typename F&gt; Foo::func...
[ { "answer_id": 228048, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "<p>Are you including foo.cc into caller.cc. Instantiation is something that happens at compile time -- when the compiler ...
2008/10/23
[ "https://Stackoverflow.com/questions/228036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1170277/" ]
I have the following problem using template instantiation [\*]. file **foo.h** ``` class Foo { public: template <typename F> void func(F f) private: int member_; }; ``` file **foo.cc** ``` template <typename F> Foo::func(F f) { f(member_); } ``` file **caller.cc** ``` Foo::func(boost::bind(&B...
The answer to this is compiler dependent. Some versions of the Sun C++ compiler would handle this automatically by building a cache of template function implementations that would be shared across separate translation units. If you're using Visual C++, and any other compiler that can't do this, you may as well put th...
228,038
<p>I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this:</p> <pre><code>public string Reverse(string text) { char[] cArray = text.ToCharArray(); string reverse = String.Empty; for (int i = cArray.Length - 1; i &gt; -1; i--) { reverse += cArr...
[ { "answer_id": 228055, "author": "Mike Thompson", "author_id": 2754, "author_profile": "https://Stackoverflow.com/users/2754", "pm_score": 4, "selected": false, "text": "<p>Have a look at the wikipedia entry <a href=\"http://en.wikipedia.org/wiki/Extension_method\" rel=\"noreferrer\">her...
2008/10/23
[ "https://Stackoverflow.com/questions/228038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this: ``` public string Reverse(string text) { char[] cArray = text.ToCharArray(); string reverse = String.Empty; for (int i = cArray.Length - 1; i > -1; i--) { reverse += cArray[i]; } ...
``` public static string Reverse( string s ) { char[] charArray = s.ToCharArray(); Array.Reverse(charArray); return new string(charArray); } ```
228,089
<p>I have tried what seems like everything - I've done similiar things many times before, but I'm obviously missing something.</p> <p>I have a UserControl (ucA) - on ucA is a LinkButton that loads a different UserControl (ucB) programatically into a panel on ucA. ucB has TextBoxes, etc. </p> <p>Why isn't my control...
[ { "answer_id": 228149, "author": "Ramesh", "author_id": 30594, "author_profile": "https://Stackoverflow.com/users/30594", "pm_score": 1, "selected": false, "text": "<p>I am installing express edition as I type. By that time, why should you clear the controls on click of the button? cant ...
2008/10/23
[ "https://Stackoverflow.com/questions/228089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26685/" ]
I have tried what seems like everything - I've done similiar things many times before, but I'm obviously missing something. I have a UserControl (ucA) - on ucA is a LinkButton that loads a different UserControl (ucB) programatically into a panel on ucA. ucB has TextBoxes, etc. Why isn't my control maintaining it's s...
I just tried to recreate what you have setup and I dont seem to experience the same problem. Would you like me to send you my Solution somehow? Final Edit, I promised - Try this solution: <http://www.vyrotek.com/code/ControlTest2.zip>
228,102
<pre><code>&lt;div&gt; &lt;span&gt;left&lt;/span&gt; &lt;span&gt;right&lt;/span&gt; &lt;!-- new line break, so no more content on that line --&gt; &lt;table&gt; ... &lt;/table&gt; &lt;/div&gt; </code></pre> <p>How can I position those spans (they can be changed to any element) so that depending on how big the table i...
[ { "answer_id": 228122, "author": "Ramesh", "author_id": 30594, "author_profile": "https://Stackoverflow.com/users/30594", "pm_score": 1, "selected": false, "text": "<p>if you have divs instead of span, try float:left for span a and float:right for span b</p>\n" }, { "answer_id": ...
2008/10/23
[ "https://Stackoverflow.com/questions/228102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` <div> <span>left</span> <span>right</span> <!-- new line break, so no more content on that line --> <table> ... </table> </div> ``` How can I position those spans (they can be changed to any element) so that depending on how big the table is (not defined anywhere, and shouldn't be) the spans are positioned just ...
> > Doesn't place them relatively, nor > does Rob Allen's answer, they put them > at the far reaches of the browser not, > within the table width. > > > Well they are going to be bound by their container width and Rob's answer makes both the table and container width 100%. The only solution I can think of off ...
228,125
<p>I am after a regular expression that validates a percentage from 0 100 and allows two decimal places. </p> <p>Does anyone know how to do this or know of good web site that has example of common regular expressions used for client side validation in javascript?</p> <p>@Tom - Thanks for the questions. Ideally there ...
[ { "answer_id": 228152, "author": "Julien Grenier", "author_id": 23051, "author_profile": "https://Stackoverflow.com/users/23051", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p><code>(100|[0-9]{1,2})(\\.[0-9]{1,2})?</code></p>\n</blockquote>\n\n<p>That should be the regex ...
2008/10/23
[ "https://Stackoverflow.com/questions/228125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5360/" ]
I am after a regular expression that validates a percentage from 0 100 and allows two decimal places. Does anyone know how to do this or know of good web site that has example of common regular expressions used for client side validation in javascript? @Tom - Thanks for the questions. Ideally there would be no leadi...
Rather than using regular expressions for this, I would simply convert the user's entered number to a floating point value, and then check for the range you want (0 to 100). Trying to do numeric range validation with regular expressions is almost always the wrong tool for the job. ``` var x = parseFloat(str); if (isNa...
228,134
<p>I like Steve Yegge's <a href="http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html" rel="noreferrer">Prototype Pattern example</a> and decided to whip up a quick proof of concept example.</p> <p>However, I didn't really think things through. While it is great for dynamically specifying the behavio...
[ { "answer_id": 228232, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 4, "selected": true, "text": "<p>Doesn't it depend how you actually implement the inheritance in your system?</p>\n\n<p>For example, in a JavaScript...
2008/10/23
[ "https://Stackoverflow.com/questions/228134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
I like Steve Yegge's [Prototype Pattern example](http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html) and decided to whip up a quick proof of concept example. However, I didn't really think things through. While it is great for dynamically specifying the behaviour of objects and is an easy solution t...
Doesn't it depend how you actually implement the inheritance in your system? For example, in a JavaScript version of what you describe, the `prototype` for `AwesomeDragonImmuneToFire` would normally be an *instance* of an `AwesomeDragon`, and since you'd always be working with instances, it wouldn't matter what you do...
228,145
<p>I am progamatically creating a SharePoint site using </p> <pre><code>SPWeb spWeb = spSite.AllWebs.Add(...); </code></pre> <p>What code do I need run to set the spWeb to turn off the "Show pages in navigation" option?</p> <p><strong>Answer:</strong></p> <pre><code>publishingWeb.IncludePagesInNavigation = false; <...
[ { "answer_id": 228211, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 4, "selected": true, "text": "<p>Wasn't sure myself but I was able to locate <a href=\"http://msdn.microsoft.com/en-us/magazine/cc507633.aspx\" rel...
2008/10/23
[ "https://Stackoverflow.com/questions/228145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13813/" ]
I am progamatically creating a SharePoint site using ``` SPWeb spWeb = spSite.AllWebs.Add(...); ``` What code do I need run to set the spWeb to turn off the "Show pages in navigation" option? **Answer:** ``` publishingWeb.IncludePagesInNavigation = false; ```
Wasn't sure myself but I was able to locate [this](http://msdn.microsoft.com/en-us/magazine/cc507633.aspx): > > Modifying navigation is another common > branding task since it affects what > users can see and how they can proceed > through a site hierarchy. The > Microsoft.SharePoint.Publishing > namespace expos...
228,165
<p>I stumbled across my rather ancient photo objects disks, and sadly found out the company (hemera) doesn't provide support for it anymore. this has left me with a whole pile of .hpi files. Luckily, I found <a href="http://www.halley.cc/ed/linux/interop/hemera.html" rel="nofollow noreferrer">this information</a> on ex...
[ { "answer_id": 228192, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 3, "selected": true, "text": "<p>It seems the regexp is wrong. That's why I wrote a little C program to do it for me:</p>\n\n<pre><code>#include &lt;stdio....
2008/10/23
[ "https://Stackoverflow.com/questions/228165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4853/" ]
I stumbled across my rather ancient photo objects disks, and sadly found out the company (hemera) doesn't provide support for it anymore. this has left me with a whole pile of .hpi files. Luckily, I found [this information](http://www.halley.cc/ed/linux/interop/hemera.html) on extracting the jpg and png components of t...
It seems the regexp is wrong. That's why I wrote a little C program to do it for me: ``` #include <stdio.h> #include <stdlib.h> #define MAX_SIZE 1048576 char stuff[MAX_SIZE]; int main (int argc, char **argv) { unsigned int j_off, j_len, p_off, p_len; FILE *fp, *jp, *pp; fp = fopen (argv[1], "r"); if...
228,175
<p>When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object?</p> <p>I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object.</p> <p>If you use...
[ { "answer_id": 228190, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 3, "selected": false, "text": "<p>If the results of the stored procedure has the same schema as one of your tables, you can build a collection using t...
2008/10/23
[ "https://Stackoverflow.com/questions/228175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When using SubSonic, do you return the data as a dataset or do you put that in a strongly typed custom collection or a generic object? I ran through the subsonic project and for the four stored procs I have in my DB, it gave me a Sps.cs with 4 methods which return a StoredProcedure object. If you used a MVC, do you u...
If the results of the stored procedure has the same schema as one of your tables, you can build a collection using this code (SubSonic 2.1): ``` ProductCollection coll = new ProductCollection(); coll.LoadAndCloseReader(SPs.GetProducts(1).GetReader()); ```
228,200
<p><code>%AX = (%AH + %AL)</code></p> <p>So why not <code>%EAX = (%SOME_REGISTER + %AX)</code> for some register <code>%SOME_REGISTER</code>? </p>
[ { "answer_id": 228231, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": "<p>In the old 8-bit days, there was the A register.</p>\n\n<p>In the 16-bit days, there was the 16 bit AX register, which...
2008/10/23
[ "https://Stackoverflow.com/questions/228200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10432/" ]
`%AX = (%AH + %AL)` So why not `%EAX = (%SOME_REGISTER + %AX)` for some register `%SOME_REGISTER`?
Just for some clarification. In the early microprocessor days of the 1970's, CPUs had only a small number of registers and a very limited instruction set. Typically, the arithmetic unit could only operate on a single CPU register, often referred to as the "accumulator". The accumulator on the 8 bit 8080 & Z80 processor...
228,205
<p>How do you handle update refresh rate from your worker function to your UI ?</p> <p>Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)</p>
[ { "answer_id": 228231, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": false, "text": "<p>In the old 8-bit days, there was the A register.</p>\n\n<p>In the 16-bit days, there was the 16 bit AX register, which...
2008/10/23
[ "https://Stackoverflow.com/questions/228205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2566/" ]
How do you handle update refresh rate from your worker function to your UI ? Sending everything to the UI or maybe using a timer (from which side ? worker or UI ?)
Just for some clarification. In the early microprocessor days of the 1970's, CPUs had only a small number of registers and a very limited instruction set. Typically, the arithmetic unit could only operate on a single CPU register, often referred to as the "accumulator". The accumulator on the 8 bit 8080 & Z80 processor...
228,218
<p>I am very new to Java. My assignment is to create my own method and then create a class to test it in. My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method?</p> <p>(Are they saved as two separate files?)</p> <p>Th...
[ { "answer_id": 228226, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 2, "selected": false, "text": "<p>In Java, ALL methods exist within classes. So in order to create a class, you write something like:</p>\n\n<pre><c...
2008/10/23
[ "https://Stackoverflow.com/questions/228218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30606/" ]
I am very new to Java. My assignment is to create my own method and then create a class to test it in. My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method? (Are they saved as two separate files?) This is what I have...
For a simple assignment such as this, you can probably create your method in the same class as your class. Create a class with a static main method, which will be your programs starting point, and then create your method which will be called. Seems like you are quite new to programming I would take advantage of any tu...
228,221
<p>I know that I can insert multiple rows using a single statement, if I use the syntax in <a href="https://stackoverflow.com/questions/39576/best-way-to-do-multi-row-insert-in-oracle#39602">this answer</a>. </p> <p>However, one of the values I am inserting is taken from a sequence, i.e. </p> <pre><code>insert into T...
[ { "answer_id": 228264, "author": "Brian Schmitt", "author_id": 30492, "author_profile": "https://Stackoverflow.com/users/30492", "pm_score": 1, "selected": false, "text": "<p>A possibility is to create a trigger on insert to add in the correct sequence number.</p>\n" }, { "answer...
2008/10/23
[ "https://Stackoverflow.com/questions/228221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
I know that I can insert multiple rows using a single statement, if I use the syntax in [this answer](https://stackoverflow.com/questions/39576/best-way-to-do-multi-row-insert-in-oracle#39602). However, one of the values I am inserting is taken from a sequence, i.e. ``` insert into TABLE_NAME (COL1,COL2) select MY_...
This works: ``` insert into TABLE_NAME (COL1,COL2) select my_seq.nextval, a from (SELECT 'SOME VALUE' as a FROM DUAL UNION ALL SELECT 'ANOTHER VALUE' FROM DUAL) ```