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
58,280
<p>Is it possible to use an UnhandledException Handler in a Windows Service?</p> <p>Normally I would use a custom built Exception Handling Component that does logging, phone home, etc. This component adds a handler to System.AppDomain.CurrentDomain.UnhandledException but as far as I can tell this doesn’t achieve anyth...
[ { "answer_id": 58408, "author": "Garo Yeriazarian", "author_id": 2655, "author_profile": "https://Stackoverflow.com/users/2655", "pm_score": 2, "selected": false, "text": "<p>You can subscribe to the <a href=\"http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception.as...
2008/09/12
[ "https://Stackoverflow.com/questions/58280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6042/" ]
Is it possible to use an UnhandledException Handler in a Windows Service? Normally I would use a custom built Exception Handling Component that does logging, phone home, etc. This component adds a handler to System.AppDomain.CurrentDomain.UnhandledException but as far as I can tell this doesn’t achieve anything win a ...
Ok, I’ve done a little more research into this now. When you create a windows service in .Net, you create a class that inherits from System.ServiceProcess.ServiceBase (In VB this is hidden in the .Designer.vb file). You then override the OnStart and OnStop function, and OnPause and OnContinue if you choose to. These m...
58,305
<p>Simple as the title states: Can you use only Java commands to take a screenshot and save it? Or, do I need to use an OS specific program to take the screenshot and then grab it off the clipboard?</p>
[ { "answer_id": 58326, "author": "David Citron", "author_id": 5309, "author_profile": "https://Stackoverflow.com/users/5309", "pm_score": 9, "selected": true, "text": "<p>Believe it or not, you can actually use <a href=\"http://java.sun.com/javase/6/docs/api/java/awt/Robot.html#createScre...
2008/09/12
[ "https://Stackoverflow.com/questions/58305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
Simple as the title states: Can you use only Java commands to take a screenshot and save it? Or, do I need to use an OS specific program to take the screenshot and then grab it off the clipboard?
Believe it or not, you can actually use [`java.awt.Robot`](http://java.sun.com/javase/6/docs/api/java/awt/Robot.html#createScreenCapture(java.awt.Rectangle)) to "create an image containing pixels read from the screen." You can then write that image to a file on disk. I just tried it, and the whole thing ends up like: ...
58,306
<p>I am trying to determine the best time efficient algorithm to accomplish the task described below.</p> <p>I have a set of records. For this set of records I have connection data which indicates how pairs of records from this set connect to one another. This basically represents an undirected graph, with the records...
[ { "answer_id": 58321, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I have solved a similar problem to this recently, instead of all solutions I was only interested in the shortest.</p>\n\n<p>...
2008/09/12
[ "https://Stackoverflow.com/questions/58306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3534/" ]
I am trying to determine the best time efficient algorithm to accomplish the task described below. I have a set of records. For this set of records I have connection data which indicates how pairs of records from this set connect to one another. This basically represents an undirected graph, with the records being the...
It appears that this can be accomplished with a depth-first search of the graph. **The depth-first search will find all non-cyclical paths between two nodes.** This algorithm should be very fast and scale to large graphs (The graph data structure is sparse so it only uses as much memory as it needs to). I noticed that...
58,380
<p>The following bit of code catches the EOS Exception</p> <pre><code>using (var reader = new BinaryReader(httpRequestBodyStream)) { try { while (true) { bodyByteList.Add(reader.ReadByte()); } } catch (EndOfStreamException) { } } </code></pre> <p>So why do I still receive first-ch...
[ { "answer_id": 58381, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": -1, "selected": false, "text": "<p>I think the stream is throwing this exception, so your try is scoped to narrow to catch it.</p>\n\n<p>Add a few m...
2008/09/12
[ "https://Stackoverflow.com/questions/58380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
The following bit of code catches the EOS Exception ``` using (var reader = new BinaryReader(httpRequestBodyStream)) { try { while (true) { bodyByteList.Add(reader.ReadByte()); } } catch (EndOfStreamException) { } } ``` So why do I still receive first-chance exceptions in my cons...
The point of "first-chance" exceptions is that you're seeing them pre-handler so that you can stop on them during debugging at the point of throwing. A "second-chance" exception is one that has no appropriate handler. Sometimes you want to catch "first-chance" exceptions because it's important to see what's happening w...
58,384
<p>I am facing a problem with .NET generics. The thing I want to do is saving an array of generics types (GraphicsItem):</p> <pre><code>public class GraphicsItem&lt;T&gt; { private T _item; public void Load(T item) { _item = item; } } </code></pre> <p>How can I save such open generic type in ...
[ { "answer_id": 58401, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 0, "selected": false, "text": "<p>If you want to store heterogeneous GrpahicsItem's i.e. GraphicsItem&lt; X> and GrpahicsItem&lt; Y> you need to derive them fro...
2008/09/12
[ "https://Stackoverflow.com/questions/58384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2078/" ]
I am facing a problem with .NET generics. The thing I want to do is saving an array of generics types (GraphicsItem): ``` public class GraphicsItem<T> { private T _item; public void Load(T item) { _item = item; } } ``` How can I save such open generic type in an array?
Implement a non-generic interface and use that: ``` public class GraphicsItem<T> : IGraphicsItem { private T _item; public void Load(T item) { _item = item; } public void SomethingWhichIsNotGeneric(int i) { // Code goes here... } } public interface IGraphicsItem { voi...
58,425
<p>I have a simple WPF application which I am trying to start. I am following the Microsoft Patterns and Practices "Composite Application Guidance for WPF". I've followed their instructions however my WPF application fails immediately with a "TypeInitializationException".</p> <p>The InnerException property reveals t...
[ { "answer_id": 58447, "author": "ima", "author_id": 5733, "author_profile": "https://Stackoverflow.com/users/5733", "pm_score": 3, "selected": false, "text": "<p>Do you use .config file? If so, check it for errors. Initialization errors of such sort are often triggered by invalid XML: if...
2008/09/12
[ "https://Stackoverflow.com/questions/58425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/148/" ]
I have a simple WPF application which I am trying to start. I am following the Microsoft Patterns and Practices "Composite Application Guidance for WPF". I've followed their instructions however my WPF application fails immediately with a "TypeInitializationException". The InnerException property reveals that "The typ...
Thanks @ima, your answer pointed me in the right direction. I was using an app.config file and it contained this: ``` <configuration> <startup> <supportedRuntime version="v2.0.50727" sku="Client"/> </startup> <configSections> <section name="modules" type="Microsoft.Practices.Composite.Modularity.ModulesC...
58,429
<p>How can I have SQL repeat some set-based operation an arbitrary number of times without looping? How can I have SQL perform an operation against a range of numbers? I'm basically looking for a way to do a set-based for loop.<p> I know I can just create a small table with integers in it, say from 1 to 1000 and then u...
[ { "answer_id": 58511, "author": "Sergio Acosta", "author_id": 2954, "author_profile": "https://Stackoverflow.com/users/2954", "pm_score": 0, "selected": false, "text": "<p>If using SQL Server 2000 or greater, you could use the <strong>table datatype</strong> to avoid creating a normal or...
2008/09/12
[ "https://Stackoverflow.com/questions/58429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489/" ]
How can I have SQL repeat some set-based operation an arbitrary number of times without looping? How can I have SQL perform an operation against a range of numbers? I'm basically looking for a way to do a set-based for loop. I know I can just create a small table with integers in it, say from 1 to 1000 and then use it ...
I think the very short answer to your question is to use WITH clauses to generate your own. Unfortunately, the big names in databases don't have built-in queryable number-range pseudo-tables. Or, more generally, easy pure-SQL data generation features. Personally, I think this is a **huge** failing, because if they did...
58,431
<p>I have wondered for some time, what a nice, clean solution for joining an array of strings might look like. Example: I have ["Alpha", "Beta", "Gamma"] and want to join the strings into one, separated by commas – "Alpha, Beta, Gamma".</p> <p>Now I know that most programming languages offer some kind of join method f...
[ { "answer_id": 58437, "author": "Mendelt", "author_id": 3320, "author_profile": "https://Stackoverflow.com/users/3320", "pm_score": 4, "selected": false, "text": "<p>The most elegant solution i found for problems like this is something like this (in pseudocode)</p>\n\n<pre><code>separato...
2008/09/12
[ "https://Stackoverflow.com/questions/58431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4991/" ]
I have wondered for some time, what a nice, clean solution for joining an array of strings might look like. Example: I have ["Alpha", "Beta", "Gamma"] and want to join the strings into one, separated by commas – "Alpha, Beta, Gamma". Now I know that most programming languages offer some kind of join method for this. I...
The most elegant solution i found for problems like this is something like this (in pseudocode) ``` separator = "" foreach(item in stringCollection) { concatenatedString += separator + item separator = "," } ``` You just run the loop and only after the second time around the separator is set. So the first ti...
58,457
<p>How do you randomly select a table row in T-SQL based on an applied weight for all candidate rows?</p> <p>For example, I have a set of rows in a table weighted at 50, 25, and 25 (which adds up to 100 but does not need to), and I want to select one of them randomly with a statistical outcome equivalent to the respec...
[ { "answer_id": 58459, "author": "Dane", "author_id": 2929, "author_profile": "https://Stackoverflow.com/users/2929", "pm_score": 3, "selected": false, "text": "<p>You simply need to sum the weights of all candidate rows, then choose a random point within that sum, then select the record ...
2008/09/12
[ "https://Stackoverflow.com/questions/58457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2929/" ]
How do you randomly select a table row in T-SQL based on an applied weight for all candidate rows? For example, I have a set of rows in a table weighted at 50, 25, and 25 (which adds up to 100 but does not need to), and I want to select one of them randomly with a statistical outcome equivalent to the respective weigh...
Dane's answer includes a self joins in a way that introduces a square law. `(n*n/2)` rows after the join where there are n rows in the table. What would be more ideal is to be able to just parse the table once. ``` DECLARE @id int, @weight_sum int, @weight_point int DECLARE @table TABLE (id int, weight int) INSERT I...
58,482
<p>I'm not entirely sure if this is possible in Ruby, but hopefully there's an easy way to do this. I want to declare a variable and later find out the name of the variable. That is, for this simple snippet:</p> <pre><code>foo = ["goo", "baz"] </code></pre> <p>How can I get the name of the array (here, "foo") back? I...
[ { "answer_id": 58492, "author": "Josh Moore", "author_id": 5004, "author_profile": "https://Stackoverflow.com/users/5004", "pm_score": 2, "selected": false, "text": "<p>I do not know of any way to get a local variable name. But, you can use the <code>instance_variables</code> method, th...
2008/09/12
[ "https://Stackoverflow.com/questions/58482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
I'm not entirely sure if this is possible in Ruby, but hopefully there's an easy way to do this. I want to declare a variable and later find out the name of the variable. That is, for this simple snippet: ``` foo = ["goo", "baz"] ``` How can I get the name of the array (here, "foo") back? If it is indeed possible, d...
What if you turn your problem around? Instead of trying to get names from variables, get the variables from the names: ``` ["foo", "goo", "bar"].each { |param_name| param = eval(param_name) if param.class != Array puts "#{param_name} wasn't an Array. It was a/an #{param.class}" return "Error: #{param_name}...
58,513
<p>How do I Unit Test a MVC redirection?</p> <pre><code>public ActionResult Create(Product product) { _productTask.Save(product); return RedirectToAction("Success"); } public ActionResult Success() { return View(); } </code></pre> <p>Is <a href="http://www.ayende.com/Blog/archive/2007/12/13/Dont-lik...
[ { "answer_id": 58789, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>You can assert on the ActionResult that is returned, you'll need to cast it to the appropriate type but it does allow you t...
2008/09/12
[ "https://Stackoverflow.com/questions/58513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/230/" ]
How do I Unit Test a MVC redirection? ``` public ActionResult Create(Product product) { _productTask.Save(product); return RedirectToAction("Success"); } public ActionResult Success() { return View(); } ``` Is [Ayende's](http://www.ayende.com/Blog/archive/2007/12/13/Dont-like-visibility-levels-chan...
``` [TestFixture] public class RedirectTester { [Test] public void Should_redirect_to_success_action() { var controller = new RedirectController(); var result = controller.Index() as RedirectToRouteResult; Assert.That(result, Is.Not.Null); Assert.That(result.Values["action"],...
58,517
<p>Is there a way to combine Enums in VB.net?</p>
[ { "answer_id": 58524, "author": "Hath", "author_id": 5186, "author_profile": "https://Stackoverflow.com/users/5186", "pm_score": 0, "selected": false, "text": "<p>If you taking about using enum flags() there is a good article <a href=\"http://www.codeguru.com/vb/sample_chapter/article.ph...
2008/09/12
[ "https://Stackoverflow.com/questions/58517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5055/" ]
Is there a way to combine Enums in VB.net?
I believe what you want is a flag type enum. You need to add the Flags attribute to the top of the enum, and then you can combine enums with the 'Or' keyword. Like this: ``` <Flags()> _ Enum CombinationEnums As Integer HasButton = 1 TitleBar = 2 [ReadOnly] = 4 ETC = 8 End Enum ``` **Note:** The numbers to ...
58,538
<p>I'm creating an installer for a website that uses a custom event log source. I would like our WiX based installer to create that event log source during installation.</p> <p>Does anyone know the best way to do this using the WiX framework.</p>
[ { "answer_id": 58686, "author": "Paul Lalonde", "author_id": 5782, "author_profile": "https://Stackoverflow.com/users/5782", "pm_score": 7, "selected": true, "text": "<p>Wix has out-of-the-box support for creating event log sources.</p>\n\n<p>Assuming you use Wix 3, you first need to add...
2008/09/12
[ "https://Stackoverflow.com/questions/58538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5182/" ]
I'm creating an installer for a website that uses a custom event log source. I would like our WiX based installer to create that event log source during installation. Does anyone know the best way to do this using the WiX framework.
Wix has out-of-the-box support for creating event log sources. Assuming you use Wix 3, you first need to add a reference to WixUtilExtension to either your Votive project or the command line. You can then add an EventSource element under a component : ``` <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmln...
58,540
<p>When trying to enter a SQL query with parameters using the Oracle OLE DB provider I get the following error:</p> <blockquote> <p>Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" acces...
[ { "answer_id": 59116, "author": "Rich Lawrence", "author_id": 1281, "author_profile": "https://Stackoverflow.com/users/1281", "pm_score": 5, "selected": true, "text": "<p>To expand on the link given in the question:</p>\n\n<ol>\n<li>Create a package variable</li>\n<li>Double click on the...
2008/09/12
[ "https://Stackoverflow.com/questions/58540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1281/" ]
When trying to enter a SQL query with parameters using the Oracle OLE DB provider I get the following error: > > Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the...
To expand on the link given in the question: 1. Create a package variable 2. Double click on the package variable name. (This allows you to access the properties of the variable) 3. Set the property 'EvaluateAsExpression' to true 4. Enter the query in the expression builder. 5. Set the OLE DB source query to SQL Comma...
58,543
<p>I have an application that I would like to embed inside our companies CMS. The only way to do that (I am told), is to load it in an <code>&lt;iframe&gt;</code>.</p> <p>Easy: just set <code>height</code> and <code>width</code> to <code>100%</code>! Except, it doesn't work.</p> <p>I did find out about setting <code>...
[ { "answer_id": 58553, "author": "ralfe", "author_id": 340241, "author_profile": "https://Stackoverflow.com/users/340241", "pm_score": 3, "selected": true, "text": "<p>You could either just use a scripting language to include the page into the parent page, other wise, you might want to tr...
2008/09/12
[ "https://Stackoverflow.com/questions/58543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
I have an application that I would like to embed inside our companies CMS. The only way to do that (I am told), is to load it in an `<iframe>`. Easy: just set `height` and `width` to `100%`! Except, it doesn't work. I did find out about setting `frameborder` to `0`, so it at least *looks* like part of the site, but I...
You could either just use a scripting language to include the page into the parent page, other wise, you might want to try one of these javascript methods: <http://brondsema.net/blog/index.php/2007/06/06/100_height_iframe> <http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22840093.html>
58,547
<p>In C++ we acquiring a resource in a constructor and release it in a destructor.</p> <p>So when an exception rises in a middle of a function there will be no resource leak or locked mutexes or whatever.</p> <p>AFAIK java classes don't have destructors. So how does one do the resource management in Java.</p> <p>For...
[ { "answer_id": 58552, "author": "qbeuek", "author_id": 5348, "author_profile": "https://Stackoverflow.com/users/5348", "pm_score": 3, "selected": true, "text": "<p>Yes you can and should put try/catch/finally block around your code. In C# there is a shorthand \"using\" statement, but in ...
2008/09/12
[ "https://Stackoverflow.com/questions/58547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1007/" ]
In C++ we acquiring a resource in a constructor and release it in a destructor. So when an exception rises in a middle of a function there will be no resource leak or locked mutexes or whatever. AFAIK java classes don't have destructors. So how does one do the resource management in Java. For example: ``` public in...
Yes you can and should put try/catch/finally block around your code. In C# there is a shorthand "using" statement, but in Java you are stuck with: ``` public int foo() { Resource f = new Resource(); try { DoSomething(f); } finally { f.Release(); } } ```
58,554
<p>I'm using Eclipse as my IDE for a C++ project, and I would love for it to tell me where a given symbol is defined and what the parameters are for a function.</p> <p>However, there's a catch: I also use <a href="http://www.lazycplusplus.com/" rel="nofollow noreferrer">Lazy C++</a>, a tool that takes a single source ...
[ { "answer_id": 59251, "author": "Mike McQuaid", "author_id": 5355, "author_profile": "https://Stackoverflow.com/users/5355", "pm_score": 2, "selected": false, "text": "<p>I'd imagine its one of:</p>\n\n<ul>\n<li><p>Eclipse doesn't want to display non-C++ resources in the tree (I've had p...
2008/09/12
[ "https://Stackoverflow.com/questions/58554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2095/" ]
I'm using Eclipse as my IDE for a C++ project, and I would love for it to tell me where a given symbol is defined and what the parameters are for a function. However, there's a catch: I also use [Lazy C++](http://www.lazycplusplus.com/), a tool that takes a single source file and generates the .h and the .cpp files. T...
I'd imagine its one of: * Eclipse doesn't want to display non-C++ resources in the tree (I've had problems with this) * You don't have "Preferences > C/C++ > Indexer > Index All Files" enabled. * You want to use the "Full C/C++ Indexer" rather than the "Fast C/C++ Indexer"
58,561
<p>I'm trying to get only the list of id of object bob for example instead of the list of bob. It's ok with a HQL request, but I would know if it's possible using criteria ?</p> <p>An example :</p> <pre><code>final StringBuilder hql = new StringBuilder(); hql.append( "select bob.id from " ) .append( bob.class.get...
[ { "answer_id": 58624, "author": "agnul", "author_id": 6069, "author_profile": "https://Stackoverflow.com/users/6069", "pm_score": 6, "selected": false, "text": "<p>I think you could do that with Projections, something like</p>\n\n<pre><code>Criteria.forClass(bob.class.getName())\n ...
2008/09/12
[ "https://Stackoverflow.com/questions/58561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to get only the list of id of object bob for example instead of the list of bob. It's ok with a HQL request, but I would know if it's possible using criteria ? An example : ``` final StringBuilder hql = new StringBuilder(); hql.append( "select bob.id from " ) .append( bob.class.getName() ).append( " bo...
I think you could do that with Projections, something like ``` Criteria.forClass(bob.class.getName()) .add(Restrictions.gt("id", 10)) .setProjection(Projections.property("id")) ); ```
58,564
<p>I have a core dump file from a process that has probably a file descriptor leak (it opens files and sockets but apparently sometimes forgets to close some of them). Is there a way to find out which files and sockets the process had opened before crashing? I can't easily reproduce the crash, so analyzing the core fil...
[ { "answer_id": 58578, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>A core dump is a copy of the memory the process had access to when crashed. Depending on how the leak is occurring...
2008/09/12
[ "https://Stackoverflow.com/questions/58564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2148773/" ]
I have a core dump file from a process that has probably a file descriptor leak (it opens files and sockets but apparently sometimes forgets to close some of them). Is there a way to find out which files and sockets the process had opened before crashing? I can't easily reproduce the crash, so analyzing the core file s...
If you have a core file and you have compiled the program with debugging options (-g), you can see where the core was dumped: ``` $ gcc -g -o something something.c $ ./something Segmentation fault (core dumped) $ gdb something core ``` You can use this to do some post-morten debugging. A few gdb commands: bt prints ...
58,584
<p>Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when ...
[ { "answer_id": 58585, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p>Use the visual block command v (or V for whole lines and <kbd>C</kbd>-<kbd>V</kbd> for rectangular blocks). While in vi...
2008/09/12
[ "https://Stackoverflow.com/questions/58584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when usi...
Well, first of all, you can set `vim` to work with the mouse, which would allow you to select text just like you would in `Eclipse`. You can also use the Visual selection - `v`, by default. Once selected, you can `yank`, `cut`, etc. As far as commenting out the block, I usually select it with `VISUAL`, then do ``` :...
58,614
<p>I'm developing a multi-threaded app for a Linux embedded platform.</p> <p>At the moment I'm setting the stack size for each thread (via pthread_set_attr) to a fairly large default value. I would like to fine tune that value for each thread to something smaller to reduce my application's memory usage. I could go thr...
[ { "answer_id": 58628, "author": "Tobi", "author_id": 5422, "author_profile": "https://Stackoverflow.com/users/5422", "pm_score": 2, "selected": false, "text": "<p>I do not know any good tools but as last resort you could include some code in your application to check it, similar to the f...
2008/09/12
[ "https://Stackoverflow.com/questions/58614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6089/" ]
I'm developing a multi-threaded app for a Linux embedded platform. At the moment I'm setting the stack size for each thread (via pthread\_set\_attr) to a fairly large default value. I would like to fine tune that value for each thread to something smaller to reduce my application's memory usage. I could go through the...
Here are two tools that measure (native pthreads) stack usage in Linux applications: * [Valgrind](http://valgrind.org "Valgrind") * [Stackusage](https://github.com/d99kris/stackusage "stackusage") **Valgrind** Usage: ``` valgrind --tool=drd --show-stack-usage=yes PROG ``` Valgrind is a stable and powerful tool, u...
58,620
<p>How do I create a button control (with <code>CreateWindow</code> of a <code>BUTTON</code> window class) that has a standard system-wide size (especially height) that's consistent with the rest of Windows applications? I should of course take DPI into account and probably other settings.</p> <blockquote> <p><stron...
[ { "answer_id": 58636, "author": "Timbo", "author_id": 1810, "author_profile": "https://Stackoverflow.com/users/1810", "pm_score": 3, "selected": false, "text": "<p>This is what MSDN has to say: <a href=\"http://msdn.microsoft.com/en-us/library/ms997619.aspx\" rel=\"noreferrer\">Design Sp...
2008/09/12
[ "https://Stackoverflow.com/questions/58620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5049/" ]
How do I create a button control (with `CreateWindow` of a `BUTTON` window class) that has a standard system-wide size (especially height) that's consistent with the rest of Windows applications? I should of course take DPI into account and probably other settings. > > **Remark:** Using `USE_CW_DEFAULT` for width and...
In the perfect, hassle-free world... ------------------------------------ To create a standard size button we would have to do this: ``` LONG units = GetDialogBaseUnits(); m_hButton = CreateWindow(TEXT("BUTTON"), TEXT("Close"), WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 0, 0, MulDiv...
58,621
<p>How do I make an MD5 hash of a string with Delphi?</p>
[ { "answer_id": 58626, "author": "devstopfix", "author_id": 3366, "author_profile": "https://Stackoverflow.com/users/3366", "pm_score": 5, "selected": false, "text": "<p>If you want an MD5 digest and have the <a href=\"http://www.indyproject.org\" rel=\"nofollow noreferrer\">Indy</a> comp...
2008/09/12
[ "https://Stackoverflow.com/questions/58621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3366/" ]
How do I make an MD5 hash of a string with Delphi?
If you want an MD5 digest and have the [Indy](http://www.indyproject.org) components installed, you can do this: ``` uses SysUtils, IdGlobal, IdHash, IdHashMessageDigest; with TIdHashMessageDigest5.Create do try Result := TIdHash128.AsHex(HashValue('Hello, world')); finally Free; end; ``` Most popular algor...
58,622
<p>I like Doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have <code>/* .. */</code> comments, and also has its own self-documentation facility which seems to be the pythonic way to document.</p> <p>Since I'm familiar with Doxygen, how can I...
[ { "answer_id": 58701, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 7, "selected": true, "text": "<p>This is <a href=\"http://www.doxygen.nl/manual/docblocks.html#pythonblocks\" rel=\"noreferrer\">documented on the doxy...
2008/09/12
[ "https://Stackoverflow.com/questions/58622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2077/" ]
I like Doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have `/* .. */` comments, and also has its own self-documentation facility which seems to be the pythonic way to document. Since I'm familiar with Doxygen, how can I use it to produce m...
This is [documented on the doxygen website](http://www.doxygen.nl/manual/docblocks.html#pythonblocks), but to summarize here: You can use doxygen to document your Python code. You can either use the Python documentation string syntax: ``` """@package docstring Documentation for this module. More details. """ def fu...
58,630
<p>I have written some code in my VB.NET application to send an HTML e-mail (in this case, a lost password reminder).</p> <p>When I test the e-mail, it gets eaten by my spam filter. One of the things that it's scoring badly on is because of the following problem:</p> <pre>MIME_QP_LONG_LINE RAW: Quoted-printable lin...
[ { "answer_id": 58667, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 4, "selected": true, "text": "<p>Quoted printable expands 8 bit characters to \"={HEX-Code}\", thus making the messages longer. Maybe you are just hitting thi...
2008/09/12
[ "https://Stackoverflow.com/questions/58630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/475/" ]
I have written some code in my VB.NET application to send an HTML e-mail (in this case, a lost password reminder). When I test the e-mail, it gets eaten by my spam filter. One of the things that it's scoring badly on is because of the following problem: ``` MIME_QP_LONG_LINE RAW: Quoted-printable line longer than 76...
Quoted printable expands 8 bit characters to "={HEX-Code}", thus making the messages longer. Maybe you are just hitting this limit? Have you tried to break the message at, say, 70 characters? That should provide space for a couple of characters per line. Or you just encode the email with Base64 - all mail client can ...
58,649
<p>I would like to write a small program in C# which goes through my jpeg photos and, for example, sorts them into dated folders (using MY dating conventions, dammit...). </p> <p>Does anyone know a relatively easy way to get at the EXIF data such as Date And Time or Exposure programatically? Thanks!</p>
[ { "answer_id": 58662, "author": "goldenmean", "author_id": 2759376, "author_profile": "https://Stackoverflow.com/users/2759376", "pm_score": 3, "selected": false, "text": "<p>Getting EXIF data from a JPEG image involves:</p>\n\n<ol>\n<li>Seeking to the JPEG markers which mentions the beg...
2008/09/12
[ "https://Stackoverflow.com/questions/58649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
I would like to write a small program in C# which goes through my jpeg photos and, for example, sorts them into dated folders (using MY dating conventions, dammit...). Does anyone know a relatively easy way to get at the EXIF data such as Date And Time or Exposure programatically? Thanks!
Check out this [metadata extractor](https://www.drewnoakes.com/code/exif/). It is written in Java but has also been ported to C#. I have used the Java version to write a small utility to rename my jpeg files based on the date and model tags. Very easy to use. --- **EDIT** *metadata-extractor* supports .NET too. It's ...
58,670
<p>Does anyone know a method to programmatically close the CD tray on Windows 2000 or higher? Open CD tray exists, but I can't seem to make it close especially under W2k. </p> <p>I am especially looking for a method to do this from a batch file, if possible, but API calls would be OK.</p>
[ { "answer_id": 58678, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.nirsoft.net/utils/nircmd.html\" rel=\"nofollow noreferrer\">Nircmd</a> is a very handy freeware co...
2008/09/12
[ "https://Stackoverflow.com/questions/58670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3225/" ]
Does anyone know a method to programmatically close the CD tray on Windows 2000 or higher? Open CD tray exists, but I can't seem to make it close especially under W2k. I am especially looking for a method to do this from a batch file, if possible, but API calls would be OK.
Here is an easy way using the Win32 API: ``` [DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)] protected static extern int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback); public void OpenCloseCD(bool Open) { if (Ope...
58,697
<p>The situation: I have a pieceofcrapuous laptop. One of the things that make it pieceofcrapuous is that the battery is dead, and the power cable pulls out of the back with little effort.</p> <p>I recently received a non-pieceofcrapuous laptop, and I am in the process of copying everything from old to new. I'm trying...
[ { "answer_id": 58700, "author": "Edward Wilde", "author_id": 5182, "author_profile": "https://Stackoverflow.com/users/5182", "pm_score": 4, "selected": false, "text": "<p>I find RoboCopy is a good alternative to xcopy. It supports high latency connections much better and supports resumin...
2008/09/12
[ "https://Stackoverflow.com/questions/58697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
The situation: I have a pieceofcrapuous laptop. One of the things that make it pieceofcrapuous is that the battery is dead, and the power cable pulls out of the back with little effort. I recently received a non-pieceofcrapuous laptop, and I am in the process of copying everything from old to new. I'm trying to xcopy ...
/D may be what you are looking for. I find it works quite fast for backing-up as existing files are not copied. ``` xcopy "O:\*.*" N:\Whatever /C /D /S /H /C Continues copying even if errors occur. /D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose ...
58,709
<p>I'm using ADO.NET to access SQL Server 2005 and would like to be able to log from inside the T-SQL stored procedures that I'm calling. Is that somehow possible?</p> <p>I'm unable to see output from the 'print'-statement when using ADO.NET and since I want to use logging just for debuging the ideal solution would be...
[ { "answer_id": 58716, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 3, "selected": false, "text": "<p>You can either log to a table, by simply inserting a new row, or you can implement a CLR stored procedure to write to...
2008/09/12
[ "https://Stackoverflow.com/questions/58709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4164/" ]
I'm using ADO.NET to access SQL Server 2005 and would like to be able to log from inside the T-SQL stored procedures that I'm calling. Is that somehow possible? I'm unable to see output from the 'print'-statement when using ADO.NET and since I want to use logging just for debuging the ideal solution would be to emit m...
I solved this by writing a SQLCLR-procedure as Eric Z Beard suggested. The assembly must be signed with a strong name key file. ``` using System; using System.Data; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.SqlServer.Server; public partial class StoredProcedures { [Microsoft.SqlServ...
58,711
<p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p> <pre><code>Shoes.app do t = para "Not clicked!" button "The Label" do alert "You clicked the button!" # when clicked, make an alert t.replace "Clicked!" # ..and replace the label's text...
[ { "answer_id": 58917, "author": "Justin Voss", "author_id": 5616, "author_profile": "https://Stackoverflow.com/users/5616", "pm_score": 4, "selected": true, "text": "<p>You could actually pull this off, but it would require using metaclasses, which are <em>deep</em> magic (there be drago...
2008/09/12
[ "https://Stackoverflow.com/questions/58711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way: ``` Shoes.app do t = para "Not clicked!" button "The Label" do alert "You clicked the button!" # when clicked, make an alert t.replace "Clicked!" # ..and replace the label's text end end ``...
You could actually pull this off, but it would require using metaclasses, which are *deep* magic (there be dragons). If you want an intro to metaclasses, there's a series of [articles from IBM](http://www.ibm.com/developerworks/linux/library/l-pymeta.html) which manage to introduce the ideas without melting your brain....
58,743
<p>As an example take the following code:</p> <pre><code>public enum ExampleEnum { FooBar, BarFoo } public class ExampleClass : INotifyPropertyChanged { private ExampleEnum example; public ExampleEnum ExampleProperty { get { return example; } { /* set and notify */; } } } </code></pre> <p>I want a to d...
[ { "answer_id": 58766, "author": "rudigrobler", "author_id": 5147, "author_profile": "https://Stackoverflow.com/users/5147", "pm_score": 5, "selected": false, "text": "<p>I don't know if it is possible in XAML-only but try the following:</p>\n\n<p>Give your ComboBox a name so you can acce...
2008/09/12
[ "https://Stackoverflow.com/questions/58743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1733/" ]
As an example take the following code: ``` public enum ExampleEnum { FooBar, BarFoo } public class ExampleClass : INotifyPropertyChanged { private ExampleEnum example; public ExampleEnum ExampleProperty { get { return example; } { /* set and notify */; } } } ``` I want a to databind the property Examp...
You can create a custom markup extension. Example of usage: ``` enum Status { [Description("Available.")] Available, [Description("Not here right now.")] Away, [Description("I don't have time right now.")] Busy } ``` At the top of your XAML: ``` xmlns:my="clr-namespace:namespace_to_enum...
58,744
<p>I want to copy the entire contents of a directory from one location to another in C#.</p> <p>There doesn't appear to be a way to do this using <code>System.IO</code> classes without lots of recursion.</p> <p>There is a method in VB that we can use if we add a reference to <code>Microsoft.VisualBasic</code>:</p> <...
[ { "answer_id": 58759, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 6, "selected": false, "text": "<p>Or, if you want to go the hard way, add a reference to your project for Microsoft.VisualBasic and then use the following:</p...
2008/09/12
[ "https://Stackoverflow.com/questions/58744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
I want to copy the entire contents of a directory from one location to another in C#. There doesn't appear to be a way to do this using `System.IO` classes without lots of recursion. There is a method in VB that we can use if we add a reference to `Microsoft.VisualBasic`: ``` new Microsoft.VisualBasic.Devices.Comput...
Much easier ``` private static void CopyFilesRecursively(string sourcePath, string targetPath) { //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath)...
58,750
<p>Is it possible to obtain raw logs from Google Analytic? Is there any tool that can generate the raw logs from GA?</p>
[ { "answer_id": 58756, "author": "Matthias Winkelmann", "author_id": 4494, "author_profile": "https://Stackoverflow.com/users/4494", "pm_score": 2, "selected": false, "text": "<p>No. But why don't you just use your webserver's logs? The value of GA is not in the data they collect, but the...
2008/09/12
[ "https://Stackoverflow.com/questions/58750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/370899/" ]
Is it possible to obtain raw logs from Google Analytic? Is there any tool that can generate the raw logs from GA?
No you can't get the raw logs, but there's nothing stopping you from getting the exact same data logged to your own web server logs. Have a look at the [Urchin code](https://ssl.google-analytics.com/urchin.js) and borrow that, changing the following two lines to point to your web server instead. ``` var _ugifpath2="ht...
58,755
<p>What is the best way to do per-user database connections in <code>Rails</code>? </p> <p>I realize this is a poor Rails design practice, but we're gradually replacing an existing web application that uses one database per user. A complete redesign/rewrite is not feasible.</p>
[ { "answer_id": 58767, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 1, "selected": false, "text": "<p>Take a look at <a href=\"http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001397\" rel=\"nofollow noreferrer\"...
2008/09/12
[ "https://Stackoverflow.com/questions/58755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/624/" ]
What is the best way to do per-user database connections in `Rails`? I realize this is a poor Rails design practice, but we're gradually replacing an existing web application that uses one database per user. A complete redesign/rewrite is not feasible.
Put something like this in your application controller. I'm using the subdomain plus "\_clientdb" to pick the name of the database. I have all the databases using the same username and password, so I can grab that from the db config file. Hope this helps! ``` class ApplicationController < ActionController::Base be...
58,774
<p>I want to paste something I have cut from my desktop into a file open in Vi.</p> <p>But if I paste the tabs embed on top of each other across the page.</p> <p>I think it is some sort of visual mode change but can't find the command.</p>
[ { "answer_id": 58788, "author": "JayG", "author_id": 5823, "author_profile": "https://Stackoverflow.com/users/5823", "pm_score": 2, "selected": false, "text": "<p>If you are using VIM, you can use \"*p (i.e. double quotes, asterisk, letter p).</p>\n" }, { "answer_id": 58794, ...
2008/09/12
[ "https://Stackoverflow.com/questions/58774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6096/" ]
I want to paste something I have cut from my desktop into a file open in Vi. But if I paste the tabs embed on top of each other across the page. I think it is some sort of visual mode change but can't find the command.
If you're using plain vi: ------------------------- You probably have `autoindent` on. To turn it off while pasting: ``` <Esc> :set noai <paste all you want> <Esc> :set ai ``` I have in my `.exrc` the following shortcuts: ``` map ^P :set noai^M map ^N :set ai^M ``` Note that these have to be the actual control...
58,831
<p>My boss found a bug in a query I created, and I don't understand the reasoning behind the bug, although the query results prove he's correct. Here's the query (simplified version) before the fix:</p> <pre><code>select PTNO,PTNM,CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD); </code></pre>...
[ { "answer_id": 58896, "author": "hollystyles", "author_id": 2083160, "author_profile": "https://Stackoverflow.com/users/2083160", "pm_score": 0, "selected": false, "text": "<p>It is generally advised to be specific and fully qualify all column names anyway, as it saves the optimizer a li...
2008/09/12
[ "https://Stackoverflow.com/questions/58831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3751/" ]
My boss found a bug in a query I created, and I don't understand the reasoning behind the bug, although the query results prove he's correct. Here's the query (simplified version) before the fix: ``` select PTNO,PTNM,CATCD from PARTS left join CATEGORIES on (CATEGORIES.CATCD=PARTS.CATCD); ``` and here it is after ...
I'm afraid I can't tell you why you're not getting an exception, but I can postulate as to why it chose CATEGORIES' version of the column over PARTS' version. > > As far as I understood, in the case of left joins, the "main" table in the query (PARTS) has precedence in ambiguity > > > It's not clear whether by "m...
58,841
<p>How can I get precompiled headers working with GCC?</p> <p>I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on <a href="https://en.wikipedia.org/wiki/Cygwin" rel="nofollow noreferrer">Cygwin</a> GCC 3.4.4 and using 4.0 on <a href="https://en.wikipedia.org/wiki...
[ { "answer_id": 58987, "author": "Paul", "author_id": 5841, "author_profile": "https://Stackoverflow.com/users/5841", "pm_score": 3, "selected": false, "text": "<p>I have managed to get precompiled headers working under gcc once in the past, and I recall having problems then as well. The ...
2008/09/12
[ "https://Stackoverflow.com/questions/58841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5200/" ]
How can I get precompiled headers working with GCC? I have had no luck in my attempts and I haven't seen many good examples for how to set it up. I've tried on [Cygwin](https://en.wikipedia.org/wiki/Cygwin) GCC 3.4.4 and using 4.0 on [Ubuntu](https://en.wikipedia.org/wiki/Ubuntu_%28operating_system%29).
[Firstly, see the documentation here](http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html). You compile headers just like any other file but you put the output inside a file with a suffix of `.gch`. So for example if you precompile stdafx.h you will have a precompiled header that will be automatically searche...
58,851
<p>I am running an application through gdb and I want to set a breakpoint for any time a specific variable is accessed / changed. Is there a good method for doing this? I would also be interested in other ways to monitor a variable in C/C++ to see if/when it changes.</p>
[ { "answer_id": 58892, "author": "mweerden", "author_id": 4285, "author_profile": "https://Stackoverflow.com/users/4285", "pm_score": 3, "selected": false, "text": "<p>I just tried the following:</p>\n\n<pre><code> $ cat gdbtest.c\n int abc = 43;\n\n int main()\n {\n abc = 10;\n }\n $ g...
2008/09/12
[ "https://Stackoverflow.com/questions/58851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3022/" ]
I am running an application through gdb and I want to set a breakpoint for any time a specific variable is accessed / changed. Is there a good method for doing this? I would also be interested in other ways to monitor a variable in C/C++ to see if/when it changes.
*watch* only breaks on write, *rwatch* let you break on read, and *awatch* let you break on read/write. You can set read watchpoints on memory locations: ``` gdb$ rwatch *0xfeedface Hardware read watchpoint 2: *0xfeedface ``` but one limitation applies to the rwatch and awatch commands; you can't use gdb variables ...
58,872
<p>I've read in several places that the rectangle functions in emacs are very useful. I've read a bit about them, and I can't quite figure why. I mean, when you want to kill a paragraph, you mark the first row/column and then the last one, and that's actually a rectangle, right? But you can still use the normal kill.....
[ { "answer_id": 58885, "author": "David Webb", "author_id": 3171, "author_profile": "https://Stackoverflow.com/users/3171", "pm_score": 6, "selected": true, "text": "<p>If you have data in columns in a text file with <code>M-x delete-rectangle</code> or <code>M-x kill-rectangle</code> you...
2008/09/12
[ "https://Stackoverflow.com/questions/58872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3785/" ]
I've read in several places that the rectangle functions in emacs are very useful. I've read a bit about them, and I can't quite figure why. I mean, when you want to kill a paragraph, you mark the first row/column and then the last one, and that's actually a rectangle, right? But you can still use the normal kill... S...
If you have data in columns in a text file with `M-x delete-rectangle` or `M-x kill-rectangle` you can delete a single column of data. Similarly, `M-x yank-rectangle` will paste in a column of text. For example, take the following text: ``` 1. alligator alphorn 2. baboon bugle 3. crocodile cornet 4. dog ...
58,916
<p>Suppose I have a table called Companies that has a DepartmentID column. There's also a Departaments table that has as EmployeeID column. Of course I have an Employee table as well. The problem is that I want to delete a company, so first i have to delete all the employees for every departament and then all the depar...
[ { "answer_id": 58943, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": "<p>I'm not answering your question, but foreign Keys <em>is</em> the way to go, why is it not an option?</p>\n\n<p>As...
2008/09/12
[ "https://Stackoverflow.com/questions/58916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
Suppose I have a table called Companies that has a DepartmentID column. There's also a Departaments table that has as EmployeeID column. Of course I have an Employee table as well. The problem is that I want to delete a company, so first i have to delete all the employees for every departament and then all the departam...
I'm not sure why you need nested transactions here. You only need one actual transaction: ``` BEGIN TRAN DELETE FROM Employee FROM Employee INNER JOIN Department ON Employee.DepartmentID = Department.DepartmentID INNER JOIN Company ON Department.CompanyID = Company.CompanyID WHERE Company.CompanyID = ...
58,925
<p>I have any ASP.NET control. I want the HTML string how to do I get the HTML string of the control?</p>
[ { "answer_id": 58931, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 6, "selected": true, "text": "<p>This appears to work.</p>\n\n<pre><code>public string RenderControlToHtml(Control ControlToRender)\n{\n System.Tex...
2008/09/12
[ "https://Stackoverflow.com/questions/58925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469/" ]
I have any ASP.NET control. I want the HTML string how to do I get the HTML string of the control?
This appears to work. ``` public string RenderControlToHtml(Control ControlToRender) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter stWriter = new System.IO.StringWriter(sb); System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(stWriter); ...
58,937
<p>Using VB.NET, how do I toggle the state of Caps Lock? </p>
[ { "answer_id": 58941, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 4, "selected": true, "text": "<p>From: <a href=\"http://www.vbforums.com/showthread.php?referrerid=61394&amp;t=537891\" rel=\"noreferrer\">http://www.vbforu...
2008/09/12
[ "https://Stackoverflow.com/questions/58937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133/" ]
Using VB.NET, how do I toggle the state of Caps Lock?
From: <http://www.vbforums.com/showthread.php?referrerid=61394&t=537891> ``` Imports System.Runtime.InteropServices Public Class Form2 Private Declare Sub keybd_event Lib "user32" ( _ ByVal bVk As Byte, _ ByVal bScan As Byte, _ ByVal dwFlags As Integer, _ ByVal dwExtraInfo As Inte...
58,939
<p>I'm trying to get an event to fire whenever a choice is made from a <code>JComboBox</code>.</p> <p>The problem I'm having is that there is no obvious <code>addSelectionListener()</code> method.</p> <p>I've tried to use <code>actionPerformed()</code>, but it never fires.</p> <p>Short of overriding the model for th...
[ { "answer_id": 58963, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 9, "selected": true, "text": "<p>It should respond to <a href=\"http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionListener.html\" rel=\"norefe...
2008/09/12
[ "https://Stackoverflow.com/questions/58939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I'm trying to get an event to fire whenever a choice is made from a `JComboBox`. The problem I'm having is that there is no obvious `addSelectionListener()` method. I've tried to use `actionPerformed()`, but it never fires. Short of overriding the model for the `JComboBox`, I'm out of ideas. How do I get notified o...
It should respond to [ActionListeners](http://docs.oracle.com/javase/7/docs/api/java/awt/event/ActionListener.html), like this: ``` combo.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { doSomething(); } }); ``` [@John Calsbeek](https://stackoverflow.com/a/58965...
58,940
<p>I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure?</p> <pre><code>CREATE PROCEDURE getOrder (@orderId as numeric) AS BEGIN s...
[ { "answer_id": 58960, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 0, "selected": false, "text": "<p>You could select them into temp tables or write table valued functions to return result sets. Are asking how to iterate ...
2008/09/12
[ "https://Stackoverflow.com/questions/58940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1836/" ]
I'm using SQL Server 2005, and I would like to know how to access different result sets from within transact-sql. The following stored procedure returns two result sets, how do I access them from, for example, another stored procedure? ``` CREATE PROCEDURE getOrder (@orderId as numeric) AS BEGIN select order_ad...
The short answer is: you can't do it. From T-SQL there is no way to access multiple results of a nested stored procedure call, without changing the stored procedure as others have suggested. To be complete, if the procedure were returning a single result, you could insert it into a temp table or table variable with t...
58,969
<p>I'm starting to learn how to use PHPUnit to test the website I'm working on. The problem I'm running into is that I have five different user types defined and I need to be able to test every class with the different types. I currently have a user class and I would like to pass this to each function but I can't fig...
[ { "answer_id": 58982, "author": "Peter Bernier", "author_id": 6112, "author_profile": "https://Stackoverflow.com/users/6112", "pm_score": 1, "selected": false, "text": "<p>If you're looking to test the actual UI, you could try using something like Selenium (www.openqa.org). It lets you w...
2008/09/12
[ "https://Stackoverflow.com/questions/58969", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4437/" ]
I'm starting to learn how to use PHPUnit to test the website I'm working on. The problem I'm running into is that I have five different user types defined and I need to be able to test every class with the different types. I currently have a user class and I would like to pass this to each function but I can't figure o...
If your various user classes inherit from a parent user class, then I recommend you use the same inheritance structure for your test case classes. Consider the following sample classes: ``` class User { public function commonFunctionality() { return 'Something'; } public function modifiedFunc...
58,976
<p>How do I find out whether or not Caps Lock is activated, using VB.NET?</p> <p>This is a follow-up to my <a href="https://stackoverflow.com/questions/58937/how-do-i-toggle-caps-lock-in-vbnet">earlier question</a>.</p>
[ { "answer_id": 58991, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "<p>I'm not an expert in VB.NET so only PInvoke comes to my mind:</p>\n\n<pre><code>Declare Function GetKeyState Lib \"user32\" \n...
2008/09/12
[ "https://Stackoverflow.com/questions/58976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133/" ]
How do I find out whether or not Caps Lock is activated, using VB.NET? This is a follow-up to my [earlier question](https://stackoverflow.com/questions/58937/how-do-i-toggle-caps-lock-in-vbnet).
[Control.IsKeyLocked(Keys) Method - MSDN](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.iskeylocked.aspx) ``` Imports System Imports System.Windows.Forms Imports Microsoft.VisualBasic Public Class CapsLockIndicator Public Shared Sub Main() if Control.IsKeyLocked(Keys.CapsLock) Then...
59,013
<p>Context: I'm in charge of running a service written in .NET. Proprietary application. It uses a SQL Server database. It ran as a user member of the Administrators group in the local machine. It worked alright before I added the machine to a domain.</p> <p>So, I added the machine to a domain (Win 2003) and changed ...
[ { "answer_id": 59070, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You can set it in the thread context in which your code is executing.</p>\n\n<p>System.Threading.Thread.CurrentThread.Curren...
2008/09/12
[ "https://Stackoverflow.com/questions/59013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
Context: I'm in charge of running a service written in .NET. Proprietary application. It uses a SQL Server database. It ran as a user member of the Administrators group in the local machine. It worked alright before I added the machine to a domain. So, I added the machine to a domain (Win 2003) and changed the user t...
There are two types of localisation in .NET, both the settings for the cultures can be found in these variables (fire up a .NET command line app on the machine to see what it says): System.Thread.CurrentThread.CurrentCulture & System.Thread.CurrentThread.CurrentUICulture <http://msdn.microsoft.com/en-us/library/syste...
59,044
<p>Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Windows server 2003)</p>
[ { "answer_id": 59055, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 8, "selected": true, "text": "<p>The following query replace each and every <code>a</code> character with a <code>b</code> character.</p>\n\n<pre><code>UPDA...
2008/09/12
[ "https://Stackoverflow.com/questions/59044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2908/" ]
Question is pretty self explanitory. I want to do a simple find and replace, like you would in a text editor on the data in a column of my database (which is MsSQL on MS Windows server 2003)
The following query replace each and every `a` character with a `b` character. ``` UPDATE YourTable SET Column1 = REPLACE(Column1,'a','b') WHERE Column1 LIKE '%a%' ``` This will not work on SQL server 2003.
59,075
<p>How do I save each sheet in an Excel workbook to separate <code>CSV</code> files with a macro?</p> <p>I have an excel with multiple sheets and I was looking for a macro that will save each sheet to a separate <code>CSV (comma separated file)</code>. Excel will not allow you to save all sheets to different <code>CSV...
[ { "answer_id": 59078, "author": "Alex Duggleby", "author_id": 5790, "author_profile": "https://Stackoverflow.com/users/5790", "pm_score": 4, "selected": false, "text": "<p>And here's my solution should work with Excel > 2000, but tested only on 2007:</p>\n\n<pre><code>Private Sub SaveAll...
2008/09/12
[ "https://Stackoverflow.com/questions/59075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5790/" ]
How do I save each sheet in an Excel workbook to separate `CSV` files with a macro? I have an excel with multiple sheets and I was looking for a macro that will save each sheet to a separate `CSV (comma separated file)`. Excel will not allow you to save all sheets to different `CSV` files.
Here is one that will give you a visual file chooser to pick the folder you want to save the files to and also lets you choose the CSV delimiter (I use pipes '|' because my fields contain commas and I don't want to deal with quotes): ``` ' ---------------------- Directory Choosing Helper Functions --------------------...
59,099
<p>Visually both of the following snippets produce the same UI. So why are there 2 controls..<br> <strong>Snippet1</strong> </p> <pre><code>&lt;TextBlock&gt;Name:&lt;/TextBlock&gt; &lt;TextBox Name="nameTextBox" /&gt; </code></pre> <p><strong>Snippet2</strong></p> <pre><code>&lt;Label&gt;Name:&lt;/Label&gt; &lt;Tex...
[ { "answer_id": 59104, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 4, "selected": false, "text": "<p>Label has an important <strong>focus handling</strong> responsibility.Its purpose is to allow you to place a caption with an...
2008/09/12
[ "https://Stackoverflow.com/questions/59099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
Visually both of the following snippets produce the same UI. So why are there 2 controls.. **Snippet1** ``` <TextBlock>Name:</TextBlock> <TextBox Name="nameTextBox" /> ``` **Snippet2** ``` <Label>Name:</Label> <TextBox Name="nameTextBox" /> ``` (*Well I am gonna answer this myself... thought this is a useful ...
The WPF Textblock inherits from **FrameworkElement** instead of deriving from **System.Windows.Control** like the Label Control. This means that the Textblock is much more lightweight. The downside of using a textblock is no support for Access/Accerelator Keys and there is no link to other controls as target. ***When ...
59,102
<p>Let's say that I'm writing a function to convert between temperature scales. I want to support at least Celsius, Fahrenheit, and Kelvin. Is it better to pass the source scale and target scale as separate parameters of the function, or some sort of combined parameter?</p> <p>Example 1 - separate parameters: function...
[ { "answer_id": 59108, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 5, "selected": true, "text": "<p>Go with the first option, but rather than allow literal strings (which are error prone), take constant values or an enume...
2008/09/12
[ "https://Stackoverflow.com/questions/59102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6126/" ]
Let's say that I'm writing a function to convert between temperature scales. I want to support at least Celsius, Fahrenheit, and Kelvin. Is it better to pass the source scale and target scale as separate parameters of the function, or some sort of combined parameter? Example 1 - separate parameters: function convertTe...
Go with the first option, but rather than allow literal strings (which are error prone), take constant values or an enumeration if your language supports it, like this: ``` convertTemperature (TempScale.CELSIUS, TempScale.FAHRENHEIT, 22) ```
59,107
<p>I'm converting an application to use Java 1.5 and have found the following method:</p> <pre><code> /** * Compare two Comparables, treat nulls as -infinity. * @param o1 * @param o2 * @return -1 if o1&amp;lt;o2, 0 if o1==o2, 1 if o1&amp;gt;o2 */ protected static int nullCompare(Comparable o1, Compar...
[ { "answer_id": 59119, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 5, "selected": true, "text": "<p>Change it to:</p>\n\n<pre><code>protected static &lt;T extends Comparable&lt;T&gt;&gt; int nullCompare(T o1, T o2) {\n</c...
2008/09/12
[ "https://Stackoverflow.com/questions/59107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4389/" ]
I'm converting an application to use Java 1.5 and have found the following method: ``` /** * Compare two Comparables, treat nulls as -infinity. * @param o1 * @param o2 * @return -1 if o1&lt;o2, 0 if o1==o2, 1 if o1&gt;o2 */ protected static int nullCompare(Comparable o1, Comparable o2) { if (o1 ...
Change it to: ``` protected static <T extends Comparable<T>> int nullCompare(T o1, T o2) { ``` You need that because Comparable is itself a generic type.
59,120
<p>I am getting this error now that I hit version number 1.256.0: Error 4 Invalid product version '1.256.0'. Must be of format '##.##.####'</p> <p>The installer was fine with 1.255.0 but something with 256 (2^8) it doesn't like. I found this stated on msdn.com: The Version property must be formatted as N.N.N, whe...
[ { "answer_id": 59119, "author": "jodonnell", "author_id": 4223, "author_profile": "https://Stackoverflow.com/users/4223", "pm_score": 5, "selected": true, "text": "<p>Change it to:</p>\n\n<pre><code>protected static &lt;T extends Comparable&lt;T&gt;&gt; int nullCompare(T o1, T o2) {\n</c...
2008/09/12
[ "https://Stackoverflow.com/questions/59120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5967/" ]
I am getting this error now that I hit version number 1.256.0: Error 4 Invalid product version '1.256.0'. Must be of format '##.##.####' The installer was fine with 1.255.0 but something with 256 (2^8) it doesn't like. I found this stated on msdn.com: The Version property must be formatted as N.N.N, where each N repre...
Change it to: ``` protected static <T extends Comparable<T>> int nullCompare(T o1, T o2) { ``` You need that because Comparable is itself a generic type.
59,166
<p>So I have an object which has some fields, doesn't really matter what. I have a generic list of these objects.</p> <pre><code>List&lt;MyObject&gt; myObjects = new List&lt;MyObject&gt;(); myObjects.Add(myObject1); myObjects.Add(myObject2); myObjects.Add(myObject3); </code></pre> <p>So I want to remove objects from my...
[ { "answer_id": 59172, "author": "Erik van Brakel", "author_id": 909, "author_profile": "https://Stackoverflow.com/users/909", "pm_score": 7, "selected": true, "text": "<p>There's two options, an explicit delegate or a delegate disguised as a lamba construct:</p>\n<p>explicit delegate</p>...
2008/09/12
[ "https://Stackoverflow.com/questions/59166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/454247/" ]
So I have an object which has some fields, doesn't really matter what. I have a generic list of these objects. ``` List<MyObject> myObjects = new List<MyObject>(); myObjects.Add(myObject1); myObjects.Add(myObject2); myObjects.Add(myObject3); ``` So I want to remove objects from my list based on some criteria. For in...
There's two options, an explicit delegate or a delegate disguised as a lamba construct: explicit delegate ``` myObjects.RemoveAll(delegate (MyObject m) { return m.X >= 10; }); ``` lambda ``` myObjects.RemoveAll(m => m.X >= 10); ``` --- Performance wise both are equal. As a matter of fact, both language construc...
59,181
<p>I have a WCF service that gets called from client side JavaScript. The call fails with a Service is null JavaScript error. WebDevelopment helper trace shows that the calls to load the jsdebug support file results in a 404 (file not found) error. </p> <p>Restarting IIS or clearing out the Temp ASP.Net files or setti...
[ { "answer_id": 59764, "author": "rams", "author_id": 3635, "author_profile": "https://Stackoverflow.com/users/3635", "pm_score": 5, "selected": true, "text": "<p>Figured it out!</p>\n\n<p>Here is the services configuration section from web.config</p>\n\n<p>Look at the bindingConfiguratio...
2008/09/12
[ "https://Stackoverflow.com/questions/59181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3635/" ]
I have a WCF service that gets called from client side JavaScript. The call fails with a Service is null JavaScript error. WebDevelopment helper trace shows that the calls to load the jsdebug support file results in a 404 (file not found) error. Restarting IIS or clearing out the Temp ASP.Net files or setting batch="...
Figured it out! Here is the services configuration section from web.config Look at the bindingConfiguration attribute on the endpoint. The value "webBinding" points to the binding name="webBinding" tag in the bindings and that is what tells the service to use Transport level security it HTTPS. In my case the attribut...
59,182
<p>What is the best way to keep an asp:button from displaying it's URL on the status bar of the browser? The button is currently defines like this:</p> <pre><code>&lt;asp:button id="btnFind" runat="server" Text="Find Info" onclick="btnFind_Click"&gt; &lt;/asp:button&gt; </code><...
[ { "answer_id": 59189, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 1, "selected": true, "text": "<p>I use FF so never noticed this, but the link does in fact appear in the status bar in IE..</p>\n<p>I dont think you can ov...
2008/09/12
[ "https://Stackoverflow.com/questions/59182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206/" ]
What is the best way to keep an asp:button from displaying it's URL on the status bar of the browser? The button is currently defines like this: ``` <asp:button id="btnFind" runat="server" Text="Find Info" onclick="btnFind_Click"> </asp:button> ``` **Update:** This appears to ...
I use FF so never noticed this, but the link does in fact appear in the status bar in IE.. I dont think you can overwrite it :( I initially thought maybe setting the ToolTip (al la "title") property might do it.. Seems it does not.. Looking at the source, what appears is nowhere to be found, so I would say this is a ...
59,217
<p>Is there a built in function in .NET 2.0 that will take two arrays and merge them into one array?</p> <p>The arrays are both of the same type. I'm getting these arrays from a widely used function within my code base and can't modify the function to return the data in a different format.</p> <p>I'm looking to avoid...
[ { "answer_id": 59230, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 3, "selected": false, "text": "<p>I think you can use <a href=\"http://msdn.microsoft.com/en-us/library/y5s0whfd.aspx\" rel=\"noreferrer\">Array.Copy</a> fo...
2008/09/12
[ "https://Stackoverflow.com/questions/59217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3058/" ]
Is there a built in function in .NET 2.0 that will take two arrays and merge them into one array? The arrays are both of the same type. I'm getting these arrays from a widely used function within my code base and can't modify the function to return the data in a different format. I'm looking to avoid writing my own f...
If you can manipulate one of the arrays, you can resize it before performing the copy: ``` T[] array1 = getOneArray(); T[] array2 = getAnotherArray(); int array1OriginalLength = array1.Length; Array.Resize<T>(ref array1, array1OriginalLength + array2.Length); Array.Copy(array2, 0, array1, array1OriginalLength, array2....
59,220
<p>I'm writing a utility for myself, partly as an exercise in learning C# Reflection and partly because I actually want the resulting tool for my own use.</p> <p>What I'm after is basically pointing the application at an assembly and choosing a given class from which to select properties that should be included in an ...
[ { "answer_id": 59243, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 5, "selected": true, "text": "<p>Couple of options here:</p>\n\n<ol>\n<li>Attach to <code>AppDomain.AssemblyResolve</code> and do another <code>LoadFi...
2008/09/12
[ "https://Stackoverflow.com/questions/59220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1124/" ]
I'm writing a utility for myself, partly as an exercise in learning C# Reflection and partly because I actually want the resulting tool for my own use. What I'm after is basically pointing the application at an assembly and choosing a given class from which to select properties that should be included in an exported H...
Couple of options here: 1. Attach to `AppDomain.AssemblyResolve` and do another `LoadFile` based on the requested assembly. 2. Spin up another `AppDomain` with the directory as its base and load the assemblies in that `AppDomain`. I'd highly recommend pursuing option 2, since that will likely be cleaner and allow you...
59,232
<p>What's the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table?</p> <p>For example: I have a <code>JOBS</code> table with the column <code>JOB_NUMBER</code>. How can I find out if I have any duplicate <code>JOB_NUMBER</code>...
[ { "answer_id": 59242, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 10, "selected": true, "text": "<p>Aggregate the column by COUNT, then use a HAVING clause to find values that appear greater than one time.</p>\n<pr...
2008/09/12
[ "https://Stackoverflow.com/questions/59232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
What's the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table? For example: I have a `JOBS` table with the column `JOB_NUMBER`. How can I find out if I have any duplicate `JOB_NUMBER`s, and how many times they're duplicated?
Aggregate the column by COUNT, then use a HAVING clause to find values that appear greater than one time. ``` SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name HAVING COUNT(column_name) > 1; ```
59,267
<p>Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are no longer supported.</p> <p>The question is, what is the equivalent for them? I've an app that was built using Preview 2, now I have to make it compatible with the latest CTP releases.</p>
[ { "answer_id": 59271, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": false, "text": "<p>Just write <code>&lt;input type=\"button\" ... /&gt;</code> into your html. There's nothing special at all with the...
2008/09/12
[ "https://Stackoverflow.com/questions/59267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
Starting from ASP.NET MVC Preview 3, HTML.Button ( and other related HTML controls) are no longer supported. The question is, what is the equivalent for them? I've an app that was built using Preview 2, now I have to make it compatible with the latest CTP releases.
I figured it out. It goes something like this: ``` <form method="post" action="<%= Html.AttributeEncode(Url.Action("CastUpVote")) %>"> <input type="submit" value="<%=ViewData.Model.UpVotes%> up votes" /> </form> ```
59,280
<p>I need to update a <code>combobox</code> with a new value so it changes the reflected text in it. The cleanest way to do this is after the <code>combobox</code>has been initialised and with a message.</p> <p>So I am trying to craft a <code>postmessage</code> to the hwnd that contains the <code>combobox</code>.</p> ...
[ { "answer_id": 59317, "author": "Simon Steele", "author_id": 4591, "author_profile": "https://Stackoverflow.com/users/4591", "pm_score": 4, "selected": true, "text": "<p>You want <a href=\"http://msdn.microsoft.com/en-us/library/bb856484(VS.85).aspx\" rel=\"nofollow noreferrer\">ComboBox...
2008/09/12
[ "https://Stackoverflow.com/questions/59280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342/" ]
I need to update a `combobox` with a new value so it changes the reflected text in it. The cleanest way to do this is after the `combobox`has been initialised and with a message. So I am trying to craft a `postmessage` to the hwnd that contains the `combobox`. So if I want to send a message to it, changing the curren...
You want [ComboBox\_SetCurSel](http://msdn.microsoft.com/en-us/library/bb856484(VS.85).aspx): ``` ComboBox_SetCurSel(hWndCombo, n); ``` or if it's an MFC CComboBox control you can probably do: ``` m_combo.SetCurSel(2); ``` I would imagine if you're doing it manually you would also want SendMessage rather than Pos...
59,294
<p>I have the following query:</p> <pre><code>select column_name, count(column_name) from table group by column_name having count(column_name) &gt; 1; </code></pre> <p>What would be the difference if I replaced all calls to <code>count(column_name)</code> to <code>count(*)</code>?</p> <p>This question was inspired b...
[ { "answer_id": 59302, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 9, "selected": true, "text": "<p><code>count(*)</code> counts NULLs and <code>count(column)</code> does not</p>\n\n<p>[edit] added this code so that people ...
2008/09/12
[ "https://Stackoverflow.com/questions/59294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I have the following query: ``` select column_name, count(column_name) from table group by column_name having count(column_name) > 1; ``` What would be the difference if I replaced all calls to `count(column_name)` to `count(*)`? This question was inspired by [How do I find duplicate values in a table in Oracle?](h...
`count(*)` counts NULLs and `count(column)` does not [edit] added this code so that people can run it ``` create table #bla(id int,id2 int) insert #bla values(null,null) insert #bla values(1,null) insert #bla values(null,1) insert #bla values(1,null) insert #bla values(null,1) insert #bla values(1,null) insert #bla v...
59,309
<p>What is the best way to vertically center the content of a div when the height of the content is variable. In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable height as well. Also, I would love a ...
[ { "answer_id": 59324, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 4, "selected": false, "text": "<p>This is something I have needed to do many times and a consistent solution still requires you add a little non-semantic m...
2008/09/12
[ "https://Stackoverflow.com/questions/59309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5651/" ]
What is the best way to vertically center the content of a div when the height of the content is variable. In my particular case, the height of the container div is fixed, but it would be great if there were a solution that would work in cases where the container has a variable height as well. Also, I would love a solu...
Just add ``` position: relative; top: 50%; transform: translateY(-50%); ``` to the inner div. What it does is moving the inner div's top border to the half height of the outer div (`top: 50%;`) and then the inner div up by half its height (`transform: translateY(-50%)`). This will work with `position: absolute` or ...
59,313
<p>I remember watching a webcast from Mark Russinovich showing the sequence of keyboard keys for a user initiated kernel dump. Can somebody refresh my memory on the exact order of the keys.</p> <p>Please note this is for XP.</p>
[ { "answer_id": 59358, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>I don't know of any keyboard short cuts, but are you looking for like in task manager, when you right click on a process a...
2008/09/12
[ "https://Stackoverflow.com/questions/59313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4337/" ]
I remember watching a webcast from Mark Russinovich showing the sequence of keyboard keys for a user initiated kernel dump. Can somebody refresh my memory on the exact order of the keys. Please note this is for XP.
<http://psacake.com/web/jr.asp> contains full instructions, and here's an excerpt: ``` While it may seem odd to think about purposefully causing a Blue Screen Of Death (BSOD), Microsoft includes such a provision in Windows XP. This might come in handy for testing and troubleshooting your Startup And Recovery settings...
59,322
<p>I have the following code:</p> <pre><code>SELECT &lt;column&gt;, count(*) FROM &lt;table&gt; GROUP BY &lt;column&gt; HAVING COUNT(*) &gt; 1; </code></pre> <p>Is there any difference to the results or performance if I replace the COUNT(*) with COUNT('x')?</p> <p>(This question is related to a <a href="https://stac...
[ { "answer_id": 59385, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 2, "selected": false, "text": "<p>The major performance difference is that COUNT(*) can be satisfied by examining the primary key on the table.</p>\n\n<p>i....
2008/09/12
[ "https://Stackoverflow.com/questions/59322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
I have the following code: ``` SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING COUNT(*) > 1; ``` Is there any difference to the results or performance if I replace the COUNT(\*) with COUNT('x')? (This question is related to a [previous one](https://stackoverflow.com/questions/59294/in-sql-whats-the-...
To say that `SELECT COUNT(*) vs COUNT(1)` results in your DBMS returning "columns" is pure bunk. That *may* have been the case long, long ago but any self-respecting query optimizer will choose some fast method to count the rows in the table - there is **NO** performance difference between `SELECT COUNT(*), COUNT(1), C...
59,331
<p>Suppose I have <code>fileA.h</code> which declares a class <code>classA</code> with template function <code>SomeFunc&lt;T&gt;()</code>. This function is implemented directly in the header file (as is usual for template functions). Now I add a specialized implementation of <code>SomeFunc()</code> (like for <code>Some...
[ { "answer_id": 59359, "author": "Brandon", "author_id": 5959, "author_profile": "https://Stackoverflow.com/users/5959", "pm_score": 0, "selected": false, "text": "<p>Unless the specialized template function is also listed in the header file, the other application will have no knowledge o...
2008/09/12
[ "https://Stackoverflow.com/questions/59331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2148773/" ]
Suppose I have `fileA.h` which declares a class `classA` with template function `SomeFunc<T>()`. This function is implemented directly in the header file (as is usual for template functions). Now I add a specialized implementation of `SomeFunc()` (like for `SomeFunc<int>()`) in `fileA.C` (ie. not in the header file). ...
It is **an error** to have a specialization for a template which is not visible at the point of call. Unfortunately, compilers are not required to diagnose this error, and can then do what they like with your code (in standardese it is "ill formed, no diagnostic required"). Technically, you need to define the speciali...
59,380
<p>I have a wildcard subdomain enabled and dynamically parse the URL by passing it as-is to my <code>index.php</code> (ex. <code>somecity.domain.com</code>). </p> <p>Now, I wish to create a few subdomains that are static where I can install different application and not co-mingle with my current one (ex. <code>blog.d...
[ { "answer_id": 59382, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 0, "selected": false, "text": "<p>You'll have to configure apache for those static sub-domains. The \"catch-all\" site will be the default site configured...
2008/09/12
[ "https://Stackoverflow.com/questions/59380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6140/" ]
I have a wildcard subdomain enabled and dynamically parse the URL by passing it as-is to my `index.php` (ex. `somecity.domain.com`). Now, I wish to create a few subdomains that are static where I can install different application and not co-mingle with my current one (ex. `blog.domain.com`). My `.htaccess` currently...
Your .htaccess does nothing useful, as Apache is probably configured with DirectoryIndex index.php. Well, it does move domain.com/a to domain.com/index.php, but I doubt that is what you want. Your wildcard virtualhost works because you probably have ServerAlias \*.domain.com in your configuration, or a single virtualh...
59,390
<p>In a ColdFusion Component (CFC), is it necessary to use fully qualified names for variables-scoped variables?</p> <p>Am I going to get myself into trouble if I change this:</p> <pre><code>&lt;cfcomponent&gt; &lt;cfset variables.foo = "a private instance variable"&gt; &lt;cffunction name = "doSomething"&gt...
[ { "answer_id": 59554, "author": "Soldarnal", "author_id": 3420, "author_profile": "https://Stackoverflow.com/users/3420", "pm_score": 4, "selected": true, "text": "<p>It won't matter to specify \"variables\" when you create the variable, because foo will be placed in the variables scope ...
2008/09/12
[ "https://Stackoverflow.com/questions/59390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437/" ]
In a ColdFusion Component (CFC), is it necessary to use fully qualified names for variables-scoped variables? Am I going to get myself into trouble if I change this: ``` <cfcomponent> <cfset variables.foo = "a private instance variable"> <cffunction name = "doSomething"> <cfset var bar = "a function ...
It won't matter to specify "variables" when you create the variable, because foo will be placed in the variables scope by default; but it will matter when you access the variable. ``` <cfcomponent> <cfset foo = "a private instance variable"> <cffunction name="doSomething"> <cfargument name="foo" requi...
59,396
<p>I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it ...
[ { "answer_id": 59420, "author": "chrissie1", "author_id": 2936, "author_profile": "https://Stackoverflow.com/users/2936", "pm_score": -1, "selected": false, "text": "<p>you should mock the transaction and make it return true fo IsSaved, if you can mock the transaction of course.</p>\n\n<...
2008/09/12
[ "https://Stackoverflow.com/questions/59396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it shoul...
Gorge, The simplest solution, which I found, applied to your question is the following: ``` Expect.Call(() => dao.Save(transaction)) .Do(new Action<Transaction>(x => x.IsSaved = true)); ``` So you don't need to create a special delegate or anything else. Just use Action which is in standard .NET 3.5 libraries....
59,422
<p>Is accessing a <strong>bool</strong> field atomic in C#? In particular, do I need to put a lock around:</p> <pre><code>class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) { ... } } </code></pre>
[ { "answer_id": 59430, "author": "Larsenal", "author_id": 337, "author_profile": "https://Stackoverflow.com/users/337", "pm_score": 8, "selected": true, "text": "<p><strong>Yes.</strong></p>\n\n<blockquote>\n <p>Reads and writes of the following data types are atomic: bool, char, byte, s...
2008/09/12
[ "https://Stackoverflow.com/questions/59422", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838/" ]
Is accessing a **bool** field atomic in C#? In particular, do I need to put a lock around: ``` class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) { ... } } ```
**Yes.** > > Reads and writes of the following data types are atomic: bool, char, byte, sbyte, short, ushort, uint, int, float, and reference types. > > > as found in [C# Language Spec](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/variables#atomicity-of-variable-refer...
59,423
<p>I've got the following in my .css file creating a little image next to each link on my site:</p> <pre class="lang-css prettyprint-override"><code>div.post .text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } </code></pre> <p>Ho...
[ { "answer_id": 59448, "author": "Thunder3", "author_id": 2832, "author_profile": "https://Stackoverflow.com/users/2832", "pm_score": 1, "selected": false, "text": "<p>It might be worth it to add a class to those <code>&lt;a&gt;</code> tags and then add another declaration to remove the b...
2008/09/12
[ "https://Stackoverflow.com/questions/59423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1683/" ]
I've got the following in my .css file creating a little image next to each link on my site: ```css div.post .text a[href^="http:"] { background: url(../../pics/remote.gif) right top no-repeat; padding-right: 10px; white-space: nowrap; } ``` How do I modify this snippet (or add something new) to exclude ...
If you set the background color and have a negative right margin on the image, the image will cover the external link image. Example: ```css a[href^="http:"] { background: url(http://en.wikipedia.org/skins-1.5/monobook/external.png) right center no-repeat; padding-right: 14px; white-space: nowrap; } a[href...
59,425
<p>I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record.</p> <pre><code>INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(), ?, ?) </code></pre>
[ { "answer_id": 59437, "author": "Alexander Morland", "author_id": 4013, "author_profile": "https://Stackoverflow.com/users/4013", "pm_score": 3, "selected": true, "text": "<pre><code>SELECT * FROM messages WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) &lt;= messageTime\n</code></pre>\n" }, ...
2008/09/12
[ "https://Stackoverflow.com/questions/59425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
I'm using MySQL in particular, but I'm hoping for a cross-vendor solution. I'm using the NOW() function to add a timestamp as a column for each record. ``` INSERT INTO messages (typeId, messageTime, stationId, message) VALUES (?, NOW(), ?, ?) ```
``` SELECT * FROM messages WHERE DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= messageTime ```
59,444
<p>Is there a system stored procedure to get the version #?</p>
[ { "answer_id": 59449, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 5, "selected": false, "text": "<p>SELECT @@VERSION</p>\n" }, { "answer_id": 59457, "author": "Joe Kuemerle", "author_id": 4273, "author_...
2008/09/12
[ "https://Stackoverflow.com/questions/59444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
Is there a system stored procedure to get the version #?
Try ``` SELECT @@VERSION ``` or for SQL Server 2000 and above the following is easier to parse :) ``` SELECT SERVERPROPERTY('productversion') , SERVERPROPERTY('productlevel') , SERVERPROPERTY('edition') ``` From: <http://support.microsoft.com/kb/321185>
59,451
<p>How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight.</p> <p>Edit: Here's the code I'm now using this for, based on the answer from Santiago below.</p> <pre><code>public DataTemplate Create(Type type) { return (DataTemplate)XamlReader.Load( ...
[ { "answer_id": 62871, "author": "jarda", "author_id": 6601, "author_profile": "https://Stackoverflow.com/users/6601", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.windows.datatemplate%28v=vs.95%29.aspx\" rel=\"nofollow noreferrer\...
2008/09/12
[ "https://Stackoverflow.com/questions/59451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5932/" ]
How do I create a silverlight data template in code? I've seen plenty of examples for WPF, but nothing for Silverlight. Edit: Here's the code I'm now using this for, based on the answer from Santiago below. ``` public DataTemplate Create(Type type) { return (DataTemplate)XamlReader.Load( @"<DataTemplate ...
Although you cannot programatically create it, you can load it from a XAML string in code like this: ``` public static DataTemplate Create(Type type) { return (DataTemplate) XamlReader.Load( @"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007""> ...
59,456
<p>I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item.</p> <p>Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, _File</p> <p>However, if I wanted to put in a UserControl, I bel...
[ { "answer_id": 59706, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 2, "selected": false, "text": "<p>The problem is you placed the image inside of the content of the MenuHeader which means that you'll lose the accelerator k...
2008/09/12
[ "https://Stackoverflow.com/questions/59456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/483/" ]
I'd like to make some custom MenuHeaders in WPF so I can have (for example), an icon and text in a menu item. Normally using MenuItems, if you populate the Header field with straight text, you can add an accelerator by using an underscore. eg, \_File However, if I wanted to put in a UserControl, I believe this functi...
I think the Icon property fits your needs. However to answer the original question, it is possible to retain the Accelerator functionality when you compose the content of your menuitem. **If you have nested content in a MenuItem you need to define the AccessText property explicitly** like in the first one below. Whe...
59,465
<p>By default the webjump hotlist has the following which I use quite often:</p> <pre><code>M-x webjump RET Google M-x webjump RET Wikipedia </code></pre> <p>How can I add 'Stackoverflow' to my list?</p>
[ { "answer_id": 59476, "author": "Marcel Levy", "author_id": 676, "author_profile": "https://Stackoverflow.com/users/676", "pm_score": 2, "selected": true, "text": "<p>Here's some example code in <a href=\"http://www.opensource.apple.com/darwinsource/10.0/emacs-39/emacs/lisp/webjump.el\" ...
2008/09/12
[ "https://Stackoverflow.com/questions/59465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
By default the webjump hotlist has the following which I use quite often: ``` M-x webjump RET Google M-x webjump RET Wikipedia ``` How can I add 'Stackoverflow' to my list?
Here's some example code in [a webjump.el file on a site run by Apple:](http://www.opensource.apple.com/darwinsource/10.0/emacs-39/emacs/lisp/webjump.el) ``` ;; (require 'webjump) ;; (global-set-key "\C-cj" 'webjump) ;; (setq webjump-sites ;; (append '( ;; ("My Home Page" . "www.someisp...
59,472
<p>Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this:</p> <p><strong>Before:</strong></p> <pre><code>Some Text here This gets cut Some Code there </code></pre> <p><strong>After:</strong></p> <pre><code>Some Text here Some Code there </code></pre> <p><strong>What I want:</strong></p> ...
[ { "answer_id": 59513, "author": "Tomas Sedovic", "author_id": 2239, "author_profile": "https://Stackoverflow.com/users/2239", "pm_score": 3, "selected": true, "text": "<p>Unless I misunderstood you:<br>\nJust place cursor on the line you want to cut (no selection) and press <kbd>Ctrl</kb...
2008/09/12
[ "https://Stackoverflow.com/questions/59472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6143/" ]
Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this: **Before:** ``` Some Text here This gets cut Some Code there ``` **After:** ``` Some Text here Some Code there ``` **What I want:** ``` Some Text here Some Code there ``` PS: I don't want to select the whole line or something...
Unless I misunderstood you: Just place cursor on the line you want to cut (no selection) and press `Ctrl` + `x`. That cuts the line (leaving no blanks) and puts the text in the Clipboard. (tested in *MS VC# 2008 Express* with no additional settings I'm aware of) Is that what you want?
59,483
<pre><code>1167 ptr = (void*)getcwd(cwd, MAX_PATH_LENGTH-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/MMC-SD/partition1/aaaaaaaaaaa" (gdb) print &amp;cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/MMC-SD/partition1/aaaaaaaaaaa", '...
[ { "answer_id": 59509, "author": "oliver", "author_id": 2148773, "author_profile": "https://Stackoverflow.com/users/2148773", "pm_score": 1, "selected": false, "text": "<p>That <code>ptr</code> is displayed as nicely-formatted string and <code>cwd</code> as \"byte buffer\" is probably spe...
2008/09/12
[ "https://Stackoverflow.com/questions/59483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5330/" ]
``` 1167 ptr = (void*)getcwd(cwd, MAX_PATH_LENGTH-1); (gdb) n 1168 if (!ptr) { (gdb) print ptr $1 = 0xbff2d96c "/media/MMC-SD/partition1/aaaaaaaaaaa" (gdb) print &cwd $2 = (char (*)[3500]) 0xbff2d96c (gdb) print strlen(cwd) $3 = 36 (gdb) print "%s",cwd $4 = "/media/MMC-SD/partition1/aaaaaaaaaaa", '\0' <repeat...
The reason that `cwd` is printed differently in `gdb` is because `gdb` knows that `ptr` is a `char *` (I guess) and that `cwd` is an array of length `3500` (as shown in your output). So when printing `ptr` it prints the pointer value (and as a service also the string it points to) and when printing `cwd` it prints the ...
59,515
<p>I am new to all the anonymous features and need some help. I have gotten the following to work:</p> <pre><code>public void FakeSaveWithMessage(Transaction t) { t.Message = "I drink goats blood"; } public delegate void FakeSave(Transaction t); public void SampleTestFunction() { Expect.Call(delegate { _dao...
[ { "answer_id": 59531, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 0, "selected": false, "text": "<p>Try something like:</p>\n\n<pre><code>Expect.Call(delegate { _dao.Save(t); }).Do(new EventHandler(delegate(Transac...
2008/09/12
[ "https://Stackoverflow.com/questions/59515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I am new to all the anonymous features and need some help. I have gotten the following to work: ``` public void FakeSaveWithMessage(Transaction t) { t.Message = "I drink goats blood"; } public delegate void FakeSave(Transaction t); public void SampleTestFunction() { Expect.Call(delegate { _dao.Save(t); }).Do...
That's a well known error message. Check the link below for a more detailed discussion. <http://staceyw1.wordpress.com/2007/12/22/they-are-anonymous-methods-not-anonymous-delegates/> Basically you just need to put a cast in front of your anonymous delegate (your lambda expression). In case the link ever goes down, ...
59,544
<p>I have the following tables, the <code>groups</code> table which contains hierarchically ordered groups and <code>group_member</code> which stores which groups a user belongs to. </p> <pre><code>groups --------- id parent_id name group_member --------- id group_id user_id ID PARENT_ID NAME -------------------...
[ { "answer_id": 59594, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 0, "selected": false, "text": "<p>I don't think that this can be accomplished without using recursion. You can accomplish it with with a single stored pro...
2008/09/12
[ "https://Stackoverflow.com/questions/59544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I have the following tables, the `groups` table which contains hierarchically ordered groups and `group_member` which stores which groups a user belongs to. ``` groups --------- id parent_id name group_member --------- id group_id user_id ID PARENT_ID NAME --------------------------- 1 NULL Cerebra 2 ...
Two things come to mind: **1 -** You can repeatedly outer-join the table to itself to recursively walk up your tree, as in: ``` SELECT * FROM MY_GROUPS MG1 ,MY_GROUPS MG2 ,MY_GROUPS MG3 ,MY_GROUPS MG4 ,MY_GROUPS MG5 ,MY_GROUP_MEMBERS MGM WHERE MG1.PARENT_ID = MG2.UNIQID (+) AND MG1.UNIQID = MGM.GROUP_ID (+) ...
59,557
<p>is there an easy way to transform HTML into markdown with JAVA?</p> <p>I am currently using the Java <strong><a href="http://code.google.com/p/markdownj/" rel="noreferrer">MarkdownJ</a></strong> library to transform markdown to html.</p> <pre><code>import com.petebevin.markdown.MarkdownProcessor; ... public static...
[ { "answer_id": 178278, "author": "myabc", "author_id": 3789, "author_profile": "https://Stackoverflow.com/users/3789", "pm_score": 2, "selected": false, "text": "<p>I am working on the same issue, and experimenting with a couple different techniques.</p>\n\n<p>The answer above could work...
2008/09/12
[ "https://Stackoverflow.com/questions/59557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
is there an easy way to transform HTML into markdown with JAVA? I am currently using the Java **[MarkdownJ](http://code.google.com/p/markdownj/)** library to transform markdown to html. ``` import com.petebevin.markdown.MarkdownProcessor; ... public static String getHTML(String markdown) { MarkdownProcessor markd...
There is a great library for JS called [Turndown](https://github.com/domchristie/turndown), you can try it online [here](https://mixmark-io.github.io/turndown/). It works for htmls that the accepted answer errors out. I needed it for Java (as the question), so I ported it. The library for Java is called [CopyDown](htt...
59,599
<p>I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with:</p> <pre><code>if not isNull(Rs("myField")) and Rs("myField") &lt;&gt; 0 then ... </code></pre> <p>...because if Rs("myField...
[ { "answer_id": 59606, "author": "busse", "author_id": 5702, "author_profile": "https://Stackoverflow.com/users/5702", "pm_score": 3, "selected": false, "text": "<p>Nested IFs (only slightly less verbose):</p>\n\n<pre><code>if not isNull(Rs(\"myField\")) Then\n if Rs(\"myField\") &lt;&g...
2008/09/12
[ "https://Stackoverflow.com/questions/59599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1818/" ]
I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with: ``` if not isNull(Rs("myField")) and Rs("myField") <> 0 then ... ``` ...because if Rs("myField") is null, you get an error in t...
Maybe not the best way, but it certainly works... Also, if you are in vb6 or .net, you can have different methods that cast to proper type too. ``` if cint( getVal( rs("blah"), "" ) )<> 0 then 'do something end if function getVal( v, replacementVal ) if v is nothing then getVal = replacementVal else get...
59,628
<p>I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects.</p> <p>Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs?</p> <p>This has bee...
[ { "answer_id": 59652, "author": "Gareth Jenkins", "author_id": 1521, "author_profile": "https://Stackoverflow.com/users/1521", "pm_score": 0, "selected": false, "text": "<p>Could you put the DataGrids inside panels that have their visibility set to false, then call a client-side javascri...
2008/09/12
[ "https://Stackoverflow.com/questions/59628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
I have a page results page (you get there after submitting your search query elsewhere) whit a whole bunch of gridviews for different type of data objects. Obviously, some of the queries take longer than the others. How can I make each gridview render as soon as it has the data it needs? This has been tricky for me b...
@Gareth Jenkins The page will execute all of the queries before returning even the first update panel, so he won't save any time there. The trick to do this is to move each of your complex gridviews into a user control, in the user control, get rid of the Object DataSource crap, and do your binding in the code behind...
59,635
<p>Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or installing them to the system.</p> <p>Pre-SP1, this was working fine (and still works fine on our...
[ { "answer_id": 70808, "author": "Roel", "author_id": 11449, "author_profile": "https://Stackoverflow.com/users/11449", "pm_score": 6, "selected": true, "text": "<p>I have battled this problem myself last week and consider myself somewhat of an expert now ;)</p>\n\n<p>I'm 99% sure that no...
2008/09/12
[ "https://Stackoverflow.com/questions/59635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1441/" ]
Since our switch from Visual Studio 6 to Visual Studio 2008, we've been using the MFC90.dll and msvc[pr]90.dlls along with the manifest files in a private side-by-side configuration so as to not worry about versions or installing them to the system. Pre-SP1, this was working fine (and still works fine on our developer...
I have battled this problem myself last week and consider myself somewhat of an expert now ;) I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put ``` #define _BIND_TO_CURRENT_MFC_VERSION 1 #define _BIND_TO_CURRENT_CRT_VERSION 1 ``` into *every* project you're us...
59,642
<p>What's the best way to determine which version of the .NET Compact Frameworks (including Service Packs) is installed on a device through a .NET application. </p>
[ { "answer_id": 70808, "author": "Roel", "author_id": 11449, "author_profile": "https://Stackoverflow.com/users/11449", "pm_score": 6, "selected": true, "text": "<p>I have battled this problem myself last week and consider myself somewhat of an expert now ;)</p>\n\n<p>I'm 99% sure that no...
2008/09/12
[ "https://Stackoverflow.com/questions/59642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2723/" ]
What's the best way to determine which version of the .NET Compact Frameworks (including Service Packs) is installed on a device through a .NET application.
I have battled this problem myself last week and consider myself somewhat of an expert now ;) I'm 99% sure that not all dlls and static libraries were recompiled with the SP1 version. You need to put ``` #define _BIND_TO_CURRENT_MFC_VERSION 1 #define _BIND_TO_CURRENT_CRT_VERSION 1 ``` into *every* project you're us...
59,648
<p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: <em><a href="http://www.gallup.com" rel="nofollow noreferrer">www.gallup.com</a></em> and <em><a href="http://www.rassmussenreports.com" rel="nofollow noreferrer">www.rassmussenreports.com</a></em></p> <p>I'm...
[ { "answer_id": 59662, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 2, "selected": false, "text": "<p>Are you talking about doing this?</p>\n\n<pre><code>&gt;&gt;&gt; a = [ ['a', 'b'], ['c', 'd'] ]\n&gt;&gt;&gt; a[1]...
2008/09/12
[ "https://Stackoverflow.com/questions/59648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6163/" ]
I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: *[www.gallup.com](http://www.gallup.com)* and *[www.rassmussenreports.com](http://www.rassmussenreports.com)* I'm using a brute force method, where the computer generates some random daily polling data and then...
Would something like this work? ``` from random import randint mcworks = [] for n in xrange(NUM_ITERATIONS): mctest = [randint(0, 100) for i in xrange(5)] if sum(mctest[:3])/3 == mcavg[2]: mcworks.append(mctest) # mcavg is real data ``` In the end, you are left with a list of valid `mctest` lis...
59,651
<p>I have a web page that I have hooked up to a <a href="http://en.wikipedia.org/wiki/Stored_procedure" rel="nofollow noreferrer">stored procedure</a>. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. </p> <p><a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nof...
[ { "answer_id": 59662, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 2, "selected": false, "text": "<p>Are you talking about doing this?</p>\n\n<pre><code>&gt;&gt;&gt; a = [ ['a', 'b'], ['c', 'd'] ]\n&gt;&gt;&gt; a[1]...
2008/09/12
[ "https://Stackoverflow.com/questions/59651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/730/" ]
I have a web page that I have hooked up to a [stored procedure](http://en.wikipedia.org/wiki/Stored_procedure). In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. [ASP.NET](http://en.wikipedia.org/wiki/ASP.NET) seems to want to default to *int32*, but the number won...
Would something like this work? ``` from random import randint mcworks = [] for n in xrange(NUM_ITERATIONS): mctest = [randint(0, 100) for i in xrange(5)] if sum(mctest[:3])/3 == mcavg[2]: mcworks.append(mctest) # mcavg is real data ``` In the end, you are left with a list of valid `mctest` lis...
59,653
<p>Is there a way to get at the ItemContaner of a selected item in a listbox? In Silverlight 2.0 Beta 1 I could, but the container is hidden in Beta 2 of Silverlight 2.0. </p> <p>I'm trying to resize the listbox item when it is unselected to a specific size and when selected to a variable size. I also want to get th...
[ { "answer_id": 86980, "author": "dcstraw", "author_id": 10391, "author_profile": "https://Stackoverflow.com/users/10391", "pm_score": 0, "selected": false, "text": "<p>If you are adding non-UI elements to the listbox (such as strings or non-UI data objects), then this is probably pretty ...
2008/09/12
[ "https://Stackoverflow.com/questions/59653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/580/" ]
Is there a way to get at the ItemContaner of a selected item in a listbox? In Silverlight 2.0 Beta 1 I could, but the container is hidden in Beta 2 of Silverlight 2.0. I'm trying to resize the listbox item when it is unselected to a specific size and when selected to a variable size. I also want to get the relative p...
There is a way to obtain the Panel containing the item's UIElement and the mapping of items to UIElements. You have to inherit from ListBox (this actually works for any ItemsControl) and override PrepareContainerForItemOverride: ``` protected override void PrepareContainerForItemOverride(DependencyObject element, obje...
59,655
<p>Given a controller method like: </p> <pre><code>def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml =&gt; model } end end </code></pre> <p>What's the best way to write an integration test that asserts that the return has the expected...
[ { "answer_id": 59714, "author": "Michael Sepcot", "author_id": 6033, "author_profile": "https://Stackoverflow.com/users/6033", "pm_score": 0, "selected": false, "text": "<p>Set the request objects accept header:</p>\n\n<pre><code>@request.accept = 'text/xml' # or 'application/xml' I forg...
2008/09/12
[ "https://Stackoverflow.com/questions/59655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4748/" ]
Given a controller method like: ``` def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => model } end end ``` What's the best way to write an integration test that asserts that the return has the expected XML?
A combination of using the format and assert\_select in an integration test works great: ``` class ProductsTest < ActionController::IntegrationTest def test_contents_of_xml get '/index/1.xml' assert_select 'product name', /widget/ end end ``` For more details check out [assert\_select](http://apidock.com...
59,670
<p>I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning:</p> <blockquote> <p>warning: deprecated conversion from string constant to ‘char*’</p> </blockquote> <p>Obviously, the correct way to fix this is to find every declaration like</p> <pre><code>char *s = &q...
[ { "answer_id": 59687, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stackoverflow.com/users/4761", "pm_score": 9, "selected": true, "text": "<p>I believe passing <a href=\"https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-write-strings\" rel=\"nofollo...
2008/09/12
[ "https://Stackoverflow.com/questions/59670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3830/" ]
I'm working on an exceedingly large codebase, and recently upgraded to GCC 4.3, which now triggers this warning: > > warning: deprecated conversion from string constant to ‘char\*’ > > > Obviously, the correct way to fix this is to find every declaration like ``` char *s = "constant string"; ``` or function ca...
I believe passing [-Wno-write-strings](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-write-strings) to GCC will suppress this warning.
59,680
<p>In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?</p>
[ { "answer_id": 59683, "author": "Derek", "author_id": 5440, "author_profile": "https://Stackoverflow.com/users/5440", "pm_score": 3, "selected": false, "text": "<pre><code>Set s = New NotesSession\nSet db = s.CurrentDatabase\n\nIf db.Server &lt;&gt; \"\" Then\n Set sName = New NotesName...
2008/09/12
[ "https://Stackoverflow.com/questions/59680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5440/" ]
In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?
``` Set s = New NotesSession Set db = s.CurrentDatabase If db.Server <> "" Then Set sName = New NotesName(db.Server) Else Set sName = New NotesName(s.Username) End If ```
59,711
<p>Is there an equivalent operator to Haskell's list difference operator <code>\\</code> in F#?</p>
[ { "answer_id": 59814, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 3, "selected": false, "text": "<p>Nope... Just write it and make it an infix operator --using the set of special characters. Backslash (<code>\\</code>) is ...
2008/09/12
[ "https://Stackoverflow.com/questions/59711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4592/" ]
Is there an equivalent operator to Haskell's list difference operator `\\` in F#?
Was bounced, yet I believe it is worth to write here the implementation of `( /-/ )` (the F# version of Haskell's `\\`): ``` let flip f x y = f y x let rec delete x = function | [] -> [] | h :: t when x = h -> t | h :: t -> h :: delete x t let inline ( /-/ ) xs ys = List.fold (flip delete) xs ys ``` This wil...
59,719
<p>I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback).</p> <p>Basically, I need to check for IsPostBack in JavaScript.</p> <p>Thank you.</p>
[ { "answer_id": 59724, "author": "NerdFury", "author_id": 6146, "author_profile": "https://Stackoverflow.com/users/6146", "pm_score": 2, "selected": false, "text": "<p>You could put a hidden input on the page, and after the page loads, give it a value. Then you can check that field, if i...
2008/09/12
[ "https://Stackoverflow.com/questions/59719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3661/" ]
I need to run a JavaScript function onLoad(), but only do it if the page loaded the first time (i.e. is not the result of a postback). Basically, I need to check for IsPostBack in JavaScript. Thank you.
Server-side, write: ``` if(IsPostBack) { // NOTE: the following uses an overload of RegisterClientScriptBlock() // that will surround our string with the needed script tags ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", "var isPostBack = true;", true); } ``` Then, in your script which run...
59,726
<p>Is there a way in .net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically?</p>
[ { "answer_id": 59738, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 0, "selected": false, "text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/system.environment.aspx\" rel=\"nofollow noreferrer\">System....
2008/09/12
[ "https://Stackoverflow.com/questions/59726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5287/" ]
Is there a way in .net 2.0 to discover the network alias for the machine that my code is running on? Specifically, if my workgroup sees my machine as //jekkedev01, how do I retrieve that name programmatically?
Since you can have multiple network interfaces, each of which can have multiple IPs, and any single IP can have multiple names that can resolve to it, there may be more than one. If you want to know all the names by which your DNS server knows your machine, you can loop through them all like this: ``` public ArrayLis...
59,734
<p>My application is using <strong>Dojo 1.1.1</strong> on an <em>SSL-only</em> website. It is currently taking advantage of <code>dijit.ProgressBar</code> and a <code>dijit.form.DateTextBox</code>.</p> <p>Everything works fabulous in <em>Firefox 2 &amp; 3</em>, but as soon as I try the same scripts in <em>IE7</em> the...
[ { "answer_id": 60433, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 1, "selected": false, "text": "<p>If your page is loading files from a non-https URL Firefox should tell you the same thing. Instead of an error the lock symbo...
2008/09/12
[ "https://Stackoverflow.com/questions/59734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644/" ]
My application is using **Dojo 1.1.1** on an *SSL-only* website. It is currently taking advantage of `dijit.ProgressBar` and a `dijit.form.DateTextBox`. Everything works fabulous in *Firefox 2 & 3*, but as soon as I try the same scripts in *IE7* the results are an annoying Security Information dialog: > > This page ...
After reviewing the JavaScript sourcecode for Dijit, I thought it was likely the error results from an "insecure" refrence to a dynamically generated IFRAME. Note there are two versions of the script file, the uncompressed represents the original source (dijit.js.uncompressed.js) and the standard (dijit.js) has been co...
59,743
<p>How many possible combinations of the variables a,b,c,d,e are possible if I know that:</p> <pre><code>a+b+c+d+e = 500 </code></pre> <p>and that they are all integers and >= 0, so I know they are finite.</p>
[ { "answer_id": 59748, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 0, "selected": false, "text": "<p>If they are a real numbers then infinite ... otherwise it is a bit trickier.</p>\n\n<p>(OK, for any computer representa...
2008/09/12
[ "https://Stackoverflow.com/questions/59743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1815/" ]
How many possible combinations of the variables a,b,c,d,e are possible if I know that: ``` a+b+c+d+e = 500 ``` and that they are all integers and >= 0, so I know they are finite.
@Torlack, @Jason Cohen: Recursion is a bad idea here, because there are "overlapping subproblems." I.e., If you choose `a` as `1` and `b` as `2`, then you have 3 variables left that should add up to 497; you arrive at the same subproblem by choosing `a` as `2` and `b` as `1`. (The number of such coincidences explodes a...
59,761
<p>I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks.</p> <p>Long Edit: </p> <p>@apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace to m...
[ { "answer_id": 59748, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 0, "selected": false, "text": "<p>If they are a real numbers then infinite ... otherwise it is a bit trickier.</p>\n\n<p>(OK, for any computer representa...
2008/09/12
[ "https://Stackoverflow.com/questions/59761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78/" ]
I need to disable specific keys (Ctrl and Backspace) in Internet Explorer 6. Is there a registry hack to do this. It has to be IE6. Thanks. Long Edit: @apandit: Whoops. I need to more specific about the backspace thing. When I say disable backspace, I mean disable the ability for Backspace to mimic the Back browser ...
@Torlack, @Jason Cohen: Recursion is a bad idea here, because there are "overlapping subproblems." I.e., If you choose `a` as `1` and `b` as `2`, then you have 3 variables left that should add up to 497; you arrive at the same subproblem by choosing `a` as `2` and `b` as `1`. (The number of such coincidences explodes a...
59,766
<p>I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jQuery 1.2.6, but intellisense will not work in a separate jscript file. I have the jQuery library referenced first on my web page in the &lt;head> tag. Am I doing anything wrong?</p>
[ { "answer_id": 59770, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 7, "selected": true, "text": "<p>At the top of your external JavaScript file, add the following:</p>\n\n<pre><code>/// &lt;reference path=\"jQuery.js\...
2008/09/12
[ "https://Stackoverflow.com/questions/59766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1284/" ]
I thought jQuery Intellisense was supposed to be improved with SP1. I even downloaded an annotated version of jQuery 1.2.6, but intellisense will not work in a separate jscript file. I have the jQuery library referenced first on my web page in the <head> tag. Am I doing anything wrong?
At the top of your external JavaScript file, add the following: ``` /// <reference path="jQuery.js"/> ``` Make sure the path is correct, relative to the file's position in the folder structure, etc. Also, any references need to be at the top of the file, before *any* other text, including comments - literally, the ...
59,790
<p>I have been hearing the podcast blog for a while, I hope I dont break this. The question is this: I have to insert an xml to a database. This will be for already defined tables and fields. So what is the best way to accomplish this? So far I am leaning toward programatic. I have been seeing varios options, one is D...
[ { "answer_id": 59882, "author": "HigherAbstraction", "author_id": 5945, "author_profile": "https://Stackoverflow.com/users/5945", "pm_score": 0, "selected": false, "text": "<p>If your XML conforms to a particular XSD schema, you can look into using the \"xsd.exe\" command line tool to ge...
2008/09/12
[ "https://Stackoverflow.com/questions/59790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have been hearing the podcast blog for a while, I hope I dont break this. The question is this: I have to insert an xml to a database. This will be for already defined tables and fields. So what is the best way to accomplish this? So far I am leaning toward programatic. I have been seeing varios options, one is Data...
In an attempt to try and help, we may need some clarification. Maybe by restating the problem you can let us know if this is what you're asking: **How can one import existing xml into a SQL 2005 database, without relying on the built-in xml type?** A fairly straight forward solution that you already mentioned is the ...
59,816
<p>I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is created. </p> <p>The tests on my developm...
[ { "answer_id": 96314, "author": "Frosty", "author_id": 7476, "author_profile": "https://Stackoverflow.com/users/7476", "pm_score": 3, "selected": true, "text": "<p>According to <a href=\"http://www.mapforums.com/load-new-map-separate-thread-keep-ui-responsive-4605.html\" rel=\"nofollow n...
2008/09/12
[ "https://Stackoverflow.com/questions/59816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1314/" ]
I'm having some problems integrating MS MapPoint 2009 into my WinForms .Net 2.0 application in C#. I've added the ActiveX MapPoint control onto a form and have no problems getting it to display a maps and locations; my concern is the time it takes to load a map once it is created. The tests on my development machine ...
According to [these](http://www.mapforums.com/load-new-map-separate-thread-keep-ui-responsive-4605.html) [threads](http://www.mapforums.com/activex-performance-net-3415.html) at mapforums.com the slowness of ActiveX startup is well known and unavoidable (though the question of threading to help with GUI responsiveness ...