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
206,970
<p>I have a web-based application that notifies users of activity on the site via email. Users can choose which kinds of notifcations they want to receive. So far there are about 10 different options (each one is a true/false).</p> <p>I'm currently storing this in one varchar field as a 0 or 1 separated by commas. For...
[ { "answer_id": 206973, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 0, "selected": false, "text": "<p>I'd expect that letting the DB manage it by using Bool columns would be better. I seem to recall that some systems will pack ...
2008/10/16
[ "https://Stackoverflow.com/questions/206970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18234/" ]
I have a web-based application that notifies users of activity on the site via email. Users can choose which kinds of notifcations they want to receive. So far there are about 10 different options (each one is a true/false). I'm currently storing this in one varchar field as a 0 or 1 separated by commas. For example: ...
I would use two tables. One table would store the user data and the other the notifications that they subscribe to. The second table would look something like this: ``` create table notifications ( user_id int, notification_type int ); ``` I'd make a FK relationship between user\_id and the user's id in the us...
206,988
<p>How do I remove the key 'bar' from an array foo so that 'bar' won't show up in</p> <pre><code>for(key in foo){alert(key);} </code></pre>
[ { "answer_id": 206994, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 6, "selected": false, "text": "<pre><code>delete foo[key];\n</code></pre>\n\n<p>:D</p>\n" }, { "answer_id": 1345122, "author": "going", "auth...
2008/10/16
[ "https://Stackoverflow.com/questions/206988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
How do I remove the key 'bar' from an array foo so that 'bar' won't show up in ``` for(key in foo){alert(key);} ```
Don't use **delete** as it won't remove an element from an array it will only set it as undefined, which will then not be reflected correctly in the length of the array. If you know the key you should use **splice** i.e. ``` myArray.splice(key, 1); ``` For someone in Steven's position you can try something like thi...
206,997
<p>I have this bit of script to widen a text box on mouseover and shorten it on mouseoff.</p> <p>The problem I am having is that Internet Explorer doesn't seem to extend it's hover over the options of a select box.</p> <p>This means in IE I can click the select, have the options drop down, but if I try to select one,...
[ { "answer_id": 207168, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 4, "selected": true, "text": "<p>Apparently IE doesn't consider the drop down bit part of the select element. It's doable, but it takes a bit of cheating wit...
2008/10/16
[ "https://Stackoverflow.com/questions/206997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
I have this bit of script to widen a text box on mouseover and shorten it on mouseoff. The problem I am having is that Internet Explorer doesn't seem to extend it's hover over the options of a select box. This means in IE I can click the select, have the options drop down, but if I try to select one, they vanish and ...
Apparently IE doesn't consider the drop down bit part of the select element. It's doable, but it takes a bit of cheating with expando properties and blur/focus events to enable and disable the 'hide' effect to stop it kicking in when the mouse enters the drop-down part of the element. Have a go with this: ``` $(funct...
206,998
<p>After some find and replace refactoring I ended up with this gem:</p> <pre><code>const class A { }; </code></pre> <p>What does "const class" mean? It seems to compile ok.</p>
[ { "answer_id": 207003, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 5, "selected": false, "text": "<p>If you had this:</p>\n\n<pre><code>const class A\n{\n} a;\n</code></pre>\n\n<p>Then it would clearly mean that 'a' i...
2008/10/16
[ "https://Stackoverflow.com/questions/206998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3146/" ]
After some find and replace refactoring I ended up with this gem: ``` const class A { }; ``` What does "const class" mean? It seems to compile ok.
> > What does "const class" mean? It seems to compile ok. > > > Not for me it doesn't. I think your compiler's just being polite and ignoring it. **Edit:** Yep, VC++ silently ignores the const, GCC complains.
207,000
<p>Is there any meaningful distinction between:</p> <pre><code>class A(object): foo = 5 # some default value </code></pre> <p>vs.</p> <pre><code>class B(object): def __init__(self, foo=5): self.foo = foo </code></pre> <p>If you're creating a lot of instances, is there any difference in performance...
[ { "answer_id": 207128, "author": "Alex Coventry", "author_id": 1941213, "author_profile": "https://Stackoverflow.com/users/1941213", "pm_score": 8, "selected": true, "text": "<p>There is a significant <em>semantic</em> difference (beyond performance considerations):</p>\n<ul>\n<li><stron...
2008/10/16
[ "https://Stackoverflow.com/questions/207000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22897/" ]
Is there any meaningful distinction between: ``` class A(object): foo = 5 # some default value ``` vs. ``` class B(object): def __init__(self, foo=5): self.foo = foo ``` If you're creating a lot of instances, is there any difference in performance or space requirements for the two styles? When y...
There is a significant *semantic* difference (beyond performance considerations): * **when the attribute is defined on the instance** (which is what we usually do), there can be multiple objects referred to. **Each gets a totally separate version of that attribute**. * **when the attribute is defined on the class**, t...
207,002
<p>Is there a way of using an 'OR' operator or equivalent in a PHP switch?</p> <p>For example, something like this:</p> <pre><code>switch ($value) { case 1 || 2: echo 'the value is either 1 or 2'; break; } </code></pre>
[ { "answer_id": 207006, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 9, "selected": false, "text": "<pre><code>switch ($value)\n{\n case 1:\n case 2:\n echo \"the value is either 1 or 2.\";\n break;\n}\n</code>...
2008/10/16
[ "https://Stackoverflow.com/questions/207002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way of using an 'OR' operator or equivalent in a PHP switch? For example, something like this: ``` switch ($value) { case 1 || 2: echo 'the value is either 1 or 2'; break; } ```
``` switch ($value) { case 1: case 2: echo "the value is either 1 or 2."; break; } ``` This is called "falling through" the case block. The term exists in most languages implementing a switch statement.
207,019
<p>I know this question has been asked before, but I ran into a problem.</p> <p>Oddly enough, when I execute this function, it includes the html of the page that the link you select to execute the function.</p> <pre><code>function exportCSV($table) { $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i =...
[ { "answer_id": 207028, "author": "Troy Howard", "author_id": 19258, "author_profile": "https://Stackoverflow.com/users/19258", "pm_score": 1, "selected": false, "text": "<p>php isn't really my thing, but it seems like you need to clear the response stream before writing out your content....
2008/10/16
[ "https://Stackoverflow.com/questions/207019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
I know this question has been asked before, but I ran into a problem. Oddly enough, when I execute this function, it includes the html of the page that the link you select to execute the function. ``` function exportCSV($table) { $result = mysql_query("SHOW COLUMNS FROM ".$table.""); $i = 0; if (mysql_num...
My guess is that you've got some sort of template that generates the same HTML header and footer regardless of the page that is requested. Sometime before the exportCSV function is called, the header is generated. You don't show the bottom of the output, but I'll bet the footer is there too, since I suspect the flow c...
207,022
<p>My problem is that I can't seem to get the image from my bundle to display properly. This method is in the view controller that controls the tableview. <em>headerView</em> is loaded with the tableview in the .nib file and contains a few UILabels (not shown) that load just fine. Any ideas?</p> <pre><code>- (void)vie...
[ { "answer_id": 207227, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 2, "selected": false, "text": "<p>FIrst you need to figure out whether your image is loading properly. The quickest way to get an image is to use the ...
2008/10/16
[ "https://Stackoverflow.com/questions/207022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28422/" ]
My problem is that I can't seem to get the image from my bundle to display properly. This method is in the view controller that controls the tableview. *headerView* is loaded with the tableview in the .nib file and contains a few UILabels (not shown) that load just fine. Any ideas? ``` - (void)viewDidLoad { [super...
If you've already created an outlet and connected it to a view in Interface Builder, you should use that view, rather than creating a UIImageView on the fly. ``` //this assumes that headerView is an already created UIView, perhaps an IBOutlet //also, imageViewOutlet is an IB outlet hooked up to a UIImageView, ...
207,024
<p>Following up on <a href="https://stackoverflow.com/questions/189893/is-there-any-way-to-get-code-folding-in-delphi-7">this</a> question, I'm working on a large Delphi 7 codebase which was not written very nicely. </p> <p>I'm looking at code like this, as a small example:</p> <pre><code> if FMode=mdCredit then beg...
[ { "answer_id": 207036, "author": "Argalatyr", "author_id": 18484, "author_profile": "https://Stackoverflow.com/users/18484", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"http://conferences.codegear.com/article/32128#RenameSymbol\" rel=\"nofollow noreferrer\">Rename Symbol<...
2008/10/16
[ "https://Stackoverflow.com/questions/207024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
Following up on [this](https://stackoverflow.com/questions/189893/is-there-any-way-to-get-code-folding-in-delphi-7) question, I'm working on a large Delphi 7 codebase which was not written very nicely. I'm looking at code like this, as a small example: ``` if FMode=mdCredit then begin Panel8.Caption:='Credit';...
Not exactly a plug-in, but you can use one of the more recent versions of Delphi and the refactoring feature in there. Maybe you could use the free [Turbo Edition](http://www.turboexplorer.com/) . . . You might try [ModelMaker](http://www.modelmakertools.com/) for Delphi 7. It has refactoring support that might work ...
207,025
<p>I want to enforce CHECK constraint on a date range such that all dates in column BIRTH_DATE are less than tomorrow and greater than or equal to 100 years ago. I tried this expression in a CHECK constraint:</p> <pre><code>BIRTH_DATE &gt;= (sysdate - numtoyminterval(100, 'YEAR')) AND BIRTH_DATE &lt; sysdate + 1 </co...
[ { "answer_id": 207087, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 3, "selected": true, "text": "<p>A check constraint expression has to be deterministic, so this sort of sliding date range is not enforcable in a che...
2008/10/16
[ "https://Stackoverflow.com/questions/207025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401/" ]
I want to enforce CHECK constraint on a date range such that all dates in column BIRTH\_DATE are less than tomorrow and greater than or equal to 100 years ago. I tried this expression in a CHECK constraint: ``` BIRTH_DATE >= (sysdate - numtoyminterval(100, 'YEAR')) AND BIRTH_DATE < sysdate + 1 ``` But I received the...
A check constraint expression has to be deterministic, so this sort of sliding date range is not enforcable in a check constraint. From the [SQL Reference](http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/clauses002.htm#SQLRF01111) > > Conditions of check constraints cannot > contain the following cons...
207,038
<p>What is the best way to approach removing items from a collection in C#, once the item is known, but not it's index. This is one way to do it, but it seems inelegant at best.</p> <pre><code>//Remove the existing role assignment for the user. int cnt = 0; int assToDelete = 0; foreach (SPRoleAssignment spAssignment ...
[ { "answer_id": 207048, "author": "Jon B", "author_id": 27414, "author_profile": "https://Stackoverflow.com/users/27414", "pm_score": 6, "selected": true, "text": "<p>If you want to access members of the collection by one of their properties, you might consider using a <code>Dictionary&lt...
2008/10/16
[ "https://Stackoverflow.com/questions/207038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18449/" ]
What is the best way to approach removing items from a collection in C#, once the item is known, but not it's index. This is one way to do it, but it seems inelegant at best. ``` //Remove the existing role assignment for the user. int cnt = 0; int assToDelete = 0; foreach (SPRoleAssignment spAssignment in workspace.Ro...
If you want to access members of the collection by one of their properties, you might consider using a `Dictionary<T>` or `KeyedCollection<T>` instead. This way you don't have to search for the item you're looking for. Otherwise, you could at least do this: ``` foreach (SPRoleAssignment spAssignment in workspace.Role...
207,045
<p>Can an ArrayList of Node contain a non-Node type? </p> <p>Is there a very dirty method of doing this with type casting?</p>
[ { "answer_id": 207052, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 4, "selected": true, "text": "<p>Yes, but you will get class cast exceptions if you try to access a non-node element as if it were a node. Generics are d...
2008/10/16
[ "https://Stackoverflow.com/questions/207045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27570/" ]
Can an ArrayList of Node contain a non-Node type? Is there a very dirty method of doing this with type casting?
Yes, but you will get class cast exceptions if you try to access a non-node element as if it were a node. Generics are discarded at (for) runtime. For example: ``` import java.util.*; import java.awt.Rectangle; public class test { public static void main(String args[]) { List<Rectangle> list = new ArrayL...
207,069
<p>I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib' prefix.)</p> <p>I am able to pass the path to the library file direc...
[ { "answer_id": 207149, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 2, "selected": false, "text": "<p>If you can copy the shared library to the working directory when g++ is invoked then this should work:</p>\n\n<pr...
2008/10/16
[ "https://Stackoverflow.com/questions/207069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13402/" ]
I have a shared library that I wish to link an executable against using GCC. The shared library has a nonstandard name not of the form libNAME.so, so I can not use the usual -l option. (It happens to also be a Python extension, and so has no 'lib' prefix.) I am able to pass the path to the library file directly to the...
There is the ":" prefix that allows you to give different names to your libraries. If you use ``` g++ -o build/bin/myapp -l:_mylib.so other_source_files ``` should search your path for the \_mylib.so.
207,150
<p>I have a view using a master page that contains some javascript that needs to be executed using the OnLoad of the Body. What is the best way to set the OnLoad on my MasterPage only for certain views?</p> <p>On idea I tried was to pass the name of the javascript function as ViewData. But I dont really want my Contro...
[ { "answer_id": 207183, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 0, "selected": false, "text": "<p>You should definitely be using jQuery or another JavaScript framework anyway.</p>\n\n<p>Have your controllers pass so...
2008/10/16
[ "https://Stackoverflow.com/questions/207150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10941/" ]
I have a view using a master page that contains some javascript that needs to be executed using the OnLoad of the Body. What is the best way to set the OnLoad on my MasterPage only for certain views? On idea I tried was to pass the name of the javascript function as ViewData. But I dont really want my Controllers to h...
I have been using the following pattern with my current MVC project and it seems to be working pretty good for my .js work thus far... Within my Master Page I load up my standard script files that I want to be used in all of my content pages (things like jquery.js, global.js, jquery-plugins, .css files, etc.). I then ...
207,157
<p>I have this XML in a column in my table:</p> <pre><code>&lt;keywords&gt; &lt;keyword name="First Name" value="|FIRSTNAME|" display="Jack" /&gt; &lt;keyword name="Last Name" value="|LASTNAME|" display="Jones" /&gt; &lt;keyword name="City" value="|CITY|" display="Anytown" /&gt; &lt;keyword name="State" value=...
[ { "answer_id": 207196, "author": "ckramer", "author_id": 20504, "author_profile": "https://Stackoverflow.com/users/20504", "pm_score": 0, "selected": false, "text": "<p>I would think something like this would work</p>\n\n<pre><code>var keywordData = from k in ga.ArticleKeywords.Elements(...
2008/10/16
[ "https://Stackoverflow.com/questions/207157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1989/" ]
I have this XML in a column in my table: ``` <keywords> <keyword name="First Name" value="|FIRSTNAME|" display="Jack" /> <keyword name="Last Name" value="|LASTNAME|" display="Jones" /> <keyword name="City" value="|CITY|" display="Anytown" /> <keyword name="State" value="|STATE|" display="MD" /> </keywords> ``...
Here is a sample code: To read keywords we need to call *Elements("**keyword**")* not *Elements("**keywords**")* since *keywords* is a root node. ``` // IEnumerable sequence with keywords data var keywords = from kw in ga.ArticleKeywords.Elements("keyword") select new { Name = (stri...
207,185
<p>Can two domain objects show on the same page, when the list method is called, for example?</p> <p><a href="http://APP_NAME/foo/list" rel="nofollow noreferrer">http://APP_NAME/foo/list</a></p> <hr> <pre><code>def list = { if(!params.max) params.max = 10 [ fooList: Foo.list( params ) ] [ barList: Bar.li...
[ { "answer_id": 207197, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 4, "selected": true, "text": "<p>Pretty sure you can return multiple things in that last line:</p>\n\n<p>[ fooList: Foo.list( params ),\n barList: ...
2008/10/16
[ "https://Stackoverflow.com/questions/207185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can two domain objects show on the same page, when the list method is called, for example? <http://APP_NAME/foo/list> --- ``` def list = { if(!params.max) params.max = 10 [ fooList: Foo.list( params ) ] [ barList: Bar.list( params ) ] // Only the last one is returned. } ``` --- On the view page, bot...
Pretty sure you can return multiple things in that last line: [ fooList: Foo.list( params ), barList: Bar.list( params ) ]
207,190
<p>I want to convert a string like this:</p> <pre><code>'10/15/2008 10:06:32 PM' </code></pre> <p>into the equivalent DATETIME value in Sql Server.</p> <p>In Oracle, I would say this:</p> <pre><code>TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:SS AM') </code></pre> <p><a href="https://stackoverflow.com/quest...
[ { "answer_id": 207228, "author": "Ovidiu Pacurar", "author_id": 28419, "author_profile": "https://Stackoverflow.com/users/28419", "pm_score": 3, "selected": false, "text": "<p>For this problem the best solution I use is to have a CLR function in Sql Server 2005 that uses one of DateTime....
2008/10/16
[ "https://Stackoverflow.com/questions/207190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
I want to convert a string like this: ``` '10/15/2008 10:06:32 PM' ``` into the equivalent DATETIME value in Sql Server. In Oracle, I would say this: ``` TO_DATE('10/15/2008 10:06:32 PM','MM/DD/YYYY HH:MI:SS AM') ``` [This question](https://stackoverflow.com/questions/202243/custom-datetime-formatting-in-sql-ser...
Try this ``` Cast('7/7/2011' as datetime) ``` and ``` Convert(DATETIME, '7/7/2011', 101) ``` See [CAST and CONVERT (Transact-SQL)](https://msdn.microsoft.com/en-us/library/ms187928(v=sql.90).aspx) for more details.
207,195
<p>Without using Javascript, is there a way to make a CSS property toggle on and off through nested elements.</p> <p>The problem I'm trying to solve is that I have a number of tags and classes which make some text italic (<code>&lt;em&gt;</code>, <code>&lt;blockquote&gt;</code>, <code>&lt;cite&gt;</code>, <code>&lt;q&...
[ { "answer_id": 207218, "author": "Geoff", "author_id": 10427, "author_profile": "https://Stackoverflow.com/users/10427", "pm_score": 0, "selected": false, "text": "<p>I would manage that with a script that generates the necessary nesting rules for each permutation. It's the only way tha...
2008/10/16
[ "https://Stackoverflow.com/questions/207195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Without using Javascript, is there a way to make a CSS property toggle on and off through nested elements. The problem I'm trying to solve is that I have a number of tags and classes which make some text italic (`<em>`, `<blockquote>`, `<cite>`, `<q>`, `<dfn>`, and some other classes), and when one of these is inside ...
I couldn't tell you which browsers (if any) implement the CSS3 `:not` pseudo-class, but if we see it supported sometime it seems like we can do: ``` q:not(q, em, dfn, cite, blockquote), em:not(q, em, dfn, cite, blockquote), dfn:not(q, em, dfn, cite, blockquote), cite:not(q, em, dfn, cite, blockquote), blockquote:...
207,212
<p>I'm writing an application in Delphi which uses an SQLite3 database. I'd like to be able to start the application while holding some modifier keys, such as CTRL + SHIFT, to signal reinitialization of the database.</p> <p>How can I capture that the application was started while these keys were held?</p>
[ { "answer_id": 207226, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 0, "selected": false, "text": "<p>You have to capture keyboard hooks in your application.\n<a href=\"http://www.delphifaq.com/faq/delphi_windows_API/f5...
2008/10/16
[ "https://Stackoverflow.com/questions/207212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10519/" ]
I'm writing an application in Delphi which uses an SQLite3 database. I'd like to be able to start the application while holding some modifier keys, such as CTRL + SHIFT, to signal reinitialization of the database. How can I capture that the application was started while these keys were held?
Tim has the right answer, but you might need a little more framework: ``` procedure TForm56.Button1Click(Sender: TObject); begin if fNeedReinit then ReinitializeDatabase; end; procedure TForm56.FormCreate(Sender: TObject); begin fNeedReinit := False; end; procedure TForm56.FormShow(Sender: TObject); begin f...
207,223
<p>I've got a script that dynamically calls and displays images from a directory, what would be the best way to paginate this? I'd like to be able to control the number of images that are displayed per page through a variable within the script. I'm thinking of using URL varriables (ie - <a href="http://domain.com/pag...
[ { "answer_id": 207287, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<p>pagination is the same concept with or without sql. you just need your basic variables, then you can create the content you w...
2008/10/16
[ "https://Stackoverflow.com/questions/207223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27025/" ]
I've got a script that dynamically calls and displays images from a directory, what would be the best way to paginate this? I'd like to be able to control the number of images that are displayed per page through a variable within the script. I'm thinking of using URL varriables (ie - <http://domain.com/page.php?page=1>...
pagination is the same concept with or without sql. you just need your basic variables, then you can create the content you want. here's some quasi-code: ``` $itemsPerPage = 5; $currentPage = isset($_GET['page']) ? $_GET['page'] : 1; $totalItems = getTotalItems(); $totalPages = ceil($totalItems / $itemsPerPage); fun...
207,256
<p>I've created the following regex pattern in an attempt to match a string 6 characters in length ending in either "PRI" or "SEC", unless the string = "SIGSEC". For example, I want to match ABCPRI, XYZPRI, ABCSEC and XYZSEC, but not SIGSEC.</p> <pre><code>(\w{3}PRI$|[^SIG].*SEC$) </code></pre> <p>It is very close an...
[ { "answer_id": 207262, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 4, "selected": true, "text": "<p>Assuming your regex engine supports negative lookaheads, try this:</p>\n\n<pre><code>((?!SIGSEC)\\w{3}(?:SEC|PRI))\n</code><...
2008/10/16
[ "https://Stackoverflow.com/questions/207256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28442/" ]
I've created the following regex pattern in an attempt to match a string 6 characters in length ending in either "PRI" or "SEC", unless the string = "SIGSEC". For example, I want to match ABCPRI, XYZPRI, ABCSEC and XYZSEC, but not SIGSEC. ``` (\w{3}PRI$|[^SIG].*SEC$) ``` It is very close and sort of works (if I pass...
Assuming your regex engine supports negative lookaheads, try this: ``` ((?!SIGSEC)\w{3}(?:SEC|PRI)) ``` Edit: A commenter pointed out that .NET does support negative lookaheads, so this should work fine (thanks, Charlie).
207,283
<p>OS: Vista enterprise</p> <p>When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option.</p> <p>This takes a l...
[ { "answer_id": 207402, "author": "Mike L", "author_id": 12085, "author_profile": "https://Stackoverflow.com/users/12085", "pm_score": 3, "selected": false, "text": "<p>See this article from The Scripting Guys, <a href=\"https://blogs.technet.microsoft.com/heyscriptingguy/2014/01/13/enabl...
2008/10/16
[ "https://Stackoverflow.com/questions/207283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26090/" ]
OS: Vista enterprise When i switch between my home and office network, i always face issues with getting connected to the network. Almost always I have to use the diagnostic service in 'Network and sharing center' and the problem gets solved when i use the reset network adapter option. This takes a lot of time (3-4 m...
You can use WMI from within PowerShell to accomplish this. Assuming there is a network adapter who's device name has *Wireless* in it, the series of commands might look something like the following: ``` $adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"} $adaptor.Disable() ...
207,306
<p>I'm using the MonthCalendar control and want to programmatically select a date range. When I do so the control doesn't paint properly if <code>Application.EnableVisualStyles()</code> has been called. This is a known issue according to MSDN. </p> <blockquote> <p>Using the MonthCalendar with visual styles enabled...
[ { "answer_id": 1410399, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 2, "selected": false, "text": "<p>While looking for a solution to the same problem, I first encountered this question here, but later I discovered a blog e...
2008/10/16
[ "https://Stackoverflow.com/questions/207306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6255/" ]
I'm using the MonthCalendar control and want to programmatically select a date range. When I do so the control doesn't paint properly if `Application.EnableVisualStyles()` has been called. This is a known issue according to MSDN. > > Using the MonthCalendar with visual > styles enabled will cause a selection > ran...
While looking for a solution to the same problem, I first encountered this question here, but later I discovered a blog entry by [Nicke Andersson](http://nickeandersson.blogs.com/blog/2006/05/_modifying_the_.html). which I found very helpful. Here is what I made of Nicke's example: ``` public class MonthCalendarEx : S...
207,309
<p>I have db table with parent child relationship as:</p> <pre><code>NodeId NodeName ParentId ------------------------------ 1 Node1 0 2 Node2 0 3 Node3 1 4 Node4 1 5 Node5 3 6 Node6 5 7 Node7 2 </code></pre> <p>He...
[ { "answer_id": 207324, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 4, "selected": true, "text": "<pre><code>with [CTE] as (\n select * from [TheTable] c where c.[ParentId] = 1\n union all\n select * from [CTE]...
2008/10/16
[ "https://Stackoverflow.com/questions/207309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28243/" ]
I have db table with parent child relationship as: ``` NodeId NodeName ParentId ------------------------------ 1 Node1 0 2 Node2 0 3 Node3 1 4 Node4 1 5 Node5 3 6 Node6 5 7 Node7 2 ``` Here parentId = 0 means that...
``` with [CTE] as ( select * from [TheTable] c where c.[ParentId] = 1 union all select * from [CTE] p, [TheTable] c where c.[ParentId] = p.[NodeId] ) select * from [CTE] ```
207,337
<p>The Oracle view V$OSSTAT holds a few operating statistics, including:</p> <ul> <li>IDLE_TICKS Number of hundredths of a second that a processor has been idle, totalled over all processors</li> <li>BUSY_TICKS Number of hundredths of a second that a processor has been busy executing user or kernel code, totalled ov...
[ { "answer_id": 208455, "author": "Leigh Riffel", "author_id": 27010, "author_profile": "https://Stackoverflow.com/users/27010", "pm_score": 3, "selected": true, "text": "<p>You'll need to include 'IOWAIT_TICKS` if they are available.</p>\n<blockquote>\n<p>IDLE_TICKS - Number of hundredth...
2008/10/16
[ "https://Stackoverflow.com/questions/207337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27308/" ]
The Oracle view V$OSSTAT holds a few operating statistics, including: * IDLE\_TICKS Number of hundredths of a second that a processor has been idle, totalled over all processors * BUSY\_TICKS Number of hundredths of a second that a processor has been busy executing user or kernel code, totalled over all processors Th...
You'll need to include 'IOWAIT\_TICKS` if they are available. > > IDLE\_TICKS - Number of hundredths of a > second that a processor has been idle, > totaled over all processors > > > BUSY\_TICKS - Number of hundredths of a second that a > processor has been busy executing > user or kernel code, totaled over all > p...
207,343
<p>I'm writing a data structure in C# (a priority queue using a <a href="http://en.wikipedia.org/wiki/Fibonacci_heap" rel="nofollow noreferrer">fibonacci heap</a>) and I'm trying to use it as a learning experience for TDD which I'm quite new to. </p> <p>I understand that each test should only test one piece of the cl...
[ { "answer_id": 207346, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<p>I think this is ok, but clear the queue at the start of your test method.</p>\n" }, { "answer_id": 207350,...
2008/10/16
[ "https://Stackoverflow.com/questions/207343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9617/" ]
I'm writing a data structure in C# (a priority queue using a [fibonacci heap](http://en.wikipedia.org/wiki/Fibonacci_heap)) and I'm trying to use it as a learning experience for TDD which I'm quite new to. I understand that each test should only test one piece of the class so that a failure in one unit doesn't confus...
Add a private accessor for the class to your test project. Use the accessor to set up the private properties of the class in some known way instead of using the classes methods to do so. You also need to use `SetUp` and `TearDown` methods on your test class to perform any initializations needed between tests. I would...
207,464
<p>I'm refactoring a number of classes in an application to use interfaces instead of base classes. Here's the interfaces I created so far:</p> <ul> <li>ICarryable implemented by all Item objects </li> <li>IActable implemented by all Actor objects</li> <li>IUseable implemented by some Item sub-classes</li> <li>IWie...
[ { "answer_id": 207471, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "<p>Sounds like an ILocateable. Something whose location you can discover and track.</p>\n" }, { "answer_id": 2074...
2008/10/16
[ "https://Stackoverflow.com/questions/207464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103052/" ]
I'm refactoring a number of classes in an application to use interfaces instead of base classes. Here's the interfaces I created so far: * ICarryable implemented by all Item objects * IActable implemented by all Actor objects * IUseable implemented by some Item sub-classes * IWieldable implemented by some Item sub-cla...
Sounds like an ILocateable. Something whose location you can discover and track.
207,477
<p>I'm looking for a reasonable way to represent searches as a RESTful URLs.</p> <p>The setup: I have two models, Cars and Garages, where Cars can be in Garages. So my urls look like:</p> <pre><code>/car/xxxx xxx == car id returns car with given id /garage/yyy yyy = garage id returns garage with given id </c...
[ { "answer_id": 207493, "author": "Justin Bozonier", "author_id": 9401, "author_profile": "https://Stackoverflow.com/users/9401", "pm_score": -1, "selected": false, "text": "<p>My advice would be this:</p>\n\n<pre><code>/garages\n Returns list of garages (think JSON array here)\n/garages...
2008/10/16
[ "https://Stackoverflow.com/questions/207477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13055/" ]
I'm looking for a reasonable way to represent searches as a RESTful URLs. The setup: I have two models, Cars and Garages, where Cars can be in Garages. So my urls look like: ``` /car/xxxx xxx == car id returns car with given id /garage/yyy yyy = garage id returns garage with given id ``` A Car can exist on...
For the searching, use querystrings. This is perfectly RESTful: ``` /cars?color=blue&type=sedan&doors=4 ``` An advantage to regular querystrings is that they are standard and widely understood and that they can be generated from form-get.
207,485
<p>When you plot things in Matlab, the most recently plotted data series is placed on top of whatever's already there. For example:</p> <pre><code>figure; hold on plot(sin(linspace(0,pi)),'linewidth',4,'color',[0 0 1]) plot(cos(linspace(0,pi)),'linewidth',4,'color',[1 0 0]) </code></pre> <p>Here, the red line is show...
[ { "answer_id": 207603, "author": "b3.", "author_id": 14946, "author_profile": "https://Stackoverflow.com/users/14946", "pm_score": 5, "selected": true, "text": "<p>Use the <strong>uistack</strong> command. For example:</p>\n\n<pre><code>h1 = plot(1:10, 'b');\nhold on;\nh2 = plot(1:10, '...
2008/10/16
[ "https://Stackoverflow.com/questions/207485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4161/" ]
When you plot things in Matlab, the most recently plotted data series is placed on top of whatever's already there. For example: ``` figure; hold on plot(sin(linspace(0,pi)),'linewidth',4,'color',[0 0 1]) plot(cos(linspace(0,pi)),'linewidth',4,'color',[1 0 0]) ``` Here, the red line is shown on top of the blue line ...
Use the **uistack** command. For example: ``` h1 = plot(1:10, 'b'); hold on; h2 = plot(1:10, 'r'); ``` will plot two lines with the red line plotted on top of the blue line. If you then do: ``` uistack(h1); ``` the blue line will be brought to the front.
207,494
<p>Its a little tricky to search for 'var:*' because most search engines wont find it.</p> <p>I'm not clear exactly what var:* means, compared to say var:Object</p> <p>I thought it would let me set arbitrary properties on an object like :</p> <pre><code>var x:* = myObject; x.nonExistantProperty = "123"; </code></pr...
[ { "answer_id": 207505, "author": "Gerald", "author_id": 19404, "author_profile": "https://Stackoverflow.com/users/19404", "pm_score": 1, "selected": false, "text": "<p>It's the \"untyped\" type. It just means that the variable can be of any type. Basically the same effect as using this:<...
2008/10/16
[ "https://Stackoverflow.com/questions/207494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24727/" ]
Its a little tricky to search for 'var:\*' because most search engines wont find it. I'm not clear exactly what var:\* means, compared to say var:Object I thought it would let me set arbitrary properties on an object like : ``` var x:* = myObject; x.nonExistantProperty = "123"; ``` but this gives me an error : `...
Expanding on the other answers, declaring something with type asterisk is *exactly* the same as leaving it untyped. ``` var x:* = {}; var y = {}; // equivalent ``` However, the question of whether you are allowed to assign non-existant properties to objects has nothing to do with the type of the reference, and is de...
207,496
<p>So my code is below. I'm not getting any errors and it places everything in the node just fine. But based on my debug statements Everytime anything is inserted it's finding the root. I'm not sure if that is right. But according to output file for the assignment, my answers are different when it comes to the heig...
[ { "answer_id": 207503, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 4, "selected": true, "text": "<p>You need to change the wording of your debug statements</p>\n\n<p>Really it should read (not Root node)</p>\n\n<pre>...
2008/10/16
[ "https://Stackoverflow.com/questions/207496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28392/" ]
So my code is below. I'm not getting any errors and it places everything in the node just fine. But based on my debug statements Everytime anything is inserted it's finding the root. I'm not sure if that is right. But according to output file for the assignment, my answers are different when it comes to the height of t...
You need to change the wording of your debug statements Really it should read (not Root node) ``` cout << "Leaf Node Found" << newNode->data << endl; ``` It is only the root when it is first called after that any call with node->left or node->right makes it an intermediate node. To write height() I would do this:...
207,497
<p>I am looking to set full trust for a single web part, is this possible? manifest.xml maybe?</p>
[ { "answer_id": 207515, "author": "Ed Altorfer", "author_id": 26552, "author_profile": "https://Stackoverflow.com/users/26552", "pm_score": 2, "selected": true, "text": "<p>Have you tried registering the assembly in the GAC? This is the preferred approach to giving any assembly full trust...
2008/10/16
[ "https://Stackoverflow.com/questions/207497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
I am looking to set full trust for a single web part, is this possible? manifest.xml maybe?
Have you tried registering the assembly in the GAC? This is the preferred approach to giving any assembly full trust on your machine: ``` gacutil.exe \i C:\Path\To\Dll.dll ``` Hope that helps. Let me know if I misunderstood your question.
207,498
<p>I am running both maven inside the m2eclipse plugin, windows command line and my cygwin command line.</p> <p>cygwin's bash shell dumps artifacts into the cygwin /home/me/.m2 directory</p> <p>but m2eclipse &amp; windows shell (on vista) uses /Users/me/Documents/.m2</p> <p>Is it possible to tell the mvn command to ...
[ { "answer_id": 207559, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 4, "selected": false, "text": "<p>Sure, several ways. The most typical is to specify this in your settings.xml file:</p>\n\n<ul>\n<li><a href=\"http:/...
2008/10/16
[ "https://Stackoverflow.com/questions/207498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
I am running both maven inside the m2eclipse plugin, windows command line and my cygwin command line. cygwin's bash shell dumps artifacts into the cygwin /home/me/.m2 directory but m2eclipse & windows shell (on vista) uses /Users/me/Documents/.m2 Is it possible to tell the mvn command to use one central .m2 director...
For Cygwin, create a file called ~/.mavenrc and put the following text inside: ``` MAVEN_OPTS="-Dmaven.repo.local=c:\documents and settings\user\.m2\repository" export MAVEN_OPTS ``` Alternatively, you can create the file under /etc/.mavenrc Another option is to create [NTFS junction](http://technet.microsoft.com/e...
207,504
<p>I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are marked as protected and the components variable is also marked as protected.</p> <p>I then want to inherit from this base UserControl to another UserControl, however the DataGridView is always locked in the d...
[ { "answer_id": 207511, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 1, "selected": false, "text": "<p>I left an answer but re-read your question and decided to delete it.</p>\n\n<p>What is it about the DataGridView that...
2008/10/16
[ "https://Stackoverflow.com/questions/207504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
I have a UserControl with some predefined controls (groupbox,button,datagridview) on it, these controls are marked as protected and the components variable is also marked as protected. I then want to inherit from this base UserControl to another UserControl, however the DataGridView is always locked in the designer. ...
By the looks of it, DataListView (and some other controls) do not support visual inheritance. There's a connect issue [logged here](http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=116457) which doesn't look hopeful. There have been similar issues logged with other form controls, e.g. [f...
207,513
<p>Is there any tool that enables you to "hot swap" JavaScript contents while executing a webpage? </p> <p>I am looking for something similar to what HotSpot does for Java, a way to "hot deploy" new JS code without having to reload the whole page.</p> <p>Is there anything like that out there?</p> <p><strong>Clarifyi...
[ { "answer_id": 207522, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 0, "selected": false, "text": "<p>If you want to do this with <em>entire</em> JavaScript files, see <a href=\"https://stackoverflow.com/questions/203...
2008/10/16
[ "https://Stackoverflow.com/questions/207513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540/" ]
Is there any tool that enables you to "hot swap" JavaScript contents while executing a webpage? I am looking for something similar to what HotSpot does for Java, a way to "hot deploy" new JS code without having to reload the whole page. Is there anything like that out there? **Clarifying in case people don't unders...
Interesting idea :) I wrote the following bookmarklet: ``` function reload(){var scripts=document.getElementsByTagName("script");var head=document.getElementsByTagName("head")[0];var newScripts=[];var removeScripts=[];for(var i=0;i<scripts.length;i++){var parent=scripts[i].parentNode;if(parent==head&&scripts[i].src)...
207,542
<p>I would like to programatically shutdown a Windows Mobile device using Compact framework 2.0, Windows mobile 5.0 SDK.</p> <p>Regards,</p>
[ { "answer_id": 207585, "author": "Marcin Gil", "author_id": 5731, "author_profile": "https://Stackoverflow.com/users/5731", "pm_score": 0, "selected": false, "text": "<p>The \"normal\" Windows API has ExitWindowsEx() function. You might want to check this out.\nIt appears however that it...
2008/10/16
[ "https://Stackoverflow.com/questions/207542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254/" ]
I would like to programatically shutdown a Windows Mobile device using Compact framework 2.0, Windows mobile 5.0 SDK. Regards,
It probably not a great idea to do it from your app - the device has a power button for a reason and shutting down the app can cause user confusion and frustration. If you must do it, and you are using Windows Mobile 5.0 or later, you can P/Invoke [ExitWindowsEx](http://msdn.microsoft.com/en-us/library/bb416523.aspx) ...
207,565
<p>I'm using Eclipse 3.4 with WTP 3.0.2 and running a fairly large Dynamic Web Project. I've set up the project so that I can access it at <a href="http://127.0.0.1:8080/share/" rel="noreferrer">http://127.0.0.1:8080/share/</a> but whenever I do, I get the following error:</p> <pre> java.lang.NoSuchMethodError: java...
[ { "answer_id": 207581, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>Did you set a Tomcat path in \"Preferences->Tomcat->Advanced->Tomcat base\" ?</p>\n\n<p>Try to clean that path (getting back...
2008/10/16
[ "https://Stackoverflow.com/questions/207565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27736/" ]
I'm using Eclipse 3.4 with WTP 3.0.2 and running a fairly large Dynamic Web Project. I've set up the project so that I can access it at <http://127.0.0.1:8080/share/> but whenever I do, I get the following error: ``` java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/la...
I ended up answering my own question: the problem was that among the necessary JARs that I had added to Tomcat was a conflicting servlet.jar. When I removed this, the error disappeared.
207,575
<p>I am trying to make a library that wraps libpurple (you shouldn't need to know anything about libpurple to help here). Libpurple in turn loads "plugins" which are just .so's accessed via something like dlopen. Those plugins in turn call back to functions in libpurple.</p> <p>I can build my library just fine, but wh...
[ { "answer_id": 209178, "author": "Tim Lesher", "author_id": 14942, "author_profile": "https://Stackoverflow.com/users/14942", "pm_score": 4, "selected": false, "text": "<p>We see a similar issue with Visual Studio 2005 projects that we want to build both for a Win32 configuration and for...
2008/10/16
[ "https://Stackoverflow.com/questions/207575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to make a library that wraps libpurple (you shouldn't need to know anything about libpurple to help here). Libpurple in turn loads "plugins" which are just .so's accessed via something like dlopen. Those plugins in turn call back to functions in libpurple. I can build my library just fine, but when it call...
We see a similar issue with Visual Studio 2005 projects that we want to build both for a Win32 configuration and for a number of distinct smart device platform/configuration combinations. At arbitrary times, every configuration gets auto-generated for every platform, whether it's valid or not, exploding the size of ea...
207,592
<p>I have a class, and I want to inspect its fields and report eventually how many bytes each field takes. I assume all fields are of type Int32, byte, etc.</p> <p>How can I find out easily how many bytes does the field take?</p> <p>I need something like:</p> <pre><code>Int32 a; // int a_size = a.GetSizeInBytes; //...
[ { "answer_id": 207598, "author": "Joachim Kerschbaumer", "author_id": 20227, "author_profile": "https://Stackoverflow.com/users/20227", "pm_score": 1, "selected": false, "text": "<p>if you have the type, use the sizeof operator. it will return the type`s size in byte. \ne.g.</p>\n\n<p>Co...
2008/10/16
[ "https://Stackoverflow.com/questions/207592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class, and I want to inspect its fields and report eventually how many bytes each field takes. I assume all fields are of type Int32, byte, etc. How can I find out easily how many bytes does the field take? I need something like: ``` Int32 a; // int a_size = a.GetSizeInBytes; // a_size should be 4 ```
You can't, basically. It will depend on padding, which may well be based on the CLR version you're using and the processor etc. It's easier to work out the total size of an object, assuming it has no references to other objects: create a big array, use [GC.GetTotalMemory](http://msdn.microsoft.com/en-us/library/system....
207,599
<p>I just wrote a new web part and now I am getting this error when I try to deploy them on my non-dev servers:</p> <blockquote> <p>the default namespace '<a href="http://schemas.microsoft.com/WebPart/v2" rel="nofollow noreferrer">http://schemas.microsoft.com/WebPart/v2</a>' is a reserved namespace for base Web ...
[ { "answer_id": 207686, "author": "Ryan", "author_id": 20198, "author_profile": "https://Stackoverflow.com/users/20198", "pm_score": 0, "selected": false, "text": "<p>A bit of a educated guess here but anyway :-</p>\n\n<p>First check that you have XmlRoot attribute like this in your web p...
2008/10/16
[ "https://Stackoverflow.com/questions/207599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
I just wrote a new web part and now I am getting this error when I try to deploy them on my non-dev servers: > > the default namespace > '<http://schemas.microsoft.com/WebPart/v2>' > is a reserved namespace for base Web > Part propertiees. Custom Web Part > properties require a unique namespace > (specified thro...
Well, it looks like your webpart definition file si somehow broken. The wey i do it is to put webpart into page and then export it. You can do this just by opening webpart galery, which can be located in site settings of root site collection and add your webpart there. After that just place webpart to any page and us...
207,608
<p>There is this style of exception system where a component throws component-specific exception. For example, all data access classes throw <code>DataAccessException</code>.</p> <p>In this style, I often find myself having to catch and rethrow the component specific exception, because called methods are delcared as <...
[ { "answer_id": 207634, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>That is ugly as hell. There isn't much more to comment on that ugly style, I think. If you already have all the c...
2008/10/16
[ "https://Stackoverflow.com/questions/207608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18573/" ]
There is this style of exception system where a component throws component-specific exception. For example, all data access classes throw `DataAccessException`. In this style, I often find myself having to catch and rethrow the component specific exception, because called methods are delcared as `throws Exception`: `...
That is ugly as hell. There isn't much more to comment on that ugly style, I think. If you already have all the code to handle different issues using the cause, that'd work. It's just that using ``` try { componentCall(); } catch (ComponentException e) { Throwable t = e.getCause(); //Handle each possible cause ...
207,636
<p>I have a Java method which starts up a Process with ProcessBuilder, and pipes its output into a byte array, and then returns its byte array when the process is finished.</p> <p>Pseudo-code:</p> <pre><code>ProcessBuilder b = new ProcessBuilder("my.exe") Process p = b.start(); ... // get output from process, close p...
[ { "answer_id": 207694, "author": "Olaf Kock", "author_id": 13447, "author_profile": "https://Stackoverflow.com/users/13447", "pm_score": 5, "selected": true, "text": "<p>Shield yourself from the classes to be mocked. Create an interface either for doing what you really want (e.g. hiding ...
2008/10/16
[ "https://Stackoverflow.com/questions/207636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I have a Java method which starts up a Process with ProcessBuilder, and pipes its output into a byte array, and then returns its byte array when the process is finished. Pseudo-code: ``` ProcessBuilder b = new ProcessBuilder("my.exe") Process p = b.start(); ... // get output from process, close process ``` What wou...
Shield yourself from the classes to be mocked. Create an interface either for doing what you really want (e.g. hiding the fact that external processes are involved at all) or only for Process and ProcessBuilder. You don't want to test, that ProcessBuilder and Process work, only that you can work with their output. Wh...
207,646
<p>I am having an VB Script. I need to log the error information in a file. I need to log every information like error number error description and in which sub routine does the error occured.</p> <p>Please provide some code</p>
[ { "answer_id": 207697, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": -1, "selected": true, "text": "<p>For error handling in VBScript is used \"On Error\" clausule.\nThere are 3 ways, how to handle errors:</p>\n\n<ul>\n<li>On...
2008/10/16
[ "https://Stackoverflow.com/questions/207646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having an VB Script. I need to log the error information in a file. I need to log every information like error number error description and in which sub routine does the error occured. Please provide some code
For error handling in VBScript is used "On Error" clausule. There are 3 ways, how to handle errors: * On Error Resume Next '' ignore errors * On Error GoTo 0 '' removes error handlning * On Error GoTo HandleError '' on error will code jump to specified signal Samples: ``` On Error Resume Next '' ignore errors SomeIg...
207,662
<p>I'm trying to write a wstring to file with ofstream in binary mode, but I think I'm doing something wrong. This is what I've tried:</p> <pre><code>ofstream outFile("test.txt", std::ios::out | std::ios::binary); wstring hello = L"hello"; outFile.write((char *) hello.c_str(), hello.length() * sizeof(wchar_t)); outFil...
[ { "answer_id": 207688, "author": "David Grayson", "author_id": 28128, "author_profile": "https://Stackoverflow.com/users/28128", "pm_score": 0, "selected": false, "text": "<p>You should look at the output file in a hex editor such as <a href=\"http://www.download.com/WinHex/3000-2352_4-1...
2008/10/16
[ "https://Stackoverflow.com/questions/207662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22283/" ]
I'm trying to write a wstring to file with ofstream in binary mode, but I think I'm doing something wrong. This is what I've tried: ``` ofstream outFile("test.txt", std::ios::out | std::ios::binary); wstring hello = L"hello"; outFile.write((char *) hello.c_str(), hello.length() * sizeof(wchar_t)); outFile.close(); ``...
I suspect that sizeof(wchar\_t) is 4 in your environment - i.e. it's writing out UTF-32/UCS-4 instead of UTF-16. That's certainly what the hex dump looks like. That's easy enough to test (just print out sizeof(wchar\_t)) but I'm pretty sure it's what's going on. To go from a UTF-32 wstring to UTF-16 you'll need to ap...
207,693
<p>The following code returns data from a spreadsheet into a grid perfectly</p> <pre><code>[ string excelConnectString = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = " + excelFileName + ";" + "Extended Properties = Excel 8.0;"; OleDbConnection objConn = new OleDbConne...
[ { "answer_id": 281829, "author": "Jason Anderson", "author_id": 1530166, "author_profile": "https://Stackoverflow.com/users/1530166", "pm_score": 0, "selected": false, "text": "<p>In your example, does <code>SUM</code> represent a potential column name or a SQL funciton?</p>\n\n<p>Are yo...
2008/10/16
[ "https://Stackoverflow.com/questions/207693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The following code returns data from a spreadsheet into a grid perfectly ``` [ string excelConnectString = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = " + excelFileName + ";" + "Extended Properties = Excel 8.0;"; OleDbConnection objConn = new OleDbConnection(excelCon...
If you don't want to do **Group by** then DataTable class has a method called **Compute** that executes few SQL functions. The following functions are supported : **COUNT, SUM, MIN, MAX, AVG, STDEV, VAR**. ``` string salary = empTable.Compute("SUM( Salary )", "").ToString(); string averageSalaryJan = empTable.C...
207,720
<p>One of the most difficult problems in my javascript experience has been the correct (that is "cross-browser") computing of a <strong>iframe height</strong>. In my applications I have a lot of dynamically generated iframe and I want them all do a sort of autoresize at the end of the load event to adjust their height ...
[ { "answer_id": 208311, "author": "jim", "author_id": 27628, "author_profile": "https://Stackoverflow.com/users/27628", "pm_score": 2, "selected": false, "text": "<p>Although I like your solution, I've always found IFRAMEs to be more trouble than they're worth.</p>\n\n<p>Why ? 1. The siz...
2008/10/16
[ "https://Stackoverflow.com/questions/207720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27789/" ]
One of the most difficult problems in my javascript experience has been the correct (that is "cross-browser") computing of a **iframe height**. In my applications I have a lot of dynamically generated iframe and I want them all do a sort of autoresize at the end of the load event to adjust their height and width. In t...
Although I like your solution, I've always found IFRAMEs to be more trouble than they're worth. Why ? 1. The sizing issue. 2. the iframe has that src attribute to worry about. i.e. absolute path. 3. the extra complexity with the pages. My solution - DIVs which are dynamically loaded through AJAX calls. DIVs will auto...
207,721
<p>As I mention in an earlier question, I'm refactoring a project I'm working on. Right now, everything depends on everything else. Everything is separated into namespaces I created early on, but I don't think my method of separtion was very good. I'm trying to eliminate cases where an object depends on another object ...
[ { "answer_id": 207741, "author": "Seldaek", "author_id": 6512, "author_profile": "https://Stackoverflow.com/users/6512", "pm_score": 0, "selected": false, "text": "<p>What you might consider, but I guess I am no expert in the area, is to split the engine in two, a renderer and a location...
2008/10/16
[ "https://Stackoverflow.com/questions/207721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1103052/" ]
As I mention in an earlier question, I'm refactoring a project I'm working on. Right now, everything depends on everything else. Everything is separated into namespaces I created early on, but I don't think my method of separtion was very good. I'm trying to eliminate cases where an object depends on another object in ...
You seem to have two conflicting requirements: > > Inside GameName.Gui I > have a **MapView object that displays** a > Map and **any IRenderable** objects on it. > > > and > > But, the **MapView also needs the object > to implement ILocateable**, so it can > see its location and know when its > changed vi...
207,730
<p>I'm trying to create a C++ class, with a templated superclass. The idea being, I can easily create lots of similar subclasses from a number of superclasses which have similar characteristics.</p> <p>I have distilled the problematic code as follows:</p> <p><code>template_test.h</code>:</p> <pre><code>template&lt;c...
[ { "answer_id": 207743, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": true, "text": "<p>With templated classes, the definitions must be available for each translation unit that uses it. The definitions can go i...
2008/10/16
[ "https://Stackoverflow.com/questions/207730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17938/" ]
I'm trying to create a C++ class, with a templated superclass. The idea being, I can easily create lots of similar subclasses from a number of superclasses which have similar characteristics. I have distilled the problematic code as follows: `template_test.h`: ``` template<class BaseClass> class Templated : public B...
With templated classes, the definitions must be available for each translation unit that uses it. The definitions can go in a separate file, usually with `.inl` or `.tcc` extension; the header file `#include`s that file at the bottom. Thus, even though it's in a separate file, it's still `#include`d for each translatio...
207,734
<p>we can use <code>time</code> in a unix environment to see how long something took...</p> <pre><code>shell&gt; time some_random_command real 0m0.709s user 0m0.008s sys 0m0.012s </code></pre> <p>is there an equivalent for recording memory usage of the process(es)?</p> <p>in particular i'm interested in pe...
[ { "answer_id": 208346, "author": "Andy Whitfield", "author_id": 4805, "author_profile": "https://Stackoverflow.com/users/4805", "pm_score": 0, "selected": false, "text": "<p>Can you not use ps? e.g. <code>ps v &lt;pid&gt;</code> will return memory information.</p>\n" }, { "answer...
2008/10/16
[ "https://Stackoverflow.com/questions/207734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26094/" ]
we can use `time` in a unix environment to see how long something took... ``` shell> time some_random_command real 0m0.709s user 0m0.008s sys 0m0.012s ``` is there an equivalent for recording memory usage of the process(es)? in particular i'm interested in peak allocation.
Check the man page for time. You can specify a format string where it is possible to output memory information. For example: ``` >time -f"mem: %M" some_random_command mem: NNNN ``` will output maximum resident set size of the process during its lifetime, in Kilobytes.
207,768
<p>I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers:</p> <pre><code>void IndexArray( unsigned int length, std::vector&lt;unsigned int&gt;&amp; v ) { v.resize(length); for ( unsigned int i = 0; i &lt; length; ++i ) { v[i] = i; } } </code></pre> <p>But thi...
[ { "answer_id": 207777, "author": "moogs", "author_id": 26374, "author_profile": "https://Stackoverflow.com/users/26374", "pm_score": 5, "selected": true, "text": "<p>You can use the generate algorithm, for a more general way of filling up containers:</p>\n\n<pre><code>#include &lt;iostre...
2008/10/16
[ "https://Stackoverflow.com/questions/207768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19863/" ]
I know how to fill an std::vector with non-trivial initial values, e.g. sequence numbers: ``` void IndexArray( unsigned int length, std::vector<unsigned int>& v ) { v.resize(length); for ( unsigned int i = 0; i < length; ++i ) { v[i] = i; } } ``` But this is a for-loop. Is there an elegant wa...
You can use the generate algorithm, for a more general way of filling up containers: ``` #include <iostream> #include <algorithm> #include <vector> struct c_unique { int current; c_unique() {current=0;} int operator()() {return ++current;} } UniqueNumber; int main () { vector<int> myvector (8); generate...
207,800
<p>I am new to C and i have this question. why does the following code crash:</p> <pre><code>int *a = 10; *a = 100; </code></pre>
[ { "answer_id": 207807, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 4, "selected": false, "text": "<p>You need to assign the pointer to a <em>memory location</em>, not arbitrary value (10).</p>\n\n<pre><code>int cell = 10;\ni...
2008/10/16
[ "https://Stackoverflow.com/questions/207800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am new to C and i have this question. why does the following code crash: ``` int *a = 10; *a = 100; ```
Because you are trying to write 100 to the memory location 0x0000000A which is probably not allocated to your program. That is, ``` int *a = 10; ``` does not mean that the pointer 'a' will point to a location in memory having the value of 10. It means it is pointing to address 10 (0x0000000A) in the memory. Then, yo...
207,837
<p>In a <a href="https://stackoverflow.com/questions/190524/mapping-computed-properties-in-linq-to-sql-to-actuall-sql-statements">previous question</a> I asked how to make "Computed properties" in a linq to sql object. The answer supplied there was sufficient for that specific case but now I've hit a similar snag in an...
[ { "answer_id": 210106, "author": "David Alpert", "author_id": 8997, "author_profile": "https://Stackoverflow.com/users/8997", "pm_score": 0, "selected": false, "text": "<p>Check out <a href=\"/questions/209924/switch-statement-in-linq#210051\">my answer</a> to \"<a href=\"/questions/2099...
2008/10/16
[ "https://Stackoverflow.com/questions/207837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26746/" ]
In a [previous question](https://stackoverflow.com/questions/190524/mapping-computed-properties-in-linq-to-sql-to-actuall-sql-statements) I asked how to make "Computed properties" in a linq to sql object. The answer supplied there was sufficient for that specific case but now I've hit a similar snag in another case. I...
The problem is that CurrentStep is a normal method. Hence, the Expression contains a call to that method, and naturally SQL cannot execute arbitrary .NET methods. You will need to represent the code as an Expression. I have one in depth example here: <http://www.atrevido.net/blog/2007/09/06/Complicated+Functions+In+LI...
207,843
<p>I am using Eclipse 3.3 ("Europa"). Periodically, Eclipse takes an inordinately long time (perhaps forever) to start up. The only thing I can see in the Eclipse log is:</p> <pre> !ENTRY org.eclipse.core.resources 2 10035 2008-10-16 09:47:34.801 !MESSAGE The workspace exited with unsaved changes in the previo...
[ { "answer_id": 208148, "author": "Ruben", "author_id": 26919, "author_profile": "https://Stackoverflow.com/users/26919", "pm_score": 5, "selected": false, "text": "<p>You can try to start <code>Eclipse</code> first with the <code>-clean</code> option.</p>\n\n<p>On Windows you can add the...
2008/10/16
[ "https://Stackoverflow.com/questions/207843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4728/" ]
I am using Eclipse 3.3 ("Europa"). Periodically, Eclipse takes an inordinately long time (perhaps forever) to start up. The only thing I can see in the Eclipse log is: ``` !ENTRY org.eclipse.core.resources 2 10035 2008-10-16 09:47:34.801 !MESSAGE The workspace exited with unsaved changes in the previous sessi...
This may not be an exact solution for your issue, but in my case, I tracked the files that Eclipse was polling against with [SysInternals Procmon](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx), and found that Eclipse was constantly polling a fairly large snapshot file for one of my projects. Removed th...
207,851
<p>I want to create a Silverlight 2 control that has two content areas. A Title and a MainContent. So the control would be:</p> <pre><code>&lt;StackPanel&gt; &lt;TextBlock Text=" CONTENT1 "/&gt; &lt;Content with CONTENT2 "/&gt; &lt;/StackPanel&gt; </code></pre> <p>When I use the control I should just be able to use...
[ { "answer_id": 207895, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 0, "selected": false, "text": "<p>What you wanted is a Silverlight version of the WPF HeaderedContentControl\nYou can find a try here. <a href=\"http://le...
2008/10/16
[ "https://Stackoverflow.com/questions/207851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5189/" ]
I want to create a Silverlight 2 control that has two content areas. A Title and a MainContent. So the control would be: ``` <StackPanel> <TextBlock Text=" CONTENT1 "/> <Content with CONTENT2 "/> </StackPanel> ``` When I use the control I should just be able to use: ``` <MyControl Text="somecontent">main content </...
You can do that easily with the [ContentProperty](http://msdn.microsoft.com/en-us/library/system.windows.markup.contentpropertyattribute.aspx) attribute. Then you can define your code behind as: ``` [ContentProperty("Child")] public partial class MyControl: UserControl { public static readonly DependencyProperty ...
207,871
<p>I need to use utf-8 characters in my perl-documentation. If I use:</p> <pre><code>perldoc MyMod.pm </code></pre> <p>I see strange characters. If I use:</p> <pre><code>pod2text MyMod.pm </code></pre> <p>everything is fine.</p> <p>I use Ubuntu/Debian.</p> <pre><code>$ locale LANG=de_DE.UTF-8 LC_CTYPE="de_DE.UTF-...
[ { "answer_id": 208048, "author": "draegtun", "author_id": 12195, "author_profile": "https://Stackoverflow.com/users/12195", "pm_score": 3, "selected": false, "text": "<p>Found this RT ticket.... <a href=\"http://rt.cpan.org/Public/Bug/Display.html?id=39000\" rel=\"nofollow noreferrer\">h...
2008/10/16
[ "https://Stackoverflow.com/questions/207871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27239/" ]
I need to use utf-8 characters in my perl-documentation. If I use: ``` perldoc MyMod.pm ``` I see strange characters. If I use: ``` pod2text MyMod.pm ``` everything is fine. I use Ubuntu/Debian. ``` $ locale LANG=de_DE.UTF-8 LC_CTYPE="de_DE.UTF-8" LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_COLLATE="de_DE...
Use `=encoding utf-8` as the first POD directive in your file, and use a fairly recent `perldoc` (for example from 5.10-maint). Then it should work.
207,878
<p>I have the following code that sets a cookie:</p> <pre><code> string locale = ((DropDownList)this.LoginUser.FindControl("locale")).SelectedValue; HttpCookie cookie = new HttpCookie("localization",locale); cookie.Expires= DateTime.Now.AddYears(1); Response.Cookies.Set(cookie); </code></pre> <p>However, when...
[ { "answer_id": 207898, "author": "Aleris", "author_id": 20417, "author_profile": "https://Stackoverflow.com/users/20417", "pm_score": 7, "selected": true, "text": "<p>The check is done after a post back? If so you should read the cookie from the Request collection instead.</p>\n\n<p>The ...
2008/10/16
[ "https://Stackoverflow.com/questions/207878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1090/" ]
I have the following code that sets a cookie: ``` string locale = ((DropDownList)this.LoginUser.FindControl("locale")).SelectedValue; HttpCookie cookie = new HttpCookie("localization",locale); cookie.Expires= DateTime.Now.AddYears(1); Response.Cookies.Set(cookie); ``` However, when I try to read the cookie, ...
The check is done after a post back? If so you should read the cookie from the Request collection instead. The cookies are persisted to the browser by adding them to Response.Cookies and are read back from Request.Cookies. The cookies added to Response can be read only if the page is on the same request.
207,881
<p>I've a dialog which contains a Qt TabWidget with a number of tabs added. </p> <p>I'd like to hide one of the tabs. </p> <pre><code>_mytab-&gt;hide() </code></pre> <p>doesn't work. I don't want to just delete the tab and all its widgets from the .ui file because other code relies on the widgets within the tab. ...
[ { "answer_id": 208425, "author": "Jérôme", "author_id": 2796, "author_profile": "https://Stackoverflow.com/users/2796", "pm_score": 4, "selected": true, "text": "<p>I would use QTabDialog::removePage(QWidget* pTabPage) which does not delete pTabPage, which is what you want.</p>\n\n<pre><...
2008/10/16
[ "https://Stackoverflow.com/questions/207881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23434/" ]
I've a dialog which contains a Qt TabWidget with a number of tabs added. I'd like to hide one of the tabs. ``` _mytab->hide() ``` doesn't work. I don't want to just delete the tab and all its widgets from the .ui file because other code relies on the widgets within the tab. However, it would be fine to generate ...
I would use QTabDialog::removePage(QWidget\* pTabPage) which does not delete pTabPage, which is what you want. ``` _myTabDlg->removePage(_mytab); ``` I'm using it and it works fine !
207,888
<p>Greetings, </p> <p>I have a particular object which can be constructed from a file, as such:</p> <pre><code>public class ConfigObj { public ConfigObj(string loadPath) { //load object using .Net's supplied Serialization library //resulting in a ConfigObj object ConfigObj dese...
[ { "answer_id": 207894, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 1, "selected": false, "text": "<p>I always go with the static method. Usually it's kind of a hierarchy which is loaded, and therefore only the root o...
2008/10/16
[ "https://Stackoverflow.com/questions/207888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5021/" ]
Greetings, I have a particular object which can be constructed from a file, as such: ``` public class ConfigObj { public ConfigObj(string loadPath) { //load object using .Net's supplied Serialization library //resulting in a ConfigObj object ConfigObj deserializedObj = VoodooL...
Your second option is what is called a [factory method](http://en.wikipedia.org/wiki/Factory_method_pattern) and is a common design technique. If you do use this technique, you may find that you need to know the type of class you will load before you actually load the class. If you run into this situation, you can use ...
207,889
<p>I want this method to work for any given number of arguments, i can do that with code generation(with a lot of ugly code), can it be done with recursion? if so how? I understand recursion, but i dont know how to write this.</p> <pre><code>private static void allCombinations(List&lt;String&gt;... lists) { if (li...
[ { "answer_id": 207912, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Do you particularly need it to be recursive? I'd make it non-recursive but still not special case things:</p>\n\n<pre...
2008/10/16
[ "https://Stackoverflow.com/questions/207889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want this method to work for any given number of arguments, i can do that with code generation(with a lot of ugly code), can it be done with recursion? if so how? I understand recursion, but i dont know how to write this. ``` private static void allCombinations(List<String>... lists) { if (lists.length == 3) { ...
Here is a simple recursive implementation: ``` private static void allCombinations(List<String>... lists) { allCombinations(lists, 0, ""); } private static void allCombinations(List<String>[] lists, int index, String pre) { for (String s : lists[index]) { if (index < lists.length - 1) { allCombinations(...
207,901
<p>I have a databound <code>DataGridView</code>. When a new row is added and the user presses <kbd>Esc</kbd> I want to delete the entire row. How can I do this?</p>
[ { "answer_id": 207970, "author": "balexandre", "author_id": 28004, "author_profile": "https://Stackoverflow.com/users/28004", "pm_score": 3, "selected": false, "text": "<p>quite easy actually</p>\n\n<pre><code>private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)\n{\n ...
2008/10/16
[ "https://Stackoverflow.com/questions/207901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a databound `DataGridView`. When a new row is added and the user presses `Esc` I want to delete the entire row. How can I do this?
quite easy actually ``` private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)27) { if (dataGridView1.Rows.Count > 0) { dataGridView1.Rows.RemoveAt(dataGridView1.Rows.Count - 1); MessageBox.Show("Last row deleted!"); } ...
207,947
<p>How do I get a platform-dependent newline in Java? I can’t use <code>"\n"</code> everywhere.</p>
[ { "answer_id": 207950, "author": "abahgat", "author_id": 27565, "author_profile": "https://Stackoverflow.com/users/27565", "pm_score": 9, "selected": false, "text": "<p>You can use</p>\n\n<pre><code>System.getProperty(\"line.separator\");\n</code></pre>\n\n<p>to get the line separator</p...
2008/10/16
[ "https://Stackoverflow.com/questions/207947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
How do I get a platform-dependent newline in Java? I can’t use `"\n"` everywhere.
In addition to the line.separator property, if you are using java 1.5 or later and the **String.format** (or other **formatting** methods) you can use `%n` as in ``` Calendar c = ...; String s = String.format("Duke's Birthday: %1$tm %1$te,%1$tY%n", c); //Note `%n` at end of line ^^ S...
207,959
<p>I'm converting some Windows batch files to Unix scripts using sh. I have problems because some behavior is dependent on the %~dp0 macro available in batch files.</p> <p>Is there any sh equivalent to this? Any way to obtain the directory where the executing script lives?</p>
[ { "answer_id": 207961, "author": "Sarien", "author_id": 1994377, "author_profile": "https://Stackoverflow.com/users/1994377", "pm_score": 3, "selected": false, "text": "<p>Yes, you can! It's in the arguments. :)</p>\n\n<p>look at</p>\n\n<pre><code>${0}\n</code></pre>\n\n<p>combining that...
2008/10/16
[ "https://Stackoverflow.com/questions/207959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11628/" ]
I'm converting some Windows batch files to Unix scripts using sh. I have problems because some behavior is dependent on the %~dp0 macro available in batch files. Is there any sh equivalent to this? Any way to obtain the directory where the executing script lives?
The problem (for you) with `$0` is that it is set to whatever command line was use to invoke the script, not the location of the script itself. This can make it difficult to get the full path of the directory containing the script which is what you get from `%~dp0` in a Windows batch file. For example, consider the fo...
207,964
<p>I have a large query in a PostgreSQL database. The Query is something like this:</p> <pre><code>SELECT * FROM table1, table2, ... WHERE table1.id = table2.id... </code></pre> <p>When I run this query as a sql query, the it returns the wanted row.</p> <p>But when I tries to use the same query to create a view, it ...
[ { "answer_id": 208004, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "<p>That happens because a view would have two id named columns, one from table1 and one from table2, because of the s...
2008/10/16
[ "https://Stackoverflow.com/questions/207964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26567/" ]
I have a large query in a PostgreSQL database. The Query is something like this: ``` SELECT * FROM table1, table2, ... WHERE table1.id = table2.id... ``` When I run this query as a sql query, the it returns the wanted row. But when I tries to use the same query to create a view, it returns an error: "error: column...
That happens because a view would have two id named columns, one from table1 and one from table2, because of the select \*. You need to specify which id you want in the view. ``` SELECT table1.id, column2, column3, ... FROM table1, table2 WHERE table1.id = table2.id ``` The query works because it can have equally ...
207,965
<p>I came across a class instance function that needed to temporarily change a class instance variable, and then restore it when the function completed. The function had return statements all over the place, and before each return there was a restoring statement. That seemed messy to me, not to mention scary when a exc...
[ { "answer_id": 208026, "author": "Peter Kühne", "author_id": 27351, "author_profile": "https://Stackoverflow.com/users/27351", "pm_score": 0, "selected": false, "text": "<p>This is how I would do it as well. This way if the function throws, or returns early for some reason, your Restorer...
2008/10/16
[ "https://Stackoverflow.com/questions/207965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28524/" ]
I came across a class instance function that needed to temporarily change a class instance variable, and then restore it when the function completed. The function had return statements all over the place, and before each return there was a restoring statement. That seemed messy to me, not to mention scary when a except...
I revised the sample a bit more based on the comments, and placed as an Community Wiki answer instead of editing the question. ``` /// c++ code sample #ifndef UTIL_RESTORER_HPP #define UTIL_RESTORER_HPP namespace Utility { /// A Restorer instance ("inst") uses the stack to restore a saved /// value to the named var...
207,976
<p>I have a bunch of enum types in some library header files that I'm using, and I want to have a way of converting enum values to user strings - and vice-versa. </p> <p>RTTI won't do it for me, because the 'user strings' need to be a bit more readable than the enumerations.</p> <p>A brute force solution would be a b...
[ { "answer_id": 207985, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 4, "selected": false, "text": "<p>Auto-generate one form from another.</p>\n\n<p>Source:</p>\n\n<pre><code>enum {\n VALUE1, /* value 1 */\n VALUE2, /* value ...
2008/10/16
[ "https://Stackoverflow.com/questions/207976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737/" ]
I have a bunch of enum types in some library header files that I'm using, and I want to have a way of converting enum values to user strings - and vice-versa. RTTI won't do it for me, because the 'user strings' need to be a bit more readable than the enumerations. A brute force solution would be a bunch of functions...
If you want the enum names themselves as strings, see [this post](https://stackoverflow.com/questions/201593/is-there-a-simple-script-to-convert-c-enum-to-string#201792). Otherwise, a `std::map<MyEnum, char const*>` will work nicely. (No point in copying your string literals to std::strings in the map) For extra synta...
207,981
<p>I came across PHP way of doing the trick:</p> <pre><code>my_bool reconnect = 1; mysql_options(&amp;mysql, MYSQL_OPT_RECONNECT, &amp;reconnect); </code></pre> <p>but no luck with MySQLdb (python-mysql).</p> <p>Can anybody please give a clue? Thanks.</p>
[ { "answer_id": 210096, "author": "Paul D. Eden", "author_id": 3045, "author_profile": "https://Stackoverflow.com/users/3045", "pm_score": 4, "selected": false, "text": "<p>If you are using ubuntu Linux there was a patch added to the python-mysql package that added the ability to set that...
2008/10/16
[ "https://Stackoverflow.com/questions/207981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140995/" ]
I came across PHP way of doing the trick: ``` my_bool reconnect = 1; mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect); ``` but no luck with MySQLdb (python-mysql). Can anybody please give a clue? Thanks.
I solved this problem by creating a function that wraps the `cursor.execute()` method since that's what was throwing the `MySQLdb.OperationalError` exception. The other example above implies that it is the `conn.cursor()` method that throws this exception. ``` import MySQLdb class DB: conn = None def connect(sel...
207,994
<p>I'm having problems with cross theme compatibility in windows forms. If you don't set the font for a control on a windows form, it will use the system font with correct typeface and size. If you want to make the font <strong>bold</strong>, it hard codes in the rest of the system font values for the current theme y...
[ { "answer_id": 207996, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 3, "selected": true, "text": "<p>FFMPEG's libavcodec and libavformat are your friend. They're extremely versatile and support more than basically a...
2008/10/16
[ "https://Stackoverflow.com/questions/207994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15087/" ]
I'm having problems with cross theme compatibility in windows forms. If you don't set the font for a control on a windows form, it will use the system font with correct typeface and size. If you want to make the font **bold**, it hard codes in the rest of the system font values for the current theme you're programming ...
FFMPEG's libavcodec and libavformat are your friend. They're extremely versatile and support more than basically anything else, and are effectively the cross-platform standard for multimedia support and manipulation. You could also try MP4box's library, GPAC, which is an MP4-specific library that is much more powerful...
208,008
<p>F# declared namespace is not available in the c# project or visible through the object browser.</p> <p>I have built a normal F# library project, but even after i build the project and reference it to my C# project, I am unable to access the desired namespace.</p> <p>I am also unable to see it in the object browser...
[ { "answer_id": 212909, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>What if you reference the produced DLL directly (i.e., not via a project reference, but via a file reference)?</p>\n" }, ...
2008/10/16
[ "https://Stackoverflow.com/questions/208008", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18619/" ]
F# declared namespace is not available in the c# project or visible through the object browser. I have built a normal F# library project, but even after i build the project and reference it to my C# project, I am unable to access the desired namespace. I am also unable to see it in the object browser, i get an error ...
What if you reference the produced DLL directly (i.e., not via a project reference, but via a file reference)?
208,016
<p>Say I create an object thus:</p> <pre><code>var myObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}; </code></pre> <p>What is the best way to retrieve a list of the property names? i.e. I would like to end up with some variable 'keys' such that:</p> <pre><code>keys == ["ircEvent"...
[ { "answer_id": 208020, "author": "slashnick", "author_id": 21030, "author_profile": "https://Stackoverflow.com/users/21030", "pm_score": 11, "selected": true, "text": "<p>In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in <a href=\"https://developer.mo...
2008/10/16
[ "https://Stackoverflow.com/questions/208016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27929/" ]
Say I create an object thus: ``` var myObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"}; ``` What is the best way to retrieve a list of the property names? i.e. I would like to end up with some variable 'keys' such that: ``` keys == ["ircEvent", "method", "regex"] ```
In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in [Object.keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) method: ``` var keys = Object.keys(myObject); ``` The above has a full polyfill but a simplified version is: ``` var getK...
208,017
<p>I've got simple java-based ppt->swf sub-project that basically works. The open source software out there, <a href="http://www.openoffice.org/" rel="nofollow noreferrer">OpenOffice.org</a> and <a href="http://www.artofsolving.com/opensource/jodconverter" rel="nofollow noreferrer">JODConverter</a> do the job great.</...
[ { "answer_id": 208020, "author": "slashnick", "author_id": 21030, "author_profile": "https://Stackoverflow.com/users/21030", "pm_score": 11, "selected": true, "text": "<p>In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in <a href=\"https://developer.mo...
2008/10/16
[ "https://Stackoverflow.com/questions/208017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2961/" ]
I've got simple java-based ppt->swf sub-project that basically works. The open source software out there, [OpenOffice.org](http://www.openoffice.org/) and [JODConverter](http://www.artofsolving.com/opensource/jodconverter) do the job great. The thing is, to do this I need to install OO.o and run it in server mode. And...
In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in [Object.keys](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) method: ``` var keys = Object.keys(myObject); ``` The above has a full polyfill but a simplified version is: ``` var getK...
208,027
<p>and can it be configured not to happen?</p> <p>I'm usually finding myself saving a result of a query as a .csv and processing it later on my Unix machine. The characters being null separated makes me have to filter those chars and is a bit of a pain.</p> <p>So, these are the questions:</p> <ul> <li>Why is this so...
[ { "answer_id": 208029, "author": "David Wengier", "author_id": 489, "author_profile": "https://Stackoverflow.com/users/489", "pm_score": 4, "selected": true, "text": "<p>The file is being outputted in Unicode, not ASCII. Unicode uses twice as many bits to represent each character, hence ...
2008/10/16
[ "https://Stackoverflow.com/questions/208027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5190/" ]
and can it be configured not to happen? I'm usually finding myself saving a result of a query as a .csv and processing it later on my Unix machine. The characters being null separated makes me have to filter those chars and is a bit of a pain. So, these are the questions: * Why is this so? EDIT: Because it outputs...
The file is being outputted in Unicode, not ASCII. Unicode uses twice as many bits to represent each character, hence the preceding 00's. There might be an option to save as ANSI or ASCII, which should use 8 bit characters.
208,033
<p>I have a class which extends SWFLoader, I use it like a normal SWFLoader:</p> <pre><code>var loader:MySWFLoader = new MySWFLoader(); loader.load("myFile.SWF"); myScene.addChild(loader); </code></pre> <p>The loading works OK, except that it remains 0 because the width &amp; height never change from 0. I had to over...
[ { "answer_id": 208041, "author": "Gerald", "author_id": 19404, "author_profile": "https://Stackoverflow.com/users/19404", "pm_score": 0, "selected": false, "text": "<p>By default the SWFLoader scales the content to the size of the loader, so you have to set the size of the loader. If you...
2008/10/16
[ "https://Stackoverflow.com/questions/208033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
I have a class which extends SWFLoader, I use it like a normal SWFLoader: ``` var loader:MySWFLoader = new MySWFLoader(); loader.load("myFile.SWF"); myScene.addChild(loader); ``` The loading works OK, except that it remains 0 because the width & height never change from 0. I had to override the width/height get prop...
I'm not sure if this applies for SWF loading, but whenever I'm loading content, i cannot access width and height before the whole thing is loaded. So make an event listener that listens when the loading is completed, and then read the height/width. Also take a look at the loaderInfo class in AS3
208,038
<p>I'm looking for a way to selectively apply a CSS class to individual rows in a <code>GridView</code> based upon a property of the data bound item.</p> <p>e.g.:</p> <p>GridView's data source is a generic list of <code>SummaryItems</code> and <code>SummaryItem</code> has a property <code>ShouldHighlight</code>. When...
[ { "answer_id": 208067, "author": "balexandre", "author_id": 28004, "author_profile": "https://Stackoverflow.com/users/28004", "pm_score": 6, "selected": true, "text": "<p>very easy</p>\n\n<pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\n{\n if (...
2008/10/16
[ "https://Stackoverflow.com/questions/208038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3599/" ]
I'm looking for a way to selectively apply a CSS class to individual rows in a `GridView` based upon a property of the data bound item. e.g.: GridView's data source is a generic list of `SummaryItems` and `SummaryItem` has a property `ShouldHighlight`. When `ShouldHighlight == true` the CSS for the associated row sho...
very easy ``` protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drv = e.Row.DataItem as DataRowView; if (drv["ShouldHighlight"].ToString().ToLower() == "true") e.Row.CssClass = "highlighted";...
208,046
<p>I'm pretty new to regular expressions. I have a requirement to replace spaces in a piece of multi-line text. The replacement rules are these:</p> <ul> <li>Replace all spaces at start-of-line with a non-breaking space (<code>&amp;nbsp;</code>).</li> <li>Replace any instance of repeated spaces (more than one space to...
[ { "answer_id": 208076, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 4, "selected": true, "text": "<p>I'd guess that it would be easier to find each space and replace it. To do that, use \"look-ahead\" and \"look...
2008/10/16
[ "https://Stackoverflow.com/questions/208046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17981/" ]
I'm pretty new to regular expressions. I have a requirement to replace spaces in a piece of multi-line text. The replacement rules are these: * Replace all spaces at start-of-line with a non-breaking space (`&nbsp;`). * Replace any instance of repeated spaces (more than one space together) with the same number of non-...
I'd guess that it would be easier to find each space and replace it. To do that, use "look-ahead" and "look-behind" groups. Or, find a space (`\x20`) that is either lead by or followed by any single whitespace (`\s`); but, only replace the space. ``` $str = "asdasd asdasd asdas1\n asda234 4545 54\n 34545 345 34...
208,063
<p>I want to develop a website in ASP classic that uses HTTP Authentication against a database or password list that is under the control of the script. Ideally, the solution should involve no components or IIS settings as the script should be runnable in a hosted environment.</p> <p>Any clues/code deeply appreciated....
[ { "answer_id": 208195, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Hi are you trying to get a list of users from a database or use network based permissions on the HTTP server?</p>\n\n<p>If ...
2008/10/16
[ "https://Stackoverflow.com/questions/208063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24461/" ]
I want to develop a website in ASP classic that uses HTTP Authentication against a database or password list that is under the control of the script. Ideally, the solution should involve no components or IIS settings as the script should be runnable in a hosted environment. Any clues/code deeply appreciated.
It is possible to do HTTP Basic Authentication in pure classic ASP VBScript. You will need something to decode base 64. [Here is a pure VBScript implementation](http://www.motobit.com/tips/detpg_base64/). You will also need to make sure that in your IIS config you turn off "Basic authentication" and "Integrated Windo...
208,077
<p>If i can use</p> <pre><code>&lt;td&gt;&lt;textarea&gt;&lt;bean:write name="smlMoverDetailForm" property="empFDJoiningDate"/&gt; &lt;/textarea&gt;&lt;/td&gt; </code></pre> <p>to displace a value how can i use the struts tags to save a vaiable to the sesssion </p> <p>in sudo code</p> <pre><code>session.setAttribut...
[ { "answer_id": 271570, "author": "Fred", "author_id": 33630, "author_profile": "https://Stackoverflow.com/users/33630", "pm_score": 1, "selected": false, "text": "<p>I don't think so.\nStruts tags are only available in jsp pages.</p>\n\n<p>But you can do something like this:</p>\n\n<p>if...
2008/10/16
[ "https://Stackoverflow.com/questions/208077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If i can use ``` <td><textarea><bean:write name="smlMoverDetailForm" property="empFDJoiningDate"/> </textarea></td> ``` to displace a value how can i use the struts tags to save a vaiable to the sesssion in sudo code ``` session.setAttribute("test" , "<bean:write name="smlMoverDetailForm" property="empFDJoiningDa...
I don't think so. Struts tags are only available in jsp pages. But you can do something like this: if the bean smlMoverDetailForm is in scope request ``` session.setAttribute("test",((THECLASSOFTHEBEAN)request.getAttribute("smlMoverDetailForm")).getEmpFDJoiningDate()); ``` else if the bean smlMoverDetailForm is in...
208,084
<p>In Visual Studio 2008 (and others) when creating a .NET or silverlight application if you look at your project properties, it seems like you can only have one assembly name - across all configurations. I would like to compile my application as:</p> <p>MyAppDebug - in debug mode and just MyApp - in release mode</p> ...
[ { "answer_id": 208143, "author": "nruessmann", "author_id": 10329, "author_profile": "https://Stackoverflow.com/users/10329", "pm_score": 2, "selected": false, "text": "<p>Sure you can add a post-build event to rename the assembly. This will work if your solution has only one assembly.</...
2008/10/16
[ "https://Stackoverflow.com/questions/208084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
In Visual Studio 2008 (and others) when creating a .NET or silverlight application if you look at your project properties, it seems like you can only have one assembly name - across all configurations. I would like to compile my application as: MyAppDebug - in debug mode and just MyApp - in release mode Does anyone k...
I've managed to achieve what I was after by using a post-build script: ``` if "$(ConfigurationName)"=="Debug" goto debug "$(SolutionDir)ftp.bat" "$(TargetDir)$(TargetName).xap" :debug "$(SolutionDir)ftp.bat" "$(TargetDir)$(TargetName).xap" "$(TargetDir)$(TargetName)Debug.xap" ``` My ftp script basically accepts an o...
208,085
<pre><code>Apache/2.2.6 (Unix) DAV/2 mod_python/3.2.8 Python/2.4.4 configured ... </code></pre> <p>One of apache processes spawns some long-running python script asynchronously, and apparently doesn't seem to collect its child process table entry. After that long-run-in-subprocess python script finishes - defunct pyth...
[ { "answer_id": 208143, "author": "nruessmann", "author_id": 10329, "author_profile": "https://Stackoverflow.com/users/10329", "pm_score": 2, "selected": false, "text": "<p>Sure you can add a post-build event to rename the assembly. This will work if your solution has only one assembly.</...
2008/10/16
[ "https://Stackoverflow.com/questions/208085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/140995/" ]
``` Apache/2.2.6 (Unix) DAV/2 mod_python/3.2.8 Python/2.4.4 configured ... ``` One of apache processes spawns some long-running python script asynchronously, and apparently doesn't seem to collect its child process table entry. After that long-run-in-subprocess python script finishes - defunct python process has been...
I've managed to achieve what I was after by using a post-build script: ``` if "$(ConfigurationName)"=="Debug" goto debug "$(SolutionDir)ftp.bat" "$(TargetDir)$(TargetName).xap" :debug "$(SolutionDir)ftp.bat" "$(TargetDir)$(TargetName).xap" "$(TargetDir)$(TargetName)Debug.xap" ``` My ftp script basically accepts an o...
208,089
<p>I am using Spring Forms for my web application. For nested properties, the form tag generates the input elements having id / name in form of .</p> <p>For example, Person is the command class and Address is contained into its address field then the city element would be,</p> <pre><code>&lt;input type="text" id="add...
[ { "answer_id": 208116, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 5, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>$(\"#address\\\\.city\").val();\n</code></pre>\n\n<p>From <a href=\"http://docs.jquery.com/Selec...
2008/10/16
[ "https://Stackoverflow.com/questions/208089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959/" ]
I am using Spring Forms for my web application. For nested properties, the form tag generates the input elements having id / name in form of . For example, Person is the command class and Address is contained into its address field then the city element would be, ``` <input type="text" id="address**.**city" name="add...
Try this: ``` $("#address\\.city").val(); ``` From [the documentation](http://docs.jquery.com/Selectors): > > Note: if you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with two backslashes (`\`). For example: > > > ``` #foo\\:bar #foo\\[bar\...
208,105
<p>Given an object:</p> <pre><code>let myObject = { &quot;ircEvent&quot;: &quot;PRIVMSG&quot;, &quot;method&quot;: &quot;newURI&quot;, &quot;regex&quot;: &quot;^http://.*&quot; }; </code></pre> <p>How do I remove the property <code>regex</code> to end up with the following <code>myObject</code>?</p> <pre><code>le...
[ { "answer_id": 208106, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 14, "selected": true, "text": "<p>To remove a property from an object (mutating the object), you can do it like this:</p>\n<pre><code>delete myObject.regex;\...
2008/10/16
[ "https://Stackoverflow.com/questions/208105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27929/" ]
Given an object: ``` let myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; ``` How do I remove the property `regex` to end up with the following `myObject`? ``` let myObject = { "ircEvent": "PRIVMSG", "method": "newURI" }; ```
To remove a property from an object (mutating the object), you can do it like this: ``` delete myObject.regex; // or, delete myObject['regex']; // or, var prop = "regex"; delete myObject[prop]; ``` Demo ```js var myObject = { "ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*" }; delete myO...
208,119
<p>How can I launch an event that has accessors like this :</p> <pre><code>public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } </code></pre> <p>If it were a no...
[ { "answer_id": 208127, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "<p><del>You've got to invoke the underlying events directly. In your case, it looks as though this would be:</p>\n\n<...
2008/10/16
[ "https://Stackoverflow.com/questions/208119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5246/" ]
How can I launch an event that has accessors like this : ``` public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } ``` If it were a normal event I would launch ...
That event is just subscribing to and unsubscribing from another event. If you want your subscribers (and *only* your subscribers - not separate ones to the other event) to be invoked, you'll need to keep hold of your subscribers separately. For instance, you could change the code to something like: ``` private EventH...
208,120
<p>I want to write a program for this: In a folder I have <em>n</em> number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for <em>n</em> number of files. The program reads ...
[ { "answer_id": 208156, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 4, "selected": false, "text": "<pre><code>import sys\n\n# argv is your commandline arguments, argv[0] is your program name, so skip it\nfor n in...
2008/10/16
[ "https://Stackoverflow.com/questions/208120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451/" ]
I want to write a program for this: In a folder I have *n* number of files; first read one file and perform some operation then store result in a separate file. Then read 2nd file, perform operation again and save result in new 2nd file. Do the same procedure for *n* number of files. The program reads all files one by ...
``` import sys # argv is your commandline arguments, argv[0] is your program name, so skip it for n in sys.argv[1:]: print(n) #print out the filename we are currently processing input = open(n, "r") output = open(n + ".out", "w") # do some processing input.close() output.close() ``` Then call...
208,133
<p>By default the SQL Server comes with the Langauge set to "English (United States)", setting the date format to mm/dd/yy instead of the date format I want it in, which is Australian and has a date format such as dd/mm/yy.</p> <p>Is there an option in the Server Management Studio / Configuration tools where I can set...
[ { "answer_id": 208168, "author": "balexandre", "author_id": 28004, "author_profile": "https://Stackoverflow.com/users/28004", "pm_score": 0, "selected": false, "text": "<p>have no idea what is the format in \"down under\" </p>\n\n<p>dd/mm/yyyy hh:mm:ss ?</p>\n\n<p>if yes, that date is th...
2008/10/16
[ "https://Stackoverflow.com/questions/208133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20900/" ]
By default the SQL Server comes with the Langauge set to "English (United States)", setting the date format to mm/dd/yy instead of the date format I want it in, which is Australian and has a date format such as dd/mm/yy. Is there an option in the Server Management Studio / Configuration tools where I can set the local...
You can set the default language/locale of each user from SQL Management Studio (look under the Security folder). And override this for a specific connection using the SET LANGUAGE command (or SET DATEFORMAT if you just want to change the date format). You can also set the default language (used for new users) in SQ...
208,151
<p>I have a checkbox list control on my asp.net web form that I am dynamically populating from an arraylist. In javascript I want to be able to iterate through the values in the list and if a particular value has been selected to display other controls on the page. </p> <p>My issue is that all the values in the checkb...
[ { "answer_id": 208167, "author": "Dylan Beattie", "author_id": 5017, "author_profile": "https://Stackoverflow.com/users/5017", "pm_score": 2, "selected": false, "text": "<p><code>options[i].checked</code> will return true or false.\n<code>options[i].value</code> will give you the value a...
2008/10/16
[ "https://Stackoverflow.com/questions/208151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1076/" ]
I have a checkbox list control on my asp.net web form that I am dynamically populating from an arraylist. In javascript I want to be able to iterate through the values in the list and if a particular value has been selected to display other controls on the page. My issue is that all the values in the checkbox list ar...
I realised after much playing about with prerender events that I didn't actually need to know the exact value of the checkbox as the arraylist values would be in the same order as the checkboxes. I searched through the arraylist to get the position of the value that I needed and then used that position on the list of c...
208,181
<p>How do I do <code>mv original.filename new.original.filename</code> without retyping the original filename?</p> <p>I would imagine being able to do something like <code>mv -p=new. original.filename</code> or perhaps <code>mv original.filename new.~</code> or whatever - but I can't see anything like this after looki...
[ { "answer_id": 208192, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 2, "selected": false, "text": "<p>If it's open to a modification, you could use a suffix instead of a prefix. Then you could use tab-completion to get t...
2008/10/16
[ "https://Stackoverflow.com/questions/208181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9360/" ]
How do I do `mv original.filename new.original.filename` without retyping the original filename? I would imagine being able to do something like `mv -p=new. original.filename` or perhaps `mv original.filename new.~` or whatever - but I can't see anything like this after looking at `man mv` / `info mv` pages. Of cours...
In Bash and zsh you can do this with [Brace Expansion](http://www.gnu.org/software/bash/manual/bashref.html#Brace-Expansion). This simply expands a list of items in braces. For example: ``` # echo {vanilla,chocolate,strawberry}-ice-cream vanilla-ice-cream chocolate-ice-cream strawberry-ice-cream ``` So you can do yo...
208,186
<p>I'm using a web service that returns a dataset. in this dataset there are 5 table, let's say table A, B, C, D, E. I use table A.</p> <p>So </p> <pre><code>DataTable dt = new DataTable() dt = dataset.Table["A"] </code></pre> <p>Now in this datatable there are columns a1,a2,a3,a4,a5,a6,a7.</p> <p>Let's say I only ...
[ { "answer_id": 208201, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 5, "selected": true, "text": "<p>Ignore the fact that you have more data than you need. Set <code>AutoGenerateColumns</code> to <code>false</code>. Create <c...
2008/10/16
[ "https://Stackoverflow.com/questions/208186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
I'm using a web service that returns a dataset. in this dataset there are 5 table, let's say table A, B, C, D, E. I use table A. So ``` DataTable dt = new DataTable() dt = dataset.Table["A"] ``` Now in this datatable there are columns a1,a2,a3,a4,a5,a6,a7. Let's say I only want to get columns a3 and a4 then bind ...
Ignore the fact that you have more data than you need. Set `AutoGenerateColumns` to `false`. Create `BoundColumns` for `a3` and `a4`.
208,231
<p>I want to use the java.util.Preferences API but I don't want my program to attempt to read or write to the Windows registry. How would I go about this?</p>
[ { "answer_id": 208264, "author": "Ruben", "author_id": 26919, "author_profile": "https://Stackoverflow.com/users/26919", "pm_score": 2, "selected": false, "text": "<p>It is always possible to extend java.util.prefs.AbstractPreferences.</p>\n\n<p>An alternative could be to use The <a href...
2008/10/16
[ "https://Stackoverflow.com/questions/208231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I want to use the java.util.Preferences API but I don't want my program to attempt to read or write to the Windows registry. How would I go about this?
I trust you have read the [read/write to Windows Registry using Java](https://stackoverflow.com/questions/62289/readwrite-to-windows-registry-using-java) and you then want to have another back-end than the registry when using the `java.util.Preferences` API You could extend the [`Preference` API](http://blogs.oracle.c...
208,234
<p>I have a form that kicks off a Response.Redirect to download a file once complete. I also want to hide the form and show a 'thank you' panel before the redirect takes place, however it seems the asp.net engine just does the redirect without doing the 2 tasks before in the following code:</p> <pre><code>if (success...
[ { "answer_id": 208247, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>Maybe sending a Redirect Header manually, with a number of seconds to wait is the way to go for you?</p>\n\n<pre><code>...
2008/10/16
[ "https://Stackoverflow.com/questions/208234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21969/" ]
I have a form that kicks off a Response.Redirect to download a file once complete. I also want to hide the form and show a 'thank you' panel before the redirect takes place, however it seems the asp.net engine just does the redirect without doing the 2 tasks before in the following code: ``` if (success) ...
``` if (success) { lblSuccessMessage.Text = _successMessage; showMessage(true); } else { lblSuccessMessage.Text = _failureMessage; showMessage(false); ...
208,254
<p>I've just started with opengl but I ran into some strange behaviour.</p> <p>Below I posted code that runs well in xp but on vista it renders just black screen.</p> <p>Sorry for posting unusally (as for this board) long code.</p> <p>Is there something very specific to open gl in vista? Thanks.</p> <pre><code>#inc...
[ { "answer_id": 208318, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Try <code>PFD_SUPPORT_COMPOSITION</code>.</p>\n\n<p>If that fails, please post the result of <code>DescribePixelFormat</cod...
2008/10/16
[ "https://Stackoverflow.com/questions/208254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25587/" ]
I've just started with opengl but I ran into some strange behaviour. Below I posted code that runs well in xp but on vista it renders just black screen. Sorry for posting unusally (as for this board) long code. Is there something very specific to open gl in vista? Thanks. ``` #include<windows.h> #include<gl\gl.h> #...
What is it supposed to do? According to the code you posted there, it shouldn't do anything except show a black screen. What do you expect to happen? The only thing I see is that you're setting glClearColor, but you're never calling glClear so that won't do anything.
208,261
<p>Ok, so I want to get a webapp running in tomcat (5.5) to run behind apache 2 (2.2.3 to be precise) serving from the root of the site (i.e. without the context), with static content being served via apache.</p> <p>So if the app is running under "<code>/myapp</code>" on tomcat I want to use apache (plus <code>mod_rew...
[ { "answer_id": 208407, "author": "Leonel Martins", "author_id": 26673, "author_profile": "https://Stackoverflow.com/users/26673", "pm_score": -1, "selected": false, "text": "<p>We use the 'R' flag instead of 'PT':</p>\n\n<pre><code>RewriteRule ^/(.*)$ /myapp/$1 [L,R]\n</code></pre>\n\n<p...
2008/10/16
[ "https://Stackoverflow.com/questions/208261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5868/" ]
Ok, so I want to get a webapp running in tomcat (5.5) to run behind apache 2 (2.2.3 to be precise) serving from the root of the site (i.e. without the context), with static content being served via apache. So if the app is running under "`/myapp`" on tomcat I want to use apache (plus `mod_rewrite`) to make it behave a...
Managed to get this working in the end. It appears that I need to set a JkOption to: ``` JkOptions +ForwardURICompat ``` And then `mod_jk` looks at the rewritten URL. Must admit not 100% sure quite why this works, but I believe it's reverting to an older form of behaviour. If anyone can tell me a better/more co...
208,262
<p>I've created a jQuery wee plugin for myself which takes care of showing, hiding and submitting a form to give in-place editing. Currently I have several of these on a page which function independently and I am happy. However, I'm thinking that an 'Edit All' might be useful. I'd therefore want to be able to access al...
[ { "answer_id": 208284, "author": "jammus", "author_id": 984, "author_profile": "https://Stackoverflow.com/users/984", "pm_score": 0, "selected": false, "text": "<p>Hmmm I guess I could create an array of instances...</p>\n\n<pre><code>var plugins = new Array();\n\nplugins.push($('first_e...
2008/10/16
[ "https://Stackoverflow.com/questions/208262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/984/" ]
I've created a jQuery wee plugin for myself which takes care of showing, hiding and submitting a form to give in-place editing. Currently I have several of these on a page which function independently and I am happy. However, I'm thinking that an 'Edit All' might be useful. I'd therefore want to be able to access all i...
Use the custom events in jQuery to make this easy. Something like this: ``` (function($) { $.fn.myPlugin = function() { return this.each(function(){ //Plugin Code Goes Here $(this).bind("pluginEdit",function(){ internalEditFunction(); ...
208,263
<p>I have a dev and a UAT environments. Dev is in our place, UAT is in client's place.</p> <p>Our DEV machine is a XEON 4 core @2,33GHz, 4Go RAM with Windows server 2003 The UAT physical machine is quite the same but a virtual machine is used (under VMWare). I don't know the exact parameters used for this VM.</p> <...
[ { "answer_id": 208284, "author": "jammus", "author_id": 984, "author_profile": "https://Stackoverflow.com/users/984", "pm_score": 0, "selected": false, "text": "<p>Hmmm I guess I could create an array of instances...</p>\n\n<pre><code>var plugins = new Array();\n\nplugins.push($('first_e...
2008/10/16
[ "https://Stackoverflow.com/questions/208263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28544/" ]
I have a dev and a UAT environments. Dev is in our place, UAT is in client's place. Our DEV machine is a XEON 4 core @2,33GHz, 4Go RAM with Windows server 2003 The UAT physical machine is quite the same but a virtual machine is used (under VMWare). I don't know the exact parameters used for this VM. The problem is ...
Use the custom events in jQuery to make this easy. Something like this: ``` (function($) { $.fn.myPlugin = function() { return this.each(function(){ //Plugin Code Goes Here $(this).bind("pluginEdit",function(){ internalEditFunction(); ...
208,272
<p>I have seen this macro defined before but never really knew its purpose. Can anyone shed light on this?</p>
[ { "answer_id": 208364, "author": "Brian Knoblauch", "author_id": 15689, "author_profile": "https://Stackoverflow.com/users/15689", "pm_score": 0, "selected": false, "text": "<p>I've seen things like that before as part of testing. If it <em>is</em> executed, then you know that you have ...
2008/10/16
[ "https://Stackoverflow.com/questions/208272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
I have seen this macro defined before but never really knew its purpose. Can anyone shed light on this?
This is a compiler intrinsic used for optimization, typically seen in embedded programming. The only time I have seen it used is in the "default" for a switch statement to assert that the variable has a limited range (for better optimization). Example: ``` /* Get DTMF index */ switch(dtmf) { case '0': cas...
208,316
<p>How can I tell if an App is ASP.NET 2.0 or ASP.NET 1.1. This is in C#</p> <p>I don't have the source code and I don't have access to IIS Manager. But I can ftp and check the ASPX files. Any Ideas?</p>
[ { "answer_id": 208319, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 4, "selected": true, "text": "<p>if you can get an error message to show it will tell you at the bottom of the page what version of the framework is in ...
2008/10/16
[ "https://Stackoverflow.com/questions/208316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
How can I tell if an App is ASP.NET 2.0 or ASP.NET 1.1. This is in C# I don't have the source code and I don't have access to IIS Manager. But I can ftp and check the ASPX files. Any Ideas?
if you can get an error message to show it will tell you at the bottom of the page what version of the framework is in use. or, if you could upload a file, you could upload an aspx page containing code to output the framework version: ``` <%@ Page Language="C#" EnableSessionState="False" EnableViewState="False" Trace...
208,345
<p>I am trying to use JMockit's code coverage abilities. Using the JVM parameter</p> <pre><code>-javaagent:jmockit.jar=coverage=.*MyClass.java:html:: </code></pre> <p>I am able to run my tests (jmockit.jar and coverage.jar are on the classpath), unfortunately my log file says:</p> <pre><code>Loaded external tool: mo...
[ { "answer_id": 208502, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 1, "selected": false, "text": "<p>Random guess... Is coverage.jar on the classpath that jmockit uses - it might be a different one?</p>\n" }, {...
2008/10/16
[ "https://Stackoverflow.com/questions/208345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I am trying to use JMockit's code coverage abilities. Using the JVM parameter ``` -javaagent:jmockit.jar=coverage=.*MyClass.java:html:: ``` I am able to run my tests (jmockit.jar and coverage.jar are on the classpath), unfortunately my log file says: ``` Loaded external tool: mockit.coverage.CodeCoverage=.*MyClass....
I was running the test with JUnit 3, but the coverage needs JUnit 4. That fixed things, and I didn't have to add any bootstrap entries.
208,355
<p>This is a follow up from this <a href="https://stackoverflow.com/questions/198087/how-do-i-list-installed-msi-from-the-command-line">question</a>.</p> <p>I'm using this slightly modified script to enumerate all installed MSI packages:</p> <pre><code>strComputer = "." Set objWMIService = GetObject("winmgmts:" &amp...
[ { "answer_id": 208454, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 1, "selected": false, "text": "<p>I suspected a network issue and Wireshark proved me right.</p>\n\n<p>It seems that Windows Installer happily attempts to ...
2008/10/16
[ "https://Stackoverflow.com/questions/208355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11892/" ]
This is a follow up from this [question](https://stackoverflow.com/questions/198087/how-do-i-list-installed-msi-from-the-command-line). I'm using this slightly modified script to enumerate all installed MSI packages: ``` strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=imperso...
Extreme slowness is a known/common problem for enumerating Win32\_Products If you need an alternate solution, consider building your own list of products using the 'Uninstall' registry entries (as suggested in one of the answers to the [original question](https://stackoverflow.com/questions/198087/how-do-i-list-instal...
208,368
<p>How can I set the font used by the FLVPlaybackCaptioning component for subtitles? Using the style property of the textarea does nothing, and using a TextFormat makes the text go blank, even though the font had been embedded.</p>
[ { "answer_id": 208585, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 3, "selected": true, "text": "<p>It seems the font, as well as the other properties of the text, are specified in the XML file where the subtitles are read ...
2008/10/16
[ "https://Stackoverflow.com/questions/208368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
How can I set the font used by the FLVPlaybackCaptioning component for subtitles? Using the style property of the textarea does nothing, and using a TextFormat makes the text go blank, even though the font had been embedded.
It seems the font, as well as the other properties of the text, are specified in the XML file where the subtitles are read (this is from the [documentation](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlaybackCaptioning.html)): ``` <?xml version="1.0" encoding="UTF-8"?> <tt xml:lang="en" xm...
208,373
<p>We need to write unit tests for a <em>wxWidgets</em> application using <em>Google Test Framework</em>. The problem is that <em>wxWidgets</em> uses the macro <strong>IMPLEMENT_APP(MyApp)</strong> to initialize and enter the application main loop. This macro creates several functions including <strong>int main()</stro...
[ { "answer_id": 209757, "author": "Ber", "author_id": 11527, "author_profile": "https://Stackoverflow.com/users/11527", "pm_score": -1, "selected": false, "text": "<p>You could possibly turn the situation around:</p>\n\n<p>Initialize and start the wxPython app including the main loop, the...
2008/10/16
[ "https://Stackoverflow.com/questions/208373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446104/" ]
We need to write unit tests for a *wxWidgets* application using *Google Test Framework*. The problem is that *wxWidgets* uses the macro **IMPLEMENT\_APP(MyApp)** to initialize and enter the application main loop. This macro creates several functions including **int main()**. The google test framework also uses macro de...
You want to use the function: ``` bool wxEntryStart(int& argc, wxChar **argv) ``` instead of wxEntry. It doesn't call your app's OnInit() or run the main loop. You can call `wxTheApp->CallOnInit()` to invoke OnInit() when needed in your tests. You'll need to use ``` void wxEntryCleanup() ``` when you're done.
208,397
<p>When importing forms in access using loadfromtext, I continually get a runtime error 2285. Searching the internet shows many people with the same problem, yet no solutions. Does anyone know what causes this bug?</p> <p><strong>Edit:</strong> In addition a file called 'errors.txt' is created in the folder containing...
[ { "answer_id": 208845, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 1, "selected": false, "text": "<p>There are problems with SP3, have you applied the hotfix?</p>\n\n<p><a href=\"http://support.microsoft.com/default.aspx...
2008/10/16
[ "https://Stackoverflow.com/questions/208397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6874/" ]
When importing forms in access using loadfromtext, I continually get a runtime error 2285. Searching the internet shows many people with the same problem, yet no solutions. Does anyone know what causes this bug? **Edit:** In addition a file called 'errors.txt' is created in the folder containing the database. **Edit:...
This problem is related to errors occuring for users of the Access Source Code Control Integration. The solution can be found here: <http://support.microsoft.com/kb/927680> "This issue occurs if the Access default file type differs from the file type for the Access database that is in the Visual SourceSafe project." ...
208,404
<p>Are C# enums typesafe?</p> <p>If not what are the implications? </p>
[ { "answer_id": 208412, "author": "Simon Keep", "author_id": 1127460, "author_profile": "https://Stackoverflow.com/users/1127460", "pm_score": 4, "selected": false, "text": "<p>Yes they are.</p>\n\n<p>The following is from <a href=\"http://www.csharp-station.com/Tutorials/Lesson17.aspx\" ...
2008/10/16
[ "https://Stackoverflow.com/questions/208404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24773/" ]
Are C# enums typesafe? If not what are the implications?
To give a slightly different answer... while the values are type-safe from the casting perspective, they are still unchecked once they have been cast - i.e. ``` enum Foo { A = 1, B = 2, C = 3 } static void Main() { Foo foo = (Foo)500; // works fine Console.WriteLine(foo); // also fine - shows 500 } ``` F...