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
231,198
<p>The following code compiles correctly under VC++ 8 on XPSP3, but running it causes a runtime error. </p> <p>My header looks like:</p> <pre><code>#include &lt;stdexcept&gt; #include &lt;iterator&gt; #include &lt;list&gt; template&lt;typename T&gt; class test_generator { public: typedef T result_type; ...
[ { "answer_id": 231270, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 0, "selected": false, "text": "<p>I haven't figured out what's causing the exception so far, but you may wish to have <code>return *value++</code> in your ...
2008/10/23
[ "https://Stackoverflow.com/questions/231198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
The following code compiles correctly under VC++ 8 on XPSP3, but running it causes a runtime error. My header looks like: ``` #include <stdexcept> #include <iterator> #include <list> template<typename T> class test_generator { public: typedef T result_type; //constructor test_generator() { ...
The `test_generator` constructor initialises the `value` iterator to reference the first element in the `tests` list (which is a member of `test_generator`). When you call `std::generate_n`, a copy of the `test` is made (because the object is passed by value). In the copied object, the `value` iterator refers to the `...
231,204
<p>I'm working on updating a classic ASP web page used by a number of sub-sites maintained at the company I work for.</p> <p>The purpose of the page is to notify the user that they are leaving "our" site and going to another site. It's basically a disclaimer, but due to resource limitations and time limitations I can'...
[ { "answer_id": 231606, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>This is what I recommend for HTML sanitizing -</p>\n\n<p>HTML Whitelist is the latest in the \"cool little Python Web servic...
2008/10/23
[ "https://Stackoverflow.com/questions/231204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3349/" ]
I'm working on updating a classic ASP web page used by a number of sub-sites maintained at the company I work for. The purpose of the page is to notify the user that they are leaving "our" site and going to another site. It's basically a disclaimer, but due to resource limitations and time limitations I can't add the ...
This is what I recommend for HTML sanitizing - HTML Whitelist is the latest in the "cool little Python Web service thrown up on App Engine" by my good colleague DeWitt Clinton. It does one thing, and it does it well. You can pass the service HTML and it will return a sanitized version. <http://html-whitelist.appspot...
231,226
<pre><code> include('adodb5/adodb.inc.php'); $myServer = "localhost"; $myUser = "root"; $myPass = "root"; $myDB = "database"; //create an instance of the ADO connection object $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); //define conn...
[ { "answer_id": 231301, "author": "Toby Allen", "author_id": 6244, "author_profile": "https://Stackoverflow.com/users/6244", "pm_score": 0, "selected": false, "text": "<p>The most likely cause is that ADO is not correctly installed on the server. Try running the latest version of MDAC and...
2008/10/23
[ "https://Stackoverflow.com/questions/231226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` include('adodb5/adodb.inc.php'); $myServer = "localhost"; $myUser = "root"; $myPass = "root"; $myDB = "database"; //create an instance of the ADO connection object $conn = new COM("ADODB.Connection") or die("Cannot start ADO"); //define connection ...
If you want to use following code: ``` new COM("ADODB.Connection") ``` you need to enable "COM support" in PHP, such using the com\_dotnet extension (php\_com\_dotnet.dll) [How to install COM extension](http://php.net//manual/fr/com.installation.php)
231,229
<p>I have source in a bunch of subdirectories like:</p> <pre><code>src/widgets/apple.cpp src/widgets/knob.cpp src/tests/blend.cpp src/ui/flash.cpp </code></pre> <p>In the root of the project I want to generate a single Makefile using a rule like:</p> <pre><code>%.o: %.cpp $(CC) -c $&lt; build/test.exe: build/wid...
[ { "answer_id": 231251, "author": "stephanea", "author_id": 8776, "author_profile": "https://Stackoverflow.com/users/8776", "pm_score": 0, "selected": false, "text": "<p>Usually, you create a Makefile in each subdirectory, and write in the top-level Makefile to call make in the subdirecto...
2008/10/23
[ "https://Stackoverflow.com/questions/231229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7743/" ]
I have source in a bunch of subdirectories like: ``` src/widgets/apple.cpp src/widgets/knob.cpp src/tests/blend.cpp src/ui/flash.cpp ``` In the root of the project I want to generate a single Makefile using a rule like: ``` %.o: %.cpp $(CC) -c $< build/test.exe: build/widgets/apple.o build/widgets/knob.o build/...
The reason is that your rule ``` %.o: %.cpp ... ``` expects the .cpp file to reside in the same directory as the .o your building. Since test.exe in your case depends on build/widgets/apple.o (etc), make is expecting apple.cpp to be build/widgets/apple.cpp. You can use VPATH to resolve this: ``` VPATH = src...
231,250
<p>How would you write a non-recursive algorithm to compute <code>n!</code>?</p>
[ { "answer_id": 231254, "author": "JohnMcG", "author_id": 1674, "author_profile": "https://Stackoverflow.com/users/1674", "pm_score": 3, "selected": false, "text": "<p>Rewrite the recursive solution as a loop.</p>\n" }, { "answer_id": 231255, "author": "Chris Marasti-Georg", ...
2008/10/23
[ "https://Stackoverflow.com/questions/231250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How would you write a non-recursive algorithm to compute `n!`?
Since an Int32 is going to overflow on anything bigger than 12! anyway, just do: ``` public int factorial(int n) { int[] fact = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600}; return fact[n]; } ```
231,259
<p>I'm trying to delete a directory that contains XML files from a remote computer. My code compiles and runs fine, but when I go to get a list of XML files in the path I specify, it is not returning anything. Am I missing something permission wise? </p> <p>I have ran it from my computer logged on as myself and from a...
[ { "answer_id": 231294, "author": "Ely", "author_id": 30488, "author_profile": "https://Stackoverflow.com/users/30488", "pm_score": 0, "selected": false, "text": "<p>I assume you are passing in a network path?\nDoes it fail when you run the program on a local path?\nDoes this line:\nfi = ...
2008/10/23
[ "https://Stackoverflow.com/questions/231259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444511/" ]
I'm trying to delete a directory that contains XML files from a remote computer. My code compiles and runs fine, but when I go to get a list of XML files in the path I specify, it is not returning anything. Am I missing something permission wise? I have ran it from my computer logged on as myself and from another com...
I think you should be using \*.xml instead of simply .xml. But I also concur with Kyralessa, test on your local machine first, then add in the complexity of going across a network.
231,288
<p>I have started using Jython as it seems to be a excellent language, and has proved to be so far.</p> <p>I am using dom4j to manipulate and retrieve data from the DOM of a bunch of HTML files I have on disk. I have wrote the below script to check threw the DOM using Xpath for <strong>H1</strong> tags and grab text,...
[ { "answer_id": 231335, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": true, "text": "<p>How about this (I don't claim to know much about Python, by the way, but this looks like an obvious first step):</p>\n\n<p...
2008/10/23
[ "https://Stackoverflow.com/questions/231288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30786/" ]
I have started using Jython as it seems to be a excellent language, and has proved to be so far. I am using dom4j to manipulate and retrieve data from the DOM of a bunch of HTML files I have on disk. I have wrote the below script to check threw the DOM using Xpath for **H1** tags and grab text, if a **H1** tag is not ...
How about this (I don't claim to know much about Python, by the way, but this looks like an obvious first step): ``` for path in ('//xhtml:h1', '//xhtml:title'): elemHolder = dom.createXPath(path) elemHolder.namespaceURIs = map elem = elemHolder.selectSingleNode(dom) if elem is not None: return...
231,318
<p>When I first discovered the Strategy pattern, I was amazed of the seemingly endless possibilities it offered to me and my programs. I could better encapsulate my models' behaviour and even exchange this behaviour on the fly. But the strategy could also be used to to provide traits and payload to the containing objec...
[ { "answer_id": 231343, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 3, "selected": false, "text": "<p>I thought they were the <a href=\"http://en.wikipedia.org/wiki/Strategy_pattern\" rel=\"noreferrer\">same thing</...
2008/10/23
[ "https://Stackoverflow.com/questions/231318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25965/" ]
When I first discovered the Strategy pattern, I was amazed of the seemingly endless possibilities it offered to me and my programs. I could better encapsulate my models' behaviour and even exchange this behaviour on the fly. But the strategy could also be used to to provide traits and payload to the containing object -...
Policies are largely set at compile time, while strategies are set at runtime. Further, policies are generally a C++ concept, and apply only to a minority of other languages(for example D), while strategy pattern is available to many (most?) object oriented languages, and languages that treat functions as first class c...
231,321
<p>I cant' figure out how to reference the current instance object defined by the XAML file in the XAML file.</p> <p>I have a converter that I want to send in the current instance as the parameter object.</p> <pre><code>{Binding Path=&lt;bindingObject&gt;, Converter={x:Static namespace:Converter.Instance}, ConverterP...
[ { "answer_id": 231446, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 0, "selected": false, "text": "<p>Have you tried using the <a href=\"http://msdn.microsoft.com/en-us/library/ms743599.aspx\" rel=\"nofollow norefe...
2008/10/23
[ "https://Stackoverflow.com/questions/231321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9331/" ]
I cant' figure out how to reference the current instance object defined by the XAML file in the XAML file. I have a converter that I want to send in the current instance as the parameter object. ``` {Binding Path=<bindingObject>, Converter={x:Static namespace:Converter.Instance}, ConverterParameter=this} ``` In thi...
According to the [Data Binding Overview](http://msdn.microsoft.com/en-us/library/ms752347.aspx#current_record_pointers), you can use the "/" to indicate the current item. You can then navigate up and down the tree as needs be using the following type syntaxes: ``` <Button Content="{Binding }" /> <Button Content="{Bind...
231,323
<p>Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode?</p>
[ { "answer_id": 231353, "author": "Keith", "author_id": 905, "author_profile": "https://Stackoverflow.com/users/905", "pm_score": 0, "selected": false, "text": "<p>I don't think there is, but why would you need to? Each is the lowest 'leaf' of the Xml structure for different ways of readi...
2008/10/23
[ "https://Stackoverflow.com/questions/231323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21909/" ]
Anyone know off the top of their heads how to convert a System.Xml.XmlNode to System.Xml.Linq.XNode?
I've never tried, but my first thought would be something like: ``` XmlNode myNode; XNode translatedNode = XDocument.Parse(myNode.OuterXml); ```
231,327
<p>I want to use the <a href="http://simplehtmldom.sourceforge.net/manual_api.htm" rel="noreferrer">php simple HTML DOM parser</a> to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set_callback which Sets a callback function. However ...
[ { "answer_id": 231339, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 6, "selected": true, "text": "<p>Here's a basic callback function example:</p>\n\n<pre><code>&lt;?php\n\nfunction thisFuncTakesACallback($callbackFunc)\n{\...
2008/10/23
[ "https://Stackoverflow.com/questions/231327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]
I want to use the [php simple HTML DOM parser](http://simplehtmldom.sourceforge.net/manual_api.htm) to grab the image, title, date, and description from each article on a page full of articles. When looking at the API I notice it has a set\_callback which Sets a callback function. However im not sure what this does or ...
Here's a basic callback function example: ``` <?php function thisFuncTakesACallback($callbackFunc) { echo "I'm going to call $callbackFunc!<br />"; $callbackFunc(); } function thisFuncGetsCalled() { echo "I'm a callback function!<br />"; } thisFuncTakesACallback( 'thisFuncGetsCalled' ); ?> ``` You can...
231,340
<p>In a project I am working on, Apache is set up to only forward requests that come in as /prefix/* to mongrel. How can I tell ruby on rails to generate all URLs with that prefix? </p> <p>I have the routes set up for forward to the correct controller action by doing this:</p> <pre><code>map.connect 'sfc/:controller/...
[ { "answer_id": 231417, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 2, "selected": false, "text": "<p>The <code>RAILS_RELATIVE_URL_ROOT</code> environment variable should do the trick, though I haven't tried it mysel...
2008/10/23
[ "https://Stackoverflow.com/questions/231340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
In a project I am working on, Apache is set up to only forward requests that come in as /prefix/\* to mongrel. How can I tell ruby on rails to generate all URLs with that prefix? I have the routes set up for forward to the correct controller action by doing this: ``` map.connect 'sfc/:controller/:action' ``` but t...
Mongrel accepts a --prefix option that will then be prepended to all generated URLs. This is the only way I know of to be able to run multiple instances of the same application on one server.
231,355
<p>Hi guys I wrote this code and i have two errors.</p> <ol> <li>Invalid rank specifier: expected ',' or ']' </li> <li>Cannot apply indexing with [] to an expression of type 'int'</li> </ol> <p>Can you help please?</p> <pre><code> static void Main(string[] args) { ArrayList numbers = new ArrayList();...
[ { "answer_id": 231365, "author": "Aaron Smith", "author_id": 12969, "author_profile": "https://Stackoverflow.com/users/12969", "pm_score": 3, "selected": false, "text": "<p>1 - You don't have to specify the length of the array just say new int[]</p>\n\n<p>2 - number is just an integer, I...
2008/10/23
[ "https://Stackoverflow.com/questions/231355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30858/" ]
Hi guys I wrote this code and i have two errors. 1. Invalid rank specifier: expected ',' or ']' 2. Cannot apply indexing with [] to an expression of type 'int' Can you help please? ``` static void Main(string[] args) { ArrayList numbers = new ArrayList(); foreach (int number in new int[12] {...
``` using System; using System.Collections; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { ArrayList numbers = new ArrayList(); foreach (int number in new int[] { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }) { numbers.Ad...
231,358
<p>I'm using NuSOAP on PHP 5.2.6 and I'm seeing that the max message size is only 1000 bytes (which makes it tough to do anything meaningful). Is this set in the endpoint's WSDL or is this something I can configure in NuSOAP?</p>
[ { "answer_id": 232448, "author": "rjray", "author_id": 6421, "author_profile": "https://Stackoverflow.com/users/6421", "pm_score": 2, "selected": false, "text": "<p>I am only passingly-familiar with PHP, and have never used the NuSOAP package at all. However, a SOAP message's size should...
2008/10/23
[ "https://Stackoverflow.com/questions/231358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
I'm using NuSOAP on PHP 5.2.6 and I'm seeing that the max message size is only 1000 bytes (which makes it tough to do anything meaningful). Is this set in the endpoint's WSDL or is this something I can configure in NuSOAP?
Regarding the FUD about a "1000 bytes limit"... I looked up the nusoap\_client sourcecode and found that the limit is only effective for **debug output**. This means all data is processed and passed on to the webservice (regardless of its size), but only the first 1000 bytes (or more precisely: characters) are shown i...
231,362
<p>For some weeks now I simply can't run gem install in windows. It sticks on this line:</p> <pre><code>C:\Windows\System32&gt;gem install rails --version 2.1.2 Bulk updating Gem source index for: http://gems.rubyforge.org/ </code></pre> <p>Any ideas what it could be?</p>
[ { "answer_id": 231603, "author": "hectorsq", "author_id": 14755, "author_profile": "https://Stackoverflow.com/users/14755", "pm_score": 1, "selected": false, "text": "<p>It worked fine on my Windows Server 2003 machine. I am using gem version 1.3.0.</p>\n" }, { "answer_id": 23167...
2008/10/23
[ "https://Stackoverflow.com/questions/231362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19224/" ]
For some weeks now I simply can't run gem install in windows. It sticks on this line: ``` C:\Windows\System32>gem install rails --version 2.1.2 Bulk updating Gem source index for: http://gems.rubyforge.org/ ``` Any ideas what it could be?
Have you been able to install stuff previously? The gem index is pretty big, about 26MB it seems - what sort of connection do you have? If you have dialup (or 512kbit "broadband" etc), it *will* take quite a while to update. You could just grab the rails gem file and install it with `gem install rails.gem` - <http://...
231,364
<p>I am currently building a small website where the content of the main div is being filled through an Ajax call. I basically have a php script that returns the content like this:</p> <p>(simplified php script...)</p> <pre><code> if(isset($_POST["id_tuto"])){ PrintHtml($_POST["id_tuto"]); } function PrintHtml($id...
[ { "answer_id": 231394, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 0, "selected": false, "text": "<p>You just do it the way you'd normally generate an HTML page, except it is not wrapped in HTML HEAD o...
2008/10/23
[ "https://Stackoverflow.com/questions/231364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25152/" ]
I am currently building a small website where the content of the main div is being filled through an Ajax call. I basically have a php script that returns the content like this: (simplified php script...) ``` if(isset($_POST["id_tuto"])){ PrintHtml($_POST["id_tuto"]); } function PrintHtml($id) { switch($id) {...
You could do it like so: ``` <?php function PrintHtml($id) { switch($id) { case [...]: ?> <h1>Tut page 1</h1> <p>this is html content.</p> <?php break; [...] } } ?> ``` Or perhaps: ``` <?php function PrintHtml($id) { switch($id) { case [...]: incl...
231,377
<p>I would like to use JavaScript to manipulate hidden input fields in a JSF/Facelets page. When the page loads, I need to set a hidden field to the color depth of the client.</p> <p>From my Facelet:</p> <pre><code>&lt;body onload="setColorDepth(document.getElementById(?????);"&gt; &lt;h:form&gt; &lt;h:inputHidden...
[ { "answer_id": 231393, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": true, "text": "<p>You'll want to set the ID of the form so you'll know what it is. Then you'll be able to construct the actual element ID.</...
2008/10/23
[ "https://Stackoverflow.com/questions/231377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27515/" ]
I would like to use JavaScript to manipulate hidden input fields in a JSF/Facelets page. When the page loads, I need to set a hidden field to the color depth of the client. From my Facelet: ``` <body onload="setColorDepth(document.getElementById(?????);"> <h:form> <h:inputHidden value="#{login.colorDepth}" id="col...
You'll want to set the ID of the form so you'll know what it is. Then you'll be able to construct the actual element ID. ``` <body onload="setColorDepth(document.getElementById('myForm:colorDepth');"> <h:form id="myForm"> <h:inputHidden value="#{login.colorDepth}" id="colorDepth" /> </h:form> ``` If you don't wan...
231,381
<p>Is this seen as an in efficient prime number generator. It seems to me that this is pretty efficient. Is it the use of the stream that makes the program run slower?</p> <p>I am trying to submit this to <a href="http://www.spoj.pl/" rel="nofollow noreferrer">SPOJ</a> and it tells me that my time limit exceeded... </...
[ { "answer_id": 231398, "author": "Matt J", "author_id": 18528, "author_profile": "https://Stackoverflow.com/users/18528", "pm_score": 5, "selected": true, "text": "<p>This is one step (skipping even numbers) above the naive algorithm. I would suggest the <a href=\"http://en.wikipedia.or...
2008/10/23
[ "https://Stackoverflow.com/questions/231381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29326/" ]
Is this seen as an in efficient prime number generator. It seems to me that this is pretty efficient. Is it the use of the stream that makes the program run slower? I am trying to submit this to [SPOJ](http://www.spoj.pl/) and it tells me that my time limit exceeded... ``` #include <iostream> #include <sstream> usi...
This is one step (skipping even numbers) above the naive algorithm. I would suggest the [Sieve Of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) as a more efficient algorithm. From the above link: > > The complexity of the algorithm is > O((nlogn)(loglogn)) with a memory > requirement of O(n). Th...
231,390
<p>I've been trying to install <a href="http://thoughtbot.com/projects/shoulda" rel="nofollow noreferrer">Shoulda</a></p> <pre><code>script/plugin install git://github.com/thoughtbot/shoulda.git </code></pre> <p>but all I get is:</p> <pre><code>removing: C:/Documents and Settings/Danny/My Documents/Projects/Ruby On ...
[ { "answer_id": 231396, "author": "Jordi Bunster", "author_id": 4272, "author_profile": "https://Stackoverflow.com/users/4272", "pm_score": 4, "selected": true, "text": "<p>Do you have git installed? If you don't, it will just not work. Rails assumes git is installed and can be found in y...
2008/10/23
[ "https://Stackoverflow.com/questions/231390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
I've been trying to install [Shoulda](http://thoughtbot.com/projects/shoulda) ``` script/plugin install git://github.com/thoughtbot/shoulda.git ``` but all I get is: ``` removing: C:/Documents and Settings/Danny/My Documents/Projects/Ruby On Rails/_ProjectName_/vendor/plugins/shoulda/.git > ``` And the `vender/pl...
Do you have git installed? If you don't, it will just not work. Rails assumes git is installed and can be found in your PATH. You can get Git for Windows [here](http://code.google.com/p/msysgit/downloads/list).
231,439
<p>Is there any easy way to create an acronym from a string?</p> <pre><code>First_name Middle_name Last_name =&gt; FML first_name middle_name last_name =&gt; FML First_name-Middle_name Last_name =&gt; F-ML first_name-middle_name last_name =&gt; F-ML </code></pre>
[ { "answer_id": 231459, "author": "Totty", "author_id": 30838, "author_profile": "https://Stackoverflow.com/users/30838", "pm_score": 0, "selected": false, "text": "<p>I don't know about language agnostic, but I would make a function that accepts an args[] parameter to bring in all of you...
2008/10/23
[ "https://Stackoverflow.com/questions/231439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3718/" ]
Is there any easy way to create an acronym from a string? ``` First_name Middle_name Last_name => FML first_name middle_name last_name => FML First_name-Middle_name Last_name => F-ML first_name-middle_name last_name => F-ML ```
Does language-agnostic means you have to use pseudocode? If not, then in Ruby: `"First_name-Middle_nameLast_name".gsub('-', ' - ').gsub(/\B[A-Z]+/, ' \&').split(' ').map { |s| s[0..0] }.join.upcase => "F-ML"` If it turns out the lack of space in the third example is a typo, you can skip the second call to `gsub` (wit...
231,491
<p>Is there an elegant way to create and initialize a <code>const std::vector&lt;const T&gt;</code> like <code>const T a[] = { ... }</code> to a fixed (and small) number of values?<br> I need to call a function frequently which expects a <code>vector&lt;T&gt;</code>, but these values will never change in my case.</p> ...
[ { "answer_id": 231495, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 7, "selected": true, "text": "<p>For C++11:</p>\n<pre><code>vector&lt;int&gt; luggage_combo = { 1, 2, 3, 4, 5 };\n</code></pre>\n<p><strong>Original answ...
2008/10/23
[ "https://Stackoverflow.com/questions/231491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26613/" ]
Is there an elegant way to create and initialize a `const std::vector<const T>` like `const T a[] = { ... }` to a fixed (and small) number of values? I need to call a function frequently which expects a `vector<T>`, but these values will never change in my case. In principle I thought of something like ``` namespa...
For C++11: ``` vector<int> luggage_combo = { 1, 2, 3, 4, 5 }; ``` **Original answer:** You would either have to wait for C++0x or use something like [Boost.Assign](http://www.boost.org/doc/libs/1_36_0/libs/assign/doc/index.html) to do that. e.g.: ``` #include <boost/assign/std/vector.hpp> using namespace boost::a...
231,512
<p>I am using RedCloth with Rails 2.1.1. The Textile <code>&lt;del&gt;</code> tag markup format (i.e. -delete-) was not translating at all. Tried a few choice options.</p> <pre><code>&gt; x=RedCloth.new('foobar -blah-') =&gt; "foobar -blah-" &gt; x.to_html =&gt; "&lt;p&gt;foobar &lt;del&gt;blah&lt;/del&gt;&lt;/p&gt;"...
[ { "answer_id": 231660, "author": "Michael Sepcot", "author_id": 6033, "author_profile": "https://Stackoverflow.com/users/6033", "pm_score": 2, "selected": false, "text": "<p>Looks like RedCloth needs a little more syntax to interpret the delete tag as the first element after a list item....
2008/10/23
[ "https://Stackoverflow.com/questions/231512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14895/" ]
I am using RedCloth with Rails 2.1.1. The Textile `<del>` tag markup format (i.e. -delete-) was not translating at all. Tried a few choice options. ``` > x=RedCloth.new('foobar -blah-') => "foobar -blah-" > x.to_html => "<p>foobar <del>blah</del></p>" # WORKED! > x=RedCloth.new('foobar * -blah-') => "foobar * -blah-"...
Looks like RedCloth needs a little more syntax to interpret the delete tag as the first element after a list item... ``` >> RedCloth.new("foobar\n* [-blah-]").to_html => "<p>foobar</p>\n<ul>\n\t<li><del>blah</del></li>\n</ul>" ```
231,525
<p>We're all familiar with the horror that is C# event declaration. To ensure thread-safety, <a href="http://blogs.msdn.com/brada/archive/2005/01/14/353132.aspx" rel="noreferrer">the standard is to write something like this</a>:</p> <pre><code>public event EventHandler SomethingHappened; protected virtual void OnSome...
[ { "answer_id": 231536, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>It will still work with events that have an explicit add/remove - you just need to use the delegate variable (or howev...
2008/10/23
[ "https://Stackoverflow.com/questions/231525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5486/" ]
We're all familiar with the horror that is C# event declaration. To ensure thread-safety, [the standard is to write something like this](http://blogs.msdn.com/brada/archive/2005/01/14/353132.aspx): ``` public event EventHandler SomethingHappened; protected virtual void OnSomethingHappened(EventArgs e) { ...
It will still work with events that have an explicit add/remove - you just need to use the delegate variable (or however you've stored the delegate) instead of the event name. However, there's an easier way to make it thread-safe - initialize it with a no-op handler: ``` public event EventHandler SomethingHappened = ...
231,538
<p>So I have a snazzy custom route for login</p> <pre><code># routes.rb map.login '/login', :controller =&gt; 'sessions', :action =&gt; 'new' </code></pre> <p>Visit www.asite.com/login and you're there. As is custom with failed login, however, we'll do the following in our action. Note what happens on failed login....
[ { "answer_id": 231625, "author": "Michael Sepcot", "author_id": 6033, "author_profile": "https://Stackoverflow.com/users/6033", "pm_score": 0, "selected": false, "text": "<p>Change <code>render :action =&gt; 'new'</code> to <code>redirect_to login_path</code></p>\n" }, { "answer_...
2008/10/23
[ "https://Stackoverflow.com/questions/231538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14895/" ]
So I have a snazzy custom route for login ``` # routes.rb map.login '/login', :controller => 'sessions', :action => 'new' ``` Visit www.asite.com/login and you're there. As is custom with failed login, however, we'll do the following in our action. Note what happens on failed login. ``` # sessions_controller.rb ...
Your problem is this: the user first visits `/login` and fills in the form. When they submit the form, they POST to `/sessions`, which is why the browser URL changes. To get around this you can do two things: As Michael mentioned, you can redirect back to the :new action, changing the else to: ``` else flash[:war...
231,550
<p>I'd like to use the <a href="https://developer.mozilla.org/en/Rhino_JavaScript_Compiler" rel="nofollow noreferrer">Rhino JavaScript</a> compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for ...
[ { "answer_id": 231750, "author": "Vladimir Dyuzhev", "author_id": 1163802, "author_profile": "https://Stackoverflow.com/users/1163802", "pm_score": 4, "selected": true, "text": "<p>Why not simply use java task?</p>\n\n<pre><code>&lt;java fork=\"yes\" \n classpathref=\"build.path\" \n c...
2008/10/23
[ "https://Stackoverflow.com/questions/231550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28604/" ]
I'd like to use the [Rhino JavaScript](https://developer.mozilla.org/en/Rhino_JavaScript_Compiler) compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and jythonc tasks for Groovy, NetREXX(!) and Jython, respectiv...
Why not simply use java task? ``` <java fork="yes" classpathref="build.path" classname="org.mozilla.javascript.tools.jsc.Main" failonerror="true"> <arg value="-debug"/> ... <arg value="file.js"/> </java> ``` Any objections?
231,553
<p>As an amateur software developer (I'm still in academia) I've written a few schemas for XML documents. I routinely run into design flubs that cause ugly-looking XML documents because I'm not entirely certain what the semantics of XML exactly are.</p> <p>My assumptions:</p> <pre><code>&lt;property&gt; value &lt;/prop...
[ { "answer_id": 231578, "author": "Rob Wells", "author_id": 2974, "author_profile": "https://Stackoverflow.com/users/2974", "pm_score": 0, "selected": false, "text": "<p>Look at the relationships of the data you are trying to represent is the best approach that I've found.</p>\n" }, {...
2008/10/23
[ "https://Stackoverflow.com/questions/231553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29119/" ]
As an amateur software developer (I'm still in academia) I've written a few schemas for XML documents. I routinely run into design flubs that cause ugly-looking XML documents because I'm not entirely certain what the semantics of XML exactly are. My assumptions: ``` <property> value </property> ``` property = value...
See the tutorial: * "[**XML Schemas: Best Practices**](http://www.xfront.com/BestPracticesHomepage.html)" by [**Roger Costello**](http://www.xfront.com/). I also recommend: * [**Priscilla Walmsley**](http://www.datypic.com/about.html)'s book "[**Definitive XML Schema**](https://rads.stackoverflow.com/amzn/click/com...
231,592
<p>I have some char() fields in a DBF table that were left encrypted by a past developer in the project. </p> <p>However, I know the plaintext result of the decryption of several records. How can I determine the function/algorithm/scheme to decrypt the original data? These are some sample fields:</p> <p>For cryptext:...
[ { "answer_id": 231597, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 1, "selected": false, "text": "<p>Determining the algorithm used without the corresponding key may not be entirely useful.</p>\n\n<p>If the text is small en...
2008/10/23
[ "https://Stackoverflow.com/questions/231592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/861/" ]
I have some char() fields in a DBF table that were left encrypted by a past developer in the project. However, I know the plaintext result of the decryption of several records. How can I determine the function/algorithm/scheme to decrypt the original data? These are some sample fields: For cryptext: ``` b5 01 02 c1...
There is no easy way in general case. This question is too general. Try posting these plain + encrypted strings. EDIT: * for the sake of learning you can read this article : [Cryptography on Wikipedia](http://en.wikipedia.org/wiki/Cryptography) * if you really beleive the encryption is simple - check if it's a byte ...
231,630
<p>I want to override the default CreateObject() function in VBScript with my own.</p> <p>Basically this example in VB6:</p> <p><a href="http://www.darinhiggins.com/the-vb6-createobject-function/" rel="nofollow noreferrer">http://www.darinhiggins.com/the-vb6-createobject-function/</a></p> <p>I cannot figure out is t...
[ { "answer_id": 231657, "author": "chadmyers", "author_id": 10862, "author_profile": "https://Stackoverflow.com/users/10862", "pm_score": 0, "selected": false, "text": "<p>I don't think you can override it so that all code will use it, only YOUR code.</p>\n\n<p>In which case, it doesn't m...
2008/10/23
[ "https://Stackoverflow.com/questions/231630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to override the default CreateObject() function in VBScript with my own. Basically this example in VB6: <http://www.darinhiggins.com/the-vb6-createobject-function/> I cannot figure out is this line: ``` Set CreateObject = VBA.CreateObject(Class$, ServerName$) ``` How do I refer to "VBA" in VBSript?
This quick test seems to work... ``` Function CreateObject(className, serverName) '---- override the CreateObject ' function in order to register what ' object is being created in any error message ' that's generated Dim source, descr, errNum WScript.echo "In custom CreateObject" If L...
231,637
<p>I need to match (case insensitive) "abcd" and an optional trademark symbol</p> <p>Regex: <code>/abcd(™)?/gi</code></p> <p>See example:</p> <pre><code>preg_match("/abcd(™)?/gi","AbCd™ U9+",$matches); print_r($matches); </code></pre> <p>When I run this, <code>$matches</code> isn't populated with anything... Not e...
[ { "answer_id": 231648, "author": "theraccoonbear", "author_id": 7210, "author_profile": "https://Stackoverflow.com/users/7210", "pm_score": 2, "selected": false, "text": "<p>I suspect it has something to do with the literal trademark symbol.</p>\n\n<p>You'll probably want to check out ho...
2008/10/23
[ "https://Stackoverflow.com/questions/231637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53001/" ]
I need to match (case insensitive) "abcd" and an optional trademark symbol Regex: `/abcd(™)?/gi` See example: ``` preg_match("/abcd(™)?/gi","AbCd™ U9+",$matches); print_r($matches); ``` When I run this, `$matches` isn't populated with anything... Not even created as an empty array. Any ideas?
How is your file encoded? PHP has got issues when it comes to unicode. In your case, try using the escape sequence `\x99` instead of directly embedding the TM symbol.
231,638
<p>I've downloaded the source for SubSonic via SVN. When I try to open the project in Visual Studio 2008, it converts the solution, loads all the projects then disappears without an error message. Subsequent loads of the solution do the same. If I run devenv /safemode and then open the project it works fine, but I can'...
[ { "answer_id": 231687, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 2, "selected": false, "text": "<p>This was a conflict with PowerCommands (see <a href=\"https://stackoverflow.com/questions/134131/aspnet-mvc-ctp5-cra...
2008/10/23
[ "https://Stackoverflow.com/questions/231638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
I've downloaded the source for SubSonic via SVN. When I try to open the project in Visual Studio 2008, it converts the solution, loads all the projects then disappears without an error message. Subsequent loads of the solution do the same. If I run devenv /safemode and then open the project it works fine, but I can't u...
looks like this issue is reported: <http://code.msdn.microsoft.com/PowerCommands/WorkItem/View.aspx?WorkItemId=34>
231,647
<p>How do you set the timeout for blocking operations on a Ruby socket?</p>
[ { "answer_id": 231662, "author": "readonly", "author_id": 4883, "author_profile": "https://Stackoverflow.com/users/4883", "pm_score": 5, "selected": true, "text": "<p>The solution I found which appears to work is to use <a href=\"http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.h...
2008/10/23
[ "https://Stackoverflow.com/questions/231647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
How do you set the timeout for blocking operations on a Ruby socket?
The solution I found which appears to work is to use [Timeout::timeout](http://www.ruby-doc.org/stdlib/libdoc/timeout/rdoc/index.html): ``` require 'timeout' ... begin timeout(5) do message, client_address = some_socket.recvfrom(1024) end rescue Timeout::Error puts "Timed out!" end ```
231,649
<p>With common lisp and I am assuming the introspection properties. How can I add code to common lisp code that will tell me when a function is called and when has finished executing. I want to take any lisp code and this particular modification to the code. I figure with lisp's AST analysis, this should be possible...
[ { "answer_id": 231796, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 2, "selected": false, "text": "<p>Common lisp has a TRACE function that reports the function, arguments and resulting value of each call specified. Here i...
2008/10/23
[ "https://Stackoverflow.com/questions/231649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
With common lisp and I am assuming the introspection properties. How can I add code to common lisp code that will tell me when a function is called and when has finished executing. I want to take any lisp code and this particular modification to the code. I figure with lisp's AST analysis, this should be possible.
You can use [`(trace function)`](http://www.sbcl.org/manual/Function-Tracing.html) for a simple mechanism. For something more involved, here is a good discussion from [comp.lang.lisp](http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/75ddcdcc160508b0?pli=1). ``` [CL_USER]> (defun fac (n) "Naïve fa...
231,666
<p>I wonder if anyone could suggest the best way of looping through all the <code>&lt;option&gt;</code> s in a <code>&lt;select&gt;</code> element with jQuery, and building an array.</p> <p>Eg.</p> <p>Instead of the following, whereby a string ins passed to the autoCompleteArray(),</p> <pre><code>$("#CityLocal").au...
[ { "answer_id": 231699, "author": "Damir Zekić", "author_id": 401510, "author_profile": "https://Stackoverflow.com/users/401510", "pm_score": 4, "selected": true, "text": "<p>This should work:</p>\n\n<pre><code>$(document).ready(function(){\n // array of option elements' values\n var op...
2008/10/23
[ "https://Stackoverflow.com/questions/231666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
I wonder if anyone could suggest the best way of looping through all the `<option>` s in a `<select>` element with jQuery, and building an array. Eg. Instead of the following, whereby a string ins passed to the autoCompleteArray(), ``` $("#CityLocal").autocompleteArray( [ "Aberdeen", "Ada", "Adam...
This should work: ``` $(document).ready(function(){ // array of option elements' values var optionValues = []; // array of option elements' text var optionTexts = []; // iterate through all option elements $('#sel > option').each(function() { // get value/text and push it into respective array opt...
231,677
<p>Given this in a grails action:</p> <pre><code>def xml = { rss(version: '2.0') { ... } } render(contentType: 'application/rss+xml', xml) </code></pre> <p>I see this:</p> <pre><code>&lt;rss&gt;&lt;channel&gt;&lt;title&gt;&lt;/title&gt;&lt;description&gt;&lt;/description&gt;&lt;link&gt;&lt;/link&gt;&...
[ { "answer_id": 232101, "author": "seansand", "author_id": 9452, "author_profile": "https://Stackoverflow.com/users/9452", "pm_score": 4, "selected": false, "text": "<p>This is a simple way to pretty-print XML, using Groovy code only:</p>\n\n<pre><code>def xml = \"&lt;rss&gt;&lt;channel&g...
2008/10/23
[ "https://Stackoverflow.com/questions/231677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2031/" ]
Given this in a grails action: ``` def xml = { rss(version: '2.0') { ... } } render(contentType: 'application/rss+xml', xml) ``` I see this: ``` <rss><channel><title></title><description></description><link></link><item></item></channel></rss> ``` Is there an easy way to pretty print the XML? Some...
According to the [reference docs](http://grails.org/Converters+Reference), you can use the following configuration option to enable pretty printing: ``` grails.converters.default.pretty.print (Boolean) //Whether the default output of the Converters is pretty-printed ( default: false ) ```
231,679
<p>To add a svg graphics in html page, it is common to use object tag to wrap it like this:</p> <pre><code>&lt;object id="svgid" data="mysvg.svg" type="image/svg+xml" wmode="transparent" width="100" height="100"&gt; this browser is not able to show SVG: &lt;a linkindex="3" href="http://getfirefox.com"&gt;http://ge...
[ { "answer_id": 233819, "author": "Jon Cram", "author_id": 5343, "author_profile": "https://Stackoverflow.com/users/5343", "pm_score": 3, "selected": false, "text": "<p><strong>> Is there any way to get svg's size by using JavaScript?</strong></p>\n\n<p>No and yes.</p>\n\n<p><strong>No:</...
2008/10/23
[ "https://Stackoverflow.com/questions/231679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
To add a svg graphics in html page, it is common to use object tag to wrap it like this: ``` <object id="svgid" data="mysvg.svg" type="image/svg+xml" wmode="transparent" width="100" height="100"> this browser is not able to show SVG: <a linkindex="3" href="http://getfirefox.com">http://getfirefox.com</a> is free ...
**> Is there any way to get svg's size by using JavaScript?** No and yes. **No:** JavaScript won't be able to access the SVG file contents that are sitting in the browser. So it wouldn't be possible to have a page containing an arbitrary SVG image and then have JavaScript determine anything from the SVG file itself...
231,693
<p>I have created a pretty basic Flash website for a client and am having an issue programming a Client Login feature that he would like. Currently, if I navigate to the site and click Client Login, it takes me to a login page. The way I need this to work is -- within the Flash, using ActionScript 2.0 -- have the user ...
[ { "answer_id": 231779, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 3, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>myVars = new LoadVars();\nmyVars.username = username.text;\nmyVars.passwo...
2008/10/23
[ "https://Stackoverflow.com/questions/231693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2715/" ]
I have created a pretty basic Flash website for a client and am having an issue programming a Client Login feature that he would like. Currently, if I navigate to the site and click Client Login, it takes me to a login page. The way I need this to work is -- within the Flash, using ActionScript 2.0 -- have the user ent...
Try this: ``` myVars = new LoadVars(); myVars.username = username.text; myVars.password = pwd.text; myVars.onLoad = function(success) { trace("yay!"); else { trace("try again"); } } myVars.sendAndLoad("login.php", myVars, "POST"); ```
231,695
<p>I need to store several date values in a database field. These values will be tied to a "User" such that each user will have their own unique set of these several date values.</p> <p>I could use a one-to-many relationship here but each user will have exactly 4 date values tied to them so I feel that a one-to-many t...
[ { "answer_id": 231708, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>How about having 4 fields alongwith User ID (if you are sure, it wont exceed that)?</p>\n" }, { "answer_id"...
2008/10/23
[ "https://Stackoverflow.com/questions/231695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055/" ]
I need to store several date values in a database field. These values will be tied to a "User" such that each user will have their own unique set of these several date values. I could use a one-to-many relationship here but each user will have exactly 4 date values tied to them so I feel that a one-to-many table would...
If you do it as four separate fields, then you don't have to join. To Save the query syntax from being too horrible, you could write: ``` SELECT * FROM MyTable WHERE 'DateLiteral' IN (MyDate1, MyDate2, MyDate3, MyDate4); ``` As mentioned in comments, the IN operator is pretty specific when it comes to date fields (d...
231,740
<p>Scott Hanselman recently posted a <a href="http://www.hanselman.com/blog/TheWeeklySourceCode35ZipCompressingASPNETSessionAndCacheState.aspx" rel="nofollow noreferrer">blog article</a> describing how to compress strings stored in the session / cache. This looks fairly promising, but the majority of data that I am st...
[ { "answer_id": 233708, "author": "Toby Mills", "author_id": 12377, "author_profile": "https://Stackoverflow.com/users/12377", "pm_score": 0, "selected": false, "text": "<p>Could you use an XML Serializer to transformed it into an XML format?</p>\n" }, { "answer_id": 236018, "...
2008/10/23
[ "https://Stackoverflow.com/questions/231740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
Scott Hanselman recently posted a [blog article](http://www.hanselman.com/blog/TheWeeklySourceCode35ZipCompressingASPNETSessionAndCacheState.aspx) describing how to compress strings stored in the session / cache. This looks fairly promising, but the majority of data that I am storing in the session / cache are not stri...
Firstly I'd look at why you need to compress the data in your session / cache. Compression should be an act of last resort, better programming should be the first. Are you running out of memory, and if so, which objects are consuming the most? This should point you in the direction for code improvement to reduce the ...
231,760
<p>This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a <code>_t</code> mean? Such as</p> <pre><code>int_t anInt; </code></pre> <p>I see it a lot in C code meant to deal closely with hardware—I can't help but think that they're related.</p>
[ { "answer_id": 231765, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 4, "selected": false, "text": "<p>It means type. <code>size_t</code> is the size type.</p>\n" }, { "answer_id": 231776, "author": "Matt ...
2008/10/23
[ "https://Stackoverflow.com/questions/231760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26237/" ]
This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a `_t` mean? Such as ``` int_t anInt; ``` I see it a lot in C code meant to deal closely with hardware—I can't help but think that they're related.
As Douglas Mayle noted, it basically denotes a type name. Consequently, you would be ill-advised to end variable or function names with '`_t`' since it could cause some confusion. As well as `size_t`, the C89 standard defines `wchar_t`, `off_t`, `ptrdiff_t`, and probably some others I've forgotten. The C99 standard def...
231,767
<p>What is the use of the <code>yield</code> keyword in Python? What does it do?</p> <p>For example, I'm trying to understand this code<sup><strong>1</strong></sup>:</p> <pre><code>def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and distance - max_dist &lt; self._median: yi...
[ { "answer_id": 231778, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 9, "selected": false, "text": "<p><code>yield</code> is just like <code>return</code> - it returns whatever you tell it to (as a generator). The diff...
2008/10/23
[ "https://Stackoverflow.com/questions/231767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18300/" ]
What is the use of the `yield` keyword in Python? What does it do? For example, I'm trying to understand this code**1**: ``` def _get_child_candidates(self, distance, min_dist, max_dist): if self._leftchild and distance - max_dist < self._median: yield self._leftchild if self._rightchild and distance ...
To understand what `yield` does, you must understand what *generators* are. And before you can understand generators, you must understand *iterables*. Iterables --------- When you create a list, you can read its items one by one. Reading its items one by one is called iteration: ``` >>> mylist = [1, 2, 3] >>> for i ...
231,827
<p>I'm designing a multi-tiered database driven web application – SQL relational database, Java for the middle service tier, web for the UI. The language doesn't really matter.</p> <p>The middle service tier performs the actual querying of the database. The UI simply asks for certain data and has no concept that it's ...
[ { "answer_id": 231835, "author": "Ty.", "author_id": 16948, "author_profile": "https://Stackoverflow.com/users/16948", "pm_score": 0, "selected": false, "text": "<p>In ASP.NET I would use server-side paging, where you only retrieve the page of data the user has requested from the data st...
2008/10/23
[ "https://Stackoverflow.com/questions/231827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
I'm designing a multi-tiered database driven web application – SQL relational database, Java for the middle service tier, web for the UI. The language doesn't really matter. The middle service tier performs the actual querying of the database. The UI simply asks for certain data and has no concept that it's backed by ...
The very first question should be: ¿The user needs to, or is capable of, manage this amount of data? Although the result set should be paged, if its potentially size is so huge, the answer will be "probably not", so the UI shouldn't try to show it. I worked on J2EE projects on Health Care Systems, that deal with eno...
231,838
<p>Alright, so I have a query that looks like this:</p> <pre><code>SELECT `orders`.*, GROUP_CONCAT( CONCAT( `menu_items`.`name`, ' ($', FORMAT(`menu_items`.`price`,2), ')' ) SEPARATOR '&lt;br&gt;' ) as `items`, SUM(`menu_items`.`price`) ...
[ { "answer_id": 231846, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 4, "selected": true, "text": "<p>Have you tried using something like this?</p>\n\n<pre><code>CASE WHEN 'menu_items'.'price' = 0 THEN 'menu.items'.'...
2008/10/23
[ "https://Stackoverflow.com/questions/231838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16417/" ]
Alright, so I have a query that looks like this: ``` SELECT `orders`.*, GROUP_CONCAT( CONCAT( `menu_items`.`name`, ' ($', FORMAT(`menu_items`.`price`,2), ')' ) SEPARATOR '<br>' ) as `items`, SUM(`menu_items`.`price`) as `additional`, ...
Have you tried using something like this? ``` CASE WHEN 'menu_items'.'price' = 0 THEN 'menu.items'.'name' ELSE CONCAT (etc) END ``` Replacing the `CONCAT` statement of course.
231,839
<p>In C++ you can disable a function in parent's class by declaring it as private in the child class. How can this be done in Python? I.E. How can I hide parent's function from child's public interface?</p>
[ { "answer_id": 231857, "author": "Jason Baker", "author_id": 2147, "author_profile": "https://Stackoverflow.com/users/2147", "pm_score": 3, "selected": false, "text": "<pre><code>class X(object):\n def some_function(self):\n do_some_stuff()\n\nclass Y(object):\n some_functio...
2008/10/23
[ "https://Stackoverflow.com/questions/231839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17523/" ]
In C++ you can disable a function in parent's class by declaring it as private in the child class. How can this be done in Python? I.E. How can I hide parent's function from child's public interface?
There really aren't any true "private" attributes or methods in Python. One thing you can do is simply override the method you don't want in the subclass, and raise an exception: ``` >>> class Foo( object ): ... def foo( self ): ... print 'FOO!' ... >>> class Bar( Foo ): ... def foo( self ): ....
231,848
<p>The follow code (running in ASP.Net 2.0) displays the contents of the requested URL <strong>twice</strong>. I only want it to display the contents of the requested URL once. I can't figure out what I'm doing wrong. The URL requested is returning XML and if I visit the URL directly, it works fine.</p> <pre><code>Htt...
[ { "answer_id": 231857, "author": "Jason Baker", "author_id": 2147, "author_profile": "https://Stackoverflow.com/users/2147", "pm_score": 3, "selected": false, "text": "<pre><code>class X(object):\n def some_function(self):\n do_some_stuff()\n\nclass Y(object):\n some_functio...
2008/10/23
[ "https://Stackoverflow.com/questions/231848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30996/" ]
The follow code (running in ASP.Net 2.0) displays the contents of the requested URL **twice**. I only want it to display the contents of the requested URL once. I can't figure out what I'm doing wrong. The URL requested is returning XML and if I visit the URL directly, it works fine. ``` HttpWebRequest request = (Http...
There really aren't any true "private" attributes or methods in Python. One thing you can do is simply override the method you don't want in the subclass, and raise an exception: ``` >>> class Foo( object ): ... def foo( self ): ... print 'FOO!' ... >>> class Bar( Foo ): ... def foo( self ): ....
231,862
<p>I'm working with a MySQL query that writes into an outfile. I run this query once every day or two and so I want to be able to remove the outfile without having to resort to su or sudo. The only way I can think of making that happen is to have the outfile written as owned by someone other than the mysql user. Is ...
[ { "answer_id": 231876, "author": "acrosman", "author_id": 24215, "author_profile": "https://Stackoverflow.com/users/24215", "pm_score": 1, "selected": false, "text": "<p>If you have another user run the query from cron, it will create the file as that user.</p>\n" }, { "answer_id...
2008/10/23
[ "https://Stackoverflow.com/questions/231862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1447/" ]
I'm working with a MySQL query that writes into an outfile. I run this query once every day or two and so I want to be able to remove the outfile without having to resort to su or sudo. The only way I can think of making that happen is to have the outfile written as owned by someone other than the mysql user. Is this p...
The output file is created by the mysqld process, not by your client process. Therefore the output file must be owned by the uid and gid of the mysqld process. You can avoid having to sudo to access the file if you access it from a process under a uid or gid that can access the file. In other words, if mysqld creates ...
231,868
<p>I'm getting a strange error from <code>g++</code> 3.3 in the following code:</p> <pre><code>#include &lt;bitset&gt; #include &lt;string&gt; using namespace std; template &lt;int N, int M&gt; bitset&lt;N&gt; slice_bitset(const bitset&lt;M&gt; &amp;original, size_t start) { string str = original.to_string&lt;ch...
[ { "answer_id": 231904, "author": "CAdaker", "author_id": 30579, "author_profile": "https://Stackoverflow.com/users/30579", "pm_score": 3, "selected": false, "text": "<p>Use either just</p>\n\n<pre><code>original.to_string();\n</code></pre>\n\n<p>or, if you really need the type specifiers...
2008/10/23
[ "https://Stackoverflow.com/questions/231868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I'm getting a strange error from `g++` 3.3 in the following code: ``` #include <bitset> #include <string> using namespace std; template <int N, int M> bitset<N> slice_bitset(const bitset<M> &original, size_t start) { string str = original.to_string<char, char_traits<char>, allocator<char> >(); string newstr ...
The selected answer from [CAdaker](https://stackoverflow.com/questions/231868/c-two-or-more-data-types-in-declaration#231904) solves the problem, but does not explain **why** it solves the problem. When a function template is being parsed, lookup does not take place in dependent types. As a result, constructs such as ...
231,870
<p>I have a separate partition on my disk formatted with FAT32. When I hibernate windows, I want to be able to load another OS, create/modify files that are on that partition, then bring Windows out of hibernation and be able to see the changes that I've made.</p> <p>I know what you're going to type, "Well, you're not...
[ { "answer_id": 231981, "author": "Kluge", "author_id": 8752, "author_profile": "https://Stackoverflow.com/users/8752", "pm_score": 0, "selected": false, "text": "<p>My memory is that the FAT table is read during the OS boot and mounting of the volume. Can't you do a shutdown, then modif...
2008/10/23
[ "https://Stackoverflow.com/questions/231870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30425/" ]
I have a separate partition on my disk formatted with FAT32. When I hibernate windows, I want to be able to load another OS, create/modify files that are on that partition, then bring Windows out of hibernation and be able to see the changes that I've made. I know what you're going to type, "Well, you're not supposed ...
So I finally got a solution to my problem. In my mind, I associated Mount Point with Mount. These are NOT the same thing. Removing all of the volume mount points does not make the volume unmounted. It's still mounted but not in the sense that you have a path you can access in explorer. [This is the article](http://msd...
231,885
<p>I encountered a problem when running some old code that was handed down to me. It works 99% of the time, but once in a while, I notice it throwing a "Violation reading location" exception. I have a variable number of threads potentially executing this code throughout the lifetime of the process. The low occurrence f...
[ { "answer_id": 231895, "author": "Henk", "author_id": 4613, "author_profile": "https://Stackoverflow.com/users/4613", "pm_score": 2, "selected": false, "text": "<p>If multiple threads are invoking the function <code>DoStuff</code> this will mean that the initialization code</p>\n\n<pre><...
2008/10/23
[ "https://Stackoverflow.com/questions/231885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22724/" ]
I encountered a problem when running some old code that was handed down to me. It works 99% of the time, but once in a while, I notice it throwing a "Violation reading location" exception. I have a variable number of threads potentially executing this code throughout the lifetime of the process. The low occurrence freq...
Given an address of "4", Likely the "this" pointer is null or the iterator is bad. You should be able to see this in the debugger. If this is null, then the problem isn't in that function but who ever is calling that function. If the iterator is bad, then it's the race condition you alluded to. Most iterators can't tol...
231,886
<p>This may seem like a somewhat contrived example, but I'm left scratching my head.</p> <p>Ok, I have a console app that instantiates a WindowsForm and calls a method called DoSomeWork() on the form.</p> <pre><code>class Program { static void Main(string[] args) { Form1 form = new Form1(); ...
[ { "answer_id": 231894, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 2, "selected": false, "text": "<p>Did you actually <code>throw NotImplementedException();</code> in the handler? or you're just mocking this up quick and f...
2008/10/23
[ "https://Stackoverflow.com/questions/231886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6419/" ]
This may seem like a somewhat contrived example, but I'm left scratching my head. Ok, I have a console app that instantiates a WindowsForm and calls a method called DoSomeWork() on the form. ``` class Program { static void Main(string[] args) { Form1 form = new Form1(); form.DoSomeWork...
You forgot to start a message loop, calling Application.Run() is required. Without a message loop, the BackgroundWorker events cannot work. To fix: ``` static void Main(string[] args) { Application.Run(new Form1()); } ``` Call DoSomeWork() in the form's constructor or it's Load event.
231,893
<p>I have seen this syntax in MSDN: <a href="https://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx" rel="noreferrer"><code>yield break</code></a>, but I don't know what it does. Does anyone know?</p>
[ { "answer_id": 231896, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 6, "selected": false, "text": "<p>Ends an iterator block (e.g. says there are no more elements in the IEnumerable).</p>\n" }, { "answer_id": 231915...
2008/10/23
[ "https://Stackoverflow.com/questions/231893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I have seen this syntax in MSDN: [`yield break`](https://msdn.microsoft.com/en-us/library/9k7k7cf0.aspx), but I don't know what it does. Does anyone know?
It specifies that an iterator has come to an end. You can think of `yield break` as a `return` statement which does not return a value. For example, if you define a function as an iterator, the body of the function may look like this: ``` for (int i = 0; i < 5; i++) { yield return i; } Console.Out.WriteLine("You...
231,903
<p>Just wondering how much people log within their applications???</p> <p>I have seen this:</p> <blockquote> <p>"I typically like to use the ERROR log level to log any exceptions that are caught by the application. I will use the INFO log level as a "first level" debugging scheme to show whenever I enter ...
[ { "answer_id": 231923, "author": "SaaS Developer", "author_id": 7215, "author_profile": "https://Stackoverflow.com/users/7215", "pm_score": 2, "selected": false, "text": "<p>You are right that this does make the code more difficult to read and maintain. One recommendation is to consider...
2008/10/23
[ "https://Stackoverflow.com/questions/231903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30572/" ]
Just wondering how much people log within their applications??? I have seen this: > > "I typically like to use the ERROR log > level to log any exceptions that are > caught by the application. I will use > the INFO log level as a "first level" > debugging scheme to show whenever I > enter or exit a method. From...
You are right that this does make the code more difficult to read and maintain. One recommendation is to consider looking into an AOP (Aspect oriented Programming) tool to separate your logging logic from your application logic. Castle Windsor and Spring are two that come to mind within the .Net community that you may ...
231,917
<p>This originally was a problem I ran into at work, but is now something I'm just trying to solve for my own curiosity.</p> <p>I want to find out if int 'a' contains the int 'b' in the most efficient way possible. I wrote some code, but it seems no matter what I write, parsing it into a string and then using indexOf...
[ { "answer_id": 231936, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p>Umm, I'm probably totally misunderstanding the question, but.....</p>\n\n<pre><code>// Check if A is inside B lol\nbool C...
2008/10/23
[ "https://Stackoverflow.com/questions/231917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14007/" ]
This originally was a problem I ran into at work, but is now something I'm just trying to solve for my own curiosity. I want to find out if int 'a' contains the int 'b' in the most efficient way possible. I wrote some code, but it seems no matter what I write, parsing it into a string and then using indexOf is twice a...
This is along Kibbee's line, but I got a little intrigued by this before he posted and worked this out: ``` long mask ( long n ) { long m = n % 10; long n_d = n; long div = 10; int shl = 0; while ( n_d >= 10 ) { n_d /= 10; long t = n_d % 10; m |= ( t << ( shl += 4 )); ...
231,937
<p>I am trying to show and hide an inline element (eg a span) using jQuery.</p> <p>If I just use toggle(), it works as expected but if I use toggle("slow") to give it an animation, it turns the span into a block element and therefore inserts breaks.</p> <p>Is animation possible with inline elements? I would prefer a...
[ { "answer_id": 232005, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "<p>I don't think it is possible like that. The only way I could think to do it would be to animate its opacity between 0 and 1...
2008/10/23
[ "https://Stackoverflow.com/questions/231937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31012/" ]
I am trying to show and hide an inline element (eg a span) using jQuery. If I just use toggle(), it works as expected but if I use toggle("slow") to give it an animation, it turns the span into a block element and therefore inserts breaks. Is animation possible with inline elements? I would prefer a smooth sliding if...
`toggle()` has a bunch of weird things with it, including hiding or transforming odd elements at times. here's a similar solution: ``` $('.toggle').click(function() { $('.hide').animate({ 'opacity' : 'toggle', }); }); ``` **edit**: here's a way to add smooth sliding, with minimal extra HTML markup: ``` var ...
231,947
<p>I have a project that is based on the Navigation Based Application template. In the AppDelegate are the methods <code>-applicationDidFinishLoading:</code> and <code>-applicationWillTerminate:</code>. In those methods, I am loading and saving the application data, and storing it in an instance variable (it is actual...
[ { "answer_id": 232016, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 4, "selected": false, "text": "<p>If I understand your question, you want to reference member variables/properties in your AppDelegate object? The sim...
2008/10/23
[ "https://Stackoverflow.com/questions/231947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a project that is based on the Navigation Based Application template. In the AppDelegate are the methods `-applicationDidFinishLoading:` and `-applicationWillTerminate:`. In those methods, I am loading and saving the application data, and storing it in an instance variable (it is actually an object-graph). When...
For variables (usually the model data structure) which I need to access it anywhere in the app, declare them in your AppDelegate class. When you need to reference it: ``` YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate]; //and then access the variable by appDelegate.variab...
232,004
<p>For the moment the best way that I have found to be able to manipulate DOM from a string that contain HTML is:</p> <pre><code>WebBrowser webControl = new WebBrowser(); webControl.DocumentText = html; HtmlDocument doc = webControl.Document; </code></pre> <p>There are two problems:</p> <ol> <li>Requires the <code>W...
[ { "answer_id": 232021, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 3, "selected": false, "text": "<p>Depending on what you are trying to do (maybe you can give us more details?) and depending on whether or not the HT...
2008/10/23
[ "https://Stackoverflow.com/questions/232004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
For the moment the best way that I have found to be able to manipulate DOM from a string that contain HTML is: ``` WebBrowser webControl = new WebBrowser(); webControl.DocumentText = html; HtmlDocument doc = webControl.Document; ``` There are two problems: 1. Requires the `WebBrowser` object! 2. This can't be used ...
I did a search to GooglePlex for HTML and I found [Html Agility Pack](https://html-agility-pack.net/) I do not know if it's for that or not, I am downloading it right now to give a try.
232,030
<p>I want a pure virtual parent class to call a child implementation of a function like so:</p> <pre><code>class parent { public: void Read() { //read stuff } virtual void Process() = 0; parent() { Read(); Process(); } } class child : public parent { public: virtual void Pr...
[ { "answer_id": 232039, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 2, "selected": false, "text": "<p>Will work in general, but not for calls within the constructor of the pure virtual base class. At the time the base class ...
2008/10/23
[ "https://Stackoverflow.com/questions/232030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
I want a pure virtual parent class to call a child implementation of a function like so: ``` class parent { public: void Read() { //read stuff } virtual void Process() = 0; parent() { Read(); Process(); } } class child : public parent { public: virtual void Process() { //pr...
Title of the following article says it all: [Never Call Virtual Functions during Construction or Destruction](http://www.artima.com/cppsource/nevercall.html).
232,052
<p>I have an MSBuild task to build a specific project in a solution file. It looks something like this:</p> <pre><code>&lt;Target Name="Baz"&gt; &lt;MSBuild Projects="Foo.sln" Targets="bar:$(BuildCmd)" /&gt; &lt;/Target&gt; </code></pre> <p>From the command line, I can set my <code>BuildCmd</code> to either <code>R...
[ { "answer_id": 232119, "author": "ripper234", "author_id": 11236, "author_profile": "https://Stackoverflow.com/users/11236", "pm_score": -1, "selected": false, "text": "<p>Just edit the sln file yourself and find out - MSBuild is a real easy syntax, just look for targets.</p>\n" }, {...
2008/10/24
[ "https://Stackoverflow.com/questions/232052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an MSBuild task to build a specific project in a solution file. It looks something like this: ``` <Target Name="Baz"> <MSBuild Projects="Foo.sln" Targets="bar:$(BuildCmd)" /> </Target> ``` From the command line, I can set my `BuildCmd` to either `Rebuild` or `Clean` and it works as expected: > > msbuild /...
I understood that you want to build a target with a specific command: Build, Clean, etc. This is how I would do it. Create a property to receive your build command, when not specified defaults to Build ``` <PropertyGroup> <BuildCmd Condition=" '$(BuildCmd)' == ''">Build</BuildCmd> </PropertyGroup> ``` After, cre...
232,078
<p>I have three projects. One is a WCF Services Project, one is a WPF Project, and one is a Microsoft Unit Testing Project. I setup the WCF Services project with a data object that looks like this:</p> <pre><code>[DataContract] public enum Priority { Low, Medium, High } [DataContract] public struct Time...
[ { "answer_id": 232335, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 1, "selected": false, "text": "<p>I could be way off, but it might be a security thing... I've gotten that error before, and I solved it... but I ...
2008/10/24
[ "https://Stackoverflow.com/questions/232078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29345/" ]
I have three projects. One is a WCF Services Project, one is a WPF Project, and one is a Microsoft Unit Testing Project. I setup the WCF Services project with a data object that looks like this: ``` [DataContract] public enum Priority { Low, Medium, High } [DataContract] public struct TimeInfo { [Data...
I Found the Answer Ok, not sure if it is kewl answering my own question, but here we go. For some reason the enumeration needed to be marked with the [EnumMember] Attributes as below: ``` [DataContract] public enum Priority { [EnumMember] Low, [EnumMember] Medium, [EnumMember] High } ``` Onc...
232,083
<p>Is there a way to know which file is being selected in windows explorer? I've been looking at the tutorial posted here <a href="https://stackoverflow.com/questions/140312/tutorial-for-windows-shell-extensions">Idiots guide to ...</a> but the actions described are:</p> <p>hover</p> <p>context </p> <p>menu properti...
[ { "answer_id": 232335, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 1, "selected": false, "text": "<p>I could be way off, but it might be a security thing... I've gotten that error before, and I solved it... but I ...
2008/10/24
[ "https://Stackoverflow.com/questions/232083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
Is there a way to know which file is being selected in windows explorer? I've been looking at the tutorial posted here [Idiots guide to ...](https://stackoverflow.com/questions/140312/tutorial-for-windows-shell-extensions) but the actions described are: hover context menu properties drag drag and drop I wonder ...
I Found the Answer Ok, not sure if it is kewl answering my own question, but here we go. For some reason the enumeration needed to be marked with the [EnumMember] Attributes as below: ``` [DataContract] public enum Priority { [EnumMember] Low, [EnumMember] Medium, [EnumMember] High } ``` Onc...
232,140
<p>My <sub>crappy</sub> web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (i.e.: the articles) which are affected, but also the standard MediaWiki te...
[ { "answer_id": 232149, "author": "Andy Lester", "author_id": 8454, "author_profile": "https://Stackoverflow.com/users/8454", "pm_score": 0, "selected": false, "text": "<p>Perhaps something else is calling set_magic_quotes_runtime().</p>\n" }, { "answer_id": 232242, "author": ...
2008/10/24
[ "https://Stackoverflow.com/questions/232140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
My crappy web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (i.e.: the articles) which are affected, but also the standard MediaWiki text. For exampl...
If PHP flags are set with `php_admin_flag`/`php_admin_value`, you can't change it from a `.htaccess` file. This has caused me some headache before. Either disable it in `php.ini` or undo magic quotes in runtime: <http://talks.php.net/show/php-best-practices/26>
232,144
<p>I have a volunteers_2009 table that lists all the volunteers and a venues table that lists the venues that a volunteer can be assigned to, they are only assigned to one.</p> <p>What I want to do, is print out the number of volunteers assigned to each venue.</p> <p>I want it to print out like this:</p> <p>Name of ...
[ { "answer_id": 232159, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>Not a MySQL person so this may be really wrong, but when you give your table an alias, don't you then need to refer t...
2008/10/24
[ "https://Stackoverflow.com/questions/232144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26130/" ]
I have a volunteers\_2009 table that lists all the volunteers and a venues table that lists the venues that a volunteer can be assigned to, they are only assigned to one. What I want to do, is print out the number of volunteers assigned to each venue. I want it to print out like this: Name of Venue: # of volunteers ...
Not a MySQL person so this may be really wrong, but when you give your table an alias, don't you then need to refer to it by that name. ``` $sql = "SELECT ven.venue_name as 'Venue', COUNT(vol.id) as 'Number Of Volunteers' FROM venues ven JOIN volunteers_2009 vol ON (ven.id=vol.venue_id) GROUP BY ven.venue_name ORDER...
232,161
<p>I'm currently developing an application that is comprised of five separate executables that communicate via ActiveMQ. I have a Visual Studio Solution that contains the five executable projects. One of the projects (the launcher.exe) launches the other four projects from their local folders as separate processes. ...
[ { "answer_id": 232176, "author": "Charlie", "author_id": 18529, "author_profile": "https://Stackoverflow.com/users/18529", "pm_score": 4, "selected": true, "text": "<p>What you need is in the Tools menu: Attach to Process. This gives you a list of running processes and allows you to atta...
2008/10/24
[ "https://Stackoverflow.com/questions/232161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191808/" ]
I'm currently developing an application that is comprised of five separate executables that communicate via ActiveMQ. I have a Visual Studio Solution that contains the five executable projects. One of the projects (the launcher.exe) launches the other four projects from their local folders as separate processes. As suc...
What you need is in the Tools menu: Attach to Process. This gives you a list of running processes and allows you to attach your debugger to those processes. For local debugging, Transport and Qualifier should keep their default values. The Attach To value just above the list determines which type of debugging you'll b...
232,168
<p>I'm trying to get a file with ant, using the get property. I'm running apache 2, and I can get the file from the indicated URL using wget and firefox, but ant gives me the following error:</p> <pre><code>[get] Error opening connection java.io.IOException: Server returned HTTP response code: 503 for URL: http://loc...
[ { "answer_id": 232220, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 3, "selected": true, "text": "<p>503 is <em>Service Unavailable</em>, which probably means that the <code>src</code> URL isn't getting interpreted prope...
2008/10/24
[ "https://Stackoverflow.com/questions/232168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3434/" ]
I'm trying to get a file with ant, using the get property. I'm running apache 2, and I can get the file from the indicated URL using wget and firefox, but ant gives me the following error: ``` [get] Error opening connection java.io.IOException: Server returned HTTP response code: 503 for URL: http://localhost/jars/ja...
503 is *Service Unavailable*, which probably means that the `src` URL isn't getting interpreted properly and sent by the ANT task or perhaps the JRE. Here are some things to try: * As always, with ANT, execute the smallest possible build.xml with **-verbose** to see if that gives any more information, **-debug** for ...
232,171
<p>I have an IQueryable and an object of type T.</p> <p>I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName))</p> <p>so ...</p> <pre><code>public IQueryable&lt;T&gt; DoWork&lt;T&gt;(string fieldName) where T : EntityObject { ... T objectOfTypeT = ...; ...
[ { "answer_id": 232304, "author": "JTew", "author_id": 25372, "author_profile": "https://Stackoverflow.com/users/25372", "pm_score": 0, "selected": false, "text": "<p>From what I can see so far it's going to have to be something like ...</p>\n\n<pre><code>IQueryable&lt;T&gt;().Where(t =&g...
2008/10/24
[ "https://Stackoverflow.com/questions/232171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25372/" ]
I have an IQueryable and an object of type T. I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName)) so ... ``` public IQueryable<T> DoWork<T>(string fieldName) where T : EntityObject { ... T objectOfTypeT = ...; .... return SomeIQueryable<T>().Wher...
Like so: ``` var param = Expression.Parameter(typeof(T), "o"); var fixedItem = Expression.Constant(objectOfTypeT, typeof(T)); var body = Expression.Equal( Expression.PropertyOrField(param, fieldName), Expression.PropertyOrField(fixedItem, fieldName)); var lambda = Expression.Lambda<Func...
232,237
<p>What's the best way to return a random line in a text file using C? It has to use the standard I/O library (<code>&lt;stdio.h&gt;</code>) because it's for Nintendo DS homebrew.</p> <p><strong>Clarifications:</strong></p> <ul> <li>Using a header in the file to store the number of lines won't work for what I want to...
[ { "answer_id": 232246, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "<p><strong>This method is good because:</strong></p>\n\n<p>i) You can keep generating random lines at no big cost</p>...
2008/10/24
[ "https://Stackoverflow.com/questions/232237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
What's the best way to return a random line in a text file using C? It has to use the standard I/O library (`<stdio.h>`) because it's for Nintendo DS homebrew. **Clarifications:** * Using a header in the file to store the number of lines won't work for what I want to do. * I want it to be as random as possible (the b...
Read each line, and use a random number to choose whether to keep that line or ignore it. For the first line, you want odds of 1:1 to keep; for the second, you want odds of 1:2, etc. ``` count = 0; while (fgets(line, length, stream) != NULL) { count++; if ((rand() * count) / RAND_MAX == 0) strcpy(keptl...
232,274
<p>When I browse code in Vim, I need to see opening and closing parenthesis/ brackets, and pressing <kbd>%</kbd> seems unproductive.</p> <p>I tried <code>:set showmatch</code>, but it makes the cursor jump back and forth when you type in a bracket. But what to do if I am browsing already written code?</p>
[ { "answer_id": 232278, "author": "jcoby", "author_id": 2884, "author_profile": "https://Stackoverflow.com/users/2884", "pm_score": 5, "selected": false, "text": "<p><code>set showmatch</code> is your best bet. you can also use the <kbd>%</kbd> command to jump between matching parenthesi...
2008/10/24
[ "https://Stackoverflow.com/questions/232274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29405/" ]
When I browse code in Vim, I need to see opening and closing parenthesis/ brackets, and pressing `%` seems unproductive. I tried `:set showmatch`, but it makes the cursor jump back and forth when you type in a bracket. But what to do if I am browsing already written code?
``` DoMatchParen ``` in your `.vimrc` file or ``` :DoMatchParen ``` within vim itself. Edit: This comes from the [pi\_paren](http://vimdoc.sourceforge.net/htmldoc/pi_paren.html) plugin (which is a standard plugin).
232,280
<p>Im having a problem with a final part of my assignment. We get in a stream of bits, etc etc, in the stream is an integer with the number of 1's in the text portion. I get that integer and its 24 which is correct, now i loop through the text data i get and i try to count all the 1's in there. But my proc is always re...
[ { "answer_id": 232291, "author": "Menkboy", "author_id": 29539, "author_profile": "https://Stackoverflow.com/users/29539", "pm_score": 3, "selected": true, "text": "<p>'shr bh,1' should probably be 'shr dh,1', no?</p>\n" }, { "answer_id": 232860, "author": "Nils Pipenbrinck",...
2008/10/24
[ "https://Stackoverflow.com/questions/232280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18431/" ]
Im having a problem with a final part of my assignment. We get in a stream of bits, etc etc, in the stream is an integer with the number of 1's in the text portion. I get that integer and its 24 which is correct, now i loop through the text data i get and i try to count all the 1's in there. But my proc is always retur...
'shr bh,1' should probably be 'shr dh,1', no?
232,316
<p>I'm tinkering with Silverlight 2.0.</p> <p>I have some images, which I currently have a static URL for the image source. Is there a way to dynamically load the image from a URL path for the site that is hosting the control?</p> <p>Alternatively, a configuration setting, stored in a single place, that holds the bas...
[ { "answer_id": 232414, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 5, "selected": true, "text": "<p>In the code behind or a value converter you can do </p>\n\n<pre><code> Uri uri = new Uri(\"http://testsvr.com/hello...
2008/10/24
[ "https://Stackoverflow.com/questions/232316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24126/" ]
I'm tinkering with Silverlight 2.0. I have some images, which I currently have a static URL for the image source. Is there a way to dynamically load the image from a URL path for the site that is hosting the control? Alternatively, a configuration setting, stored in a single place, that holds the base path for the UR...
In the code behind or a value converter you can do ``` Uri uri = new Uri("http://testsvr.com/hello.jpg"); YourImage.Source = new BitmapImage(uri); ```
232,333
<p>How long should it take to run </p> <pre><code>ALTER DATABASE [MySite] SET READ_COMMITTED_SNAPSHOT ON </code></pre> <p>I just ran it and it's taken 10 minutes.</p> <p>How can I check if it is applied?</p>
[ { "answer_id": 232358, "author": "Rick", "author_id": 14138, "author_profile": "https://Stackoverflow.com/users/14138", "pm_score": 7, "selected": true, "text": "<p>You can check the status of the READ_COMMITTED_SNAPSHOT setting using the <strong><code>sys.databases</code></strong> view....
2008/10/24
[ "https://Stackoverflow.com/questions/232333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
How long should it take to run ``` ALTER DATABASE [MySite] SET READ_COMMITTED_SNAPSHOT ON ``` I just ran it and it's taken 10 minutes. How can I check if it is applied?
You can check the status of the READ\_COMMITTED\_SNAPSHOT setting using the **`sys.databases`** view. Check the value of the **`is_read_committed_snapshot_on`** column. Already [asked and answered](https://stackoverflow.com/questions/51969/how-to-detect-readcommittedsnapshot-is-enabled). As for the duration, Books Onl...
232,344
<p>I have some code which ignores a specific exception. </p> <pre><code>try { foreach (FileInfo fi in di.GetFiles()) { collection.Add(fi.Name); } foreach (DirectoryInfo d in di.GetDirectories()) { populateItems(collection, d); } } catch (UnauthorizedAccessException ex) { //i...
[ { "answer_id": 232350, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 5, "selected": true, "text": "<p>Just rewrite it as</p>\n\n<pre><code>catch (UnauthorizedAccessException) {}\n</code></pre>\n" }, { "answer_id...
2008/10/24
[ "https://Stackoverflow.com/questions/232344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
I have some code which ignores a specific exception. ``` try { foreach (FileInfo fi in di.GetFiles()) { collection.Add(fi.Name); } foreach (DirectoryInfo d in di.GetDirectories()) { populateItems(collection, d); } } catch (UnauthorizedAccessException ex) { //ignore and move ...
Just rewrite it as ``` catch (UnauthorizedAccessException) {} ```
232,386
<p>I'm trying to make an item on ToolBar (specifically a Label, TextBlock, or a TextBox) That will fill all available horizontal space. I've gotten the ToolBar itself to stretch out by taking it out of its ToolBarTray, but I can't figure out how to make items stretch.</p> <p>I tried setting Width to Percenatage or St...
[ { "answer_id": 232407, "author": "Anthony Potts", "author_id": 22777, "author_profile": "https://Stackoverflow.com/users/22777", "pm_score": 0, "selected": false, "text": "<p>Try putting a horizontal StackPanel in the ToolBar and then the element you want inside of that StackPanel.</p>\n...
2008/10/24
[ "https://Stackoverflow.com/questions/232386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7649/" ]
I'm trying to make an item on ToolBar (specifically a Label, TextBlock, or a TextBox) That will fill all available horizontal space. I've gotten the ToolBar itself to stretch out by taking it out of its ToolBarTray, but I can't figure out how to make items stretch. I tried setting Width to Percenatage or Star values, ...
Unfortunately it looks like the default ControlTemplate for ToolBar doesn't use an ItemsPresenter, it uses a ToolBarPanel, so setting ToolBar.ItemsPanel won't have any effect. ToolBarPanel inherits from StackPanel. By default its Orientation is bound to the parent ToolBar.Orientation, but you can override this and set...
232,387
<p>Suppose I have a table with a numeric column (lets call it "score").</p> <p>I'd like to generate a table of counts, that shows how many times scores appeared in each range.</p> <p>For example:</p> <pre> score range | number of occurrences ------------------------------------- 0-9 | 11 10-19 ...
[ { "answer_id": 232405, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<pre><code>create table scores (\n user_id int,\n score int\n)\n\nselect t.range as [score range], count(*) as [num...
2008/10/24
[ "https://Stackoverflow.com/questions/232387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31060/" ]
Suppose I have a table with a numeric column (lets call it "score"). I'd like to generate a table of counts, that shows how many times scores appeared in each range. For example: ``` score range | number of occurrences ------------------------------------- 0-9 | 11 10-19 | 14 20-29 ...
Neither of the highest voted answers are correct on SQL Server 2000. Perhaps they were using a different version. Here are the correct versions of both of them on SQL Server 2000. ``` select t.range as [score range], count(*) as [number of occurences] from ( select case when score between 0 and 9 then ' 0- 9'...
232,395
<p>I have a two-dimensional array (of Strings) which make up my data table (of rows and columns). I want to sort this array by any column. I tried to find an algorithm for doing this in C#, but have not been successful.</p> <p>Any help is appreciated.</p>
[ { "answer_id": 232413, "author": "Doug L.", "author_id": 19179, "author_profile": "https://Stackoverflow.com/users/19179", "pm_score": 3, "selected": false, "text": "<p><a href=\"https://web.archive.org/web/20160819174858/http://www.informit.com/guides/content.aspx?g=dotnet&amp;seqNum=15...
2008/10/24
[ "https://Stackoverflow.com/questions/232395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15052/" ]
I have a two-dimensional array (of Strings) which make up my data table (of rows and columns). I want to sort this array by any column. I tried to find an algorithm for doing this in C#, but have not been successful. Any help is appreciated.
Load your two-dimensional string array into an actual DataTable (System.Data.DataTable), and then use the DataTable object's Select() method to generate a sorted array of DataRow objects (or use a DataView for a similar effect). ``` // assumes stringdata[row, col] is your 2D string array DataTable dt = new DataTable()...
232,435
<p>I have a two way foreign relation similar to the following</p> <pre><code>class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True) class Child(models.Model): name = models.CharField(max_length=255) myparent = models.ForeignKey(Par...
[ { "answer_id": 232644, "author": "Eric Holscher", "author_id": 4169, "author_profile": "https://Stackoverflow.com/users/4169", "pm_score": 4, "selected": false, "text": "<p>This isn't how django works. You would only create the relation going one way.</p>\n\n<pre><code>class Parent(model...
2008/10/24
[ "https://Stackoverflow.com/questions/232435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25521/" ]
I have a two way foreign relation similar to the following ``` class Parent(models.Model): name = models.CharField(max_length=255) favoritechild = models.ForeignKey("Child", blank=True, null=True) class Child(models.Model): name = models.CharField(max_length=255) myparent = models.ForeignKey(Parent) ``` How...
I just came across [ForeignKey.limit\_choices\_to](http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to) in the Django docs. Not sure yet how this works, but it might just be the right thing here. **Update:** ForeignKey.limit\_choices\_to allows to specify either a const...
232,445
<p>I'm just starting to learn C++ so excuse me for this simple question. What I'm doing is reading in numbers from a file and then trying to add them to an array. My problem is how do you increase the size of the array? For example I thought might be able to just do:</p> <pre><code>#include &lt;iostream&gt; using name...
[ { "answer_id": 232454, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "<p>You don't want to work with arrays directly. Consider using a <code>vector</code>, instead. Then, you can call the <code>p...
2008/10/24
[ "https://Stackoverflow.com/questions/232445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38/" ]
I'm just starting to learn C++ so excuse me for this simple question. What I'm doing is reading in numbers from a file and then trying to add them to an array. My problem is how do you increase the size of the array? For example I thought might be able to just do: ``` #include <iostream> using namespace std; int main...
You don't want to work with arrays directly. Consider using a `vector`, instead. Then, you can call the `push_back` function to add things to the end, and it will automatically resize the vector for you. ``` #include <iostream> #include <vector> int main() { double value; std::vector<double> values; // R...
232,472
<p>In C and C++ what do the following declarations do?</p> <pre><code>const int * i; int * const i; const volatile int ip; const int *i; </code></pre> <p>Are any of the above declarations wrong?</p> <p>If not what is the meaning and differences between them?</p> <p>What are the useful uses of above declarations (I ...
[ { "answer_id": 232479, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 5, "selected": false, "text": "<p><code>const int * i;</code></p>\n\n<p><code>i</code> is a pointer to constant integer. <code>i</code> can be cha...
2008/10/24
[ "https://Stackoverflow.com/questions/232472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In C and C++ what do the following declarations do? ``` const int * i; int * const i; const volatile int ip; const int *i; ``` Are any of the above declarations wrong? If not what is the meaning and differences between them? What are the useful uses of above declarations (I mean in which situation we have to use t...
`const int * i;` `i` is a pointer to constant integer. `i` can be changed to point to a different value, but the value being pointed to by `i` can not be changed. `int * const i;` `i` is a constant pointer to a non-constant integer. The value pointed to by `i` can be changed, but `i` cannot be changed to point to a ...
232,475
<p>I need to add unit testing to some old scripts, the scripts are all basically in the following form:</p> <pre><code>#!/usr/bin/perl # Main code foo(); bar(); # subs sub foo { } sub bar { } </code></pre> <p>If I try to 'require' this code in a unit test, the main section of the code will run, where as I want to...
[ { "answer_id": 232552, "author": "ysth", "author_id": 17389, "author_profile": "https://Stackoverflow.com/users/17389", "pm_score": 4, "selected": false, "text": "<p>Assuming you have no security concerns, wrap it in a sub { ... } and eval it:</p>\n\n<pre><code>use File::Slurp \"read_fil...
2008/10/24
[ "https://Stackoverflow.com/questions/232475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
I need to add unit testing to some old scripts, the scripts are all basically in the following form: ``` #!/usr/bin/perl # Main code foo(); bar(); # subs sub foo { } sub bar { } ``` If I try to 'require' this code in a unit test, the main section of the code will run, where as I want to be able to just test "foo...
Another common trick for unit testing scripts is to wrap the body of their code into a 'caller' block: ``` #!/usr/bin/perl use strict; use warnings; unless (caller) { # startup code } sub foo { ... } ``` When run from the command line, cron, a bash script, etc., it runs normally. However, if you load it from ...
232,535
<p>What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime?</p> <p>Consider the following sample code - inside the <code>Example()</code> method, what's the most concise way to invoke <code>GenericMethod&lt;T&gt;()</code> using th...
[ { "answer_id": 232621, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 11, "selected": true, "text": "<p>You need to use reflection to get the method to start with, then \"construct\" it by supplying type arguments with <a...
2008/10/24
[ "https://Stackoverflow.com/questions/232535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30280/" ]
What's the best way to call a generic method when the type parameter isn't known at compile time, but instead is obtained dynamically at runtime? Consider the following sample code - inside the `Example()` method, what's the most concise way to invoke `GenericMethod<T>()` using the `Type` stored in the `myType` variab...
You need to use reflection to get the method to start with, then "construct" it by supplying type arguments with [MakeGenericMethod](http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.makegenericmethod.aspx): ``` MethodInfo method = typeof(Sample).GetMethod(nameof(Sample.GenericMethod)); MethodInfo g...
232,545
<p>Say I have a rectangular string array - not a jagged array</p> <pre><code>string[,] strings = new string[8, 3]; </code></pre> <p>What's the best way to extract a one-dimensional array from this (either a single row or a single column)? I can do this with a for loop, of course, but I'm hoping .NET has a more elega...
[ { "answer_id": 232553, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 1, "selected": false, "text": "<p>LINQ is the answer </p>\n\n<pre><code>static object[] GetColumn(string[][] source, int col) {\n return source.Itera...
2008/10/24
[ "https://Stackoverflow.com/questions/232545", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
Say I have a rectangular string array - not a jagged array ``` string[,] strings = new string[8, 3]; ``` What's the best way to extract a one-dimensional array from this (either a single row or a single column)? I can do this with a for loop, of course, but I'm hoping .NET has a more elegant way built in. Bonus poi...
For a rectangular array: ``` string[,] rectArray = new string[3,3] { {"a", "b", "c"}, {"d", "e", "f"}, {"g", "h", "i"} }; var rectResult = rectArray.Cast<object>().ToArray(); ``` And for a jagged array: ``` string[][] jaggedArray = { new string[] {"a", "b", "c", "d"}, new string[] {"e", "...
232,575
<p>How do I check if a column exists in SQL Server 2000?</p>
[ { "answer_id": 232582, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 5, "selected": false, "text": "<pre><code>IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS\nWHERE TABLE_NAME='tablename' AND COLUMN_NAME=...
2008/10/24
[ "https://Stackoverflow.com/questions/232575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31071/" ]
How do I check if a column exists in SQL Server 2000?
``` IF EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='tablename' AND COLUMN_NAME='columname' ) ```
232,596
<p>Let say I run this command:</p> <pre><code>makecert testcert.cer </code></pre> <p>Is a private key created? If so, where is it automatically stored in the system even though I did not tell makecert to install this certificate in any certificate store?</p>
[ { "answer_id": 341374, "author": "Scott Ivey", "author_id": 36297, "author_profile": "https://Stackoverflow.com/users/36297", "pm_score": 2, "selected": false, "text": "<p>It looks like the private key is stored in the file itself. From the documentation at <a href=\"http://msdn.microso...
2008/10/24
[ "https://Stackoverflow.com/questions/232596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13484/" ]
Let say I run this command: ``` makecert testcert.cer ``` Is a private key created? If so, where is it automatically stored in the system even though I did not tell makecert to install this certificate in any certificate store?
It looks like the private key is stored in the file itself. From the documentation at <http://msdn.microsoft.com/en-us/library/bfsktky3(VS.80).aspx> it states... Caution You should use a certificate store to securely store your certificates. The .snk files used by this tool store private keys in an unprotected mann...
232,611
<p>I'm building a webpage that queries a MySQL database and (currently) produces a text-only list of the findings. The queries to complete a single record are similar to:</p> <ul> <li>movie (title, description, etc) <ul> <li>actors in the movie (name, gender)</li> <li>related movies</li> </ul></li> </ul> <p>Out of c...
[ { "answer_id": 232647, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": false, "text": "<p>Ultimately it's preferable to optimize when convenient of course, but 2MB of memory use sounds fine. PHP4 has a default conf...
2008/10/24
[ "https://Stackoverflow.com/questions/232611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29230/" ]
I'm building a webpage that queries a MySQL database and (currently) produces a text-only list of the findings. The queries to complete a single record are similar to: * movie (title, description, etc) + actors in the movie (name, gender) + related movies Out of curiosity I've used `memory_get_peak_usage()` and `me...
Ultimately it's preferable to optimize when convenient of course, but 2MB of memory use sounds fine. PHP4 has a default config of 8mb, and PHP5 16mb. A lot of pre-packaged PHP builds will have different configs, of course, but generally speaking, if you can keep your app under 8mb, you can be sure it'll be highly porta...
232,625
<p>How to invoke the default browser with an URL from C#?</p>
[ { "answer_id": 232633, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "<pre><code>System.Diagnostics.Process.Start(\"http://mysite.com\");\n</code></pre>\n" }, { "answer_id":...
2008/10/24
[ "https://Stackoverflow.com/questions/232625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to invoke the default browser with an URL from C#?
``` System.Diagnostics.Process.Start("http://www.google.com"); ``` More details here - <http://msdn.microsoft.com/en-us/library/aa326951.aspx>
232,651
<p>While running a batch file in Windows XP I have found randomly occurring error message:</p> <blockquote> <p>The system cannot find the batch label specified name_of_label</p> </blockquote> <p>Of course label existed. What causes this error?</p>
[ { "answer_id": 232656, "author": "Slimak", "author_id": 31086, "author_profile": "https://Stackoverflow.com/users/31086", "pm_score": 4, "selected": false, "text": "<p>If batch file has unix line endings (line separators) this can sometimes happen.</p>\n\n<p>Just <a href=\"http://dos2uni...
2008/10/24
[ "https://Stackoverflow.com/questions/232651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31086/" ]
While running a batch file in Windows XP I have found randomly occurring error message: > > The system cannot find the batch label specified name\_of\_label > > > Of course label existed. What causes this error?
Actually, you need 2 conditions for this to happen: * the batch file must not use CRLF line endings * the label you jump to must span a block boundary (as opposed to and :end label wich is just a shortcut to the end of your script) See. [The system cannot find the batch label specified](https://web.archive.org/web/20...
232,662
<p>I have a function which launches a javascript window, like this</p> <pre><code> function genericPop(strLink, strName, iWidth, iHeight) { var parameterList = "location=0,directories=0,status=0,menubar=0,resizable=no, scrollbars=no,toolbar=0,maximize=0,width=" + iWidth + ", height=" + iHeight; ...
[ { "answer_id": 232684, "author": "Gene", "author_id": 22673, "author_profile": "https://Stackoverflow.com/users/22673", "pm_score": 2, "selected": false, "text": "<p>I use this <a href=\"http://www.leigeber.com/2008/04/custom-javascript-dialog-boxes/\" rel=\"nofollow noreferrer\">dialog ...
2008/10/24
[ "https://Stackoverflow.com/questions/232662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11602/" ]
I have a function which launches a javascript window, like this ``` function genericPop(strLink, strName, iWidth, iHeight) { var parameterList = "location=0,directories=0,status=0,menubar=0,resizable=no, scrollbars=no,toolbar=0,maximize=0,width=" + iWidth + ", height=" + iHeight; var new_wi...
Here is my solution using jQuery and jQuery UI libraries. Your API is not changed ~~, but parameter 'name' is ignored~~. I use `iframe` to load content from given `strLink` and then display that `iframe` as a child to generated `div`, which is then converted to modal pop-up using jQuery: ``` function genericPop(strLin...
232,678
<p>I am working on implementing tail for an assignment. I have it working correctly however I seem to be getting an error from free at random times.</p> <p>I can't see, to track it down to a pattern or anything besides it is consistent.</p> <p>For example if I call my program as "tail -24 test.in" I would get the the...
[ { "answer_id": 232708, "author": "Windows programmer", "author_id": 23705, "author_profile": "https://Stackoverflow.com/users/23705", "pm_score": 0, "selected": false, "text": "<p>Do nlines and numlines have the same value?</p>\n\n<p>Does the caller of insert_line allow room for the trai...
2008/10/24
[ "https://Stackoverflow.com/questions/232678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25012/" ]
I am working on implementing tail for an assignment. I have it working correctly however I seem to be getting an error from free at random times. I can't see, to track it down to a pattern or anything besides it is consistent. For example if I call my program as "tail -24 test.in" I would get the the the incorrect ch...
Your routine is writing beyond the allocated line buffer. The size of the line passed as an argument (i.e. "len") probably does not include the NUL terminator. When you call malloc to copy the line (i.e. "s") you need to allocate an extra byte for the string terminator: ``` *(lines + slot) = (char *) malloc((len + 1...
232,682
<p>I've already written a generator that does the trick, but I'd like to know the best possible way to implement the off-side rule.</p> <p>Shortly: <a href="http://en.wikipedia.org/wiki/Off-side_rule" rel="noreferrer">Off-side rule</a> means in this context that indentation is getting recognized as a syntactic element...
[ { "answer_id": 258167, "author": "zaphod", "author_id": 13871, "author_profile": "https://Stackoverflow.com/users/13871", "pm_score": 4, "selected": true, "text": "<p>I've written tokenizers and parsers for a couple of little indentation-centric domain-specific languages in the past coup...
2008/10/24
[ "https://Stackoverflow.com/questions/232682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21711/" ]
I've already written a generator that does the trick, but I'd like to know the best possible way to implement the off-side rule. Shortly: [Off-side rule](http://en.wikipedia.org/wiki/Off-side_rule) means in this context that indentation is getting recognized as a syntactic element. Here is the offside rule in pseudoc...
I've written tokenizers and parsers for a couple of little indentation-centric domain-specific languages in the past couple of years, and what you have there looks pretty reasonable to me, for whatever that's worth. If I'm not mistaken, your method is quite similar to what Python does, for example, which seems like it ...
232,688
<pre><code>&lt;style type="text/css"&gt; html, body { background: #fff; margin: 0; padding: 0; } #nav { font-family: Verdana, sans-serif; height: 29px; font-size: 12px; padding: 0 0 0 10px; /* this is used for something else */ background-color: #456; } #nav ul, #nav ul li { list-s...
[ { "answer_id": 232699, "author": "Gene", "author_id": 22673, "author_profile": "https://Stackoverflow.com/users/22673", "pm_score": 0, "selected": false, "text": "<p>have you tried:</p>\n\n<pre><code>#nav ul li a {\n color: #FFF;\n text-decoration: none;\n padding: 0px 0 0 20px;...
2008/10/24
[ "https://Stackoverflow.com/questions/232688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
``` <style type="text/css"> html, body { background: #fff; margin: 0; padding: 0; } #nav { font-family: Verdana, sans-serif; height: 29px; font-size: 12px; padding: 0 0 0 10px; /* this is used for something else */ background-color: #456; } #nav ul, #nav ul li { list-style: none; ...
This works on my machine: ``` <style type="text/css"> html, body { background: #fff; margin: 0; padding: 0; } #nav { font-family: Verdana, sans-serif; height: 29px; font-size: 12px; padding: 0 0 0 10px; /* this is used for something else */ background-color: #456; } #nav ul, #nav ul l...
232,691
<p>I've allocated an "array" of <code>mystruct</code> of size <code>n</code> like this:</p> <pre><code>if (NULL == (p = calloc(sizeof(struct mystruct) * n,1))) { /* handle error */ } </code></pre> <p>Later on, I only have access to <code>p</code>, and no longer have <code>n</code>. Is there a way to determine the le...
[ { "answer_id": 232696, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 4, "selected": false, "text": "<p>keep track of the array size yourself; free uses the malloc chain to free the <em>block</em> that was allocated, w...
2008/10/24
[ "https://Stackoverflow.com/questions/232691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31092/" ]
I've allocated an "array" of `mystruct` of size `n` like this: ``` if (NULL == (p = calloc(sizeof(struct mystruct) * n,1))) { /* handle error */ } ``` Later on, I only have access to `p`, and no longer have `n`. Is there a way to determine the length of the array given just the pointer `p`? I figure it *must* be p...
No, there is no way to get this information without depending strongly on the implementation details of `malloc`. In particular, `malloc` may allocate more bytes than you request (e.g. for efficiency in a particular memory architecture). It would be much better to redesign your code so that you keep track of `n` explic...
232,732
<p>How do I convert a string to DateTime format? For example, if I had a string like:</p> <p><code>"24/10/2008"</code></p> <p>How do I get that into DateTime format ?</p>
[ { "answer_id": 232739, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": false, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.datetime.parseexact.aspx\" rel=\"noreferrer\">DateTime.P...
2008/10/24
[ "https://Stackoverflow.com/questions/232732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I convert a string to DateTime format? For example, if I had a string like: `"24/10/2008"` How do I get that into DateTime format ?
Use [DateTime.ParseExact](http://msdn.microsoft.com/en-us/library/system.datetime.parseexact.aspx): ``` string str = "24/10/2008"; DateTime dt = DateTime.ParseExact(str, "dd/MM/yyyy", Thread.CurrentThread.CurrentCulture); ``` (You should consider what culture you actually want to p...
232,744
<p>Sometimes gdb prints "incomplete type" for some type of variables. What does this mean and how can we see that value?</p>
[ { "answer_id": 240856, "author": "Daniel Cassidy", "author_id": 31662, "author_profile": "https://Stackoverflow.com/users/31662", "pm_score": 6, "selected": true, "text": "<p>It means that the type of that variable has been incompletely specified. For example:</p>\n\n<pre><code>struct ha...
2008/10/24
[ "https://Stackoverflow.com/questions/232744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1692070/" ]
Sometimes gdb prints "incomplete type" for some type of variables. What does this mean and how can we see that value?
It means that the type of that variable has been incompletely specified. For example: ``` struct hatstand; struct hatstand *foo; ``` GDB knows that `foo` is a pointer to a `hatstand` structure, but the members of that structure haven't been defined. Hence, "incomplete type". To print the value, you can cast it to a...
232,747
<p>I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That is, it should look like this:</p> <pre><code>setting1=Value1 set...
[ { "answer_id": 232788, "author": "call me Steve", "author_id": 24334, "author_profile": "https://Stackoverflow.com/users/24334", "pm_score": 2, "selected": false, "text": "<p>You can pass the property file as a parameter to a Java program (that may launch the main program later on). And ...
2008/10/24
[ "https://Stackoverflow.com/questions/232747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22227/" ]
I'm trying to read variables from a batch file for later use in the batch script, which is a Java launcher. I'd ideally like to have the same format for the settings file on all platforms (Unix, Windows), and also be a valid Java Properties file. That is, it should look like this: ``` setting1=Value1 setting2=Value2 ....
You can do this in a batch file as follows: ``` setlocal FOR /F "tokens=*" %%i in ('type Settings.txt') do SET %%i java -Dsetting1=%setting1% ... endlocal ``` This reads a text file containing strings like "SETTING1=VALUE1" and calls SET to set them as environment variables. setlocal/endlocal are used to limit the ...
232,781
<p>can anybody show me how to build a string using checkbox. what would be the best way to do this.</p> <p>for example i have 4 checkbox's each with its own value (valueA, valueB, valueC, valueD) the thing is i want to display each result in different lines.</p> <p>result if B &amp; C is selected : </p> <p>valueB <b...
[ { "answer_id": 232801, "author": "Unsliced", "author_id": 2902, "author_profile": "https://Stackoverflow.com/users/2902", "pm_score": 0, "selected": false, "text": "<pre><code>\"if I saved this into a database\" ? \n</code></pre>\n\n<p>You'll need to be a bit more specific with your home...
2008/10/24
[ "https://Stackoverflow.com/questions/232781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
can anybody show me how to build a string using checkbox. what would be the best way to do this. for example i have 4 checkbox's each with its own value (valueA, valueB, valueC, valueD) the thing is i want to display each result in different lines. result if B & C is selected : valueB valueC and how would i d...
Use a StringBuilder to build the string, and append Environment.NewLine each time you append: ``` StringBuilder builder = new StringBuilder(); foreach (CheckBox cb in checkboxes) { if (cb.Checked) { builder.AppendLine(cb.Text); // Or whatever // Alternatively: // builder.Append(cb.Text...
232,848
<p>I'm writing code like this, doing a little quick and dirty timing:</p> <pre><code>var sw = new Stopwatch(); sw.Start(); for (int i = 0; i &lt; 1000; i++) { b = DoStuff(s); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); </code></pre> <p>Surely there's a way to call this bit of timing code as a fancy-sc...
[ { "answer_id": 232852, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 4, "selected": false, "text": "<p>You could try writing an extension method for whatever class you're using (or any base class).</p>\n\n<p>I would have t...
2008/10/24
[ "https://Stackoverflow.com/questions/232848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1/" ]
I'm writing code like this, doing a little quick and dirty timing: ``` var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { b = DoStuff(s); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); ``` Surely there's a way to call this bit of timing code as a fancy-schmancy .NET 3.0 lambda rather...
How about extending the Stopwatch class? ``` public static class StopwatchExtensions { public static long Time(this Stopwatch sw, Action action, int iterations) { sw.Reset(); sw.Start(); for (int i = 0; i < iterations; i++) { action(); } sw.Stop(); ...
232,861
<p>Generate the Fibonacci sequence in the fewest amount of characters possible. Any language is OK, except for one that you define with one operator, <code>f</code>, which prints the Fibonacci numbers.</p> <p>Starting point: <strong><s>25</s> 14 characters</strong> in <strong>Haskell</strong>:</p> <p><s> <code>f=0:1...
[ { "answer_id": 232943, "author": "Chris Young", "author_id": 9417, "author_profile": "https://Stackoverflow.com/users/9417", "pm_score": 3, "selected": false, "text": "<p>22 characters with dc:</p>\n\n<pre><code>1[pdd5**v1++2/lxx]dsxx\n</code></pre>\n\n<p>Invoke with either:</p>\n\n<pre>...
2008/10/24
[ "https://Stackoverflow.com/questions/232861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Generate the Fibonacci sequence in the fewest amount of characters possible. Any language is OK, except for one that you define with one operator, `f`, which prints the Fibonacci numbers. Starting point: **~~25~~ 14 characters** in **Haskell**: ~~`f=0:1:zipWith(+)f(tail f)`~~ ``` f=0:scanl(+)1f ```
RePeNt, 9, 8 chars ================== ``` 1↓[2?+1] ``` Or 10 chars with printing: ``` 1↓[2?+↓£1] ``` Run using: ``` RePeNt "1↓[2?+1]" ``` RePeNt is a stack based toy language I wrote (and am still improving) in which all operators/functions/blocks/loops use Reverse Polish Notation (RPN). ``` Command Expl...
232,869
<pre><code>&lt;style type="text/css"&gt; body { font-family:Helvetica, sans-serif; font-size:12px; } p, h1, form, button { border: 0; margin: 0; padding: 0; } .spacer { clear: both; height: 1px; } /* ----------- My Form ----------- */ .myform { margin: 0 auto; width: 400px; padding: 14px;...
[ { "answer_id": 232880, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 0, "selected": false, "text": "<p>You have them named the same as a text input - change <code>name=\"textfield\"</code> to <code>name=\"my_radio\"</code></p...
2008/10/24
[ "https://Stackoverflow.com/questions/232869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
``` <style type="text/css"> body { font-family:Helvetica, sans-serif; font-size:12px; } p, h1, form, button { border: 0; margin: 0; padding: 0; } .spacer { clear: both; height: 1px; } /* ----------- My Form ----------- */ .myform { margin: 0 auto; width: 400px; padding: 14px; } /* ---...
(within the style tags) add these new style rules: ``` #basic input.radio { width:20px; } #basic label.radiolabel { width:40px; text-align:left; line-height:24px; } ``` in your html: add a new class to each label, like so: ``` <!-- Problem ---> <input type="radio" name="textfield" id="r1" cla...
232,884
<p>Like most developers here and in the entire world, I have been developing software systems using object-oriented programming (OOP) techniques for many years. So when I read that aspect-oriented programming (AOP) addresses many of the problems that traditional OOP doesn't solve completely or directly, I pause and thi...
[ { "answer_id": 232897, "author": "Norbert B.", "author_id": 2605840, "author_profile": "https://Stackoverflow.com/users/2605840", "pm_score": 5, "selected": false, "text": "<p>OOP and AOP are not mutually exclusive.\nAOP can be good addition to OOP.\nAOP is especially handy for adding st...
2008/10/24
[ "https://Stackoverflow.com/questions/232884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30715/" ]
Like most developers here and in the entire world, I have been developing software systems using object-oriented programming (OOP) techniques for many years. So when I read that aspect-oriented programming (AOP) addresses many of the problems that traditional OOP doesn't solve completely or directly, I pause and think,...
Why "vs"? It is not "vs". You can use Aspect Oriented programming in combination with functional programming, but also in combination with Object Oriented one. It is not "vs", it is "Aspect Oriented Programming **with** Object Oriented Programming". To me AOP is some kind of "meta-programming". Everything that AOP doe...
232,895
<p>I came across an interesting article which shows how we can transparently encrypt jdbc connections using java thin client. </p> <p><a href="http://javasight.wordpress.com/2008/08/29/network-data-encryption-and-integrity-for-thin-jdbc-clients/" rel="nofollow noreferrer">http://javasight.wordpress.com/2008/08/29/netw...
[ { "answer_id": 574473, "author": "Franklin", "author_id": 67517, "author_profile": "https://Stackoverflow.com/users/67517", "pm_score": 1, "selected": false, "text": "<p>It can be similarly done. I believe on the Oracle AS there is an option at the bottom of the page when you create data...
2008/10/24
[ "https://Stackoverflow.com/questions/232895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I came across an interesting article which shows how we can transparently encrypt jdbc connections using java thin client. <http://javasight.wordpress.com/2008/08/29/network-data-encryption-and-integrity-for-thin-jdbc-clients/> However I want to know how this can be achieved for application servers (like oc4j) datas...
It can be similarly done. I believe on the Oracle AS there is an option at the bottom of the page when you create datasource which says add properties. I believe you can add the following over there and give it a try. ``` // Set the Client encryption level "oracle.net.encryption_client" = Service.getLevelString(leve...
232,905
<p>I got this logic in a control to create a correct url for an image. My control basically needs to diplay an image, but the src is actually a complex string based on different parameters pointing at an image-server.</p> <p>So we decided to to create a control MyImage derived from asp:Image - it works like a charm. N...
[ { "answer_id": 574473, "author": "Franklin", "author_id": 67517, "author_profile": "https://Stackoverflow.com/users/67517", "pm_score": 1, "selected": false, "text": "<p>It can be similarly done. I believe on the Oracle AS there is an option at the bottom of the page when you create data...
2008/10/24
[ "https://Stackoverflow.com/questions/232905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
I got this logic in a control to create a correct url for an image. My control basically needs to diplay an image, but the src is actually a complex string based on different parameters pointing at an image-server. So we decided to to create a control MyImage derived from asp:Image - it works like a charm. Now i need ...
It can be similarly done. I believe on the Oracle AS there is an option at the bottom of the page when you create datasource which says add properties. I believe you can add the following over there and give it a try. ``` // Set the Client encryption level "oracle.net.encryption_client" = Service.getLevelString(leve...
232,926
<p>For instance, winsock libs works great across all versions of the visual studio. But I am having real trouble to provide a consistent binary across all the versions. The dll compiled with VS 2005 won't work when linked to an application written in 2008. I upgraded both 2k5 and 2k8 to SP1, but the results haven't cha...
[ { "answer_id": 232959, "author": "Chris Becke", "author_id": 27491, "author_profile": "https://Stackoverflow.com/users/27491", "pm_score": 5, "selected": true, "text": "<p>First, dont pass anything other than plain old data accross DLL boundries. i.e. structs are fine. classes are not.\n...
2008/10/24
[ "https://Stackoverflow.com/questions/232926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1781/" ]
For instance, winsock libs works great across all versions of the visual studio. But I am having real trouble to provide a consistent binary across all the versions. The dll compiled with VS 2005 won't work when linked to an application written in 2008. I upgraded both 2k5 and 2k8 to SP1, but the results haven't change...
First, dont pass anything other than plain old data accross DLL boundries. i.e. structs are fine. classes are not. Second, make sure that ownership is not transferred - i.e. any structs passed accross the dll boundry are never deallocated outside the dll. So, if you dll exports a X\* GetX() function, there is a corresp...