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
473,117
<p>I have a simple bat script that copies files from an known directory to a directory given by the user. How can I pass the path (it might contain spaces) to my script and use it with the xcopy command?</p> <hr> <p>In my code i have the following</p> <pre><code>:READ_PWA_PATH if "%1" == "" ( rem Set de...
[ { "answer_id": 473127, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>If you have a path with spaces you must surround it with quotation marks (\").</p>\n\n<p>Not sure if that's exactly what yo...
2009/01/23
[ "https://Stackoverflow.com/questions/473117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
I have a simple bat script that copies files from an known directory to a directory given by the user. How can I pass the path (it might contain spaces) to my script and use it with the xcopy command? --- In my code i have the following ``` :READ_PWA_PATH if "%1" == "" ( rem Set default path set...
Interesting one. I love collecting quotes about quotes handling in cmd/command. Your particular scripts gets fixed by using %1 instead of "%1" !!! By adding an 'echo on' ( or getting rid of an echo off ), you could have easily found that out.
473,119
<p>Heres my link ( BE WARNED, its got autoplay audio - sorry...!)</p> <p><a href="http://tinyurl.com/bt5n4c" rel="nofollow noreferrer">link text</a></p> <p>Its not the usual 'looks fine in FF but bad in IE' problem :)</p> <p>It looks fine in IE6/7 Firefox, but in Chrome &amp; Safari it has big problems with what loo...
[ { "answer_id": 473155, "author": "Bo Jeanes", "author_id": 56690, "author_profile": "https://Stackoverflow.com/users/56690", "pm_score": 3, "selected": true, "text": "<p>The problem is the margin-top on the <code>&lt;h4&gt;</code> inside <code>product-panel-content</code> <code>&lt;div&g...
2009/01/23
[ "https://Stackoverflow.com/questions/473119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
Heres my link ( BE WARNED, its got autoplay audio - sorry...!) [link text](http://tinyurl.com/bt5n4c) Its not the usual 'looks fine in FF but bad in IE' problem :) It looks fine in IE6/7 Firefox, but in Chrome & Safari it has big problems with what looks like either margin/padding, or positioning. ( That narrows it ...
The problem is the margin-top on the `<h4>` inside `product-panel-content` `<div>`s. Modify the following style in `site.css`: ``` .product-panel-content h4 { font-size:140%; letter-spacing:-0.5px; } ``` to be: ``` .product-panel-content h4 { font-size:140%; margin-top:0; letter-spacing:-0.5px;...
473,143
<p>I have created a simple grid of divs by left floating them and an empty div with a clear at the end of each row.</p> <p>This works fine in Firefox, but in IE I get extra vertical space between rows. I tried to apply the "clearfix" method, but I must be doing something wrong.</p> <p>Why does IE insert the extra ver...
[ { "answer_id": 473251, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 5, "selected": true, "text": "<p>IE is a bit <em>funny</em> about empty <code>&lt;div&gt;</code>s - it likes to give them the height of a line of text.</p>\...
2009/01/23
[ "https://Stackoverflow.com/questions/473143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3740/" ]
I have created a simple grid of divs by left floating them and an empty div with a clear at the end of each row. This works fine in Firefox, but in IE I get extra vertical space between rows. I tried to apply the "clearfix" method, but I must be doing something wrong. Why does IE insert the extra vertical space and h...
IE is a bit *funny* about empty `<div>`s - it likes to give them the height of a line of text. If you change `.clear` to this, it'll shrink to 1 pixel: ``` .clear { clear: both; height: 1px; overflow: hidden; } ``` Put a background colour on to see what's happening
473,148
<p>To add items to column 1 in my <code>listView</code> control (<code>Winform</code>) I'm using <code>listView1.Items.Add</code>, this works fine but how do I add items to columns 2 and 3 etc? </p>
[ { "answer_id": 473209, "author": "Inisheer", "author_id": 2982, "author_profile": "https://Stackoverflow.com/users/2982", "pm_score": 7, "selected": false, "text": "<p>There are several ways to do it, but here is one solution (for 4 columns).</p>\n\n<pre><code>string[] row1 = { \"s1\", \...
2009/01/23
[ "https://Stackoverflow.com/questions/473148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
To add items to column 1 in my `listView` control (`Winform`) I'm using `listView1.Items.Add`, this works fine but how do I add items to columns 2 and 3 etc?
There are several ways to do it, but here is one solution (for 4 columns). ``` string[] row1 = { "s1", "s2", "s3" }; listView1.Items.Add("Column1Text").SubItems.AddRange(row1); ``` And a more verbose way is here: ``` ListViewItem item1 = new ListViewItem("Something"); item1.SubItems.Add("SubItem1a"); item1.SubItems...
473,156
<p>It should be an easy question ,</p> <p>I am building a site under IIS , For one part of it inside a <strong>subdirectory like \blog</strong> I turned it to a <strong>vitual directory</strong> .</p> <p>the root folder has its own web.config and the blog sub Folder has its own .</p> <p>in the <strong>root's web.con...
[ { "answer_id": 473183, "author": "Jay S", "author_id": 30440, "author_profile": "https://Stackoverflow.com/users/30440", "pm_score": 0, "selected": false, "text": "<p>I have not been able to find a solution to this other than to move both applications into subfolders and ensure the paren...
2009/01/23
[ "https://Stackoverflow.com/questions/473156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50506/" ]
It should be an easy question , I am building a site under IIS , For one part of it inside a **subdirectory like \blog** I turned it to a **vitual directory** . the root folder has its own web.config and the blog sub Folder has its own . in the **root's web.config** I used : ``` <pages theme="DefaultTheme"> ``` a...
Look into the: ``` <location> ... </location> ``` elements that can be loaded into the web.config. Not everything will work under it, but you might be able to override the subfolder to have no theme. Either that or maybe you can restrict the theme to only the top level folder with those tags?
473,160
<p>Okay, I have ran in to a problem with VB.NET. So all those defenders of VB.NET please can you help me out? Here is my issue: I am using LINQ to Entities, it also works with LINQ to SQL, I build my edmx file I then create a Partial Publc Class of the same name as one of the entities All fine up to now, so here comes ...
[ { "answer_id": 473214, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 1, "selected": false, "text": "<p>There is no way round this. It's a flaw in how VB forces you to handle the implementation of interfaces.</p>\n\n<p>...
2009/01/23
[ "https://Stackoverflow.com/questions/473160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58309/" ]
Okay, I have ran in to a problem with VB.NET. So all those defenders of VB.NET please can you help me out? Here is my issue: I am using LINQ to Entities, it also works with LINQ to SQL, I build my edmx file I then create a Partial Publc Class of the same name as one of the entities All fine up to now, so here comes the...
A little bit of indirection in the partial class should do the trick... ``` Public Property AssetId() As Int32 Implements IAsset.AssetId Get Return Id1 End Get Set(ByVal value As Int32) Id1 = value End Set End Property ``` The property that implements the interface calls the actual pr...
473,173
<p>I'm setting up a public site and the first thing on my mind is SQL injection. I have some text fields I'm saving and am using linq to update/write to the database. Am I safe using linq? </p> <p>This example is creating the user account. </p> <pre><code>Data.MemberRegistrationDataContext context = new MemberRegistr...
[ { "answer_id": 473186, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 7, "selected": true, "text": "<p>Yes, LINQ will help stop SQL injection.</p>\n\n<blockquote>\n <p>LINQ to SQL passes all data to the\n database via SQL...
2009/01/23
[ "https://Stackoverflow.com/questions/473173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46064/" ]
I'm setting up a public site and the first thing on my mind is SQL injection. I have some text fields I'm saving and am using linq to update/write to the database. Am I safe using linq? This example is creating the user account. ``` Data.MemberRegistrationDataContext context = new MemberRegistrationDataContext(); D...
Yes, LINQ will help stop SQL injection. > > LINQ to SQL passes all data to the > database via SQL parameters. So, > although the SQL query is composed > dynamically, the values are substitued > server side through parameters > safeguarding against the most common > cause of SQL injection attacks. > > > Also...
473,181
<p>I have a simple question related to one-line programming. First an example:</p> <pre><code>function test(a) { var b=a.toString(); return b.replace(&quot;a&quot;,&quot;b&quot;); } </code></pre> <p>It's very simple (this function is, of course, useless), but the question here is little more complicated: What if ...
[ { "answer_id": 473212, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<p>I think you only have to try reading it to realise it's not a \"clean\" solution!\nI'd especially avoid chaining an assign...
2009/01/23
[ "https://Stackoverflow.com/questions/473181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58260/" ]
I have a simple question related to one-line programming. First an example: ``` function test(a) { var b=a.toString(); return b.replace("a","b"); } ``` It's very simple (this function is, of course, useless), but the question here is little more complicated: What if I was to do this in one line? I have my thou...
Your example may be over-complicating a simple operation but the technique you are demonstrating is called method 'chaining'. It's a perfectly valid form and can actually be used to make code more readable when the intermediate results are not needed or meaningful. My current favorite example of this is the wonderful...
473,182
<p>When serializing, I would like to serialize an object only once, then any references to that object should be serialized as a reference to the object. This is because, when I later deserialize the objects, I would like to maintain those references. To illustrate my goal, the code below should output "After Serializa...
[ { "answer_id": 473194, "author": "Jan Bannister", "author_id": 460845, "author_profile": "https://Stackoverflow.com/users/460845", "pm_score": 0, "selected": false, "text": "<p>You will have to do that by giving the objects identifiers other than their object reference. </p>\n\n<p>An obj...
2009/01/23
[ "https://Stackoverflow.com/questions/473182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21786/" ]
When serializing, I would like to serialize an object only once, then any references to that object should be serialized as a reference to the object. This is because, when I later deserialize the objects, I would like to maintain those references. To illustrate my goal, the code below should output "After Serializatio...
If you're using .NET 3 or later, you should use the `DataContractSerializer` and set `PreserveObjectReferences` to `true`.
473,188
<p>how to get output parameter from stored procedure of one table and by using that value how to insert data in another table which is in realation with that table? </p>
[ { "answer_id": 473196, "author": "SQLMenace", "author_id": 740, "author_profile": "https://Stackoverflow.com/users/740", "pm_score": 0, "selected": false, "text": "<p>an output parameter is just a value, I am not sure I understand your question. Are you talking about SQL Server 2008 Tabl...
2009/01/23
[ "https://Stackoverflow.com/questions/473188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
how to get output parameter from stored procedure of one table and by using that value how to insert data in another table which is in realation with that table?
When you create your SqlParameter object, assign Output to its Direction property. Then after you execute your query, cast out the value of the parameter to a C# variable and use it as you please: ``` SqlParameter newId = new SqlParameter(); newId.Direction = ParameterDirection.Output; SqlCommand cmd = new SqlCommand(...
473,195
<p>What is the function of the namespace here? </p> <p>I would think in this simple example I would be able to put "Key" and "XData" instead of "x:Key" and "x:XData" but when I do it says "Key" was not found in XmlDataProvider.</p> <pre><code>&lt;Window x:Class="DataBindingWPF.XmlBinding" xmlns="http://schemas.mi...
[ { "answer_id": 473281, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "<p>Did you also remove the :x from </p>\n\n<pre><code>xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n</cod...
2009/01/23
[ "https://Stackoverflow.com/questions/473195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
What is the function of the namespace here? I would think in this simple example I would be able to put "Key" and "XData" instead of "x:Key" and "x:XData" but when I do it says "Key" was not found in XmlDataProvider. ``` <Window x:Class="DataBindingWPF.XmlBinding" xmlns="http://schemas.microsoft.com/winfx/2006/x...
The "Key" property is not an actual property of the XmlDataProvider. It's a Xaml attribute that lives in the "<http://schemas.microsoft.com/winfx/2006/xaml>" namespace you prefixed with "x". StackPanel.Resources is a ResourceDictionary. In order to add something to a dictionary you need a Key/value pair. The Key attr...
473,205
<p>When retrieving values from a DataRow is it better to use the column name or column index?</p> <p>The column name is more readable and easier to maintain:</p> <pre><code>int price = (int)dr["Price"]; </code></pre> <p>While column index is just faster (I think):</p> <pre><code>int price = (int)dr[3]; </code></pre...
[ { "answer_id": 473213, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 2, "selected": false, "text": "<p>I would think the column name is the best way to go. It is easier to determine what you are pulling, and the column...
2009/01/23
[ "https://Stackoverflow.com/questions/473205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
When retrieving values from a DataRow is it better to use the column name or column index? The column name is more readable and easier to maintain: ``` int price = (int)dr["Price"]; ``` While column index is just faster (I think): ``` int price = (int)dr[3]; ``` Would using column names break if you decide to ob...
I generally prefer readability and understanding over speed. Go with the name. You could (should) use string constants that can be updated in one place if you decide to change database column names.
473,216
<p>Here's my desired result:</p> <p>Given a ASP.net MVC page that has a block at the top with several parameters for filtering against a list that is display below, something like...</p> <pre> TextBox1 RadioButton1 TextBox2 OtherOptions Here item item item </pre> <p>I'd like the filtering to be interacti...
[ { "answer_id": 473968, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 0, "selected": false, "text": "<p>Take a look at the approach StackOverflow used under the Users and Tags sections of the site. When you type in the te...
2009/01/23
[ "https://Stackoverflow.com/questions/473216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13139/" ]
Here's my desired result: Given a ASP.net MVC page that has a block at the top with several parameters for filtering against a list that is display below, something like... ``` TextBox1 RadioButton1 TextBox2 OtherOptions Here item item item ``` I'd like the filtering to be interactive capable on later iter...
[This jQuery plugin](http://trirand.com/jqgrid/jqgrid.html) may help you. Open "jqGrid Examples" -> "Advanced" -> "Search Big Sets" for sample of filtering and searching. There are a lot of other samples too.
473,218
<p>I have a search query that I'm inheriting and attempting to optimize. I am curious to hear if anyone has any best practices and recommendations for such. The production server is still SQL Server 2000 also.</p> <p>The query is an advanced customer search stored procedure that accepts 5 different search criteria pa...
[ { "answer_id": 473232, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 1, "selected": false, "text": "<ul>\n<li>Avoid \"OR\"s - they in general prevent the use of indexes</li>\n<li>Never put a \"%\" on the left side. - ...
2009/01/23
[ "https://Stackoverflow.com/questions/473218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28540/" ]
I have a search query that I'm inheriting and attempting to optimize. I am curious to hear if anyone has any best practices and recommendations for such. The production server is still SQL Server 2000 also. The query is an advanced customer search stored procedure that accepts 5 different search criteria parameters (i...
isn't this whole line ``` AND (@Zip = '' OR a.Zip = @Zip OR a.Zip LIKE @Zip + '%') ``` the same as this ``` AND (a.Zip LIKE @Zip + '%') ``` for sure ``` AND (a.Zip LIKE @Zip + '%') ``` it is the same as ``` a.Zip = @Zip OR a.Zip LIKE @Zip + '%' ```
473,236
<p>I'm working in C++ and I need to know if a scalar value (for instance a <code>double</code>) is "defined" or not. I also need to be able to "undef" it if needed:</p> <pre><code>class Foo { public: double get_bar(); private: double bar; void calculate_bar() { bar = something(); } }; double ...
[ { "answer_id": 473246, "author": "Jason S", "author_id": 44330, "author_profile": "https://Stackoverflow.com/users/44330", "pm_score": 2, "selected": false, "text": "<p>If you mean at run-time, there is no such thing. If <code>bar</code> is never initialized, it will have whatever random...
2009/01/23
[ "https://Stackoverflow.com/questions/473236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25418/" ]
I'm working in C++ and I need to know if a scalar value (for instance a `double`) is "defined" or not. I also need to be able to "undef" it if needed: ``` class Foo { public: double get_bar(); private: double bar; void calculate_bar() { bar = something(); } }; double Foo::get_bar() { if (...
As the other answers says, C++ doesn't have this concept. You can easily work around it though. Either you can have an undefined value which you initialize bar to in the constructor, typically -1.0 or something similar. If you know that calculate\_bar never returns negative values you can implement the undefined func...
473,271
<p>I'm using some code from SmallSharpTools Web Preview to get screen shots of websites but i get a blank screen shot if the url returns a 301/302 redirect. </p> <pre><code> WebBrowser wb = new WebBrowser(); wb.ScrollBarsEnabled = false; wb.Size = new Size(1024, 768); wb.ScriptErrorsSup...
[ { "answer_id": 473276, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 3, "selected": true, "text": "<p>Rasmus mentioned <a href=\"http://valgrind.org/\" rel=\"nofollow noreferrer\">valgrind</a> a couple times in his pr...
2009/01/23
[ "https://Stackoverflow.com/questions/473271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46706/" ]
I'm using some code from SmallSharpTools Web Preview to get screen shots of websites but i get a blank screen shot if the url returns a 301/302 redirect. ``` WebBrowser wb = new WebBrowser(); wb.ScrollBarsEnabled = false; wb.Size = new Size(1024, 768); wb.ScriptErrorsSuppressed = true...
Rasmus mentioned [valgrind](http://valgrind.org/) a couple times in his presentations. If I remember correctly it measures IO, memory, etc. Might want to take a look.
473,275
<p>I have a bunch of MDI child nodes that are all created in the same way and to reduce redundant code I'd like to be able to call a method, pass it a string (name of child node), have it create the node and add it to the parent.</p> <p>I can do all the stuff except create the class from a string of a class name, how ...
[ { "answer_id": 473290, "author": "GWLlosa", "author_id": 18071, "author_profile": "https://Stackoverflow.com/users/18071", "pm_score": 0, "selected": false, "text": "<p>If you have a string which is the name of the class, then you should be able to get a Type object therefrom, by calling...
2009/01/23
[ "https://Stackoverflow.com/questions/473275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
I have a bunch of MDI child nodes that are all created in the same way and to reduce redundant code I'd like to be able to call a method, pass it a string (name of child node), have it create the node and add it to the parent. I can do all the stuff except create the class from a string of a class name, how can I do t...
I'm currently using this in one of my applications to new up a class ``` public static IMobileAdapter CreateAdapter(Type AdapterType) { return (IMobileAdapter)System.Activator.CreateInstance(AdapterType); } ``` It's returning an instance of a class that implements IMobileAdapter, but you could use it equally easil...
473,282
<p>How do you left pad an <code>int</code> with zeros when converting to a <code>String</code> in java?</p> <p>I'm basically looking to pad out integers up to <code>9999</code> with leading zeros (e.g. 1 = <code>0001</code>).</p>
[ { "answer_id": 473305, "author": "Omar Kooheji", "author_id": 20400, "author_profile": "https://Stackoverflow.com/users/20400", "pm_score": 5, "selected": false, "text": "<p>Found this example... Will test...</p>\n\n<pre><code>import java.text.DecimalFormat;\nclass TestingAndQualityAssur...
2009/01/23
[ "https://Stackoverflow.com/questions/473282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
How do you left pad an `int` with zeros when converting to a `String` in java? I'm basically looking to pad out integers up to `9999` with leading zeros (e.g. 1 = `0001`).
Use [`java.lang.String.format(String,Object...)`](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#format-java.lang.String-java.lang.Object...-) like this: ``` String.format("%05d", yournumber); ``` for zero-padding with a length of 5. For hexadecimal output replace the `d` with an `x` as in `"%05x"`....
473,294
<p>I have the following css code:</p> <pre><code>#Layer3 { position:absolute; width: 89%; height: 40%; left: 10%; top: 56%; background-color: #f1ffff; } #Layer3 h1 { font-size: medium; color: #000033; text-decoration: none; text-align: center; } .tableheader { border-width:10px; border-style:solid; } .tablecon...
[ { "answer_id": 473314, "author": "geowa4", "author_id": 50214, "author_profile": "https://Stackoverflow.com/users/50214", "pm_score": 2, "selected": true, "text": "<pre><code>#tableheader {\n border: 10px solid #000;\n}\n</code></pre>\n\n<p>Try giving it a color.</p>\n\n<p>EDIT: since i...
2009/01/23
[ "https://Stackoverflow.com/questions/473294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have the following css code: ``` #Layer3 { position:absolute; width: 89%; height: 40%; left: 10%; top: 56%; background-color: #f1ffff; } #Layer3 h1 { font-size: medium; color: #000033; text-decoration: none; text-align: center; } .tableheader { border-width:10px; border-style:solid; } .tablecontent { hei...
``` #tableheader { border: 10px solid #000; } ``` Try giving it a color. EDIT: since its id is tableheader, try changing the style selector to be an id. You could also try using !important to see if anything is overriding your class selector. Specificity values: inline: 1000; id: 100, class: 10, element: 1 !imp...
473,325
<p>I asked a question earlier which elicited some great responses.</p> <p><a href="https://stackoverflow.com/questions/472733/how-would-you-tidy-up-this-controller-logic">Here's the earlier question</a></p> <p>On the back of some advice given there, I've tried moving the following controller logic</p> <pre><code> if...
[ { "answer_id": 473543, "author": "Samuel", "author_id": 32465, "author_profile": "https://Stackoverflow.com/users/32465", "pm_score": 4, "selected": true, "text": "<p>Instead of <code>status =</code> try <code>self.status =</code>. I've found that I needed to use <code>self.</code> to ch...
2009/01/23
[ "https://Stackoverflow.com/questions/473325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52092/" ]
I asked a question earlier which elicited some great responses. [Here's the earlier question](https://stackoverflow.com/questions/472733/how-would-you-tidy-up-this-controller-logic) On the back of some advice given there, I've tried moving the following controller logic ``` if params[:concept][:consulted_legal] == ...
Instead of `status =` try `self.status =`. I've found that I needed to use `self.` to change a model's attribute within the model. It's also much better to have `errors.empty?` at the end instead of `true`, so if you ever use `errors.add_to_base` in the future, your `set_status` method is ready to abort a save. **Edi...
473,327
<p>This is an Erlang question.</p> <p>I have run into some unexpected behavior by io:fread.</p> <p>I was wondering if someone could check whether there is something wrong with the way I use io:fread or whether there is a bug in io:fread.</p> <p>I have a text file which contains a "triangle of numbers"as follows:</p>...
[ { "answer_id": 488129, "author": "Vector", "author_id": 17058, "author_profile": "https://Stackoverflow.com/users/17058", "pm_score": 0, "selected": false, "text": "<p>I noticed that there are multiple instances where two numbers are merged, and it appears to be at the line boundaries on...
2009/01/23
[ "https://Stackoverflow.com/questions/473327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21435/" ]
This is an Erlang question. I have run into some unexpected behavior by io:fread. I was wondering if someone could check whether there is something wrong with the way I use io:fread or whether there is a bug in io:fread. I have a text file which contains a "triangle of numbers"as follows: ``` 59 73 41 52 40 09 26 ...
I'm going to go with it being a bug in Erlang, too, and a weird one. Changing the format string to "~2s" gives equally weird results: ``` ["59","73","4","15","2","40","0","92","6","53","0","6","34", "10","5","1","87","8","6","81","61","9","5","66","5","7", "25","6", [...]|...] ``` So it appears that it's counting...
473,366
<p>I'm working on a rather large project, and its unlikely will catch everything. I've found the event that notifies me of unhandled exceptions, however I haven't found a way to programmatically shut off the windows error dialog. Ideally, if there is an unhandled exception, I would like to have that event fired, provid...
[ { "answer_id": 473381, "author": "Aaron Smith", "author_id": 12969, "author_profile": "https://Stackoverflow.com/users/12969", "pm_score": 4, "selected": true, "text": "<p>This is what we did.</p>\n\n<pre><code>static void Main() {\n try\n {\n SubMain();\n }\n catch (E...
2009/01/23
[ "https://Stackoverflow.com/questions/473366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48552/" ]
I'm working on a rather large project, and its unlikely will catch everything. I've found the event that notifies me of unhandled exceptions, however I haven't found a way to programmatically shut off the windows error dialog. Ideally, if there is an unhandled exception, I would like to have that event fired, provide a...
This is what we did. ``` static void Main() { try { SubMain(); } catch (Exception e) { HandleUnhandledException(e); } } private static void SubMain() { // Setup unhandled exception handlers AppDomain.CurrentDomain.UnhandledException += // CLR new UnhandledExcepti...
473,379
<p>I am using the Apache Commons IO:</p> <pre><code> FileUtils.copyFileToDirectory(srcFile, destDir) </code></pre> <p>How do I make Windows lock the destination file during copy? Windows locks the file correctly if I use:</p> <pre><code> Runtime.getRuntime().exec( "cmd /c copy /Y \"" + srcFile.getCano...
[ { "answer_id": 473505, "author": "Kevin", "author_id": 26620, "author_profile": "https://Stackoverflow.com/users/26620", "pm_score": 3, "selected": true, "text": "<p>Java doesn't natively support file locking. </p>\n\n<p>If contention for the file is coming from within your program, per...
2009/01/23
[ "https://Stackoverflow.com/questions/473379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
I am using the Apache Commons IO: ``` FileUtils.copyFileToDirectory(srcFile, destDir) ``` How do I make Windows lock the destination file during copy? Windows locks the file correctly if I use: ``` Runtime.getRuntime().exec( "cmd /c copy /Y \"" + srcFile.getCanonicalPath() + "\" \"" + des...
Java doesn't natively support file locking. If contention for the file is coming from within your program, perhaps you need to build additional synchronization on top of the file copy to make sure concurrent writes don't clobber one another. However, if the contention is coming from somewhere external to your softwar...
473,397
<p>I'm working through <a href="https://rads.stackoverflow.com/amzn/click/com/0321503619" rel="nofollow noreferrer" rel="nofollow noreferrer">Cocoa Programming for Mac OS X (3rd ed)</a> and in chapter 4 I wrote this app:</p> <pre><code>int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutor...
[ { "answer_id": 473425, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 3, "selected": true, "text": "<p>doh! Just typing the code made me realize my problem. Doncha love it when that happens? </p>\n\n<p>I am retaining...
2009/01/23
[ "https://Stackoverflow.com/questions/473397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3381/" ]
I'm working through [Cocoa Programming for Mac OS X (3rd ed)](https://rads.stackoverflow.com/amzn/click/com/0321503619) and in chapter 4 I wrote this app: ``` int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; //create the date object NSCalendarDate *no...
doh! Just typing the code made me realize my problem. Doncha love it when that happens? I am retaining the date in my `init`, but I still had that extra `setEntryDate` method that was not calling retain. Removing this and calling the `initWithDate` method instead seemed to fix the problem.
473,401
<p>In JUnit 3, I could get the name of the currently running test like this:</p> <pre><code>public class MyTest extends TestCase { public void testSomething() { System.out.println("Current test is " + getName()); ... } } </code></pre> <p>which would print "Current test is testSomething". <...
[ { "answer_id": 473431, "author": "cordellcp3", "author_id": 36267, "author_profile": "https://Stackoverflow.com/users/36267", "pm_score": 2, "selected": false, "text": "<p>JUnit 4 does not have any out-of-the-box mechanism for a test case to get it’s own name (including during setup and ...
2009/01/23
[ "https://Stackoverflow.com/questions/473401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40310/" ]
In JUnit 3, I could get the name of the currently running test like this: ``` public class MyTest extends TestCase { public void testSomething() { System.out.println("Current test is " + getName()); ... } } ``` which would print "Current test is testSomething". Is there any out-of-the-b...
JUnit 4.7 added this feature it seems using [TestName-Rule](https://github.com/junit-team/junit/wiki/Rules#testname-rule). Looks like this will get you the method name: ``` import org.junit.Rule; public class NameRuleTest { @Rule public TestName name = new TestName(); @Test public void testA() { asse...
473,420
<p>I have following issue: I have a table for maintaining the hierarchical data. I'd like to use CTE from SQL 2005.</p> <pre><code>WITH tree (id, parentid, code, name) AS ( SELECT id, ofs.ParentID, ofs.code, ofs.name FROM OrganizationFeatures ofs WHERE ofs.ParentID IS NULL UNION ALL SELECT ofs...
[ { "answer_id": 473437, "author": "Loki", "author_id": 39057, "author_profile": "https://Stackoverflow.com/users/39057", "pm_score": 2, "selected": false, "text": "<p>To get the concatenated values, you need to do it in the with.</p>\n\n<p>To sort, you need to add an order by in the last ...
2009/01/23
[ "https://Stackoverflow.com/questions/473420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53332/" ]
I have following issue: I have a table for maintaining the hierarchical data. I'd like to use CTE from SQL 2005. ``` WITH tree (id, parentid, code, name) AS ( SELECT id, ofs.ParentID, ofs.code, ofs.name FROM OrganizationFeatures ofs WHERE ofs.ParentID IS NULL UNION ALL SELECT ofs.id, ofs.Paren...
To get the concatenated values, you need to do it in the with. To sort, you need to add an order by in the last select. ``` WITH tree (id, parentid, code, name) AS ( SELECT id, ofs.ParentID, ofs.code, ofs.name FROM OrganizationFeatures ofs WHERE ofs.ParentID IS NULL UNION ALL SELECT ofs.id, o...
473,435
<p>I wish to know where I can add Keywords for the syntax coloring in Flex Builder - i need to extend it a little for my own sanity.</p>
[ { "answer_id": 473437, "author": "Loki", "author_id": 39057, "author_profile": "https://Stackoverflow.com/users/39057", "pm_score": 2, "selected": false, "text": "<p>To get the concatenated values, you need to do it in the with.</p>\n\n<p>To sort, you need to add an order by in the last ...
2009/01/23
[ "https://Stackoverflow.com/questions/473435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18671/" ]
I wish to know where I can add Keywords for the syntax coloring in Flex Builder - i need to extend it a little for my own sanity.
To get the concatenated values, you need to do it in the with. To sort, you need to add an order by in the last select. ``` WITH tree (id, parentid, code, name) AS ( SELECT id, ofs.ParentID, ofs.code, ofs.name FROM OrganizationFeatures ofs WHERE ofs.ParentID IS NULL UNION ALL SELECT ofs.id, o...
473,446
<p>Is it possible to get the name of the currently logged in user (Windows/Unix) and the hostname of the machine?</p> <p>I assume it's just a property of some static environment class.</p> <p>I've found this for the user name</p> <pre><code>com.sun.security.auth.module.NTSystem NTSystem = new com.sun.securit...
[ { "answer_id": 473470, "author": "cordellcp3", "author_id": 36267, "author_profile": "https://Stackoverflow.com/users/36267", "pm_score": 9, "selected": true, "text": "<p>To get the currently logged in user:</p>\n\n<pre><code>System.getProperty(\"user.name\"); //platform independent \n</...
2009/01/23
[ "https://Stackoverflow.com/questions/473446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
Is it possible to get the name of the currently logged in user (Windows/Unix) and the hostname of the machine? I assume it's just a property of some static environment class. I've found this for the user name ``` com.sun.security.auth.module.NTSystem NTSystem = new com.sun.security.auth.module.NTSystem(); Sy...
To get the currently logged in user: ``` System.getProperty("user.name"); //platform independent ``` and the hostname of the machine: ``` java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost(); System.out.println("Hostname of local machine: " + localMachine.getHostName()); ```
473,463
<p>I am currently trying to validate a form server side, the way it works is all the data is put into and array, with the form field as the key and and the field data as the value, however I need to check that all the keys have a value associated with other wise I want the submittion to stop and the user having to edit...
[ { "answer_id": 473518, "author": "Anthony", "author_id": 18641, "author_profile": "https://Stackoverflow.com/users/18641", "pm_score": 0, "selected": false, "text": "<p>How about something like</p>\n\n<pre><code>&lt;?php\n$arrayFilled = true;\nforeach($array as $key=&gt;$value) {\n $a...
2009/01/23
[ "https://Stackoverflow.com/questions/473463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57872/" ]
I am currently trying to validate a form server side, the way it works is all the data is put into and array, with the form field as the key and and the field data as the value, however I need to check that all the keys have a value associated with other wise I want the submittion to stop and the user having to edit th...
One option is to do a bit of both. Have a separate array of field options with the field name as the key. ``` $fieldTypes = array('nameFirst' => 'name', 'nameLast' => 'name', 'phone' => 'phone', 'email' => 'email'); foreach($input as $key => $value)...
473,478
<p>I spend my days in vim, currently writing a lot of JavaScript. I've been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this?</p> <p>I tried this: <a href="http://mikecantelon.com/story/javascript-syntax-checking-vim" rel="nofollow...
[ { "answer_id": 496086, "author": "f3lix", "author_id": 60617, "author_profile": "https://Stackoverflow.com/users/60617", "pm_score": 6, "selected": true, "text": "<p>You can follow the intructions from <a href=\"http://wiki.whatwg.org/wiki/IDE\" rel=\"noreferrer\">JSLint web-service + VI...
2009/01/23
[ "https://Stackoverflow.com/questions/473478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40843/" ]
I spend my days in vim, currently writing a lot of JavaScript. I've been trying to find a way to integrate JSLint or something similar into vim to improve my coding. Has anyone managed to do something like this? I tried this: [Javascript Syntax Checking From Vim](http://mikecantelon.com/story/javascript-syntax-checkin...
You can follow the intructions from [JSLint web-service + VIM integration](http://wiki.whatwg.org/wiki/IDE) or do what I did: Download <http://jslint.webvm.net/mylintrun.js> and <http://www.jslint.com/fulljslint.js> and put them in a directory of your choice. Then add the following line to the beginning of mylintrun....
473,498
<p>Using Python's Imaging Library I want to create a PNG file.<br> I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page.</p> <p>Is the resolution encoded in the image? </p> <p>If so, how do I specify it?</p> <p>And even if it is,...
[ { "answer_id": 473514, "author": "Spikolynn", "author_id": 58142, "author_profile": "https://Stackoverflow.com/users/58142", "pm_score": 1, "selected": false, "text": "<p>Printers have various resolutions in which they print. If you select a print resolution of 200 DPI for instance (or i...
2009/01/23
[ "https://Stackoverflow.com/questions/473498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20498/" ]
Using Python's Imaging Library I want to create a PNG file. I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page. Is the resolution encoded in the image? If so, how do I specify it? And even if it is, does this have any relev...
As of PIL 1.1.5, there is a way to get the DPI: ``` im = ... # get image into PIL image instance dpi = im.info["dpi"] # retrive the DPI print dpi # (x-res, y-res) im.info["dpi"] = new dpi # (x-res, y-res) im.save("PNG") # uses the new DPI ```
473,520
<p>I am using temp data as follow in my controllers - very simple, when there is a problem:</p> <pre><code>TempData("StatusMessage") = "You have no items set to Auto-Ship." </code></pre> <p>Then on every page I have a user control as follows:</p> <pre><code>&lt;div class="error-container"&gt; &lt;% If TempData.Cont...
[ { "answer_id": 473569, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 6, "selected": true, "text": "<p>The <em>sole purpose</em> of TempData is to persist until the next request. Stuff you do not want to persist until th...
2009/01/23
[ "https://Stackoverflow.com/questions/473520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I am using temp data as follow in my controllers - very simple, when there is a problem: ``` TempData("StatusMessage") = "You have no items set to Auto-Ship." ``` Then on every page I have a user control as follows: ``` <div class="error-container"> <% If TempData.ContainsKey("ErrorMessage") Then%> <script> $('div...
The *sole purpose* of TempData is to persist until the next request. Stuff you do not want to persist until the next request should go into ViewData, instead. Realistically, this means that TempData is only safe to use when redirecting. When not redirecting, the "next request" could be anything.
473,522
<p>I am doing a CSV Import tool for the project I'm working on. The client needs to be able to enter the data in excel, export them as CSV and upload them to the database. For example I have this CSV record:</p> <pre><code> 1, John Doe, ACME Comapny (the typo is on purpose) </code></pre> <p>Of course, the c...
[ { "answer_id": 473529, "author": "MattK", "author_id": 52734, "author_profile": "https://Stackoverflow.com/users/52734", "pm_score": 5, "selected": true, "text": "<p>You might want to check out the <a href=\"http://en.wikipedia.org/wiki/Levenshtein_distance\" rel=\"nofollow noreferrer\">...
2009/01/23
[ "https://Stackoverflow.com/questions/473522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36047/" ]
I am doing a CSV Import tool for the project I'm working on. The client needs to be able to enter the data in excel, export them as CSV and upload them to the database. For example I have this CSV record: ``` 1, John Doe, ACME Comapny (the typo is on purpose) ``` Of course, the companies are kept in a sep...
You might want to check out the [Levenshtein Distance](http://en.wikipedia.org/wiki/Levenshtein_distance) algorithm as a starting point. It will rate the "distance" between two words. [This SO thread](https://stackoverflow.com/questions/41424/how-do-you-implement-a-did-you-mean) on implementing a Google-style "Do you ...
473,527
<p>The message that drives me crazy is <code>ORA-01008 - Not all variables bound</code>.</p> <p>Is there a way to know which one of the 42 possible variable names I have misspelled without staring at the monitor till my eyes pop out?</p> <p><strong>Update:</strong> I use <code>ADO.NET</code> to access the database. P...
[ { "answer_id": 473642, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 1, "selected": false, "text": "<p>I don't know of any way to get Oracle to make the error more specific. Maybe some future version will improve this er...
2009/01/23
[ "https://Stackoverflow.com/questions/473527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11185/" ]
The message that drives me crazy is `ORA-01008 - Not all variables bound`. Is there a way to know which one of the 42 possible variable names I have misspelled without staring at the monitor till my eyes pop out? **Update:** I use `ADO.NET` to access the database. Perhaps it does lose some information in Oracle excep...
In general, Oracle provides the line and column number of any errors, but it is up to the particular API you are using (unless you happen to be writing an OCI application, which is probably unlikely) as to whether and how those APIs are called. Since the answer is likely to end up being API-specific, what API are are y...
473,540
<p>The naive way of writing building a menu in a Java Swing app is to do something like:</p> <pre><code>JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open..."); openItem.addActionListener(new ActionListener() { /* action listener stuff */ } ) fileMenu.addMenuItem(openItem); </code></pre> <p>...
[ { "answer_id": 473586, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 0, "selected": false, "text": "<p><code>Action</code> is a bad abstraction - an <code>ActionListener</code> welded to a poor man's <code>Map<...
2009/01/23
[ "https://Stackoverflow.com/questions/473540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2197/" ]
The naive way of writing building a menu in a Java Swing app is to do something like: ``` JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open..."); openItem.addActionListener(new ActionListener() { /* action listener stuff */ } ) fileMenu.addMenuItem(openItem); ``` A more experienced develop...
Applications that I have developed that need to use that same actions across menus, toolbars, and other buttons have been done using Swing Application Framework. [Swing Application Framework](https://appframework.dev.java.net/) This framework will allow you to have a resource file where you can define all menu text, ...
473,562
<p>I have a javascript routine that is performing actions on a group of checkboxes, but the final action I want to set the clicked checkbox to checked or unchecked based on if the user was checking the box or unchecking.</p> <p>Unfortunately, every time I check for whether it is being checked or unchecked, it returns ...
[ { "answer_id": 473576, "author": "Paolo Bergantino", "author_id": 16417, "author_profile": "https://Stackoverflow.com/users/16417", "pm_score": 4, "selected": false, "text": "<p>The <code>value</code> attribute of a <code>checkbox</code> is what you set by:</p>\n\n<pre><code>&lt;input ty...
2009/01/23
[ "https://Stackoverflow.com/questions/473562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16642/" ]
I have a javascript routine that is performing actions on a group of checkboxes, but the final action I want to set the clicked checkbox to checked or unchecked based on if the user was checking the box or unchecking. Unfortunately, every time I check for whether it is being checked or unchecked, it returns "on" indic...
You should be evaluating against the checked property of the checkbox element. ``` for (i=0; i<arrChecks.length; i++) { var attribute = arrChecks[i].getAttribute("xid") if (attribute == elementName) { // if the current state is checked, unchecked and vice-versa if (arrChecks[i].checked) ...
473,568
<p>So I have a little WPF XAML that gets the titles of my RSS feed and puts them in a ListBox.</p> <p>However, it takes about 2 seconds to load.</p> <p>How can I have put some kind of AJAXy spinning graphic in the ListBox until the data is there?</p> <p>Here is the code:</p> <pre><code>&lt;Window x:Class="WpfApplic...
[ { "answer_id": 473580, "author": "Micah", "author_id": 17744, "author_profile": "https://Stackoverflow.com/users/17744", "pm_score": 1, "selected": false, "text": "<p>You could could create the spinny-loady-thingy and add it to the AdornerLayer of the ListBox.</p>\n" }, { "answer...
2009/01/23
[ "https://Stackoverflow.com/questions/473568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
So I have a little WPF XAML that gets the titles of my RSS feed and puts them in a ListBox. However, it takes about 2 seconds to load. How can I have put some kind of AJAXy spinning graphic in the ListBox until the data is there? Here is the code: ``` <Window x:Class="WpfApplication5.Window1" xmlns="http://sche...
My solution for this is to implement a asynchronous layer between my data and WPF. This totally decouples WPF from any delays on the data side and gives me nice events and properties to trigger and bind against. I built this on top of the [View Model or Presenter Model architecture](http://blogs.msdn.com/dancre/archiv...
473,575
<p>I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties that I didn't really want exposed outside my DLLs to internal. Then I started getting exceptions.</p> <p>So it seems that using the [Depend...
[ { "answer_id": 473634, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 3, "selected": false, "text": "<p>If the property is get-only, it makes more sense to use <a href=\"http://msdn.microsoft.com/en-us/library/cc440940....
2009/01/23
[ "https://Stackoverflow.com/questions/473575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28278/" ]
I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties that I didn't really want exposed outside my DLLs to internal. Then I started getting exceptions. So it seems that using the [Dependency] attri...
Well after a lof of poking around in reflector, I figured this out. By default, the code that finds a constructor for constructor injection calls: ``` ConstructorInfo[] constructors = typeToConstruct.GetConstructors() ``` With no BindingFlags, that will only detect public constructors. With some trickery (as in copy...
473,587
<p>I've jumped into an ongoing .Net 2.0 web app project for a larger company as a freelancer. Their DAL has lots of functions that manually construct and execute SQL statements -- many of them are long, messy and as a result difficult to understand and debug. I wrote a simple "sql helper" that lets me write things like...
[ { "answer_id": 473641, "author": "Pondidum", "author_id": 1500, "author_profile": "https://Stackoverflow.com/users/1500", "pm_score": 0, "selected": false, "text": "<p>SqLCommand and SQLParameter objects might be of use to you:</p>\n\n<pre><code> Dim sc As New SqlClient.SqlCommand\n\n ...
2009/01/23
[ "https://Stackoverflow.com/questions/473587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23063/" ]
I've jumped into an ongoing .Net 2.0 web app project for a larger company as a freelancer. Their DAL has lots of functions that manually construct and execute SQL statements -- many of them are long, messy and as a result difficult to understand and debug. I wrote a simple "sql helper" that lets me write things like th...
I created my own stored procedure to create insert statements based on a given table schema, I thought I was pretty awesome. Then I found this: > > [CREATE PROC sp\_generate\_inserts](http://vyaskn.tripod.com/code/generate_inserts.txt) > > > **EDIT** I know that I found about that script as a result of a previou...
473,604
<p>I think this should be easy, but it's evading me. I've got a many-to-many relationship between Accounts and Account Groups. An Account can be in zero or more Groups, so I'm using the standard join table.</p> <pre><code>Accounts -------- ID BankName AcctNumber Balance AccountGroups ------------- ID GroupName Join...
[ { "answer_id": 473652, "author": "SquareCog", "author_id": 15962, "author_profile": "https://Stackoverflow.com/users/15962", "pm_score": 0, "selected": false, "text": "<pre><code>SELECT act.acctid AS AcctId, bankName, acctNumber, Balance, \n NVL(jag.gid, '-') AS GroupID, NVL(gp.gro...
2009/01/23
[ "https://Stackoverflow.com/questions/473604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24197/" ]
I think this should be easy, but it's evading me. I've got a many-to-many relationship between Accounts and Account Groups. An Account can be in zero or more Groups, so I'm using the standard join table. ``` Accounts -------- ID BankName AcctNumber Balance AccountGroups ------------- ID GroupName JoinAccountsGroups...
This ``` SELECT a.BankName, a.AcctNumber, a.Balance, ag.GroupName FROM (Accounts a LEFT JOIN JoinAccountsGroups jag ON a.ID = jag.AID) LEFT JOIN AccountGroups ag ON jag.GID = ag.GroupName; ``` Will select the data for the first table, however to concatenate the groups (Monthly, Payroll), y...
473,607
<p>I have 3 tables and I have to inner join Table A with Table B but a left outer between Table A and Table C. </p> <p>Can I combine outer and inner join in the same query? I can nest queries and attain the desired result but I am unable to do both the joins in the same query. It appears that in other SQL languages, t...
[ { "answer_id": 473616, "author": "gkrogers", "author_id": 54501, "author_profile": "https://Stackoverflow.com/users/54501", "pm_score": 2, "selected": false, "text": "<p>You can use both inner and outer joins in the same query, but their order is important. See this question:<br>\n<a hre...
2009/01/23
[ "https://Stackoverflow.com/questions/473607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58348/" ]
I have 3 tables and I have to inner join Table A with Table B but a left outer between Table A and Table C. Can I combine outer and inner join in the same query? I can nest queries and attain the desired result but I am unable to do both the joins in the same query. It appears that in other SQL languages, the order o...
If I understand correctly you want something like this: ``` select * from a left outer join c inner join b on c.bID = b.ID on a.cID = c.ID ```
473,610
<p>I have been tasked with creating a reusable process for our Finance Dept to upload our payroll to the State(WI) for reporting. I need to create something that takes a sheet or range in Excel and creates a specifically formatted text file.</p> <p><strong><em>THE FORMAT</em></strong></p> <ul> <li>Column 1 - A Static...
[ { "answer_id": 474280, "author": "Andy Mikula", "author_id": 58114, "author_profile": "https://Stackoverflow.com/users/58114", "pm_score": -1, "selected": false, "text": "<p>Depending on the format of your document, I'd probably recommend exporting to .csv and working with that. If all y...
2009/01/23
[ "https://Stackoverflow.com/questions/473610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46724/" ]
I have been tasked with creating a reusable process for our Finance Dept to upload our payroll to the State(WI) for reporting. I need to create something that takes a sheet or range in Excel and creates a specifically formatted text file. ***THE FORMAT*** * Column 1 - A Static Number, never changes, position 1-10 * C...
Using VBA seems like the way to go to me. This lets you write a macro that takes care of all of the various formatting options and should, hopefully, be simple enough for your finance people to run themselves. You said you need something that takes a sheet or range in Excel. The first column never changes so we can st...
473,617
<p>Just finished read <a href="http://codebetter.com/blogs/gregyoung/archive/2009/01/22/the-data-centric-universe.aspx" rel="noreferrer">this post</a> by Greg Young, where he is talking about Microsoft recommending patterns with dumb data transfer objects. He implied that in the Java community, things are trending the ...
[ { "answer_id": 473959, "author": "MicSim", "author_id": 44522, "author_profile": "https://Stackoverflow.com/users/44522", "pm_score": 2, "selected": false, "text": "<p>The main point is how one defines logic. To give some examples:</p>\n\n<ol>\n<li>I wouldn't categorize a function getFul...
2009/01/23
[ "https://Stackoverflow.com/questions/473617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10771/" ]
Just finished read [this post](http://codebetter.com/blogs/gregyoung/archive/2009/01/22/the-data-centric-universe.aspx) by Greg Young, where he is talking about Microsoft recommending patterns with dumb data transfer objects. He implied that in the Java community, things are trending the other direction. My question i...
Matt, I would say that your shop is writing procedural code. I want to make clear that there is nothing wrong with that many large systems (including many I have worked on) have been written using procedural code. There is a time and place for it. Now procedural code has no place in a domain model. If you want to use...
473,618
<p>In attempting to use the Performance Tools on an ASP.NET website I'm getting various combinations of these errors (depending on what I attempt to do to fix them):</p> <ol> <li>The web site could not be configured correctly. Configuring '\web.config' failed. Access to the path '\web.config' is denied. - <em>I can ma...
[ { "answer_id": 483081, "author": "Tom Robinson", "author_id": 12124, "author_profile": "https://Stackoverflow.com/users/12124", "pm_score": 4, "selected": true, "text": "<p>I found a solution to the above errors which allows me to use the sampling profile method but there is another, pos...
2009/01/23
[ "https://Stackoverflow.com/questions/473618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12124/" ]
In attempting to use the Performance Tools on an ASP.NET website I'm getting various combinations of these errors (depending on what I attempt to do to fix them): 1. The web site could not be configured correctly. Configuring '\web.config' failed. Access to the path '\web.config' is denied. - *I can make this dissappe...
I found a solution to the above errors which allows me to use the sampling profile method but there is another, possibly unrelated problem when I try to use the instrumentation profile method. As in the original question - just check-out the Web.config or remove the read-only attribute, this fixes error 1. To fix err...
473,627
<p>I'm working with an incorrectly built spring application. Rather than use IOC, objects that require references are pulling their references from the context:</p> <pre><code> BeanFactory b = SingletonBeanFactoryLocator.getInstance(). useBeanFactory("factory").getFactory(); Bean foo = (FOO)beanF...
[ { "answer_id": 473729, "author": "Eclipse", "author_id": 8701, "author_profile": "https://Stackoverflow.com/users/8701", "pm_score": 2, "selected": false, "text": "<p>I would suggest using some sort of polygon model in memory to implement them the worlds, use a file to store them and ren...
2009/01/23
[ "https://Stackoverflow.com/questions/473627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19479/" ]
I'm working with an incorrectly built spring application. Rather than use IOC, objects that require references are pulling their references from the context: ``` BeanFactory b = SingletonBeanFactoryLocator.getInstance(). useBeanFactory("factory").getFactory(); Bean foo = (FOO)beanFactory.getBean...
For rendering, you'll need to use some sort of level-of-detail algorithm in order to seamlessly move from close to the planet's surface to far away. There are many dynamic LOD algorithms ([see here](http://www.vterrain.org/LOD/Papers/)). An older algorithm, called ROAM, can be adapted to handle spherical objects, or pl...
473,628
<p>Since a single web page may contain lots of external resource: external javascript, external css, images, applets, flash, etc., usually my conventional wisdom tells me that the window.onload event is fired when all the linked resources are finished downloading(though the external resources are usually downloaded in ...
[ { "answer_id": 473704, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 0, "selected": false, "text": "<p>Script resources are loaded before onload fires. However imgs load in a lazy asynchronous manner not necessarily ...
2009/01/23
[ "https://Stackoverflow.com/questions/473628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54060/" ]
Since a single web page may contain lots of external resource: external javascript, external css, images, applets, flash, etc., usually my conventional wisdom tells me that the window.onload event is fired when all the linked resources are finished downloading(though the external resources are usually downloaded in mul...
Check out [Cuzillion](http://stevesouders.com/cuzillion/). It was written by Steve Souders from the Yahoo performance team to evaluate exactly these things. What it comes down to is this: Browsers load scripts in the order they are encountered in the document and all other loading is halted while each script is downlo...
473,645
<p>Hello I have a number of crystal reports in my VS2008 project.</p> <p>I am making a change to a couple of my database tables and want to ensure that I make all the necessary changes to the reports. I have done a standard VS search for the specific stored procedure that is being used and it found no results. However...
[ { "answer_id": 479853, "author": "Philippe Grondier", "author_id": 11436, "author_profile": "https://Stackoverflow.com/users/11436", "pm_score": 2, "selected": true, "text": "<p>This is a part of the VB proc I built to generates the list of all tables used by my reports. Reports are list...
2009/01/23
[ "https://Stackoverflow.com/questions/473645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18821/" ]
Hello I have a number of crystal reports in my VS2008 project. I am making a change to a couple of my database tables and want to ensure that I make all the necessary changes to the reports. I have done a standard VS search for the specific stored procedure that is being used and it found no results. However, when I w...
This is a part of the VB proc I built to generates the list of all tables used by my reports. Reports are listed in a 'reports Table', and I use a memo field to store the name of all used tables. It is then quite easy to update all requested reports once tables have been modified. ``` Public function tablesUsedByARepo...
473,650
<p>This should be simple, not sure why I am having trouble with this..... In a data input range that a user is entering data there is a "left" and a "right" side of the form. Not all the data in any given row has to be filled in. I want to create a macro (and assign it to a hot key I.E. ctrl-z ) such that if it is hit...
[ { "answer_id": 473825, "author": "Andrew Cowenhoven", "author_id": 12281, "author_profile": "https://Stackoverflow.com/users/12281", "pm_score": 1, "selected": false, "text": "<p>In this case column \"x\" is actually column E:</p>\n\n<pre><code>Sub ToColE()\n Const colE = 5\n Dim o...
2009/01/23
[ "https://Stackoverflow.com/questions/473650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This should be simple, not sure why I am having trouble with this..... In a data input range that a user is entering data there is a "left" and a "right" side of the form. Not all the data in any given row has to be filled in. I want to create a macro (and assign it to a hot key I.E. ctrl-z ) such that if it is hit it ...
In this case column "x" is actually column E: ``` Sub ToColE() Const colE = 5 Dim offset As Integer offset = colE - ActiveCell.Column ActiveCell.offset(rowOffset:=0, columnOffset:=offset).Activate End Sub ```
473,661
<pre><code>#include &lt;stdio.h&gt; #include &lt;conio.h&gt; main() { char ch,name[20]; int i=0; clrscr(); printf("Enter a string:"); while((ch=getch())!='\n') { name[i]=ch; i++; } name[i] = '\0'; printf("%s",name); } </code></pre> <p>When I give "abc" as input and i...
[ { "answer_id": 473668, "author": "Binary Worrier", "author_id": 18797, "author_profile": "https://Stackoverflow.com/users/18797", "pm_score": 3, "selected": false, "text": "<p>Try \\r instead of \\n</p>\n\n<p>\\n is the new line character (0x0A) or 10 decimal, \\r is the carrige return c...
2009/01/23
[ "https://Stackoverflow.com/questions/473661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58349/" ]
``` #include <stdio.h> #include <conio.h> main() { char ch,name[20]; int i=0; clrscr(); printf("Enter a string:"); while((ch=getch())!='\n') { name[i]=ch; i++; } name[i] = '\0'; printf("%s",name); } ``` When I give "abc" as input and if I press enter it's not workin...
Try \r instead of \n \n is the new line character (0x0A) or 10 decimal, \r is the carrige return character (0x0D) or 13 decimal. The return key is a carrige return.
473,662
<p>Is that .NET related? It appears to be a pointer of some sort, what is the difference?</p> <p>Edit: </p> <p>I actually know it is the XOR operator, but look at this example from this page.</p> <pre><code>void objectCollection() { using namespace System::Collections; **ArrayList ^as = gcnew ArrayList;** ...
[ { "answer_id": 473667, "author": "Kevin", "author_id": 26620, "author_profile": "https://Stackoverflow.com/users/26620", "pm_score": 3, "selected": false, "text": "<p>In C++, that is the <a href=\"http://en.wikipedia.org/wiki/Xor\" rel=\"nofollow noreferrer\">XOR</a> operator.</p>\n" }...
2009/01/23
[ "https://Stackoverflow.com/questions/473662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is that .NET related? It appears to be a pointer of some sort, what is the difference? Edit: I actually know it is the XOR operator, but look at this example from this page. ``` void objectCollection() { using namespace System::Collections; **ArrayList ^as = gcnew ArrayList;** //... } ``` What is th...
I'm assuming that you're looking at constructs of the form: ``` Foo ^bar = gcnew Foo(); ``` You're right, in .NET it is a pointer-"like" type and is part of C++/CLI, not but not standard ISO C++. It's a reference to a garbage-collected, managed .NET object as opposed to a regular, unmanaged C++ object. As the othe...
473,666
<p>Does Perl have an enumeration type <em>that adheres to best practices</em>, or maybe more importantly, does it need one?</p> <p>The project I am working one uses strings all over the place to denote things that would typically use an Enum in a language like C#. For example, we have a set of phone numbers in an arr...
[ { "answer_id": 473707, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 4, "selected": false, "text": "<p>Perl doesn't support the concept natively but there are modules to add this functionality</p>\n\n<p><a href=\"https...
2009/01/23
[ "https://Stackoverflow.com/questions/473666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6406/" ]
Does Perl have an enumeration type *that adheres to best practices*, or maybe more importantly, does it need one? The project I am working one uses strings all over the place to denote things that would typically use an Enum in a language like C#. For example, we have a set of phone numbers in an array of hashes, each...
No, there isn't a built-in enum construct. Perl doesn't do a lot of strict typing, so I think there's actually little need for one. In my opinion, the [`Readonly`](https://metacpan.org/pod/Readonly) approach you used is solid. There's also the more traditional [`constant`](http://perldoc.perl.org/constant.html) pragm...
473,679
<p>I have a quick little application and wanted to give a try to develop using TDD. I've never used TDD and actually didn't even know what it was until I found ASP.NET-MVC. (My first MVC app had unit tests, but they were brittle, way coupled, took too much up keep, and were abandoned -- I've come to learn unit tests ...
[ { "answer_id": 473712, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 2, "selected": false, "text": "<p>Instead of making the setters public, make them internal and then make your test assembly InternalsVisibleTo in your...
2009/01/23
[ "https://Stackoverflow.com/questions/473679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36602/" ]
I have a quick little application and wanted to give a try to develop using TDD. I've never used TDD and actually didn't even know what it was until I found ASP.NET-MVC. (My first MVC app had unit tests, but they were brittle, way coupled, took too much up keep, and were abandoned -- I've come to learn unit tests != TD...
One solution is to not have the constructor do the work: ``` public class PurchaseOrder { public PurchaseOrder(string newNumber, string newLine) { NewNumber = newNumber; NewLine = newLine; } // ... } ``` Then testing is easy and isolated - you're not testing `GetNewNumber` and `GetNew...
473,684
<p>I can not control the scrolling of a scrollpane from within my actionscript (I am using actionscript 3.0)</p> <p><strong>Here is my Definition:</strong></p> <pre><code>var scrollPane:ScrollPane = new ScrollPane(); scrollPane.verticalScrollPolicy = "false"; scrollPane.move(374, 0); scrollPane.setSize(476, 370); </c...
[ { "answer_id": 473730, "author": "James Hay", "author_id": 47339, "author_profile": "https://Stackoverflow.com/users/47339", "pm_score": 1, "selected": false, "text": "<p>horizontalScrollPosition is a property of ScrollPane so you would set it through</p>\n\n<p>scrollPane.horizontalScrol...
2009/01/23
[ "https://Stackoverflow.com/questions/473684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19226/" ]
I can not control the scrolling of a scrollpane from within my actionscript (I am using actionscript 3.0) **Here is my Definition:** ``` var scrollPane:ScrollPane = new ScrollPane(); scrollPane.verticalScrollPolicy = "false"; scrollPane.move(374, 0); scrollPane.setSize(476, 370); ``` **When I try to set it - scroll...
If you look at the error trace, the error is occuring inside of ``` fl.containers::ScrollPane/setScrollDrag(). ``` If you look [here](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/) you find out that scrollDrag ... *Gets or sets a value that indicates whether scrolling occurs when a user drags on cont...
473,685
<p>I was 'forced' to add <code>myLocalVar = null;</code> statement into finally clause just before leaving method. Reason is to help GC. I was told I will get SMS's during night when server crashes next time, so I better did it :-).</p> <p>I think this is pointless, as myLocalVar is scoped to method, and will be 'lost...
[ { "answer_id": 473699, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 3, "selected": false, "text": "<p>That is a myth that goes way back to when java first came out and C++ guys didn't trust the gc.</p>\n\n<p>The gc kn...
2009/01/23
[ "https://Stackoverflow.com/questions/473685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47190/" ]
I was 'forced' to add `myLocalVar = null;` statement into finally clause just before leaving method. Reason is to help GC. I was told I will get SMS's during night when server crashes next time, so I better did it :-). I think this is pointless, as myLocalVar is scoped to method, and will be 'lost' as soon as method e...
There was an old piece of Sun documentation, *[Java Platform Performance](https://web.archive.org/web/20120626144027/http://java.sun.com:80/docs/books/performance/1st_edition/html/JPAppGC.fm.html)* (link sadly now broken, and I haven't been able to find a new one), which described a situation where nulling a local vari...
473,687
<p>I have an ASP.NET MVC project containing an AdminController class and giving me URls like these:</p> <blockquote> <p><a href="http://example.com/admin/AddCustomer" rel="noreferrer">http://example.com/admin/AddCustomer</a></p> <p><a href="http://examle.com/Admin/ListCustomers" rel="noreferrer">http://examle.com/Admin...
[ { "answer_id": 473697, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>You should have access to the <code>UserHostAddress</code> in the Request object in your controller to do the restri...
2009/01/23
[ "https://Stackoverflow.com/questions/473687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5017/" ]
I have an ASP.NET MVC project containing an AdminController class and giving me URls like these: > > <http://example.com/admin/AddCustomer> > > > <http://examle.com/Admin/ListCustomers> > > > I want to configure the server/app so that URIs containing **/Admin** are only accessible from the 192.168.0.0/24 networ...
I know this is an old question, but I needed to have this functionality today so I implemented it and thought about posting it here. Using the IPList class from here (<http://www.codeproject.com/KB/IP/ipnumbers.aspx>) **The filter attribute FilterIPAttribute.cs:** ``` using System; using System.Collections.Generic; ...
473,720
<p>The following code demonstrates a weird problem I have in a Turbo C++ Explorer project. One of the three stack objects in D::D() is not destroyed after going out of scope. </p> <p>This only happens if compiled in release mode, the auto_ptrs a_ and b_ are of different types and the exception thrown doesn't inherit f...
[ { "answer_id": 473737, "author": "Andrew Rollings", "author_id": 40410, "author_profile": "https://Stackoverflow.com/users/40410", "pm_score": 1, "selected": false, "text": "<p>If an exception is thrown in an object constructor, the destructor will not run.</p>\n\n<p>The compiler has no ...
2009/01/23
[ "https://Stackoverflow.com/questions/473720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4097/" ]
The following code demonstrates a weird problem I have in a Turbo C++ Explorer project. One of the three stack objects in D::D() is not destroyed after going out of scope. This only happens if compiled in release mode, the auto\_ptrs a\_ and b\_ are of different types and the exception thrown doesn't inherit from std...
This appears to be a compiler bug. I just ran the same sample in VS2008SP1 and got the expected output.
473,782
<p>How do you do "inline functions" in C#? I don't think I understand the concept. Are they like anonymous methods? Like lambda functions?</p> <p><strong>Note</strong>: The answers almost entirely deal with the ability to <a href="http://en.wikipedia.org/wiki/Inline_expansion" rel="noreferrer">inline functions</a>, i....
[ { "answer_id": 473788, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 7, "selected": false, "text": "<p>Inline methods are simply a compiler optimization where the code of a function is rolled into the caller.</p>\n...
2009/01/23
[ "https://Stackoverflow.com/questions/473782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356/" ]
How do you do "inline functions" in C#? I don't think I understand the concept. Are they like anonymous methods? Like lambda functions? **Note**: The answers almost entirely deal with the ability to [inline functions](http://en.wikipedia.org/wiki/Inline_expansion), i.e. "a manual or compiler optimization that replaces...
Finally in .NET 4.5, the CLR allows one to hint/suggest1 method inlining using [`MethodImplOptions.AggressiveInlining`](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.methodimploptions%28v=VS.110%29.aspx) value. It is also available in the Mono's trunk (committed today). ``` // The full attrib...
473,790
<p>I'm rolling my own logger class, and want to represent the heirarchy of logs as the app moves through different phases:</p> <pre><code>log start loading loaded 400 values processing couldn't process var "x" </code></pre> <p>etc.</p> <p>In C++ (yes I know), I'd use RAII classlets that push...
[ { "answer_id": 473890, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.trace.aspx\" rel=\"nofollow noreferrer\"><code...
2009/01/23
[ "https://Stackoverflow.com/questions/473790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11801/" ]
I'm rolling my own logger class, and want to represent the heirarchy of logs as the app moves through different phases: ``` log start loading loaded 400 values processing couldn't process var "x" ``` etc. In C++ (yes I know), I'd use RAII classlets that pushed themselves on the log stack wh...
You can get the behavior you are asking about if you use the [using](http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx) statement with an IDisposable-class. Do something like this: ``` public class LogContext: IDisposable { private readonly Logger _logger; private readonly string _context; public Lo...
473,801
<p>I am trying to use oauth with the rares-branch Ruby gem. I keep getting the error:</p> <p>instance of OAuth::Consumer needs to have method `marshal_load'</p> <p>My code, activate.rb is below. Any thoughts on how to fix this? THANKS! -Henry</p> <pre><code>require 'oauth/consumer' def index @consumer = OAuth::...
[ { "answer_id": 476247, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 0, "selected": false, "text": "<p>You need to have the user physically authorize it on the Netflix site. In this case, probably you. As I understand it, you...
2009/01/23
[ "https://Stackoverflow.com/questions/473801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to use oauth with the rares-branch Ruby gem. I keep getting the error: instance of OAuth::Consumer needs to have method `marshal\_load' My code, activate.rb is below. Any thoughts on how to fix this? THANKS! -Henry ``` require 'oauth/consumer' def index @consumer = OAuth::Consumer.new("CONSUMER KEY","...
The token isn't serializable, so you can't store it in the session. Store the token key and secret individually in the session instead, and create a new OAuthToken with the key and secret when you need it again. You may need to clear out your session store to get rid of the token that you already put in there.
473,809
<p>What is the best way to play audio utilzing the J2ME Media libary? For example, should I make use of the MMAPI or should I just use the Midlet's platformRequest(String s) method?</p>
[ { "answer_id": 479879, "author": "Anthony Rizk", "author_id": 45837, "author_profile": "https://Stackoverflow.com/users/45837", "pm_score": 2, "selected": false, "text": "<p>By <em>best</em>, what do you mean? Highest quality? Best user experience? Most standards-compliant?</p>\n\n<p>B...
2009/01/23
[ "https://Stackoverflow.com/questions/473809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57627/" ]
What is the best way to play audio utilzing the J2ME Media libary? For example, should I make use of the MMAPI or should I just use the Midlet's platformRequest(String s) method?
The following code should work for 90-95% of handsets out there that support JSR-135. Ordering of all the various method calls is key for this to be portable. This is for sounds local to your JAR. Any streamed audio would be another problem altogether :) ``` // loads the InputStream for the sound InputStream inputStre...
473,812
<p>Our custom automatic email delivery service is hitting this problem with a couple of our clients' SMTP servers. It only happens with about three of them--the message is bounced back with the following response from the SMTP server:</p> <pre><code>SMTP error from remote mail server after end of data: host clients.ho...
[ { "answer_id": 473846, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": true, "text": "<p>There are no <code>Message-ID</code> or <code>Date</code> headers in the messages being generated by your program. That m...
2009/01/23
[ "https://Stackoverflow.com/questions/473812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1857603/" ]
Our custom automatic email delivery service is hitting this problem with a couple of our clients' SMTP servers. It only happens with about three of them--the message is bounced back with the following response from the SMTP server: ``` SMTP error from remote mail server after end of data: host clients.host.name [XXX.X...
There are no `Message-ID` or `Date` headers in the messages being generated by your program. That may be why they're getting rejected. Also, strictly speaking SMTP requires that the lines are CRLF delimited. I can't tell whether that's what you've got or not.
473,854
<p>How can you convert wav files with MPeg layer 3 (MPeg3) audio format to PCM?</p>
[ { "answer_id": 473896, "author": "Lucas Jones", "author_id": 41981, "author_profile": "https://Stackoverflow.com/users/41981", "pm_score": 3, "selected": false, "text": "<p>You could use <a href=\"http://ffmpeg.org\" rel=\"noreferrer\">FFMPEG</a> called from the command-line, like so:</p...
2009/01/23
[ "https://Stackoverflow.com/questions/473854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can you convert wav files with MPeg layer 3 (MPeg3) audio format to PCM?
You could use [FFMPEG](http://ffmpeg.org) called from the command-line, like so: ``` ffmpeg -i source.wav -f wav -acodec pcm dest.wav ``` **NOTE**: Untested Also, Windows binaries are available (I had some from another place as well) [here](http://ffdshow.faireal.net/mirror/ffmpeg/).
473,862
<p>I seem to be using the wrong search terms for this in Google...</p> <p>I have written a Generic Class for Many-To-Many Associations, but I'm guessing this has already been done. It is highly likely that it exists in an implementation much better than my own. This is my first foray into writing a generic class.</p...
[ { "answer_id": 473870, "author": "Michael Myers", "author_id": 13531, "author_profile": "https://Stackoverflow.com/users/13531", "pm_score": 2, "selected": false, "text": "<p>Looks like <a href=\"http://commons.apache.org/collections/api-release/org/apache/commons/collections/MultiMap.ht...
2009/01/23
[ "https://Stackoverflow.com/questions/473862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58363/" ]
I seem to be using the wrong search terms for this in Google... I have written a Generic Class for Many-To-Many Associations, but I'm guessing this has already been done. It is highly likely that it exists in an implementation much better than my own. This is my first foray into writing a generic class. For a better ...
Looks like [Apache Commons Multimap](http://commons.apache.org/collections/api-release/org/apache/commons/collections/MultiMap.html) might be useful. **EDIT:** except it's one-to-many, not many-to-many. However, it still might be handy to use instead of your `Map<T, List<S>>` and `Map<S, List<T>>`, or as a reference.
473,874
<p>Hopefully someone can shed a little light on an issue that I'm currently having with an Oracle DB - I'm sure it's something simple!!</p> <p>I've managed to recreate this in a sample, so here is the DB structure:</p> <pre><code>CREATE TABLE MyTable( ixMyTable NUMBER, clobData CLOB ) / CREATE OR REPLACE PAC...
[ { "answer_id": 473904, "author": "Thomas Jones-Low", "author_id": 23030, "author_profile": "https://Stackoverflow.com/users/23030", "pm_score": 4, "selected": true, "text": "<p>Are you sure that you are reading the blob from disk each time, and not reading if from disk cache the second a...
2009/01/23
[ "https://Stackoverflow.com/questions/473874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/951280/" ]
Hopefully someone can shed a little light on an issue that I'm currently having with an Oracle DB - I'm sure it's something simple!! I've managed to recreate this in a sample, so here is the DB structure: ``` CREATE TABLE MyTable( ixMyTable NUMBER, clobData CLOB ) / CREATE OR REPLACE PACKAGE PKGTEST AS P...
Are you sure that you are reading the blob from disk each time, and not reading if from disk cache the second and following? I've seen this problem with performance testing, particularly on Oracle, where the first run of a test is terrible. Then with one minor (and seeming insignificant change) the performance sudden...
473,880
<p>I need to find a way to proxy some traffic on port 80 to tinyproxy running on a separate port. We have a client working behind a very strict firewall with only port 80 open (and cannot get to sites like meebo.com, etc). I was hoping I could create a CNAME to our domain and a virtual host on apache, catch the request...
[ { "answer_id": 473904, "author": "Thomas Jones-Low", "author_id": 23030, "author_profile": "https://Stackoverflow.com/users/23030", "pm_score": 4, "selected": true, "text": "<p>Are you sure that you are reading the blob from disk each time, and not reading if from disk cache the second a...
2009/01/23
[ "https://Stackoverflow.com/questions/473880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54356/" ]
I need to find a way to proxy some traffic on port 80 to tinyproxy running on a separate port. We have a client working behind a very strict firewall with only port 80 open (and cannot get to sites like meebo.com, etc). I was hoping I could create a CNAME to our domain and a virtual host on apache, catch the request fo...
Are you sure that you are reading the blob from disk each time, and not reading if from disk cache the second and following? I've seen this problem with performance testing, particularly on Oracle, where the first run of a test is terrible. Then with one minor (and seeming insignificant change) the performance sudden...
473,887
<p>I'm using Automation to get_Text from an Excel worksheet. I do this because I need the formatted value (getting the value of the cell doesn't apply any formatting). If the column the cell is in is too narrow, I get "#####" the same was I would if I were to look at the spreadsheet via Excel. How can I avoid that? ...
[ { "answer_id": 474219, "author": "Andy Mikula", "author_id": 58114, "author_profile": "https://Stackoverflow.com/users/58114", "pm_score": 0, "selected": false, "text": "<p>You should be able to get and set the column width (rangeobject.ColumnWidth) - increasing the width before grabbing...
2009/01/23
[ "https://Stackoverflow.com/questions/473887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965047/" ]
I'm using Automation to get\_Text from an Excel worksheet. I do this because I need the formatted value (getting the value of the cell doesn't apply any formatting). If the column the cell is in is too narrow, I get "#####" the same was I would if I were to look at the spreadsheet via Excel. How can I avoid that? EDI...
The `IRange` interface provides an `AutoFit()` method. According to [the documentation](http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.autofit(VS.80).aspx), calling this would make columns wide enough to fit their contents. (*It's the .NET interop documentation, but I expect no differenc...
473,892
<p>I have a statistics page which has a meta refresh tag on it.</p> <pre><code>&lt;meta http-equiv="refresh" content="10" /&gt; </code></pre> <p>How do I stop it forcing a refresh of the images in the page too? I've tried setting Cache control but the browser (IE7) still refreshes the 50+ images in the page.</p> <pr...
[ { "answer_id": 473923, "author": "Spikolynn", "author_id": 58142, "author_profile": "https://Stackoverflow.com/users/58142", "pm_score": 0, "selected": false, "text": "<p>Maybe your IE is set to not cache images? How do you generate the images? Do they contain some kind of no-cache heade...
2009/01/23
[ "https://Stackoverflow.com/questions/473892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4453/" ]
I have a statistics page which has a meta refresh tag on it. ``` <meta http-equiv="refresh" content="10" /> ``` How do I stop it forcing a refresh of the images in the page too? I've tried setting Cache control but the browser (IE7) still refreshes the 50+ images in the page. ``` Response.Cache.AppendCacheExtension...
I solved this issue by using javascript to manually refresh the page rather than the meta tag. This stopped the browser refreshing all the images on every reload, but still forced the browser to refresh the ASPX page itself. ``` <script> setTimeout('document.location=document.location',10000) </script> ```
473,915
<p>Should I make my own framework by wrapping up the STL classes and/or Boost libraries so that if I need to change the implementation of the string, vectors, lists, etc. or I need to write functions that MFC, other other libraries or even other platforms would need to use their format, I can easily mutate them to meet...
[ { "answer_id": 473927, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Should I make my own framework?</p>\n</blockquote>\n\n<p>Uh... no.</p>\n\n<p>I wouldn't really worr...
2009/01/23
[ "https://Stackoverflow.com/questions/473915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23528/" ]
Should I make my own framework by wrapping up the STL classes and/or Boost libraries so that if I need to change the implementation of the string, vectors, lists, etc. or I need to write functions that MFC, other other libraries or even other platforms would need to use their format, I can easily mutate them to meet th...
It seems to me like there won't be a lot of benefit to this; in my experience, the *point* of using these frameworks is so that you don't go reinventing the wheel. If you find that you need to write a new string class or a new vector class, you should think really hard about it, and make sure you're not just doing some...
473,934
<p>I have a generic class </p> <pre><code>public MyClass&lt;TContext, T&gt; where TContext : DataContext </code></pre> <p>that effectively acts on an instance of another</p> <pre><code>public class MyOtherClass&lt;T&gt; : IEnumerable&lt;T&gt; </code></pre> <p>I want to enforce that the <code>TContext</code> has a <...
[ { "answer_id": 473939, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 4, "selected": true, "text": "<p>Are you wanting to verify that TContext has a member which is a Table&lt;T&gt;? If so, the only way to do that is to d...
2009/01/23
[ "https://Stackoverflow.com/questions/473934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45914/" ]
I have a generic class ``` public MyClass<TContext, T> where TContext : DataContext ``` that effectively acts on an instance of another ``` public class MyOtherClass<T> : IEnumerable<T> ``` I want to enforce that the `TContext` has a `Table<T>`. Is there a clean way to enforce this?
Are you wanting to verify that TContext has a member which is a Table<T>? If so, the only way to do that is to define an interface for this contract and alter your generic constraints ``` interface IMyTable<T> { Table<T> Table; } public MyClass<TContext,T> where TContext : DataContext,IMyTable<T> ``` **EDIT** Ja...
473,943
<p>I've been working on optimizing a query and have ran into a situation that's making me question how I've always used SQL's OR operator. (SQL Server 2000 also)</p> <p>I have a query where the conditional (WHERE) clause looks something like this:</p> <pre><code>WHERE (Column1 = @Param1 or Column1 LIKE @Param1 + '%')...
[ { "answer_id": 473955, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 4, "selected": true, "text": "<p>\"OR only evaluates expressions until it find a TRUE result\"</p>\n\n<p>It only has to, but that's not your problem (a...
2009/01/23
[ "https://Stackoverflow.com/questions/473943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28540/" ]
I've been working on optimizing a query and have ran into a situation that's making me question how I've always used SQL's OR operator. (SQL Server 2000 also) I have a query where the conditional (WHERE) clause looks something like this: ``` WHERE (Column1 = @Param1 or Column1 LIKE @Param1 + '%') AND (@Param2 = '' OR...
"OR only evaluates expressions until it find a TRUE result" It only has to, but that's not your problem (actually this is what was saving you in your original case). Your two queries are not really equivalent. I'm thinking you have `NULL`s in Column2 which will never cause `(Column2 LIKE ISNULL(@Param2, '') + '%')` t...
473,945
<p>I've browsed page after page after page of data on the web and everyone seems to say that you cannot have an executable remotely execute an application on another machine via WMI and have the window of that application display.</p> <p>Does anyone know a way around this?</p> <p>I have tried created 2 executables. 1...
[ { "answer_id": 476091, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>If your command line string is OK, the process name (Mexe.exe) should appear in the process list in Windows Task Manager ev...
2009/01/23
[ "https://Stackoverflow.com/questions/473945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50947/" ]
I've browsed page after page after page of data on the web and everyone seems to say that you cannot have an executable remotely execute an application on another machine via WMI and have the window of that application display. Does anyone know a way around this? I have tried created 2 executables. 1 executable uses ...
You have to use Win32\_ScheduledJob.Create to create an interactive process remotely I believe. See <http://msdn.microsoft.com/en-us/library/aa389769%28VS.85%29.aspx> You can just schedule it for Now +1 second.
473,961
<p>I have a bunch of Python modules in a directory, all being a derivate class. I need a "runner" script that, for each module, instantiate the class that is inside it (the actual class name can be built by the module file name) and than call the "go" method on each of them.</p> <p>I don't know how many modules are th...
[ { "answer_id": 474004, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "<p>You could use <a href=\"http://docs.python.org/library/functions.html#__import__\" rel=\"nofollow noreferrer\"><c...
2009/01/23
[ "https://Stackoverflow.com/questions/473961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27958/" ]
I have a bunch of Python modules in a directory, all being a derivate class. I need a "runner" script that, for each module, instantiate the class that is inside it (the actual class name can be built by the module file name) and than call the "go" method on each of them. I don't know how many modules are there, but I...
``` def run_all(path): import glob, os print "Exploring %s" % path for filename in glob.glob(path + "/*.py"): # modulename = "bot_paperino" modulename = os.path.splitext(os.path.split(filename)[-1])[0] # classname = "Paperino" classname = modulename.split("bot_")[-1].capitali...
473,967
<p>Here is an example that a forum poster gave, I can't tell if this tail optimized. Also, could someone give a laymans description of how a tail optimized version would trump the normal version.</p> <pre><code>(defun mylength (s) (labels ((mylength-inner (s x) (if (car s) (mylength-inner (cdr s) (+ x ...
[ { "answer_id": 474027, "author": "wowest", "author_id": 49237, "author_profile": "https://Stackoverflow.com/users/49237", "pm_score": 1, "selected": false, "text": "<p>Tail calls can be optimized to not need extra space on the call stack, and it requires that the last operation in the fu...
2009/01/23
[ "https://Stackoverflow.com/questions/473967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
Here is an example that a forum poster gave, I can't tell if this tail optimized. Also, could someone give a laymans description of how a tail optimized version would trump the normal version. ``` (defun mylength (s) (labels ((mylength-inner (s x) (if (car s) (mylength-inner (cdr s) (+ x 1)) x))) ...
A function can be tail-call optimized if it returns a straight call to itself or no call to itself. The function mylength-inner will return either `x` or `(mylength-inner (cdr s) (+ x 1))`, and so it can be tail-optimized. This means the compiler can turn it into a loop instead of calling the function recursively. Eit...
473,973
<p>What's the easiest way to shuffle an array with python?</p>
[ { "answer_id": 473983, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 10, "selected": true, "text": "<pre><code>import random\nrandom.shuffle(array)\n</code></pre>\n" }, { "answer_id": 473988, "author": "Douglas...
2009/01/23
[ "https://Stackoverflow.com/questions/473973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12930/" ]
What's the easiest way to shuffle an array with python?
``` import random random.shuffle(array) ```
473,977
<p>Does anyone know how to change the location of the svn tool used in the Xcode IDE?</p> <p>I've installed a newer version in <code>/opt/subversion/bin</code> and updated my <code>$PATH</code> so that it works from the command line but can't get Xcode to recognize this.</p>
[ { "answer_id": 473983, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 10, "selected": true, "text": "<pre><code>import random\nrandom.shuffle(array)\n</code></pre>\n" }, { "answer_id": 473988, "author": "Douglas...
2009/01/23
[ "https://Stackoverflow.com/questions/473977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35485/" ]
Does anyone know how to change the location of the svn tool used in the Xcode IDE? I've installed a newer version in `/opt/subversion/bin` and updated my `$PATH` so that it works from the command line but can't get Xcode to recognize this.
``` import random random.shuffle(array) ```
473,979
<p>Looking for a solution in bash (will be part of a larger script).</p> <p>Given a variable containing information of the form</p> <pre> diff -r efb93662e8a7 -r 53784895c0f7 diff.txt --- diff.txt Fri Jan 23 14:48:30 2009 +0000 +++ b/diff.txt Fri Jan 23 14:49:58 2009 +0000 @@ -1,9 +0,0 @@ -diff -r 9741ec300459 myfil...
[ { "answer_id": 474010, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 0, "selected": false, "text": "<p>Could you perform your operation before setting $editing - then you might still have the line breaks?</p>\n\n<p>Th...
2009/01/23
[ "https://Stackoverflow.com/questions/473979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58387/" ]
Looking for a solution in bash (will be part of a larger script). Given a variable containing information of the form ``` diff -r efb93662e8a7 -r 53784895c0f7 diff.txt --- diff.txt Fri Jan 23 14:48:30 2009 +0000 +++ b/diff.txt Fri Jan 23 14:49:58 2009 +0000 @@ -1,9 +0,0 @@ -diff -r 9741ec300459 myfile.c ---- myfil...
A solution using only bash built-ins, no external programs is: ``` res="edited: "; var="${var#* --- } --- " while test -n "$var";do res="$res ${var%% *}"; var="${var#* --- }";done echo "$res" ``` It iterates on all occurences of " --- ". The trick is to prepare the string by first trimming garbarge from the start (u...
473,998
<p>I am trying to determine the best way to parse a log file and get a count of all of the errors in it by type. Currently, I open the log in a text editor, strip out the date and thread ID, then sort the file. This puts all errors together by type, which I can then count (using the count function in the editor, not ...
[ { "answer_id": 474022, "author": "Joe Basirico", "author_id": 20795, "author_profile": "https://Stackoverflow.com/users/20795", "pm_score": 2, "selected": false, "text": "<p>Perl would be my first choice for the string parsing. Using a RegEx you could parse through that log file in no ti...
2009/01/23
[ "https://Stackoverflow.com/questions/473998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4555/" ]
I am trying to determine the best way to parse a log file and get a count of all of the errors in it by type. Currently, I open the log in a text editor, strip out the date and thread ID, then sort the file. This puts all errors together by type, which I can then count (using the count function in the editor, not manua...
Perl would be my first choice for the string parsing. Using a RegEx you could parse through that log file in no time. From what I can see it looks like you're dealing with a nicely computer readable file. You could use a Perl hash to do your averaging. You could likely do the same thing with C# and their RegExs if yo...
474,007
<p>I want to take a floating point number in C++, like 2.25125, and a int array filled with the binary value that is used to store the float in memory (IEEE 754).</p> <p>So I could take a number, and end up with a int num[16] array with the binary value of the float: num[0] would be 1 num[1] would be 1 num[2] would be...
[ { "answer_id": 474014, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": false, "text": "<pre><code>int fl = *(int*)&amp;floatVar; //assuming sizeof(int) = sizeof(float)\n\nint binaryRepresentation[sizeof(float) * 8...
2009/01/23
[ "https://Stackoverflow.com/questions/474007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58389/" ]
I want to take a floating point number in C++, like 2.25125, and a int array filled with the binary value that is used to store the float in memory (IEEE 754). So I could take a number, and end up with a int num[16] array with the binary value of the float: num[0] would be 1 num[1] would be 1 num[2] would be 0 num[3] ...
Use union and bitset: ``` #include <iostream> #include <bitset> #include <climits> int main() { union { float input; // assumes sizeof(float) == sizeof(int) int output; } data; data.input = 2.25125; std::bitset<sizeof(float) * CHAR_BIT> bits(data.output); std::cout << bits ...
474,047
<p>I have a windows service that has a custom configuration section. In the configSectionHandler class I am using attributes on the properties to validate the settings like this:</p> <pre><code> //ProcessingSleepTime Property [ConfigurationProperty("ProcessingSleepTime", DefaultValue = 1000, IsRequired = false...
[ { "answer_id": 474132, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": -1, "selected": false, "text": "<p>First, check if your configuration contains the key that you're looking for, then wrap it in a try catch, the...
2009/01/23
[ "https://Stackoverflow.com/questions/474047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35165/" ]
I have a windows service that has a custom configuration section. In the configSectionHandler class I am using attributes on the properties to validate the settings like this: ``` //ProcessingSleepTime Property [ConfigurationProperty("ProcessingSleepTime", DefaultValue = 1000, IsRequired = false)] [Integer...
Or better yet (as you might need multiple such a properties), using the code from @Ricardo Villiamil, create: ``` int GetIntFromConfigSetting(string settingName, int defaultValue) { int retValue = defaultValue; if(this.ContainsKey(settingName)) { int sleepInterval; if(Int32.TryParse(this[settingNa...
474,057
<p>Is there a way to initialize all elements of an array to a constant value through generics?</p>
[ { "answer_id": 474124, "author": "Vojislav Stojkovic", "author_id": 58099, "author_profile": "https://Stackoverflow.com/users/58099", "pm_score": 3, "selected": false, "text": "<p>Personally, I would use a good, old for loop, but if you want a one-liner, here it is:</p>\n\n<pre><code>T[]...
2009/01/23
[ "https://Stackoverflow.com/questions/474057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22769/" ]
Is there a way to initialize all elements of an array to a constant value through generics?
I would use an extender (.net 3.5 feature) ``` public static class Extenders { public static T[] FillWith<T>( this T[] array, T value ) { for(int i = 0; i < array.Length; i++) { array[i] = value; } return array; } } // now you can do this... int[] array = new in...
474,063
<p>Which is the best way of validating an input passed to the function i.e. do you validate all input before proceeding some thing like</p> <pre><code>class A; void fun(A* p) { if(! p) { return; } B* pB = p-&gt;getB(); if(! pB) { return; } ....... } </code></pre> <p>Or do you write it like thi...
[ { "answer_id": 474088, "author": "Jay S", "author_id": 30440, "author_profile": "https://Stackoverflow.com/users/30440", "pm_score": 1, "selected": false, "text": "<p>I prefer to do my input validation upfront, but will often perform the tests all at once</p>\n\n<p>i.e.</p>\n\n<pre><code...
2009/01/23
[ "https://Stackoverflow.com/questions/474063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39742/" ]
Which is the best way of validating an input passed to the function i.e. do you validate all input before proceeding some thing like ``` class A; void fun(A* p) { if(! p) { return; } B* pB = p->getB(); if(! pB) { return; } ....... } ``` Or do you write it like this: ``` void fun(A* p) { if...
The first way is easier to read and less complex (by depth) than the second one. In the second one, the complexity and depth increase as the number of parameters goes up. But in the first example, it's just linear.
474,065
<p>There's no strongly typed View() method to return an ActionResult. So, suppose I have </p> <pre><code>class Edit : ViewPage&lt;Frob&gt; </code></pre> <p>In my FrobController, I will do something like "return View("Edit", someFrob);". There's no checking going on here, so I have to always manually synchronize the v...
[ { "answer_id": 474092, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 3, "selected": true, "text": "<p>The first problem I see is that you've now made your Controller aware of the View. That's a line you should never cro...
2009/01/23
[ "https://Stackoverflow.com/questions/474065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27012/" ]
There's no strongly typed View() method to return an ActionResult. So, suppose I have ``` class Edit : ViewPage<Frob> ``` In my FrobController, I will do something like "return View("Edit", someFrob);". There's no checking going on here, so I have to always manually synchronize the view and controller's use of it. ...
The first problem I see is that you've now made your Controller aware of the View. That's a line you should never cross.
474,083
<p>I want to create a group function on my site and I'm wondering what the best way to do this would be? would i be best to create two tables groups and group_members? im fairly new to sql so im not so sure.</p> <p>im thinking this:</p> <pre> groups group_id int(11) NOT NULL auto_increment, group_name varchar(32)...
[ { "answer_id": 474099, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>would that be the best?</p>\n</blockquote>\n\n<p>Exactly.</p>\n\n<p>It's a <a href=\"http://en.wikiped...
2009/01/23
[ "https://Stackoverflow.com/questions/474083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to create a group function on my site and I'm wondering what the best way to do this would be? would i be best to create two tables groups and group\_members? im fairly new to sql so im not so sure. im thinking this: ``` groups group_id int(11) NOT NULL auto_increment, group_name varchar(32) NOT NULL ```...
That is how I would do it. Another option would be to put a group\_id column in the users table, but if you do that you'd be restricting yourself to only one group per user. The way you are doing it allows a many to many relationship, which I think is the best route to go :o)
474,095
<p>I'm making a simple navigation menu for a site. You create an <code>ul</code> with id <code>menu</code>, and should be pretty simple from there. I have some simple css to give all the <code>li</code>s the correct background image, then some jQuery to change the look of an <code>li</code> when the user mouses over....
[ { "answer_id": 474131, "author": "Kip", "author_id": 18511, "author_profile": "https://Stackoverflow.com/users/18511", "pm_score": 1, "selected": false, "text": "<p>I know this isn't exactly an answer to your question, but changing the CSS properties of an element when hovered can be don...
2009/01/23
[ "https://Stackoverflow.com/questions/474095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I'm making a simple navigation menu for a site. You create an `ul` with id `menu`, and should be pretty simple from there. I have some simple css to give all the `li`s the correct background image, then some jQuery to change the look of an `li` when the user mouses over. It works pretty well, but there's one problem. W...
You know you can do everything you're doing there with *just* CSS and HTML? * Set the `a` to `display:block` so that it fills the `li` * Set a `:hover` state on a to change the background. * ??? * Profit.
474,114
<p>Sometimes the overhead of creating a new model type is annoying. In these cases, I want to set ViewData, and the options seem to be:</p> <ol> <li><p>Simply set viewdata with a string key, and cast it out. This has obvious problems.</p></li> <li><p>Store the identifier (string key) somewhere (where? on the controlle...
[ { "answer_id": 474125, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "<p>I think this is what the model does in the MVC pattern. Why you don't use a typed view instead? </p>\n\n<p>I believe you jus...
2009/01/23
[ "https://Stackoverflow.com/questions/474114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27012/" ]
Sometimes the overhead of creating a new model type is annoying. In these cases, I want to set ViewData, and the options seem to be: 1. Simply set viewdata with a string key, and cast it out. This has obvious problems. 2. Store the identifier (string key) somewhere (where? on the controller?) and cast it out on the vi...
I think this is what the model does in the MVC pattern. Why you don't use a typed view instead? I believe you just make things more complicated by introducing yet another dependency between the controller and the view. I don't see any specific benefit in terms of line of code or something like that. You have to decla...
474,119
<p>I have a SQL table like so:</p> <p>Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items.</p> <pre><code>entities id name 1 Apple 2 ...
[ { "answer_id": 474144, "author": "Tim Wardle", "author_id": 55549, "author_profile": "https://Stackoverflow.com/users/55549", "pm_score": 1, "selected": false, "text": "<p>I think the structure you have suggested is fine.</p>\n\n<p>To get the related records do something like</p>\n\n<pre...
2009/01/23
[ "https://Stackoverflow.com/questions/474119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3238/" ]
I have a SQL table like so: Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items. ``` entities id name 1 Apple 2 Orange ...
Define a constraint: `entity_id_a < entity_id_b`. Create indexes: ``` CREATE UNIQUE INDEX ix_a_b ON entity_entity(entity_id_a, entity_id_b); CREATE INDEX ix_b ON entity_entity(entity_id_b); ``` Second index doesn't need to include `entity_id_a` as you will use it only to select all `a`'s within one `b`. `RANGE SCAN...
474,159
<p>I'm using Spring + JPA + Hibernate. I'm trying to enable Hibernate's second level cache. In my Spring's <code>applicationContext.xml</code> I have:</p> <pre><code>&lt;prop key="hibernate.cache.provider_class"&gt;net.sf.ehcache.hibernate.SingletonEhCacheProvider&lt;/prop&gt; &lt;prop key="hibernate.cache.provider_co...
[ { "answer_id": 931961, "author": "Mainguy", "author_id": 81385, "author_profile": "https://Stackoverflow.com/users/81385", "pm_score": 5, "selected": true, "text": "<p>I didn't answer this, but it's not obvious that the poster found the answer himself. I'm reposting his answer:</p>\n\n<...
2009/01/23
[ "https://Stackoverflow.com/questions/474159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
I'm using Spring + JPA + Hibernate. I'm trying to enable Hibernate's second level cache. In my Spring's `applicationContext.xml` I have: ``` <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.cache.provider_configuration_file_resource_path">/ehcache...
I didn't answer this, but it's not obvious that the poster found the answer himself. I'm reposting his answer: ### Resolved Since I'm using `LocalEntityManagerFactoryBean` it gets its settings from `META-INF/persistence.xml`. My settings in `applicationContext.xml` weren't even being read.
474,165
<p>I know this question might sound a little cheesy but this is the first time I am implementing a "tagging" feature to one of my project sites and I want to make sure I do everything right.</p> <p>Right now, I am using the very same tagging system as in SO.. space seperated, dash(-) combined multiple words. so when I...
[ { "answer_id": 474302, "author": "Ian Greenleaf Young", "author_id": 58418, "author_profile": "https://Stackoverflow.com/users/58418", "pm_score": 0, "selected": false, "text": "<p>I hope you're doing the usual protection against injection attacks - maybe that's included under #2. </p>\...
2009/01/23
[ "https://Stackoverflow.com/questions/474165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49742/" ]
I know this question might sound a little cheesy but this is the first time I am implementing a "tagging" feature to one of my project sites and I want to make sure I do everything right. Right now, I am using the very same tagging system as in SO.. space seperated, dash(-) combined multiple words. so when I am valida...
I've never implemented a tagging system, but am likely to do so soon for a project I'm working on. I'm primarily a database guy and it occurs to me that for performance reasons it may be best to relate your tagged entities with the tag keywords via a resolution table. So, for instance, with example tables such as: **T...
474,184
<p>I've got some code which accepts a DataTable as a parameter and calculates the total of several of the columns in the DataTable. I thought it might be nice to be able to pass in a lambda expression which would perform a filter on the column I'm totaling. </p> <p>Here's a portion of the code:</p> <pre><code>public ...
[ { "answer_id": 474198, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>I'm slightly confused because you're <em>already</em> specifying the Where clause with a lambda expression, but I susp...
2009/01/23
[ "https://Stackoverflow.com/questions/474184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3656/" ]
I've got some code which accepts a DataTable as a parameter and calculates the total of several of the columns in the DataTable. I thought it might be nice to be able to pass in a lambda expression which would perform a filter on the column I'm totaling. Here's a portion of the code: ``` public TrafficTotals Calcula...
I'm slightly confused because you're *already* specifying the Where clause with a lambda expression, but I suspect you want this: ``` public TrafficTotals CalculateTotals(DataTable table, Func<DataRow, bool> filter) { TrafficTotals total = new TrafficTotals(); total.TotalT...
474,203
<p>I have several objects in the database. Url to edit an object using the generic view looks like <code>site.com/cases/edit/123/</code> where <code>123</code> is an id of the particular object. Consider the <code>cases/url.py</code> contents:</p> <pre><code>url(r'edit/(?P&lt;object_id&gt;\d{1,5})/$', update_object, {...
[ { "answer_id": 474524, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 0, "selected": false, "text": "<p>First, read up on the <a href=\"http://docs.djangoproject.com/en/dev/topics/http/urls/?from=olddocs#reverse\" rel=\"nofo...
2009/01/23
[ "https://Stackoverflow.com/questions/474203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36832/" ]
I have several objects in the database. Url to edit an object using the generic view looks like `site.com/cases/edit/123/` where `123` is an id of the particular object. Consider the `cases/url.py` contents: ``` url(r'edit/(?P<object_id>\d{1,5})/$', update_object, { ... 'post_save_redirect': ???}, name = 'cases_edit')...
In short what you need to do is wrap the update\_object function. ``` def update_object_wrapper(request, object_id, *args, **kwargs): redirect_to = reverse('your object edit url name', object_id) return update_object(request, object_id, post_save_redirect=redirect_to, *args, **kwargs) ```
474,204
<p>I'm making my first foray into WPF - I have a simple form with a popup defined for inline help. I'm using rounded corners, and for some reason a black background is bleeding through around the corners. I don't understand which element is causing the problem.</p> <p><a href="http://www.awbrey.net/rounded.jpg">alt ...
[ { "answer_id": 474409, "author": "Bubblewrap", "author_id": 57497, "author_profile": "https://Stackoverflow.com/users/57497", "pm_score": 6, "selected": true, "text": "<p>I think it is the Popup that is causing the problem. Try setting AllowsTransparency to True on the popup.</p>\n\n<p><...
2009/01/23
[ "https://Stackoverflow.com/questions/474204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1338/" ]
I'm making my first foray into WPF - I have a simple form with a popup defined for inline help. I'm using rounded corners, and for some reason a black background is bleeding through around the corners. I don't understand which element is causing the problem. [alt text http://www.awbrey.net/rounded.jpg](http://www.awbr...
I think it is the Popup that is causing the problem. Try setting AllowsTransparency to True on the popup. [Popup.AllowsTransparency](http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup.allowstransparency.aspx) When set to False, any transparent colors are "merged" with black.
474,216
<p>Obviously, the actual style of the odd/even rows will be done via a CSS class, but what is the best way to "attach" the class to the rows? Is is better to put it in the markup, or is it better to do it via client-side javascript? Which is better and why? </p> <p>For simplicity's sake, let's assume that this is a la...
[ { "answer_id": 474231, "author": "Tim Wardle", "author_id": 55549, "author_profile": "https://Stackoverflow.com/users/55549", "pm_score": 1, "selected": false, "text": "<p>For a table of such a large size I would do the row processing on the server side, using PHP or similar to calculate...
2009/01/23
[ "https://Stackoverflow.com/questions/474216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20770/" ]
Obviously, the actual style of the odd/even rows will be done via a CSS class, but what is the best way to "attach" the class to the rows? Is is better to put it in the markup, or is it better to do it via client-side javascript? Which is better and why? For simplicity's sake, let's assume that this is a large table,...
You can do this fairly easily with jQuery, like so: ``` $(function(){ $('tr:even').addClass('alternateClass'); $('tr:odd').addClass('mainClass'); }); ``` You can qualify the selector a bit more if you just want to do this on one particular table, or do it on 'li' elements as well. I think this is a bit clea...
474,224
<p>I'm used to using Telerik Grids and I'm able to display them in an outlook style, i.e. a picture on the far left, a bold title and a few other lines of text under the main title.</p> <p>Is there a way do this using a standard .Net2.0 Windows control? Either with a cheap control, or the existing datagridview or list...
[ { "answer_id": 474618, "author": "Tom Faust", "author_id": 58410, "author_profile": "https://Stackoverflow.com/users/58410", "pm_score": 0, "selected": false, "text": "<p>I can't give you an example as I don't have time to write it at this time, but you could create a UserControl which l...
2009/01/23
[ "https://Stackoverflow.com/questions/474224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44269/" ]
I'm used to using Telerik Grids and I'm able to display them in an outlook style, i.e. a picture on the far left, a bold title and a few other lines of text under the main title. Is there a way do this using a standard .Net2.0 Windows control? Either with a cheap control, or the existing datagridview or listview? Bas...
Here is help with using a listview for the list. I would go with the list because you will only have one column, so no need for the grid. You want to use : ``` private void lstItems_DrawItem(object sender, DrawItemEventArgs e) ``` Then use the e.Graphics to get an object you can draw directly to. I used this [tuto...
474,239
<p>This is really strange but this code is working fine unless the value entered by the user includes an asterik (*) or other characters like $ or #. The #ticketNumber.Val() is the suspected problem. Some of our id's have an * in them. Any help would be appreciated.</p> <pre><code>function buttonClicks() { var ...
[ { "answer_id": 474286, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<p>A <code>*</code> shouldn't cause a problem but a <code>#</code> will - you should URL-encode the value using <a href=\"htt...
2009/01/23
[ "https://Stackoverflow.com/questions/474239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9938/" ]
This is really strange but this code is working fine unless the value entered by the user includes an asterik (\*) or other characters like $ or #. The #ticketNumber.Val() is the suspected problem. Some of our id's have an \* in them. Any help would be appreciated. ``` function buttonClicks() { var action = '/Serv...
My guess is that (as RoBorg suggests), the URL rewriter that is used by the MVC framework considers \* to be a special character... I can't be sure of what the problem is, but it seems like you could avoid the issue pretty easily by just removing asterisks before the request and adding them back again on the server-sid...
474,259
<p>I'm working on an application that loads untrusted assemblies via an interface. Each of those assemblies should be able to add one or more GameAction objects to a thread-safe queue used by the server.</p> <p>The first iteration of design was to just pass the queue--something like this:</p> <pre><code>public interf...
[ { "answer_id": 474288, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Thoughts in no particular order:</p>\n\n<p>1) Events <em>do</em> guarantee ordering (or at least, your implementation ...
2009/01/23
[ "https://Stackoverflow.com/questions/474259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5287/" ]
I'm working on an application that loads untrusted assemblies via an interface. Each of those assemblies should be able to add one or more GameAction objects to a thread-safe queue used by the server. The first iteration of design was to just pass the queue--something like this: ``` public interface IGameClient { v...
Thoughts in no particular order: 1) Events *do* guarantee ordering (or at least, your implementation could guarantee whatever ordering you want, and the simplest implementations will preserve ordering). 2) I don't see why you'd want to pass the queue by reference in the first example of the interface. It may be worth...
474,261
<p>I think I am being a bonehead, maybe not importing the right package, but when I do...</p> <pre><code> from pysqlite2 import dbapi2 as sqlite import types import re import sys ... def create_asgn(self): stmt = "CREATE TABLE ? (login CHAR(8) PRIMARY KEY NOT NULL, grade INTEGER NOT NULL)" stmt2 = ...
[ { "answer_id": 474296, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 4, "selected": true, "text": "<p>That's because parameters can only be passed to VALUES. The table name can't be parametrized.</p>\n\n<p>Also you have quo...
2009/01/23
[ "https://Stackoverflow.com/questions/474261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37840/" ]
I think I am being a bonehead, maybe not importing the right package, but when I do... ``` from pysqlite2 import dbapi2 as sqlite import types import re import sys ... def create_asgn(self): stmt = "CREATE TABLE ? (login CHAR(8) PRIMARY KEY NOT NULL, grade INTEGER NOT NULL)" stmt2 = "insert into a...
That's because parameters can only be passed to VALUES. The table name can't be parametrized. Also you have quotes around a parametrized argument on the second query. Remove the quotes, escaping is handled by the underlining library automatically for you.
474,270
<p>I'm looking to determine whether a string value from a user input (UITextField) is "blank" if it's not nil. Checking if <code>[textField.text isEqualToString:""]</code> isn't quite enough because I want to avoid any blank/whitespace input (like say a few space characters).</p> <p>There does seem to be an indicatio...
[ { "answer_id": 474369, "author": "Matt Flowers", "author_id": 57702, "author_profile": "https://Stackoverflow.com/users/57702", "pm_score": 7, "selected": true, "text": "<p>You're using whitespaceAndNewlineCharacterSet, good. But instead of using scanUpToCharactersFromSet, why not use s...
2009/01/23
[ "https://Stackoverflow.com/questions/474270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50798/" ]
I'm looking to determine whether a string value from a user input (UITextField) is "blank" if it's not nil. Checking if `[textField.text isEqualToString:""]` isn't quite enough because I want to avoid any blank/whitespace input (like say a few space characters). There does seem to be an indication of a good solution f...
You're using whitespaceAndNewlineCharacterSet, good. But instead of using scanUpToCharactersFromSet, why not use stringByTrimmingCharactersInSet? Something like this... ``` strResult = [strResult stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; ``` EDIT: Didn't realize you already ...
474,279
<p>I'm working on a resource management class and want to have the user provide a functor to a "ReleaseResource" method as part of the resource manager's constructor. From there when a resource is requested that functor will be provided as the deleter for the shared_ptr that I will be returning so that the appropriate ...
[ { "answer_id": 474291, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 0, "selected": false, "text": "<p>Not sure if this would help, but be aware that boost::shared_ptr has constructor overrides which allow the user to include...
2009/01/23
[ "https://Stackoverflow.com/questions/474279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25968/" ]
I'm working on a resource management class and want to have the user provide a functor to a "ReleaseResource" method as part of the resource manager's constructor. From there when a resource is requested that functor will be provided as the deleter for the shared\_ptr that I will be returning so that the appropriate me...
``` template<class MyFunctor> MyMethod(MyFunctor f) { boost::function<void()> g = f; g(); } ``` The type you pass to [`boost::function`](http://www.boost.org/doc/libs/1_37_0/doc/html/function.html) is the function type. For example, `int(bool, char)` is the type of a function returning int and taking a bool a...
474,283
<p>Is there any command which would list down all the JRE versions and releases installed on a system?</p>
[ { "answer_id": 474292, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 1, "selected": false, "text": "<p>Um...</p>\n\n<pre><code>find / -name \"java\" -print\n</code></pre>\n\n<p>on *nix.</p>\n\n<p>Not given any other rel...
2009/01/23
[ "https://Stackoverflow.com/questions/474283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26927/" ]
Is there any command which would list down all the JRE versions and releases installed on a system?
To list all the registered JRE (in a file called "jre.txt") on a Windows machine : ``` start /w regedit /e jre.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" ```
474,307
<p>can ASP.NET controls be used with generics? Never seen this done and want a way to differentiate some controls on a page by type, ie: <strong>DateTime</strong> vs <strong>int</strong></p> <p>example: </p> <pre><code>public class MyGenericTextBox&lt;T&gt;: TextBox { public MyGenericTextBox&lt;T&gt;() {... } } </cod...
[ { "answer_id": 474343, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 2, "selected": false, "text": "<p>This would probably work if you only used the control from code. I doubt it could be represented in markup or in...
2009/01/23
[ "https://Stackoverflow.com/questions/474307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
can ASP.NET controls be used with generics? Never seen this done and want a way to differentiate some controls on a page by type, ie: **DateTime** vs **int** example: ``` public class MyGenericTextBox<T>: TextBox { public MyGenericTextBox<T>() {... } } ```
It can be done with a special hack, for example the one I used in this article: [A Typed Repeater in ASP.NET](http://www.codeproject.com/KB/aspnet/TypedRepeater.aspx) However I would not recommend doing this just for convenience in simple cases, since the result would be more complex than the thing you'll try to impr...