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
267,064
<p>Why is the dropdown not showing my blank item first? Here is what I have</p> <pre><code>drpList.Items.Add(New ListItem("", "")) With drpList .DataSource = myController.GetList(userid) .DataTextField = "Name" .DataValueField = "ID" .DataBind() End With </code></pre> <p>Edit ~ I am binding to a Gene...
[ { "answer_id": 267070, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>it looks like you are adding a blank item, and then databinding, which would empty the list; try inserting the bla...
2008/11/05
[ "https://Stackoverflow.com/questions/267064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
Why is the dropdown not showing my blank item first? Here is what I have ``` drpList.Items.Add(New ListItem("", "")) With drpList .DataSource = myController.GetList(userid) .DataTextField = "Name" .DataValueField = "ID" .DataBind() End With ``` Edit ~ I am binding to a Generig List, could this be th...
After your databind: ``` drpList.Items.Insert(0, new ListItem(String.Empty, String.Empty)); drpList.SelectedIndex = 0; ```
267,071
<p>I'm using the JSP <a href="http://displaytag.sourceforge.net/11/" rel="nofollow noreferrer">displaytag</a> tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below:</p> <pre><code>&lt;display:table name="tableData" id="stat" sort="pag...
[ { "answer_id": 267081, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 2, "selected": false, "text": "<p>Take a look at using <a href=\"http://jquery.com\" rel=\"nofollow noreferrer\">jquery</a> and its excellent <a href=\"...
2008/11/05
[ "https://Stackoverflow.com/questions/267071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I'm using the JSP [displaytag](http://displaytag.sourceforge.net/11/) tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below: ``` <display:table name="tableData" id="stat" sort="page"> <display:column property="name" title="Name" sor...
As far as I know, this is not possible. JQuery's tablesorter may work for the small tables that it uses for its examples, but most tables have to come from an actual database. This hit is far too great to simply retrieve all the data before returning to the client with this information, and then allowing it to be sorte...
267,076
<p>Could someone please tell me which objects types can be tested using Regular Expressions in C#?</p>
[ { "answer_id": 267084, "author": "Manu", "author_id": 2133, "author_profile": "https://Stackoverflow.com/users/2133", "pm_score": 4, "selected": true, "text": "<p>If I understand you correctly and you are asking which object types can be tested against regular expressions then the answer...
2008/11/05
[ "https://Stackoverflow.com/questions/267076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
Could someone please tell me which objects types can be tested using Regular Expressions in C#?
If I understand you correctly and you are asking which object types can be tested against regular expressions then the answer is: strings and only strings. Thus your test would be: ``` if(obj is string){...} ```
267,085
<p>I'm trying to convert the below SQL query to HQL and am having a few issues. A straight line by line conversion doesn't work, I am wondering if I should be using an Inner Join in the HQL?</p> <pre><code> SELECT (UNIX_TIMESTAMP(cosc1.change_date) - UNIX_TIMESTAMP(cosc2.change_date)) FROM customer_ord...
[ { "answer_id": 267166, "author": "Nick", "author_id": 34558, "author_profile": "https://Stackoverflow.com/users/34558", "pm_score": 4, "selected": true, "text": "<p>Typically you HQL joins are specified using the property on the object, eg, if class Foo and Bar and Foo.bar is of type Bar...
2008/11/05
[ "https://Stackoverflow.com/questions/267085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18340/" ]
I'm trying to convert the below SQL query to HQL and am having a few issues. A straight line by line conversion doesn't work, I am wondering if I should be using an Inner Join in the HQL? ``` SELECT (UNIX_TIMESTAMP(cosc1.change_date) - UNIX_TIMESTAMP(cosc2.change_date)) FROM customer_order_state_chang...
Typically you HQL joins are specified using the property on the object, eg, if class Foo and Bar and Foo.bar is of type Bar, then `from Foo f inner join f.bar as b` is the join. As far as I know, there's no way of performing a self-join in HQL (I could be wrong here). That said, Hibernate allows you to write (slightly...
267,091
<p>At the risk of being downmodded, I want to ask what the best mechanism (best is obviously subjective for the practice violation inherent here) for viewing data from a table, using C#, with a <em>lot</em> of columns. By a lot, I mean something like 1000.</p> <p>Now before you get all click happy, or throw out respo...
[ { "answer_id": 267107, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>try a html table with a <sub>very tiny font</sub></p>\n\n<p>if you're concerned about formatting the table use CSS...
2008/11/05
[ "https://Stackoverflow.com/questions/267091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13154/" ]
At the risk of being downmodded, I want to ask what the best mechanism (best is obviously subjective for the practice violation inherent here) for viewing data from a table, using C#, with a *lot* of columns. By a lot, I mean something like 1000. Now before you get all click happy, or throw out responses like "why the...
Ok, what turned out to be the right answer for me was to use the [ReportViewer control](http://msdn.microsoft.com/en-us/library/ms251671(VS.80).aspx), but not in any manner documented in MSDN. The problem is that I have dynamic data, so I need a dynamic report, and all of the tutorials, etc. seem to assume you have the...
267,101
<p>once you have a commit that contains a submodule object, you pretty much cannot get git-svn to commit past it.</p> <p>Any ideas, workarounds, anything that is not "don't use submodules with git-svn"?</p> <p>So far the answer seems to be a big NO.</p> <p>Is there any way to at least allow existing git commits cont...
[ { "answer_id": 286185, "author": "Aupajo", "author_id": 10407, "author_profile": "https://Stackoverflow.com/users/10407", "pm_score": 1, "selected": false, "text": "<p>You'll need to replace the submodules with the <code>svn:externals</code> property to play nice with Subversion.</p>\n\n...
2008/11/05
[ "https://Stackoverflow.com/questions/267101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13989/" ]
once you have a commit that contains a submodule object, you pretty much cannot get git-svn to commit past it. Any ideas, workarounds, anything that is not "don't use submodules with git-svn"? So far the answer seems to be a big NO. Is there any way to at least allow existing git commits containing submodule data to...
You'll need to replace the submodules with the `svn:externals` property to play nice with Subversion. ``` svn propset svn:externals [...] ``` I don't think there's any other way round it.
267,113
<p>I’m trying to implement a dictionary for use with WCF. My requirements are:</p> <ul> <li>actual (private variable or base class) type equivalent to Dictionary </li> <li>Comparer = <code>System.StringComparer.InvariantCultureIgnoreCase</code></li> <li>Custom (override/new) Add(key, value) method (to include valida...
[ { "answer_id": 267691, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Preamble: note that adding a \"new\" <code>Add</code> doesn't stop people calling the old <code>Add</code> simply ...
2008/11/05
[ "https://Stackoverflow.com/questions/267113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28736/" ]
I’m trying to implement a dictionary for use with WCF. My requirements are: * actual (private variable or base class) type equivalent to Dictionary * Comparer = `System.StringComparer.InvariantCultureIgnoreCase` * Custom (override/new) Add(key, value) method (to include validations). * Override ToString() * Use of the...
* Use the `CollectionDataContract` attribute as jezell suggested * Manually generate the reference (proxy) code with SvcUtil, using the /collectionType parameter. This parameter is not supported by the vs2008 service reference GUI. Source: [WCF Collection Type Sharing](http://www.codeproject.com/KB/WCF/WCFCollectionTy...
267,114
<p>I always try to avoid to return string literals, because I fear they aren't defined outside of the function. But I'm not sure if this is the case. Let's take, for example, this function:</p> <pre><code> const char * return_a_string(void) { return "blah"; } </code></pre> <p>Is this correct code? It does work fo...
[ { "answer_id": 267134, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 7, "selected": true, "text": "<p>This code is fine across all platforms. The string gets compiled into the binary as a static string literal. If y...
2008/11/05
[ "https://Stackoverflow.com/questions/267114", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18687/" ]
I always try to avoid to return string literals, because I fear they aren't defined outside of the function. But I'm not sure if this is the case. Let's take, for example, this function: ``` const char * return_a_string(void) { return "blah"; } ``` Is this correct code? It does work for me, but maybe it only wo...
This code is fine across all platforms. The string gets compiled into the binary as a static string literal. If you are on windows for example you can even open your .exe with notepad and search for the string itself. Since it is a static string literal scope does not matter. **String pooling:** One thing to look o...
267,124
<p>I'm working on an ASP.Net application and working to add some Ajax to it to speed up certain areas. The first area that I am concentrating is the attendance area for the teachers to report attendance (and some other data) about the kids. This needs to be fast.</p> <p>I've created a dual-control set up where the use...
[ { "answer_id": 267159, "author": "Justin Bozonier", "author_id": 9401, "author_profile": "https://Stackoverflow.com/users/9401", "pm_score": 0, "selected": false, "text": "<p>To find out why it's taking so long I would recommend using Fiddler to spy on your IE traffic: <a href=\"http://w...
2008/11/05
[ "https://Stackoverflow.com/questions/267124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3442/" ]
I'm working on an ASP.Net application and working to add some Ajax to it to speed up certain areas. The first area that I am concentrating is the attendance area for the teachers to report attendance (and some other data) about the kids. This needs to be fast. I've created a dual-control set up where the user clicks o...
If speed/performance is a major concern for you, I would strongly suggest against UpdatePanels, as they cause a full page postback that drags the ViewState in the header, among other crap, and forces the page to go through the whole life cycle every time (even though the user doesn't see this). You should be able to (...
267,163
<p>I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line program to make a simple HTTP request, there are zero compiler errors or warnings. The program compiles fine, yet the HTTP Request is never made...
[ { "answer_id": 267265, "author": "Mike Abdullah", "author_id": 28768, "author_profile": "https://Stackoverflow.com/users/28768", "pm_score": 2, "selected": false, "text": "<p><code>NSURLConnection</code> is an asynchronous API that relies upon <code>NSRunLoop</code>. Your posted code nev...
2008/11/05
[ "https://Stackoverflow.com/questions/267163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've had significant success with NSURL, NSURL[Mutable]Request, NSURLConnection with my iPhone applications. When trying to compile a stand alone Cocoa application, 10 line program to make a simple HTTP request, there are zero compiler errors or warnings. The program compiles fine, yet the HTTP Request is never made to...
The other poster pretty much answered this for you, but I thought I would just add a few things. First, you don't really need to link to Cocoa for this, just linking to the Foundation framework is okay. Also, since you don't need a connection to the Window Server, you can get rid of the [NSApplication sharedApplicaito...
267,168
<p>In Visual Studio, I can select the "Treat warnings as errors" option to prevent my code from compiling if there are any warnings. Our team uses this option, but there are two warnings we would like to keep as warnings. </p> <p>There is an option to suppress warnings, but we DO want them to show up as warnings, so t...
[ { "answer_id": 267472, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 1, "selected": false, "text": "<p>Why do you want to keep seeing warnings that you are not treating as errors? I am confused about why this is desirable - e...
2008/11/05
[ "https://Stackoverflow.com/questions/267168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24315/" ]
In Visual Studio, I can select the "Treat warnings as errors" option to prevent my code from compiling if there are any warnings. Our team uses this option, but there are two warnings we would like to keep as warnings. There is an option to suppress warnings, but we DO want them to show up as warnings, so that won't ...
In Visual Studio 2022 we have a new Project Properties UI which includes an editor for this. Under *Build | Errors and Warnings* if you set *Treat warnings as errors* to *All*, then another property appears which allows you to exempt specific warnings from being treated as errors: [![enter image description here](htt...
267,179
<p>I'm trying to create a template class to insulate the users from a data type. I would have preferred to use an adapter class, but the function signatures needed to change requiring a template.</p> <p>In the code sample below(not the actual project just a simplified version to illustrate the problem), while in the ...
[ { "answer_id": 267254, "author": "Greg Rogers", "author_id": 5963, "author_profile": "https://Stackoverflow.com/users/5963", "pm_score": 0, "selected": false, "text": "<p><code>StructWrapper</code> is inheriting from the primary class template (ie the least specialized), which does not d...
2008/11/05
[ "https://Stackoverflow.com/questions/267179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a template class to insulate the users from a data type. I would have preferred to use an adapter class, but the function signatures needed to change requiring a template. In the code sample below(not the actual project just a simplified version to illustrate the problem), while in the main routin...
`dumpOuter` fails because `IntAdapter` needs to be qualified (as in the referenced question). `dumpOuterFailsAsWell` fails because GCC does parsing of this code,even though it's not complete, and so it needs to know it's a type that you mean: ``` void dumpOuterWorks(const T& tempParam) { typename ob_traits<T>::In...
267,186
<p>In C++ when can a virtual function use static binding? If it is being accessed through a pointer, accessed directly, or never?</p>
[ { "answer_id": 267231, "author": "Skizz", "author_id": 1898, "author_profile": "https://Stackoverflow.com/users/1898", "pm_score": 2, "selected": false, "text": "<p>Static binding can only be done when the object's type is totally unambiguous at compile time. I can only think of four pla...
2008/11/05
[ "https://Stackoverflow.com/questions/267186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In C++ when can a virtual function use static binding? If it is being accessed through a pointer, accessed directly, or never?
If you want to call the base class version of a function, you can do that by explicitly naming the base class: ``` class Base { public: virtual ~Base() {} virtual void DoIt() { printf("In Base::DoIt()\n"); } }; class Derived : public Base { public: virtual void DoIt() { printf("In Derived::DoIt()\n"); } }; Bas...
267,191
<p>Bascially I want to know the best way to hide/show an ASP.NET control from a Javascript function. I figured I would just access the control in Javascript using:</p> <pre><code>var theControl = document.getElementById("txtEditBox"); </code></pre> <p>Then just set the control's Visible property to true/false. It d...
[ { "answer_id": 267197, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 6, "selected": true, "text": "<p>The \"Visible\" property of an ASP.NET control determines whether or not it will be rendered on the client (i.e. sen...
2008/11/05
[ "https://Stackoverflow.com/questions/267191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12172/" ]
Bascially I want to know the best way to hide/show an ASP.NET control from a Javascript function. I figured I would just access the control in Javascript using: ``` var theControl = document.getElementById("txtEditBox"); ``` Then just set the control's Visible property to true/false. It doesn't seem to be working, I...
The "Visible" property of an ASP.NET control determines whether or not it will be rendered on the client (i.e. sent to the client). If it is false when the page is rendered, it will never arrive at the client. So, you cannot, technically, set that property of the control. That said, if the control *is* rendered on th...
267,193
<p>I have a computer at home which I can't access from work. I'd like to be able to view results from work that my home computer produces. The best idea I've come up with is an automated script running on my home computer that emails myself the results (from a text file or stderr/out) when complete. </p> <p>I'm dec...
[ { "answer_id": 267220, "author": "SpoonMeiser", "author_id": 1577190, "author_profile": "https://Stackoverflow.com/users/1577190", "pm_score": 0, "selected": false, "text": "<p>Traditionaly, with unix systems like Linux, you'd have an MTA, a mail transfer agent, on the computer that deal...
2008/11/05
[ "https://Stackoverflow.com/questions/267193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a computer at home which I can't access from work. I'd like to be able to view results from work that my home computer produces. The best idea I've come up with is an automated script running on my home computer that emails myself the results (from a text file or stderr/out) when complete. I'm decent with bash...
On any Linux I have used the mail sending from command-line is simple: ``` mail -s "My subject here" recipient@wherever.com <message_body.txt ``` AFAIK this acts as a front-end to sendmail, and you have to have sendmail configured to forward the messages to your ISP mail server.
267,198
<p>We need to handle this event in the base form, regardless of which controls currently have focus. We have a couple of global key commands that need to work regardless of control focus.</p> <p>This works by handling the PreviewKeyDown event in the form normally. When we add a user control to the form, the event no ...
[ { "answer_id": 267385, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 1, "selected": false, "text": "<p>This is probably not the best way of doing it, but the first way that comes to mind. </p>\n\n<p>In your forms constructor...
2008/11/05
[ "https://Stackoverflow.com/questions/267198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1811110/" ]
We need to handle this event in the base form, regardless of which controls currently have focus. We have a couple of global key commands that need to work regardless of control focus. This works by handling the PreviewKeyDown event in the form normally. When we add a user control to the form, the event no longer fire...
We ended up doing this: I found a workaround for this by setting up a hidden menu item by setting: ``` ToolStripMenuItem.Visible = false ``` (Thanks to [this article)](http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx). It appears that the Main Menu of a form always gets searched for your shortcut ke...
267,219
<p>I want to display the current host and database names in a view.</p> <p>Where can I get these names?</p> <p>Are there some predefined environment or global variables? </p>
[ { "answer_id": 267251, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 5, "selected": true, "text": "<p>You can create a rails configuration object and obtain the necessary information from it:</p>\n\n<pre><code>config...
2008/11/06
[ "https://Stackoverflow.com/questions/267219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14755/" ]
I want to display the current host and database names in a view. Where can I get these names? Are there some predefined environment or global variables?
You can create a rails configuration object and obtain the necessary information from it: ``` config = Rails::Configuration.new host = config.database_configuration[RAILS_ENV]["host"] database = config.database_configuration[RAILS_ENV]["database"] ``` See the [documentation](http://edgedocs.planetargon.org/cla...
267,221
<p>I've got a Perforce server set up, and installed the P4V client. I've created a new depot and a new workspace. Per the documentation, I've mapped the workspace to the depot. So far so good.</p> <p>I now have a .SQL script that was created by an external application that I wish to check in for the first time. I ...
[ { "answer_id": 267232, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 0, "selected": false, "text": "<p>Are you sure your filespec includes the directory you have added your file in?</p>\n\n<p>Perhaps you could post your Clie...
2008/11/06
[ "https://Stackoverflow.com/questions/267221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34903/" ]
I've got a Perforce server set up, and installed the P4V client. I've created a new depot and a new workspace. Per the documentation, I've mapped the workspace to the depot. So far so good. I now have a .SQL script that was created by an external application that I wish to check in for the first time. I copied the fil...
I think your problem is likely to be with the mappings. This is a reasonably common issue. Taking your details ``` Workspace root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666 File dir under root: C:\Documents and Settings\wtansill\Perforce\wtansill_localhost_1666\tunnel_files View mappings: ...
267,236
<p>It seems if I do something like</p> <pre><code>$file = fopen($filepath, "w"); $CR = curl_init(); curl_setopt($CR, CURLOPT_URL, $source_path); curl_setopt($CR, CURLOPT_POST, 1); curl_setopt($CR, CURLOPT_FAILONERROR, true); curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1); curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0); curl...
[ { "answer_id": 279844, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 3, "selected": true, "text": "<p>Note that functions like filesize() cache their result, try adding a call to clearstatcache() above 'print filesize...
2008/11/06
[ "https://Stackoverflow.com/questions/267236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
It seems if I do something like ``` $file = fopen($filepath, "w"); $CR = curl_init(); curl_setopt($CR, CURLOPT_URL, $source_path); curl_setopt($CR, CURLOPT_POST, 1); curl_setopt($CR, CURLOPT_FAILONERROR, true); curl_setopt($CR, CURLOPT_RETURNTRANSFER, 1); curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($CR, C...
Note that functions like filesize() cache their result, try adding a call to clearstatcache() above 'print filesize(...);'. Here is an example: ``` $file = '/tmp/test12345'; file_put_contents($file, 'hello'); echo filesize($file), "\n"; file_put_contents($file, 'hello world, this is a test'); echo filesize($file), "\n...
267,237
<p>What's the best way to unit test protected and private methods in Ruby, using the standard Ruby <code>Test::Unit</code> framework?</p> <p>I'm sure somebody will pipe up and dogmatically assert that "you should only unit test public methods; if it needs unit testing, it shouldn't be a protected or private method", b...
[ { "answer_id": 267401, "author": "James Baker", "author_id": 9365, "author_profile": "https://Stackoverflow.com/users/9365", "pm_score": 7, "selected": false, "text": "<p>You can bypass encapsulation with the send method:</p>\n\n<pre class=\"lang-ruby prettyprint-override\"><code>myobjec...
2008/11/06
[ "https://Stackoverflow.com/questions/267237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13157/" ]
What's the best way to unit test protected and private methods in Ruby, using the standard Ruby `Test::Unit` framework? I'm sure somebody will pipe up and dogmatically assert that "you should only unit test public methods; if it needs unit testing, it shouldn't be a protected or private method", but I'm not really int...
You can bypass encapsulation with the send method: ```ruby myobject.send(:method_name, args) ``` This is a 'feature' of Ruby. :) There was internal debate during Ruby 1.9 development which considered having `send` respect privacy and `send!` ignore it, but in the end nothing changed in Ruby 1.9. Ignore the comments...
267,248
<p>I have some code that looks like:</p> <pre><code>template&lt;unsigned int A, unsigned int B&gt; int foo() { int v = 1; const int x = A - B; if (x &gt; 0) { v = v &lt;&lt; x; } bar(v); } </code></pre> <p>gcc will complain about x being negative for certain instantiations of A, B; however, I do perfor...
[ { "answer_id": 267255, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 0, "selected": false, "text": "<p>Would this work?</p>\n\n<pre><code>const short unsigned int x = A - B;\n</code></pre>\n\n<p>It's cutting off a lot more...
2008/11/06
[ "https://Stackoverflow.com/questions/267248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have some code that looks like: ``` template<unsigned int A, unsigned int B> int foo() { int v = 1; const int x = A - B; if (x > 0) { v = v << x; } bar(v); } ``` gcc will complain about x being negative for certain instantiations of A, B; however, I do perform a check to make sure it is non-negative....
Since A and B are known at compile time, not only can you get rid of your warning, but you can also get rid of a runtime `if`, without any casts, like this: ``` #include <iostream> using namespace std; template< unsigned int A, unsigned int B > struct my { template< bool P > static void shift_if( int & ); ...
267,250
<p>I am using <code>getch()</code> and my app crashes instantly. Including when doing:</p> <pre><code>int main() { getch(); } </code></pre> <p>I can't find the link but supposedly the problem is that it needs to turn off buffering or something strange along those lines, and I still want <code>cout</code> to work ...
[ { "answer_id": 267281, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 2, "selected": false, "text": "<p>You have not exhibited a</p>\n\n<pre><code>#include &lt;stdio.h&gt;\n</code></pre>\n\n<p>or</p>\n\...
2008/11/06
[ "https://Stackoverflow.com/questions/267250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using `getch()` and my app crashes instantly. Including when doing: ``` int main() { getch(); } ``` I can't find the link but supposedly the problem is that it needs to turn off buffering or something strange along those lines, and I still want `cout` to work along with cross platform code. I was told to u...
Have you looked in `<curses.h>` to see what the `getch()` function does? Hint: OSX and Linux are not the same as Windows. Specifically, as a macro in `<curses.h>`, we find: ``` #define getch() wgetch(stdscr) ``` Now, there appears, on your system, to be an actual function `getch()` in the curses library, but it ex...
267,256
<p>After considering the answers to my previous question (<a href="https://stackoverflow.com/questions/252459/one-svn-repository-or-many">One SVN Repository or many?</a>), I've decided to take the 4 or so repositories I have and consolidate them into one. This of course leads to the question, <strong>what's the best wa...
[ { "answer_id": 267284, "author": "Davide Gualano", "author_id": 28582, "author_profile": "https://Stackoverflow.com/users/28582", "pm_score": 3, "selected": false, "text": "<p>Yes, using <a href=\"http://svnbook.red-bean.com/en/1.5/svn.ref.svnadmin.c.dump.html\" rel=\"noreferrer\">svnadm...
2008/11/06
[ "https://Stackoverflow.com/questions/267256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
After considering the answers to my previous question ([One SVN Repository or many?](https://stackoverflow.com/questions/252459/one-svn-repository-or-many)), I've decided to take the 4 or so repositories I have and consolidate them into one. This of course leads to the question, **what's the best way to do this?** Is ...
Edit: Oh well, the question edit was made while I was typing. This is an answer to > > Is there a way to combine two or more > repositories maintaining the version > history for both? > > > --- Assuming that The existing repositories have a structure like: * repository root + branches + tags + trunk and...
267,259
<p>So, I've been doing Java for a number of years now, but now I'm starting a C++ project. I'm trying to determine best practices for setting up said project.</p> <p>Within the project, how do you generally structure their code? Do you do it Java style with namespace folders and break up your source that way? Do you k...
[ { "answer_id": 267284, "author": "Davide Gualano", "author_id": 28582, "author_profile": "https://Stackoverflow.com/users/28582", "pm_score": 3, "selected": false, "text": "<p>Yes, using <a href=\"http://svnbook.red-bean.com/en/1.5/svn.ref.svnadmin.c.dump.html\" rel=\"noreferrer\">svnadm...
2008/11/06
[ "https://Stackoverflow.com/questions/267259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9450/" ]
So, I've been doing Java for a number of years now, but now I'm starting a C++ project. I'm trying to determine best practices for setting up said project. Within the project, how do you generally structure their code? Do you do it Java style with namespace folders and break up your source that way? Do you keep your p...
Edit: Oh well, the question edit was made while I was typing. This is an answer to > > Is there a way to combine two or more > repositories maintaining the version > history for both? > > > --- Assuming that The existing repositories have a structure like: * repository root + branches + tags + trunk and...
267,275
<p>Despite an earlier question (<a href="https://stackoverflow.com/questions/223894/opengl-rotation-using-gldrawpixels">asked here</a>), our project is constrained to using glDrawPixels, so we have to do some hackery.</p> <p>One of the feature requirements is to be able to have a magnified view show up on a clicked re...
[ { "answer_id": 267867, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 0, "selected": false, "text": "<p>Please, pretty please with loads of sugar, molasses, sprinkles and a mist of high-fructose corn syrup on top and all ove...
2008/11/06
[ "https://Stackoverflow.com/questions/267275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21981/" ]
Despite an earlier question ([asked here](https://stackoverflow.com/questions/223894/opengl-rotation-using-gldrawpixels)), our project is constrained to using glDrawPixels, so we have to do some hackery. One of the feature requirements is to be able to have a magnified view show up on a clicked region of an image; so,...
Here's the answer. The problem is that the LUT is being applied twice, so before calling the copy, call: ``` Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_FALSE); ``` Then, once done, call: ``` Gl.glPixelTransferi(Gl.GL_MAP_COLOR, Gl.GL_TRUE); ``` That way, the 'extreme clamping' I was describing is removed. @thing...
267,287
<p>Attempting to print out a list of values from 2 different variables that are aligned correctly.</p> <pre><code>foreach finalList ($correctList $wrongList) printf "%20s%s\n" $finalList end </code></pre> <p>This prints them out an they are aligned, but it's one after another. How would I have it go through each ite...
[ { "answer_id": 267313, "author": "Ray Tayek", "author_id": 51292, "author_profile": "https://Stackoverflow.com/users/51292", "pm_score": 0, "selected": false, "text": "<p>try getting rid of the \\n</p>\n" }, { "answer_id": 267340, "author": "Robert Gamble", "author_id": 2...
2008/11/06
[ "https://Stackoverflow.com/questions/267287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28392/" ]
Attempting to print out a list of values from 2 different variables that are aligned correctly. ``` foreach finalList ($correctList $wrongList) printf "%20s%s\n" $finalList end ``` This prints them out an they are aligned, but it's one after another. How would I have it go through each item in each list and THEN go ...
You can iterate over both lists at the same time like this: ``` # Get the max index of the smallest list set maxIndex = $#correctList if ( $#wrongList < $#correctList ) then set maxIndex = $#wrongList endif set index = 1 while ($index <= $maxIndex) printf "%-20s %s\n" "$correctList[$index]" "$wrongList[$index]" ...
267,303
<p>I'm am building my asp.net web application using MVC (Preview 5), and am also using the Master pages concept. </p> <p>My PageA and PageB are both content pages. I'm doing a form submit in a method via JavaScript from PageA to PageB. PageB has its PreviousPageType attribute set to PageA, but when I access the Pre...
[ { "answer_id": 267313, "author": "Ray Tayek", "author_id": 51292, "author_profile": "https://Stackoverflow.com/users/51292", "pm_score": 0, "selected": false, "text": "<p>try getting rid of the \\n</p>\n" }, { "answer_id": 267340, "author": "Robert Gamble", "author_id": 2...
2008/11/06
[ "https://Stackoverflow.com/questions/267303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31622/" ]
I'm am building my asp.net web application using MVC (Preview 5), and am also using the Master pages concept. My PageA and PageB are both content pages. I'm doing a form submit in a method via JavaScript from PageA to PageB. PageB has its PreviousPageType attribute set to PageA, but when I access the PreviousPage ...
You can iterate over both lists at the same time like this: ``` # Get the max index of the smallest list set maxIndex = $#correctList if ( $#wrongList < $#correctList ) then set maxIndex = $#wrongList endif set index = 1 while ($index <= $maxIndex) printf "%-20s %s\n" "$correctList[$index]" "$wrongList[$index]" ...
267,318
<p>I'm trying to create an OS X Service. I found <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/SysServices/Tasks/providing.html#//apple_ref/doc/uid/20000853" rel="nofollow noreferrer">Providing System Services</a> in Apple's documentation, however I'm finding it less than clear on what exactly I ne...
[ { "answer_id": 267363, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 0, "selected": false, "text": "<p>You might want to look at some commercial products to help you with this. See this posting on <a href=\"http://pmougin....
2008/11/06
[ "https://Stackoverflow.com/questions/267318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3857/" ]
I'm trying to create an OS X Service. I found [Providing System Services](http://developer.apple.com/documentation/Cocoa/Conceptual/SysServices/Tasks/providing.html#//apple_ref/doc/uid/20000853) in Apple's documentation, however I'm finding it less than clear on what exactly I need to do. I'm currently using an applica...
Make sure you are launching your app first to get the system to see the Service. Make sure you are registering the services handler in your app using - setServicesProvider: Also, check the Console log as that might give you some useful error info.
267,351
<p>The Dragon Book includes an exercise on converting integers to roman numerals using a syntax-directed translation scheme.</p> <p>How can this be completed?</p>
[ { "answer_id": 267587, "author": "Oddthinking", "author_id": 8014, "author_profile": "https://Stackoverflow.com/users/8014", "pm_score": 3, "selected": true, "text": "<p>I would consider parsing from right-to-left.</p>\n\n<p>First, I would map the units column:</p>\n\n<pre><code>0 -&gt; ...
2008/11/06
[ "https://Stackoverflow.com/questions/267351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
The Dragon Book includes an exercise on converting integers to roman numerals using a syntax-directed translation scheme. How can this be completed?
I would consider parsing from right-to-left. First, I would map the units column: ``` 0 -> '' 1 -> 'I' 2 -> 'II' 3 -> 'III' 4 -> 'IV' ... 9 -> 'IX' ``` Then, if there was a second column (e.g. second from the right = tens column), I would use that to map to ``` 0 -> '' 1 -> 'X' 2 -> 'XX' ... 9 -> 'XC' ``` That ...
267,367
<p>For example:</p> <p>Base class header file has:</p> <pre><code>enum FOO { FOO_A, FOO_B, FOO_C, FOO_USERSTART }; </code></pre> <p>Then the derived class has:</p> <pre><code>enum FOO { FOO_USERA=FOO_USERSTART FOO_USERB, FOO_USERC }; </code></pre> <p>Just to be clear on my usage it is for having an event handler w...
[ { "answer_id": 267390, "author": "Mark Kegel", "author_id": 14788, "author_profile": "https://Stackoverflow.com/users/14788", "pm_score": 2, "selected": false, "text": "<p>Yes, as long as the enum's are both members of a class. If they weren't then they would be of the same type and the ...
2008/11/06
[ "https://Stackoverflow.com/questions/267367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
For example: Base class header file has: ``` enum FOO { FOO_A, FOO_B, FOO_C, FOO_USERSTART }; ``` Then the derived class has: ``` enum FOO { FOO_USERA=FOO_USERSTART FOO_USERB, FOO_USERC }; ``` Just to be clear on my usage it is for having an event handler where the base class has events and then derived classes ...
No. The compiler needs to be able to decide whether the enum fits in a char, short, int or long once it sees the }. So if the base class header has ``` enum Foo { A, B, MAX = 1<<15 }; ``` a compiler may decide the enum fits in 16 bits. It can then use that, e.g. when laying out the base class. If you were lat...
267,369
<p>When beginning a new web project, i'm always a bit worried about removing pieces of the web.config. It seems there are more entries than ever with Net 3.5 SP1.</p> <p>Which bits of the .config do you delete for the following scenarios:</p> <ul> <li>WCF Web Service, no Javascript support</li> <li>Simple MVC Websit...
[ { "answer_id": 267380, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 2, "selected": false, "text": "<p>I usually just delete items from the web.config until things break -- a process of trial and error.</p>\n\n<p>It's astonish...
2008/11/06
[ "https://Stackoverflow.com/questions/267369", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30576/" ]
When beginning a new web project, i'm always a bit worried about removing pieces of the web.config. It seems there are more entries than ever with Net 3.5 SP1. Which bits of the .config do you delete for the following scenarios: * WCF Web Service, no Javascript support * Simple MVC Website EDIT Can someone document ...
Here is a stripped down Web.config i use for a simple WCF service ``` <?xml version="1.0"?> <configuration> <system.web> <compilation debug="true"> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> ...
267,374
<p>People in java/.net world has framework which provides methods for sorting a list.</p> <p>In CS, we all might have gone through Bubble/Insertion/Merge/Shell sorting algorithms. Do you write any of it these days?</p> <p>With frameworks in place, do you write code for sorting?<br></p> <p>Do you think it makes sense...
[ { "answer_id": 267381, "author": "tunaranch", "author_id": 27708, "author_profile": "https://Stackoverflow.com/users/27708", "pm_score": 1, "selected": false, "text": "<p>Personally, I've not had a need to write my own sorting code for a while.</p>\n\n<p>As far as interview questions go,...
2008/11/06
[ "https://Stackoverflow.com/questions/267374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23574/" ]
People in java/.net world has framework which provides methods for sorting a list. In CS, we all might have gone through Bubble/Insertion/Merge/Shell sorting algorithms. Do you write any of it these days? With frameworks in place, do you write code for sorting? Do you think it makes sense to ask people to write co...
There are two pieces of code I write today in order to sort data ``` list.Sort(); enumerable.OrderBy(x => x); // Occasionally a different lambda is used ```
267,399
<p>Thinking about <a href="https://stackoverflow.com/questions/267351/how-can-i-convert-from-integers-to-roman-numerals-using-a-syntax-directed-trans">my other problem</a>, i decided I can't even create a regular expression that will match roman numerals (let alone a context-free grammar that will generate them)</p> <...
[ { "answer_id": 267405, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 10, "selected": true, "text": "<p>You can use the following regex for this:</p>\n\n<pre><code>^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$\...
2008/11/06
[ "https://Stackoverflow.com/questions/267399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
Thinking about [my other problem](https://stackoverflow.com/questions/267351/how-can-i-convert-from-integers-to-roman-numerals-using-a-syntax-directed-trans), i decided I can't even create a regular expression that will match roman numerals (let alone a context-free grammar that will generate them) The problem is matc...
You can use the following regex for this: ``` ^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$ ``` Breaking it down, `M{0,4}` specifies the thousands section and basically restrains it to between `0` and `4000`. It's a relatively simple: ``` 0: <empty> matched by M{0} 1000: M matched by M{1} 2000...
267,410
<p>I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview</p> <p>Here is some pseudo code that doesn't work to help illustrate what I am trying to do:</p> <pre><code>MyDataTable dt = GetDataSource(); ListView1.DataBindings.Add("Column1.Text", dt, ...
[ { "answer_id": 267466, "author": "Handruin", "author_id": 26173, "author_profile": "https://Stackoverflow.com/users/26173", "pm_score": -1, "selected": false, "text": "<p>Check out this <a href=\"https://web.archive.org/web/20200221035838/http://geekswithblogs.net:80/rashid/archive/2007/...
2008/11/06
[ "https://Stackoverflow.com/questions/267410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
I have a datasource that I want to bind to a listview that has multiple columns. How do I bind my datasource to that listview Here is some pseudo code that doesn't work to help illustrate what I am trying to do: ``` MyDataTable dt = GetDataSource(); ListView1.DataBindings.Add("Column1.Text", dt, "MyDBCol1"); ListView...
It seems there is a lacuna in functionality of WinForms ListView control (thought it's possible to [databind](http://msdn.microsoft.com/en-us/library/ms750972.aspx#BindingDatatoaListView) new WPF ListBox). This article by Nick Karnik describes how to add databinding capability to custom control inherited from WinForm...
267,418
<p>Is there an elegant way to specialize a template based on one of its template parameters?</p> <p>Ie.</p> <pre><code>template&lt;int N&gt; struct Junk { static int foo() { // stuff return Junk&lt;N - 1&gt;::foo(); } }; // compile error: template argument '(size * 5)' involves template param...
[ { "answer_id": 267514, "author": "jwfearn", "author_id": 10559, "author_profile": "https://Stackoverflow.com/users/10559", "pm_score": 5, "selected": true, "text": "<p>How's this:</p>\n\n<pre><code>#include &lt;iostream&gt;\nusing namespace std;\n\ntemplate &lt; typename T, T N, T D &gt;...
2008/11/06
[ "https://Stackoverflow.com/questions/267418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
Is there an elegant way to specialize a template based on one of its template parameters? Ie. ``` template<int N> struct Junk { static int foo() { // stuff return Junk<N - 1>::foo(); } }; // compile error: template argument '(size * 5)' involves template parameter(s) template<int N> struct Ju...
How's this: ``` #include <iostream> using namespace std; template < typename T, T N, T D > struct fraction { typedef T value_type; static const value_type num = N; static const value_type denom = D; static const bool is_div = (num % denom == 0); }; template< typename T, T N, T D, bool P > struct do_i...
267,427
<p>I have a file with data listed as follows:</p> <pre><code>0, 2, 10 10, 8, 10 10, 10, 10 10, 16, 10 15, 10, 16 17, 10, 16 </code></pre> <p>I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting ea...
[ { "answer_id": 267449, "author": "Matthew Smith", "author_id": 20889, "author_profile": "https://Stackoverflow.com/users/20889", "pm_score": 2, "selected": false, "text": "<p>Something like:</p>\n\n<pre><code>vector&lt;int&gt; inint;\nvector&lt;int&gt; inbase;\nvector&lt;int&gt; outbase;...
2008/11/06
[ "https://Stackoverflow.com/questions/267427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338360/" ]
I have a file with data listed as follows: ``` 0, 2, 10 10, 8, 10 10, 10, 10 10, 16, 10 15, 10, 16 17, 10, 16 ``` I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting each element to integers. F...
There is really nothing wrong with fscanf, which is probably the fastest solution in this case. And it's as short and readable as the python code: ``` FILE *fp = fopen("file.dat", "r"); int x, y, z; std::vector<int> vx, vy, vz; while (fscanf(fp, "%d, %d, %d", &x, &y, &z) == 3) { vx.push_back(x); vy.push_back(y); ...
267,436
<p>For example, if I have a <em>unicode</em> string, I can encode it as an <em>ASCII</em> string like so:</p> <pre><code>&gt;&gt;&gt; u'\u003cfoo/\u003e'.encode('ascii') '&lt;foo/&gt;' </code></pre> <p>However, I have e.g. this <em>ASCII</em> string:</p> <pre><code>'\u003foo\u003e' </code></pre> <p>... that I want ...
[ { "answer_id": 267444, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 0, "selected": false, "text": "<p>It's a little dangerous depending on where the string is coming from, but how about:</p>\n\n<pre><code>&gt;&gt;&...
2008/11/06
[ "https://Stackoverflow.com/questions/267436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
For example, if I have a *unicode* string, I can encode it as an *ASCII* string like so: ``` >>> u'\u003cfoo/\u003e'.encode('ascii') '<foo/>' ``` However, I have e.g. this *ASCII* string: ``` '\u003foo\u003e' ``` ... that I want to turn into the same *ASCII* string as in my first example above: ``` '<foo/>' ```
It took me a while to figure this one out, but [this page](http://www.egenix.com/www2002/python/unicode-proposal.txt) had the best answer: ``` >>> s = '\u003cfoo/\u003e' >>> s.decode( 'unicode-escape' ) u'<foo/>' >>> s.decode( 'unicode-escape' ).encode( 'ascii' ) '<foo/>' ``` There's also a 'raw-unicode-escape' code...
267,439
<p>Much related to <a href="https://stackoverflow.com/questions/245687/managing-reference-paths-between-x86-and-x64-workstations-in-a-team">this question</a>, we have a scenario on my team where we need to copy the contents of a folder for a suite of libraries and configuration files for said libraries to our folder wh...
[ { "answer_id": 267444, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 0, "selected": false, "text": "<p>It's a little dangerous depending on where the string is coming from, but how about:</p>\n\n<pre><code>&gt;&gt;&...
2008/11/06
[ "https://Stackoverflow.com/questions/267439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14409/" ]
Much related to [this question](https://stackoverflow.com/questions/245687/managing-reference-paths-between-x86-and-x64-workstations-in-a-team), we have a scenario on my team where we need to copy the contents of a folder for a suite of libraries and configuration files for said libraries to our folder where our test c...
It took me a while to figure this one out, but [this page](http://www.egenix.com/www2002/python/unicode-proposal.txt) had the best answer: ``` >>> s = '\u003cfoo/\u003e' >>> s.decode( 'unicode-escape' ) u'<foo/>' >>> s.decode( 'unicode-escape' ).encode( 'ascii' ) '<foo/>' ``` There's also a 'raw-unicode-escape' code...
267,451
<p>I would like to read/write encrypted XML files using LINQ to XML. Does anyone know how to use encryption algorithms built into the .NET Framework to encrypt the Stream used by the XDocument object?</p> <p>I did try it, but you can't set the CryptoStream to Read/Write access. It only support Read or Write, which cau...
[ { "answer_id": 267713, "author": "Corbin March", "author_id": 7625, "author_profile": "https://Stackoverflow.com/users/7625", "pm_score": 4, "selected": true, "text": "<p>The easiest approach is probably an XDocument.Load(), Linq around, then XDocument.Save(). From a quick test app (go e...
2008/11/06
[ "https://Stackoverflow.com/questions/267451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7831/" ]
I would like to read/write encrypted XML files using LINQ to XML. Does anyone know how to use encryption algorithms built into the .NET Framework to encrypt the Stream used by the XDocument object? I did try it, but you can't set the CryptoStream to Read/Write access. It only support Read or Write, which causes LINQ t...
The easiest approach is probably an XDocument.Load(), Linq around, then XDocument.Save(). From a quick test app (go easy on non-disposed resources): ``` XDocument writeContacts = new XDocument( new XElement("contacts", new XElement("contact", new XElement("name", "Patrick Hines"), new XEleme...
267,473
<p>The exception mentions</p> <pre><code>FILE* __cdecl _getstream </code></pre> <p>I'm calling <code>fopen</code> and it keeps crashing. </p> <pre><code>AfxMessageBox("getting here 1"); FILE* filePtr = fopen(fileName, "rb"); AfxMessageBox("getting here 2"); </code></pre> <p>For some reason, I never get to the secon...
[ { "answer_id": 267739, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": -1, "selected": false, "text": "<p>I guess that something is wrong with fileName (does it have trailing zero ?)</p>\n\n<p>Try to comment <em>fope...
2008/11/06
[ "https://Stackoverflow.com/questions/267473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31325/" ]
The exception mentions ``` FILE* __cdecl _getstream ``` I'm calling `fopen` and it keeps crashing. ``` AfxMessageBox("getting here 1"); FILE* filePtr = fopen(fileName, "rb"); AfxMessageBox("getting here 2"); ``` For some reason, I never get to the second message box. Interestingly, when I'm in debug mode, the ap...
I think memory corruption. On Windows (which the \_\_cdecl makes me think you are using), there is the gflags utility which comes with the Windows Debugging Tools. With it, you can make each heap allocation have it's own page -- this will help catch memory overruns and double freeing immediately at the point of the pro...
267,477
<p>I know that you can use a dummy "int" parameter on <code>operator++</code> and <code>operator--</code> to override the postfix versions of those operators, but I vaguely recall something about a dummy parameter that you could declare on a destructor. Does anyone know anything about that, and if so, what that dummy p...
[ { "answer_id": 267482, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 3, "selected": false, "text": "<p>Either you are misremembering, or you should try to forget it. Destructors don't have parameters, return types and...
2008/11/06
[ "https://Stackoverflow.com/questions/267477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
I know that you can use a dummy "int" parameter on `operator++` and `operator--` to override the postfix versions of those operators, but I vaguely recall something about a dummy parameter that you could declare on a destructor. Does anyone know anything about that, and if so, what that dummy parameter did? This was i...
You're possibly thinking of the placement and nothrow forms of operator delete, which have the signatures: ``` void operator delete(void *, void *) throw(); void operator delete(void *, const std::nothrow_t&) throw(); void operator delete[](void *, void *) throw(); void operator delete[](void *, const std::nothrow_t&)...
267,487
<p>I want to do something like this:</p> <pre><code>SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]); </code></pre> <p>But Format doesn't like that last '%', of course. So how can I escape it? <code>\%</code>? <code>%%</code>? </p> <p>Or do I have to do this:</p> <pre><code>SQL.Text := ...
[ { "answer_id": 267499, "author": "moobaa", "author_id": 3569, "author_profile": "https://Stackoverflow.com/users/3569", "pm_score": 3, "selected": false, "text": "<p>%% , IIRC.</p>\n" }, { "answer_id": 267506, "author": "Robert Gamble", "author_id": 25222, "author_pro...
2008/11/06
[ "https://Stackoverflow.com/questions/267487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
I want to do something like this: ``` SQL.Text := Format('select foo from bar where baz like ''%s%''',[SearchTerm]); ``` But Format doesn't like that last '%', of course. So how can I escape it? `\%`? `%%`? Or do I have to do this: ``` SQL.Text := Format('select foo from bar where baz like ''%s''',[SearchTerm+'%'...
Use another % in the format string: ``` SQL.Text := Format('select foo from bar where baz like ''%s%%''',[SearchTerm]); ```
267,488
<p>I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax.</p> <p><strong>T-SQL</strong></p> <pre><code>SELECT o.OrderNumber, v.VendorName, s.StatusName FROM Orders o LEFT...
[ { "answer_id": 267542, "author": "Jon Norton", "author_id": 4797, "author_profile": "https://Stackoverflow.com/users/4797", "pm_score": 2, "selected": false, "text": "<p>I think you should be able to follow the method used in <a href=\"http://blogs.msdn.com/vbteam/archive/2008/01/31/conv...
2008/11/06
[ "https://Stackoverflow.com/questions/267488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/299/" ]
I'm having some trouble figuring out how to use more than one left outer join using LINQ to SQL. I understand how to use one left outer join. I'm using VB.NET. Below is my SQL syntax. **T-SQL** ``` SELECT o.OrderNumber, v.VendorName, s.StatusName FROM Orders o LEFT OUTER JOIN Vendors v ON v.Id = o...
This may be cleaner (**you dont need all the `into` statements**): ``` var query = from order in dc.Orders from vendor in dc.Vendors .Where(v => v.Id == order.VendorId) .DefaultIfEmpty() from status in dc.Status .Where(s => s.Id == order.StatusId) .DefaultIfEmpty(...
267,530
<p>I have two tables that I would like to join but I am getting an error from MySQL</p> <pre><code>Table: books bookTagNum ShelfTagNum book1 1 book2 2 book3 2 Table: shelf shelfNum shelfTagNum 1 shelf1 2 shelf2 </code></pre> <p>I want my results to be:</p> <pre><code>bookTagNum Sh...
[ { "answer_id": 267531, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 3, "selected": false, "text": "<p>I think you want</p>\n\n<pre><code>where `books`.`shelfTagNum`=`shelf`.`shelfNum`\n</code></pre>\n\n<p>In order to m...
2008/11/06
[ "https://Stackoverflow.com/questions/267530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
I have two tables that I would like to join but I am getting an error from MySQL ``` Table: books bookTagNum ShelfTagNum book1 1 book2 2 book3 2 Table: shelf shelfNum shelfTagNum 1 shelf1 2 shelf2 ``` I want my results to be: ``` bookTagNum ShelfTagNum shelfNum book1 shelf1 ...
I think you want ``` where `books`.`shelfTagNum`=`shelf`.`shelfNum` ``` In order to match rows from the `books` and `shelf` tables, you need to have terms from each in your `where` clause - otherwise, you're just performing a no-operation check on the rows of `books`, since every row's `shelfNum` will be equal to it...
267,534
<p>I asked this question before, <a href="https://stackoverflow.com/questions/264441/does-a-native-php-5-function-exist-that-does-the-following-in-1-line">Here</a> however I think I presented the problem poorly, and got quite a few replies that may have been useful to someone but did not address the actual question and...
[ { "answer_id": 267543, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": true, "text": "<p><strong>No, there is no way to do that natively.</strong></p>\n\n<p>You can, however:</p>\n\n<p>1.- Store the unav...
2008/11/06
[ "https://Stackoverflow.com/questions/267534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34561/" ]
I asked this question before, [Here](https://stackoverflow.com/questions/264441/does-a-native-php-5-function-exist-that-does-the-following-in-1-line) however I think I presented the problem poorly, and got quite a few replies that may have been useful to someone but did not address the actual question and so I pose the...
**No, there is no way to do that natively.** You can, however: 1.- Store the unavoidable array instead of the string. Given PHP's limitation this is what makes most sense in my opinion. Also, don't forget you can [unset()](http://php.net/unset) 2.- Use strpos() and friends to parse the string into what you need, as...
267,540
<p>I've met a really strange problem.</p> <p>The code is as follow:</p> <pre><code>::boost::shared_ptr&lt;CQImageFileInfo&gt; pInfo=CQUserViewDataManager::GetInstance()-&gt;GetImageFileInfo(nIndex); Image* pImage=pInfo-&gt;m_pThumbnail; if(pImage==NULL) pImage=m_pStretchedDefaultThumbImage; else { // int...
[ { "answer_id": 267559, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 0, "selected": false, "text": "<p>What happens if <code>pImage == NULL</code> on the third line you pasted? In that case, <code>rcShowImage</code> is no...
2008/11/06
[ "https://Stackoverflow.com/questions/267540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
I've met a really strange problem. The code is as follow: ``` ::boost::shared_ptr<CQImageFileInfo> pInfo=CQUserViewDataManager::GetInstance()->GetImageFileInfo(nIndex); Image* pImage=pInfo->m_pThumbnail; if(pImage==NULL) pImage=m_pStretchedDefaultThumbImage; else { // int sourceWidth = pInfo->GetWidth()...
`0xfeeefeee` is a fill pattern that the debug version of the Windows heap (not the C runtime heap) uses for uninitialized memory. `0xfeeefef2` is `0xfeeefeee+4`. It sounds like you're dereferencing an uninitialized pointer located in (or copied from) a block of memory allocated from the heap. The debug heap automatica...
267,553
<p>Just to make this clear - what is the difference between:</p> <pre><code>String(value) </code></pre> <p>and</p> <pre><code>value as String </code></pre> <p>What are the cases where you would use one over the other? They seem interchangeable...</p>
[ { "answer_id": 267568, "author": "Randy Stegbauer", "author_id": 34301, "author_profile": "https://Stackoverflow.com/users/34301", "pm_score": 4, "selected": true, "text": "<p>Casting with Type(variable) can cause a runtime exeception (RTE), while \"variable as type\" will return null in...
2008/11/06
[ "https://Stackoverflow.com/questions/267553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3435/" ]
Just to make this clear - what is the difference between: ``` String(value) ``` and ``` value as String ``` What are the cases where you would use one over the other? They seem interchangeable...
Casting with Type(variable) can cause a runtime exeception (RTE), while "variable as type" will return null instead of throwing an exception. See <http://raghuonflex.wordpress.com/2007/07/27/casting-vs-the-as-operator/> for more explanations.
267,613
<p>Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths.</p> <p>I have a circle at (x:250, y:250) with a radius of 50.</p> <p>My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse.</p> <p>W...
[ { "answer_id": 267622, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 3, "selected": true, "text": "<p><code>atan(height/length)</code> is not enough to get the angle. You need to compensate for each quadrant, as we...
2008/11/06
[ "https://Stackoverflow.com/questions/267613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26310/" ]
Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths. I have a circle at (x:250, y:250) with a radius of 50. My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse. Where Im getting confused...
`atan(height/length)` is not enough to get the angle. You need to compensate for each quadrant, as well as the possibility of "division-by-zero". Most programming language libraries supply a method called `atan2` which take two arguments; `y` and `x`. This method does this calculation for you. More information on [Wik...
267,615
<p>Using jquery how do I focus the first element (edit field, text area, dropdown field, etc) in the form when the page load?</p> <p>Something like:</p> <pre><code>document.forms[0].elements[0].focus(); </code></pre> <p>but using jquery.</p> <p>Another requirement, don't focus the first element when the form has cl...
[ { "answer_id": 267645, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": false, "text": "<pre><code>$('form:not(.filter) :input:visible:enabled:first').focus()\n</code></pre>\n\n<p>This will select the first visible...
2008/11/06
[ "https://Stackoverflow.com/questions/267615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3370/" ]
Using jquery how do I focus the first element (edit field, text area, dropdown field, etc) in the form when the page load? Something like: ``` document.forms[0].elements[0].focus(); ``` but using jquery. Another requirement, don't focus the first element when the form has class="filter".
For the background I used the script in *ruby on rails* app. After trying all your answer and found out they all **doesn't works**, With a search on google i found this snippet that **works**: ``` $(function() { $("form:not(.filter) :input:visible:enabled:first").focus(); }); ``` It turn out `$('form :input:first'...
267,618
<p>I've been trying to use Firebug's profiler to better understand the source of some JavaScript performance issues we are seeing, but I'm a little confused by the output.</p> <p>When I profile some code the profiler reports <strong>Profile (464.323 ms, 26,412 calls)</strong>. I suspect that the 464.323 ms is the sum ...
[ { "answer_id": 267865, "author": "Gene", "author_id": 22673, "author_profile": "https://Stackoverflow.com/users/22673", "pm_score": 3, "selected": false, "text": "<p>If I understand things correctly it goes something like this:</p>\n\n<p>On the first line you'll see that the Own time is ...
2008/11/06
[ "https://Stackoverflow.com/questions/267618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1654/" ]
I've been trying to use Firebug's profiler to better understand the source of some JavaScript performance issues we are seeing, but I'm a little confused by the output. When I profile some code the profiler reports **Profile (464.323 ms, 26,412 calls)**. I suspect that the 464.323 ms is the sum of the execution time f...
Each column has a description of what it means if you set your mouse to hover over it in Firebug. I'll assume you can read up on how each column works on your own then. However, you have definitely come across some odd behavior which needs to be explained. The *own time* is the amount of time the function spent execut...
267,658
<p>I have the following table schema;</p> <pre><code>CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `Message` VARCHAR(160) NOT NULL DEFAULT 'Unknown Message Error', `CurrentState` VARCHAR(10) NOT NULL DEFAULT 'None', `Phone` VARCHAR(14) DEFAULT NULL, `Created` TIMESTAMP NOT N...
[ { "answer_id": 267663, "author": "Stephen Walcher", "author_id": 25375, "author_profile": "https://Stackoverflow.com/users/25375", "pm_score": 5, "selected": false, "text": "<p>You can have them both, just take off the \"CURRENT_TIMESTAMP\" flag on the created field. Whenever you create ...
2008/11/06
[ "https://Stackoverflow.com/questions/267658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/264/" ]
I have the following table schema; ``` CREATE TABLE `db1`.`sms_queue` ( `Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `Message` VARCHAR(160) NOT NULL DEFAULT 'Unknown Message Error', `CurrentState` VARCHAR(10) NOT NULL DEFAULT 'None', `Phone` VARCHAR(14) DEFAULT NULL, `Created` TIMESTAMP NOT NULL DEFAULT CU...
[From the **MySQL 5.5** documentation](http://dev.mysql.com/doc/refman/5.5/en/timestamp-initialization.html): > > One TIMESTAMP column in a table can have the current timestamp as the default value for initializing the column, as the auto-update value, or both. **It is not possible to have the current timestamp be th...
267,672
<p>I am trying to use native windows API with Qt using mingw toolset. There are link problems with some functions. What happens? Is this a bug with mingw name mangling?</p> <pre><code>#ifdef Q_WS_WIN HWND hwnd = QWidget::winId(); HDC hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL ) ; Rectangle(hdcEMF,1...
[ { "answer_id": 267678, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 3, "selected": true, "text": "<p>The functions <code>CreateEnhMetaFileW()</code> and <code>CloseEnhMetaFile()</code> are defined in the static libr...
2008/11/06
[ "https://Stackoverflow.com/questions/267672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19884/" ]
I am trying to use native windows API with Qt using mingw toolset. There are link problems with some functions. What happens? Is this a bug with mingw name mangling? ``` #ifdef Q_WS_WIN HWND hwnd = QWidget::winId(); HDC hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL ) ; Rectangle(hdcEMF,100,100,200,200...
The functions `CreateEnhMetaFileW()` and `CloseEnhMetaFile()` are defined in the static library Gdi32.lib, so you have to make sure to link against that. Try adding `-lgdi32` to the end of your command line you're using to compile. If that doesn't work, you might have to specify the full path to Gdi32.lib by adding `-L...
267,674
<p>Is it possible to inspect the return value of a function in gdb assuming the return value is <strong>not</strong> assigned to a variable?</p>
[ { "answer_id": 267682, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 6, "selected": false, "text": "<p>Yes, just examine the <code>EAX</code> register by typing <code>print $eax</code>. For most functions, the retur...
2008/11/06
[ "https://Stackoverflow.com/questions/267674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11688/" ]
Is it possible to inspect the return value of a function in gdb assuming the return value is **not** assigned to a variable?
I imagine there are better ways to do it, but the [finish](http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html#SEC37) command executes until the current stack frame is popped off and prints the return value -- given the program ``` int fun() { return 42; } int main( int argc, char *v[] ) { fun(); ...
267,685
<p>This question is regarding the performance issue in Mac OS X</p> <p>Canvas3D object is embedded in a JPanel; then the panel is integrated with the rest of the Swing-built application. Within that Canvas I am rendering a simple cube by applying certain transformations. At the initial launch It works fine. But when ...
[ { "answer_id": 267682, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 6, "selected": false, "text": "<p>Yes, just examine the <code>EAX</code> register by typing <code>print $eax</code>. For most functions, the retur...
2008/11/06
[ "https://Stackoverflow.com/questions/267685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This question is regarding the performance issue in Mac OS X Canvas3D object is embedded in a JPanel; then the panel is integrated with the rest of the Swing-built application. Within that Canvas I am rendering a simple cube by applying certain transformations. At the initial launch It works fine. But when i try to r...
I imagine there are better ways to do it, but the [finish](http://www.chemie.fu-berlin.de/chemnet/use/info/gdb/gdb_6.html#SEC37) command executes until the current stack frame is popped off and prints the return value -- given the program ``` int fun() { return 42; } int main( int argc, char *v[] ) { fun(); ...
267,693
<p>I have a .NET assembly that (for reasons outside my control) <em>must</em> be in the GAC. However, the same assembly is used by another program, which has a its own copy of an older version of the same assembly. It must use its own copy and not whatever is in the GAC. Proper versioning is probably more hassle than i...
[ { "answer_id": 267710, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 2, "selected": false, "text": "<p>Have you tried Assembly.LoadFromFile()? This is a manual thing to do, but should load your assembly into memory b...
2008/11/06
[ "https://Stackoverflow.com/questions/267693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20336/" ]
I have a .NET assembly that (for reasons outside my control) *must* be in the GAC. However, the same assembly is used by another program, which has a its own copy of an older version of the same assembly. It must use its own copy and not whatever is in the GAC. Proper versioning is probably more hassle than it's worth ...
Make sure the GAC Assembly and local Assembly have different version numbers (not a bad idea to let your build number, at least, auto-increment by wild-carding your AssemblyVersion in AssemblyInfo: [assembly: AssemblyVersion("1.0.0.\*")] ). Then, redirect your assembly binding using your app's config: * <http://msdn....
267,704
<p>Is there an easy way to modify this code so that the target URL opens in the SAME window?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a href="javascript:q=(do...
[ { "answer_id": 267705, "author": "Stephen Walcher", "author_id": 25375, "author_profile": "https://Stackoverflow.com/users/25375", "pm_score": 3, "selected": false, "text": "<pre><code>&lt;a href=\"javascript:;\" onclick=\"window.location = 'http://example.com/submit.php?url=' + escape(d...
2008/11/06
[ "https://Stackoverflow.com/questions/267704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34964/" ]
Is there an easy way to modify this code so that the target URL opens in the SAME window? ```html <a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'','resizable,location,menubar,toolbar,scrollbars,status'));">click here</a>`` ```
The second parameter of *window.open()* is a string representing the name of the target window. Set it to: "\_self". ``` <a href="javascript:q=(document.location.href);void(open('http://example.com/submit.php?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status'));">click here</a> ``` **Si...
267,707
<p>I have a View that allows a user to enter/edit data for a new Widget. I'd like to form up that data into a json object and send it to my controller via AJAX so I can do the validation on the server without a postback.</p> <p>I've got it all working, except I can't figure out how to pass the data so my controller m...
[ { "answer_id": 267731, "author": "Sugendran", "author_id": 22466, "author_profile": "https://Stackoverflow.com/users/22466", "pm_score": 2, "selected": false, "text": "<p>What you want to do is structure your javascript form object in the same way your backend object is structured:</p>\n...
2008/11/06
[ "https://Stackoverflow.com/questions/267707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34720/" ]
I have a View that allows a user to enter/edit data for a new Widget. I'd like to form up that data into a json object and send it to my controller via AJAX so I can do the validation on the server without a postback. I've got it all working, except I can't figure out how to pass the data so my controller method can a...
Thanks Jeff, that got me on the right path. The DefaultModelBinder is smart enough to do all the magic for me...my problem was in my Widget type. In my haste, my type was defined as: ``` public class Widget { public int Id; public string Name; public decimal Price; } ``` Notice that the type has public fiel...
267,719
<p>I just recently installed the MVC beta. However, I assumed because the versioning numbers have changed and because it now uses the GAC instead of the bin folder that it wouldn't break existing applications.</p> <p>However, it has.</p> <p>What steps do I need to follow to ensure my existing preview 3 applications u...
[ { "answer_id": 267762, "author": "Raj", "author_id": 219862, "author_profile": "https://Stackoverflow.com/users/219862", "pm_score": 3, "selected": true, "text": "<p>ASP.NET MVC beta is also bin-deployable, Move the following DLL's from GAC to the bin folder of your app</p>\n\n<pre><code...
2008/11/06
[ "https://Stackoverflow.com/questions/267719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
I just recently installed the MVC beta. However, I assumed because the versioning numbers have changed and because it now uses the GAC instead of the bin folder that it wouldn't break existing applications. However, it has. What steps do I need to follow to ensure my existing preview 3 applications use a bin copy of ...
ASP.NET MVC beta is also bin-deployable, Move the following DLL's from GAC to the bin folder of your app ``` * System.Web.Mvc * System.Web.Routing * System.Web.Abstractions ``` [Check this article for more information](http://haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx)
267,721
<p>I need to do a date comparison in Mysql without taking into account the time component i.e. i need to convert '2008-11-05 14:30:00' to '2008-11-05'</p> <p>Currently i am doing this:</p> <pre><code>SELECT from_days(to_days(my_date)) </code></pre> <p>Is there a proper way of doing this?</p>
[ { "answer_id": 267732, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 9, "selected": true, "text": "<p>Yes, use the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date\" rel=\"n...
2008/11/06
[ "https://Stackoverflow.com/questions/267721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24390/" ]
I need to do a date comparison in Mysql without taking into account the time component i.e. i need to convert '2008-11-05 14:30:00' to '2008-11-05' Currently i am doing this: ``` SELECT from_days(to_days(my_date)) ``` Is there a proper way of doing this?
Yes, use the [date](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date) function: ``` SELECT date(my_date) ```
267,724
<p>I'm writing code to do Xml serialization. With below function.</p> <pre><code>public static string SerializeToXml(object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, obj); return writer...
[ { "answer_id": 267727, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 9, "selected": true, "text": "<p>During an object's de-serialization, the class responsible for de-serializing an object creates an instance of the seriali...
2008/11/06
[ "https://Stackoverflow.com/questions/267724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
I'm writing code to do Xml serialization. With below function. ``` public static string SerializeToXml(object obj) { XmlSerializer serializer = new XmlSerializer(obj.GetType()); using (StringWriter writer = new StringWriter()) { serializer.Serialize(writer, obj); return writer.ToString(); ...
During an object's de-serialization, the class responsible for de-serializing an object creates an instance of the serialized class and then proceeds to populate the serialized fields and properties only after acquiring an instance to populate. You can make your constructor `private` or `internal` if you want, just so...
267,750
<p>What is the difference in the accessibility of the following variables in Java?</p> <pre><code>public class Joe { public int a; protected int b; private int b; int c; } </code></pre> <p>I'm most interested in what the last one is doing.</p>
[ { "answer_id": 267756, "author": "Daniel Hiller", "author_id": 16193, "author_profile": "https://Stackoverflow.com/users/16193", "pm_score": 4, "selected": true, "text": "<ul>\n<li><code>public</code>: read/writable for anyone</li>\n<li><code>protected</code>: read/writable for\ninstance...
2008/11/06
[ "https://Stackoverflow.com/questions/267750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
What is the difference in the accessibility of the following variables in Java? ``` public class Joe { public int a; protected int b; private int b; int c; } ``` I'm most interested in what the last one is doing.
* `public`: read/writable for anyone * `protected`: read/writable for instances of subclasses **and from within the enclosing package** * `private`: read/writable for **any** instance of the class and inner or outer (enclosing) instance * `int c`: package-private, read/writable for all classes inside same package See ...
267,752
<p>So I've been trying to learn the boost::asio stuff to communicate to a serial device using RS232. The documementation is sparse and the examples are non-existent. Can't figure out exactly how to communicate with the device. The device can't send data so all I need to do is write, but other projects require actual...
[ { "answer_id": 269148, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 5, "selected": true, "text": "<p>In addition to the baud rate, you may also need to set other options like: character_size, flow_control, parity an...
2008/11/06
[ "https://Stackoverflow.com/questions/267752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3176/" ]
So I've been trying to learn the boost::asio stuff to communicate to a serial device using RS232. The documementation is sparse and the examples are non-existent. Can't figure out exactly how to communicate with the device. The device can't send data so all I need to do is write, but other projects require actual back ...
In addition to the baud rate, you may also need to set other options like: character\_size, flow\_control, parity and stop\_bits. To write your data to the serial port you can do the following: ``` boost::asio::write(port, boost::asio::buffer(commands, 4)); ``` The libraries acceptance of buffer types is very flexib...
267,754
<p>I'm impressed with the simplicity of Microsoft's Virtual Earth Street Address search service.</p> <p>My requirement is to type rough address info with no comma separators into a simple text box, press a find button, wait a few seconds and then observe a result picklist.</p> <p>I mocked up something <a href="http:/...
[ { "answer_id": 269148, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 5, "selected": true, "text": "<p>In addition to the baud rate, you may also need to set other options like: character_size, flow_control, parity an...
2008/11/06
[ "https://Stackoverflow.com/questions/267754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3048/" ]
I'm impressed with the simplicity of Microsoft's Virtual Earth Street Address search service. My requirement is to type rough address info with no comma separators into a simple text box, press a find button, wait a few seconds and then observe a result picklist. I mocked up something [here](http://www.garyrusso.org/...
In addition to the baud rate, you may also need to set other options like: character\_size, flow\_control, parity and stop\_bits. To write your data to the serial port you can do the following: ``` boost::asio::write(port, boost::asio::buffer(commands, 4)); ``` The libraries acceptance of buffer types is very flexib...
267,763
<p>Ever since I first wrote</p> <pre><code>if ($a = 5) { # do something with $a, e.g. print "$a"; } </code></pre> <p>and went through the normal puzzling session of </p> <ul> <li>why is the result always true</li> <li>why is $a always 5</li> </ul> <p>until I realized, I'd assigned 5 to $a, instead of perform...
[ { "answer_id": 267776, "author": "Torbjørn", "author_id": 22621, "author_profile": "https://Stackoverflow.com/users/22621", "pm_score": 4, "selected": false, "text": "<p>This is a simple and obvious one, but I NEVER EVER NEVER repeat the same string constant twice in my code, cause I KNO...
2008/11/06
[ "https://Stackoverflow.com/questions/267763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31472/" ]
Ever since I first wrote ``` if ($a = 5) { # do something with $a, e.g. print "$a"; } ``` and went through the normal puzzling session of * why is the result always true * why is $a always 5 until I realized, I'd assigned 5 to $a, instead of performing a comparison. So I decided to write that kind of cond...
This is a simple and obvious one, but I NEVER EVER NEVER repeat the same string constant twice in my code, cause I KNOW that if I do I will be spelling one of them wrong :) Use constants, people!
267,764
<p>I need to copy a set of rows from one tab to another tab of the same Excel document by just clicking a button. </p> <p>Also, can I also get information on how can I copy a set of rows that are hidden and paste it in the same tab without copying the "hidden" format?</p>
[ { "answer_id": 270326, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 1, "selected": false, "text": "<p>If 'Copystart' is your original rows, and 'Copyend' is where you want to paste them, then using named ranges:</p>...
2008/11/06
[ "https://Stackoverflow.com/questions/267764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to copy a set of rows from one tab to another tab of the same Excel document by just clicking a button. Also, can I also get information on how can I copy a set of rows that are hidden and paste it in the same tab without copying the "hidden" format?
If 'Copystart' is your original rows, and 'Copyend' is where you want to paste them, then using named ranges: ``` Sub Copybutton_Click() Range("Copyend").value = Range("Copystart").value Range("Copyend").visible = True End Sub ``` If you have multiple named ranges with the same name, then add [Sheetname]. in front...
267,781
<p>Slightly related to my <a href="https://stackoverflow.com/questions/267750/java-instance-variable-accessibility">other question</a>: What is the difference between the following:</p> <pre><code>private class Joe protected class Joe public class Joe class Joe </code></pre> <p>Once again, the difference between the ...
[ { "answer_id": 267793, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 5, "selected": true, "text": "<p>A public class is accessible to a class in any package.</p>\n\n<p>A class with default access (<code>class Joe</code>) is...
2008/11/06
[ "https://Stackoverflow.com/questions/267781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Slightly related to my [other question](https://stackoverflow.com/questions/267750/java-instance-variable-accessibility): What is the difference between the following: ``` private class Joe protected class Joe public class Joe class Joe ``` Once again, the difference between the last 2 is what I'm most interested in...
A public class is accessible to a class in any package. A class with default access (`class Joe`) is only visible to other classes in the same package. The private and protected modifiers can only be applied to inner classes. A private class is only visible to its enclosing class, and other inner classes in the sa...
267,804
<p>I'm trying to figure out the best way to insert a record into a single table but only if the item doesn't already exist. The KEY in this case is an NVARCHAR(400) field. For this example, lets pretend it's the name of a <em>word</em> in the Oxford English Dictionary / insert your fav dictionary here. Also, i'm guessi...
[ { "answer_id": 267859, "author": "Roger Lipscombe", "author_id": 8446, "author_profile": "https://Stackoverflow.com/users/8446", "pm_score": 6, "selected": true, "text": "<p>Your solution:</p>\n\n<pre><code>INSERT INTO Words (Word)\n SELECT @Word\nWHERE NOT EXISTS (SELECT WordID FROM ...
2008/11/06
[ "https://Stackoverflow.com/questions/267804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I'm trying to figure out the best way to insert a record into a single table but only if the item doesn't already exist. The KEY in this case is an NVARCHAR(400) field. For this example, lets pretend it's the name of a *word* in the Oxford English Dictionary / insert your fav dictionary here. Also, i'm guessing i will ...
Your solution: ``` INSERT INTO Words (Word) SELECT @Word WHERE NOT EXISTS (SELECT WordID FROM Words WHERE Word = @Word) ``` ...is about as good as it gets. You could simplify it to this: ``` INSERT INTO Words (Word) SELECT @Word WHERE NOT EXISTS (SELECT * FROM Words WHERE Word = @Word) ``` ...because EXIS...
267,808
<p>(Note: This is for MySQL's SQL, not SQL Server.)</p> <p>I have a database column with values like "abc def GHI JKL". I want to write a WHERE clause that includes a case-insensitive test for any word that begins with a specific letter. For example, that example would test true for the letters a,c,g,j because there's...
[ { "answer_id": 267814, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 0, "selected": false, "text": "<p>Check the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/pattern-matching.html\" rel=\"nofollow noreferrer...
2008/11/06
[ "https://Stackoverflow.com/questions/267808", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17307/" ]
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column with values like "abc def GHI JKL". I want to write a WHERE clause that includes a case-insensitive test for any word that begins with a specific letter. For example, that example would test true for the letters a,c,g,j because there's a 'word' ...
Using REGEXP opearator: ``` SELECT * FROM `articles` WHERE `body` REGEXP '[[:<:]][acgj]' ``` It returns records where column body contains words starting with a,c,g or i (case insensitive) Be aware though: this is not a very good idea if you expect any heavy load (not using index - it scans every row!)
267,832
<p>Hey, in the Programming Pearls book, there is a source code for setting, clearing and testing a bit of the given index in an array of ints that is actually a set representation.</p> <p>The code is the following:</p> <pre><code>#include&lt;stdio.h&gt; #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F #define...
[ { "answer_id": 267839, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "<p>From <a href=\"http://bytes.com/forum/thread847594.html\" rel=\"nofollow noreferrer\">Here</a> (General answer to get this t...
2008/11/06
[ "https://Stackoverflow.com/questions/267832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20915/" ]
Hey, in the Programming Pearls book, there is a source code for setting, clearing and testing a bit of the given index in an array of ints that is actually a set representation. The code is the following: ``` #include<stdio.h> #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F #define N 10000000 int a[1+ N/BIT...
VonC posted a good answer about bitmasks in general. Here's some information that's more specific to the code you posted. Given an integer representing a bit, we work out which member of the array holds that bit. That is: Bits 0 to 31 live in `a[0]`, bits 32 to 63 live in `a[1]`, etc. All that `i>>SHIFT` does is `i / ...
267,841
<p>I am writing a Rails app that processes data into a graph (using Scruffy). I am wondering how can I render the graph to a blog/string and then send the blog/string directly to the the browser to be displayed (without saving it to a file)? Or do I need to render it, save it to a file, then display the saved image f...
[ { "answer_id": 268036, "author": "Codebeef", "author_id": 12037, "author_profile": "https://Stackoverflow.com/users/12037", "pm_score": 3, "selected": false, "text": "<p>I think you will be able to use <a href=\"http://www.railsbrain.com/api/rails-2.1.0/doc/index.html?a=M000271&amp;name=...
2008/11/06
[ "https://Stackoverflow.com/questions/267841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
I am writing a Rails app that processes data into a graph (using Scruffy). I am wondering how can I render the graph to a blog/string and then send the blog/string directly to the the browser to be displayed (without saving it to a file)? Or do I need to render it, save it to a file, then display the saved image file i...
I think you will be able to use [send\_data](http://www.railsbrain.com/api/rails-2.1.0/doc/index.html?a=M000271&name=send_data) for this purpose: ``` send_data data_string, :filename => 'icon.jpg', :type => 'image/jpeg', :disposition => 'inline' ``` If you put this in a controller action - say show on a picture cont...
267,861
<p>I'm using SQLAlchemy 0.5rc, and I'd like to add an automatic filter to a relation, so that every time it tries to fetch records for that relation, it ignores the "remote" ones if they're flagged as "logically_deleted" (a boolean field of the child table)</p> <p>For example, if an object "parent" has a "children" re...
[ { "answer_id": 267975, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 0, "selected": false, "text": "<p>I'm only currently developing agains 0.4.something, but here's how I'd suggest it:</p>\n\n<pre><code>db.query(Obj...
2008/11/06
[ "https://Stackoverflow.com/questions/267861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3497/" ]
I'm using SQLAlchemy 0.5rc, and I'd like to add an automatic filter to a relation, so that every time it tries to fetch records for that relation, it ignores the "remote" ones if they're flagged as "logically\_deleted" (a boolean field of the child table) For example, if an object "parent" has a "children" relation th...
The and\_() function is the correct way to do logical conjunctions in SQLAlchemy, together with the & operator, but be careful with the latter as it has surprising precedence rules, i.e. higher precedence than comparison operators. You could also use a string as a primary join with the text() constructor, but that wi...
267,862
<p>Reading <a href="http://www.paulgraham.com/articles.html" rel="noreferrer">Paul Graham's essays</a> on programming languages one would think that <a href="http://wiki.c2.com/?LispMacro" rel="noreferrer">Lisp macros</a> are the only way to go. As a busy developer, working on other platforms, I have not had the privil...
[ { "answer_id": 267880, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 7, "selected": false, "text": "<p>You will find a comprehensive debate around <a href=\"http://lists.warhead.org.uk/pipermail/iwe/2005-July/000130.html\" rel=...
2008/11/06
[ "https://Stackoverflow.com/questions/267862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
Reading [Paul Graham's essays](http://www.paulgraham.com/articles.html) on programming languages one would think that [Lisp macros](http://wiki.c2.com/?LispMacro) are the only way to go. As a busy developer, working on other platforms, I have not had the privilege of using Lisp macros. As someone who wants to understan...
To give the short answer, macros are used for defining language syntax extensions to Common Lisp or Domain Specific Languages (DSLs). These languages are embedded right into the existing Lisp code. Now, the DSLs can have syntax similar to Lisp (like Peter Norvig's [Prolog Interpreter](http://norvig.com/paip/prolog.lisp...
267,869
<p>What is the best way to configure Tomcat 5.5 or later to authenticate users from Windows Active Directory?</p>
[ { "answer_id": 267906, "author": "Blauohr", "author_id": 22176, "author_profile": "https://Stackoverflow.com/users/22176", "pm_score": 5, "selected": false, "text": "<p><strong>From <a href=\"http://www.jspwiki.org\" rel=\"nofollow noreferrer\">www.jspwiki.org</a></strong></p>\n<p>See : ...
2008/11/06
[ "https://Stackoverflow.com/questions/267869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34986/" ]
What is the best way to configure Tomcat 5.5 or later to authenticate users from Windows Active Directory?
**From [www.jspwiki.org](http://www.jspwiki.org)** See : [ActiveDirectoryIntegration](https://web.archive.org/web/20130526124801/http://www.jspwiki.org/wiki/ActiveDirectoryIntegration) Try this in the server.xml with your ldap-settings : ``` <Realm className="org.apache.catalina.realm.JNDIRealm" debug="99" conne...
267,892
<p>How are paged results commonly implemented in PHP?</p> <p>I'd like to have a results page with 10 results. Paging forward in the navigation would give me the next and previous sets.</p> <p>Is there a way this is commonly done? Does anyone have simple advice on getting started?</p>
[ { "answer_id": 267900, "author": "Factor Mystic", "author_id": 1569, "author_profile": "https://Stackoverflow.com/users/1569", "pm_score": 0, "selected": false, "text": "<p>The term you are referring to is \"pagination\". Unfortunately you'll have to give some more information to get a m...
2008/11/06
[ "https://Stackoverflow.com/questions/267892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How are paged results commonly implemented in PHP? I'd like to have a results page with 10 results. Paging forward in the navigation would give me the next and previous sets. Is there a way this is commonly done? Does anyone have simple advice on getting started?
You'll need a beginner's understanding of PHP, and probably some understanding of relational databases. Pagination is often implemented with some simple query parameters. ``` stackoverflow.com/myResults.php?page=1 ``` The page increments the query parameter: ``` stackoverflow.com/myResults.php?page=2 ``` On the ...
267,893
<p>Is there a way to customize Firebug's keyboard shortcuts? I love being able to step through JavaScript code using Firebug's <em>Script</em> panel, but it looks like I'm limited to either using the default keyboard shortcuts for stepping over/into/out of code or using the mouse to click the appropriate button. </p>...
[ { "answer_id": 267905, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "<p>As stated in their <a href=\"https://groups.google.com/forum/#!topic/firebug/tgDCmsg89yE\" rel=\"nofollow noreferrer\">discu...
2008/11/06
[ "https://Stackoverflow.com/questions/267893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19020/" ]
Is there a way to customize Firebug's keyboard shortcuts? I love being able to step through JavaScript code using Firebug's *Script* panel, but it looks like I'm limited to either using the default keyboard shortcuts for stepping over/into/out of code or using the mouse to click the appropriate button. Am I missing s...
You can change them manually. Go to this directory: In recent versions the extension comes in a single file with the extension XPI. Just rename it to ZIP, create a directory and extract its contents into it. Linux: ``` .mozilla/firefox/*****.default/extensions/firebug@software.joehewitt.com/ ``` Windows: ``` %AP...
267,908
<p>I think most C++ programmers here would agree that polluting the global namespace is a bad idea, but are there times when this rule can be ignored?</p> <p>For example, I have a type that I need to use all over a particular application - should I define it thus:</p> <pre><code>mytypes.h typedef int MY_TYPE; foo.c...
[ { "answer_id": 267914, "author": "Anthony Williams", "author_id": 5597, "author_profile": "https://Stackoverflow.com/users/5597", "pm_score": 4, "selected": true, "text": "<p>I use namespaces for partitioning library code from application-specific code, and in a big project to partition ...
2008/11/06
[ "https://Stackoverflow.com/questions/267908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
I think most C++ programmers here would agree that polluting the global namespace is a bad idea, but are there times when this rule can be ignored? For example, I have a type that I need to use all over a particular application - should I define it thus: ``` mytypes.h typedef int MY_TYPE; foo.cpp MY_TYPE myType; ...
I use namespaces for partitioning library code from application-specific code, and in a big project to partition the various modules that make up the project. The global namespace is thus useful for application-specific types and functions that are used across multiple modules in the application. So, if your `MY_TYPE...
267,944
<p>Some background info;</p> <ul> <li>LanguageResource is the base class</li> <li>LanguageTranslatorResource and LanguageEditorResource inherit from LanguageResource</li> <li>LanguageEditorResource defines an IsDirty property</li> <li>LanguageResourceCollection is a collection of LanguageResource</li> <li>LanguageReso...
[ { "answer_id": 267964, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>It sounds like your collection implements <code>IEnumerable</code>, not <code>IEnumerable&lt;T&gt;</code>, hence yo...
2008/11/06
[ "https://Stackoverflow.com/questions/267944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1535/" ]
Some background info; * LanguageResource is the base class * LanguageTranslatorResource and LanguageEditorResource inherit from LanguageResource * LanguageEditorResource defines an IsDirty property * LanguageResourceCollection is a collection of LanguageResource * LanguageResourceCollection internally holds LanguageRe...
It sounds like your collection implements `IEnumerable`, not `IEnumerable<T>`, hence you need: ``` _resources.Cast<LanguageEditorResource>().Where(r => r.IsDirty) ``` Note that `Enumerable.Where` is defined on `IEnumerable<T>`, not `IEnumerable` - if you have the non-generic type, you need to use `Cast<T>` (or `OfTy...
267,949
<p>I'm working on a code base in which we have several configurable types. One of those types is 64 bit integer. When we compile for platforms that have no native 64 bit integer type, we simple represent 64 bit integers using a struct similar to</p> <pre><code>typedef struct { unsigned int hi, lo; } int64; </code>...
[ { "answer_id": 267965, "author": "Dan Fego", "author_id": 34426, "author_profile": "https://Stackoverflow.com/users/34426", "pm_score": 1, "selected": false, "text": "<p>You could try:</p>\n\n<pre><code>#define mytime int64\n</code></pre>\n\n<p>Instead of the typedef.</p>\n\n<p>That look...
2008/11/06
[ "https://Stackoverflow.com/questions/267949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20398/" ]
I'm working on a code base in which we have several configurable types. One of those types is 64 bit integer. When we compile for platforms that have no native 64 bit integer type, we simple represent 64 bit integers using a struct similar to ``` typedef struct { unsigned int hi, lo; } int64; ``` In order to mak...
Do you really need the cast? gcc is compiling the following example without any complains: ``` typedef struct int64 int64; struct int64 { unsigned int hi, lo; }; typedef int64 mytime; int64 add_int64(int64 a, int64 b) { int64 c; /* I know that is wrong */ c.hi = a.hi + b.hi; c.lo = a.lo + b.lo;...
267,953
<p>I have two applications under <code>tomcat/webapps</code> folder. </p> <pre><code>tomcat/webapps/App1 tomcat/webapps/App2 </code></pre> <p>Both applications share the same libraries. Which are stored for example in <code>tomcat/webapps/App1/WEB-INF/lib</code>.</p> <p>Are both libraries loaded twice in memory?</...
[ { "answer_id": 267959, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 6, "selected": true, "text": "<p>As you can see <a href=\"http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html\" rel=\"noreferrer\">he...
2008/11/06
[ "https://Stackoverflow.com/questions/267953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I have two applications under `tomcat/webapps` folder. ``` tomcat/webapps/App1 tomcat/webapps/App2 ``` Both applications share the same libraries. Which are stored for example in `tomcat/webapps/App1/WEB-INF/lib`. Are both libraries loaded twice in memory? Should I put these shared libraries in `tomcat/server/lib...
As you can see [here](http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html), Tomcat creates one class-loader per webapp on your server. Thus, if you have webapp1 and webapp2 that share the same library, then this library will be indeed loaded twice. You can eventually place this library in the common direct...
267,998
<p>I have a QGraphicsScene that I want to copy and append to the start of a list. What is the best method of doing this?</p> <pre><code>QGraphicsScene* m_scene = new QGraphicsScene(); QGraphicsScene* m_DuplicateScene; QList&lt;QGraphicsScene *&gt;m_list; </code></pre>
[ { "answer_id": 312047, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 4, "selected": true, "text": "<p>Doing this would be very complicated because you don't know anything about the children of <code>m_scene</code>. Even i...
2008/11/06
[ "https://Stackoverflow.com/questions/267998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24459/" ]
I have a QGraphicsScene that I want to copy and append to the start of a list. What is the best method of doing this? ``` QGraphicsScene* m_scene = new QGraphicsScene(); QGraphicsScene* m_DuplicateScene; QList<QGraphicsScene *>m_list; ```
Doing this would be very complicated because you don't know anything about the children of `m_scene`. Even if you `dynamic_cast` and create a `clone()` function for each type of `QGraphicsItem`, you still need to remember that other people can subclass `QGraphicsItem` and create their own type of graphics item, making ...
268,013
<p>Basically I am inserting an image using the listviews inserting event, trying to resize an image from the fileupload control, and then save it in a SQL database using LINQ.</p> <p>I found some code to create a new bitmap of the content in the fileupload control, but this was to store it in a file on the server, fro...
[ { "answer_id": 268026, "author": "Tamir", "author_id": 30879, "author_profile": "https://Stackoverflow.com/users/30879", "pm_score": 3, "selected": false, "text": "<p>Assuming, that your bitmap is bmp</p>\n\n<pre><code>byte[] data;\nusing(System.IO.MemoryStream stream = new System.IO.Mem...
2008/11/06
[ "https://Stackoverflow.com/questions/268013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32792/" ]
Basically I am inserting an image using the listviews inserting event, trying to resize an image from the fileupload control, and then save it in a SQL database using LINQ. I found some code to create a new bitmap of the content in the fileupload control, but this was to store it in a file on the server, from [this so...
You should be able to change this block to ``` System.IO.MemoryStream stream = new System.IO.MemoryStream(); newBMP.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); PHJProjectPhoto myPhoto = new PHJProjectPhoto { ProjectPhoto = stream.ToArray(), // ...
268,023
<p>I have read the answers for <a href="https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c-cross-platform">What's the best way to check if a file exists in C? (cross platform)</a>, but I'm wondering if there is a better way to do this using standard c++ libs? Preferably without...
[ { "answer_id": 268031, "author": "activout.se", "author_id": 20444, "author_profile": "https://Stackoverflow.com/users/20444", "pm_score": 4, "selected": false, "text": "<p>Use stat(), if it is cross-platform enough for your needs. It is not C++ standard though, but POSIX.</p>\n\n<p>On M...
2008/11/06
[ "https://Stackoverflow.com/questions/268023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2079/" ]
I have read the answers for [What's the best way to check if a file exists in C? (cross platform)](https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c-cross-platform), but I'm wondering if there is a better way to do this using standard c++ libs? Preferably without trying to ope...
Use [boost::filesystem](http://www.boost.org/doc/libs/1_37_0/libs/filesystem/doc/index.htm): ``` #include <boost/filesystem.hpp> if ( !boost::filesystem::exists( "myfile.txt" ) ) { std::cout << "Can't find my file!" << std::endl; } ```
268,025
<p>The install instructions are:</p> <pre><code>$ python setup.py build $ sudo python setup.py install # or su first </code></pre> <p>This gives me an .egg file. How do I tell the install to dump the files as a normal, uncompressed library?</p> <p>Thanks!</p>
[ { "answer_id": 268054, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 2, "selected": false, "text": "<p>From the <a href=\"http://peak.telecommunity.com/DevCenter/EasyInstall#command-line-options\" rel=\"nofollow noreferrer\">...
2008/11/06
[ "https://Stackoverflow.com/questions/268025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/563932/" ]
The install instructions are: ``` $ python setup.py build $ sudo python setup.py install # or su first ``` This gives me an .egg file. How do I tell the install to dump the files as a normal, uncompressed library? Thanks!
OK, I hate to answer my own question, but: find your python site-packages (mine is /usr/local/lib/python2.5/site-packages ) then: ``` $ unzip MySQL_python-1.2.2-py2.5-linux-i686.egg ``` This worked fine for me
268,037
<p>I am working on creating a custom project template with Visual Studio 2008 Team System edition. I have also created a custom wizard for the custom template.</p> <p>So I have to update the vstemplate file to tell the template to use my custom wizard. But the archive is corrupted!</p> <p>7zip thinks folders within...
[ { "answer_id": 603214, "author": "penyaskito", "author_id": 3008, "author_profile": "https://Stackoverflow.com/users/3008", "pm_score": 0, "selected": false, "text": "<p>Same problem here. I solved it by using <code>&lt;ProjectItem&gt;MyFolder\\MyFile.cs&lt;/ProjectItem&gt;</code> instea...
2008/11/06
[ "https://Stackoverflow.com/questions/268037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19377/" ]
I am working on creating a custom project template with Visual Studio 2008 Team System edition. I have also created a custom wizard for the custom template. So I have to update the vstemplate file to tell the template to use my custom wizard. But the archive is corrupted! 7zip thinks folders within the archive are us...
You don't need to modify the contents of the archive to be flat. The trick is after editing the unzipped contents of the archive, instead of selecting the folder and zipping that, open the folder and select all the files (and folders if present), and zip those instead. This is what is preventing Visual Studio from re...
268,045
<p>I am looking for a tool to replace multiple lines through out a project. For example:</p> <pre><code>#include "../DiscreteIO/Discrete.h" #include "../PCI/pci.h" #include "../Arinc429/ARINC429.h" </code></pre> <p>with</p> <pre><code>#include "../PCI/pci.h" #include "../DiscreteIO/DiscreteHW.h" #include "../Discret...
[ { "answer_id": 268071, "author": "Stephen Denne", "author_id": 11721, "author_profile": "https://Stackoverflow.com/users/11721", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.ultraedit.com/\" rel=\"nofollow noreferrer\">Ultraedit</a> can do that. I parted with money ...
2008/11/06
[ "https://Stackoverflow.com/questions/268045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34989/" ]
I am looking for a tool to replace multiple lines through out a project. For example: ``` #include "../DiscreteIO/Discrete.h" #include "../PCI/pci.h" #include "../Arinc429/ARINC429.h" ``` with ``` #include "../PCI/pci.h" #include "../DiscreteIO/DiscreteHW.h" #include "../DiscreteIO/Discrete.h" ``` I have tried tw...
sed will do what you want. See the FAQ entry about exactly this here <http://sed.sourceforge.net/sedfaq4.html#s4.23.3> > > If you need to match a static block of > text (which may occur any number of > times throughout a file), where the > contents of the block are known in > advance, then this script is easy to...
268,048
<p>Take the following function:</p> <pre><code>DataTable go() { return someTableAdapter.getSomeData(); } </code></pre> <p>When I set a breakpoint in this function, is there a possibility to inspect the returned value? <code>go()</code> is directly coupled to a datagrid in an <code>.aspx</code> page.</p> <p>The o...
[ { "answer_id": 268052, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 9, "selected": true, "text": "<p>Not that I know of. Note that if you <em>do</em> add a variable, it will get removed by the compiler in release bui...
2008/11/06
[ "https://Stackoverflow.com/questions/268048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56/" ]
Take the following function: ``` DataTable go() { return someTableAdapter.getSomeData(); } ``` When I set a breakpoint in this function, is there a possibility to inspect the returned value? `go()` is directly coupled to a datagrid in an `.aspx` page. The only way to inspect the returned datatable is to use a t...
Not that I know of. Note that if you *do* add a variable, it will get removed by the compiler in release builds anyway... **Update:** [This functionality has been added to VS2013](https://devblogs.microsoft.com/devops/seeing-function-return-values-in-the-visual-studio-2013-debugger/). You can see the return values in ...
268,064
<p>Looking at <code>System.Collections.Generic.Dictionary&lt;TKey, TValue&gt;</code>, it clearly implements <code>ICollection&lt;KeyValuePair&lt;TKey, TValue&gt;&gt;</code>, but doesn't have the required "<code>void Add(KeyValuePair&lt;TKey, TValue&gt; item)</code>" function.</p> <p>This can also be seen when trying t...
[ { "answer_id": 268083, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>The expected API is to add via the two argument <code>Add(key,value)</code> method (or the <code>this[key]</code> i...
2008/11/06
[ "https://Stackoverflow.com/questions/268064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918/" ]
Looking at `System.Collections.Generic.Dictionary<TKey, TValue>`, it clearly implements `ICollection<KeyValuePair<TKey, TValue>>`, but doesn't have the required "`void Add(KeyValuePair<TKey, TValue> item)`" function. This can also be seen when trying to initialize a `Dictionary` like this: ``` private const Dictionar...
The expected API is to add via the two argument `Add(key,value)` method (or the `this[key]` indexer); as such, it uses explicit interface implementation to provide the `Add(KeyValuePair<,>)` method. If you use the `IDictionary<string, int>` interface instead, you will have access to the missing method (since you can't...
268,069
<p>I have been trying to include a file in a included file e.g</p> <p><strong>main.cpp file</strong></p> <pre><code>#include &lt;includedfile.cpp&gt; int main(){ cout&lt;&lt;name&lt;&lt;endl; } </code></pre> <p><strong>includedfile.cpp</strong></p> <pre><code>#include &lt;iostream&gt; using namespace std; stri...
[ { "answer_id": 268085, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 3, "selected": false, "text": "<p>You cannot have statements exist outside of a method!</p>\n\n<pre><code>name = \"jim\"; // This is outside of any method, ...
2008/11/06
[ "https://Stackoverflow.com/questions/268069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have been trying to include a file in a included file e.g **main.cpp file** ``` #include <includedfile.cpp> int main(){ cout<<name<<endl; } ``` **includedfile.cpp** ``` #include <iostream> using namespace std; string name; name = "jim"; ``` this code does not work, the debuger says that name is not define...
You cannot have statements exist outside of a method! ``` name = "jim"; // This is outside of any method, so it is an error. ``` You could refactor your code so the variable declaration is also an initial assignment, which should be valid (my C++ is a bit rusty, so I might be wrong on this point). ``` string name =...
268,079
<p>I have 3 lists, I will make them simple here. </p> <p>list of letters<br> A<br> B<br> C </p> <p>list of numbers<br> 1<br> 2<br> 3 </p> <p>Mixed<br> A,1<br> A,2<br> B,2<br> B,3<br> C,1<br> C,3</p> <p>I need to know what is missing:<br> A,3<br> B,1<br> C,2</p> <p>The...
[ { "answer_id": 268099, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<p>A cross join would produce every combination there is, given that you have both of your lists in SQL tables:</p>\n\n<pr...
2008/11/06
[ "https://Stackoverflow.com/questions/268079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35003/" ]
I have 3 lists, I will make them simple here. list of letters A B C list of numbers 1 2 3 Mixed A,1 A,2 B,2 B,3 C,1 C,3 I need to know what is missing: A,3 B,1 C,2 The list of letters has about 85 entries and the list of numbers has about 500 entries. The mixed l...
There's no need to create extra tables. The following query would work just as well: ``` SELECT c.chr, n.num FROM chars c, nums n WHERE NOT EXISTS (SELECT 1 FROM mix m WHERE m.chr = c.chr AND m.num = n.num) ```
268,084
<p>What is the most efficient way to create a <strong>constant</strong> (never changes at runtime) mapping of <code>string</code>s to <code>int</code>s? </p> <p>I've tried using a <a href="https://stackoverflow.com/questions/268064/c-how-can-dictionarykv-implement-icollectionkeyvaluepairkv-without-having-addke">const ...
[ { "answer_id": 268097, "author": "Sander", "author_id": 2928, "author_profile": "https://Stackoverflow.com/users/2928", "pm_score": 1, "selected": false, "text": "<p>There does not seem to be any standard immutable interface for dictionaries, so creating a wrapper seems like the only rea...
2008/11/06
[ "https://Stackoverflow.com/questions/268084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4918/" ]
What is the most efficient way to create a **constant** (never changes at runtime) mapping of `string`s to `int`s? I've tried using a [const Dictionary](https://stackoverflow.com/questions/268064/c-how-can-dictionarykv-implement-icollectionkeyvaluepairkv-without-having-addke), but that didn't work out. I could impl...
Creating a truly compile-time generated constant dictionary in C# is not really a straightforward task. Actually, none of the answers here really achieve that. There is one solution though which meets your requirements, although not necessarily a nice one; remember that according to the C# specification, switch-case t...
268,088
<p>After I open something with emacsclient, when I kill that buffer (C-x k) I get a confirmation dialog:</p> <pre><code>Buffer `blah' still has clients; kill it? (yes or no) </code></pre> <p>But when I kill buffers opened directly from Emacs I don't. Is there a way not to get them when emacsclient opened them?</p>
[ { "answer_id": 268205, "author": "Touko", "author_id": 28482, "author_profile": "https://Stackoverflow.com/users/28482", "pm_score": 5, "selected": true, "text": "<p>This worked for me:</p>\n\n<pre><code>(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)\n</cod...
2008/11/06
[ "https://Stackoverflow.com/questions/268088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
After I open something with emacsclient, when I kill that buffer (C-x k) I get a confirmation dialog: ``` Buffer `blah' still has clients; kill it? (yes or no) ``` But when I kill buffers opened directly from Emacs I don't. Is there a way not to get them when emacsclient opened them?
This worked for me: ``` (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function) ``` There's more information on [Using Emacsclient blog entry](http://shreevatsa.wordpress.com/2007/01/06/using-emacsclient).
268,089
<p>From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet.</p> <p>Can anyone please tell me how one can achieve multiple database connections in Django.</p> <p>Does anyone have any idea by when Django will fully/officially support M...
[ { "answer_id": 268369, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 2, "selected": false, "text": "<p>The most recent discussion I've seen on it was in the <a href=\"http://groups.google.com/group/django-developers/b...
2008/11/06
[ "https://Stackoverflow.com/questions/268089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35009/" ]
From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet. Can anyone please tell me how one can achieve multiple database connections in Django. Does anyone have any idea by when Django will fully/officially support Multiple database ...
If you simply need multiple connections, you can do something like this: ``` from django.db import load_backend myBackend = load_backend('postgresql_psycopg2') # or 'mysql', 'sqlite3', 'oracle' myConnection = myBackend.DatabaseWrapper({ 'DATABASE_HOST': '192.168.1.1', 'DATABASE_NAME': 'my_database', 'DATAB...
268,093
<p>I'd like to create a webpage layout with the sidebar to the right and the main content flowing around the sidebar.</p> <p>Requirements:</p> <ol> <li>Content below the sidebar should occupy all of the available width</li> <li>Content below the sidebar should not wrap when it hits the left of the sidebar</li> <li>Ma...
[ { "answer_id": 268135, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 2, "selected": false, "text": "<p>I believe you're gonna have to change the order for this, putting the sidebar first. Then, use CSS's <code>fl...
2008/11/06
[ "https://Stackoverflow.com/questions/268093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5343/" ]
I'd like to create a webpage layout with the sidebar to the right and the main content flowing around the sidebar. Requirements: 1. Content below the sidebar should occupy all of the available width 2. Content below the sidebar should not wrap when it hits the left of the sidebar 3. Main content should *precede* the ...
Simple floating w/ opposite source order just can't be done (w/o CSS3 draft specs). The pragmatic approach is to first build a nice layout that supports your desired source order. HTML: ``` <div id="content" class="noJs"> <div id="floatSpace"></div> <p>Lorem ipsum ....</p> <p>Pellentesque ....</p> <div id="sid...
268,105
<p>In a table I have the following schema</p> <pre><code>table1: playerID int primary key, nationalities nvarchar table2: playerID int, pubVisited nvarchar </code></pre> <p>Now, I want to set all the players' playedVisited to null, for player whose nationality is "England", any idea on how to do this? </p>
[ { "answer_id": 268127, "author": "pilsetnieks", "author_id": 6615, "author_profile": "https://Stackoverflow.com/users/6615", "pm_score": 2, "selected": false, "text": "<p>Judging by the <em>nvarchar</em> type, you're using MSSQL. Now, in MySQL you could use a subselect in the update .. w...
2008/11/06
[ "https://Stackoverflow.com/questions/268105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
In a table I have the following schema ``` table1: playerID int primary key, nationalities nvarchar table2: playerID int, pubVisited nvarchar ``` Now, I want to set all the players' playedVisited to null, for player whose nationality is "England", any idea on how to do this?
Tested on SQL Server 2005 ``` update table2 set pubVisited = NULL from table1 t1 inner join table2 t2 on (t1.playerID = t2.playerID and t1.nationalities = 'England') ```
268,107
<pre> SELECT `name` , COUNT(*) AS `count` FROM `t1`, `t2` WHERE `t2`.`id` = `t1`.`id` GROUP BY `t2`.`id` </pre> <p>I want to obtain the name from t1 and the number of rows in t2 where the id is the same as on t1.</p> <p>I've got the above so far, however it won't return any data if there are no rows in t2 that match....
[ { "answer_id": 268118, "author": "Dheer", "author_id": 17266, "author_profile": "https://Stackoverflow.com/users/17266", "pm_score": 0, "selected": false, "text": "<p>Do a union to get the other set</p>\n\n<pre><code>SELECT `name` , COUNT(*) AS `count`\nFROM `t1`, `t2`\nWHERE `t2`.`id` =...
2008/11/06
[ "https://Stackoverflow.com/questions/268107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21559/" ]
``` SELECT `name` , COUNT(*) AS `count` FROM `t1`, `t2` WHERE `t2`.`id` = `t1`.`id` GROUP BY `t2`.`id` ``` I want to obtain the name from t1 and the number of rows in t2 where the id is the same as on t1. I've got the above so far, however it won't return any data if there are no rows in t2 that match. I'd prefer `...
This should work for you: ``` SELECT `t1`.`id` , COUNT(`t2`.`id`) AS `count` FROM `t1` LEFT JOIN `t2` ON `t1`.`id` = `t2`.`id` GROUP BY `t1`.`id` ``` Left join ensures you have all rows from t1, and COUNT(`t2`.`id`) makes it count only records where t2.id is not null (that is - those that really exist in t2)
268,109
<p>I have a VB.NET application which needs to generate reports (invoices) which contains optional images. The images are going to be loaded into 1 of 6 places on the report, but will reside on the client PC (deployed with the application). I've been trying to access the ICROleObject object, which is what's placed ont...
[ { "answer_id": 268481, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 2, "selected": false, "text": "<p>There is no reliable way to do this using the current iPhone SDK. You should file a <a href=\"http://bugreporter....
2008/11/06
[ "https://Stackoverflow.com/questions/268109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6850/" ]
I have a VB.NET application which needs to generate reports (invoices) which contains optional images. The images are going to be loaded into 1 of 6 places on the report, but will reside on the client PC (deployed with the application). I've been trying to access the ICROleObject object, which is what's placed onto the...
There is no reliable way to do this using the current iPhone SDK. You should file a [bug](http://bugreporter.apple.com) with Apple to try to get them to add more control over the camera.
268,116
<p>I have the following code block in my xslt;</p> <pre><code> &lt;xsl:when test="StatusData/Status/Temperature &gt; 27"&gt; &lt;td bgcolor="#ffaaaa"&gt; &lt;xsl:value-of select="StatusData/Status/Temperature" /&gt; &lt;/td&gt; &lt;/xsl:when&gt; </code><...
[ { "answer_id": 268140, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "<p>There is a <code>translate()</code> function in XPath:</p>\n\n<pre><code>test=\"translate(StatusData/Status/Temperature,...
2008/11/06
[ "https://Stackoverflow.com/questions/268116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35012/" ]
I have the following code block in my xslt; ``` <xsl:when test="StatusData/Status/Temperature > 27"> <td bgcolor="#ffaaaa"> <xsl:value-of select="StatusData/Status/Temperature" /> </td> </xsl:when> ``` But as you might guess when the value is 34,5 ins...
There is a `translate()` function in XPath: ``` test="translate(StatusData/Status/Temperature, ",", ".") > 27" ``` Additionally you should make use of the number function, which converts it's argument to a number (or NaN, if that fails): ``` test="number(translate(StatusData/Status/Temperature, ",", ".")) > 27.0" ...
268,120
<p>I am having an string like this</p> <p>string str = "dfdsfdsf8fdfdfd9dfdfd4"</p> <p>I need to check whether the string contains number by looping through the array.</p>
[ { "answer_id": 268148, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 6, "selected": true, "text": "<p>What about a regular expression:</p>\n\n<pre><code>bool val = System.Text.RegularExpressions.Regex.IsMatch(str, @\"...
2008/11/06
[ "https://Stackoverflow.com/questions/268120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having an string like this string str = "dfdsfdsf8fdfdfd9dfdfd4" I need to check whether the string contains number by looping through the array.
What about a regular expression: ``` bool val = System.Text.RegularExpressions.Regex.IsMatch(str, @"\d"); ```
268,123
<p>Is there a single shortcut to start inserting in the new line at end of the file?</p> <p>I'm aware of <kbd>G</kbd> + <kbd>o</kbd> combo.</p>
[ { "answer_id": 268134, "author": "LeopardSkinPillBoxHat", "author_id": 22489, "author_profile": "https://Stackoverflow.com/users/22489", "pm_score": 4, "selected": false, "text": "<p>Not that I know of - <kbd>G</kbd>+<kbd>o</kbd> is what I would have suggested too, but that is 2 steps :)...
2008/11/06
[ "https://Stackoverflow.com/questions/268123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11439/" ]
Is there a single shortcut to start inserting in the new line at end of the file? I'm aware of `G` + `o` combo.
There's also the command line option "+": ``` vim + myfile.txt ``` Will open myfile.txt and do an automatic G for you.
268,132
<p>When I ran <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> on my code, for example:</p> <pre><code> if (some condition) { Some code... } </code></pre> <p>ReSharper gave me the above warning (Invert "if" statement to reduce nesting), and suggested the f...
[ { "answer_id": 268145, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 2, "selected": false, "text": "<p>That is simply controversial. There is no \"agreement among programmers\" on the question of early return. It's always s...
2008/11/06
[ "https://Stackoverflow.com/questions/268132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/278/" ]
When I ran [ReSharper](http://en.wikipedia.org/wiki/ReSharper) on my code, for example: ``` if (some condition) { Some code... } ``` ReSharper gave me the above warning (Invert "if" statement to reduce nesting), and suggested the following correction: ``` if (!some condition) retu...
A return in the middle of the method is not necessarily bad. It might be better to return immediately if it makes the intent of the code clearer. For example: ``` double getPayAmount() { double result; if (_isDead) result = deadAmount(); else { if (_isSeparated) result = separatedAmount(); ...