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
502,261
<p>Purely as an experiment, I'm writing sort functions in MATLAB then running these through the MATLAB profiler. The aspect I find most perplexing is to do with swapping elements.</p> <p>I've found that the "official" way of swapping two elements in a matrix</p> <pre><code>self.Data([i1, i2]) = self.Data([i2, i1]) </...
[ { "answer_id": 502274, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 2, "selected": false, "text": "<p>In the first (slow) approach, the RHS value is a matrix, so I think MATLAB incurs a performance penalty in creati...
2009/02/02
[ "https://Stackoverflow.com/questions/502261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25216/" ]
Purely as an experiment, I'm writing sort functions in MATLAB then running these through the MATLAB profiler. The aspect I find most perplexing is to do with swapping elements. I've found that the "official" way of swapping two elements in a matrix ``` self.Data([i1, i2]) = self.Data([i2, i1]) ``` runs much slower ...
Based on suggestions posted, I've run some more tests. It appears the performance hit comes when the same matrix is referenced in both the LHS and RHS of the assignment. My theory is that MATLAB uses an internal reference-counting / copy-on-write mechanism, and this is causing the entire matrix to be copied internally...
502,271
<p>I have been searching for this for some time, but haven't got any explanation.</p> <p>For "onclick" and other events in javascript, the event handler returning <strong><em>false</em></strong> means "prevent default action". However, there is one exception for "onmouseover". For "onmouseover", returning <strong><em>...
[ { "answer_id": 502291, "author": "Luca Matteis", "author_id": 50394, "author_profile": "https://Stackoverflow.com/users/50394", "pm_score": 3, "selected": false, "text": "<p>Instead of using return <strong>false</strong> / <strong>true</strong> to prevent default event behaviour, use the...
2009/02/02
[ "https://Stackoverflow.com/questions/502271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
I have been searching for this for some time, but haven't got any explanation. For "onclick" and other events in javascript, the event handler returning ***false*** means "prevent default action". However, there is one exception for "onmouseover". For "onmouseover", returning ***true*** means "prevent default action"....
Instead of using return **false** / **true** to prevent default event behaviour, use the default method / attribute on the event object: ``` elem.onmouseover = function(e) { if (!e) var e = window.event; // IE if(e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; // IE ...
502,282
<p>How do you create a main window that fills the entire desktop <strong>without covering (or being covered by) the task bar</strong> and <strong>without being maximized</strong>? I can find the entire screen size with and set the main window accordingly with this:</p> <pre><code>window = gtk.Window() screen = window....
[ { "answer_id": 508251, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 4, "selected": true, "text": "<p>You are totally at the mercy of your window manager for this, and the key issue here is:</p>\n\n<blockquote>\n <p><s...
2009/02/02
[ "https://Stackoverflow.com/questions/502282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1142/" ]
How do you create a main window that fills the entire desktop **without covering (or being covered by) the task bar** and **without being maximized**? I can find the entire screen size with and set the main window accordingly with this: ``` window = gtk.Window() screen = window.get_screen() window.resize(screen.get_wi...
You are totally at the mercy of your window manager for this, and the key issue here is: > > **without being maximized** > > > So we are left with a number of hacks, because basically maximization and resizing are two separate things, in order that you might be able to remember where it was when it is unmaximized...
502,290
<p>I'm using Visual C# to program an RPN calculator using Stack. Problem is I don't know how to do this. I'm using System.Collections.Generic, but</p> <pre><code>Stack&lt;double&gt; s = new Stack&lt;double&gt;(); </code></pre> <p>generates the error:</p> <blockquote> <p>Using the generic type 'System.Collections.G...
[ { "answer_id": 502294, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 2, "selected": false, "text": "<p>You need to specify the type of the elements that you will store on your stack, for example a stack of integ...
2009/02/02
[ "https://Stackoverflow.com/questions/502290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using Visual C# to program an RPN calculator using Stack. Problem is I don't know how to do this. I'm using System.Collections.Generic, but ``` Stack<double> s = new Stack<double>(); ``` generates the error: > > Using the generic type 'System.Collections.Generic.Stack' requires '1' type arguments > > > I'm...
You need to specify the type of the elements that you will store on your stack, for example a stack of integers: ``` Stack<int> s = new Stack<int>(); ```
502,303
<p>I need to access the assembly of my project in C#.</p> <p>I can see the GUID in the 'Assembly Information' dialog in under project properties, and at the moment I have just copied it to a const in the code. The GUID will never change, so this is not that bad of a solution, but it would be nice to access it directly....
[ { "answer_id": 502308, "author": "amazedsaint", "author_id": 45956, "author_profile": "https://Stackoverflow.com/users/45956", "pm_score": 3, "selected": false, "text": "<p>You should be able to read the GUID attribute of the assembly via reflection. This will get the GUID for the curren...
2009/02/02
[ "https://Stackoverflow.com/questions/502303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6062/" ]
I need to access the assembly of my project in C#. I can see the GUID in the 'Assembly Information' dialog in under project properties, and at the moment I have just copied it to a const in the code. The GUID will never change, so this is not that bad of a solution, but it would be nice to access it directly. Is there...
Try the following code. The value you are looking for is stored on a `GuidAttribute` instance attached to the `Assembly` ```cs using System.Runtime.InteropServices; static void Main(string[] args) { var assembly = typeof(Program).Assembly; var attribute = (GuidAttribute)assembly.GetCustomAttributes(typeof(Gui...
502,311
<p>Is it possible to show calendar as shown below using jquery datepicker.</p> <pre><code> OCT-2009 Mon Tue Wed Thur Fri Sat Sun 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
[ { "answer_id": 502321, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 2, "selected": true, "text": "<p>\"Changes are a part of the requirement.\"</p>\n\n<p>I dont think that the web packages that we design changes a lot. ...
2009/02/02
[ "https://Stackoverflow.com/questions/502311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to show calendar as shown below using jquery datepicker. ``` OCT-2009 Mon Tue Wed Thur Fri Sat Sun 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...
"Changes are a part of the requirement." I dont think that the web packages that we design changes a lot. If it changes, then it is a bad design. If we use external API's, a very few get deprecated, otherwise most of them are the same. Some packages used as a JAVA/J2EE programmer: - MVC - Struts - few AJAX framewo...
502,318
<p>I had an issue in building the resultset using Java.</p> <p>I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object (which is stored as vector/array list) in cache and trying to retrieve the same collection object.</p> <p>Here I need to build ba...
[ { "answer_id": 502333, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 0, "selected": false, "text": "<p>From what I could get, your code may be like this:</p>\n\n<pre><code>List collection = new ArrayList();\ncollection.a...
2009/02/02
[ "https://Stackoverflow.com/questions/502318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61369/" ]
I had an issue in building the resultset using Java. I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object (which is stored as vector/array list) in cache and trying to retrieve the same collection object. Here I need to build back the resultse...
The best idea if you are using a collection in place of a cache is to use a [CachedRowSet](http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/rowset/CachedRowSet.html) instead of a ResultSet. CachedRowSet is a Subinterface of ResultSet, but the data is already cached. This is far simpler than to write all the data into ...
502,328
<p>I am having trouble replicating the following sql as a LINQ statement</p> <pre><code>select TableA.* from TableA left outer join TableAinTableB on TableA.Id = TableAId where TableBId is null </code></pre> <p>The following returns no lines</p> <pre><code>from TableA in db.TableA join AinB in db.TableAinTableB on T...
[ { "answer_id": 502353, "author": "Yuval Peled", "author_id": 20257, "author_profile": "https://Stackoverflow.com/users/20257", "pm_score": 2, "selected": false, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/bb360179.aspx\" rel=\"nofollow noreferrer\">Defau...
2009/02/02
[ "https://Stackoverflow.com/questions/502328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1834/" ]
I am having trouble replicating the following sql as a LINQ statement ``` select TableA.* from TableA left outer join TableAinTableB on TableA.Id = TableAId where TableBId is null ``` The following returns no lines ``` from TableA in db.TableA join AinB in db.TableAinTableB on TableA.Id equals TableAId where AinB.T...
You can use the [DefaultIfEmpty](http://msdn.microsoft.com/en-us/library/bb360179.aspx) to simulate an outer join. Check out this [sample](http://msdn.microsoft.com/en-us/vbasic/bb737929.aspx). In your example it's something like: ``` var q = from a in TableA join b in TableB on a.Id equals b.Id into g ...
502,345
<p>The question could be subjective, so the syntax of </p> <pre><code>std::ostream&amp; operator &lt;&lt; (std::ostream &amp; o, const SomeClass &amp;a) { return o &lt;&lt; a.accessor().. ; } </code></pre> <p>When do you normally define this for the classes that you write, when do you avoid writing this friend f...
[ { "answer_id": 502349, "author": "vava", "author_id": 6258, "author_profile": "https://Stackoverflow.com/users/6258", "pm_score": 1, "selected": false, "text": "<p>I had never ever overloaded this one in production code. Although you might want do this if you log a lot, it'll be useful.<...
2009/02/02
[ "https://Stackoverflow.com/questions/502345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43756/" ]
The question could be subjective, so the syntax of ``` std::ostream& operator << (std::ostream & o, const SomeClass &a) { return o << a.accessor().. ; } ``` When do you normally define this for the classes that you write, when do you avoid writing this friend function for your class.
IF I want to stream a class I normally write this: ``` std::ostream& operator << (std::ostream& o, const SomeClass& a) { a.print(o); return o; } ``` Then make print a const method on SomeClass that knows how to serialize the class to a stream.
502,346
<p>StringBuilder has a reputation as being a faster string manipulation tool than simply concatenating strings. Whether or not that's true, I'm left wondering about the results of StringBuilder operations and the strings they produce.</p> <p>A quick jaunt into Reflector shows that StringBuilder.ToString() doesn't alw...
[ { "answer_id": 502360, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 4, "selected": true, "text": "<p>Outside of mscorlib, any instance of a System.String is immutable, period.</p>\n\n<p>StringBuilder does some interestin...
2009/02/02
[ "https://Stackoverflow.com/questions/502346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61164/" ]
StringBuilder has a reputation as being a faster string manipulation tool than simply concatenating strings. Whether or not that's true, I'm left wondering about the results of StringBuilder operations and the strings they produce. A quick jaunt into Reflector shows that StringBuilder.ToString() doesn't always return ...
Outside of mscorlib, any instance of a System.String is immutable, period. StringBuilder does some interesting manipulation of Strings internally but at the end of the day it won't return a string to you and then subsequently mutate it in a way that is visible to your code. As to whether subsequent calls to StringBu...
502,362
<p>Mathematics naive question:</p> <p>What is the "canonical" way to represent 14+1i? </p> <pre><code>14+i1 </code></pre> <p>or</p> <pre><code>14+i </code></pre> <p>Similarly, is it likely, in the 'real world', that scientific notation is going to creep into a complex number so as to freak out a complex numbers pa...
[ { "answer_id": 502368, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "<p>I would represent your first example as:</p>\n\n<pre><code>14 + 1i\n</code></pre>\n\n<p>And I would certainly expect t...
2009/02/02
[ "https://Stackoverflow.com/questions/502362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/426/" ]
Mathematics naive question: What is the "canonical" way to represent 14+1i? ``` 14+i1 ``` or ``` 14+i ``` Similarly, is it likely, in the 'real world', that scientific notation is going to creep into a complex number so as to freak out a complex numbers parser? For example, ``` 1.2345E+02-1.7002E-09i ``` **E...
No problems with MATLAB: ``` >> 5+i ans = 5.0000 + 1.0000i >> 5+1i ans = 5.0000 + 1.0000i >> 1.2345E+02-1.7002E-09i ans = 1.2345e+002 -1.7002e-009i ``` I think this shows that scientific notation ("`E`") in complex numbers is handled pretty well in the "real world"... to the extent that MATLAB is an influen...
502,366
<p>Previously, when I needed to store a number of related variables, I'd create a class.</p> <pre class="lang-js prettyprint-override"><code>function Item(id, speaker, country) { this.id = id; this.speaker = speaker; this.country = country; } var myItems = [new Item(1, 'john', 'au'), new Item(2, 'mary', 'us')]; <...
[ { "answer_id": 502369, "author": "vava", "author_id": 6258, "author_profile": "https://Stackoverflow.com/users/6258", "pm_score": 5, "selected": false, "text": "<p>I always use object literals</p>\n\n<pre><code>{id: 1, speaker:\"john\", country: \"au\"}\n</code></pre>\n" }, { "an...
2009/02/02
[ "https://Stackoverflow.com/questions/502366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Previously, when I needed to store a number of related variables, I'd create a class. ```js function Item(id, speaker, country) { this.id = id; this.speaker = speaker; this.country = country; } var myItems = [new Item(1, 'john', 'au'), new Item(2, 'mary', 'us')]; ``` But I'm wondering if this is a good practic...
The only difference between object literals and constructed objects are the properties inherited from the prototype. ``` var o = { 'a': 3, 'b': 4, 'doStuff': function() { alert(this.a + this.b); } }; o.doStuff(); // displays: 7 ``` --- You could make a struct factory. ``` function makeStruct(names) { v...
502,389
<p>I'm trying to build a data grid where one of the columns is a font name displayed in that font. Previously, I was working with a list box where I had defined the following template:</p> <pre><code>&lt;TextBlock Text="{Binding Path=Name}" FontFamily="{Binding Path=Name}"/&gt; </code></pre> <p>This worked just fine....
[ { "answer_id": 503425, "author": "Bryan Anderson", "author_id": 21186, "author_profile": "https://Stackoverflow.com/users/21186", "pm_score": 1, "selected": false, "text": "<p>Try </p>\n\n<pre><code>TextBlock.FontFamily=\"{Binding Font.Name}\"\n</code></pre>\n\n<p>Sometimes the binding s...
2009/02/02
[ "https://Stackoverflow.com/questions/502389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2186/" ]
I'm trying to build a data grid where one of the columns is a font name displayed in that font. Previously, I was working with a list box where I had defined the following template: ``` <TextBlock Text="{Binding Path=Name}" FontFamily="{Binding Path=Name}"/> ``` This worked just fine. So, I tweaked the data structur...
Jared's answer is correct, but I've found a concrete solution that's solved my problem. <http://blogs.msdn.com/vinsibal/archive/2008/12/17/wpf-datagrid-dynamically-updating-datagridcomboboxcolumn.aspx> Following this example, I changed my DataGridTextColumn definition to: ``` <dg:DataGridTextColumn Binding="{Binding...
502,391
<p>I am relatively new to jQuery and web development.</p> <p>I am using jQuery UI Tabs to create tabs.</p> <p>But I want the contents to be loaded only when I select a particular tab.</p>
[ { "answer_id": 502398, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 4, "selected": false, "text": "<p>UI/Tabs support loading tab content on demand via Ajax, check <a href=\"http://docs.jquery.com/UI/Tabs#Ajax_...
2009/02/02
[ "https://Stackoverflow.com/questions/502391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am relatively new to jQuery and web development. I am using jQuery UI Tabs to create tabs. But I want the contents to be loaded only when I select a particular tab.
OK, I assume when the user clicks a tab, you intend to fetch content dynamically, via AJAX. This really involves two things, **setting an onclick even for your tab** and **fetching the data via ajax**. **Setting an onclick event** Give your tab an class, for example *my\_tab*. Let's say that when the user clicks the ...
502,393
<p>I'm having an PHP application running on IIS7. I want to secure particular folder by modifying <code>web.config</code>. I don't want to use <code>&lt;location&gt;</code> tag in config as this will redirect users to login page. Rather then, I'd like to implement <code>HttpNotFoundHandler</code>.</p> <p>Say for examp...
[ { "answer_id": 502398, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 4, "selected": false, "text": "<p>UI/Tabs support loading tab content on demand via Ajax, check <a href=\"http://docs.jquery.com/UI/Tabs#Ajax_...
2009/02/02
[ "https://Stackoverflow.com/questions/502393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having an PHP application running on IIS7. I want to secure particular folder by modifying `web.config`. I don't want to use `<location>` tag in config as this will redirect users to login page. Rather then, I'd like to implement `HttpNotFoundHandler`. Say for example, <http://domain.com/SecureFolder> is the direc...
OK, I assume when the user clicks a tab, you intend to fetch content dynamically, via AJAX. This really involves two things, **setting an onclick even for your tab** and **fetching the data via ajax**. **Setting an onclick event** Give your tab an class, for example *my\_tab*. Let's say that when the user clicks the ...
502,411
<p>When I change the connection string using this code, it does not reload <code>app.config</code> at runtime. I expected it to reload similarly to how we reload <code>app.config</code>.</p> <pre><code>config.ConnectionStrings.ConnectionStrings["JVVNL_NEW.Properties.Settings.JVVNL_NEWConnectionString1"].ConnectionStri...
[ { "answer_id": 502464, "author": "Cerebrus", "author_id": 53718, "author_profile": "https://Stackoverflow.com/users/53718", "pm_score": 3, "selected": false, "text": "<p>IIRC, the ConfigurationManager.RefreshSection requires a string parameter specifying the name of the Section to refres...
2009/02/02
[ "https://Stackoverflow.com/questions/502411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When I change the connection string using this code, it does not reload `app.config` at runtime. I expected it to reload similarly to how we reload `app.config`. ``` config.ConnectionStrings.ConnectionStrings["JVVNL_NEW.Properties.Settings.JVVNL_NEWConnectionString1"].ConnectionString = ConString; config.ConnectionStr...
Had to do this exact thing. This is the code that worked for me: ``` var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionStringsSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); connectionStringsSection.ConnectionStrings["Blah"].ConnectionString ...
502,414
<p>I'm trying to move the caret in a Flex TextArea to the end after appending some text from my code. I've looked through the reference documentation for TextArea and its underlying TextField but it appears there is no method provided to handle this.</p> <p>One approach I've tried is to set focus to the text area and ...
[ { "answer_id": 502434, "author": "Chetan S", "author_id": 31284, "author_profile": "https://Stackoverflow.com/users/31284", "pm_score": 4, "selected": true, "text": "<p>Try this</p>\n\n<pre><code>textArea.selectionBeginIndex = textArea.length;\ntextArea.selectionEndIndex = textArea.lengt...
2009/02/02
[ "https://Stackoverflow.com/questions/502414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61385/" ]
I'm trying to move the caret in a Flex TextArea to the end after appending some text from my code. I've looked through the reference documentation for TextArea and its underlying TextField but it appears there is no method provided to handle this. One approach I've tried is to set focus to the text area and dispatch a...
Try this ``` textArea.selectionBeginIndex = textArea.length; textArea.selectionEndIndex = textArea.length; ```
502,415
<p>Using LinqToSql, I need to return a single (L) for the most recent modDate in a join table (CL).</p> <p>Tables:<br> L (Lid, meta1, meta2, ...)<br> CL (Cid, Lid, ModDate)</p> <p>Here is sql that produces the expected result</p> <pre><code>SELECT l.* FROM L l INNER JOIN ( SELECT TOP 1 cl.Lid, MAX(cl.ModDate) as...
[ { "answer_id": 502450, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>My SQL-fu isn't fabulous and it's before my first coffee, so I assume \"l\" in the outer query ends up being a comple...
2009/02/02
[ "https://Stackoverflow.com/questions/502415", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61378/" ]
Using LinqToSql, I need to return a single (L) for the most recent modDate in a join table (CL). Tables: L (Lid, meta1, meta2, ...) CL (Cid, Lid, ModDate) Here is sql that produces the expected result ``` SELECT l.* FROM L l INNER JOIN ( SELECT TOP 1 cl.Lid, MAX(cl.ModDate) as ModDate FROM CL cl IN...
Simple enough. The subquery projects us to the ids. The query fetches those records with matching ids. ``` var subquery = db.L .Where(L => L.meta1 = 5) .SelectMany(L => L.CLs) .GroupBy(CL => CL.Lid) .OrderByDescending(g => g.Max(CL => CL.ModDate)) .Select(g => g.Key) .Take(1) var query = db.L ...
502,420
<p>I am using <a href="http://en.wikipedia.org/wiki/MooTools" rel="nofollow noreferrer">MooTools</a> 1.11 and <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow noreferrer">jQuery</a> 1.2. The Ajax function is not working properly for the following code.</p> <pre><code>jQuery(document).ready(function($) { ...
[ { "answer_id": 502437, "author": "Ricardo Vega", "author_id": 53246, "author_profile": "https://Stackoverflow.com/users/53246", "pm_score": 0, "selected": false, "text": "<p>Or maybe (it's untested) you can use:</p>\n\n<pre><code>jQuery(document).ready(function(jQuery.noConflict(true)) {...
2009/02/02
[ "https://Stackoverflow.com/questions/502420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I am using [MooTools](http://en.wikipedia.org/wiki/MooTools) 1.11 and [jQuery](http://en.wikipedia.org/wiki/JQuery) 1.2. The Ajax function is not working properly for the following code. ``` jQuery(document).ready(function($) { confirm("Hello"); function confirm(message){ $.ajax({ url: 'aja...
[`confirm`](http://www.tizag.com/javascriptT/javascriptconfirm.php) is a built-in function (a reserved name)... try using a different name for it.
502,430
<p>Is there an equivalent in Java to the passing on const references in C++?<br> Isn't leaving out the "constness" misleading in regard to the method signature?</p>
[ { "answer_id": 502449, "author": "Naveen", "author_id": 39742, "author_profile": "https://Stackoverflow.com/users/39742", "pm_score": 1, "selected": false, "text": "<p>See this for achieving this in Java:\n<a href=\"http://www.javamex.com/java_equivalents/const_java.shtml\" rel=\"nofollo...
2009/02/02
[ "https://Stackoverflow.com/questions/502430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56380/" ]
Is there an equivalent in Java to the passing on const references in C++? Isn't leaving out the "constness" misleading in regard to the method signature?
No, there isn't. Java "final" is not an exact equivalent of C++ "const". The following (delayed initialization of a final variable) works in Java: ``` final double x; int w = 1; if (w > 2) { x = 0.5; } else { x = - 0.5; } ``` but it doesn't work in C++ with "final" replaced by "const". Using "final" on a v...
502,431
<p>Is there any option for using IF-ELSE conditioning in HTML tags</p> <pre><code> &lt;if true&gt; do something &lt;/if&gt; &lt;else&gt; do something &lt;/else&gt; </code></pre>
[ { "answer_id": 502442, "author": "wilsoniya", "author_id": 60366, "author_profile": "https://Stackoverflow.com/users/60366", "pm_score": 3, "selected": false, "text": "<p>Not to be pedantic, but HTML is a markup language, and isn't useful for conditional logic. </p>\n\n<p>That being sai...
2009/02/02
[ "https://Stackoverflow.com/questions/502431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
Is there any option for using IF-ELSE conditioning in HTML tags ``` <if true> do something </if> <else> do something </else> ```
There is, but it's [really only used in IE](http://www.quirksmode.org/css/condcom.html) to distinguish between different versions: ``` <!--[if IE6]> Things here! <![endif]--> ```
502,443
<p>I'm currently trying out some questions just to practice my programming skills. ( Not taking it in school or anything yet, self taught ) I came across this problem which required me to read in a number from a given txt file. This number would be N. Now I'm suppose to find the Nth prime number for N &lt;= 10 000. Aft...
[ { "answer_id": 502466, "author": "dreeves", "author_id": 4234, "author_profile": "https://Stackoverflow.com/users/4234", "pm_score": 0, "selected": false, "text": "<p>Since this is for pedagogical purposes, I would suggest implementing <a href=\"http://en.wikipedia.org/wiki/Sieve_of_Erat...
2009/02/02
[ "https://Stackoverflow.com/questions/502443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61393/" ]
I'm currently trying out some questions just to practice my programming skills. ( Not taking it in school or anything yet, self taught ) I came across this problem which required me to read in a number from a given txt file. This number would be N. Now I'm suppose to find the Nth prime number for N <= 10 000. After I f...
``` #include <cstdio> #include <iostream> #include <cstdlib> #include <fstream> using namespace std; int main() { ifstream trial; trial.open("C:\\Users\\User\\Documents\\trial.txt"); int prime, e; trial>>prime; ofstream write; write.open("C:\\Users\\User\\Documents\\answer.txt"); int num[10000], currentPrime, c, pri...
502,447
<p>Slowly getting the hang of List matching and tail recursion, I needed a function which 'stitches' a list of lists together leaving off intermediate values (easier to show than explain):</p> <p>merge [[1;2;3];[3;4;5];[5;6;7]] //-> [1;2;3;4;5;6;7]</p> <p>The code for the List.merge function looks like this:</p> <pr...
[ { "answer_id": 502466, "author": "dreeves", "author_id": 4234, "author_profile": "https://Stackoverflow.com/users/4234", "pm_score": 0, "selected": false, "text": "<p>Since this is for pedagogical purposes, I would suggest implementing <a href=\"http://en.wikipedia.org/wiki/Sieve_of_Erat...
2009/02/02
[ "https://Stackoverflow.com/questions/502447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
Slowly getting the hang of List matching and tail recursion, I needed a function which 'stitches' a list of lists together leaving off intermediate values (easier to show than explain): merge [[1;2;3];[3;4;5];[5;6;7]] //-> [1;2;3;4;5;6;7] The code for the List.merge function looks like this: ``` ///Like concat, but ...
``` #include <cstdio> #include <iostream> #include <cstdlib> #include <fstream> using namespace std; int main() { ifstream trial; trial.open("C:\\Users\\User\\Documents\\trial.txt"); int prime, e; trial>>prime; ofstream write; write.open("C:\\Users\\User\\Documents\\answer.txt"); int num[10000], currentPrime, c, pri...
502,463
<p>I recently started using the module <a href="http://search.cpan.org/dist/MooseX-Declare" rel="nofollow noreferrer">MooseX::Declare</a>. I love it for its syntax. It's elegant and neat. Has anyone come across cases where you would want to write many functions (some of them big) inside a class and the class definition...
[ { "answer_id": 502914, "author": "Penfold", "author_id": 11952, "author_profile": "https://Stackoverflow.com/users/11952", "pm_score": 3, "selected": false, "text": "<p>Easy (but needs adding to the doc).</p>\n\n<pre><code>class BankAccount is mutable {\n}\n</code></pre>\n\n<p>As an asid...
2009/02/02
[ "https://Stackoverflow.com/questions/502463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48288/" ]
I recently started using the module [MooseX::Declare](http://search.cpan.org/dist/MooseX-Declare). I love it for its syntax. It's elegant and neat. Has anyone come across cases where you would want to write many functions (some of them big) inside a class and the class definition running into pages? Is there any workar...
Easy (but needs adding to the doc). ``` class BankAccount is mutable { } ``` As an aside, why are you defining your methods outside the class? You can just go ``` class BankAccount is mutable { method foo (Int $bar) { # do stuff } } ```
502,482
<p>In my app I change the value of a text label from an initial value of 0 and increment it on a touch event. Sometimes, but not all the time, the new value will be overlayed over the 0, which is not cool..</p> <p>This is the relevant code:</p> <pre><code>UITableViewCell *cell = [tableView cellForRowAtIndexPath:index...
[ { "answer_id": 601479, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Under your UILabel options UNCHECK 'opaque', that will fix it.</p>\n" }, { "answer_id": 800209, "author": "Comm...
2009/02/02
[ "https://Stackoverflow.com/questions/502482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In my app I change the value of a text label from an initial value of 0 and increment it on a touch event. Sometimes, but not all the time, the new value will be overlayed over the 0, which is not cool.. This is the relevant code: ``` UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UILabel *label...
check the "clears graphics context" works for me, i carelessly deselected it at first~~
502,485
<p>what would happen if I spin off a thread to execute a long-running process right before the ASP.NET page lifecycle completes? Will the ASP.NET runtime kill the thread? Can this lead to undefined behaviour?</p> <p>Here's a sample of the code, which spins the background thread in the Page_Load event. Is this a safe t...
[ { "answer_id": 502565, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": true, "text": "<p>I have done some experimenting with the same type of code doing some time consuming logging in a separate thread. ...
2009/02/02
[ "https://Stackoverflow.com/questions/502485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6441/" ]
what would happen if I spin off a thread to execute a long-running process right before the ASP.NET page lifecycle completes? Will the ASP.NET runtime kill the thread? Can this lead to undefined behaviour? Here's a sample of the code, which spins the background thread in the Page\_Load event. Is this a safe thing to d...
I have done some experimenting with the same type of code doing some time consuming logging in a separate thread. It seems to work well, but I haven't tested it in a production enviroment. The only difference between your code and mine is that I used the thread pool instead of setting up a new thread. You will probab...
502,491
<p>How to get a link not underlined in HTML?</p>
[ { "answer_id": 502497, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 1, "selected": false, "text": "<p>You'll probably want to do that in CSS.</p>\n\n<pre><code>a {\n text-decoration: none;\n}\n</code></pre>\n\n<p>Or, a...
2009/02/02
[ "https://Stackoverflow.com/questions/502491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to get a link not underlined in HTML?
It can be done in following ways: 1) If you want to remove underline from specific link, then use ``` <a href="#" style="text-decoration:none;">Some text</a> ``` 2) To remove the underline from entire html page, Create a .css file, In that write following: ``` a { text-decoration: none; } ``` It will suppress un...
502,494
<p>I used </p> <pre><code>Runtime.getRuntime().exec("_____") </code></pre> <p>but it throws a <code>IOException</code> as below:</p> <pre><code>java.io.IOException: CreateProcess: c:/ error=5 at java.lang.Win32Process.create(Native Method) at java.lang.Win32Process.&lt;init&gt;(Win32Process.java:63) at java.la...
[ { "answer_id": 502581, "author": "Dean", "author_id": 59646, "author_profile": "https://Stackoverflow.com/users/59646", "pm_score": 2, "selected": false, "text": "<p>How about just calling the main from your java program?</p>\n\n<p>Test.main(null);</p>\n\n<p>This worked fine for me</p>\n...
2009/02/02
[ "https://Stackoverflow.com/questions/502494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/201406/" ]
I used ``` Runtime.getRuntime().exec("_____") ``` but it throws a `IOException` as below: ``` java.io.IOException: CreateProcess: c:/ error=5 at java.lang.Win32Process.create(Native Method) at java.lang.Win32Process.<init>(Win32Process.java:63) at java.lang.Runtime.execInternal(Native Method ``` I don't kn...
You're trying to execute "C:/". You'll want to execute something like: `"javaw.exe d:\\somejavaprogram\\program.jar"` Notice the path separators. I'm assuming this is for an ad-hoc project, rather than something large. However, for best practice running external programs from code: * Don't hardcode the executable l...
502,500
<p>I have a div with a width of 250px. When the innertext is wider than that i want it to break down. The div is float: left and now has an overflow. I want the scrollbar to go away by using word-wrapping. How can i achieve this?</p> <pre><code>&lt;div id="Treeview"&gt; &lt;div id="HandboekBox"&gt; &lt;div id="Han...
[ { "answer_id": 502514, "author": "Andrew", "author_id": 51534, "author_profile": "https://Stackoverflow.com/users/51534", "pm_score": 2, "selected": false, "text": "<p>I'm a little surprised it doesn't just do that. Could there another element inside the div that has a width set to somet...
2009/02/02
[ "https://Stackoverflow.com/questions/502500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
I have a div with a width of 250px. When the innertext is wider than that i want it to break down. The div is float: left and now has an overflow. I want the scrollbar to go away by using word-wrapping. How can i achieve this? ``` <div id="Treeview"> <div id="HandboekBox"> <div id="HandboekTitel"> <asp:Lab...
As Andrew said, your text should be doing just that. There is one instance that I can think of that will behave in the manner you suggest, and that is if you have the whitespace property set. See if you don't have the following in your CSS somewhere: ``` white-space: nowrap ``` That will cause text to continue on ...
502,502
<p>I am doing an HTTP POST using cURL</p> <pre><code>$url = "http://localhost:8080/~demo/cgi-bin/execute/100"; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($data)); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); ...
[ { "answer_id": 502515, "author": "David Grant", "author_id": 40581, "author_profile": "https://Stackoverflow.com/users/40581", "pm_score": 0, "selected": false, "text": "<p>It may not be cURL that is changing the URL, rather that the web server is sending a redirect header to cURL, point...
2009/02/02
[ "https://Stackoverflow.com/questions/502502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18615/" ]
I am doing an HTTP POST using cURL ``` $url = "http://localhost:8080/~demo/cgi-bin/execute/100"; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($data)); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); //execute post...
* Install Fiddler. * Enable debugging. * Visit the site in the browser. * Execute php cURL code. Fiddler will tell you exactly what the web server is receiving and sending. since you are running locally, you can see exactly what php is sending as well. Compare the two and that will tell you the problem.
502,535
<p>I think its possible but i cant come up with the right algorithm for it.</p> <p>What i wanted to do was:</p> <p>If today is monday feb 2 2009, how would i know the date of last week's tuesday? Using that same code 2 days after, i would find the same date of last week's tuesday with the current date being wednesday...
[ { "answer_id": 502550, "author": "Jack Sleight", "author_id": 39428, "author_profile": "https://Stackoverflow.com/users/39428", "pm_score": 4, "selected": false, "text": "<p>PHP actually makes this really easy:</p>\n\n<pre><code>echo strtotime('last Tuesday');\n</code></pre>\n\n<p>See th...
2009/02/02
[ "https://Stackoverflow.com/questions/502535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24744/" ]
I think its possible but i cant come up with the right algorithm for it. What i wanted to do was: If today is monday feb 2 2009, how would i know the date of last week's tuesday? Using that same code 2 days after, i would find the same date of last week's tuesday with the current date being wednesday, feb 4 2009.
I know there is an accepted answer already, but imho it does not meet the second requirement that was asked for. In the above case, strtotime would yield yesterday if used on a wednesday. So, just to be exact you would still need to check for this: ``` $tuesday = strtotime('last Tuesday'); // check if we need to go ba...
502,545
<pre><code>mysqldump: Couldn't execute 'show fields from `tablename`': Out of resources when opening file './databasename/tablename#P#p125.MYD' (Errcode: 24) (23) </code></pre> <p>on checking the error 24 on the shell it says</p> <pre><code>&gt;&gt;perror 24 OS error code 24: Too many open files </code></pre> <p>...
[ { "answer_id": 502555, "author": "Nik Reiman", "author_id": 14302, "author_profile": "https://Stackoverflow.com/users/14302", "pm_score": 0, "selected": false, "text": "<p>There is no guarantee that \"24\" is an OS-level error number, so don't assume that this means that too many file ha...
2009/02/02
[ "https://Stackoverflow.com/questions/502545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` mysqldump: Couldn't execute 'show fields from `tablename`': Out of resources when opening file './databasename/tablename#P#p125.MYD' (Errcode: 24) (23) ``` on checking the error 24 on the shell it says ``` >>perror 24 OS error code 24: Too many open files ``` how do I solve this?
At first, to identify the certain user or group limits you have to do the following: ``` root@ubuntu:~# sudo -u mysql bash mysql@ubuntu:~$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimite...
502,548
<p>For the following If-statements in VB.NET, what will be the sequence in which the conditions will be evaluated?</p> <p><strong>Case 1:</strong></p> <pre><code>If ( condition1 AND condition2 AND condition3 ) . . End If </code></pre> <p><strong>Case 2:</strong></p> <pre><code>If ( condition1 OR condition2 OR condi...
[ { "answer_id": 502559, "author": "Gerrie Schenck", "author_id": 57036, "author_profile": "https://Stackoverflow.com/users/57036", "pm_score": 4, "selected": false, "text": "<p>VB.Net evaluates all the conditions, so the order isn't important here.</p>\n\n<p>If you want to use short-circu...
2009/02/02
[ "https://Stackoverflow.com/questions/502548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For the following If-statements in VB.NET, what will be the sequence in which the conditions will be evaluated? **Case 1:** ``` If ( condition1 AND condition2 AND condition3 ) . . End If ``` **Case 2:** ``` If ( condition1 OR condition2 OR condition3 ) . . End If ``` **Case 3:** ``` If ( condition1 OR condition...
VB.NET is a very strange beast from the C-programmer standpoint. As Gerrie mentioned in a different answer, all three conditions are evaluated in their full entirety without short-circuiting. AndAlso and OrElse can save your day if that's what you want. As for the last *if*, the order of evaluation is as follows: ```...
502,570
<p>I am working on a simple token replacement feature of our product. I have almost resolved all the issue but I missed one thing. A token must support attributes, and an attribute can also be a token. This is part of a bigger project. hope you can help.</p> <p>The begining tag is <code>"**#[**"</code> and the ending ...
[ { "answer_id": 502613, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "<p>This is a little border-line for a regexp, since it depends on a context, but still...</p>\n\n<pre><code>#\\[(\\](?=\")|[^\\...
2009/02/02
[ "https://Stackoverflow.com/questions/502570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on a simple token replacement feature of our product. I have almost resolved all the issue but I missed one thing. A token must support attributes, and an attribute can also be a token. This is part of a bigger project. hope you can help. The begining tag is `"**#[**"` and the ending tag is `"**]**"`. Say...
This is a little border-line for a regexp, since it depends on a context, but still... ``` #\[(\](?=")|[^\]])+\] ``` should do it. The idea is to mention a closing square bracket can be part of the parsed content if followed by a double quotes, as part of the end of an attribute. If that same square bracket were a...
502,600
<p>If you look at Stackoverflow.com's source you'll see the reference to their css file is:</p> <pre><code>&lt;link href="/Content/all.min.css?v=2383" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>How is this done so they can pass a version via query string and have the correct CSS file served up?</p>
[ { "answer_id": 502618, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<p>Its so your browser does not cache the css file. And using the version number is handy since the css file could ha...
2009/02/02
[ "https://Stackoverflow.com/questions/502600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2635/" ]
If you look at Stackoverflow.com's source you'll see the reference to their css file is: ``` <link href="/Content/all.min.css?v=2383" rel="stylesheet" type="text/css" /> ``` How is this done so they can pass a version via query string and have the correct CSS file served up?
[This article (PHP/.htaccess example)](http://particletree.com/notebook/automatically-version-your-css-and-javascript-files/) explains the idea behind it. Basically, you could append the timestamp of the last time you modified the file to the filename but still serve the original file. This way every time you save a ne...
502,610
<p>I have a class that I wish to test via SimpleXMLRPCServer in python. The way I have my unit test set up is that I create a new thread, and start SimpleXMLRPCServer in that. Then I run all the test, and finally shut down.</p> <p>This is my ServerThread:</p> <pre><code>class ServerThread(Thread): running = True ...
[ { "answer_id": 502956, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": true, "text": "<p>Two suggestions.</p>\n\n<p>Suggestion One is to use a separate process instead of a separate thread.</p>\n\n<ul>\n<li><p>...
2009/02/02
[ "https://Stackoverflow.com/questions/502610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I have a class that I wish to test via SimpleXMLRPCServer in python. The way I have my unit test set up is that I create a new thread, and start SimpleXMLRPCServer in that. Then I run all the test, and finally shut down. This is my ServerThread: ``` class ServerThread(Thread): running = True def run(self): ...
Two suggestions. Suggestion One is to use a separate process instead of a separate thread. * Create a stand-alone XMLRPC server program. * Start it with `subprocess.Popen()`. * Kill it when the test is done. In standard OS's (not Windows) the kill works nicely. In Windows, however, there's no trivial kill function, b...
502,614
<p>Can someone explain to me why</p> <pre><code>@Override public void fooMethod(Class&lt;?&gt; c) </code></pre> <p>doesn't override</p> <pre><code>public void fooMethod(Class c) </code></pre> <p>and gives me the following errors instead:</p> <pre> - Name clash: The method fooMethod(Class&lt;?&gt;) of type SubClas...
[ { "answer_id": 502623, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": -1, "selected": false, "text": "<p>Because <code>Class&lt;?&gt;</code> is more specific than just <code>Class</code>.</p>\n\n<p>For example, <code>foo(Class...
2009/02/02
[ "https://Stackoverflow.com/questions/502614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2238/" ]
Can someone explain to me why ``` @Override public void fooMethod(Class<?> c) ``` doesn't override ``` public void fooMethod(Class c) ``` and gives me the following errors instead: ``` - Name clash: The method fooMethod(Class<?>) of type SubClass has the same erasure as fooMethod(Class) of type SuperClass but...
The signature of `fooMethod(Class<?>)` is the same as the signature of `fooMethod(Class)` after erasure, since the erasure of `Class<?>` is simply `Class` ([JLS 4.6](http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html)). Hence, `fooMethod(Class)` is a subsignature of the `fooMethod(Class<?>)` but not...
502,640
<p>I am using the MFC Feature Pack and I have some buttons on a ribbon bar, instances of CMFCRibbonButton. The problem is that I would like to enable and disable some of them in certain conditions, but at runtime. How can I do this? because there is no specific method for this...I heard that a solution would be to atta...
[ { "answer_id": 504125, "author": "ChrisN", "author_id": 3853, "author_profile": "https://Stackoverflow.com/users/3853", "pm_score": 5, "selected": true, "text": "<p>When you create the <code>CMFCRibbonButton</code> object you have to specify the associated command ID (see the documentati...
2009/02/02
[ "https://Stackoverflow.com/questions/502640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51336/" ]
I am using the MFC Feature Pack and I have some buttons on a ribbon bar, instances of CMFCRibbonButton. The problem is that I would like to enable and disable some of them in certain conditions, but at runtime. How can I do this? because there is no specific method for this...I heard that a solution would be to attach/...
When you create the `CMFCRibbonButton` object you have to specify the associated command ID (see the documentation for the `CMFCRibbonButton` constructor [here](http://msdn.microsoft.com/en-us/library/bb982247.aspx)). Enabling and disabling of ribbon buttons is then done using the usual command update mechanism in MFC,...
502,641
<p>I'm playing with a PHP weblog application using a shared hosting service, as a part of my PHP learning process. The service provider has a typical LAMP environment with remote ssh access. </p> <p>Vim has been my best friend in exploring the PHP code. However, I found it sometimes hard to trace stuff in the code in ...
[ { "answer_id": 502654, "author": "pvieira", "author_id": 18073, "author_profile": "https://Stackoverflow.com/users/18073", "pm_score": 0, "selected": false, "text": "<p>Try NuSphere PhpED</p>\n" }, { "answer_id": 502658, "author": "cg.", "author_id": 52439, "author_pr...
2009/02/02
[ "https://Stackoverflow.com/questions/502641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47707/" ]
I'm playing with a PHP weblog application using a shared hosting service, as a part of my PHP learning process. The service provider has a typical LAMP environment with remote ssh access. Vim has been my best friend in exploring the PHP code. However, I found it sometimes hard to trace stuff in the code in case of er...
I assume your hosting provider configured their PHP installation with [display\_errors](http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors) turned off, which is a good thing. That's why you're seeing blank pages. So the most practical solution at the moment would be to have an .htaccess file wh...
502,657
<ul> <li>a ticketing site offers a discount on "family" tickets.</li> <li>a family ticket is 2 adults, 2 children.</li> <li>the sell tickets page allows a user to enter any number of adult and child tickets.</li> </ul> <p><strong>How do I work out how to apply the family ticket discount, then charge all remaining tick...
[ { "answer_id": 502665, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 2, "selected": false, "text": "<p>Something along these lines (pseudocode):</p>\n\n<pre><code>adultPairs = totalAdults / 2\nchildPairs = totalChild...
2009/02/02
[ "https://Stackoverflow.com/questions/502657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31399/" ]
* a ticketing site offers a discount on "family" tickets. * a family ticket is 2 adults, 2 children. * the sell tickets page allows a user to enter any number of adult and child tickets. **How do I work out how to apply the family ticket discount, then charge all remaining tickets at their relevant cost (i.e. adult ti...
I don't think your approach actually works. Assume you have 6 adults and 4 children. In this case your first `if` would be true and you would end up with `3 - 2 = 1` family ticket. The correct result would be two family tickets and two adult tickets, though. You want the lowest number of pairs to determine the amount ...
502,667
<p>In a <code>Telerik</code> control, I was able to bind a <code>DataTable</code> directly to the <code>ItemSource</code>, but when I switched to the Codeplex <code>WPFToolkit</code> <code>Datagrid</code>:</p> <pre><code>&lt;dg:DataGrid Name="theGrid"/&gt; --- theGrid.ItemsSource = dt; </code></pre> <p>I get this err...
[ { "answer_id": 502701, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 3, "selected": true, "text": "<p>You'll have to project your datatable into something that implements IEnumerable as that is waht the DataGrid expect...
2009/02/02
[ "https://Stackoverflow.com/questions/502667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
In a `Telerik` control, I was able to bind a `DataTable` directly to the `ItemSource`, but when I switched to the Codeplex `WPFToolkit` `Datagrid`: ``` <dg:DataGrid Name="theGrid"/> --- theGrid.ItemsSource = dt; ``` I get this error: ``` Cannot implicitly convert type 'System.Data.DataTable' to 'System.Collections....
You'll have to project your datatable into something that implements IEnumerable as that is waht the DataGrid expects. The grid is a different implementation to the Telerik version so its hard to expect the same functionality from both.
502,671
<p>I have a table where new records are added daily. How would I go about finding records created in the previous month?</p>
[ { "answer_id": 502694, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 0, "selected": false, "text": "<p>Do you have the \"usual\" fields on your table? See the <a href=\"http://wiki.rubyonrails.org/rails/pages/MagicFieldNam...
2009/02/02
[ "https://Stackoverflow.com/questions/502671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a table where new records are added daily. How would I go about finding records created in the previous month?
Set up a named scope: ``` named_scope :in_last_month, :conditions => [ "records.created_at > ?", 1.month.ago ] ``` To call it (in your controller): ``` Record.in_last_month ```
502,672
<p>How do you create multiple DB connections using Singleton pattern? Or maybe there's better approach, to share the same class but multiple connections?</p>
[ { "answer_id": 502681, "author": "Techmaddy", "author_id": 50434, "author_profile": "https://Stackoverflow.com/users/50434", "pm_score": 0, "selected": false, "text": "<p>Connection Pooling.</p>\n\n<p>In case of java:</p>\n\n<p><a href=\"http://java.sun.com/developer/onlineTraining/Progr...
2009/02/02
[ "https://Stackoverflow.com/questions/502672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53948/" ]
How do you create multiple DB connections using Singleton pattern? Or maybe there's better approach, to share the same class but multiple connections?
How about using a Factory pattern to return the same instance for each connection, e.g. ``` ConnectionFactory::getInstance(ConnectionFactory::DEVELOPMENT); ``` Returns a `Connection` instance for a connection to the development database. Instantiation of the `Connection` should only be performed by the `Connection...
502,684
<p>I am currently developing a small project of mine that generates SQL calls in a dynamic way to be used by an other software. The SQL calls are not known beforehand and therefore I would like to be able to unit test the object that generates the SQL. </p> <p>Do you have a clue of how would be the best approach to do...
[ { "answer_id": 502697, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 0, "selected": false, "text": "<p>You don't have to test all cases. Make a collection of example calls, be sure to include as many of the difficult aspec...
2009/02/02
[ "https://Stackoverflow.com/questions/502684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59332/" ]
I am currently developing a small project of mine that generates SQL calls in a dynamic way to be used by an other software. The SQL calls are not known beforehand and therefore I would like to be able to unit test the object that generates the SQL. Do you have a clue of how would be the best approach to do this? Bea...
This seems like a hen-egg situation. You aren't sure what the generator will spit out and you have a moving target to test against (the real database). So you need to tie the loose ends down. Create a small test database (for example with HSQLDB or Derby). This database should use the same features as the real one, bu...
502,695
<p>I have a weird problem with Visual Studio 2008 in just one of my projects. When I set a break point on a line of code, it gets hit alright, but when I try to 'step over,' or whatever else that is supposed to pass over that break point and stop on the next line, the code gets executed and continues as if I hit F5. Th...
[ { "answer_id": 502705, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 2, "selected": false, "text": "<p>Often this can be due to an uncaught exception. Try catching all exceptions in your IDE.</p>\n\n<p>On the menu b...
2009/02/02
[ "https://Stackoverflow.com/questions/502695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34623/" ]
I have a weird problem with Visual Studio 2008 in just one of my projects. When I set a break point on a line of code, it gets hit alright, but when I try to 'step over,' or whatever else that is supposed to pass over that break point and stop on the next line, the code gets executed and continues as if I hit F5. This ...
Known issue with VS2008. A patch is available [here](http://support.microsoft.com/kb/957912).
502,726
<p>Using a Python script, I need to read a CVS file where dates are formated as DD/MM/YYYY, and convert them to YYYY-MM-DD before saving this into a SQLite database.</p> <p>This almost works, but fails because I don't provide time:</p> <pre><code>from datetime import datetime lastconnection = datetime.strptime("21/1...
[ { "answer_id": 502737, "author": "SilentGhost", "author_id": 12855, "author_profile": "https://Stackoverflow.com/users/12855", "pm_score": 4, "selected": false, "text": "<p>you first would need to convert string into datetime tuple, and then convert that datetime tuple to string, it woul...
2009/02/02
[ "https://Stackoverflow.com/questions/502726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Using a Python script, I need to read a CVS file where dates are formated as DD/MM/YYYY, and convert them to YYYY-MM-DD before saving this into a SQLite database. This almost works, but fails because I don't provide time: ``` from datetime import datetime lastconnection = datetime.strptime("21/12/2008", "%Y-%m-%d") ...
Your example code is wrong. This works: ``` import datetime datetime.datetime.strptime("21/12/2008", "%d/%m/%Y").strftime("%Y-%m-%d") ``` The call to strptime() parses the first argument according to the format specified in the second, so those two need to match. Then you can call strftime() to format the result in...
502,727
<p>Windows HeapFree, msvcrt free: do they cause the memory being freed to be paged-in? I am trying to estimate if not freeing memory at exit would speed up application shutdown significantly.</p> <p>NOTE: This is a very specific technical question. It's not about whether applications should or should not call <code>fr...
[ { "answer_id": 502752, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "<p>I'm almost certain the answer to the speed improvement question would be \"yes\". Freeing a block may or may not touch...
2009/02/02
[ "https://Stackoverflow.com/questions/502727", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20310/" ]
Windows HeapFree, msvcrt free: do they cause the memory being freed to be paged-in? I am trying to estimate if not freeing memory at exit would speed up application shutdown significantly. NOTE: This is a very specific technical question. It's not about whether applications should or should not call `free` at exit.
I ran a test for `HeapFree`. The following program has access violation inside `HeapFree` at i = 31999: ``` #include <windows.h> int main() { HANDLE heap = GetProcessHeap(); void * bufs[64000]; // populate heap for (unsigned i = 0; i < _countof(bufs); ++i) { bufs[i] = HeapAlloc(heap, 0, 4000...
502,731
<p>At which part of the Scrum process does your team make educated estimates as to the effort required to complete a given product backlog item?</p> <p>For example, say you have a product backlog item that says "The user will be able to supply their email address and receive an email with a link for resetting their pa...
[ { "answer_id": 502760, "author": "Oskar Duveborn", "author_id": 49293, "author_profile": "https://Stackoverflow.com/users/49293", "pm_score": 3, "selected": false, "text": "<p>The rough estimate should be done before the sprint planning where this particular item is supposedly picked by ...
2009/02/02
[ "https://Stackoverflow.com/questions/502731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33404/" ]
At which part of the Scrum process does your team make educated estimates as to the effort required to complete a given product backlog item? For example, say you have a product backlog item that says "The user will be able to supply their email address and receive an email with a link for resetting their password" sc...
Usually, estimation should be done in 2 levels at the start of each sprint: story level and task level. For best results, product owner and team should do both together, every time, although sometimes it is acceptable for the team estimate at task level without the product owner present. Project Estimation / Roadmap C...
502,735
<p>The normal way to get the windows serial number is WMI.</p> <pre><code> ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * From Win32_OperatingSystem"); // ... // Select number from managementobject mo["SerialNumber"] </code></pre> <p>I don't want to use WMI because the compact framework dosn'...
[ { "answer_id": 502762, "author": "Stormenet", "author_id": 2090, "author_profile": "https://Stackoverflow.com/users/2090", "pm_score": 2, "selected": true, "text": "<p>You'll need to invoke KernelIOControl for WindowsCE.</p>\n\n<p>Here's the c++ code, don't have the time to convert it to...
2009/02/02
[ "https://Stackoverflow.com/questions/502735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40357/" ]
The normal way to get the windows serial number is WMI. ``` ManagementObjectSearcher mos = new ManagementObjectSearcher("Select * From Win32_OperatingSystem"); // ... // Select number from managementobject mo["SerialNumber"] ``` I don't want to use WMI because the compact framework dosn't support it. The assembly...
You'll need to invoke KernelIOControl for WindowsCE. Here's the c++ code, don't have the time to convert it to c# ``` #include <WINIOCTL.H> extern "C" __declspec(dllimport) BOOL KernelIoControl( DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned ); ...
502,743
<p>I have an application with 2 directories (books and export).<br /> If we create a book or a page of a book in the application a directory is added with the id of the page (this is for uploading resources).<br /> If we delete a page, the page (and it's directory) is removed from the database and the filesystem.</p> <...
[ { "answer_id": 502754, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I had the same problem. The solution is to externalize the session handling by using the ASP.Net State service. The only dr...
2009/02/02
[ "https://Stackoverflow.com/questions/502743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29964/" ]
I have an application with 2 directories (books and export). If we create a book or a page of a book in the application a directory is added with the id of the page (this is for uploading resources). If we delete a page, the page (and it's directory) is removed from the database and the filesystem. However this ...
> > Oh and putting the directory outside > the virtual directory is not an > option. > > > Putting the directory outside the virtual directory is the only solution I found (so far). What you can do, is to create a link (junction) in the file system so that the directory appears to be inside the virtual directory...
502,761
<p>I have created a custom WPF user control which is intended to be used by a third party. My control has a private member which is disposable, and I would like to ensure that its dispose method will always get called once the containing window/application is closed. However, UserControl is not disposable.</p> <p>I tri...
[ { "answer_id": 502773, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 7, "selected": true, "text": "<p>Interesting blog post here: <a href=\"https://web.archive.org/web/20091029112834/http://geekswithblogs.net/cskardon/...
2009/02/02
[ "https://Stackoverflow.com/questions/502761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7532/" ]
I have created a custom WPF user control which is intended to be used by a third party. My control has a private member which is disposable, and I would like to ensure that its dispose method will always get called once the containing window/application is closed. However, UserControl is not disposable. I tried implem...
Interesting blog post here: [Dispose of a WPF UserControl (ish)](https://web.archive.org/web/20091029112834/http://geekswithblogs.net/cskardon/archive/2008/06/23/dispose-of-a-wpf-usercontrol-ish.aspx) It mentions subscribing to [Dispatcher.ShutdownStarted](http://msdn.microsoft.com/en-us/library/system.windows.threadi...
502,763
<p>Does anyone have experience with the prefuse graph toolkit? Is it possible to change an already displayed graph, ie. add/remove nodes and/or edges, and have the display correctly adapt? </p> <p>For instance, prefuse comes with an example that visualizes a network of friends:</p> <blockquote> <p><a href="http://p...
[ { "answer_id": 502900, "author": "aldrinleal", "author_id": 39261, "author_profile": "https://Stackoverflow.com/users/39261", "pm_score": 0, "selected": false, "text": "<p>You need to tell the control container ('d', in example.java) do get redrawn. Calling invalidate() should be enough ...
2009/02/02
[ "https://Stackoverflow.com/questions/502763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone have experience with the prefuse graph toolkit? Is it possible to change an already displayed graph, ie. add/remove nodes and/or edges, and have the display correctly adapt? For instance, prefuse comes with an example that visualizes a network of friends: > > <http://prefuse.org/doc/manual/introduction/...
As pointed out in my other post, the reason new nodes and edges are not visible in the original example is that the colors etc. for the nodes are not set correctly. One way to fix this is to explicitly call vis.run("color"); whenever a node or edge was added. Alternatively, we can ensure that the color action is alway...
502,782
<p>Hai, </p> <p>I tried to create a <strong>ListViewControl</strong> (tile mode) and added a <em>ListViewItem</em>. I created it like this,</p> <pre><code>ListViewItem aFooItem = new ListViewItem("foo"); listView1.Items.Add(aFooItem); //Adding the ListViewItem to the ListViewControl </code></pre> <p>Now I ran the a...
[ { "answer_id": 502800, "author": "Robert MacLean", "author_id": 53236, "author_profile": "https://Stackoverflow.com/users/53236", "pm_score": 2, "selected": false, "text": "<p>For me it is that your code to communicate via SOAP, WS*, TCP, MSMQ, Named Pipes or any other transport later is...
2009/02/02
[ "https://Stackoverflow.com/questions/502782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hai, I tried to create a **ListViewControl** (tile mode) and added a *ListViewItem*. I created it like this, ``` ListViewItem aFooItem = new ListViewItem("foo"); listView1.Items.Add(aFooItem); //Adding the ListViewItem to the ListViewControl ``` Now I ran the application and tried to debug the first line. I found...
A major advantage is that WCF allows a single consistent access to windows communication technologies for developers thereby enabling easier development of SOA applications. Microsoft has abstracted a lot of the plumbing work so as to enable this. A drawback would be that, WCF is Microsoft's implementation of SOA and ...
502,792
<p>I am working on a web API for the insurance industry and trying to work out a suitable data structure for the quoting of insurance.</p> <p>The database already contains a "ratings" table which is basically:</p> <pre><code>sysID (PK, INT IDENTITY) goods_type (VARCHAR(16)) suminsured_min (DECIMAL(9,2)) suminsured_ma...
[ { "answer_id": 502837, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 0, "selected": false, "text": "<p>i am not entirely sure exactly what calculations we are talking about, but unless they are obnoxiously complicated...
2009/02/02
[ "https://Stackoverflow.com/questions/502792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59754/" ]
I am working on a web API for the insurance industry and trying to work out a suitable data structure for the quoting of insurance. The database already contains a "ratings" table which is basically: ``` sysID (PK, INT IDENTITY) goods_type (VARCHAR(16)) suminsured_min (DECIMAL(9,2)) suminsured_max (DECIMAL(9,2)) perc...
Don't create new tables. You already have an index on goods, min and max values, so this sql for (known goods and its value): ``` SELECT percent_premium FROM ratings WHERE goods='PRECIOUST' and :PREC_VALUE BETWEEN suminsured_min AND suminsured_max ``` will use your index efficently. The data type you are lookin...
502,794
<p>The problem I'm trying to solve is that I have a table like this:</p> <p>a and b refer to point on a different table. distance is the distance between the points.</p> <pre><code>| id | a_id | b_id | distance | delete | | 1 | 1 | 1 | 1 | 0 | | 2 | 1 | 2 | 0.2345 | 0 | | 3 | 1 | ...
[ { "answer_id": 502809, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 0, "selected": false, "text": "<p>Does PostgreSQL have the analytic function rank()? If so try:</p>\n\n<pre><code>select a_id, b_id, distance\nfrom...
2009/02/02
[ "https://Stackoverflow.com/questions/502794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161922/" ]
The problem I'm trying to solve is that I have a table like this: a and b refer to point on a different table. distance is the distance between the points. ``` | id | a_id | b_id | distance | delete | | 1 | 1 | 1 | 1 | 0 | | 2 | 1 | 2 | 0.2345 | 0 | | 3 | 1 | 3 | 100 | 0...
Try this: ``` SELECT * FROM ( SELECT a_id, ( SELECT b_id FROM mytable mib WHERE mib.a_id = ma.a_id ORDER BY dist DESC LIMIT 1 OFFSET s ) AS b_id FROM ( SELECT DISTINCT a_id FROM mytable mia ) ma, generate_series (1, 10)...
502,795
<p>I am quite sure I've seen the answer to this question somewhere, but as I couldn't find it with a couple of searches on SO or google, I ask it again anyway...</p> <p>In Entity Framework, the only way to delete a data object seems to be </p> <pre><code>MyEntityModel ent = new MyEntityModel(); ent.DeleteObject(theOb...
[ { "answer_id": 502907, "author": "Tomas Aschan", "author_id": 38055, "author_profile": "https://Stackoverflow.com/users/38055", "pm_score": 3, "selected": false, "text": "<p>I found <a href=\"http://www.thejoyofcode.com/Working_with_Ids_in_the_Entity_Framework.aspx\" rel=\"noreferrer\">t...
2009/02/02
[ "https://Stackoverflow.com/questions/502795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38055/" ]
I am quite sure I've seen the answer to this question somewhere, but as I couldn't find it with a couple of searches on SO or google, I ask it again anyway... In Entity Framework, the only way to delete a data object seems to be ``` MyEntityModel ent = new MyEntityModel(); ent.DeleteObject(theObjectToDelete); ent.Sa...
It is worth knowing that the Entity Framework supports both to Linq to Entities and Entity SQL. If you find yourself wanting to do deletes or updates that could potentially affect many records you can use the equivalent of `ExecuteNonQuery`. In Entity SQL this might look like ``` Using db As New HelloEfEntities ...
502,818
<p>I have a table which contains data recorded every minute, so I have a row for each minute. When returning the data for processing, this accuracy is required for the last 6 hours but after that, a lower level of accuracy is sufficient, e.g. every 5 minutes.</p> <p>I can return all the data into an array and then rem...
[ { "answer_id": 502841, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 0, "selected": false, "text": "<p>completely untested but this might work</p>\n\n<pre><code>SELECT Row, col_a \nFROM (SELECT @row := @row + 1 AS Row, co...
2009/02/02
[ "https://Stackoverflow.com/questions/502818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2183/" ]
I have a table which contains data recorded every minute, so I have a row for each minute. When returning the data for processing, this accuracy is required for the last 6 hours but after that, a lower level of accuracy is sufficient, e.g. every 5 minutes. I can return all the data into an array and then remove all bu...
The list of timestamps every 5 minutes: ``` SELECT MIN(logtimestamp) AS first_of_five_minutes FROM tLog GROUP BY DATE(logtimestamp), HOUR(logtimestamp), MINUTE(logtimestamp) - (MINUTE(logtimestamp) % 5) ``` Now, you can use this as a sub-select to get the requested log entries by joining `logtimestamps` to `...
502,835
<p>Over the time i developed my own framework and it's working great - it's light, it's fast and is proven that can handle decent load.</p> <p>Now I'm working on project that can be described as a online shop where every user will have his sub domain where his items will be available for sale.</p> <p>My framework wo...
[ { "answer_id": 502868, "author": "Giraffe", "author_id": 50136, "author_profile": "https://Stackoverflow.com/users/50136", "pm_score": 0, "selected": false, "text": "<p>What you're talking about sounds like multi-tenancy. Mike Hadlow does a good write-up of his approach to the issue in ...
2009/02/02
[ "https://Stackoverflow.com/questions/502835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13549/" ]
Over the time i developed my own framework and it's working great - it's light, it's fast and is proven that can handle decent load. Now I'm working on project that can be described as a online shop where every user will have his sub domain where his items will be available for sale. My framework works by splitting r...
It sounds like, to me, the approach you are describing is the logical next step to implement the features you are adding. The new features will bring some added complexity but your Request object/Router should do a good job of encapsulating the logic of "What controller do I invoke when a segment is provided? When a se...
502,877
<p>long time ago I wrote webservice that is still in use. Now I plan to refactor it. The webservice is full of most likely unused functions and I have no idea how it is used by the clients. In order to strip away the unused functions I need to analyze the function calls and data of currently installed webservice.</p> <...
[ { "answer_id": 502889, "author": "Anton Gogolev", "author_id": 60188, "author_profile": "https://Stackoverflow.com/users/60188", "pm_score": 0, "selected": false, "text": "<p>You can potentially write your own IHttpHandler that would log all the information and then delegate the call to ...
2009/02/02
[ "https://Stackoverflow.com/questions/502877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25782/" ]
long time ago I wrote webservice that is still in use. Now I plan to refactor it. The webservice is full of most likely unused functions and I have no idea how it is used by the clients. In order to strip away the unused functions I need to analyze the function calls and data of currently installed webservice. Is ther...
As Kobi wrote, you can find the required information in the IIS log files (i.e. in c:\WINDOWS\system32\LogFiles\W3SVC1). If you want to log the usage into a database, you could write a simple HttpModule, which checks every request, and logs it into the DB if it is a call to your web service. E.g. here's the relevant ...
502,898
<p>I have two tables related together using one-to-many relation : employee -> department : and relation through department_id in the employee table.</p> <p>I use hibernate : and my hibernate mapping files are:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hib...
[ { "answer_id": 502930, "author": "andcoz", "author_id": 45318, "author_profile": "https://Stackoverflow.com/users/45318", "pm_score": 3, "selected": false, "text": "<p>You could map the relation as \"lazy\" and write two queries to get your datas:</p>\n\n<ul>\n<li><p>The usual simple que...
2009/02/02
[ "https://Stackoverflow.com/questions/502898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have two tables related together using one-to-many relation : employee -> department : and relation through department\_id in the employee table. I use hibernate : and my hibernate mapping files are: ``` <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3...
You could map the relation as "lazy" and write two queries to get your datas: * The usual simple query to get your data ("lazy"). E.g. "select e from Employee e where ..." * The same query using "fetch join" to force Hibernate to fetch "childs". E.g. "select e from Employee left join fetch e.department where ..." LLP...
502,905
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/29482/cast-int-to-enum-in-c-sharp">Cast int to enum in C#</a> </p> </blockquote> <p>If I have the following code:</p> <pre><code>enum foo : int { option1 = 1, option2, ... } private foo convertInt...
[ { "answer_id": 502910, "author": "Cameron MacFarland", "author_id": 3820, "author_profile": "https://Stackoverflow.com/users/3820", "pm_score": 4, "selected": false, "text": "<p>I'm pretty sure you can do explicit casting here.</p>\n\n<pre><code>foo f = (foo)value;\n</code></pre>\n\n<p>S...
2009/02/02
[ "https://Stackoverflow.com/questions/502905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
> > **Possible Duplicate:** > > [Cast int to enum in C#](https://stackoverflow.com/questions/29482/cast-int-to-enum-in-c-sharp) > > > If I have the following code: ``` enum foo : int { option1 = 1, option2, ... } private foo convertIntToFoo(int value) { // Convert int to respective Foo value ...
It's fine just to cast your int to Foo: ``` int i = 1; Foo f = (Foo)i; ``` If you try to cast a value that's not defined it will still work. The only harm that may come from this is in how you use the value later on. If you really want to make sure your value is defined in the enum, you can use Enum.IsDefined: ```...
502,913
<p>I have a xml file like this </p> <pre><code>&lt;Root&gt; ... &lt;x&gt;&lt;/x&gt; &lt;node&gt; ... &lt;x&gt;&lt;/x&gt; &lt;y&gt;&lt;/y&gt; &lt;/node&gt; &lt;/Root&gt; </code></pre> <p>My xslt is</p> <pre><code>&lt;xsl:template match="/"&gt; &lt;!-- proceed the treatment of the statement before x--&gt; ...
[ { "answer_id": 503092, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>To divo,</p>\n\n<p>match=\"x\" template deals with the child elements of \"x\". Sorry for making you misunderstand, i just ...
2009/02/02
[ "https://Stackoverflow.com/questions/502913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a xml file like this ``` <Root> ... <x></x> <node> ... <x></x> <y></y> </node> </Root> ``` My xslt is ``` <xsl:template match="/"> <!-- proceed the treatment of the statement before x--> <tr> <xsl:apply-templates match="Root/x"/> </tr> <tr> <xsl:apply-templates match="Root"/> </tr> </xsl:...
It looks like you are processing stuff in your "/" template, then processing it all again in the "Root" template, since the "/" template explicitly applies the Root template as well. Try deleting the definition of the "/" template and just doing all the work in the template for "Root"
502,916
<p>I have a Django app that requires a <code>settings</code> attribute in the form of:</p> <pre><code>RELATED_MODELS = ('appname1.modelname1.attribute1', 'appname1.modelname2.attribute2', 'appname2.modelname3.attribute3', ...) </code></pre> <p>Then hooks their post_save signal to ...
[ { "answer_id": 503435, "author": "Carl Meyer", "author_id": 3207, "author_profile": "https://Stackoverflow.com/users/3207", "pm_score": 7, "selected": true, "text": "<p>You can put your tests in a <code>tests/</code> subdirectory of the app (rather than a <code>tests.py</code> file), and...
2009/02/02
[ "https://Stackoverflow.com/questions/502916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42188/" ]
I have a Django app that requires a `settings` attribute in the form of: ``` RELATED_MODELS = ('appname1.modelname1.attribute1', 'appname1.modelname2.attribute2', 'appname2.modelname3.attribute3', ...) ``` Then hooks their post\_save signal to update some other fixed model depend...
You can put your tests in a `tests/` subdirectory of the app (rather than a `tests.py` file), and include a `tests/models.py` with the test-only models. Then provide a test-running script ([example](https://github.com/carljm/django-model-utils/blob/master/runtests.py)) that includes your `tests/` "app" in `INSTALLED_A...
502,949
<p>I'm using MS SQL 2005 and when I create a function I need to put the schema name to call it:</p> <pre><code>select dbo.MyFunc </code></pre> <p>All my tables are also in "dbo" schema and I don't need the schema name to reference it, so I'd like to know if I'm missing some configuration that could do the same to fun...
[ { "answer_id": 502981, "author": "Lieven Keersmaekers", "author_id": 52598, "author_profile": "https://Stackoverflow.com/users/52598", "pm_score": 5, "selected": true, "text": "<p>Short answer, no it isn't.</p>\n\n<p>You should consider to prefix <strong>all</strong> your database object...
2009/02/02
[ "https://Stackoverflow.com/questions/502949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2089/" ]
I'm using MS SQL 2005 and when I create a function I need to put the schema name to call it: ``` select dbo.MyFunc ``` All my tables are also in "dbo" schema and I don't need the schema name to reference it, so I'd like to know if I'm missing some configuration that could do the same to functions.
Short answer, no it isn't. You should consider to prefix **all** your database objects with the schema owner to avoid having sql server to "look it up". It makes your statements more readable and gives a slight increase in performance (although you'd probably won't notice it). Regards, Lieven
502,958
<p>I have HTML output similar to this:</p> <pre><code>&lt;select&gt; &lt;option value="1"&gt;Item1 &lt;/option&gt; &lt;/select&gt; </code></pre> <p><strong>How do I use JavaScript to get the value "Item1 " (with the space) rather than "Item1"?</strong></p> <p>In Internet Explorer all the properties I've tried, e.g. ...
[ { "answer_id": 502980, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 3, "selected": true, "text": "<p>Sorry, IE's parser indeed throws away trailing spaces in &lt;option>. Curiously, if you assign a string with trailing sp...
2009/02/02
[ "https://Stackoverflow.com/questions/502958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12124/" ]
I have HTML output similar to this: ``` <select> <option value="1">Item1 </option> </select> ``` **How do I use JavaScript to get the value "Item1 " (with the space) rather than "Item1"?** In Internet Explorer all the properties I've tried, e.g. *text*, *innerHTML*, *data*, *nodeValue* return "Item1" instead of "It...
Sorry, IE's parser indeed throws away trailing spaces in <option>. Curiously, if you assign a string with trailing spaces to innerHTML IE manages to remember one of them. Probably best not relied on. Normally if you want visible trailing spaces (in any browser) you have to use a non-breaking-space character (eg. &#160...
502,968
<p>I am following <em>Structure and Interpretation of Computer Programs</em> and while attempting to solve Ex 1.3 I arrived at the following code as my first attempt:</p> <pre><code>(define (sumsq a b c)( (define highest (if (&gt; (if (&gt; a b) a b) (if (&gt; a c) a c)) (if (&gt; a b) a b) (if (&gt; a c) a c))) (defi...
[ { "answer_id": 502983, "author": "Baishampayan Ghose", "author_id": 8024, "author_profile": "https://Stackoverflow.com/users/8024", "pm_score": 2, "selected": false, "text": "<p>One of the ideas of Scheme is <code>bottom-up programming</code> where you create a function for each and ever...
2009/02/02
[ "https://Stackoverflow.com/questions/502968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25453/" ]
I am following *Structure and Interpretation of Computer Programs* and while attempting to solve Ex 1.3 I arrived at the following code as my first attempt: ``` (define (sumsq a b c)( (define highest (if (> (if (> a b) a b) (if (> a c) a c)) (if (> a b) a b) (if (> a c) a c))) (define second_h (if (> (if (> a b) b a) ...
What you wrote (minus one extra paren) is: ``` (define (sumsq a b c) (define highest (if (> (if (> a b) a b) (if (> a c) a c)) (if (> a b) a b) (if (> a c) a c))) (define second_h (if (> (if (> a b) b a) (if (> a c) c a)) (if (> a b) b a) (if (> a c) c a))) (...
502,994
<p>I'm trying to use Spring IoC with an interface like this:</p> <pre><code>public interface ISimpleService&lt;T&gt; { void someOp(T t); T otherOp(); } </code></pre> <p>Can Spring provide IoC based on the generic type argument T? I mean, something like this:</p> <pre><code>public class SpringIocTest { @A...
[ { "answer_id": 503011, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 6, "selected": true, "text": "<p>I do not believe this is possible due to erasure. We generally switched to strongly typed sub-interfaces when going ...
2009/02/02
[ "https://Stackoverflow.com/questions/502994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22992/" ]
I'm trying to use Spring IoC with an interface like this: ``` public interface ISimpleService<T> { void someOp(T t); T otherOp(); } ``` Can Spring provide IoC based on the generic type argument T? I mean, something like this: ``` public class SpringIocTest { @Autowired ISimpleService<Long> longSvc; ...
I do not believe this is possible due to erasure. We generally switched to strongly typed sub-interfaces when going for full-autowiring: ``` public interface LongService extends ISimpleService<Long> {} public interface StringService extends ISimpleService<String> {} ``` Upon doing this switch we found we actually li...
503,003
<p>I'm gettting the following exception when performing an insert to an Oracle Databse using JDBC.</p> <pre><code>java.sql.SQLRecoverableException: Io exception: Unexpected packet </code></pre> <p>What could cause this and how can I recover from it?</p> <p>The application I'm writing performs an aweful lot of update...
[ { "answer_id": 503022, "author": "Bombe", "author_id": 43582, "author_profile": "https://Stackoverflow.com/users/43582", "pm_score": 4, "selected": true, "text": "<p>Are you per any chance using multiple threads and forgot synchronization?</p>\n" }, { "answer_id": 503069, "au...
2009/02/02
[ "https://Stackoverflow.com/questions/503003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
I'm gettting the following exception when performing an insert to an Oracle Databse using JDBC. ``` java.sql.SQLRecoverableException: Io exception: Unexpected packet ``` What could cause this and how can I recover from it? The application I'm writing performs an aweful lot of updates the the databse in rapid succes...
Are you per any chance using multiple threads and forgot synchronization?
503,052
<p>So I have ~12600 subnets:</p> <p>eg. 123.123.208.0/20</p> <p>and an IP.</p> <p>I can use a SQLite Database or an array or whatever </p> <p>There was a similar question asked about a month ago, however I am not looking for checking one IP against one subnet but a bunch of subnets (obviously the most efficient way...
[ { "answer_id": 503073, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 2, "selected": false, "text": "<p>Convert the lower ip and the upper ip in the range to integers and store the range in the db then make sure both c...
2009/02/02
[ "https://Stackoverflow.com/questions/503052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
So I have ~12600 subnets: eg. 123.123.208.0/20 and an IP. I can use a SQLite Database or an array or whatever There was a similar question asked about a month ago, however I am not looking for checking one IP against one subnet but a bunch of subnets (obviously the most efficient way, hopefully not O(total subnets...
The best approach is IMO making use of bitwise operators. For example, `123.123.48.0/22` represents `(123<<24)+(123<<16)+(48<<8)+0` (=2071670784; this might be a negative number) as a 32 bit numeric IP address, and `-1<<(32-22)` = -1024 as a mask. With this, and likewise, your test IP address converted to a number, you...
503,054
<p>I need to create a stored procedure which pulls data from multiple tables that are not linked what do i do .Basically i got a few tables that are not linked and all i need to do is pull all the data from all those tables.</p> <p>PLEASE HELP MY LIFE DEPENDS ON THIS </p>
[ { "answer_id": 503059, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 2, "selected": false, "text": "<p>Just do several selects?</p>\n\n<pre><code>select * from MyTable1;\nselect * from MyTable2;\nselect * from MyTab...
2009/02/02
[ "https://Stackoverflow.com/questions/503054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to create a stored procedure which pulls data from multiple tables that are not linked what do i do .Basically i got a few tables that are not linked and all i need to do is pull all the data from all those tables. PLEASE HELP MY LIFE DEPENDS ON THIS
Just do several selects? ``` select * from MyTable1; select * from MyTable2; select * from MyTable3; ``` You can then access each of those tables from your calling code. I'd include an example on how to do that, but you don't include any details about what language you are calling from.. details I would have include...
503,057
<p>I am running tomcat 6.0.18 as a windows service. In the service applet the jvm is configured default, i.e. it is using jvm.dll of the JRE.</p> <p>I am trying to monitor this application with JConsole but cannot connect to it locally. I added the parameter -Dcom.sun.management.jmxremote (which works when starting to...
[ { "answer_id": 503845, "author": "Ron", "author_id": 61572, "author_profile": "https://Stackoverflow.com/users/61572", "pm_score": 2, "selected": false, "text": "<p>Here's the prescribed way for changing jvmoptions &amp; interacting with the service:</p>\n\n<p><a href=\"http://tomcat.apa...
2009/02/02
[ "https://Stackoverflow.com/questions/503057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26496/" ]
I am running tomcat 6.0.18 as a windows service. In the service applet the jvm is configured default, i.e. it is using jvm.dll of the JRE. I am trying to monitor this application with JConsole but cannot connect to it locally. I added the parameter -Dcom.sun.management.jmxremote (which works when starting tomcat with ...
There's a nice GUI to edit the options, no need to muck around in the registry. Open up the C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\tomcat6.exe (or just double-click on the monitor icon in the task bar). Go to the Java pane, add the following to the list of arguments, and restart Tomcat. ``` -Dcom...
503,065
<p>I have an application that runs on a terminal. </p> <p>The terminal is registered on a database table.</p> <p>During all session that application is running on a terminal, I need to ensure that the line of the table corresponding to the terminal is locked and nobody can update that.</p> <p>What is the best way to...
[ { "answer_id": 503090, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 0, "selected": false, "text": "<p>Databases do not work for this kind of locking. You can lock items, but its only for the duration of the operation (...
2009/02/02
[ "https://Stackoverflow.com/questions/503065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58251/" ]
I have an application that runs on a terminal. The terminal is registered on a database table. During all session that application is running on a terminal, I need to ensure that the line of the table corresponding to the terminal is locked and nobody can update that. What is the best way to do this? I use C#.NET ...
In general, I try to work with short-lived locks where I can do an entire unit of work in a single (serializable) transaction; this avoids the need for an additional locking mechanism, as the db locks will do everything needed. When working with long-lived locks: It is a bad idea to use rdbms-locks for that purpose - ...
503,066
<p>I'm attempting to send HTML formatted emails using C# 3 via <code>Outlook.MailItem</code></p> <pre><code>Outlook.MailItem objMail = (Outlook.MailItem)olkApp.CreateItem(Outlook.OlItemType.olMailItem); objMail.To = to; objMail.Subject = subject; objMail.HTMLBody = htmlBody; </code></pre> <p>The email is generated ex...
[ { "answer_id": 503154, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 1, "selected": false, "text": "<p>Since you are using .net > 2.0, you may want to look into the System.Net.Mail namespace for the creation of mail mes...
2009/02/02
[ "https://Stackoverflow.com/questions/503066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11635/" ]
I'm attempting to send HTML formatted emails using C# 3 via `Outlook.MailItem` ``` Outlook.MailItem objMail = (Outlook.MailItem)olkApp.CreateItem(Outlook.OlItemType.olMailItem); objMail.To = to; objMail.Subject = subject; objMail.HTMLBody = htmlBody; ``` The email is generated externally by saving from an RTF contro...
DOH!, actually *sending* the email in Outlook 2007 forces the images to become embedded. The Sent Item size of 8K is a lot smaller than the draft size of 60K (RTF) I was seeing vs the draft size of 1K (HTML that hadn't been converted to RTF and back again). So it was Doing What I Mean all the time. Grr. I'll leave t...
503,068
<p>I was using the following script to delete the browsing history in IE 7.0</p> <pre><code>RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 </code></pre> <p>But now I need a script to clear browsing history in IE 6.0</p> <p>I get an error that "missing entry ClearMyTracksByProcess" I have passed different parame...
[ { "answer_id": 503087, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>Since <code>INETCPL.CPL version 7.0</code> that ships with Internet Explorer 7 does have an entry-point named <code>ClearMyT...
2009/02/02
[ "https://Stackoverflow.com/questions/503068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46795/" ]
I was using the following script to delete the browsing history in IE 7.0 ``` RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 ``` But now I need a script to clear browsing history in IE 6.0 I get an error that "missing entry ClearMyTracksByProcess" I have passed different parameters like 2 ,5 etc and wasn't suc...
``` // test.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "test.h" #include <shlguid.h> // Needed for CLSID_CUrlHistory #include <urlhist.h> // Needed for IUrlHistoryStg2 and IID_IUrlHistoryStg2 #ifdef _DEBUG #define new DEBUG_NEW #endif // The one and only application ob...
503,077
<p>I am having trouble with modifying a php application to have pagination. My error seems to be with my logic, and I am not clear exactly what I am doing incorrectly. I have had before, but am not currently getting errors that mysql_num_rows() not valid result resource and that invalid arguments were supplied to fore...
[ { "answer_id": 503152, "author": "Karsten", "author_id": 28144, "author_profile": "https://Stackoverflow.com/users/28144", "pm_score": 0, "selected": false, "text": "<p>This is wrong:</p>\n\n<pre><code>if($cmd==\"GetRecordSet\")\necho \"test in loop\\n\"; {\n</code></pre>\n\n<p>It should...
2009/02/02
[ "https://Stackoverflow.com/questions/503077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am having trouble with modifying a php application to have pagination. My error seems to be with my logic, and I am not clear exactly what I am doing incorrectly. I have had before, but am not currently getting errors that mysql\_num\_rows() not valid result resource and that invalid arguments were supplied to forea...
The problem (or at least one of them) is in the code that reads: ``` $rows = getRowsByProductSearch($query, $table, $max); $numRows = mysql_num_rows($rows); ``` The $numRows variable is not a MySQL resultset, it is just a normal array returned by getRowsByProductSearch. Change the code to read: ``` $rows = getRow...
503,079
<p>I've got a little class hierarchy where each class corresponds to a certain TComponent descendent (say base class TDefaultFrobber with descendents TActionFrobber and TMenuItemFrobber, corresponding to TComponent, TCustomAction and TMenuItem, respectively). Now I want a factory (?) function something like this:</p> ...
[ { "answer_id": 503146, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 2, "selected": false, "text": "<p>If you create a class with a virtual constructor and create a class type for that class. You can create a lookupli...
2009/02/02
[ "https://Stackoverflow.com/questions/503079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1431618/" ]
I've got a little class hierarchy where each class corresponds to a certain TComponent descendent (say base class TDefaultFrobber with descendents TActionFrobber and TMenuItemFrobber, corresponding to TComponent, TCustomAction and TMenuItem, respectively). Now I want a factory (?) function something like this: ``` fun...
2 suggestions: Make class pair array of classes, then you can get the Index and use the pair of the class constructor, ``` var ArrayItem: array[0..1] of TComponentClass = (TActionFrobber, TMenuItemFrobber); ArrayOwner: array[0..1] of TComponentClass = (TCustomAction, TMenuItem); function CreateFrobber(AComponent:...
503,084
<p>I want to render a partial depending on a selection in selection box. This looks trivial but I can't find an example.</p> <p>All help is greatly appreciated.</p> <p>Regards </p>
[ { "answer_id": 503328, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 1, "selected": false, "text": "<p>I'd start with something like this:</p>\n\n<pre><code>app/views/_layout_selector.html.erb:\n&lt;form action=\"&lt;...
2009/02/02
[ "https://Stackoverflow.com/questions/503084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52086/" ]
I want to render a partial depending on a selection in selection box. This looks trivial but I can't find an example. All help is greatly appreciated. Regards
If you're simply trying to render a partial on the page that the form submits to, ``` <%= render :partial => params[:your_selectbox_value_matching_the_partial_you_want] %> ``` So if you had a select box like ``` <select name='the_partial'> <input value="partial1">Some Partial</input> <input value="partial2"...
503,093
<p>How can I redirect the user from one page to another using jQuery or pure JavaScript?</p>
[ { "answer_id": 503178, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 8, "selected": false, "text": "<p>It would help if you were a little more descriptive in what you are trying to do. If you are trying to generate pag...
2009/02/02
[ "https://Stackoverflow.com/questions/503093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
How can I redirect the user from one page to another using jQuery or pure JavaScript?
One does not simply redirect using jQuery ----------------------------------------- jQuery is not necessary, and [**`window.location.replace(...)`**](https://developer.mozilla.org/en-US/docs/Web/API/Location/replace) will best simulate an HTTP redirect. `window.location.replace(...)` is better than using `window.loc...
503,101
<p>First question...</p> <p>I'm having trouble getting ANY of the Drop down menu/Input Select's to appear with size 18 font in Safari. </p> <p>Works fine in FF.</p> <p>Code:</p> <pre><code>&lt;form class="form"&gt; &lt;select name="make"&gt; &lt;option value="0"&gt; All&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; ...
[ { "answer_id": 503111, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>The <code>select</code> technically isn't an <code>input</code> tag. Try assigning a class to your select and set t...
2009/02/02
[ "https://Stackoverflow.com/questions/503101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
First question... I'm having trouble getting ANY of the Drop down menu/Input Select's to appear with size 18 font in Safari. Works fine in FF. Code: ``` <form class="form"> <select name="make"> <option value="0"> All</option> </select> </form> ``` Css: ``` .form input{ font-size:18px; margin-bottom:0px; } ``` ...
To style a select in Safari you first have to turn off the os styling: ``` select { -webkit-appearance: none; } ```
503,118
<p>I'm a ASP.NET and ABAP developer. For years, I used RFC's to communicate with ASP.NET using SAP .NET Connector.</p> <p>During the integrated tests, sometimes we need to debug a RFC that has been called from ASP.ENT, just because the bug we are facing does not happens at SE37.</p> <p>So, everytime I needed to debug...
[ { "answer_id": 504101, "author": "Thorsten", "author_id": 25320, "author_profile": "https://Stackoverflow.com/users/25320", "pm_score": 0, "selected": false, "text": "<p>Tricky .. can you elaborate what you mean by \"the bug does not happen at se37\"?</p>\n\n<p>Does that mean that you ca...
2009/02/02
[ "https://Stackoverflow.com/questions/503118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61468/" ]
I'm a ASP.NET and ABAP developer. For years, I used RFC's to communicate with ASP.NET using SAP .NET Connector. During the integrated tests, sometimes we need to debug a RFC that has been called from ASP.ENT, just because the bug we are facing does not happens at SE37. So, everytime I needed to debug the RFC, I just ...
I assume you are using a fairly recent version of sap (4.7+) Do the following: * Get the username that makes the RFC call into SAP in ASP * Fire up SE37, go to the code section of your RFC * Look at the menu on top, click on 'Utilities' * Click on Settings * Go for the Debugging tab * Fill in the username that will m...
503,120
<p>I'm working on an asp.net-mvc application. The linq data context is being passed into my service objects by structure map. I've got is set to have a scope of hybrid. This all works just fine.</p> <pre><code>protected override void configure() { ForRequestedType&lt;AetherDataContext&gt;() .TheDefaultIs((...
[ { "answer_id": 503450, "author": "Chris Marisic", "author_id": 37055, "author_profile": "https://Stackoverflow.com/users/37055", "pm_score": 2, "selected": true, "text": "<p>This is almost an exact copy of the question I asked 2 days ago: <a href=\"https://stackoverflow.com/questions/498...
2009/02/02
[ "https://Stackoverflow.com/questions/503120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35047/" ]
I'm working on an asp.net-mvc application. The linq data context is being passed into my service objects by structure map. I've got is set to have a scope of hybrid. This all works just fine. ``` protected override void configure() { ForRequestedType<AetherDataContext>() .TheDefaultIs(() => new AetherDataC...
This is almost an exact copy of the question I asked 2 days ago: [Session containing items implementing IDisposable](https://stackoverflow.com/questions/498095/session-containing-items-implementing-idisposable) InstanceScope.Hybrid just stores the object inside HttpContext.Current.Items if it exists or ThreadLocal sto...
503,125
<p>I want to integrate yahoo search api in my web application in asp.net with C#. I don't know how to call yahoo api.</p>
[ { "answer_id": 503457, "author": "Martin Brown", "author_id": 20553, "author_profile": "https://Stackoverflow.com/users/20553", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if it still works, but I wrote a C# &amp; VB.Net wrapper for this some years ago. Yahoo even included...
2009/02/02
[ "https://Stackoverflow.com/questions/503125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to integrate yahoo search api in my web application in asp.net with C#. I don't know how to call yahoo api.
``` string AppId = "foo"; string Query = "stackoverflow"; int NumResults = 10; WebClient webClient = new WebClient(); string request = string.Format( "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid={0}&query={1}&results={2}" , AppId , Query , NumResults); byte[] response = ...
503,139
<p>I have some logic, which defines and uses some user-defined types, like these:</p> <pre><code>class Word { System.Drawing.Font font; //a System type string text; } class Canvass { System.Drawing.Graphics graphics; //another, related System type ... and other data members ... //a method whose implementati...
[ { "answer_id": 503155, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": true, "text": "<p>First, I wonder if the entire scenario isn't a little artificial; are you really going to <strong>need</strong> thi...
2009/02/02
[ "https://Stackoverflow.com/questions/503139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49942/" ]
I have some logic, which defines and uses some user-defined types, like these: ``` class Word { System.Drawing.Font font; //a System type string text; } class Canvass { System.Drawing.Graphics graphics; //another, related System type ... and other data members ... //a method whose implementation combines th...
First, I wonder if the entire scenario isn't a little artificial; are you really going to **need** this level of abstraction? Perhaps subscribe to [YAGNI](http://en.wikipedia.org/wiki/You_Ain't_Gonna_Need_It)? Why does your `MyGraphics` only work with a `MyFont`? Can it work with an `IFont`? That would be a better use...
503,148
<p>I'd like to parse status.dat file for nagios3 and output as xml with a python script. The xml part is the easy one but how do I go about parsing the file? Use multi line regex? It's possible the file will be large as many hosts and services are monitored, will loading the whole file in memory be wise?<br> I only ne...
[ { "answer_id": 503532, "author": "devio", "author_id": 21336, "author_profile": "https://Stackoverflow.com/users/21336", "pm_score": 2, "selected": false, "text": "<p>Don't know nagios and its config file, but the structure seems pretty simple:</p>\n\n<pre><code># comment\nidentifier {\n...
2009/02/02
[ "https://Stackoverflow.com/questions/503148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9789/" ]
I'd like to parse status.dat file for nagios3 and output as xml with a python script. The xml part is the easy one but how do I go about parsing the file? Use multi line regex? It's possible the file will be large as many hosts and services are monitored, will loading the whole file in memory be wise? I only need t...
Nagiosity does exactly what you want: <http://code.google.com/p/nagiosity/>
503,171
<p>Is there a command line based way to send pings to each computer in a subnet? Like</p> <pre><code>for(int i = 1; i &lt; 254; i++) ping(192.168.1.i); </code></pre> <p>to enforce arp resolution?</p>
[ { "answer_id": 503185, "author": "Ryan McGeary", "author_id": 8985, "author_profile": "https://Stackoverflow.com/users/8985", "pm_score": 6, "selected": false, "text": "<p><strong>Broadcast ping:</strong></p>\n\n<pre><code>$ ping 192.168.1.255\nPING 192.168.1.255 (192.168.1.255): 56 data...
2009/02/02
[ "https://Stackoverflow.com/questions/503171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44107/" ]
Is there a command line based way to send pings to each computer in a subnet? Like ``` for(int i = 1; i < 254; i++) ping(192.168.1.i); ``` to enforce arp resolution?
I would suggest the use of **fping** with the mask option, since you are not restricting yourself in ping. ``` fping -g 192.168.1.0/24 ``` The response will be easy to parse in a script: ``` 192.168.1.1 is alive 192.168.1.2 is alive 192.168.1.3 is alive 192.168.1.5 is alive ... 192.168.1.4 is unreachable 192.168.1....
503,190
<p>I have the following code, for which I get the error:</p> <p><strong>Warning</strong>: mysqli_stmt::bind_result() [mysqli-stmt.bind-result]: Number of bind variables doesn't match number of fields in prepared statement in file.</p> <p>If this is only a warning, shouldn't the code still work? I want to do a select ...
[ { "answer_id": 503508, "author": "draegtun", "author_id": 12195, "author_profile": "https://Stackoverflow.com/users/12195", "pm_score": 4, "selected": false, "text": "<blockquote>\n <p>\"is there any point to use exceptions in Perl?\"</p>\n</blockquote>\n\n<p>Yes, I highly recommend rea...
2009/02/02
[ "https://Stackoverflow.com/questions/503190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I have the following code, for which I get the error: **Warning**: mysqli\_stmt::bind\_result() [mysqli-stmt.bind-result]: Number of bind variables doesn't match number of fields in prepared statement in file. If this is only a warning, shouldn't the code still work? I want to do a select \* and display all the data ...
I should note that the article you referenced is old, and that you should now use [Exception::Class](http://metacpan.org/pod/Exception::Class) instead of Error.pm, which is quirky and tends to break (it's what I call "black magick"). I should note that I am now the Error.pm maintainer, but I no longer recommend it or m...
503,199
<p>I run a couple of game tunnelling servers and would like to have a page where the client can run a ping on all the servers and find out which is the most responsive. As far as I can see there seems to be no proper way to do this in JavaScript, but I was thinking, does anybody know of a way to do this in flash or som...
[ { "answer_id": 503221, "author": "Yuval Adam", "author_id": 24545, "author_profile": "https://Stackoverflow.com/users/24545", "pm_score": 2, "selected": false, "text": "<p>If you are talking about running something client side, I am not sure this is possible due to security reasons.</p>\...
2009/02/02
[ "https://Stackoverflow.com/questions/503199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11421/" ]
I run a couple of game tunnelling servers and would like to have a page where the client can run a ping on all the servers and find out which is the most responsive. As far as I can see there seems to be no proper way to do this in JavaScript, but I was thinking, does anybody know of a way to do this in flash or some o...
Most applet technology, including Javascript, enforces a same-origin policy. It may be possible to dynamically add DOM elements, such as images, and collect timing information using the onload event handler. Psuedo-code ``` for (server in servers) { var img = document.createElement('IMG'); server.startTime = get...
503,208
<p>In my code I'd like to make my repositories IQueryable. This way, the criteria for selection will be a linq expression tree.</p> <p>Now if I want to mock my repository in theorie this is very easy : just implement the interface of my repository (which is also a IQueryable object).</p> <p>My mock repository impleme...
[ { "answer_id": 503224, "author": "Michael Prewecki", "author_id": 4403, "author_profile": "https://Stackoverflow.com/users/4403", "pm_score": 0, "selected": false, "text": "<p>Can you use the extension method </p>\n\n<pre><code>.ToList&lt;&gt;\n</code></pre>\n" }, { "answer_id": ...
2009/02/02
[ "https://Stackoverflow.com/questions/503208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19803/" ]
In my code I'd like to make my repositories IQueryable. This way, the criteria for selection will be a linq expression tree. Now if I want to mock my repository in theorie this is very easy : just implement the interface of my repository (which is also a IQueryable object). My mock repository implementation would be ...
Use [AsQueryable](http://msdn.microsoft.com/en-us/library/bb353734.aspx) on your mocks. Now they're queryable and you can treat them like any other queryable.
503,233
<p>So I'm coming at WPF from a HTML perspective.</p> <p>I just want to put a <code>TextBox</code> on my Window like this:</p> <pre><code>&lt;Grid&gt; &lt;TextBox Name="theName" /&gt; &lt;/Grid&gt; </code></pre> <p>Turns out that the <code>TextBox</code> is then HUGE, covers the whole window. (!)</p> <p>Ok, that...
[ { "answer_id": 503275, "author": "Stefan", "author_id": 48003, "author_profile": "https://Stackoverflow.com/users/48003", "pm_score": 3, "selected": false, "text": "<p>Use a different container.\nThe Grid always streches its child controls to fill the grid cell.</p>\n\n<p>You could use e...
2009/02/02
[ "https://Stackoverflow.com/questions/503233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
So I'm coming at WPF from a HTML perspective. I just want to put a `TextBox` on my Window like this: ``` <Grid> <TextBox Name="theName" /> </Grid> ``` Turns out that the `TextBox` is then HUGE, covers the whole window. (!) Ok, that's not what I want, but I don't want to define the EXACT size either since I kno...
You can take Bryan's example even a bit further. By specifying a specific alignment that isn't stretch and further constrain the TextBox so that it won't expand beyond a certain size. eg: ``` <Grid x:Name="LayoutRoot"> <TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Text="TextBox" TextWrapping="Wra...
503,251
<p>I am pulling down a large XML file and I have no control over it's structure.</p> <p>I used a custom function to use the tag name to view the tree structure as a flex tree, but then it breaks. I am guessing it has something to do with my other function, one that calls attribute values from the selected node. </p>...
[ { "answer_id": 504358, "author": "James Hay", "author_id": 47339, "author_profile": "https://Stackoverflow.com/users/47339", "pm_score": 0, "selected": false, "text": "<p>Have you tried debugging this in flex builder or eclipse? </p>\n\n<p>The most likely candidate for your null referen...
2009/02/02
[ "https://Stackoverflow.com/questions/503251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60805/" ]
I am pulling down a large XML file and I have no control over it's structure. I used a custom function to use the tag name to view the tree structure as a flex tree, but then it breaks. I am guessing it has something to do with my other function, one that calls attribute values from the selected node. See code. ```...
OK. It sounds like your XML looks something like this: ``` <root> <test> <child>leaf 1</child> </test> <test2> <child2>leaf 2</child2> </test2> </root> ``` The significant part of this is that there is simple content within the child and child2 tags. Expanding the tree to show 'leaf 1' or 'leaf 2' ca...
503,263
<p>Assume the following type definitions:</p> <pre><code>public interface IFoo&lt;T&gt; : IBar&lt;T&gt; {} public class Foo&lt;T&gt; : IFoo&lt;T&gt; {} </code></pre> <p>How do I find out whether the type <code>Foo</code> implements the generic interface <code>IBar&lt;T&gt;</code> when only the mangled type is availab...
[ { "answer_id": 503273, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 2, "selected": false, "text": "<p>You have to check against a constructed type of the generic interface.</p>\n\n<p>You will have to do something like...
2009/02/02
[ "https://Stackoverflow.com/questions/503263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31770/" ]
Assume the following type definitions: ``` public interface IFoo<T> : IBar<T> {} public class Foo<T> : IFoo<T> {} ``` How do I find out whether the type `Foo` implements the generic interface `IBar<T>` when only the mangled type is available?
By using the answer from TcKs it can also be done with the following LINQ query: ``` bool isBar = foo.GetType().GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IBar<>)); ```
503,267
<p>I have a user control that has: a) a buttons panel at the top (it always has to be visible) b) a panel with controls that are dynamically added and re-sized at run-time. The controls can be many, so the panel has to be scrollable.</p> <p>This user control will be hosted in a form, with the following requirements: a...
[ { "answer_id": 503276, "author": "Michael Prewecki", "author_id": 4403, "author_profile": "https://Stackoverflow.com/users/4403", "pm_score": 0, "selected": false, "text": "<p>Without knowing the specifics of your problem I find multiple fill docked split containers with one fixed panel ...
2009/02/02
[ "https://Stackoverflow.com/questions/503267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61508/" ]
I have a user control that has: a) a buttons panel at the top (it always has to be visible) b) a panel with controls that are dynamically added and re-sized at run-time. The controls can be many, so the panel has to be scrollable. This user control will be hosted in a form, with the following requirements: a) The init...
I succeeded to meet the requirements. Here is my solution: The dynamic panel is anchored to the top and the bottom of the control. It does not AutoSize, it manually changes its MaximumSize and PreferredSize after change in the contents. The form hosts the form using: ``` cntrl.AutoSize = true; cntrl....
503,285
<p>OK, having tried my first TDD attempt, it's time to reflect a little and get some guidance, because it wasn't that successful for me. The solution was partly being made with an existing framework, perhaps making TDD less ideal. The part that seemed to give me the biggest problem, was the interaction between the view...
[ { "answer_id": 503276, "author": "Michael Prewecki", "author_id": 4403, "author_profile": "https://Stackoverflow.com/users/4403", "pm_score": 0, "selected": false, "text": "<p>Without knowing the specifics of your problem I find multiple fill docked split containers with one fixed panel ...
2009/02/02
[ "https://Stackoverflow.com/questions/503285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44726/" ]
OK, having tried my first TDD attempt, it's time to reflect a little and get some guidance, because it wasn't that successful for me. The solution was partly being made with an existing framework, perhaps making TDD less ideal. The part that seemed to give me the biggest problem, was the interaction between the view an...
I succeeded to meet the requirements. Here is my solution: The dynamic panel is anchored to the top and the bottom of the control. It does not AutoSize, it manually changes its MaximumSize and PreferredSize after change in the contents. The form hosts the form using: ``` cntrl.AutoSize = true; cntrl....
503,292
<p>I wonder if it is possible to restrain users to insert duplicate registration records. For example some team is registered from 5.1.2009 - 31.12.2009. Then someone registers the same team for 5.2.2009 - 31.12.2009. Usually the end_date is not an issue, but start_date should not be between existing records start and ...
[ { "answer_id": 503301, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 3, "selected": true, "text": "<p>I would check it in the code df the program, not the database.</p>\n" }, { "answer_id": 503307, "author": "n...
2009/02/02
[ "https://Stackoverflow.com/questions/503292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44715/" ]
I wonder if it is possible to restrain users to insert duplicate registration records. For example some team is registered from 5.1.2009 - 31.12.2009. Then someone registers the same team for 5.2.2009 - 31.12.2009. Usually the end\_date is not an issue, but start\_date should not be between existing records start and e...
I would check it in the code df the program, not the database.
503,298
<p>I'm trying to convert a byte array to a bitmap but it always shows me: </p> <blockquote> <p>System.ArgumentException: Parameter is not valid.</p> </blockquote> <p>My code is as follows:</p> <p>I'm passing the bytes through a webservice with:</p> <pre><code> string DecodedString = string.Empty; DecodedString =...
[ { "answer_id": 503331, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 2, "selected": false, "text": "<p>Try passing the string as a Base64:</p>\n\n<pre><code>string DecodedString = string.Empty;\nDecodedString = System.C...
2009/02/02
[ "https://Stackoverflow.com/questions/503298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to convert a byte array to a bitmap but it always shows me: > > System.ArgumentException: Parameter is not valid. > > > My code is as follows: I'm passing the bytes through a webservice with: ``` string DecodedString = string.Empty; DecodedString = System.Text.Encoding.GetEncoding(1251).GetString(...
Try passing the string as a Base64: ``` string DecodedString = string.Empty; DecodedString = System.Convert.ToBase64String(bytes) sResult = sResult + "<Photo>" +XmlConvert.EncodeName(DecodedString) + "</Photo>"; ``` ... ``` byte[] bytes = System.Convert.FromBase64String(xDocument.SelectSingleNode("Response/Images/P...
503,310
<p>Is it possible to map an enum as a string using Fluent Nhibernate?</p>
[ { "answer_id": 503327, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 6, "selected": true, "text": "<p>Yes, it does that by default if you just do:</p>\n\n<pre><code>Map(x =&gt; x.YourProperty);\n</code></pre>\n\n<p>Mak...
2009/02/02
[ "https://Stackoverflow.com/questions/503310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2849/" ]
Is it possible to map an enum as a string using Fluent Nhibernate?
Yes, it does that by default if you just do: ``` Map(x => x.YourProperty); ``` Make sure you're using the latest version off the trunk. --- As [Yavor Shahpasov](https://stackoverflow.com/users/463181/yavor-shahpasov) pointed out in the comments, in more recent versions you can accomplish the same with: ``` Map(x ...
503,312
<p>I have this code,</p> <pre><code>showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID); if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then showmessage('Removed') else showmessage('Failed'); </code></pre> <p>The message shows <code>C:\TEMP\0</code> and this directory does exist as the pro...
[ { "answer_id": 503338, "author": "zendar", "author_id": 25732, "author_profile": "https://Stackoverflow.com/users/25732", "pm_score": 2, "selected": false, "text": "<p>If I understood correctly, <code>openfiles[openfilelist.ItemIndex].ID</code> is a string that contains number?<br>\nIf s...
2009/02/02
[ "https://Stackoverflow.com/questions/503312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53915/" ]
I have this code, ``` showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID); if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then showmessage('Removed') else showmessage('Failed'); ``` The message shows `C:\TEMP\0` and this directory does exist as the program created it earlier and used file...
Make sure that neither your program nor any other program have the directory as their current working directory. When you recompile the program this may no longer be the case, so it may be a red herring that the hardcoded value works for you.
503,322
<p>When I use file_get_contents and pass it as a parameter to another function, without assigning it to a variable, does that memory get released before the script execution finishes?</p> <p>For Example:</p> <pre><code>preg_match($pattern, file_get_contents('http://domain.tld/path/to/file.ext'), $matches); </code></p...
[ { "answer_id": 503343, "author": "meouw", "author_id": 12161, "author_profile": "https://Stackoverflow.com/users/12161", "pm_score": 0, "selected": false, "text": "<p>In your example the memory will be released when <code>$matches</code> goes out of scope.<br>\nIf you weren't storing the...
2009/02/02
[ "https://Stackoverflow.com/questions/503322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
When I use file\_get\_contents and pass it as a parameter to another function, without assigning it to a variable, does that memory get released before the script execution finishes? For Example: ``` preg_match($pattern, file_get_contents('http://domain.tld/path/to/file.ext'), $matches); ``` Will the memory used by...
The temporary string created to hold the file contents will be destroyed. Without delving into the sources to confirm, here's a couple of ways you can test that a temporary value created as a function parameter gets destroyed: Method 1: a class which reports its destruction --------------------------------------------...
503,383
<p>Oh, 2 things: 1) It is a console application. 2 ) I know it is in danish, but it doesn't really matter, its just an example of asking for some input. The text and variables does not matter.</p> <p>Alright, consider this simple input: It could be any sort of input question really.</p> <pre><code>Console.WriteLine("...
[ { "answer_id": 503387, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.int16.tryparse.aspx\" rel=\"nofollow noreferrer\">Int16.T...
2009/02/02
[ "https://Stackoverflow.com/questions/503383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61521/" ]
Oh, 2 things: 1) It is a console application. 2 ) I know it is in danish, but it doesn't really matter, its just an example of asking for some input. The text and variables does not matter. Alright, consider this simple input: It could be any sort of input question really. ``` Console.WriteLine("Hvad er dit kundenumm...
Use [Int16.TryParse](http://msdn.microsoft.com/en-us/library/system.int16.tryparse.aspx) and the equivalents for other numeric types. All of these return a Boolean result to indicate success or failure for parsing, and take an `out` parameter which is set to the result of the parsing (or 0 in case of failure). In your ...
503,404
<p>Here I have the start of a news posting app I'm working on in ruby. Creating an article works fine, but I'm lost as to how to retrieve one. I'd like my Article.get method to return an article object,.. but it seems the only way to do this is to make all the Article attributes writable, which I don't really want to d...
[ { "answer_id": 503461, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 2, "selected": false, "text": "<p>I think the problem here is that you are using the initialize method to save the record to the filesystem, when if...
2009/02/02
[ "https://Stackoverflow.com/questions/503404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here I have the start of a news posting app I'm working on in ruby. Creating an article works fine, but I'm lost as to how to retrieve one. I'd like my Article.get method to return an article object,.. but it seems the only way to do this is to make all the Article attributes writable, which I don't really want to do. ...
I think the problem here is that you are using the initialize method to save the record to the filesystem, when if you want to instantiate an article object to return with ``` Article.new ``` then that will also call the initialize method; which is probably why it's confusing; you seem to be conflating two things in...