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
161,056
<p>Is there a CSS editor which automatically expands one-line declarations as multi-line declarations on focus ? To clarify my thought, see example below:</p> <p>Original CSS:</p> <pre><code>div#main { color: orange; margin: 1em 0; border: 1px solid black; } </code></pre> <p>But when focusing on it, editor automatic...
[ { "answer_id": 161079, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 0, "selected": false, "text": "<p>Sorry. I don't know of any IDEs that explicitly do that.</p>\n\n<p>But, there are quite a few external option...
2008/10/02
[ "https://Stackoverflow.com/questions/161056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a CSS editor which automatically expands one-line declarations as multi-line declarations on focus ? To clarify my thought, see example below: Original CSS: ``` div#main { color: orange; margin: 1em 0; border: 1px solid black; } ``` But when focusing on it, editor automatically expands it to: ``` div#main...
If you are using Visual Studio you should be able to do a close approximation of this: 1. You can change how CSS is formatted via the Tools -> Options menu. 2. Check 'Show all settings' if it is unchecked. 3. Go to Text Editor -> CSS -> Format and pick the semi-expanded option 4. Ok you changes. 5. Then `ctrl+A`, `ctr...
161,064
<p>I'm running autoconf and configure sets SHELL to '/bin/sh'. This creates huge problems. How to force SHELL to be '/bin/bash' for autoconf?</p> <p>I'm trying to get this running on osx, it's working on linux. Linux is using SHELL=/bin/bash. osx defaults to /bin/sh.</p>
[ { "answer_id": 161070, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": -1, "selected": false, "text": "<p><code>ln -f /bin/bash /bin/sh</code></p>\n\n<p>:-P (No, it's not a serious answer. Please don't hose your system by doin...
2008/10/02
[ "https://Stackoverflow.com/questions/161064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15054/" ]
I'm running autoconf and configure sets SHELL to '/bin/sh'. This creates huge problems. How to force SHELL to be '/bin/bash' for autoconf? I'm trying to get this running on osx, it's working on linux. Linux is using SHELL=/bin/bash. osx defaults to /bin/sh.
I have similar problems on Solaris with GCC - and I use the 'standard' technique: ``` CONFIG_SHELL=/bin/bash ./configure ... ``` (Or, actually, I use /bin/ksh, but setting the CONFIG\_SHELL env var allows you to tell autoconf scripts which shell to use.) I checked the configure script for git and gd (they happened ...
161,084
<p>I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post.</p> <p>I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below</p> <p>I would really like ...
[ { "answer_id": 161092, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://www.google.com/search?client=safari&amp;rls=en-us&amp;q=parse+.ini+vb+.net&amp;ie=UTF-8&amp;oe=UTF-8\" rel...
2008/10/02
[ "https://Stackoverflow.com/questions/161084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I was just wondering if anyone knew of a good way that I could parse the file at the bottom of the post. I have a database setup with the correct tables for each section eg Refferal Table,Caller Table,Location Table. Each table has the same columns that are show in the file below I would really like something that is...
[Google has the answers](http://www.google.com/search?client=safari&rls=en-us&q=parse+.ini+vb+.net&ie=UTF-8&oe=UTF-8), once you know that the file-format is called '.ini' **Edit:** That is, it's an .ini plus some extra leading/trailing gunk.
161,093
<p>I have a table that looks like that:</p> <p><img src="https://i.stack.imgur.com/R0TIr.jpg" alt="alt text"></p> <p>The rows are sorted by CLNDR_DATE DESC.</p> <p>I need to find a CLNDR_DATE that corresponds to the highlighted row, in other words:<br> Find the topmost group of rows WHERE EFFECTIVE_DATE IS NOT NULL,...
[ { "answer_id": 161105, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 4, "selected": true, "text": "<p>Warning: Not a DBA by any means. ;)</p>\n\n<p>But, a quick, untested stab at it:</p>\n\n<pre><code>SELECT min(...
2008/10/02
[ "https://Stackoverflow.com/questions/161093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10557/" ]
I have a table that looks like that: ![alt text](https://i.stack.imgur.com/R0TIr.jpg) The rows are sorted by CLNDR\_DATE DESC. I need to find a CLNDR\_DATE that corresponds to the highlighted row, in other words: Find the topmost group of rows WHERE EFFECTIVE\_DATE IS NOT NULL, and return the CLNR\_DATE of a last...
Warning: Not a DBA by any means. ;) But, a quick, untested stab at it: ``` SELECT min(CLNDR_DATE) FROM [TABLE] WHERE (EFFECTIVE_DATE IS NOT NULL) AND (CLNDR_DATE > ( SELECT max(CLNDR_DATE) FROM [TABLE] WHERE EFFECTIVE_DATE IS NULL )) ``` Assuming you want the **first** CLNDR\_DATE **with** EFFECTIVE\_DATE a...
161,108
<p>I've been developing web applications for a while and i am quite comfortable with mySql, in fact as many do i use some form of SQL almost every day. I like the syntax and a have zero problems writing queries or optimizing my tables. I have enjoyed this mysql <a href="http://www.tmtm.org/en/mysql/ruby/" rel="nofoll...
[ { "answer_id": 161135, "author": "Erik Forbes", "author_id": 16942, "author_profile": "https://Stackoverflow.com/users/16942", "pm_score": 1, "selected": false, "text": "<p>The idea here is that by putting your DB logic inside your Active Records, you're dealing with SQL code in one plac...
2008/10/02
[ "https://Stackoverflow.com/questions/161108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18159/" ]
I've been developing web applications for a while and i am quite comfortable with mySql, in fact as many do i use some form of SQL almost every day. I like the syntax and a have zero problems writing queries or optimizing my tables. I have enjoyed this mysql [api](http://www.tmtm.org/en/mysql/ruby/). The thing that ha...
You're right that hiding the SQL behind ActiveRecord's layer means people might forget to check the generated SQL. I've been bitten by this myself: missing indexes, inefficient queries, etc. What ActiveRecord allows is making the easy things easy: ``` Post.find(1) ``` vs ``` SELECT * FROM posts WHERE posts.id = 1 ...
161,127
<p>We have a scenario where we want to display a list of items and indicate which is the "current" item (with a little arrow marker or a changed background colour).</p> <p>ItemsControl is no good to us, because we need the context of "SelectedItem". However, we want to move the selection programattically and not allow...
[ { "answer_id": 161232, "author": "Mark Glorie", "author_id": 952, "author_profile": "https://Stackoverflow.com/users/952", "pm_score": 1, "selected": false, "text": "<p>Is your ItemsControl/ListBox databound? </p>\n\n<p>I'm just thinking you could make the Background Brush of each item ...
2008/10/02
[ "https://Stackoverflow.com/questions/161127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/615/" ]
We have a scenario where we want to display a list of items and indicate which is the "current" item (with a little arrow marker or a changed background colour). ItemsControl is no good to us, because we need the context of "SelectedItem". However, we want to move the selection programattically and not allow the user ...
One option is to set `ListBoxItem.IsEnabled` to `false`: ``` <ListBox x:Name="_listBox"> <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="IsEnabled" Value="False"/> </Style> </ListBox.ItemContainerStyle> </ListBox> ``` This ensures that the items are...
161,166
<p>Currently I'm trying to erase a sequence of iterators from a set, however GCC's standard library seems to be broken because std::set::erase(iterator) should return the an iterator (next iterator), however in GCC it returns void (which is standard?)</p> <p>Anyways I want to write:</p> <pre><code>myIter = mySet.eras...
[ { "answer_id": 161239, "author": "Camille", "author_id": 16990, "author_profile": "https://Stackoverflow.com/users/16990", "pm_score": 4, "selected": true, "text": "<p>There is no problem with </p>\n\n<pre><code>mySet.erase(myIter++);\n</code></pre>\n\n<p>The order of operation is well-d...
2008/10/02
[ "https://Stackoverflow.com/questions/161166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
Currently I'm trying to erase a sequence of iterators from a set, however GCC's standard library seems to be broken because std::set::erase(iterator) should return the an iterator (next iterator), however in GCC it returns void (which is standard?) Anyways I want to write: ``` myIter = mySet.erase(myIter); ``` But ...
There is no problem with ``` mySet.erase(myIter++); ``` The order of operation is well-defined: myIter is copied into myTempIter, myIter is incremented, and myTempIter is then given to the erase method. **For Greg and Mark**: no, there is no way operator++ can perform operations after the call to erase. By definit...
161,176
<p>I am working on an ASP site hosted using SUN One (used to be called Chillisoft) server. I am having trouble loading in an XML file, the code I am using is below</p> <pre><code>dim directory set directory = Server.CreateObject("MSXML2.DOMDocument") if(directory.load(Server.MapPath("directory.xml"))) then Respo...
[ { "answer_id": 161245, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 1, "selected": false, "text": "<p>I don't know much about Sun One but I do know it has a Bean that emulates MSXML.</p>\n\n<p>Oridinarily, you would...
2008/10/02
[ "https://Stackoverflow.com/questions/161176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on an ASP site hosted using SUN One (used to be called Chillisoft) server. I am having trouble loading in an XML file, the code I am using is below ``` dim directory set directory = Server.CreateObject("MSXML2.DOMDocument") if(directory.load(Server.MapPath("directory.xml"))) then Response.Write("Loa...
I don't know much about Sun One but I do know it has a Bean that emulates MSXML. Oridinarily, you would use:- ``` Set directory = Server.CreateObject("MSXML2.DOMDocument") directory.async = false directory.load(Server.MapPath("directory.xml") ``` Otherwise load returns immeadiately whilst the xml is loaded asynchro...
161,177
<p>Does C++ support '<a href="http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html" rel="noreferrer"><strong>finally</strong></a>' blocks?</p> <p>What is the <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer"><strong>RAII idiom</strong></a>?</p> <p>What...
[ { "answer_id": 161179, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 8, "selected": false, "text": "<p>No, C++ does not support 'finally' blocks. The reason is that C++ instead supports RAII: \"Resource Acquisition Is Initial...
2008/10/02
[ "https://Stackoverflow.com/questions/161177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6386/" ]
Does C++ support '[**finally**](http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html)' blocks? What is the [**RAII idiom**](http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization)? What is the difference between C++'s RAII idiom and [**C#'s 'using' statement**](http://www.c-sharpcorn...
No, C++ does not support 'finally' blocks. The reason is that C++ instead supports RAII: "Resource Acquisition Is Initialization" -- a *poor name***†** for a really useful concept. The idea is that an object's destructor is responsible for freeing resources. When the object has automatic storage duration, the object'...
161,222
<p>I've been using maven2 and hudson for a while to do my continuous integration, but I find that Eclipse and Maven do not play well together. Sure there's a plugin, but it's cranky to mash the maven project into something that eclipse likes and the build times and unit test are too long. I'm considering switching back...
[ { "answer_id": 161476, "author": "Valters Vingolds", "author_id": 885, "author_profile": "https://Stackoverflow.com/users/885", "pm_score": 2, "selected": false, "text": "<p>Yeah, Eclipse Maven2 plugin is crap for now. But I would suggest for you to hang in there, there is a lot of benef...
2008/10/02
[ "https://Stackoverflow.com/questions/161222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17554/" ]
I've been using maven2 and hudson for a while to do my continuous integration, but I find that Eclipse and Maven do not play well together. Sure there's a plugin, but it's cranky to mash the maven project into something that eclipse likes and the build times and unit test are too long. I'm considering switching back to...
I managed find a good solution. I simply got infinitest (can be installed from the Eclipse marketplace) to work when using maven and eclipse In Eclipse->Project Properties->Java Build Path->Source uncheck the box called: "Allow output folders for source folders" That will enable your project to have more than one out...
161,238
<p>As I understand it, the command to ignore the <em>content</em> of a directory using SVN is this:</p> <pre><code>svn propset svn:ignore "*" tmp/ </code></pre> <p>This should set the ignore property on the content of the <code>tmp</code> directory, right? In other words, the wildcard is set to be the ignore value on...
[ { "answer_id": 161250, "author": "Matthias Winkelmann", "author_id": 4494, "author_profile": "https://Stackoverflow.com/users/4494", "pm_score": 0, "selected": false, "text": "<p>Try it without the trailing slash. Also, the tmp directory itself has to be added to the repository.</p>\n" ...
2008/10/02
[ "https://Stackoverflow.com/questions/161238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944/" ]
As I understand it, the command to ignore the *content* of a directory using SVN is this: ``` svn propset svn:ignore "*" tmp/ ``` This should set the ignore property on the content of the `tmp` directory, right? In other words, the wildcard is set to be the ignore value on the tmp directory. Trouble is, here's what ...
The command ***should*** be working as you expect. The `*` is getting globbed, which it shouldn't be doing. So, you're running: `svn propset svn:ignore [value] app config db doc lib log nbproject public ... tmp` (since app was the first folder affected, I'm guessing there's another folder before it). 2 things y...
161,252
<p>I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do:</p> <pre><code>forloop { //this part is actually written in perl //call command sequence print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`; } </code></pre> <p>The part between backticks (``...
[ { "answer_id": 161284, "author": "GavinCattell", "author_id": 21644, "author_profile": "https://Stackoverflow.com/users/21644", "pm_score": 4, "selected": false, "text": "<pre><code>for command in $commands\ndo\n \"$command\" &amp;\ndone\nwait\n</code></pre>\n\n<p>The ampersand at the...
2008/10/02
[ "https://Stackoverflow.com/questions/161252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23780/" ]
I'm trying to run some commands in paralel, in background, using bash. Here's what I'm trying to do: ``` forloop { //this part is actually written in perl //call command sequence print `touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;`; } ``` The part between backticks (``) spawns a new shell and e...
I haven't tested this but how about ``` print `(touch .file1.lock; cp bigfile1 /destination; rm .file1.lock;) &`; ``` The parentheses mean execute in a subshell but that shouldn't hurt.
161,348
<p>Given the following:</p> <pre><code>#light //any function returning bool * 'a let foo = let x = ref 10 fun () -&gt; x := !x - 1 if !x &lt;&gt; 0 then (true, x) else (false, x) while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinen...
[ { "answer_id": 161344, "author": "MrValdez", "author_id": 1599, "author_profile": "https://Stackoverflow.com/users/1599", "pm_score": 4, "selected": true, "text": "<p>I found a library in google code: <a href=\"http://code.google.com/p/php-email-address-validation/\" rel=\"noreferrer\">h...
2008/10/02
[ "https://Stackoverflow.com/questions/161348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21182/" ]
Given the following: ``` #light //any function returning bool * 'a let foo = let x = ref 10 fun () -> x := !x - 1 if !x <> 0 then (true, x) else (false, x) while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinent. //this is how I wan...
I found a library in google code: <http://code.google.com/p/php-email-address-validation/> Are there any others?
161,388
<p>I'm using @media print in my external css file to hide menus etc. However while printing the little triangle of a dropdownlist still shows. Is there a css setting available to hide it as well and only print the selected item?</p>
[ { "answer_id": 161414, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https://Stackoverflow.com/users/6615", "pm_score": 1, "selected": false, "text": "<p>No, there isn't. Besides, every browser displays its dropdowns in its own way, some use system widgets, some have the...
2008/10/02
[ "https://Stackoverflow.com/questions/161388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using @media print in my external css file to hide menus etc. However while printing the little triangle of a dropdownlist still shows. Is there a css setting available to hide it as well and only print the selected item?
This works in Chrome and Firefox (others may work also) ``` -moz-appearance: none; -webkit-appearance: none; appearance: none; ```
161,398
<p>I'm possibly just stupid, but I'm trying to find a user in Active Directory from C#, using the Login name ("domain\user").</p> <p>My "Skeleton" AD Search Functionality looks like this usually:</p> <pre><code>de = new DirectoryEntry(string.Format("LDAP://{0}", ADSearchBase), null, null, AuthenticationTypes.Secure);...
[ { "answer_id": 161719, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 4, "selected": true, "text": "<p>You need to set a filter (DirectorySearcher.Filter) something like:</p>\n\n<p>\"(&amp;(objectCategory=person)(objectClass=us...
2008/10/02
[ "https://Stackoverflow.com/questions/161398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
I'm possibly just stupid, but I'm trying to find a user in Active Directory from C#, using the Login name ("domain\user"). My "Skeleton" AD Search Functionality looks like this usually: ``` de = new DirectoryEntry(string.Format("LDAP://{0}", ADSearchBase), null, null, AuthenticationTypes.Secure); ds = new DirectorySe...
You need to set a filter (DirectorySearcher.Filter) something like: "(&(objectCategory=person)(objectClass=user)(sAMAccountName={0}))" Note that you only specify the username (without the domain) for the property sAMAccountName. To search for domain\user, first locate the naming context for the required domain, then ...
161,399
<p>I have a control where I have to check in which page I am, so I can set a certain variable accordingly.</p> <pre><code>string pageName = this.Page.ToString(); switch (pageName) { case "ASP.foo_bar_aspx": doSomething(); break; default: doSomethingElse(); break; } </code></pre> <p>this works fine locally and on some...
[ { "answer_id": 161409, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "<p>That seems like a really dodgy way of getting the current request. Have you tried using <code>HttpContext.Current.Request.F...
2008/10/02
[ "https://Stackoverflow.com/questions/161399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15981/" ]
I have a control where I have to check in which page I am, so I can set a certain variable accordingly. ``` string pageName = this.Page.ToString(); switch (pageName) { case "ASP.foo_bar_aspx": doSomething(); break; default: doSomethingElse(); break; } ``` this works fine locally and on some developmentservers, howev...
You cant rely on auto generated names. Use types instead, eg: ``` if (Page is FooBar) { ... } ```
161,404
<p>I have three tables, A, B, C, where A is many to one B, and B is many to one C. I'd like a list of all C's in A. </p> <p>My tables are something like this: A[id, valueA, lookupB], B[id, valueB, lookupC], C[id, valueC]. I've written a query with two nested SELECTs, but I'm wondering if it's possible to do INNER JOIN...
[ { "answer_id": 161423, "author": "kristian", "author_id": 20377, "author_profile": "https://Stackoverflow.com/users/20377", "pm_score": 1, "selected": false, "text": "<p>Is this what you mean?</p>\n\n<pre><code>SELECT DISTINCT C.valueC\nFROM \nC\nINNER JOIN B ON C.id = B.lookupC\nINNER J...
2008/10/02
[ "https://Stackoverflow.com/questions/161404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2973/" ]
I have three tables, A, B, C, where A is many to one B, and B is many to one C. I'd like a list of all C's in A. My tables are something like this: A[id, valueA, lookupB], B[id, valueB, lookupC], C[id, valueC]. I've written a query with two nested SELECTs, but I'm wondering if it's possible to do INNER JOIN with DIST...
I did a test on MS SQL 2005 using the following tables: A 400K rows, B 26K rows and C 450 rows. The estimated query plan indicated that the basic inner join would be 3 times slower than the nested sub-queries, however when actually running the query, the basic inner join was twice as fast as the nested queries, The ba...
161,427
<p>I'm trying to understand how hibernate query cache really works. What I see now is that Hibernate does not update its second-level cache automatically when I insert new entities into the database (although I'm using only Hibernate calls). The only way I have found to make it work was to manually clean the cache aft...
[ { "answer_id": 166517, "author": "bernardn", "author_id": 21548, "author_profile": "https://Stackoverflow.com/users/21548", "pm_score": 1, "selected": false, "text": "<p>Hibernate stores data from queries by using a key composed of the query (or query name) and the value of the specified...
2008/10/02
[ "https://Stackoverflow.com/questions/161427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to understand how hibernate query cache really works. What I see now is that Hibernate does not update its second-level cache automatically when I insert new entities into the database (although I'm using only Hibernate calls). The only way I have found to make it work was to manually clean the cache after ...
You might find my blog on query cache workings to be helpful in understanding what the query cache does and why it might not work the way you think it works: * <http://tech.puredanger.com/2009/07/10/hibernate-query-cache/>
161,432
<p>Imagine the following type:</p> <pre><code>public struct Account { public int Id; public double Amount; } </code></pre> <p>What is the best algorithm to synchronize two <code>IList&lt;Account&gt;</code> in C# 2.0 ? (No linq) ?</p> <p>The first list (L1) is the reference list, the second (L2) is the one to...
[ { "answer_id": 161441, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>For a start I'd get rid of the mutable struct. Mutable value types are a fundamentally bad thing. (As are public fiel...
2008/10/02
[ "https://Stackoverflow.com/questions/161432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
Imagine the following type: ``` public struct Account { public int Id; public double Amount; } ``` What is the best algorithm to synchronize two `IList<Account>` in C# 2.0 ? (No linq) ? The first list (L1) is the reference list, the second (L2) is the one to synchronize according to the first: * All accoun...
For a start I'd get rid of the mutable struct. Mutable value types are a fundamentally bad thing. (As are public fields, IMO.) It's probably worth building a Dictionary so you can easily compare the contents of the two lists. Once you've got that easy way of checking for presence/absence, the rest should be straightfo...
161,443
<p>In Kohana/CodeIgniter, I can have a URL in this form:</p> <pre><code>http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... </code></pre> <p>And then read the parameters in my controller as follows:</p> <pre><code>class MyController { public function method_name($param_A, $pa...
[ { "answer_id": 161636, "author": "Andrew Taylor", "author_id": 1776, "author_profile": "https://Stackoverflow.com/users/1776", "pm_score": 4, "selected": false, "text": "<p>Take a look at the Zend_Controller_Router classes:</p>\n\n<p><a href=\"http://framework.zend.com/manual/en/zend.con...
2008/10/02
[ "https://Stackoverflow.com/questions/161443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
In Kohana/CodeIgniter, I can have a URL in this form: ``` http://www.name.tld/controller_name/method_name/parameter_1/parameter_2/parameter_3 ... ``` And then read the parameters in my controller as follows: ``` class MyController { public function method_name($param_A, $param_B, $param_C ...) { //...
**Update (04/13/2016):** The link in my answer below moved and has been fixed. However, just in case it disappears again -- here are a few alternatives that provide some in depth information on this technique, as well as use the original article as reference material: * [Zend Framework Controller Actions with Function...
161,462
<p>I'm using <code>org.w3c</code> <code>XML API</code> to open an existing <code>XML</code> file. I'm removing some nodes , and I'm adding others instead.</p> <p>The problem is that the new nodes that are added are written one after the other, with no newline and no indentation what so ever. While it's true that the <...
[ { "answer_id": 161478, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 7, "selected": true, "text": "<p>I'm assuming that you're using a <a href=\"http://java.sun.com/javase/6/docs/api/javax/xml/transform/Transformer.html\" re...
2008/10/02
[ "https://Stackoverflow.com/questions/161462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
I'm using `org.w3c` `XML API` to open an existing `XML` file. I'm removing some nodes , and I'm adding others instead. The problem is that the new nodes that are added are written one after the other, with no newline and no indentation what so ever. While it's true that the `XML` file is valid , it is very hard for a ...
I'm assuming that you're using a [`Transformer`](http://java.sun.com/javase/6/docs/api/javax/xml/transform/Transformer.html) to do the actual writing (to a [`StreamResult`](http://java.sun.com/javase/6/docs/api/javax/xml/transform/stream/StreamResult.html)). In which case, do this before you call `transform`: ``` tran...
161,474
<p>My basic question is, in .NET, how do I clone WebControls?</p> <p>I would like to build a custom tag, which can produce multiple copies of its children. Ultimately I intend to build a tag similar to in JSP/Struts.</p> <p>But the first hurdle I have is the ability to duplicate/clone the contents of a control.</p> ...
[ { "answer_id": 161526, "author": "csgero", "author_id": 21764, "author_profile": "https://Stackoverflow.com/users/21764", "pm_score": 0, "selected": false, "text": "<p>The way to do this in ASP.NET is using templates. There are samples in MSDN for this, just look for templated controls /...
2008/10/02
[ "https://Stackoverflow.com/questions/161474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24232/" ]
My basic question is, in .NET, how do I clone WebControls? I would like to build a custom tag, which can produce multiple copies of its children. Ultimately I intend to build a tag similar to in JSP/Struts. But the first hurdle I have is the ability to duplicate/clone the contents of a control. Consider this rather ...
What's wrong with using a Repeater and binding a dud data source. It'll duplicate the templated controls and handle the ID creation and all.
161,477
<p>Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I've done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the following:</p> <pre><code>class GenericClass&lt;T&gt; { public event EventHandler&lt;EventData&gt; MyEvent; ...
[ { "answer_id": 161484, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 10, "selected": true, "text": "<p>No, there's no true equivalent of typedef. You can use 'using' directives within one file, e.g.</p>\n\n<pre><code>usi...
2008/10/02
[ "https://Stackoverflow.com/questions/161477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I've done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the following: ``` class GenericClass<T> { public event EventHandler<EventData> MyEvent; public class EventData : ...
No, there's no true equivalent of typedef. You can use 'using' directives within one file, e.g. ``` using CustomerList = System.Collections.Generic.List<Customer>; ``` but that will only impact that source file. In C and C++, my experience is that `typedef` is usually used within .h files which are included widely -...
161,485
<p>How should I configure the class to bind three dropdowns (date, month, year) to a single Date property so that it works the way it works for 'single request parameter per property' scenario ? I guess a should add some custom PropertyEditors by overriding initBinder method. What else ?</p>
[ { "answer_id": 161514, "author": "miceuz", "author_id": 24443, "author_profile": "https://Stackoverflow.com/users/24443", "pm_score": 1, "selected": false, "text": "<p>You could create a hidden input in your form and populate it using JavaScript when user selects date, then bind to this ...
2008/10/02
[ "https://Stackoverflow.com/questions/161485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
How should I configure the class to bind three dropdowns (date, month, year) to a single Date property so that it works the way it works for 'single request parameter per property' scenario ? I guess a should add some custom PropertyEditors by overriding initBinder method. What else ?
Aleksey Kudryavtsev: you can override the onBind method in your controller, i which you cant fiddle something special in command object, like ``` dateField = new SimpleFormat("YYYY-mm-dd").parse(this.year + "-" + this.month + "-" this.day); ``` or: ``` Calendar c = Calendar.getInstance(); c.set(year, month, day); ...
161,486
<p>I developing ASP.NET application using a Swedish version of Windows XP and Visual studio Professional. When ever i get an error aka. "yellow screen of death" the error message is in swedish, making it a bit hard to search for info about it.</p> <p>How can i change what language the error messages in ASP.NET uses?</...
[ { "answer_id": 161496, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 1, "selected": true, "text": "<p>Aren't the error messages dependent on the installed .NET Framework? I.e. you could just uninstall the Swedish langu...
2008/10/02
[ "https://Stackoverflow.com/questions/161486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20368/" ]
I developing ASP.NET application using a Swedish version of Windows XP and Visual studio Professional. When ever i get an error aka. "yellow screen of death" the error message is in swedish, making it a bit hard to search for info about it. How can i change what language the error messages in ASP.NET uses? I have no ...
Aren't the error messages dependent on the installed .NET Framework? I.e. you could just uninstall the Swedish language pack for .NET. On the production server, you'll most likely have an English-only Framework anyway.
161,490
<p>I am currently porting a lot of code from an MFC-based application to a DLL for client branding purposes.</p> <p>I've come across an unusual problem. This bit of code is the same in both systems:</p> <pre><code>// ... CCommsProperties props; pController-&gt;GetProperties( props ); if (props.handshake ...
[ { "answer_id": 161564, "author": "user22044", "author_id": 22044, "author_profile": "https://Stackoverflow.com/users/22044", "pm_score": 1, "selected": false, "text": "<p>It is difficult to see what is wrong from the given code alone. Some general pointers:</p>\n\n<ol>\n<li><p>The object...
2008/10/02
[ "https://Stackoverflow.com/questions/161490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342/" ]
I am currently porting a lot of code from an MFC-based application to a DLL for client branding purposes. I've come across an unusual problem. This bit of code is the same in both systems: ``` // ... CCommsProperties props; pController->GetProperties( props ); if (props.handshake != HANDSHAKE_RTS_CTS) ...
After Saratv posting, I decided to ditch what I had done and restart it from working source again. This time however it works...I guess I will never know why passing a structure caused it to change.
161,510
<p>In Ruby, is it possible to pass by reference a parameter with value-type semantics (e.g. a Fixnum)? I'm looking for something similar to C#'s '<strong>ref</strong>' keyword.</p> <p>Example:</p> <pre><code>def func(x) x += 1 end a = 5 func(a) #this should be something like func(ref a) puts a #should read '...
[ { "answer_id": 161589, "author": "Christoph Schiessl", "author_id": 20467, "author_profile": "https://Stackoverflow.com/users/20467", "pm_score": 4, "selected": false, "text": "<p>Ruby doesn't support \"pass by reference\" at all. Everything is an object and the references to those objec...
2008/10/02
[ "https://Stackoverflow.com/questions/161510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11545/" ]
In Ruby, is it possible to pass by reference a parameter with value-type semantics (e.g. a Fixnum)? I'm looking for something similar to C#'s '**ref**' keyword. Example: ``` def func(x) x += 1 end a = 5 func(a) #this should be something like func(ref a) puts a #should read '6' ``` Btw. I know I could just ...
You can accomplish this by explicitly passing in the current binding: ``` def func(x, bdg) eval "#{x} += 1", bdg end a = 5 func(:a, binding) puts a # => 6 ```
161,519
<p>I use Visual Basic and an automation interface to retrieve strings from an external application. These strings contain simple html formatting codes (&lt;b&gt;, &lt;i&gt;, etc.). Is there any easy function in Visual Basic for Word to insert these strings into a word document and convert the html formatting codes to w...
[ { "answer_id": 161699, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 0, "selected": false, "text": "<p>AFAIK there is no builtin function to do that in VBA. You will have to write it yourself, which would be not too difficult...
2008/10/02
[ "https://Stackoverflow.com/questions/161519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I use Visual Basic and an automation interface to retrieve strings from an external application. These strings contain simple html formatting codes (<b>, <i>, etc.). Is there any easy function in Visual Basic for Word to insert these strings into a word document and convert the html formatting codes to word formatting?
Here's a link to add HTML to the clipboard using VB: <http://support.microsoft.com/kb/274326> Once you have the HTML on the clipboard, paste it into your word doc using something like this: ``` ActiveDocument.Range.PasteSpecial ,,,,WdPasteDataType.wdPasteHTML ``` This is pretty much the equivalent of you cutting a...
161,524
<p>I'm writing a query for an application that needs to list all the products with the number of times they have been purchased.</p> <p>I came up with this and it works, but I am not too sure how optimized it is. My SQL is really rusty due to my heavy usage of ORM's, But in this case a query is a much more elegant sol...
[ { "answer_id": 161533, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 1, "selected": false, "text": "<p>Does it give you the right answer?</p>\n\n<p>Except for just modifying it to get rid of the SELECT in the inner qu...
2008/10/02
[ "https://Stackoverflow.com/questions/161524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1877/" ]
I'm writing a query for an application that needs to list all the products with the number of times they have been purchased. I came up with this and it works, but I am not too sure how optimized it is. My SQL is really rusty due to my heavy usage of ORM's, But in this case a query is a much more elegant solution. Ca...
I'm not sure about the "(SELECT \*" ... business. This executes (always a good start) and I think is equivalent to what was posted. ``` SELECT products.id, products.long_name AS name, count(oi.order_id) AS sold FROM products LEFT OUTER JOIN orderitems AS oi INNER JOIN orders ...
161,531
<p>This seems to be a common problem but I cannot find a solution.</p> <p>I type in my username and password which are in a login control I have created. I then press enter once I've typed in my password and the page just refreshes. It triggers the page load event but not the button on click event.</p> <p>If I press ...
[ { "answer_id": 161547, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 0, "selected": false, "text": "<p>Pressing ENTER on a text input executes <strong>Form.onsubmit</strong>, not <strong>Button.onclick</strong>.<...
2008/10/02
[ "https://Stackoverflow.com/questions/161531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1469/" ]
This seems to be a common problem but I cannot find a solution. I type in my username and password which are in a login control I have created. I then press enter once I've typed in my password and the page just refreshes. It triggers the page load event but not the button on click event. If I press the submit button...
using your forms default button is correct, but you need to supply it the correct id as it will be rendered to HTML. so you do as Jon said above: ``` <form runat="server" DefaultButton="SubmitButton"> ``` But ensure you use the Button name that will be rendered. You can achieve this my making the Button public in y...
161,539
<p>Imagine the following Ruby Module:</p> <pre><code>module Foo def inst_method puts "Called Foo.inst_method" end def self.class_method puts "Called Foo.class_method" end end </code></pre> <p>Obviously <code>Foo.class_method</code> can be called without any class instances. However, what's happening t...
[ { "answer_id": 161618, "author": "Jean", "author_id": 7898, "author_profile": "https://Stackoverflow.com/users/7898", "pm_score": 2, "selected": false, "text": "<p>My answer would be : \"no you can't call module instance methods without first extending or including that module in a class...
2008/10/02
[ "https://Stackoverflow.com/questions/161539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467/" ]
Imagine the following Ruby Module: ``` module Foo def inst_method puts "Called Foo.inst_method" end def self.class_method puts "Called Foo.class_method" end end ``` Obviously `Foo.class_method` can be called without any class instances. However, what's happening to `Foo.inst_method`? Is it possible t...
The primary purpose of instance methods within modules is to give that functionality to classes that include it. "Mixing in" a module this way is most commonly used as a method of simulating [multiple inheritance](http://en.wikipedia.org/wiki/Multiple_inheritance), or in other situations where inheritance is not the r...
161,549
<p>I recently had to rename a table (and a column and FK/PK contraints) in SQL Server 2000 without losing an data. There did not seem to be an obvious DDL T-SQL statements for performing this action, so I used sp_rename to directly fiddle with object names.</p> <p>Was this the only solution to the problem? (other, tha...
[ { "answer_id": 161557, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 4, "selected": false, "text": "<p>sp_rename is the correct way to do it.</p>\n\n<pre><code>EXEC sp_rename 'Old_TableName', 'New_TableName'\n</code></pre>...
2008/10/02
[ "https://Stackoverflow.com/questions/161549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23497/" ]
I recently had to rename a table (and a column and FK/PK contraints) in SQL Server 2000 without losing an data. There did not seem to be an obvious DDL T-SQL statements for performing this action, so I used sp\_rename to directly fiddle with object names. Was this the only solution to the problem? (other, than give th...
sp\_rename is the correct way to do it. ``` EXEC sp_rename 'Old_TableName', 'New_TableName' ```
161,556
<p>I've got a Method that gets a IDictionary as a parameter. Now I want to provide a method that retrieves the value from this dictionary, but it should be case-invariant.</p> <p>So my solution to this right now was to have a static function that loops through the keys and converts them toLower() like this:</p> <pre>...
[ { "answer_id": 161565, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>Yes - pass the Dictionary constructor <code>StringComparer.OrdinalIgnoreCase</code> (or another case-ignoring comparer...
2008/10/02
[ "https://Stackoverflow.com/questions/161556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
I've got a Method that gets a IDictionary as a parameter. Now I want to provide a method that retrieves the value from this dictionary, but it should be case-invariant. So my solution to this right now was to have a static function that loops through the keys and converts them toLower() like this: ``` private static ...
Yes - pass the Dictionary constructor `StringComparer.OrdinalIgnoreCase` (or another case-ignoring comparer, depending on your culture-sensitivity needs).
161,614
<p>I need to get the Class of an object at runtime.</p> <p>For an non-abstract class I could do something like:</p> <pre><code>public class MyNoneAbstract{ public static Class MYNONEABSTRACT_CLASS = new MyNoneAbstract().getClass(); </code></pre> <p>But for an abstract class this does NOT work (always gives me <c...
[ { "answer_id": 161625, "author": "skaffman", "author_id": 21234, "author_profile": "https://Stackoverflow.com/users/21234", "pm_score": 3, "selected": true, "text": "<p>You just need</p>\n\n<pre><code>MyAbstract.class\n</code></pre>\n\n<p>That expression returns the Class object represen...
2008/10/02
[ "https://Stackoverflow.com/questions/161614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/180142/" ]
I need to get the Class of an object at runtime. For an non-abstract class I could do something like: ``` public class MyNoneAbstract{ public static Class MYNONEABSTRACT_CLASS = new MyNoneAbstract().getClass(); ``` But for an abstract class this does NOT work (always gives me `Object`) ``` public abstract clas...
You just need ``` MyAbstract.class ``` That expression returns the Class object representing MyAbstract.
161,631
<p>I have a rails app that is working fine except for one thing.</p> <p>When I request something that doesn't exist (i.e. /not_a_controller_or_file.txt) and rails throws a "No Route matches..." exception, the response is this (blank line intentional):</p> <pre><code>HTTP/1.1 200 OK Date: Thu, 02 Oct 2008 10:28:02 GMT...
[ { "answer_id": 161689, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 1, "selected": false, "text": "<p>This html file is coming from Rails. It is encountering some sort of error (probably an exception of some kind...
2008/10/02
[ "https://Stackoverflow.com/questions/161631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
I have a rails app that is working fine except for one thing. When I request something that doesn't exist (i.e. /not\_a\_controller\_or\_file.txt) and rails throws a "No Route matches..." exception, the response is this (blank line intentional): ``` HTTP/1.1 200 OK Date: Thu, 02 Oct 2008 10:28:02 GMT Content-Type: te...
This is a fairly old thread, but for what it's worth I found a great resource that includes a detailed description of the problem and the solution. Apparently this bug affects Rails < 2.3 when used with Mongrel. * [The article that helped me understand the problem](http://billkirtley.wordpress.com/2009/03/03/failsafe-...
161,639
<p>I have two overloads of a c++ function and I would like to set a breakpoint on one of them:</p> <pre><code>0:000&gt; bu myexe!displayerror Matched: 00000000`ff3c6100 myexe!displayError (int, HRESULT, wchar_t *) Matched: 00000000`ff3c60d0 myexe!displayError (int, HRESULT) Ambiguous symbol error at 'myexe!displayerro...
[ { "answer_id": 161658, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>bu 0xff3c6100\n</code></pre>\n\n<p>If I remember right, WinDbg allows setting breakpoints by addre...
2008/10/02
[ "https://Stackoverflow.com/questions/161639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15071/" ]
I have two overloads of a c++ function and I would like to set a breakpoint on one of them: ``` 0:000> bu myexe!displayerror Matched: 00000000`ff3c6100 myexe!displayError (int, HRESULT, wchar_t *) Matched: 00000000`ff3c60d0 myexe!displayError (int, HRESULT) Ambiguous symbol error at 'myexe!displayerror' ``` Heck I w...
Try: ``` bu 0xff3c6100 ``` If I remember right, WinDbg allows setting breakpoints by address too.
161,654
<p>This is a subjective question as I want to gauge if it's worth me moaning at my co-workers for doing something which I find utterly detestable.</p> <p>The issue is that a bunch of my co-workers will truncate method calls to fit a width. We all use widescreen laptops that can handle large resolutions (mine is 1920x1...
[ { "answer_id": 161670, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Maybe you should have as part of your standard build process some sort of checkstyle plugin which checks for exactly that k...
2008/10/02
[ "https://Stackoverflow.com/questions/161654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6414/" ]
This is a subjective question as I want to gauge if it's worth me moaning at my co-workers for doing something which I find utterly detestable. The issue is that a bunch of my co-workers will truncate method calls to fit a width. We all use widescreen laptops that can handle large resolutions (mine is 1920x1200) and w...
Maybe you should have as part of your standard build process some sort of checkstyle plugin which checks for exactly that kind of thing? If you've agreed the standard with your co-workers it seems reasonable to ask them to keep to it. I personally find the second of the two options the more readable, but that's just b...
161,655
<p>Consider the following subversion directory structure</p> <p>/dir1/file.txt</p> <p>/dir2/file.txt</p> <p>I want to move the file.txt in dir1 to replace the same file in dir2 and ensure that the history for the dir1 file is maintained. I don't care about the history of original dir2 file.</p> <p>Is this possible ...
[ { "answer_id": 161668, "author": "Richard Harrison", "author_id": 19624, "author_profile": "https://Stackoverflow.com/users/19624", "pm_score": 4, "selected": true, "text": "<p>Firstly you should never consider hacking the backend - it negates the point of using SVN in the first place.</...
2008/10/02
[ "https://Stackoverflow.com/questions/161655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445016/" ]
Consider the following subversion directory structure /dir1/file.txt /dir2/file.txt I want to move the file.txt in dir1 to replace the same file in dir2 and ensure that the history for the dir1 file is maintained. I don't care about the history of original dir2 file. Is this possible using subversion commands and n...
Firstly you should never consider hacking the backend - it negates the point of using SVN in the first place. I don't see why you couldn't just do ``` svn rm /dir2/file.txt svn mv /dir1/file.txt /dir2/file.txt ``` the history of the file will follow it after the move.
161,666
<p>I'm trying to learn scheme via SICP. Exercise 1.3 reads as follow: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. Please comment on how I can improve my solution.</p> <pre><code>(define (big x y) (if (&gt; x y) x y)) (define (p a b c) ...
[ { "answer_id": 161674, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": true, "text": "<p>Looks ok to me, is there anything specific you want to improve on?</p>\n\n<p>You could do something like:</p>\n\n<pre><co...
2008/10/02
[ "https://Stackoverflow.com/questions/161666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
I'm trying to learn scheme via SICP. Exercise 1.3 reads as follow: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. Please comment on how I can improve my solution. ``` (define (big x y) (if (> x y) x y)) (define (p a b c) (cond ((> a b) (+...
Looks ok to me, is there anything specific you want to improve on? You could do something like: ``` (define (max2 . l) (lambda () (let ((a (apply max l))) (values a (apply max (remv a l)))))) (define (q a b c) (call-with-values (max2 a b c) (lambda (a b) (+ (* a a) (* b b))))) (define (skip-...
161,672
<p>I noticed some code of a colleague today that initialized class variables in the initialization. However it was causing a warning, he says because of the order they are in. My question is why is it better to do variable initialization where it currently is and not within the curly brackets?</p> <pre><code>Diagram...
[ { "answer_id": 161684, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "<ul>\n<li>It is more efficient (in general). All members of a class are initialised in the constructor, whether you explic...
2008/10/02
[ "https://Stackoverflow.com/questions/161672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24459/" ]
I noticed some code of a colleague today that initialized class variables in the initialization. However it was causing a warning, he says because of the order they are in. My question is why is it better to do variable initialization where it currently is and not within the curly brackets? ``` DiagramScene::DiagramSc...
* It is more efficient (in general). All members of a class are initialised in the constructor, whether you explicitly initialise them or not. If you do not specify an initialiser, then the default constructor of the member is run. If you assign a value in the constructor body, then the assignment operator is called ag...
161,676
<p>I'm running zsh as the default shell on a Ubuntu box, and everything works fine using gnome-terminal (which as far as I know emulates xterm). When I login from a windows box via ssh and putty (which also emulates xterm) suddendly the home/end keys no longer work. </p> <p>I've been able to solve that adding these li...
[ { "answer_id": 161892, "author": "Sec", "author_id": 20555, "author_profile": "https://Stackoverflow.com/users/20555", "pm_score": 0, "selected": false, "text": "<p>These bindings simply don't appear to be part of the default bindings set in emacs mode.</p>\n\n<p>executing \"where-is beg...
2008/10/02
[ "https://Stackoverflow.com/questions/161676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6069/" ]
I'm running zsh as the default shell on a Ubuntu box, and everything works fine using gnome-terminal (which as far as I know emulates xterm). When I login from a windows box via ssh and putty (which also emulates xterm) suddendly the home/end keys no longer work. I've been able to solve that adding these lines to my ...
I found it's a combination: **One** The ZSH developers do not think that ZSH should define the actions of the `Home`, `End`, `Del`, ... keys. Debian and Ubuntu fix this by defining the normal actions the average user would expect in the global `/etc/zsh/zshrc` file. Following the relevant code (it is the same on Deb...
161,687
<p>You sometimes hear it said about Perl that there might be 6 different ways to approach the same problem. Good Perl developers usually have well-reasoned insights for making choices between the various possible methods of implementation.</p> <p>So an example Perl problem:</p> <p>A simple script which recursively i...
[ { "answer_id": 161740, "author": "antik", "author_id": 1625, "author_profile": "https://Stackoverflow.com/users/1625", "pm_score": -1, "selected": false, "text": "<p>I write a subroutine that reads a directory with <code>readdir</code>, throws out the \".\" and \"..\" directories, recurs...
2008/10/02
[ "https://Stackoverflow.com/questions/161687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19468/" ]
You sometimes hear it said about Perl that there might be 6 different ways to approach the same problem. Good Perl developers usually have well-reasoned insights for making choices between the various possible methods of implementation. So an example Perl problem: A simple script which recursively iterates through a ...
This sounds like a job for [File::Find::Rule](http://search.cpan.org/perldoc?File::Find::Rule): ``` #!/usr/bin/perl use strict; use warnings; use autodie; # Causes built-ins like open to succeed or die. # You can 'use Fatal qw(open)' if autodie is not installed. use File::Find::Rule; use Getopt::Std; ...
161,717
<p>If I create a function with jQuery that adds an empty div, performs some animation inside the blank space created by the div, then removes the div, the browser never makes room for the empty div (height and width are set).</p> <p>If I don't remove the empty div in my function, then the browser will create the neede...
[ { "answer_id": 161729, "author": "roenving", "author_id": 23142, "author_profile": "https://Stackoverflow.com/users/23142", "pm_score": 0, "selected": false, "text": "<p>Doesn't it work if you use a setTimeout ?-)</p>\n" }, { "answer_id": 161809, "author": "Joe Brinkman", ...
2008/10/02
[ "https://Stackoverflow.com/questions/161717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4820/" ]
If I create a function with jQuery that adds an empty div, performs some animation inside the blank space created by the div, then removes the div, the browser never makes room for the empty div (height and width are set). If I don't remove the empty div in my function, then the browser will create the needed space an...
Some jQuery effects have callbacks, which will are run after the effect, for example: ``` $('#someDiv').slideDown(100, function() { $(this).remove(); }); ```
161,738
<p>How can I check if a given string is a valid URL address?</p> <p>My knowledge of regular expressions is basic and doesn't allow me to choose from the hundreds of regular expressions I've already seen on the web.</p>
[ { "answer_id": 161749, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 5, "selected": false, "text": "<p>The post <a href=\"https://stackoverflow.com/questions/27745/getting-parts-of-a-url-regex#27755\">Getting parts of a...
2008/10/02
[ "https://Stackoverflow.com/questions/161738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842864/" ]
How can I check if a given string is a valid URL address? My knowledge of regular expressions is basic and doesn't allow me to choose from the hundreds of regular expressions I've already seen on the web.
I wrote my URL (actually IRI, internationalized) pattern to comply with RFC 3987 (<http://www.faqs.org/rfcs/rfc3987.html>). These are in PCRE syntax. For absolute IRIs (internationalized): ``` /^[a-z](?:[-a-z0-9\+\.])*:(?:\/\/(?:(?:%[0-9a-f][0-9a-f]|[-a-z0-9\._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{1000...
161,747
<p>I would like to allow the logged user to edit MediaWiki/Common.css without adding them to the sysop group.</p> <p>I understand that this will allow user to change it to harful ways but it is a closed wiki so that is not a problem.</p> <p>Any solution is acceptable even changing php code :)</p>
[ { "answer_id": 295808, "author": "che", "author_id": 7806, "author_profile": "https://Stackoverflow.com/users/7806", "pm_score": 5, "selected": true, "text": "<p>Create a new group, add give it \"editinterface\" privilege. In LocalSettings.php it's done like this:</p>\n\n<pre><code>$wgGr...
2008/10/02
[ "https://Stackoverflow.com/questions/161747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4508/" ]
I would like to allow the logged user to edit MediaWiki/Common.css without adding them to the sysop group. I understand that this will allow user to change it to harful ways but it is a closed wiki so that is not a problem. Any solution is acceptable even changing php code :)
Create a new group, add give it "editinterface" privilege. In LocalSettings.php it's done like this: ``` $wgGroupPermissions['mynewgroup']['editinterface'] = true; ``` Then add the user to you new group. Or if you want to give that right to all logged-in users, do it like this: ``` $wgGroupPermissions['user']['edi...
161,755
<p>Ant has a nice way to select groups of files, most handily using ** to indicate a directory tree. E.g.</p> <pre><code>**/CVS/* # All files immediately under a CVS directory. mydir/mysubdir/** # All files recursively under mysubdir </code></pre> <p>More examples can be seen here:</p> <p><a href="http:...
[ { "answer_id": 161858, "author": "dkagedal", "author_id": 24458, "author_profile": "https://Stackoverflow.com/users/24458", "pm_score": 2, "selected": false, "text": "<p><code>os.walk</code> is your friend. Look at the example in the Python manual \n(<a href=\"https://docs.python.org/2/l...
2008/10/02
[ "https://Stackoverflow.com/questions/161755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974/" ]
Ant has a nice way to select groups of files, most handily using \*\* to indicate a directory tree. E.g. ``` **/CVS/* # All files immediately under a CVS directory. mydir/mysubdir/** # All files recursively under mysubdir ``` More examples can be seen here: <http://ant.apache.org/manual/dirtasks.html> ...
As soon as you come across a `**`, you're going to have to recurse through the whole directory structure, so I think at that point, the easiest method is to iterate through the directory with os.walk, construct a path, and then check if it matches the pattern. You can probably convert to a regex by something like: ```...
161,775
<p>I am working on a script that downloads emails and stores them in a db, I usually receive thousands of emails on this account, once downloaded the mails are deleted.</p> <p>Being paranoic, I want to have at least one month backup of my emails, but I cannot clutter my main mailbox address leaving them in there.</p> ...
[ { "answer_id": 161786, "author": "tpk", "author_id": 8437, "author_profile": "https://Stackoverflow.com/users/8437", "pm_score": 0, "selected": false, "text": "<p>Why separate account and all the hassle that will be involved? Can't you either</p>\n\n<p>a) backup the mail account using st...
2008/10/02
[ "https://Stackoverflow.com/questions/161775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15780/" ]
I am working on a script that downloads emails and stores them in a db, I usually receive thousands of emails on this account, once downloaded the mails are deleted. Being paranoic, I want to have at least one month backup of my emails, but I cannot clutter my main mailbox address leaving them in there. So i need to ...
First, IMAP does not have a MOVE command only copy but even if it did you can copy from one IMAP server to another directly. Why not use a subfolder in the account for backups. Download them to your local machine then COPY them to the subfolder and then DELETE them from the INBOX. COPY and DELETE are imap server side...
161,788
<p>Are there any downsides to passing structs by value in C, rather than passing a pointer?</p> <p>If the struct is large, there is obviously the performance aspect of copying lots of data, but for a smaller struct, it should basically be the same as passing several values to a function.</p> <p>It is maybe even more in...
[ { "answer_id": 161799, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p>I'd say passing (not-too-large) structs by value, both as parameters and as return values, is a perfectly legitimate t...
2008/10/02
[ "https://Stackoverflow.com/questions/161788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24458/" ]
Are there any downsides to passing structs by value in C, rather than passing a pointer? If the struct is large, there is obviously the performance aspect of copying lots of data, but for a smaller struct, it should basically be the same as passing several values to a function. It is maybe even more interesting when ...
For small structs (eg point, rect) passing by value is perfectly acceptable. But, apart from speed, there is one other reason why you should be careful passing/returning large structs by value: Stack space. A lot of C programming is for embedded systems, where memory is at a premium, and stack sizes may be measured in...
161,790
<p>I have the following class in C++:</p> <pre><code>class a { const int b[2]; // other stuff follows // and here's the constructor a(void); } </code></pre> <p>The question is, how do I initialize b in the initialization list, given that I can't initialize it inside the body of the function of the co...
[ { "answer_id": 161806, "author": "Trap", "author_id": 7839, "author_profile": "https://Stackoverflow.com/users/7839", "pm_score": 2, "selected": false, "text": "<p>You can't do that from the initialization list, </p>\n\n<p>Have a look at this:</p>\n\n<p><a href=\"http://www.cprogramming....
2008/10/02
[ "https://Stackoverflow.com/questions/161790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
I have the following class in C++: ``` class a { const int b[2]; // other stuff follows // and here's the constructor a(void); } ``` The question is, how do I initialize b in the initialization list, given that I can't initialize it inside the body of the function of the constructor, because b is `c...
Like the others said, ISO C++ doesn't support that. But you can workaround it. Just use std::vector instead. ``` int* a = new int[N]; // fill a class C { const std::vector<int> v; public: C():v(a, a+N) {} }; ```
161,794
<p>I am not sure if I formulated the question right, but still ...</p> <p>I have a view that shows a flash embed and this flash take as parameter a <code>/controller/action</code> URL that generates a XML. I nee to send, from this view, an array to the XML generator action. How is the best way ? Is there some <code>he...
[ { "answer_id": 161854, "author": "Gustavo Carreno", "author_id": 8167, "author_profile": "https://Stackoverflow.com/users/8167", "pm_score": 1, "selected": true, "text": "<p>First of all you cannot send data from one view to another in the manner you are speaking. Each of those calls wou...
2008/10/02
[ "https://Stackoverflow.com/questions/161794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2274/" ]
I am not sure if I formulated the question right, but still ... I have a view that shows a flash embed and this flash take as parameter a `/controller/action` URL that generates a XML. I nee to send, from this view, an array to the XML generator action. How is the best way ? Is there some `helper->set()` method like o...
First of all you cannot send data from one view to another in the manner you are speaking. Each of those calls would be a separate request and this means that it goes out of the framework and then in again. This means that the framework will be built and tear down between calls, making impossible to pass the data betwe...
161,813
<p>How do I resolve merge conflicts in my Git repository?</p>
[ { "answer_id": 162056, "author": "davetron5000", "author_id": 3029, "author_profile": "https://Stackoverflow.com/users/3029", "pm_score": 9, "selected": false, "text": "<ol>\n<li><p>Identify which files are in conflict (Git should tell you this).</p></li>\n<li><p>Open each file and exami...
2008/10/02
[ "https://Stackoverflow.com/questions/161813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3713/" ]
How do I resolve merge conflicts in my Git repository?
Try: ```bash git mergetool ``` It opens a GUI that steps you through each conflict, and you get to choose how to merge. Sometimes it requires a bit of hand editing afterwards, but usually it's enough by itself. It is much better than doing the whole thing by hand certainly. --- As per [Josh Glover's comment](https...
161,819
<p>What are the main/best Maven repositories to use that will include the majority of your open source Java package dependencies.</p> <p>Also in what order should these be included? Does it matter?</p>
[ { "answer_id": 161846, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 5, "selected": false, "text": "<p>This is the current setup in the project we are building:</p>\n\n<ul>\n<li>MavenCentral</li>\n<li>ObjectWeb</li>\n...
2008/10/02
[ "https://Stackoverflow.com/questions/161819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17719/" ]
What are the main/best Maven repositories to use that will include the majority of your open source Java package dependencies. Also in what order should these be included? Does it matter?
This is the current setup in the project we are building: * MavenCentral * ObjectWeb * JBoss Maven2 * and some snapshots (see below) ``` <repository> <id>MavenCentral</id> <name>Maven repository</name> <url>http://repo1.maven.org/maven2</url> <releases> <enabled>true</enabled> </releases> ...
161,822
<p>I have several similar methods, say eg. CalculatePoint(...) and CalculateListOfPoints(...). Occasionally, they may not succeed, and need to indicate this to the caller. For CalculateListOfPoints, which returns a generic List, I could return an empty list and require the caller to check this; however Point is a value...
[ { "answer_id": 161827, "author": "GEOCHET", "author_id": 5640, "author_profile": "https://Stackoverflow.com/users/5640", "pm_score": 0, "selected": false, "text": "<p>I would say best practice is a return value means success, and an <a href=\"http://www.c-sharpcorner.com/UploadFile/rajes...
2008/10/02
[ "https://Stackoverflow.com/questions/161822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6091/" ]
I have several similar methods, say eg. CalculatePoint(...) and CalculateListOfPoints(...). Occasionally, they may not succeed, and need to indicate this to the caller. For CalculateListOfPoints, which returns a generic List, I could return an empty list and require the caller to check this; however Point is a value ty...
Personally, I think I'd use the same idea as TryParse() : using an out parameter to output the real value, and returning a boolean indicating whether the call was successful or not `public bool CalculatePoint(... out Point result);` I am not a fan of using exception for "normal" behaviors (if you expect the function ...
161,828
<p>I need to control the data type when reading XML data in SAS. The XML data are written and accessed using the XML libname engine in SAS.</p> <p>SAS seems to guess the data type based on the contents of a column: If I write "20081002" to my XML data in a character column, it will be read back in as a numerical varia...
[ { "answer_id": 162067, "author": "jilles de wit", "author_id": 7531, "author_profile": "https://Stackoverflow.com/users/7531", "pm_score": 1, "selected": false, "text": "<p>I think you need to define some xml specific options whith your libname XML statement for export go:</p>\n\n<pre><c...
2008/10/02
[ "https://Stackoverflow.com/questions/161828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18968/" ]
I need to control the data type when reading XML data in SAS. The XML data are written and accessed using the XML libname engine in SAS. SAS seems to guess the data type based on the contents of a column: If I write "20081002" to my XML data in a character column, it will be read back in as a numerical variable. An e...
Take a look at the SAS XML Mapper. It allows you to create a map to read (and wrte in 9.2) XML files and specifying column attributes. If this is your XML file: This is obviously text 20081002 42 42 You could create a MAP like this: ``` <!-- ############################################################ --> <...
161,838
<p>Is it possible to unlisten on a socket after you have called listen(fd, backlog)? </p> <p>Edit: My mistake for not making myself clear. I'd like to be able to temporarily unlisten on the socket. Calling close() will leave the socket in the M2LS state and prevent me from reopening it (or worse, some nefarious progra...
[ { "answer_id": 161841, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "<p>Close it. As I recall;</p>\n\n<pre><code>close(fd);\n</code></pre>\n" }, { "answer_id": 161896, "a...
2008/10/02
[ "https://Stackoverflow.com/questions/161838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6449/" ]
Is it possible to unlisten on a socket after you have called listen(fd, backlog)? Edit: My mistake for not making myself clear. I'd like to be able to temporarily unlisten on the socket. Calling close() will leave the socket in the M2LS state and prevent me from reopening it (or worse, some nefarious program could bi...
Some socket libraries allow you to specifically reject incoming connections. For example: [GNU's CommonC++: TCPsocket Class](ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/commoncpp/docs/refman/html/class_t_c_p_socket.html) has a [*reject*](ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/commoncpp/docs/ref...
161,852
<p>I have a slight problem reading data from file. I want to be able to read wstring's, aswell as a chunk of raw data of arbitrary size (size is in bytes). </p> <pre><code>std::wfstream stream(file.c_str()); std::wstring comType; stream &gt;&gt; comType; int comSize; stream &gt;&gt; comSize; char *comData = new cha...
[ { "answer_id": 161878, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 1, "selected": false, "text": "<p>Considering your requirements I do not think wfstream is the way to go. Considerer using something like the follow...
2008/10/02
[ "https://Stackoverflow.com/questions/161852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2166173/" ]
I have a slight problem reading data from file. I want to be able to read wstring's, aswell as a chunk of raw data of arbitrary size (size is in bytes). ``` std::wfstream stream(file.c_str()); std::wstring comType; stream >> comType; int comSize; stream >> comSize; char *comData = new char[comSize]; memset(comData...
the problem with the stream.read is that it uses wchar\_t as "character unit" with wfstream. If you use fstream it uses char as "character unit". This would work if you want to read wide characters: ``` wchar_t *comData = new wchar_t[comSize]; stream.read(comData, comSize); ``` Also 15 bytes of data can't be read w...
161,859
<p>I'd like to invoke bash using a string as input. Something like:</p> <pre><code>sh -l -c "./foo" </code></pre> <p>I'd like to do this from Java. Unfortunately, when I try to invoke the command using <code>getRuntime().exec</code>, I get the following error: </p> <pre><code> foo": -c: line 0: unexpected EOF ...
[ { "answer_id": 161863, "author": "Lev", "author_id": 7224, "author_profile": "https://Stackoverflow.com/users/7224", "pm_score": 2, "selected": false, "text": "<p>EOF is NOT a character, so there's no way to write an EOF. \nYou've forgotten to close a quoted string.</p>\n" }, { "...
2008/10/02
[ "https://Stackoverflow.com/questions/161859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20426/" ]
I'd like to invoke bash using a string as input. Something like: ``` sh -l -c "./foo" ``` I'd like to do this from Java. Unfortunately, when I try to invoke the command using `getRuntime().exec`, I get the following error: ``` foo": -c: line 0: unexpected EOF while looking for matching `"' foo": -c: l...
Use this: ``` Runtime.getRuntime().exec(new String[] {"sh", "-l", "-c", "./foo"}); ``` Main point: don't put the double quotes in. That's only used when writing a command-line in the shell! e.g., `echo "Hello, world!"` (as typed in the shell) gets translated to: ``` Runtime.getRuntime().exec(new String[] {"echo", ...
161,872
<p>What are some really useful but esoteric language features in Perl that you've actually been able to employ to do useful work?</p> <p>Guidelines:</p> <ul> <li>Try to limit answers to the Perl core and not CPAN</li> <li>Please give an example and a short description</li> </ul> <hr> <h2>Hidden Features also found ...
[ { "answer_id": 161943, "author": "Sec", "author_id": 20555, "author_profile": "https://Stackoverflow.com/users/20555", "pm_score": 4, "selected": false, "text": "<p>Let's start easy with the <a href=\"http://en.wikipedia.org/wiki/Spaceship_operator\" rel=\"nofollow noreferrer\">Spaceship...
2008/10/02
[ "https://Stackoverflow.com/questions/161872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21632/" ]
What are some really useful but esoteric language features in Perl that you've actually been able to employ to do useful work? Guidelines: * Try to limit answers to the Perl core and not CPAN * Please give an example and a short description --- Hidden Features also found in other languages' Hidden Features: -------...
The flip-flop operator is useful for skipping the first iteration when looping through the records (usually lines) returned by a file handle, without using a flag variable: ``` while(<$fh>) { next if 1..1; # skip first record ... } ``` Run `perldoc perlop` and search for "flip-flop" for more information and exam...
161,873
<p>I'm working on the K&amp;R book. I've read farther ahead than I've done exercises, mostly for lack of time. I'm catching up, and have done almost all the exercises from chapter 1, which is the tutorial.</p> <p>My issue was exercise 1-18. The exercise is to:</p> <blockquote> <p>Write a program to remove trailing ...
[ { "answer_id": 161895, "author": "Eric Z Beard", "author_id": 1219, "author_profile": "https://Stackoverflow.com/users/1219", "pm_score": 3, "selected": false, "text": "<p>If you are sticking with chapter 1, that looks pretty good to me. Here's what I would recommend from a code-review ...
2008/10/02
[ "https://Stackoverflow.com/questions/161873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
I'm working on the K&R book. I've read farther ahead than I've done exercises, mostly for lack of time. I'm catching up, and have done almost all the exercises from chapter 1, which is the tutorial. My issue was exercise 1-18. The exercise is to: > > Write a program to remove trailing blanks and > tabs from line o...
There is no reason to have two buffers, you can trim the input line in place ``` int trim(char line[]) { int len = 0; for (len = 0; line[len] != 0; ++len) ; while (len > 0 && line[len-1] == ' ' && line[len-1] == '\t' && line[len-1] == '\n') line[--len] = 0; return len; } `...
161,879
<p>Quite often in ANSI C code I can see parenthesis sorrounding a single return value. </p> <p>Like this:-</p> <pre><code>int foo(int x) { if (x) return (-1); else return (0); } </code></pre> <p>Why use () around the return value in those cases? Any ideas? I can see no reason for that.</p>
[ { "answer_id": 161894, "author": "Manrico Corazzi", "author_id": 4690, "author_profile": "https://Stackoverflow.com/users/4690", "pm_score": 2, "selected": false, "text": "<p>As often the case when using parenthesis, I think that's just for readability (e.g., Ruby supports method calls w...
2008/10/02
[ "https://Stackoverflow.com/questions/161879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23864/" ]
Quite often in ANSI C code I can see parenthesis sorrounding a single return value. Like this:- ``` int foo(int x) { if (x) return (-1); else return (0); } ``` Why use () around the return value in those cases? Any ideas? I can see no reason for that.
There really isn't a reason...it's just old convention. To save space, programmers would often do the final math in the return line instead of on it's own line and the parens ensure are mostly there to make it easier to see that it is a single statement that is returned, like this: ``` return (x+i*2); ``` instead o...
161,884
<p>For those of you that like puzzles: I had this problem recently and am sure there must be a nicer solution.</p> <p>Consider :</p> <ul> <li>an ObservableCollection of <strong>Foo</strong> objects called <em>foos</em>.</li> <li><strong>Foo</strong> contains a string ID field</li> <li>I have no control over <em>foos<...
[ { "answer_id": 161894, "author": "Manrico Corazzi", "author_id": 4690, "author_profile": "https://Stackoverflow.com/users/4690", "pm_score": 2, "selected": false, "text": "<p>As often the case when using parenthesis, I think that's just for readability (e.g., Ruby supports method calls w...
2008/10/02
[ "https://Stackoverflow.com/questions/161884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20508/" ]
For those of you that like puzzles: I had this problem recently and am sure there must be a nicer solution. Consider : * an ObservableCollection of **Foo** objects called *foos*. * **Foo** contains a string ID field * I have no control over *foos* * *foos* will be changing Then: * I have another collection called *...
There really isn't a reason...it's just old convention. To save space, programmers would often do the final math in the return line instead of on it's own line and the parens ensure are mostly there to make it easier to see that it is a single statement that is returned, like this: ``` return (x+i*2); ``` instead o...
161,885
<p>When running performance tests file system cache hit or miss can significantly influence test results. Therefore generally before running such tests used files are evicted from system cache. How to do that on Linux?</p> <p><strong>Clarification:</strong> If possible, the solution should not require root privileges....
[ { "answer_id": 162041, "author": "Mecki", "author_id": 15809, "author_profile": "https://Stackoverflow.com/users/15809", "pm_score": 4, "selected": false, "text": "<p>As a superuser you can do the following:</p>\n\n<p>To free pagecache:</p>\n\n<ul>\n<li>echo 1 > /proc/sys/vm/drop_caches<...
2008/10/02
[ "https://Stackoverflow.com/questions/161885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403/" ]
When running performance tests file system cache hit or miss can significantly influence test results. Therefore generally before running such tests used files are evicted from system cache. How to do that on Linux? **Clarification:** If possible, the solution should not require root privileges.
Ha, I have the answer: ``` #include <unistd.h> #include <fcntl.h> int main(int argc, char *argv[]) { int fd; fd = open(argv[1], O_RDONLY); fdatasync(fd); posix_fadvise(fd, 0,0,POSIX_FADV_DONTNEED); close(fd); return 0; } ``` This is from <http://insights.oetiker.ch/linux/fadvise.html>
161,913
<p>I would like to draw a diagram in HTML. The positioning structure looks like this:</p> <pre class="lang-html prettyprint-override"><code>&lt;div id='hostDiv'&gt; &lt;div id='backgroundDiv'&gt; ... drawing the background ... &lt;/div&gt; &lt;div id='foregroundDiv' style='position: absolute;'&gt; ... dra...
[ { "answer_id": 161923, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 3, "selected": false, "text": "<p>There isn't any way to predict the height without actually rendering it in the target browser.</p>\n\n<p>Once you...
2008/10/02
[ "https://Stackoverflow.com/questions/161913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24451/" ]
I would like to draw a diagram in HTML. The positioning structure looks like this: ```html <div id='hostDiv'> <div id='backgroundDiv'> ... drawing the background ... </div> <div id='foregroundDiv' style='position: absolute;'> ... drawing the foreground ... </div> </div> ``` The foreground contains a ...
There isn't any way to predict the height without actually rendering it in the target browser. Once you do that, you can use (for example) [**jQuery**](http://docs.jquery.com/) to get the height of the element: ``` var height = $('#myTable').height(); ```
161,915
<p>I'm trying to have two inputs (one textbox, one drop down) to have the same width. You can set the width through css, but for some reason, the select box is always a few pixels smaller. It seems this only happens with the xhtml 1.0 strict doctype Any suggestions/ideas about the reason/work around?</p> <p>Having the...
[ { "answer_id": 161940, "author": "Vincent McNabb", "author_id": 16299, "author_profile": "https://Stackoverflow.com/users/16299", "pm_score": 0, "selected": false, "text": "<p>You're right, there is a 4px difference. The <code>input</code> is coming out at 103px wide, while the <code>sel...
2008/10/02
[ "https://Stackoverflow.com/questions/161915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I'm trying to have two inputs (one textbox, one drop down) to have the same width. You can set the width through css, but for some reason, the select box is always a few pixels smaller. It seems this only happens with the xhtml 1.0 strict doctype Any suggestions/ideas about the reason/work around? Having the following...
You could try resetting the margins, padding and borders to see if that helps: ``` .searchInput { margin:0; padding:0; border-width:1px; width:1000px; } ```
161,937
<p>I understand there is a HTTP response header directive to disable page caching:</p> <pre><code>Cache-Control:no-cache </code></pre> <p>I can modify the header by "hand":</p> <pre><code> &lt;%response.addHeader("Cache-Control","no-cache");%&gt; </code></pre> <p>But is there a "nice" way to make the JSP interprete...
[ { "answer_id": 161952, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 0, "selected": false, "text": "<p>If you were using a servlet, then I believe what you posted in the question would be the correct approach. I'm not awar...
2008/10/02
[ "https://Stackoverflow.com/questions/161937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17428/" ]
I understand there is a HTTP response header directive to disable page caching: ``` Cache-Control:no-cache ``` I can modify the header by "hand": ``` <%response.addHeader("Cache-Control","no-cache");%> ``` But is there a "nice" way to make the JSP interpreter return this header line in the server response? (I c...
Also add ``` response.addHeader("Expires","-1"); response.addHeader("Pragma","no-cache"); ``` to your headers and give that a shot.
161,960
<p>A query that is used to loop through <b>17 millions records to remove duplicates</b> has been running now for about <b>16 hours</b> and I wanted to know if the query is stopped right now if it will finalize the delete statements or if it has been deleting while running this query? Indeed, if I do stop it, does it f...
[ { "answer_id": 161990, "author": "Joe Phillips", "author_id": 20471, "author_profile": "https://Stackoverflow.com/users/20471", "pm_score": -1, "selected": false, "text": "<p>I'm pretty sure that is a negatory. Otherwise what would the point of transactions be?</p>\n" }, { "answe...
2008/10/02
[ "https://Stackoverflow.com/questions/161960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
A query that is used to loop through **17 millions records to remove duplicates** has been running now for about **16 hours** and I wanted to know if the query is stopped right now if it will finalize the delete statements or if it has been deleting while running this query? Indeed, if I do stop it, does it finalize th...
no, sql server will not roll back the deletes it has already performed if you stop query execution. oracle requires an explicit committal of action queries or the data gets rolled back, but not mssql. with sql server it will not roll back unless you are specifically running in the context of a transaction and you roll...
161,984
<p>Is it possible to create Selenium tests using the Firefox plugin that use randomly generated values to help do regression tests?</p> <p><strong>The full story:</strong> I would like to help my clients do acceptance testing by providing them with a suite of tests that use some smarts to create random (or at least ps...
[ { "answer_id": 162107, "author": "Thilo", "author_id": 14955, "author_profile": "https://Stackoverflow.com/users/14955", "pm_score": 7, "selected": true, "text": "<p>First off, the Selenium IDE is rather limited, you should consider switching to Selenium RC, which can be driven by Java o...
2008/10/02
[ "https://Stackoverflow.com/questions/161984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14971/" ]
Is it possible to create Selenium tests using the Firefox plugin that use randomly generated values to help do regression tests? **The full story:** I would like to help my clients do acceptance testing by providing them with a suite of tests that use some smarts to create random (or at least pseudo-random) values for...
First off, the Selenium IDE is rather limited, you should consider switching to Selenium RC, which can be driven by Java or Perl or Ruby or some other languages. Using just Selenium IDE, you can embed JavaScript expressions to derive command parameters. You should be able to type a random number into a text field, for...
161,988
<p>I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query. The thing is, the table contains a colum that is mapped to a char in Hibernate Model, and sometimes this column is empty. And I suppose this is where my exception comes from. How can I map a colum of char to my hibernate model without ge...
[ { "answer_id": 162145, "author": "MetroidFan2002", "author_id": 8026, "author_profile": "https://Stackoverflow.com/users/8026", "pm_score": 3, "selected": true, "text": "<p>I am assuming from your question that you're mapping this to a primitive character. Next time, please post the sta...
2008/10/02
[ "https://Stackoverflow.com/questions/161988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24069/" ]
I'm reading data from a table( from a MySQL Database) with Hibernate SQL Query. The thing is, the table contains a colum that is mapped to a char in Hibernate Model, and sometimes this column is empty. And I suppose this is where my exception comes from. How can I map a colum of char to my hibernate model without getti...
I am assuming from your question that you're mapping this to a primitive character. Next time, please post the stacktrace that you receive (you may leave out where you call it, you could only include the hibernate stuff if your project is too sensitive). If you do map to a primitive character, and it is null, you will...
162,007
<p>I have an object of the type System.Drawing.Image and want to make every pixel which has some specific color, for example black, transparent (that is, set alpha to 0 for this pixel).</p> <p>What is the best way to do this?</p>
[ { "answer_id": 162017, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Do you only know that it's an Image? If it's a Bitmap, you could call LockBits, check/fix every pixel and then unlock...
2008/10/02
[ "https://Stackoverflow.com/questions/162007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7559/" ]
I have an object of the type System.Drawing.Image and want to make every pixel which has some specific color, for example black, transparent (that is, set alpha to 0 for this pixel). What is the best way to do this?
One good approach is to use the **ImageAttributes** class to setup a list of colors to remap when drawing takes place. The advantage of this is good performance as well as allowing you to alter the remapping colors very easily. Try something like this code... ``` ImageAttributes attribs = new ImageAttributes(); List<C...
162,011
<p>I have a Nant build file which executes NUnit after compiling the dll's. I am executing the NAnt build file with a task in CruiseControl. So NAnt is running the tests not CruiseControl.</p> <p>How do I configure it so that the CruiseControl web dashboard can be used to view the NUnit output ?</p> <hr> <p>This fi...
[ { "answer_id": 162055, "author": "ckramer", "author_id": 20504, "author_profile": "https://Stackoverflow.com/users/20504", "pm_score": 4, "selected": true, "text": "<p>You want to use the merge capabilities of CruiseControl to grab your NUnit XML output. This is the situation my company...
2008/10/02
[ "https://Stackoverflow.com/questions/162011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2083160/" ]
I have a Nant build file which executes NUnit after compiling the dll's. I am executing the NAnt build file with a task in CruiseControl. So NAnt is running the tests not CruiseControl. How do I configure it so that the CruiseControl web dashboard can be used to view the NUnit output ? --- This fixed it: ``` <publi...
You want to use the merge capabilities of CruiseControl to grab your NUnit XML output. This is the situation my company has going, and it seems to work fairly well. Here is a config snippet (This goes in the <publishers> element in CCNet.config): ``` <merge> <files> <file><path to XML output>\*.xml</fil...
162,032
<p>I've got two arrays of the same size. I'd like to merge the two so the values of one are the key indexes of the new array, and the values of the new array are the values of the other.</p> <p>Right now I'm just looping through the arrays and creating the new array manually, but I have a feeling there is a much more...
[ { "answer_id": 162040, "author": "aib", "author_id": 1088, "author_profile": "https://Stackoverflow.com/users/1088", "pm_score": 7, "selected": true, "text": "<p>See <a href=\"http://php.net/array_combine\" rel=\"noreferrer\"><code>array_combine()</code></a> on PHP.net.</p>\n" }, { ...
2008/10/02
[ "https://Stackoverflow.com/questions/162032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got two arrays of the same size. I'd like to merge the two so the values of one are the key indexes of the new array, and the values of the new array are the values of the other. Right now I'm just looping through the arrays and creating the new array manually, but I have a feeling there is a much more elegant wa...
See [`array_combine()`](http://php.net/array_combine) on PHP.net.
162,037
<p>My Outlook add-in handles NewInspector event of the Inspector object, in order to display a custom form for the mail item.</p> <p>I can get EntryID of the CurrentItem of the Inspector object which is passed as a parameter of the event. But, the problem is that the EntryID of the current mail item is shorter than it...
[ { "answer_id": 162585, "author": "Nenad Dobrilovic", "author_id": 22062, "author_profile": "https://Stackoverflow.com/users/22062", "pm_score": 3, "selected": true, "text": "<p>The idea is to remember every EntryID of the MailItem that was created by an add-in, so that it can be treated ...
2008/10/02
[ "https://Stackoverflow.com/questions/162037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22062/" ]
My Outlook add-in handles NewInspector event of the Inspector object, in order to display a custom form for the mail item. I can get EntryID of the CurrentItem of the Inspector object which is passed as a parameter of the event. But, the problem is that the EntryID of the current mail item is shorter than it should be...
The idea is to remember every EntryID of the MailItem that was created by an add-in, so that it can be treated differently later. Problem was that EntryID of the item opened by an Inspector was the short one, and not in the list of remembered ids, although it should be. Few lines of code where I was creating mail item...
162,057
<p>I'm building a Thunderbird extension and would like to add my own header to all outgoing email (e.g. &lt;myext-version: 1.0&gt; ). Any idea how to do this? I know it's possible since this is done in the OpenPGP Enigmail extension. Thanks!</p>
[ { "answer_id": 229559, "author": "Colin Pickard", "author_id": 12744, "author_profile": "https://Stackoverflow.com/users/12744", "pm_score": 1, "selected": false, "text": "<p>I don't know the answer but just some thoughts...</p>\n\n<p>I think thunderbird extensions are usually just xul a...
2008/10/02
[ "https://Stackoverflow.com/questions/162057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24473/" ]
I'm building a Thunderbird extension and would like to add my own header to all outgoing email (e.g. <myext-version: 1.0> ). Any idea how to do this? I know it's possible since this is done in the OpenPGP Enigmail extension. Thanks!
Here is the code from one extension I'm working on: ``` function SendObserver() { this.register(); } SendObserver.prototype = { observe: function(subject, topic, data) { /* thunderbird sends a notification even when it's only saving the message as a draft. * We examine the caller chain to check for va...
162,064
<p>I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions? </p> <p>Ideally I would like to do this without increasing the width of the textbox as I am sh...
[ { "answer_id": 162222, "author": "dguaraglia", "author_id": 2384, "author_profile": "https://Stackoverflow.com/users/2384", "pm_score": 0, "selected": false, "text": "<p>Hmmm, there's no direct way really. You'd probably have to resort to subclassing (in the Windows API sense) the TextBo...
2008/10/02
[ "https://Stackoverflow.com/questions/162064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6165/" ]
I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions? Ideally I would like to do this without increasing the width of the textbox as I am short for spac...
Not that I know of, but you can auto-size the Textbox so that it is only wide when it needs to be, rather than always as wide as the longest text. Example from <http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3311429&SiteID=1> ``` Public Class Form1 Private WithEvents T As TextBox Private Sub Form1_Load(ByVal s...
162,079
<p>We have the usual <strong>web.xml</strong> for our web application which includes some jsp and jsp tag files. I want to switch to using pre-compiled jsp's. I have the pre-compilation happening in the build ok, and it generates the web.xml fragment and now I want to merge the fragment into the main web.xml.</p> <p...
[ { "answer_id": 162186, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 2, "selected": false, "text": "<p>Doh - there is an option on the jasper2 task to auto-merge the fragment into the main web.xml - <strong>addWebXml...
2008/10/02
[ "https://Stackoverflow.com/questions/162079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48310/" ]
We have the usual **web.xml** for our web application which includes some jsp and jsp tag files. I want to switch to using pre-compiled jsp's. I have the pre-compilation happening in the build ok, and it generates the web.xml fragment and now I want to merge the fragment into the main web.xml. Is there an **include** ...
I use the [Tomcat jasper ANT tasks](http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html) in my project, which precompile the JSPs into servlets and add the new servlet mappings to the original web.xml. In the DEV builds, just skip this step and deploy the JSPs without pre-compile and modification of the web.xml. ...
162,086
<p>in web.xml i set my welcome file to a jsp within web.xml</p> <pre><code>&lt;welcome-file&gt;WEB-INF/index.jsp&lt;/welcome-file&gt; </code></pre> <p>inside index.jsp i then forward on to a servlet </p> <pre><code>&lt;% response.sendRedirect(response.encodeRedirectURL("myServlet/")); %&gt; </code></pre> <p>however...
[ { "answer_id": 162186, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 2, "selected": false, "text": "<p>Doh - there is an option on the jasper2 task to auto-merge the fragment into the main web.xml - <strong>addWebXml...
2008/10/02
[ "https://Stackoverflow.com/questions/162086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24481/" ]
in web.xml i set my welcome file to a jsp within web.xml ``` <welcome-file>WEB-INF/index.jsp</welcome-file> ``` inside index.jsp i then forward on to a servlet ``` <% response.sendRedirect(response.encodeRedirectURL("myServlet/")); %> ``` however the application tries to find the servlet at the following path ...
I use the [Tomcat jasper ANT tasks](http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html) in my project, which precompile the JSPs into servlets and add the new servlet mappings to the original web.xml. In the DEV builds, just skip this step and deploy the JSPs without pre-compile and modification of the web.xml. ...
162,088
<p>I use <code>serialize</code> in one <code>ActiveRecord</code> model to serialize an <code>Array</code> of simple Hashes into a text database field. I even use the second parameter to coerce deserialization into <code>Array</code>s.</p> <pre><code>class Shop &lt; ActiveRecord::Base serialize : recipients, Array en...
[ { "answer_id": 12409593, "author": "J_McCaffrey", "author_id": 318699, "author_profile": "https://Stackoverflow.com/users/318699", "pm_score": 1, "selected": false, "text": "<p>This seems like something you should be able to reproduce locally with enough testing.\nLook through your produ...
2008/10/02
[ "https://Stackoverflow.com/questions/162088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21702/" ]
I use `serialize` in one `ActiveRecord` model to serialize an `Array` of simple Hashes into a text database field. I even use the second parameter to coerce deserialization into `Array`s. ``` class Shop < ActiveRecord::Base serialize : recipients, Array end ``` It seems to work fine but, after a few requests, the ...
I had the same problem with some serialized fields in one of my Rails 3.1 apps. After a lot of troubleshooting I narrowed it down to a character encoding issue. I wasn't able to reproduce it locally because I was using SQLite, while my production environment was on Postgres. Try applying `some_field.force_encoding(Enc...
162,113
<p>I'm looking for an elegant, high performance solution to the following problem. </p> <p>There are 256 linked lists. </p> <ul> <li>Each list contains the same types of object that among other things holds a whole number that is used to define a sort order.</li> <li>All numbers across all lists are unique</li> <li>...
[ { "answer_id": 162131, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": true, "text": "<p>You could use a priority queue that holds the “topmost” item of each of the 256 linked lists. This “topmost” item i...
2008/10/02
[ "https://Stackoverflow.com/questions/162113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7855/" ]
I'm looking for an elegant, high performance solution to the following problem. There are 256 linked lists. * Each list contains the same types of object that among other things holds a whole number that is used to define a sort order. * All numbers across all lists are unique * Each individual list is sorted in as...
You could use a priority queue that holds the “topmost” item of each of the 256 linked lists. This “topmost” item is the one that is scheduled to be inserted into the resulting list. This way, you can just take the smallest element from the priority queue, insert it into your resulting queue, and insert its next elemen...
162,142
<p>Perforce allows people to check in unchanged files. Why any version control system would allow this is beyond me, but that's a topic for another question. I want to create a trigger that will deny the submission of unchanged files. However, I have no experience with Perforce triggers. From what I've read, I'm gue...
[ { "answer_id": 162285, "author": "Curro", "author_id": 10688, "author_profile": "https://Stackoverflow.com/users/10688", "pm_score": 1, "selected": false, "text": "<p>If you look at the Triggers table in Perforce, you will see that triggers are nothing but scripts that get invoked when s...
2008/10/02
[ "https://Stackoverflow.com/questions/162142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
Perforce allows people to check in unchanged files. Why any version control system would allow this is beyond me, but that's a topic for another question. I want to create a trigger that will deny the submission of unchanged files. However, I have no experience with Perforce triggers. From what I've read, I'm guessing ...
In recent version of perforce allow a client setting which prevents submitting unchanged files: ``` SubmitOptions: Flags to change submit behaviour. submitunchanged All open files are submitted submitunchanged+reopen (default). revertunchanged Files tha...
162,172
<p>I am trying to install xampp 1.6.7 in a Red Hat Enterprise Edition. I followed the installation instructions and after that I started the stack with the command </p> <pre><code>sudo /opt/lampp/lampp start </code></pre> <p>And I get te usual response</p> <pre><code>XAMPP: Starting Apache with SSL (and PHP5)... XAM...
[ { "answer_id": 162230, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": "<p>What do</p>\n\n<pre><code>mysql status\n</code></pre>\n\n<p>and</p>\n\n<pre><code>ps aux | grep mysql\n</code></p...
2008/10/02
[ "https://Stackoverflow.com/questions/162172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9132/" ]
I am trying to install xampp 1.6.7 in a Red Hat Enterprise Edition. I followed the installation instructions and after that I started the stack with the command ``` sudo /opt/lampp/lampp start ``` And I get te usual response ``` XAMPP: Starting Apache with SSL (and PHP5)... XAMPP: Starting MySQL... XAMPP: Starting...
When mysqld *crashes* (I think it just shuts down), you may need to configure `log-error` in `my.cnf` to see anything of real use. I am not sure how xampp is setup, but a simple `find / -name "my.cnf"` should point you to the location of that file. **Edit** You want to install libgcc. It should be available as an RPM...
162,176
<p><code>fopen</code> is failing when I try to read in a very moderately sized file in <code>PHP</code>. <code>A 6 meg file</code> makes it choke, though smaller files around <code>100k</code> are just fine. i've read that it is sometimes necessary to recompile <code>PHP</code> with the <code>-D_FILE_OFFSET_BITS=64</...
[ { "answer_id": 162210, "author": "Fionn", "author_id": 21566, "author_profile": "https://Stackoverflow.com/users/21566", "pm_score": 1, "selected": false, "text": "<p>Well you could try to use the readfile function if you just want to output the file.</p>\n\n<p>If this is not the case - ...
2008/10/02
[ "https://Stackoverflow.com/questions/162176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`fopen` is failing when I try to read in a very moderately sized file in `PHP`. `A 6 meg file` makes it choke, though smaller files around `100k` are just fine. i've read that it is sometimes necessary to recompile `PHP` with the `-D_FILE_OFFSET_BITS=64` flag in order to read files over 20 gigs or something ridiculous,...
Are you sure that it's `fopen` that's failing and not your script's timeout setting? The default is usually around 30 seconds or so, and if your file is taking longer than that to read in, it may be tripping that up. Another thing to consider may be the memory limit on your script - reading the file into an array may ...
162,187
<p>When used like this:</p> <pre><code>import static com.showboy.Myclass; public class Anotherclass{} </code></pre> <p>what's the difference between <code>import static com.showboy.Myclass</code> and <code>import com.showboy.Myclass</code>?</p>
[ { "answer_id": 162195, "author": "xsl", "author_id": 11387, "author_profile": "https://Stackoverflow.com/users/11387", "pm_score": 10, "selected": true, "text": "<p>See <a href=\"http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html\" rel=\"noreferrer\">Documentation...
2008/10/02
[ "https://Stackoverflow.com/questions/162187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10927/" ]
When used like this: ``` import static com.showboy.Myclass; public class Anotherclass{} ``` what's the difference between `import static com.showboy.Myclass` and `import com.showboy.Myclass`?
See [Documentation](http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html) > > The static import declaration is > analogous to the normal import > declaration. Where the normal import > declaration imports classes from > packages, allowing them to be used > without package qualification, the...
162,225
<p>I've got an XML document containing news stories, and the body element of a news story contains p tags amongst the plain text. When I use XSL to retrieve the body, e.g.</p> <pre><code>&lt;xsl:value-of select="body" /&gt; </code></pre> <p>the p tags seem to get stripped out. I'm using Visual Studio 2005's implement...
[ { "answer_id": 162248, "author": "Eugene Katz", "author_id": 1533, "author_profile": "https://Stackoverflow.com/users/1533", "pm_score": 1, "selected": false, "text": "<p>If you have control over the input document, <a href=\"http://en.wikipedia.org/wiki/CDATA\" rel=\"nofollow noreferrer...
2008/10/02
[ "https://Stackoverflow.com/questions/162225", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12277/" ]
I've got an XML document containing news stories, and the body element of a news story contains p tags amongst the plain text. When I use XSL to retrieve the body, e.g. ``` <xsl:value-of select="body" /> ``` the p tags seem to get stripped out. I'm using Visual Studio 2005's implementation of XSL. Does anyone have ...
Try to use ``` <xsl:copy-of select="body"/> ``` instead. From [w3schools' documentation on same](http://www.w3schools.com/XSL/el_copy-of.asp): > > The `<xsl:copy-of>` element creates a > copy of the current node. > > > Note: Namespace nodes, child nodes, > and attributes of the current node are > automaticall...
162,255
<p>What's the best way, using SQL, to check the maximum number of connections that is allowed for an Oracle database? In the end, I would like to show the current number of sessions and the total number allowed, e.g. "Currently, 23 out of 80 connections are used".</p>
[ { "answer_id": 162374, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 5, "selected": false, "text": "<p>I thought this would work, based on <a href=\"http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/dynvie...
2008/10/02
[ "https://Stackoverflow.com/questions/162255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24495/" ]
What's the best way, using SQL, to check the maximum number of connections that is allowed for an Oracle database? In the end, I would like to show the current number of sessions and the total number allowed, e.g. "Currently, 23 out of 80 connections are used".
There are a few different limits that might come in to play in determining the number of connections an Oracle database supports. The simplest approach would be to use the SESSIONS parameter and V$SESSION, i.e. The number of sessions the database was configured to allow ``` SELECT name, value FROM v$parameter WHE...
162,276
<p>I am wanting to use the Facebox plugin for JQuery but am having a few issues getting it running how I want. The div that houses the facebox content is created outside of the tag so even though I am loading up some web controls none of them are firing back to the server.</p> <p>Has anyone dealt with this that can ...
[ { "answer_id": 162317, "author": "Kevin Sheffield", "author_id": 590, "author_profile": "https://Stackoverflow.com/users/590", "pm_score": 3, "selected": true, "text": "<p>poking around the facebox.js I came across this line in the function init(settings)...</p>\n\n<pre><code>$('body').a...
2008/10/02
[ "https://Stackoverflow.com/questions/162276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/590/" ]
I am wanting to use the Facebox plugin for JQuery but am having a few issues getting it running how I want. The div that houses the facebox content is created outside of the tag so even though I am loading up some web controls none of them are firing back to the server. Has anyone dealt with this that can give me some...
poking around the facebox.js I came across this line in the function init(settings)... ``` $('body').append($.facebox.settings.faceboxHtml) ``` I changed that to ... ``` $('#aspnetForm').append($.facebox.settings.faceboxHtml) ``` and it loads up in the form tag, not sure yet if there are any side effects
162,291
<p>How can I check if an application is running from a batch (well cmd) file?</p> <p>I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.)</p> <p>Also the application could be running as any user.</p>
[ { "answer_id": 162302, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": -1, "selected": false, "text": "<p>You should check the parent process name, see <a href=\"http://en.wikipedia.org/wiki/The_Code_Project\" rel=\"nofollow nor...
2008/10/02
[ "https://Stackoverflow.com/questions/162291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1755/" ]
How can I check if an application is running from a batch (well cmd) file? I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.) Also the application could be running as any user.
Another possibility I came up with, which does not require to save a file, inspired by using [grep](http://en.wikipedia.org/wiki/Grep) is: ``` tasklist /fi "ImageName eq MyApp.exe" /fo csv 2>NUL | find /I "myapp.exe">NUL if "%ERRORLEVEL%"=="0" echo Program is running ``` * `/fi ""` defines a filter of apps to find, ...
162,298
<p>I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value.</p> <p>How do i express this with </p> <pre><code>validates_presence_of </code></pre> <p>statemen...
[ { "answer_id": 162334, "author": "Bartosz Blimke", "author_id": 18715, "author_profile": "https://Stackoverflow.com/users/18715", "pm_score": 4, "selected": true, "text": "<pre><code>validates_presence_of :main_file, :if =&gt; Proc.new { |p| p.alt_file.blank? }\nvalidates_presence_of :al...
2008/10/02
[ "https://Stackoverflow.com/questions/162298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
I have a basic ActiveRecord model in which i have two fields that i would like to validate. The requirement is that at least one of the fields must have a value. Both can have values, but at least one needs a value. How do i express this with ``` validates_presence_of ``` statements? For example: ``` validates_p...
``` validates_presence_of :main_file, :if => Proc.new { |p| p.alt_file.blank? } validates_presence_of :alt_file, :if => Proc.new { |p| p.main_file.blank? } ```
162,309
<p>To pop up the UAC dialog in Vista when writing to the HKLM registry hive, we opt to not use the Win32 Registry API, as when Vista permissions are lacking, we'd need to relaunch our entire application with administrator rights. Instead, we do this trick:</p> <pre><code>ShellExecute(hWnd, "runas" /* display UAC promp...
[ { "answer_id": 162327, "author": "Rob", "author_id": 7872, "author_profile": "https://Stackoverflow.com/users/7872", "pm_score": 2, "selected": false, "text": "<p>Have you considered creating a small \"helper\" application to make the registry update for you? If you compile it to 64bit a...
2008/10/02
[ "https://Stackoverflow.com/questions/162309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9744/" ]
To pop up the UAC dialog in Vista when writing to the HKLM registry hive, we opt to not use the Win32 Registry API, as when Vista permissions are lacking, we'd need to relaunch our entire application with administrator rights. Instead, we do this trick: ``` ShellExecute(hWnd, "runas" /* display UAC prompt on Vista */,...
try this (from a 32bit process): ``` > %WINDIR%\sysnative\reg.exe query ... ``` (found that [here](http://ovidiupl.spaces.live.com/blog/cns!1E8A6038167E4BE9!925.entry)).
162,325
<p>This has been an adventure. I started with the looping duplicate query located in <a href="https://stackoverflow.com/questions/161960">my previous question</a>, but each loop would go over all <strong>17 million records</strong>, <strong>meaning it would take weeks</strong> (just running <code>*select count * from M...
[ { "answer_id": 162378, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 1, "selected": false, "text": "<p>Run this in query analyzer:</p>\n\n<pre><code>SET SHOWPLAN_TEXT ON\n</code></pre>\n\n<p>Then ask query analyzer to run your...
2008/10/02
[ "https://Stackoverflow.com/questions/162325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
This has been an adventure. I started with the looping duplicate query located in [my previous question](https://stackoverflow.com/questions/161960), but each loop would go over all **17 million records**, **meaning it would take weeks** (just running `*select count * from MyTable*` takes my server 4:30 minutes using M...
Seeing the QueryPlan would help. Is this feasible? ``` SELECT m.* into #temp FROM tl_acxiomimport.dbo.tblacxiomlistings m inner join (SELECT RecordID, Rank() over (Partition BY BusinessName, latitude, lon...
162,326
<p>How to get the checked option in a group of radio inputs with JavaScript?</p>
[ { "answer_id": 162339, "author": "Torbjørn", "author_id": 22621, "author_profile": "https://Stackoverflow.com/users/22621", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.somacon.com/p143.php\" rel=\"nofollow noreferrer\">http://www.somacon.com/p143.php</a></p>\n" }...
2008/10/02
[ "https://Stackoverflow.com/questions/162326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100/" ]
How to get the checked option in a group of radio inputs with JavaScript?
``` <html> <head> <script type="text/javascript"> function testR(){ var x = document.getElementsByName('r') for(var k=0;k<x.length;k++) if(x[k].checked){ alert('Option selected: ' + x[k].value) } } </script> </head> <body> <form> <inpu...
162,331
<p>I'm developing an application targeting .NET Framework 2.0 using C# for which I need to be able to find the default application that is used for opening a particular file type.</p> <p>I know that, for example, if you just want to open a file using that application you can use something like:</p> <pre><code>System....
[ { "answer_id": 162351, "author": "curtisk", "author_id": 17651, "author_profile": "https://Stackoverflow.com/users/17651", "pm_score": 5, "selected": true, "text": "<p>You can check under registry section <code>HKEY_CLASSES_ROOT</code> for the extension and action details. Documentation ...
2008/10/02
[ "https://Stackoverflow.com/questions/162331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17786/" ]
I'm developing an application targeting .NET Framework 2.0 using C# for which I need to be able to find the default application that is used for opening a particular file type. I know that, for example, if you just want to open a file using that application you can use something like: ``` System.Diagnostics.Process.S...
You can check under registry section `HKEY_CLASSES_ROOT` for the extension and action details. Documentation for this is [on MSDN](http://msdn.microsoft.com/en-us/library/cc144148.aspx). Alternatively, you can use the [IQueryAssociations](http://msdn.microsoft.com/en-us/library/bb761400.aspx) interface.
162,399
<p>Hi why doesn't this work in SQL Server 2005?</p> <pre><code>select HALID, count(HALID) as CH from Outages.FaultsInOutages where CH &gt; 3 group by HALID </code></pre> <p>I get invalid column name 'CH'</p> <hr> <p>i think having was the right way to go but still receive the error: Invalid column name 'CH'.</p> ...
[ { "answer_id": 162406, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>Try</p>\n\n<pre><code>select HALID, count(HALID) from Outages.FaultsInOutages \ngroup by HALID having count(HALID...
2008/10/02
[ "https://Stackoverflow.com/questions/162399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21004/" ]
Hi why doesn't this work in SQL Server 2005? ``` select HALID, count(HALID) as CH from Outages.FaultsInOutages where CH > 3 group by HALID ``` I get invalid column name 'CH' --- i think having was the right way to go but still receive the error: Invalid column name 'CH'. When running: select HALID, count(HALID...
You can't use the alias in the where clause or having clause, as it isn't processed until AFTER the result set is generated, the proper syntax is ``` SELECT HALID, COUNT(HALID) AS CH FROM Outages.FaultsInOutages GROUP BY HALID HAVING COUNT(HALID) > 3 ``` This will group items on HALID, then ONLY return results that ...
162,421
<p>Being lazy (and liking DRY code), I'm the kind of guy who's going to write a few little wrappers for recurring HTML markup. Those provided by Rails are good already, but sometimes I have something a little more specific that I know I'm going to repeat over and over.</p> <p>In some situations a partial can be the so...
[ { "answer_id": 162508, "author": "Christoph Schiessl", "author_id": 20467, "author_profile": "https://Stackoverflow.com/users/20467", "pm_score": 0, "selected": false, "text": "<p>It's not a real solution but you could use tests (TestUnit, RSpec or whatever) to make sure your helpers wor...
2008/10/02
[ "https://Stackoverflow.com/questions/162421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6349/" ]
Being lazy (and liking DRY code), I'm the kind of guy who's going to write a few little wrappers for recurring HTML markup. Those provided by Rails are good already, but sometimes I have something a little more specific that I know I'm going to repeat over and over. In some situations a partial can be the solution, bu...
Good question! This is a technique I should abuse more frequently. ``` #I go in environment.db (presumably it will work in one of the per-environment files, too.) Dependencies.explicitly_unloadable_constants << 'NameOfHelperToReloadHere' ``` That array starts out empty, incidentally, at least in my install. ...
162,459
<p>I have 3 tables</p> <ol> <li><b>Links</b><br/> Link ID<br/> Link Name<br/> GroupID (FK into Groups)<br/> SubGroupID (FK into Subgroups)<br/> <br/></li> <li><p><b>Groups</b><br/> GroupID<br/> GroupName<br/></p></li> <li><p><b>SubGroup</b><br/> SubGroupID<br/> SubGroupName<br/> GroupID (FK into Groups)<br/></p></li> ...
[ { "answer_id": 162478, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 1, "selected": false, "text": "<pre><code>SELECT \n links.linkname\n , groups.groupname\n , subgroup.groupname\nFROM\n links \n JOIN groups ON links.g...
2008/10/02
[ "https://Stackoverflow.com/questions/162459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
I have 3 tables 1. **Links** Link ID Link Name GroupID (FK into Groups) SubGroupID (FK into Subgroups) 2. **Groups** GroupID GroupName 3. **SubGroup** SubGroupID SubGroupName GroupID (FK into Groups) Every link needs to have a GroupID but teh SubGroupID is optional. How do i write a SQL que...
This assumes that there is at most only 1 subgroup per group. if there are more, then you have the potential to get additional records. ``` select links.linkname, groups.groupname, subgroup.subgroupname from links inner join groups on (links.groupid = groups.groupid) left outer join subgroup on (links.subgroupid =...
162,480
<p>Consider:</p> <pre><code>int testfunc1 (const int a) { return a; } int testfunc2 (int const a) { return a; } </code></pre> <p>Are these two functions the same in every aspect or is there a difference?</p> <p>I'm interested in an answer for the C language, but if there is something interesting in the C++ lang...
[ { "answer_id": 162499, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": 2, "selected": false, "text": "<p>Yes, they are same for just <code>int</code></p>\n\n<p>and different for <code>int*</code></p>\n" }, { "answer_id":...
2008/10/02
[ "https://Stackoverflow.com/questions/162480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15955/" ]
Consider: ``` int testfunc1 (const int a) { return a; } int testfunc2 (int const a) { return a; } ``` Are these two functions the same in every aspect or is there a difference? I'm interested in an answer for the C language, but if there is something interesting in the C++ language, I'd like to know as well.
`const T` and `T const` are identical. With pointer types it becomes more complicated: 1. `const char*` is a pointer to a constant `char` 2. `char const*` is a pointer to a constant `char` 3. `char* const` is a constant pointer to a (mutable) `char` In other words, (1) and (2) are identical. The only way of making th...
162,497
<p>There is a select dropdown and I want to add &quot;No selection&quot; item to the list which should give me 'null' when submitted. I'm using SimpleFormController derived controller.</p> <pre><code>protected Map referenceData(HttpServletRequest httpServletRequest, Object o, Errors errors) throws Exception { Map&l...
[ { "answer_id": 171260, "author": "Jacob Mattison", "author_id": 1237, "author_profile": "https://Stackoverflow.com/users/1237", "pm_score": 6, "selected": true, "text": "<p>One option:</p>\n\n<pre class=\"lang-html prettyprint-override\"><code>&lt;form:select path=\"country\" title=\"cou...
2008/10/02
[ "https://Stackoverflow.com/questions/162497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
There is a select dropdown and I want to add "No selection" item to the list which should give me 'null' when submitted. I'm using SimpleFormController derived controller. ``` protected Map referenceData(HttpServletRequest httpServletRequest, Object o, Errors errors) throws Exception { Map<String, Object> map = ne...
One option: ```html <form:select path="country" title="country" > <form:option value="">&nbsp;</form:option> <form:options items="${countryList}" /> </form:select> ```
162,534
<p>I just wanna ask what would be better approach to supply these objects in my unit tests.</p> <p>In my unit test I am testing CSLA object. CSLA object is internally using one property and one method of ApplicationUser object. ApplicationUser is inherited from IPrincipal. The properties are: 1) ApplicationContext.Use...
[ { "answer_id": 162667, "author": "Carlton Jenke", "author_id": 1215, "author_profile": "https://Stackoverflow.com/users/1215", "pm_score": 2, "selected": false, "text": "<p>Here is the code I use to return a test user (using Stubs):</p>\n\n<pre><code> [SetUp]\n public void Setup()\...
2008/10/02
[ "https://Stackoverflow.com/questions/162534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24507/" ]
I just wanna ask what would be better approach to supply these objects in my unit tests. In my unit test I am testing CSLA object. CSLA object is internally using one property and one method of ApplicationUser object. ApplicationUser is inherited from IPrincipal. The properties are: 1) ApplicationContext.User.IsInRole...
The reason you're getting a null reference error is because `IPrincipal.Identity` is null; it hasn't been set in your mocked `IPrincipal` yet. Calling `.Name` the null `Identity` results in your exception. The answer, as Carlton pointed out, is to mock `IIdentity` *also*, and set it up to return "ju" for its `Name` pr...
162,537
<p>I just upgraded a VS 2005 project to VS 2008 and was examining the changes. I noticed one of the .Designer.cs files had changed significantly. The majority of the changes were simply replacements of <em>System</em> with <em>global::System</em>. For example,</p> <pre><code>protected override System.Data.DataTable ...
[ { "answer_id": 162554, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 5, "selected": true, "text": "<p>The :: operator is called a Namespace Alias Qualifier.</p>\n\n<pre><code> global::System.Data.DataTable \n</code></pre>\n\...
2008/10/02
[ "https://Stackoverflow.com/questions/162537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4228/" ]
I just upgraded a VS 2005 project to VS 2008 and was examining the changes. I noticed one of the .Designer.cs files had changed significantly. The majority of the changes were simply replacements of *System* with *global::System*. For example, ``` protected override System.Data.DataTable CreateInstance() ``` became ...
The :: operator is called a Namespace Alias Qualifier. ``` global::System.Data.DataTable ``` is the same as: ``` System.Data.DataTable ``` Visual Studio 2008 added it to the designer generated code to avoid ambigious reference issues that occasionally happened when people created classes named System...For exa...
162,542
<p>How do you perform delete and put operations restfully in rails? I have read the documentation and thought I was doing everything properly, but I can't seem to get it to work.</p> <p>For example, if I wanted to delete an employee I would create a controller called "EmployeesController" and create a destroy method t...
[ { "answer_id": 162590, "author": "Matthias Winkelmann", "author_id": 4494, "author_profile": "https://Stackoverflow.com/users/4494", "pm_score": 4, "selected": true, "text": "<p>Try </p>\n\n<pre><code>:url =&gt; employee_url(@employee)\n</code></pre>\n\n<p>IIRC, *_path is a named route g...
2008/10/02
[ "https://Stackoverflow.com/questions/162542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5923/" ]
How do you perform delete and put operations restfully in rails? I have read the documentation and thought I was doing everything properly, but I can't seem to get it to work. For example, if I wanted to delete an employee I would create a controller called "EmployeesController" and create a destroy method to perform ...
Try ``` :url => employee_url(@employee) ``` IIRC, \*\_path is a named route generated by the :resource directive which includes the method, thus overwriting your :method => :delete
162,564
<p>I need a way to update the month value on a dateTime field in my db. I'm being past an int value for the month and need to use that for the update. Is it possible to do this in the sql statement or would I be best doing it in c# in the webservice?</p>
[ { "answer_id": 162584, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 3, "selected": true, "text": "<p>Shift down and then up again:</p>\n\n<pre><code>UPDATE table\nSET datecol = DATEADD(m, @newmonth, DATEADD(m, -MONTH(da...
2008/10/02
[ "https://Stackoverflow.com/questions/162564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
I need a way to update the month value on a dateTime field in my db. I'm being past an int value for the month and need to use that for the update. Is it possible to do this in the sql statement or would I be best doing it in c# in the webservice?
Shift down and then up again: ``` UPDATE table SET datecol = DATEADD(m, @newmonth, DATEADD(m, -MONTH(datecol), datecol)) WHERE id = @id ``` or, more simply: ``` UPDATE table SET datecol = DATEADD(m, @newmonth - MONTH(datecol), datecol) WHERE id = @id ```