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
421,973
<p>I'm trying to optimize query performance and have had to resort to using optimizer hints. But I've never learned if the optimizer will use more than one hint at a time.</p> <p>e.g.</p> <pre><code>SELECT /*+ INDEX(i dcf_vol_prospect_ids_idx)*/ /*+ LEADING(i vol) */ /*+ ALL_ROWS */ i.id_numbe...
[ { "answer_id": 422033, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 6, "selected": true, "text": "<p>Try specifying all the hints in a single comment block, as shown in this example from the wonderful Oracle documentatio...
2009/01/07
[ "https://Stackoverflow.com/questions/421973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50943/" ]
I'm trying to optimize query performance and have had to resort to using optimizer hints. But I've never learned if the optimizer will use more than one hint at a time. e.g. ``` SELECT /*+ INDEX(i dcf_vol_prospect_ids_idx)*/ /*+ LEADING(i vol) */ /*+ ALL_ROWS */ i.id_number, ... FROM i...
Try specifying all the hints in a single comment block, as shown in this example from the wonderful Oracle documentation (<http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/hintsref.htm>). > > 16.2.1 Specifying a Full Set of Hints > > > When using hints, in some cases, you > might need to specify a fu...
421,989
<p>I have some standard-texts, but some portion of it is different. But of these different parts only a few exists.</p> <p>For instance I want:</p> <pre><code>\mytext{...}{a} \mytext{...}{b} </code></pre> <p>That produces:</p> <pre><code>\section{Item: ...}\label{item...} This is a standard item. Items of type a a...
[ { "answer_id": 422073, "author": "starblue", "author_id": 49246, "author_profile": "https://Stackoverflow.com/users/49246", "pm_score": 2, "selected": false, "text": "<p>You can use \\newif\\iffoo to declare a new condition.\nThen \\footrue or \\foofalse sets it to true or false, and you...
2009/01/07
[ "https://Stackoverflow.com/questions/421989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
I have some standard-texts, but some portion of it is different. But of these different parts only a few exists. For instance I want: ``` \mytext{...}{a} \mytext{...}{b} ``` That produces: ``` \section{Item: ...}\label{item...} This is a standard item. Items of type a are very precious. \section{Item: ...}\label...
The `ifthen` package (which is included in a standard LaTeX installation) defines a command `\ifthenelse`, which is used like this: ``` \usepackage{ifthen} \ifthenelse{test}{then-code}{else-code} ``` so you could do something similar to: ``` \newcommand\mytext[1]{% \ifthenelse{\equal{#1}{a}}{very precious}{% ...
422,002
<p>I need to open foxpro free tables in vb.net using the oledb connection.</p> <p>But... I only need to get the column names. I don't really need to 'select' anything. I am trying to dynamically browse through all our free tables and set up a listing of every column from every file and xref that to another free table ...
[ { "answer_id": 422079, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 4, "selected": true, "text": "<p>Why do you need to get any records at all? You should be able to say:</p>\n\n<pre><code>SELECT * FROM \"File\" where ...
2009/01/07
[ "https://Stackoverflow.com/questions/422002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32540/" ]
I need to open foxpro free tables in vb.net using the oledb connection. But... I only need to get the column names. I don't really need to 'select' anything. I am trying to dynamically browse through all our free tables and set up a listing of every column from every file and xref that to another free table that conta...
Why do you need to get any records at all? You should be able to say: ``` SELECT * FROM "File" where 1 = 0 ``` This will give you an empty result set, will also give you metadata on the projection returned. You might also want to look into the [`GetOleDbSchemaTable` method](http://msdn.microsoft.com/en-us/library/s...
422,010
<p>I am using a Datagrid with several columns of data (call it myDG) and one of these columns is a DateTime bound to a datasource. Its value is dependent on a "job" object completing a job and assigning the date time value. Since this normally takes up to a minute the value is left unassigned at the beginning.</p> <p>...
[ { "answer_id": 422025, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 2, "selected": false, "text": "<p>I would probably hook OnItemDataBound, check the value, and replace/reformat if required.</p>\n" }, { "a...
2009/01/07
[ "https://Stackoverflow.com/questions/422010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52587/" ]
I am using a Datagrid with several columns of data (call it myDG) and one of these columns is a DateTime bound to a datasource. Its value is dependent on a "job" object completing a job and assigning the date time value. Since this normally takes up to a minute the value is left unassigned at the beginning. The column...
I have done similar things in the past and here is what I have done. Bind the data to a column that is not visible at all. Add a visible column for the data you wish to display. At the time you populate your grid, loop through the records and for any that have a value that isn't 01-Jan-0001 12:00:00 AM, set your visib...
422,032
<p>So I have a Stateful .NET webservice (C#) that I would like Flex to use. The only problem is that I don't see a cookie being passed, even though I have the WebMethods decorated with:</p> <pre><code>WebMethod(EnableSession=true) </code></pre> <p>I can't seem to figure out if it is an issue with Flex or .NET. </p> ...
[ { "answer_id": 422051, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>Set your modal overlay div to fill the body, so even if they scroll there's nothing they can do because everything ...
2009/01/07
[ "https://Stackoverflow.com/questions/422032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19854/" ]
So I have a Stateful .NET webservice (C#) that I would like Flex to use. The only problem is that I don't see a cookie being passed, even though I have the WebMethods decorated with: ``` WebMethod(EnableSession=true) ``` I can't seem to figure out if it is an issue with Flex or .NET. Does Flex 3 (as3) pay attentio...
To answer your various questions (including that in your other comment), I think you're using the wrong positioning method. Try `position:fixed`. It's basically the same as `position:absolute` apart from it's relative to the absolute viewport. Ie: if the user scrolls, the item stays in the same place on the screen. S...
422,045
<p>How do I split data into pages on ASP.Net?</p> <p>I'm looking for something like what Google does when you have too many search results and it splits them into x number of pages.</p>
[ { "answer_id": 422055, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 3, "selected": false, "text": "<p>It would depend entirely on the content. If it's a simple datagrid you can use the built in datagrid paging. If ...
2009/01/07
[ "https://Stackoverflow.com/questions/422045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52590/" ]
How do I split data into pages on ASP.Net? I'm looking for something like what Google does when you have too many search results and it splits them into x number of pages.
It would depend entirely on the content. If it's a simple datagrid you can use the built in datagrid paging. If the data is coming from SQL though, I'd advise building a generic "paging control" and using the paging functionality of SQL to only pull back the data you want to see. If it's SQL 2005 (or above) paging is ...
422,078
<p>I have the following DataTemplate in a Listbox</p> <pre><code>&lt;ListBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock OverridesDefaultStyle="True" Background="{x:Nul...
[ { "answer_id": 424439, "author": "Rhys", "author_id": 22169, "author_profile": "https://Stackoverflow.com/users/22169", "pm_score": 0, "selected": false, "text": "<p>This is what I think is happening:-</p>\n\n<p>I'm assuming the ItemSource is a simple collection of bare strings values(i....
2009/01/07
[ "https://Stackoverflow.com/questions/422078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21186/" ]
I have the following DataTemplate in a Listbox ``` <ListBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock OverridesDefaultStyle="True" Background="{x:Null}" Margin="0" ...
If you are looking for a solution, maybe you can find what you want here: [Why can't I select a null value in a ComboBox?](https://stackoverflow.com/questions/518579/why-cant-i-select-a-null-value-in-a-combobox) Combobox has the same behavior as ListBox.
422,081
<p>I have a view which is derived from CEditView. It is read only. I would like to set the text as a kind of logging, but nothing shows up on the screen. If I inspect <code>temp</code> in the debugger after <code>GetEditCtrl().GetWindowText(temp);</code> I can see that the text is indeed changing internally, but I s...
[ { "answer_id": 422223, "author": "Joel", "author_id": 46852, "author_profile": "https://Stackoverflow.com/users/46852", "pm_score": 2, "selected": false, "text": "<p>The problem seems to lie somewhere other than in the code you posted. I created a new MFC app with the view derived from C...
2009/01/07
[ "https://Stackoverflow.com/questions/422081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
I have a view which is derived from CEditView. It is read only. I would like to set the text as a kind of logging, but nothing shows up on the screen. If I inspect `temp` in the debugger after `GetEditCtrl().GetWindowText(temp);` I can see that the text is indeed changing internally, but I see nothing on the screen. `...
Turns out that a third-party UI toolkit was reconstructing the View (who knows why?) so my pointer to it was stale. Thus, I was actually refreshing a different view!
422,090
<p>Is there a method in the System.IO namespace that checks the validity of a filename?</p> <p>For example, <code>C:\foo\bar</code> would validate and <code>:"~-*</code> would not</p> <p>Or a little trickier, <code>X:\foo\bar</code> would validate is there is an <code>X:</code> drive on the system, but wouldn't other...
[ { "answer_id": 422109, "author": "Eugene Katz", "author_id": 1533, "author_profile": "https://Stackoverflow.com/users/1533", "pm_score": 5, "selected": false, "text": "<p>You can get a list of invalid characters from <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.io.path.g...
2009/01/07
[ "https://Stackoverflow.com/questions/422090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a method in the System.IO namespace that checks the validity of a filename? For example, `C:\foo\bar` would validate and `:"~-*` would not Or a little trickier, `X:\foo\bar` would validate is there is an `X:` drive on the system, but wouldn't otherwise. I suppose I could write such a method myself, but I'm ...
Just do; ``` System.IO.FileInfo fi = null; try { fi = new System.IO.FileInfo(fileName); } catch (ArgumentException) { } catch (System.IO.PathTooLongException) { } catch (NotSupportedException) { } if (ReferenceEquals(fi, null)) { // file name is not valid } else { // file name is valid... May check for existence...
422,091
<p>How can I implement the following in python?</p> <pre><code>#include &lt;iostream&gt; int main() { std::string a; std::cout &lt;&lt; "What is your name? "; std::cin &gt;&gt; a; std::cout &lt;&lt; std::endl &lt;&lt; "You said: " &lt;&lt; a &lt;&lt; std::endl; } </code></pre> <p>Output:</p> <blockqu...
[ { "answer_id": 422105, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>Look at the <code>print</code> statement and the <code>raw_input()</code> function.</p>\n\n<p>Or look at <code>sys.stdin...
2009/01/07
[ "https://Stackoverflow.com/questions/422091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
How can I implement the following in python? ``` #include <iostream> int main() { std::string a; std::cout << "What is your name? "; std::cin >> a; std::cout << std::endl << "You said: " << a << std::endl; } ``` Output: > > What is your name? Nick > > > You said: Nick > > >
Call ``` name = raw_input('What is your name?') ``` and ``` print 'You said', name ```
422,108
<p>I am trying to add the following method to the Math class in Ruby on Rails:</p> <pre><code>class Math def self.round_with_precision(number, precision) scalar = 10.0 ** precision number = number * scalar number = number.round number = number / scalar return number; end end </code></pre> <p>I...
[ { "answer_id": 422117, "author": "Pedro Henriques", "author_id": 51164, "author_profile": "https://Stackoverflow.com/users/51164", "pm_score": 4, "selected": true, "text": "<p>Math is a module, just rename class to module.</p>\n" }, { "answer_id": 422150, "author": "Matt Darb...
2009/01/07
[ "https://Stackoverflow.com/questions/422108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
I am trying to add the following method to the Math class in Ruby on Rails: ``` class Math def self.round_with_precision(number, precision) scalar = 10.0 ** precision number = number * scalar number = number.round number = number / scalar return number; end end ``` I then added the following ...
Math is a module, just rename class to module.
422,181
<p>Is there a technique such that I can specify a number n such that when the (n + 1)th entry is inserted, the oldest entry is removed first ensuring that the size of the hashtable is always limited to n?</p>
[ { "answer_id": 422193, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "<p>You're looking for a <a href=\"http://en.wikipedia.org/wiki/Cache_algorithms\" rel=\"noreferrer\">LRU cache</a> perhaps? ...
2009/01/07
[ "https://Stackoverflow.com/questions/422181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a technique such that I can specify a number n such that when the (n + 1)th entry is inserted, the oldest entry is removed first ensuring that the size of the hashtable is always limited to n?
[LinkedHashMap](http://java.sun.com/javase/6/docs/api/java/util/LinkedHashMap.html) does exactly that, see javadoc for the [removeEldestEntry](http://java.sun.com/javase/6/docs/api/java/util/LinkedHashMap.html#removeEldestEntry(java.util.Map.Entry)) method. Something like this should do the trick, this will remove the...
422,186
<p>I have a value type that represents a gaussian distribution:</p> <pre><code>struct Gauss { double mean; double variance; } </code></pre> <p>I would like to perform an integral over a series of these values:</p> <pre><code>Gauss eulerIntegrate(double dt, Gauss iv, Gauss[] values) { Gauss r = iv; fo...
[ { "answer_id": 422213, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 4, "selected": true, "text": "<p>The sum of two normal distributions is itself a normal distribution:</p>\n\n<p><em>N(mean1, variance1) + N(mean2, v...
2009/01/07
[ "https://Stackoverflow.com/questions/422186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
I have a value type that represents a gaussian distribution: ``` struct Gauss { double mean; double variance; } ``` I would like to perform an integral over a series of these values: ``` Gauss eulerIntegrate(double dt, Gauss iv, Gauss[] values) { Gauss r = iv; foreach (Gauss v in values) { r...
The sum of two normal distributions is itself a normal distribution: *N(mean1, variance1) + N(mean2, variance2) ~ N(mean1 + mean2, variance1 + variance2)* This is all on [wikipedia page](http://en.wikipedia.org/wiki/Normal_distribution#Related_distributions). Be careful that these really are variances and not standa...
422,188
<p>I'm doing research into a web API for my company, and it's starting to look like we might implement a RESTful one. I've read a couple of books about this now (O'Reilly's "RESTful web services" seeming the most useful) and have come up with the following set of URIs and operations for an object that can be commented ...
[ { "answer_id": 422231, "author": "Martijn Laarman", "author_id": 47020, "author_profile": "https://Stackoverflow.com/users/47020", "pm_score": 1, "selected": false, "text": "<p>Well, the way I see it some of the information you return now as objects could simply be added to the metadata ...
2009/01/07
[ "https://Stackoverflow.com/questions/422188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13552/" ]
I'm doing research into a web API for my company, and it's starting to look like we might implement a RESTful one. I've read a couple of books about this now (O'Reilly's "RESTful web services" seeming the most useful) and have come up with the following set of URIs and operations for an object that can be commented on,...
Most of what you have looks good. There were just a couple of strange things I saw. When I put my URLs together, I try to follow these four principles. Peel the onion -------------- If you make the R in REST really be a resource then the resource URL should be able to be peeled back and still be meaningful. If it doe...
422,199
<p>What is the best way to discover what USB drives are connected, where they are mounted, and their unique details like Serial number, PID and which USB Hub port they are connected to? Something similar to what <a href="http://www.usblyzer.com/" rel="noreferrer">USBlyzer</a> does for Windows but programmatically.</p>
[ { "answer_id": 423685, "author": "mouviciel", "author_id": 45249, "author_profile": "https://Stackoverflow.com/users/45249", "pm_score": 0, "selected": false, "text": "<p>I'm not an expert of I/O on Mac OS X, but I've heard of <a href=\"http://developer.apple.com/documentation/devicedriv...
2009/01/07
[ "https://Stackoverflow.com/questions/422199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47110/" ]
What is the best way to discover what USB drives are connected, where they are mounted, and their unique details like Serial number, PID and which USB Hub port they are connected to? Something similar to what [USBlyzer](http://www.usblyzer.com/) does for Windows but programmatically.
You can use Terminal and execute: ``` system_profiler SPUSBDataType ``` It will show all connected USB devices, with detailed information.
422,207
<p>Let's say I'm generating markup through server-side code. I'm generating a bunch of HTML tags but I want to add custom client-side behavior.</p> <p>With JavaScript (if I had a reference to the DOM node) I could have written:</p> <pre><code>var myDOMNode = ... myDOMNode.myCustomAttribute = "Hi!"; </code></pre> <p>...
[ { "answer_id": 422233, "author": "Dan Williams", "author_id": 4230, "author_profile": "https://Stackoverflow.com/users/4230", "pm_score": 0, "selected": false, "text": "<p>How about this?</p>\n\n<pre><code>&lt;script&gt;\n function LoadElement(myDiv)\n {\n alert(this.myCusto...
2009/01/07
[ "https://Stackoverflow.com/questions/422207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58961/" ]
Let's say I'm generating markup through server-side code. I'm generating a bunch of HTML tags but I want to add custom client-side behavior. With JavaScript (if I had a reference to the DOM node) I could have written: ``` var myDOMNode = ... myDOMNode.myCustomAttribute = "Hi!"; ``` Now the issue here is that I don'...
I do appricate the input but I've finally figured this out and it's the way I go about *initialization* that has been the thorn in my side. What you never wan't do is to pollute your global namespace with a bunch of short lived identifiers. Any time you put `id=""` on an element you're doing exactly that (same thing f...
422,224
<pre><code> private void CheckBox_CheckedChanged(object sender, EventArgs e) { CheckBox chk = (CheckBox)sender; SetValuesInDB( System.Security.Principal.WindowsIdentity.GetCurrent().Name, DateTime.Today.Date); } </code></pre> <p>Now I want to setvalues of my id and cu...
[ { "answer_id": 422305, "author": "foson", "author_id": 22539, "author_profile": "https://Stackoverflow.com/users/22539", "pm_score": 2, "selected": false, "text": "<p>Use the CheckBox.Click event instead. It gets fired if either the user clicks on the checkbox or uses Space to toggle t...
2009/01/07
[ "https://Stackoverflow.com/questions/422224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
``` private void CheckBox_CheckedChanged(object sender, EventArgs e) { CheckBox chk = (CheckBox)sender; SetValuesInDB( System.Security.Principal.WindowsIdentity.GetCurrent().Name, DateTime.Today.Date); } ``` Now I want to setvalues of my id and current date in datab...
Use the CheckBox.Click event instead. It gets fired if either the user clicks on the checkbox or uses Space to toggle the checkbox.
422,230
<p>I'm using the .NET Fx 3.5 and have written my own configuration classes which inherit from ConfigurationSection/ConfigurationElement. Currently I end up with something that looks like this in my configuration file:</p> <pre><code>&lt;blah.mail&gt; &lt;templates&gt; &lt;add name="TemplateNbr1" subject="...
[ { "answer_id": 453918, "author": "oefe", "author_id": 49793, "author_profile": "https://Stackoverflow.com/users/49793", "pm_score": 2, "selected": false, "text": "<p>In your ConfigurationElement subclass, try overriding SerializeElement using XmlWriter.WriteCData to write your data, and ...
2009/01/07
[ "https://Stackoverflow.com/questions/422230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5645/" ]
I'm using the .NET Fx 3.5 and have written my own configuration classes which inherit from ConfigurationSection/ConfigurationElement. Currently I end up with something that looks like this in my configuration file: ``` <blah.mail> <templates> <add name="TemplateNbr1" subject="..." body="Hi!\r\nThis is a te...
In your custom configuration element class you need to override method `OnDeserializeUnrecognizedElement`. Example: ``` public class PluginConfigurationElement : ConfigurationElement { public NameValueCollection CustomProperies { get; set; } public PluginConfigurationElement() { this.CustomPrope...
422,234
<p>How can you make the ASP.net Session Data available to a JavaScript method? I found <a href="http://blogs.msdn.com/mattgi/archive/2006/11/15/accessing-session-data-from-javascript.aspx" rel="nofollow noreferrer">this</a> link when I googled. Anyone has a better trick that does not use the ScriptManager? </p>
[ { "answer_id": 422248, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 1, "selected": false, "text": "<p>You have to put it into the page somehow. Using hidden form fields is one approach. Using webmethods like your link is ...
2009/01/07
[ "https://Stackoverflow.com/questions/422234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37494/" ]
How can you make the ASP.net Session Data available to a JavaScript method? I found [this](http://blogs.msdn.com/mattgi/archive/2006/11/15/accessing-session-data-from-javascript.aspx) link when I googled. Anyone has a better trick that does not use the ScriptManager?
If ditching the ScriptManager is your aim, exposing the page method is still a good option, just use javascript that doesn't rely on the ScriptManager js libraries. I like the solution proposed in the linked page, but it might be a too wide open though. Maybe you want to create a strongly typed and controlled PageMet...
422,236
<p>The intent here is to deal with obfuscated passwords for resources.</p> <p>We have an Advisor that intercepts calls to setPassword and decrypts the argument.</p> <p>We've set up a template that looks somewhat like this:</p> <pre><code>&lt;bean id="pwAdvisor" class="org.springframework.aop.support.NameMatchMethodP...
[ { "answer_id": 422424, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 0, "selected": false, "text": "<p>I thought you wanted the beforeMethod advice to use the encrypted password String that's passed into the setPassword me...
2009/01/07
[ "https://Stackoverflow.com/questions/422236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13757/" ]
The intent here is to deal with obfuscated passwords for resources. We have an Advisor that intercepts calls to setPassword and decrypts the argument. We've set up a template that looks somewhat like this: ``` <bean id="pwAdvisor" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"> <property n...
My first effort was poor, but I was in hurry. I apologize. Now I think I know how it should work, because I believe I've implemented what you want myself. I started with a Credential class (note: no interface): ``` package aop; import org.springframework.context.ApplicationContext; import org.springframework.cont...
422,241
<p>I have two process and a shared memory zone, my workflow is like this. The process A write some data in the shared memory, after that it should wait and send a signal to other process B to start running. The process B should read some data from the shared memory do some stuff write the result, and send a signal to t...
[ { "answer_id": 422279, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 2, "selected": false, "text": "<p>Not quite what you've asked for, but could you use pipes (named or otherwise) to affect the synchr...
2009/01/07
[ "https://Stackoverflow.com/questions/422241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39160/" ]
I have two process and a shared memory zone, my workflow is like this. The process A write some data in the shared memory, after that it should wait and send a signal to other process B to start running. The process B should read some data from the shared memory do some stuff write the result, and send a signal to the ...
Here is a proof-of-concept of how it can be done: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #include <unistd.h> #include <assert.h> typedef void (*sighandler_t)(int); #define SHM_SIZE 8 /* size of shared memor...
422,242
<p>Here's a piece of code to take a string (either NSString or NSAttributedString) <code>input</code> that represents a command line and parse it into two strings, the command <code>cmd</code> and the arguments <code>args</code>:</p> <pre><code>NSString* cmd = [[input mutableCopy] autorelease]; NSString* args = [[inpu...
[ { "answer_id": 422310, "author": "Zach Langley", "author_id": 45230, "author_profile": "https://Stackoverflow.com/users/45230", "pm_score": 3, "selected": false, "text": "<p>Something like this?</p>\n\n<pre><code>int index = [input rangeOfString:@\" \"].location;\nNSString *cmd = [input ...
2009/01/07
[ "https://Stackoverflow.com/questions/422242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
Here's a piece of code to take a string (either NSString or NSAttributedString) `input` that represents a command line and parse it into two strings, the command `cmd` and the arguments `args`: ``` NSString* cmd = [[input mutableCopy] autorelease]; NSString* args = [[input mutableCopy] autorelease]; NSScanner* scanner...
``` NSString *cmd; NSScanner *scanner = [NSScanner scannerWithString:[inStr string]]; [scanner scanUpToCharactersFromSet:[NSCharacterSet whitespaceAndNewlineCharacterSet] intoString:&cmd]; NSString *args = [[scanner string] substringFromIndex:[scanner scanLoc...
422,246
<p>I have a C# base class that I was to associate information with on a per-type (rather than per-instance) basis. Essentially I want all child classes to present an Icon and a FriendlyName that represents the type. I'd like to <em>not</em> have to create a type instance to get this information and I want to require ...
[ { "answer_id": 422276, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 1, "selected": false, "text": "<p>If you want to absolutely dictate that the child implement this, then the only way I see doing it is making the base ...
2009/01/07
[ "https://Stackoverflow.com/questions/422246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13154/" ]
I have a C# base class that I was to associate information with on a per-type (rather than per-instance) basis. Essentially I want all child classes to present an Icon and a FriendlyName that represents the type. I'd like to *not* have to create a type instance to get this information and I want to require that all chi...
If you want to absolutely dictate that the child implement this, then the only way I see doing it is making the base class abstract, and expose instance properties to return the icon and friendly name. These would be abstract, not virtual, so you force the implementation by the derived class. I know it's not clean, in...
422,270
<p>In Access, what is the difference between these two statements?</p> <pre><code>DBEngine.BeginTrans </code></pre> <p>and</p> <pre><code>DBEngine.Workspaces(0).BeginTrans </code></pre> <p>The documentation for both leads to the same place.</p>
[ { "answer_id": 422376, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 3, "selected": false, "text": "<p>Have a look here: <a href=\"http://msdn.microsoft.com/en-us/library/aa293491(VS.60).aspx\" rel=\"noreferrer\">DAO Wor...
2009/01/07
[ "https://Stackoverflow.com/questions/422270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
In Access, what is the difference between these two statements? ``` DBEngine.BeginTrans ``` and ``` DBEngine.Workspaces(0).BeginTrans ``` The documentation for both leads to the same place.
My own answer: It appears that DBEngine.BeginTrans and DBEngine.Workspaces(0).BeginTrans do the same thing because this code works (see below). "Workspaces" is the default member of DBEngine. ``` Dim db As Database Set db = CurrentDb DBEngine.BeginTrans db.Execute "Update Table1 SET CITY='Newark'" DBEngine.Workspace...
422,296
<p>I want to display an image at 'true size' in my application. For that I need to know the pixel size of the display.</p> <p>I know windows display resolution is nominally 96dpi, but for my purposes I want a better guess. I understand this information may not always be available or accurate (e.g. older CRT displays...
[ { "answer_id": 422322, "author": "Stephen Wrighton", "author_id": 7516, "author_profile": "https://Stackoverflow.com/users/7516", "pm_score": 1, "selected": false, "text": "<p>sorry, you've got to P/Invoke for this information.</p>\n\n<p>Here's the link that I utilized for it a while ago...
2009/01/07
[ "https://Stackoverflow.com/questions/422296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31531/" ]
I want to display an image at 'true size' in my application. For that I need to know the pixel size of the display. I know windows display resolution is nominally 96dpi, but for my purposes I want a better guess. I understand this information may not always be available or accurate (e.g. older CRT displays), but I ima...
For the display size you'll want [`Screen`](http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx)`.PrimaryScreen.Bounds.Size` (or `Screen.GetBounds(myform)`). If you want the DPI, use the [DpiX](http://msdn.microsoft.com/en-us/library/system.drawing.graphics.dpix.aspx) and [DpiY](http://msdn.micros...
422,327
<p>What is the best way to test the speed of a LAMP based site, without factoring in the user's connection?</p> <p>In other words, I have a CMS and I want to see how long it takes for PHP and MySQL to do all their work.</p> <p>Additionally I do not have shell access to the server, it is in a shared hosting environmen...
[ { "answer_id": 422359, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 3, "selected": true, "text": "<p>The best way in this case is to let the server count itself. Wrap your CMS code to store the time the operation started, t...
2009/01/07
[ "https://Stackoverflow.com/questions/422327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46540/" ]
What is the best way to test the speed of a LAMP based site, without factoring in the user's connection? In other words, I have a CMS and I want to see how long it takes for PHP and MySQL to do all their work. Additionally I do not have shell access to the server, it is in a shared hosting environment.
The best way in this case is to let the server count itself. Wrap your CMS code to store the time the operation started, then substract it from the current time at the end of the script and print it. You can use this code to read the time value: ``` function curtime() { $tm = explode(' ', microtime()); ...
422,328
<p>Does anyone know any Firefox add-on that can show you the size of the current viewing page?</p>
[ { "answer_id": 422335, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 3, "selected": false, "text": "<p><a href=\"https://addons.mozilla.org/en-US/firefox/addon/60\" rel=\"nofollow noreferrer\">Web Developer Toolbar</a> (dime...
2009/01/07
[ "https://Stackoverflow.com/questions/422328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
Does anyone know any Firefox add-on that can show you the size of the current viewing page?
If you're optimizing your page size (in kilobytes, not pixels!) you need to know both the compressed sizes of each element if your server is gzipping your output. You can't get that with the standard web browser "right-click-->Properties." The Web Developer Toolbar extension, mentioned in another reply, does this. <...
422,332
<p>I am using a third-party application, and making a call to create an instance of <strong>my</strong> COM object. This call is succeeding, however the function on the third-party application does <em>not</em> return a pointer to the created object (I have no idea why). Is there any way to get a pointer to my object...
[ { "answer_id": 422386, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 3, "selected": true, "text": "<p>When your object is created, make it store a reference to itself in a global variable or some other sort of shareabl...
2009/01/07
[ "https://Stackoverflow.com/questions/422332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37474/" ]
I am using a third-party application, and making a call to create an instance of **my** COM object. This call is succeeding, however the function on the third-party application does *not* return a pointer to the created object (I have no idea why). Is there any way to get a pointer to my object? To clarify, here's som...
When your object is created, make it store a reference to itself in a global variable or some other sort of shareable storage location. Then export a function from your COM DLL that will read from that location so you can call it and get a reference to the previously created object. This shared reference should *not* ...
422,342
<p>For Example: Let's say that I want to return a <strong>view</strong> that displays a list of cars and also show a section of dealers in your area. These are two disjointed pieces of data.</p> <p>My <strong>view</strong> inherits a list of cars like the following:</p> <pre><code>public partial class CarLot : ViewP...
[ { "answer_id": 422366, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 5, "selected": true, "text": "<p>Create a data transfer object</p>\n\n<pre><code>public class CarLotViewModel\n{\n public List&lt;Car&gt; Cars { g...
2009/01/07
[ "https://Stackoverflow.com/questions/422342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47576/" ]
For Example: Let's say that I want to return a **view** that displays a list of cars and also show a section of dealers in your area. These are two disjointed pieces of data. My **view** inherits a list of cars like the following: ``` public partial class CarLot : ViewPage<List<Cars>> { } ``` Now from the **contro...
Create a data transfer object ``` public class CarLotViewModel { public List<Car> Cars { get; set; } public List<Dealer> NearbyDealers { get; set; } } ``` Set your view to use the view model: ``` public partial class CarLot : ViewPage<CarLotViewModel> { } ``` Then in your controller: ``` var model ...
422,355
<p>In trying to make my Javascript unobtrusive, I'm using <code>onLoad</code>s to add functionality to <code>&lt;input&gt;</code>s and such. With Dojo, this looks something like:</p> <pre><code>var coolInput = dojo.byId('cool_input'); if(coolInput) { dojo.addOnLoad(function() { coolInput.onkeyup = function() { ...
[ { "answer_id": 422409, "author": "ihumanable", "author_id": 52639, "author_profile": "https://Stackoverflow.com/users/52639", "pm_score": 0, "selected": false, "text": "<p>As far as I know there isn't a built-in JavaScript function that has that same functionality. I think the best solu...
2009/01/07
[ "https://Stackoverflow.com/questions/422355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
In trying to make my Javascript unobtrusive, I'm using `onLoad`s to add functionality to `<input>`s and such. With Dojo, this looks something like: ``` var coolInput = dojo.byId('cool_input'); if(coolInput) { dojo.addOnLoad(function() { coolInput.onkeyup = function() { ... }; }); } ``` Or, approximately equi...
The exact syntax you want is not possible in JavaScript. The way JavaScript executes would need to change in a pretty fundamental fashion. For example: ``` var name = getUserById(id).andand().name; // ^ // |------------------------------- // if getUserById returns null, ex...
422,379
<p>I have a class that I am unit testing into with DUnit. It has a number of methods some public methods and private methods.</p> <pre><code>type TAuth = class(TDataModule) private procedure PrivateMethod; public procedure PublicMethod; end; </code></pre> <p>In order to write a unit test for this clas...
[ { "answer_id": 422400, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 5, "selected": true, "text": "<p>You don't need to make them public. Protected will do. Then you can subtype the class for unit testing and surface th...
2009/01/07
[ "https://Stackoverflow.com/questions/422379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
I have a class that I am unit testing into with DUnit. It has a number of methods some public methods and private methods. ``` type TAuth = class(TDataModule) private procedure PrivateMethod; public procedure PublicMethod; end; ``` In order to write a unit test for this class I have to make all the m...
You don't need to make them public. Protected will do. Then you can subtype the class for unit testing and surface the protected methods. Example: ``` type TAuth = class(TDataModule) protected procedure MethodIWantToUnitTest; public procedure PublicMethod; end; ``` Now you can subtype it for your uni...
422,389
<p>I'm having problems allocating and deallocating my memory in a recursive C++ program. So without using an automatic memory management solution, I wonder if anyone can help me resolve the memory leak I am experiencing.</p> <p>The following code essentially explains the problem (although it's a contrived example, ple...
[ { "answer_id": 422405, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 5, "selected": true, "text": "<p>The problem is here:</p>\n\n<pre><code>Number&amp; operator + (const Number&amp; n1) const {\n Number result = ...
2009/01/07
[ "https://Stackoverflow.com/questions/422389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
I'm having problems allocating and deallocating my memory in a recursive C++ program. So without using an automatic memory management solution, I wonder if anyone can help me resolve the memory leak I am experiencing. The following code essentially explains the problem (although it's a contrived example, please correc...
The problem is here: ``` Number& operator + (const Number& n1) const { Number result = value + n1.value; return result; }; ``` You're returning a local variable (`result`) by reference, and that's a big NO-NO. Local variables are allocated on the stack, and when the function exits, the variables are gone. Re...
422,401
<p>My employers website has multiple hostnames that all hit the same server and we just show different skins for branding purposes.</p> <p>Unfortunately WCF doesn't seem to work well in this situation. </p> <p>I've tried <a href="http://www.robzelt.com/blog/2007/01/24/WCF+This+Collection+Already+Contains+An+Address+...
[ { "answer_id": 422502, "author": "thaBadDawg", "author_id": 48832, "author_profile": "https://Stackoverflow.com/users/48832", "pm_score": 4, "selected": true, "text": "<p>If you don't put an address in the endpoint then it should resolve to whatever server hits the service. I use this co...
2009/01/07
[ "https://Stackoverflow.com/questions/422401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45005/" ]
My employers website has multiple hostnames that all hit the same server and we just show different skins for branding purposes. Unfortunately WCF doesn't seem to work well in this situation. I've tried [overriding the default host with a custom host factory](http://www.robzelt.com/blog/2007/01/24/WCF+This+Collectio...
If you don't put an address in the endpoint then it should resolve to whatever server hits the service. I use this code and it resolves both to my .local address and to my .com address from IIS. ``` <system.serviceModel> <services> <service name="ServiceName" behaviorConfiguration="ServiceName.Service1Beha...
422,411
<p>I am struggling a bit to figure this one out. </p> <p>I'm working on an ASP.NET MVC project, using LINQ to SQL for my data layer. The database consists of 10 or so different "exceptions" tables, e.g. "Exceptions.LADM", "Exceptions.USB", "Exceptions.GPO". Basically these tables are tracking user+machine information ...
[ { "answer_id": 422466, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": true, "text": "<p>You could try dynamic method dispatching by using reflection (it's pretty costly, performance-wise):</p>\n\n<pre><code>objec...
2009/01/07
[ "https://Stackoverflow.com/questions/422411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16522/" ]
I am struggling a bit to figure this one out. I'm working on an ASP.NET MVC project, using LINQ to SQL for my data layer. The database consists of 10 or so different "exceptions" tables, e.g. "Exceptions.LADM", "Exceptions.USB", "Exceptions.GPO". Basically these tables are tracking user+machine information for relaxa...
You could try dynamic method dispatching by using reflection (it's pretty costly, performance-wise): ``` object items = _repository.GetType().GetMethod("ListAll"+type+"Exceptions") .Invoke(_repository, null); ``` I would write a `switch` statement (not `if/else`) for 10 cases however. It's ...
422,440
<p>In domain driven design, it appears to be a good practice to use Factories to create your domain objects in your domain layer (as opposed to using a direct constructor or IoC). </p> <p>But what about using the domain object factories in a presenter layer. For instance, say that I was creating a domain object from u...
[ { "answer_id": 422483, "author": "RS Conley", "author_id": 7890, "author_profile": "https://Stackoverflow.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>There are two main ways I would handle this</p>\n\n<p>1) If this is setup through a dialog I would create classes imple...
2009/01/07
[ "https://Stackoverflow.com/questions/422440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25847/" ]
In domain driven design, it appears to be a good practice to use Factories to create your domain objects in your domain layer (as opposed to using a direct constructor or IoC). But what about using the domain object factories in a presenter layer. For instance, say that I was creating a domain object from user input ...
I'd advise against letting your domain objects out of the domain layer and into the presentation layer. Keep the presentation layer focused on presentation. For this reason, I construct Data Transfer Objects to shuffle data to and from the domain and presentation layers. In your case, have the dialog populate a DTO th...
422,452
<p>currently writes an application to connect to the device "BTLink Bluetooth to Serial Adapter"</p> <p>More information about device: <a href="http://cgi.ebay.pl/Bluetooth-to-RS232-Serial-Adapter-Dongle-100m-UK_W0QQitemZ300266522534QQcmdZViewItem?hash=item300266522534&amp;_trkparms=72%3A1399|39%3A1|66%3A2|65%3A12|240...
[ { "answer_id": 422483, "author": "RS Conley", "author_id": 7890, "author_profile": "https://Stackoverflow.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>There are two main ways I would handle this</p>\n\n<p>1) If this is setup through a dialog I would create classes imple...
2009/01/07
[ "https://Stackoverflow.com/questions/422452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51591/" ]
currently writes an application to connect to the device "BTLink Bluetooth to Serial Adapter" More information about device: [device specification](http://cgi.ebay.pl/Bluetooth-to-RS232-Serial-Adapter-Dongle-100m-UK_W0QQitemZ300266522534QQcmdZViewItem?hash=item300266522534&_trkparms=72%3A1399|39%3A1|66%3A2|65%3A12|240...
I'd advise against letting your domain objects out of the domain layer and into the presentation layer. Keep the presentation layer focused on presentation. For this reason, I construct Data Transfer Objects to shuffle data to and from the domain and presentation layers. In your case, have the dialog populate a DTO th...
422,476
<p>Could you explain the difference between setting methods in the constructor and through prototype object? The following code shows these two ways of setting the methods - <code>say_hello</code> and <code>say_bye</code> both work fine:</p> <pre><code>function MessageClass() { this.say_bye = function() { alert('see...
[ { "answer_id": 422484, "author": "foxxtrot", "author_id": 10369, "author_profile": "https://Stackoverflow.com/users/10369", "pm_score": 3, "selected": false, "text": "<p>The difference is when you derive a class from Message Class. Only the methods declared on the prototype will be avail...
2009/01/07
[ "https://Stackoverflow.com/questions/422476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34134/" ]
Could you explain the difference between setting methods in the constructor and through prototype object? The following code shows these two ways of setting the methods - `say_hello` and `say_bye` both work fine: ``` function MessageClass() { this.say_bye = function() { alert('see ya'); }; } MessageClass.prototype....
foxxtrot and annakata are both correct, but I'll throw in my 2 cents. If you use the prototype then each instance of the "MessageClass" is really referencing the same functions. The functions exist in memory only once and are used for all instances. If you declare the methods in the constructor (or otherwise add it to...
422,486
<p>Perhaps I'm missing something with the concept of Extension Methods, but I cannot gain access to the Extension Methods within the KeyCollection Class as defined here: <a href="http://msdn.microsoft.com/en-us/library/dk7e2d8e.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dk7e2d8e.aspx</a>.</...
[ { "answer_id": 422494, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 4, "selected": true, "text": "<p>I just tried it and it looks like I can.</p>\n\n<p>You didn't forget</p>\n\n<pre><code>using System.Linq;\n</code></...
2009/01/07
[ "https://Stackoverflow.com/questions/422486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52653/" ]
Perhaps I'm missing something with the concept of Extension Methods, but I cannot gain access to the Extension Methods within the KeyCollection Class as defined here: <http://msdn.microsoft.com/en-us/library/dk7e2d8e.aspx>. Using the following code excerpt: ``` Dictionary<int, int> foo = new Dictionary<int,int>();...
I just tried it and it looks like I can. You didn't forget ``` using System.Linq; ``` did you?
422,530
<p>I have a pair of shell programs that talk over a named pipe. The reader creates the pipe when it starts, and removes it when it exits.</p> <p>Sometimes, the writer will attempt to write to the pipe between the time that the reader stops reading and the time that it removes the pipe.</p> <pre><code>reader: while co...
[ { "answer_id": 422792, "author": "Norman Ramsey", "author_id": 41661, "author_profile": "https://Stackoverflow.com/users/41661", "pm_score": 1, "selected": false, "text": "<p>This question comes up periodically (though I couldn't find it with a search). I've written two shell scripts to...
2009/01/07
[ "https://Stackoverflow.com/questions/422530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a pair of shell programs that talk over a named pipe. The reader creates the pipe when it starts, and removes it when it exits. Sometimes, the writer will attempt to write to the pipe between the time that the reader stops reading and the time that it removes the pipe. ``` reader: while condition; do read data...
This pair of programs works much more nicely after being re-written in Perl using Unix domain sockets instead of named pipes. The particular problem in this question went away entirely, since if/when one end dies the connection disappears instead of hanging.
422,536
<p>I'm just learning ruby and trying to understand the scope of code executed in blocks. For example, I want to be able to create a block that affects the method that it is attached to, like so:</p> <pre><code>def test(&amp;block) block.call() if block_given? puts "in test, foo is #{foo}" puts "in test, bar is #...
[ { "answer_id": 422564, "author": "krusty.ar", "author_id": 43981, "author_profile": "https://Stackoverflow.com/users/43981", "pm_score": 5, "selected": true, "text": "<p>First of all, <code>block.call()</code> is done with <code>yield</code>, and you don't need the <code>&amp;block</code...
2009/01/07
[ "https://Stackoverflow.com/questions/422536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7432/" ]
I'm just learning ruby and trying to understand the scope of code executed in blocks. For example, I want to be able to create a block that affects the method that it is attached to, like so: ``` def test(&block) block.call() if block_given? puts "in test, foo is #{foo}" puts "in test, bar is #{bar}" end test()...
First of all, `block.call()` is done with `yield`, and you don't need the `&block` parameter that way. You can't normally do what you want, blocks are bound when they are created, and inside the block you can see the local variables defined at that moment; the easiest way to do what you want, which is not how you will...
422,542
<p>I'm trying to create a feature that both creates a list template and an instance of that list (using the <code>&lt;ListTemplate</code>> and <code>&lt;ListInstance</code>> elements. I would like for content approval to be turned on by default. According to the <a href="http://msdn.microsoft.com/en-us/library/ms462947...
[ { "answer_id": 424298, "author": "Jason", "author_id": 10639, "author_profile": "https://Stackoverflow.com/users/10639", "pm_score": 1, "selected": false, "text": "<p>Does your custom list have a field of type 'ModStat' on it? </p>\n\n<blockquote>\n <p>ModStat Specifies Content Appro...
2009/01/07
[ "https://Stackoverflow.com/questions/422542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21957/" ]
I'm trying to create a feature that both creates a list template and an instance of that list (using the `<ListTemplate`> and `<ListInstance`> elements. I would like for content approval to be turned on by default. According to the [docs on ListTemplate](http://msdn.microsoft.com/en-us/library/ms462947.aspx), setting t...
I ended up just using the feature receiver approach, since I just needed to move on. However, I later found that the [List element](http://msdn.microsoft.com/en-us/library/ms415091.aspx) used for defining your list schema also has ModeratedList and ModerationType properties that look like they probably have something t...
422,553
<p>How do you go about creating an instance of an object when given the class name as a string in an ASP.NET v2 application? For example, I've got a class called SystemLog defined in the app_code section of the application. The class is defined within the Reports namespace. To create an instance of the object, I do som...
[ { "answer_id": 422572, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 4, "selected": true, "text": "<pre><code>string typeName = \"Your Type Name Here\";\nType t = Type.GetType(typeName);\nobject o = Activator.CreateIns...
2009/01/07
[ "https://Stackoverflow.com/questions/422553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18128/" ]
How do you go about creating an instance of an object when given the class name as a string in an ASP.NET v2 application? For example, I've got a class called SystemLog defined in the app\_code section of the application. The class is defined within the Reports namespace. To create an instance of the object, I do somet...
``` string typeName = "Your Type Name Here"; Type t = Type.GetType(typeName); object o = Activator.CreateInstance(t); ``` This will give you an instanciated type. If will be up to you to cast it to the correct type and call your appropriate methods. If you need to create a type that doesn't have a parameterless con...
422,554
<p>This one has been a stumper for me. Its very easy to duplicate though a rather obscure issue. It came about as I was doing some javascript work on a web page yet also make use of the validation controls that ASP.NET provides.</p> <p>Some specifics up front: using a Vista-based development machine with the 3.5 fra...
[ { "answer_id": 422952, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 1, "selected": false, "text": "<p>I am having the same issue with a similar setup. Differences in the browserCaps settings is the most promising possibilit...
2009/01/07
[ "https://Stackoverflow.com/questions/422554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3874797/" ]
This one has been a stumper for me. Its very easy to duplicate though a rather obscure issue. It came about as I was doing some javascript work on a web page yet also make use of the validation controls that ASP.NET provides. Some specifics up front: using a Vista-based development machine with the 3.5 framework and I...
Check your web.config for xhtmlconformance and make sure it is not set to legacy. <http://aspadvice.com/blogs/rbirkby/archive/2006/11/01/Client_2D00_side-validation-in-Firefox.aspx>
422,555
<p>I've got a Python program using PIL to render text, and it works great with all kinds of fonts. But it only draws "missing glyph" rectangles with wingdings or webdings.</p> <p>Here's a sample that tries to draw every unicode character:</p> <pre><code># Run this with .ttf file path as an argument, and also an enco...
[ { "answer_id": 422630, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 3, "selected": true, "text": "<p>I must have done something wrong before. \"symb\" as the encoding works for wingdings too! Sorry for the noise....
2009/01/07
[ "https://Stackoverflow.com/questions/422555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14343/" ]
I've got a Python program using PIL to render text, and it works great with all kinds of fonts. But it only draws "missing glyph" rectangles with wingdings or webdings. Here's a sample that tries to draw every unicode character: ``` # Run this with .ttf file path as an argument, and also an encoding if you like. # It...
I must have done something wrong before. "symb" as the encoding works for wingdings too! Sorry for the noise...
422,597
<p>is there a way to hide columns of a buffer (text file, you know what I mean) while editing it in Vim? e.g. text visible in the buffer before hiding column 2&amp;3:</p> <pre><code>abbcccccc accdddddd </code></pre> <p>And after hiding them:</p> <pre><code>acccccc adddddd </code></pre> <p>(Not to mention I'm worki...
[ { "answer_id": 422610, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 2, "selected": false, "text": "<p>Is <a href=\"http://www.vim.org/scripts/script.php?script_id=1161\" rel=\"nofollow noreferrer\">foldcol.vim</a> maybe what ...
2009/01/07
[ "https://Stackoverflow.com/questions/422597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11621/" ]
is there a way to hide columns of a buffer (text file, you know what I mean) while editing it in Vim? e.g. text visible in the buffer before hiding column 2&3: ``` abbcccccc accdddddd ``` And after hiding them: ``` acccccc adddddd ``` (Not to mention I'm working with really huge files (sometimes over 200 gb).) A...
Cannot be done in stock vim; there is a conceal patch that has not been accepted. The most recent version is only for vim7, and not 7.2 (much less 7.2+patches), so it's probably best considered dead.
422,600
<p>Is there a canonical or recommended pattern for implementing arithmetic operator overloading in C++ number-like classes?</p> <p>From the C++ FAQ, we have an exception-safe assignment operator that avoids most problems:</p> <pre><code>class NumberImpl; class Number { NumberImpl *Impl; ... }; Number&amp; Nu...
[ { "answer_id": 422688, "author": "John Mulder", "author_id": 2242, "author_profile": "https://Stackoverflow.com/users/2242", "pm_score": 3, "selected": true, "text": "<p>In Bjarne Stroustrup's book \"<a href=\"https://rads.stackoverflow.com/amzn/click/com/0201700735\" rel=\"nofollow nore...
2009/01/07
[ "https://Stackoverflow.com/questions/422600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8701/" ]
Is there a canonical or recommended pattern for implementing arithmetic operator overloading in C++ number-like classes? From the C++ FAQ, we have an exception-safe assignment operator that avoids most problems: ``` class NumberImpl; class Number { NumberImpl *Impl; ... }; Number& Number::operator=(const Num...
In Bjarne Stroustrup's book "[The C++ Programming Language](https://rads.stackoverflow.com/amzn/click/com/0201700735)", in chapter 11 (the one devoted to Operator Overloading) he goes through witting a class for a complex number type (section 11.3). One thing I do notice from that section is that he implements mixed ...
422,608
<p>I have a UITextField in a view (on an iPhone) but the input text appears very small. I don't see an option in Interface Builder to set the size.</p> <p>Is there a way to set it declaratively or do I have to resort to code?</p>
[ { "answer_id": 422619, "author": "Sophie Alpert", "author_id": 49485, "author_profile": "https://Stackoverflow.com/users/49485", "pm_score": 2, "selected": false, "text": "<p>Press Cmd-T for the Fonts panel.</p>\n" }, { "answer_id": 422670, "author": "Genericrich", "autho...
2009/01/07
[ "https://Stackoverflow.com/questions/422608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35958/" ]
I have a UITextField in a view (on an iPhone) but the input text appears very small. I don't see an option in Interface Builder to set the size. Is there a way to set it declaratively or do I have to resort to code?
You can do it in code as well: ``` myUITextField.font = [UIFont systemFontOfSize:12.0f]; ``` Cheers.
422,625
<p>I have a method that I'm writing that is calling another overloaded method inside it. I'd like to only write one outer method, since the parameter to the outer method is being passed to the inner one. Is there a way to do this?</p> <p>I tried using generics, but I don't know enough about this so it isn't working:...
[ { "answer_id": 422668, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 3, "selected": true, "text": "<p>You can do this in C++ but not in C# (unless the inner method can also be generic instead of overloaded).</p>\n\n<hr>\n\n...
2009/01/07
[ "https://Stackoverflow.com/questions/422625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16320/" ]
I have a method that I'm writing that is calling another overloaded method inside it. I'd like to only write one outer method, since the parameter to the outer method is being passed to the inner one. Is there a way to do this? I tried using generics, but I don't know enough about this so it isn't working: ``` public...
You can do this in C++ but not in C# (unless the inner method can also be generic instead of overloaded). --- Alternatively (if you won't take 'no' for an answer), you can do a run-time switch on type, like for example ... ``` public void OuterMethod(object parameter) { if (parameter is int) InnerMethod(...
422,713
<p>I'm working on a script that sadly I inherited - with no commenting or anything. Argh! For testing purposes I duplicated one of the tables in the database which had an auto-incrementing ID. When the data is saved to the database, though, the ID number just reads "0" -- which is the default for that column. I'm not ...
[ { "answer_id": 422716, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 2, "selected": false, "text": "<p>Are you sure you set the field in the duplicate table to auto-increment? Try running:</p>\n\n<pre><code> ALTER TA...
2009/01/08
[ "https://Stackoverflow.com/questions/422713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm working on a script that sadly I inherited - with no commenting or anything. Argh! For testing purposes I duplicated one of the tables in the database which had an auto-incrementing ID. When the data is saved to the database, though, the ID number just reads "0" -- which is the default for that column. I'm not sur...
Are you sure you set the field in the duplicate table to auto-increment? Try running: ``` ALTER TABLE `duplicate_table` CHANGE `ai_key` `ai_key` INT( key_length ) NOT NULL AUTO_INCREMENT ``` And see if it is set or not.
422,738
<p>I'm trying to use the CRT memory leak detection but I keep getting the following message in Microsoft Visual Studio: "Detected memory leaks - skipping object dump." I can never get the it to actually do and object dump.</p> <p>I followed the directions in the Microsoft article on Memory Leak Detection (<a href="htt...
[ { "answer_id": 422753, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 2, "selected": true, "text": "<p>I don't have it here on my machine, but when you instal MSVC you have the option of installing (most of the) source code ...
2009/01/08
[ "https://Stackoverflow.com/questions/422738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28760/" ]
I'm trying to use the CRT memory leak detection but I keep getting the following message in Microsoft Visual Studio: "Detected memory leaks - skipping object dump." I can never get the it to actually do and object dump. I followed the directions in the Microsoft article on Memory Leak Detection (<http://msdn.microsoft...
I don't have it here on my machine, but when you instal MSVC you have the option of installing (most of the) source code for the C run-time library (i.e. for MSVCRTxx.xxx). If you look in that source code for "skipping object dump" then you might be able to work out why the object dump is being skipped.
422,747
<p>I'm interested in speed, not good looking code, that is why I'm using array and not list(of integer).</p> <p>I have an array looking like: 0,1,0,1,1,0,1,0,1,1,1,0,0,1</p> <p>I'm interesting in the position of each number so I can later pick one randomly.</p> <p>so what I do is looping through the array to take po...
[ { "answer_id": 422760, "author": "Stephan Eggermont", "author_id": 35306, "author_profile": "https://Stackoverflow.com/users/35306", "pm_score": 0, "selected": false, "text": "<p>Speed for how many items? </p>\n\n<p>Changing items? </p>\n\n<p>Compile time or execution time? </p>\n\n<p>Wi...
2009/01/08
[ "https://Stackoverflow.com/questions/422747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40868/" ]
I'm interested in speed, not good looking code, that is why I'm using array and not list(of integer). I have an array looking like: 0,1,0,1,1,0,1,0,1,1,1,0,0,1 I'm interesting in the position of each number so I can later pick one randomly. so what I do is looping through the array to take position number of each 1 ...
Few tips on the original algorithm: 1. Try storing the results of arIn.GetUpperBound(0) in a variable. I don't know how VB makes it's loops, but there is a chance that the function gets called once every iteration. You should check that though. 2. That `If arCount > -1` is always going to be true. Remove it. If you w...
422,768
<p>When writing plugins for media center your plugin is hosted in <code>ehexthost.exe</code> this exe gets launched from <code>ehshell.exe</code> and you have no way of launching it directly, instead you pass a special param to <code>ehshell.exe</code> which will launch the plugin in a separate process.</p> <p>When we...
[ { "answer_id": 422816, "author": "galets", "author_id": 14395, "author_profile": "https://Stackoverflow.com/users/14395", "pm_score": 0, "selected": false, "text": "<p>You can automatically attach to a process by pressing F5, if you setup something like that in visual studio:</p>\n\n<p><...
2009/01/08
[ "https://Stackoverflow.com/questions/422768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
When writing plugins for media center your plugin is hosted in `ehexthost.exe` this exe gets launched from `ehshell.exe` and you have no way of launching it directly, instead you pass a special param to `ehshell.exe` which will launch the plugin in a separate process. When we are debugging [media browser](http://code....
I would use a macro. I've redefined my F5 function to attach to the asp.net process instead of the long build/validate it usually performs. This works pretty well for me and it's really easy. ``` For Each process In DTE.Debugger.LocalProcesses If (process.Name.IndexOf("aspnet_wp.exe") <> -1) Then ...
422,774
<p>I have a function inside a class that returns a reference to a member variable.</p> <pre><code>std::vector&lt;uint8&gt; &amp; getBuffer() const { return m_myBuffer; } </code></pre> <p>Now say in another class I call this method:</p> <pre><code>int someFunction() { std::vector&lt;uint8&gt; myFileBuffer = myF...
[ { "answer_id": 422782, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 2, "selected": false, "text": "<p>Declare your local variable as being a reference type instead of a value type, i.e. like this ...</p>\n\n<pre><code>std:...
2009/01/08
[ "https://Stackoverflow.com/questions/422774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52704/" ]
I have a function inside a class that returns a reference to a member variable. ``` std::vector<uint8> & getBuffer() const { return m_myBuffer; } ``` Now say in another class I call this method: ``` int someFunction() { std::vector<uint8> myFileBuffer = myFile.getBuffer(); } ``` This line calls the copy con...
Note since your member method is const you should be returning a const reference. ``` // Note the extra const on this line. std::vector<uint8> const& getBuffer() const { return m_myBuffer; } ``` So to use the returned value by reference do this: ``` std::vector<uint8> const& myFileBuffer = myFile.getBuffer(); ...
422,784
<p>In the code below I'm trying to load some images and put them in the stage as soon as they get individually loaded. But it is bugged since only the last image is displayed. I suspect it's a closure problem. How can I fix it? Isn't the behaviour of closures in AS3 the same as in Java Script ?</p> <pre><code>var imag...
[ { "answer_id": 423073, "author": "bobince", "author_id": 18936, "author_profile": "https://Stackoverflow.com/users/18936", "pm_score": 7, "selected": true, "text": "<blockquote>\n <p>Isn't the behaviour of closures in AS3 the same as in Java Script ?</p>\n</blockquote>\n\n<p>Yes, JavaSc...
2009/01/08
[ "https://Stackoverflow.com/questions/422784", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47883/" ]
In the code below I'm trying to load some images and put them in the stage as soon as they get individually loaded. But it is bugged since only the last image is displayed. I suspect it's a closure problem. How can I fix it? Isn't the behaviour of closures in AS3 the same as in Java Script ? ``` var imageList:Array = ...
> > Isn't the behaviour of closures in AS3 the same as in Java Script ? > > > Yes, JavaScript does exactly the same thing. As does Python. And others. Although you define 'var imageData' inside the 'for', for loops do not introduce a new scope in these languages; in fact the variable imageData is bound in the con...
422,809
<p>I am working on a little online multiplayer pong game with C# and XNA.</p> <p>I use sockets to transfer data between two computers on my personnal LAN. It works fine.</p> <p>The issue is with speed : the transfer is slow.</p> <p>When I ping the second computer, it shows a latency of 2 ms. I set up a little timer ...
[ { "answer_id": 422822, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 2, "selected": false, "text": "<p>Most networked games don't use TCP but UDP for communications. The problem with that is that data can be easily drop...
2009/01/08
[ "https://Stackoverflow.com/questions/422809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on a little online multiplayer pong game with C# and XNA. I use sockets to transfer data between two computers on my personnal LAN. It works fine. The issue is with speed : the transfer is slow. When I ping the second computer, it shows a latency of 2 ms. I set up a little timer inside my code, and it s...
The latency you're seeing is most likely due to [Nagle's algorithm](http://en.wikipedia.org/wiki/Nagles_algorithm) which is used to improve efficiency when sending lots of small packets using TCP. Essentially, the TCP stack collects small packets together and coalesces them into a larger packet before transmitting. Thi...
422,828
<p>My table has data like so</p> <pre><code> products_parent_id | products_quantity 2 5 2 7 2 9 2 4 </code></pre> <p>My SQL statement looks like so (so far):</p> <pre><code>UPDATE ' . TABLE_PRODUCTS . ' SET products_quantity =...
[ { "answer_id": 422883, "author": "Luke", "author_id": 46304, "author_profile": "https://Stackoverflow.com/users/46304", "pm_score": 0, "selected": false, "text": "<p>You can also use the LIMIT keyword when using UPDATE with the single table reference, however I have not tested this mysel...
2009/01/08
[ "https://Stackoverflow.com/questions/422828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
My table has data like so ``` products_parent_id | products_quantity 2 5 2 7 2 9 2 4 ``` My SQL statement looks like so (so far): ``` UPDATE ' . TABLE_PRODUCTS . ' SET products_quantity = products_quantity +' . $order['produ...
Short Answer: No Long Answer: Sort Of. Because the order the rows are returned is not defined by SQL. Technically two different requests to the DB could return the rows in a different order. So even if you update the third row, which is the third will depend on the implementation. The only way to mitigate this is...
422,830
<p>If I have a class as follows</p> <pre><code> class Example_Class { private: int x; int y; public: Example_Class() { x = 8; y = 9; } ~Example_Class() { } }; </code></pre> <p>And a struct as follows</p>...
[ { "answer_id": 422836, "author": "ChrisW", "author_id": 49942, "author_profile": "https://Stackoverflow.com/users/49942", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Is the structure in memory of the example_struct simmilar to that in Example_Class</p>\n</blockquote>\n\...
2009/01/08
[ "https://Stackoverflow.com/questions/422830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42303/" ]
If I have a class as follows ``` class Example_Class { private: int x; int y; public: Example_Class() { x = 8; y = 9; } ~Example_Class() { } }; ``` And a struct as follows ``` struct { int x; in...
The C++ standard *guarantees* that memory layouts of a C `struct` and a C++ `class` (or `struct` -- same thing) will be identical, provided that the C++ `class`/`struct` fits the criteria of being **POD** ("Plain Old Data"). So what does POD mean? A class or struct is POD if: * All data members are public and themsel...
422,837
<p>I'd rather do this:</p> <pre><code>say $shop-&gt;ShopperDueDate-&gt;andand-&gt;day_name(); </code></pre> <p>vs. this:</p> <pre><code>say $shop-&gt;ShopperDueDate-&gt;day_name() if $shop-&gt;ShopperDueDate; </code></pre> <p>Any ideas?</p> <p>(This idea is inspired by the Ruby <a href="http://andand.rubyforge.org...
[ { "answer_id": 422905, "author": "pjf", "author_id": 19422, "author_profile": "https://Stackoverflow.com/users/19422", "pm_score": 3, "selected": false, "text": "<p>You can use Perl's <code>eval</code> statement to catch exceptions, including those from trying to call methods on an undef...
2009/01/08
[ "https://Stackoverflow.com/questions/422837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12448/" ]
I'd rather do this: ``` say $shop->ShopperDueDate->andand->day_name(); ``` vs. this: ``` say $shop->ShopperDueDate->day_name() if $shop->ShopperDueDate; ``` Any ideas? (This idea is inspired by the Ruby [andand](http://andand.rubyforge.org/) extension.) (Actually it is inspired by the Groovy language, but most ...
I think I've just written it. I've just uploaded it to CPAN, you can find it [here](http://search.cpan.org/perldoc?Scalar::Andand).
422,840
<p>What i want is to take an integer represented as a string, for example "1234", and convert it to a file called int, containing a 32-bit big endian integer, with the value 1234.</p> <p>The only way I have figured out to do this is something like</p> <pre><code>echo 1234 | awk '{printf "0: %08X", $1}' | xxd -r &gt; ...
[ { "answer_id": 422859, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>A slightly simpler way would be:</p>\n\n<pre><code>printf \"0: %08X\" 1234 | xxd -r &gt; int\n</code></pre>\n" }, {...
2009/01/08
[ "https://Stackoverflow.com/questions/422840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11084/" ]
What i want is to take an integer represented as a string, for example "1234", and convert it to a file called int, containing a 32-bit big endian integer, with the value 1234. The only way I have figured out to do this is something like ``` echo 1234 | awk '{printf "0: %08X", $1}' | xxd -r > int ``` which is a bit...
ok well seeing that mark williams seems to have gone awol i will post the corrected version of his answer ``` echo 1234 | perl -e 'print pack("N", <STDIN>); > int ```
422,848
<p>The java.library.path property appears to be read-only. For example when you run ant on the following buildfile</p> <pre><code>&lt;project name="MyProject" default="showprops" basedir="."&gt; &lt;property name="java.library.path" value="test"/&gt; &lt;property name="some.other.property" value="test1"/&gt; ...
[ { "answer_id": 422869, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 0, "selected": false, "text": "<p>I think this is not possible, mainly because the JVM has already started by the time this value is modified.</p>\n\n<p...
2009/01/08
[ "https://Stackoverflow.com/questions/422848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10814/" ]
The java.library.path property appears to be read-only. For example when you run ant on the following buildfile ``` <project name="MyProject" default="showprops" basedir="."> <property name="java.library.path" value="test"/> <property name="some.other.property" value="test1"/> <target name="showprops"> ...
Ant properties do not work the way you expect: they are immutable, i.e. you cannot change a property's value after you have set it once. If you run > > ant -Dsome.other.property=commandlinedefinedpath > > > the output will no longer show > > [echo] some.other.property=test1 > > >
422,858
<p>I am using impersonation is used to access file on UNC share as below.</p> <pre><code> var ctx = ((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate(); string level = WindowsIdentity.GetCurrent().ImpersonationLevel); </code></pre> <p>On two Windows 2003 servers using IIS6, I am getting different im...
[ { "answer_id": 800991, "author": "Jon", "author_id": 95016, "author_profile": "https://Stackoverflow.com/users/95016", "pm_score": 2, "selected": false, "text": "<p>If your testing with localhost as webserver and its working but when deployed you receive errors you could be running into ...
2009/01/08
[ "https://Stackoverflow.com/questions/422858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/437435/" ]
I am using impersonation is used to access file on UNC share as below. ``` var ctx = ((WindowsIdentity)HttpContext.Current.User.Identity).Impersonate(); string level = WindowsIdentity.GetCurrent().ImpersonationLevel); ``` On two Windows 2003 servers using IIS6, I am getting different impersonation levels: *Deleg...
It sounds like one of the computer is trusted for delegation by your Active Directory, but the other is not. If the app pool identity is Network Service, make sure the Computer Account is marked "Trusted for Delegation" in AD. You may need to ask your AD admin to force a replication and then log out/in to your worksta...
422,865
<p>I'm using a DataGridView in my WinForms application. My main objective is to make the Enter key not move to the next row in the grid. I still want the enter key to validate and end edit mode.</p> <p>I found <a href="http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27...
[ { "answer_id": 425135, "author": "Malfist", "author_id": 12243, "author_profile": "https://Stackoverflow.com/users/12243", "pm_score": 0, "selected": false, "text": "<p>No, but you can manually fire the CellValidating event. Just create the proper parameters. All events are is a class us...
2009/01/08
[ "https://Stackoverflow.com/questions/422865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4794/" ]
I'm using a DataGridView in my WinForms application. My main objective is to make the Enter key not move to the next row in the grid. I still want the enter key to validate and end edit mode. I found [this FAQ entry](http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b8...
CellValidating doesn't get called until you change the CurrentCell. So the way I kludged around this was to change the CurrentCell, then switch back to the current one. ``` protected override bool ProcessDialogKey(Keys keyData) { if (keyData == Keys.Enter) { DataGridViewCell current...
422,929
<p>Whenever I use Html.ActionLink it always Html encodes my display string. For instance I want my link to look like this:</p> <pre><code>&lt;a href="/posts/422/My-Post-Title-Here"&gt;More&amp;hellip;&lt;/a&gt; </code></pre> <p>it outputs like this: <a href="/posts/422/My-Post-Title-Here">More&amp;hellip;</a></p> <p...
[ { "answer_id": 422968, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 7, "selected": true, "text": "<p>It looks like ActionLink always uses calls HttpUtility.Encode on the link text. You could use UrlHelper to generate ...
2009/01/08
[ "https://Stackoverflow.com/questions/422929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
Whenever I use Html.ActionLink it always Html encodes my display string. For instance I want my link to look like this: ``` <a href="/posts/422/My-Post-Title-Here">More&hellip;</a> ``` it outputs like this: [More&hellip;](/posts/422/My-Post-Title-Here) &hellip is "..." incase you were wondering. However the action...
It looks like ActionLink always uses calls HttpUtility.Encode on the link text. You could use UrlHelper to generate the href and build the anchor tag yourself. ``` <a href='@Url.Action("Posts", ...)'>More&hellip;</a> ``` Alternatively you can "decode" the string you pass to ActionLink. Constructing the link in HTML ...
422,932
<p>When I retrieve any Scalar value from the database, I usually write code like this for nullable fields.</p> <pre><code>cmd.ExecuteScalar() == DBNull.Value ? 0 : (int)cmd.ExecuteScalar() </code></pre> <p>But I don't like it because it executes the Executescalar statement twice. It's an extra trip to the server for ...
[ { "answer_id": 422937, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": false, "text": "<p>Just use a variable to cache the result:</p>\n\n<pre><code>var o = cmd.ExecuteScalar();\nreturn o == DBNull.Value ? 0...
2009/01/08
[ "https://Stackoverflow.com/questions/422932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33052/" ]
When I retrieve any Scalar value from the database, I usually write code like this for nullable fields. ``` cmd.ExecuteScalar() == DBNull.Value ? 0 : (int)cmd.ExecuteScalar() ``` But I don't like it because it executes the Executescalar statement twice. It's an extra trip to the server for my website and in favor of...
Write yourself an extension method for the sql command. ``` public static T ExecuteNullableScalar<T>(this SqlCommand cmd) where T : struct { var result = cmd.ExecuteScalar(); if (result == DBNull.Value) return default(T); return (T)result; } ``` Usage becomes: ``` int value = cmd.ExecuteNullableScal...
422,958
<p>There are 4 overloaded signatures for Enumerable.SelectMany. To make it simple, we ignore the two signatures with <em>int</em> argument. So we have 2 signatures for SelectMany:</p> <pre><code>public static IEnumerable&lt;TResult&gt; SelectMany&lt;TSource, TResult&gt;( this IEnumerable&lt;TSource&gt; source, ...
[ { "answer_id": 423332, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>these function may be useful</p>\n\n<pre><code>void *sqlite3_update_hook(\n sqlite3*, \n void(*)(void *,int ,char const *...
2009/01/08
[ "https://Stackoverflow.com/questions/422958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
There are 4 overloaded signatures for Enumerable.SelectMany. To make it simple, we ignore the two signatures with *int* argument. So we have 2 signatures for SelectMany: ``` public static IEnumerable<TResult> SelectMany<TSource, TResult>( this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> se...
Though the following doesn't meet all your requirements, you may wish to see one way to do it. [Mike Chirico's SQLite Tutorial](http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html) has a section on **Logging All Inserts, Updates, and Deletes** that mimics the functionality of MySQL's binlog. It relies on tr...
422,963
<p>I'm using the following command to remove every ".dummy" directories in a folder named "Test Folder":</p> <pre><code>rm -rf `find "Test Folder" -type d -name .dummy` </code></pre> <p>However, this doesn't work since it expands to, say:</p> <pre><code>rm -rf Test Folder/.dummy </code></pre> <p>Since the whitespac...
[ { "answer_id": 422974, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>Try</p>\n\n<pre><code>find \"Test Folder\" -type d -name .dummy -exec rm -rf \\\"{}\\\" \\;\n</code></pre>\n\n<p>Note th...
2009/01/08
[ "https://Stackoverflow.com/questions/422963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9936/" ]
I'm using the following command to remove every ".dummy" directories in a folder named "Test Folder": ``` rm -rf `find "Test Folder" -type d -name .dummy` ``` However, this doesn't work since it expands to, say: ``` rm -rf Test Folder/.dummy ``` Since the whitespace is not escaped, this fails. I also tried somet...
A couple of things. Easiest is to change and use ``` $ find 'Test Folder' -type d -print0 | xargs -0 rm -rf ``` Another choice is ``` $ find 'Test Folder' -type d -exec \'{}\' \; ```
422,970
<p>I would like to use java to get the source of a website (secure) and then parse that website for links that are in it. I have found how to connect to that url, but then how can i easily get just the source, preferraby as the DOM Document oso that I could easily get the info I want.</p> <p>Or is there a better way t...
[ { "answer_id": 422986, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 2, "selected": false, "text": "<p>Try <a href=\"http://httpunit.sourceforge.net/\" rel=\"nofollow noreferrer\">HttpUnit</a> or <a href=\"http://hc.apa...
2009/01/08
[ "https://Stackoverflow.com/questions/422970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673/" ]
I would like to use java to get the source of a website (secure) and then parse that website for links that are in it. I have found how to connect to that url, but then how can i easily get just the source, preferraby as the DOM Document oso that I could easily get the info I want. Or is there a better way to connect ...
You can get low level and just request it with a socket. In java it looks like ``` // Arg[0] = Hostname // Arg[1] = File like index.html public static void main(String[] args) throws Exception { SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket sslsock = (SSLSocket) factor...
422,984
<p>Today I was looking at some code atually from Nikhil Kothari's Facebook.NET API. I just wanted to check out how he was doing some things in there for ideas.</p> <p>One of the things I came across was a Property that just seemed really weird to me.</p> <p>check this out:</p> <p>FacebookRequest.cs defines a proper...
[ { "answer_id": 423010, "author": "Mike Hofer", "author_id": 47580, "author_profile": "https://Stackoverflow.com/users/47580", "pm_score": 3, "selected": true, "text": "<p>I don't think it's odd at all. It saves the client the trouble of having to instantiate the <code>FacebookRequestPara...
2009/01/08
[ "https://Stackoverflow.com/questions/422984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Today I was looking at some code atually from Nikhil Kothari's Facebook.NET API. I just wanted to check out how he was doing some things in there for ideas. One of the things I came across was a Property that just seemed really weird to me. check this out: FacebookRequest.cs defines a property and sets it in the con...
I don't think it's odd at all. It saves the client the trouble of having to instantiate the `FacebookRequestParameterList` instance, and the `FacebookRequest` class is guaranteed that `_parameters` contains a valid instance of the `FacebookRequestParameterList` class, and isn't `null`. It's a matter of convenience fo...
422,989
<p>I have inherited a project that uses the following pattern for passing parameters from the code behind to the aspx page. I know this is wrong, but I am on the fence on the best way to refactor it.</p> <p>Code Behind:</p> <pre><code>using System; using System.Web; namespace BadPassing { public partial class _D...
[ { "answer_id": 423014, "author": "Brownie", "author_id": 6600, "author_profile": "https://Stackoverflow.com/users/6600", "pm_score": 1, "selected": false, "text": "<p>In the normal case if two users load the page at the same time they will be using different instances of the page. As nu...
2009/01/08
[ "https://Stackoverflow.com/questions/422989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17715/" ]
I have inherited a project that uses the following pattern for passing parameters from the code behind to the aspx page. I know this is wrong, but I am on the fence on the best way to refactor it. Code Behind: ``` using System; using System.Web; namespace BadPassing { public partial class _Default : System.Web.U...
This code is ok. The member variables are instantiated every time the page loads, as a new instance of a class is created on every page load. If the variables were static, only then would you have problems with 2 people loading the page at the same moment. Think about the controls you drop on a page. They are member ...
422,999
<p>I have a fixed-length data file need to persistence into database. I use a XML file to define the length for the fields and use a list of FieldItem class to store the data.</p> <pre><code> class FieldItem { public string ObjectName {get; set;} public string ObjectProperty {get; set;} pu...
[ { "answer_id": 423044, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 0, "selected": false, "text": "<p>You could have them store it in the database as C# code expression, and then use the CodeDom classes to parse and com...
2009/01/08
[ "https://Stackoverflow.com/questions/422999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
I have a fixed-length data file need to persistence into database. I use a XML file to define the length for the fields and use a list of FieldItem class to store the data. ``` class FieldItem { public string ObjectName {get; set;} public string ObjectProperty {get; set;} public string Ob...
RE: "What should I do if I only like my rule expression like: "Company.CompanyName = 'ABC Corp' and Product.ProductCode = 'XYZ001'"? Map this user-friendly query: "Company.CompanyName = 'ABC Corp' **AND** Product.ProductCode = 'XYZ001'" to something that is friendly to your data structure(FieldItem): "ObjectName = 'C...
423,013
<p>When I create an application on my laptop it compiles and renders just fine. If I compile the page and put it on a server to host it, it still renders just fine on multiple computers.</p> <p>However, if I transfer the code to my desktop and run it on my desktop the size of all the fonts is all messed up. Everythi...
[ { "answer_id": 423199, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 0, "selected": false, "text": "<p>It is something to do with the Browser you used, the Browser on your desktop may have large font as preference set. Try ...
2009/01/08
[ "https://Stackoverflow.com/questions/423013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16584/" ]
When I create an application on my laptop it compiles and renders just fine. If I compile the page and put it on a server to host it, it still renders just fine on multiple computers. However, if I transfer the code to my desktop and run it on my desktop the size of all the fonts is all messed up. Everything is MUCH b...
Because you have different default font sizes and/or monitor dpi settings on the two machines? AIUI the GWT standard styles just sets font size to "small", which will be relative to the default font size set in the browser. Either set the fonts to a measurement in pixels or, better, use a more liquid layout that can c...
423,023
<p>I have a ridiculously long xml row, it has > 800000 characters. The 'client' is also the 'server'. The OS is windows 2k8 x64. The database has plenty of memory as does the client.</p> <p>The problem is that once i hit some magic number of characters - exactly 43679 xml chars - the row returns what APPEARS to be '...
[ { "answer_id": 423199, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 0, "selected": false, "text": "<p>It is something to do with the Browser you used, the Browser on your desktop may have large font as preference set. Try ...
2009/01/08
[ "https://Stackoverflow.com/questions/423023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44714/" ]
I have a ridiculously long xml row, it has > 800000 characters. The 'client' is also the 'server'. The OS is windows 2k8 x64. The database has plenty of memory as does the client. The problem is that once i hit some magic number of characters - exactly 43679 xml chars - the row returns what APPEARS to be ''. i call th...
Because you have different default font sizes and/or monitor dpi settings on the two machines? AIUI the GWT standard styles just sets font size to "small", which will be relative to the default font size set in the browser. Either set the fonts to a measurement in pixels or, better, use a more liquid layout that can c...
423,070
<p>Let us say that I have a Flex 3 mxml component, call it A. A has a get/set attribute called 'b'. Within A I have another internal component C, which is specified using mxml. When "instantiating" component A within mxml, I can specify the value of b at declaration, and everything works fine. However, when I initializ...
[ { "answer_id": 423990, "author": "inferis", "author_id": 51998, "author_profile": "https://Stackoverflow.com/users/51998", "pm_score": 4, "selected": true, "text": "<p>To force a control to create its child controls you have to call the initialize method.</p>\n\n<p>i.e. this should work ...
2009/01/08
[ "https://Stackoverflow.com/questions/423070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21317/" ]
Let us say that I have a Flex 3 mxml component, call it A. A has a get/set attribute called 'b'. Within A I have another internal component C, which is specified using mxml. When "instantiating" component A within mxml, I can specify the value of b at declaration, and everything works fine. However, when I initialize t...
To force a control to create its child controls you have to call the initialize method. i.e. this should work : ``` var a:A = new A(); a.initialize(); a.b = "woopy"; this.addChild(a); ``` However, what I've been doing so far when declaring mxml controls is binding the internal controls to public variables declared ...
423,081
<p>i have added an icon to a WPF app in the project properties.</p> <p>How do I refer to that icon so I can add it to a NotifyIcon that I am creating for system tray.</p> <p>In code that is??</p> <pre><code> System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon(); ni.Icon = new System.Drawing.I...
[ { "answer_id": 423400, "author": "Ben McIntosh", "author_id": 50859, "author_profile": "https://Stackoverflow.com/users/50859", "pm_score": 2, "selected": false, "text": "<p>I think this may be what you are looking for:</p>\n\n<p><a href=\"https://stackoverflow.com/questions/74466/how-do...
2009/01/08
[ "https://Stackoverflow.com/questions/423081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40568/" ]
i have added an icon to a WPF app in the project properties. How do I refer to that icon so I can add it to a NotifyIcon that I am creating for system tray. In code that is?? ``` System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon(); ni.Icon = new System.Drawing.Icon("MyIcon.ico"); ``` Doe...
``` System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon(); ni.Icon = System.Drawing.Icon.ExtractAssociatedIcon( System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name); ni.Visible = true; ```
423,107
<p>I've been trying to find a way to match a number in a Javascript string that is surrounded by parenthesis at the end of the string, then increment it.</p> <p>Say I have a string:</p> <pre><code>var name = "Item Name (4)"; </code></pre> <p>I need a RegExp to match the (4) part, and then I need to increment the 4 t...
[ { "answer_id": 423150, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 0, "selected": false, "text": "<p>I can can only think of a way of doing it in three steps: Extract, increment and replace. </p>\n\n<pre><code>// Tes...
2009/01/08
[ "https://Stackoverflow.com/questions/423107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52749/" ]
I've been trying to find a way to match a number in a Javascript string that is surrounded by parenthesis at the end of the string, then increment it. Say I have a string: ``` var name = "Item Name (4)"; ``` I need a RegExp to match the (4) part, and then I need to increment the 4 then put it back into the string. ...
The replace method can take a function as its second argument. It gets the match (including submatches) and returns the replacement string. Others have already mentioned that the parentheses need to be escaped. ``` "Item Name (4)".replace(/\((\d+)\)/, function(fullMatch, n) { return "(" + (Number(n) + 1) + ")"; })...
423,110
<p>I have a command line program in C# that I've wrapped with a try-catch block to keep it from crashing the console. However, while I am debugging it, if an exception is thrown somewhere in the DoStuff() method, Visual Studio will break on the "catch" statement. I want Visual Studio to break where the exception occu...
[ { "answer_id": 423120, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I think setting VS to <a href=\"http://msdn.microsoft.com/en-us/library/d14azbfh.aspx\" rel=\"nofollow noreferrer\">...
2009/01/08
[ "https://Stackoverflow.com/questions/423110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/571/" ]
I have a command line program in C# that I've wrapped with a try-catch block to keep it from crashing the console. However, while I am debugging it, if an exception is thrown somewhere in the DoStuff() method, Visual Studio will break on the "catch" statement. I want Visual Studio to break where the exception occurred....
You can turn on [First chance exceptions](http://blogs.msdn.com/davidklinems/archive/2005/07/18/440150.aspx) in VS. This will allow you to be notified as soon as an exception is raised.
423,111
<p>It's probably the tenth time I'm implementing something like this, and I've never been 100% happy about solutions I came up with.</p> <p>The reason using mysql table instead of a "proper" messaging system is attractive is primarily because most application already use some relational database for other stuff (which...
[ { "answer_id": 423123, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 1, "selected": false, "text": "<p>I would suggest using <a href=\"http://quartznet.sourceforge.net/\" rel=\"nofollow noreferrer\">Quartz.NET</a></p>\...
2009/01/08
[ "https://Stackoverflow.com/questions/423111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52751/" ]
It's probably the tenth time I'm implementing something like this, and I've never been 100% happy about solutions I came up with. The reason using mysql table instead of a "proper" messaging system is attractive is primarily because most application already use some relational database for other stuff (which tends to ...
I've built a few message queuing systems and I'm not certain what type of message you're referring to, but in the case of the dequeuing (is that a word?) I've done the same thing you've done. Your method looks simple, clean and solid. Not that my work is the best, but it's proven very effective for large-monitoring for...
423,127
<p>So I'm new to rhino mocks and I'm trying to get it going in a MVP patterned project I'm on. So I've got an interface representing my View and a class for my Presenter like so:</p> <pre><code>public interface IView { string SomeData { get; set; } } public class Presenter { public IView View { get; set; } publ...
[ { "answer_id": 423145, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>You need to mock the View property as well, instead of calling the Init method on the mocked presenter.</p>\n\n<pre><...
2009/01/08
[ "https://Stackoverflow.com/questions/423127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11388/" ]
So I'm new to rhino mocks and I'm trying to get it going in a MVP patterned project I'm on. So I've got an interface representing my View and a class for my Presenter like so: ``` public interface IView { string SomeData { get; set; } } public class Presenter { public IView View { get; set; } public void Init(I...
You need to mock the View property as well, instead of calling the Init method on the mocked presenter. ``` presenter.Expect( p => p.View ).Return( view ); ``` You might also want to look at using the new [AAA](http://ayende.com/Blog/archive/2008/05/16/Rhino-Mocks--Arrange-Act-Assert-Syntax.aspx) (Arrange-Act-Assert...
423,128
<p>Simple question: do I have to <code>delete</code> or <code>delete []</code> <code>c</code>? Does the language matter?</p> <pre><code>char c[] = "hello" </code></pre>
[ { "answer_id": 423130, "author": "Gordon Wilson", "author_id": 23071, "author_profile": "https://Stackoverflow.com/users/23071", "pm_score": 5, "selected": true, "text": "<p>In c++ that is not dynamic memory allocation. No <code>delete[]</code> will be needed.</p>\n\n<p>Your example is ...
2009/01/08
[ "https://Stackoverflow.com/questions/423128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Simple question: do I have to `delete` or `delete []` `c`? Does the language matter? ``` char c[] = "hello" ```
In c++ that is not dynamic memory allocation. No `delete[]` will be needed. Your example is basically a short-cut for this: ``` char c[6]={'h','e','l','l','o','\0'}; ```
423,132
<p>Does it make sense to use interfaces for your domain object factories by default, or should interfaces be reserved for the factory classes only when you need them?</p> <pre><code>public IUserFactory { User CreateNewUser(); } public UserFactory : IUserFactory { public User CreateNewUser() { retu...
[ { "answer_id": 423139, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 3, "selected": false, "text": "<p>Not everything has to have an interface; if you have a single implementation of something, and no reason to have a...
2009/01/08
[ "https://Stackoverflow.com/questions/423132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25847/" ]
Does it make sense to use interfaces for your domain object factories by default, or should interfaces be reserved for the factory classes only when you need them? ``` public IUserFactory { User CreateNewUser(); } public UserFactory : IUserFactory { public User CreateNewUser() { return new User();...
Here's a translation of the same problem into Java. Original example ``` public interface UserFactoryIF { User createNewUser(); } ``` Then the implementation of the Factory ``` public class UserFactory implements UserFactoryIF { public User createNewUser() { // whatever special logic it takes...
423,157
<p>I have the following classes:</p> <pre><code>public class Person { public String FirstName { set; get; } public String LastName { set; get; } public Role Role { set; get; } } public class Role { public String Description { set; get; } public Double Salary { set; get; } public Boolean HasBon...
[ { "answer_id": 423179, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>If the properties aren't value types, why not just call DiffObjectProperties recursively on them and append the resu...
2009/01/08
[ "https://Stackoverflow.com/questions/423157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52752/" ]
I have the following classes: ``` public class Person { public String FirstName { set; get; } public String LastName { set; get; } public Role Role { set; get; } } public class Role { public String Description { set; get; } public Double Salary { set; get; } public Boolean HasBonus { set; get;...
``` public static List<String> DiffObjectsProperties(object a, object b) { Type type = a.GetType(); List<String> differences = new List<String>(); foreach (PropertyInfo p in type.GetProperties()) { object aValue = p.GetValue(a, null); object bValue = p.GetValue(b, null); if (p.P...
423,160
<p>I have a rails model that validates uniqueness of 2 form values. If these 2 values aren't unique the validation errors are shows and the "submit" button is changed to "resubmit". I want to allow a user to click the "resubmit" button and bypass the model validation. I want to do something like this from the rails...
[ { "answer_id": 423173, "author": "zenazn", "author_id": 46848, "author_profile": "https://Stackoverflow.com/users/46848", "pm_score": 3, "selected": false, "text": "<p>Try this:</p>\n\n<p>Rails 2: <code>Model.save(false)</code><br>\nRails 3: <code>Model.save(:validate =&gt; false)</code>...
2009/01/08
[ "https://Stackoverflow.com/questions/423160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50029/" ]
I have a rails model that validates uniqueness of 2 form values. If these 2 values aren't unique the validation errors are shows and the "submit" button is changed to "resubmit". I want to allow a user to click the "resubmit" button and bypass the model validation. I want to do something like this from the rails valida...
In my opinion this is the best way to do it: ``` class FooBar < ActiveRecord::Base validates_uniqueness_of :foo, :bar, :unless => :force_submit attr_accessor :force_submit end ``` then in your view, make sure you name the submit tag like ``` <%= submit_tag 'Resubmit', :name => 'foo_bar[force_submit]' %> ``` t...
423,166
<p>I'm embedding a Flash ActiveX control in my C++ app (Flash.ocx, Flash10a.ocx, etc depending on your Flash version). </p> <p>I can load an SWF file by calling LoadMovie(0, filename), but the file needs to physically reside in the disk. How to load the SWF from memory (or resource, or stream)? I'm sure there must be ...
[ { "answer_id": 423254, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 0, "selected": false, "text": "<p>Being a flash guy I don't know any details on the C++ side, but if you made a request on the Flash side to a fake proto...
2009/01/08
[ "https://Stackoverflow.com/questions/423166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
I'm embedding a Flash ActiveX control in my C++ app (Flash.ocx, Flash10a.ocx, etc depending on your Flash version). I can load an SWF file by calling LoadMovie(0, filename), but the file needs to physically reside in the disk. How to load the SWF from memory (or resource, or stream)? I'm sure there must be a way, bec...
Appearantly I a going to need to supply details for a vote 'up'.. OK. The internal flash buffer when first initiailized indicates if a movie is loaded or if the buffer hold properties in the buffer fisrt four bytes. gUfU -- no movie loaded. properties to follow .... fUfU -- .. [4bytes] size as integer. then the UNC...
423,172
<p>Is it possible to have two background images? For instance, I'd like to have one image repeat across the top (repeat-x), and another repeat across the entire page (repeat), where the one across the entire page is behind the one which repeats across the top.</p> <p>I've found that I can achieve the desired effect f...
[ { "answer_id": 423184, "author": "Sean James", "author_id": 51071, "author_profile": "https://Stackoverflow.com/users/51071", "pm_score": 1, "selected": false, "text": "<p>You could have a div for the top with one background and another for the main page, and seperate the page content be...
2009/01/08
[ "https://Stackoverflow.com/questions/423172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/219/" ]
Is it possible to have two background images? For instance, I'd like to have one image repeat across the top (repeat-x), and another repeat across the entire page (repeat), where the one across the entire page is behind the one which repeats across the top. I've found that I can achieve the desired effect for two back...
CSS3 allows this sort of thing and it looks like this: ```css body { background-image: url(images/bgtop.png), url(images/bg.png); background-repeat: repeat-x, repeat; } ``` [The current versions of all the major browsers now support it](http://caniuse.com/#search=multiple%20backgrounds), however if you need ...
423,182
<p>As the code shown below, I want to get value from the OracleParameter object. Its datatype is datetime.</p> <pre><code>... Dim cmd As New OracleCommand("stored_proc_name", cnObject) cmd.Parameters.Add("tran_date_out", OracleDbType.Date, ParameterDirection.Output) ... cmd.ExecuteNonQuery() ... Dim tranDate As D...
[ { "answer_id": 423216, "author": "CodingWithSpike", "author_id": 28278, "author_profile": "https://Stackoverflow.com/users/28278", "pm_score": 3, "selected": false, "text": "<p>off the top of my head, the OracleParameter.Value, when an out parameter, is assigned to a strange Oracle boxed...
2009/01/08
[ "https://Stackoverflow.com/questions/423182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1602746/" ]
As the code shown below, I want to get value from the OracleParameter object. Its datatype is datetime. ``` ... Dim cmd As New OracleCommand("stored_proc_name", cnObject) cmd.Parameters.Add("tran_date_out", OracleDbType.Date, ParameterDirection.Output) ... cmd.ExecuteNonQuery() ... Dim tranDate As Date tranDate =...
off the top of my head, the OracleParameter.Value, when an out parameter, is assigned to a strange Oracle boxed type. It seems like a completely terrible design or Oracle's part... but instead of returning String, you will get OracleString, etc. Each of the Oracle types has a .Value that has the system type, but of co...
423,186
<p>As a follow-up to <a href="https://stackoverflow.com/questions/423128/is-this-dynamic-memory-allocation">this question</a>:</p> <p>From what I've seen, this should work as expected:</p> <pre><code>void greet(){ char c[] = "Hello"; greetWith(c); return; } </code></pre> <p>but this will cause undefined behavi...
[ { "answer_id": 423197, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "author_profile": "https://Stackoverflow.com/users/2509", "pm_score": 0, "selected": false, "text": "<p>Allocate the character array in the heap?</p>\n\n<p>Whether you can use <code>malloc</code> or not...
2009/01/08
[ "https://Stackoverflow.com/questions/423186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As a follow-up to [this question](https://stackoverflow.com/questions/423128/is-this-dynamic-memory-allocation): From what I've seen, this should work as expected: ``` void greet(){ char c[] = "Hello"; greetWith(c); return; } ``` but this will cause undefined behavior: ``` char *greet(){ char c[] = "Hello...
You're absolutely right. Your c array in the second example is being allocated on the stack, and thus the memory will get reused immediately following. In particular, if you had code like ``` printf("%s\n",greet()); ``` you'd get weird results, because the call to printf would have reused some of the space of your ...
423,212
<p>I'm trying to make a graph in Rails, for example the avg sales amount per day for each day in a given date range</p> <p>Say I have a products_sold model which has a "sales_price" float attribute. But if a specific day has no sales (e.g none in the model/db), I want to return simply 0.</p> <p>What's the best way in...
[ { "answer_id": 423426, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 0, "selected": false, "text": "<p>Does MySQL have set-returning functions? I.e. functions that return different values on each row of a query? ...
2009/01/08
[ "https://Stackoverflow.com/questions/423212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1609611/" ]
I'm trying to make a graph in Rails, for example the avg sales amount per day for each day in a given date range Say I have a products\_sold model which has a "sales\_price" float attribute. But if a specific day has no sales (e.g none in the model/db), I want to return simply 0. What's the best way in MySQL/Rails to...
Is there a reason (other than the date one already mentioned) why you wouldn't use the built-in group function capabilities in ActiveRecord? You seem to be concerned about "post-processing", which I don't think is really something to worry about. You're in Rails, so you should probably be looking for a Rails solution ...
423,228
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/5938802/are-function-and-function-functionally-equal-i">Are &ldquo;(function ( ) { } ) ( )&rdquo; and &ldquo;(function ( ) { } ( ) )&rdquo; functionally equal in JavaScript?</a> </p> </blockquote> <p>This is so...
[ { "answer_id": 423264, "author": "Henk", "author_id": 44427, "author_profile": "https://Stackoverflow.com/users/44427", "pm_score": 3, "selected": false, "text": "<p>The extra set of parentheses makes it clearer that you are constructing a function and then calling it. It's a coding styl...
2009/01/08
[ "https://Stackoverflow.com/questions/423228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50394/" ]
> > **Possible Duplicate:** > > [Are “(function ( ) { } ) ( )” and “(function ( ) { } ( ) )” functionally equal in JavaScript?](https://stackoverflow.com/questions/5938802/are-function-and-function-functionally-equal-i) > > > This is something I haven't quite figured out yet, but I have been using function(){}...
Peter Michaux discusses the difference in [An Important Pair of Parens](http://peter.michaux.ca/articles/an-important-pair-of-parens). Basically the parentheses are a convention to denote that an immediately invoked function expression is following, not a plain function. Especially if the function body is lengthy, thi...
423,247
<p>I would like to be able to do somthing like the following:</p> <pre><code>//non-generic var MyTable = new Table(); string name = MyTable.Name; IEnumerable&lt;String&gt; rows = MyTable.Rows; //generic var MyTableGeneric = new Table&lt;MyType&gt;(); string name = MyTableGeneric.Name; IEnumerable&lt;MyType&gt; rows =...
[ { "answer_id": 423265, "author": "Cameron MacFarland", "author_id": 3820, "author_profile": "https://Stackoverflow.com/users/3820", "pm_score": 4, "selected": true, "text": "<p>I'd say the second design is better. Less items and easier inheritance path. </p>\n\n<p>The first design has un...
2009/01/08
[ "https://Stackoverflow.com/questions/423247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I would like to be able to do somthing like the following: ``` //non-generic var MyTable = new Table(); string name = MyTable.Name; IEnumerable<String> rows = MyTable.Rows; //generic var MyTableGeneric = new Table<MyType>(); string name = MyTableGeneric.Name; IEnumerable<MyType> rows = MyTableGeneric .Rows; ``` Wou...
I'd say the second design is better. Less items and easier inheritance path. The first design has unnecessary interfaces, which you don't really need unless you're implementing something else which implements the interface, but doesn't inherit from the base class.
423,248
<p>The OpenGroup POSIX.1-2001 defines <a href="http://www.opengroup.org/onlinepubs/000095399/functions/strerror.html" rel="noreferrer">strerror_r</a>, as does <a href="http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib-strerror-r.html" rel="noreferrer">The Linux Standard Base Core Spe...
[ { "answer_id": 423301, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": false, "text": "<p>I wouldn't worry about it - a buffer size of 256 is far more than sufficient, and 1024 is overkill. You could us...
2009/01/08
[ "https://Stackoverflow.com/questions/423248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11032/" ]
The OpenGroup POSIX.1-2001 defines [strerror\_r](http://www.opengroup.org/onlinepubs/000095399/functions/strerror.html), as does [The Linux Standard Base Core Specification 3.1](http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib-strerror-r.html). But I can find no reference to the max...
I wouldn't worry about it - a buffer size of 256 is far more than sufficient, and 1024 is overkill. You could use `strerror()` instead of `strerror_r()`, and then optionally `strdup()` the result if you need to store the error string. This isn't thread-safe, though. If you really need to use `strerror_r()` instead of `...
423,298
<p>Instruction on accessing a interface to an application, in <b>plain</b> C/C++ <b>without</b>:</p> <ul> <li>MFC</li> <li>ATL</li> <li>WTL</li> </ul> <p>Basically, I would like to make use of a COM object.</p> <p>Working sample source code or guidance - to <b>using</b> (functionality) a COM object, <b>not</b> creat...
[ { "answer_id": 423325, "author": "casperOne", "author_id": 50776, "author_profile": "https://Stackoverflow.com/users/50776", "pm_score": 1, "selected": false, "text": "<p>Well, assuming you have the interface declaration, all you need is a call to CoInitialize in order to initialize COM,...
2009/01/08
[ "https://Stackoverflow.com/questions/423298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51078/" ]
Instruction on accessing a interface to an application, in **plain** C/C++ **without**: * MFC * ATL * WTL Basically, I would like to make use of a COM object. Working sample source code or guidance - to **using** (functionality) a COM object, **not** creating a COM server. Regards
Here is a simple example in plain C++: ``` CoInitialize(NULL); // absolutely essential: initialize the COM subsystem IMyInterface* pIFace; // create the object and obtain a pointer to the sought interface CoCreateInstance(CLSID_MyObject, NULL, CLSCTX_ALL, IID_IMyInterface, &pIFace); pIFace->MethodIReallyNeed(); // use...
423,320
<p>I have a feeling that I already know the answer to this one, but I thought I'd check.</p> <p>I have a number of different folders:</p> <pre><code>images_a/ images_b/ images_c/ </code></pre> <p>Can I create some sort of symlink such that this new directory has the contents of all those directories? That is this ne...
[ { "answer_id": 423326, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "<p>No. You would have to symbolically link all the individual files.</p>\n\n<p>What you <em>could</em> do is to create a ...
2009/01/08
[ "https://Stackoverflow.com/questions/423320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have a feeling that I already know the answer to this one, but I thought I'd check. I have a number of different folders: ``` images_a/ images_b/ images_c/ ``` Can I create some sort of symlink such that this new directory has the contents of all those directories? That is this new "`images_all`" would contain al...
No. You would have to symbolically link all the individual files. What you *could* do is to create a job to run periodically which basically removed all of the existing symbolic links in `images_all`, then re-create the links for all files from the three other directories, but it's a bit of a kludge, something like th...
423,330
<p>I have Perl v5.10. I am trying to install Net::SSLeay 1.30 and Crypt::SSLeay 0.57. I have already installed OpenSSL 0.9.8e.</p> <p>For Net::SSLeay 1.30 I followed these steps:</p> <pre> perl Makefile.PL -windows C:\openssl nmake nmake test -- test fails nmake install perl test.pl </pre> <p>but I got an fatal er...
[ { "answer_id": 423532, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 3, "selected": false, "text": "<p>Randy Kobes has <a href=\"http://www.mail-archive.com/perl-win32-users@listserv.activestate.com/msg32520.html\"...
2009/01/08
[ "https://Stackoverflow.com/questions/423330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have Perl v5.10. I am trying to install Net::SSLeay 1.30 and Crypt::SSLeay 0.57. I have already installed OpenSSL 0.9.8e. For Net::SSLeay 1.30 I followed these steps: ``` perl Makefile.PL -windows C:\openssl nmake nmake test -- test fails nmake install perl test.pl ``` but I got an fatal error as: ``` D:\per...
Randy Kobes has [an answer for this on the Perl Win32 mailing list](http://www.mail-archive.com/perl-win32-users@listserv.activestate.com/msg32520.html). Does your PATH environment variable contain the directory that contains libeay32.dll or ssleay32.dll? There are many other answers that you can find in Google too. I...
423,373
<p>It is obvious what I am trying to do below, but I get the following exception:</p> <blockquote> <p>Unable to return a TimeSpan property value for a Duration value of 'Automatic'.</p> </blockquote> <p>I was discouraged to read that</p> <blockquote> <p>NaturalDuration cannot be determined until after MediaOpene...
[ { "answer_id": 423819, "author": "Rhys", "author_id": 22169, "author_profile": "https://Stackoverflow.com/users/22169", "pm_score": 0, "selected": false, "text": "<p>It is possible to get the duration info from the ID3 tags in MP3s and similar tags in WMA using one of the libraries menti...
2009/01/08
[ "https://Stackoverflow.com/questions/423373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50859/" ]
It is obvious what I am trying to do below, but I get the following exception: > > Unable to return a TimeSpan property value for a Duration value of 'Automatic'. > > > I was discouraged to read that > > NaturalDuration cannot be determined until after MediaOpened has occurred. ([link](http://msdn.microsoft.com...
> > I have to come up with a contrived method to open the file, wait for the media opened event in a separate thread, then return the duration only after the event has fired > > > That's exactly what it means, unfortunately. The below is what I just came up with for this: ``` using System; using System.Threading;...
423,376
<p>Is there a way that I can get the last value (based on the '\' symbol) from a full path?</p> <p>Example:</p> <p><code>C:\Documents and Settings\img\recycled log.jpg</code></p> <p>With this case, I just want to get <code>recycled log.jpg</code> from the full path in JavaScript.</p>
[ { "answer_id": 423385, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 11, "selected": true, "text": "<pre><code>var filename = fullPath.replace(/^.*[\\\\\\/]/, '')\n</code></pre>\n\n<p>This will handle both \\ OR / in paths</p>...
2009/01/08
[ "https://Stackoverflow.com/questions/423376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52745/" ]
Is there a way that I can get the last value (based on the '\' symbol) from a full path? Example: `C:\Documents and Settings\img\recycled log.jpg` With this case, I just want to get `recycled log.jpg` from the full path in JavaScript.
``` var filename = fullPath.replace(/^.*[\\\/]/, '') ``` This will handle both \ OR / in paths
423,379
<p>How do I create or use a global variable inside a function?</p> <p>How do I use a global variable that was defined in one function inside other functions?</p> <hr /> <p><sub>Failing to use the <code>global</code> keyword where appropriate often causes <code>UnboundLocalError</code>. The precise rules for this are ex...
[ { "answer_id": 423401, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 8, "selected": false, "text": "<p>You may want to explore the notion of <a href=\"http://docs.python.org/reference/datamodel.html\" rel=\"noreferrer\">namesp...
2009/01/08
[ "https://Stackoverflow.com/questions/423379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46646/" ]
How do I create or use a global variable inside a function? How do I use a global variable that was defined in one function inside other functions? --- Failing to use the `global` keyword where appropriate often causes `UnboundLocalError`. The precise rules for this are explained at [UnboundLocalError on local varia...
You can use a global variable within other functions by declaring it as `global` within each function that assigns a value to it: ``` globvar = 0 def set_globvar_to_one(): global globvar # Needed to modify global copy of globvar globvar = 1 def print_globvar(): print(globvar) # No need for global ...
423,458
<p>I am getting this exception when disposing an OdbcDataReader just after retrieving data from the database. The reader is actually disposed while leaving a Using block. This should not be causing any errors as far as I know. Any ideas?</p> <pre><code>System.AccessViolationException: Attempted to read or write protec...
[ { "answer_id": 423462, "author": "Brad Leach", "author_id": 708, "author_profile": "https://Stackoverflow.com/users/708", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://www.vistadb.net/\" rel=\"nofollow noreferrer\">VistaDB</a> and (as you mentioned) <a href=\"http://www.m...
2009/01/08
[ "https://Stackoverflow.com/questions/423458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10786/" ]
I am getting this exception when disposing an OdbcDataReader just after retrieving data from the database. The reader is actually disposed while leaving a Using block. This should not be causing any errors as far as I know. Any ideas? ``` System.AccessViolationException: Attempted to read or write protected memory. Th...
[VistaDB](http://www.vistadb.net/) and (as you mentioned) [Sql Server Compact Edition](http://www.microsoft.com/Sqlserver/2005/en/us/compact-downloads.aspx) are two small options for an embedded database. Sql Server Compact Edition can be used with Linq to SQL or Entity Framework. I believe VistaDB can be used with the...
423,467
<p>While working with ASP.Net Forms Authentication I came across the .ASPXAUTH cookie. I have a couple questions:</p> <ul> <li>What is the purpose of this cookie?</li> <li>What is the location of this cookie?</li> </ul>
[ { "answer_id": 424061, "author": "Todd", "author_id": 2572, "author_profile": "https://Stackoverflow.com/users/2572", "pm_score": 7, "selected": true, "text": "<p>The ASPXAUTH cookie is used to determine if a user is authenticated. </p>\n\n<p>As far as the location of the cookie, that d...
2009/01/08
[ "https://Stackoverflow.com/questions/423467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
While working with ASP.Net Forms Authentication I came across the .ASPXAUTH cookie. I have a couple questions: * What is the purpose of this cookie? * What is the location of this cookie?
The ASPXAUTH cookie is used to determine if a user is authenticated. As far as the location of the cookie, that depends on your browser. If you are using Firefox you can view the cookie by clicking on Tools -> Options -> Privacy. Then scroll down to the domain and expand it to see the cookie and its value. The value ...
423,469
<p>I have encountered odd behavior when using document.getElementById tonight. Duplicated in Firefox 3 and Safari.</p> <p>Basically, it finds the div with id "divid" in Example1. However, in Example2 it always returns null. What's going on here?</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//E...
[ { "answer_id": 423478, "author": "cbp", "author_id": 21966, "author_profile": "https://Stackoverflow.com/users/21966", "pm_score": 5, "selected": true, "text": "<p>When you write this line:</p>\n\n<pre><code>window.onload = addelement();\n</code></pre>\n\n<p>...you are not actually assig...
2009/01/08
[ "https://Stackoverflow.com/questions/423469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68788/" ]
I have encountered odd behavior when using document.getElementById tonight. Duplicated in Firefox 3 and Safari. Basically, it finds the div with id "divid" in Example1. However, in Example2 it always returns null. What's going on here? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...
When you write this line: ``` window.onload = addelement(); ``` ...you are not actually assigning **addelement** to window.onload. You are executing **addelement**, then assigning the result to window.onload. Change the line to this: ``` window.onload = addelement; ```
423,483
<p>My test file is basically:</p> <pre><code>class Test(unittest.TestCase): def testOk(): pass if __name__ == "__main__": expensiveSetup() try: unittest.main() finally: cleanUp() </code></pre> <p>However, I do wish to run my test through Netbeans testing tools, and to do that ...
[ { "answer_id": 423569, "author": "muhuk", "author_id": 42188, "author_profile": "https://Stackoverflow.com/users/42188", "pm_score": 2, "selected": false, "text": "<p>You can save the state if <code>expensiveSetup()</code> is run or not.</p>\n\n<pre><code>__expensiveSetup_has_run = False...
2009/01/08
[ "https://Stackoverflow.com/questions/423483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
My test file is basically: ``` class Test(unittest.TestCase): def testOk(): pass if __name__ == "__main__": expensiveSetup() try: unittest.main() finally: cleanUp() ``` However, I do wish to run my test through Netbeans testing tools, and to do that I need unittests that don'...
If you use Python >= 2.7 (or [unittest2](http://pypi.python.org/pypi/unittest2) for Python >= 2.4 & <= 2.6), the best approach would be be to use ``` def setUpClass(cls): # ... setUpClass = classmethod(setUpClass) ``` to perform some initialization once for all tests belonging to the given class. And to perfor...