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
472,048
<p>I want every cell in each row except the last in each row. I tried:</p> <pre><code>$("table tr td:not(:last)") </code></pre> <p>but that seems to have given me every cell except the very last in the table. Not quite what I want.</p> <p>I'm sure this is simple but I'm still wrapping my head around the selectors....
[ { "answer_id": 472183, "author": "Ricardo Vega", "author_id": 53246, "author_profile": "https://Stackoverflow.com/users/53246", "pm_score": 6, "selected": true, "text": "<p>Try:</p>\n\n<pre><code>$('table tr td:not(:last-child)')\n</code></pre>\n" }, { "answer_id": 472185, "a...
2009/01/23
[ "https://Stackoverflow.com/questions/472048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
I want every cell in each row except the last in each row. I tried: ``` $("table tr td:not(:last)") ``` but that seems to have given me every cell except the very last in the table. Not quite what I want. I'm sure this is simple but I'm still wrapping my head around the selectors.
Try: ``` $('table tr td:not(:last-child)') ```
472,052
<p>Here is the domain that I wish to have:</p> <pre><code>public class Person { public int Id { get; set; } public IList&lt;AcquiredCertificate&gt; AcquiredCertificates { get; set; } } public class AcquiredCertificate { public Person Acquirer { get; set; } public Certificate Certificate { get; set; } ...
[ { "answer_id": 472061, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 0, "selected": false, "text": "<p>Your implementation is exactly correct. Your join table includes the two key fields (making a composite primary key for...
2009/01/23
[ "https://Stackoverflow.com/questions/472052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1894/" ]
Here is the domain that I wish to have: ``` public class Person { public int Id { get; set; } public IList<AcquiredCertificate> AcquiredCertificates { get; set; } } public class AcquiredCertificate { public Person Acquirer { get; set; } public Certificate Certificate { get; set; } public DateTime ...
By design, NHibernate only supports the implicit many-to-many mapping if there is absolutely NOTHING other than the pair of FKs represented in the intermediate (middle) table that holds the many-to-many relationship. Some time ago, Billy McCafferty blogged about this exact 'issue' (not really an issue since its BY DES...
472,053
<p>I've read a file, and stored its contents into a string array.</p> <p>I need to change some numerical values, interpreted as characters by the compiler.</p> <p>The file is of the format: ABCDE,EFGHIJ KLMNOPQRS,45.58867,122.59750</p> <p>I've searched and studied but haven't got onto anything too comprehensive.</p>...
[ { "answer_id": 472093, "author": "Whaledawg", "author_id": 23829, "author_profile": "https://Stackoverflow.com/users/23829", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://en.cppreference.com/w/cpp/io/basic_stringstream\" rel=\"nofollow noreferrer\"><code>std::stringstrea...
2009/01/23
[ "https://Stackoverflow.com/questions/472053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40120/" ]
I've read a file, and stored its contents into a string array. I need to change some numerical values, interpreted as characters by the compiler. The file is of the format: ABCDE,EFGHIJ KLMNOPQRS,45.58867,122.59750 I've searched and studied but haven't got onto anything too comprehensive. If someone can please tell...
[`std::stringstream`](http://en.cppreference.com/w/cpp/io/basic_stringstream) Learn to love it. Not istringstream, since you want to get output from it. Something like: ``` getline ( inFile, sBuffer ); stringstream myStream(sBuffer); string first, second, third; char comma; myStream >> first; myStream >> second; m...
472,059
<p>I am using a <code>dijit.form.FilteringSelect</code> backed by a <code>dojox.data.QueryReadStore</code> in order to allow the user to select a region (think "auto-complete" mechanism). On each character entered by the user, the <code>QueryReadStore</code> sends a request to the server, awaiting a json list of match...
[ { "answer_id": 500574, "author": "damelin", "author_id": 60158, "author_profile": "https://Stackoverflow.com/users/60158", "pm_score": 2, "selected": false, "text": "<p>I think I finally found the explanation for such behavior. In a few words, it happens due to unfulfillment of contract,...
2009/01/23
[ "https://Stackoverflow.com/questions/472059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53747/" ]
I am using a `dijit.form.FilteringSelect` backed by a `dojox.data.QueryReadStore` in order to allow the user to select a region (think "auto-complete" mechanism). On each character entered by the user, the `QueryReadStore` sends a request to the server, awaiting a json list of matching regions (with associated IDs). By...
I think I finally found the explanation for such behavior. In a few words, it happens due to unfulfillment of contract, which FilteringSelect expects from QueryReadStore. And as QueryReadStore totally relies on response from server module, which generates json, it could not fulfil contract due to unexpected response fr...
472,063
<p><em>LIKE</em> operator in MySql is used to find rows that contain our query text, for example:</p> <pre><code>select name from user where name like "%john%" </code></pre> <p>which will return <code>John Smith</code>, <code>Peter Johnson</code> etc.</p> <p>What if I need the opposite - to find rows that are <em>CO...
[ { "answer_id": 472124, "author": "Stepan Stolyarov", "author_id": 6573, "author_profile": "https://Stackoverflow.com/users/6573", "pm_score": -1, "selected": false, "text": "<p>This is a text indexing problem. If I get it right, your task is to find all references to people in a free-for...
2009/01/23
[ "https://Stackoverflow.com/questions/472063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128/" ]
*LIKE* operator in MySql is used to find rows that contain our query text, for example: ``` select name from user where name like "%john%" ``` which will return `John Smith`, `Peter Johnson` etc. What if I need the opposite - to find rows that are *CONTAINED* in our query text? For example I give it `John Smith and...
Here's a way you can achieve what you describe: ``` SELECT name FROM user WHERE 'John Smith and Peter Johnson are best friends' LIKE CONCAT('%', name, '%') ```
472,077
<p>So I was thinking one way that you can bring method chaining into PHP with the built-in global functions would be to "borrow" the |> (pipe) operator from F#. It would pipe the results on the left into the first parameter of the function on the right. Of course PHP would have to revisit the parameter order of some of...
[ { "answer_id": 472100, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 2, "selected": false, "text": "<p>I've never seen that annotation before, but it sure looks nice. Somehow reminds me of functional programming (maybe i...
2009/01/23
[ "https://Stackoverflow.com/questions/472077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
So I was thinking one way that you can bring method chaining into PHP with the built-in global functions would be to "borrow" the |> (pipe) operator from F#. It would pipe the results on the left into the first parameter of the function on the right. Of course PHP would have to revisit the parameter order of some of th...
It looks like what he wants is a String class with methods that mirror the builtin functions. This is a guess, but maybe you could use the \_\_call magic method to do the work like this: **(untested)** ``` class String { private $_value = ''; public function __construct($value) { $_value = $value; } ...
472,078
<p>What are the different or best ways I can implement a simple product dropdown in ASP.NET MVC, that redirect the user to a new product when they pick from the dropdown ?</p> <p>I have currently have my primary mapping rule :</p> <pre><code> routes.MapRoute( "Product", "Products/{sku}", ...
[ { "answer_id": 472141, "author": "Andrew Stanton-Nurse", "author_id": 29813, "author_profile": "https://Stackoverflow.com/users/29813", "pm_score": 0, "selected": false, "text": "<p>I think JavaScript is your only option here. The form tag can only submit to one URL, so if you want to a...
2009/01/23
[ "https://Stackoverflow.com/questions/472078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
What are the different or best ways I can implement a simple product dropdown in ASP.NET MVC, that redirect the user to a new product when they pick from the dropdown ? I have currently have my primary mapping rule : ``` routes.MapRoute( "Product", "Products/{sku}", new { co...
The problem arises because both your Route uses {sku} and your form field is called sku. The {sku} from the route supersedes the sku form field (it would seem). A (fairly pragmatic) solution could be to have them named differently, so your controller action would be something like: ``` public void ActionResult ViewPro...
472,079
<p>We have a C#/ASP.NET (2.0) application running on IIS 6 on Windows Server 2003 Enterprise Edition. This application reads Excel files using OleDb, but there are instances when we get an "Unspecified Error" exception thrown from within the application. </p> <p>The file is stored in the temporary directory by our fi...
[ { "answer_id": 472609, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 2, "selected": false, "text": "<p>I suspect the error is something to do with the venerable Jet OLEDB engine. It's fairly creaky - fine for most desktop things...
2009/01/23
[ "https://Stackoverflow.com/questions/472079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have a C#/ASP.NET (2.0) application running on IIS 6 on Windows Server 2003 Enterprise Edition. This application reads Excel files using OleDb, but there are instances when we get an "Unspecified Error" exception thrown from within the application. The file is stored in the temporary directory by our file upload c...
I suspect the error is something to do with the venerable Jet OLEDB engine. It's fairly creaky - fine for most desktop things but not much use for enterprise data interchange. If you can upgrade to a recent C# 3/.Net 3.5 you can use the `System.IO.Packaging` library to open Office 2007 files (.xlsx or .xlsm files). T...
472,083
<p>I am working on the billing component of a Ruby on Rails application using ActiveMerchant. The payment gateway we have chosen is <a href="http://paymentexpress.com" rel="nofollow noreferrer">PaymentExpress</a>.</p> <p>Code examples I am seeing such as the one below, use <code>authorize()</code> and <code>void()</co...
[ { "answer_id": 472609, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 2, "selected": false, "text": "<p>I suspect the error is something to do with the venerable Jet OLEDB engine. It's fairly creaky - fine for most desktop things...
2009/01/23
[ "https://Stackoverflow.com/questions/472083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56690/" ]
I am working on the billing component of a Ruby on Rails application using ActiveMerchant. The payment gateway we have chosen is [PaymentExpress](http://paymentexpress.com). Code examples I am seeing such as the one below, use `authorize()` and `void()` to test the validity of a card: ``` def test_card! auth_respon...
I suspect the error is something to do with the venerable Jet OLEDB engine. It's fairly creaky - fine for most desktop things but not much use for enterprise data interchange. If you can upgrade to a recent C# 3/.Net 3.5 you can use the `System.IO.Packaging` library to open Office 2007 files (.xlsx or .xlsm files). T...
472,090
<p>This is my situation, I was able to remove the spaces using trim or replace. But it does not remove the linefeed or newline at the end of each file. How can I remove the spaces and linefeed in C#?</p> <p>Thanks in advance.</p>
[ { "answer_id": 472099, "author": "idursun", "author_id": 5984, "author_profile": "https://Stackoverflow.com/users/5984", "pm_score": 3, "selected": false, "text": "<p>You can call Trim method with all characters that you want to be removed like:</p>\n\n<pre><code>line = line.Trim(' ','\\...
2009/01/23
[ "https://Stackoverflow.com/questions/472090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55700/" ]
This is my situation, I was able to remove the spaces using trim or replace. But it does not remove the linefeed or newline at the end of each file. How can I remove the spaces and linefeed in C#? Thanks in advance.
You can call Trim method with all characters that you want to be removed like: ``` line = line.Trim(' ','\r','\n'); ```
472,133
<p>I'm a C++ programmer thats considering using D for a personal project I want to play around with. I was wondering if there's a way to completely disable the garbage collector, and what the risks are of doing so. </p> <p>I know I can manage my own memory by overriding new and delete to use malloc and free, but if ...
[ { "answer_id": 472174, "author": "Tim Matthews", "author_id": 36157, "author_profile": "https://Stackoverflow.com/users/36157", "pm_score": 3, "selected": false, "text": "<p>If you want to use malloc and free use <a href=\"http://www.digitalmars.com/d/1.0/phobos/std_c_stdlib.html\" rel=\...
2009/01/23
[ "https://Stackoverflow.com/questions/472133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26983/" ]
I'm a C++ programmer thats considering using D for a personal project I want to play around with. I was wondering if there's a way to completely disable the garbage collector, and what the risks are of doing so. I know I can manage my own memory by overriding new and delete to use malloc and free, but if I did that I...
To turn off the GC in D2: ``` import core.memory; void main(string[] args) { GC.disable; // Do stuff. } ``` If using D1/Phobos: ``` import std.gc; void main(char[][] args) { std.gc.disable; // Do stuff. } ``` In D1/Tango: ``` import tango.core.Memory; void main(char[][] args) { GC.disable...
472,137
<p>I've a dictionary object:</p> <pre><code>Dictionary&lt;string, string[]&gt; dictCompanies = new Dictionary&lt;string, string[]&gt;(); </code></pre> <p>How do sort this object on its key?</p> <p>I tried using OrderBy like below, but it does no seem to work</p> <pre><code>dictCompanies .OrderByDescending(c=&gt; c....
[ { "answer_id": 472153, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>You can't sort an actual <a href=\"http://msdn.microsoft.com/en-us/library/xfhwa508.aspx\" rel=\"nofollow noreferrer\"...
2009/01/23
[ "https://Stackoverflow.com/questions/472137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40907/" ]
I've a dictionary object: ``` Dictionary<string, string[]> dictCompanies = new Dictionary<string, string[]>(); ``` How do sort this object on its key? I tried using OrderBy like below, but it does no seem to work ``` dictCompanies .OrderByDescending(c=> c.Key); ``` I'm binding this dictionary object to a checkb...
You can't sort an actual [`Dictionary<TKey,TValue>`](http://msdn.microsoft.com/en-us/library/xfhwa508.aspx) - the order items come out of it is basically determined by the internal implementation. You might want to look at [`SortedDictionary<TKey,TValue>`](http://msdn.microsoft.com/en-us/library/f7fta44c.aspx) and [`So...
472,168
<p>I am using the <code>Picker</code> controller with <code>UIImagePickerControllerSourceTypePhotoLibrary</code>.</p> <p>In the delegate <code>didFinishPickingImage</code> is called, but when I click on the cancel button it doesn't enter:</p> <pre><code>(void)imagePickerControllerDidCancel:(UIImagePickerController *)...
[ { "answer_id": 472187, "author": "Andrew Stanton-Nurse", "author_id": 29813, "author_profile": "https://Stackoverflow.com/users/29813", "pm_score": 0, "selected": false, "text": "<p>Unfortunately no, the only file-related HTML control is the file picker (&lt;input type=\"file\"&gt;).</p>...
2009/01/23
[ "https://Stackoverflow.com/questions/472168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55817/" ]
I am using the `Picker` controller with `UIImagePickerControllerSourceTypePhotoLibrary`. In the delegate `didFinishPickingImage` is called, but when I click on the cancel button it doesn't enter: ``` (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker ``` This happens even though the controller ...
No, you can't do with standart ASP.NET controls which map to HTML controls. Probably it's possible if you are using Flash, Silverlight or Java applets.
472,179
<p>How do I read the response headers returned from a PyCurl request?</p>
[ { "answer_id": 472243, "author": "bortzmeyer", "author_id": 15625, "author_profile": "https://Stackoverflow.com/users/15625", "pm_score": 6, "selected": true, "text": "<p>There are several solutions (by default, they are dropped). Here is an\nexample using the option HEADERFUNCTION which...
2009/01/23
[ "https://Stackoverflow.com/questions/472179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/473/" ]
How do I read the response headers returned from a PyCurl request?
There are several solutions (by default, they are dropped). Here is an example using the option HEADERFUNCTION which lets you indicate a function to handle them. Other solutions are options WRITEHEADER (not compatible with WRITEFUNCTION) or setting HEADER to True so that they are transmitted with the body. ``` #!/usr...
472,182
<p>I'm working on a XML-document with Groovy and test a node for a certain attribute, which has a namespace prefix. How could it work:</p> <p>in groovy-script:</p> <pre><code>... Element.Subelement.each { if (it.'@type'=='ns2:xyType') ...do what ever... } </code></pre> <p>in XML document:</p> <pre><code>&lt;...
[ { "answer_id": 477093, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 2, "selected": false, "text": "<p>Well, your document is a little confusing, since it seems that neither xsi nor ns2 namespaces were ever declared, ...
2009/01/23
[ "https://Stackoverflow.com/questions/472182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm working on a XML-document with Groovy and test a node for a certain attribute, which has a namespace prefix. How could it work: in groovy-script: ``` ... Element.Subelement.each { if (it.'@type'=='ns2:xyType') ...do what ever... } ``` in XML document: ``` <Element> <Subelement xsi:type="ns2:xyType"> ...
Well, your document is a little confusing, since it seems that neither xsi nor ns2 namespaces were ever declared, but I'm going to assume they were declared somewhere in the complete doc. From [The Groovy Docs](http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlSlurper) ``` def wsdl = ''' <definitions name="A...
472,212
<p>Hi I have a unmanaged function that takes a chunk of memory allocated by malloc and deallocates it later on in async manner. I want to wrap it into managed wrapper. Is following code OK?</p> <pre><code>void managed_fx (byte data __gc[], size_t size) { // Pin the data byte __pin *pinned_data = &amp;data [0]...
[ { "answer_id": 472240, "author": "Spence", "author_id": 53771, "author_profile": "https://Stackoverflow.com/users/53771", "pm_score": 0, "selected": false, "text": "<p>you need to test your malloc that it actually has allocated your pointer.\nDon't know C++/CLI so I don't know if your pi...
2009/01/23
[ "https://Stackoverflow.com/questions/472212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi I have a unmanaged function that takes a chunk of memory allocated by malloc and deallocates it later on in async manner. I want to wrap it into managed wrapper. Is following code OK? ``` void managed_fx (byte data __gc[], size_t size) { // Pin the data byte __pin *pinned_data = &data [0]; // Copy da...
My MC++ is a little rusty, but I think \_\_pin pins the source variable until "pinned\_data" goes out of scope (at least, that's what the equivalent pin\_ptr in C++/CLI does). You should generally un-pin it as soon as possible, i.e. you shouldn't call fx in the same scope for performance reasons. > > Is pinning neces...
472,234
<p>I have a Flash movie embeded in a Windows Form (using the component "Shockwave Flash Object included with Visual Studio 8). The Flash movie was created with Flash CS4 and uses ActionScript 3.</p> <p>Is it possible to use C# to call an ActionScript function in the Flash movie that returns a value?</p> <p>Also, is i...
[ { "answer_id": 472309, "author": "James Hay", "author_id": 47339, "author_profile": "https://Stackoverflow.com/users/47339", "pm_score": 1, "selected": false, "text": "<p>ExternalInterface.addCallback(functionName:String, closure:Function):void registers an actionscript method to be call...
2009/01/23
[ "https://Stackoverflow.com/questions/472234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a Flash movie embeded in a Windows Form (using the component "Shockwave Flash Object included with Visual Studio 8). The Flash movie was created with Flash CS4 and uses ActionScript 3. Is it possible to use C# to call an ActionScript function in the Flash movie that returns a value? Also, is it possible for my...
In order to make an ActionScript function callable from your Flash player's host, you have to use the ExternalInterface.addCallback function, for example: ``` ExternalInterface.addCallback("testCallback", function (text : String) : String { var helloText : String = "Hello, " + text; myTextField.text = helloTex...
472,252
<p>I have a set of .EXE commands. How do I get all those commands run in Perl as a single file? Whats the process to call the .EXE files in Perl?</p>
[ { "answer_id": 472254, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "<p>The Perl <a href=\"http://perldoc.perl.org/functions/system.html\" rel=\"nofollow noreferrer\"><code>system()</code></a...
2009/01/23
[ "https://Stackoverflow.com/questions/472252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45284/" ]
I have a set of .EXE commands. How do I get all those commands run in Perl as a single file? Whats the process to call the .EXE files in Perl?
The Perl [`system()`](http://perldoc.perl.org/functions/system.html) function will do this: ``` #!/usr/bin/perl -w system("prog1.exe"); system("prog2.exe"); ```
472,259
<p>I'm trying to do something when a user selects an option from a select box - As simple as can be right? I'm using JQuery 1.3.1 to register a click handler with the id of the select box. Everything was fine until I tested using Chrome and Safari and found it didn't work.</p> <ol> <li>Firefox 3.05 - YES</li> <li>I.E ...
[ { "answer_id": 472268, "author": "Tom", "author_id": 42754, "author_profile": "https://Stackoverflow.com/users/42754", "pm_score": 4, "selected": true, "text": "<p>I found my problem. For Select boxes, you need to register a handler for a \"change\" event rather than a \"click\" event. I...
2009/01/23
[ "https://Stackoverflow.com/questions/472259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42754/" ]
I'm trying to do something when a user selects an option from a select box - As simple as can be right? I'm using JQuery 1.3.1 to register a click handler with the id of the select box. Everything was fine until I tested using Chrome and Safari and found it didn't work. 1. Firefox 3.05 - YES 2. I.E 7.0.5730.13 - YES 3...
I found my problem. For Select boxes, you need to register a handler for a "change" event rather than a "click" event. It's strange that Firefox and IE work with the click event. To sum up, the following code works across all browsers: ``` <html> <head> <script language="javascript" type="text/javascript" src="ht...
472,262
<p>I have a problem which is perfectly described here (<a href="http://www.bokebb.com/dev/english/1972/posts/197270504.shtml" rel="nofollow noreferrer">http://www.bokebb.com/dev/english/1972/posts/197270504.shtml</a>):</p> <p>Scenario:</p> <p>Windows smart client app and the CrystalReportViewer for windows. Using Ser...
[ { "answer_id": 472268, "author": "Tom", "author_id": 42754, "author_profile": "https://Stackoverflow.com/users/42754", "pm_score": 4, "selected": true, "text": "<p>I found my problem. For Select boxes, you need to register a handler for a \"change\" event rather than a \"click\" event. I...
2009/01/23
[ "https://Stackoverflow.com/questions/472262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32582/" ]
I have a problem which is perfectly described here (<http://www.bokebb.com/dev/english/1972/posts/197270504.shtml>): Scenario: Windows smart client app and the CrystalReportViewer for windows. Using ServerFileReports to access reports through a centralized and disconnected folder location. When accessing a report wh...
I found my problem. For Select boxes, you need to register a handler for a "change" event rather than a "click" event. It's strange that Firefox and IE work with the click event. To sum up, the following code works across all browsers: ``` <html> <head> <script language="javascript" type="text/javascript" src="ht...
472,275
<p>I've made a very simple MEF sample which runs on .NET, but doesn't work properly on Mono.</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.ComponentModel.Composition; namespace Vialis { class Program { [Import(typeof(ILedController))] public Lis...
[ { "answer_id": 472293, "author": "TheCodeJunkie", "author_id": 25319, "author_profile": "https://Stackoverflow.com/users/25319", "pm_score": 2, "selected": false, "text": "<p>So I'm assuming that the exports are defined in external assemblies, because you use the DirectoryPartCatalog.. e...
2009/01/23
[ "https://Stackoverflow.com/questions/472275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28149/" ]
I've made a very simple MEF sample which runs on .NET, but doesn't work properly on Mono. ``` using System; using System.Collections.Generic; using System.Text; using System.ComponentModel.Composition; namespace Vialis { class Program { [Import(typeof(ILedController))] public List<ILedControll...
With the latest MEF release (Preview 4 - <http://www.codeplex.com/MEF>) it works just fine! Since the bug is no longer relevant I voted to close this question.
472,282
<p>Is there a way to show the console in a Windows application?</p> <p>I want to do something like this:</p> <pre><code>static class Program { [STAThread] static void Main(string[] args) { bool consoleMode = Boolean.Parse(args[0]); if (consoleMode) { Console.WriteLine("consolemode...
[ { "answer_id": 472286, "author": "Igal Serban", "author_id": 25737, "author_profile": "https://Stackoverflow.com/users/25737", "pm_score": 7, "selected": true, "text": "<p>What you want to do is not possible in a sane way. There was a similar question <a href=\"https://stackoverflow.com/...
2009/01/23
[ "https://Stackoverflow.com/questions/472282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52418/" ]
Is there a way to show the console in a Windows application? I want to do something like this: ``` static class Program { [STAThread] static void Main(string[] args) { bool consoleMode = Boolean.Parse(args[0]); if (consoleMode) { Console.WriteLine("consolemode started"); ...
What you want to do is not possible in a sane way. There was a similar question [so look at the answers](https://stackoverflow.com/questions/338951/output-to-command-line-if-started-from-command-line#339216). Then there's also an [insane approach](http://www.rootsilver.com/2007/08/how-to-create-a-consolewindow) (site ...
472,313
<p>I am trying to get an address based on the long/lat. it appears that something like this should work? </p> <pre><code>Geocoder myLocation = Geocoder(Locale.getDefault()); List myList = myLocation.getFromLocation(latPoint,lngPoint,1); </code></pre> <p>The issue is that I keep getting : The method Geocoder(Local...
[ { "answer_id": 472463, "author": "Reto Meier", "author_id": 822, "author_profile": "https://Stackoverflow.com/users/822", "pm_score": 5, "selected": false, "text": "<p>It looks like there's two things happening here.</p>\n\n<p>1) You've missed the <code>new</code> keyword from before cal...
2009/01/23
[ "https://Stackoverflow.com/questions/472313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/393258/" ]
I am trying to get an address based on the long/lat. it appears that something like this should work? ``` Geocoder myLocation = Geocoder(Locale.getDefault()); List myList = myLocation.getFromLocation(latPoint,lngPoint,1); ``` The issue is that I keep getting : The method Geocoder(Locale) is undefined for the ty...
The following code snippet is doing it for me (lat and lng are doubles declared above this bit): ``` Geocoder geocoder = new Geocoder(this, Locale.getDefault()); List<Address> addresses = geocoder.getFromLocation(lat, lng, 1); ```
472,325
<p>I'm looking for the fastest way of counting the number of bit transitions in an <code>unsigned int</code>.</p> <p>If the int contains: <code>0b00000000000000000000000000001010</code></p> <p>The number of transitions are: 4</p> <p>If the int contains: <code>0b00000000000000000000000000001001</code></p> <p>The n...
[ { "answer_id": 472331, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 0, "selected": false, "text": "<p>What language?</p>\n\n<p>I would loop 64 times and then bit shift your number to inspect of the bits, then store the pr...
2009/01/23
[ "https://Stackoverflow.com/questions/472325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46583/" ]
I'm looking for the fastest way of counting the number of bit transitions in an `unsigned int`. If the int contains: `0b00000000000000000000000000001010` The number of transitions are: 4 If the int contains: `0b00000000000000000000000000001001` The number of transitions are: 3 Language is C.
``` int numTransitions(int a) { int b = a >> 1; // sign-extending shift properly counts bits at the ends int c = a ^ b; // xor marks bits that are not the same as their neighbors on the left return CountBits(c); // count number of set bits in c } ``` For an efficient implementation of [CountBits](http://graphi...
472,326
<p>I have a simple question about Java's XML API and I hope there's a simple answer too:</p> <p>Lets say that after processing I have the following XML output:</p> <pre><code>&lt;a&gt; &lt;b&gt;&lt;c&gt; &lt;d&gt; &lt;e&gt; some content &lt;/e&gt; &lt;/d&gt; &lt;/c&gt; &lt;/b&gt; &lt;/a&gt; ...
[ { "answer_id": 472360, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/Transformer.html\" rel=\"nofollow noreferrer\">T...
2009/01/23
[ "https://Stackoverflow.com/questions/472326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44523/" ]
I have a simple question about Java's XML API and I hope there's a simple answer too: Lets say that after processing I have the following XML output: ``` <a> <b><c> <d> <e> some content </e> </d> </c> </b> </a> ``` The structure is correct but whitespaces are all over the place. The questi...
Use [Transformer](http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/Transformer.html).[setOutputProperty](http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/Transformer.html#setOutputProperty(java.lang.String,%20java.lang.String))([OutputKeys](http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transfo...
472,351
<p>I'm designing a client-server chat application (in fact I'm not, but let's pretend I am:)), and I'm a bit puzzled by some race conditions I've experienced.</p> <p>Let's say I've got the following code:</p> <pre><code>public interface IServer { [OperationContract(IsOneWay = false)] [FaultContract(typeof(ChatExc...
[ { "answer_id": 472364, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>It sounds like a deadlock, perhaps due to the sync-context. What is the client? Winform? WPF? WCF respects sync-con...
2009/01/23
[ "https://Stackoverflow.com/questions/472351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47341/" ]
I'm designing a client-server chat application (in fact I'm not, but let's pretend I am:)), and I'm a bit puzzled by some race conditions I've experienced. Let's say I've got the following code: ``` public interface IServer { [OperationContract(IsOneWay = false)] [FaultContract(typeof(ChatException))] void Broa...
It sounds like a deadlock, perhaps due to the sync-context. What is the client? Winform? WPF? WCF respects sync-context, which means "switch to the UI thread" for winforms and WPF. If you are **making** the blocking request on the UI thread, then game over. Try performing your WCF request on a background thread, so th...
472,362
<p>If I declare a variable const char ** stringTable, how should I be able to put values to it if it is a const? (It has to be const because a function I am supposed to use takes const char ** as a parameter.)</p> <p>Edit: No you cannot convert from char ** to const char ** implicitly. Compiler complains: cannot conve...
[ { "answer_id": 472369, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 2, "selected": false, "text": "<p>That const declaration is a quarantee of the function, you dont have to fullfill it. That means the function will keep yo...
2009/01/23
[ "https://Stackoverflow.com/questions/472362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I declare a variable const char \*\* stringTable, how should I be able to put values to it if it is a const? (It has to be const because a function I am supposed to use takes const char \*\* as a parameter.) Edit: No you cannot convert from char \*\* to const char \*\* implicitly. Compiler complains: cannot convert...
Wow, I'm surprised nobody got this! Maybe I can get a necromancer badge. Implicit const casting only scans one level deep. So a `char*` can become a `const char*` but it won't dig deep enough inside the a `char**` type to find what needs to be changed to make it a `const char**`. ``` #include <iostream> using namespac...
472,384
<p>I'm trying to convert an Enum array to an int array:</p> <pre><code>public enum TestEnum { Item1, Item2 } int[] result = Array.ConvertAll&lt;TestEnum, int&gt;(enumArray, new Converter&lt;TestEnum, int&gt;(Convert.ToInt32)); </code></pre> <p>For some reason Convert.ToInt32 doesn't work when used in Array.ConvertAl...
[ { "answer_id": 472390, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "<p>Just cast using an anonymous method:</p>\n\n<pre><code>int[] result = Array.ConvertAll&lt;TestEnum, int&gt;(\n e...
2009/01/23
[ "https://Stackoverflow.com/questions/472384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676066/" ]
I'm trying to convert an Enum array to an int array: ``` public enum TestEnum { Item1, Item2 } int[] result = Array.ConvertAll<TestEnum, int>(enumArray, new Converter<TestEnum, int>(Convert.ToInt32)); ``` For some reason Convert.ToInt32 doesn't work when used in Array.ConvertAll, so I had to make some changes: ```...
Just cast using an anonymous method: ``` int[] result = Array.ConvertAll<TestEnum, int>( enumArray, delegate(TestEnum value) {return (int) value;}); ``` or with C# 3.0, a lambda: ``` int[] result = Array.ConvertAll(enumArray, value => (int) value); ```
472,389
<p>I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.scrolleventtype.aspx" rel="noreferrer">the MSDN document...
[ { "answer_id": 767603, "author": "Simon", "author_id": 15371, "author_profile": "https://Stackoverflow.com/users/15371", "pm_score": 4, "selected": true, "text": "<pre><code>using System.Reflection;\nusing System.Windows.Forms;\n\nbool addScrollListener(DataGridView dgv)\n{\n bool ret...
2009/01/23
[ "https://Stackoverflow.com/questions/472389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
I have a DataGridView, and I'm listening to its Scroll event. This gives me a ScrollEventArgs object whose Type member is supposed to tell me the type of scroll event that has occurred. On [the MSDN documentation page](http://msdn.microsoft.com/en-us/library/system.windows.forms.scrolleventtype.aspx) it says I should b...
``` using System.Reflection; using System.Windows.Forms; bool addScrollListener(DataGridView dgv) { bool ret = false; Type t = dgv.GetType(); PropertyInfo pi = t.GetProperty("VerticalScrollBar", BindingFlags.Instance | BindingFlags.NonPublic); ScrollBar s = null; if (pi != null) s = pi.Ge...
472,391
<p>Can WWF handle high throughput scenarios where several dozen records are 'actively' being processed in parallel at any one time?</p> <p>We want to build a workflow process which handles a few thousand records per hour. Each record takes up to a minute to process, because it makes external web service calls.</p> <p...
[ { "answer_id": 767603, "author": "Simon", "author_id": 15371, "author_profile": "https://Stackoverflow.com/users/15371", "pm_score": 4, "selected": true, "text": "<pre><code>using System.Reflection;\nusing System.Windows.Forms;\n\nbool addScrollListener(DataGridView dgv)\n{\n bool ret...
2009/01/23
[ "https://Stackoverflow.com/questions/472391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58236/" ]
Can WWF handle high throughput scenarios where several dozen records are 'actively' being processed in parallel at any one time? We want to build a workflow process which handles a few thousand records per hour. Each record takes up to a minute to process, because it makes external web service calls. We are testing W...
``` using System.Reflection; using System.Windows.Forms; bool addScrollListener(DataGridView dgv) { bool ret = false; Type t = dgv.GetType(); PropertyInfo pi = t.GetProperty("VerticalScrollBar", BindingFlags.Instance | BindingFlags.NonPublic); ScrollBar s = null; if (pi != null) s = pi.Ge...
472,393
<p>Some time ago I wrote a little piece of code to ask about on interviews and see how people understand concepts of cache and memory:</p> <pre><code>#include "stdafx.h" #include &lt;stdlib.h&gt; #include &lt;windows.h&gt; #include &lt;iostream&gt; #define TOTAL 0x20000000 using namespace std; __int64 count(int INN...
[ { "answer_id": 472399, "author": "Anteru", "author_id": 39912, "author_profile": "https://Stackoverflow.com/users/39912", "pm_score": 4, "selected": true, "text": "<p>Probably because 64 is the cache line size on your machine, and you basically run each iteration fully out of a single ca...
2009/01/23
[ "https://Stackoverflow.com/questions/472393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55159/" ]
Some time ago I wrote a little piece of code to ask about on interviews and see how people understand concepts of cache and memory: ``` #include "stdafx.h" #include <stdlib.h> #include <windows.h> #include <iostream> #define TOTAL 0x20000000 using namespace std; __int64 count(int INNER, int OUTER) { int a = 0; ...
Probably because 64 is the cache line size on your machine, and you basically run each iteration fully out of a single cache line.
472,418
<p>Just curious: </p> <ul> <li>4 instanceof Number => false</li> <li>new Number(4) instanceof Number => true?</li> </ul> <p>Why is this? Same with strings: </p> <ul> <li><code>'some string' instanceof String</code> returns false</li> <li><code>new String('some string') instanceof String</code> => true</li> <li><code...
[ { "answer_id": 472427, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 7, "selected": true, "text": "<p><code>value instanceof Constructor</code> is the same as <code>Constructor.prototype.isPrototypeOf(value)</code> and b...
2009/01/23
[ "https://Stackoverflow.com/questions/472418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58186/" ]
Just curious: * 4 instanceof Number => false * new Number(4) instanceof Number => true? Why is this? Same with strings: * `'some string' instanceof String` returns false * `new String('some string') instanceof String` => true * `String('some string') instanceof String` also returns false * `('some string').toStrin...
`value instanceof Constructor` is the same as `Constructor.prototype.isPrototypeOf(value)` and both check the [[Prototype]]-chain of `value` for occurences of a specific object. Strings and numbers are **primitive values**, not objects and therefore don't have a [[Prototype]], so it'll only work if you wrap them in r...
472,428
<p>I have an image with two points, aligned something like this:</p> <pre><code>|----------------| | | | . | | | | . | | | |----------------| </code></pre> <p>I have both X, Y coordinates for both points and I need to rotate the image X degrees so...
[ { "answer_id": 472455, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 2, "selected": false, "text": "<p>You need to look up geometric rotation matrices: <a href=\"http://mathworld.wolfram.com/RotationMatrix.html\" rel=\"nofollo...
2009/01/23
[ "https://Stackoverflow.com/questions/472428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/452521/" ]
I have an image with two points, aligned something like this: ``` |----------------| | | | . | | | | . | | | |----------------| ``` I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instea...
It depends on which point you want to use as a "center" for your rotation. Let's call the point to the up and left pointA and the one to the right and below pointB. If you want to rotate around the point A so that point B aligns with it, calculating the rotation angle in radians would go like this: ``` double angle = ...
472,431
<p>I'm working on a multi-threaded Silverlight application.</p> <p>The application has two threads: Main/UI and a background working thread.</p> <p>The UI thread should be able to kill the background thread, like so:</p> <pre><code>private Thread executionThread; .... executionThread = new Thread(ExecuteStart); ex...
[ { "answer_id": 472470, "author": "Davy Landman", "author_id": 11098, "author_profile": "https://Stackoverflow.com/users/11098", "pm_score": 2, "selected": false, "text": "<p>It's documented, see <a href=\"http://msdn.microsoft.com/en-us/library/ty8d3wta(VS.95).aspx\" rel=\"nofollow noref...
2009/01/23
[ "https://Stackoverflow.com/questions/472431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2721/" ]
I'm working on a multi-threaded Silverlight application. The application has two threads: Main/UI and a background working thread. The UI thread should be able to kill the background thread, like so: ``` private Thread executionThread; .... executionThread = new Thread(ExecuteStart); executionThread.Start(); .......
Rather than creating a Thread manually for this purpose you might want to consider using the [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(VS.95).aspx) class. This class has built in functionality for cancelling the asynchronous operation when WorkerSupportsCancellat...
472,441
<p>i have a function which retrieves values from a webservice , then loops through the returned values and for each returned value does another webservice lookup.</p> <p>Im having a problem however that when i make the second webservice call within the for loop that the function does not wait for the reuslt and just k...
[ { "answer_id": 472635, "author": "Simon Groenewolt", "author_id": 31884, "author_profile": "https://Stackoverflow.com/users/31884", "pm_score": 1, "selected": false, "text": "<p>As far as I know flex/as3 cannot do a blocking wait for the result - you have to add a listener and wait to be...
2009/01/23
[ "https://Stackoverflow.com/questions/472441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
i have a function which retrieves values from a webservice , then loops through the returned values and for each returned value does another webservice lookup. Im having a problem however that when i make the second webservice call within the for loop that the function does not wait for the reuslt and just keeps proce...
The documentation [here](http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_3.html) indicates that you do not call the Web service directly, you need to set up an event listener and handle the response on completed delivery. From the section "Calling web services in ActionScript": ``` <?xml version="...
472,450
<p>How do you create and send emails from Rails application, that contain images and proper formatting? like the ones you get from facebook and like.</p>
[ { "answer_id": 472898, "author": "Bo Jeanes", "author_id": 56690, "author_profile": "https://Stackoverflow.com/users/56690", "pm_score": 6, "selected": true, "text": "<p>Assuming you know how to send normal plain-text emails from Rails using ActionMailer, to get <code>HTML</code> emails ...
2009/01/23
[ "https://Stackoverflow.com/questions/472450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356145/" ]
How do you create and send emails from Rails application, that contain images and proper formatting? like the ones you get from facebook and like.
Assuming you know how to send normal plain-text emails from Rails using ActionMailer, to get `HTML` emails working you need to set a content type for your email. For example, your notifer might look like this: ``` class MyMailer < ActionMailer::Base def signup_notification(recipient) recipients recipient.emai...
472,456
<p>Can I access Subversion and <code>ssh://someAddress</code> by a web browser?</p>
[ { "answer_id": 472898, "author": "Bo Jeanes", "author_id": 56690, "author_profile": "https://Stackoverflow.com/users/56690", "pm_score": 6, "selected": true, "text": "<p>Assuming you know how to send normal plain-text emails from Rails using ActionMailer, to get <code>HTML</code> emails ...
2009/01/23
[ "https://Stackoverflow.com/questions/472456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can I access Subversion and `ssh://someAddress` by a web browser?
Assuming you know how to send normal plain-text emails from Rails using ActionMailer, to get `HTML` emails working you need to set a content type for your email. For example, your notifer might look like this: ``` class MyMailer < ActionMailer::Base def signup_notification(recipient) recipients recipient.emai...
472,460
<p>Does anyone know, please, if there's a way to specify "this machine" in a file path that SQL Server will like?</p> <p>I have an Agent job I want to script onto all my servers. It outputs to a file on the local machine so I want to script the file name as </p> <pre><code>\\localhost\&lt;shared-folder-name&gt;\&lt;f...
[ { "answer_id": 473049, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 1, "selected": false, "text": "<p>have you tried @@SERVERNAME?</p>\n\n<pre><code>SELECT @@SERVERNAME\n</code></pre>\n\n<p>Or you can use this, the second o...
2009/01/23
[ "https://Stackoverflow.com/questions/472460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43631/" ]
Does anyone know, please, if there's a way to specify "this machine" in a file path that SQL Server will like? I have an Agent job I want to script onto all my servers. It outputs to a file on the local machine so I want to script the file name as ``` \\localhost\<shared-folder-name>\<file-name> ``` Another reason...
have you tried @@SERVERNAME? ``` SELECT @@SERVERNAME ``` Or you can use this, the second one you can use if you have multiple instances of SQl server running ``` SELECT serverproperty('MachineName'),serverproperty('Instancename') ```
472,478
<p>Is there any way to make some sections of the web.config file only apply to a single file (or directory, or a group of files, etc.)</p> <p>Basically I would like to apply the following thing only to a single page in the application, the rest should use the default settings: (it limits the upload size to 32M)</p> <...
[ { "answer_id": 472487, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 2, "selected": false, "text": "<p>You can place a web.config file on any directory of your web application, what you define there will only work for that ...
2009/01/23
[ "https://Stackoverflow.com/questions/472478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
Is there any way to make some sections of the web.config file only apply to a single file (or directory, or a group of files, etc.) Basically I would like to apply the following thing only to a single page in the application, the rest should use the default settings: (it limits the upload size to 32M) ``` <system.web...
You can use: ``` <location path="UploadPage.aspx"> <system.web> <httpRuntime maxRequestLength="33554432" executionTimeout="360" /> </system.web> </location> ``` More info [here](http://msdn.microsoft.com/en-us/library/b6x6shw7.aspx).
472,485
<p>I want to have a standard method of formatting "Show More" links in my HTML pages.</p> <p>In HTML I use:</p> <pre><code>&lt;span class="showMore"&gt;Show more details&lt;/span&gt; </code></pre> <p>Then in the css, I have:</p> <pre class="lang-css prettyprint-override"><code>.showMore { color: #0E4B82; pa...
[ { "answer_id": 472528, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 0, "selected": false, "text": "<p>Does </p>\n\n<pre><code>display: block;\nheight: 16px;\n</code></pre>\n\n<p>Help fix the height of the span?</p>\n...
2009/01/23
[ "https://Stackoverflow.com/questions/472485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42754/" ]
I want to have a standard method of formatting "Show More" links in my HTML pages. In HTML I use: ``` <span class="showMore">Show more details</span> ``` Then in the css, I have: ```css .showMore { color: #0E4B82; padding-left: 18px; background: url("images/icons/add.png") no-repeat 0px 0px; } .showMo...
I've solved the problem. I've no idea why but using `no-repeat center left` instead of `no-repeat top left` ensures IE doesn't chop off the bottom 2px of the icon. Why using `center` instead of `top` should result in the image being higher is strange but that's IE for you?? ```css .showMore { color: #0E4B82; p...
472,496
<p>I need some help ... I'm a bit (read total) n00b when it comes to regular expressions, and need some help writing one to find a specific piece of text contained within a specific HTML tag from PHP.</p> <p>The source string looks like this:</p> <pre><code>&lt;span lang="en"&gt;English Content&lt;/span&gt;&lt;span l...
[ { "answer_id": 472512, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "<p>There are plenty of HTML parsers available for PHP. I suggest you check out one of those, (for example: <a href=\"http:/...
2009/01/23
[ "https://Stackoverflow.com/questions/472496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4309/" ]
I need some help ... I'm a bit (read total) n00b when it comes to regular expressions, and need some help writing one to find a specific piece of text contained within a specific HTML tag from PHP. The source string looks like this: ``` <span lang="en">English Content</span><span lang="fr">French content</span> ... e...
There are plenty of HTML parsers available for PHP. I suggest you check out one of those, (for example: [PHP Simple HTML DOM Parser](http://sourceforge.net/projects/simplehtmldom/)). Shooting yourself in the foot with trying to read HTML with regex is a lot easier than you think, and a lot harder to avoid than you wis...
472,500
<p>For simplicity, i have the following file named test.jsp:</p> <pre><code>&lt;script language="javascript"&gt; alert("a$b".replace(/\$/g,"k")); &lt;/script&gt; </code></pre> <p>I put this file in my local server, then display it using firefox: <a href="http://localhost:8080/myproj/test.jsp" rel="nofollow noref...
[ { "answer_id": 472573, "author": "Peter Štibraný", "author_id": 47190, "author_profile": "https://Stackoverflow.com/users/47190", "pm_score": 4, "selected": true, "text": "<p>JSP 2.0 Spec says: \"When EL evaluation is disabled, \\$ will not be recognized as a quote, whereas when EL evalu...
2009/01/23
[ "https://Stackoverflow.com/questions/472500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54060/" ]
For simplicity, i have the following file named test.jsp: ``` <script language="javascript"> alert("a$b".replace(/\$/g,"k")); </script> ``` I put this file in my local server, then display it using firefox: <http://localhost:8080/myproj/test.jsp>. It works okay, the result alert string is: ``` akb ``` But wh...
JSP 2.0 Spec says: "When EL evaluation is disabled, \$ will not be recognized as a quote, whereas when EL evaluation is enabled, \$ will be recognized as a quote for $." (JSP.3.3.2) Whether EL Evaluation is enabled or disabled depends on many things: * if application server supports JSP 2.0 (Tomcat 5.0 and higher doe...
472,516
<p>When data binding two elements together, how can I include the binding information AND text as in the case below where I want my label to say:</p> <p>The font size is 8.5</p> <pre><code>&lt;Grid&gt; &lt;StackPanel&gt; &lt;Slider Name="theSlider" Margin="5" Minimum="8" Maximum="14"&gt;&lt;/Slider&gt; ...
[ { "answer_id": 472536, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 0, "selected": false, "text": "<p>Use a IValueConverter for the Font-Size.. and use 2 label objects to split the string...</p>\n\n<p>HTH</p>\n" }, { ...
2009/01/23
[ "https://Stackoverflow.com/questions/472516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
When data binding two elements together, how can I include the binding information AND text as in the case below where I want my label to say: The font size is 8.5 ``` <Grid> <StackPanel> <Slider Name="theSlider" Margin="5" Minimum="8" Maximum="14"></Slider> <Label Content="The font size is: {Bind...
Something i learned only a couple of days ago here on stackoverflow :) If you're using 3.5 SP1 you can use the StringFormat property in your Binding: <http://blogs.msdn.com/llobo/archive/2008/05/19/wpf-3-5-sp1-feature-stringformat.aspx>
472,522
<p>so, problem is when we are showing to user created document in JasperReport Dialog. User can press print icon and sent it to printer. </p> <p>It seems to take too much resources on client's computer on all three levels: creating report, showing report on screen and sending it to printer. One example PC is AMD Duron...
[ { "answer_id": 472532, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 1, "selected": false, "text": "<p>Well Jasper Reports is simply a jar so you need to be more specific: are you running JasperReports in a Web app (on Tomc...
2009/01/23
[ "https://Stackoverflow.com/questions/472522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
so, problem is when we are showing to user created document in JasperReport Dialog. User can press print icon and sent it to printer. It seems to take too much resources on client's computer on all three levels: creating report, showing report on screen and sending it to printer. One example PC is AMD Duron 800MHz wi...
Excessive use of subreports can increase resource demands for a report. Each subreport spawns its own thread during fill time. Also if you are using scriptlets or helpers classes ensure all resources they create are being properly cleaned up. Also ensure you are using the latest JR package. One note. The JR api includ...
472,535
<p>HI,</p> <p>I am trying to convert the following vba code to c# and i am facing some errors.Hope someone can help me</p> <p>vba code</p> <pre><code> Open "C:\testfile.txt" For Input As #1 varii = "" Do While Not EOF(1) Line Input #1, strField varii = varii &amp; "," &amp; strFiel...
[ { "answer_id": 472532, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 1, "selected": false, "text": "<p>Well Jasper Reports is simply a jar so you need to be more specific: are you running JasperReports in a Web app (on Tomc...
2009/01/23
[ "https://Stackoverflow.com/questions/472535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
HI, I am trying to convert the following vba code to c# and i am facing some errors.Hope someone can help me vba code ``` Open "C:\testfile.txt" For Input As #1 varii = "" Do While Not EOF(1) Line Input #1, strField varii = varii & "," & strField Loop Close #1 ...
Excessive use of subreports can increase resource demands for a report. Each subreport spawns its own thread during fill time. Also if you are using scriptlets or helpers classes ensure all resources they create are being properly cleaned up. Also ensure you are using the latest JR package. One note. The JR api includ...
472,557
<p>i have in the database typical tables like user, usergroup, and they have relations.</p> <p>in my domain-model i want that if you request users, you will get the users and each user has the property belongsto, which means these are the groups he belongs to. in the property i want to have the list of groups (typesaf...
[ { "answer_id": 472607, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 0, "selected": false, "text": "<p>The best thing is to only retrieve the entity that was requested by the client but allow that entity to expose a me...
2009/01/23
[ "https://Stackoverflow.com/questions/472557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49034/" ]
i have in the database typical tables like user, usergroup, and they have relations. in my domain-model i want that if you request users, you will get the users and each user has the property belongsto, which means these are the groups he belongs to. in the property i want to have the list of groups (typesafe as group...
> > my current code is based on foreach over the groups, relations.where for the groups, and then users.singleordefault to find the user and then add the user to the group and the group to the user. > > > I don't understand what you're saying here. > > it takes appx 30secs to do this > > > Whatever it is you...
472,558
<p>What options are there in <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="noreferrer">ASP Classic</a> for error handling?</p> <p>For example:</p> <p>I'm using the <code>Mail.SendMail</code> function but when switching on the testing server it doesn't work, which is normal. I want to test if mailing...
[ { "answer_id": 472569, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "<p>Been a while since I was in ASP land, but iirc there's a couple of ways:</p>\n\n<p><code>try catch finally</code> can ...
2009/01/23
[ "https://Stackoverflow.com/questions/472558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2172/" ]
What options are there in [ASP Classic](http://en.wikipedia.org/wiki/Active_Server_Pages) for error handling? For example: I'm using the `Mail.SendMail` function but when switching on the testing server it doesn't work, which is normal. I want to test if mailing is possible, if not then continue and/or show a message...
There are two approaches, you can code in JScript or VBScript which do have the construct or you can fudge it in your code. Using JScript you'd use the following type of construct: ``` <script language="jscript" runat="server"> try { tryStatements } catch(exception) { catchStatements } finally { finally...
472,559
<p>I want to use the FTP task in ant, and I have found the appropriate jar files and got everything working fine. I have put the jar files in a "libs" directory alongside the other files used in the build. The only problem is that the user must run "ant -lib commons-net-ftp-2.0.jar" to make a build; I would really pr...
[ { "answer_id": 473688, "author": "Instantsoup", "author_id": 9861, "author_profile": "https://Stackoverflow.com/users/9861", "pm_score": 0, "selected": false, "text": "<p>Your users all have ant installed on their machines but you can't / don't want to make them add the FTP jar? Can you ...
2009/01/23
[ "https://Stackoverflow.com/questions/472559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
I want to use the FTP task in ant, and I have found the appropriate jar files and got everything working fine. I have put the jar files in a "libs" directory alongside the other files used in the build. The only problem is that the user must run "ant -lib commons-net-ftp-2.0.jar" to make a build; I would really prefer ...
The problem you are having is due to the different class-loaders in use. The Commons Net classes must be loaded by the same class-loader that loads the FTP task. Because the FTP task is loaded by Ant on start-up, you need to add the Commons Net to Ant's classpath so that it is loaded by the same class-loader. That's wh...
472,563
<p>I have a winform in vs2008 that contains a DataGridView. The datagrid contains a list with several columns. These are fixed width, exept one that I have set up to take whatever space is left and fill the width of the view. The winform is resizeable in all directions.</p> <p>The issue I am trying to solve is that wh...
[ { "answer_id": 472818, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 4, "selected": true, "text": "<p>Try subclassing the DataGridView and handling the VerticalScrollBar's VisibleChanged event. You should be able to set t...
2009/01/23
[ "https://Stackoverflow.com/questions/472563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45704/" ]
I have a winform in vs2008 that contains a DataGridView. The datagrid contains a list with several columns. These are fixed width, exept one that I have set up to take whatever space is left and fill the width of the view. The winform is resizeable in all directions. The issue I am trying to solve is that when I incre...
Try subclassing the DataGridView and handling the VerticalScrollBar's VisibleChanged event. You should be able to set the Visible property to True in there, overriding the default behaviour. Something like this, I think... ``` public class SubclassedDataGridView : DataGridView { public SubclassedDataGridV...
472,575
<p>I created a utility function to return the expected single item from an generator expression</p> <pre><code>print one(name for name in ('bob','fred') if name=='bob') </code></pre> <p>Is this a good way to go about it?</p> <pre><code>def one(g): try: val = g.next() try: g.next() ...
[ { "answer_id": 472588, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 2, "selected": false, "text": "<p>Simple approach:</p>\n\n<pre><code>print (name for name in ('bob', 'fred') if name == 'bob').next()\n</code></pre>\n\n<p...
2009/01/23
[ "https://Stackoverflow.com/questions/472575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18138/" ]
I created a utility function to return the expected single item from an generator expression ``` print one(name for name in ('bob','fred') if name=='bob') ``` Is this a good way to go about it? ``` def one(g): try: val = g.next() try: g.next() except StopIteration: ...
A simpler solution is to use tuple unpacking. This will already do everything you want, including checking that it contains exactly one item. Single item: ``` >>> name, = (name for name in ('bob','fred') if name=='bob') >>> name 'bob' ``` Too many items: ``` >>> name, = (name for name in ('bob','bob') if name==...
472,578
<p>I'm using this code to reset the identity on a table:</p> <pre><code>DBCC CHECKIDENT('TableName', RESEED, 0) </code></pre> <p>This works fine most of the time, with the first insert I do inserting 1 into the Id column. However, if I drop the DB and recreate it (using scripts I've written) and then call DBCC CHECKIDE...
[ { "answer_id": 472608, "author": "dmajkic", "author_id": 39233, "author_profile": "https://Stackoverflow.com/users/39233", "pm_score": 2, "selected": false, "text": "<p>Change statement to </p>\n\n<pre><code> DBCC CHECKIDENT('TableName', RESEED, 1)\n</code></pre>\n\n<p>This will start f...
2009/01/23
[ "https://Stackoverflow.com/questions/472578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47437/" ]
I'm using this code to reset the identity on a table: ``` DBCC CHECKIDENT('TableName', RESEED, 0) ``` This works fine most of the time, with the first insert I do inserting 1 into the Id column. However, if I drop the DB and recreate it (using scripts I've written) and then call DBCC CHECKIDENT, the first item inser...
As you pointed out in your question it is a [documented behavior](http://msdn.microsoft.com/en-us/library/aa258817(SQL.80).aspx). I still find it strange though. I use to repopulate the test database and even though I do not rely on the values of identity fields it was a bit of annoying to have different values when po...
472,605
<p>Example:</p> <pre><code>function pcs() { var t1 = document.getElementById("tot1").value var pb = document.getElementById("pcbox").value var pc = "" if (t1==! &amp;&amp; pb==!) { document.getElementId("rbox").innerHTML = "" } } </code></pre> <p>My question is if <code>t1</code> and ...
[ { "answer_id": 472618, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 2, "selected": false, "text": "<p><code>if(t1==! &amp;&amp; pb==!)</code> --> this is absolutly wrong.... What are you trying to check?</p>\n\n<p>Maybe <c...
2009/01/23
[ "https://Stackoverflow.com/questions/472605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Example: ``` function pcs() { var t1 = document.getElementById("tot1").value var pb = document.getElementById("pcbox").value var pc = "" if (t1==! && pb==!) { document.getElementId("rbox").innerHTML = "" } } ``` My question is if `t1` and `pb` are null the function `pcs()` is not cal...
The line ``` if(t1==! && pb==!) ``` is not legal syntax. If this is exactly how you have written the code it will not parse and thus the function will not be defined (plus you'll be getting Javascript errors). Perhaps you meant ``` if(t1 != null && pb != null) ``` Additionally, while semicolons at the end of lines...
472,632
<p>I have a page with multiple charts in a grid-like format as follows: </p> <pre><code>[ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] </code></pre> <p>Each chart is displayed in a wrapper with <code>float:left</code> and the div the charts are in has <code>overflow: auto</code>. This...
[ { "answer_id": 490067, "author": "jeroen", "author_id": 42139, "author_profile": "https://Stackoverflow.com/users/42139", "pm_score": 2, "selected": false, "text": "<p>I don't know if you really need the <code>float: left</code> for other things, but you could try:</p>\n\n<pre><code>/* w...
2009/01/23
[ "https://Stackoverflow.com/questions/472632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58268/" ]
I have a page with multiple charts in a grid-like format as follows: ``` [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] ``` Each chart is displayed in a wrapper with `float:left` and the div the charts are in has `overflow: auto`. This gives the desired layout wrapping the charts to...
Float does not work well in print css, so remove the floats or override them with float: none and use inline-block instead: ``` .chartWrapper { float: none; display: inline-block; vertical-align: top; padding: 0 20px 0 0; } ```
472,667
<p>Is there support for lambda expressions from C++ 0x in Visual Studio 2008 SP1? Example below throws me syntax errors. Is there any '-Cpp0x' flag for compiler or something?</p> <pre><code>#include &lt;algorithm&gt; #include &lt;iostream&gt; #include &lt;ostream&gt; #include &lt;vector&gt; using namespace std; int ...
[ { "answer_id": 472683, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 3, "selected": true, "text": "<p>See <a href=\"https://stackoverflow.com/questions/146381/visual-studio-support-for-new-c-c-standards\">Stackoverflow...
2009/01/23
[ "https://Stackoverflow.com/questions/472667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33013/" ]
Is there support for lambda expressions from C++ 0x in Visual Studio 2008 SP1? Example below throws me syntax errors. Is there any '-Cpp0x' flag for compiler or something? ``` #include <algorithm> #include <iostream> #include <ostream> #include <vector> using namespace std; int main() { vector<int> v; for (int...
See [Stackoverflow question #146381](https://stackoverflow.com/questions/146381/visual-studio-support-for-new-c-c-standards) Simply put: no. Visual Studio 2010 will support C++0x to some extent, but I'm unsure if that will include lambda expressions.
472,669
<p>How can I convert a <code>List&lt;MyObject&gt;</code> to an <code>IEnumerable&lt;MyObject&gt;</code> and then back again?</p> <p>I want to do this in order to run a series of LINQ statements on the List, e. g. <code>Sort()</code></p>
[ { "answer_id": 472671, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 8, "selected": true, "text": "<pre><code>List&lt;string&gt; myList = new List&lt;string&gt;();\nIEnumerable&lt;string&gt; myEnumerable = myList;\nLis...
2009/01/23
[ "https://Stackoverflow.com/questions/472669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
How can I convert a `List<MyObject>` to an `IEnumerable<MyObject>` and then back again? I want to do this in order to run a series of LINQ statements on the List, e. g. `Sort()`
``` List<string> myList = new List<string>(); IEnumerable<string> myEnumerable = myList; List<string> listAgain = myEnumerable.ToList(); ```
472,690
<p>I have an AJAX application which has used CSS divs to create panels on the screen, which are loaded separately and in succession, depending on what was loaded before it. The bottom "panel" is a table showing a list or records from a database. At the top of the database is the name of the table, and I would like a wa...
[ { "answer_id": 472728, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 0, "selected": false, "text": "<p>Do you want the table name to be inside the panel with the table? If so, I think it should be pretty straightforward, b...
2009/01/23
[ "https://Stackoverflow.com/questions/472690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have an AJAX application which has used CSS divs to create panels on the screen, which are loaded separately and in succession, depending on what was loaded before it. The bottom "panel" is a table showing a list or records from a database. At the top of the database is the name of the table, and I would like a way t...
I assume you mean to be able to scroll the table without moving the header? I think your easiest option is the CSS [`overflow` property](http://www.w3schools.com/Css/pr_pos_overflow.asp). ``` <style type="text/css"> div#dblist { overflow: scroll; height: 400px; } </style> <!-- ... --> <div>Database Titl...
472,692
<p>As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure:</p> <pre><code>folder1 folder2 folder3 data.zip info.txt abc.xyz folder4 folder5 data.zip somefile.exe someotherfile.dll </c...
[ { "answer_id": 472701, "author": "aphoria", "author_id": 2441, "author_profile": "https://Stackoverflow.com/users/2441", "pm_score": 9, "selected": true, "text": "<p>You don't mention if it has to be batch only, but if you can use <code>ROBOCOPY</code>, try this:</p>\n\n<pre><code>ROBOCO...
2009/01/23
[ "https://Stackoverflow.com/questions/472692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19635/" ]
As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure: ``` folder1 folder2 folder3 data.zip info.txt abc.xyz folder4 folder5 data.zip somefile.exe someotherfile.dll ``` The files *...
You don't mention if it has to be batch only, but if you can use `ROBOCOPY`, try this: ``` ROBOCOPY C:\Source C:\Destination data.zip info.txt /E ``` EDIT: Changed the `/S` parameter to `/E` to include empty folders.
472,694
<p>I just tested which type of code is executed by the WinForms Designer in VS 2008. It seems that the designer is not executing the default constructor anymore. I added a simple thing like this.Text = "foo"; nothing is changed in the designer.</p> <p>Did I miss a change between VS 2005/2008? (or SP1)</p> <p>tia</p>...
[ { "answer_id": 472701, "author": "aphoria", "author_id": 2441, "author_profile": "https://Stackoverflow.com/users/2441", "pm_score": 9, "selected": true, "text": "<p>You don't mention if it has to be batch only, but if you can use <code>ROBOCOPY</code>, try this:</p>\n\n<pre><code>ROBOCO...
2009/01/23
[ "https://Stackoverflow.com/questions/472694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58275/" ]
I just tested which type of code is executed by the WinForms Designer in VS 2008. It seems that the designer is not executing the default constructor anymore. I added a simple thing like this.Text = "foo"; nothing is changed in the designer. Did I miss a change between VS 2005/2008? (or SP1) tia
You don't mention if it has to be batch only, but if you can use `ROBOCOPY`, try this: ``` ROBOCOPY C:\Source C:\Destination data.zip info.txt /E ``` EDIT: Changed the `/S` parameter to `/E` to include empty folders.
472,697
<p>Is there a POSIX function that will give me the size of a directory (including all sub-folders), roughly equivalent to "<code>du -s somepath</code>"?</p>
[ { "answer_id": 472704, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>There is no ready-made function, so you will have to make your own. You may look at the source code of the GNU implemenatio...
2009/01/23
[ "https://Stackoverflow.com/questions/472697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8331/" ]
Is there a POSIX function that will give me the size of a directory (including all sub-folders), roughly equivalent to "`du -s somepath`"?
``` $ man nftw ``` > > **NAME** > > > `ftw`, `nftw` - file tree walk > > > **DESCRIPTION** > > > `ftw()` walks through the directory tree > that is located under the directory > dirpath, and calls `fn()` once for each > entry in the tree. By default, > directories are handled before the > files and subdi...
472,715
<p>Hi I am using log4j api to log the informations. I have used log4j_conffig.xml file for creating the log files. I have given the absolute path for each log file in param tag value.</p> <p>eg :</p> <pre><code>appender name="GPREPROCESSOR_DEBUG" class="org.apache.log4j.DailyRollingFileAppender"&gt;&lt;br&gt; ...
[ { "answer_id": 472789, "author": "emeraldjava", "author_id": 55794, "author_profile": "https://Stackoverflow.com/users/55794", "pm_score": 0, "selected": false, "text": "<p>You have use ${java.home} or ${user.home} to define a relative path for your file. See <a href=\"http://www.vipan.c...
2009/01/23
[ "https://Stackoverflow.com/questions/472715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51659/" ]
Hi I am using log4j api to log the informations. I have used log4j\_conffig.xml file for creating the log files. I have given the absolute path for each log file in param tag value. eg : ``` appender name="GPREPROCESSOR_DEBUG" class="org.apache.log4j.DailyRollingFileAppender"><br> param name="DatePattern" val...
Any Java System property may be used in a log4j config file. For example, your application at its startup could do something like: ``` String directory = "logfiles"; // relative to "." try { path = new File(directory).getCanonicalPath(); } catch (IOException e) { // Cannot use log4j yet, so complain to system out...
472,717
<p>Can we change the appearance of scroll bar? I mean we want to change the image of the scroll bar, so it can match our web theme. more specifically, i'm pointing at the scroll bar in</p> <pre><code>&lt;div style=overflow:auto&gt; </code></pre> <p>If it can't be done, then is there some other way to make our own "sc...
[ { "answer_id": 473619, "author": "Jayx", "author_id": 45527, "author_profile": "https://Stackoverflow.com/users/45527", "pm_score": 1, "selected": false, "text": "<p>Check out <a href=\"http://www.hesido.com/web.php?page=customscrollbar\" rel=\"nofollow noreferrer\">this site</a> - I've ...
2009/01/23
[ "https://Stackoverflow.com/questions/472717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can we change the appearance of scroll bar? I mean we want to change the image of the scroll bar, so it can match our web theme. more specifically, i'm pointing at the scroll bar in ``` <div style=overflow:auto> ``` If it can't be done, then is there some other way to make our own "scroll bar", which use our own ima...
Check out [this site](http://www.hesido.com/web.php?page=customscrollbar) - I've heard good things about the method implemented, although I have never really bothered to create my own custom scroll bars. You should be able to style in line with your own theme with a bit of experimentation.
472,722
<p>We recently upgraded from MSBuild 2005 to 2008. Since then MSBuild stops on the first error when building a solution. This wasn't the case in 2005. Is there a way to get the old behavior?</p> <p><b>EDIT</b>: We call MSBuild form the command line:</p> <pre><code>MSBuild.exe xyz.sln /p:Platform=Win32 /p:Configuratio...
[ { "answer_id": 472768, "author": "Mariano", "author_id": 12514, "author_profile": "https://Stackoverflow.com/users/12514", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;MSBuild Projects=\"@(Solution)\" ContinueOnError=\"false\" StopOnFirstFailure=\"true\"&gt;&lt;/MSBuild&gt;\...
2009/01/23
[ "https://Stackoverflow.com/questions/472722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44086/" ]
We recently upgraded from MSBuild 2005 to 2008. Since then MSBuild stops on the first error when building a solution. This wasn't the case in 2005. Is there a way to get the old behavior? **EDIT**: We call MSBuild form the command line: ``` MSBuild.exe xyz.sln /p:Platform=Win32 /p:Configuration=Debug ```
``` <MSBuild Projects="@(Solution)" ContinueOnError="false" StopOnFirstFailure="true"></MSBuild> ``` You have to change this on the script
472,732
<p>I have a table of values like this</p> <pre><code>978412, 400 978813, 20 978834, 50 981001, 20 </code></pre> <p>As you can see the second number when added to the first is 1 number before the next in the sequence. The last number is not in the range (doesnt follow a direct sequence, as in the next value). What I n...
[ { "answer_id": 472943, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "<p>Check out this <a href=\"http://msdn.microsoft.com/en-us/library/aa175780(SQL.80).aspx\" rel=\"nofollow noreferrer\">...
2009/01/23
[ "https://Stackoverflow.com/questions/472732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42434/" ]
I have a table of values like this ``` 978412, 400 978813, 20 978834, 50 981001, 20 ``` As you can see the second number when added to the first is 1 number before the next in the sequence. The last number is not in the range (doesnt follow a direct sequence, as in the next value). What I need is a CTE (yes, ideally...
From the article that Josh posted, here's my take (tested and working): ``` SELECT MAX(t1.gapID) as gapID, t2.gapID-MAX(t1.gapID)+t2.gapSize as gapSize -- max(t1) is the specific lower bound of t2 because of the group by. FROM ( -- t1 is the lower boundary of an island. SELECT gapID FROM gaps tbl...
472,733
<p>I've got some logic in a controller that sets a status of an object if certain conditions are met:</p> <pre><code>if params[:concept][:consulted_legal] == 0 &amp;&amp; params[:concept][:consulted_marketing] == 1 @concept.attributes = {:status =&gt; 'Awaiting Compliance Approval'} elsif params[:concept][:consulted...
[ { "answer_id": 472762, "author": "Bo Jeanes", "author_id": 56690, "author_profile": "https://Stackoverflow.com/users/56690", "pm_score": 3, "selected": true, "text": "<p>This is my take on it. I call it Super DRY.</p>\n\n<pre><code>statuses = \n [\n ['Awaiting Marketing &amp; Legal A...
2009/01/23
[ "https://Stackoverflow.com/questions/472733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52092/" ]
I've got some logic in a controller that sets a status of an object if certain conditions are met: ``` if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1 @concept.attributes = {:status => 'Awaiting Compliance Approval'} elsif params[:concept][:consulted_marketing] == 0 && param...
This is my take on it. I call it Super DRY. ``` statuses = [ ['Awaiting Marketing & Legal Approval','Awaiting Compliance Approval'], ['Awaiting Marketing Approval','Pending Approval'] ] {:status => statuses[params[:concept][:consulted_legal].to_i][params[:concept][:consulted_marketing].to_i]} ``` Alter...
472,739
<p>I have a problem with jaas and jboss. I try to authenticate users against a database using form based method but jboss tells me the password are wrong (no, the password is correct), but if i use UsersRolesLoginModule with properties files, no problem.</p> <p>In the pg database in debug mode the query that JBoss doe...
[ { "answer_id": 1159294, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;application-policy name = \"AP\"&gt; change to &lt;application-policy name = \"Admin\"&gt;\n</code></pre>\n\n<...
2009/01/23
[ "https://Stackoverflow.com/questions/472739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a problem with jaas and jboss. I try to authenticate users against a database using form based method but jboss tells me the password are wrong (no, the password is correct), but if i use UsersRolesLoginModule with properties files, no problem. In the pg database in debug mode the query that JBoss does seems ok...
``` <application-policy name = "AP"> change to <application-policy name = "Admin"> ``` OR ``` <security-domain>java:/jaas/Admin</security-domain> change to <security-domain>java:/jaas/AP</security-domain> ```
472,782
<p>EIMI being an explicit interface member implementation. So instead of:</p> <pre><code>public int SomeValue{get;} </code></pre> <p>you have</p> <pre><code>int SomeInterface.SomeValue {get;} </code></pre> <p>I'm currently considering using one as i'm using an internal interface (to decouple, yet restrict) and I do...
[ { "answer_id": 472844, "author": "Vojislav Stojkovic", "author_id": 58099, "author_profile": "https://Stackoverflow.com/users/58099", "pm_score": 3, "selected": true, "text": "<p>Yep, that's a good use case. According to <a href=\"http://msdn.microsoft.com/en-us/library/aa664591(VS.71).a...
2009/01/23
[ "https://Stackoverflow.com/questions/472782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1143/" ]
EIMI being an explicit interface member implementation. So instead of: ``` public int SomeValue{get;} ``` you have ``` int SomeInterface.SomeValue {get;} ``` I'm currently considering using one as i'm using an internal interface (to decouple, yet restrict) and I don't want to make the methods on the implementing ...
Yep, that's a good use case. According to [C# Language Specification](http://msdn.microsoft.com/en-us/library/aa664591(VS.71).aspx) on MSDN: > > Explicit interface member implementations serve two primary purposes: > > > * Because explicit interface member implementations are not accessible through class or struct ...
472,784
<p>I use SQL Server 2005 and need to test whether values in a column that's metadata has been specified as DECIMAL(18.3) actually contains data that has values to the right of the Decimal point, and if so, what these values are.</p> <p>I've read a few articles that only discuss how to drop off the decimal places or ho...
[ { "answer_id": 472795, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 1, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>SELECT a - FLOOR(a)\nFROM ...\n</code></pre>\n" }, { "answer_id": 472801, "author": "...
2009/01/23
[ "https://Stackoverflow.com/questions/472784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I use SQL Server 2005 and need to test whether values in a column that's metadata has been specified as DECIMAL(18.3) actually contains data that has values to the right of the Decimal point, and if so, what these values are. I've read a few articles that only discuss how to drop off the decimal places or how to round...
Try: ``` SELECT a - FLOOR(a) FROM ... ```
472,796
<p>In the example below I have a ListBox with dozens of font names in it.</p> <p>I would have thought it would automatically have a vertical scrollbar on it so that you can select ANY font, not just the first ones in the list, but it doesn't.</p> <p>So I added a "ScrollViewer" and that puts a "scrollbar area" on the ...
[ { "answer_id": 472813, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 8, "selected": true, "text": "<p>The problem with your solution is you're putting a scrollbar around a ListBox where you probably want to put it inside ...
2009/01/23
[ "https://Stackoverflow.com/questions/472796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
In the example below I have a ListBox with dozens of font names in it. I would have thought it would automatically have a vertical scrollbar on it so that you can select ANY font, not just the first ones in the list, but it doesn't. So I added a "ScrollViewer" and that puts a "scrollbar area" on the right but there i...
The problem with your solution is you're putting a scrollbar around a ListBox where you probably want to put it inside the ListBox. If you want to force a scrollbar in your ListBox, use the ScrollBar.VerticalScrollBarVisibility attached property. ``` <ListBox ItemsSource="{Binding}" ScrollViewer.VerticalSc...
472,809
<p>I have an application that has to calculate the MD5 of file, I have used the openssl library, valgrind complains about some blocks still reachable.</p> <p>Compile the following code:</p> <pre><code>#include &lt;openssl/bio.h&gt; int main(int, char**) { BIO * mem = BIO_new(BIO_s_mem()); BIO_vfree(mem); re...
[ { "answer_id": 472854, "author": "HUAGHAGUAH", "author_id": 38809, "author_profile": "https://Stackoverflow.com/users/38809", "pm_score": 2, "selected": false, "text": "<p>OpenSSL has actions that confuse Valgrind when not compiled with -DPURIFY. <a href=\"http://www.openssl.org/support...
2009/01/23
[ "https://Stackoverflow.com/questions/472809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49820/" ]
I have an application that has to calculate the MD5 of file, I have used the openssl library, valgrind complains about some blocks still reachable. Compile the following code: ``` #include <openssl/bio.h> int main(int, char**) { BIO * mem = BIO_new(BIO_s_mem()); BIO_vfree(mem); return 0; } ``` the run it ...
OpenSSL has actions that confuse Valgrind when not compiled with -DPURIFY. [Is this the error you are seeing?](http://www.openssl.org/support/faq.html#PROG14)
472,814
<p>At the moment, we have a problem that exists only for a few Subversion clients. </p> <p>We would like to get a Subversion client log file, which contains information what command was send to the server, what response came back and so on. Is there the possibility to switch on logging to get that information on the c...
[ { "answer_id": 472976, "author": "Dan Fitch", "author_id": 27614, "author_profile": "https://Stackoverflow.com/users/27614", "pm_score": 4, "selected": true, "text": "<p>Set <code>neon-debug-mask</code> in the <code>[global]</code> section of your <a href=\"http://svnbook.red-bean.com/en...
2009/01/23
[ "https://Stackoverflow.com/questions/472814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2603665/" ]
At the moment, we have a problem that exists only for a few Subversion clients. We would like to get a Subversion client log file, which contains information what command was send to the server, what response came back and so on. Is there the possibility to switch on logging to get that information on the client? I ...
Set `neon-debug-mask` in the `[global]` section of your [subversion `servers` config file](http://svnbook.red-bean.com/en/1.7/svn.advanced.confarea.html#svn.advanced.confarea.opts.servers) to 138 to get authentication debugging. ``` [global] <snip...> neon-debug-mask = 138 ``` This can be done on the SVN server side...
472,815
<p>what select statement would I use to add the excel spreadsheet to an existing table, as i am getting an error trying to create a new table on the database? please can you assist me. Thanks</p>
[ { "answer_id": 472976, "author": "Dan Fitch", "author_id": 27614, "author_profile": "https://Stackoverflow.com/users/27614", "pm_score": 4, "selected": true, "text": "<p>Set <code>neon-debug-mask</code> in the <code>[global]</code> section of your <a href=\"http://svnbook.red-bean.com/en...
2009/01/23
[ "https://Stackoverflow.com/questions/472815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58269/" ]
what select statement would I use to add the excel spreadsheet to an existing table, as i am getting an error trying to create a new table on the database? please can you assist me. Thanks
Set `neon-debug-mask` in the `[global]` section of your [subversion `servers` config file](http://svnbook.red-bean.com/en/1.7/svn.advanced.confarea.html#svn.advanced.confarea.opts.servers) to 138 to get authentication debugging. ``` [global] <snip...> neon-debug-mask = 138 ``` This can be done on the SVN server side...
472,817
<p>I have two controllers for two respective models, by example, photos and categories. index and show methods are very similar in each controller, and the views are identical. What is the best method for share the view by the two models?</p> <p>I've though two options:</p> <ul> <li><p>Use a helper. In the helper wil...
[ { "answer_id": 472832, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 1, "selected": false, "text": "<p>I'd use an helper because they are shared among views. For the HTML part, I'd use partials so it would be a mix of both...
2009/01/23
[ "https://Stackoverflow.com/questions/472817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36599/" ]
I have two controllers for two respective models, by example, photos and categories. index and show methods are very similar in each controller, and the views are identical. What is the best method for share the view by the two models? I've though two options: * Use a helper. In the helper will put the code for the v...
I have a similar situation with one of my projects. All the delete views for most controllers are styled the same way, display the same confirmation boxes, and simply renders a predictable display of whatever object is being deleted. The solution was quite simple and elegant in my opinion. Simply put, what we (the dev...
472,825
<p>I create a plugin which includes the following folder structure:</p> <ul> <li>src </li> <li>native/so/libsystemcommand.so</li> <li>META-INF/MANIFEST.MF</li> </ul> <p>The manifest include the command</p> <pre><code>Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Commands Plug-in Bundle-SymbolicName: d...
[ { "answer_id": 472868, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 1, "selected": false, "text": "<p>The lib has to be in your filesystem (not in an archive file). \nThen you can either use the linux environment variable <...
2009/01/23
[ "https://Stackoverflow.com/questions/472825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39062/" ]
I create a plugin which includes the following folder structure: * src * native/so/libsystemcommand.so * META-INF/MANIFEST.MF The manifest include the command ``` Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Commands Plug-in Bundle-SymbolicName: de.system.commands;singleton:=true Bundle-Version: 1.0....
I think i found the solution. We only build the plugin which was not working and copy it to the destination platform directory. After this we start the application as wtach the log files whether the library was foud or not. What we miss, was to **delete the configurations folder**. The new plugin was not unzipp and t...
472,840
<p>As a mostly self-taught programmer, I have never really had anyone explain why certain things should or should not be used. One example (which I picked up years ago and use quite often) is the alternative control structure syntax:</p> <pre><code>x = (y == true) ? "foo" : "bar"; </code></pre> <p>I personally find t...
[ { "answer_id": 472853, "author": "Markus Olsson", "author_id": 2114, "author_profile": "https://Stackoverflow.com/users/2114", "pm_score": 1, "selected": false, "text": "<p>The syntax you're referring to is often called <a href=\"http://en.wikipedia.org/wiki/%3F:\" rel=\"nofollow norefer...
2009/01/23
[ "https://Stackoverflow.com/questions/472840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58244/" ]
As a mostly self-taught programmer, I have never really had anyone explain why certain things should or should not be used. One example (which I picked up years ago and use quite often) is the alternative control structure syntax: ``` x = (y == true) ? "foo" : "bar"; ``` I personally find this syntax easy to follow,...
As a fellow mostly self-taught programmer, I can only give you my opinion, without any special authority behind it. I find that the ternary conditional operator (?:) is perfectly acceptable when you're using it for an expression with no side-effects. As soon as you start using it to represent a decision to do somethin...
472,879
<p>I'm looking for a routine that will format a string of numbers as a UK phone number. The routine should account for UK area codes that require different formatting (i.e. London compared to Edinburgh compared to Worcester) as well as mobile numbers.</p> <p>My phone numbers are stored in the database as strings, cont...
[ { "answer_id": 472907, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 5, "selected": true, "text": "<p>UK telephone numbers vary in length from 7 digits to 10 digits, not including the leading zero. \"area\" codes can vary b...
2009/01/23
[ "https://Stackoverflow.com/questions/472879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39709/" ]
I'm looking for a routine that will format a string of numbers as a UK phone number. The routine should account for UK area codes that require different formatting (i.e. London compared to Edinburgh compared to Worcester) as well as mobile numbers. My phone numbers are stored in the database as strings, containing onl...
UK telephone numbers vary in length from 7 digits to 10 digits, not including the leading zero. "area" codes can vary between 2 and usually 4 (but occasionally 5) digits. All of the tables that show the area code and total length for each number prefix are available from [OFCOM's website](http://www.ofcom.org.uk/stati...
472,892
<p>I'm looking for a JQuery code sample or library for displaying tooltips when the cursor hovers over an element. Specifically, what I want to do is display my own &lt;div&gt; element on hover, not an automatically-constructed or loaded-from-the-host-element tooltip. I've looked at a couple JQuery tooltip plugins and ...
[ { "answer_id": 472995, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 4, "selected": false, "text": "<p>Well, I can't offer you an entire solution but getting a div to appear as a tooltip is pretty simple:</p>\n\n<pre><code>(...
2009/01/23
[ "https://Stackoverflow.com/questions/472892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54486/" ]
I'm looking for a JQuery code sample or library for displaying tooltips when the cursor hovers over an element. Specifically, what I want to do is display my own <div> element on hover, not an automatically-constructed or loaded-from-the-host-element tooltip. I've looked at a couple JQuery tooltip plugins and they all ...
Well, I can't offer you an entire solution but getting a div to appear as a tooltip is pretty simple: ``` (function($){ var $div = $('<div/>').css({ position: 'absolute', background: 'white', border: '1px solid black', padding: '10px', zIndex: 999, display: 'none' ...
472,897
<p>C# In a nut shell can I display images in a list box? I have a list of users and I want to display a green tick next to some of the names, is this possible? </p> <p>Thanks</p>
[ { "answer_id": 472949, "author": "Michael Meadows", "author_id": 7643, "author_profile": "https://Stackoverflow.com/users/7643", "pm_score": 0, "selected": false, "text": "<p>In WPF it's quite simple, but if you're using winforms, you can't do it with the System.Windows.Forms.ListBox con...
2009/01/23
[ "https://Stackoverflow.com/questions/472897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C# In a nut shell can I display images in a list box? I have a list of users and I want to display a green tick next to some of the names, is this possible? Thanks
The following code displays how to do custom drawing in a listbox. ``` using System.Windows.Forms; using System.Drawing; namespace Toolset.Controls { public class CustomDrawListBox : ListBox { public CustomDrawListBox() { this.DrawMode = DrawMode.OwnerDrawVariable; // We're using c...
472,906
<p>How do I convert a <code>string</code> to a <code>byte[]</code> in .NET (C#) without manually specifying a specific encoding?</p> <p>I'm going to encrypt the string. I can encrypt it without converting, but I'd still like to know why encoding comes to play here.</p> <p>Also, why should encoding even be taken into ...
[ { "answer_id": 472916, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 4, "selected": false, "text": "<pre><code>byte[] strToByteArray(string str)\n{\n System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();\n ...
2009/01/23
[ "https://Stackoverflow.com/questions/472906", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
How do I convert a `string` to a `byte[]` in .NET (C#) without manually specifying a specific encoding? I'm going to encrypt the string. I can encrypt it without converting, but I'd still like to know why encoding comes to play here. Also, why should encoding even be taken into consideration? Can't I simply get what ...
**Contrary to the answers here, you DON'T need to worry about encoding ***if*** the bytes don't need to be interpreted!** Like you mentioned, your goal is, simply, to *"get what bytes the string has been stored in"*. (And, of course, to be able to re-construct the string from the bytes.) **For those goals, I hones...
472,910
<p>I have several asp.net mvc websites consuming the same controller and model.<br> This common logic is put in seperate libraries. These libraries use the HttpContext.Current.Session. How can I make these unit testable? I read about the StateValue but can't completely grasp it. Where should I get this StateValue thing...
[ { "answer_id": 472916, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 4, "selected": false, "text": "<pre><code>byte[] strToByteArray(string str)\n{\n System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();\n ...
2009/01/23
[ "https://Stackoverflow.com/questions/472910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I have several asp.net mvc websites consuming the same controller and model. This common logic is put in seperate libraries. These libraries use the HttpContext.Current.Session. How can I make these unit testable? I read about the StateValue but can't completely grasp it. Where should I get this StateValue thing? Is...
**Contrary to the answers here, you DON'T need to worry about encoding ***if*** the bytes don't need to be interpreted!** Like you mentioned, your goal is, simply, to *"get what bytes the string has been stored in"*. (And, of course, to be able to re-construct the string from the bytes.) **For those goals, I hones...
472,914
<p>Why is my GetEntity function in my overloaded XmlResolver being passed the <a href="http://en.wikipedia.org/wiki/Formal_Public_Identifier" rel="nofollow noreferrer">Formal Public Identifier</a> when I load an xml file into an XmlDocument? Is this a bug or am I supposed to deal with this some how?</p> <p><em>edit:<...
[ { "answer_id": 472916, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 4, "selected": false, "text": "<pre><code>byte[] strToByteArray(string str)\n{\n System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();\n ...
2009/01/23
[ "https://Stackoverflow.com/questions/472914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15233/" ]
Why is my GetEntity function in my overloaded XmlResolver being passed the [Formal Public Identifier](http://en.wikipedia.org/wiki/Formal_Public_Identifier) when I load an xml file into an XmlDocument? Is this a bug or am I supposed to deal with this some how? *edit:* Here's some code. Say for example I do this: ```...
**Contrary to the answers here, you DON'T need to worry about encoding ***if*** the bytes don't need to be interpreted!** Like you mentioned, your goal is, simply, to *"get what bytes the string has been stored in"*. (And, of course, to be able to re-construct the string from the bytes.) **For those goals, I hones...
472,917
<p>How do you compare a value from jQuery with a fixed number?</p> <p>I thought this might work but it doesn't:</p> <pre><code>if (parseInt($("#days").value) &gt; 7) { alert("more than one week"); } </code></pre>
[ { "answer_id": 472923, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 3, "selected": true, "text": "<p>if #days is an input then you need .val() instead of value</p>\n\n<p>e.g.</p>\n\n<pre><code> if (parseInt($(\"#days\")....
2009/01/23
[ "https://Stackoverflow.com/questions/472917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1122/" ]
How do you compare a value from jQuery with a fixed number? I thought this might work but it doesn't: ``` if (parseInt($("#days").value) > 7) { alert("more than one week"); } ```
if #days is an input then you need .val() instead of value e.g. ``` if (parseInt($("#days").val()) > 7) { alert("more than one week"); } ```
472,930
<p>The <a href="https://api.jquery.com/slidedown/" rel="nofollow noreferrer"><code>slideDown()</code></a> applied to a <code>div</code> element does the slide down, but doesn't scroll the page down and the <code>div</code> slided down <code>div</code> remains hidden from view.</p> <p>Is there a way to scroll the page d...
[ { "answer_id": 472954, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 6, "selected": true, "text": "<p>Quick demo <a href=\"http://jsbin.com/agahi\" rel=\"noreferrer\">here</a></p>\n\n<p>Basically all you need is</p>\n\n<pr...
2009/01/23
[ "https://Stackoverflow.com/questions/472930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
The [`slideDown()`](https://api.jquery.com/slidedown/) applied to a `div` element does the slide down, but doesn't scroll the page down and the `div` slided down `div` remains hidden from view. Is there a way to scroll the page down as well so the user can view the `div`?
Quick demo [here](http://jsbin.com/agahi) Basically all you need is ``` $('html, body').animate({ scrollTop: $('#yourDiv').offset().top }, 3000); ```
472,936
<p>I need to create an SQL query to insert some data into a table based on the results of a SELECT query into a local variable. My DB platform is MySQL 5.1, but I don't think that should make a difference here. Basically, what I want to do is:</p> <pre><code>SELECT id INTO var_name FROM table1 WHERE some_column='som...
[ { "answer_id": 472950, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 2, "selected": false, "text": "<p>You need to declare <code>@var_name</code> and then select into <code>@var_name</code>. I don't know MySQL too wel...
2009/01/23
[ "https://Stackoverflow.com/questions/472936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14302/" ]
I need to create an SQL query to insert some data into a table based on the results of a SELECT query into a local variable. My DB platform is MySQL 5.1, but I don't think that should make a difference here. Basically, what I want to do is: ``` SELECT id INTO var_name FROM table1 WHERE some_column='something' LIMIT 1;...
Try ``` INSERT INTO table2 (`number`) SELECT id FROM table1 WHERE some_column='something' LIMIT 1 ```
472,951
<p>Can someone please help me out with printing the contents of an IFrame via a javascript call in Safari/Chrome.</p> <p>This works in firefox:</p> <pre><code>$('#' + id)[0].focus(); $('#' + id)[0].contentWindow.print(); </code></pre> <p>this works in IE:</p> <pre><code>window.frames[id].focus(); window.frames[id]....
[ { "answer_id": 473270, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 6, "selected": true, "text": "<p>Put a print function in the iframe and call it from the parent.</p>\n\n<p>iframe:</p>\n\n<pre><code>f...
2009/01/23
[ "https://Stackoverflow.com/questions/472951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
Can someone please help me out with printing the contents of an IFrame via a javascript call in Safari/Chrome. This works in firefox: ``` $('#' + id)[0].focus(); $('#' + id)[0].contentWindow.print(); ``` this works in IE: ``` window.frames[id].focus(); window.frames[id].print(); ``` But I can't get anything to w...
Put a print function in the iframe and call it from the parent. iframe: ``` function printMe() { window.print() } ``` parent: ``` document.frame1.printMe() ```
472,956
<p>I created a vanilla C# dll and marked it for COM inter op. The dll is a plain user form with no functionality as this is an experiment. </p> <p>I registered the DLL and opened active x test container and instantiated my COM object. It shows up in the test container and i can view the exposed methods of the control ...
[ { "answer_id": 472988, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 2, "selected": false, "text": "<p>You could try: </p>\n\n<pre><code>public void IDisposable.Dispose()\n{ \n System.Runtime.InteropServices.Marsha...
2009/01/23
[ "https://Stackoverflow.com/questions/472956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38230/" ]
I created a vanilla C# dll and marked it for COM inter op. The dll is a plain user form with no functionality as this is an experiment. I registered the DLL and opened active x test container and instantiated my COM object. It shows up in the test container and i can view the exposed methods of the control - these ar...
You could try: ``` public void IDisposable.Dispose() { System.Runtime.InteropServices.Marshal.ReleaseComObject(this); } ``` Typically you do this when consuming COM objects from within .net, not sure about the other way. But it can't hurt to try. Let me know how it worked out;-) Edit: ===== You can also t...
472,959
<p>I am trying to open an Excel file and populate its cells with data? I have done the following coding so far.</p> <p>Currently I am at this stage with the following code but still I am getting errors:</p> <pre><code>Microsoft.Office.Interop.Excel.ApplicationClass appExcel = new Microsoft.Office.Inte...
[ { "answer_id": 472981, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 4, "selected": false, "text": "<p><strike>If you are trying to automate Excel, you probably shouldn't be opening a Word document and using the Word au...
2009/01/23
[ "https://Stackoverflow.com/questions/472959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I am trying to open an Excel file and populate its cells with data? I have done the following coding so far. Currently I am at this stage with the following code but still I am getting errors: ``` Microsoft.Office.Interop.Excel.ApplicationClass appExcel = new Microsoft.Office.Interop.Excel.Application...
If you are trying to automate Excel, you probably shouldn't be opening a Word document and using the Word automation ;) Check this out, it should get you started, <http://www.codeproject.com/KB/office/package.aspx> And here is some code. It is taken from some of my code and has a lot of stuff deleted, so it doesn't ...
472,963
<p>What is the difference between the controller result named <code>ViewResult</code> and <code>PartialViewResult</code>? More importantly, when is the <code>PartialViewResult</code> used?</p>
[ { "answer_id": 473035, "author": "veggerby", "author_id": 54108, "author_profile": "https://Stackoverflow.com/users/54108", "pm_score": 6, "selected": false, "text": "<p>PartialViewResult is used to render a partialview (fx. just a user control). This is pretty nifty for AJAX stuff, i.e....
2009/01/23
[ "https://Stackoverflow.com/questions/472963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54101/" ]
What is the difference between the controller result named `ViewResult` and `PartialViewResult`? More importantly, when is the `PartialViewResult` used?
PartialViewResult is used to render a partialview (fx. just a user control). This is pretty nifty for AJAX stuff, i.e. ``` <script type="text/javascript"> $.get( "/MyController/MyAction", null, function (data) { $("#target").html(data) } ); </script> ``` and action ``` public Action...
472,966
<p>I have the following sample XML structure:</p> <pre><code>&lt;SavingAccounts&gt; &lt;SavingAccount&gt; &lt;ServiceOnline&gt;yes&lt;/ServiceOnline&gt; &lt;ServiceViaPhone&gt;no&lt;/ServiceViaPhone&gt; &lt;/SavingAccount&gt; &lt;SavingAccount&gt; &lt;ServiceOnline&gt;no&lt;/ServiceOnl...
[ { "answer_id": 472996, "author": "falstro", "author_id": 46991, "author_profile": "https://Stackoverflow.com/users/46991", "pm_score": 2, "selected": false, "text": "<p>Will</p>\n\n<pre><code>/SavingAccounts/SavingAccount[ServiceOnline/text()='yes' or ServiceViaPhone/text()='yes']\n</cod...
2009/01/23
[ "https://Stackoverflow.com/questions/472966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following sample XML structure: ``` <SavingAccounts> <SavingAccount> <ServiceOnline>yes</ServiceOnline> <ServiceViaPhone>no</ServiceViaPhone> </SavingAccount> <SavingAccount> <ServiceOnline>no</ServiceOnline> <ServiceViaPhone>yes</ServiceViaPhone> </SavingAccount>...
**This is a very fundamental XPath feature: composing a number of conditions with the logical operators [`and`](http://www.w3.org/TR/xpath#NT-AndExpr), [`or`](http://www.w3.org/TR/xpath#NT-OrExpr), and the function [`not()`](http://www.w3.org/TR/xpath#function-not).** **`and`** has a higher priority than **`or`** and ...
472,977
<p>serial.write() method in pyserial seems to only send string data. I have arrays like [0xc0,0x04,0x00] and want to be able to send/receive them via the serial port? Are there any separate methods for raw I/O?</p> <p>I think I might need to change the arrays to ['\xc0','\x04','\x00'], still, null character might pose...
[ { "answer_id": 473057, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 5, "selected": true, "text": "<p>You need to convert your data to a string</p>\n\n<pre><code>\"\\xc0\\x04\\x00\"\n</code></pre>\n\n<p>Null characters are not a...
2009/01/23
[ "https://Stackoverflow.com/questions/472977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42968/" ]
serial.write() method in pyserial seems to only send string data. I have arrays like [0xc0,0x04,0x00] and want to be able to send/receive them via the serial port? Are there any separate methods for raw I/O? I think I might need to change the arrays to ['\xc0','\x04','\x00'], still, null character might pose a problem...
You need to convert your data to a string ``` "\xc0\x04\x00" ``` Null characters are not a problem in Python -- strings are not null-terminated the zero byte behaves just like another byte `"\x00"`. One way to do this: ``` >>> import array >>> array.array('B', [0xc0, 0x04, 0x00]).tostring() '\xc0\x04\x00' ```
472,984
<p>I'm having problems deploying a simple WebServices app (like "Hello World" simple) to OC4J. The same code works fine under Jetty, but breaks in OC4J, and I'm wondering if anyone else has faced the same issue. I'm using Enterprise Manager to deploy the app, but the deployment fails with this message:</p> <pre><code>...
[ { "answer_id": 473009, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 1, "selected": false, "text": "<p>I would think its a CLASSPATH issue. </p>\n\n<p>I'm not that familiar with OC4J, but how are you packaging/deploying your...
2009/01/23
[ "https://Stackoverflow.com/questions/472984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16787/" ]
I'm having problems deploying a simple WebServices app (like "Hello World" simple) to OC4J. The same code works fine under Jetty, but breaks in OC4J, and I'm wondering if anyone else has faced the same issue. I'm using Enterprise Manager to deploy the app, but the deployment fails with this message: ``` [Jan 23, 2...
I hate to ask the obvious, but have you looked at all the stuff for configuring OS4J and CXF together from the CXF web site? <http://cwiki.apache.org/CXF20DOC/appserverguide.html#AppServerGuide-OC4J>
472,989
<p>I have an Excel spreadsheet of data like:</p> <pre><code>ColumnA ColumnB 33 11 25 5 6 4 </code></pre> <p>What i would like to do is add a third column which shows the ratio of columnA to columnB in the format of A:B. For example:</p> <pre><code>ColumnA ColumnB Ratio 33 11 3:1 ...
[ { "answer_id": 473006, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 5, "selected": false, "text": "<p>Try this formula:</p>\n\n<pre><code>=SUBSTITUTE(TEXT(A1/B1,\"?/?\"),\"/\",\":\")\n</code></pre>\n\n<p>Result:</p>\n\n<p...
2009/01/23
[ "https://Stackoverflow.com/questions/472989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54508/" ]
I have an Excel spreadsheet of data like: ``` ColumnA ColumnB 33 11 25 5 6 4 ``` What i would like to do is add a third column which shows the ratio of columnA to columnB in the format of A:B. For example: ``` ColumnA ColumnB Ratio 33 11 3:1 25 5 5:1 6 4 3:2...
You are looking for the greatest common divisor (GCD). You can calculate it recursively in VBA, like this: ``` Function GCD(numerator As Integer, denominator As Integer) If denominator = 0 Then GCD = numerator Else GCD = GCD(denominator, numerator Mod denominator) End If End Function ``` And use it in...
473,028
<p>For my project I have settings that I added through the Settings in the project properties. </p> <p>I quickly discovered that editing the app.config file directly seems to no really update the settings value. Seems I have to view the project properties when I make a change and then recompile. </p> <ul> <li><p>I...
[ { "answer_id": 473052, "author": "Jay S", "author_id": 30440, "author_profile": "https://Stackoverflow.com/users/30440", "pm_score": 2, "selected": false, "text": "<p><strong>EDIT:</strong> My mistake. I misunderstood the purpose of the original question.</p>\n\n<p><strong>ORIGINAL TEXT...
2009/01/23
[ "https://Stackoverflow.com/questions/473028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
For my project I have settings that I added through the Settings in the project properties. I quickly discovered that editing the app.config file directly seems to no really update the settings value. Seems I have to view the project properties when I make a change and then recompile. * I'm wondering ... what is th...
This is silly ... and I think I am going to have to apologize for wasting everyone's time! But it looks like I just need to **set the scope to User** instead of Application and I can the write the new value.
473,041
<p>I have some existing Java code that does an XSLT transform programmatically - originally using Xalan. I have refactored it to be able to use another (externally configured) TransformerFactory.</p> <p>I have tried using the Saxon (v6.5.3 and v8.7) factory, but do not see any perfromance improvements - if anything Sa...
[ { "answer_id": 473051, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 2, "selected": false, "text": "<p>If you need to refresh the entire page, a post would probably be easier. </p>\n" }, { "answer_id": 473056, ...
2009/01/23
[ "https://Stackoverflow.com/questions/473041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15452/" ]
I have some existing Java code that does an XSLT transform programmatically - originally using Xalan. I have refactored it to be able to use another (externally configured) TransformerFactory. I have tried using the Saxon (v6.5.3 and v8.7) factory, but do not see any perfromance improvements - if anything Saxon is slo...
This question is a little tricky because it conflates two concepts. The first is POSTing and the second is Ajax. POSTing, as compared to GETting, is a different HTTP method with different implementation and semantics. Ajax, or XmlHttpRequest, has its counterpart in normal requesting/navigation. You can use POST or GET ...
473,059
<p>I misremembered what the key was for this Templates table and therefore I added the wrong field as a foreign key. Now I need to add the foreign key and I want to populate its values based on this other field that is already populated. I started trying to do this with an update statement, but I'm not sure how to do i...
[ { "answer_id": 473074, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "<pre><code>update Templates\nset TemplateId=Products.TemplateId\nfrom Templates\ninner join Products\n on Templates.Te...
2009/01/23
[ "https://Stackoverflow.com/questions/473059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26140/" ]
I misremembered what the key was for this Templates table and therefore I added the wrong field as a foreign key. Now I need to add the foreign key and I want to populate its values based on this other field that is already populated. I started trying to do this with an update statement, but I'm not sure how to do it. ...
You can do it with a simple UPDATE query ``` UPDATE Products SET Products.TemplateID = Templates.TemplateID FROM Templates WHERE Templates.TemplateName = Products.TemplateName ``` You do not need to specify the Products table in the FROM clause, nor a JOIN clause. Just specify the Templates table in the FROM clause....
473,060
<p>In testing, the user on a db i've used was a big jefe. In production, he only has Execute.</p> <p>When I called,</p> <pre><code>Membership.DeleteUser(user) </code></pre> <p>In testing, it worked. I try the same in production, and I get this:</p> <blockquote> <p>The DELETE statement conflicted with the REFEREN...
[ { "answer_id": 473101, "author": "Kyle B.", "author_id": 6158, "author_profile": "https://Stackoverflow.com/users/6158", "pm_score": 2, "selected": false, "text": "<p>I believe your 'REFERENCE' constraint is actually a Foreign key in the database that exists between the aspnet_Users tabl...
2009/01/23
[ "https://Stackoverflow.com/questions/473060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27483/" ]
In testing, the user on a db i've used was a big jefe. In production, he only has Execute. When I called, ``` Membership.DeleteUser(user) ``` In testing, it worked. I try the same in production, and I get this: > > The DELETE statement conflicted with the REFERENCE constraint > "FK\_\_aspnet\_Us\_\_UserI\_\_3770...
After a little inspection I found the issue is this line in the aspnet\_Users\_DeleteUser stored procedure: ``` IF ((@TablesToDeleteFrom & 1) <> 0 AND (EXISTS (SELECT name FROM sysobjects WHERE (name = N'vw_aspnet_MembershipUsers') AND (type = 'V')))) ``` There are 3 other similar lines for 3 other tables. The i...
473,080
<p>I have this ListBox:</p> <pre><code>&lt;ListBox Name="lbColor"&gt; &lt;ListBoxItem Content="Blue"/&gt; &lt;ListBoxItem Content="Red"/&gt; &lt;ListBoxItem Content="Orange"/&gt; &lt;/ListBox&gt; </code></pre> <p>This code pre-selects the choice alright, but doesn't set the focus, how can I do that?</p> ...
[ { "answer_id": 473103, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 3, "selected": true, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.uielement.focus.aspx\" rel=\"nof...
2009/01/23
[ "https://Stackoverflow.com/questions/473080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I have this ListBox: ``` <ListBox Name="lbColor"> <ListBoxItem Content="Blue"/> <ListBoxItem Content="Red"/> <ListBoxItem Content="Orange"/> </ListBox> ``` This code pre-selects the choice alright, but doesn't set the focus, how can I do that? ``` public Window1() { InitializeComponent(); lbCol...
You can use the [Focus](http://msdn.microsoft.com/en-us/library/system.windows.uielement.focus.aspx) method: ``` public Window1() { InitializeComponent(); lbColor.SelectedIndex = 1; lbColor.Focus(); } ```
473,087
<p>I've been tinkering with small functions on my own time, trying to find ways to refactor them (I recently read Martin Fowler's book <em><a href="https://rads.stackoverflow.com/amzn/click/com/0201485672" rel="nofollow noreferrer" rel="nofollow noreferrer">Refactoring: Improving the Design of Existing Code</a></em>). ...
[ { "answer_id": 473120, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 2, "selected": false, "text": "<p>You might want to try instantiating a <code>Regex</code> object as a class member and using the <code>RegexOpti...
2009/01/23
[ "https://Stackoverflow.com/questions/473087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16587/" ]
I've been tinkering with small functions on my own time, trying to find ways to refactor them (I recently read Martin Fowler's book *[Refactoring: Improving the Design of Existing Code](https://rads.stackoverflow.com/amzn/click/com/0201485672)*). I found the following function `MakeNiceString()` while updating another ...
1) Use a StringBuilder, preferrably set with a reasonable initial capacity (e.g. string length \* 5/4, to allow one extra space per four characters). 2) Try using a foreach loop instead of a for loop - it may well be simpler 3) You don't need to convert the string into a char array first - foreach will work over a st...
473,093
<p>how can i pass values from my custom components back to the main.mxml? i need to do this to pass back ana array collection </p>
[ { "answer_id": 473511, "author": "cdugga", "author_id": 24481, "author_profile": "https://Stackoverflow.com/users/24481", "pm_score": 0, "selected": false, "text": "<p>got it; just needed to import mx.core.Application;</p>\n" }, { "answer_id": 473632, "author": "Christian Nun...
2009/01/23
[ "https://Stackoverflow.com/questions/473093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
how can i pass values from my custom components back to the main.mxml? i need to do this to pass back ana array collection
You can call directly into Application using the static Application.application.yourPublicMethodName() or .yourPublicPropertyName = n, but you might also consider using the event framework, to keep your components loosely coupled. Since your component is by definition an event dispatcher, you can simply dispatch an eve...
473,094
<p>I am trying to have a table header, in a seperate div stay in place while a div undernearth is able to scroll al arge list of records. Both divs are in a div named Layer 3. Hereis the css file I am using:</p> <pre class="lang-css prettyprint-override"><code>#Layer3 { position:absolute; width: 89%; heigh...
[ { "answer_id": 473511, "author": "cdugga", "author_id": 24481, "author_profile": "https://Stackoverflow.com/users/24481", "pm_score": 0, "selected": false, "text": "<p>got it; just needed to import mx.core.Application;</p>\n" }, { "answer_id": 473632, "author": "Christian Nun...
2009/01/23
[ "https://Stackoverflow.com/questions/473094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am trying to have a table header, in a seperate div stay in place while a div undernearth is able to scroll al arge list of records. Both divs are in a div named Layer 3. Hereis the css file I am using: ```css #Layer3 { position:absolute; width: 89%; height: 40%; left: 10%; top: 56%; backgrou...
You can call directly into Application using the static Application.application.yourPublicMethodName() or .yourPublicPropertyName = n, but you might also consider using the event framework, to keep your components loosely coupled. Since your component is by definition an event dispatcher, you can simply dispatch an eve...
473,099
<p>How do I find out if a key in a dictionary has already been set to a non-None value?</p> <p>I want to increment the value if there's already one there, or set it to 1 otherwise:</p> <pre><code>my_dict = {} if my_dict[key] is not None: my_dict[key] = 1 else: my_dict[key] += 1 </code></pre>
[ { "answer_id": 473108, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 9, "selected": true, "text": "<p>You are looking for <a href=\"https://docs.python.org/3/library/collections.html#collections.defaultdict\" rel=\"noreferrer\">...
2009/01/23
[ "https://Stackoverflow.com/questions/473099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
How do I find out if a key in a dictionary has already been set to a non-None value? I want to increment the value if there's already one there, or set it to 1 otherwise: ``` my_dict = {} if my_dict[key] is not None: my_dict[key] = 1 else: my_dict[key] += 1 ```
You are looking for [`collections.defaultdict`](https://docs.python.org/3/library/collections.html#collections.defaultdict) (available for Python 2.5+). This ``` from collections import defaultdict my_dict = defaultdict(int) my_dict[key] += 1 ``` will do what you want. For regular Python `dict`s, if there is no va...