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
541,797
<p>I have a class (say <code>MyClass</code>) that uses (has as a private field) a <code>TcpClient</code> object. <code>MyClass</code> implements <code>IDisposable</code> calling <code>TcpClient.Close</code> in the <code>Dispose</code> method. </p> <p>My question is should <code>MyClass</code> also implement a finalize...
[ { "answer_id": 541807, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 0, "selected": false, "text": "<p>Yes you should - <a href=\"http://msdn.microsoft.com/en-us/library/b1yfkh5e(VS.71).aspx\" rel=\"nofollow noreferrer...
2009/02/12
[ "https://Stackoverflow.com/questions/541797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class (say `MyClass`) that uses (has as a private field) a `TcpClient` object. `MyClass` implements `IDisposable` calling `TcpClient.Close` in the `Dispose` method. My question is should `MyClass` also implement a finalizer to call `Dispose(bool Disposing)` to free the `TcpClient’s` unmanaged resources in ca...
**No you shouldn't.** Because **you should never call a method on an other object in a finalizer**, it could have been finalized before your object. The finalizer of your TcpClient will be called by the garbage collector, so let him do. The pattern in Dispose is : ``` protected virtual void Dispose(bool disposing) ...
541,808
<p>We're taking one of our production databases and creating a copy on another server for read-only purposes. The read-only database is on SQL Server 2008. Once the database is on the new server we'd like to optimize it for read-only use.</p> <p>One problem is that there are large amounts of allocated space for some...
[ { "answer_id": 541822, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 0, "selected": false, "text": "<p>I think it will be OK to just recreate it from the backup.</p>\n\n<p>Putting <code>tables</code> and <code>indexes</co...
2009/02/12
[ "https://Stackoverflow.com/questions/541808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18891/" ]
We're taking one of our production databases and creating a copy on another server for read-only purposes. The read-only database is on SQL Server 2008. Once the database is on the new server we'd like to optimize it for read-only use. One problem is that there are large amounts of allocated space for some of the tabl...
One thing you may wish to consider is to change the recovery model of the database to simple. If you do not intend to perform any write activity to the database then you may as well benefit from automatic truncation of the transaction log, and eliminate the administrative overhead of using the other recovery models. Yo...
541,816
<p>Is there any practical difference in terms of effects on the component model between:</p> <pre><code>class MyComponent : Component { public MyComponent() { InitializeComponent(); } public MyComponent(IContainer container) { container.Add(this); InitializeComponent(); } } </c...
[ { "answer_id": 541849, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 3, "selected": true, "text": "<p>Order of execution differs. In </p>\n\n<pre><code>public MyComponent(IContainer container) {\n container.Add(th...
2009/02/12
[ "https://Stackoverflow.com/questions/541816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27667/" ]
Is there any practical difference in terms of effects on the component model between: ``` class MyComponent : Component { public MyComponent() { InitializeComponent(); } public MyComponent(IContainer container) { container.Add(this); InitializeComponent(); } } ``` and: ``` c...
Order of execution differs. In ``` public MyComponent(IContainer container) { container.Add(this); InitializeComponent(); } ``` `InitializeComponent()` is executed *after* `container.Add()`, whereas here ``` public MyComponent(IContainer container) : this() { container.Add(this); } ``` `container.Add...
541,832
<p>I'm looking for a tool or a script that will take the console log from my web app, parse out the garbage collection information and display it in a meaningful way.</p> <p>I'm starting up on a Sun Java 1.4.2 JVM with the following flags:</p> <pre><code>-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails </code><...
[ { "answer_id": 541845, "author": "Petteri H", "author_id": 28841, "author_profile": "https://Stackoverflow.com/users/28841", "pm_score": 1, "selected": false, "text": "<p>How about trying out some profiling tool like JProbe Freeware (Eclipse plug-in).</p>\n" }, { "answer_id": 541...
2009/02/12
[ "https://Stackoverflow.com/questions/541832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28991/" ]
I'm looking for a tool or a script that will take the console log from my web app, parse out the garbage collection information and display it in a meaningful way. I'm starting up on a Sun Java 1.4.2 JVM with the following flags: ``` -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails ``` The log output looks li...
IBM's GC toolkit does exactly what you ask. <https://www.ibm.com/developerworks/java/jdk/tools/gcmv/> I'm not sure if it's compatible with GC logs from Sun's JVM though.
541,848
<p>What are your favourite plugins in VIM for Latex editing? Is there some ready variant of VIM for Latex?</p>
[ { "answer_id": 541857, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 2, "selected": false, "text": "<p>You probably want LaTex Suite. See <a href=\"http://www.vim.org/scripts/script.php?script_id=475\" rel=\"nofollow noref...
2009/02/12
[ "https://Stackoverflow.com/questions/541848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54964/" ]
What are your favourite plugins in VIM for Latex editing? Is there some ready variant of VIM for Latex?
Actually, I think the default support that Vim includes for `filetype=tex` is already quite good. So strictly, no plugins are necessary. However, I do recommend a few settings that you can cherry-pick from and adapt to your own taste. See the help to see what each command/setting does. ``` setlocal iskeyword+=:,- set...
541,869
<p>Is there a way to determine which element submitted a form from within an onsubmit handler? Trying to write a generic handler that knows which element was clicked. For example, given this form:</p> <pre><code>&lt;form onsubmit="onSubmitHandler"&gt; &lt;input type="submit" name="submit1" /&gt; &lt;input type...
[ { "answer_id": 542102, "author": "Joseph Tary", "author_id": 65630, "author_profile": "https://Stackoverflow.com/users/65630", "pm_score": 2, "selected": false, "text": "<p>An alternative solution would be to move the event trigger from the form's submit event, to the submit element's on...
2009/02/12
[ "https://Stackoverflow.com/questions/541869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8037/" ]
Is there a way to determine which element submitted a form from within an onsubmit handler? Trying to write a generic handler that knows which element was clicked. For example, given this form: ``` <form onsubmit="onSubmitHandler"> <input type="submit" name="submit1" /> <input type="submit" name="submit2" /> <...
An alternative solution would be to move the event trigger from the form's submit event, to the submit element's onclick event, as such: ``` <form name='form1'> <input type="submit" name="submit1" onclick="onSubmitHandler"/> <input type="submit" name="submit2" onclick="onSubmitHandler"/> </form> ``` In you...
541,896
<p>I want to show a list of Customer objects in a WPF ItemsControl. I've created a DataTemplate for this:</p> <pre><code> &lt;DataTemplate DataType="{x:Type myNameSpace:Customer}"&gt; &lt;StackPanel Orientation="Horizontal" Margin="10"&gt; &lt;CheckBox"&gt;&lt;/CheckBox&gt; &lt;TextB...
[ { "answer_id": 542014, "author": "PiRX", "author_id": 25718, "author_profile": "https://Stackoverflow.com/users/25718", "pm_score": 9, "selected": true, "text": "<p>There is StringFormat property (in .NET 3.5 SP1), which you probably can use. And usefull WPF binding cheat sheat can found...
2009/02/12
[ "https://Stackoverflow.com/questions/541896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57036/" ]
I want to show a list of Customer objects in a WPF ItemsControl. I've created a DataTemplate for this: ``` <DataTemplate DataType="{x:Type myNameSpace:Customer}"> <StackPanel Orientation="Horizontal" Margin="10"> <CheckBox"></CheckBox> <TextBlock Text="{Binding Path=Number}"></TextB...
There is StringFormat property (in .NET 3.5 SP1), which you probably can use. And usefull WPF binding cheat sheat can found [here](http://www.nbdtech.com/blog/archive/2009/02/02/wpf-xaml-data-binding-cheat-sheet.aspx). If it doesn't help, you can allways write your own ValueConverter or custom property for your object...
541,903
<p>Surely there has to be many ways to optimize the following code, where I basically have to make sure that a lot of textboxes aren't empty and then read their values:</p> <pre><code>if (foo1.Text.Length != 0 &amp; bar1.Text.Length != 0) { output.Text += myStrings[i] + " / " + foo1.Text + " / " + bar1.Text; } if...
[ { "answer_id": 541911, "author": "Gerrie Schenck", "author_id": 57036, "author_profile": "https://Stackoverflow.com/users/57036", "pm_score": 3, "selected": false, "text": "<p>I would just loop over the Controls collection on which these TextBoxes reside, then filter on TextBox only and ...
2009/02/12
[ "https://Stackoverflow.com/questions/541903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55072/" ]
Surely there has to be many ways to optimize the following code, where I basically have to make sure that a lot of textboxes aren't empty and then read their values: ``` if (foo1.Text.Length != 0 & bar1.Text.Length != 0) { output.Text += myStrings[i] + " / " + foo1.Text + " / " + bar1.Text; } if (foo2.Text.Length...
I would put the repeated elements in arrays and then loop over them. ``` TextBox[] foos = new TextBox[] { foo1, foo2, foo3, /* etc */ }; TextBox[] bars = new TextBox[] { bar1, bar2, bar3, /* etc */ }; for (int i = 0; i <= 10; i++) if (foos[i].Text.Length != 0 && bars[i].Text.Length != 0) output.Text += m...
541,919
<p>We currently run a specific SQL script as part of our Ant deploy process.</p> <p>What we'd like to do is change this so we run all SQL scripts in a given directory. We can't figure out how to get this directory listing in Ant and iterate through the list and run each SQL script. Does anyone know how to do this?</...
[ { "answer_id": 542130, "author": "Rob Di Marco", "author_id": 24195, "author_profile": "https://Stackoverflow.com/users/24195", "pm_score": 4, "selected": true, "text": "<p>I would recommend using the Ant <a href=\"http://ant.apache.org/manual/Tasks/sql.html\" rel=\"nofollow noreferrer\"...
2009/02/12
[ "https://Stackoverflow.com/questions/541919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47281/" ]
We currently run a specific SQL script as part of our Ant deploy process. What we'd like to do is change this so we run all SQL scripts in a given directory. We can't figure out how to get this directory listing in Ant and iterate through the list and run each SQL script. Does anyone know how to do this? Note: we cur...
I would recommend using the Ant [`SQL` task](http://ant.apache.org/manual/Tasks/sql.html). You can then specify with the following: ``` <sql driver="org.database.jdbcDriver" url="jdbc:database-url" userid="sa" password="pass"> <path> <fileset dir="."> <include name="data*.sql"/> </files...
541,920
<p>I have a small code example I want to include in the Javadoc comment for a method. </p> <pre><code>/** * -- ex: looping through List of Map objects -- * &lt;code&gt; * for (int i = 0; i &lt; list.size(); i++) { * Map map = (Map)list.get(i); * System.out.println(map.get("wordID")); * System.out...
[ { "answer_id": 541944, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 5, "selected": false, "text": "<p>Enclose your multiline code with <code>&lt;pre&gt;&lt;/pre&gt;</code> tags.</p>\n" }, { "answer_id": 5419...
2009/02/12
[ "https://Stackoverflow.com/questions/541920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50262/" ]
I have a small code example I want to include in the Javadoc comment for a method. ``` /** * -- ex: looping through List of Map objects -- * <code> * for (int i = 0; i < list.size(); i++) { * Map map = (Map)list.get(i); * System.out.println(map.get("wordID")); * System.out.println(map.get("word")...
In addition to the already mentioned `<pre>` tags, you should also use the `@code` JavaDoc annotation, which will make life much easier when it comes to HTML entities issues (in particular with Generics), e.g.: ``` * <pre> * {@code * Set<String> s; * System.out.println(s); * } * </pre> ``` Will give correct HTML out...
541,924
<p>Installing third-party components always take a long time specially if you have large ones, but also it take more time if you setup the environment in more than one computer.</p> <p>And I'm thinking to add them to the Version Control (Subversion), so it will be always easy to checkout the project with all it's requ...
[ { "answer_id": 541941, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 5, "selected": true, "text": "<p>If we have the source, then we include that in our repository, under a separate folder.</p>\n\n<p>If we don't have the ...
2009/02/12
[ "https://Stackoverflow.com/questions/541924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24462/" ]
Installing third-party components always take a long time specially if you have large ones, but also it take more time if you setup the environment in more than one computer. And I'm thinking to add them to the Version Control (Subversion), so it will be always easy to checkout the project with all it's required compo...
If we have the source, then we include that in our repository, under a separate folder. If we don't have the source, then we just keep the most recent binaries (bpl, dll, whatever) in the repository, and include installation / usage instructions in a setup document. It looks like this: ``` \root \third_party_stu...
541,926
<p>In many languages (and places) there is a nice practice of creating local scopes by creating a block like <a href="https://stackoverflow.com/questions/541705/is-iftrue-a-good-idea-in-c">this</a>.</p> <pre><code>void foo() { ... Do some stuff ... if(TRUE) { char a; int b; ...
[ { "answer_id": 541948, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 3, "selected": false, "text": "<p>Why do you want to create new scopes in python anyway?</p>\n\n<p>The normal reason for doing it in other languages...
2009/02/12
[ "https://Stackoverflow.com/questions/541926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17523/" ]
In many languages (and places) there is a nice practice of creating local scopes by creating a block like [this](https://stackoverflow.com/questions/541705/is-iftrue-a-good-idea-in-c). ``` void foo() { ... Do some stuff ... if(TRUE) { char a; int b; ... Do some more stuff .....
In Python, scoping is of three types : global, local and class. You can create specialized 'scope' dictionaries to pass to exec / eval(). In addition you can use nested scopes (defining a function within another). I found these to be sufficient in all my code. As Douglas Leeder said already, the main reason to use it ...
541,933
<p>I would like to open external URLs from within my Flash project. I typically use something like this:</p> <pre><code>getURL("javascript:newwin=window.open('http://someurl.com','','');"); </code></pre> <p>But, if Javascript isn't available (in cases where the SWF is not embedded in HTML) then this will fail. How ...
[ { "answer_id": 542188, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 3, "selected": false, "text": "<p>To accomplish what you're describing, the best way is to have Flash invoke a JavaScript function called \"pingJavaScript\". If ...
2009/02/12
[ "https://Stackoverflow.com/questions/541933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60006/" ]
I would like to open external URLs from within my Flash project. I typically use something like this: ``` getURL("javascript:newwin=window.open('http://someurl.com','','');"); ``` But, if Javascript isn't available (in cases where the SWF is not embedded in HTML) then this will fail. How can I detect whether Javascr...
I find that there is actually a much easier way to accomplish this: ``` public function isThereJavaScript():Boolean{ return Boolean(ExternalInterface.call("window.location.href.toString")); } ``` This requires no JavaScript back-end. It just works consistently. If there is the ability to call JavaScript, that me...
541,934
<p>My question is a simple one, but I can't seem to find the answer. I'm currently working on some URL rewriting for a website, but I have encountered a problem. Currently the most basic rule I have goes something like this:</p> <pre><code>RewriteRule ^([a-zA-Z]+)/(([a-zA-Z]+)/?$ index.php?mod=$1&amp;com$2 </code></pr...
[ { "answer_id": 541973, "author": "Gumbo", "author_id": 53114, "author_profile": "https://Stackoverflow.com/users/53114", "pm_score": 0, "selected": false, "text": "<p>You could use a recursive rule:</p>\n\n<pre><code>RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/?$ index.php?mod=$1&amp;com$2 [L,Q...
2009/02/12
[ "https://Stackoverflow.com/questions/541934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37472/" ]
My question is a simple one, but I can't seem to find the answer. I'm currently working on some URL rewriting for a website, but I have encountered a problem. Currently the most basic rule I have goes something like this: ``` RewriteRule ^([a-zA-Z]+)/(([a-zA-Z]+)/?$ index.php?mod=$1&com$2 ``` This works in most case...
Depending on what language/framework you're using, it may be simpler to put the rewriting/dispatch in the script rather than attempt to do everything in mod\_rewrite. For example, if you were using PHP, given the URL: ``` http://www.example.com/asdf.php/jkl/id/5/page/2 ``` a script at asf.php could read the PATH\_I...
541,936
<p>All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly?</p> <p>Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language.</p> <p>So far we have this:</p> <ol> <li>Tail recursion</li> <li>Generic Co/C...
[ { "answer_id": 541957, "author": "ermau", "author_id": 26908, "author_profile": "https://Stackoverflow.com/users/26908", "pm_score": 4, "selected": false, "text": "<p>The CLR supports generic co/contravariance already, but C# is not getting this feature until 4.0</p>\n\n<ul>\n<li><a href...
2009/02/12
[ "https://Stackoverflow.com/questions/541936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33015/" ]
All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly? Let us also have things done easier in MSIL than C#, VB.NET, F#, j# or any other .NET language. So far we have this: 1. Tail recursion 2. Generic Co/Contravariance (allowed in C# 4...
MSIL allows for overloads which differ only in return types because of ``` call void [mscorlib]System.Console::Write(string) ``` or ``` callvirt int32 ... ```
541,953
<p>I'm trying to retrieve a specific image from a html document, using html agility pack and this xpath:</p> <pre><code>//div[@id='topslot']/a/img/@src </code></pre> <p>As far as I can see, it finds the src-attribute, but it returns the img-tag. Why is that?</p> <p>I would expect the InnerHtml/InnerText or something...
[ { "answer_id": 576172, "author": "Azat Razetdinov", "author_id": 9649, "author_profile": "https://Stackoverflow.com/users/9649", "pm_score": 5, "selected": true, "text": "<p>Html Agility Pack <a href=\"http://www.codeplex.com/htmlagilitypack/Thread/View.aspx?ThreadId=1720\" rel=\"norefer...
2009/02/12
[ "https://Stackoverflow.com/questions/541953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11956/" ]
I'm trying to retrieve a specific image from a html document, using html agility pack and this xpath: ``` //div[@id='topslot']/a/img/@src ``` As far as I can see, it finds the src-attribute, but it returns the img-tag. Why is that? I would expect the InnerHtml/InnerText or something to be set, but both are empty st...
Html Agility Pack [does not support](http://www.codeplex.com/htmlagilitypack/Thread/View.aspx?ThreadId=1720) attribute selection.
541,954
<p>I am doing something where I realised I wanted to count how many <code>/</code>s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was.</p> <p>At the moment I'm going with something like:</p> <pre><code>string source = "/once/u...
[ { "answer_id": 541976, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 8, "selected": false, "text": "<pre><code>string source = \"/once/upon/a/time/\";\nint count = 0;\nforeach (char c in source) \n if (c == '/') count...
2009/02/12
[ "https://Stackoverflow.com/questions/541954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
I am doing something where I realised I wanted to count how many `/`s I could find in a string, and then it struck me, that there were several ways to do it, but couldn't decide on what the best (or easiest) was. At the moment I'm going with something like: ``` string source = "/once/upon/a/time/"; int count = source...
If you're using .NET 3.5 you can do this in a one-liner with LINQ: ``` int count = source.Count(f => f == '/'); ``` If you don't want to use LINQ you can do it with: ``` int count = source.Split('/').Length - 1; ``` --- You might be surprised to learn that your original technique seems to be about 30% faster tha...
541,956
<p>I have the current problem, let's explain the context before :</p> <p>I have a Modal popup extender who contains a form. There is a feature "Save and Add New", when the user click on this button the data in the form is saved in the database during postback and the page is reloaded. </p> <p>I want this Modal popup ...
[ { "answer_id": 541976, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 8, "selected": false, "text": "<pre><code>string source = \"/once/upon/a/time/\";\nint count = 0;\nforeach (char c in source) \n if (c == '/') count...
2009/02/12
[ "https://Stackoverflow.com/questions/541956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62921/" ]
I have the current problem, let's explain the context before : I have a Modal popup extender who contains a form. There is a feature "Save and Add New", when the user click on this button the data in the form is saved in the database during postback and the page is reloaded. I want this Modal popup to appear again o...
If you're using .NET 3.5 you can do this in a one-liner with LINQ: ``` int count = source.Count(f => f == '/'); ``` If you don't want to use LINQ you can do it with: ``` int count = source.Split('/').Length - 1; ``` --- You might be surprised to learn that your original technique seems to be about 30% faster tha...
541,960
<p>I use inheritance in my model. An event has different types:</p> <pre><code>Event &lt; activity Event &lt; training Event &lt; game </code></pre> <p>I want to set session data to every event type like</p> <pre><code>game.user_id = session[:user_id] training.user_id = session[:user_id] activity.user_id = session[:...
[ { "answer_id": 542367, "author": "erik", "author_id": 1191, "author_profile": "https://Stackoverflow.com/users/1191", "pm_score": 2, "selected": false, "text": "<p>Perhaps you are looking for a before_filter that resides in your ApplicationController? Then in each controller, you can set...
2009/02/12
[ "https://Stackoverflow.com/questions/541960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52086/" ]
I use inheritance in my model. An event has different types: ``` Event < activity Event < training Event < game ``` I want to set session data to every event type like ``` game.user_id = session[:user_id] training.user_id = session[:user_id] activity.user_id = session[:user_id] ``` I want to avoid writing @game.u...
Don't use game.user\_id, instead you can do this: ``` game = current_user.games.build(params[:game]) if game.save # do something else # do something else end ``` Repeat for your other controllers too! The [associations guide](http://guides.rubyonrails.org/association_basics.html) may be helpful too.
541,962
<p>I was asking myself if there are examples online which covers how you can for instance detect shapes in touch gestures.</p> <p>for example a rectangle or a circle (or more complex a heart .. )</p> <p>or determine the speed of swiping (over time ( like i'm swiping my iphone against 50mph ))</p>
[ { "answer_id": 542113, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>For very simple gestures (horizontal vs. vertical swipe), calculate the difference in x and y between two touches.</p>\n\n<p...
2009/02/12
[ "https://Stackoverflow.com/questions/541962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62009/" ]
I was asking myself if there are examples online which covers how you can for instance detect shapes in touch gestures. for example a rectangle or a circle (or more complex a heart .. ) or determine the speed of swiping (over time ( like i'm swiping my iphone against 50mph ))
For very simple gestures (horizontal vs. vertical swipe), calculate the difference in x and y between two touches. ``` dy = abs(y2 - y1) dx = abs(x2 - x1) f = dy/dx ``` An f close to zero is a horizontal swipe. An f close to 1 is a diagonal swipe. And a very large f is a vertical swipe (keep in mind that dx could be...
541,963
<p>I have a multi-threaded .Net app in which thread-local storage is used to hold a flag of sorts. I have reason to suspect that the flag is being set incorrectly in one of the threads and would like to use the VS debugger to inspect when and where the flag is being set.</p> <p>Once I have stopped the application at a...
[ { "answer_id": 542113, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>For very simple gestures (horizontal vs. vertical swipe), calculate the difference in x and y between two touches.</p>\n\n<p...
2009/02/12
[ "https://Stackoverflow.com/questions/541963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4200/" ]
I have a multi-threaded .Net app in which thread-local storage is used to hold a flag of sorts. I have reason to suspect that the flag is being set incorrectly in one of the threads and would like to use the VS debugger to inspect when and where the flag is being set. Once I have stopped the application at a break poi...
For very simple gestures (horizontal vs. vertical swipe), calculate the difference in x and y between two touches. ``` dy = abs(y2 - y1) dx = abs(x2 - x1) f = dy/dx ``` An f close to zero is a horizontal swipe. An f close to 1 is a diagonal swipe. And a very large f is a vertical swipe (keep in mind that dx could be...
541,966
<p>I am using a <code>ListView</code> to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load images so while the text displays, the UI is not blocked and images are displayed as they are downloaded? </p> <p>The total number of images is ...
[ { "answer_id": 543018, "author": "jasonhudgins", "author_id": 24590, "author_profile": "https://Stackoverflow.com/users/24590", "pm_score": 6, "selected": false, "text": "<p>The way I do it is by launching a thread to download the images in the background and hand it a callback for each ...
2009/02/12
[ "https://Stackoverflow.com/questions/541966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46297/" ]
I am using a `ListView` to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load images so while the text displays, the UI is not blocked and images are displayed as they are downloaded? The total number of images is not fixed.
Here's what I created to hold the images that my app is currently displaying. Please note that the "Log" object in use here is my custom wrapper around the final Log class inside Android. ``` package com.wilson.android.library; /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license...
541,970
<p>How do I intercept a NotImplementedException in a WPF application?</p> <p>I'll occasionally throw a NotImplementedException while testing my in-progress WPF application:</p> <pre><code>Private Sub ButtonDoSomething_Click(...) Handles ButtonDoSomething.Click Throw New NotImplementedException( _ "ButtonD...
[ { "answer_id": 542015, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 3, "selected": false, "text": "<p>You can attach to the DispatcherUnhandledException event on the Application class, which will be raised anytime an un...
2009/02/12
[ "https://Stackoverflow.com/questions/541970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
How do I intercept a NotImplementedException in a WPF application? I'll occasionally throw a NotImplementedException while testing my in-progress WPF application: ``` Private Sub ButtonDoSomething_Click(...) Handles ButtonDoSomething.Click Throw New NotImplementedException( _ "ButtonDoSomething_Click() no...
You can attach to the DispatcherUnhandledException event on the Application class, which will be raised anytime an unhandled exception occurs. In there, you can check the Exception property on the DispatcherUnhandledExceptionEventArgs instance passed to the event handler to see if it is of type NotImplementedException....
541,975
<p>In Silverlight a tooltip can have as many elements in it as you want.</p> <p>However, it doesn't receive focus so you can't have user interactivity in it.</p> <p>Could you, though, start a video playing as soon as the tooltip opens and have the video stop as soon as the tooltip closes?</p>
[ { "answer_id": 542523, "author": "bperreault", "author_id": 65563, "author_profile": "https://Stackoverflow.com/users/65563", "pm_score": 2, "selected": true, "text": "<p>This is my first answer on Stack Overflow so I ask for your good humor.<br>\nI think you could run your video in the ...
2009/02/12
[ "https://Stackoverflow.com/questions/541975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
In Silverlight a tooltip can have as many elements in it as you want. However, it doesn't receive focus so you can't have user interactivity in it. Could you, though, start a video playing as soon as the tooltip opens and have the video stop as soon as the tooltip closes?
This is my first answer on Stack Overflow so I ask for your good humor. I think you could run your video in the tooltip by using a video brush. Here's some code I used to paint a fire video on the bar in the chart that represented heating with corn. ( long story) right here, you can see it is set to the fill of an...
541,983
<p>Our core business application uses a library (C# project) of business objects. Data access is done using the Wilson O/R Mapper (we're migrating to NHibernate this summer). The application has 3 front-end UIs: Windows Forms, ASP.NET, and a Windows Forms app that is installed on tablet PCs. The three front-ends perfor...
[ { "answer_id": 542523, "author": "bperreault", "author_id": 65563, "author_profile": "https://Stackoverflow.com/users/65563", "pm_score": 2, "selected": true, "text": "<p>This is my first answer on Stack Overflow so I ask for your good humor.<br>\nI think you could run your video in the ...
2009/02/12
[ "https://Stackoverflow.com/questions/541983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12752/" ]
Our core business application uses a library (C# project) of business objects. Data access is done using the Wilson O/R Mapper (we're migrating to NHibernate this summer). The application has 3 front-end UIs: Windows Forms, ASP.NET, and a Windows Forms app that is installed on tablet PCs. The three front-ends perform d...
This is my first answer on Stack Overflow so I ask for your good humor. I think you could run your video in the tooltip by using a video brush. Here's some code I used to paint a fire video on the bar in the chart that represented heating with corn. ( long story) right here, you can see it is set to the fill of an...
542,024
<p>This piece of code doesn't work; it's logging in into website which is using https protocol. How to solve this problem? The code stops at <code>GetRequestStream()</code> anytime anywhere saying that protocol violation exception is unhandled..</p> <pre><code>string username = "user"; string password = "pass"; HttpWe...
[ { "answer_id": 542099, "author": "Ramesh", "author_id": 30594, "author_profile": "https://Stackoverflow.com/users/30594", "pm_score": 4, "selected": true, "text": "<p>Set request method to post, before calling GetRequestStream</p>\n\n<p>like </p>\n\n<pre><code>request.Method = \"POST\";...
2009/02/12
[ "https://Stackoverflow.com/questions/542024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21209/" ]
This piece of code doesn't work; it's logging in into website which is using https protocol. How to solve this problem? The code stops at `GetRequestStream()` anytime anywhere saying that protocol violation exception is unhandled.. ``` string username = "user"; string password = "pass"; HttpWebRequest request = (HttpW...
Set request method to post, before calling GetRequestStream like ``` request.Method = "POST"; using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII)) { writer.Write("nick=" + username + "&password=" + password); } ```
542,028
<pre><code>for (int i = 0 ; i &lt; stlVector.size() ; i++) { if (i == 10) { stlVector.erase(stlVector.begin() + 5 ) } } </code></pre> <p>Does the termination condition part "stlVector.size()" take "stlVector.erase(...)" into consideration? In other word does stlVector.size() refresh for every loo...
[ { "answer_id": 542069, "author": "claf", "author_id": 61838, "author_profile": "https://Stackoverflow.com/users/61838", "pm_score": 2, "selected": false, "text": "<p>Yes it does!</p>\n\n<pre><code>stlVector.size () // is called for evey iteration\n</code></pre>\n\n<p>Thus for every loop ...
2009/02/12
[ "https://Stackoverflow.com/questions/542028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40260/" ]
``` for (int i = 0 ; i < stlVector.size() ; i++) { if (i == 10) { stlVector.erase(stlVector.begin() + 5 ) } } ``` Does the termination condition part "stlVector.size()" take "stlVector.erase(...)" into consideration? In other word does stlVector.size() refresh for every loop iteration? I can't t...
Just to be clear, don't think of it in terms of the loop refreshing anything. Every time the condition is checked (at the start of each time through the loop), the size() method is called on the stlVector variable, and the current size of the vector is returned. The erase() method reduces the size of the vector, so th...
542,046
<p>I just moved a project from localhost over to my remote server, and noticed that some of my scripts stopped working. Most importantly was one that relied upon <code>file_get_contents()</code> to fetch JSON values from another script.</p> <p>PHP Version is 5.2.4<br/> <code>allow_url_fopen</code> is ON<br/></p> <blo...
[ { "answer_id": 542115, "author": "schmilblick", "author_id": 65136, "author_profile": "https://Stackoverflow.com/users/65136", "pm_score": 0, "selected": false, "text": "<p>Please include more information, does $contents contain anything? Remember to do json_decode($contents, true) if yo...
2009/02/12
[ "https://Stackoverflow.com/questions/542046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54680/" ]
I just moved a project from localhost over to my remote server, and noticed that some of my scripts stopped working. Most importantly was one that relied upon `file_get_contents()` to fetch JSON values from another script. PHP Version is 5.2.4 `allow_url_fopen` is ON > > Warning: `file_get_contents()` `[functio...
> > Name or service not known > > > DNS is broke. Can you `ping data.mysite.com` from a shell on the machine (assuming you have one)? Try replacing `data.mysite.com` with a fixed IP address for now.
542,062
<p>I have made a bunch of 2D arrays in Excel, and I have written a function to put the same data in a copy of each. I'm not quite sure I'm getting the fiddly parts of the syntax correct.</p> <p>The function is called 'Fill', the old array 'Old' and the new one 'New'. I'm using the name 'Block' for the passing-between ...
[ { "answer_id": 542105, "author": "Toby Allen", "author_id": 6244, "author_profile": "https://Stackoverflow.com/users/6244", "pm_score": 2, "selected": true, "text": "<p>It has been a while since I did VBA programming, but I would think the following is more likely to be correct:</p>\n\n<...
2009/02/12
[ "https://Stackoverflow.com/questions/542062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59790/" ]
I have made a bunch of 2D arrays in Excel, and I have written a function to put the same data in a copy of each. I'm not quite sure I'm getting the fiddly parts of the syntax correct. The function is called 'Fill', the old array 'Old' and the new one 'New'. I'm using the name 'Block' for the passing-between variable n...
It has been a while since I did VBA programming, but I would think the following is more likely to be correct: ``` NewArray = Fill(OldArray) Function Fill(Block As Variant) As Variant Fill = Block End Function ```
542,064
<p>I'm using the following CSS:</p> <pre><code>h2 { font-weight: normal; border-bottom: 1px solid #DDD; font-size: 1.6em; font-style: italic; } h2 span { position: absolute; top: 7px; padding-right: 6px; background-color: #F9F9EE; } </code></pre> <p>When used like:</p> <pre><code>&lt...
[ { "answer_id": 542107, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 1, "selected": false, "text": "<p>I'm not entirely sure what you're trying to do and what the problem is exactly, but adding <code>position: relative;</code> t...
2009/02/12
[ "https://Stackoverflow.com/questions/542064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using the following CSS: ``` h2 { font-weight: normal; border-bottom: 1px solid #DDD; font-size: 1.6em; font-style: italic; } h2 span { position: absolute; top: 7px; padding-right: 6px; background-color: #F9F9EE; } ``` When used like: ``` <h2><span>abc</span></h2> ``` Gives th...
As Rory mentioned, using position relative on the H2 tag solves the problem without the use of an image. ``` h2 { font-weight: normal; border-bottom: 1px solid #DDD; font-size: 1.6em; font-style: italic; position:relative; } h2 span { position: absolute; top: -0.8em; padding-right: 6px...
542,065
<p>How can I "delete" a file which is already in the SVN repository without deleting it from my file system?</p> <p>TortoiseSVN or command line instructions are welcome.</p> <p>The following works, but I am hoping for something nicer:</p> <ol> <li>Copy the file to some other location outside the repository.</li> <li...
[ { "answer_id": 542100, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 9, "selected": true, "text": "<pre><code>svn delete --keep-local the_file\n</code></pre>\n" }, { "answer_id": 542104, "author": "harpo", "...
2009/02/12
[ "https://Stackoverflow.com/questions/542065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41662/" ]
How can I "delete" a file which is already in the SVN repository without deleting it from my file system? TortoiseSVN or command line instructions are welcome. The following works, but I am hoping for something nicer: 1. Copy the file to some other location outside the repository. 2. SVN Delete the file. 3. Commit 4...
``` svn delete --keep-local the_file ```
542,127
<p>I'm extending a utility class that bundles a set of images and .xml description files. Currently I keep all the files in a directory and load them from there. The directory looks like this:</p> <pre><code>8.png 8.xml 9.png 9.xml 10.png 10.xml ... ... 50.png 50.xml ... </code></pre> <p><br><br> Here's my current ...
[ { "answer_id": 542164, "author": "leeand00", "author_id": 18149, "author_profile": "https://Stackoverflow.com/users/18149", "pm_score": -1, "selected": false, "text": "<p><a href=\"http://www.quicklz.com/\" rel=\"nofollow noreferrer\">This library</a> may not compress as much as you need...
2009/02/12
[ "https://Stackoverflow.com/questions/542127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61248/" ]
I'm extending a utility class that bundles a set of images and .xml description files. Currently I keep all the files in a directory and load them from there. The directory looks like this: ``` 8.png 8.xml 9.png 9.xml 10.png 10.xml ... ... 50.png 50.xml ... ``` Here's my current constructor. It is lightning fast and...
Well, I found the answer. The answer to my original question was "Wrong question." The Jar file wasn't the issue, it was the library I was using to load the images. When I was loading from the file system, the image was being named "38.png", etc. When I was loading from the Jar, I was simply naming it "38". The Imag...
542,166
<p>I am using asp.net and I'm working with a gridview. I have one of the fields in my GridView set up as a HyperLinkField that represents the name of the category. I pull the name and Id from a database and I can never be sure what they are because they are added separately. I want to be able to pass a changing Categor...
[ { "answer_id": 542205, "author": "regex", "author_id": 23869, "author_profile": "https://Stackoverflow.com/users/23869", "pm_score": -1, "selected": false, "text": "<p>You can do it by using a <code>&lt;asp:TemplateField /&gt;</code> as one of your columns instead of a <code>&lt;asp:Boun...
2009/02/12
[ "https://Stackoverflow.com/questions/542166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45429/" ]
I am using asp.net and I'm working with a gridview. I have one of the fields in my GridView set up as a HyperLinkField that represents the name of the category. I pull the name and Id from a database and I can never be sure what they are because they are added separately. I want to be able to pass a changing CategoryId...
In your Hyperlink field, set the DataNavigateUrlFields to your ID column and set the DataNavigateUrlFormatString to the Url to navigate to (where {0} will be replaced by ID) ``` <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="Target.aspx?ID={0}" DataTextField="Name" Targe...
542,173
<p>I setup my build definition, is that all I do when it comes to setting up my build using the Team Explorer GUI?</p> <p>It seems like the only thing for me to do now is edit the msbuild .proj file?</p> <p>Is there a GUI for this or its all hand editing from here on it?</p>
[ { "answer_id": 542205, "author": "regex", "author_id": 23869, "author_profile": "https://Stackoverflow.com/users/23869", "pm_score": -1, "selected": false, "text": "<p>You can do it by using a <code>&lt;asp:TemplateField /&gt;</code> as one of your columns instead of a <code>&lt;asp:Boun...
2009/02/12
[ "https://Stackoverflow.com/questions/542173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I setup my build definition, is that all I do when it comes to setting up my build using the Team Explorer GUI? It seems like the only thing for me to do now is edit the msbuild .proj file? Is there a GUI for this or its all hand editing from here on it?
In your Hyperlink field, set the DataNavigateUrlFields to your ID column and set the DataNavigateUrlFormatString to the Url to navigate to (where {0} will be replaced by ID) ``` <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="Target.aspx?ID={0}" DataTextField="Name" Targe...
542,178
<p>I've built a self hosted wcf server, using <code>wsHttpBinding</code>. I'm running Win 2003 server R2 SP2.</p> <p>If I configure it to listen on <code>http://localhost:443/MyService</code>, everything works fine. I can connect to <code>http://localhost:443/MyService</code> with Internet Explorer, and I get the stan...
[ { "answer_id": 542189, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 1, "selected": false, "text": "<p>Telnet cannot be used to comunicate with encrited webs.</p>\n\n<p>Checkout this <a href=\"http://support.microsoft.com/...
2009/02/12
[ "https://Stackoverflow.com/questions/542178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47341/" ]
I've built a self hosted wcf server, using `wsHttpBinding`. I'm running Win 2003 server R2 SP2. If I configure it to listen on `http://localhost:443/MyService`, everything works fine. I can connect to `http://localhost:443/MyService` with Internet Explorer, and I get the standard "Bad Request" message Now, if I try t...
The telnet client is not going to know to send a properly constructed request to initiate an https handshake, so I imagine the ssl secured server is just waiting for more data. The telnet client is certainly not going to know what to do with the response from a ssl secured server (it's certainly not going to prompt yo...
542,186
<p>I'm using <strong>psql 8.2.3</strong> on FreeBSD. Every time I press <strong>Insert</strong>, <strong>Home</strong>, <strong>Delete</strong>, <strong>End</strong>, <strong>Page Up</strong> or <strong>Page Down</strong>, a tilde (<code>~</code>) character is inserted instead of performing the expected function of th...
[ { "answer_id": 542350, "author": "Patryk Kordylewski", "author_id": 30927, "author_profile": "https://Stackoverflow.com/users/30927", "pm_score": 1, "selected": false, "text": "<p>That shouldn't be a psql problem - it's os specific.\nA <a href=\"http://fixunix.com/bsd/538417-home-end-del...
2009/02/12
[ "https://Stackoverflow.com/questions/542186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
I'm using **psql 8.2.3** on FreeBSD. Every time I press **Insert**, **Home**, **Delete**, **End**, **Page Up** or **Page Down**, a tilde (`~`) character is inserted instead of performing the expected function of the key. Why does this happen and how can I fix it?
As mentioned in [Endlessdeath's answer](https://stackoverflow.com/questions/542186/why-is-psql-inserting-a-tilde-when-i-press-any-of-the-keys-in-the-home-key-cluste/542350#542350), this turned out to be a key mapping problem with the operating system (**FreeBSD**), *not* **psql**. You can make these keys work as expect...
542,203
<p>Somebody please help me by modifying this code.In my login page i have three column Login,UserName,Password.In Login i have kept dropdownlist with two list item Admin and User.So when i Select Admin,UserName,Password it should go to desired destination page and when i select User,UserName,Password it should go to ...
[ { "answer_id": 542253, "author": "Andy Rose", "author_id": 1762, "author_profile": "https://Stackoverflow.com/users/1762", "pm_score": 1, "selected": false, "text": "<p>Firstly, your opening up your application to and SQL injection attack.\nI would suggest at least using a stored procedu...
2009/02/12
[ "https://Stackoverflow.com/questions/542203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59637/" ]
Somebody please help me by modifying this code.In my login page i have three column Login,UserName,Password.In Login i have kept dropdownlist with two list item Admin and User.So when i Select Admin,UserName,Password it should go to desired destination page and when i select User,UserName,Password it should go to anoth...
Firstly, your opening up your application to and SQL injection attack. I would suggest at least using a stored procedure to query the login credentials against your database to minimise this risk. 1st rule of user input - do not trust user input. It may be worth having a look at this question for further help: [...
542,212
<p>I have the variable assignment in order to return the assigned value and compare that to an empty string, directly in the while loop.</p> <p>Here is how I'm doing it in PHP:</p> <pre><code>while((name = raw_input("Name: ")) != ''): names.append(name) </code></pre> <p>What I'm trying to do is identical to this...
[ { "answer_id": 542224, "author": "Philip Reynolds", "author_id": 1087, "author_profile": "https://Stackoverflow.com/users/1087", "pm_score": 3, "selected": false, "text": "<p>No, sorry. It's a FAQ, explained well here:</p>\n<p>In <a href=\"http://docs.python.org/faq/design.html#why-can-t...
2009/02/12
[ "https://Stackoverflow.com/questions/542212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65635/" ]
I have the variable assignment in order to return the assigned value and compare that to an empty string, directly in the while loop. Here is how I'm doing it in PHP: ``` while((name = raw_input("Name: ")) != ''): names.append(name) ``` What I'm trying to do is identical to this in functionality: ``` names = ...
``` from functools import partial for name in iter(partial(raw_input, 'Name:'), ''): do_something_with(name) ``` or if you want a list: ``` >>> names = list(iter(partial(raw_input, 'Name: '), '')) Name: nosklo Name: Andreas Name: Aaron Name: Phil Name: >>> names ['nosklo', 'Andreas', 'Aaron', 'Phil'] ```
542,217
<p>When I try to save a BitmapSource that I loaded earlier, a <code>System.IO.IOException</code> is thrown stating another process is accessing that file and the filestream cannot be opened.</p> <p>If I only save whithout loading earlier, everything works fine.</p> <p>The loading code:</p> <pre><code>BitmapImage ima...
[ { "answer_id": 546839, "author": "Crippeoblade", "author_id": 6204, "author_profile": "https://Stackoverflow.com/users/6204", "pm_score": 0, "selected": false, "text": "<p>Now i'm not sure if this can be applied to BitmapImage but i had a very similar problem with saving a modified image...
2009/02/12
[ "https://Stackoverflow.com/questions/542217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64140/" ]
When I try to save a BitmapSource that I loaded earlier, a `System.IO.IOException` is thrown stating another process is accessing that file and the filestream cannot be opened. If I only save whithout loading earlier, everything works fine. The loading code: ``` BitmapImage image = new BitmapImage(); image.BeginIni...
Inspired by the comments I got on this issue, I solved the problem by reading all bytes into a memorystream and using it as the BitmapImage's Sreamsource. This one works perfectly: ``` if (File.Exists(filePath)) { MemoryStream memoryStream = new MemoryStream(); byte[] fileBytes = File.ReadAllBytes(filePath);...
542,218
<p>So I am utilizing CollectionBase as an inherited class for custom collections. I am utilizing CollectionBase through an abstract class so that I don't repeated knowledge (following the DRY principle). The abstract class is defined as a generic class also. Here is how I am implementing my class: </p> <pre><code> ...
[ { "answer_id": 542244, "author": "ermau", "author_id": 26908, "author_profile": "https://Stackoverflow.com/users/26908", "pm_score": 0, "selected": false, "text": "<p>Making an extension method against IDictionary would be far more useful. There's also methods like Intersect from LINQ th...
2009/02/12
[ "https://Stackoverflow.com/questions/542218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53587/" ]
So I am utilizing CollectionBase as an inherited class for custom collections. I am utilizing CollectionBase through an abstract class so that I don't repeated knowledge (following the DRY principle). The abstract class is defined as a generic class also. Here is how I am implementing my class: ``` public abstract c...
I don't believe you are trying to accomplish too much. If an abstract class was meant to not have any implementation at all, or other methods which define functionality, then they would be interfaces. The only thing I would change is to use `EqualityComparer<T>` instead of equals for the comparison of `this[i]` and `c...
542,226
<p>I'm cleaning an incoming text in my Java code. The text includes a lot of "\n", but not as in a new line, but literally "\n". I was using replaceAll() from the String class, but haven't been able to delete the "\n". This doesn't seem to work:</p> <pre><code>String string; string = string.replaceAll("\\n", ""); </co...
[ { "answer_id": 542258, "author": "hooknc", "author_id": 42962, "author_profile": "https://Stackoverflow.com/users/42962", "pm_score": 5, "selected": false, "text": "<p>I think you need to add a couple more slashies...</p>\n\n<pre><code>String string;\nstring = string.replaceAll(\"\\\\\\\...
2009/02/12
[ "https://Stackoverflow.com/questions/542226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1492/" ]
I'm cleaning an incoming text in my Java code. The text includes a lot of "\n", but not as in a new line, but literally "\n". I was using replaceAll() from the String class, but haven't been able to delete the "\n". This doesn't seem to work: ``` String string; string = string.replaceAll("\\n", ""); ``` Neither does...
Hooknc is right. I'd just like to post a little explanation: "\\n" translates to "\n" after the compiler is done (since you escape the backslash). So the regex engine sees "\n" and thinks new line, and would remove those (and not the literal "\n" you have). "\n" translates to a real new line by the compiler. So the n...
542,232
<p>I want to perform a global replace of string using String.replace in Javascript.</p> <p>In the documentation I read that I can do this with /g, i.e. for example;</p> <pre><code>var mystring = mystring.replace(/test/g, mystring); </code></pre> <p>and this will replace all occurrences inside mystring. No quotes for th...
[ { "answer_id": 542260, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 8, "selected": false, "text": "<pre><code>var mystring = \"hello world test world\";\nvar find = \"world\";\nvar regex = new RegExp(find, \"g\")...
2009/02/12
[ "https://Stackoverflow.com/questions/542232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to perform a global replace of string using String.replace in Javascript. In the documentation I read that I can do this with /g, i.e. for example; ``` var mystring = mystring.replace(/test/g, mystring); ``` and this will replace all occurrences inside mystring. No quotes for the expression. But if I have a...
Can you use prototype.js? If so you could use String.gsub, like ``` var myStr = "a day in a life of a thing"; var replace = "a"; var resultString = myStr.gsub(replace, "g"); // resultString will be "g day in g life of g thing" ``` It will also take regular expressions. To me this is one of the more elegant ways ...
542,238
<p>I have a typedef int my_type and i have a function which looks like</p> <pre><code>void my_func (my_type* x); </code></pre> <p>How should I use this func to modify x using the best practice?</p>
[ { "answer_id": 542251, "author": "claf", "author_id": 61838, "author_profile": "https://Stackoverflow.com/users/61838", "pm_score": 4, "selected": true, "text": "<p>You can use the dereferencing operator '*' in your function :</p>\n\n<pre><code>void my_func (my_type* x)\n{\n assert(x); ...
2009/02/12
[ "https://Stackoverflow.com/questions/542238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65636/" ]
I have a typedef int my\_type and i have a function which looks like ``` void my_func (my_type* x); ``` How should I use this func to modify x using the best practice?
You can use the dereferencing operator '\*' in your function : ``` void my_func (my_type* x) { assert(x); // To protect from NULL pointer as mentioned in com. *x = 5; //for example } ```
542,247
<p>I know this would be difficult to understand but please give a try. Have a look at the screenshot.</p> <p>The small input box's name is <code>murl</code>.</p> <p><code>add()</code> is used to submit the form. if <code>murl</code> is empty the form has to be submitted directly, if its not empty the <code>murl</code...
[ { "answer_id": 542377, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 3, "selected": false, "text": "<p>It has to be clicked twice because you are defining <code>#microsubmit</code>'s <code>click</code> event insid...
2009/02/12
[ "https://Stackoverflow.com/questions/542247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I know this would be difficult to understand but please give a try. Have a look at the screenshot. The small input box's name is `murl`. `add()` is used to submit the form. if `murl` is empty the form has to be submitted directly, if its not empty the `murl` entry has to be checked against the database if it exists. ...
It has to be clicked twice because you are defining `#microsubmit`'s `click` event inside the function. So the first time you click you bind the event handler, and the 2nd time the event handler is in place and gets fired. I haven't gone over the logic behind what you're trying to accomplish but my guess is that if you...
542,263
<p>I have a query to a database on a seperate thread and on the return I invoke a threadsafe call. But an exception is created - what am I doing wrong?</p> <p>Note I also populate the list view but have left it out for clarity</p> <pre><code> private void ThreadSafeListView() { if (this.listView1.Invoke...
[ { "answer_id": 542299, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>What exception is thrown? If it's still a thread-safe exception, then it may be because you're not invoking from the item th...
2009/02/12
[ "https://Stackoverflow.com/questions/542263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54009/" ]
I have a query to a database on a seperate thread and on the return I invoke a threadsafe call. But an exception is created - what am I doing wrong? Note I also populate the list view but have left it out for clarity ``` private void ThreadSafeListView() { if (this.listView1.InvokeRequired) { ...
What exception is thrown? If it's still a thread-safe exception, then it may be because you're not invoking from the item that requires invocation. Try: ``` listView1.Invoke(d) ``` rather than ``` this.Invoke(d) ``` In theory this is the form, so it should work, but without more information about the exception ...
542,265
<p>I'm connecting to a remote sql server instance with the following connection string</p> <p>"Network Library=DBMSSOCN;Data Source=xx.xxx.x.xxx,1433;Initial Catalog=MyDatabase;User Id=MyUserId;Password=MyPassword;Connect Timeout=120;"</p> <ol> <li>Sql Server Browser is running</li> <li>Local and remote connections a...
[ { "answer_id": 542272, "author": "Magnus Akselvoll", "author_id": 4683, "author_profile": "https://Stackoverflow.com/users/4683", "pm_score": 3, "selected": true, "text": "<p>No, SQL Server Agent does not need to be running. SQL Server agent is only needed to execute scheduled tasks on t...
2009/02/12
[ "https://Stackoverflow.com/questions/542265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12918/" ]
I'm connecting to a remote sql server instance with the following connection string "Network Library=DBMSSOCN;Data Source=xx.xxx.x.xxx,1433;Initial Catalog=MyDatabase;User Id=MyUserId;Password=MyPassword;Connect Timeout=120;" 1. Sql Server Browser is running 2. Local and remote connections are allowed using TCP/IP on...
No, SQL Server Agent does not need to be running. SQL Server agent is only needed to execute scheduled tasks on the SQL server. This is probably a network issue. Can you ping the server? If so, try to ping it continuously with /t and see if all packets arrive. It could also be a problem with the SQL server load. Is t...
542,267
<p>I put a TLinkLabel on my form, filled it in with a caption including a valid HTML link, and got some nice blue underlined text. When I ran the program, I expected it to invoke Firefox (my default browser) and open the link automatically. Apparently that's not the case.</p> <p>The helpfile says I have to code this...
[ { "answer_id": 542472, "author": "Cesar Romero", "author_id": 36875, "author_profile": "https://Stackoverflow.com/users/36875", "pm_score": 5, "selected": true, "text": "<p>You can call ShellExecute.\nI wrote this method for generic calls, and should works in your case.</p>\n\n<pre><code...
2009/02/12
[ "https://Stackoverflow.com/questions/542267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
I put a TLinkLabel on my form, filled it in with a caption including a valid HTML link, and got some nice blue underlined text. When I ran the program, I expected it to invoke Firefox (my default browser) and open the link automatically. Apparently that's not the case. The helpfile says I have to code this in an OnLin...
You can call ShellExecute. I wrote this method for generic calls, and should works in your case. ``` procedure ShellOpen(const Url: string; const Params: string = ''); begin ShellAPI.ShellExecute(0, 'Open', PChar(Url), PChar(Params), nil, SW_SHOWNORMAL); end; ``` In your code you should call this ``` procedure TF...
542,280
<p>Im having the following problem with vb.net asp.net webparts. Im trying to create a static connection between webparts but im running into a problem, namely: </p> <blockquote> <p>Could not find the connection provider Web Part with ID 'Ucl_Diary_Summary1'</p> </blockquote> <p>I have the following defined as my i...
[ { "answer_id": 542297, "author": "Rex M", "author_id": 67, "author_profile": "https://Stackoverflow.com/users/67", "pm_score": 4, "selected": true, "text": "<p>Event Validation verifies that the values have not been tampered with manually, e.g. outside the scope permitted by the controls...
2009/02/12
[ "https://Stackoverflow.com/questions/542280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64560/" ]
Im having the following problem with vb.net asp.net webparts. Im trying to create a static connection between webparts but im running into a problem, namely: > > Could not find the connection provider Web Part with ID 'Ucl\_Diary\_Summary1' > > > I have the following defined as my iterface: ``` Public Interface...
Event Validation verifies that the values have not been tampered with manually, e.g. outside the scope permitted by the controls involved. For example, if you have a drop-down list with three choices 1, 2, or 3... if the user (or malicious middleman) changes the value to 4, validation will fail. As long as you are doi...
542,296
<p>I want to backup a table saving the copy in the same database with another name. I want to do it programatically using .NET 2.0 (preferably C#). Someone can point me what should I do?</p>
[ { "answer_id": 542348, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 4, "selected": true, "text": "<p>Just send this query to the server:</p>\n\n<pre><code>SELECT * INTO [BackupTable] FROM [OriginalTable]\n</code></pre...
2009/02/12
[ "https://Stackoverflow.com/questions/542296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
I want to backup a table saving the copy in the same database with another name. I want to do it programatically using .NET 2.0 (preferably C#). Someone can point me what should I do?
Just send this query to the server: ``` SELECT * INTO [BackupTable] FROM [OriginalTable] ``` This will create the backup table from scratch (an error will be thrown if it already exists). For large tables be prepared for it to take a while. This should mimic datatypes, collation, and NULLness (NULL or NOT NULL), but...
542,304
<p>I'm working on a project for school that involves a heavy amount of XML Parsing. I'm coding in C#, but I have yet to find a "suitable" method of parsing this XML out. There's several different ways I've looked at, but haven't gotten it right yet; so I have come to you. Ideally, I'm looking for something kind of simi...
[ { "answer_id": 542318, "author": "Welbog", "author_id": 52443, "author_profile": "https://Stackoverflow.com/users/52443", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://cache.gawker.com/assets/images/gawker/2009/02/flier.jpg\" rel=\"nofollow noreferrer\">XmlDocument</a> +...
2009/02/12
[ "https://Stackoverflow.com/questions/542304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm working on a project for school that involves a heavy amount of XML Parsing. I'm coding in C#, but I have yet to find a "suitable" method of parsing this XML out. There's several different ways I've looked at, but haven't gotten it right yet; so I have come to you. Ideally, I'm looking for something kind of similar...
[XmlDocument](http://cache.gawker.com/assets/images/gawker/2009/02/flier.jpg) + [XPath](http://www.w3schools.com/XPath/default.asp) is pretty much all you ever need in .NET to parse XML.
542,312
<p>I'm experiencing this problem today on many different servers. </p> <p><strong>System.UnauthorizedAccessException: Access to the temp directory is denied.</strong></p> <p>The servers were not touched recently. The only thing that comes in my mind is a windows update breaking something.. Any idea? </p> <p>This hap...
[ { "answer_id": 542343, "author": "Mun", "author_id": 775, "author_profile": "https://Stackoverflow.com/users/775", "pm_score": 5, "selected": true, "text": "<p>Have you checked the permissions on the temp folder? In these cases, the easiest and quickest solution is usually to re-run the...
2009/02/12
[ "https://Stackoverflow.com/questions/542312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2250286/" ]
I'm experiencing this problem today on many different servers. **System.UnauthorizedAccessException: Access to the temp directory is denied.** The servers were not touched recently. The only thing that comes in my mind is a windows update breaking something.. Any idea? This happens when trying to access a webservi...
Have you checked the permissions on the temp folder? In these cases, the easiest and quickest solution is usually to re-run the *aspnet\_regiis -i* command to re-install the asp.net framework which also resets the permissions on the required folders. Failing that, try using [Process Monitor](http://technet.microsoft.co...
542,328
<p>This question is relating to a specific functionality that a client has requested for an application I am designing. Basically, the client wants the DateTimePicker to prompt a question after the date was selected.</p> <p>This sounds simple, however, I am having difficulties accomplishing this simple task. </p> <...
[ { "answer_id": 542364, "author": "Jim Counts", "author_id": 36737, "author_profile": "https://Stackoverflow.com/users/36737", "pm_score": 1, "selected": false, "text": "<p>I would use the OnValueChanged event. After they change the value, ask the question. If they answer wrong (Example...
2009/02/12
[ "https://Stackoverflow.com/questions/542328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62923/" ]
This question is relating to a specific functionality that a client has requested for an application I am designing. Basically, the client wants the DateTimePicker to prompt a question after the date was selected. This sounds simple, however, I am having difficulties accomplishing this simple task. 1. **If I prompt ...
I ended up coding a custom control to handle this the right way. I created a textbox with a button, and added a MonthCalendar control as well. The textbox+button opens the MonthCalendar control. The only way to choose the datetime now is via the MonthCalendar. You cannot select from the Textbox. I also created a custo...
542,338
<p>I have a view which would like to be notified about all the currently opened editors. Where can I add a listener to achieve this?</p> <p>I was expecting WorkbenchPage or EditorManager to have some appropriate listener registry, but I couldn't find it.</p>
[ { "answer_id": 542375, "author": "Kothar", "author_id": 37416, "author_profile": "https://Stackoverflow.com/users/37416", "pm_score": 2, "selected": false, "text": "<p>I think you're on the right track. You need to listen to the IWorkbenchPage <a href=\"http://download.eclipse.org/eclips...
2009/02/12
[ "https://Stackoverflow.com/questions/542338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9886/" ]
I have a view which would like to be notified about all the currently opened editors. Where can I add a listener to achieve this? I was expecting WorkbenchPage or EditorManager to have some appropriate listener registry, but I couldn't find it.
Does your view uses a [`org.eclipse.ui.IPartListener2`](http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/IPartListener2.html) ? That is what is using this [EditorListener](http://www.koders.com/java/fidC16A4CE2FC6A7F818AD035376967CA06F87DBA4F.aspx?s=EditorList...
542,369
<p>I am looking at an asp.net application that makes calls to a database within the application start inside global.asax. These calls takes around 3 seconds (depends on SQL cache plan) to run. I have noticed that the application runs <strong>slowly</strong> when I first redeploy. I put this down to the calls to the dat...
[ { "answer_id": 542386, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 2, "selected": false, "text": "<p>Check the event log, something is causing the app pool to recycle.</p>\n" }, { "answer_id": 542678, "...
2009/02/12
[ "https://Stackoverflow.com/questions/542369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15410/" ]
I am looking at an asp.net application that makes calls to a database within the application start inside global.asax. These calls takes around 3 seconds (depends on SQL cache plan) to run. I have noticed that the application runs **slowly** when I first redeploy. I put this down to the calls to the database whilst the...
It turned out to be a leaky dll...
542,376
<p>I Created Segment Control through Interface Builder. Created a IBAction and Linked to Value Changed Option of segment Controller.</p> <pre><code>- (IBAction)GenderBttonAction:(id)sender { printf("\n Segemt Controll"); } </code></pre> <p>When i click on segment controller this method is calling , but how wo...
[ { "answer_id": 542440, "author": "Alfons", "author_id": 21915, "author_profile": "https://Stackoverflow.com/users/21915", "pm_score": 3, "selected": false, "text": "<pre><code>((UISegmentedControl *)sender).selectedSegmentIndex;\n</code></pre>\n\n<p>:-)</p>\n" }, { "answer_id": 1...
2009/02/12
[ "https://Stackoverflow.com/questions/542376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I Created Segment Control through Interface Builder. Created a IBAction and Linked to Value Changed Option of segment Controller. ``` - (IBAction)GenderBttonAction:(id)sender { printf("\n Segemt Controll"); } ``` When i click on segment controller this method is calling , but how would i get the seleced inde...
``` ((UISegmentedControl *)sender).selectedSegmentIndex; ``` :-)
542,378
<p>My (C#, .NET 3.5) application generates files and, in addition to raising events that can be caught and reacted to, I want to display the target folder to the user in a form. The file-list is being shown within the same form as other information.</p> <p>I'm using an instance of the <code>WebBrowser</code> control (...
[ { "answer_id": 572720, "author": "Asaf R", "author_id": 6827, "author_profile": "https://Stackoverflow.com/users/6827", "pm_score": 0, "selected": false, "text": "<p>If you want to open a different window to display the target folder's content you can use System.Windows.Forms.OpenFileDia...
2009/02/12
[ "https://Stackoverflow.com/questions/542378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2902/" ]
My (C#, .NET 3.5) application generates files and, in addition to raising events that can be caught and reacted to, I want to display the target folder to the user in a form. The file-list is being shown within the same form as other information. I'm using an instance of the `WebBrowser` control (`System.Windows.Forms...
In order to handle renaming, deleting and make other customization you need to write your own file explorer. WebBrowser control is not suitable for your needs. It's just a wrapper over ActiveX component. You should check [this codeproject article](http://www.codeproject.com/KB/miscctrl/FileBrowser.aspx). It contains...
542,383
<p>I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP:</p> <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt; &lt;c:set var="path" value="test"/&gt; </code></pre> <p>However, I am getting this error when The JSP runs:</p> <pr...
[ { "answer_id": 542454, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 3, "selected": true, "text": "<p>Looks like you may have some versioning problem, maybe a conflicting jar file of some sort. Look <a href=\"http://faq...
2009/02/12
[ "https://Stackoverflow.com/questions/542383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
I am trying to set a variable that I will refer to in a custom JSP tag, so I have something like this in my JSP: ``` <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="path" value="test"/> ``` However, I am getting this error when The JSP runs: ``` java.lang.AbstractMethodError: javax.serv...
Looks like you may have some versioning problem, maybe a conflicting jar file of some sort. Look [here](http://faq.javaranch.com/view?JstlTagLibDefinitions), maybe it'll help. You need to supply some more info about your runtime environment if you can't solve it.
542,389
<p>I have a scenario I'm stuck on - I have a domain object that has a collection of objects attached to it. Something like this:</p> <pre><code>public class Person { public string Name { get; set; } public IList&lt;PhoneNumber&gt; PhoneNumbers {get; set; } public IList&lt;Address&gt; Addresses { get; set; } ...
[ { "answer_id": 542452, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 0, "selected": false, "text": "<p>In the past I've used the railsy convention for this.</p>\n\n<pre><code>&lt;input name=\"Parent[childObjectType][...
2009/02/12
[ "https://Stackoverflow.com/questions/542389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1338/" ]
I have a scenario I'm stuck on - I have a domain object that has a collection of objects attached to it. Something like this: ``` public class Person { public string Name { get; set; } public IList<PhoneNumber> PhoneNumbers {get; set; } public IList<Address> Addresses { get; set; } } ``` The UI the client w...
It is supported by the framework by using a special "form layout". Phil Haack has an article on this, [check this out](http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx) Edit Scott Hanselman (<http://www.hanselman.com/blog/ASPNETWireFormatForModelBindingToArraysListsCollectionsDictionaries.aspx>) just...
542,392
<p>I've got a WPF application with a Treeview control.</p> <p>When the user clicks a node on the tree, other TextBox, ComboBox, etc. controls on the page are populated with appropriate values.</p> <p>The user can then make changes to those values and save his or her changes by clicking a Save button.</p> <p>However,...
[ { "answer_id": 542459, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 1, "selected": false, "text": "<p>Since the <code>SelectedItemChanged</code> event is triggered after the <code>SelectedItem</code> has already changed, yo...
2009/02/12
[ "https://Stackoverflow.com/questions/542392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
I've got a WPF application with a Treeview control. When the user clicks a node on the tree, other TextBox, ComboBox, etc. controls on the page are populated with appropriate values. The user can then make changes to those values and save his or her changes by clicking a Save button. However, if the user selects a d...
**UPDATE** Realized I could put the logic in SelectedItemChanged instead. A little cleaner solution. Xaml ``` <TreeView Name="c_treeView" SelectedItemChanged="c_treeView_SelectedItemChanged"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property...
542,396
<p>I'm posting a form in ColdFusion on Linux. Form has a file field. CF requires the enctype="multipart/form-data" attribute on the form tag. If I have this, I get a "JRun Servlet Error - 500 No such file or directory"</p> <p>If I take the attrib out, the form posts and I get the CF "enctype=multipart/form-data" er...
[ { "answer_id": 544531, "author": "anopres", "author_id": 1537, "author_profile": "https://Stackoverflow.com/users/1537", "pm_score": 0, "selected": false, "text": "<p>You've probably already tried this, but have you tried all upper-case or all lowercase in your paths and file names? Som...
2009/02/12
[ "https://Stackoverflow.com/questions/542396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
I'm posting a form in ColdFusion on Linux. Form has a file field. CF requires the enctype="multipart/form-data" attribute on the form tag. If I have this, I get a "JRun Servlet Error - 500 No such file or directory" If I take the attrib out, the form posts and I get the CF "enctype=multipart/form-data" error. What to...
Possible reason is that server can not find the uploaded temp file. Have you tried to make upload without component wrapper? Simply ``` <cfif StructKeyExists(Form, "before") AND Form.before NEQ ""> <cffile action="upload" filefield="before" destination="#AbsPathToStoreFile#" > </cfif> <cfdump var="#...
542,405
<p>I'm trying to write an ant build script to build my group's flex app, and I've run into some roadblocks that I'm hoping someone on SO has seen before.</p> <p>We have two projects that we build into SWCs and these components contain resource bundles. One SWC requires the other SWC. We have one project that we build ...
[ { "answer_id": 557882, "author": "dw.mackie", "author_id": 59084, "author_profile": "https://Stackoverflow.com/users/59084", "pm_score": 4, "selected": true, "text": "<p>Arrgh!<p>\nAfter many hours of staring at this problem, I realized that the issue was looking me in the face the whole...
2009/02/12
[ "https://Stackoverflow.com/questions/542405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59084/" ]
I'm trying to write an ant build script to build my group's flex app, and I've run into some roadblocks that I'm hoping someone on SO has seen before. We have two projects that we build into SWCs and these components contain resource bundles. One SWC requires the other SWC. We have one project that we build into our a...
Arrgh! After many hours of staring at this problem, I realized that the issue was looking me in the face the whole time. The compc task is using 'locale="EN\_US"' and the mxmlc task is using 'locale="en\_US"'. If anyone ever posts a "what's the stupidest work problem you've ever had?", this would be my answer.
542,410
<p>I am creating a user control in ASP.NET (using VB) that uses the autocomplete ajax control on a textbox to get a value. Then I want the page to post back and run some code according to whatever value is passed to it from this control. Problem is, I'm not exactly sure how to do this. I'm sure it's easy and I should ...
[ { "answer_id": 542417, "author": "Dested", "author_id": 11137, "author_profile": "https://Stackoverflow.com/users/11137", "pm_score": 0, "selected": false, "text": "<p>((NameOfPage)this.Page).VariableOnPage = this.Foobar;</p>\n" }, { "answer_id": 542423, "author": "Bob", ...
2009/02/12
[ "https://Stackoverflow.com/questions/542410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I am creating a user control in ASP.NET (using VB) that uses the autocomplete ajax control on a textbox to get a value. Then I want the page to post back and run some code according to whatever value is passed to it from this control. Problem is, I'm not exactly sure how to do this. I'm sure it's easy and I should know...
In your user control expose a property for the value ``` Public Property SomeValue() As String Get Return textbox1.Text End Get End Property ``` Then in your aspx page load, just reference the user control's value. ``` userControl1.SomeValue ``` Edit, I just tried changing my syntax to vb.net, I don't actual...
542,419
<p>I have two tables involved in this query I need to create, and I'm not exactly sure how to join these two tables in order to update.</p> <p>I have a ITEM and CONSUMER_ITEMS table. The ITEM table has a distinct code for each item and a UPC code. I need to concatenate a string with the ITEM.UPC_CODE to CONSUMER_ITEMS...
[ { "answer_id": 542462, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 4, "selected": true, "text": "<p>Sounds like you want:</p>\n\n<pre><code>UPDATE consumer_items ci\nSET new_item_code = (SELECT 'string' || item.u...
2009/02/12
[ "https://Stackoverflow.com/questions/542419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38629/" ]
I have two tables involved in this query I need to create, and I'm not exactly sure how to join these two tables in order to update. I have a ITEM and CONSUMER\_ITEMS table. The ITEM table has a distinct code for each item and a UPC code. I need to concatenate a string with the ITEM.UPC\_CODE to CONSUMER\_ITEMS.NEW\_I...
Sounds like you want: ``` UPDATE consumer_items ci SET new_item_code = (SELECT 'string' || item.upc_code FROM item WHERE item.item_code = ci.item_code ) WHERE ci.item_code IN ('a','b','c'); ``` Alternatively, assuming there is a foreign ke...
542,421
<p>I'm having a problem where I have been able to add a project to CC.rb perfectly fine but when I start the service I get "Access Denied" messages each time it checks with Subversion for a newer version.</p> <p>I'm running with --trace and running the exact command it is trying from the project's work directory:</p> ...
[ { "answer_id": 542434, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 1, "selected": false, "text": "<p>Make sure that if you are using SSL that the user account running the script, has a cached certificate permission...
2009/02/12
[ "https://Stackoverflow.com/questions/542421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6369/" ]
I'm having a problem where I have been able to add a project to CC.rb perfectly fine but when I start the service I get "Access Denied" messages each time it checks with Subversion for a newer version. I'm running with --trace and running the exact command it is trying from the project's work directory: ``` svn --non...
Make sure that if you are using SSL that the user account running the script, has a cached certificate permission for the SSL. That is for cruisecontrol.net, which is a service that runs as a very specific user in windows. You may need to figure out the impersonation rules for ruby.exe to determine if it runs as netwo...
542,429
<p>How do you solve the infinite login loop problem when you are using cookieless sessions and cannot change the name of login.aspx to a httphandler ?</p> <p>i.e. When a user with admin rights hits the logout button and the return url to a restricted page is passed to login.aspx then another user without admin rights ...
[ { "answer_id": 549839, "author": "Bravax", "author_id": 13911, "author_profile": "https://Stackoverflow.com/users/13911", "pm_score": 0, "selected": false, "text": "<p>Could you change the page flow?</p>\n\n<p>What I mean is, rather then redirect back to the login.aspx page when a user d...
2009/02/12
[ "https://Stackoverflow.com/questions/542429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50970/" ]
How do you solve the infinite login loop problem when you are using cookieless sessions and cannot change the name of login.aspx to a httphandler ? i.e. When a user with admin rights hits the logout button and the return url to a restricted page is passed to login.aspx then another user without admin rights try's to l...
Check if the user is authorized to access the page in the returnUrl, after log in on the login.aspx page. You might use this method of the UrlAuthorizationModule (or a custom one if it works best for you): ``` System.Web.Security.UrlAuthorizationModule.CheckUrlAccessForPrincipal( returnUrl, userPrincipal, ...
542,436
<p>I'll just start out by saying I am not at all experienced with creating Perl modules so I'm sorry if I'm way off here.</p> <p>Let's say I am creating a few modules:</p> <pre><code>foo::bar foo::bar::a foo::bar::b </code></pre> <p>Since I don't know what they are called, I am calling the a.pm and b.pm modules "sub...
[ { "answer_id": 542473, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 2, "selected": false, "text": "<p>Yes, you can do that. It will probably involve writing a custom 'sub import' in foo::bar that interprets incoming argume...
2009/02/12
[ "https://Stackoverflow.com/questions/542436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40619/" ]
I'll just start out by saying I am not at all experienced with creating Perl modules so I'm sorry if I'm way off here. Let's say I am creating a few modules: ``` foo::bar foo::bar::a foo::bar::b ``` Since I don't know what they are called, I am calling the a.pm and b.pm modules "sub modules" since they are related ...
Look at my [Test::Data](http://search.cpan.org/dist/Test-Data) module for an example about doing that. Even though you can make it happen, I've never been terribly fond of the result. You might want to consider a Plugin or Mixin approach instead. There are some modules on [CPAN](http://search.cpan.org) that can help wi...
542,439
<p>I followed ScottGu's advice on enabling javascript intellisense using a -vsdoc.js file. </p> <p><a href="http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx</a></p> <p>...
[ { "answer_id": 542453, "author": "Andrey Shchekin", "author_id": 39068, "author_profile": "https://Stackoverflow.com/users/39068", "pm_score": 5, "selected": true, "text": "<p>Sure, add</p>\n\n<pre><code>/// &lt;reference path=\"path-to-jquery\" /&gt;\n</code></pre>\n\n<p>at the very beg...
2009/02/12
[ "https://Stackoverflow.com/questions/542439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
I followed ScottGu's advice on enabling javascript intellisense using a -vsdoc.js file. <http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx> I now get intellisense when I write javascript inside my HTML/ASPX files. I write most of my javascript in separate javascript files that I a...
Sure, add ``` /// <reference path="path-to-jquery" /> ``` at the very beginning of your js file.
542,444
<p>The CodeRush file search tool "Quick File Navigation" looks pretty similar to a regular "Find" window. What type of window/form is that? </p> <p>How do we create such windows that stay within the VS IDE (MDI I guess)?</p>
[ { "answer_id": 542453, "author": "Andrey Shchekin", "author_id": 39068, "author_profile": "https://Stackoverflow.com/users/39068", "pm_score": 5, "selected": true, "text": "<p>Sure, add</p>\n\n<pre><code>/// &lt;reference path=\"path-to-jquery\" /&gt;\n</code></pre>\n\n<p>at the very beg...
2009/02/12
[ "https://Stackoverflow.com/questions/542444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64574/" ]
The CodeRush file search tool "Quick File Navigation" looks pretty similar to a regular "Find" window. What type of window/form is that? How do we create such windows that stay within the VS IDE (MDI I guess)?
Sure, add ``` /// <reference path="path-to-jquery" /> ``` at the very beginning of your js file.
542,455
<p>Is it possible to write a REGEX (search replace) that when run on an XML string will output that XML string indented nicely?</p> <p>If so whats the REGEX :)</p>
[ { "answer_id": 542469, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "<p>Doing this would be far, far simpler if you didn't use a regex. In fact I'm not even sure it's possible with regex.</p>\n...
2009/02/12
[ "https://Stackoverflow.com/questions/542455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6244/" ]
Is it possible to write a REGEX (search replace) that when run on an XML string will output that XML string indented nicely? If so whats the REGEX :)
> > Is it possible to write a REGEX (search replace) that when run on an XML string [...anything] > > > No. Use an XML parser to read the string, then an XML serialiser to write it back out in ‘pretty’ mode. Each XML processor has its own options so it depends on platform, but here is the somewhat long-winded wa...
542,461
<p>I'm new to TFS build.</p> <p>I am looking at the .proj file right now, and I see it references the microsoft.teamfoundation.build.targets file.</p> <p>Which file do I add my custom tasks to? And where is that file located (if it's not the .proj file)?</p> <p>I want to add a custom task to run dotfuscator (comman...
[ { "answer_id": 542469, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": false, "text": "<p>Doing this would be far, far simpler if you didn't use a regex. In fact I'm not even sure it's possible with regex.</p>\n...
2009/02/12
[ "https://Stackoverflow.com/questions/542461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm new to TFS build. I am looking at the .proj file right now, and I see it references the microsoft.teamfoundation.build.targets file. Which file do I add my custom tasks to? And where is that file located (if it's not the .proj file)? I want to add a custom task to run dotfuscator (command line tool) and pass it ...
> > Is it possible to write a REGEX (search replace) that when run on an XML string [...anything] > > > No. Use an XML parser to read the string, then an XML serialiser to write it back out in ‘pretty’ mode. Each XML processor has its own options so it depends on platform, but here is the somewhat long-winded wa...
542,483
<p>I'm developing a card game that uses rummy-style sets of three cards. From a random selection of cards, I need the algorithm to pick out which cards would get me the highest number of sets.</p> <p>By "rummy-style sets of three" I mean:</p> <ul><li>All three cards have the same value, like three Jacks. OR</li> <li...
[ { "answer_id": 542548, "author": "mqp", "author_id": 55943, "author_profile": "https://Stackoverflow.com/users/55943", "pm_score": 1, "selected": false, "text": "<p>My intuitive approach would be to start by discovering all the possible sets, by examining each card and searching for what...
2009/02/12
[ "https://Stackoverflow.com/questions/542483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65595/" ]
I'm developing a card game that uses rummy-style sets of three cards. From a random selection of cards, I need the algorithm to pick out which cards would get me the highest number of sets. By "rummy-style sets of three" I mean: * All three cards have the same value, like three Jacks. OR * All three cards are of the ...
if you have N cards (N = 8), you can enumerate through all the distinct triples in the set in time N \* (N - 1) \* (N - 2) (with N = 8 you get 336). This is pretty fast. Check which ones of the triples are "rummy-style" sets, and store them in a table as integer triples (the integer denote the sequence numbers of the c...
542,484
<p>I have the following SQL statement</p> <pre><code>INSERT INTO A_Table (field1, field2) SELECT field1, field2 FROM B_Table WHERE field1 NOT IN ( SELECT field1 FROM A_Table); </code></pre> <p>basically, I need to copy all the data from B_Table to A_Table, with a constrain: field1 from B_Table not existing i...
[ { "answer_id": 542495, "author": "Shawn", "author_id": 26, "author_profile": "https://Stackoverflow.com/users/26", "pm_score": 0, "selected": false, "text": "<p>Well it looks like that query wouldn't work in its current form because you aren't specifying a column in your sub query. Most ...
2009/02/12
[ "https://Stackoverflow.com/questions/542484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
I have the following SQL statement ``` INSERT INTO A_Table (field1, field2) SELECT field1, field2 FROM B_Table WHERE field1 NOT IN ( SELECT field1 FROM A_Table); ``` basically, I need to copy all the data from B\_Table to A\_Table, with a constrain: field1 from B\_Table not existing in A\_Table. I need to a...
maybe it will help if you look at you query as on two separate statements the select statement ``` SELECT field1, field2 FROM B_Table WHERE field1 NOT IN ( SELECT field1 FROM A_Table) ``` which gives you some results now you insert those results into your table A\_table ``` INSERT INTO A_Table (field1, ...
542,497
<p>I'm trying to import a spreadsheet to our database using SSIS. For some reason SSIS wants to believe two of the columns are of type Double, when they contain character data. I've tried remapping the columns to be nvarchar(255) but it still doesn't want to select the data it thinks is double, because there are char...
[ { "answer_id": 542573, "author": "James", "author_id": 56753, "author_profile": "https://Stackoverflow.com/users/56753", "pm_score": 7, "selected": true, "text": "<p>I've seen this issue before, it's Excel that is the issue not SSIS. Excel samples the 1st few rows and then infers the dat...
2009/02/12
[ "https://Stackoverflow.com/questions/542497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17145/" ]
I'm trying to import a spreadsheet to our database using SSIS. For some reason SSIS wants to believe two of the columns are of type Double, when they contain character data. I've tried remapping the columns to be nvarchar(255) but it still doesn't want to select the data it thinks is double, because there are character...
I've seen this issue before, it's Excel that is the issue not SSIS. Excel samples the 1st few rows and then infers the data type even if you explicitly set it to text. What you need to do is put this into the Excel file connection string in the SSIS package. This instruction tells Excel that the columns contain mixed d...
542,510
<p>I've heard that "everyone" is using parameterized SQL queries to protect against SQL injection attacks without having to vailidate every piece of user input.</p> <p>How do you do this? Do you get this automatically when using stored procedures?</p> <p>So my understanding this is non-parameterized:</p> <pre cla...
[ { "answer_id": 542535, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 3, "selected": false, "text": "<p>You want to go with your last example as this is the only one that is truly parametrized. Besides security concern...
2009/02/12
[ "https://Stackoverflow.com/questions/542510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36737/" ]
I've heard that "everyone" is using parameterized SQL queries to protect against SQL injection attacks without having to vailidate every piece of user input. How do you do this? Do you get this automatically when using stored procedures? So my understanding this is non-parameterized: ```vb cmdText = String.Format("S...
The `EXEC` example in the question would **NOT** be parameterized. You need parameterized queries (prepared statements in some circles) to prevent input like this from causing damage: > > ';DROP TABLE bar;-- > > > Try putting that in your `fuz` variable (or don't, if you value the `bar` table). More subtle and da...
542,515
<p>I am trying to understand pros and cons of using log4netor enterprise library logging application block (LAB) for logging in application. I know one thing LAB is little difficult to use then log4net.</p>
[ { "answer_id": 542535, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 3, "selected": false, "text": "<p>You want to go with your last example as this is the only one that is truly parametrized. Besides security concern...
2009/02/12
[ "https://Stackoverflow.com/questions/542515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65266/" ]
I am trying to understand pros and cons of using log4netor enterprise library logging application block (LAB) for logging in application. I know one thing LAB is little difficult to use then log4net.
The `EXEC` example in the question would **NOT** be parameterized. You need parameterized queries (prepared statements in some circles) to prevent input like this from causing damage: > > ';DROP TABLE bar;-- > > > Try putting that in your `fuz` variable (or don't, if you value the `bar` table). More subtle and da...
542,525
<p>What are the differences between the classic transaction pattern in LINQ to SQL like:</p> <pre><code>using(var context = Domain.Instance.GetContext()) { try { context.Connection.Open(); context.Transaction = context.Connection.BeginTransaction(); /*code*/ context.Transaction....
[ { "answer_id": 542613, "author": "Chris Marisic", "author_id": 37055, "author_profile": "https://Stackoverflow.com/users/37055", "pm_score": 2, "selected": false, "text": "<p>I believe they are fundamentally the same that the TransactionScope class will interface with the ADO.NET underly...
2009/02/12
[ "https://Stackoverflow.com/questions/542525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455/" ]
What are the differences between the classic transaction pattern in LINQ to SQL like: ``` using(var context = Domain.Instance.GetContext()) { try { context.Connection.Open(); context.Transaction = context.Connection.BeginTransaction(); /*code*/ context.Transaction.Commit(); ...
Linq2SQL will use an implicit transaction. If all of your updates are done within a single Submit, you may not need to handle the transaction yourself. From the documentation (emphasis mine): > > When you call SubmitChanges, LINQ to SQL checks to see whether the call is in the scope of a Transaction or if the Transa...
542,551
<p>How do you do a Remote HTTP Post (request) in ruby? </p>
[ { "answer_id": 542723, "author": "Chuck", "author_id": 50742, "author_profile": "https://Stackoverflow.com/users/50742", "pm_score": 3, "selected": false, "text": "<p>With Net::HTTP. Correct but non-working example (because Google only supports GET — sorry, I couldn't think of any open P...
2009/02/12
[ "https://Stackoverflow.com/questions/542551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65122/" ]
How do you do a Remote HTTP Post (request) in ruby?
With Net::HTTP. Correct but non-working example (because Google only supports GET — sorry, I couldn't think of any open POST forms off the top of my head): ``` require 'net/http' require 'uri' result = Net::HTTP.post_form(URI.parse("http://google.com/search"), {"q" => "Rick Astley"}) ``` [docs](http://www.ruby-doc....
542,556
<p>Using ASP.NET WebServices, by default you can't pass any IDictionary objects, because xml serialization for IDictionaries isn't supported. I have found various ways to serialized dictionaries (<a href="http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/...
[ { "answer_id": 542723, "author": "Chuck", "author_id": 50742, "author_profile": "https://Stackoverflow.com/users/50742", "pm_score": 3, "selected": false, "text": "<p>With Net::HTTP. Correct but non-working example (because Google only supports GET — sorry, I couldn't think of any open P...
2009/02/12
[ "https://Stackoverflow.com/questions/542556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24954/" ]
Using ASP.NET WebServices, by default you can't pass any IDictionary objects, because xml serialization for IDictionaries isn't supported. I have found various ways to serialized dictionaries (<http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx>, <http://blogs.msdn.com/psheill/archive/2005/04/09/406823.asp...
With Net::HTTP. Correct but non-working example (because Google only supports GET — sorry, I couldn't think of any open POST forms off the top of my head): ``` require 'net/http' require 'uri' result = Net::HTTP.post_form(URI.parse("http://google.com/search"), {"q" => "Rick Astley"}) ``` [docs](http://www.ruby-doc....
542,564
<p>I'm trying to integrate analytics into my GWT application. To do this, I'm calling a service that returns a String of HTML that needs to be parsed and eval'ed. </p> <p>I need a regex that looks for and grabs either 1) the body of the tag or 2) the contents of the "src" attribute. I want to eval both of these with ...
[ { "answer_id": 542640, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 0, "selected": false, "text": "<p>To match the body of the tag, you can try something like</p>\n\n<pre><code>&lt;script[^&gt;]*?&gt;(.*?)&lt;/script&...
2009/02/12
[ "https://Stackoverflow.com/questions/542564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65681/" ]
I'm trying to integrate analytics into my GWT application. To do this, I'm calling a service that returns a String of HTML that needs to be parsed and eval'ed. I need a regex that looks for and grabs either 1) the body of the tag or 2) the contents of the "src" attribute. I want to eval both of these with JavaScript....
This seems to do what you want: ``` final String srcOne = "<html>\r\n<head>\r\n<script src=\"http://test.com/some.js\"/>\r\n</head></html>"; final String srcTwo = "<html>\r\n<head>\r\n<script src=\"http://test.com/some.js\"></script>\r\n</head></html>"; final String tag = "<html>\r\n<head>\r\n<script>\r\nf...
542,595
<p>The idea is to create a class that exposes a context but handles the storage of it in a web application.</p> <p>Currently this is what I have:</p> <pre><code>public class EntityContext { private static String MAIN_CONTEXT_KEY = "MainContext"; private static TISQLEntities _context; public static void ...
[ { "answer_id": 542750, "author": "Chris Marisic", "author_id": 37055, "author_profile": "https://Stackoverflow.com/users/37055", "pm_score": 4, "selected": true, "text": "<p>You are implementing the equivalent of NHibernate's session per request pattern which is a good construct in NHibe...
2009/02/12
[ "https://Stackoverflow.com/questions/542595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21691/" ]
The idea is to create a class that exposes a context but handles the storage of it in a web application. Currently this is what I have: ``` public class EntityContext { private static String MAIN_CONTEXT_KEY = "MainContext"; private static TISQLEntities _context; public static void RemoveContext() {...
You are implementing the equivalent of NHibernate's session per request pattern which is a good construct in NHibernate. While I can't say 100% for sure that it's applicable to EF it most likely is. Further expanding on other session management patterns is the Session per Business Conversation which allows NHibernate t...
542,603
<p>Assume I've a sql statement like the following with the variable @FOO set somewhere earlier in code: </p> <pre><code>SELECT FIELDLIST FROM TABLE WHERE (FIELD = @FOO OR @FOO IS NULL) </code></pre> <p>Is the query optimizer smart enough to do the second side of the OR first (@FOO IS NULL) because (another assump...
[ { "answer_id": 542605, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>It's smart enough to apply the faster condition first, assuming it can judge which comparison will be faster in the...
2009/02/12
[ "https://Stackoverflow.com/questions/542603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64/" ]
Assume I've a sql statement like the following with the variable @FOO set somewhere earlier in code: ``` SELECT FIELDLIST FROM TABLE WHERE (FIELD = @FOO OR @FOO IS NULL) ``` Is the query optimizer smart enough to do the second side of the OR first (@FOO IS NULL) because (another assumption) it is faster to do a ...
The short answer... **Yes**, the optimiser is smart enough. The longer answer... SQL is declarative rather than imperative: Your query is a description of the criteria that your results must meet, it is *not* step-by-step instructions on how to generate those results. The optimiser executes the query in the most ef...
542,672
<p>Assuming the code:</p> <pre><code>MessageBox.Show(this, "Would you like the differential girdle spring on the up-end of the grammeters?", "Smi-Boloid Stater Slots", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); </code></pre> <p><a href="https://i.stack.imgur.com/GUFMo.png" rel="...
[ { "answer_id": 542686, "author": "BC.", "author_id": 54838, "author_profile": "https://Stackoverflow.com/users/54838", "pm_score": 4, "selected": false, "text": "<p>You have to enable the \"Cancel\" option with the enum value \"MessageBoxButtons.YesNoCancel\"</p>\n\n<p>This will return D...
2009/02/12
[ "https://Stackoverflow.com/questions/542672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
Assuming the code: ``` MessageBox.Show(this, "Would you like the differential girdle spring on the up-end of the grammeters?", "Smi-Boloid Stater Slots", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); ``` [![alt text](https://i.stack.imgur.com/GUFMo.png)](https://i.stack.imgur.com/...
I don't believe this is possible, although the typical equivalent is specifying one of the *[MessageBoxButtons](https://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxbuttons(v=vs.110).aspx)* flags with *Cancel* (specifically YesNoCancel in your case). It should be fairly straightforward to recreate y...
542,690
<p>I'm trying to use String.Format("{0:c}", somevalue) in C# but am having a hard time figuring out how to configure the output to meet my needs. Here are my needs:</p> <ol> <li>0 outputs to blank</li> <li>1.00 outputs to $1.00</li> <li>10.00 outputs to $10.00</li> <li>100.00 outputs to $100.00</li> <li>1000.00 output...
[ { "answer_id": 542700, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 2, "selected": false, "text": "<p>Try something like this:</p>\n\n<pre><code>String currency = (number == 0) ? String.Empty : number.ToString(\"c\");...
2009/02/12
[ "https://Stackoverflow.com/questions/542690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9809/" ]
I'm trying to use String.Format("{0:c}", somevalue) in C# but am having a hard time figuring out how to configure the output to meet my needs. Here are my needs: 1. 0 outputs to blank 2. 1.00 outputs to $1.00 3. 10.00 outputs to $10.00 4. 100.00 outputs to $100.00 5. 1000.00 outputs to $1,000.00 I've tried String.For...
If you use ``` string.Format("{0:$#,##0.00;($#,##0.00);''}", value) ``` You will get "" for the zero value and the other values should be formatted properly too.
542,705
<p>I am a noob when it comes to SQL syntax. </p> <p>I have a table with lots of rows and columns of course :P Lets say it looks like this:</p> <pre><code> AAA BBB CCC DDD ----------------------- Row1 | 1 A D X Row2 | 2 B C X Row3 | 3 C D Z </code></pre> <p>Now I want to create an advanced sele...
[ { "answer_id": 542715, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 4, "selected": false, "text": "<p>If they are from the same table, I think <a href=\"http://www.devguru.com/technologies/t-sql/7118.asp\" rel=\"nore...
2009/02/12
[ "https://Stackoverflow.com/questions/542705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37643/" ]
I am a noob when it comes to SQL syntax. I have a table with lots of rows and columns of course :P Lets say it looks like this: ``` AAA BBB CCC DDD ----------------------- Row1 | 1 A D X Row2 | 2 B C X Row3 | 3 C D Z ``` Now I want to create an advanced select statement that gives me this c...
You have two choices here. The first is to have two result sets which will set 'Test1' or 'Test2' based on the condition in the `WHERE` clause, and then `UNION` them together: ``` select 'Test1', * from TABLE Where CCC='D' AND DDD='X' AND exists(select ...) UNION select 'Test2', * from TABL...
542,710
<p>At my last job (legacy FORTRAN 77 code), we had files of cross references that list what subroutines called other subroutines, in what files subroutines were defined, what common blocks held what variables, what subroutines included what common blocks, etc. These were then used by shell scripts that grepped the cro...
[ { "answer_id": 542722, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 3, "selected": false, "text": "<p>You might want to consider using <a href=\"http://www.doxygen.nl/\" rel=\"nofollow noreferrer\">doxygen</a>. It can...
2009/02/12
[ "https://Stackoverflow.com/questions/542710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6688/" ]
At my last job (legacy FORTRAN 77 code), we had files of cross references that list what subroutines called other subroutines, in what files subroutines were defined, what common blocks held what variables, what subroutines included what common blocks, etc. These were then used by shell scripts that grepped the cross r...
You might want to consider using [doxygen](http://www.doxygen.nl/). It can produce web pages that show you the entire call tree and class structure, as well as pulling out properly formatted comments to document the classes and methods just like Javadocs do for java. Another possibility is to start using an IDE. After...
542,716
<p>Asking on behalf of my coworker:</p> <p>We're working on a Facebook app that uses Flash 9 (and Flex, but that's not really relevant).</p> <p>We've got a fairly complex system of drawing an object with accessories over it, where the accessories can have arbitrary scale, rotation, and position relative to the base o...
[ { "answer_id": 542858, "author": "JD Isaacks", "author_id": 46011, "author_profile": "https://Stackoverflow.com/users/46011", "pm_score": 1, "selected": false, "text": "<p>Here you go, this might not be 100% efficient but if you pass it a BitmapData object it will return to you the exact...
2009/02/12
[ "https://Stackoverflow.com/questions/542716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23965/" ]
Asking on behalf of my coworker: We're working on a Facebook app that uses Flash 9 (and Flex, but that's not really relevant). We've got a fairly complex system of drawing an object with accessories over it, where the accessories can have arbitrary scale, rotation, and position relative to the base object. We recent...
How is your matrix constructed? You need to make sure as well as flipping the x scale that you also translate it back again across it's width. Here's an example with a MovieClip in the stage, where it is then drawn to a bitmap and flipped horizontally ``` import flash.display.*; import flash.geom.*; var toFlip : Movi...
542,720
<p>I've been trying to figure out the best way to copy files in Windows with deep paths (files, not folders so robocopy is out of the question). The best solution I've been able to come up with is writing my own solution. I've been able to write the code to handle listing directories with 10,000 character deeps paths...
[ { "answer_id": 542752, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 3, "selected": true, "text": "<p>If the call to CopyFile (not your overload, the P/Invoke declaration) returns false I would throw a Win32Exception:</p...
2009/02/12
[ "https://Stackoverflow.com/questions/542720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1469014/" ]
I've been trying to figure out the best way to copy files in Windows with deep paths (files, not folders so robocopy is out of the question). The best solution I've been able to come up with is writing my own solution. I've been able to write the code to handle listing directories with 10,000 character deeps paths but ...
If the call to CopyFile (not your overload, the P/Invoke declaration) returns false I would throw a Win32Exception: ``` public static void CopyFile(string source, string dest) { source = fixPathForLong(source); dest = fixPathForLong(dest); if (!CopyFile(source, dest, false)) { throw new Win32E...
542,724
<p>I have a WebBrowser control that is created and added to the form during run-time.</p> <p>How do I connect this control to subroutine that can handle its events at run-time?</p>
[ { "answer_id": 542734, "author": "Daniel LeCheminant", "author_id": 62055, "author_profile": "https://Stackoverflow.com/users/62055", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/7taxzxka(VS.80).aspx\" rel=\"noreferrer\">AddHandler</a...
2009/02/12
[ "https://Stackoverflow.com/questions/542724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57175/" ]
I have a WebBrowser control that is created and added to the form during run-time. How do I connect this control to subroutine that can handle its events at run-time?
Use [AddHandler](http://msdn.microsoft.com/en-us/library/7taxzxka(VS.80).aspx) e.g. ``` AddHandler Obj.Ev_Event, AddressOf EventHandler ``` and when you want to get rid of it (and you should get rid of it when you're done using it) ``` RemoveHandler Obj.Ev_Event, AddressOf EventHandler ``` in your case, you mig...
542,739
<p>I'm writing an iPhone app, and I've got an image which I'ld like to have swirl outwards.</p> <p>Currently my code looks like this (wrapped in a beginAnimations/commitAnimations block):</p> <pre><code>scale = CGAffineTransformScale(CGAffineTransformIdentity, 5.0f, 5.0f); swirl = CGAffineTransformRotate(scale, M_PI)...
[ { "answer_id": 542950, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 3, "selected": false, "text": "<p>You can, but you will need to split your animation into half-circle rotations. I provide an example of this in res...
2009/02/12
[ "https://Stackoverflow.com/questions/542739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/735/" ]
I'm writing an iPhone app, and I've got an image which I'ld like to have swirl outwards. Currently my code looks like this (wrapped in a beginAnimations/commitAnimations block): ``` scale = CGAffineTransformScale(CGAffineTransformIdentity, 5.0f, 5.0f); swirl = CGAffineTransformRotate(scale, M_PI); [player setTransfor...
You can rotate a view, by some number of radians, regardless of whether it is less than a full rotation or many multiples of a full rotation, without having to split the rotation into pieces. As an example, the following code will spin a view, once per second, for a specified number of seconds. You can easily modify it...
542,744
<p>I have <a href="https://stackoverflow.com/questions/539661/server-side-includes-and-character-encoding">a problem</a> with character encoding in some HTML pages. It seems that the cause of the problem is that some of the .html files are not saved as UTF-8 encoded files. Even though I have instructed Eclipse to save ...
[ { "answer_id": 542775, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "<p>The problem with UTF-8 is that there is no magic byte sequence at the beginning of these files - the browser's only...
2009/02/12
[ "https://Stackoverflow.com/questions/542744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have [a problem](https://stackoverflow.com/questions/539661/server-side-includes-and-character-encoding) with character encoding in some HTML pages. It seems that the cause of the problem is that some of the .html files are not saved as UTF-8 encoded files. Even though I have instructed Eclipse to save these files as...
You may need to change the content type header that your web server sends the client. Edit: While this did work for this particular situation, using a tool to change the file encoding as suggested by other posters may be a better solution in other situations. YMMV. --- Instructions for saving as UTF-8 in Eclipse (wh...
542,766
<p>At this point most people will be thinking "Ah ill post this..:"</p> <pre><code>byte[] dataB= System.Text.Encoding.ASCII.GetBytes(data); </code></pre> <p>However.. the problem I have is i need the exact value of the bytes with no encoding just the pure value for each byte. For example if the value of the string is...
[ { "answer_id": 542772, "author": "Phaedrus", "author_id": 46072, "author_profile": "https://Stackoverflow.com/users/46072", "pm_score": 2, "selected": false, "text": "<p>Use a <a href=\"http://msdn.microsoft.com/en-us/library/ms143295.aspx\" rel=\"nofollow noreferrer\">BinaryReader</a>.<...
2009/02/12
[ "https://Stackoverflow.com/questions/542766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65699/" ]
At this point most people will be thinking "Ah ill post this..:" ``` byte[] dataB= System.Text.Encoding.ASCII.GetBytes(data); ``` However.. the problem I have is i need the exact value of the bytes with no encoding just the pure value for each byte. For example if the value of the string is (0xFF32) i want it to con...
The problem is with your approach to start with: > > I need the exact value of the bytes with no encoding > > > ... > > For example if the value of the string is (0xFF32) > > > That's a bit like looking at an oil painting and saying, "I want the bytes for that picture, with no encoding." It doesn't make sen...
542,780
<p>I need to group some records based on a date but it is a date and time field and I need to ignore the time part of is and just group by the date part - here is my SQL as it stands:</p> <pre><code>SELECT AutoShipItems.CustomerID,AutoShipItems.NextOrderDate, Customer.FirstName,Customer.LastName, Customer.E...
[ { "answer_id": 542797, "author": "mson", "author_id": 36902, "author_profile": "https://Stackoverflow.com/users/36902", "pm_score": 4, "selected": false, "text": "<pre><code>cast (x as date)\n</code></pre>\n\n<p>or </p>\n\n<pre><code>year(x)\nmonth(x)\nday(x)\n</code></pre>\n" }, { ...
2009/02/12
[ "https://Stackoverflow.com/questions/542780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I need to group some records based on a date but it is a date and time field and I need to ignore the time part of is and just group by the date part - here is my SQL as it stands: ``` SELECT AutoShipItems.CustomerID,AutoShipItems.NextOrderDate, Customer.FirstName,Customer.LastName, Customer.EmailAddress FR...
You can group by this: ``` cast(floor(cast(AutoShipItems.NextOrderDate as float)) as datetime) ``` I put this into a scalar user-defined function to make it easier: ``` create function [dbo].[xfn_TrimTimeFromDateTime] ( @date as datetime ) returns datetime with schemabinding as begin --- Convert to a float,...
542,787
<p>In the following ruby code, the output becomes: "x y"</p> <pre><code>x = "x %s" y = "y" z = "z" print x % y %z </code></pre> <p>The %z is ignored. </p> <p>I want the output to be "x y z".</p> <p><strong>To understand the possibilities and limitations of the syntax of Ruby, I want to use only the print command an...
[ { "answer_id": 542806, "author": "krusty.ar", "author_id": 43981, "author_profile": "https://Stackoverflow.com/users/43981", "pm_score": 3, "selected": true, "text": "<p>I don't actually understand what you want to do, but: </p>\n\n<pre><code>irb(main):001:0&gt; x = \"x %s\"\n=&gt; \"x %...
2009/02/12
[ "https://Stackoverflow.com/questions/542787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the following ruby code, the output becomes: "x y" ``` x = "x %s" y = "y" z = "z" print x % y %z ``` The %z is ignored. I want the output to be "x y z". **To understand the possibilities and limitations of the syntax of Ruby, I want to use only the print command and the %s and % flags**. I know how to do this ...
I don't actually understand what you want to do, but: ``` irb(main):001:0> x = "x %s" => "x %s" irb(main):002:0> y = "y %s" => "y %s" irb(main):003:0> z = "z" => "z" irb(main):004:0> print x % y % z x y z=> nil ``` and: ``` irb(main):006:0> x = "x %s %s" => "x %s %s" irb(main):007:0> y = "y" => "y" irb(main):008:...
542,844
<h2>Edit:</h2> <p>The question follows the horizontal rule; my own answer precedes it.</p> <p><br></p> <p>Based on help from <a href="https://stackoverflow.com/users/20654/oscar-reyes">Oscar Reyes</a>, I crafted this solution:</p> <pre><code>import javax.swing.JOptionPane; import javax.swing.JFrame; public class M...
[ { "answer_id": 543012, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 6, "selected": true, "text": "<ul>\n<li>Can JOptionPane show up as a task on the taskbar?</li>\n</ul>\n\n<p>No</p>\n\n<ul>\n<li>If not, is there anythin...
2009/02/12
[ "https://Stackoverflow.com/questions/542844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43263/" ]
Edit: ----- The question follows the horizontal rule; my own answer precedes it. Based on help from [Oscar Reyes](https://stackoverflow.com/users/20654/oscar-reyes), I crafted this solution: ``` import javax.swing.JOptionPane; import javax.swing.JFrame; public class MyApp extends JFrame { public static void mai...
* Can JOptionPane show up as a task on the taskbar? No * If not, is there anything else that's a one-liner like JOptionPane.show[whatever]dialog()? Not exactly one liner ( but some extra 6 lines :P ) I bet you cam put all this in a utlity method pretty easy and call it whenever you need it with a single call. The...
542,845
<p>I'm trying to figure out how to rescue syntax errors that come up when <code>eval()</code>ing code in Ruby 1.8.6.</p> <p>I would expect the following Ruby code:</p> <pre><code>#!/usr/bin/ruby good_str = "(1+1)" bad_str = "(1+1" # syntax error: missing closing paren begin puts eval(good_str) puts eval(...
[ { "answer_id": 542857, "author": "Brent Chapman", "author_id": 13157, "author_profile": "https://Stackoverflow.com/users/13157", "pm_score": 7, "selected": true, "text": "<p>Well, that was easy...</p>\n\n<p>It turns out that, by default, the \"rescue\" statement does not catch <strong>al...
2009/02/12
[ "https://Stackoverflow.com/questions/542845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13157/" ]
I'm trying to figure out how to rescue syntax errors that come up when `eval()`ing code in Ruby 1.8.6. I would expect the following Ruby code: ``` #!/usr/bin/ruby good_str = "(1+1)" bad_str = "(1+1" # syntax error: missing closing paren begin puts eval(good_str) puts eval(bad_str) rescue => exc puts ...
Well, that was easy... It turns out that, by default, the "rescue" statement does not catch **all** exceptions, but only those that are subclasses of StandardError. SyntaxError is a sibling/cousin of StandardError, not a subclass of it, so the rescue statement doesn't capture it unless explicitly told to. To have the...
542,850
<p>Most of the examples I see say to put it on the clipboard and use paste, but that doesn't seem to be very good because it overwrites the clipboard.</p> <p>I did see <a href="http://www.codeproject.com/KB/edit/csexrichtextbox.aspx" rel="noreferrer">one method</a> that manually put the image into the RTF using a pinv...
[ { "answer_id": 568378, "author": "Sylverdrag", "author_id": 61905, "author_profile": "https://Stackoverflow.com/users/61905", "pm_score": 7, "selected": true, "text": "<p>The most straightforward way would be to modify the RTF code to insert the picture yourself. </p>\n\n<p>In RTF, a pic...
2009/02/12
[ "https://Stackoverflow.com/questions/542850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62055/" ]
Most of the examples I see say to put it on the clipboard and use paste, but that doesn't seem to be very good because it overwrites the clipboard. I did see [one method](http://www.codeproject.com/KB/edit/csexrichtextbox.aspx) that manually put the image into the RTF using a pinvoke to convert the image to a wmf. Is ...
The most straightforward way would be to modify the RTF code to insert the picture yourself. In RTF, a picture is defined like this: '{' \pict (brdr? & shading? & picttype & pictsize & metafileinfo?) data '}' A question mark indicates the control word is optional. "data" is simply the content of the file in hex for...
542,853
<p>In a virtual host in apache I would like to redirect all requests to <code>&lt;anything&gt;.mydomain.&lt;anything&gt;</code> to just <code>mydomain.com</code>.</p> <p>However, the below rewrite rule is ignored for some reason. Why?</p> <pre><code>RewriteCond %{REMOTE_HOST} ^.*mydomain.* RewriteRule ^(.*)$ http://...
[ { "answer_id": 568378, "author": "Sylverdrag", "author_id": 61905, "author_profile": "https://Stackoverflow.com/users/61905", "pm_score": 7, "selected": true, "text": "<p>The most straightforward way would be to modify the RTF code to insert the picture yourself. </p>\n\n<p>In RTF, a pic...
2009/02/12
[ "https://Stackoverflow.com/questions/542853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In a virtual host in apache I would like to redirect all requests to `<anything>.mydomain.<anything>` to just `mydomain.com`. However, the below rewrite rule is ignored for some reason. Why? ``` RewriteCond %{REMOTE_HOST} ^.*mydomain.* RewriteRule ^(.*)$ http://mydomain.com [R=301,L] ```
The most straightforward way would be to modify the RTF code to insert the picture yourself. In RTF, a picture is defined like this: '{' \pict (brdr? & shading? & picttype & pictsize & metafileinfo?) data '}' A question mark indicates the control word is optional. "data" is simply the content of the file in hex for...
542,856
<p>I'm trying to test a controller and I got this error. I understand the error, but don't know how to fix it.</p> <pre><code>test: on CREATE to :user with completely invalid email should respond with redirect (UsersControllerTest):ActionController::RedirectBackError: No HTTP_REFERER was set in the request to th...
[ { "answer_id": 542905, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 8, "selected": true, "text": "<p>Their recommendation translates to the following:</p>\n\n<pre><code>setup do\n @request.env['HTTP_REFERER'] = 'htt...
2009/02/12
[ "https://Stackoverflow.com/questions/542856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42595/" ]
I'm trying to test a controller and I got this error. I understand the error, but don't know how to fix it. ``` test: on CREATE to :user with completely invalid email should respond with redirect (UsersControllerTest):ActionController::RedirectBackError: No HTTP_REFERER was set in the request to this action, ...
Their recommendation translates to the following: ``` setup do @request.env['HTTP_REFERER'] = 'http://test.com/sessions/new' post :create, { :user => { :email => 'invalid@abc' } } end ```
542,875
<p>I have some code from my VB.NET 1.1 days that allowed me to dynamically check if Debug was enabled in web.config. I figured why re-invent the wheel in turning on/off logging if I could simply have the web administrator enable debug. Here is the code I used in VB.NET that worked just fine:</p> <pre><code>Configurat...
[ { "answer_id": 542896, "author": "driis", "author_id": 13627, "author_profile": "https://Stackoverflow.com/users/13627", "pm_score": 8, "selected": true, "text": "<p>Use:</p>\n\n<pre><code>HttpContext.Current.IsDebuggingEnabled\n</code></pre>\n\n<p>This property actually looks at the web...
2009/02/12
[ "https://Stackoverflow.com/questions/542875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51949/" ]
I have some code from my VB.NET 1.1 days that allowed me to dynamically check if Debug was enabled in web.config. I figured why re-invent the wheel in turning on/off logging if I could simply have the web administrator enable debug. Here is the code I used in VB.NET that worked just fine: ``` ConfigurationSettings.Get...
Use: ``` HttpContext.Current.IsDebuggingEnabled ``` This property actually looks at the web.config configuration setting. If you look at it using Reflector you will find that it gets the actual ConfigurationSection object using some internal classes.
542,877
<p>I'm using the ruby <a href="http://raa.ruby-lang.org/project/daemons/" rel="noreferrer">daemon</a> gem. Wondering how I can add some extra steps to the stop action? Was hoping I could detect stop was called, and add some extra code to it. Anyone know how I can accomplish this?</p>
[ { "answer_id": 543907, "author": "James Mead", "author_id": 2025138, "author_profile": "https://Stackoverflow.com/users/2025138", "pm_score": 4, "selected": true, "text": "<p>Looking at the daemon gem code, it doesn't look like it has an obvious extension point for this purpose. However,...
2009/02/12
[ "https://Stackoverflow.com/questions/542877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18933/" ]
I'm using the ruby [daemon](http://raa.ruby-lang.org/project/daemons/) gem. Wondering how I can add some extra steps to the stop action? Was hoping I could detect stop was called, and add some extra code to it. Anyone know how I can accomplish this?
Looking at the daemon gem code, it doesn't look like it has an obvious extension point for this purpose. However, I wonder if (in the daemonized process) you could trap the KILL/TERM signal that daemons sends when a 'stop' occurs...? ``` trap("TERM") do # execute your extra code here end ``` Alternatively you coul...