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
56,472
<p>I'm trying to send messages to Objective-C objects in gdb.</p> <pre><code>(gdb) p $esi $2 = (void *) 0x1268160 (gdb) po $esi &lt;NSArray: 0x1359c0&gt; (gdb) po [$esi count] Target does not respond to this message selector. </code></pre> <p>I can't send any message to it. Am I missing something? Do I really need th...
[ { "answer_id": 57279, "author": "John Calsbeek", "author_id": 5696, "author_profile": "https://Stackoverflow.com/users/5696", "pm_score": 1, "selected": false, "text": "<p>Is it possible that you need to cast <code>$esi</code>?</p>\n\n<pre><code>p (NSUInteger)[(NSArray *)$esi count]\n</c...
2008/09/11
[ "https://Stackoverflow.com/questions/56472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5577/" ]
I'm trying to send messages to Objective-C objects in gdb. ``` (gdb) p $esi $2 = (void *) 0x1268160 (gdb) po $esi <NSArray: 0x1359c0> (gdb) po [$esi count] Target does not respond to this message selector. ``` I can't send any message to it. Am I missing something? Do I really need the symbols, or something else?
If you must override gdb and send a message to an object when it will not let you, you can use performSelector: ``` (gdb) print (int)[receivedData count] Target does not respond to this message selector. (gdb) print (int)[receivedData performSelector:@selector(count) ] 2008-09-15 00:46:35.854 Executable[1008:20b] ***...
56,500
<p>I'm stuck on a fix to a legacy Visual C++ 6 app. In the C++ DLL source I have put</p> <pre><code>extern "C" _declspec(dllexport) char* MyNewVariable = 0; </code></pre> <p>which results in MyNewVariable showing up (nicely undecorated) in the export table (as shown by dumpbin /exports blah.dll). However, I can't fig...
[ { "answer_id": 56513, "author": "Tony Lee", "author_id": 5819, "author_profile": "https://Stackoverflow.com/users/5819", "pm_score": 2, "selected": false, "text": "<p>extern \"C\" is how you remove decoration - it should work to use:</p>\n\n<p>extern \"C\" declspec(dllimport) char MyNewV...
2008/09/11
[ "https://Stackoverflow.com/questions/56500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5816/" ]
I'm stuck on a fix to a legacy Visual C++ 6 app. In the C++ DLL source I have put ``` extern "C" _declspec(dllexport) char* MyNewVariable = 0; ``` which results in MyNewVariable showing up (nicely undecorated) in the export table (as shown by dumpbin /exports blah.dll). However, I can't figure out how to declare the...
you must link against the lib generated after compiling the DLL. In the linker options of the project, you must add the `.lib` file. And yes, you should also declare the variable as: ``` extern "C" { declspec(dllimport) char MyNewVariable; } ```
56,521
<p>I have a "numeric textbox" in C# .NET which is nothing more than a derivation of Textbox, with some added logic to prevent the user entering anything non-numeric. As part of this, I have added a Value property of type <code>double?</code> (or <code>Nullable&lt;double&gt;</code>). It's nullable to support the case wh...
[ { "answer_id": 56528, "author": "Alex Duggleby", "author_id": 5790, "author_profile": "https://Stackoverflow.com/users/5790", "pm_score": -1, "selected": false, "text": "<p>Could it help to setting the <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueat...
2008/09/11
[ "https://Stackoverflow.com/questions/56521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a "numeric textbox" in C# .NET which is nothing more than a derivation of Textbox, with some added logic to prevent the user entering anything non-numeric. As part of this, I have added a Value property of type `double?` (or `Nullable<double>`). It's nullable to support the case where the user doesn't enter anyt...
Or, if you don't want the designer adding any code at all... add this to the Property. ``` [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] ```
56,547
<p>How do you perform a CROSS JOIN with LINQ to SQL?</p>
[ { "answer_id": 56612, "author": "Steve Morgan", "author_id": 5806, "author_profile": "https://Stackoverflow.com/users/5806", "pm_score": 8, "selected": true, "text": "<p>A cross-join is simply the Cartesian product of two sets. There's no explicit join operator for it.</p>\n\n<pre>\nvar ...
2008/09/11
[ "https://Stackoverflow.com/questions/56547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5556/" ]
How do you perform a CROSS JOIN with LINQ to SQL?
A cross-join is simply the Cartesian product of two sets. There's no explicit join operator for it. ``` var combo = from p in people from c in cars select new { p.Name, c.Make, c.Model, c.Colour }; ```
56,554
<p>Let's say I want to represent <code>\q</code> (or any other particular "backslash-escaped character"). That is, I want to match <code>\q</code> but not <code>\\q</code>, since the latter is a backslash-escaped backslash followed by a <code>q</code>. Yet <code>\\\q</code> would match, since it's a backslash-escaped...
[ { "answer_id": 56583, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.codinghorror.com/blog/archives/001016.html\" rel=\"nofollow noreferrer\">Now You Have Two Problem...
2008/09/11
[ "https://Stackoverflow.com/questions/56554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
Let's say I want to represent `\q` (or any other particular "backslash-escaped character"). That is, I want to match `\q` but not `\\q`, since the latter is a backslash-escaped backslash followed by a `q`. Yet `\\\q` would match, since it's a backslash-escaped backslash followed by a backslash-escaped `q`. (Well, it wo...
Updated: My new and improved Perl regex, supporting more than 3 backslashes: ``` /(?<!\\) # Not preceded by a single backslash (?>\\\\)* # an even number of backslashes \\q # Followed by a \q /x; ``` or if your regex library doesn't support extended syntax. ``` /(?<!\\)(?>\\\\)*\\q/ ``` Output of my ...
56,568
<p>How do you actually perform datetime operations such as adding date, finding difference, find out how many days excluding weekends in an interval? I personally started to pass some of these operations to my postgresql dbms as typically I would only need to issue one sql statement to obtain an answer, however, to do ...
[ { "answer_id": 56595, "author": "reefnet_alex", "author_id": 2745, "author_profile": "https://Stackoverflow.com/users/2745", "pm_score": 3, "selected": false, "text": "<p>While for most datetime operations I would normally convert to Unixtime and perform addition subtraction etc. on the ...
2008/09/11
[ "https://Stackoverflow.com/questions/56568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
How do you actually perform datetime operations such as adding date, finding difference, find out how many days excluding weekends in an interval? I personally started to pass some of these operations to my postgresql dbms as typically I would only need to issue one sql statement to obtain an answer, however, to do it ...
PHP5+'s DateTime object is useful because it is leap time and daylight savings aware, but it needs some extension to really solve the problem. I wrote the following to solve a similar problem. The find\_WeekdaysFromThisTo() method is brute-force, but it works reasonably quickly if your time span is less than 2 years. ...
56,574
<p>A while back I was reading the W3C article on '<a href="http://www.w3.org/International/articles/text-reuse/" rel="noreferrer">Re-using Strings in Scripted Content</a>', which contains some useful advice on internationalisation, but which strikes me as at odds iwth the DRY (Don't Repeat Yourself) principle of elimin...
[ { "answer_id": 56609, "author": "badbod99", "author_id": 3614, "author_profile": "https://Stackoverflow.com/users/3614", "pm_score": 0, "selected": false, "text": "<p>I would suggest using a CMS rather than hardcoding in your textual values to cover localisation.</p>\n" }, { "ans...
2008/09/11
[ "https://Stackoverflow.com/questions/56574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/797/" ]
A while back I was reading the W3C article on '[Re-using Strings in Scripted Content](http://www.w3.org/International/articles/text-reuse/)', which contains some useful advice on internationalisation, but which strikes me as at odds iwth the DRY (Don't Repeat Yourself) principle of eliminating repetitive code. To take...
I'd try to keep complete sentences in the language resource. As you said you might need different words in different contexts. But a bigger problem is that the order of sentences might be different in different languages. So building up strings from words can cause problems. Just store ``` The printer is on The print...
56,591
<p>Ok, this is bit of an obscure question, but hopefully someone can help me out with it.</p> <p>The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user...
[ { "answer_id": 56636, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 1, "selected": false, "text": "<p>When I run this:</p>\n\n<pre><code>select 'test\"columnname\"' from dual\n</code></pre>\n\n<p>Oracle returns this (noti...
2008/09/11
[ "https://Stackoverflow.com/questions/56591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5827/" ]
Ok, this is bit of an obscure question, but hopefully someone can help me out with it. The system I'm working on builds a dynamic SQL string for execution inside a stored procedure, and part of that dynamic SQL defining column aliases, which themselves are actually values retrieved from another table of user generated...
Can you just put another character instead of double quotes and replace that with double quotes in the code? Something like this: ``` SELECT table1.Col1 AS "This is |not| an alias" FROM table1 ``` Then just replace | with ". I know it's a hack, but I can't think of any better solution... And what you are doing the...
56,628
<p>I'm not a SQL expert, and I'm reminded of the fact every time I need to do something beyond the basics. I have a test database that is not large in size, but the transaction log definitely is. How do I clear out the transaction log?</p>
[ { "answer_id": 56647, "author": "Johnno Nolan", "author_id": 1116, "author_profile": "https://Stackoverflow.com/users/1116", "pm_score": 5, "selected": false, "text": "<p>Here is a simple and <strong>very inelegant</strong> &amp; <strong>potentially dangerous</strong> way. </p>\n\n<ol>\...
2008/09/11
[ "https://Stackoverflow.com/questions/56628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
I'm not a SQL expert, and I'm reminded of the fact every time I need to do something beyond the basics. I have a test database that is not large in size, but the transaction log definitely is. How do I clear out the transaction log?
Making a log file smaller should really be reserved for scenarios where it encountered unexpected growth which you do not expect to happen again. If the log file will grow to the same size again, not very much is accomplished by shrinking it temporarily. Now, depending on the recovery goals of your database, these are ...
56,630
<p>Slashdot has a little widget that allows you to tweak your comment threshold to filter out down-modded comments. It will be in one place if you scroll to the top of the page, and as you scroll down, at some point, where its original home is about to scroll off the page, it will switch to fixed position, and stay on...
[ { "answer_id": 56759, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 3, "selected": true, "text": "<p>Okay, I figured it out. I will post it here in case it help anyone else. This solution uses prototype, and an internal l...
2008/09/11
[ "https://Stackoverflow.com/questions/56630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
Slashdot has a little widget that allows you to tweak your comment threshold to filter out down-modded comments. It will be in one place if you scroll to the top of the page, and as you scroll down, at some point, where its original home is about to scroll off the page, it will switch to fixed position, and stay on you...
Okay, I figured it out. I will post it here in case it help anyone else. This solution uses prototype, and an internal library that gives me the registerEvent, getElementX and getElementY functions, which do what you would think. ``` var MenuManager = Class.create({ initialize: function initialize(menuElt) { ...
56,638
<p>I want to convert a number that is in <a href="https://en.wikipedia.org/wiki/Netscape_Portable_Runtime#Time" rel="nofollow noreferrer">PRTime</a> format (a 64-bit integer representing the number of microseconds since midnight (00:00:00) 1 January 1970 Coordinated Universal Time (UTC)) to a <code>DateTime</code>.</p>...
[ { "answer_id": 56674, "author": "Barry", "author_id": 845, "author_profile": "https://Stackoverflow.com/users/845", "pm_score": 3, "selected": true, "text": "<pre><code>Dim prTimeInMillis As UInt64\nprTimeInMillis = prTime/1000\n\nDim prDateTime As New DateTime(1970, 1, 1)\nprDateTime = ...
2008/09/11
[ "https://Stackoverflow.com/questions/56638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842864/" ]
I want to convert a number that is in [PRTime](https://en.wikipedia.org/wiki/Netscape_Portable_Runtime#Time) format (a 64-bit integer representing the number of microseconds since midnight (00:00:00) 1 January 1970 Coordinated Universal Time (UTC)) to a `DateTime`. Note that this is slightly different than the usual "...
``` Dim prTimeInMillis As UInt64 prTimeInMillis = prTime/1000 Dim prDateTime As New DateTime(1970, 1, 1) prDateTime = prDateTime.AddMilliseconds(prTimeInMillis) ```
56,655
<p>This is the day of weird behavior.</p> <p>We have a Win32 project made with Delphi 2007, which hosts the .NET runtime and calls into .NET to show new forms, as part of a transition period.</p> <p>Recently we've begun experiencing exceptions at seemingly random locations and points of our code: Arithmetic overflow or...
[ { "answer_id": 56696, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 1, "selected": false, "text": "<p>Have you added all the WMI components? As far as I know, you need all the WMI components to access the counters!</p>\n...
2008/09/11
[ "https://Stackoverflow.com/questions/56655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
This is the day of weird behavior. We have a Win32 project made with Delphi 2007, which hosts the .NET runtime and calls into .NET to show new forms, as part of a transition period. Recently we've begun experiencing exceptions at seemingly random locations and points of our code: Arithmetic overflow or underflow. Th...
It looks like this is what I was missing: <http://msdn.microsoft.com/en-us/library/aa939695.aspx>
56,658
<h3>Summary</h3> <p>What's the best way to ensure a table cell cannot be less than a certain minimum width. </p> <h3>Example</h3> <p>I want to ensure that all cells in a table are at least 100px wide regards of the width of the tables container. If there is more available space the table cells should fill that space...
[ { "answer_id": 56663, "author": "James B", "author_id": 2951, "author_profile": "https://Stackoverflow.com/users/2951", "pm_score": 7, "selected": true, "text": "<p>This CSS should suffice:</p>\n\n<pre><code>td { min-width: 100px; }\n</code></pre>\n\n<p>However, it's not always obeyed co...
2008/09/11
[ "https://Stackoverflow.com/questions/56658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5182/" ]
### Summary What's the best way to ensure a table cell cannot be less than a certain minimum width. ### Example I want to ensure that all cells in a table are at least 100px wide regards of the width of the tables container. If there is more available space the table cells should fill that space. ### Browser compa...
This CSS should suffice: ``` td { min-width: 100px; } ``` However, it's not always obeyed correctly (the min-width attribute) by all browsers (for example, IE6 dislikes it a great deal). **Edit:** As for an IE6 (and before) solution, there isn't one that works reliably under all circumstances, as far as I know. Usi...
56,682
<p>In Windows, is there an easy way to tell if a folder has a subfile that has changed?</p> <p>I verified, and the last modified date on the folder does not get updated when a subfile changes.</p> <p>Is there a registry entry I can set that will modify this behavior?</p> <p>If it matters, I am using an NTFS volume. ...
[ { "answer_id": 56695, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 1, "selected": false, "text": "<p>If you can't run a process when the change occurs, then there's not much you can do except scan the filesystem, and che...
2008/09/11
[ "https://Stackoverflow.com/questions/56682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
In Windows, is there an easy way to tell if a folder has a subfile that has changed? I verified, and the last modified date on the folder does not get updated when a subfile changes. Is there a registry entry I can set that will modify this behavior? If it matters, I am using an NTFS volume. I would ultimately lik...
This [article](http://msdn.microsoft.com/en-us/library/aa365261(VS.85).aspx) should help. Basically, you create one or more notification object such as: ``` HANDLE dwChangeHandles[2]; dwChangeHandles[0] = FindFirstChangeNotification( lpDir, // directory to watch FALSE, ...
56,692
<p>Consider the class below that represents a Broker:</p> <pre><code>public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } </code></pre> <p>I'd like to randomly select a Broker from an a...
[ { "answer_id": 56735, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 6, "selected": true, "text": "<p>Your algorithm is nearly correct. However, the test should be <code>&lt;</code> instead of <code>&lt;=</code>:</p>\n...
2008/09/11
[ "https://Stackoverflow.com/questions/56692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2868/" ]
Consider the class below that represents a Broker: ``` public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } ``` I'd like to randomly select a Broker from an array, taking into account ...
Your algorithm is nearly correct. However, the test should be `<` instead of `<=`: ``` if (randomNumber < broker.Weight) ``` This is because 0 is inclusive in the random number while `totalWeight` is exclusive. In other words, a broker with weight 0 would still have a small chance of being selected – not at all what...
56,698
<p>I would like to generate a list of differences between 2 instances of the the same object. Object in question:</p> <pre><code>public class Step { [DataMember] public StepInstanceInfo InstanceInfo { get; set; } [DataMember] public Collection&lt;string&gt; AdHocRules { get; set; } [DataMember] ...
[ { "answer_id": 56774, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>Implementing the IComparable interface in your object may provide you with the functionality you need. This will provide yo...
2008/09/11
[ "https://Stackoverflow.com/questions/56698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to generate a list of differences between 2 instances of the the same object. Object in question: ``` public class Step { [DataMember] public StepInstanceInfo InstanceInfo { get; set; } [DataMember] public Collection<string> AdHocRules { get; set; } [DataMember] public Collection...
You'll need a separate object, like StepDiff with collections for removed and added items. The easiest way to do something like this is to copy the collections from each of the old and new objects, so that StepDiff has collectionOldStepDocs and collectionNewStepDocs. Grab the shorter collection and iterate through it...
56,709
<p>I get the following error message in SQL Server 2005:</p> <pre><code>User '&lt;username&gt;' does not have permission to run DBCC DBREINDEX for object '&lt;table&gt;'. </code></pre> <p>Which minimum role do I have to give to user in order to run the command?</p>
[ { "answer_id": 56720, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 4, "selected": true, "text": "<p>You will need to be a member of the <strong>db_ddladmin</strong> or the <strong>db_owner</strong> role AFAIK</p>\n" }, ...
2008/09/11
[ "https://Stackoverflow.com/questions/56709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383/" ]
I get the following error message in SQL Server 2005: ``` User '<username>' does not have permission to run DBCC DBREINDEX for object '<table>'. ``` Which minimum role do I have to give to user in order to run the command?
You will need to be a member of the **db\_ddladmin** or the **db\_owner** role AFAIK
56,729
<p>Can somebody give me a complete and working example of calling the <code>AllocateAndInitializeSid</code> function from C# code?</p> <p>I found <a href="http://msdn.microsoft.com/en-us/library/aa375213(VS.85).aspx" rel="nofollow noreferrer">this</a>: </p> <pre><code>BOOL WINAPI AllocateAndInitializeSid( __in P...
[ { "answer_id": 56745, "author": "Mendelt", "author_id": 3320, "author_profile": "https://Stackoverflow.com/users/3320", "pm_score": 1, "selected": false, "text": "<p>For Platform Invoke www.pinvoke.net is your new best friend!</p>\n\n<p><a href=\"http://www.pinvoke.net/default.aspx/advap...
2008/09/11
[ "https://Stackoverflow.com/questions/56729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/95/" ]
Can somebody give me a complete and working example of calling the `AllocateAndInitializeSid` function from C# code? I found [this](http://msdn.microsoft.com/en-us/library/aa375213(VS.85).aspx): ``` BOOL WINAPI AllocateAndInitializeSid( __in PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, __in BYTE nSubAutho...
Using [P/Invoke Interop Assistant](http://www.codeplex.com/clrinterop): ``` [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public struct SidIdentifierAuthority { /// BYTE[6] [System.Runtime.InteropServices.MarshalAsAttribute( ...
56,737
<p>Is the standard Java 1.6 <a href="http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilder.html" rel="noreferrer">javax.xml.parsers.DocumentBuilder</a> class thread safe? Is it safe to call the parse() method from several threads in parallel?</p> <p>The JavaDoc doesn't mention the issue, but the <a h...
[ { "answer_id": 56815, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 6, "selected": true, "text": "<p>Even though DocumentBuilder.parse appears not to mutate the builder it does on the Sun JDK default implementa...
2008/09/11
[ "https://Stackoverflow.com/questions/56737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1605/" ]
Is the standard Java 1.6 [javax.xml.parsers.DocumentBuilder](http://java.sun.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilder.html) class thread safe? Is it safe to call the parse() method from several threads in parallel? The JavaDoc doesn't mention the issue, but the [JavaDoc for the same class](http://java.s...
Even though DocumentBuilder.parse appears not to mutate the builder it does on the Sun JDK default implementation (based on Apache Xerces). Eccentric design decision. What can you do? I guess use a ThreadLocal: ``` private static final ThreadLocal<DocumentBuilder> builderLocal = new ThreadLocal<DocumentBuilder>() ...
56,767
<p>Is there a difference (performance, overhead) between these two ways of merging data sets?</p> <pre><code>MyTypedDataSet aDataSet = new MyTypedDataSet(); aDataSet .Merge(anotherDataSet); aDataSet .Merge(yetAnotherDataSet); </code></pre> <p>and</p> <pre><code>MyTypedDataSet aDataSet = anotherDataSet; aDataSet .Merge(...
[ { "answer_id": 56772, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 3, "selected": false, "text": "<p>Those two lines do different things.</p>\n\n<p>The first one creates a new set, and then merges a second set into it.</p>\n\n<...
2008/09/11
[ "https://Stackoverflow.com/questions/56767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
Is there a difference (performance, overhead) between these two ways of merging data sets? ``` MyTypedDataSet aDataSet = new MyTypedDataSet(); aDataSet .Merge(anotherDataSet); aDataSet .Merge(yetAnotherDataSet); ``` and ``` MyTypedDataSet aDataSet = anotherDataSet; aDataSet .Merge(yetAnotherDataSet); ``` Which do...
While Keith is right, I suppose the example was simply badly chosen. Generally, it is better to initialize to the “right” object from the beginning and *not* construct an intermediate, empty object as in your case. Two reasons: 1. Performance. This should be obvious: Object creation costs time so creating less objects...
56,801
<p>I was reviewing some code that a consultant checked in and notice they were using SQLCLR. I don't have any experience with it so thought I would research what it was about. I noticed that they used</p> <pre><code>Dim cn As New SqlConnection("server=LOCALHOST;integrated security=yes;database=" &amp; sDb) </code></...
[ { "answer_id": 56864, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 4, "selected": true, "text": "<p>The context connection uses the user's already established connection to the server. So you inherit things like their data...
2008/09/11
[ "https://Stackoverflow.com/questions/56801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2357/" ]
I was reviewing some code that a consultant checked in and notice they were using SQLCLR. I don't have any experience with it so thought I would research what it was about. I noticed that they used ``` Dim cn As New SqlConnection("server=LOCALHOST;integrated security=yes;database=" & sDb) ``` instead of ``` DIM con...
The context connection uses the user's already established connection to the server. So you inherit things like their database context, connection options, etc. Using localhost will connect to the server using a normal shared memory connection. This can be useful if you don't want to use the user's connection (i.e. if...
56,810
<p>I have used fork() in C to start another process. How do I start a new thread?</p>
[ { "answer_id": 56818, "author": "epatel", "author_id": 842, "author_profile": "https://Stackoverflow.com/users/842", "pm_score": 3, "selected": false, "text": "<p>pthreads is a good start, look <a href=\"https://computing.llnl.gov/tutorials/pthreads/\" rel=\"noreferrer\">here</a></p>\n" ...
2008/09/11
[ "https://Stackoverflow.com/questions/56810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077/" ]
I have used fork() in C to start another process. How do I start a new thread?
Since you mentioned fork() I assume you're on a Unix-like system, in which case [POSIX threads](http://en.wikipedia.org/wiki/POSIX_Threads) (usually referred to as pthreads) are what you want to use. Specifically, pthread\_create() is the function you need to create a new thread. Its arguments are: ``` int pthread_c...
56,812
<p>I'm trying to consume a SharePoint webservice from ColdFusion via cfinvoke ('cause I don't want to deal with (read: parse) the SOAP response itself).</p> <p>The SOAP response includes a byte-order-mark character (BOM), which produces the following exception in CF:</p> <pre><code>"Cannot perform web service invocat...
[ { "answer_id": 56896, "author": "matt b", "author_id": 4249, "author_profile": "https://Stackoverflow.com/users/4249", "pm_score": 0, "selected": false, "text": "<p>It sounds like ColdFusion is using Apache Axis under the covers.</p>\n\n<p>This doesn't apply exactly to your solution, but...
2008/09/11
[ "https://Stackoverflow.com/questions/56812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5849/" ]
I'm trying to consume a SharePoint webservice from ColdFusion via cfinvoke ('cause I don't want to deal with (read: parse) the SOAP response itself). The SOAP response includes a byte-order-mark character (BOM), which produces the following exception in CF: ``` "Cannot perform web service invocation GetList. The faul...
I'm going to say that the answer to your question (is it possible?) is no. I don't know that definitively, but the poster who commented just above halL ([in the comments on this page](http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_g-h_09.html#comments)) gave a work-around for the problem -- so I...
56,820
<p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html" rel="noreferrer">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p> <pre><code>n = 5.59 round(n, 1) # 5.6 </code></pre> <p>But, in actuality, good...
[ { "answer_id": 56832, "author": "ima", "author_id": 5733, "author_profile": "https://Stackoverflow.com/users/5733", "pm_score": -1, "selected": false, "text": "<p>What about:</p>\n\n<pre><code>round(n,1)+epsilon\n</code></pre>\n" }, { "answer_id": 56833, "author": "Jimmy", ...
2008/09/11
[ "https://Stackoverflow.com/questions/56820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/736/" ]
The documentation for the [round()](http://docs.python.org/lib/built-in-funcs.html) function states that you pass it a number, and the positions past the decimal to round. Thus it *should* do this: ``` n = 5.59 round(n, 1) # 5.6 ``` But, in actuality, good old floating point weirdness creeps in and you get: ``` 5.5...
I can't help the way it's stored, but at least formatting works correctly: ``` '%.1f' % round(n, 1) # Gives you '5.6' ```
56,837
<p>My problem is that my XML document contains snippets of XHTML within it and while passing it through an XSLT I would like it to render those snippets without mangling them.</p> <p>I've tried wrapping the snippet in a CDATA but it doesn't work since less than and greater than are translated to &lt; and &gt; as oppos...
[ { "answer_id": 56858, "author": "Apocalisp", "author_id": 3434, "author_profile": "https://Stackoverflow.com/users/3434", "pm_score": 0, "selected": false, "text": "<p>xsl:copy-of</p>\n" }, { "answer_id": 58466, "author": "DaveP", "author_id": 3577, "author_profile": ...
2008/09/11
[ "https://Stackoverflow.com/questions/56837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
My problem is that my XML document contains snippets of XHTML within it and while passing it through an XSLT I would like it to render those snippets without mangling them. I've tried wrapping the snippet in a CDATA but it doesn't work since less than and greater than are translated to < and > as opposed to being echo...
``` <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> ``` This is referred to as the "identity transformation" in the [XSLT specification](http://www.w3.org/TR/xslt#copying).
56,843
<p>I'm looking for a builder for <a href="http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html" rel="noreferrer">HQL</a> in Java. I want to get rid of things like:</p> <pre><code>StringBuilder builder = new StringBuilder() .append("select stock from ") .append( Stock.class.getName() ) .append(...
[ { "answer_id": 56866, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "<p>Doesn't the <a href=\"http://www.hibernate.org/hib_docs/v3/reference/en/html/querycriteria.html\" rel=\"noreferrer\">Crite...
2008/09/11
[ "https://Stackoverflow.com/questions/56843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2797/" ]
I'm looking for a builder for [HQL](http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html) in Java. I want to get rid of things like: ``` StringBuilder builder = new StringBuilder() .append("select stock from ") .append( Stock.class.getName() ) .append( " as stock where stock.id = ") .appen...
@[Sébastien Rocca-Serra](https://stackoverflow.com/questions/56843/looking-for-an-hql-builder-hibernate-query-language#57001) Now we're getting somewhere concrete. The sort of join you're trying to do isn't really possible through the Criteria API, but a sub-query should accomplish the same thing. First you create a...
56,865
<p>A simple question, but could someone provide sample code as to how would someone call a web service from within the JBoss Seam framework, and process the results?</p> <p>I need to be able to integrate with a search platform being provided by a private vendor who is exposing his functionality as a web service. So, I...
[ { "answer_id": 57090, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 0, "selected": false, "text": "<pre><code>import org.restlet.Client;\nimport org.restlet.data.Protocol;\nimport org.restlet.data.Reference;\nimport org.res...
2008/09/11
[ "https://Stackoverflow.com/questions/56865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
A simple question, but could someone provide sample code as to how would someone call a web service from within the JBoss Seam framework, and process the results? I need to be able to integrate with a search platform being provided by a private vendor who is exposing his functionality as a web service. So, I'm just lo...
There's roughly a gajillion HTTP client libraries (Restlet is quite a bit more than that, but I already had that code snippet for something else), but they should all provide support for sending GET requests. Here's a rather less featureful snippet that uses [HttpClient](http://hc.apache.org/httpclient-3.x/tutorial.htm...
56,867
<p>When should I use an interface and when should I use a base class? </p> <p>Should it always be an interface if I don't want to actually define a base implementation of the methods?</p> <p>If I have a Dog and Cat class. Why would I want to implement IPet instead of PetBase? I can understand having interfaces for IS...
[ { "answer_id": 56871, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 7, "selected": false, "text": "<p>Modern style is to define IPet <em>and</em> PetBase.</p>\n\n<p>The advantage of the interface is that other code can u...
2008/09/11
[ "https://Stackoverflow.com/questions/56867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2871/" ]
When should I use an interface and when should I use a base class? Should it always be an interface if I don't want to actually define a base implementation of the methods? If I have a Dog and Cat class. Why would I want to implement IPet instead of PetBase? I can understand having interfaces for ISheds or IBarks (I...
Let's take your example of a Dog and a Cat class, and let's illustrate using C#: Both a dog and a cat are animals, specifically, quadruped mammals (animals are waaay too general). Let us assume that you have an abstract class Mammal, for both of them: ```cs public abstract class Mammal ``` This base class will prob...
56,895
<p>How would you go about proving that two queries are functionally equivalent, eg they will always both return the same result set.</p> <hr> <p>As I had a specific query in mind when I was doing this, I ended up doing as @dougman suggested, over about 10% of rows the tables concerned and comparing the results, ensur...
[ { "answer_id": 56931, "author": "Rik", "author_id": 5409, "author_profile": "https://Stackoverflow.com/users/5409", "pm_score": 3, "selected": false, "text": "<p>This sounds to me like a an NP complete problem. I'm not sure there is a sure fire way to prove this kind of thing</p>\n" },...
2008/09/11
[ "https://Stackoverflow.com/questions/56895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
How would you go about proving that two queries are functionally equivalent, eg they will always both return the same result set. --- As I had a specific query in mind when I was doing this, I ended up doing as @dougman suggested, over about 10% of rows the tables concerned and comparing the results, ensuring there w...
The best you can do is compare the 2 query outputs based on a given set of inputs looking for any differences. To say that they will always return the same results for all inputs really depends on the data. For Oracle one of the better if not best approaches (very efficient) is here (`Ctrl`+`F` Comparing the Contents ...
56,905
<p>Ran into an “Out of Stack Space” error trying to serialize an ASP.Net AJAX Array object. </p> <p>Here is the scenario with simplified code:</p> <ol> <li><p><code>Default.aspx</code></p></li> <li><p><code>MainScript.js</code></p> <pre><code>function getObject(){ return new Array(); } function function1(obj){ ...
[ { "answer_id": 57433, "author": "d91-jal", "author_id": 5085, "author_profile": "https://Stackoverflow.com/users/5085", "pm_score": 0, "selected": false, "text": "<p>I have no way of testing your code right now, but it looks like a bug in JavaScriptSerializer.serialize to me. My guess is...
2008/09/11
[ "https://Stackoverflow.com/questions/56905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3635/" ]
Ran into an “Out of Stack Space” error trying to serialize an ASP.Net AJAX Array object. Here is the scenario with simplified code: 1. `Default.aspx` 2. `MainScript.js` ``` function getObject(){ return new Array(); } function function1(obj){ var s=Sys.Serialization.JavaScriptSerializer.serialize(obj); ...
This problem happens because Sys.Serialization.JavaScriptSerializer can't serialize objects from others frames, but only those objects which where instantiated in the current window (which calls serialize() method). The only workaround which is known for me it's making clone of the object from other frame before callin...
56,908
<p>Is there any way to create a virtual drive in "(My) Computer" and manipulate it, somewhat like JungleDisk does it?</p> <p>It probably does something like:</p> <pre><code>override OnRead(object sender, Event e) { ShowFilesFromAmazon(); } </code></pre> <p>Are there any API:s for this? Maybe to write to an XML-f...
[ { "answer_id": 56919, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 2, "selected": false, "text": "<p>Yes, use the classes in <a href=\"http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.aspx\" rel=\"nofo...
2008/09/11
[ "https://Stackoverflow.com/questions/56908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
Is there any way to create a virtual drive in "(My) Computer" and manipulate it, somewhat like JungleDisk does it? It probably does something like: ``` override OnRead(object sender, Event e) { ShowFilesFromAmazon(); } ``` Are there any API:s for this? Maybe to write to an XML-file or a database, instead of a r...
You can use the [Dokan library](https://dokan-dev.github.io/) to create a virtual drive. There is a .Net wrapper for interfacing with C#.
56,913
<p>I have a whole bunch of files with filenames using our lovely Swedish letters <strong>å å</strong> and <strong>ö</strong>. For various reasons I now need to convert these to an [a-zA-Z] range. Just removing anything outside this range is fairly easy. The thing that's causing me trouble is that I'd like to replace <s...
[ { "answer_id": 56924, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 0, "selected": false, "text": "<p>I would write this in C++, C#, or Java -- environments where I know for certain that you can get the Unicode character...
2008/09/11
[ "https://Stackoverflow.com/questions/56913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/914/" ]
I have a whole bunch of files with filenames using our lovely Swedish letters **å å** and **ö**. For various reasons I now need to convert these to an [a-zA-Z] range. Just removing anything outside this range is fairly easy. The thing that's causing me trouble is that I'd like to replace **å** with **a**, **ö** with **...
You can use this code (Python) Rename international files ========================== ``` # -*- coding: cp1252 -*- import os, shutil base_dir = "g:\\awk\\" # Base Directory (includes subdirectories) char_table_1 = "áéíóúñ" char_table_2 = "aeioun" adirs = os.walk (base_dir) for adir in adirs: dir = adir[0] +...
56,943
<p>I'm looking for a simple solution for a yes/no dialog to use in a Java ME midlet. I'd like to use it like this but other ways are okey.</p> <pre><code>if (YesNoDialog.ask("Are you sure?") == true) { // yes was chosen } else { // no was chosen } </code></pre>
[ { "answer_id": 56970, "author": "Telcontar", "author_id": 518, "author_profile": "https://Stackoverflow.com/users/518", "pm_score": -1, "selected": false, "text": "<p>I dont have programed in Java ME, but i found in it's reference for optional packages the\n<a href=\"http://java.sun.com/...
2008/09/11
[ "https://Stackoverflow.com/questions/56943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5896/" ]
I'm looking for a simple solution for a yes/no dialog to use in a Java ME midlet. I'd like to use it like this but other ways are okey. ``` if (YesNoDialog.ask("Are you sure?") == true) { // yes was chosen } else { // no was chosen } ```
You need an [Alert](http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Alert.html): > > An alert is a screen that shows data to the user and waits for a certain period of time before proceeding to the next Displayable. An alert can contain a text string and an image. The intended use of Alert i...
56,946
<p>Say I have:</p> <pre><code>&lt;ul&gt; &lt;li id="x"&gt; &lt;a href="x"&gt;x&lt;/a&gt; &lt;/li&gt; &lt;li id="y"&gt; &lt;a href="y"&gt;y&lt;/a&gt; &lt;ul&gt; &lt;li id="z"&gt; &lt;a href="z"&gt;z&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; ...
[ { "answer_id": 56958, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 0, "selected": false, "text": "<p>I suggest you parse it into a DOM and recurse backwards like you were thinking. Regular expressions don't work very well fo...
2008/09/11
[ "https://Stackoverflow.com/questions/56946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Say I have: ``` <ul> <li id="x"> <a href="x">x</a> </li> <li id="y"> <a href="y">y</a> <ul> <li id="z"> <a href="z">z</a> </li> </ul> </li> </ul> ``` I want to add a class value to all the list items that are the parents of z. ...
I would use XSLT. You can specify to search for nodes that are ancestors of z .
56,950
<p>We all know T-SQL's string manipulation capabilities sometimes leaves much to be desired...</p> <p>I have a numeric field that needs to be output in T-SQL as a right-aligned text column. Example:</p> <pre><code>Value ---------- 143.55 3532.13 1.75 </code></pre> <p>How would you go about that? A good sol...
[ { "answer_id": 56972, "author": "d91-jal", "author_id": 5085, "author_profile": "https://Stackoverflow.com/users/5085", "pm_score": 5, "selected": true, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/ms189527.aspx\" rel=\"noreferrer\">STR function</a> has an optional l...
2008/09/11
[ "https://Stackoverflow.com/questions/56950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2230/" ]
We all know T-SQL's string manipulation capabilities sometimes leaves much to be desired... I have a numeric field that needs to be output in T-SQL as a right-aligned text column. Example: ``` Value ---------- 143.55 3532.13 1.75 ``` How would you go about that? A good solution ought to be clear and compa...
The [STR function](http://msdn.microsoft.com/en-us/library/ms189527.aspx) has an optional length argument as well as a number-of-decimals one. ``` SELECT STR(123.45, 6, 1) ------ 123.5 (1 row(s) affected) ```
56,954
<p>The code</p> <pre><code>private SomeClass&lt;Integer&gt; someClass; someClass = EasyMock.createMock(SomeClass.class); </code></pre> <p>gives me a warning "Type safety: The expression of type SomeClass needs unchecked conversion to conform to SomeClass&lt;Integer&gt;".</p>
[ { "answer_id": 56996, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 2, "selected": false, "text": "<p>The two obvious routes are to suppress the warning or mock a subclass.</p>\n\n<pre><code>private static clas...
2008/09/11
[ "https://Stackoverflow.com/questions/56954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4792/" ]
The code ``` private SomeClass<Integer> someClass; someClass = EasyMock.createMock(SomeClass.class); ``` gives me a warning "Type safety: The expression of type SomeClass needs unchecked conversion to conform to SomeClass<Integer>".
AFAIK, you can't avoid the unchecked warning when a class name literal is involved, and the `SuppressWarnings` annotation is the only way to handle this. Note that it is good form to narrow the scope of the `SuppressWarnings` annotation as much as possible. You can apply this annotation to a single local variable assi...
56,968
<p>I'm trying to attach an instance of UIScrollbar component to a dynamic text field inside of an instance of a class that is being made after some XML is loaded. The scroll bar component is getting properly attached, as the size of the slider varies depending on the amount of content in the text field, however, it won...
[ { "answer_id": 57197, "author": "Jeff Winkworth", "author_id": 1306, "author_profile": "https://Stackoverflow.com/users/1306", "pm_score": 0, "selected": false, "text": "<p>Have you tried putting the UI scrollbar onto the stage, binding it to the textfield at design time, and then callin...
2008/09/11
[ "https://Stackoverflow.com/questions/56968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to attach an instance of UIScrollbar component to a dynamic text field inside of an instance of a class that is being made after some XML is loaded. The scroll bar component is getting properly attached, as the size of the slider varies depending on the amount of content in the text field, however, it won't ...
You might try adding the scrollbar once your textfield is initialized from a separate function similar to this: ``` private function assignScrollBar(tf:TextField, sb:UIScrollBar):void { trace("assigning scrollbar"); sb.move(tf.x + tf.width, tf.y); sb.setSize(15, tf.height); sb.direction = ScrollBarDire...
56,974
<p>In the following snippet:</p> <pre><code>public class a { public void otherMethod(){} public void doStuff(String str, InnerClass b){} public void method(a){ doStuff("asd", new InnerClass(){ public void innerMethod(){ otherMethod(); ...
[ { "answer_id": 56987, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 9, "selected": true, "text": "<p>In general you use <code>OuterClassName.this</code> to refer to the enclosing instance of the outer class.</p>\n\n<...
2008/09/11
[ "https://Stackoverflow.com/questions/56974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/292/" ]
In the following snippet: ``` public class a { public void otherMethod(){} public void doStuff(String str, InnerClass b){} public void method(a){ doStuff("asd", new InnerClass(){ public void innerMethod(){ otherMethod(); } ...
In general you use `OuterClassName.this` to refer to the enclosing instance of the outer class. In your example that would be `a.this.otherMethod()`
56,975
<p>I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem with this is that it's slow. Each email takes about 5-10 seconds to send (it's possible this is just an issue with my host). I had to override the executionTimeout default in my web.config file (it defa...
[ { "answer_id": 56988, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 4, "selected": true, "text": "<p>You could send the mail asynchronous. That way the timeout should not interrupt your sending.</p>\n\n<p>This article should he...
2008/09/11
[ "https://Stackoverflow.com/questions/56975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4965/" ]
I'm currently looping through a datareader and calling the System.Net.Mail.SmtpClient's Send() method. The problem with this is that it's slow. Each email takes about 5-10 seconds to send (it's possible this is just an issue with my host). I had to override the executionTimeout default in my web.config file (it default...
You could send the mail asynchronous. That way the timeout should not interrupt your sending. This article should help you get started with that: [Sending Emails Asynchronously in C#](http://www.eggheadcafe.com/articles/20030720.asp). There is another approach here: <http://www.vikramlakhotia.com/Sending_Email_asynch...
57,010
<p>Please, now that I've re-written the question, and before it suffers from further <a href="https://stackoverflow.com/questions/56103/fastest-gun-in-the-west-problem">fast-gun answers</a> or premature closure by <a href="https://stackoverflow.com/users/905/keith">eager editors</a> let me point out that this is not a ...
[ { "answer_id": 57013, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 1, "selected": false, "text": "<p>I would dump them all into your favorite Set implementation.</p>\n\n<p>EDIT: Now that I understand the question, ...
2008/09/11
[ "https://Stackoverflow.com/questions/57010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4200/" ]
Please, now that I've re-written the question, and before it suffers from further [fast-gun answers](https://stackoverflow.com/questions/56103/fastest-gun-in-the-west-problem) or premature closure by [eager editors](https://stackoverflow.com/users/905/keith) let me point out that this is not a duplicate of [this questi...
Here's C# app i wrote that solves this problem. **takes** aabccacdcd **outputs** abcacd Probably looks pretty messy, took me a bit to get my head around the dynamic pattern length bit. ``` class Program { private static List<string> values; private const int MAX_PATTERN_LENGTH = 4; static void ...
57,020
<p>Was considering the <code>System.Collections.ObjectModel ObservableCollection&lt;T&gt;</code> class. This one is strange because </p> <ul> <li>it has an Add Method which takes <strong>one</strong> item only. No AddRange or equivalent. </li> <li>the Notification event arguments has a NewItems property, which is a <...
[ { "answer_id": 57029, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p>Inherit from List&lt;T> and override the Add() and AddRange() methods to raise an event?</p>\n" }, { "answer...
2008/09/11
[ "https://Stackoverflow.com/questions/57020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
Was considering the `System.Collections.ObjectModel ObservableCollection<T>` class. This one is strange because * it has an Add Method which takes **one** item only. No AddRange or equivalent. * the Notification event arguments has a NewItems property, which is a **IList** (of objects.. not T) My need here is to add...
It seems that the `INotifyCollectionChanged` interface allows for updating when multiple items were added, so I'm not sure why `ObservableCollection<T>` doesn't have an `AddRange`. You could make an extension method for `AddRange`, but that would cause an event for every item that is added. If that isn't acceptable you...
57,054
<p>I've got a collection that implements an interface that extends both IList&lt;T> and List. </p> <pre><code>public Interface IMySpecialCollection : IList&lt;MyObject&gt;, IList { ... } </code></pre> <p>That means I have two versions of the indexer. </p> <p>I wish the generic implementation to be used, so I implem...
[ { "answer_id": 57072, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": -1, "selected": false, "text": "<p>List&lt;T> implies IList, so it's a bad idea to use both in the same class.</p>\n" }, { "answer_id": 57084,...
2008/09/11
[ "https://Stackoverflow.com/questions/57054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got a collection that implements an interface that extends both IList<T> and List. ``` public Interface IMySpecialCollection : IList<MyObject>, IList { ... } ``` That means I have two versions of the indexer. I wish the generic implementation to be used, so I implement that one normally: ``` public MyObject...
You can't do this with `public interface IMySpecialCollection : IList<MyObject>, IList { ... }` But you can do what you want with a class, you will need to make the implementations for one of the interfaces explicit. In my example I made IList explicit. `public class MySpecialCollection : IList<MyObject>, IList { ....
57,091
<p>Let's say I have a parent DIV. Inside, there are three child DIVs: header, content and footer. Header is attached to the top of the parent and fills it horizontally. Footer is attached to the bottom of the parent and fills it horizontally too. Content is supposed to fill all the space between header and footer.</p> ...
[ { "answer_id": 57119, "author": "rpetrich", "author_id": 4007, "author_profile": "https://Stackoverflow.com/users/4007", "pm_score": 0, "selected": false, "text": "<p>Absolute positioning is messing you up. Try something like this:</p>\n\n<p>HTML:</p>\n\n<pre><code>&lt;div id=\"wrapper\"...
2008/09/11
[ "https://Stackoverflow.com/questions/57091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5348/" ]
Let's say I have a parent DIV. Inside, there are three child DIVs: header, content and footer. Header is attached to the top of the parent and fills it horizontally. Footer is attached to the bottom of the parent and fills it horizontally too. Content is supposed to fill all the space between header and footer. The pa...
I'm going to get downmodded for this, but this sounds like a job for a table. What you're trying to do is to set the total height of three contiguous divs as a unit, and a 1x3 table with height 100% is actually a cleaner solution.
57,094
<p>I have ASP.NET web pages for which I want to build automated tests (using WatiN &amp; MBUnit). How do I start the ASP.Net Development Server from my code? I do not want to use IIS.</p>
[ { "answer_id": 57105, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 4, "selected": true, "text": "<p>From what I know, you can fire up the dev server from the command prompt with the following path/syntax:</p>\n\n<pre><code>C:\...
2008/09/11
[ "https://Stackoverflow.com/questions/57094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
I have ASP.NET web pages for which I want to build automated tests (using WatiN & MBUnit). How do I start the ASP.Net Development Server from my code? I do not want to use IIS.
From what I know, you can fire up the dev server from the command prompt with the following path/syntax: ``` C:\Windows\Microsoft.NET\Framework\v2.0.50727\Webdev.WebServer.exe /port:[PORT NUMBER] /path: [PATH TO ROOT] ``` ...so I could imagine you could easily use Process.Start() to launch the particulars you need t...
57,104
<p>I'm going to be starting a project soon that requires support for large-ish binary files. I'd like to use Ruby on Rails for the webapp, but I'm concerned with the BLOB support. In my experience with other languages, frameworks, and databases, BLOBs are often overlooked and thus have poor, difficult, and/or buggy fun...
[ { "answer_id": 57112, "author": "Teflon Ted", "author_id": 4061, "author_profile": "https://Stackoverflow.com/users/4061", "pm_score": 2, "selected": false, "text": "<p>I think your best bet is the attachment_fu plug-in:\n<a href=\"http://github.com/technoweenie/attachment_fu/tree/master...
2008/09/11
[ "https://Stackoverflow.com/questions/57104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
I'm going to be starting a project soon that requires support for large-ish binary files. I'd like to use Ruby on Rails for the webapp, but I'm concerned with the BLOB support. In my experience with other languages, frameworks, and databases, BLOBs are often overlooked and thus have poor, difficult, and/or buggy functi...
+1 for attachment\_fu I use attachment\_fu in one of my apps and MUST store files in the DB (for annoying reasons which are outside the scope of this convo). The (one?) tricky thing dealing w/BLOB's I've found is that you need a separate code path to send the data to the user -- you can't simply in-line a path on the...
57,124
<p>I know I can call the GetVersionEx Win32 API function to retrieve Windows version. In most cases returned value reflects the version of my Windows, but sometimes that is not so.</p> <p>If a user runs my application under the compatibility layer, then GetVersionEx won't be reporting the real version but the version ...
[ { "answer_id": 57128, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 5, "selected": false, "text": "<p>WMI QUery:</p>\n\n<pre><code>\"Select * from Win32_OperatingSystem\"\n</code></pre>\n\n<p>EDIT: Actually better would be:<...
2008/09/11
[ "https://Stackoverflow.com/questions/57124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4997/" ]
I know I can call the GetVersionEx Win32 API function to retrieve Windows version. In most cases returned value reflects the version of my Windows, but sometimes that is not so. If a user runs my application under the compatibility layer, then GetVersionEx won't be reporting the real version but the version enforced b...
The best approach I know is to check if specific API is exported from some DLL. Each new Windows version adds new functions and by checking the existance of those functions one can tell which OS the application is running on. For example, Vista exports [GetLocaleInfoEx](http://msdn.microsoft.com/en-us/library/ms724451(...
57,140
<p>Say instead of returning void a method you returned a reference to the class even if it didn't make any particular semantic sense. It seems to me like it would give you more options on how the methods are called, allowing you to use it in a fluent-interface-like style and I can't really think of any disadvantages s...
[ { "answer_id": 57165, "author": "argv0", "author_id": 5595, "author_profile": "https://Stackoverflow.com/users/5595", "pm_score": 2, "selected": false, "text": "<p>Returning \"self\" or \"this\" is a common pattern, sometimes referred to as <a href=\"http://www.martinfowler.com/dslwip/Me...
2008/09/11
[ "https://Stackoverflow.com/questions/57140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
Say instead of returning void a method you returned a reference to the class even if it didn't make any particular semantic sense. It seems to me like it would give you more options on how the methods are called, allowing you to use it in a fluent-interface-like style and I can't really think of any disadvantages since...
I know in Java they're actually thinking about making this standard behaviour for void methods. If you do that you don't need the extra syntactic sugar. The only downside I can think of is performance. But that's easilly measured. I'll get back to you with the results in a few minutes :-) Edit: Returning a reference...
57,145
<p>While creating classes in Java I often find myself creating instance-level collections that I know ahead of time will be very small - less than 10 items in the collection. But I don't know the number of items ahead of time so I typically opt for a dynamic collection (ArrayList, Vector, etc).</p> <pre><code>class Fo...
[ { "answer_id": 57177, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 1, "selected": false, "text": "<p>The overhead is very small. It is possible to write a hybrid array list that has fields for the first few it...
2008/09/11
[ "https://Stackoverflow.com/questions/57145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2881/" ]
While creating classes in Java I often find myself creating instance-level collections that I know ahead of time will be very small - less than 10 items in the collection. But I don't know the number of items ahead of time so I typically opt for a dynamic collection (ArrayList, Vector, etc). ``` class Foo { ArrayLis...
The `ArrayList` class in Java has only two data members, a reference to an `Object[]` array and a size—which you need anyway if you don't use an `ArrayList`. So the only advantage to not using an `ArrayList` is saving one object allocation, which is unlikely ever to be a big deal. If you're creating and disposing of m...
57,152
<p>Let's say I've got Alpha things that may or may not <em>be</em> or be <em>related to</em> Bravo or Charlie things.</p> <p>These are one-to-one relationships: No Alpha will relate to more than one Bravo. And no Bravo will relate to more than one Alpha.</p> <p>I've got a few goals:</p> <ul> <li>a system that's eas...
[ { "answer_id": 57164, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 1, "selected": false, "text": "<p>One more approach is having 3 tables for storing the 3 entities and having a separate table for storing the relations...
2008/09/11
[ "https://Stackoverflow.com/questions/57152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
Let's say I've got Alpha things that may or may not *be* or be *related to* Bravo or Charlie things. These are one-to-one relationships: No Alpha will relate to more than one Bravo. And no Bravo will relate to more than one Alpha. I've got a few goals: * a system that's easy to learn and maintain. * data integrity e...
If you want each Alpha to be related to by only one Bravo I would vote for the possibility with using a combined FK/PK: ``` Bravos -------- FK PK AlphaId BravoOne BravoTwo BravoThree ``` This way one and only one Bravo may refer to your Alphas. If the Bravos and Charlies have to be mut...
57,168
<p>I have two identical tables and need to copy rows from table to another. What is the best way to do that? (I need to programmatically copy just a few rows, I don't need to use the bulk copy utility).</p>
[ { "answer_id": 57172, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 3, "selected": false, "text": "<pre><code>SELECT * INTO &lt; new_table &gt; FROM &lt; existing_table &gt; WHERE &lt; clause &gt;\n</code></pre>\n" }...
2008/09/11
[ "https://Stackoverflow.com/questions/57168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536/" ]
I have two identical tables and need to copy rows from table to another. What is the best way to do that? (I need to programmatically copy just a few rows, I don't need to use the bulk copy utility).
As long as there are no identity columns you can just ``` INSERT INTO TableNew SELECT * FROM TableOld WHERE [Conditions] ```
57,183
<p>How do I get the history of commits that have been made to the repository for a particular user? </p> <p>I am able to access CVS either through the command line or TortioseCVS, so a solution using either method is sufficient.</p>
[ { "answer_id": 57218, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 4, "selected": true, "text": "<pre><code>cvs history -u username\n</code></pre>\n\n<p>gives a history of changes the user has made</p>\n" }, { ...
2008/09/11
[ "https://Stackoverflow.com/questions/57183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3498/" ]
How do I get the history of commits that have been made to the repository for a particular user? I am able to access CVS either through the command line or TortioseCVS, so a solution using either method is sufficient.
``` cvs history -u username ``` gives a history of changes the user has made
57,202
<p>I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created. </p> <p>How can I make the dialog box show something like this:</p> <pre><code>There was an error. Go to this page to fix it. wwww.TheWebPag...
[ { "answer_id": 57204, "author": "Matthias Winkelmann", "author_id": 4494, "author_profile": "https://Stackoverflow.com/users/4494", "pm_score": 3, "selected": false, "text": "<p>You can't. Alert boxes don't support html. You should display the error as part of the page, it's nicer than J...
2008/09/11
[ "https://Stackoverflow.com/questions/57202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created. How can I make the dialog box show something like this: ``` There was an error. Go to this page to fix it. wwww.TheWebPageToFix.com ``` Than...
You could try asking them if they wish to visit via window.prompt: ``` if(window.prompt('Do you wish to visit the following website?','http://www.google.ca')) location.href='http://www.google.ca/'; ``` Also, Internet Explorer supports modal dialogs so you could try showing one of those: ``` if (window.showModalDi...
57,238
<p>Say I have several JavaScript includes in a page:</p> <pre><code>&lt;script type="text/javascript" src="/js/script0.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/js/script1.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/js/script2.js"&gt;&lt;/script&gt; &lt;script type="text/javascr...
[ { "answer_id": 57246, "author": "Alex Argo", "author_id": 5885, "author_profile": "https://Stackoverflow.com/users/5885", "pm_score": 4, "selected": true, "text": "<p>If you get the <a href=\"https://addons.mozilla.org/en-US/firefox/addon/1843\" rel=\"noreferrer\" title=\"Firebug\">Fireb...
2008/09/11
[ "https://Stackoverflow.com/questions/57238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
Say I have several JavaScript includes in a page: ``` <script type="text/javascript" src="/js/script0.js"></script> <script type="text/javascript" src="/js/script1.js"></script> <script type="text/javascript" src="/js/script2.js"></script> <script type="text/javascript" src="/js/script3.js"></script> <script type="tex...
If you get the [Firebug](https://addons.mozilla.org/en-US/firefox/addon/1843 "Firebug") firefox plugin and enable the consoles it should tell you when there are errors retrieving resources in the console.
57,243
<p>I am trying to do something I've done a million times and it's not working, can anyone tell me why?</p> <p>I have a table for people who sent in resumes, and it has their email address in it...</p> <p>I want to find out if any of these people have NOT signed up on the web site. The aspnet_Membership table has all ...
[ { "answer_id": 57251, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>You could have a lot of duplicates out there. I'm not seeing the query error off the top of my head, but you might ...
2008/09/11
[ "https://Stackoverflow.com/questions/57243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5255/" ]
I am trying to do something I've done a million times and it's not working, can anyone tell me why? I have a table for people who sent in resumes, and it has their email address in it... I want to find out if any of these people have NOT signed up on the web site. The aspnet\_Membership table has all the people who A...
We had a very similar problem recently where the subquery was returning null values sometimes. Then, the in statement treats null in a weird way, I think always matching the value, so if you change your query to: ``` select j.email from jobseeker j where j.email not in (select email from aspnet_Membership ...
57,350
<p>I want to point a file dialog at a particular folder in the current user's Local Settings folder on Windows. What is the shortcut to get this path?</p>
[ { "answer_id": 57361, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "<p>Environment.GetFolderPath( Environment.SpecialFolders.LocalApplicationData);?</p>\n\n<p>I can't remember if there is a \"L...
2008/09/11
[ "https://Stackoverflow.com/questions/57350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
I want to point a file dialog at a particular folder in the current user's Local Settings folder on Windows. What is the shortcut to get this path?
How about this, for example: ``` String appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); ``` I don't see an enum for just the Local Settings folder. <http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx> has a list...
57,355
<p>I'm having a little trouble figuring out exactly how const applies in a specific case. Here's the code I have:</p> <pre><code>struct Widget { Widget():x(0), y(0), z(0){} int x, y, z; }; struct WidgetHolder //Just a simple struct to hold four Widgets. { WidgetHolder(Widget a, Widget b, Widget c, Widget...
[ { "answer_id": 57364, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 2, "selected": false, "text": "<p>unchangeable.AccessWidgets():</p>\n\n<p>At this point, you are creating a new object of type WidgetHolder. \nThis o...
2008/09/11
[ "https://Stackoverflow.com/questions/57355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3175/" ]
I'm having a little trouble figuring out exactly how const applies in a specific case. Here's the code I have: ``` struct Widget { Widget():x(0), y(0), z(0){} int x, y, z; }; struct WidgetHolder //Just a simple struct to hold four Widgets. { WidgetHolder(Widget a, Widget b, Widget c, Widget d): A(a), B(b...
This compiles because although the WidgetHolder is a const object, this const-ness does not automatically apply to objects pointed to (referenced by) the WidgetHolder. Think of it at a machine level - if the WidgetHolder object itself were held in read-only memory, you could still write to things that were pointed to b...
57,380
<p>Will the code below work if the clock on the server is ahead of the clock on the client?</p> <pre><code>Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1)) </code></pre> <p>EDIT: the reason I ask is on one of our web apps some users are claiming they are seeing the pages ( account numbers, etc ) from a user tha...
[ { "answer_id": 57407, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 3, "selected": true, "text": "<p><a href=\"https://stackoverflow.com/questions/49547/making-sure-a-webpage-is-not-cached-across-all-browsers\">This quest...
2008/09/11
[ "https://Stackoverflow.com/questions/57380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2357/" ]
Will the code below work if the clock on the server is ahead of the clock on the client? ``` Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1)) ``` EDIT: the reason I ask is on one of our web apps some users are claiming they are seeing the pages ( account numbers, etc ) from a user that previously used that mac...
[This question](https://stackoverflow.com/questions/49547/making-sure-a-webpage-is-not-cached-across-all-browsers) covers making sure a webpage is not cached. It seems you have to set several properties to ensure a web page is not cached across all browsers.
57,383
<p>I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it?<br> I am rethrowing the InnerException, but this destroys the stack trace.<br> Example code:</p> <pre><code>public void test1() { // Throw an exceptio...
[ { "answer_id": 57387, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 5, "selected": false, "text": "<p>I think your best bet would be to just put this in your catch block:</p>\n\n<pre><code>throw;\n</code></pre>\n\n<p>And the...
2008/09/11
[ "https://Stackoverflow.com/questions/57383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3205/" ]
I am calling, through reflection, a method which may cause an exception. How can I pass the exception to my caller without the wrapper reflection puts around it? I am rethrowing the InnerException, but this destroys the stack trace. Example code: ``` public void test1() { // Throw an exception for testing pu...
In **.NET 4.5** there is now the [`ExceptionDispatchInfo`](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.exceptionservices.exceptiondispatchinfo) class. This lets you capture an exception and re-throw it without changing the stack-trace: ``` using ExceptionDispatchInfo = System.Runtime.ExceptionSer...
57,421
<p>I would like to make an ajax call to a different server (same domain and box, just a different port.) e.g.</p> <p>My page is</p> <pre> http://localhost/index.html </pre> <p>I would like to make a ajax get request to:</p> <pre> http://localhost:7076/?word=foo </pre> <p>I am getting this error:</p> <pre> Access ...
[ { "answer_id": 57435, "author": "Joseph Bui", "author_id": 3275, "author_profile": "https://Stackoverflow.com/users/3275", "pm_score": 3, "selected": true, "text": "<p>Have a certain page on your port 80 server proxy requests to the other port. For example:</p>\n\n<pre><code>http://local...
2008/09/11
[ "https://Stackoverflow.com/questions/57421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
I would like to make an ajax call to a different server (same domain and box, just a different port.) e.g. My page is ``` http://localhost/index.html ``` I would like to make a ajax get request to: ``` http://localhost:7076/?word=foo ``` I am getting this error: ``` Access to restricted URI denied (NS_ERROR_...
Have a certain page on your port 80 server proxy requests to the other port. For example: ``` http://localhost/proxy?port=7076&url=%2f%3fword%3dfoo ``` Note the url encoding on the last query string argument value.
57,439
<p>No, this is not a question about generics.</p> <p>I have a Factory pattern with several classes with internal constructors (I don't want them being instantiated if not through the factory).</p> <p>My problem is that <code>CreateInstance</code> fails with a "No parameterless constructor defined for this object" err...
[ { "answer_id": 57450, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 5, "selected": true, "text": "<p>To get around this, couldnt you just alter your usage as such:</p>\n\n<pre><code>public class GenericFactory&lt;T&gt; whe...
2008/09/11
[ "https://Stackoverflow.com/questions/57439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
No, this is not a question about generics. I have a Factory pattern with several classes with internal constructors (I don't want them being instantiated if not through the factory). My problem is that `CreateInstance` fails with a "No parameterless constructor defined for this object" error unless I pass "true" on t...
To get around this, couldnt you just alter your usage as such: ``` public class GenericFactory<T> where T : MyAbstractType { public static T GetInstance() { return Activator.CreateInstance(typeof(T), true); } } ``` Your factory method will still be generic, but the call to the activator will not ...
57,479
<p>Help! I am using jQuery to make an AJAX call to fill in a drop-down dynamically given the user's previous input (from another drop-down, that is filled server-side). In all other browsers aside from Firefox (IE6/7, Opera, Safari), my append call actually appends the information below my existing option - "Select An ...
[ { "answer_id": 57514, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 0, "selected": false, "text": "<p>I just did the following and it worked fine:</p>\n\n<pre><code>&lt;select name=\"Products\" id=\"Products\"&gt;\n&lt;o...
2008/09/11
[ "https://Stackoverflow.com/questions/57479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5405/" ]
Help! I am using jQuery to make an AJAX call to fill in a drop-down dynamically given the user's previous input (from another drop-down, that is filled server-side). In all other browsers aside from Firefox (IE6/7, Opera, Safari), my append call actually appends the information below my existing option - "Select An ". ...
Can you just change your success function to reset the selected item to the first option? ``` $("#Products").append(result).selectedIndex = 0; ``` or to set it to the previous selection? ``` var tmpIdx = $("#Products").selectedIndex; $("#Products").append(result).selectedIndex = tmpIdx; ``` If the onChange event ...
57,483
<p>What is the difference between a pointer variable and a reference variable?</p>
[ { "answer_id": 57490, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": false, "text": "<p>Apart from syntactic sugar, a reference is a <code>const</code> pointer (<em>not</em> pointer to a <code>const</code>). You ...
2008/09/11
[ "https://Stackoverflow.com/questions/57483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/123/" ]
What is the difference between a pointer variable and a reference variable?
1. A pointer can be re-assigned: ``` int x = 5; int y = 6; int *p; p = &x; p = &y; *p = 10; assert(x == 5); assert(y == 10); ``` A reference cannot be re-bound, and must be bound at initialization: ``` int x = 5; int y = 6; int &q; // error int &r = x; ``` 2. A pointer variable has its own identity: a distinct, vi...
57,484
<p>I'm trying to do a basic "OR" on three fields using a hibernate criteria query.</p> <p>Example</p> <pre><code>class Whatever{ string name; string address; string phoneNumber; } </code></pre> <p>I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".</p>
[ { "answer_id": 57526, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 8, "selected": true, "text": "<p>You want to use <code>Restrictions.disjuntion()</code>. Like so</p>\n\n<pre><code>session.createCriteria(Whatever.class)\n ...
2008/09/11
[ "https://Stackoverflow.com/questions/57484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1310/" ]
I'm trying to do a basic "OR" on three fields using a hibernate criteria query. Example ``` class Whatever{ string name; string address; string phoneNumber; } ``` I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber".
You want to use `Restrictions.disjuntion()`. Like so ``` session.createCriteria(Whatever.class) .add(Restrictions.disjunction() .add(Restrictions.eq("name", queryString)) .add(Restrictions.eq("address", queryString)) .add(Restrictions.eq("phoneNumber", queryString)) ); ``` See the Hib...
57,488
<p>Does anyone know of a way to declare a date constant that is compatible with international dates?</p> <p>I've tried:</p> <pre><code>' not international compatible public const ADate as Date = #12/31/04# ' breaking change if you have an optional parameter that defaults to this value ' because it isnt constant. pub...
[ { "answer_id": 57511, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 0, "selected": false, "text": "<p>OK, I am unsure what you are trying to do here:</p>\n\n<ul>\n<li>The code you are posting is <strong>NOT</strong> .NET, a...
2008/09/11
[ "https://Stackoverflow.com/questions/57488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5966/" ]
Does anyone know of a way to declare a date constant that is compatible with international dates? I've tried: ``` ' not international compatible public const ADate as Date = #12/31/04# ' breaking change if you have an optional parameter that defaults to this value ' because it isnt constant. public shared readonly A...
If you look at the IL generated by the statement ``` public const ADate as Date = #12/31/04# ``` You'll see this: ``` .field public static initonly valuetype [mscorlib]System.DateTime ADate .custom instance void [mscorlib]System.Runtime.CompilerServices.DateTimeConstantAttribute::.ctor(int64) = ( 01 00 00 C0 2F CE ...
57,493
<p>In my WPF application, I have a number of databound TextBoxes. The <code>UpdateSourceTrigger</code> for these bindings is <code>LostFocus</code>. The object is saved using the File menu. The problem I have is that it is possible to enter a new value into a TextBox, select Save from the File menu, and never persist t...
[ { "answer_id": 57506, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 2, "selected": false, "text": "<p>Have you tried setting the UpdateSourceTrigger to PropertyChanged? Alternatively, you could call the UpdateSOurce() metho...
2008/09/11
[ "https://Stackoverflow.com/questions/57493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/317/" ]
In my WPF application, I have a number of databound TextBoxes. The `UpdateSourceTrigger` for these bindings is `LostFocus`. The object is saved using the File menu. The problem I have is that it is possible to enter a new value into a TextBox, select Save from the File menu, and never persist the new value (the one vis...
> > Suppose you have a TextBox in a window, and a ToolBar with a Save button in it. Assume the TextBox’s Text property is bound to a property on a business object, and the binding’s UpdateSourceTrigger property is set to the default value of LostFocus, meaning that the bound value is pushed back to the business object...
57,522
<p>I can create the following and reference it using</p> <pre><code>area[0].states[0] area[0].cities[0] var area = [ { "State" : "Texas", "Cities" : ['Austin','Dallas','San Antonio'] }, { "State" :"Arkansas", "Cities" : ['Little Rock','Texarkana','Hot...
[ { "answer_id": 57531, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 2, "selected": true, "text": "<p>If you want to just create it that way to begin with, just say</p>\n\n<pre><code>area = {\n \"Texas\": ['Austin'...
2008/09/11
[ "https://Stackoverflow.com/questions/57522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
I can create the following and reference it using ``` area[0].states[0] area[0].cities[0] var area = [ { "State" : "Texas", "Cities" : ['Austin','Dallas','San Antonio'] }, { "State" :"Arkansas", "Cities" : ['Little Rock','Texarkana','Hot Springs'] ...
If you want to just create it that way to begin with, just say ``` area = { "Texas": ['Austin','Dallas','San Antonio'] } ``` and so on. If you're asking how to take an existing object and convert it into this, just say ``` states = {} for(var j=0; j<area.length; j++) states[ area[0].State ] = area[0].Cities...
57,537
<p>In my Servlet I would like to access the root of the context so that I can do some JavaScript minifying.</p> <p>It would be possible to do the minify as part of the install process but I would like to do it on Servlet startup to reduce the implementation cost.</p> <p>Does anyone know of a method for getting the co...
[ { "answer_id": 57563, "author": "Walter Rumsby", "author_id": 1654, "author_profile": "https://Stackoverflow.com/users/1654", "pm_score": -1, "selected": false, "text": "<p>Do you mean:</p>\n\n<pre><code>public class MyServlet extends HttpServlet {\n\n public void init(final ServletCo...
2008/09/11
[ "https://Stackoverflow.com/questions/57537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4682/" ]
In my Servlet I would like to access the root of the context so that I can do some JavaScript minifying. It would be possible to do the minify as part of the install process but I would like to do it on Servlet startup to reduce the implementation cost. Does anyone know of a method for getting the context directory s...
This should give you the real path that you can use to extract / edit files. [Javadoc Link](http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)) We're doing something similar in a context listener. ``` public class MyServlet extends HttpServlet { public ...
57,560
<p>What's the best way in c# to determine is a given QFE/patch has been installed?</p>
[ { "answer_id": 57626, "author": "rpetrich", "author_id": 4007, "author_profile": "https://Stackoverflow.com/users/4007", "pm_score": 1, "selected": false, "text": "<p>The most reliable way is to determine which files are impacted by the QFE and use <code>System.Diagnostics.FileVersionInf...
2008/09/11
[ "https://Stackoverflow.com/questions/57560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2564/" ]
What's the best way in c# to determine is a given QFE/patch has been installed?
Use WMI and inspect the [Win32\_QuickFixEngineering](http://msdn.microsoft.com/en-us/library/aa394391.aspx) enumeration. From TechNet: ``` strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colQuickFixes = objWMIService.ExecQuer...
57,577
<p>What is the easiest way to merge XML from two distinct DOM Documents? Is there a way other than using the Canonical <a href="http://support.microsoft.com/kb/311530" rel="nofollow noreferrer">DataReader</a> approach and then messing with the outputted DOM. What I basically want is to AppendChild to XmlElements with...
[ { "answer_id": 57593, "author": "ckarras", "author_id": 5688, "author_profile": "https://Stackoverflow.com/users/5688", "pm_score": 4, "selected": true, "text": "<p>You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another.</p>\n" }, { "answer_id"...
2008/09/11
[ "https://Stackoverflow.com/questions/57577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
What is the easiest way to merge XML from two distinct DOM Documents? Is there a way other than using the Canonical [DataReader](http://support.microsoft.com/kb/311530) approach and then messing with the outputted DOM. What I basically want is to AppendChild to XmlElements without getting: `The node to be inserted is f...
You can use the XmlDocument.ImportNode method to copy a node from a XmlDocument to another.
57,599
<p>What would be the best way to calculate someone's age in years, months, and days in T-SQL (SQL Server 2000)?</p> <p>The <code>datediff</code> function doesn't handle year boundaries well, plus getting the months and days separate will be a bear. I know I can do it on the client side relatively easily, but I'd like...
[ { "answer_id": 57642, "author": "Michael Runyon", "author_id": 5405, "author_profile": "https://Stackoverflow.com/users/5405", "pm_score": 0, "selected": false, "text": "<p>Are you trying to calculate the total days/months/years of an age? do you have a starting date? Or are you trying t...
2008/09/11
[ "https://Stackoverflow.com/questions/57599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/845/" ]
What would be the best way to calculate someone's age in years, months, and days in T-SQL (SQL Server 2000)? The `datediff` function doesn't handle year boundaries well, plus getting the months and days separate will be a bear. I know I can do it on the client side relatively easily, but I'd like to have it done in my...
Here is some T-SQL that gives you the number of years, months, and days since the day specified in @date. It takes into account the fact that DATEDIFF() computes the difference without considering what month or day it is (so the month diff between 8/31 and 9/1 is 1 month) and handles that with a case statement that dec...
57,600
<p>Should developers avoid using <a href="http://msdn.microsoft.com/en-us/library/923ahwt1.aspx" rel="nofollow noreferrer">continue</a> in C# or its equivalent in other languages to force the next iteration of a loop? Would arguments for or against overlap with arguments about <a href="https://stackoverflow.com/questio...
[ { "answer_id": 57606, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 2, "selected": false, "text": "<p>I don't think continue could ever be as difficult as goto since continue never moves execution out of the code block that ...
2008/09/11
[ "https://Stackoverflow.com/questions/57600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
Should developers avoid using [continue](http://msdn.microsoft.com/en-us/library/923ahwt1.aspx) in C# or its equivalent in other languages to force the next iteration of a loop? Would arguments for or against overlap with arguments about [Goto](https://stackoverflow.com/questions/46586/goto-still-considered-harmful)?
I think there should be more use of continue! Too often I come across code like: ``` for (...) { if (!cond1) { if (!cond2) { ... highly indented lines ... } } } ``` instead of ``` for (...) { if (cond1 || cond2) { continue; } ... } ``` Use it to make the c...
57,615
<p>I have a console app in which I want to give the user <em>x</em> seconds to respond to the prompt. If no input is made after a certain period of time, program logic should continue. We assume a timeout means empty response.</p> <p>What is the most straightforward way of approaching this?</p>
[ { "answer_id": 57639, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 3, "selected": false, "text": "<p>I think you will need to make a secondary thread and poll for a key on the console. I know of no built in way to accomplis...
2008/09/11
[ "https://Stackoverflow.com/questions/57615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
I have a console app in which I want to give the user *x* seconds to respond to the prompt. If no input is made after a certain period of time, program logic should continue. We assume a timeout means empty response. What is the most straightforward way of approaching this?
I'm surprised to learn that after 5 years, all of the answers still suffer from one or more of the following problems: * A function other than ReadLine is used, causing loss of functionality. (Delete/backspace/up-key for previous input). * Function behaves badly when invoked multiple times (spawning multiple threads, ...
57,625
<p>This one will take some explaining. What I've done is create a specific custom message queue in SQL Server 2005. I have a table with messages that contain timestamps for both acknowledgment and completion. The stored procedure that callers execute to obtain the next message in their queue also acknowledges the messa...
[ { "answer_id": 57637, "author": "Blorgbeard", "author_id": 369, "author_profile": "https://Stackoverflow.com/users/369", "pm_score": -1, "selected": false, "text": "<p>You want to wrap your code in a transaction, then SQL server will handle locking the appropriate rows or tables.</p>\n\n...
2008/09/11
[ "https://Stackoverflow.com/questions/57625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
This one will take some explaining. What I've done is create a specific custom message queue in SQL Server 2005. I have a table with messages that contain timestamps for both acknowledgment and completion. The stored procedure that callers execute to obtain the next message in their queue also acknowledges the message....
Something like this ``` --Grab the next message id begin tran declare @MessageId uniqueidentifier select top 1 @MessageId = ActionMessageId from UnacknowledgedDemands with(holdlock, updlock); --Acknowledge the message update ActionMessages set AcknowledgedTime = getdate() where ActionMessageId = @MessageId -- some...
57,652
<p>Scenario:</p> <ol> <li>The user has two monitors.</li> <li>Their browser is open on the secondary monitor.</li> <li>They click a link in the browser which calls window.open() with a specific top and left window offset.</li> <li>The popup window always opens on their primary monitor.</li> </ol> <p>Is there any way ...
[ { "answer_id": 57680, "author": "Jared", "author_id": 1980, "author_profile": "https://Stackoverflow.com/users/1980", "pm_score": -1, "selected": false, "text": "<p>as long as you know the x and y position that falls on the particular monitor you can do:</p>\n\n<pre><code>var x = 0;\nvar...
2008/09/11
[ "https://Stackoverflow.com/questions/57652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1436/" ]
Scenario: 1. The user has two monitors. 2. Their browser is open on the secondary monitor. 3. They click a link in the browser which calls window.open() with a specific top and left window offset. 4. The popup window always opens on their primary monitor. Is there any way in JavaScript to get the popup window to open...
You can't specify the monitor, but you can specify the position of the popup window as being relative to the where the click caused the window to popup. Use the getMouseXY() function to get values to pass as the left and top args to the window.open() method. (the left and top args only work with V3 and up browsers). ...
57,665
<p>Is there an easy way to return data to web service clients in JSON using Rails?</p>
[ { "answer_id": 57706, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://wiki.rubyonrails.org/rails/pages/HowtoGenerateJSON\" rel=\"nofollow noreferrer\">http://wiki.rubyo...
2008/09/11
[ "https://Stackoverflow.com/questions/57665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5988/" ]
Is there an easy way to return data to web service clients in JSON using Rails?
Rails resource gives a RESTful interface for your model. Let's see. Model ===== ``` class Contact < ActiveRecord::Base ... end ``` Routes ====== ``` map.resources :contacts ``` Controller ========== ``` class ContactsController < ApplicationController ... def show @contact = Contact.find(params[:id] ...
57,679
<p>I'm trying to determine, based on the result of this call, if it was successful. The <code>successFunction</code> doesn't get called, so I'm assuming it was not. How do I know what went wrong?</p> <pre><code>xmlRequest = $.post("/url/file/", { 'id' : object.id }, successFunction, 'json'); </code></pre> <p>Do I use...
[ { "answer_id": 57688, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 3, "selected": false, "text": "<p>You could use the $.ajaxComplete() and/or $.ajaxError() methods to attach function to those events. I would also recommen...
2008/09/11
[ "https://Stackoverflow.com/questions/57679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
I'm trying to determine, based on the result of this call, if it was successful. The `successFunction` doesn't get called, so I'm assuming it was not. How do I know what went wrong? ``` xmlRequest = $.post("/url/file/", { 'id' : object.id }, successFunction, 'json'); ``` Do I use the xmlRequest object?
You can use: ``` $.ajax({ url:"/url/file/", dataType:"json" data:{ 'id' : object.id } error:function(request){alert(request.statusText)} success:successFunction }) ```
57,708
<p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p> <p>For example:</p> <p>I get back:</p> <pre><code>&amp;#x01ce; </code></pre> <p>which represents an "ǎ" with a to...
[ { "answer_id": 57745, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 3, "selected": false, "text": "<p>You could find an answer here -- <a href=\"https://stackoverflow.com/questions/53224/getting-international-characters-from-a-w...
2008/09/11
[ "https://Stackoverflow.com/questions/57708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type? For example: I get back: ``` &#x01ce; ``` which represents an "ǎ" with a tone mark. In binary, this is represented as t...
The standard lib’s very own HTMLParser has an undocumented function unescape() which does exactly what you think it does: up to Python 3.4: ``` import HTMLParser h = HTMLParser.HTMLParser() h.unescape('&copy; 2010') # u'\xa9 2010' h.unescape('&#169; 2010') # u'\xa9 2010' ``` Python 3.4+: ``` import html html.unesc...
57,731
<p>I have a table in SQL Server that I inherited from a legacy system thats still in production that is structured according to the code below. I created a SP to query the table as described in the code below the table create statement. My issue is that, sporadically, calls from .NET to this SP both through the Enter...
[ { "answer_id": 57741, "author": "rpetrich", "author_id": 4007, "author_profile": "https://Stackoverflow.com/users/4007", "pm_score": 0, "selected": false, "text": "<p>Sounds like another query is running in the background that has locked the table and your innocent query is simply waitin...
2008/09/11
[ "https://Stackoverflow.com/questions/57731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a table in SQL Server that I inherited from a legacy system thats still in production that is structured according to the code below. I created a SP to query the table as described in the code below the table create statement. My issue is that, sporadically, calls from .NET to this SP both through the Enterprise...
I have seen this happen with indexes that were out of date. It could also be a parameter sniffing problem, where a different query plan is being used for different parameters that come in to the stored procedure. You should capture the parameters of the slow calls and see if they are the same ones each time it runs sl...
57,751
<p>I want to find any text in a file that matches a regexp of the form <em>t</em><code>[A-Z]</code><em>u</em> (i.e., a match <em>t</em> followed by a capital letter and another match <em>u</em>, and transform the matched text so that the capital letter is lowercase. For example, for the regexp <code>x[A-Z]y</code></p> ...
[ { "answer_id": 57794, "author": "Marcel Levy", "author_id": 676, "author_profile": "https://Stackoverflow.com/users/676", "pm_score": 5, "selected": true, "text": "<p>It looks like <a href=\"http://steve-yegge.blogspot.com/\" rel=\"noreferrer\">Steve Yegge</a> actually already posted the...
2008/09/11
[ "https://Stackoverflow.com/questions/57751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I want to find any text in a file that matches a regexp of the form *t*`[A-Z]`*u* (i.e., a match *t* followed by a capital letter and another match *u*, and transform the matched text so that the capital letter is lowercase. For example, for the regexp `x[A-Z]y` ``` xAy ``` becomes ``` xay ``` and ``` xZy ``` ...
It looks like [Steve Yegge](http://steve-yegge.blogspot.com/) actually already posted the answer to this a few years back: ["Shiny and New: Emacs 22."](http://steve-yegge.blogspot.com/2006/06/shiny-and-new-emacs-22.html) Scroll down to "Changing Case in Replacement Strings" and you'll see his example code using the `re...
57,766
<p>I am getting the below error and call stack at the same time everyday after several hours of application use. Can anyone shed some light on what is happening?</p> <pre><code>System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress. at Syste...
[ { "answer_id": 57820, "author": "qbeuek", "author_id": 5348, "author_profile": "https://Stackoverflow.com/users/5348", "pm_score": 0, "selected": false, "text": "<p>a shot in the dark - are you painting from multiple threads? If you are doing painting related work, do it on the GUI threa...
2008/09/11
[ "https://Stackoverflow.com/questions/57766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4770/" ]
I am getting the below error and call stack at the same time everyday after several hours of application use. Can anyone shed some light on what is happening? ``` System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress. at System.Drawing.Buff...
There is a very long MSDN forums discussion of this error [here](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=200483&SiteID=1). In most cases the error is apparently associated with either: 1. An underlying OutOfMemory problem, which manifests as the BufferedGraphicsContext exception, possibly due to a framew...
57,791
<p>I have a page which does quite a bit of work and I don't want the user to be able to navigate away from that page (close browser, hit back button, etc.) without getting a warning. I found that the onbeforeunload event (which I think is IE-specific, which works fine for me as the project uses lots of ActiveX) works g...
[ { "answer_id": 57798, "author": "Tom Kidd", "author_id": 2577, "author_profile": "https://Stackoverflow.com/users/2577", "pm_score": 2, "selected": false, "text": "<p><strong>EDIT:</strong> My \"workaround\" below is complete overkill, based on my lack of understanding. Go with Shog9's a...
2008/09/11
[ "https://Stackoverflow.com/questions/57791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577/" ]
I have a page which does quite a bit of work and I don't want the user to be able to navigate away from that page (close browser, hit back button, etc.) without getting a warning. I found that the onbeforeunload event (which I think is IE-specific, which works fine for me as the project uses lots of ActiveX) works grea...
Let me guess: the help "icon" is actually a link with a `javascript:` url? Change it to a real button, a real link, or at least put the functionality in an onclick event handler (that prevents the default behavior). Problem solved. ``` <!-- clicking this link will do nothing. No onbeforeunload handler triggered. Noth...
57,803
<p>How do you convert decimal values to their hexadecimal equivalent in JavaScript?</p>
[ { "answer_id": 57805, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 13, "selected": true, "text": "<p>Convert a number to a hexadecimal string with:</p>\n<pre><code>hexString = yourNumber.toString(16);\n</code></pre>\n<p>An...
2008/09/11
[ "https://Stackoverflow.com/questions/57803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5556/" ]
How do you convert decimal values to their hexadecimal equivalent in JavaScript?
Convert a number to a hexadecimal string with: ``` hexString = yourNumber.toString(16); ``` And reverse the process with: ``` yourNumber = parseInt(hexString, 16); ```
57,804
<p>Now, before you say it: I <strong>did</strong> Google and my <code>hbm.xml</code> file <strong>is</strong> an Embedded Resource. </p> <p>Here is the code I am calling:</p> <pre><code>ISession session = GetCurrentSession(); var returnObject = session.Get&lt;T&gt;(Id); </code></pre> <p>Here is my mapping file for ...
[ { "answer_id": 57860, "author": "Matt Hinze", "author_id": 2676, "author_profile": "https://Stackoverflow.com/users/2676", "pm_score": 2, "selected": false, "text": "<p>Should it be <code>name=\"Id\"</code>? Typos are a likely cause.</p>\n\n<p>Next would be to try it out with a non-gene...
2008/09/11
[ "https://Stackoverflow.com/questions/57804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4140/" ]
Now, before you say it: I **did** Google and my `hbm.xml` file **is** an Embedded Resource. Here is the code I am calling: ``` ISession session = GetCurrentSession(); var returnObject = session.Get<T>(Id); ``` Here is my mapping file for the class: ```xml <?xml version="1.0" encoding="utf-8" ?> <hibernate-mappin...
Sounds like you forgot to add a mapping assembly to the session factory configuration.. If you're using app.config... ``` . . <property name="show_sql">true</property> <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property> <mapping assembly="Project.DomainModel"/> <!-- Here --> ...
57,812
<p>I have a div with <code>id="a"</code> that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to re...
[ { "answer_id": 57819, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 4, "selected": false, "text": "<p>You don't need any jQuery specific code to handle this. Just use a RegExp to replace them:</p>\n\n<pre><code>$(\"#a\").c...
2008/09/11
[ "https://Stackoverflow.com/questions/57812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5464/" ]
I have a div with `id="a"` that may have any number of classes attached to it, from several groups. Each group has a specific prefix. In the javascript, I don't know which class from the group is on the div. I want to be able to clear all classes with a given prefix and then add a new one. If I want to remove all of th...
With jQuery, the actual DOM element is at index zero, this should work ``` $('#a')[0].className = $('#a')[0].className.replace(/\bbg.*?\b/g, ''); ```
57,840
<p>I have a wrapper around a C++ function call which I call from C# code. How do I attach a debugger in Visual Studio to step into the native C++ code?</p> <p>This is the wrapper that I have which calls GetData() defined in a C++ file:</p> <pre><code> [DllImport("Unmanaged.dll", CallingConvention=CallingConvention...
[ { "answer_id": 57862, "author": "Lou", "author_id": 4341, "author_profile": "https://Stackoverflow.com/users/4341", "pm_score": 6, "selected": true, "text": "<p>Check the Debug tab on your project's properties page. There should be an \"Enable unmanaged code debugging\" checkbox. This wo...
2008/09/11
[ "https://Stackoverflow.com/questions/57840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5734/" ]
I have a wrapper around a C++ function call which I call from C# code. How do I attach a debugger in Visual Studio to step into the native C++ code? This is the wrapper that I have which calls GetData() defined in a C++ file: ``` [DllImport("Unmanaged.dll", CallingConvention=CallingConvention.Cdecl, ...
Check the Debug tab on your project's properties page. There should be an "Enable unmanaged code debugging" checkbox. This worked for me when we developed a new .NET UI for our old c++ DLLs. If your unmanaged DLL is being built from another project (for a while ours were being built using VS6) just make sure you have ...
57,849
<p>There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around?</p>
[ { "answer_id": 57975, "author": "Joel Lucsy", "author_id": 645, "author_profile": "https://Stackoverflow.com/users/645", "pm_score": 3, "selected": false, "text": "<p>A workaround is to use an ImageList that is as tall as you want the items to be. Just fill a blank image with the backgro...
2008/09/11
[ "https://Stackoverflow.com/questions/57849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There doesn't seem to be a way to change the padding (or row height) for all rows in a .NET ListView. Does anybody have an elegant hack-around?
I know this post is fairly old, however, if you never found the best option, I've got a [blog post](http://qdevblog.blogspot.co.uk/2011/11/c-listview-item-spacing.html) that may help, it involves utilizing LVM\_SETICONSPACING. **According to my blog,** Initially, you'll need to add: ``` using System.Runtime.Interop...
57,854
<p>How can I close a browser window without receiving the <em>Do you want to close this window</em> prompt?</p> <p>The prompt occurs when I use the <code>window.close();</code> function.</p>
[ { "answer_id": 57857, "author": "Derek", "author_id": 5440, "author_profile": "https://Stackoverflow.com/users/5440", "pm_score": -1, "selected": false, "text": "<p>The best solution I have found is:</p>\n\n<pre><code>this.focus();\nself.opener=this;\nself.close();\n</code></pre>\n" },...
2008/09/11
[ "https://Stackoverflow.com/questions/57854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5440/" ]
How can I close a browser window without receiving the *Do you want to close this window* prompt? The prompt occurs when I use the `window.close();` function.
My friend... there is a way but "hack" does not begin to describe it. You have to basically exploit a bug in IE 6 & 7. Works every time! Instead of calling `window.close()`, redirect to another page. Opening Page: ``` alert("No whammies!"); window.open("closer.htm", '_self'); ``` Redirect to another page. This ...
57,855
<p>I'm troubleshooting a problem with creating Vista shortcuts.</p> <p>I want to make sure that our Installer is reading the Programs folder from the right registry key.</p> <p>It's reading it from:</p> <pre><code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Programs </code></pr...
[ { "answer_id": 57866, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 0, "selected": false, "text": "<p>Sounds correct to me.</p>\n" }, { "answer_id": 57869, "author": "Tadmas", "author_id": 3750, "author_p...
2008/09/11
[ "https://Stackoverflow.com/questions/57855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
I'm troubleshooting a problem with creating Vista shortcuts. I want to make sure that our Installer is reading the Programs folder from the right registry key. It's reading it from: ``` HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Programs ``` And it's showing this directory f...
use windows installer properties. will probably be easier. <http://msdn.microsoft.com/en-us/library/aa370905(VS.85).aspx#system_folder_properties>
57,912
<p>I'm currently updating a legacy system which allows users to dictate part of the schema of one of its tables. Users can create and remove columns from the table through this interface. This legacy system is using ADO 2.8, and is using SQL Server 2005 as its database (you don't even WANT to know what database it wa...
[ { "answer_id": 57922, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 0, "selected": false, "text": "<p>The behavior you describe is allowed. How is the code making the schema changes? Building SQL on the fly and executing t...
2008/09/11
[ "https://Stackoverflow.com/questions/57912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3068/" ]
I'm currently updating a legacy system which allows users to dictate part of the schema of one of its tables. Users can create and remove columns from the table through this interface. This legacy system is using ADO 2.8, and is using SQL Server 2005 as its database (you don't even WANT to know what database it was usi...
The code is using a server-side cursor, that's what those calls are for. The first set of calls is preparing/opening the cursor. Then fetching rows from the cursor. Finally closing the cursor. Those sprocs are analogous to the OPEN CURSOR, FETCH NEXT, CLOSE CURSOR T-SQL statements. I'd have to take a closer look (whic...
57,918
<p>We have a whole bunch of queries that "search" for clients, customers, etc. You can search by first name, email, etc. We're using LIKE statements in the following manner: </p> <pre><code>SELECT * FROM customer WHERE fname LIKE '%someName%' </code></pre> <p>Does full-text indexing help in the scenario? We're usi...
[ { "answer_id": 57930, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 6, "selected": true, "text": "<p>It will depend upon your DBMS. I believe that most systems will not take advantage of the full-text index unless you use ...
2008/09/11
[ "https://Stackoverflow.com/questions/57918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
We have a whole bunch of queries that "search" for clients, customers, etc. You can search by first name, email, etc. We're using LIKE statements in the following manner: ``` SELECT * FROM customer WHERE fname LIKE '%someName%' ``` Does full-text indexing help in the scenario? We're using SQL Server 2005.
It will depend upon your DBMS. I believe that most systems will not take advantage of the full-text index unless you use the full-text functions. (e.g. [MATCH/AGAINST](http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html) in mySQL or FREETEXT/CONTAINS in MS SQL) Here is two good articles on when, why,...
57,927
<p>I have an excel spreadsheet in a format similar to the following...</p> <pre><code>| NAME | CLUB | STATUS | SCORE | | Fred | a | Gent | 145 | | Bert | a | Gent | 150 | | Harry | a | Gent | 195 | | Jim | a | Gent | 150 | | Clare | a | Lady | 99 | | Simon | a | Junior | 130...
[ { "answer_id": 57955, "author": "Knox", "author_id": 4873, "author_profile": "https://Stackoverflow.com/users/4873", "pm_score": 0, "selected": false, "text": "<p>Use a pivot table which will act as a database query on the data you have. Pivot so that the teams go down the columns and t...
2008/09/11
[ "https://Stackoverflow.com/questions/57927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3720/" ]
I have an excel spreadsheet in a format similar to the following... ``` | NAME | CLUB | STATUS | SCORE | | Fred | a | Gent | 145 | | Bert | a | Gent | 150 | | Harry | a | Gent | 195 | | Jim | a | Gent | 150 | | Clare | a | Lady | 99 | | Simon | a | Junior | 130 | | John |...
``` Public Function TopTen(Club As String, Scores As Range) Dim i As Long Dim vaScores As Variant Dim bLady As Boolean Dim lCnt As Long Dim lTotal As Long vaScores = FilterOnClub(Scores.Value, Club) vaScores = SortOnScore(vaScores) For i = LBound(vaScores, 2) To UBound(vaScores, 2) ...
57,947
<p>I'm really confused by the various configuration options for .Net configuration of dll's, ASP.net websites etc in .Net v2 - especially when considering the impact of a config file at the UI / end-user end of the chain.</p> <p>So, for example, some of the applications I work with use settings which we access with:</...
[ { "answer_id": 57953, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 0, "selected": false, "text": "<p>I think your confusion comes from the fact that it looks like your first example is a home-brewed library, not part of .NE...
2008/09/11
[ "https://Stackoverflow.com/questions/57947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6004/" ]
I'm really confused by the various configuration options for .Net configuration of dll's, ASP.net websites etc in .Net v2 - especially when considering the impact of a config file at the UI / end-user end of the chain. So, for example, some of the applications I work with use settings which we access with: ``` string...
Nij, our difference in thinking comes from our different perspectives. I'm thinking about developing enterprise apps that predominantly use WinForms clients. In this instance the business logic is contained on an application server. Each client would need to know the phone number to dial, but placing it in the App.conf...
57,958
<p>I like HtmlControls because there is no HTML magic going on... the asp source looks similar to what the client sees. </p> <p>I can't argue with the utility of GridView, Repeater, CheckBoxLists, etc, so I use them when I need that functionality. </p> <p>Also, it looks weird to have code that mixes and matches:</p> ...
[ { "answer_id": 57961, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "<p>well... i wouldn't use an html control if you don't need to do anything on it on the server. i would do</p>\n\n<pre><code>...
2008/09/11
[ "https://Stackoverflow.com/questions/57958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4435/" ]
I like HtmlControls because there is no HTML magic going on... the asp source looks similar to what the client sees. I can't argue with the utility of GridView, Repeater, CheckBoxLists, etc, so I use them when I need that functionality. Also, it looks weird to have code that mixes and matches: ``` <asp:Button id='...
It might be useful to think of HTML controls as an option when you want more control over the mark up that ends up getting emitted by your page. More control in the sense that you want EVERY browser to see exactly the same markup. If you create System.Web.UI.HtmlControls like: ``` <input id='btnCancel' runat='server'...
57,987
<p>Does anyone know how to write to an excel file (.xls) via OLEDB in C#? I'm doing the following:</p> <pre><code> OleDbCommand dbCmd = new OleDbCommand("CREATE TABLE [test$] (...)", connection); dbCmd.CommandTimeout = mTimeout; results = dbCmd.ExecuteNonQuery(); </code></pre> <p>But I get an OleDbException ...
[ { "answer_id": 58162, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 1, "selected": false, "text": "<p>A couple questions: </p>\n\n<ul>\n<li>Does the user that executes your app (you?) have permission to write to the file? ...
2008/09/12
[ "https://Stackoverflow.com/questions/57987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39040/" ]
Does anyone know how to write to an excel file (.xls) via OLEDB in C#? I'm doing the following: ``` OleDbCommand dbCmd = new OleDbCommand("CREATE TABLE [test$] (...)", connection); dbCmd.CommandTimeout = mTimeout; results = dbCmd.ExecuteNonQuery(); ``` But I get an OleDbException thrown with message: > > ...
You need to add `ReadOnly=False;` to your connection string ``` Provider=Microsoft.Jet.OLEDB.4.0;Data Source=fifa_ng_db.xls;Mode=ReadWrite;ReadOnly=false;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"; ```
58,024
<p>I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser.</p> <p>What is the best way to open a URL in the user's default browser from a Windows Forms application?</p>
[ { "answer_id": 58032, "author": "Aaron Wagner", "author_id": 3909, "author_profile": "https://Stackoverflow.com/users/3909", "pm_score": 5, "selected": false, "text": "<pre><code>using System.Diagnostics;\n\nProcess.Start(\"http://www.google.com/\");\n</code></pre>\n\n<p>This approach ha...
2008/09/12
[ "https://Stackoverflow.com/questions/58024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148/" ]
I'm trying to provide a link to my company's website from a Windows Form. I want to be well behaved and launch using the user's preferred browser. What is the best way to open a URL in the user's default browser from a Windows Forms application?
This [article](http://support.microsoft.com/kb/320478) will walk you through it. Short answer: ``` ProcessStartInfo sInfo = new ProcessStartInfo("http://mysite.com/"); Process.Start(sInfo); ```
58,054
<p>I have a list of bean objects passed into my JSP page, and one of them is a comment field. This field may contain newlines, and I want to replace them with semicolons using JSTL, so that the field can be displayed in a text input. I have found one solution, but it's not very elegant. I'll post below as a possibility...
[ { "answer_id": 58060, "author": "parkerfath", "author_id": 6027, "author_profile": "https://Stackoverflow.com/users/6027", "pm_score": 7, "selected": true, "text": "<p>Here is a solution I found. It doesn't seem very elegant, though:</p>\n\n<pre><code>&lt;%@ taglib prefix=\"fn\" uri=\"ht...
2008/09/12
[ "https://Stackoverflow.com/questions/58054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6027/" ]
I have a list of bean objects passed into my JSP page, and one of them is a comment field. This field may contain newlines, and I want to replace them with semicolons using JSTL, so that the field can be displayed in a text input. I have found one solution, but it's not very elegant. I'll post below as a possibility.
Here is a solution I found. It doesn't seem very elegant, though: ``` <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <% pageContext.setAttribute("newLineChar", "\n"); %> ${fn:replace(item.comments, newLineChar, "; ")} ```
58,070
<p>I remember back when MS released a forum sample application, the design of the application was like this:</p> <p>/Classes/User.cs /Classes/Post.cs ... /Users.cs /Posts.cs</p> <p>So the classes folder had just the class i.e. properties and getters/setters. The Users.cs, Post.cs, etc. have the actual methods that ac...
[ { "answer_id": 58080, "author": "Eric Haskins", "author_id": 100, "author_profile": "https://Stackoverflow.com/users/100", "pm_score": 0, "selected": false, "text": "<p>Are you sure the classes aren't partial classes. In which case they really aren't two classes, just a single class spre...
2008/09/12
[ "https://Stackoverflow.com/questions/58070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
I remember back when MS released a forum sample application, the design of the application was like this: /Classes/User.cs /Classes/Post.cs ... /Users.cs /Posts.cs So the classes folder had just the class i.e. properties and getters/setters. The Users.cs, Post.cs, etc. have the actual methods that access the Data Acc...
If every method is just a static call straight to the data source, then the "Posts" class is really a Factory. You could certainly put the static methods in "Posts" into the "Post" class (this is how CSLA works), but they are still factory methods. I would say that a more modern and accurate name for the "Posts" class...
58,119
<p>I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s...
[ { "answer_id": 58129, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 5, "selected": true, "text": "<p>Well, <code>re.compile</code> certainly may:</p>\n\n<pre><code>&gt;&gt;&gt; import re\n&gt;&gt;&gt; re.compile('he(lo'...
2008/09/12
[ "https://Stackoverflow.com/questions/58119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1892/" ]
I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s) a...
Well, `re.compile` certainly may: ``` >>> import re >>> re.compile('he(lo') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python25\lib\re.py", line 180, in compile return _compile(pattern, flags) File "C:\Python25\lib\re.py", line 233, in _compile raise error, v # invali...
58,123
<p>This is actually a two part question. First,does the HttpContext.Current correspond to the current System.UI.Page object?</p> <p>And the second question, which is probably related to the first, is why can't I use the following to see if the current page implements an interface:</p> <pre><code>private IWebBase Find...
[ { "answer_id": 58128, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 5, "selected": false, "text": "<p>You're looking for <code>HttpContext.Handler</code>. Since Page implements IHttpHandler, you'll obtain a reference to th...
2008/09/12
[ "https://Stackoverflow.com/questions/58123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1685/" ]
This is actually a two part question. First,does the HttpContext.Current correspond to the current System.UI.Page object? And the second question, which is probably related to the first, is why can't I use the following to see if the current page implements an interface: ``` private IWebBase FindWebBase() { if (H...
No, from MSDN on HttpContext.Current: "Gets or sets the HttpContext object for the current HTTP request." In other words it is an HttpContext object, not a Page. You can get to the Page object via HttpContext using: ``` Page page = HttpContext.Current.Handler as Page; if (page != null) { // Use page instance....
58,207
<p>To create a playlist for all of the music in a folder, I am using the following command in bash:</p> <pre><code>ls &gt; list.txt </code></pre> <p>I would like to use the result of the <code>pwd</code> command for the name of the playlist.</p> <p>Something like:</p> <pre><code>ls &gt; ${pwd}.txt </code></pre> <p...
[ { "answer_id": 58212, "author": "John Calsbeek", "author_id": 5696, "author_profile": "https://Stackoverflow.com/users/5696", "pm_score": 8, "selected": true, "text": "<p>The best way to do this is with <code>\"$(command substitution)\"</code> (thanks, <a href=\"https://stackoverflow.com...
2008/09/12
[ "https://Stackoverflow.com/questions/58207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/840/" ]
To create a playlist for all of the music in a folder, I am using the following command in bash: ``` ls > list.txt ``` I would like to use the result of the `pwd` command for the name of the playlist. Something like: ``` ls > ${pwd}.txt ``` That doesn't work though - can anyone tell me what syntax I need to use ...
The best way to do this is with `"$(command substitution)"` (thanks, [Landon](https://stackoverflow.com/a/58233/1899640)): ``` ls > "$(pwd).txt" ``` You will sometimes also see people use the older backtick notation, but this has [several drawbacks](https://stackoverflow.com/questions/4708549/what-is-the-difference-...