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
385,129
<p>In Visual Studio 2008 I can add a project reference and set Copy Local property to true. As result the referenced assembly will be copied to the same folder the main assembly is build to.</p> <p>But what if I want to have all referenced assemblies in a subfolder near the main assembly?</p> <p>Something like this:<...
[ { "answer_id": 385135, "author": "Kevin Tighe", "author_id": 39461, "author_profile": "https://Stackoverflow.com/users/39461", "pm_score": 0, "selected": false, "text": "<p>You could turn off the \"Copy Local\" setting, then setup a build action on the referenced projects to copy the dll...
2008/12/21
[ "https://Stackoverflow.com/questions/385129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48195/" ]
In Visual Studio 2008 I can add a project reference and set Copy Local property to true. As result the referenced assembly will be copied to the same folder the main assembly is build to. But what if I want to have all referenced assemblies in a subfolder near the main assembly? Something like this: ``` .. myApp.exe...
For other versions of the framework, this is what you would do: <http://msdn.microsoft.com/en-us/library/twy1dw1e.aspx> For compact, I suggest reading this: <http://blogs.msdn.com/stevenpr/archive/2005/01/05/347353.aspx> HTH Colby Africa
385,141
<p>I have a WPF application that is using a custom style. In it I have a set of buttons that each have a custom background image. For each button, I'm supplying a normal and a mouse down image. Is there a simple way to do this with a single style (and customize each button on a case by case basis)? </p> <p>Current...
[ { "answer_id": 385671, "author": "justin.m.chase", "author_id": 12958, "author_profile": "https://Stackoverflow.com/users/12958", "pm_score": 0, "selected": false, "text": "<p>You can create the style in a ResourceDictionary then merge that dictionary into your controls resources. If you...
2008/12/21
[ "https://Stackoverflow.com/questions/385141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10086/" ]
I have a WPF application that is using a custom style. In it I have a set of buttons that each have a custom background image. For each button, I'm supplying a normal and a mouse down image. Is there a simple way to do this with a single style (and customize each button on a case by case basis)? Currently I'm creatin...
For a XAML only solution you could consider this:- I'm assuming you are using a control template as part of your style something like the following:- ``` <Style x:Key="MyButtonStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> ...
385,150
<p>I have here a piece of PHP code that deletes a directory and all files in it if present. However, I'm not too sure about it, it looks to me like it'll delete all sub-maps too and then files in those and so on...</p> <p>I basically want to give and optional true/false parameter to select wheter or not to delete sub ...
[ { "answer_id": 385169, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>And what I'm basically wondering is: what can go wrong here? Is there a situation where this piece of c...
2008/12/21
[ "https://Stackoverflow.com/questions/385150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795/" ]
I have here a piece of PHP code that deletes a directory and all files in it if present. However, I'm not too sure about it, it looks to me like it'll delete all sub-maps too and then files in those and so on... I basically want to give and optional true/false parameter to select wheter or not to delete sub directorie...
> > And what I'm basically wondering is: what can go wrong here? Is there a situation where this piece of code can seriously screw up? > > > If the dir contains a symlink to somewhere else, it would be followed (unless I'm mistaken - You should check this). That could lead to a wildfire, where you basically wipe o...
385,178
<p>What is the best way to code the following generic data access functions (ADO.NET, C# or VB, SQLServer or OLEDB)</p> <ol> <li>Execute SQL on a connection</li> <li>Open a DataReader</li> <li>Open a DataSet (any ideas on this one?)</li> </ol> <p>Such that I can call these functions from anywhere in my program. I'm ...
[ { "answer_id": 385162, "author": "Mark A. Nicolosi", "author_id": 1103052, "author_profile": "https://Stackoverflow.com/users/1103052", "pm_score": 1, "selected": false, "text": "<p>Since you are already familiar with PyGTK, why not use <a href=\"http://www.gtk.org/\" rel=\"nofollow nore...
2008/12/21
[ "https://Stackoverflow.com/questions/385178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21826/" ]
What is the best way to code the following generic data access functions (ADO.NET, C# or VB, SQLServer or OLEDB) 1. Execute SQL on a connection 2. Open a DataReader 3. Open a DataSet (any ideas on this one?) Such that I can call these functions from anywhere in my program. I'm not interested in Data Access patterns o...
This sounds like exactly the job [Tcl/Tk](http://www.tcl.tk/) was designed for. It has a very simple C API that allows you to register commands with a callback. If you use the command in a Tcl program, it will invoke the callback and provide a mechanism to convert the arguments between a Tcl list (native data structure...
385,193
<p>I previously <a href="https://stackoverflow.com/questions/322659/sendmail-and-mx-records-when-mail-server-is-not-on-web-host">asked a question regarding MX records</a> (and appreciate the thoughtful answers I received from SO'ers). Now that that problem is resolved, I want to step back and ask why there are MX reco...
[ { "answer_id": 385199, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>It seems like every other Internet protocol gets along just fine with DNS' A record.</p>\n</blockqu...
2008/12/21
[ "https://Stackoverflow.com/questions/385193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32168/" ]
I previously [asked a question regarding MX records](https://stackoverflow.com/questions/322659/sendmail-and-mx-records-when-mail-server-is-not-on-web-host) (and appreciate the thoughtful answers I received from SO'ers). Now that that problem is resolved, I want to step back and ask why there are MX records in the firs...
`MX` records were used because there was a need for SMTP traffic to `user@domain` to be routed differently to other traffic for that domain, and `SRV` records hadn't been invented yet. The modern convention that you can type `http://example.com/` in your browser without a `www` prefix and still get to the required web...
385,195
<p>We've licensed a commercial product (product not important in this context), which is limited by the number of concurrent users. Users access this product by going through a Spring Controller.</p> <p>We have N licenses for this product, and if N+1 users access it, they get a nasty error message about needing to bu...
[ { "answer_id": 385689, "author": "TRF", "author_id": 48230, "author_profile": "https://Stackoverflow.com/users/48230", "pm_score": 4, "selected": true, "text": "<p>What you need is a ObjectPool. Check out Apache Commons Pool <a href=\"http://commons.apache.org/pool\" rel=\"nofollow noref...
2008/12/21
[ "https://Stackoverflow.com/questions/385195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48208/" ]
We've licensed a commercial product (product not important in this context), which is limited by the number of concurrent users. Users access this product by going through a Spring Controller. We have N licenses for this product, and if N+1 users access it, they get a nasty error message about needing to buy more lice...
What you need is a ObjectPool. Check out Apache Commons Pool <http://commons.apache.org/pool> At the application startup you should create a Object Pool with licences or objects of commercial library (Not sure what kind of public interface they have). ``` public class CommercialObjectFactory extends BasePoolableObjec...
385,219
<p>I have this code..</p> <pre><code> Models.Person p = new testmvc.Models.Person { Firstname = "yongeks", Lastname = "ucab" }; Models.Person p2 = new testmvc.Models.Person { Firstname = "lyn", Lastname = "torreon" }; string q = JavaScriptConvert.SerializeObject(new String[] { JavaScriptConver...
[ { "answer_id": 385232, "author": "Mike Scott", "author_id": 43649, "author_profile": "https://Stackoverflow.com/users/43649", "pm_score": 3, "selected": false, "text": "<p>Just use the controller's Json method to serialize the type and return a JsonResult:</p>\n\n<pre><code>Models.Person...
2008/12/21
[ "https://Stackoverflow.com/questions/385219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31445/" ]
I have this code.. ``` Models.Person p = new testmvc.Models.Person { Firstname = "yongeks", Lastname = "ucab" }; Models.Person p2 = new testmvc.Models.Person { Firstname = "lyn", Lastname = "torreon" }; string q = JavaScriptConvert.SerializeObject(new String[] { JavaScriptConvert.SerializeObj...
Just use the controller's Json method to serialize the type and return a JsonResult: ``` Models.Person p2 = new testmvc.Models.Person { Firstname = "lyn", Lastname = "torreon" }; return Json( p2 ); ```
385,237
<p>I know this is a simple question, I'm just curious.</p>
[ { "answer_id": 385232, "author": "Mike Scott", "author_id": 43649, "author_profile": "https://Stackoverflow.com/users/43649", "pm_score": 3, "selected": false, "text": "<p>Just use the controller's Json method to serialize the type and return a JsonResult:</p>\n\n<pre><code>Models.Person...
2008/12/22
[ "https://Stackoverflow.com/questions/385237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2484/" ]
I know this is a simple question, I'm just curious.
Just use the controller's Json method to serialize the type and return a JsonResult: ``` Models.Person p2 = new testmvc.Models.Person { Firstname = "lyn", Lastname = "torreon" }; return Json( p2 ); ```
385,238
<blockquote> <p>Edit again: I think I get it now. All I need to do then is use the current class colon the class I want to be able to access? Person : Student, or person : teacher Is that correct?</p> </blockquote> <p>I'm currently trying to learn the ins and outs of object oriented programming. Currently I hav...
[ { "answer_id": 385247, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>Well, at least three ways.</p>\n\n<ol>\n<li>Make grades and teacher methods of the Student class: </li>\n</ol>\n\...
2008/12/22
[ "https://Stackoverflow.com/questions/385238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48214/" ]
> > Edit again: > I think I get it now. All I need to do then is use the current class colon the class I want to be able to access? Person : Student, or person : teacher > Is that correct? > > > I'm currently trying to learn the ins and outs of object oriented programming. Currently I have a new object that's s...
You're still missing the essential point: a *class* associates the data *with its methods.* So the method that sets Jim's teacher is part of the Student class, as is the method that sets Jim's grade. Think of it in natural language first. "Jim is a student; students have names, stident ID numbers, and classes. Classes...
385,262
<p>I want to send a custom "Accept" header in my request when using urllib2.urlopen(..). How do I do that?</p>
[ { "answer_id": 385411, "author": "pantsgolem", "author_id": 9261, "author_profile": "https://Stackoverflow.com/users/9261", "pm_score": 8, "selected": true, "text": "<p>Not quite. Creating a <code>Request</code> object does not actually send the request, and Request objects have no <cod...
2008/12/22
[ "https://Stackoverflow.com/questions/385262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16432/" ]
I want to send a custom "Accept" header in my request when using urllib2.urlopen(..). How do I do that?
Not quite. Creating a `Request` object does not actually send the request, and Request objects have no `Read()` method. (Also: `read()` is lowercase.) All you need to do is pass the `Request` as the first argument to `urlopen()` and that will give you your response. ``` import urllib2 request = urllib2.Request("http:/...
385,269
<p>I have tried to use some of the widgets in <code>JQuery UI</code> on an <code>Asp.Net MVC</code> site without luck.</p> <p>For example the basic datepicker from <a href="http://ui.jquery.com/repository/tags/latest/demos/functional/#ui.datepicker" rel="nofollow noreferrer">jQuery UI - functional demos</a>.</p> <p>I...
[ { "answer_id": 385283, "author": "Andy Hume", "author_id": 46460, "author_profile": "https://Stackoverflow.com/users/46460", "pm_score": 2, "selected": false, "text": "<p>It looks like you are executing the JavaScript inline as the page loads. In which case the <code>#basics</code> selec...
2008/12/22
[ "https://Stackoverflow.com/questions/385269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459417/" ]
I have tried to use some of the widgets in `JQuery UI` on an `Asp.Net MVC` site without luck. For example the basic datepicker from [jQuery UI - functional demos](http://ui.jquery.com/repository/tags/latest/demos/functional/#ui.datepicker). I have created a simple MVC project and added the script references in `Site....
Make sure your initializer is called after the DOM is loaded: ``` $(document).ready(function() { $("#basics").datepicker(); }); ``` [jQuery ready event](http://docs.jquery.com/Events/ready#fn): > > By using this method, your bound > function will be called the instant > the DOM is ready to be read and > man...
385,272
<p>I have a simple structured XML file like this:</p> <pre><code>&lt;ttest ID="ttest00001", NickName="map00001"/&gt; &lt;ttest ID="ttest00002", NickName="map00002"/&gt; &lt;ttest ID="ttest00003", NickName="map00003"/&gt; &lt;ttest ID="ttest00004", NickName="map00004"/&gt; </code></pre> <p>..... This xml file can be a...
[ { "answer_id": 385289, "author": "Eric Rosenberger", "author_id": 41624, "author_profile": "https://Stackoverflow.com/users/41624", "pm_score": 0, "selected": false, "text": "<p>In this case you might want to consider reading the nicknames in the XML file into an array (if your test IDs ...
2008/12/22
[ "https://Stackoverflow.com/questions/385272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a simple structured XML file like this: ``` <ttest ID="ttest00001", NickName="map00001"/> <ttest ID="ttest00002", NickName="map00002"/> <ttest ID="ttest00003", NickName="map00003"/> <ttest ID="ttest00004", NickName="map00004"/> ``` ..... This xml file can be around 2.5MB. In my source code I will have a loop...
You're using XPath already ("//ttest..."), and it's the slowest way to access the doc nodes as the "//" syntax looks across the entire doc. try something like... ``` foreach (XMLNode node in MyXmlDoc.ChildNodes) { ... } ``` instead, no xpath required and it should be quicker. (implicit assumption that it's a 'f...
385,298
<p>I want to overload operators &lt; and > to allow the searching of an int value inside a BST (which ain't designed to store ints but rather words).</p> <p>For those who are wondering why is this overload being done on the first place please check <a href="https://stackoverflow.com/questions/384587/c-im-stuck-filling...
[ { "answer_id": 385318, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 0, "selected": false, "text": "<p>I think you need to read this: <a href=\"http://www.devarticles.com/c/a/Cplusplus/Operator-Overloading-in-C-plus/\...
2008/12/22
[ "https://Stackoverflow.com/questions/385298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45963/" ]
I want to overload operators < and > to allow the searching of an int value inside a BST (which ain't designed to store ints but rather words). For those who are wondering why is this overload being done on the first place please check [C++ I'm stuck filling this BST with its proper values](https://stackoverflow.com/q...
I'm not quite sure why you want to overload > and < in this case, but perhaps I don't quite understand the question. It looks like you intend to have several different kinds of tree nodes, all of which inherit from `DataType`. If that is the case, simply add a const member function to the `DataType` base class: ``` cl...
385,300
<p>I'm trying to create a route for the following urls: www.mysite.com/user/username www.mysite.com/user/username/pictures</p> <p>I tried doing that with the following code:</p> <pre><code>routes.MapRoute( "UserProfile", "user/{sn}/{action}", new { controller = "User", action = "In...
[ { "answer_id": 385318, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 0, "selected": false, "text": "<p>I think you need to read this: <a href=\"http://www.devarticles.com/c/a/Cplusplus/Operator-Overloading-in-C-plus/\...
2008/12/22
[ "https://Stackoverflow.com/questions/385300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23695/" ]
I'm trying to create a route for the following urls: www.mysite.com/user/username www.mysite.com/user/username/pictures I tried doing that with the following code: ``` routes.MapRoute( "UserProfile", "user/{sn}/{action}", new { controller = "User", action = "Index", sn = "" } ...
I'm not quite sure why you want to overload > and < in this case, but perhaps I don't quite understand the question. It looks like you intend to have several different kinds of tree nodes, all of which inherit from `DataType`. If that is the case, simply add a const member function to the `DataType` base class: ``` cl...
385,306
<p>I've got a very strange bug cropping up in some PHP code I've got. The page is managing student enrolments in courses. On the page is a table of the student's courses, and each row has a number of dates: when they enrolled, when they completed, when they passed the assessment and when they picked up their certificat...
[ { "answer_id": 385326, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "<p>Ok, I just figured out why it's mucking up one date but not the other. Daylight savings wasn't in effect in August. <em>fac...
2008/12/22
[ "https://Stackoverflow.com/questions/385306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I've got a very strange bug cropping up in some PHP code I've got. The page is managing student enrolments in courses. On the page is a table of the student's courses, and each row has a number of dates: when they enrolled, when they completed, when they passed the assessment and when they picked up their certificate. ...
Thats because you use mktime which is locale specific. That is it will convert it to the number of seconds from 00:00:00 1970-1-1 GMT, and that is offset by 1 hour with one timezone. You should also remember that the javascript does use the same timezone as the browser, not the web page. ``` e.resultDate = new Date(...
385,325
<p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p> <p>The input data is a mix of floats and strings. Desired output:</p> <p>0 --> '0'</p> <p>0.0 --> '0'</p> <p>0.1 --> '0.1'</p> <p>1.0 --> '1'</p> <p>I've come up with the following generator expression, but I wonder ...
[ { "answer_id": 385360, "author": "Daniel Naab", "author_id": 32638, "author_profile": "https://Stackoverflow.com/users/32638", "pm_score": 2, "selected": false, "text": "<p>Using Python's <a href=\"http://docs.python.org/library/stdtypes.html#string-formatting\" rel=\"nofollow noreferrer...
2008/12/22
[ "https://Stackoverflow.com/questions/385325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22893/" ]
I'm looking for a way to convert numbers to string format, dropping any redundant '.0' The input data is a mix of floats and strings. Desired output: 0 --> '0' 0.0 --> '0' 0.1 --> '0.1' 1.0 --> '1' I've come up with the following generator expression, but I wonder if there's a faster way: ``` (str(i).rstrip('.0...
``` (str(i)[-2:] == '.0' and str(i)[:-2] or str(i) for i in ...) ```
385,327
<p>I recently started using vim 7 (previously vim 6) and the <code>smartindent</code> setting. For the most part, it works well, though I'm so used to typing a tab after an open brace that it is almost counter-productive.</p> <p>However, there is one piece of maniacal behaviour. When editing a shell script, I try to...
[ { "answer_id": 385343, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>Find the indent file, (e.g. /usr/share/vim/vim71/indent/sh.vim on my system)</p>\n\n<p>This line looks like the problem:</p>...
2008/12/22
[ "https://Stackoverflow.com/questions/385327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15168/" ]
I recently started using vim 7 (previously vim 6) and the `smartindent` setting. For the most part, it works well, though I'm so used to typing a tab after an open brace that it is almost counter-productive. However, there is one piece of maniacal behaviour. When editing a shell script, I try to create a comment at th...
Find the indent file, (e.g. /usr/share/vim/vim71/indent/sh.vim on my system) This line looks like the problem: ``` setlocal indentkeys-=:,0# ``` Perhaps you can fix this in your .vimrc or load a custom indent file manually. edit: It looks more complicated than I thought, but maybe there is something specifically ...
385,370
<p>I have some code in MS VC++ 6.0 that I am debugging. For some reason, at this certain point where I am trying to delete some dynamically allocated memory, it breaks and I get a pop up message box saying "User Breakpoint called from code at blah blah".. then the Disassembly window pops up and I see</p> <pre><code>*...
[ { "answer_id": 385373, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 4, "selected": true, "text": "<p>You're probably hitting code in the debug heap routines that have found heap corruption.</p>\n\n<p>What does the ca...
2008/12/22
[ "https://Stackoverflow.com/questions/385370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29482/" ]
I have some code in MS VC++ 6.0 that I am debugging. For some reason, at this certain point where I am trying to delete some dynamically allocated memory, it breaks and I get a pop up message box saying "User Breakpoint called from code at blah blah".. then the Disassembly window pops up and I see ``` *memory address*...
You're probably hitting code in the debug heap routines that have found heap corruption. What does the call stack look like when you've hit the Int 3? Edit: Based on the stack trace in your comments, the routine `_CrtIsValidHeapPointer()` is saying that the pointer being freed is bad. Here's the snippet of code from ...
385,381
<p>If you have a pending operation, eg </p> <pre><code>stream.BeginRead(_buffer, 0, _buffer.Length, _asyncCallbackRead, this); </code></pre> <p>and you close the stream provider, eg</p> <pre><code>serialPort.Close(); </code></pre> <p>you unsurprisingly cause an exception.</p> <p>Is there an preferred method by whi...
[ { "answer_id": 385443, "author": "Colby Africa", "author_id": 47164, "author_profile": "https://Stackoverflow.com/users/47164", "pm_score": 1, "selected": true, "text": "<p>This is not directly supported in the framework. Your best bet is to write a wrapper that spawns a thread and use s...
2008/12/22
[ "https://Stackoverflow.com/questions/385381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1715673/" ]
If you have a pending operation, eg ``` stream.BeginRead(_buffer, 0, _buffer.Length, _asyncCallbackRead, this); ``` and you close the stream provider, eg ``` serialPort.Close(); ``` you unsurprisingly cause an exception. Is there an preferred method by which one might cancel a pending APM operation, prior to cl...
This is not directly supported in the framework. Your best bet is to write a wrapper that spawns a thread and use synchronization primitives like events to signal a cancel request. HTH Colby Africa
385,394
<p>I have a small project I want to try porting to Python 3 - how do I go about this?</p> <p>I have made made the code run without warnings using <code>python2.6 -3</code> (mostly removing <code>.has_key()</code> calls), but I am not sure of the best way to use the 2to3 tool.</p> <blockquote> <p>Use the 2to3 tool t...
[ { "answer_id": 385397, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 4, "selected": true, "text": "<p>Aha, you can pipe the 2to3 output to the <code>patch</code> command, which can write the modified file to a new file:</p>\n\n<pr...
2008/12/22
[ "https://Stackoverflow.com/questions/385394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have a small project I want to try porting to Python 3 - how do I go about this? I have made made the code run without warnings using `python2.6 -3` (mostly removing `.has_key()` calls), but I am not sure of the best way to use the 2to3 tool. > > Use the 2to3 tool to convert this source code to 3.0 syntax. Do not ...
Aha, you can pipe the 2to3 output to the `patch` command, which can write the modified file to a new file: ``` mv something.py py2.6_something.py 2to3 py2.6_something.py | patch -o something.py ```
385,408
<p>I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution.</p> <p>I know I could write a perl or python script that would do this, but is there a way I can do it in the shell? (which happens to be bash)</p>
[ { "answer_id": 385418, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 10, "selected": true, "text": "<p>Use the built-in <code>time</code> keyword:</p>\n\n<pre>\n$ help time\n\ntime: time [-p] PIPELINE\n Execute PI...
2008/12/22
[ "https://Stackoverflow.com/questions/385408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41613/" ]
I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution. I know I could write a perl or python script that would do this, but is there a way I can do it in the shell? (which happens to be bash)
Use the built-in `time` keyword: ``` $ help time time: time [-p] PIPELINE Execute PIPELINE and print a summary of the real time, user CPU time, and system CPU time spent executing PIPELINE when it terminates. The return status is the return status of PIPELINE. The `-p' option prints the timing summa...
385,420
<p>Does PHP have the ability to watch a variable (or object property) and run a function when its value changes, similar to <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Object/Watch" rel="nofollow noreferrer">Gecko's Javascript <code>watch</code> function</a>?</p>
[ { "answer_id": 385450, "author": "ieure", "author_id": 45224, "author_profile": "https://Stackoverflow.com/users/45224", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.xdebug.org/\" rel=\"nofollow noreferrer\">XDebug</a> <em>might</em> have this, but I don't know for ...
2008/12/22
[ "https://Stackoverflow.com/questions/385420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Does PHP have the ability to watch a variable (or object property) and run a function when its value changes, similar to [Gecko's Javascript `watch` function](https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Object/Watch)?
[XDebug](http://www.xdebug.org/) *might* have this, but I don't know for sure. If you're trying to debug a member variable on an object, you can use overloading: ``` public function __set($var, $val) { if ($var == 'interesting') { echo "$var set to: "; var_dump($val); } $this->$var = $val;...
385,441
<p>This is a sql newbie question.</p> <p>Basically, I want an extra column to return with my select statement to number the rows. I'm using mysql.</p> <p>Eg: </p> <pre><code>select * from friends David Steve Joe </code></pre> <p>What is the syntax to get:</p> <pre><code>1 David 2 Steve 3 Joe </code></pre>
[ { "answer_id": 385447, "author": "YonahW", "author_id": 3821, "author_profile": "https://Stackoverflow.com/users/3821", "pm_score": 1, "selected": false, "text": "<p>In SQL Server 2005 and higher you can use the <a href=\"http://msdn.microsoft.com/en-us/library/ms186734.aspx\" rel=\"nofo...
2008/12/22
[ "https://Stackoverflow.com/questions/385441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45066/" ]
This is a sql newbie question. Basically, I want an extra column to return with my select statement to number the rows. I'm using mysql. Eg: ``` select * from friends David Steve Joe ``` What is the syntax to get: ``` 1 David 2 Steve 3 Joe ```
From: <http://markmal.blogspot.com/2006/04/oracle-like-rownum-in-mysql.html> ``` SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT @rownum:=0) r, mytable t; ```
385,451
<p>I have a WCF RESTFul service declared thus:</p> <pre><code>[ServiceContract] public interface IGasPriceService { [OperationContract] [WebGet (ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/GetGasPrice/For/ZipCode/{zipCode}" )] ...
[ { "answer_id": 385458, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>Your url needs to be:</p>\n\n<pre><code> http://localhost:7002/SetGasPrice/For/ZipCode/45678/Price/7.80\n</code></pr...
2008/12/22
[ "https://Stackoverflow.com/questions/385451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a WCF RESTFul service declared thus: ``` [ServiceContract] public interface IGasPriceService { [OperationContract] [WebGet (ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/GetGasPrice/For/ZipCode/{zipCode}" )] GasPriceData ...
Your url needs to be: ``` http://localhost:7002/SetGasPrice/For/ZipCode/45678/Price/7.80 ``` Or you need to change your template to: ``` "/SetGasPrice/For/ZipCode/{zipCode}/{price}" ```
385,506
<p>As Knuth said,</p> <blockquote> <p>We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.</p> </blockquote> <p>This is something which often comes up in Stack Overflow answers to questions like "which is the most efficient loop mechanism", "SQL optim...
[ { "answer_id": 385518, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 5, "selected": false, "text": "<blockquote>\n <p>My question is, if a particular\n technique is different but not\n particularly obscure or obfuscated,\n c...
2008/12/22
[ "https://Stackoverflow.com/questions/385506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
As Knuth said, > > We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. > > > This is something which often comes up in Stack Overflow answers to questions like "which is the most efficient loop mechanism", "SQL optimisation techniques?" ([and so on...
Don Knuth started the *[literate programming](http://www.literateprogramming.com/)* movement because he believed that **the most important function of computer code is to communicate the programmer's intent to a human reader**. Any coding practice that makes your code harder to understand in the name of performance is ...
385,512
<p>I have got a field with data type <code>int?</code> price and allow null, when I set</p> <pre><code>book.price = null; </code></pre> <p>and update, it is not saved and does not throw any exceptions, when I change value # null, it is ok. I want set it null.</p>
[ { "answer_id": 385591, "author": "fasih.rana", "author_id": 46024, "author_profile": "https://Stackoverflow.com/users/46024", "pm_score": 2, "selected": true, "text": "<p>They are both iterative models which seem similar, but both of them are vastly different. RUP is a framework for orga...
2008/12/22
[ "https://Stackoverflow.com/questions/385512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44533/" ]
I have got a field with data type `int?` price and allow null, when I set ``` book.price = null; ``` and update, it is not saved and does not throw any exceptions, when I change value # null, it is ok. I want set it null.
They are both iterative models which seem similar, but both of them are vastly different. RUP is a framework for organizations and teams while Scrum is intended for a product team with stringent guidelines. I'd suggest you read these: [SCRUM](http://en.wikipedia.org/wiki/Scrum_%28development%29) [RUP](http://en.wikipe...
385,530
<p><code>AVFoundation.framework</code> is not where the documentation says it should be. I have iPhone SDK 2.2 installed (never had previous sdk versions installed) and I can't find that folder under <code>/System/Library/Frameworks</code></p> <p>I did find it under</p> <pre><code> /Developer/Platforms/iPhoneOS.platf...
[ { "answer_id": 385820, "author": "rustyshelf", "author_id": 6044, "author_profile": "https://Stackoverflow.com/users/6044", "pm_score": 5, "selected": true, "text": "<p>I've used the AVFoundation classes in my code, and added it the same way you did. You cannot browse the headers for som...
2008/12/22
[ "https://Stackoverflow.com/questions/385530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44091/" ]
`AVFoundation.framework` is not where the documentation says it should be. I have iPhone SDK 2.2 installed (never had previous sdk versions installed) and I can't find that folder under `/System/Library/Frameworks` I did find it under ``` /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/L...
I've used the AVFoundation classes in my code, and added it the same way you did. You cannot browse the headers for some unknown reason, but putting this in your classes header file compiles just fine: ``` #import <AVFoundation/AVAudioPlayer.h> ``` I've submitted my app and had it approved, so I don't think there's ...
385,532
<p>Is there a way to set up a second persistence.xml file in a Maven project such that it is used for testing instead of the normal one that is used for deployment?</p> <p>I tried putting a persistence.xml into src/test/resources/META-INF, which gets copied into target/test-classes/META-INF, but it seems target/classe...
[ { "answer_id": 385546, "author": "TRF", "author_id": 48230, "author_profile": "https://Stackoverflow.com/users/48230", "pm_score": 2, "selected": false, "text": "<p>Keep two copies of persistence.xml file. One for testing and another for normal build.</p>\n\n<p>The default life cycle cop...
2008/12/22
[ "https://Stackoverflow.com/questions/385532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19820/" ]
Is there a way to set up a second persistence.xml file in a Maven project such that it is used for testing instead of the normal one that is used for deployment? I tried putting a persistence.xml into src/test/resources/META-INF, which gets copied into target/test-classes/META-INF, but it seems target/classes/META-INF...
The following will work for Maven 2.1+ (prior to that there wasn't a phase between test and package that you could bind an execution to). You can use the maven-antrun-plugin to replace the persistence.xml with the test version for the duration of the tests, then restore the proper version before the project is package...
385,539
<p>Mostly for my amusement, I created a <code>makefile</code> in my <code>$HOME/bin</code> directory called <code>rebuild.mk</code>, and made it executable, and the first lines of the file read:</p> <pre><code>#!/bin/make -f # # Comments on what the makefile is for ... all: ${SCRIPTS} ${LINKS} ... ... </code></pre>...
[ { "answer_id": 385548, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": true, "text": "<p>One problem with this for generally distributable Makefiles is that the location of <code>make</code> is not always con...
2008/12/22
[ "https://Stackoverflow.com/questions/385539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15168/" ]
Mostly for my amusement, I created a `makefile` in my `$HOME/bin` directory called `rebuild.mk`, and made it executable, and the first lines of the file read: ``` #!/bin/make -f # # Comments on what the makefile is for ... all: ${SCRIPTS} ${LINKS} ... ... ``` I can now type: ``` rebuild.mk ``` and this causes ...
One problem with this for generally distributable Makefiles is that the location of `make` is not always consistent across platforms. Also, some systems might require an alternate name like `gmake`. Of course one can always run the appropriate command manually, but this sort of defeats the whole purpose of making the ...
385,551
<p>This is a purely theoretical question.</p> <p>Given three simple classes:</p> <pre><code>class Base { } class Sub extends Base { } class SubSub extends Sub { } </code></pre> <p>And a function meant to operate on these classes:</p> <pre><code>public static void doSomething(Base b) { System.out.println("BA...
[ { "answer_id": 385561, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 2, "selected": false, "text": "<p>As far as I know, Java and C++ make this decision at compilation time (since these are static functions that are not dynami...
2008/12/22
[ "https://Stackoverflow.com/questions/385551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
This is a purely theoretical question. Given three simple classes: ``` class Base { } class Sub extends Base { } class SubSub extends Sub { } ``` And a function meant to operate on these classes: ``` public static void doSomething(Base b) { System.out.println("BASE CALLED"); } public static void doSomethin...
The formal specification can be found in [part 15.12.2.5 of the Java Language Specification (JLS)](http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#301183). Thanks to generics this is pretty complicated, so you might want to look at [same section of the first edition of the JLS](http://java.sun.co...
385,556
<p>Say I have three classes:</p> <pre><code>class X{}; class Y{}; class Both : public X, public Y {}; </code></pre> <p>I mean to say I have two classes, and then a third class which extends both (multiple-inheritance).</p> <p>Now say I have a function defined in another class:</p> <pre><code>void doIt(X *arg) { } v...
[ { "answer_id": 385565, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>I get this error with gcc:</p>\n\n<pre><code>jeremy@jeremy-desktop:~/Desktop$ g++ -o test test.cpp\ntest.cpp: In functi...
2008/12/22
[ "https://Stackoverflow.com/questions/385556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Say I have three classes: ``` class X{}; class Y{}; class Both : public X, public Y {}; ``` I mean to say I have two classes, and then a third class which extends both (multiple-inheritance). Now say I have a function defined in another class: ``` void doIt(X *arg) { } void doIt(Y *arg) { } ``` and I call this f...
Simple: if it's ambiguous, then the compiler gives you an error, forcing you to choose. In your snippet, you'll get a different error, because the type of `new Both()` is a pointer to `Both`, whereas both overloads of `doIt()` accept their parameters by value (i.e. they do not accept pointers). If you changed `doIt()` ...
385,558
<p>How do I extract a double value from a string using regex.</p> <pre><code>import re pattr = re.compile(???) x = pattr.match("4.5") </code></pre>
[ { "answer_id": 385597, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 6, "selected": false, "text": "<p>A regexp from the <a href=\"http://perldoc.perl.org/perlretut.html#Building-a-regexp\" rel=\"noreferrer\"><code>perldoc perlr...
2008/12/22
[ "https://Stackoverflow.com/questions/385558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10522/" ]
How do I extract a double value from a string using regex. ``` import re pattr = re.compile(???) x = pattr.match("4.5") ```
Here's the easy way. Don't use regex's for built-in types. ``` try: x = float( someString ) except ValueError, e: # someString was NOT floating-point, what now? ```
385,572
<p>I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.</p> <p>How can I do this?</p>
[ { "answer_id": 385580, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 2, "selected": false, "text": "<p>Python only has a single <code>int</code> type. To convert a string to an <code>int</code>, use <code>int()</code> like...
2008/12/22
[ "https://Stackoverflow.com/questions/385572", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings. How can I do this?
You can convert a string to a 32-bit signed integer with the `int` function: ```py string = "1234" i = int(string) # i is a 32-bit integer ``` If the string does not represent an integer, you'll get a `ValueError` exception. Note, however, that if the string does represent an integer, but that integer does not fit ...
385,605
<p>If a form in Access DB is set as hidden. Then how to unhide it? so that we can manipulate the form programmentically using vb.net.</p> <p>Thank you.</p>
[ { "answer_id": 385642, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>Does the form have Visible property? You can set to true to make the form visible.</p>\n" }, { "answer_id":...
2008/12/22
[ "https://Stackoverflow.com/questions/385605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45255/" ]
If a form in Access DB is set as hidden. Then how to unhide it? so that we can manipulate the form programmentically using vb.net. Thank you.
I cannot help with .net, in VBA: ``` Sub FormHidden() Dim frm For Each frm In CurrentProject.AllForms SetHiddenAttribute acForm, frm.Name, False Next End Sub ```
385,614
<p>We have a data entry portlet that occassionally generates urls in excess of the 2k limit enforced by Internet Explorer. </p> <p>Is there any way to stop these excessively long urls from being generated without loss of functionality?</p>
[ { "answer_id": 385642, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>Does the form have Visible property? You can set to true to make the form visible.</p>\n" }, { "answer_id":...
2008/12/22
[ "https://Stackoverflow.com/questions/385614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33889/" ]
We have a data entry portlet that occassionally generates urls in excess of the 2k limit enforced by Internet Explorer. Is there any way to stop these excessively long urls from being generated without loss of functionality?
I cannot help with .net, in VBA: ``` Sub FormHidden() Dim frm For Each frm In CurrentProject.AllForms SetHiddenAttribute acForm, frm.Name, False Next End Sub ```
385,620
<p>I'm programming in PHP and would like to create web pages which have email addresses that are easily read by humans but not easily harvested by spammers. The email addresses are coming from user input, and I think I can identify an address by using a regular expression, but I'm not clear exactly how I should replac...
[ { "answer_id": 385649, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>one option: <a href=\"http://www.google.com/search?hl=en&amp;q=javascript+email+obfuscation&amp;aq=f&amp;oq=\" rel...
2008/12/22
[ "https://Stackoverflow.com/questions/385620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
I'm programming in PHP and would like to create web pages which have email addresses that are easily read by humans but not easily harvested by spammers. The email addresses are coming from user input, and I think I can identify an address by using a regular expression, but I'm not clear exactly how I should replace th...
You can obfuscate it using CSS as well... ``` <span class="email-encrypt">moc.liamelgoog@avynnib<span class="email-decrypt-message">(Reverse this text to get my Email address)</span></span> /*Decrypt Email */ .email-encrypt { unicode-bidi:bidi-override; direction: rtl; } .email-encrypt .email-decrypt-message ...
385,629
<p>I am rendering an OpenGL scene that include some bitmap text. It is my understanding the order I draw things in will determine which items are on top.</p> <p>However, my bitmap text, even though I draw it last, is not on top!</p> <p>For instance, I am drawing:</p> <p>1) Background<br> 2) Buttons<br> 3) Text</p> ...
[ { "answer_id": 385643, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 4, "selected": true, "text": "<p>You can simply disable the z-test via </p>\n\n<pre><code> glDisable (GL_DEPTH_TEST); // or something related....
2008/12/22
[ "https://Stackoverflow.com/questions/385629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407725/" ]
I am rendering an OpenGL scene that include some bitmap text. It is my understanding the order I draw things in will determine which items are on top. However, my bitmap text, even though I draw it last, is not on top! For instance, I am drawing: 1) Background 2) Buttons 3) Text All at the same z depth. Butto...
You can simply disable the z-test via ``` glDisable (GL_DEPTH_TEST); // or something related.. ``` If you do so the Z of your text-primitives will be ignored. Primitives are drawn in the same order as your call the gl-functions. Another way would be to set some constant z-offset via glPolygonOffset (not recomme...
385,632
<p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p> <pre><code>import re from string import digits PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})') def numbers2links(s): result = "" last_match_...
[ { "answer_id": 385647, "author": "Kamil Kisiel", "author_id": 15061, "author_profile": "https://Stackoverflow.com/users/15061", "pm_score": 0, "selected": false, "text": "<p>A few things that will clean up your existing regex without really changing the functionality:</p>\n\n<p>Replace {...
2008/12/22
[ "https://Stackoverflow.com/questions/385632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37522/" ]
I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty. ``` import re from string import digits PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})') def numbers2links(s): result = "" last_match_index = 0 ...
Nice first take :) I think this version is a bit more readable (and probably a teensy bit faster). The key thing to note here is the use of [re.sub](http://docs.python.org/library/re.html#module-contents). Keeps us away from the nasty match indexes... ``` import re PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-...
385,656
<p>We have a table, name <em>'employeeReg'</em> with fields</p> <pre><code>employeeNo | employeeName | Registered_on </code></pre> <p>Here <em>Registered_on</em> is a timestamp.</p> <p>We require an hourly pattern of registrations, over a period of days. eg.</p> <blockquote> <p>01 Jan 08 : 12 - 01 PM : 1592 regis...
[ { "answer_id": 385669, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 3, "selected": true, "text": "<p>This is closely related to, but slightly different from, this question about <a href=\"https://stackoverflow.co...
2008/12/22
[ "https://Stackoverflow.com/questions/385656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18615/" ]
We have a table, name *'employeeReg'* with fields ``` employeeNo | employeeName | Registered_on ``` Here *Registered\_on* is a timestamp. We require an hourly pattern of registrations, over a period of days. eg. > > 01 Jan 08 : 12 - 01 PM : 1592 registrations > > > 01 Jan 08 : 01 - 02 PM : 1020 registrations > ...
This is closely related to, but slightly different from, this question about [How to get the latest record for each day when there are multiple entries per day](https://stackoverflow.com/questions/384142/how-to-get-latest-record-for-each-day-when-there-are-multiple-entries-per-day). (*One point in common with many, man...
385,658
<p>I have a page, where I want to dynamically add asp.net user controls. The scenario is that we want that on specific event of a control, It disposes itself and loads another control in the page.</p> <p>I am not able to have solution about how to do this?</p> <p>Anyone have decent idea?</p>
[ { "answer_id": 385669, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 3, "selected": true, "text": "<p>This is closely related to, but slightly different from, this question about <a href=\"https://stackoverflow.co...
2008/12/22
[ "https://Stackoverflow.com/questions/385658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a page, where I want to dynamically add asp.net user controls. The scenario is that we want that on specific event of a control, It disposes itself and loads another control in the page. I am not able to have solution about how to do this? Anyone have decent idea?
This is closely related to, but slightly different from, this question about [How to get the latest record for each day when there are multiple entries per day](https://stackoverflow.com/questions/384142/how-to-get-latest-record-for-each-day-when-there-are-multiple-entries-per-day). (*One point in common with many, man...
385,681
<p>I am developing a web app. which will generate a random link pointing to an image on my server. something like -<a href="http://dummy.com/Images/Image1.jpg?id=19234" rel="nofollow noreferrer">http://dummy.com/Images/Image1.jpg?id=19234</a></p> <p>Here this link can then be used by anybody on their site, now I just ...
[ { "answer_id": 385686, "author": "Oddthinking", "author_id": 8014, "author_profile": "https://Stackoverflow.com/users/8014", "pm_score": 2, "selected": false, "text": "<p>Is this as simple as Googling? Search for </p>\n\n<pre><code>link:http://dummy.com/Images/Image1.jpg?id=19234\n</code...
2008/12/22
[ "https://Stackoverflow.com/questions/385681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am developing a web app. which will generate a random link pointing to an image on my server. something like -<http://dummy.com/Images/Image1.jpg?id=19234> Here this link can then be used by anybody on their site, now I just want to know how many sites are using my links, without anybody clicking on those links. Ca...
Is this as simple as Googling? Search for ``` link:http://dummy.com/Images/Image1.jpg?id=19234 ``` If you want to do this programmatically, you'll need to use the Google API.
385,684
<p>In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ).</p> <p>The framework has a managed definition of the COM IStream interface: <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.comtyp...
[ { "answer_id": 385719, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 3, "selected": true, "text": "<p>It's not really straightforward (ie. there is no built in way to do it in the framework), but the idea is to implement a c...
2008/12/22
[ "https://Stackoverflow.com/questions/385684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26374/" ]
In a .NET 3.0 project, I need to make some calls via P/Invoke (specifically to the PrintTicket Provider functions like PTConvertPrintTicketToDevMode() ). The framework has a managed definition of the COM IStream interface: [System.Runtime.InteropServices.ComTypes.IStream](http://msdn.microsoft.com/en-us/library/system...
It's not really straightforward (ie. there is no built in way to do it in the framework), but the idea is to implement a class that implements System.Runtime.InteropServices.ComTypes.IStream. Here is an article with the code. The article does not implement the Write method, but it should be another 10 minutes to write ...
385,688
<h1>Background</h1> <p>In a C# command-line app I'm writing, several of the parameters have "yes" and "no" as the possible values.</p> <p>I am storing their input using the Enum type shown below.</p> <pre><code>enum YesNo { Yes, No } </code></pre> <p>Which is fine - the code works. No problem there. </p> ...
[ { "answer_id": 385690, "author": "moogs", "author_id": 26374, "author_profile": "https://Stackoverflow.com/users/26374", "pm_score": 1, "selected": false, "text": "<p>EUserAction ?</p>\n\n<p>You described it as some user action. You could also be more specific, though. The name allows fo...
2008/12/22
[ "https://Stackoverflow.com/questions/385688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13477/" ]
Background ========== In a C# command-line app I'm writing, several of the parameters have "yes" and "no" as the possible values. I am storing their input using the Enum type shown below. ``` enum YesNo { Yes, No } ``` Which is fine - the code works. No problem there. NOTE: Yes, I could store these as ...
I'd suggest you use a name that indicates the Value which is set to Yes or No. E.G. ``` public enum Married { YES, NO } ```
385,705
<p>I have a .NET program to upload an image to a webserver. I am using the ASP.NET file uploading control to do it. The program works alright in my local environment but when I run it on the webserver, I get the following error:</p> <pre><code>&gt; System.UnauthorizedAccessException: &gt; Access to the path &gt; '...
[ { "answer_id": 385755, "author": "Manu", "author_id": 2133, "author_profile": "https://Stackoverflow.com/users/2133", "pm_score": 0, "selected": false, "text": "<p>Check if the problem only occurs when you copy files to your production environment instead of uploading them. Copied files ...
2008/12/22
[ "https://Stackoverflow.com/questions/385705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40521/" ]
I have a .NET program to upload an image to a webserver. I am using the ASP.NET file uploading control to do it. The program works alright in my local environment but when I run it on the webserver, I get the following error: ``` > System.UnauthorizedAccessException: > Access to the path > '\\fsvs02\target03\35297...
Do you upload the file to the same filename for every user (it looks from the error message that this is the case)? If so, then it's probably as Ady says. Instead, use Path.GetTempFileName to generate a filename for your temporary file that won't collide with one that's already there. Make sure to move or delete the fi...
385,709
<p>When an application is launched, I need to know for certain methods when they are fired. How to do this using attributes and AOP techniques?</p> <p>The simplest way is to record the time in the event method such as this:</p> <pre><code>private void Page_load() { DateTime dt = DateTime.Now; } </code></pre> <p>An...
[ { "answer_id": 385747, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>You don't need to have a separate method for every event you want to log like this.</p>\n\n<p>Write a single method t...
2008/12/22
[ "https://Stackoverflow.com/questions/385709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3834/" ]
When an application is launched, I need to know for certain methods when they are fired. How to do this using attributes and AOP techniques? The simplest way is to record the time in the event method such as this: ``` private void Page_load() { DateTime dt = DateTime.Now; } ``` And save the Datetime into a databa...
[Postsharp](http://www.postsharp.org/) can probably help you here
385,730
<p>I have a number of projects in a solution file that have unit tests written for them and I want to set them up to be run by our continuous integration server. However, because many of the tests have been written poorly and have not been run regularly, there are many that are failing.</p> <p>I don't have the time at ...
[ { "answer_id": 385734, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 4, "selected": true, "text": "<p>Well, in NUnit you have the option to ignore tests using the ignore attribute:</p>\n\n<pre><code>[Test, Ignore(\"Test nee...
2008/12/22
[ "https://Stackoverflow.com/questions/385730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39532/" ]
I have a number of projects in a solution file that have unit tests written for them and I want to set them up to be run by our continuous integration server. However, because many of the tests have been written poorly and have not been run regularly, there are many that are failing. I don't have the time at the momen...
Well, in NUnit you have the option to ignore tests using the ignore attribute: ``` [Test, Ignore("Test needs rewrite")] ``` Personally though, there are two things that I do with such tests: * Delete them if I don't understand the test, or if the test is out of date/out of synch with current specs * Refactor it to ...
385,732
<p>I'm trying to make a front end for all my music and video files on a spare PC I have but have come up against a bit of a road block. I originally wanted to stream the movies (avi, mpeg, flv etc) using a flash media player but after a bit of searching it seems that flash can only stream flv's. Obviously, I don't want...
[ { "answer_id": 385780, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 2, "selected": false, "text": "<p>Why reinvent the wheel? Look at <a href=\"http://xbmc.org/\" rel=\"nofollow noreferrer\">XBMC</a> or <a href=\"http...
2008/12/22
[ "https://Stackoverflow.com/questions/385732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18856/" ]
I'm trying to make a front end for all my music and video files on a spare PC I have but have come up against a bit of a road block. I originally wanted to stream the movies (avi, mpeg, flv etc) using a flash media player but after a bit of searching it seems that flash can only stream flv's. Obviously, I don't want to...
Why reinvent the wheel? Look at [XBMC](http://xbmc.org/) or [boxee](http://www.boxee.tv/). edit: with most media players these days you can also share your libary directly so another media player can see it. or simply export the media directory as a network share and import it into the media player you're using on the...
385,784
<p>In Silverlight 2 I'm using a usercontrol which inherits the datacontext of the page that it's embedded on. This datacontext contains question text, a question type and a collection of answers. In the user control is a listbox which is bound to the collection of answers. As shown below:</p> <pre><code>&lt;ListBox Da...
[ { "answer_id": 509947, "author": "geofftnz", "author_id": 20122, "author_profile": "https://Stackoverflow.com/users/20122", "pm_score": 1, "selected": false, "text": "<p>I've just been battling with a similar problem. Mine consists of a combobox that displays for each listitem. The top-l...
2008/12/22
[ "https://Stackoverflow.com/questions/385784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36086/" ]
In Silverlight 2 I'm using a usercontrol which inherits the datacontext of the page that it's embedded on. This datacontext contains question text, a question type and a collection of answers. In the user control is a listbox which is bound to the collection of answers. As shown below: ``` <ListBox DataContext="{Bindi...
In Silverlight 3 and higher you can use Element to Element binding and point to the controls DataContext and then some property in my example its Threshold property. So first name your control (for example in my example its x:Name="control") ``` <UserControl x:Class="SomeApp.Views.MainPageView" x:Name="control" > ``...
385,793
<p>What's the best way to programmatically start an application on login for Windows? I know you can do it by adding an item to the startup folder in the start menu, but I want to have an option in my application to turn it off and on.</p>
[ { "answer_id": 385797, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 4, "selected": true, "text": "<p>This is how you could do it in C#:</p>\n\n<pre><code>Registry.SetValue(@\"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\...
2008/12/22
[ "https://Stackoverflow.com/questions/385793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23339/" ]
What's the best way to programmatically start an application on login for Windows? I know you can do it by adding an item to the startup folder in the start menu, but I want to have an option in my application to turn it off and on.
This is how you could do it in C#: ``` Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "MyStartUp", @"C:\StartUpApp.exe"); ``` You basically need to add a registry entry. The above one works on start-up. There are a few more. I recommend that you download a ...
385,796
<p>The regular code snippet of syncing data with sync framework is this:</p> <pre><code>LocalDBSyncAgent syncAgent = new LocalDBSyncAgent(); Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize(); </code></pre> <p>Do anynody knows a way to sync a subset of my tables. Note not the data insid...
[ { "answer_id": 386511, "author": "Bramha Ghosh", "author_id": 3268, "author_profile": "https://Stackoverflow.com/users/3268", "pm_score": 3, "selected": true, "text": "<p>Yes, you absolutely can. </p>\n\n<p>Create a SyncTable for each table you want to sync, and add it to the Configurati...
2008/12/22
[ "https://Stackoverflow.com/questions/385796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11659/" ]
The regular code snippet of syncing data with sync framework is this: ``` LocalDBSyncAgent syncAgent = new LocalDBSyncAgent(); Microsoft.Synchronization.Data.SyncStatistics syncStats = syncAgent.Synchronize(); ``` Do anynody knows a way to sync a subset of my tables. Note not the data inside each table but the decid...
Yes, you absolutely can. Create a SyncTable for each table you want to sync, and add it to the Configuration.SyncTables in the SyncAgent. I found [this article](http://msmvps.com/blogs/williamryan/archive/2007/11/13/filtering-data-ado-net-synchronization-services.aspx) from Bill Ryan very instructive. He goes into h...
385,809
<p>I have a MS SQL table that I don't have any control over and I need to write to. This table has a int primary key that isn't automatically incremented. I can't use stored procs and I would like to use Linq to SQL since it makes other processing very easy.</p> <p>My current solution is to read the last value, increm...
[ { "answer_id": 385814, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>That looks like an expensive way to get the maximum ID. Have you already tried</p>\n\n<pre><code>var maxId = dc.Logs.M...
2008/12/22
[ "https://Stackoverflow.com/questions/385809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11063/" ]
I have a MS SQL table that I don't have any control over and I need to write to. This table has a int primary key that isn't automatically incremented. I can't use stored procs and I would like to use Linq to SQL since it makes other processing very easy. My current solution is to read the last value, increment it, tr...
That looks like an expensive way to get the maximum ID. Have you already tried ``` var maxId = dc.Logs.Max(s => s.ID); ``` ? Maybe it doesn't work for some reason, but I really *hope* it does... (Admittedly it's more than possible that SQL Server optimises this appropriately.) Other than that, it looks okay (smell...
385,824
<p>Of all these methods what's being run and in what order?? I guess the first question to ask is whats being run first?</p> <p><strong>And why does th.start() start run()?</strong></p> <pre><code>import java.applet.*; import java.awt.*; import javax.swing.JFrame; public class BallApplet extends Applet implements R...
[ { "answer_id": 385830, "author": "Adeel Ansari", "author_id": 42769, "author_profile": "https://Stackoverflow.com/users/42769", "pm_score": 2, "selected": false, "text": "<p>The browser or Applet viewer first calls </p>\n\n<ul>\n<li>init() method to inform this applet that it has been lo...
2008/12/22
[ "https://Stackoverflow.com/questions/385824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51518/" ]
Of all these methods what's being run and in what order?? I guess the first question to ask is whats being run first? **And why does th.start() start run()?** ``` import java.applet.*; import java.awt.*; import javax.swing.JFrame; public class BallApplet extends Applet implements Runnable { int x_pos = 10; ...
The `init()` and `start()` methods are invoked first. That in turn creates a `Thread` and starts that thread, which causes this class's `run()` method to be invoked. The `paint()` method is invoked by Swing independently in the GUI event handling thread, if Swing detects that the applet needs to be redrawn. I note t...
385,837
<p>In the past I've written sites in ASP.NET just to get nice reusable templating via master pages (layouts) and user controls (partials). I'm talking about sites that have no more complicated code in them than simple variable substitution in templates - I'm just using it to keep my HTML organized. It's great to be abl...
[ { "answer_id": 385905, "author": "Nikola Stjelja", "author_id": 32582, "author_profile": "https://Stackoverflow.com/users/32582", "pm_score": 1, "selected": false, "text": "<p>I would suggest to you to look at Drupal and its Block templating model. I think its just what you need.</p>\n" ...
2008/12/22
[ "https://Stackoverflow.com/questions/385837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11284/" ]
In the past I've written sites in ASP.NET just to get nice reusable templating via master pages (layouts) and user controls (partials). I'm talking about sites that have no more complicated code in them than simple variable substitution in templates - I'm just using it to keep my HTML organized. It's great to be able t...
> > I just want something that will let me > properly modularize the HTML of my > site. > > > Look at <http://code.google.com/p/hoduli/> With that simple tool you'll be able to write like this: ``` <h:define name="header"> some header contents </h:define> ... <h:header /> <h:include file="middle_part.php"...
385,890
<p>I have created a one-time subscription in SSRS report manager 2008. However I keep getting duplicate emails sent out by the subscription. The interval between each email is about 30 minutes. </p> <p>I have checked SQL agent job and it looks the SQL agent job is created correctly. It just runs once and after that th...
[ { "answer_id": 389420, "author": "Sam", "author_id": 37379, "author_profile": "https://Stackoverflow.com/users/37379", "pm_score": 1, "selected": false, "text": "<p>I'd try to make sure that an extra job was not created. Maybe poke around the report server database and see if there is s...
2008/12/22
[ "https://Stackoverflow.com/questions/385890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42356/" ]
I have created a one-time subscription in SSRS report manager 2008. However I keep getting duplicate emails sent out by the subscription. The interval between each email is about 30 minutes. I have checked SQL agent job and it looks the SQL agent job is created correctly. It just runs once and after that the next run...
Update on this problem. When I enable the reporting service log, the problem never happens again. To the configuration file, the following is added. ``` <system.diagnostics> <switches> <add name="DefaultTraceSwitch" value="3" /> </switches> </system.diagnostics> <RStrace> <add na...
385,895
<p>What is the preferred naming convention for Django model classes?</p>
[ { "answer_id": 385951, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 3, "selected": false, "text": "<p>As far as I know, the idea is that the class name should be singular and should use SentenceCase with no spaces. So you'd h...
2008/12/22
[ "https://Stackoverflow.com/questions/385895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1897/" ]
What is the preferred naming convention for Django model classes?
Django models are just Python classes, so the Python naming conventions detailed in [PEP-8](http://www.python.org/dev/peps/pep-0008/) apply. For example: 1. Person 2. Category 3. ZipCode If Django fails to pluralize the class name properly when creating the corresponding table, you can easily override the pluralizat...
385,907
<p>I have to write a Java Client to connect to an SSL server. The server uses openssl certificate, and is configured to do Client Auth.</p> <p>I can't seem to locate any useful resources online that can help me (who doesn't know anything about openssl and much about SSL) to understand who to go about implementing my C...
[ { "answer_id": 385936, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 0, "selected": false, "text": "<p>You could use httpclient. Have a look at this <a href=\"http://hc.apache.org/httpclient-3.x/sslguide.html\" rel=\"...
2008/12/22
[ "https://Stackoverflow.com/questions/385907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29860/" ]
I have to write a Java Client to connect to an SSL server. The server uses openssl certificate, and is configured to do Client Auth. I can't seem to locate any useful resources online that can help me (who doesn't know anything about openssl and much about SSL) to understand who to go about implementing my Client Side...
The twist here is that you are using client authentication, so you need a private key and a certificate to identify yourself. You provide this to JSSE by specifying KeyManagers when you initialize an SSLContext. Customizable Setup ------------------ Following are the basic steps. The JSSE API was significantly impro...
385,910
<p>I am new to Silverlight 2.0 and I am actually trying to deploy the Silverlight as webpart in Sharepoint 2007.</p> <p>I have done the following Installations:</p> <ol> <li>VS 2008 with SP1</li> <li>Silverlight 2.0 SDK and exe</li> <li>Silverlight Tools for VS 2008</li> <li>MOSS 2007</li> </ol> <p>I have created th...
[ { "answer_id": 385923, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>You're best starting point would be to read through the Silverlight for SharePoint blueprint from the folks at u2u...
2008/12/22
[ "https://Stackoverflow.com/questions/385910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am new to Silverlight 2.0 and I am actually trying to deploy the Silverlight as webpart in Sharepoint 2007. I have done the following Installations: 1. VS 2008 with SP1 2. Silverlight 2.0 SDK and exe 3. Silverlight Tools for VS 2008 4. MOSS 2007 I have created the sample Silverlight application and got the xap fil...
I was able to resolve my issue by ensuring that my SharePoint web.config was properly configured for ASP.NET AJAX. It is not set up properly by default. See this site for details on how to do that: [Integrating ASP.NET AJAX with SharePoint](http://aspalliance.com/1719_Integrating_ASPNET_Ajax_WebPart_with_SharePoint_30...
385,912
<p>I need to convert a passed in argument (single object or collection) to an Array. I don't know what the argument is. If it is an Array already, I want to leave it, otherwise create a one-element array from it. I'm looking to <strong>allow both <code>method(:objs =&gt; obj)</code> and <code>method(:objs =&gt; [obj1, ...
[ { "answer_id": 385932, "author": "Keltia", "author_id": 16143, "author_profile": "https://Stackoverflow.com/users/16143", "pm_score": 0, "selected": false, "text": "<p>What about Array.new(1, arg)?</p>\n" }, { "answer_id": 385937, "author": "Jonathan Lonowski", "author_id...
2008/12/22
[ "https://Stackoverflow.com/questions/385912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13216/" ]
I need to convert a passed in argument (single object or collection) to an Array. I don't know what the argument is. If it is an Array already, I want to leave it, otherwise create a one-element array from it. I'm looking to **allow both `method(:objs => obj)` and `method(:objs => [obj1, obj2])`** This seems to be the...
Use the method [Kernel#Array](http://www.ruby-doc.org/core/classes/Kernel.html#M005989): ``` Array([1,2,3]) #=> [1, 2, 3] Array(123) #=> [123] ``` Yes it may look like a class at first but this is actually a method that starts with a capital letter.
385,919
<p>I face a problem when I try to get value from primary table in my mapping file.</p> <p>My tables:</p> <pre><code>CREATE TABLE Customer ( [CustomerId] INT PRIMARY KEY, [FullName] NVARCHAR(50) NOT NULL ) CREATE TABLE CustomerOrder ( [CustomerOrderId] INT PRIMARY KEY, [CustomerId] INT, [Transacti...
[ { "answer_id": 386073, "author": "James Gregory", "author_id": 27206, "author_profile": "https://Stackoverflow.com/users/27206", "pm_score": 2, "selected": true, "text": "<p>You wouldn't, really. A better design would be to have a Customer property, which is an instance of a Customer cla...
2008/12/22
[ "https://Stackoverflow.com/questions/385919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35700/" ]
I face a problem when I try to get value from primary table in my mapping file. My tables: ``` CREATE TABLE Customer ( [CustomerId] INT PRIMARY KEY, [FullName] NVARCHAR(50) NOT NULL ) CREATE TABLE CustomerOrder ( [CustomerOrderId] INT PRIMARY KEY, [CustomerId] INT, [TransactionDate] DATETIME ) `...
You wouldn't, really. A better design would be to have a Customer property, which is an instance of a Customer class. ``` public class CustomerOrder { public int Id { get; set; } public Customer Customer { get; set; } } public class CustomerOrderMap : ClassMap<CustomerOrder> { public CustomerOrderMap() { ...
385,925
<p>When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called <code>[0]</code>, <code>[1]</code>, etc. Is it possible give the tests <code>[0]</code>, <code>[1]</code>, etc. explicit names? Implementing a <code>toString</code> ...
[ { "answer_id": 386082, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 3, "selected": false, "text": "<p>I think there's nothing <em>built in</em> in jUnit 4 to do this.</p>\n\n<p>I've implemented a solution. I've built ...
2008/12/22
[ "https://Stackoverflow.com/questions/385925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21499/" ]
When you run a JUnit 4 ParameterizedTest with the Eclipse TestRunner, the graphical representation is rather dumb: for each test you have a node called `[0]`, `[1]`, etc. Is it possible give the tests `[0]`, `[1]`, etc. explicit names? Implementing a `toString` method for the tests does not seem to help. (This is a fo...
JUnit4 now [allows specifying a name attribute](https://github.com/junit-team/junit/wiki/Parameterized-tests) to the Parameterized annotation, such that you can specify a naming pattern from the index and toString methods of the arguments. E.g.: ``` @Parameters(name = "{index}: fib({0})={1}") public static Iterable<Ob...
385,928
<p>I want to show a modeless dialog on the screen and display some information in it.</p> <p>However if I use it the following way, it has some problems:</p> <pre><code>function() { showdialog(XXX). //heavy work. update the dialog.. //heavy work. update the dialog... } </code></pre> <p>It seems the dialog displayed,...
[ { "answer_id": 385979, "author": "jussij", "author_id": 14738, "author_profile": "https://Stackoverflow.com/users/14738", "pm_score": 3, "selected": false, "text": "<p>There are a few things you can do.</p>\n\n<p><strong>(1)</strong> You could <strong>post</strong> the dialog a message f...
2008/12/22
[ "https://Stackoverflow.com/questions/385928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
I want to show a modeless dialog on the screen and display some information in it. However if I use it the following way, it has some problems: ``` function() { showdialog(XXX). //heavy work. update the dialog.. //heavy work. update the dialog... } ``` It seems the dialog displayed, but it does not draw any informa...
There are a few things you can do. **(1)** You could **post** the dialog a message from inside the **CDialog::OnInitDialog** method and then handle the long function in the message handler of that posted message. That way the dialog will first be displayed and then later the long function will get run. **(2)** The se...
385,945
<p>I want to capture all the requests going to <code>*.jpg</code> files on my server. To do so, I have created an HttpHandler whose code is as follows:</p> <pre><code>using System; using System.Collections.Generic; using System.Text; using System.Web; using System.IO; using System.Globalization; namespace MyHandler {...
[ { "answer_id": 385950, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 2, "selected": false, "text": "<p>Does the user your application is running under have access to C:\\? That's usually <strong>not</strong> the case; allow...
2008/12/22
[ "https://Stackoverflow.com/questions/385945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to capture all the requests going to `*.jpg` files on my server. To do so, I have created an HttpHandler whose code is as follows: ``` using System; using System.Collections.Generic; using System.Text; using System.Web; using System.IO; using System.Globalization; namespace MyHandler { public class NewHand...
Does the user your application is running under have access to C:\? That's usually **not** the case; allowing an application context access to the root directory presents a big security risk. Instead create a specific directory, for example c:\logs and give the ASP.NET application pool's user account full rights to th...
385,959
<p>Lets say you have a model like the following:</p> <pre><code>class Stock &lt; ActiveRecord::Base # Positions BUY = 1 SELL = 2 end </code></pre> <p>And in that class as an attribute of type integer called 'position' that can hold any of the above values. What is the Rails best practice for converting those in...
[ { "answer_id": 385970, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 2, "selected": false, "text": "<p>Sounds to me like something that belongs in the views as it is a presentation issue. </p>\n\n<p>If it is used widel...
2008/12/22
[ "https://Stackoverflow.com/questions/385959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48321/" ]
Lets say you have a model like the following: ``` class Stock < ActiveRecord::Base # Positions BUY = 1 SELL = 2 end ``` And in that class as an attribute of type integer called 'position' that can hold any of the above values. What is the Rails best practice for converting those integer values into human reada...
Sounds to me like something that belongs in the views as it is a presentation issue. If it is used widely, then in a helper method for DRY purposes, and use I18N if you need it.
385,960
<p>Say I have the following code:</p> <pre><code>function One() {} One.prototype.x = undefined; function Two() {} var o = new One(); var t = new Two(); </code></pre> <p><code>o.x</code> and <code>t.x</code> will both evaluate to <code>undefined</code>. <code>o.hasOwnProperty('x')</code> and <code>t.hasOwnProperty('...
[ { "answer_id": 385962, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 0, "selected": false, "text": "<p>One way to do it is this:</p>\n\n<pre><code>var definedProperties = [];\nfor (var prop in o) definedProperties.push(pro...
2008/12/22
[ "https://Stackoverflow.com/questions/385960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Say I have the following code: ``` function One() {} One.prototype.x = undefined; function Two() {} var o = new One(); var t = new Two(); ``` `o.x` and `t.x` will both evaluate to `undefined`. `o.hasOwnProperty('x')` and `t.hasOwnProperty('x')` will both return false; the same goes for `propertyIsEnumerable`. Two ...
A slightly simpler way than your method is to use the [Javascript in operator](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/in_Operator) ``` alert('x' in o); // true alert('x' in t); // false ```
385,975
<p>What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library.</p> <p>There are two ways I've been thinking of:</p> <p>Always return error code. A typical function would look like this:</p> <pre><code>MYAPI_ERROR getObjectSize(MYAPIHandle h, int* returnedSize); </c...
[ { "answer_id": 385998, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "<p>I personally prefer the former approach (returning an error indicator).</p>\n\n<p>Where necessary the return result shoul...
2008/12/22
[ "https://Stackoverflow.com/questions/385975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11758/" ]
What do you consider "best practice" when it comes to error handling errors in a consistent way in a C library. There are two ways I've been thinking of: Always return error code. A typical function would look like this: ``` MYAPI_ERROR getObjectSize(MYAPIHandle h, int* returnedSize); ``` The always provide an err...
I like the error as return-value way. If you're designing the api and you want to make use of your library as painless as possible think about these additions: * store all possible error-states in one typedef'ed enum and use it in your lib. Don't just return ints or even worse, mix ints or different enumerations with ...
385,980
<p>I'm trying to create a script to update a password in a non-interactive way. It's working on my laptop but fails on my server. Both are running the same configuration, using Etch.</p> <p>This is the script:</p> <pre><code>#!/usr/bin/expect -f # Change user passwd set timeout 30 strace 4 set password [lindex $argv ...
[ { "answer_id": 385987, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 3, "selected": true, "text": "<p>I usually fire up <a href=\"http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx\" rel=\"nofo...
2008/12/22
[ "https://Stackoverflow.com/questions/385980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a script to update a password in a non-interactive way. It's working on my laptop but fails on my server. Both are running the same configuration, using Etch. This is the script: ``` #!/usr/bin/expect -f # Change user passwd set timeout 30 strace 4 set password [lindex $argv 1] set old_password [...
I usually fire up [ProcMon](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) and watch what registry/files are opened/read/written. ProcMon shows also if the operation succeeded or failed. That helps me pinpoint the first 80% of the problems. The usual problems are attempted writes to \Windows, \Program ...
385,986
<p>I would like to cache my most database heavy actions in my asp.net-mvc site. In my research I have found </p> <ul> <li><a href="http://haacked.com/archive/2008/11/05/donut-caching-in-asp.net-mvc.aspx" rel="noreferrer">donut caching</a> on Phil's blog</li> <li><a href="http://weblogs.asp.net/rashid/archive/2008/03/2...
[ { "answer_id": 388175, "author": "Matthew", "author_id": 20162, "author_profile": "https://Stackoverflow.com/users/20162", "pm_score": 7, "selected": true, "text": "<p>I like to cache in the model or data layer as well. This isolates everything to do with retrieving data from the contro...
2008/12/22
[ "https://Stackoverflow.com/questions/385986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I would like to cache my most database heavy actions in my asp.net-mvc site. In my research I have found * [donut caching](http://haacked.com/archive/2008/11/05/donut-caching-in-asp.net-mvc.aspx) on Phil's blog * [Caching/compressing](http://weblogs.asp.net/rashid/archive/2008/03/28/asp-net-mvc-action-filter-caching-...
I like to cache in the model or data layer as well. This isolates everything to do with retrieving data from the controller/presentation. You can access the ASP.NET cache from `System.Web.HttpContext.Current.Cache` or use the Caching Application Block from the Enterprise Library. Create your key for the cached data fro...
386,006
<p>I have the table (Product_Id, category priority, atribute1, atribute2...) in MS Access, and I am trying to make a query that orders the data grouped by Category and ordered by the highest priority. Priority can be Null, so it should be placed at the end. Example: Table</p> <pre><code>1, 100, 2, atr1, atr2 2, 300, ...
[ { "answer_id": 386025, "author": "Unsliced", "author_id": 2902, "author_profile": "https://Stackoverflow.com/users/2902", "pm_score": 0, "selected": false, "text": "<p>You need to weight the categories (I'm weighting null with some suitably large value): </p>\n\n<pre><code>select t1.* \...
2008/12/22
[ "https://Stackoverflow.com/questions/386006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the table (Product\_Id, category priority, atribute1, atribute2...) in MS Access, and I am trying to make a query that orders the data grouped by Category and ordered by the highest priority. Priority can be Null, so it should be placed at the end. Example: Table ``` 1, 100, 2, atr1, atr2 2, 300, , atr1, atr2 ...
In Jet SQL, this may suit: ``` SELECT t2.MinOfPriority, tn.Field2, Nz([tn.Field3],999) AS Priority, tn.Field4, tn.Field5 FROM tn INNER JOIN (SELECT Min(Nz(tn.Field3,999)) AS MinOfPriority, tn.Field2 FROM tn GROUP BY tn.Field2) AS t2 ON tn.Field2 = t2.Field2 ORDER BY t2.MinOfPriority, tn.Field2, N...
386,017
<p>I have methods with <strong>more than one parameter</strong> that are guarded against bad input by throwing ArgumentNullExceptions and ArgumentExceptions whenever any parameter is null.</p> <p>So there are two obvious ways to test this:</p> <ul> <li>One test per Parameter using the [ExpectedException] attribute</l...
[ { "answer_id": 386037, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>Well, you can reduce it to a single dead line by extracting a utility method, e.g.</p>\n\n<pre><code>public void Expe...
2008/12/22
[ "https://Stackoverflow.com/questions/386017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21699/" ]
I have methods with **more than one parameter** that are guarded against bad input by throwing ArgumentNullExceptions and ArgumentExceptions whenever any parameter is null. So there are two obvious ways to test this: * One test per Parameter using the [ExpectedException] attribute * One test for all parameters using ...
From [release notes of NUnit 2.4.7](http://nunit.org/index.php?p=releaseNotes&r=2.4.7) NUnit now includes the RowTest extension, written by Andreas Schlapsi, in it's extension assemblies. This extension allows you to write test methods that take arguments and to provide multiple sets of argument values using the RowAtt...
386,034
<p>If I'd like to control the IP phone from my web application, how should I begin?</p> <p>Let's say I have a standalone IP phone connected to the provider of IP telephony services. On the other side I have a server-side web application for the sales support. I'd like to initiate a call on my phone from this web appli...
[ { "answer_id": 386037, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>Well, you can reduce it to a single dead line by extracting a utility method, e.g.</p>\n\n<pre><code>public void Expe...
2008/12/22
[ "https://Stackoverflow.com/questions/386034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25956/" ]
If I'd like to control the IP phone from my web application, how should I begin? Let's say I have a standalone IP phone connected to the provider of IP telephony services. On the other side I have a server-side web application for the sales support. I'd like to initiate a call on my phone from this web application, on...
From [release notes of NUnit 2.4.7](http://nunit.org/index.php?p=releaseNotes&r=2.4.7) NUnit now includes the RowTest extension, written by Andreas Schlapsi, in it's extension assemblies. This extension allows you to write test methods that take arguments and to provide multiple sets of argument values using the RowAtt...
386,039
<p>I have a problem. I need to host grid with controls in ScrollViewer to prevent textbox from being either truncated or collapsed to zero-with at the UI. Also I want the with of textbox to be expanded when user change windows width. I'm setting Window's content to following code</p> <pre><code>&lt;DockPanel&gt; &...
[ { "answer_id": 387338, "author": "Robert Macnee", "author_id": 19273, "author_profile": "https://Stackoverflow.com/users/19273", "pm_score": 6, "selected": true, "text": "<p>The problem is that the parent elements are providing TextBox with as much space as it thinks it needs, and when m...
2008/12/22
[ "https://Stackoverflow.com/questions/386039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47856/" ]
I have a problem. I need to host grid with controls in ScrollViewer to prevent textbox from being either truncated or collapsed to zero-with at the UI. Also I want the with of textbox to be expanded when user change windows width. I'm setting Window's content to following code ``` <DockPanel> <TreeView DockPanel.D...
The problem is that the parent elements are providing TextBox with as much space as it thinks it needs, and when more text is present it will expand instead of staying at the initial automatic size. One solution here is to make another auto-sized element and bind the TextBox.Width to it: ``` <DockPanel> <TreeView...
386,042
<p>I want to have a checkbox for terms and conditions, label of which should contain a link to a page with, well, terms and conditions.</p> <p>The following field will have the label with the tags escaped.</p> <pre><code>BooleanField(label="I agree to &lt;a href='terms-conditions.html'&gt;terms&amp;conditions&lt;/a&g...
[ { "answer_id": 386065, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 4, "selected": true, "text": "<p>I'm not sure how django works, but if the label in the above code creates a:</p>\n\n<pre><code>&lt;label&gt;I agree to t...
2008/12/22
[ "https://Stackoverflow.com/questions/386042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5978/" ]
I want to have a checkbox for terms and conditions, label of which should contain a link to a page with, well, terms and conditions. The following field will have the label with the tags escaped. ``` BooleanField(label="I agree to <a href='terms-conditions.html'>terms&conditions</a>") ```
I'm not sure how django works, but if the label in the above code creates a: ``` <label>I agree to terms&conditions</label> ``` element then this is NOT the way to do this. The label element inherently selects the associated field by default, so you'd be mixing 2 click actions (one that checks, and another that ope...
386,044
<p>JavaScript does funky automatic conversions with objects:</p> <pre><code>var o = {toString: function() {return "40"; }}; print(o + o); print((o+1)+o); print((o*2) + (+o)); </code></pre> <p>will print:</p> <pre><code>4040 40140 120 </code></pre> <p>This is because +, if any of the arguments are objects/strings, w...
[ { "answer_id": 386048, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "<p>The following code illustrates this well:</p>\n\n<pre><code>var a = {toString: function() {return \"40\"; }};\nnl(typeo...
2008/12/22
[ "https://Stackoverflow.com/questions/386044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
JavaScript does funky automatic conversions with objects: ``` var o = {toString: function() {return "40"; }}; print(o + o); print((o+1)+o); print((o*2) + (+o)); ``` will print: ``` 4040 40140 120 ``` This is because +, if any of the arguments are objects/strings, will try to convert all the arguments to strings t...
From [ECMAScript Language Specification](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) > > 11.3 Postfix Expressions > ------------------------ > > > **Syntax** > > > PostfixExpression : > > > * LeftHandSideExpression > * LeftHandSideExpression [no LineTerminator here] ++ > * LeftHan...
386,064
<p>I want to create a lst file from a sql script</p> <p>Here is my code:</p> <pre><code>BEGIN DECLARE loc_bia_foracid GAM.foracid%TYPE; loc_fba_foracid GAM.foracid%TYPE; out_spool VARCHAR2(32000); BEGIN loc_bia_foracid:= '&amp;loc_bia_foracid'; loc_fba_foracid:= '&amp;loc_fba_foracid'; out_spool := out_spool || '|' ...
[ { "answer_id": 386858, "author": "darreljnz", "author_id": 10538, "author_profile": "https://Stackoverflow.com/users/10538", "pm_score": 0, "selected": false, "text": "<p>Here is how the above would look as a stored procedure:</p>\n\n<pre><code>CREATE OR REPLACE FUNCTION make_lst(\n pis...
2008/12/22
[ "https://Stackoverflow.com/questions/386064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to create a lst file from a sql script Here is my code: ``` BEGIN DECLARE loc_bia_foracid GAM.foracid%TYPE; loc_fba_foracid GAM.foracid%TYPE; out_spool VARCHAR2(32000); BEGIN loc_bia_foracid:= '&loc_bia_foracid'; loc_fba_foracid:= '&loc_fba_foracid'; out_spool := out_spool || '|' || loc_bia_foracid; out_spool...
It would be something like this i presume ``` declare loc_bia_foracid varchar2(32767); loc_fba_foracid varchar2(32767); out_spool clob; begin loc_bia_foracid := '&loc_bia_foracid'; loc_fba_foracid := '&loc_fba_foracid'; out_spool := out_spool || '|' || loc_bia_foracid; out_spool := out_spool || '|' || lo...
386,066
<p>I'm implementing a locking and copy protection system for my software. I've shut every hole that would allow someone to break my lock (well, that's a little too optimistic, I know!) but the last thing is this:</p> <p>I hear crackers can change Windows DLLs like Kernel32.dll in a way that the API I use returns a val...
[ { "answer_id": 386086, "author": "James Ogden", "author_id": 3198, "author_profile": "https://Stackoverflow.com/users/3198", "pm_score": 3, "selected": false, "text": "<p>Are you going to write your own crypto routines so you can validate the signature yourself, or are you going to trust...
2008/12/22
[ "https://Stackoverflow.com/questions/386066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41389/" ]
I'm implementing a locking and copy protection system for my software. I've shut every hole that would allow someone to break my lock (well, that's a little too optimistic, I know!) but the last thing is this: I hear crackers can change Windows DLLs like Kernel32.dll in a way that the API I use returns a value which i...
MS does sign some system binaries, depending on the version of Windows and the binary. For example, if you [check](http://technet.microsoft.com/en-us/sysinternals/bb897441.aspx) kernel32.dll on Windows XP: ``` C:\Windows\system32>sigcheck kernel32.dll Sigcheck v1.5 Copyright (C) 2004-2008 Mark Russinovich Sysinternals...
386,083
<p>I am trying to use <a href="https://stackoverflow.com/questions/46663/how-do-you-send-email-from-a-java-app-using-gmail#47452">Bill the Lizard's code</a> to send an email using Google Apps. I am getting this error: </p> <pre><code>Exception in thread "main" javax.mail.SendFailedException: Sending failed; nested e...
[ { "answer_id": 386166, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 2, "selected": false, "text": "<p>I think it's got to do with using SMTPS instead of SMTP for mail transport. Here's a different version, modeled a...
2008/12/22
[ "https://Stackoverflow.com/questions/386083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I am trying to use [Bill the Lizard's code](https://stackoverflow.com/questions/46663/how-do-you-send-email-from-a-java-app-using-gmail#47452) to send an email using Google Apps. I am getting this error: ``` Exception in thread "main" javax.mail.SendFailedException: Sending failed; nested exception is: javax.m...
I found the problem. Previously i was using j2ee.jar to import javax.mail. I removed j2ee.jar from the classpath and downloaded [JavaMail](http://java.sun.com/products/javamail/) 1.4.1 and put into my classpath two jars, smtp.jar and mailapi.jar. I use now **smtps** instead **smtp** ``` Transport transport = session...
386,088
<p>I am using the following code to attempt to read a large file (280Mb) into a byte array from a UNC path</p> <pre><code>public void ReadWholeArray(string fileName, byte[] data) { int offset = 0; int remaining = data.Length; log.Debug("ReadWholeArray"); FileStream stream = new FileStream(fileName, F...
[ { "answer_id": 386099, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>I suspect that something lower down is trying to read into another buffer, and reading all 280MB in one go is failing....
2008/12/22
[ "https://Stackoverflow.com/questions/386088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/983/" ]
I am using the following code to attempt to read a large file (280Mb) into a byte array from a UNC path ``` public void ReadWholeArray(string fileName, byte[] data) { int offset = 0; int remaining = data.Length; log.Debug("ReadWholeArray"); FileStream stream = new FileStream(fileName, FileMode.Open, ...
I suspect that something lower down is trying to read into another buffer, and reading all 280MB in one go is failing. There may be more buffers required in the network case than in the local case. I would read about 64K at a time instead of trying to read the whole lot in one go. That's enough to avoid too much overh...
386,094
<p>the following js works fine in FF2 but in IE6 the dropdown always selects one option to early, IE -> testix2 vs. FF2 -> testix3 If we add an alertBox somewhere in the script, it also works fine in IE6. But how to solve this without an alertBox?</p> <p>tia</p> <pre><code>&lt;script language="JavaScript" type="text/...
[ { "answer_id": 386127, "author": "Tom Haigh", "author_id": 22224, "author_profile": "https://Stackoverflow.com/users/22224", "pm_score": 3, "selected": true, "text": "<p>I'm not entirely sure why your example does not work, but it works if you do it like this (i.e. setting the selectedIn...
2008/12/22
[ "https://Stackoverflow.com/questions/386094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28968/" ]
the following js works fine in FF2 but in IE6 the dropdown always selects one option to early, IE -> testix2 vs. FF2 -> testix3 If we add an alertBox somewhere in the script, it also works fine in IE6. But how to solve this without an alertBox? tia ``` <script language="JavaScript" type="text/javascript"> <!-- functi...
I'm not entirely sure why your example does not work, but it works if you do it like this (i.e. setting the selectedIndex on the <select> rather than setting the <option>'s selected propery). Tested FF3, IE6, Chrome. ``` var i = 0; for (i in productCategoryLevel2) { var optL2 = document.createElement('option'); ...
386,107
<p>I've written my first JQuery plugin and one of it's dependancies is an external css stylesheet. Do you think this is an acceptable strategy to include this in the distributable or should I embed style information in the plugin itself? Should I ship with no style information at all? The visual elements of the plugin ...
[ { "answer_id": 386117, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 2, "selected": false, "text": "<p>I would include the external css with the plugin distribution. Embedding the styles with js make it far less appealing ...
2008/12/22
[ "https://Stackoverflow.com/questions/386107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39655/" ]
I've written my first JQuery plugin and one of it's dependancies is an external css stylesheet. Do you think this is an acceptable strategy to include this in the distributable or should I embed style information in the plugin itself? Should I ship with no style information at all? The visual elements of the plugin mak...
UI is surely one of the most important plug-ins and it does include css files in its distribution. This is how the distribution looks like: ``` jquery.js licence.txt readme.txt ui\*.js themes\*.css tests\ demos\ ``` I suppose you could use a similar structure. Note that some widgets don't work without the style shee...
386,115
<p>I've been coding in Ruby for sometime now, but I don't understand when to use:</p> <pre><code>def self.METHOD_NAME end </code></pre> <p>or just:</p> <pre><code>def METHOD_NAME end </code></pre> <p>In any Rails model. Is "self" a modifier like private in Java? When should I use it and when not?. Thanks a ton.</p>...
[ { "answer_id": 386132, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 8, "selected": true, "text": "<pre><code>def self.method_name\nend\n</code></pre>\n\n<p>defines a class method.</p>\n\n<pre><code>def method_name\ne...
2008/12/22
[ "https://Stackoverflow.com/questions/386115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44916/" ]
I've been coding in Ruby for sometime now, but I don't understand when to use: ``` def self.METHOD_NAME end ``` or just: ``` def METHOD_NAME end ``` In any Rails model. Is "self" a modifier like private in Java? When should I use it and when not?. Thanks a ton.
``` def self.method_name end ``` defines a class method. ``` def method_name end ``` defines an instance method. [This](http://www.rubyfleebie.com/understanding-class-methods-in-ruby/) is a pretty good post on it.
386,122
<p>I would like to know if there is a function to correctly escape string literals for filter expressions. e.g.:</p> <pre><code>DataTable.Select(String.Format(&quot;[name] = '{0}'&quot;, MyName)) </code></pre> <p>If MyName contains ' or a number of other key characters an exception is generated. The <a href="http://msd...
[ { "answer_id": 386134, "author": "Ady", "author_id": 31395, "author_profile": "https://Stackoverflow.com/users/31395", "pm_score": 3, "selected": false, "text": "<p>If I replace ' with two single ' the query works.</p>\n" }, { "answer_id": 2928226, "author": "Rory", "auth...
2008/12/22
[ "https://Stackoverflow.com/questions/386122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31395/" ]
I would like to know if there is a function to correctly escape string literals for filter expressions. e.g.: ``` DataTable.Select(String.Format("[name] = '{0}'", MyName)) ``` If MyName contains ' or a number of other key characters an exception is generated. The [Microsoft documentation](http://msdn.microsoft.com/e...
Escape the single quote ' by doubling it to ''. Escape \* % [ ] characters by wrapping in []. e.g. ``` private string EscapeLikeValue(string value) { StringBuilder sb = new StringBuilder(value.Length); for (int i = 0; i < value.Length; i++) { char c = value[i]; switch (c) { ...
386,131
<p>I want to keep viewstate of a specific page in session but following code block does not help me, what might I be missing?</p> <p>So here is the code-behind file content of my page;</p> <pre><code> public partial class ConfigurationEditorWebForm : PageBase { protected void Page_Load(object sender, E...
[ { "answer_id": 484656, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 2, "selected": false, "text": "<p>The important part of the code is</p>\n\n<pre><code>protected override PageStatePersister PageStatePersister\n{\n get...
2008/12/22
[ "https://Stackoverflow.com/questions/386131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35012/" ]
I want to keep viewstate of a specific page in session but following code block does not help me, what might I be missing? So here is the code-behind file content of my page; ``` public partial class ConfigurationEditorWebForm : PageBase { protected void Page_Load(object sender, EventArgs e) {...
Note that even after you move the page state to view state, you will still see a \_\_Viewstate element on your pages. Also, I believe that [this solution](http://aspalliance.com/72) may be more correct than the others offered, as it handles the back button a bit more elegantly. When you store the ViewState in a hidden...
386,151
<p>I want to convert strings to bit-fields.Also,convert them to binary and then use. Need help with this..help me ..</p>
[ { "answer_id": 386161, "author": "Cogsy", "author_id": 48234, "author_profile": "https://Stackoverflow.com/users/48234", "pm_score": 0, "selected": false, "text": "<p>they're all binary already... Which language are we talking about?</p>\n\n<p>I'd start by looking at the string as an arr...
2008/12/22
[ "https://Stackoverflow.com/questions/386151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
I want to convert strings to bit-fields.Also,convert them to binary and then use. Need help with this..help me ..
I think the [struct module](http://www.python.org/doc/2.5.2/lib/module-struct.html) is what you're after. Example of usage: ``` >>> from struct import * >>> pack('hhl', 1, 2, 3) '\x00\x01\x00\x02\x00\x00\x00\x03' >>> unpack('hhl', '\x00\x01\x00\x02\x00\x00\x00\x03') (1, 2, 3) >>> calcsize('hhl') 8 ```
386,155
<p>I'm doing some research in code generation from xsd schema files. My requirements:</p> <ul> <li>Must generate C# 2.0 code (or above), using generic collections where needed.</li> <li>Must generate comments from the xsd comments</li> <li>Must generate fully serializable code.</li> <li>Should be able to generate res...
[ { "answer_id": 386190, "author": "Steen", "author_id": 1448983, "author_profile": "https://Stackoverflow.com/users/1448983", "pm_score": 2, "selected": false, "text": "<p>I a project a bit over a year ago we used CodeXS. With some minor adjustments (a script that cleaned up the generated...
2008/12/22
[ "https://Stackoverflow.com/questions/386155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6399/" ]
I'm doing some research in code generation from xsd schema files. My requirements: * Must generate C# 2.0 code (or above), using generic collections where needed. * Must generate comments from the xsd comments * Must generate fully serializable code. * Should be able to generate resuable basetypes when generating fro...
I believe [XSD2Code](http://xsd2code.codeplex.com/) is the best tool currently available (in 2011). I recently went through the same process at work of analysing the available tools out there so i thought i would provide an updated answer that relates to **VS2010**. Our main driver was that **xsd.exe** does not gener...
386,174
<p>Steps:<br /> - Installed Mysql Server 2005 <br /> - Downloaded Mysql++, built both debug and release version.<br /> - Ran install.hta and selected a directory<br /> - Added library/include directory in MSVC++ 2008<br /> - Included mysql++.h in my application<br /> - Moved .dll files (libMYSQL.dll and mysqlpp.dll and...
[ { "answer_id": 414081, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "<p>I would not make this pointer:</p>\n<pre><code>mysqlpp::Connection* conn;\n</code></pre>\n<p>Just make it a normal ...
2008/12/22
[ "https://Stackoverflow.com/questions/386174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Steps: - Installed Mysql Server 2005 - Downloaded Mysql++, built both debug and release version. - Ran install.hta and selected a directory - Added library/include directory in MSVC++ 2008 - Included mysql++.h in my application - Moved .dll files (libMYSQL.dll and mysqlpp.dll and mysqlpp\_d.dll) to D...
I would not make this pointer: ``` mysqlpp::Connection* conn; ``` Just make it a normal member of the class. ``` mysqlpp::Connection conn; ``` This has several advantages. But the most important to you is that you will avoid the shallow copy problem. ### Rule of 4: If an object is the owner of a RAW pointe...
386,183
<p>i have a sub with this signature</p> <pre><code>Public Sub Save(ByVal obj As IPta) </code></pre> <p>now i want the create a instance of Generic.PtaDao(of T) with the type of obj, which could be anything that inherits from my base class Pta</p> <p>how can i do that? i already found a c# example <a href="https://st...
[ { "answer_id": 386267, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>Make it a generic method, taking an instance of the type parameter as one of the parameters, and constrain the type pa...
2008/12/22
[ "https://Stackoverflow.com/questions/386183", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12406/" ]
i have a sub with this signature ``` Public Sub Save(ByVal obj As IPta) ``` now i want the create a instance of Generic.PtaDao(of T) with the type of obj, which could be anything that inherits from my base class Pta how can i do that? i already found a c# example [Declare a generic type instance dynamically](https:...
Make it a generic method, taking an instance of the type parameter as one of the parameters, and constrain the type parameter to have a public parameterless constructor and to implement IPta: ``` Public Sub Save(Of T As { IPta, New })(ByVal obj As T) Dim foo As New T ' Do more stuff here End Sub ```
386,189
<p>Is there any way that I could get the source of a website (as a string preferably), let's say www.google.com, from some c# code inside code behind of asp.net website?</p> <p>edit: of course i mean html code - in every browser you can view it using "view <strong>source</strong>" in context menu.</p>
[ { "answer_id": 386217, "author": "Darin Dimitrov", "author_id": 29407, "author_profile": "https://Stackoverflow.com/users/29407", "pm_score": 4, "selected": true, "text": "<p>Assuming you want to retrieve the html:</p>\n\n<pre><code>class Program\n{\n static void Main(string[] args)\n...
2008/12/22
[ "https://Stackoverflow.com/questions/386189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40872/" ]
Is there any way that I could get the source of a website (as a string preferably), let's say www.google.com, from some c# code inside code behind of asp.net website? edit: of course i mean html code - in every browser you can view it using "view **source**" in context menu.
Assuming you want to retrieve the html: ``` class Program { static void Main(string[] args) { using (WebClient client = new WebClient()) using (Stream stream = client.OpenRead("http://www.google.com")) using (StreamReader reader = new StreamReader(stream)) { Console....
386,211
<p>I posted this <a href="https://stackoverflow.com/questions/385442/linq-submitchanges-not-updating-certain-fields">question</a> yesterday evening, which has led me to discover a <strong>huge</strong> problem!</p> <p>I have a decimal column in my database called Units, anytime I set the value of the column to a NON Z...
[ { "answer_id": 386367, "author": "Gaspar Nagy", "author_id": 26530, "author_profile": "https://Stackoverflow.com/users/26530", "pm_score": 2, "selected": false, "text": "<p>I have tried to reproduce this with a the following code, but for me it works.</p>\n\n<pre><code>using (DataClasses...
2008/12/22
[ "https://Stackoverflow.com/questions/386211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
I posted this [question](https://stackoverflow.com/questions/385442/linq-submitchanges-not-updating-certain-fields) yesterday evening, which has led me to discover a **huge** problem! I have a decimal column in my database called Units, anytime I set the value of the column to a NON ZERO, and SubmitChanges the column ...
I figured out my problem with the help of the SO community. My problem was being caused by the fact when I created my entity to attach, the default value of the column was set to zero, so when it tried to assign the value to zero ... LinqToSql says hey ... nothing changed, so I am not updating the value. What I am doi...
386,220
<p>I have a bunch of compile time asserts, such as:</p> <pre><code>CASSERT(isTrue) or CASSERT2(isTrue, prefix_) </code></pre> <p>When compiling with GCC I get many warnings like <code>'prefix_LineNumber' defined but not used</code>. Is there a way I can hide warnings for compile time asserts? I had no luck searching ...
[ { "answer_id": 386237, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "<p>How about <code>-Wunused-label</code> ?</p>\n" }, { "answer_id": 386273, "author": "Community", "au...
2008/12/22
[ "https://Stackoverflow.com/questions/386220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a bunch of compile time asserts, such as: ``` CASSERT(isTrue) or CASSERT2(isTrue, prefix_) ``` When compiling with GCC I get many warnings like `'prefix_LineNumber' defined but not used`. Is there a way I can hide warnings for compile time asserts? I had no luck searching the GCC documentation. I thought I mi...
Just saw this thread while searching for solutions to this problem. I post here for completeness the solution I found... The GCC compiler flags that control unused [warnings](http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html) include: ``` -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunuse...
386,252
<p>I want to keep the class simple and not defined a constructor so i can do Pt data = {0, 5}; so i figured the best way convert Pt_t from a short to long or vice versa is to do something like this.</p> <pre><code>template &lt;class T&gt; struct Pt_t { T x, y; template &lt;class T2&gt; operator Pt_t&lt;T2&gt;(...
[ { "answer_id": 386262, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 1, "selected": false, "text": "<p>I'm unfamiliar with C++, but are you declaring the right type in your method there?</p>\n\n<p>Shouldn't it be <cod...
2008/12/22
[ "https://Stackoverflow.com/questions/386252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to keep the class simple and not defined a constructor so i can do Pt data = {0, 5}; so i figured the best way convert Pt\_t from a short to long or vice versa is to do something like this. ``` template <class T> struct Pt_t { T x, y; template <class T2> operator Pt_t<T2>() { Pt_t pt = {x, y}; return pt...
I'm pretty sure the unqualified Pt\_t in your functions body is `Pt_t<T>`, but don't you want it to be `Pt_t<T2>`? You'll need to explicitly qualify it.
386,265
<p>At the root of my d: drive, TortoiseSVN is showing the question mark decorators on all the folders. The d: drive is not a SVN working copy. How do I remove the decorators?</p>
[ { "answer_id": 386279, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 5, "selected": true, "text": "<p>TSVNCache, which TortoiseSVN uses to keep those icons uptodate, doesn't always make the correct choices about which dir...
2008/12/22
[ "https://Stackoverflow.com/questions/386265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
At the root of my d: drive, TortoiseSVN is showing the question mark decorators on all the folders. The d: drive is not a SVN working copy. How do I remove the decorators?
TSVNCache, which TortoiseSVN uses to keep those icons uptodate, doesn't always make the correct choices about which directories need decoration. You can limit which directories it will consider by: * In **TortoiseSVN|Settings|Look and Feel|Icon Overlays** * In the **Drive Types** section + Mark the drive types you w...
386,281
<p>I have an HTML page with multiple checkboxes.</p> <p>I need one more checkbox by the name "select all". When I select this checkbox all checkboxes in the HTML page must be selected. How can I do this?</p>
[ { "answer_id": 386290, "author": "Cogsy", "author_id": 48234, "author_profile": "https://Stackoverflow.com/users/48234", "pm_score": 3, "selected": false, "text": "<p>JavaScript is your best bet. The link below gives an example using buttons to de/select all. You could try to adapt it ...
2008/12/22
[ "https://Stackoverflow.com/questions/386281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
I have an HTML page with multiple checkboxes. I need one more checkbox by the name "select all". When I select this checkbox all checkboxes in the HTML page must be selected. How can I do this?
``` <script language="JavaScript"> function toggle(source) { checkboxes = document.getElementsByName('foo'); for(var checkbox in checkboxes) checkbox.checked = source.checked; } </script> <input type="checkbox" onClick="toggle(this)" /> Toggle All<br/> <input type="checkbox" name="foo" value="bar1"> Bar 1<br/...
386,286
<p>I am creating a web service that generates the following in the WSDL file:</p> <pre><code>&lt;wsdl:portType name="myServicePortSoap"&gt; </code></pre> <p>and would like to have it renamed to generate:</p> <pre><code>&lt;wsdl:portType name="myServicePort"&gt; </code></pre> <p>How can I do that within the .asmx fi...
[ { "answer_id": 386416, "author": "seanhodges", "author_id": 43662, "author_profile": "https://Stackoverflow.com/users/43662", "pm_score": 0, "selected": false, "text": "<p>.asmx? I assume you are using ASP.NET to auto-generate your WSDL?</p>\n\n<p>I'm not sure how you would override the ...
2008/12/22
[ "https://Stackoverflow.com/questions/386286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am creating a web service that generates the following in the WSDL file: ``` <wsdl:portType name="myServicePortSoap"> ``` and would like to have it renamed to generate: ``` <wsdl:portType name="myServicePort"> ``` How can I do that within the .asmx file to do so? Any ideas please?
Apparently specifying the Name parameter in the WebServiceBinding attribute is supposed to affect this but I couldn't see the change in the WSDL.
386,294
<p>What is the maximum length of a valid email address? Is it defined by any standard?</p>
[ { "answer_id": 386302, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 6, "selected": false, "text": "<p>320</p>\n<p>And the segments look like this</p>\n<p>{64}@{255}</p>\n<p>64 + 1 + 255 = 320</p>\n<p>You should also read this if yo...
2008/12/22
[ "https://Stackoverflow.com/questions/386294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20305/" ]
What is the maximum length of a valid email address? Is it defined by any standard?
An email address must not exceed **254** characters. This was accepted by the IETF following [submitted erratum](http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690). A full diagnosis of any given address is available [online](http://isemail.info/). The original version of RFC 3696 described 320 as the maxim...
386,307
<p>I have an access database with many tables. I am looking for a field which may or may not exist in one or many of the tables. How do I check if it exists or not? (without querying each table of course)</p>
[ { "answer_id": 386323, "author": "ericp", "author_id": 48363, "author_profile": "https://Stackoverflow.com/users/48363", "pm_score": -1, "selected": false, "text": "<p>MSSQL \nLooking for ADDRESS1 column:\nselect so.name from sysobjects so\nwhere so.id in (select sc.id from syscolumns sc...
2008/12/22
[ "https://Stackoverflow.com/questions/386307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31132/" ]
I have an access database with many tables. I am looking for a field which may or may not exist in one or many of the tables. How do I check if it exists or not? (without querying each table of course)
There is a schema for fields: ``` Set cn = CurrentProject.Connection SelectFieldName = "SomeFieldName" 'Get names of all tables that have a column = SelectFieldName ' Set rs = cn.OpenSchema(adSchemaColumns, _ Array(Empty, Empty, Empty, SelectFieldName)) ``` From: [MS Access: How to bypass/suppress an error?](http...
386,308
<p>When creating a criteria for NHibernate all criteria are added as <code>AND</code>.</p> <p>For instance:</p> <pre><code>session.CreateCriteria(typeof(someobject)) .Add(critiera) .Add(other_criteria) </code></pre> <p>then end result will be</p> <pre><code>SELECT ... FROM ... WHERE criteria **AND** other_criteria ...
[ { "answer_id": 386329, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "<p>You could use <code>Restrictions.or</code>, such that:</p>\n\n<pre><code>session.CreateCriteria(typeof(someobject))\n ...
2008/12/22
[ "https://Stackoverflow.com/questions/386308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30719/" ]
When creating a criteria for NHibernate all criteria are added as `AND`. For instance: ``` session.CreateCriteria(typeof(someobject)) .Add(critiera) .Add(other_criteria) ``` then end result will be ``` SELECT ... FROM ... WHERE criteria **AND** other_criteria ``` I would like to tell NHibernate to add the criter...
You're looking for the `Conjunction` and `Disjunction` classes, these can be used to combine various statements to form OR and AND statements. **AND** ``` .Add( Expression.Conjunction() .Add(criteria) .Add(other_criteria) ) ``` **OR** ``` .Add( Expression.Disjunction() .Add(criteria) .Add(other...
386,315
<p>I am in the process of refactoring our BI layers to make our code more "loosely coupled" and I was interested to hear what you guys thought might be interesting improvements to make?</p> <p>At present, our API is something like the following:-</p> <pre><code>// Fetch a collection of objects ProductCollection prods...
[ { "answer_id": 386405, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I think the primary issue here is separation of concerns: why should your business object care how it is persisted? ...
2008/12/22
[ "https://Stackoverflow.com/questions/386315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38911/" ]
I am in the process of refactoring our BI layers to make our code more "loosely coupled" and I was interested to hear what you guys thought might be interesting improvements to make? At present, our API is something like the following:- ``` // Fetch a collection of objects ProductCollection prods = Product.GetProduct...
Your current API is an implementation of the [Active Record Pattern](http://en.wikipedia.org/wiki/Active_record_pattern). This pattern tends to work fine when the object model used in the code is a one-on-one match with the database model. Another advantage is that tooling exists to generate these classes,including the...
386,319
<p>Hi I'm trying to fix a bit of test html to work with opera/chrome. It's using the <a href="http://www.alistapart.com/articles/holygrail" rel="nofollow noreferrer">holygrail box model from matt levine</a>. </p> <p>In IE and firefox it looks like</p> <p><a href="http://img187.imageshack.us/img187/4049/writedn1.jpg" ...
[ { "answer_id": 386347, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 0, "selected": false, "text": "<p>Well, I know that min-width doesn't work on the BODY tag, at least in certain versions of IE (I thought it worked i...
2008/12/22
[ "https://Stackoverflow.com/questions/386319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/253/" ]
Hi I'm trying to fix a bit of test html to work with opera/chrome. It's using the [holygrail box model from matt levine](http://www.alistapart.com/articles/holygrail). In IE and firefox it looks like [correct layout http://img187.imageshack.us/img187/4049/writedn1.jpg](http://img187.imageshack.us/img187/4049/writedn...
I got it to work in both Safari and Firefox (haven't tested the other browsers yet) Change this: ```css #content{ padding-right:300px; background:#F00; } #main{ padding:5px 15px; width: 100%; margin-right: -30px; } ``` Dunno why this works any better than what you have above, but it do...
386,321
<p>I am html page with 5 checkboxes</p> <p>My requirement is to have one morecheckboxes "Select All" which is used to select all 5 checkboxes.</p> <p>Thanks in advance</p> <p><strong>Closed</strong> as exact duplicate of <a href="https://stackoverflow.com/questions/386281/how-to-implement-select-all-check-box-in-htm...
[ { "answer_id": 386332, "author": "Mark Carpenter", "author_id": 47645, "author_profile": "https://Stackoverflow.com/users/47645", "pm_score": 2, "selected": false, "text": "<p>If you're looking for javascript that will check your 5 checkboxes when the 6th is clicked, something like this ...
2008/12/22
[ "https://Stackoverflow.com/questions/386321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48094/" ]
I am html page with 5 checkboxes My requirement is to have one morecheckboxes "Select All" which is used to select all 5 checkboxes. Thanks in advance **Closed** as exact duplicate of [this question](https://stackoverflow.com/questions/386281/how-to-implement-select-all-check-box-in-html).
If you're looking for javascript that will check your 5 checkboxes when the 6th is clicked, something like this should work: ``` function CheckAll(value){ document.getElementByID("CheckBox1").checked = value; document.getElementByID("CheckBox2").checked = value; document.getElementByID("CheckBox3").checked...
386,341
<p>I have a ticks value of 28000000000 which should be 480 minutes but how can I be sure? How do I convert a ticks value to minutes?</p>
[ { "answer_id": 386350, "author": "Blounty", "author_id": 33944, "author_profile": "https://Stackoverflow.com/users/33944", "pm_score": 3, "selected": false, "text": "<p>there are 600 million ticks per minute.\n<a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.timespan.tickspe...
2008/12/22
[ "https://Stackoverflow.com/questions/386341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a ticks value of 28000000000 which should be 480 minutes but how can I be sure? How do I convert a ticks value to minutes?
``` TimeSpan.FromTicks(28000000000).TotalMinutes; ```