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
192,641
<p>I recently wrote a DLL in C# (.Net 2.0) which contains a class that requires an IP address. A co-worker of mine altered the class to retrieve the IP from a ".dll.config" (XML) file -- This apparently is automatically generated by the "Application Settings" file he created (Settings1.settings). The benefit of this wa...
[ { "answer_id": 192673, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": "https://Stackoverflow.com/users/31505", "pm_score": 1, "selected": false, "text": "<p>Apparently your application is trying to read from the default config file (which is probably the application's co...
2008/10/10
[ "https://Stackoverflow.com/questions/192641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21244/" ]
I recently wrote a DLL in C# (.Net 2.0) which contains a class that requires an IP address. A co-worker of mine altered the class to retrieve the IP from a ".dll.config" (XML) file -- This apparently is automatically generated by the "Application Settings" file he created (Settings1.settings). The benefit of this was t...
I'm addressing this exact issue in an application I'm in the midst of prototyping. Although Decker's suggestion of hacking the config files together should work I think this is a pretty inconvenient manual hack to perform as part of a build cycle. Instead of that I've decided that the cleanest solution is to just have ...
192,648
<p>OK, so I'm trying to teach myself the CakePHP framework, and I'm trying to knock up a simple demo app for myself.</p> <p>I have the controllers, views and models all set up and working, but I want to do something slightly more than the basic online help shows.</p> <p>I have a guitars_controller.php file as follows...
[ { "answer_id": 192657, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<pre><code>$this-&gt;pageTitle = $this-&gt;Guitar-&gt;Name;\n</code></pre>\n\n<p>It should go in the View though, I don't PH...
2008/10/10
[ "https://Stackoverflow.com/questions/192648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377/" ]
OK, so I'm trying to teach myself the CakePHP framework, and I'm trying to knock up a simple demo app for myself. I have the controllers, views and models all set up and working, but I want to do something slightly more than the basic online help shows. I have a guitars\_controller.php file as follows... ``` <?php c...
These actions are model agnostic so can be put in your app/app\_controller.php file ``` <?php class AppController extends Controller { function index() { $this->set(Inflector::variable($this->name), $this->{$this->modelClass}->findAll()); $this->pageTitle = 'All '.Inflector::humanize($this->name); ...
192,649
<p>Ruby can add methods to the Number class and other core types to get effects like this:</p> <pre class="lang-rb prettyprint-override"><code>1.should_equal(1) </code></pre> <p>But it seems like Python cannot do this. Is this true? And if so, why? Does it have something to do with the fact that <em>type</em> can't be ...
[ { "answer_id": 192651, "author": "sanxiyn", "author_id": 18382, "author_profile": "https://Stackoverflow.com/users/18382", "pm_score": 0, "selected": false, "text": "<p>No, you can't do that in Python. I consider it to be a good thing.</p>\n" }, { "answer_id": 192681, "author...
2008/10/10
[ "https://Stackoverflow.com/questions/192649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5304/" ]
Ruby can add methods to the Number class and other core types to get effects like this: ```rb 1.should_equal(1) ``` But it seems like Python cannot do this. Is this true? And if so, why? Does it have something to do with the fact that *type* can't be modified? *Rather than talking about different definitions of mon...
What exactly do you mean by Monkey Patch here? There are [several slightly different definitions](http://wikipedia.org/wiki/Monkey_patch). If you mean, "can you change a class's methods at runtime?", then the answer is emphatically yes: ``` class Foo: pass # dummy class Foo.bar = lambda self: 42 x = Foo() print x...
192,653
<p>I'm using .NET 3.5 and I have a class, A, marked as internal sealed partial and it derives from System.Configuration.ApplicationSettingsBase. I then use an instance of this class in the following manner:</p> <pre><code>A A_Instance = new A(); A_Instance.Default.Save(); </code></pre> <p>Why would the Visual C# comp...
[ { "answer_id": 192677, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 0, "selected": false, "text": "<p>ApplicationSettingsBase inherits from SettingsBase, neither of which expose a Default property. Judging by the compil...
2008/10/10
[ "https://Stackoverflow.com/questions/192653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2836/" ]
I'm using .NET 3.5 and I have a class, A, marked as internal sealed partial and it derives from System.Configuration.ApplicationSettingsBase. I then use an instance of this class in the following manner: ``` A A_Instance = new A(); A_Instance.Default.Save(); ``` Why would the Visual C# compiler be complaining: ``` ...
You are probably looking for this: ``` private static ServerSettings defaultInstance = ((ServerSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new ServerSettings()))); public static ServerSettings Default { get { return defaultInstance; } } ``` This is the code that gets generat...
192,678
<p>We are connecting to a WCF web service which has Anonomous Access turned off, Windows Authentication turned on. The web.config file has a local user account for allow users and deny users="?". </p> <p>I can download and generate the service proxy fine (being prompted for creds), however from my windows form proje...
[ { "answer_id": 194009, "author": "tomasr", "author_id": 10292, "author_profile": "https://Stackoverflow.com/users/10292", "pm_score": 1, "selected": false, "text": "<p>Looks like your service is asking for <em>basic</em> authentication; not windows integrated authentication. </p>\n\n<p>I...
2008/10/10
[ "https://Stackoverflow.com/questions/192678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We are connecting to a WCF web service which has Anonomous Access turned off, Windows Authentication turned on. The web.config file has a local user account for allow users and deny users="?". I can download and generate the service proxy fine (being prompted for creds), however from my windows form project (even whe...
Looks like your service is asking for *basic* authentication; not windows integrated authentication. In that case, I think you need to specify the credentials on the client proxy using in the ClientCredentials.UserName property and not ClientCredentials.Windows.
192,693
<p>I'm writing a routine that validates data before inserting it into a database, and one of the steps is to see if numeric values fit the precision and scale of a Numeric(x,y) SQL-Server type. </p> <p>I have the precision and scale from SQL-Server already, but what's the most efficient way in C# to get the precision ...
[ { "answer_id": 192750, "author": "HasaniH", "author_id": 7141, "author_profile": "https://Stackoverflow.com/users/7141", "pm_score": 0, "selected": false, "text": "<p>You can use decimal.Truncate(val) to get the integral part of the value and decimal.Remainder(val, 1) to get the part aft...
2008/10/10
[ "https://Stackoverflow.com/questions/192693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5548/" ]
I'm writing a routine that validates data before inserting it into a database, and one of the steps is to see if numeric values fit the precision and scale of a Numeric(x,y) SQL-Server type. I have the precision and scale from SQL-Server already, but what's the most efficient way in C# to get the precision and scale ...
``` System.Data.SqlTypes.SqlDecimal.ConvertToPrecScale( new SqlDecimal (1234.56789), 8, 2) ``` gives 1234.57. it will truncate extra digits after the decimal place, and will throw an error rather than try to truncate digits before the decimal place (i.e. ConvertToPrecScale(12344234, 5,2)
192,715
<p>Take this non-compiling code for instance:</p> <pre><code>public string GetPath(string basefolder, string[] extraFolders) { string version = Versioner.GetBuildAndDotNetVersions(); string callingModule = StackCrawler.GetCallingModuleName(); return AppendFolders(basefolder, version, callingModule, extraFo...
[ { "answer_id": 192726, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 1, "selected": false, "text": "<p>A quick and dirty solution would be to build a List&lt;string&gt; from the items and then pass that (with ToArray()...
2008/10/10
[ "https://Stackoverflow.com/questions/192715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9251/" ]
Take this non-compiling code for instance: ``` public string GetPath(string basefolder, string[] extraFolders) { string version = Versioner.GetBuildAndDotNetVersions(); string callingModule = StackCrawler.GetCallingModuleName(); return AppendFolders(basefolder, version, callingModule, extraFolders); } priv...
One option is to make the `params` parameter an `object[]`: ``` static string appendFolders(params object[] folders) { return (string) folders.Aggregate("",(output, f) => Path.Combine( (string)output ,(f is string[]) ? ...
192,718
<p>I need to run a JNDI provider without the overhead of a J2EE container. I've tried to follow the directions in this <a href="http://www.javaworld.com/javaworld/jw-04-2002/jw-0419-jndi.html" rel="noreferrer">article</a>, which describes (on page 3) exactly what I want to do. Unfortunately, these directions fail. I...
[ { "answer_id": 192727, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 1, "selected": false, "text": "<p>The JBoss JMQ can also be run with just the MicroKernel and a very minimal set of libraries. The JBoss AS installe...
2008/10/10
[ "https://Stackoverflow.com/questions/192718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13816/" ]
I need to run a JNDI provider without the overhead of a J2EE container. I've tried to follow the directions in this [article](http://www.javaworld.com/javaworld/jw-04-2002/jw-0419-jndi.html), which describes (on page 3) exactly what I want to do. Unfortunately, these directions fail. I had to add the jboss-common.jar t...
[Apache ActiveMQ](http://activemq.apache.org/) already comes with an integrated lightweight JNDI provider. See [these instructions on using it](http://activemq.apache.org/jndi-support.html). Basically you just add the jndi.properties file to the classpath and you're done. ``` java.naming.factory.initial = org.apache...
192,721
<p>In <a href="https://stackoverflow.com/users/23233/mmalc">@mmalc's</a> <a href="https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa#156288">response</a> to <a href="https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writi...
[ { "answer_id": 192852, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 5, "selected": false, "text": "<p>It's basically a guideline to minimize the potential for bugs.</p>\n\n<p>In this case there is the (possibility) tha...
2008/10/10
[ "https://Stackoverflow.com/questions/192721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23113/" ]
In [@mmalc's](https://stackoverflow.com/users/23233/mmalc) [response](https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa#156288) to [this question](https://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and...
It is all about using idiomatically consistent code. If you pattern all of your code appropriately there are sets of rules that guarantee that using an accessor in init/dealloc is safe. The big issue is that (as mmalc said) the code the sets up the properties default state should not go through an accessor because it ...
192,725
<p>I have just started learning Erlang and am trying out some Project Euler problems to get started. However, I seem to be able to do any operations on large sequences without crashing the erlang shell.</p> <p>Ie.,even this:</p> <pre><code>list:seq(1,64000000). </code></pre> <p>crashes erlang, with the error:</p> ...
[ { "answer_id": 192771, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 2, "selected": false, "text": "<p>Possibly a noob answer (I'm a Java dev), but the JVM artificially limits the amount of memory to help detect memory lea...
2008/10/10
[ "https://Stackoverflow.com/questions/192725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
I have just started learning Erlang and am trying out some Project Euler problems to get started. However, I seem to be able to do any operations on large sequences without crashing the erlang shell. Ie.,even this: ``` list:seq(1,64000000). ``` crashes erlang, with the error: eheap\_alloc: Cannot allocate 46707856...
Your OS may have a default limit on the size of a user process. On Linux you can change this with ulimit. You probably want to iterate over these 64000000 numbers without needing them all in memory at once. Lazy lists let you write code similar in style to the list-all-at-once code: ``` -module(lazy). -export([seq/2]...
192,736
<p>A word of warning: I'm a n00b to <code>git</code> in general. My team uses feature branches in <code>svn</code>, and I'd like to use <code>git-svn</code> to track my work on a particular feature branch. I've been (roughly) following <a href="http://andy.delcambre.com/2008/03/04/git-svn-workflow.html" rel="noreferrer...
[ { "answer_id": 192763, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 1, "selected": false, "text": "<p>I use git-svn but I haven't used the features that interoperate with SVN branches. Having said that, I notice that the...
2008/10/10
[ "https://Stackoverflow.com/questions/192736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4203/" ]
A word of warning: I'm a n00b to `git` in general. My team uses feature branches in `svn`, and I'd like to use `git-svn` to track my work on a particular feature branch. I've been (roughly) following [Andy Delcambre's post](http://andy.delcambre.com/2008/03/04/git-svn-workflow.html) to set up my local `git` repo, but t...
Muchas gracias to Bart's Blog for this handy [reference for svn branches in git](http://www.jukie.net/~bart/blog/svn-branches-in-git). Apparently all I needed was to specify a remote branch when creating the `git` branch, e.g., ``` git checkout -b git-topic-branch-foo foo ``` where `foo` is the name of the remote b...
192,748
<p>I am working on a webpage in ASP.Net/C# that uses absolute positioning for a textbox, for several in fact. It was working just fine, until I added some more text boxes. That is, the existing text boxes still positioned correctly, but the new ones did not, despite the fact that I created new styles in the CSS for the...
[ { "answer_id": 192836, "author": "ljubomir", "author_id": 11506, "author_profile": "https://Stackoverflow.com/users/11506", "pm_score": 0, "selected": false, "text": "<p>It is difficult to explain problems like this if no actual code is provided, but my first guess would be that you're h...
2008/10/10
[ "https://Stackoverflow.com/questions/192748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26895/" ]
I am working on a webpage in ASP.Net/C# that uses absolute positioning for a textbox, for several in fact. It was working just fine, until I added some more text boxes. That is, the existing text boxes still positioned correctly, but the new ones did not, despite the fact that I created new styles in the CSS for them j...
If you have absolutely positioned elements that have a parent that is either absolutely or relatively positioned, they will position themselves relative to their container instead of the whole page. In other words, your elements might be positioning themselves from different origin points.
192,796
<p>Suppose I have an M-file that calculates, for exampleת <code>d=a+b+c</code> (The values on <code>a</code>, <code>b</code>, <code>c</code> were given earlier). </p> <p>What command should I use in order to produce an output M-file showing the result of this sum?</p>
[ { "answer_id": 192841, "author": "Scottie T", "author_id": 6688, "author_profile": "https://Stackoverflow.com/users/6688", "pm_score": 1, "selected": false, "text": "<pre><code>disp(num2str(d));\n</code></pre>\n" }, { "answer_id": 192859, "author": "Azim J", "author_id": ...
2008/10/10
[ "https://Stackoverflow.com/questions/192796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Suppose I have an M-file that calculates, for exampleת `d=a+b+c` (The values on `a`, `b`, `c` were given earlier). What command should I use in order to produce an output M-file showing the result of this sum?
In Matlab a semicolon ";" at the end of a line suppresses output. So, ``` >> d=1+2; >> d=1+2 d = 3 ``` Or you can use *disp* as in the [first answer](https://stackoverflow.com/questions/192796/creating-output-m-file-in-matlab#192841). ``` >> disp(num2str(d)); 3 ``` If you want to write the values of a variab...
192,801
<p>Trivial data binding examples are just that, trivial. I want to do something a little more complicated and am wondering if there's an easy, built in way to handle it.</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); List&lt;DataStruct&gt; list = new List&lt;Dat...
[ { "answer_id": 192841, "author": "Scottie T", "author_id": 6688, "author_profile": "https://Stackoverflow.com/users/6688", "pm_score": 1, "selected": false, "text": "<pre><code>disp(num2str(d));\n</code></pre>\n" }, { "answer_id": 192859, "author": "Azim J", "author_id": ...
2008/10/10
[ "https://Stackoverflow.com/questions/192801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16979/" ]
Trivial data binding examples are just that, trivial. I want to do something a little more complicated and am wondering if there's an easy, built in way to handle it. ``` public partial class Form1 : Form { public Form1() { InitializeComponent(); List<DataStruct> list = new List<DataStruct>() { n...
In Matlab a semicolon ";" at the end of a line suppresses output. So, ``` >> d=1+2; >> d=1+2 d = 3 ``` Or you can use *disp* as in the [first answer](https://stackoverflow.com/questions/192796/creating-output-m-file-in-matlab#192841). ``` >> disp(num2str(d)); 3 ``` If you want to write the values of a variab...
192,824
<p>Can I ignore a folder on svn checkout? I need to ignore DOCs folder on checkout at my build server.</p> <p><strong>edit:</strong> Ignore externals isn't an option. I have some externals that I need.</p>
[ { "answer_id": 192830, "author": "Peter Parker", "author_id": 23264, "author_profile": "https://Stackoverflow.com/users/23264", "pm_score": 1, "selected": false, "text": "<p>No, ignore is only for adding files.<br>\nYou can use sparse checkouts (if you use svn 1.5)</p>\n" }, { "a...
2008/10/10
[ "https://Stackoverflow.com/questions/192824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20683/" ]
Can I ignore a folder on svn checkout? I need to ignore DOCs folder on checkout at my build server. **edit:** Ignore externals isn't an option. I have some externals that I need.
You can't directly ignore folders on a checkout, but you can use sparse checkouts in svn 1.5. For example: ``` $ svn co http://subversion/project/trunk my_checkout --depth immediates ``` This will check files and directories from your project trunk into 'my\_checkout', but not recurse into those directories. Eg: ``...
192,839
<p>Is it possible to get the machine name, or IP, or MAC address (basically client network information) from javascript running Internet Explorer?</p> <p>I found the following code that seems to accomplish this:</p> <pre><code>function Button1_onclick() { var locator = new ActiveXObject("WbemScripting.SWbemLocator"...
[ { "answer_id": 193088, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 0, "selected": false, "text": "<p>If a user is logged onto a Terminal Server and visits a page in Internet Explorer in that TS session, then Internet ...
2008/10/10
[ "https://Stackoverflow.com/questions/192839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1341/" ]
Is it possible to get the machine name, or IP, or MAC address (basically client network information) from javascript running Internet Explorer? I found the following code that seems to accomplish this: ``` function Button1_onclick() { var locator = new ActiveXObject("WbemScripting.SWbemLocator"); var service = lo...
Basically, there are two possibilities to get hold of the client name/address that come to mind: * Use MFCOM, namely the `MetaFrameSession` object. * Use WMI, the `MetaFrame_ICA_Client` class in `root\Citrix` looks promising. Mayor drawback of both solutions is, that they require more user permissions than you might ...
192,862
<p>I'm developing a webapp where the user is given the chance to upload his resume in pdf format. I'm using NHibernate as a data mapper and MS SQL SERVER 2005.</p> <p>I want to be able to save the .pdf file to a given table... any ideas?</p> <p>Thank you very much!</p>
[ { "answer_id": 192911, "author": "Joshua", "author_id": 14768, "author_profile": "https://Stackoverflow.com/users/14768", "pm_score": 0, "selected": false, "text": "<p>INSERT INTO Table (DocumentId, PDF)\nVALUES (newid(), 0x12345667)</p>\n\n<p>where the hex constant is the hex-encoded by...
2008/10/10
[ "https://Stackoverflow.com/questions/192862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
I'm developing a webapp where the user is given the chance to upload his resume in pdf format. I'm using NHibernate as a data mapper and MS SQL SERVER 2005. I want to be able to save the .pdf file to a given table... any ideas? Thank you very much!
We are doing exactly that with the "original" Java Hibernate3. You just map a byte array property of your persistable class to an column of Type "image". ``` package com.hibernate.pdf.sample; public class TPDFDocument implements java.io.Serializable { private Integer pdfDocumentId; private byte[] doc...
192,888
<p>I have some nested tables that I want to hide/show upon a click on one of the top-level rows.</p> <p>The markup is, in a nutshell, this:</p> <pre> &lt;table&gt; &lt;tr&gt; &lt;td&gt;stuff&lt;/td&gt; .... more tds here &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=some_number&gt; &lt...
[ { "answer_id": 192901, "author": "Mark Biek", "author_id": 305, "author_profile": "https://Stackoverflow.com/users/305", "pm_score": 1, "selected": false, "text": "<p>There are a bunch of bugs in IE related to modifying the contents of tables from Javascript. In a lot of cases, IE (incl...
2008/10/10
[ "https://Stackoverflow.com/questions/192888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22390/" ]
I have some nested tables that I want to hide/show upon a click on one of the top-level rows. The markup is, in a nutshell, this: ``` <table> <tr> <td>stuff</td> .... more tds here </tr> <tr> <td colspan=some_number> <table> </table> </td> </tr> </table> `...
Keep in mind that the innerHTML of a <table> element is *read-only* in IE(6 for sure, not sure about 7). That being the case, are you explicitly adding a <tbody> element? If not, try adding one and adding the rows to the body element rather than the table element. ``` <table> <tbody> <!-- Add stuff here... --> ...
192,892
<p>Has anyone implemented a very large EAV or open schema style database in SQL Server? I'm wondering if there are performance issues with this and how you were able to overcome those obstacles.</p>
[ { "answer_id": 194490, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I'm not an expert on EAV, but several more experienced developers than I have commented that Magento's open-source e-commer...
2008/10/10
[ "https://Stackoverflow.com/questions/192892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4541/" ]
Has anyone implemented a very large EAV or open schema style database in SQL Server? I'm wondering if there are performance issues with this and how you were able to overcome those obstacles.
Regardless of MS SQL Server versus any other brand of database, the worst performance issue with EAV is that people try to do monster queries to reconstruct an entity on a single row. *This requires a separate join per attribute*. ``` SELECT e.id, a1.attr_value as "cost", a2.attr_value as "color", a3.attr_value as "...
192,900
<p>Is it possible to set the cursor to 'wait' on the entire html page in a simple way? The idea is to show the user that something is going on while an ajax call is being completed. The code below shows a simplified version of what I tried and also demonstrate the problems I run into:</p> <ol> <li>if an element (#id1)...
[ { "answer_id": 192917, "author": "unexist", "author_id": 18179, "author_profile": "https://Stackoverflow.com/users/18179", "pm_score": 2, "selected": false, "text": "<p>Why don't you just use one of those fancy loading graphics (eg: <a href=\"http://ajaxload.info/\" rel=\"nofollow norefe...
2008/10/10
[ "https://Stackoverflow.com/questions/192900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20417/" ]
Is it possible to set the cursor to 'wait' on the entire html page in a simple way? The idea is to show the user that something is going on while an ajax call is being completed. The code below shows a simplified version of what I tried and also demonstrate the problems I run into: 1. if an element (#id1) has a cursor...
I understand you may not have control over this, but you might instead go for a "masking" div that covers the entire body with a z-index higher than 1. The center part of the div could contain a loading message if you like. Then, you can set the cursor to wait on the div and don't have to worry about links as they are...
192,907
<p>Python has several ways to parse XML...</p> <p>I understand the very basics of parsing with <strong>SAX</strong>. It functions as a stream parser, with an event-driven API.</p> <p>I understand the <strong>DOM</strong> parser also. It reads the XML into memory and converts it to objects that can be accessed with ...
[ { "answer_id": 192913, "author": "sanxiyn", "author_id": 18382, "author_profile": "https://Stackoverflow.com/users/18382", "pm_score": 3, "selected": false, "text": "<p>ElementTree's parse() is like DOM, whereas iterparse() is like SAX. In my opinion, ElementTree is better than DOM and S...
2008/10/10
[ "https://Stackoverflow.com/questions/192907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
Python has several ways to parse XML... I understand the very basics of parsing with **SAX**. It functions as a stream parser, with an event-driven API. I understand the **DOM** parser also. It reads the XML into memory and converts it to objects that can be accessed with Python. Generally speaking, it was easy to c...
ElementTree is much easier to use, because it represents an XML tree (basically) as a structure of lists, and attributes are represented as dictionaries. ElementTree needs much less memory for XML trees than DOM (and thus is faster), and the parsing overhead via `iterparse` is comparable to SAX. Additionally, `iterpar...
192,915
<p>Within my Subversion project I have a few directories that contain other open source projects that my code needs. For example ffmpeg, freetype, matrixssl and a few others. </p> <p>What is the best way to update SVN to hold the the latest version of one of these projects?</p> <p>Essentially I will be doing the foll...
[ { "answer_id": 192925, "author": "Dandikas", "author_id": 23436, "author_profile": "https://Stackoverflow.com/users/23436", "pm_score": 1, "selected": false, "text": "<p>All is correct except that you don't need steps 1 and 5 - if step 3 fails revert changes using svn revert functionalit...
2008/10/10
[ "https://Stackoverflow.com/questions/192915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
Within my Subversion project I have a few directories that contain other open source projects that my code needs. For example ffmpeg, freetype, matrixssl and a few others. What is the best way to update SVN to hold the the latest version of one of these projects? Essentially I will be doing the following (using ffmp...
You can take a look to svnbook talking about [vendor branches](http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.advanced.vendorbr). This is exactly what you try to accomplish You can use **svn\_load\_dirs.pl** to replace your manual steps 1-5. svn\_load\_dirs.pl will also keep track of new, moved or deleted files.
192,924
<p>Can you get the distinct combination of 2 different fields in a database table? if so, can you provide the SQL example.</p>
[ { "answer_id": 192933, "author": "Howard Pinsley", "author_id": 7961, "author_profile": "https://Stackoverflow.com/users/7961", "pm_score": 8, "selected": true, "text": "<p>How about simply:</p>\n\n<pre><code>select distinct c1, c2 from t\n</code></pre>\n\n<p>or</p>\n\n<pre><code>select ...
2008/10/10
[ "https://Stackoverflow.com/questions/192924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
Can you get the distinct combination of 2 different fields in a database table? if so, can you provide the SQL example.
How about simply: ``` select distinct c1, c2 from t ``` or ``` select c1, c2, count(*) from t group by c1, c2 ```
192,980
<p>I've recently created these two (unrelated) methods to replace lots of boiler-plate code in my winforms application. As far as I can tell, they work ok, but I need some reassurance/advice on whether there are some problems I might be missing.</p> <p>(from memory)</p> <pre><code>static class SafeInvoker { //Uti...
[ { "answer_id": 193012, "author": "eulerfx", "author_id": 13855, "author_profile": "https://Stackoverflow.com/users/13855", "pm_score": 0, "selected": false, "text": "<p>Similar patterns have worked for me with no problems. I am not sure why you are wrapping Action in MethodInvoker though...
2008/10/10
[ "https://Stackoverflow.com/questions/192980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
I've recently created these two (unrelated) methods to replace lots of boiler-plate code in my winforms application. As far as I can tell, they work ok, but I need some reassurance/advice on whether there are some problems I might be missing. (from memory) ``` static class SafeInvoker { //Utility to avoid boiler-...
This is good stuff. Make them extension methods though to clean up your code a little more. For example: ``` //Replaces OnMyEventRaised boiler-plate code //Usage: SafeInvoker.RaiseEvent(this, MyEventRaised) public static void Raise(this EventHandler eventToRaise, object sender) { EventHandler eventHandler ...
192,997
<p>I have a Windows forms project and a Web Service project in my solution, and I'm trying to call the web service and return a customer object as the result. The problem is that when I try to receive the return object, I get an error that it can't convert it. For example, here is the signature for my webservice:</p> ...
[ { "answer_id": 193018, "author": "hangy", "author_id": 11963, "author_profile": "https://Stackoverflow.com/users/11963", "pm_score": 0, "selected": false, "text": "<p>The web service reference in a VB.NET or C# project can reference <em>any</em> type of web service and is not limited to ...
2008/10/10
[ "https://Stackoverflow.com/questions/192997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8114/" ]
I have a Windows forms project and a Web Service project in my solution, and I'm trying to call the web service and return a customer object as the result. The problem is that when I try to receive the return object, I get an error that it can't convert it. For example, here is the signature for my webservice: ``` Pub...
This is actually pretty common. What's happening is that the Web Service has defined in it the definitions of all the types used in the web service. When you add a reference to that web service, it auto-generates a proxy type in a sub namespace of your namespace. That is what is being returned by your web service when ...
192,998
<p>I have some custom SharePoint site definitions that are deployed via SharePoint wsp solution packages. They appear to work fine. I can deploy them fine via the stsadm command line, and my C# code running in some features can also deploy sites based on them. My <code>webtemp.*.xml</code> files appear to be correc...
[ { "answer_id": 193022, "author": "MrChrister", "author_id": 24229, "author_profile": "https://Stackoverflow.com/users/24229", "pm_score": 0, "selected": false, "text": "<p>Do you have the publishing feature enabled? I read that content types can't be saved in templates, so they don't al...
2008/10/10
[ "https://Stackoverflow.com/questions/192998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/404/" ]
I have some custom SharePoint site definitions that are deployed via SharePoint wsp solution packages. They appear to work fine. I can deploy them fine via the stsadm command line, and my C# code running in some features can also deploy sites based on them. My `webtemp.*.xml` files appear to be correctly placed in the ...
Many tasks in SharePoint are queued and then executed via timer job. An IISReset causes the web applicationt to be reloaded into memory and for configuration information for example the web.config to be reloaded. To give SharePoint a "nudge" and cause jobs to execute you might try: ``` stsadm -o execadmsvcjobs ```
193,020
<p>If I define a constant in a Perl module, how do I use that constant in my main program? (Or how do I call that constant in the main program?)</p>
[ { "answer_id": 193031, "author": "friedo", "author_id": 20745, "author_profile": "https://Stackoverflow.com/users/20745", "pm_score": 6, "selected": false, "text": "<p>Constants can be exported just like other package symbols. Using the standard <a href=\"http://search.cpan.org/~ferreira...
2008/10/10
[ "https://Stackoverflow.com/questions/193020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26964/" ]
If I define a constant in a Perl module, how do I use that constant in my main program? (Or how do I call that constant in the main program?)
Constants can be exported just like other package symbols. Using the standard [Exporter](http://search.cpan.org/~ferreira/Exporter-5.63/lib/Exporter.pm) module, you can export constants from a package like this: ``` package Foo; use strict; use warnings; use base 'Exporter'; use constant CONST => 42; our @EXPORT_OK...
193,044
<p>Languages like C and even C# (which technically doesn't have a preprocessor) allow you to write code like:</p> <pre><code>#DEFINE DEBUG ... string returnedStr = this.SomeFoo(); #if DEBUG Debug.WriteLine("returned string =" + returnedStr); #endif </code></pre> <p>This is something I like to use in my code as a...
[ { "answer_id": 193072, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<p>PHP doesn't have anything like this. but you could definitely whip up something quickly (and perhaps a regex parse to strip i...
2008/10/10
[ "https://Stackoverflow.com/questions/193044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
Languages like C and even C# (which technically doesn't have a preprocessor) allow you to write code like: ``` #DEFINE DEBUG ... string returnedStr = this.SomeFoo(); #if DEBUG Debug.WriteLine("returned string =" + returnedStr); #endif ``` This is something I like to use in my code as a form of scaffolding, and ...
PHP doesn't have anything like this. but you could definitely whip up something quickly (and perhaps a regex parse to strip it out later if you wanted). i'd do it as such: ``` define('DEBUG', true); ... if (DEBUG): $debug->writeLine("stuff"); endif; ``` of course you'd have to write your own debug module to handle...
193,092
<p>I am just starting to fiddle with Excel via C# to be able to automate the creation, and addition to an Excel file.</p> <p>I can open the file and update its data and move through the existing worksheets. My problem is how can I add new sheets?</p> <p>I tried:</p> <pre><code>Excel.Worksheet newWorksheet; newWorksh...
[ { "answer_id": 193323, "author": "AR.", "author_id": 1354, "author_profile": "https://Stackoverflow.com/users/1354", "pm_score": 6, "selected": true, "text": "<p>You need to add a COM reference in your project to the <strong>\"<code>Microsoft Excel 11.0 Object Library</code>\"</strong> -...
2008/10/10
[ "https://Stackoverflow.com/questions/193092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6486/" ]
I am just starting to fiddle with Excel via C# to be able to automate the creation, and addition to an Excel file. I can open the file and update its data and move through the existing worksheets. My problem is how can I add new sheets? I tried: ``` Excel.Worksheet newWorksheet; newWorksheet = (Excel.Worksheet)excel...
You need to add a COM reference in your project to the **"`Microsoft Excel 11.0 Object Library`"** - or whatever version is appropriate. This code works for me: ``` private void AddWorksheetToExcelWorkbook(string fullFilename,string worksheetName) { Microsoft.Office.Interop.Excel.Application xlApp = null; Wor...
193,096
<p>Why is an exception being thrown in the "f++" part of the code below ("IndexOutOfRangeException was unhandled by user code"):</p> <pre><code>for (int f = 0; f &lt; gnf; f++) { fieldNames[g] = grid.FieldName(f); } </code></pre> <p>The bug is in the "fieldNames[g] = ..." part of the code, my algorithm sh...
[ { "answer_id": 193103, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ey1cdcx8.aspx\" rel=\"nofollow noreferrer\">http://msdn.microsoft.com/e...
2008/10/10
[ "https://Stackoverflow.com/questions/193096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2543/" ]
Why is an exception being thrown in the "f++" part of the code below ("IndexOutOfRangeException was unhandled by user code"): ``` for (int f = 0; f < gnf; f++) { fieldNames[g] = grid.FieldName(f); } ``` The bug is in the "fieldNames[g] = ..." part of the code, my algorithm should be: ``` for (int f = 0;...
<http://msdn.microsoft.com/en-us/library/ey1cdcx8.aspx> You need to use the overloaded DateTime.Parse to accurately parse timezones.
193,107
<p>I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as</p> <pre><code>PRINT 'Querying Table1'; SELECT * from Table1; </code></pre> <p>What do I use to Print / show text output? It's not Print, because that gives me the error: Bind Variable <c...
[ { "answer_id": 193158, "author": "Eddie Awad", "author_id": 17273, "author_profile": "https://Stackoverflow.com/users/17273", "pm_score": 4, "selected": false, "text": "<p>You could <a href=\"http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12040.htm#SQPUG075\" rel=\"nore...
2008/10/10
[ "https://Stackoverflow.com/questions/193107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22523/" ]
I am using Oracle SQL (in SQLDeveloper, using the SQL Worksheet). I would like to print a statement before my select, such as ``` PRINT 'Querying Table1'; SELECT * from Table1; ``` What do I use to Print / show text output? It's not Print, because that gives me the error: Bind Variable `Table1` is NOT DECLARED. DBMS...
![enter image description here](https://i.stack.imgur.com/72MPn.png) for simple comments: ``` set serveroutput on format wrapped; begin DBMS_OUTPUT.put_line('simple comment'); end; / -- do something begin DBMS_OUTPUT.put_line('second simple comment'); end; / ``` you should get: ``` anonymous block comple...
193,119
<p>I need to have my iPhone Objective-C code catch Javascript errors in a UIWebView. That includes uncaught exceptions, syntax errors when loading files, undefined variable references, etc.</p> <p>This is for a development environment, so it doesn't need to be SDK-kosher. In fact, it only really needs to work on the...
[ { "answer_id": 193212, "author": "kdbdallas", "author_id": 26728, "author_profile": "https://Stackoverflow.com/users/26728", "pm_score": 0, "selected": false, "text": "<p>I have done this in firmware 1.x but not 2.x.\nHere is the code I used in 1.x, it should at least help you on your wa...
2008/10/10
[ "https://Stackoverflow.com/questions/193119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16952/" ]
I need to have my iPhone Objective-C code catch Javascript errors in a UIWebView. That includes uncaught exceptions, syntax errors when loading files, undefined variable references, etc. This is for a development environment, so it doesn't need to be SDK-kosher. In fact, it only really needs to work on the simulator. ...
I have now found one way using the script debugger hooks in WebView (note, NOT UIWebView). I first had to subclass UIWebView and add a method like this: ``` - (void)webView:(id)webView windowScriptObjectAvailable:(id)newWindowScriptObject { // save these goodies windowScriptObject = newWindowScriptObject; ...
193,124
<p>I have an ASPX page that creates an XMLDocument object from SQL data and then transforms it into another XML document (RSS feed) using an XSLT file with XPathNavigator and XslCompiledTransform. Occasionally the data will contain smart quotes (\u2019) which results in an error (Unable to translate Unicode character ...
[ { "answer_id": 193886, "author": "AmbroseChapel", "author_id": 242241, "author_profile": "https://Stackoverflow.com/users/242241", "pm_score": 0, "selected": false, "text": "<p>What's the document encoding of the input XML your XSL is working on? You should be able to set that, then the ...
2008/10/10
[ "https://Stackoverflow.com/questions/193124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an ASPX page that creates an XMLDocument object from SQL data and then transforms it into another XML document (RSS feed) using an XSLT file with XPathNavigator and XslCompiledTransform. Occasionally the data will contain smart quotes (\u2019) which results in an error (Unable to translate Unicode character \u20...
Your transform is working fine. The problem is that the transform is emitting a character that isn't supported by the content encoding of the output stream. Set the `ContentEncoding` on the `HttpResponse` to `Encoding.UTF16` and this problem should go away.
193,130
<p>I'd like to have a custom object attached to the application so I can preserve state in it between different html pages in adobe air. Is this possible?</p> <hr> <p>I was asking for a fullblown solution to store a custom js object in memory and persist it between pages loaded from the application sandbox, but this ...
[ { "answer_id": 193909, "author": "roenving", "author_id": 23142, "author_profile": "https://Stackoverflow.com/users/23142", "pm_score": 0, "selected": false, "text": "<p>What sort of object ?-)</p>\n\n<p>If it only holds values that are meaningful in a string, you could store it as a coo...
2008/10/10
[ "https://Stackoverflow.com/questions/193130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7883/" ]
I'd like to have a custom object attached to the application so I can preserve state in it between different html pages in adobe air. Is this possible? --- I was asking for a fullblown solution to store a custom js object in memory and persist it between pages loaded from the application sandbox, but this cannot be d...
Perhaps you could try attaching the object on the user's machine. There is a tutorial online that seems like it could help: <http://corlan.org/2008/09/02/storing-data-locally-in-air/> Example from the site: ``` //write an Object to a file private function writeObject():void { var object:Object = new Object();//c...
193,143
<p>I'm using MSTEST inside Visual Studio 2008. How can I have each unit test method in a certain test class act as if it were the first test to run so that all global state is reset before running each test? I do not want to explicitly clean up the world using TestInitialize, ClassInitialize, AssemblyInitialize, etc. F...
[ { "answer_id": 197910, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>We had a similar issue arise with our MSTests. We handled it by calling a function at the beginning and end of the specifi...
2008/10/10
[ "https://Stackoverflow.com/questions/193143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1869/" ]
I'm using MSTEST inside Visual Studio 2008. How can I have each unit test method in a certain test class act as if it were the first test to run so that all global state is reset before running each test? I do not want to explicitly clean up the world using TestInitialize, ClassInitialize, AssemblyInitialize, etc. For ...
In the end, I wrote a helper that used [AppDomain.CreateDomain](http://msdn.microsoft.com/en-us/library/system.appdomain.createdomain.aspx) and then used reflection to call the unit test under a different AppDomain. It provides the isolation I needed. [This post](http://social.msdn.microsoft.com/Forums/en-US/vststest/...
193,151
<p>So the question is how to distribute/offload the media files from Wordpress posts across multiple domains. </p> <p>The reasoning being to overcome this limitation: "Most browser will only make 2 simultaneous requests to a server, so if you page requires 16 files they will be requested 2 at a time."</p> <p>In relat...
[ { "answer_id": 193207, "author": "Osama Al-Maadeed", "author_id": 25544, "author_profile": "https://Stackoverflow.com/users/25544", "pm_score": 0, "selected": false, "text": "<p>The question is a bit ambiguous, I'm not sure but maybe if the domains are on the same server you could replac...
2008/10/10
[ "https://Stackoverflow.com/questions/193151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
So the question is how to distribute/offload the media files from Wordpress posts across multiple domains. The reasoning being to overcome this limitation: "Most browser will only make 2 simultaneous requests to a server, so if you page requires 16 files they will be requested 2 at a time." In relation to: <http://c...
You just need to edit the URL's to the various media files throughout your WordPress theme. For example, edit you "header.php" to change the css file to an alternate domain. Change This: ``` print("<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />"); ``` To someth...
193,154
<p>I am getting the following error when I try to call a stored procedure that contains a SELECT Statement:</p> <blockquote> <p>The operation is not valid for the state of the transaction</p> </blockquote> <p>Here is the structure of my calls:</p> <pre><code>public void MyAddUpdateMethod() { using (Transactio...
[ { "answer_id": 193167, "author": "Wyatt", "author_id": 26626, "author_profile": "https://Stackoverflow.com/users/26626", "pm_score": 3, "selected": false, "text": "<p>I've encountered this error when my Transaction is nested within another. Is it possible that the stored procedure declar...
2008/10/10
[ "https://Stackoverflow.com/questions/193154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
I am getting the following error when I try to call a stored procedure that contains a SELECT Statement: > > The operation is not valid for the state of the transaction > > > Here is the structure of my calls: ``` public void MyAddUpdateMethod() { using (TransactionScope Scope = new TransactionScope(Transac...
After doing some research, it seems I cannot have two connections opened to the same database with the TransactionScope block. I needed to modify my code to look like this: ``` public void MyAddUpdateMethod() { using (TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew)) { ...
193,155
<p>SQL Server (2005/2008)</p> <p>Each of the below statements have the same result. Does anyone know if one outperforms the other?</p> <pre><code>insert into SOMETABLE values ('FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000') insert into SOMETABLE select 'FieldOneValue','FieldTwoValue',3,4.55,'...
[ { "answer_id": 193164, "author": "Aaron Smith", "author_id": 12969, "author_profile": "https://Stackoverflow.com/users/12969", "pm_score": 0, "selected": false, "text": "<p>It looks like you're just mimicking</p>\n\n<pre><code>INSERT into SOMETABLE\n(\nSELECT * FROM SOMEOTHERTABLE\n)\n</...
2008/10/10
[ "https://Stackoverflow.com/questions/193155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7870/" ]
SQL Server (2005/2008) Each of the below statements have the same result. Does anyone know if one outperforms the other? ``` insert into SOMETABLE values ('FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000') insert into SOMETABLE select 'FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.0...
I just tested this. 5 million iterations of both approaches on two sets of hardware, one a server with 16GB RAM, one a notebook with 1GB. Result: They appear to be the same. The query plans for these are the same, and the performance differential is statistically insignificant.
193,185
<p>I've got a little problem that's slightly frustrating. Is it possible to set a default value when deserializing xml in C# (.NET 3.5)? Basically I'm trying to deserialize some xml that is not under my control and one element looks like this:</p> <pre><code>&lt;assignee-id type="integer"&gt;38628&lt;/assignee-id&gt; ...
[ { "answer_id": 193195, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>XmlSerializer uses xsi:nil - so I expect you'd need to do custom IXmlSerializable serialization for this. Sorry.</...
2008/10/10
[ "https://Stackoverflow.com/questions/193185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15726/" ]
I've got a little problem that's slightly frustrating. Is it possible to set a default value when deserializing xml in C# (.NET 3.5)? Basically I'm trying to deserialize some xml that is not under my control and one element looks like this: ``` <assignee-id type="integer">38628</assignee-id> ``` it can also look lik...
It looks like your source XML is using xsi:type and xsi:nil, but not prefixing them with a namespace. What you could do is process these with XSLT to turn this: ``` <assignees> <assignee> <assignee-id type="integer">123456</assignee-id> </assignee> <assignee> <assignee-id type="integer" nil="true"></ass...
193,215
<p>I'm sorting out a series of SQL scripts for my company written in Oracle PL/SQL. I came across an essential script with a strangely placed slash near the bottom. It is checked into CVS this way. Is this a pure syntax error or does it have some function I'm not aware of. The slightly obfuscated script:</p> <pre>...
[ { "answer_id": 193223, "author": "Eric", "author_id": 6367, "author_profile": "https://Stackoverflow.com/users/6367", "pm_score": 3, "selected": false, "text": "<p>the / at the end is to tell the interpreter to execute the loaded script</p>\n\n<p>basicaly you type stuff then type \"/\" a...
2008/10/10
[ "https://Stackoverflow.com/questions/193215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22452/" ]
I'm sorting out a series of SQL scripts for my company written in Oracle PL/SQL. I came across an essential script with a strangely placed slash near the bottom. It is checked into CVS this way. Is this a pure syntax error or does it have some function I'm not aware of. The slightly obfuscated script: ``` set serverou...
The slash has [a meaning](http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch12004.htm#SQPUG162): > > Executes the most recently executed > SQL command or PL/SQL block which is > stored in the SQL buffer. You can > enter a slash (/) at the command > prompt or at a line number prompt of a > multi-li...
193,257
<p>Assuming a Read Committed Snapshot transaction isolation setting, is the following statement "atomic" in the sense that you won't ever "lose" a concurrent increment?</p> <pre><code>update mytable set counter = counter + 1 </code></pre> <p>I would assume that in the general case, where this update statement is part...
[ { "answer_id": 193265, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 2, "selected": false, "text": "<p>No, it's not. The value is read in shared mode and then updated in exclusive mode, so multiple reads can occur.</p>\n\n<p...
2008/10/10
[ "https://Stackoverflow.com/questions/193257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26651/" ]
Assuming a Read Committed Snapshot transaction isolation setting, is the following statement "atomic" in the sense that you won't ever "lose" a concurrent increment? ``` update mytable set counter = counter + 1 ``` I would assume that in the general case, where this update statement is part of a larger transaction, ...
Read Committed Snapshot only deals with locks on selecting data from tables. In t1 and t2 however, you're UPDATEing the data, which is a different scenario. When you UPDATE the counter you escalate to a write lock (on the row), preventing the other update from occurring. t2 could read, but t2 will block on its UPDATE...
193,260
<p>We're currently running an <code>svnserve</code> instance as NT service. While this works, it's needlessly cumbersome to administer, and I'd like to move on to the much simpler VisualSVN Server. (Bonus side benefits include Windows-integrated authentication and, thanks to HTTP/WebDAV, browsing of the latest revision...
[ { "answer_id": 193265, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 2, "selected": false, "text": "<p>No, it's not. The value is read in shared mode and then updated in exclusive mode, so multiple reads can occur.</p>\n\n<p...
2008/10/10
[ "https://Stackoverflow.com/questions/193260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1600/" ]
We're currently running an `svnserve` instance as NT service. While this works, it's needlessly cumbersome to administer, and I'd like to move on to the much simpler VisualSVN Server. (Bonus side benefits include Windows-integrated authentication and, thanks to HTTP/WebDAV, browsing of the latest revision.) That said,...
Read Committed Snapshot only deals with locks on selecting data from tables. In t1 and t2 however, you're UPDATEing the data, which is a different scenario. When you UPDATE the counter you escalate to a write lock (on the row), preventing the other update from occurring. t2 could read, but t2 will block on its UPDATE...
193,288
<p>Most of Apples documentation seems to avoid using autoreleased objects especially when creating gui views, but I want to know what the cost of using autoreleased objects is?</p> <pre><code>UIScrollView *timeline = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 34)]; [self addSubview:timeline]; [timeline...
[ { "answer_id": 193377, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 2, "selected": false, "text": "<p>As I understand it, the main downside to using autorelease is that you don't know when the object will finally be released a...
2008/10/10
[ "https://Stackoverflow.com/questions/193288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26986/" ]
Most of Apples documentation seems to avoid using autoreleased objects especially when creating gui views, but I want to know what the cost of using autoreleased objects is? ``` UIScrollView *timeline = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 20, 320, 34)]; [self addSubview:timeline]; [timeline release]; ``...
There are two costs: 1. (Assuming you have an option to avoid autoreleased objects.) You effectively unnecessarily extend the lifetime of your objects. This can mean that your memory footprint grows -- unnecessarily. On a constrained platform, this can mean that your application is terminated if it exceeds a limit. Ev...
193,341
<p>I have a Trac project installed on top of a Subversion implementation (easy to do thanks to Webfaction's control panel), but now I have configuration work to do. With that in mind, are there <em>easy</em> ways to do the following in Trac:</p> <p>1) Ensure that customers can only see a high level progress indicator...
[ { "answer_id": 193445, "author": "Dave Dunkin", "author_id": 453303, "author_profile": "https://Stackoverflow.com/users/453303", "pm_score": 4, "selected": false, "text": "<p>I would not recommend using the same Trac project for tracking development tasks and showing the customer progres...
2008/10/10
[ "https://Stackoverflow.com/questions/193341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13990/" ]
I have a Trac project installed on top of a Subversion implementation (easy to do thanks to Webfaction's control panel), but now I have configuration work to do. With that in mind, are there *easy* ways to do the following in Trac: 1) Ensure that customers can only see a high level progress indicator. 2) Give daily...
**1) high level progress indicator:** The roadmap tab gives you kind of a high level progress indicator. It lists all milestones, and for each milestone it shows you: * milestone title * short description * date on which the milestone is due * how much time is left until then (or how long you are behind you schedule)...
193,351
<p>Is it possible to break at runtime when a particular file has been modified? </p> <p>ie. monitor the file and break into a debugger once a change has been made to it.</p> <p>This is for a windows app...is this possible in visual studio or windbg?</p> <p>edit: i should have mentioned that this is for a Win32 app...
[ { "answer_id": 193360, "author": "MusiGenesis", "author_id": 14606, "author_profile": "https://Stackoverflow.com/users/14606", "pm_score": 0, "selected": false, "text": "<p>Assuming this is .NET, the System.IO.<strong>FileSystemWatcher</strong> class is what you need.</p>\n\n<pre><code>F...
2008/10/10
[ "https://Stackoverflow.com/questions/193351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19263/" ]
Is it possible to break at runtime when a particular file has been modified? ie. monitor the file and break into a debugger once a change has been made to it. This is for a windows app...is this possible in visual studio or windbg? edit: i should have mentioned that this is for a Win32 app..
you can use the System.IO.FileSystemWatcher class. ``` FileSystemWatcher watcher = = new FileSystemWatcher(); watcher.Filter = @"myFile.ini"; watcher.Changed += new FileSystemEventHandler(watcher_Changed); ``` and then you implement the delegate of type FileSystemEventHandler: ``` static void watcher_Changed(object...
193,398
<p>Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum integer size of 18446744073709551615). Realistically, I would like to be able to do this by breaking up each number, processing them somehow us...
[ { "answer_id": 193411, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 2, "selected": false, "text": "<p>Yes, you do it using a datatype that is effectively a string of digits (just like a normal 'string' is a string of char...
2008/10/10
[ "https://Stackoverflow.com/questions/193398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14322/" ]
Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum integer size of 18446744073709551615). Realistically, I would like to be able to do this by breaking up each number, processing them somehow using...
Most languages have functions or libraries that do this, usually called a Bignum library ([GMP](http://gmplib.org/) is a good one.) If you want to do it yourself, I would do it the same way that people do long multiplication on paper. To do this you could either work with strings containing the number, or do it in bin...
193,440
<pre><code>func() { Object* pNext; func1(pNext); } func1(Object* pNext) { pNext = Segement-&gt;GetFirstPara(0); } </code></pre> <p>I was expecting it to be pointer to firstpara returned from func1() but I'm seeing NULL can some explain and how to fix it to actually return the firstpara() pointer?</p>
[ { "answer_id": 193450, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "<p>To change a pointer, you need to pass a pointer to the pointer, ie <code>Object** pNext</code>. To change the ...
2008/10/11
[ "https://Stackoverflow.com/questions/193440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22535/" ]
``` func() { Object* pNext; func1(pNext); } func1(Object* pNext) { pNext = Segement->GetFirstPara(0); } ``` I was expecting it to be pointer to firstpara returned from func1() but I'm seeing NULL can some explain and how to fix it to actually return the firstpara() pointer?
For C++ only, you can make the parameter a reference ``` func() { Object* pNext; func1(pNext); } func1(Object*& pNext) { pNext = Segement->GetFirstPara(0); } ``` What is going on here is the difference between passing parameters by value and passing by reference. C always passes by value. In order to ge...
193,457
<p>I have subclassed <a href="https://docs.oracle.com/javase/9/docs/api/java/awt/Frame.html" rel="nofollow noreferrer"><code>java.awt.Frame</code></a> and have overridden the <a href="https://docs.oracle.com/javase/9/docs/api/java/awt/Window.html#paint-java.awt.Graphics-" rel="nofollow noreferrer"><code>paint()</code><...
[ { "answer_id": 193450, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "<p>To change a pointer, you need to pass a pointer to the pointer, ie <code>Object** pNext</code>. To change the ...
2008/10/11
[ "https://Stackoverflow.com/questions/193457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8779/" ]
I have subclassed [`java.awt.Frame`](https://docs.oracle.com/javase/9/docs/api/java/awt/Frame.html) and have overridden the [`paint()`](https://docs.oracle.com/javase/9/docs/api/java/awt/Window.html#paint-java.awt.Graphics-) method as I wish to draw the entire contents of the window manually. However, on the graphics ...
For C++ only, you can make the parameter a reference ``` func() { Object* pNext; func1(pNext); } func1(Object*& pNext) { pNext = Segement->GetFirstPara(0); } ``` What is going on here is the difference between passing parameters by value and passing by reference. C always passes by value. In order to ge...
193,471
<p>As I recall <code>BOOST_MPL_ASSERT</code> was once preferred. Is this still true? Anyone know why?</p>
[ { "answer_id": 193592, "author": "Head Geek", "author_id": 12193, "author_profile": "https://Stackoverflow.com/users/12193", "pm_score": 2, "selected": false, "text": "<p><code>BOOST_MPL_ASSERT</code> is (still) generally considered better. The messages from it are somewhat easier to see...
2008/10/11
[ "https://Stackoverflow.com/questions/193471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10559/" ]
As I recall `BOOST_MPL_ASSERT` was once preferred. Is this still true? Anyone know why?
*[Answering my own question]* It depends. This is an apples to oranges comparison. Although similar, these macros are NOT interchangeable. Here's a summary of how each works: `BOOST_STATIC_ASSERT( P )` generates a compilation error if `P != true`. `BOOST_MPL_ASSERT(( P ))` generates a compilation error if `P::type::...
193,474
<p>I want to create an ini file to store some settings for my application. Is it a good idea to find where the jar file is located and create an ini file there? If yes, then how can I find the location of the jar file? </p> <p>But if you know a better solution for something like this, I would like to hear some of them...
[ { "answer_id": 193479, "author": "BoltBait", "author_id": 20848, "author_profile": "https://Stackoverflow.com/users/20848", "pm_score": 1, "selected": false, "text": "<p>You should not be storing temp files in the install directory of an application. Remember, the user running the appli...
2008/10/11
[ "https://Stackoverflow.com/questions/193474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8418/" ]
I want to create an ini file to store some settings for my application. Is it a good idea to find where the jar file is located and create an ini file there? If yes, then how can I find the location of the jar file? But if you know a better solution for something like this, I would like to hear some of them. **EDIT*...
You can locate your application directory using the ClassLoader. See: [Java: finding the application directory](http://illegalargumentexception.blogspot.com/2008/04/java-finding-application-directory.html). Rather than an *.INI* file, use a *.properties* file - you can load and save this via the [Properties](http://jav...
193,483
<p>When using Maven to build an executable JAR, how do I specify the JVM arguments that are used when the JAR is executed?</p> <p>I can specify the main class using <code>&lt;mainClass&gt;</code>. I suspect there's a similar attribute for JVM arguments. Specially I need to specify the maximum memory (example -Xmx500m)...
[ { "answer_id": 195007, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 4, "selected": true, "text": "<p>I don't know of any such mechanism. The JVM configuration is specified by the calling java command. </p>\n\n<p>Here'...
2008/10/11
[ "https://Stackoverflow.com/questions/193483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
When using Maven to build an executable JAR, how do I specify the JVM arguments that are used when the JAR is executed? I can specify the main class using `<mainClass>`. I suspect there's a similar attribute for JVM arguments. Specially I need to specify the maximum memory (example -Xmx500m). Here's my assembly plugi...
I don't know of any such mechanism. The JVM configuration is specified by the calling java command. Here's the jar file specification which conspicuously doesn't mention any attribute other than Main-Class for stand-alone execution: <http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html>
193,488
<p>I've just started tinkering with XML manipulation with PHP, and i've stumbled into something unexpected. Here's the XML i'm using as a test input:</p> <pre><code>&lt;list&gt; &lt;activity1&gt; running &lt;/activity1&gt; &lt;activity2&gt; swimming &lt;/activity2&gt; &lt;activity3&gt; soccer &lt;/activity...
[ { "answer_id": 193506, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 1, "selected": false, "text": "<p>The first <em>node</em> is the text (in this case whitespace) between the opening list tag and activity1 tag, the next ...
2008/10/11
[ "https://Stackoverflow.com/questions/193488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've just started tinkering with XML manipulation with PHP, and i've stumbled into something unexpected. Here's the XML i'm using as a test input: ``` <list> <activity1> running </activity1> <activity2> swimming </activity2> <activity3> soccer </activity3> </list> ``` Now, i was expecting that this PHP c...
The first *node* is the text (in this case whitespace) between the opening list tag and activity1 tag, the next *node* is the activity1 *element*. elements are not the same as nodes.
193,499
<p>What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone?</p>
[ { "answer_id": 193516, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": false, "text": "<p><a href=\"http://us.php.net/manual/en/function.timezone-offset-get.php\" rel=\"noreferrer\"><code>timezone_offset_g...
2008/10/11
[ "https://Stackoverflow.com/questions/193499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79/" ]
What's the easiest way to get the UTC offset in PHP, relative to the current (system) timezone?
``` date('Z'); ``` returns the UTC offset in seconds.
193,514
<p>There is another recent Project Euler question but I think this is a bit more specific (I'm only really interested in PHP based solutions) so I'm asking anyway.</p> <p><a href="http://projecteuler.net/index.php?section=problems&amp;id=5" rel="nofollow noreferrer">Question #5</a> tasks you with: "What is the smalles...
[ { "answer_id": 193521, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": false, "text": "<p>Collect prime factors for all numbers between 1 and 20. Counting the maximal exponents of each prime factor, we have <cod...
2008/10/11
[ "https://Stackoverflow.com/questions/193514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11252/" ]
There is another recent Project Euler question but I think this is a bit more specific (I'm only really interested in PHP based solutions) so I'm asking anyway. [Question #5](http://projecteuler.net/index.php?section=problems&id=5) tasks you with: "What is the smallest number that is evenly divisible by all of the num...
in php it will look like this: ``` <?php function gcd($a,$b) { while($a>0 && $b>0) { if($a>$b) $a=$a-$b; else $b=$b-$a; } if($a==0) return $b; return $a; } function euler5($i=20) { $euler=$x=1; while($x++<$i) { $euler*=$x/gcd($euler,$x); } return $euler; } ?> `...
193,547
<p>I have stumbled into several methods of looping in JavaScript, what I like the most is:</p> <pre><code>for(var i = 0; i &lt; a.length; i++){ var element = a[i]; } </code></pre> <p>But as tested here (<a href="http://www.robertnyman.com/2008/04/11/javascript-loop-performance/" rel="noreferrer">http://www.robert...
[ { "answer_id": 193553, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 2, "selected": false, "text": "<p>You could just always use a while loop, and compute the array limit before hand.</p>\n\n<pre><code>Var max = a.length-1;\n...
2008/10/11
[ "https://Stackoverflow.com/questions/193547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13995/" ]
I have stumbled into several methods of looping in JavaScript, what I like the most is: ``` for(var i = 0; i < a.length; i++){ var element = a[i]; } ``` But as tested here (<http://www.robertnyman.com/2008/04/11/javascript-loop-performance/>), it should probably be written so that the length is only calculated o...
I've started using iterators where relevant. Performance is reasonable, however more importantly it allows you to encapsulate the looping logic: ``` function createIterator(x) { var i = 0; return function(){ return x[i++]; }; } ``` Then to use: ``` var iterator=createIterator(['a','b','c','d','...
193,561
<p>I have managed to create an <a href="http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreeNode" rel="nofollow noreferrer">Ext.tree.TreePanel</a> that loads child nodes dynamically, but I'm having a difficult time clearing the tree and loading it with new data. Can someone help me with the code to do this?</p>
[ { "answer_id": 193617, "author": "slmcmahon", "author_id": 26233, "author_profile": "https://Stackoverflow.com/users/26233", "pm_score": 1, "selected": false, "text": "<p>I finally found an answer in their forums. For anyone interested it is here:</p>\n\n<pre><code>if (tree)\n{\n var...
2008/10/11
[ "https://Stackoverflow.com/questions/193561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26233/" ]
I have managed to create an [Ext.tree.TreePanel](http://docs.sencha.com/ext-js/3-4/#!/api/Ext.tree.TreeNode) that loads child nodes dynamically, but I'm having a difficult time clearing the tree and loading it with new data. Can someone help me with the code to do this?
From the wonderful blog of Saki an ExtJS guru. ``` while (node.firstChild) { node.removeChild(node.firstChild); } ``` <http://blog.extjs.eu/know-how/how-to-remove-all-children-of-a-tree-node/>
193,602
<p>Does anyone know of a really simple way of publishing Java methods as web services? I don't really want the overhead of using Tomcat or Jetty or any of the other container frameworks.</p> <p>Scenario: I've got a set of Java methods in a service type application that I want to access from other machines on the local...
[ { "answer_id": 193607, "author": "Draemon", "author_id": 26334, "author_profile": "https://Stackoverflow.com/users/26334", "pm_score": 1, "selected": false, "text": "<p>Jetty's pretty lightweight. Otherwise, I think XML-RPC is your only sensible option.</p>\n" }, { "answer_id": 1...
2008/10/11
[ "https://Stackoverflow.com/questions/193602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/826/" ]
Does anyone know of a really simple way of publishing Java methods as web services? I don't really want the overhead of using Tomcat or Jetty or any of the other container frameworks. Scenario: I've got a set of Java methods in a service type application that I want to access from other machines on the local LAN.
Well, Tomcat or Jetty may be overkill for publishing just some methods as a web service. But on the other hand its not too complicated and they do the job, so why not? I had a similar problem not too long ago and used a Tomcat together with Axis2. Just download Tomcat, unpack it, deploy the Axis2 WAR. To publish a web...
193,630
<p>I've implemented a few poor solutions for bringing up an AJAX loader before dynamically updating a content DIV, but none seem to be "universal", and I find each time I do it I'm reworking it. If I have a DIV with content that updates depending on what a user clicks on the page, and I want to display the loader over ...
[ { "answer_id": 193648, "author": "swilliams", "author_id": 736, "author_profile": "https://Stackoverflow.com/users/736", "pm_score": 0, "selected": false, "text": "<p>You could use a <a href=\"http://ui.jquery.com/repository/latest/demos/functional/#ui.progressbar\" rel=\"nofollow norefe...
2008/10/11
[ "https://Stackoverflow.com/questions/193630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've implemented a few poor solutions for bringing up an AJAX loader before dynamically updating a content DIV, but none seem to be "universal", and I find each time I do it I'm reworking it. If I have a DIV with content that updates depending on what a user clicks on the page, and I want to display the loader over thi...
Some JavaScript libraries allow listening to opening and closing requests. Check out Prototype's request Responder <http://www.prototypejs.org/api/ajax/responders>. You would do something like this: ``` Ajax.Responders.register({ onCreate: function() { $('loader').show(); Ajax.activeRequestCount++; }, o...
193,634
<p>Is it possible to create a footer div that sits at the bottom of a site regardless of how much information is present in the middle?</p> <p>Currently the div I have is positioned depending on how much content i have in the body.</p> <blockquote> <h3>See also:</h3> <p><a href="https://stackoverflow.com/quest...
[ { "answer_id": 193637, "author": "JasonS", "author_id": 1865, "author_profile": "https://Stackoverflow.com/users/1865", "pm_score": 5, "selected": true, "text": "<p>I am by no means a css expert, but this works for me across the major browsers:</p>\n\n<pre><code>.d_footer\n{\n positio...
2008/10/11
[ "https://Stackoverflow.com/questions/193634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
Is it possible to create a footer div that sits at the bottom of a site regardless of how much information is present in the middle? Currently the div I have is positioned depending on how much content i have in the body. > > ### See also: > > > [How do you get the footer to stay at the bottom of a Web page?](http...
I am by no means a css expert, but this works for me across the major browsers: ``` .d_footer { position:fixed; bottom:0px; background-color: #336699; width:100%; text-align:center; padding-top:5px; padding-bottom:5px; color:#ffffff; } ```
193,651
<p>I've had my first go at writing a DLL in Delphi. So far so good. By using a typelib I've been able to pass Widestrings to and from the DLL without difficulty.</p> <p>What's curious at the moment is that I'm using VB6 as the testbed, and every time I run a test within the IDE, the program runs and then the IDE proce...
[ { "answer_id": 193774, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 2, "selected": false, "text": "<pre><code>result := PWideString(s);\n</code></pre>\n\n<p>You are returning pointer to a local variable here. It immediately...
2008/10/11
[ "https://Stackoverflow.com/questions/193651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/426/" ]
I've had my first go at writing a DLL in Delphi. So far so good. By using a typelib I've been able to pass Widestrings to and from the DLL without difficulty. What's curious at the moment is that I'm using VB6 as the testbed, and every time I run a test within the IDE, the program runs and then the IDE process suddenl...
To elaborate on GSerg's answer: ``` result := PWideString(s); ``` you'd think it would be ok because s was initialized with a string literal... but wide strings in Delphi are not reference counted like normal strings, so s actually holds a bit of dynamically allocated heap memory, and as soon as the function returns...
193,656
<p>Can I put the painter into the class variables? :</p> <pre><code>protected: QPainter *myPainter; ... void MyWidget::paintEvent(QPaintEvent *event) { myPainter = new QPainter(this); </code></pre>
[ { "answer_id": 193658, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>don't do that. just put it on the stack so that when it is destroyed in the destructor it will perform the painting automa...
2008/10/11
[ "https://Stackoverflow.com/questions/193656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19884/" ]
Can I put the painter into the class variables? : ``` protected: QPainter *myPainter; ... void MyWidget::paintEvent(QPaintEvent *event) { myPainter = new QPainter(this); ```
A new anser to address more reentrancy more specifically... [danatel](https://stackoverflow.com/users/19884/danatel) left the following comment to [this message](https://stackoverflow.com/questions/193656/is-it-necessary-for-qtpaintevent-to-be-reentrant#195755) (in part): > > By reentrancy I mean this specific situa...
193,686
<p>I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work:</p> <blockquote> <p>AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml<br> AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml </p> </blockquote> <p>Locally, I am...
[ { "answer_id": 193702, "author": "Edward Z. Yang", "author_id": 23845, "author_profile": "https://Stackoverflow.com/users/23845", "pm_score": 0, "selected": false, "text": "<p>So, you're in kind of a tough place; ideally speaking your webhost should not need you to put extra gunk in your...
2008/10/11
[ "https://Stackoverflow.com/questions/193686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I enabled PHP5 on my website and my webhost needs me to add the following to .htaccess files for PHP5 to work: > > AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml > > AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml > > > Locally, I am running XAMPP to develop code...
Apache has [`<IfDefine>`](http://httpd.apache.org/docs/2.0/mod/core.html#ifdefine) directive. You can use it to hide `AddType` from your own server: ``` <IfDefine !MyServer> AddType application/x-httpd-php5 .php5 … … </IfDefine> ``` And start apache with ``` apachectl -D MyServer ```
193,703
<p>recently I've been reading through Scott Meyers's excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0321334876" rel="noreferrer" rel="nofollow noreferrer">Effective C++</a> book. In one of the last tips he covered some of the features from TR1 - I knew many of them via Boost. </p> <p>However, there w...
[ { "answer_id": 193752, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 5, "selected": true, "text": "<p>It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions w...
2008/10/11
[ "https://Stackoverflow.com/questions/193703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
recently I've been reading through Scott Meyers's excellent [Effective C++](https://rads.stackoverflow.com/amzn/click/com/0321334876) book. In one of the last tips he covered some of the features from TR1 - I knew many of them via Boost. However, there was one that I definitely did NOT recognize: tr1::reference\_wrap...
It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions where you need to pass parameters by reference. For example (using boost syntax): ``` void Increment( int& iValue ) { iValue++; } int iVariable = 0; boost::function< void () > fIncrementMyVar...
193,707
<p>What is a preferred way to store recurring time windows? <br /> For example. If I have a calendar system where I need to be able to accommodate daily, weekly or monthly recurring events, what sort of time management system is best? <br /><br /> How is this best represented in a database? </p> <p><strong>More Detail...
[ { "answer_id": 193752, "author": "Nick", "author_id": 26240, "author_profile": "https://Stackoverflow.com/users/26240", "pm_score": 5, "selected": true, "text": "<p>It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions w...
2008/10/11
[ "https://Stackoverflow.com/questions/193707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8880/" ]
What is a preferred way to store recurring time windows? For example. If I have a calendar system where I need to be able to accommodate daily, weekly or monthly recurring events, what sort of time management system is best? How is this best represented in a database? **More Details** The Specific goal of...
It's like boost::ref, as far as I know. Basically, a reference which can be copied. Very useful when binding to functions where you need to pass parameters by reference. For example (using boost syntax): ``` void Increment( int& iValue ) { iValue++; } int iVariable = 0; boost::function< void () > fIncrementMyVar...
193,715
<p>atoi() is giving me this error:</p> <pre><code> error C2664: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast </code></pre> <p>from this line: int pid = atoi( token.at(0) ); where t...
[ { "answer_id": 193717, "author": "Jason Etheridge", "author_id": 2193, "author_profile": "https://Stackoverflow.com/users/2193", "pm_score": 2, "selected": false, "text": "<p>You'll have to create a string:</p>\n\n<pre><code>int pid = atoi(std::string(1, token.at(0)).c_str());\n</code></...
2008/10/11
[ "https://Stackoverflow.com/questions/193715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
atoi() is giving me this error: ``` error C2664: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast ``` from this line: int pid = atoi( token.at(0) ); where token is a vector how can ...
token.at(0) is returning a single char, but atoi() is expecting a string (a pointer to a char.) Either convert the single character to a string, or to convert a single digit char into the number it represents you can usually\* just do this: ``` int pid = token.at(0) - '0'; ``` \* The exception is when the charset do...
193,728
<p>Is there a free XML formatting (indent) tool available where I can past an XML string and have it formatted so I can read the XML document correctly?</p> <p>Thanks</p> <p>Edit ~ I am using XML Notepad on Windows XP.</p>
[ { "answer_id": 193745, "author": "zoul", "author_id": 17279, "author_profile": "https://Stackoverflow.com/users/17279", "pm_score": 6, "selected": false, "text": "<p>Use the following:</p>\n\n<blockquote>\n <p><a href=\"http://xmlsoft.org/xmllint.html\" rel=\"noreferrer\"><code>xmllint<...
2008/10/11
[ "https://Stackoverflow.com/questions/193728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
Is there a free XML formatting (indent) tool available where I can past an XML string and have it formatted so I can read the XML document correctly? Thanks Edit ~ I am using XML Notepad on Windows XP.
I believe that [Notepad++](http://notepad-plus.sourceforge.net/) has this feature. **Edit (for newer versions)** Install the "XML Tools" plugin (Menu Plugins, Plugin Manager) Then run: Menu Plugins, Xml Tools, Pretty Print (XML only - with line breaks) **Original answer (for older versions of Notepad++)** Not...
193,773
<p>You often see, on sites like <a href="http://en.wikipedia.org/wiki/The_Daily_WTF" rel="nofollow noreferrer">The Daily WTF</a>, examples of overengineered code that should have just been a call to a built-in method within the .NET framework.</p> <p>What namespaces/classes should be considered essential knowledge for...
[ { "answer_id": 193783, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>System.String</p>\n\n<p>and learn how to use regular expressions that are exposed via the System.Text.RegularExpressions na...
2008/10/11
[ "https://Stackoverflow.com/questions/193773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1588/" ]
You often see, on sites like [The Daily WTF](http://en.wikipedia.org/wiki/The_Daily_WTF), examples of overengineered code that should have just been a call to a built-in method within the .NET framework. What namespaces/classes should be considered essential knowledge for a developer starting his/her first .NET job? ...
``` System; System.Collections; System.Collections.Generic; ```
193,780
<p>I have 2-3 different column names that I want to look up in the entire database and list out all tables which have those columns. Is there any easy script?</p>
[ { "answer_id": 193788, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 8, "selected": false, "text": "<pre><code>SELECT TABLE_NAME, COLUMN_NAME\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE COLUMN_NAME LIKE '%wild%';\n</code></pre>\...
2008/10/11
[ "https://Stackoverflow.com/questions/193780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8091/" ]
I have 2-3 different column names that I want to look up in the entire database and list out all tables which have those columns. Is there any easy script?
To get all tables with columns `columnA` or `ColumnB` in the database `YourDatabase`: ``` SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME IN ('columnA','ColumnB') AND TABLE_SCHEMA='YourDatabase'; ```
193,794
<p>How can I change a file's extension using PHP?</p> <p>Ex: photo.jpg to photo.exe</p>
[ { "answer_id": 193795, "author": "Galen", "author_id": 7894, "author_profile": "https://Stackoverflow.com/users/7894", "pm_score": 3, "selected": false, "text": "<p>You may use the <a href=\"http://www.php.net/rename\" rel=\"nofollow noreferrer\"><code>rename(string $from, string $to, ?r...
2008/10/11
[ "https://Stackoverflow.com/questions/193794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27025/" ]
How can I change a file's extension using PHP? Ex: photo.jpg to photo.exe
In modern operating systems, filenames very well might contain periods long before the file extension, for instance: ``` my.file.name.jpg ``` PHP provides a way to find the filename without the extension that takes this into account, then just add the new extension: ``` function replace_extension($filename, $new_ex...
193,835
<p>I'm looking to move some of my lighter weight metaprogramming from Nemerle to Boo and I'm trying to figure out how to define custom operators. For example, I can do the following in Nemerle:</p> <pre><code>macro @&lt;-(func, v) { &lt;[ $func($v) ]&gt; } </code></pre> <p>Then these two are equivalent:</p> <pr...
[ { "answer_id": 197738, "author": "Stoo", "author_id": 27425, "author_profile": "https://Stackoverflow.com/users/27425", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this is exactly what you need but you can create syntactic macros in Boo. There's some information on the ...
2008/10/11
[ "https://Stackoverflow.com/questions/193835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4977/" ]
I'm looking to move some of my lighter weight metaprogramming from Nemerle to Boo and I'm trying to figure out how to define custom operators. For example, I can do the following in Nemerle: ``` macro @<-(func, v) { <[ $func($v) ]> } ``` Then these two are equivalent: ``` foo <- 5; foo(5); ``` I can't find a ...
While Boo supports operator overloading by defining the appropriate static operator function (`op_addition`), and also supports syntactic macros, it does not support creating custom operators at this time.
193,838
<p>I want to do a conditional rendering at the layout level based on the actual template has defined <code>content_for(:an__area)</code>, any idea how to get this done?</p>
[ { "answer_id": 194243, "author": "William Yeung", "author_id": 16371, "author_profile": "https://Stackoverflow.com/users/16371", "pm_score": 1, "selected": false, "text": "<p>Ok I am going to shamelessly do a self reply as no one has answered and I have already found the answer :) \nDefi...
2008/10/11
[ "https://Stackoverflow.com/questions/193838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16371/" ]
I want to do a conditional rendering at the layout level based on the actual template has defined `content_for(:an__area)`, any idea how to get this done?
`@content_for_whatever` is deprecated. Use `content_for?` instead, like this: ``` <% if content_for?(:whatever) %> <div><%= yield(:whatever) %></div> <% end %> ```
193,849
<p>Would this be right??</p> <ol> <li><p>Black Box</p> <p>1.1 Functional</p> <pre><code> 1.1.1 Equivalence 1.1.2 BVA 1.1.3 Use case 1.1.4 Regression 1.1.5 UAT </code></pre> <p>1.2 Non Functional</p> <pre><code> 1.2.1 Testing the System Design </code></pre></li> <li><p>White box</p> <p>2.1. F...
[ { "answer_id": 193882, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "<p>You might also consider the case when several programs depending one on another are developed simultaneously. You have then ...
2008/10/11
[ "https://Stackoverflow.com/questions/193849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Would this be right?? 1. Black Box 1.1 Functional ``` 1.1.1 Equivalence 1.1.2 BVA 1.1.3 Use case 1.1.4 Regression 1.1.5 UAT ``` 1.2 Non Functional ``` 1.2.1 Testing the System Design ``` 2. White box 2.1. Functional ``` 2.1.1 Unit 2.1.2 Integration 2.1.3 System ```...
You might also consider the case when several programs depending one on another are developed simultaneously. You have then to take into account the ***applicative architecture*** which groups all those applications into several *functional domains* So, for instance, a financial application having to process a large n...
193,852
<p>I have the following character string: </p> <pre><code>"..1....10..20....30...40....50...80..." </code></pre> <p>and I need to extract all numbers from it into array. </p> <p>What is the best way to do it in C? </p>
[ { "answer_id": 193858, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "<p>Perhaps the easiest way is to use the <code>strtok()</code> function (or <code>strtok_r()</code> if reentrancy is a co...
2008/10/11
[ "https://Stackoverflow.com/questions/193852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have the following character string: ``` "..1....10..20....30...40....50...80..." ``` and I need to extract all numbers from it into array. What is the best way to do it in C?
Perhaps the easiest way is to use the `strtok()` function (or `strtok_r()` if reentrancy is a concern): ``` char str[] = "..1...10...20"; char *p = strtok(str, "."); while (p != NULL) { printf("%d\n", atoi(p)); p = strtok(NULL, "."); } ``` Once you have the results of calling `atoi()`, it should be a simple ...
193,855
<p>I'm having trouble with something that I thought would be easy... I can't get my NotifyIcon to show a balloon tip. The basic code is:</p> <pre><code>public void ShowSystrayBubble(string msg, int ms) { sysTrayIcon.Visible = true; sysTrayIcon.ShowBalloonTip(20, "Title", "Text", ToolTipIcon.None); } </code></pre>...
[ { "answer_id": 193866, "author": "greg7gkb", "author_id": 10505, "author_profile": "https://Stackoverflow.com/users/10505", "pm_score": 4, "selected": true, "text": "<p>I had foiled myself... This turned out to be an issue at the OS level. I had previously disabled all balloons via the ...
2008/10/11
[ "https://Stackoverflow.com/questions/193855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10505/" ]
I'm having trouble with something that I thought would be easy... I can't get my NotifyIcon to show a balloon tip. The basic code is: ``` public void ShowSystrayBubble(string msg, int ms) { sysTrayIcon.Visible = true; sysTrayIcon.ShowBalloonTip(20, "Title", "Text", ToolTipIcon.None); } ``` Nothing happens when I...
I had foiled myself... This turned out to be an issue at the OS level. I had previously disabled all balloons via the registry a few weeks ago. You can read the information here on how to disable balloon tips in WinXP: <http://support.microsoft.com/kb/307729> To enable them, just set the registry value to 1 instead a...
193,875
<p>I have some very simple code to generate an assembly and invoke a method on a contained type. The method gets called and runs correctly, however when I view the generated assembly using Reflector, I don't see the type.</p> <p>Below is the sample code:</p> <pre><code>namespace ConsoleApplication2 { class Progg...
[ { "answer_id": 193932, "author": "alexmac", "author_id": 23066, "author_profile": "https://Stackoverflow.com/users/23066", "pm_score": -1, "selected": false, "text": "<p>I am not sure why the type is not getting added. </p>\n\n<p>Another way of doing this however is to dynamically create...
2008/10/11
[ "https://Stackoverflow.com/questions/193875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26054/" ]
I have some very simple code to generate an assembly and invoke a method on a contained type. The method gets called and runs correctly, however when I view the generated assembly using Reflector, I don't see the type. Below is the sample code: ``` namespace ConsoleApplication2 { class Proggy { public...
The trick is to use a "persistable module" version of DefineDynamicModule method on the AssemblyBuilder instance. That is, instead of: ``` var module = ab.DefineDynamicModule(ab.GetName().Name); ``` use something like: ``` var module = ab.DefineDynamicModule(ab.GetName().Name, ab.GetName().Name + ".mod"); ``` The...
193,918
<p>Given a point such as (0, 0, 0) and a vector like (x, y, z). What is the easiest way to align the negative Z-axis centered at (0, 0, 0) to point in the direction of this vector? Examples using OpenGL would be welcome, but not neccessary.</p>
[ { "answer_id": 193923, "author": "fluffels", "author_id": 12828, "author_profile": "https://Stackoverflow.com/users/12828", "pm_score": 1, "selected": false, "text": "<p>To answer my own question, the best answer I've come up with is this:</p>\n\n<p>Divide the vector up into \"components...
2008/10/11
[ "https://Stackoverflow.com/questions/193918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12828/" ]
Given a point such as (0, 0, 0) and a vector like (x, y, z). What is the easiest way to align the negative Z-axis centered at (0, 0, 0) to point in the direction of this vector? Examples using OpenGL would be welcome, but not neccessary.
There's lots of different ways to rotate a coordinate-frame to point in a given direction; they'll all leave the z-axis pointed in the direction you want, but with variations in how the x- and y-axes are oriented. The following gets you the shortest rotation, which may or may not be what you want. ``` vec3 target_dir...
193,919
<p>I am a little confused by the multitude of ways in which you can import modules in Python. </p> <pre><code>import X import X as Y from A import B </code></pre> <p>I have been reading up about scoping and namespaces, but I would like some practical advice on what is the best strategy, under which circumstances and...
[ { "answer_id": 193927, "author": "MvdD", "author_id": 18044, "author_profile": "https://Stackoverflow.com/users/18044", "pm_score": 4, "selected": false, "text": "<p>I would normally use <code>import X</code> on module level. If you only need a single object from a module, use <code>from...
2008/10/11
[ "https://Stackoverflow.com/questions/193919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24039/" ]
I am a little confused by the multitude of ways in which you can import modules in Python. ``` import X import X as Y from A import B ``` I have been reading up about scoping and namespaces, but I would like some practical advice on what is the best strategy, under which circumstances and why. Should imports happen...
In production code in our company, we try to follow the following rules. We place imports at the beginning of the file, right after the main file's docstring, e.g.: ``` """ Registry related functionality. """ import wx # ... ``` Now, if we import a class that is one of few in the imported module, we import the name...
193,941
<p>For a long time I've been trying different languages to find the feature-set I want and I've not been able to find it. I have languages that fit decently for various projects of mine, but I've come up with an intersection of these languages that will allow me to do 99.9% of my projects in a single language. I want...
[ { "answer_id": 193953, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 2, "selected": false, "text": "<p>Writing your own language is not a easy project.. Especially one to be used in any kind of \"professional setting\"</p>\n\n<p>I...
2008/10/11
[ "https://Stackoverflow.com/questions/193941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4977/" ]
For a long time I've been trying different languages to find the feature-set I want and I've not been able to find it. I have languages that fit decently for various projects of mine, but I've come up with an intersection of these languages that will allow me to do 99.9% of my projects in a single language. I want the ...
Sadly, there's no metrics or stories around failed languages. Just successful languages. Clearly, the failures outnumber the successes. What do I base this on? Two common experiences. 1. Once or twice a year, I have to endure a pitch for a product/language/tool/framework that will Absolutely Change Everything. My ans...
193,973
<p>It obviously depends on the context you are using them in but, I was wondering if there is a universally accepted way to name such variables, or at least in a mathematical context.</p> <p>I've often seen:</p> <pre><code>float k = someValue; float oneMinusK = 1 - k; </code></pre> <p>...which seems as descr...
[ { "answer_id": 193975, "author": "Scott James", "author_id": 6715, "author_profile": "https://Stackoverflow.com/users/6715", "pm_score": 3, "selected": false, "text": "<p>You should name your variables based on what it means in terms of the domain you are working on not the algorithm you...
2008/10/11
[ "https://Stackoverflow.com/questions/193973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7839/" ]
It obviously depends on the context you are using them in but, I was wondering if there is a universally accepted way to name such variables, or at least in a mathematical context. I've often seen: ``` float k = someValue; float oneMinusK = 1 - k; ``` ...which seems as descriptive as much as meaningless to ...
In probability 1-k is the probability of X not occurring, given that k is the probability of X occurring. So ``` float will_win_lottery = 0.00000000001; float will_not_win_lottery = 1 - will_win_lottery; ```
193,994
<p>I'm writing a construct in PHP where a parser determins which function to call dynamically, kind of like this:</p> <pre><code>// The definition of what to call $function_call_spec = array( "prototype" =&gt; "myFunction", "parameters" =&gt; array( "first_par" =&gt; "Hello", ...
[ { "answer_id": 193998, "author": "moo", "author_id": 23107, "author_profile": "https://Stackoverflow.com/users/23107", "pm_score": 3, "selected": false, "text": "<pre><code>call_user_func_array($funcPrototype, $function_call_spec[\"parameters\"]);\n</code></pre>\n\n<p>You might want to c...
2008/10/11
[ "https://Stackoverflow.com/questions/193994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
I'm writing a construct in PHP where a parser determins which function to call dynamically, kind of like this: ``` // The definition of what to call $function_call_spec = array( "prototype" => "myFunction", "parameters" => array( "first_par" => "Hello", ...
You should use [`call_user_func_array`](http://php.net/call_user_func_array) which can call any function or method and takes parameteres from an array. Alternatively you can use [`ReflectionFunction::invokeArgs`](http://php.net/manual/en/language.oop5.reflection.php#language.oop5.reflection.reflectionfunction), but th...
194,077
<p>I've just recently setup a custom replication for my subscriber database, as described in <a href="https://stackoverflow.com/questions/161890/how-do-you-track-the-time-of-replicated-rows-for-subscribers-in-sql-server-2005">another post here</a>. Basically, when the publisher pushes a new record to the subscribers, t...
[ { "answer_id": 527961, "author": "Timbo", "author_id": 20992, "author_profile": "https://Stackoverflow.com/users/20992", "pm_score": 0, "selected": false, "text": "<p>I see this is a very old question now so you've probably resolved this, but anyway...</p>\n\n<p>The problem you describe ...
2008/10/11
[ "https://Stackoverflow.com/questions/194077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19582/" ]
I've just recently setup a custom replication for my subscriber database, as described in [another post here](https://stackoverflow.com/questions/161890/how-do-you-track-the-time-of-replicated-rows-for-subscribers-in-sql-server-2005). Basically, when the publisher pushes a new record to the subscribers, the stored proc...
I finally have an answer for this problem a few months ago, just that I never got around to update this question. We have to log a support call to Microsoft, but we got a working solution. To resolve the problem, when adding a subscription, you need to run the script like below: ``` sp_addsubscription @publication = ...
194,089
<p>Say I've got a string which contains a number. I want to check if this number is an integer.</p> <h3>Examples</h3> <pre><code>IsInteger(&quot;sss&quot;) =&gt; false IsInteger(&quot;123&quot;) =&gt; true IsInterger(&quot;123.45&quot;) =&gt;false </code></pre>
[ { "answer_id": 194091, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 4, "selected": false, "text": "<p>You can use int.<a href=\"http://msdn.microsoft.com/en-us/library/f02979c7.aspx\" rel=\"noreferrer\">TryParse</a>. It ...
2008/10/11
[ "https://Stackoverflow.com/questions/194089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Say I've got a string which contains a number. I want to check if this number is an integer. ### Examples ``` IsInteger("sss") => false IsInteger("123") => true IsInterger("123.45") =>false ```
You can use int.[TryParse](http://msdn.microsoft.com/en-us/library/f02979c7.aspx). It will return a bool if it can parse the string and set your out parameter to the value ``` int val; if(int.TryParse(inputString, out val)) { //dosomething } ```
194,101
<p>I'd like to track changes in inputs in a form via javascript. My intent is (but not limited) to</p> <ul> <li>enable "save" button only when something has changed</li> <li>alert if the user wants to close the page and something is not saved</li> </ul> <p>Ideas?</p>
[ { "answer_id": 194110, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 6, "selected": true, "text": "<p>Loop through all the input elements, and put an <code>onchange</code> handler on each. When that fires, set a flag which let...
2008/10/11
[ "https://Stackoverflow.com/questions/194101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19224/" ]
I'd like to track changes in inputs in a form via javascript. My intent is (but not limited) to * enable "save" button only when something has changed * alert if the user wants to close the page and something is not saved Ideas?
Loop through all the input elements, and put an `onchange` handler on each. When that fires, set a flag which lets you know the form has changed. A basic version of that would be very easy to set up, but wouldn't be smart enough to recognize if someone changed an input from "a" to "b" and then back to "a". If it were i...
194,102
<p>We have a web service that is deployed on 2 separate machines in different locations. Is it possible to monitor the url that a person used to call our webservice using java code? We have a 3DNS url set up and we want all clients to use this url as oppossed hitting the boxes directly with the correct port numbers in ...
[ { "answer_id": 196767, "author": "billjamesdev", "author_id": 13824, "author_profile": "https://Stackoverflow.com/users/13824", "pm_score": 0, "selected": false, "text": "<p>You might look into something like OWSM (Oracle Web Services Manager)... there may be open source alternatives.</p...
2008/10/11
[ "https://Stackoverflow.com/questions/194102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11612/" ]
We have a web service that is deployed on 2 separate machines in different locations. Is it possible to monitor the url that a person used to call our webservice using java code? We have a 3DNS url set up and we want all clients to use this url as oppossed hitting the boxes directly with the correct port numbers in the...
Have you taken a look at: ``` @Resource WebServiceContext wsContext; ``` This will return the context of the current message sent to your webservice. I've been able to get the IP address of the user from that. This is assuming that you are using Java.
194,150
<p>How to check reliably if a SoundChannel is still playing a sound? </p> <p>For example,</p> <pre><code>[Embed(source="song.mp3")] var Song: Class; var s: Song = new Song(); var ch: SoundChannel = s.play(); // how to check if ch is playing? </code></pre>
[ { "answer_id": 194653, "author": "James Fassett", "author_id": 27081, "author_profile": "https://Stackoverflow.com/users/27081", "pm_score": 5, "selected": true, "text": "<p>I've done a little research and I can't find a way to query any object to determine if a sound is playing. You'll ...
2008/10/11
[ "https://Stackoverflow.com/questions/194150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
How to check reliably if a SoundChannel is still playing a sound? For example, ``` [Embed(source="song.mp3")] var Song: Class; var s: Song = new Song(); var ch: SoundChannel = s.play(); // how to check if ch is playing? ```
I've done a little research and I can't find a way to query any object to determine if a sound is playing. You'll have to write a wrapper class and manage it yourself it seems. ``` package { import flash.events.Event; import flash.media.Sound; import flash.media.SoundChannel; public class SoundPlayer...
194,157
<p>I'm using:</p> <pre><code>FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" </code></pre> <p>In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm looking for is a right old kludge of a M...
[ { "answer_id": 194163, "author": "tomasr", "author_id": 10292, "author_profile": "https://Stackoverflow.com/users/10292", "pm_score": 3, "selected": false, "text": "<p>One way would be to look for the \"ProgramFiles(x86)\" environment variable:</p>\n\n<pre><code>String x86folder = Enviro...
2008/10/11
[ "https://Stackoverflow.com/questions/194157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293123/" ]
I'm using: ``` FileInfo( System.Environment.GetFolderPath( System.Environment.SpecialFolder.ProgramFiles) + @"\MyInstalledApp" ``` In order to determine if a program is detected on a users machine (it's not ideal, but the program I'm looking for is a right old kludge of a MS-DOS application, and I c...
The function below will return the x86 `Program Files` directory in all of these three Windows configurations: * 32 bit Windows * 32 bit program running on 64 bit Windows * 64 bit program running on 64 bit windows ``` static string ProgramFilesx86() { if( 8 == IntPtr.Size || (!String.IsNullOrEmpty(Enviro...
194,165
<p>I'm using the standard <code>ConsoleHandler</code> from <code>java.util.logging</code> and by default the console output is directed to the error stream (i.e. <code>System.err</code>).</p> <p>How do I change the console output to the output stream (i.e. <code>System.out</code>)?</p>
[ { "answer_id": 194198, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Have a look at the docs and source for <a href=\"http://java.sun.com/javase/6/docs/api/java/util/logging/ConsoleHandl...
2008/10/11
[ "https://Stackoverflow.com/questions/194165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
I'm using the standard `ConsoleHandler` from `java.util.logging` and by default the console output is directed to the error stream (i.e. `System.err`). How do I change the console output to the output stream (i.e. `System.out`)?
I've arrived at ``` SimpleFormatter fmt = new SimpleFormatter(); StreamHandler sh = new StreamHandler(System.out, fmt); logger.addHandler(sh); ```
194,168
<p>I asked before about pixel-pushing, and have now managed to get far enough to get noise to show up on the screen. Here's how I init:</p> <pre><code>CGDataProviderRef provider; bitmap = malloc(320*480*4); provider = CGDataProviderCreateWithData(NULL, bitmap, 320*480*4, NULL); CGColorSpaceRef colorSpaceRef; colorSpac...
[ { "answer_id": 194216, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 1, "selected": false, "text": "<p>I suspect doing 614400 (<code>320*480*4</code>) memory writes, random number generation and making a new object each fr...
2008/10/11
[ "https://Stackoverflow.com/questions/194168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8005/" ]
I asked before about pixel-pushing, and have now managed to get far enough to get noise to show up on the screen. Here's how I init: ``` CGDataProviderRef provider; bitmap = malloc(320*480*4); provider = CGDataProviderCreateWithData(NULL, bitmap, 320*480*4, NULL); CGColorSpaceRef colorSpaceRef; colorSpaceRef = CGColor...
The slowness is almost certainly in the noise generation. If you run this in Instruments you'll probably see that a ton of time is spent sitting in your loop. Another smaller issue is your colorspace. If you use the screen's colorspace, you'll avoid a colorspace conversion which is potentially expensive. If you can ...
194,194
<p>I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the i...
[ { "answer_id": 194205, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 0, "selected": false, "text": "<p>A class for each rule? <em>Really?</em> Perhaps I'm not understanding the quantity or complexity of these rules, but I woul...
2008/10/11
[ "https://Stackoverflow.com/questions/194194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the info...
If I didn't care to do this in 1 step (as Oli mentions), I'd probably use a [pipe and filters](http://www.eaipatterns.com/PipesAndFilters.html) design. Since your rules are relatively simple, I'd probably do a couple delegate based classes. For instance (C# code, but Java should be pretty similar...perhaps someone coul...
194,208
<p>I'm using the following code within the JCProperty class to retrieve data from a DAL: </p> <pre><code>Dim x As JCProperty x = JCPropertyDB.GetProperty(PropertyID) If Not x Is Nothing Then Me.PropertyID = x.PropertyID Me.AddressLine1 = x.AddressLine1 Me.AddressLi...
[ { "answer_id": 194250, "author": "Erlend", "author_id": 5746, "author_profile": "https://Stackoverflow.com/users/5746", "pm_score": 2, "selected": false, "text": "<p>Not sure if this will answer your question, but the important point is that the domain model is independent of display and...
2008/10/11
[ "https://Stackoverflow.com/questions/194208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20048/" ]
I'm using the following code within the JCProperty class to retrieve data from a DAL: ``` Dim x As JCProperty x = JCPropertyDB.GetProperty(PropertyID) If Not x Is Nothing Then Me.PropertyID = x.PropertyID Me.AddressLine1 = x.AddressLine1 Me.AddressLine2 = x.Address...
Personally, I'm lazy. I usually do something like: ``` class JCProperty : inherits JCPropertyDB { New() { MyBase.New() GetProperty(PropertyID) } } ``` Then you're basically done, until you have some additional functionality in the JCProperty class that needs to happen "on top" of ...
194,241
<p>In Visual Studio if I define a class to implement an interface e.g.</p> <pre><code>class MyObject : ISerializable {} </code></pre> <p>I am able to right click on ISerializable, select "<em>Implement Interface</em>" from the context menu and see the appropriate methods appear in my class definition.</p> <pre><code...
[ { "answer_id": 194335, "author": "David Grant", "author_id": 26829, "author_profile": "https://Stackoverflow.com/users/26829", "pm_score": 4, "selected": true, "text": "<p>I have not seen that feature in Xcode.\nBut it seems like someone could write a new user script called \"Place Imple...
2008/10/11
[ "https://Stackoverflow.com/questions/194241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1403/" ]
In Visual Studio if I define a class to implement an interface e.g. ``` class MyObject : ISerializable {} ``` I am able to right click on ISerializable, select "*Implement Interface*" from the context menu and see the appropriate methods appear in my class definition. ``` class MyObject : ISerializable { #regio...
I have not seen that feature in Xcode. But it seems like someone could write a new user script called "Place Implementor Defs on Clipboard" that sits inside of Scripts > Code. You did not find this useful.
194,247
<p>I have a 2 dimensional array, like so:</p> <pre><code>char[,] str = new char[2,50]; </code></pre> <p>Now, after I've stored contents in both str[0] and str[1], how do I store it in a </p> <pre><code>string[] s = new string[2]; </code></pre> <p>?</p> <p>I tried </p> <pre><code>s[0] = str[0].ToString(); </code><...
[ { "answer_id": 194252, "author": "Drew Noakes", "author_id": 24874, "author_profile": "https://Stackoverflow.com/users/24874", "pm_score": 2, "selected": false, "text": "<p>Assuming the dimensions are fixed as 2x50:</p>\n\n<pre><code>char[,] str = new char[2,50];\n\n// populate str someh...
2008/10/11
[ "https://Stackoverflow.com/questions/194247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8127/" ]
I have a 2 dimensional array, like so: ``` char[,] str = new char[2,50]; ``` Now, after I've stored contents in both str[0] and str[1], how do I store it in a ``` string[] s = new string[2]; ``` ? I tried ``` s[0] = str[0].ToString(); ``` but that seems to be an error: VC# expects 'two' indices within the b...
A jagged array is almost always the best solution for a variety of reasons, and this is one good example. There is so much more flexibility available with an array of arrays than with a multi-dimensional array. In this case, once you have the values in an array of chars, then a constructor on the string class can be us...
194,261
<p>I just played with Java file system API, and came down with the following function, used to copy binary files. The original source came from the Web, but I added try/catch/finally clauses to be sure that, should something wrong happen, the Buffer Streams would be closed (and thus, my OS ressources freed) before quit...
[ { "answer_id": 194281, "author": "volley", "author_id": 13905, "author_profile": "https://Stackoverflow.com/users/13905", "pm_score": 2, "selected": false, "text": "<p>Unfortunately, this type of code tends to get a bit bloated in Java.</p>\n\n<p>By the way, if one of the calls to oSBuff...
2008/10/11
[ "https://Stackoverflow.com/questions/194261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14089/" ]
I just played with Java file system API, and came down with the following function, used to copy binary files. The original source came from the Web, but I added try/catch/finally clauses to be sure that, should something wrong happen, the Buffer Streams would be closed (and thus, my OS ressources freed) before quiting...
The try/finally pattern is the correct way to handle streams in most cases for Java 6 and lower. *Some are advocating silently closing streams. Be careful doing this for these reasons: [Java: how not to make a mess of stream handling](http://illegalargumentexception.blogspot.com/2008/10/java-how-not-to-make-mess-of-st...
194,304
<p>I'm trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range. </p> <p>Here's an example:</p> <pre><code>IEnumerable&lt;int&gt; EnumerateIntegerRange(int from, int to) { for (int i = from; i &lt;= to; i++) { yield return i; } } </c...
[ { "answer_id": 194307, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>This is already in the framework: <a href=\"http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx\...
2008/10/11
[ "https://Stackoverflow.com/questions/194304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5314/" ]
I'm trying to think of clever, clear, and simple ways to write code that describes the sequence of integers in a given range. Here's an example: ``` IEnumerable<int> EnumerateIntegerRange(int from, int to) { for (int i = from; i <= to; i++) { yield return i; } } ```
This is already in the framework: [Enumerable.Range](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx). For other types, you might be interested in the range classes in my [MiscUtil](http://pobox.com/~skeet/csharp/miscutil) library.
194,328
<p>I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring?</p> <p>Any idea?</p>
[ { "answer_id": 194351, "author": "MatthieuGD", "author_id": 3109, "author_profile": "https://Stackoverflow.com/users/3109", "pm_score": 3, "selected": false, "text": "<p>you have VisualGC, it's not very advanced but you can see the memory usage of your application (garbage,old, perm etc....
2008/10/11
[ "https://Stackoverflow.com/questions/194328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25368/" ]
I know we can use tools like JProfiler etc. Is there any tutorial on how to configure it to display the memory usage just by remote monitoring? Any idea?
you have VisualGC, it's not very advanced but you can see the memory usage of your application (garbage,old, perm etc...) [http://java.sun.com/performance/jvmstat/visualgc.html](http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstatd.html) to resume : you launch a daemon monitoring on the remote machine (<http://j...
194,331
<p>I have a domain class containing a couple of fields. I can access them from my .gsps. I want to add a method to the domain class, which I can call from the .gsps (this method is a kind of virtual field; it's data is not coming directly from the database).</p> <p>How do I add the method and how can I then call it fr...
[ { "answer_id": 194348, "author": "Hates_", "author_id": 3410, "author_profile": "https://Stackoverflow.com/users/3410", "pm_score": 5, "selected": true, "text": "<p>To add a method, just write it out like you would any other regular method. It will be available on the object when you dis...
2008/10/11
[ "https://Stackoverflow.com/questions/194331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3506/" ]
I have a domain class containing a couple of fields. I can access them from my .gsps. I want to add a method to the domain class, which I can call from the .gsps (this method is a kind of virtual field; it's data is not coming directly from the database). How do I add the method and how can I then call it from the .gs...
To add a method, just write it out like you would any other regular method. It will be available on the object when you display it in your GSP. ``` def someMethod() { return "Hello." } ``` Then in your GSP. ``` ${myObject.someMethod()} ```
194,339
<p>I have several python projects that share common modules. Until now, I've been ... ahem ... keeping multiple copies of the common code and synchronizing by hand. But I'd clearly prefer to do something else.</p> <p>It looks to me now, as if zc.Buildout maybe what I need. I guess that what I should be doing is puttin...
[ { "answer_id": 194472, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>This is why you have the <a href=\"http://www.python.org/doc/2.5.2/lib/module-site.html\" rel=\"nofollow noreferrer\">si...
2008/10/11
[ "https://Stackoverflow.com/questions/194339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
I have several python projects that share common modules. Until now, I've been ... ahem ... keeping multiple copies of the common code and synchronizing by hand. But I'd clearly prefer to do something else. It looks to me now, as if zc.Buildout maybe what I need. I guess that what I should be doing is putting each reu...
Do not separate the tests from your code, you need to keep the two closely together. It's not as if tests take up that much disk space or any memory! And tests can be extremely instructive to your library users. For library packages, include a `buildout.cfg` and `bootstrap.py` file with your package to make running th...
194,346
<p>I have an HTML page (say welcome.html) which contains an iframe to a page I have no control over (say app.html). The user performs some actions using the app within the iframe and clicks submit. Once they do this, they are taken to a new page (say thanks.jsp), which loads within the iframe. Is there a way in whic...
[ { "answer_id": 194363, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 4, "selected": true, "text": "<p>You probably want to use a framebuster, with a base target in case it fails.</p>\n\n<p>First:</p>\n\n<p><strong>If</stro...
2008/10/11
[ "https://Stackoverflow.com/questions/194346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/78/" ]
I have an HTML page (say welcome.html) which contains an iframe to a page I have no control over (say app.html). The user performs some actions using the app within the iframe and clicks submit. Once they do this, they are taken to a new page (say thanks.jsp), which loads within the iframe. Is there a way in which I ca...
You probably want to use a framebuster, with a base target in case it fails. First: **If** `thanks.jsp` is requested via a post request - redirect so it you present the page as the response to a get request. Then: Include framebuster JavaScript: ``` <script type="text/javascript"> if (self != top) { top.locatio...
194,382
<p>What is the difference between applying the visitor design pattern to your code and the following approach:</p> <pre><code>interface Dointerface { public void perform(Object o); } public class T { private Dointerface d; private String s; public String getS() { return s; } publ...
[ { "answer_id": 194398, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>The only thing that I see that is readily obvious is that by storing the interface, you make it so you have to do tw...
2008/10/11
[ "https://Stackoverflow.com/questions/194382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11234/" ]
What is the difference between applying the visitor design pattern to your code and the following approach: ``` interface Dointerface { public void perform(Object o); } public class T { private Dointerface d; private String s; public String getS() { return s; } public T(String s)...
Two things: * In your example you need two methods. The `perfom` and the `setInterface`. With a visitor pattern you would only need one method, the `perfom`, usually called `accept`. * If you need more than one 'performer', you will have to set the performer -via the `setInterface` method- for each. This makes it impo...
194,443
<p>I want to post an xml document to an <strong>asp</strong> page from an <strong>asp.net</strong> page. If I use WebRequest with content/type text/xml the document never gets to the asp page. How can I do this ?</p>
[ { "answer_id": 194467, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>It's absolutely possible. Make sure that you are writing the XML to the RequestStream.</p>\n\n<p><a href=\"http://msdn.mi...
2008/10/11
[ "https://Stackoverflow.com/questions/194443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to post an xml document to an **asp** page from an **asp.net** page. If I use WebRequest with content/type text/xml the document never gets to the asp page. How can I do this ?
Here is a sample without any error handling (do it yourself :) ): ``` HttpWebRequest request = (HttpWebRequest)WebRequest.Create(targetUri); string sendString = formParameterName + "=" + HttpUtility.UrlEncode(xmlData); byte[] byteStream; byteStream = System.Text.Encoding.UTF8.GetBytes(sendString); request.Method = PO...