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
76,254
<p>Any advice on how to read auto-incrementing identity field assigned to newly created record from call through <code>java.sql.Statement.executeUpdate</code>?</p> <p>I know how to do this in SQL for several DB platforms, but would like to know what database independent interfaces exist in <code>java.sql</code> to do ...
[ { "answer_id": 76292, "author": "ScArcher2", "author_id": 1310, "author_profile": "https://Stackoverflow.com/users/1310", "pm_score": 0, "selected": false, "text": "<p>I've always had to make a second call using query after the insert.</p>\n\n<p>You could use an ORM like hibernate. I thi...
2008/09/16
[ "https://Stackoverflow.com/questions/76254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5446/" ]
Any advice on how to read auto-incrementing identity field assigned to newly created record from call through `java.sql.Statement.executeUpdate`? I know how to do this in SQL for several DB platforms, but would like to know what database independent interfaces exist in `java.sql` to do this, and any input on people's ...
The following snibblet of code should do ya': ``` PreparedStatement stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); // ... ResultSet res = stmt.getGeneratedKeys(); while (res.next()) System.out.println("Generated key: " + res.getInt(1)); ``` This is known to...
76,274
<p>In Microsoft IL, to call a method on a value type you need an indirect reference. Lets say we have an ILGenerator named "il" and that currently we have a Nullable on top of the stack, if we want to check whether it has a value then we could emit the following:</p> <pre><code>var local = il.DeclareLocal(typeof(Nulla...
[ { "answer_id": 76320, "author": "Abe Heidebrecht", "author_id": 9268, "author_profile": "https://Stackoverflow.com/users/9268", "pm_score": 3, "selected": true, "text": "<p>If the variable is already on the stack, you can go ahead and just emit the method call. </p>\n\n<p>It seems that ...
2008/09/16
[ "https://Stackoverflow.com/questions/76274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13552/" ]
In Microsoft IL, to call a method on a value type you need an indirect reference. Lets say we have an ILGenerator named "il" and that currently we have a Nullable on top of the stack, if we want to check whether it has a value then we could emit the following: ``` var local = il.DeclareLocal(typeof(Nullable<int>)); il...
If the variable is already on the stack, you can go ahead and just emit the method call. It seems that the constructor doesn't push the variable on the stack in a typed form. After digging into the IL a bit, it appears there are two ways of using the variable after constructing it. You can load the variable that wi...
76,275
<p>I have multiple users running attachemate on a Windows 2003 server. I want to kill attachemate.exe started by user_1 without killing attachemate.exe started by user_2.</p> <p>I want to use VBScript.</p>
[ { "answer_id": 76309, "author": "Colin Neller", "author_id": 12571, "author_profile": "https://Stackoverflow.com/users/12571", "pm_score": 2, "selected": false, "text": "<p>Shell out to pskill from <a href=\"http://sysinternals.com/\" rel=\"nofollow noreferrer\">http://sysinternals.com/<...
2008/09/16
[ "https://Stackoverflow.com/questions/76275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9882/" ]
I have multiple users running attachemate on a Windows 2003 server. I want to kill attachemate.exe started by user\_1 without killing attachemate.exe started by user\_2. I want to use VBScript.
You could use this to find out who the process owner is, then once you have that you can use Win32\_Process to kill the process by the process ID. [MSDN Win32\_Process class details](http://msdn.microsoft.com/en-us/library/aa394372.aspx) [MSDN Terminating a process with Win32\_Process](http://msdn.microsoft.com/en-us...
76,300
<p>In my SWT Java app I often want to return information from inside a Display.syncExec() call. The best way I've found so far to do this is:</p> <pre><code>final ArrayList&lt;Integer&gt; result = new ArrayList&lt;Integer&gt;(); GUI.display().syncExec(new Runnable(){ public void run() { MessageBox mb = /* ... */; ...
[ { "answer_id": 76393, "author": "Dónal", "author_id": 2648, "author_profile": "https://Stackoverflow.com/users/2648", "pm_score": 1, "selected": false, "text": "<p>ArrayList is <em>not</em> thread-safe. From the relevant <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayLi...
2008/09/16
[ "https://Stackoverflow.com/questions/76300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13581/" ]
In my SWT Java app I often want to return information from inside a Display.syncExec() call. The best way I've found so far to do this is: ``` final ArrayList<Integer> result = new ArrayList<Integer>(); GUI.display().syncExec(new Runnable(){ public void run() { MessageBox mb = /* ... */; /* set up messagebox */...
[`ArrayList` is not thread-safe](http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html). You can obtain a thread-safe `List` with [`Collections.synchronizedList`](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedList%28java.util.List%29). However, it is much simpler to use an ...
76,324
<p>I really want to get the google Calendar Api up an running. I found a <a href="http://www.ibm.com/developerworks/library/x-googleclndr/" rel="nofollow noreferrer">great article</a> about how to get started. I downloaded the Zend GData classes. I have php 5 running on my dev box and all the exetensions should be lo...
[ { "answer_id": 76608, "author": "DustinB", "author_id": 7888, "author_profile": "https://Stackoverflow.com/users/7888", "pm_score": 0, "selected": false, "text": "<p>Could you have mistyped the PROTOCOL in the URL? It should be HTTPS, not \"SSL\". For example, , not SSL://www.google.co...
2008/09/16
[ "https://Stackoverflow.com/questions/76324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6244/" ]
I really want to get the google Calendar Api up an running. I found a [great article](http://www.ibm.com/developerworks/library/x-googleclndr/) about how to get started. I downloaded the Zend GData classes. I have php 5 running on my dev box and all the exetensions should be loading. I cant get openssl running and rec...
I think this use of SSL is part of the Zend GData library so I assume it is correct. I think not having OpenSSL correctly installed is my main issue.
76,325
<p>How do I move an active directory group to another organizational unit using Powershell?</p> <p>ie.</p> <p>I would like to move the group "IT Department" from:</p> <pre><code> (CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca) </code></pre> <p>to:</p> <pre><code> (CN=IT Department, ...
[ { "answer_id": 80253, "author": "Steven Murawski", "author_id": 1233, "author_profile": "https://Stackoverflow.com/users/1233", "pm_score": 2, "selected": false, "text": "<p>I haven't tried this yet, but this should do it..</p>\n\n<pre><code>$objectlocation= 'CN=IT Department, OU=Technol...
2008/09/16
[ "https://Stackoverflow.com/questions/76325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/889/" ]
How do I move an active directory group to another organizational unit using Powershell? ie. I would like to move the group "IT Department" from: ``` (CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca) ``` to: ``` (CN=IT Department, OU=Temporarily Moved Groups, DC=Company,DC=ca) ```
Your script was really close to correct (and I really appreciate your response). The following script is what I used to solve my problem.: ``` $from = [ADSI]"LDAP://CN=IT Department, OU=Technology Department, OU=Departments,DC=Company,DC=ca" $to = [ADSI]"LDAP://OU=Temporarily Moved Groups, DC=Company,DC=ca" $from.PSB...
76,327
<p>I'm writing a Java application that runs on Linux (using Sun's JDK). It keeps creating <code>/tmp/hsperfdata_username</code> directories, which I would like to prevent. Is there any way to stop java from creating these files?</p>
[ { "answer_id": 76418, "author": "svrist", "author_id": 86, "author_profile": "https://Stackoverflow.com/users/86", "pm_score": 1, "selected": false, "text": "<p><em>EDIT: Cleanup info and summarize</em></p>\n\n<p>Summary:</p>\n\n<ul>\n<li>Its a feature, not a bug</li>\n<li>It can be turn...
2008/09/16
[ "https://Stackoverflow.com/questions/76327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13582/" ]
I'm writing a Java application that runs on Linux (using Sun's JDK). It keeps creating `/tmp/hsperfdata_username` directories, which I would like to prevent. Is there any way to stop java from creating these files?
Try JVM option **-XX:-UsePerfData** [more info](http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html) The following might be helpful that is from link <https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html> ``` -XX:+UsePerfData Enables the perfdata feature. This option is ...
76,334
<p>Does anyone know a mechanism to calculate at compile-time the LCM (Least Common Multiple) and/or GCD (Greatest Common Denominator) of at least two number in <strong>C</strong> (<strong>not C++</strong>, I know that template magic is available there)?</p> <p>I generally use <strong>GCC</strong> and recall that it ca...
[ { "answer_id": 76746, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 3, "selected": false, "text": "<p>I figured it out afterall...</p>\n\n<pre><code>#define GCD(a,b) ((a&gt;=b)*GCD_1(a,b)+(a&lt;b)*GCD_1(b,a))\n#define GCD_1(a,...
2008/09/16
[ "https://Stackoverflow.com/questions/76334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12713/" ]
Does anyone know a mechanism to calculate at compile-time the LCM (Least Common Multiple) and/or GCD (Greatest Common Denominator) of at least two number in **C** (**not C++**, I know that template magic is available there)? I generally use **GCC** and recall that it can calculate certain values at compile-time when a...
I figured it out afterall... ``` #define GCD(a,b) ((a>=b)*GCD_1(a,b)+(a<b)*GCD_1(b,a)) #define GCD_1(a,b) ((((!(b)))*(a)) + (!!(b))*GCD_2((b), (a)%((b)+!(b)))) #define GCD_2(a,b) ((((!(b)))*(a)) + (!!(b))*GCD_3((b), (a)%((b)+!(b)))) #define GCD_3(a,b) ((((!(b)))*(a)) + (!!(b))*GCD_4((b), (a)%((b)+!(b)))) #define GCD_4...
76,346
<p>I just got surprised by something in TSQL. I thought that if xact_abort was on, calling something like</p> <pre><code>raiserror('Something bad happened', 16, 1); </code></pre> <p>would stop execution of the stored procedure (or any batch).</p> <p>But my ADO.NET error message just proved the opposite. I got both...
[ { "answer_id": 76416, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 6, "selected": false, "text": "<p>This is By Design<sup>TM</sup>, as you can see on <a href=\"http://connect.microsoft.com/SQLServer/feedback/ViewFee...
2008/09/16
[ "https://Stackoverflow.com/questions/76346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
I just got surprised by something in TSQL. I thought that if xact\_abort was on, calling something like ``` raiserror('Something bad happened', 16, 1); ``` would stop execution of the stored procedure (or any batch). But my ADO.NET error message just proved the opposite. I got both the raiserror error message in th...
This is By DesignTM, as you can see on [Connect](http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=275308) by the SQL Server team's response to a similar question: > > Thank you for your feedback. By design, the XACT\_ABORT set option does not impact the behavior of the RAISERROR statement....
76,411
<p>How can I create a regular expression that will grab delimited text from a string? For example, given a string like </p> <pre><code>text ###token1### text text ###token2### text text </code></pre> <p>I want a regex that will pull out <code>###token1###</code>. Yes, I do want the delimiter as well. By adding an...
[ { "answer_id": 76427, "author": "David Beleznay", "author_id": 13359, "author_profile": "https://Stackoverflow.com/users/13359", "pm_score": 3, "selected": true, "text": "<pre><code>/###(.+?)###/\n</code></pre>\n\n<p>if you want the ###'s then you need</p>\n\n<pre><code>/(###.+?###)/\n<...
2008/09/16
[ "https://Stackoverflow.com/questions/76411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/410/" ]
How can I create a regular expression that will grab delimited text from a string? For example, given a string like ``` text ###token1### text text ###token2### text text ``` I want a regex that will pull out `###token1###`. Yes, I do want the delimiter as well. By adding another group, I can get both: ``` (###(....
``` /###(.+?)###/ ``` if you want the ###'s then you need ``` /(###.+?###)/ ``` the **?** means non greedy, if you didn't have the **?**, then it would grab too much. e.g. `'###token1### text text ###token2###'` would all get grabbed. My initial answer had a \* instead of a +. \* means 0 or more. + means 1 or ...
76,412
<p>When developing WPF UserControls, what is the best way to expose a DependencyProperty of a child control as a DependencyProperty of the UserControl? The following example shows how I would currently expose the Text property of a TextBox inside a UserControl. Surely there is a better / simpler way to accomplish this...
[ { "answer_id": 77094, "author": "user7116", "author_id": 7116, "author_profile": "https://Stackoverflow.com/users/7116", "pm_score": 5, "selected": true, "text": "<p>That is how we're doing it in our team, without the RelativeSource search, rather by naming the UserControl and referencin...
2008/09/16
[ "https://Stackoverflow.com/questions/76412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/317/" ]
When developing WPF UserControls, what is the best way to expose a DependencyProperty of a child control as a DependencyProperty of the UserControl? The following example shows how I would currently expose the Text property of a TextBox inside a UserControl. Surely there is a better / simpler way to accomplish this? `...
That is how we're doing it in our team, without the RelativeSource search, rather by naming the UserControl and referencing properties by the UserControl's name. ``` <UserControl x:Class="WpfApplication3.UserControl1" x:Name="UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns...
76,424
<p>XmlElement.Attributes.Remove* methods are working fine for arbitrary attributes resulting in the removed attributes being removed from XmlDocument.OuterXml property. Xmlns attribute however is different. Here is an example:</p> <pre><code>XmlDocument doc = new XmlDocument(); doc.InnerXml = @"&lt;Element1 attr1=""va...
[ { "answer_id": 76513, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Yes, because its an ELEMENT name, you can't explicitly remove it. Using XmlTextWriter's WriteStartElement and WirteStartAttr...
2008/09/16
[ "https://Stackoverflow.com/questions/76424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
XmlElement.Attributes.Remove\* methods are working fine for arbitrary attributes resulting in the removed attributes being removed from XmlDocument.OuterXml property. Xmlns attribute however is different. Here is an example: ``` XmlDocument doc = new XmlDocument(); doc.InnerXml = @"<Element1 attr1=""value1"" xmlns=""h...
.NET DOM API doesn't support modifying element's namespace which is what you are essentially trying to do. So, in order to solve your problem you have to construct a new document one way or another. You can use the same .NET DOM API and create a new element without specifying its namespace. Alternatively, you can creat...
76,440
<p>As developers and as professional engineers have you been exposed to the tenants of Extreme Programming as defined in the "version 1" by Kent Beck. Which of those 12 core principles do you feel you have been either allowed to practice or at least be a part of in your current job or others?</p> <pre><code>* Pair pro...
[ { "answer_id": 76543, "author": "pmlarocque", "author_id": 7419, "author_profile": "https://Stackoverflow.com/users/7419", "pm_score": 1, "selected": false, "text": "<p>I consider myself lucky, all except \"Pair programming\" we can do it, but only to solve big issues not on a day-to-day...
2008/09/16
[ "https://Stackoverflow.com/questions/76440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
As developers and as professional engineers have you been exposed to the tenants of Extreme Programming as defined in the "version 1" by Kent Beck. Which of those 12 core principles do you feel you have been either allowed to practice or at least be a part of in your current job or others? ``` * Pair programming[5] * ...
We are following these practices you've mentioned: * Planning game * Test driven development * Whole team (being empowered to deliver) * Continuous integration * Refactoring or design improvement * Small releases * Coding standards * Collective code ownership * Simple design And I must say that after one year I can't...
76,455
<p>In C#.NET I am trying to programmatically change the color of the border in a group box.</p> <p>Update: This question was asked when I was working on a winforms system before we switched to .NET.</p>
[ { "answer_id": 5629954, "author": "swajak", "author_id": 100258, "author_profile": "https://Stackoverflow.com/users/100258", "pm_score": 1, "selected": false, "text": "<p>I'm not sure this applies to every case, but thanks to this thread, we quickly hooked into the Paint event programmat...
2008/09/16
[ "https://Stackoverflow.com/questions/76455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/300930/" ]
In C#.NET I am trying to programmatically change the color of the border in a group box. Update: This question was asked when I was working on a winforms system before we switched to .NET.
Building on the previous answer, a better solution that includes the label for the group box: ``` groupBox1.Paint += PaintBorderlessGroupBox; private void PaintBorderlessGroupBox(object sender, PaintEventArgs p) { GroupBox box = (GroupBox)sender; p.Graphics.Clear(SystemColors.Control); p.Graphics.DrawString(box...
76,464
<p>I'd like to create a module in DNN that, similar to the Announcements control, offers a template that the portal admin can modify for formatting. I have a control that currently uses a Repeater control with templates. Is there a way to override the contents of the repeater ItemTemplate, HeaderTemplate, and FooterT...
[ { "answer_id": 5629954, "author": "swajak", "author_id": 100258, "author_profile": "https://Stackoverflow.com/users/100258", "pm_score": 1, "selected": false, "text": "<p>I'm not sure this applies to every case, but thanks to this thread, we quickly hooked into the Paint event programmat...
2008/09/16
[ "https://Stackoverflow.com/questions/76464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13100/" ]
I'd like to create a module in DNN that, similar to the Announcements control, offers a template that the portal admin can modify for formatting. I have a control that currently uses a Repeater control with templates. Is there a way to override the contents of the repeater ItemTemplate, HeaderTemplate, and FooterTempla...
Building on the previous answer, a better solution that includes the label for the group box: ``` groupBox1.Paint += PaintBorderlessGroupBox; private void PaintBorderlessGroupBox(object sender, PaintEventArgs p) { GroupBox box = (GroupBox)sender; p.Graphics.Clear(SystemColors.Control); p.Graphics.DrawString(box...
76,472
<p>Is there a way in Ruby to find the version of a file, specifically a .dll file?</p>
[ { "answer_id": 76554, "author": "cynicalman", "author_id": 410, "author_profile": "https://Stackoverflow.com/users/410", "pm_score": 1, "selected": false, "text": "<p>For any file, you'd need to discover what format the file is in, and then open the file and read the necessary bytes to f...
2008/09/16
[ "https://Stackoverflow.com/questions/76472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way in Ruby to find the version of a file, specifically a .dll file?
For Windows EXE's and DLL's: ``` require "Win32API" FILENAME = "c:/ruby/bin/ruby.exe" #your filename here s="" vsize=Win32API.new('version.dll', 'GetFileVersionInfoSize', ['P', 'P'], 'L').call(FILENAME, s) p vsize if (vsize > 0) result = ' '*vsize Win32API.new('version.dll', 'GetFileVersionInfo...
76,482
<p>I have a file saved as UCS-2 Little Endian I want to change the encoding so I ran the following code:</p> <pre><code>cat tmp.log -encoding UTF8 &gt; new.log </code></pre> <p>The resulting file is still in UCS-2 Little Endian. Is this because the pipeline is always in that format? Is there an easy way to pipe this...
[ { "answer_id": 76734, "author": "driis", "author_id": 13627, "author_profile": "https://Stackoverflow.com/users/13627", "pm_score": 5, "selected": false, "text": "<p>I would do it like this:</p>\n\n<pre><code>get-content tmp.log -encoding Unicode | set-content new.log -encoding UTF8\n</c...
2008/09/16
[ "https://Stackoverflow.com/questions/76482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2582/" ]
I have a file saved as UCS-2 Little Endian I want to change the encoding so I ran the following code: ``` cat tmp.log -encoding UTF8 > new.log ``` The resulting file is still in UCS-2 Little Endian. Is this because the pipeline is always in that format? Is there an easy way to pipe this to a new file as UTF8?
As suggested [here](https://stackoverflow.com/questions/64860/best-way-to-convert-text-files-between-character-sets#64937): ``` Get-Content tmp.log | Out-File -Encoding UTF8 new.log ```
76,549
<p>An array of ints in java is stored as a block of 32-bit values in memory. How is an array of Integer objects stored? i.e.</p> <pre><code>int[] vs. Integer[] </code></pre> <p>I'd imagine that each element in the Integer array is a reference to an Integer object, and that the Integer object has object storage overhe...
[ { "answer_id": 76588, "author": "Will Hartung", "author_id": 13663, "author_profile": "https://Stackoverflow.com/users/13663", "pm_score": 1, "selected": false, "text": "<p>I think your hope is woefully naive. Specifically, it needs to deal with the issue that Integer can potentially be ...
2008/09/16
[ "https://Stackoverflow.com/questions/76549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/974/" ]
An array of ints in java is stored as a block of 32-bit values in memory. How is an array of Integer objects stored? i.e. ``` int[] vs. Integer[] ``` I'd imagine that each element in the Integer array is a reference to an Integer object, and that the Integer object has object storage overheads, just like any other o...
No VM I know of will store an Integer[] array like an int[] array for the following reasons: 1. There can be **null** Integer objects in the array and you have no bits left for indicating this in an int array. The VM could store this 1-bit information per array slot in a hiden bit-array though. 2. You can synchronize ...
76,564
<p>All I want is to be able to change the color of a bullet in a list to a light gray. It defaults to black, and I can't figure out how to change it.</p> <p>I know I could just use an image; I'd rather not do that if I can help it.</p>
[ { "answer_id": 76603, "author": "Jonathan Arkell", "author_id": 11052, "author_profile": "https://Stackoverflow.com/users/11052", "pm_score": 3, "selected": false, "text": "<pre><code>&lt;ul&gt;\n &lt;li style=\"color: #888;\"&gt;&lt;span style=\"color: #000\"&gt;test&lt;/span&gt;&lt;/l...
2008/09/16
[ "https://Stackoverflow.com/questions/76564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7072/" ]
All I want is to be able to change the color of a bullet in a list to a light gray. It defaults to black, and I can't figure out how to change it. I know I could just use an image; I'd rather not do that if I can help it.
The bullet gets its color from the text. So if you want to have a different color bullet than text in your list you'll have to add some markup. Wrap the list text in a span: ``` <ul> <li><span>item #1</span></li> <li><span>item #2</span></li> <li><span>item #3</span></li> </ul> ``` Then modify your style rule...
76,571
<p>In JavaScript, using the Prototype library, the following functional construction is possible:</p> <pre><code>var words = ["aqueous", "strength", "hated", "sesquicentennial", "area"]; words.pluck('length'); //-&gt; [7, 8, 5, 16, 4] </code></pre> <p>Note that this example code is equivalent to</p> <pre><code>words...
[ { "answer_id": 79511, "author": "Gavin", "author_id": 2377, "author_profile": "https://Stackoverflow.com/users/2377", "pm_score": 1, "selected": false, "text": "<p>Prototype's <code>pluck</code> takes advantage of that in Javascript <code>object.method()</code> is the same as <code>objec...
2008/09/16
[ "https://Stackoverflow.com/questions/76571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264/" ]
In JavaScript, using the Prototype library, the following functional construction is possible: ``` var words = ["aqueous", "strength", "hated", "sesquicentennial", "area"]; words.pluck('length'); //-> [7, 8, 5, 16, 4] ``` Note that this example code is equivalent to ``` words.map( function(word) { return word.lengt...
I saw your request on the F# mailing list. Hope I can help. You could use type extension and reflection to allow this. We simple extend the generic list type with the pluck function. Then we can use pluck() on any list. An unknown property will return a list with the error string as its only contents. ``` type Micro...
76,581
<p>There's an MSDN article <a href="http://msdn.microsoft.com/en-us/library/aa919730.aspx" rel="nofollow noreferrer">here</a>, but I'm not getting very far:</p> <pre><code>p = 139; g = 5; CRYPT_DATA_BLOB pblob; pblob.cbData = sizeof( ULONG ); pblob.pbData = ( LPBYTE ) &amp;p; CRYPT_DATA_BLOB gblob; gblob.cbData = si...
[ { "answer_id": 78156, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 1, "selected": false, "text": "<p>It looks to me that <code>KP_P</code>, <code>KP_G</code>, <code>KP_Q</code> are for DSS keys (Digital Signature Stand...
2008/09/16
[ "https://Stackoverflow.com/questions/76581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There's an MSDN article [here](http://msdn.microsoft.com/en-us/library/aa919730.aspx), but I'm not getting very far: ``` p = 139; g = 5; CRYPT_DATA_BLOB pblob; pblob.cbData = sizeof( ULONG ); pblob.pbData = ( LPBYTE ) &p; CRYPT_DATA_BLOB gblob; gblob.cbData = sizeof( ULONG ); gblob.pbData = ( LPBYTE ) &g; HCRYPTKEY...
It may be that it just doesn't like the very short keys you're using. I found [the desktop version of that article](http://msdn.microsoft.com/en-us/library/aa381969.aspx) which may help, as it has a full example. EDIT: The OP realised from the example that you have to tell CryptGenKey how long the keys are, which yo...
76,624
<p>Is there a way to have a 64 bit enum in C++? Whilst refactoring some code I came across bunch of #defines which would be better as an enum, but being greater than 32 bit causes the compiler to error.</p> <p>For some reason I thought the following might work:</p> <pre><code>enum MY_ENUM : unsigned __int64 { ...
[ { "answer_id": 76661, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 0, "selected": false, "text": "<p>An enum in C++ can be any integral type. You can, for example, have an enum of chars. IE:</p>\n\n<pre><code>enum MY_ENUM\n...
2008/09/16
[ "https://Stackoverflow.com/questions/76624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
Is there a way to have a 64 bit enum in C++? Whilst refactoring some code I came across bunch of #defines which would be better as an enum, but being greater than 32 bit causes the compiler to error. For some reason I thought the following might work: ``` enum MY_ENUM : unsigned __int64 { LARGE_VALUE = 0x1000...
I don't think that's possible with C++98. The underlying representation of enums is up to the compiler. In that case, you are better off using: ``` const __int64 LARGE_VALUE = 0x1000000000000000L; ``` As of C++11, it is possible to use enum classes to specify the base type of the enum: ``` enum class MY_ENUM : unsi...
76,650
<p>This has me puzzled. This code worked on another server, but it's failing on Perl v5.8.8 with <a href="http://search.cpan.org/dist/Date-Manip" rel="nofollow noreferrer">Date::Manip</a> loaded from CPAN today.</p> <pre><code>Warning: Use of uninitialized value in numeric lt (&lt;) at /home/downside/lib/Date/Manip.pm...
[ { "answer_id": 76698, "author": "Darren Meyer", "author_id": 7826, "author_profile": "https://Stackoverflow.com/users/7826", "pm_score": 2, "selected": false, "text": "<p>It's almost certain that your host doesn't have a definition for the timezone you're specifying, which is what's caus...
2008/09/16
[ "https://Stackoverflow.com/questions/76650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This has me puzzled. This code worked on another server, but it's failing on Perl v5.8.8 with [Date::Manip](http://search.cpan.org/dist/Date-Manip) loaded from CPAN today. ``` Warning: Use of uninitialized value in numeric lt (<) at /home/downside/lib/Date/Manip.pm line 3327. at dailyupdate.pl line 13 main::__...
It's almost certain that your host doesn't have a definition for the timezone you're specifying, which is what's causing a value to be undefined. Have you checked to make sure a TZ definition file of the same name actually exists on the host?
76,680
<p>I want to maintain a list of global messages that will be displayed to all users of a web app. I want each user to be able to mark these messages as read individually. I've created 2 tables; <code>messages (id, body)</code> and <code>messages_read (user_id, message_id)</code>.</p> <p>Can you provide an sql statemen...
[ { "answer_id": 76702, "author": "cynicalman", "author_id": 410, "author_profile": "https://Stackoverflow.com/users/410", "pm_score": 3, "selected": false, "text": "<p>Well, you could use</p>\n\n<pre><code>SELECT id FROM messages m WHERE m.id NOT IN(\n SELECT message_id FROM messages_r...
2008/09/16
[ "https://Stackoverflow.com/questions/76680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13636/" ]
I want to maintain a list of global messages that will be displayed to all users of a web app. I want each user to be able to mark these messages as read individually. I've created 2 tables; `messages (id, body)` and `messages_read (user_id, message_id)`. Can you provide an sql statement that selects the unread messag...
If the table definitions you mentioned are complete, you might want to include a date for each message, so you can order them by date. Also, this might be a slightly more efficient way to do the select: ``` SELECT id, message FROM messages LEFT JOIN messages_read ON messages_read.message_id = messages.id AND ...
76,700
<p>I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?</p>
[ { "answer_id": 76719, "author": "JBB", "author_id": 12332, "author_profile": "https://Stackoverflow.com/users/12332", "pm_score": 2, "selected": false, "text": "<p>Use Procmail. Procmail is your friend. Procmail is made for this sort of thing.</p>\n" }, { "answer_id": 76721, ...
2008/09/16
[ "https://Stackoverflow.com/questions/76700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12624/" ]
I'm looking for a little shell script that will take anything piped into it, and dump it to a file.. for email debugging purposes. Any ideas?
The unix command tee does this. ``` man tee ```
76,724
<p>I need to return a list of record id's from a table that may/may not have multiple entries with that record id on the same date. The same date criteria is key - if a record has three entries on 09/10/2008, then I need all three returned. If the record only has one entry on 09/12/2008, then I don't need it.</p>
[ { "answer_id": 76783, "author": "Leigh Caldwell", "author_id": 3267, "author_profile": "https://Stackoverflow.com/users/3267", "pm_score": 3, "selected": false, "text": "<pre><code>SELECT id, datefield, count(*) FROM tablename GROUP BY datefield\n HAVING count(*) &gt; 1\n</code></pre>\n...
2008/09/16
[ "https://Stackoverflow.com/questions/76724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to return a list of record id's from a table that may/may not have multiple entries with that record id on the same date. The same date criteria is key - if a record has three entries on 09/10/2008, then I need all three returned. If the record only has one entry on 09/12/2008, then I don't need it.
``` SELECT id, datefield, count(*) FROM tablename GROUP BY datefield HAVING count(*) > 1 ```
76,781
<p>I need to create a custom membership user and provider for an ASP.NET mvc app and I'm looking to use TDD. I have created a User class which inherits from the MembershipUser class, but when I try to test it I get an error that I can't figure out. How do I give it a valid provider name? Do I just need to add it to ...
[ { "answer_id": 76883, "author": "ssmith", "author_id": 13729, "author_profile": "https://Stackoverflow.com/users/13729", "pm_score": 1, "selected": false, "text": "<p>Yes, you need to configure it in your configuration file (probably not web.config for a test library, but app.config). Y...
2008/09/16
[ "https://Stackoverflow.com/questions/76781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9938/" ]
I need to create a custom membership user and provider for an ASP.NET mvc app and I'm looking to use TDD. I have created a User class which inherits from the MembershipUser class, but when I try to test it I get an error that I can't figure out. How do I give it a valid provider name? Do I just need to add it to web.co...
The configuration to add to your unit test project configuration file would look something like this: ``` <connectionStrings> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString="<connection string>" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <...
76,793
<p>I'm working on a set of classes that will be used to serialize to XML. The XML is not controlled by me and is organized rather well. Unfortunately, there are several sets of nested nodes, the purpose of some of them is just to hold a collection of their children. Based on my current knowledge of XML Serialization...
[ { "answer_id": 76826, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 4, "selected": true, "text": "<p>Are you not using the <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx\" rel=...
2008/09/16
[ "https://Stackoverflow.com/questions/76793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13611/" ]
I'm working on a set of classes that will be used to serialize to XML. The XML is not controlled by me and is organized rather well. Unfortunately, there are several sets of nested nodes, the purpose of some of them is just to hold a collection of their children. Based on my current knowledge of XML Serialization, thos...
Are you not using the [XmlSerializer](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx)? It's pretty damn good and makes doing things like this real easy (I use it quite a lot!). You can simply decorate your class properties with some attributes and the rest is all done for you.. Ha...
76,812
<p>What factors determine which approach is more appropriate?</p>
[ { "answer_id": 76832, "author": "Loren Segal", "author_id": 6436, "author_profile": "https://Stackoverflow.com/users/6436", "pm_score": 0, "selected": false, "text": "<p>Not nearly enough information here. It depends if your language even supports the construct \"Thing.something\" or equ...
2008/09/16
[ "https://Stackoverflow.com/questions/76812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
What factors determine which approach is more appropriate?
I think both have their places. You shouldn't simply use `DoSomethingToThing(Thing n)` just because you think "Functional programming is good". Likewise you shouldn't simply use `Thing.DoSomething()` because "Object Oriented programming is good". I think it comes down to what you are trying to convey. Stop thinking a...
76,870
<p>I want to load a different properties file based upon one variable.</p> <p>Basically, if doing a dev build use this properties file, if doing a test build use this other properties file, and if doing a production build use yet a third properties file.</p>
[ { "answer_id": 77099, "author": "Andy Whitfield", "author_id": 4805, "author_profile": "https://Stackoverflow.com/users/4805", "pm_score": 0, "selected": false, "text": "<p>The way I've done this kind of thing is to include seperate build files depending on the type of build using the <a...
2008/09/16
[ "https://Stackoverflow.com/questions/76870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9052/" ]
I want to load a different properties file based upon one variable. Basically, if doing a dev build use this properties file, if doing a test build use this other properties file, and if doing a production build use yet a third properties file.
**Step 1**: Define a property in your NAnt script to track the environment you're building for (local, test, production, etc.). ``` <property name="environment" value="local" /> ``` **Step 2**: If you don't already have a configuration or initialization target that all targets depends on, then create a configuration...
76,891
<p>I have some curious behavior that I'm having trouble figuring out why is occurring. I'm seeing intermittent timeout exceptions. I'm pretty sure it's related to volume because it's not reproducible in our development environment. As a bandaid solution, I tried upping the sql command timeout to sixty seconds, but a...
[ { "answer_id": 76911, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 1, "selected": false, "text": "<p>Try changing the SqlConnection's timeout property, rather than that of the command</p>\n" }, { "answer_id": 76921,...
2008/09/16
[ "https://Stackoverflow.com/questions/76891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
I have some curious behavior that I'm having trouble figuring out why is occurring. I'm seeing intermittent timeout exceptions. I'm pretty sure it's related to volume because it's not reproducible in our development environment. As a bandaid solution, I tried upping the sql command timeout to sixty seconds, but as I've...
SQL commands time out because the query you're using takes longer than that to execute. Execute it in Query Analyzer or Management Studio, *with a representative amount of data in the database*, and look at the execution plan to find out what's slow. If something is taking a large percentage of the time and is describ...
76,939
<p>Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to managed code in a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process. </p> <p>I tried creating the Service using the ...
[ { "answer_id": 77920, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "<p>I haven't tried this, but here's a suggestion anyway:</p>\n\n<p>Try installing the x86 remote debugger service manu...
2008/09/16
[ "https://Stackoverflow.com/questions/76939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3291/" ]
Is it possible to install the x86 Remote Debugger as a Service on a 64bit machine? I need to attach a debugger to managed code in a Session 0 process. The process runs 32bit but the debugger service that gets installed is 64bit and wont attach to the 32bit process. I tried creating the Service using the SC command, a...
This works on my machine(TM) after installing rdbgsetup\_x64.exe and going through the configuration wizard: ``` sc stop msvsmon90 sc config msvsmon90 binPath= "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86\msvsmon.exe /service msvsmon90" sc start msvsmon90 ```
76,967
<p>I know that that is not a question... erm anyway HERE is the question.</p> <p>I have inherited a database that has 1(one) table in that looks much like this. Its aim is to record what species are found in the various (200 odd) countries.</p> <pre><code>ID Species Afghanistan Albania Algeria American Samoa Andorra...
[ { "answer_id": 76999, "author": "Sarien", "author_id": 1994377, "author_profile": "https://Stackoverflow.com/users/1994377", "pm_score": 3, "selected": false, "text": "<p>Why do you want to do it in SQL? Just write a little script that does the conversion.</p>\n" }, { "answer_id"...
2008/09/16
[ "https://Stackoverflow.com/questions/76967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5552/" ]
I know that that is not a question... erm anyway HERE is the question. I have inherited a database that has 1(one) table in that looks much like this. Its aim is to record what species are found in the various (200 odd) countries. ``` ID Species Afghanistan Albania Algeria American Samoa Andorra Angola .... Western ...
I would use a script to generate all the individual queries, since this is a one-off import process. Some programs such as Excel are good at mixing different dimensions of data (comparing column names to data inside rows) but relational databases rarely are. However, you might find that some systems (such as Microsof...
76,976
<p>Is it possible to get the progress of an XMLHttpRequest (bytes uploaded, bytes downloaded)? </p> <p>This would be useful to show a progress bar when the user is uploading a large file. The standard API doesn't seem to support it, but maybe there's some non-standard extension in any of the browsers out there? It see...
[ { "answer_id": 77075, "author": "Sean McMains", "author_id": 2041950, "author_profile": "https://Stackoverflow.com/users/2041950", "pm_score": 3, "selected": false, "text": "<p>One of the most promising approaches seems to be opening a second communication channel back to the server to a...
2008/09/16
[ "https://Stackoverflow.com/questions/76976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to get the progress of an XMLHttpRequest (bytes uploaded, bytes downloaded)? This would be useful to show a progress bar when the user is uploading a large file. The standard API doesn't seem to support it, but maybe there's some non-standard extension in any of the browsers out there? It seems like a ...
For the bytes uploaded it is quite easy. Just monitor the `xhr.upload.onprogress` event. The browser knows the size of the files it has to upload and the size of the uploaded data, so it can provide the progress info. For the bytes downloaded (when getting the info with `xhr.responseText`), it is a little bit more dif...
76,993
<p>How can I set the protected <code>DoubleBuffered</code> property of the controls on a form that are suffering from flicker?</p>
[ { "answer_id": 77023, "author": "Arno", "author_id": 13685, "author_profile": "https://Stackoverflow.com/users/13685", "pm_score": 4, "selected": false, "text": "<pre><code>public void EnableDoubleBuffering()\n{\n this.SetStyle(ControlStyles.DoubleBuffer | \n ControlStyles.UserPai...
2008/09/16
[ "https://Stackoverflow.com/questions/76993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
How can I set the protected `DoubleBuffered` property of the controls on a form that are suffering from flicker?
Here's a more generic version of [Dummy's solution](https://stackoverflow.com/questions/76993/how-to-double-buffer-net-controls-on-a-form#77041). We can use reflection to get at the protected [DoubleBuffered](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx) property, and then ...
77,005
<p>I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace.</p> <p>My program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are compiled using <code>gcc</code>).</p> <p>I would like my program...
[ { "answer_id": 76867, "author": "mana", "author_id": 12016, "author_profile": "https://Stackoverflow.com/users/12016", "pm_score": 3, "selected": false, "text": "<pre><code>ulimit -c unlimited\n</code></pre>\n\n<p>is a system variable, wich will allow to create a core dump after your app...
2008/09/16
[ "https://Stackoverflow.com/questions/77005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
I am working on Linux with the GCC compiler. When my C++ program crashes I would like it to automatically generate a stacktrace. My program is being run by many different users and it also runs on Linux, Windows and Macintosh (all versions are compiled using `gcc`). I would like my program to be able to generate a st...
For Linux and I believe Mac OS X, if you're using gcc, or any compiler that uses glibc, you can use the backtrace() functions in `execinfo.h` to print a stacktrace and exit gracefully when you get a segmentation fault. Documentation can be found [in the libc manual](http://www.gnu.org/software/libc/manual/html_node/Bac...
77,025
<p>I want to set a breakpoint on the <code>__DoPostBack</code> method, but it's a pain to find the correct file to set the breakpoint in.</p> <p>The method <code>__DoPostBack</code> is contained in an auto-generated js file called something like: </p> <pre><code>ScriptResource.axd?d=P_lo2... </code></pre> <p>After ...
[ { "answer_id": 77032, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 1, "selected": false, "text": "<p>Anything that you like and feel that you can contribute to.</p>\n" }, { "answer_id": 77049, "author": "benefac...
2008/09/16
[ "https://Stackoverflow.com/questions/77025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7936/" ]
I want to set a breakpoint on the `__DoPostBack` method, but it's a pain to find the correct file to set the breakpoint in. The method `__DoPostBack` is contained in an auto-generated js file called something like: ``` ScriptResource.axd?d=P_lo2... ``` After a few post-backs visual studio gets littered with many o...
How about this one <http://sourceforge.net/projects/sqlitebrowser/>: > > SQLite Database browser is a light GUI editor for SQLite databases, built on top of QT. The main goal of the project is to allow non-technical users to create, modify and edit SQLite databases using a set of wizards and a spreadsheet-like interf...
77,171
<p>After reading Evan's and Nilsson's books I am still not sure how to manage Data access in a domain driven project. Should the CRUD methods be part of the repositories, i.e. OrderRepository.GetOrdersByCustomer(customer) or should they be part of the entities: Customer.GetOrders(). The latter approach seems more OO, b...
[ { "answer_id": 77244, "author": "Vin", "author_id": 1747, "author_profile": "https://Stackoverflow.com/users/1747", "pm_score": 2, "selected": false, "text": "<p>Even in a DDD, I would keep Data Access classes and routines separate from Entities.</p>\n\n<p>Reasons are,</p>\n\n<ol>\n<li>T...
2008/09/16
[ "https://Stackoverflow.com/questions/77171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
After reading Evan's and Nilsson's books I am still not sure how to manage Data access in a domain driven project. Should the CRUD methods be part of the repositories, i.e. OrderRepository.GetOrdersByCustomer(customer) or should they be part of the entities: Customer.GetOrders(). The latter approach seems more OO, but ...
CRUD-ish methods should be part of the Repository...ish. But I think you should ask why you have a bunch of CRUD methods. What do they *really* do? What are they *really* for? If you actually call out the data access patterns your application uses I think it makes the repository a lot more useful and keeps you from hav...
77,172
<p>Do you guys keep track of stored procedures and database schema in your source control system of choice?</p> <p>When you make a change (add a table, update an stored proc, how do you get the changes into source control? </p> <p>We use SQL Server at work, and I've begun using darcs for versioning, but I'd be curio...
[ { "answer_id": 77187, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>We keep stored procedures in source control. </p>\n" }, { "answer_id": 77196, "author": "ahockley", "autho...
2008/09/16
[ "https://Stackoverflow.com/questions/77172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7856/" ]
Do you guys keep track of stored procedures and database schema in your source control system of choice? When you make a change (add a table, update an stored proc, how do you get the changes into source control? We use SQL Server at work, and I've begun using darcs for versioning, but I'd be curious about general s...
We choose to script everything, and that includes all stored procedures and schema changes. No wysiwyg tools, and no fancy 'sync' programs are necessary. Schema changes are easy, all you need to do is create and maintain a single file for that version, including all schema and data changes. This becomes your conversio...
77,213
<p>I have a large number of Enums that implement this interface:</p> <pre><code>/** * Interface for an enumeration, each element of which can be uniquely identified by its code */ public interface CodableEnum { /** * Get the element with a particular code * @param code * @return */ publi...
[ { "answer_id": 77298, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 1, "selected": false, "text": "<p>Unfortunately, I don't think that there is a way to do this. Your best bet would pro ably be to give up in emums a...
2008/09/16
[ "https://Stackoverflow.com/questions/77213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have a large number of Enums that implement this interface: ``` /** * Interface for an enumeration, each element of which can be uniquely identified by its code */ public interface CodableEnum { /** * Get the element with a particular code * @param code * @return */ public CodableEnum ...
You could factor the duplicated code into a `CodeableEnumHelper` class: ``` public class CodeableEnumHelper { public static CodeableEnum getByCode(String code, CodeableEnum[] values) { for (CodeableEnum e : values) { if (e.getCode().equalsIgnoreCase(code)) { return e; ...
77,258
<p>I am trying to solve the current problem using GPU capabilities: "given a point cloud P and an oriented plane described by a point and a normal (Pp, Np) return the points in the cloud which lye at a distance equal or less than EPSILON from the plane".</p> <p>Talking with a colleague of mine I converged toward the f...
[ { "answer_id": 77543, "author": "Sarien", "author_id": 1994377, "author_profile": "https://Stackoverflow.com/users/1994377", "pm_score": 0, "selected": false, "text": "<p>Ok first as a little disclaimer: I know nothing about 3D programming.</p>\n\n<p>Now my purely mathematical idea:</p>\...
2008/09/16
[ "https://Stackoverflow.com/questions/77258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to solve the current problem using GPU capabilities: "given a point cloud P and an oriented plane described by a point and a normal (Pp, Np) return the points in the cloud which lye at a distance equal or less than EPSILON from the plane". Talking with a colleague of mine I converged toward the following s...
It's simple: Let n be the normal of the plane and x be the point. ``` n_u = n/norm(n) //this is a normal vector of unit length d = scalarprod(n,x) //this is the distance of the plane to the origin for each point p_i d_i = abs(scalarprod(p_i,n) - d) //this is the distance of the point to the plane ``...
77,266
<p>Can I persuade <code>operator&gt;&gt;</code> in C++ to read both a <code>hex</code> value AND and a <code>decimal</code> value? The following program demonstrates how reading hex goes wrong. I'd like the same <code>istringstream</code> to be able to read both <code>hex</code> and <code>decimal</code>.</p> <pre><co...
[ { "answer_id": 77359, "author": "nsanders", "author_id": 1244, "author_profile": "https://Stackoverflow.com/users/1244", "pm_score": 4, "selected": false, "text": "<p>You need to tell C++ what your base is going to be.</p>\n\n<p>Want to parse a hex number? Change your \"is >> result\" l...
2008/09/16
[ "https://Stackoverflow.com/questions/77266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1359466/" ]
Can I persuade `operator>>` in C++ to read both a `hex` value AND and a `decimal` value? The following program demonstrates how reading hex goes wrong. I'd like the same `istringstream` to be able to read both `hex` and `decimal`. ``` #include <iostream> #include <sstream> int main(int argc, char** argv) { int re...
Use [`std::setbase(0)`](http://en.cppreference.com/w/cpp/io/manip/setbase) which enables prefix dependent parsing. It will be able to parse `10` (dec) as 10 decimal, `0x10` (hex) as 16 decimal and `010` (octal) as 8 decimal. ``` #include <iomanip> is >> std::setbase(0) >> result; ```
77,287
<p>I have a <code>modal dialog</code> form which has some "help links" within it which should open other non-modal panels or dialogs on top of it (while keeping the main dialog otherwise modal). </p> <p>However, these always end up behind the mask. <code>YUI</code> seems to be recognizing the highest <code>z-index</...
[ { "answer_id": 81688, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 0, "selected": false, "text": "<p>The original dialog can't be modal if the user is supposed to interact with other elements—that's the definition of modal...
2008/09/16
[ "https://Stackoverflow.com/questions/77287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8131/" ]
I have a `modal dialog` form which has some "help links" within it which should open other non-modal panels or dialogs on top of it (while keeping the main dialog otherwise modal). However, these always end up behind the mask. `YUI` seems to be recognizing the highest `z-index` out there and setting the mask and moda...
By default, YUI manages the z-index of anything that extends YAHOO.widget.Overlay and uses an overlay panel. It does this through the YAHOO.widget.Overlay's "bringToTop" method. You can turn this off by simply changing the "bringToTop" method to be an empty function: ``` YAHOO.widget.Overlay.prototype.bringToTop = fun...
77,293
<p>I would like to keep the overhead at a minimum. Right now I have:</p> <pre><code>// Launch a Message Box with advice to the user DialogResult result = MessageBox::Show("This may take awhile, do you wish to continue?", "Warning", MessageBoxButtons::YesNo, MessageBoxIcon::Exclamation); // The test will only be launc...
[ { "answer_id": 77457, "author": "Corin Blaikie", "author_id": 1736, "author_profile": "https://Stackoverflow.com/users/1736", "pm_score": 3, "selected": true, "text": "<p>You can use \"OK\" and \"Cancel\"</p>\n\n<p>By substituting <code>MessageBoxButtons::YesNo</code> with <code>MessageB...
2008/09/16
[ "https://Stackoverflow.com/questions/77293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9058/" ]
I would like to keep the overhead at a minimum. Right now I have: ``` // Launch a Message Box with advice to the user DialogResult result = MessageBox::Show("This may take awhile, do you wish to continue?", "Warning", MessageBoxButtons::YesNo, MessageBoxIcon::Exclamation); // The test will only be launched if the use...
You can use "OK" and "Cancel" By substituting `MessageBoxButtons::YesNo` with `MessageBoxButtons::OKCancel` [MessageBoxButtons Enum](http://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxbuttons.aspx) Short of that you would have to create a new form, as I don't believe the Enum can be extended.
77,382
<p>I have a class with a public array of bytes. Lets say its</p> <pre><code>Public myBuff as byte() </code></pre> <p>Events within the class get chunks of data in byte array. How do i tell the event code to stick the get chunk on the end? Lets say</p> <pre><code>Private Sub GetChunk Dim chunk as byte '... get st...
[ { "answer_id": 77390, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "<p>if i remember right, in vb you want to redim with preserve to grow an array.</p>\n" }, { "answer_id": 77402, "...
2008/09/16
[ "https://Stackoverflow.com/questions/77382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class with a public array of bytes. Lets say its ``` Public myBuff as byte() ``` Events within the class get chunks of data in byte array. How do i tell the event code to stick the get chunk on the end? Lets say ``` Private Sub GetChunk Dim chunk as byte '... get stuff in chunk Me.myBuff += chunk '(s...
if i remember right, in vb you want to redim with preserve to grow an array.
77,387
<p>In the Java collections framework, the Collection interface declares the following method:</p> <blockquote> <p><a href="http://java.sun.com/javase/6/docs/api/java/util/Collection.html#toArray(T%5B%5D)" rel="noreferrer"><code>&lt;T&gt; T[] toArray(T[] a)</code></a></p> <p>Returns an array containing all of the elemen...
[ { "answer_id": 77426, "author": "Arno", "author_id": 13685, "author_profile": "https://Stackoverflow.com/users/13685", "pm_score": 2, "selected": false, "text": "<pre><code>Array.newInstance(Class componentType, int length)\n</code></pre>\n" }, { "answer_id": 77429, "author":...
2008/09/16
[ "https://Stackoverflow.com/questions/77387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13979/" ]
In the Java collections framework, the Collection interface declares the following method: > > [`<T> T[] toArray(T[] a)`](http://java.sun.com/javase/6/docs/api/java/util/Collection.html#toArray(T%5B%5D)) > > > Returns an array containing all of the elements in this collection; the runtime type of the returned array...
Use the static method ``` java.lang.reflect.Array.newInstance(Class<?> componentType, int length) ``` A tutorial on its use can be found here: <http://java.sun.com/docs/books/tutorial/reflect/special/arrayInstance.html>
77,434
<p>Suppose I have a vector that is nested in a dataframe one or two levels. Is there a quick and dirty way to access the last value, without using the <code>length()</code> function? Something ala PERL's <code>$#</code> special var?</p> <p>So I would like something like:</p> <pre><code>dat$vec1$vec2[$#] </code></pr...
[ { "answer_id": 83162, "author": "Gregg Lind", "author_id": 15842, "author_profile": "https://Stackoverflow.com/users/15842", "pm_score": 7, "selected": false, "text": "<p>If you're looking for something as nice as Python's x[-1] notation, I think you're out of luck. The standard idiom i...
2008/09/16
[ "https://Stackoverflow.com/questions/77434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14008/" ]
Suppose I have a vector that is nested in a dataframe one or two levels. Is there a quick and dirty way to access the last value, without using the `length()` function? Something ala PERL's `$#` special var? So I would like something like: ``` dat$vec1$vec2[$#] ``` instead of ``` dat$vec1$vec2[length(dat$vec1$vec2...
I use the `tail` function: ``` tail(vector, n=1) ``` The nice thing with `tail` is that it works on dataframes too, unlike the `x[length(x)]` idiom.
77,503
<p>I am trying to compare two large datasets from a SQL query. Right now the SQL query is done externally and the results from each dataset is saved into its own csv file. My little C# console application loads up the two text/csv files and compares them for differences and saves the differences to a text file.</p> <p...
[ { "answer_id": 77546, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 0, "selected": false, "text": "<p>Well, there are several approaches that would work. You could write your own data structure that did this. Or you can t...
2008/09/16
[ "https://Stackoverflow.com/questions/77503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8664/" ]
I am trying to compare two large datasets from a SQL query. Right now the SQL query is done externally and the results from each dataset is saved into its own csv file. My little C# console application loads up the two text/csv files and compares them for differences and saves the differences to a text file. Its a ver...
If data in both of your CSV files is already sorted and have the same number of records, you could skip the data structure entirely and do in-place analysis. ``` StreamReader one = new StreamReader("C:\file1.csv"); StreamReader two = new StreamReader("C:\file2.csv"); String lineOne; String lineTwo; StreamWriter diffe...
77,528
<p>I'm currently running Vista and I would like to manually complete the same operations as my Windows Service. Since the Windows Service is running under the Local System Account, I would like to emulate this same behavior. Basically, I would like to run CMD.EXE under the Local System Account.</p> <p>I found informat...
[ { "answer_id": 77615, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 3, "selected": false, "text": "<p>Found an answer <a href=\"http://blogs.msdn.com/adioltean/articles/271063.aspx\" rel=\"noreferrer\">here</a> which seems ...
2008/09/16
[ "https://Stackoverflow.com/questions/77528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4115/" ]
I'm currently running Vista and I would like to manually complete the same operations as my Windows Service. Since the Windows Service is running under the Local System Account, I would like to emulate this same behavior. Basically, I would like to run CMD.EXE under the Local System Account. I found information online...
Though I haven't personally tested, I have good reason to believe that the above stated AT COMMAND solution will work for XP, 2000 and Server 2003. Per my and Bryant's testing, we've identified that the same approach does not work with Vista or Windows Server 2008 -- most probably due to added security and the /interac...
77,552
<p>Why is it bad to name a variable <code>id</code> in Python?</p>
[ { "answer_id": 77563, "author": "ahockley", "author_id": 8209, "author_profile": "https://Stackoverflow.com/users/8209", "pm_score": -1, "selected": false, "text": "<p>Because it's the name of a builtin function.</p>\n" }, { "answer_id": 77600, "author": "Toni Ruža", "aut...
2008/09/16
[ "https://Stackoverflow.com/questions/77552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5926/" ]
Why is it bad to name a variable `id` in Python?
`id()` is a fundamental built-in: > > Help on built-in function `id` in module > `__builtin__`: > > > > ```none > id(...) > > id(object) -> integer > > Return the identity of an object. This is guaranteed to be unique among > simultaneously existing objects. (Hint: it's the object's memory > a...
77,558
<p>I want to write a raw byte/byte stream to a position in a file. This is what I have currently:</p> <pre><code>$fpr = fopen($out, 'r+'); fseek($fpr, 1); //seek to second byte fwrite($fpr, 0x63); fclose($fpr); </code></pre> <p>This currently writes the actually string value of "99" starting at byte offset 1. IE, i...
[ { "answer_id": 77585, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 4, "selected": true, "text": "<p><code>fwrite()</code> takes strings. Try <code>chr(0x63)</code> if you want to write a <code>0x63</code> byte to the file....
2008/09/16
[ "https://Stackoverflow.com/questions/77558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10333/" ]
I want to write a raw byte/byte stream to a position in a file. This is what I have currently: ``` $fpr = fopen($out, 'r+'); fseek($fpr, 1); //seek to second byte fwrite($fpr, 0x63); fclose($fpr); ``` This currently writes the actually string value of "99" starting at byte offset 1. IE, it writes bytes "9" and "9"....
`fwrite()` takes strings. Try `chr(0x63)` if you want to write a `0x63` byte to the file.
77,582
<p>I am looking for a tool for regression testing a suite of equipment we are building.</p> <p>The current concept is that you create an input file (text/csv) to the tool specifying inputs to the system under test. The tool then captures the outputs from the system and records the inputs and outputs to an output file....
[ { "answer_id": 77684, "author": "apenwarr", "author_id": 42219, "author_profile": "https://Stackoverflow.com/users/42219", "pm_score": 0, "selected": false, "text": "<p>You can just use any test framework. The hard part is writing the tools to send/retrieve the data from your test syste...
2008/09/16
[ "https://Stackoverflow.com/questions/77582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13923/" ]
I am looking for a tool for regression testing a suite of equipment we are building. The current concept is that you create an input file (text/csv) to the tool specifying inputs to the system under test. The tool then captures the outputs from the system and records the inputs and outputs to an output file. The out...
I recently built a system like this on top of git (<http://git.or.cz/>). Basically, write a program that takes all your input files, sends them to the server, reads the output back, and writes it to a set of output files. After the first run, commit the output files to git. For future runs, your success is determined ...
77,659
<p>I have a .NET <strong>2.0</strong> WebBrowser control used to navigate some pages with no user interaction (don't ask...long story). Because of the user-less nature of this application, I have set the WebBrowser control's ScriptErrorsSuppressed property to true, which the documentation included with VS 2005 states ...
[ { "answer_id": 98543, "author": "William", "author_id": 14829, "author_profile": "https://Stackoverflow.com/users/14829", "pm_score": 0, "selected": false, "text": "<p>Are you trying to implement a web robot? I have little experience in using the hosted IE control but I did completed a f...
2008/09/16
[ "https://Stackoverflow.com/questions/77659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13791/" ]
I have a .NET **2.0** WebBrowser control used to navigate some pages with no user interaction (don't ask...long story). Because of the user-less nature of this application, I have set the WebBrowser control's ScriptErrorsSuppressed property to true, which the documentation included with VS 2005 states will [...]"hide a...
This is most definitely hacky, but if you do any work with the WebBrowser control, you'll find yourself doing a lot of hacky stuff. This is the easiest way that I know of to do this. You need to inject JavaScript to override the alert function... something along the lines of injecting this JavaScript function: ``` wi...
77,683
<p>For example, <a href="http://reductiotest.org/" rel="nofollow noreferrer">Reductio</a> (for Java/Scala) and <a href="http://www.cs.chalmers.se/~rjmh/QuickCheck/" rel="nofollow noreferrer">QuickCheck</a> (for Haskell). The kind of framework I'm thinking of would provide "generators" for built-in data types and allow...
[ { "answer_id": 77720, "author": "Adam Driscoll", "author_id": 13688, "author_profile": "https://Stackoverflow.com/users/13688", "pm_score": -1, "selected": false, "text": "<p>I might not understand you correctly but check this out...</p>\n\n<p><a href=\"http://www.ayende.com/projects/rhi...
2008/09/16
[ "https://Stackoverflow.com/questions/77683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14113/" ]
For example, [Reductio](http://reductiotest.org/) (for Java/Scala) and [QuickCheck](http://www.cs.chalmers.se/~rjmh/QuickCheck/) (for Haskell). The kind of framework I'm thinking of would provide "generators" for built-in data types and allow the programmer to define new generators. Then, the programmer would define a ...
There's FsCheck, a port from QuickCheck to F# and thus C#, although most of the doc seems to be for f#. I've been exploring the ideas myself aswell. see : <http://kilfour.wordpress.com/2009/08/02/testing-tool-tour-quicknet-preview/>
77,695
<p>What do I need to set up and maintain a local CPAN mirror? What scripts and best practices should I be aware of?</p>
[ { "answer_id": 77722, "author": "mopoke", "author_id": 14054, "author_profile": "https://Stackoverflow.com/users/14054", "pm_score": 2, "selected": false, "text": "<p>Try <a href=\"http://search.cpan.org/perldoc/CPAN::Mini\" rel=\"nofollow noreferrer\">CPAN::Mini</a>.</p>\n" }, { ...
2008/09/16
[ "https://Stackoverflow.com/questions/77695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9532/" ]
What do I need to set up and maintain a local CPAN mirror? What scripts and best practices should I be aware of?
[CPAN::Mini](http://search.cpan.org/perldoc?CPAN::Mini) is the way to go. Once you've mirrored CPAN locally, you'll want to set your mirror URL in CPAN.pm or CPANPLUS to the local directory using a "file:" URL like this: ``` file:///path/to/my/cpan/mirror ``` If you'd like your mirror to have copies of development v...
77,718
<p>Coming from C++ to Java, the obvious unanswered question is why didn't Java include operator overloading?</p> <p>Isn't <code>Complex a, b, c; a = b + c;</code> much simpler than <code>Complex a, b, c; a = b.add(c);</code>?</p> <p>Is there a known reason for this, valid arguments for <em>not</em> allowing operator ...
[ { "answer_id": 77738, "author": "Sarien", "author_id": 1994377, "author_profile": "https://Stackoverflow.com/users/1994377", "pm_score": 3, "selected": false, "text": "<p>Well you can really shoot yourself in the foot with operator overloading. It's like with pointers people make stupid ...
2008/09/16
[ "https://Stackoverflow.com/questions/77718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Coming from C++ to Java, the obvious unanswered question is why didn't Java include operator overloading? Isn't `Complex a, b, c; a = b + c;` much simpler than `Complex a, b, c; a = b.add(c);`? Is there a known reason for this, valid arguments for *not* allowing operator overloading? Is the reason arbitrary, or lost ...
Assuming you wanted to overwrite the previous value of the object referred to by `a`, then a member function would have to be invoked. ``` Complex a, b, c; // ... a = b.add(c); ``` In C++, this expression tells the compiler to create three (3) objects on the stack, perform addition, and *copy* the resultant value fr...
77,744
<p>I have a command line program, which outputs logging to the screen.</p> <p>I want error lines to show up in red. Is there some special character codes I can output to switch the text color to red, then switch it back to white?</p> <p>I'm using ruby but I imagine this would be the same in any other language.</p> <...
[ { "answer_id": 77795, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>As far as I know it is not possible with a command line, it is just one color...</p>\n" }, { "answer_id"...
2008/09/16
[ "https://Stackoverflow.com/questions/77744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
I have a command line program, which outputs logging to the screen. I want error lines to show up in red. Is there some special character codes I can output to switch the text color to red, then switch it back to white? I'm using ruby but I imagine this would be the same in any other language. Something like: ``` r...
You need to access the [Win32 Console API](https://learn.microsoft.com/en-us/windows/console/console-functions). Unfortunately, I don't know how you'd do that from Ruby. In Perl, I'd use the [Win32::Console](http://search.cpan.org/perldoc?Win32::Console) module. The Windows console does not respond to ANSI escape codes...
77,748
<p>We have a server with 10 running mongrel_cluster instances with apache in front of them, and every now and then one or some of them hang. No activity is seen in the database (we're using activerecord sessions). Mysql with innodb tables. show innodb status shows no locks. show processlist shows nothing.</p> <p>The s...
[ { "answer_id": 78044, "author": "sean lynch", "author_id": 14232, "author_profile": "https://Stackoverflow.com/users/14232", "pm_score": 1, "selected": false, "text": "<p>Chapter 6.3 in the book Deploying Rails Applications (A Step by Step Guide) has a good section on installing and conf...
2008/09/16
[ "https://Stackoverflow.com/questions/77748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13709/" ]
We have a server with 10 running mongrel\_cluster instances with apache in front of them, and every now and then one or some of them hang. No activity is seen in the database (we're using activerecord sessions). Mysql with innodb tables. show innodb status shows no locks. show processlist shows nothing. The server is ...
Consider using [ImageScience](http://seattlerb.rubyforge.org/ImageScience.html), RMagick is known to leak massive amounts of memory and lock.
77,813
<p>Does anyone have any pointers on how to read the Windows EventLog without using JNI? Or if you <em>have to</em> use JNI, are there any good open-source libraries for doing so?</p>
[ { "answer_id": 78015, "author": "Sanjaya R", "author_id": 9353, "author_profile": "https://Stackoverflow.com/users/9353", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://bloggingabout.net/blogs/wellink/archive/2005/04/08/3289.aspx\" rel=\"nofollow noreferrer\">http://blogg...
2008/09/16
[ "https://Stackoverflow.com/questions/77813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1693/" ]
Does anyone have any pointers on how to read the Windows EventLog without using JNI? Or if you *have to* use JNI, are there any good open-source libraries for doing so?
JNA 3.2.8 has both an implementation for all event logging functions and a Java iterator. Read [this](http://code.dblock.org/ShowPost.aspx?id=125). ``` EventLogIterator iter = new EventLogIterator("Application"); while(iter.hasNext()) { EventLogRecord record = iter.next(); System.out.println(record....
77,826
<p>One thing I've started doing more often recently is <strong>retrieving some data</strong> at the beginning of a task <strong>and storing it in a $_SESSION['myDataForTheTask']</strong>. </p> <p>Now it seems very convenient to do so but I don't know anything about performance, security risks or similar, using this ap...
[ { "answer_id": 77846, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 1, "selected": false, "text": "<p>$_SESSION items are stored in the session, which is, by default, kept on disk. There is no need to make your own array an...
2008/09/16
[ "https://Stackoverflow.com/questions/77826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11995/" ]
One thing I've started doing more often recently is **retrieving some data** at the beginning of a task **and storing it in a $\_SESSION['myDataForTheTask']**. Now it seems very convenient to do so but I don't know anything about performance, security risks or similar, using this approach. Is it something which is re...
Well Session variables are really one of the only ways (and probably the most efficient) of having these variables available for the entire time that visitor is on the website, there's no real way for a user to edit them (other than an exploit in your code, or in the PHP interpreter) so they are fairly secure. It's a ...
77,835
<p>I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script. </p> <p>My goal is to use phpunit with Selenium RC in CruiseControl &amp; phpUnderControl. This is what the test looks like:</p> <pre><code>require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class WebTe...
[ { "answer_id": 77955, "author": "Ciaran", "author_id": 5048, "author_profile": "https://Stackoverflow.com/users/5048", "pm_score": 1, "selected": false, "text": "<p>Have a look at one of the comments in the require_once entry in the php manual..</p>\n\n<p><a href=\"http://ie.php.net/manu...
2008/09/16
[ "https://Stackoverflow.com/questions/77835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12645/" ]
I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script. My goal is to use phpunit with Selenium RC in CruiseControl & phpUnderControl. This is what the test looks like: ``` require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; class WebTest extends PHPUnit_Extens...
hopefully this is a more definitive answer then the ones given here (which did not solve me problem). If you are getting this error, check your PEAR folder and see if the "SeleniumTestCase.php" file is actually there: ``` /PEAR/PHPUnit/Extensions/SeleniumTestCase.php ``` If it is NOT, the easiest thing to do is to u...
77,873
<p>Are there PHP libraries which can be used to fill PDF forms and then save (flatten) them to PDF files?</p>
[ { "answer_id": 77930, "author": "pix0r", "author_id": 72, "author_profile": "https://Stackoverflow.com/users/72", "pm_score": 1, "selected": false, "text": "<p>Looks like this has been <a href=\"https://stackoverflow.com/questions/7364/pdf-editing-in-php\">covered before</a>. Click thro...
2008/09/16
[ "https://Stackoverflow.com/questions/77873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14166/" ]
Are there PHP libraries which can be used to fill PDF forms and then save (flatten) them to PDF files?
The libraries and frameworks mentioned here are good, but if all you want to do is fill in a form and flatten it, I recommend the command line tool called pdftk (PDF Toolkit). See <https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/> You can call the command line from php, and the command is `pdftk` *formfile.pdf* ...
77,887
<p>As someone who is just starting to learn the intricacies of computer debugging, for the life of me, I can't understand how to read the Stack Text of a dump in Windbg. I've no idea of where to start on how to interpret them or how to go about it. Can anyone offer direction to this poor soul?</p> <p>ie (the only dump...
[ { "answer_id": 77921, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 0, "selected": false, "text": "<p>It might help to include an example of the stack you are trying to read. A good tip is to ensure you have correct...
2008/09/16
[ "https://Stackoverflow.com/questions/77887", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14173/" ]
As someone who is just starting to learn the intricacies of computer debugging, for the life of me, I can't understand how to read the Stack Text of a dump in Windbg. I've no idea of where to start on how to interpret them or how to go about it. Can anyone offer direction to this poor soul? ie (the only dump I have on...
First, you need to have the proper symbols configured. The symbols will allow you to match memory addresses to function names. In order to do this you have to create a local folder in your machine in which you will store a local cache of symbols (for example: C:\symbols). Then you need to specify the symbols server pat...
77,890
<p>I am writing some code to see if there is a hole in the firewall exception list for <strong>WinXP</strong> and <strong>Vista</strong> for a specific port used by our client software. </p> <p>I can see that I can use the <code>NetFwMgr.LocalPolicy.CurrentProfile.GloballyOpenPorts</code> to get a list of the current ...
[ { "answer_id": 78144, "author": "Jim McKeeth", "author_id": 255, "author_profile": "https://Stackoverflow.com/users/255", "pm_score": 0, "selected": false, "text": "<p>Without setting up an application to test with, I'll suggest the following. Let me know if it works.</p>\n\n<p>I looked...
2008/09/16
[ "https://Stackoverflow.com/questions/77890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12425/" ]
I am writing some code to see if there is a hole in the firewall exception list for **WinXP** and **Vista** for a specific port used by our client software. I can see that I can use the `NetFwMgr.LocalPolicy.CurrentProfile.GloballyOpenPorts` to get a list of the current Open port exceptions. But i can not figure out ...
OK, I think that I have it figured out. I had to create a type library file of the hnetcfg.dll. I did that when I first started but have learned a lot about the firewall objects since then. It didn't work then, but its working now. You can create your own file from Component|Import Component. And then follow the wiza...
77,900
<p>Has anyone ever written a function that can convert all of the controls on an aspx page into a read only version? For example, if UserDetails.aspx is used to edit and save a users information, if someone with inappropriate permissions enter the page, I would like to render it as read-only. So, most controls would ...
[ { "answer_id": 77938, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 2, "selected": false, "text": "<p>You could use a multiview and just have a display view and an edit view.. then do your assignments as:</p>\n\n<...
2008/09/16
[ "https://Stackoverflow.com/questions/77900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8678/" ]
Has anyone ever written a function that can convert all of the controls on an aspx page into a read only version? For example, if UserDetails.aspx is used to edit and save a users information, if someone with inappropriate permissions enter the page, I would like to render it as read-only. So, most controls would be co...
You could use a multiview and just have a display view and an edit view.. then do your assignments as: ``` lblWhatever.Text = txtWhatever.Text = whateverOriginatingSource; lblSomethingElse.Text = txtSomethingElse.Text = somethingElseOriginatingSource; myViews.SelectedIndex = myConditionOrVariableThatDeterminesEditabl...
77,934
<p>I have written code to read a windows bitmap and would now like to display it with ltk. How can I construct an appropriate object? Is there such functionality in ltk? If not how can I do it directly interfacing to tk?</p>
[ { "answer_id": 78937, "author": "Bryan Oakley", "author_id": 7432, "author_profile": "https://Stackoverflow.com/users/7432", "pm_score": 2, "selected": false, "text": "<p>Tk does not natively support windows bitmap files. However, the \"Img\" extension does and is freely available on jus...
2008/09/16
[ "https://Stackoverflow.com/questions/77934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1994377/" ]
I have written code to read a windows bitmap and would now like to display it with ltk. How can I construct an appropriate object? Is there such functionality in ltk? If not how can I do it directly interfacing to tk?
It has been a while since I used LTK for anything, but the simplest way to display an image with LTK is as follows: ``` (defpackage #:ltk-image-example (:use #:cl #:ltk)) (in-package #:ltk-image-example) (defun image-example () (with-ltk () (let ((image (make-image))) (image-load image "testimage.gif")...
77,936
<p>As part of a project at work I have to calculate the centroid of a set of points in 3D space. Right now I'm doing it in a way that seems simple but naive -- by taking the average of each set of points, as in:</p> <pre><code>centroid = average(x), average(y), average(z) </code></pre> <p>where <code>x</code>, <code>...
[ { "answer_id": 77978, "author": "deemer", "author_id": 11192, "author_profile": "https://Stackoverflow.com/users/11192", "pm_score": 4, "selected": false, "text": "<p>Nope, that is the only formula for the centroid of a collection of points. See Wikipedia: <a href=\"http://en.wikipedia....
2008/09/16
[ "https://Stackoverflow.com/questions/77936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/676/" ]
As part of a project at work I have to calculate the centroid of a set of points in 3D space. Right now I'm doing it in a way that seems simple but naive -- by taking the average of each set of points, as in: ``` centroid = average(x), average(y), average(z) ``` where `x`, `y` and `z` are arrays of floating-point nu...
Contrary to the common refrain here, there are different ways to define (and calculate) a center of a point cloud. The first and most common solution has been suggested by you already and I will **not** argue that there is anything wrong with this: `centroid = average(x), average(y), average(z)` The "problem" here is...
77,954
<p>How do you get Perl to stop and give a stack trace when you reference an undef value, rather than merely warning? It seems that <code>use strict;</code> isn't sufficient for this purpose.</p>
[ { "answer_id": 77969, "author": "Neil", "author_id": 14193, "author_profile": "https://Stackoverflow.com/users/14193", "pm_score": 2, "selected": false, "text": "<p>Include this:</p>\n\n<pre><code>use Carp ();\n</code></pre>\n\n<p>Then include <em>one</em> of these lines at the top of yo...
2008/09/16
[ "https://Stackoverflow.com/questions/77954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14193/" ]
How do you get Perl to stop and give a stack trace when you reference an undef value, rather than merely warning? It seems that `use strict;` isn't sufficient for this purpose.
``` use warnings FATAL => 'uninitialized'; use Carp (); $SIG{__DIE__} = \&Carp::confess; ``` The first line makes the warning fatal. The next two cause a stack trace when your program dies. See also `man 3pm warnings` for more details.
77,957
<p>I'm using Visual Studio 2008 for an ASP .Net application, and Visual Studio keeps adding blank lines to my aspx file whenever I save, switch to design mode and back to code view, switch to split mode, or switch between files. Before I save, I will have:</p> <pre><code> &lt;/ContentTemplate&g...
[ { "answer_id": 78486, "author": "LizB", "author_id": 13616, "author_profile": "https://Stackoverflow.com/users/13616", "pm_score": 0, "selected": false, "text": "<p>I can't say I've ever experience this with any Visual Studio yet, but try this</p>\n\n<p><strong>Ctrl-E, D</strong> command...
2008/09/16
[ "https://Stackoverflow.com/questions/77957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13208/" ]
I'm using Visual Studio 2008 for an ASP .Net application, and Visual Studio keeps adding blank lines to my aspx file whenever I save, switch to design mode and back to code view, switch to split mode, or switch between files. Before I save, I will have: ``` </ContentTemplate></asp:UpdatePanel> ...
The only time I've seen Visual Studio do something close to this is when the XML/HTML in question is invalid, for example you are missing a closing tag somewhere.
77,996
<p>Is it possible to create custom events in C++? For example, say I have the variable X, and the variable Y. Whenever X changes, I would like to execute a function that sets Y equal to 3X. Is there a way to create such a trigger/event? (triggers are common in some databases)</p>
[ { "answer_id": 78013, "author": "epatel", "author_id": 842, "author_profile": "https://Stackoverflow.com/users/842", "pm_score": 1, "selected": false, "text": "<p>Think you should read a little about <a href=\"http://en.wikipedia.org/wiki/Design_pattern_(computer_science)\" rel=\"nofollo...
2008/09/16
[ "https://Stackoverflow.com/questions/77996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13790/" ]
Is it possible to create custom events in C++? For example, say I have the variable X, and the variable Y. Whenever X changes, I would like to execute a function that sets Y equal to 3X. Is there a way to create such a trigger/event? (triggers are common in some databases)
This is basically an instance of the Observer pattern (as others have mentioned and linked). However, you can use template magic to render it a little more syntactically palettable. Consider something like... ``` template <typename T> class Observable { T underlying; public: Observable<T>& operator=(const T &rhs)...
78,053
<p>I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do:</p> <pre><code>Excel::HPageBreaksPtr pHPageBreaks = pSheet-&gt;GetHPageBreaks(); long count = pHPageBreaks-&gt;Count; for (long i=0; i &lt; count; ++i...
[ { "answer_id": 78519, "author": "Joel Spolsky", "author_id": 4, "author_profile": "https://Stackoverflow.com/users/4", "pm_score": 0, "selected": false, "text": "<p>Did you set ScreenUpdating to True, as mentioned in the KB article?</p>\n\n<p>You may want to actually toggle it to True to...
2008/09/16
[ "https://Stackoverflow.com/questions/78053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14238/" ]
I've been trying to retrieve the locations of all the page breaks on a given Excel 2003 worksheet over COM. Here's an example of the kind of thing I'm trying to do: ``` Excel::HPageBreaksPtr pHPageBreaks = pSheet->GetHPageBreaks(); long count = pHPageBreaks->Count; for (long i=0; i < count; ++i) { Excel::HPageBreakP...
Experimenting with Excel 2007 from Visual Basic, I discovered that the page break isn't known unless it has been displayed on the screen at least once. The best workaround I could find was to page down, from the top of the sheet to the last row containing data. Then you can enumerate all the page breaks. Here's the V...
78,064
<p>I've read this <a href="https://stackoverflow.com/questions/40122/exceptions-in-web-services">thread</a> for WCF has inbuilt Custom Fault codes and stuff.</p> <p>But what is the best practice for <em>ASP.Net</em> web services? Do I throw exceptions and let the client handle the exception or send an Error code (succ...
[ { "answer_id": 78171, "author": "Sunny Milenov", "author_id": 8220, "author_profile": "https://Stackoverflow.com/users/8220", "pm_score": 1, "selected": false, "text": "<p>Depends on how you are going to consume the web service - i.e. which protocol are you going to use.</p>\n\n<p>If it ...
2008/09/16
[ "https://Stackoverflow.com/questions/78064", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747/" ]
I've read this [thread](https://stackoverflow.com/questions/40122/exceptions-in-web-services) for WCF has inbuilt Custom Fault codes and stuff. But what is the best practice for *ASP.Net* web services? Do I throw exceptions and let the client handle the exception or send an Error code (success, failure etc) that the c...
Jeff Atwood posted [an interesting aerticle](http://www.codinghorror.com/blog/archives/000054.html) about this subject some time ago. Allthough a .NET exception is converted to a SoapFault, which is compatible with most other toolkits, the information in the faults isn't very good. Therefor, the conlusion of the articl...
78,077
<p>What is the best/fastest way to sort Alphanumeric fields? </p>
[ { "answer_id": 78096, "author": "senfo", "author_id": 10792, "author_profile": "https://Stackoverflow.com/users/10792", "pm_score": 0, "selected": false, "text": "<p>You will find that most development libraries ship with an implementation of the quicksort algorithm, which is often the f...
2008/09/16
[ "https://Stackoverflow.com/questions/78077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14239/" ]
What is the best/fastest way to sort Alphanumeric fields?
You don't specify your target language, but whatever it is, it should have reliable, built-in sorting methods, so use one of them! For PHP... Load into an array and sort($array); [php sort](http://ie.php.net/sort)... ``` $fruits = array("lemon", "orange", "banana", "apple"); sort($fruits); foreach ($fruits as $key ...
78,125
<p>The following code snippet (correctly) gives a warning in C and an error in C++ (using gcc &amp; g++ respectively, tested with versions 3.4.5 and 4.2.1; MSVC does not seem to care):</p> <pre><code>char **a; const char** b = a; </code></pre> <p>I can understand and accept this.<br> The C++ solution to this problem ...
[ { "answer_id": 78202, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 7, "selected": true, "text": "<p>I had this same problem a few years ago and it irked me to no end.</p>\n\n<p>The rules in C are more simply stated (i.e. they...
2008/09/16
[ "https://Stackoverflow.com/questions/78125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14266/" ]
The following code snippet (correctly) gives a warning in C and an error in C++ (using gcc & g++ respectively, tested with versions 3.4.5 and 4.2.1; MSVC does not seem to care): ``` char **a; const char** b = a; ``` I can understand and accept this. The C++ solution to this problem is to change b to be a const ch...
I had this same problem a few years ago and it irked me to no end. The rules in C are more simply stated (i.e. they don't list exceptions like converting `char**` to `const char*const*`). Consequenlty, it's just not allowed. With the C++ standard, they included more rules to allow cases like this. In the end, it's ju...
78,141
<h2>Edit - New Question</h2> <p>Ok lets rephrase the question more generically. </p> <p>Using reflection, is there a way to dynamically call at runtime a base class method that you may be overriding. You cannot use the 'base' keyword at compile time because you cannot be sure it exists. At runtime I want to list my a...
[ { "answer_id": 78226, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 2, "selected": false, "text": "<p>Personally, I think you might be better off handling this with something like FxCop. You should be able to write a rule t...
2008/09/16
[ "https://Stackoverflow.com/questions/78141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7984/" ]
Edit - New Question ------------------- Ok lets rephrase the question more generically. Using reflection, is there a way to dynamically call at runtime a base class method that you may be overriding. You cannot use the 'base' keyword at compile time because you cannot be sure it exists. At runtime I want to list my ...
The standard pattern is for your base class to implement IDisposable and the non-virtual Dispose() method, and to implement a virtual Dispose(bool) method, which those classes which hold disposable resources must override. They should always call their base Dispose(bool) method, which will chain up to the top class in ...
78,161
<p>In a C++ app, I have an hWnd pointing to a window running in a third party process. This window contains controls which extend the COM TreeView control. I am interested in obtaining the CheckState of this control.<br> I use the hWnd to get an HTREEITEM using TreeView_GetRoot(hwnd) from commctrl.h</p> <p>hwnd points...
[ { "answer_id": 78229, "author": "Mike Dimmick", "author_id": 6970, "author_profile": "https://Stackoverflow.com/users/6970", "pm_score": 1, "selected": false, "text": "<p>Why are you not using a Windows Forms TreeView control? If you are using this control, set the control's CheckBoxes p...
2008/09/16
[ "https://Stackoverflow.com/questions/78161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/165305/" ]
In a C++ app, I have an hWnd pointing to a window running in a third party process. This window contains controls which extend the COM TreeView control. I am interested in obtaining the CheckState of this control. I use the hWnd to get an HTREEITEM using TreeView\_GetRoot(hwnd) from commctrl.h hwnd points to the wi...
We have these definitions from CommCtrl.h: ``` #define TreeView_SetItemState(hwndTV, hti, data, _mask) \ { TVITEM _ms_TVi;\ _ms_TVi.mask = TVIF_STATE; \ _ms_TVi.hItem = (hti); \ _ms_TVi.stateMask = (_mask);\ _ms_TVi.state = (data);\ SNDMSG((hwndTV), TVM_SETITEM, 0, (LPARAM)(TV_ITEM *)&_ms_TVi);\ } #define T...
78,181
<p>If I am given a <code>MemoryStream</code> that I know has been populated with a <code>String</code>, how do I get a <code>String</code> back out?</p>
[ { "answer_id": 78189, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 6, "selected": false, "text": "<p>use a <a href=\"http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx\" rel=\"nofollow noreferrer\">StreamRe...
2008/09/16
[ "https://Stackoverflow.com/questions/78181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/320/" ]
If I am given a `MemoryStream` that I know has been populated with a `String`, how do I get a `String` back out?
This sample shows how to read and write a string to a MemoryStream. --- ``` Imports System.IO Module Module1 Sub Main() ' We don't need to dispose any of the MemoryStream ' because it is a managed object. However, just for ' good practice, we'll close the MemoryStream. Using ms As New MemoryStre...
78,233
<p>I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application. I have run into two problems with this:</p> <ol> <li><p>Excel is not the default Windows application to open Excel ...
[ { "answer_id": 78246, "author": "sgwill", "author_id": 1204, "author_profile": "https://Stackoverflow.com/users/1204", "pm_score": 1, "selected": false, "text": "<p>What if you save the file as an xlsx, the extension for XML-Excel?</p>\n" }, { "answer_id": 78292, "author": "M...
2008/09/16
[ "https://Stackoverflow.com/questions/78233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2916/" ]
I have a dataset that I have modified into an xml document and then used a xsl sheet to transform into an Excel xml format in order to allow the data to be opened programatically from my application. I have run into two problems with this: 1. Excel is not the default Windows application to open Excel files, therefore ...
``` Process.Start(@"C:\Program Files\Microsoft Office\Officexx\excel.exe", "yourfile.xml"); ``` That being said, you will still get the message box. I suppose that you could use the Interop, but I am not sure how well it will work for you.
78,277
<p>When can 64-bit writes be guaranteed to be atomic, when programming in C on an Intel x86-based platform (in particular, an Intel-based Mac running MacOSX 10.4 using the Intel compiler)? For example:</p> <pre><code>unsigned long long int y; y = 0xfedcba87654321ULL; /* ... a bunch of other time-consuming stuff happe...
[ { "answer_id": 78285, "author": "Dark Shikari", "author_id": 11206, "author_profile": "https://Stackoverflow.com/users/11206", "pm_score": 1, "selected": false, "text": "<p>GCC has intrinsics for atomic operations; I suspect you can do similar with other compilers, too. Never rely on th...
2008/09/16
[ "https://Stackoverflow.com/questions/78277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When can 64-bit writes be guaranteed to be atomic, when programming in C on an Intel x86-based platform (in particular, an Intel-based Mac running MacOSX 10.4 using the Intel compiler)? For example: ``` unsigned long long int y; y = 0xfedcba87654321ULL; /* ... a bunch of other time-consuming stuff happens... */ y = 0x...
Your best bet is to avoid trying to build your own system out of primitives, and instead use locking unless it **really** shows up as a hot spot when profiling. (If you think you can be clever and avoid locks, don't. You aren't. That's the general "you" which includes me and everybody else.) You should at minimum use a...
78,278
<p>How do I write a clean implementation of the strategy pattern in Perl? I want to do it in a way that leverages Perl's features.</p>
[ { "answer_id": 78301, "author": "Leon Timmermans", "author_id": 4727, "author_profile": "https://Stackoverflow.com/users/4727", "pm_score": 2, "selected": false, "text": "<p>Use sub references, and closures. A good perlish example of this</p>\n\n<pre><code>sort { lc($a) cmp lc($b) } @ite...
2008/09/16
[ "https://Stackoverflow.com/questions/78278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1227001/" ]
How do I write a clean implementation of the strategy pattern in Perl? I want to do it in a way that leverages Perl's features.
It really depends on what you mean by "clean implementation". As in any other language, you can use Perl's object system with polymorphism to do this for you. However, since Perl has first class functions, this pattern isn't normally coded explicitly. Leon Timmermans' example of ``` sort { lc($a) cmp lc($b) } @items ...
78,296
<p>What are some reasons why PHP would force errors to show, no matter what you tell it to disable?</p> <p>I have tried </p> <pre><code>error_reporting(0); ini_set('display_errors', 0); </code></pre> <p>with no luck.</p>
[ { "answer_id": 78324, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 5, "selected": true, "text": "<p>Note the caveat in the manual at <a href=\"http://uk.php.net/error_reporting\" rel=\"noreferrer\">http://uk.php.net/err...
2008/09/16
[ "https://Stackoverflow.com/questions/78296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14322/" ]
What are some reasons why PHP would force errors to show, no matter what you tell it to disable? I have tried ``` error_reporting(0); ini_set('display_errors', 0); ``` with no luck.
Note the caveat in the manual at <http://uk.php.net/error_reporting>: > > > > > > Most of E\_STRICT errors are evaluated at the compile time thus such errors are not reported in the file where error\_reporting is enhanced to include E\_STRICT errors (and vice versa). > > > > > > > > > If your underlying syst...
78,389
<p>I'm new to RhinoMocks, and trying to get a grasp on the syntax in addition to what is happening under the hood.</p> <p>I have a user object, we'll call it User, which has a property called IsAdministrator. The value for IsAdministrator is evaluated via another class that checks the User's security permissions, and ...
[ { "answer_id": 78428, "author": "Aaron Jensen", "author_id": 11229, "author_profile": "https://Stackoverflow.com/users/11229", "pm_score": 1, "selected": false, "text": "<p>Make sure IsAdministrator is virtual.</p>\n\n<p>Also, be sure you call _mocks.ReplayAll()</p>\n" }, { "answ...
2008/09/16
[ "https://Stackoverflow.com/questions/78389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769/" ]
I'm new to RhinoMocks, and trying to get a grasp on the syntax in addition to what is happening under the hood. I have a user object, we'll call it User, which has a property called IsAdministrator. The value for IsAdministrator is evaluated via another class that checks the User's security permissions, and returns ei...
One quick note before I jump into this. Typically you want to avoid the use of a "Strict" mock because it makes for a brittle test. A strict mock will throw an exception if anything occurs that you do not explicitly tell Rhino will happen. Also I think you may be misunderstanding exactly what Rhino is doing when you ma...
78,392
<p>I have an application that works pretty well in Ubuntu, Windows and the Xandros that come with the Asus EeePC.</p> <p>Now we are moving to the <a href="http://en.wikipedia.org/wiki/Aspire_One" rel="nofollow noreferrer">Acer Aspire One</a> but I'm having a lot of trouble making php-gtk to compile under the Fedora-li...
[ { "answer_id": 87995, "author": "X-Istence", "author_id": 13986, "author_profile": "https://Stackoverflow.com/users/13986", "pm_score": 0, "selected": false, "text": "<p>If you could give us more to go on than just trouble making it compile; we might be better able to help you with your ...
2008/09/16
[ "https://Stackoverflow.com/questions/78392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7946/" ]
I have an application that works pretty well in Ubuntu, Windows and the Xandros that come with the Asus EeePC. Now we are moving to the [Acer Aspire One](http://en.wikipedia.org/wiki/Aspire_One) but I'm having a lot of trouble making php-gtk to compile under the Fedora-like (Linpus Linux Lite) Linux that come with it.
Hi Guys well I finally got this thing to work the basic workflow was this: ``` #!/bin/bash sudo yum install yum-utils #We don't want to update the main gtk2 by mistake so we download them #manually and install with no-deps[1](and forced because gtk version #version of AA1 and the gtk2-devel aren't compatible). sudo yu...
78,423
<p>The error I'm getting:</p> <pre><code>in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable </code></pre> <p>Cliff notes:</p> <ul> <li>trying to include framework</li> <li>doesn't want to link</li> </ul> <p>More d...
[ { "answer_id": 79109, "author": "amrox", "author_id": 4468, "author_profile": "https://Stackoverflow.com/users/4468", "pm_score": 0, "selected": false, "text": "<p>I haven't tried it for so called <em>mobile device</em>, but I would guess its very similar to the method for a regular Coco...
2008/09/16
[ "https://Stackoverflow.com/questions/78423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The error I'm getting: ``` in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable ``` Cliff notes: * trying to include framework * doesn't want to link More detail: I'm developing for a *mobile device... hint, hint* ...
Apple clearly said that you can **not** use dynamic libraries on their mobiles. And a private framework is just this. You can, however, use static libraries.
78,431
<p>I would like to replicate this in python:</p> <pre><code>gvimdiff &lt;(hg cat file.txt) file.txt </code></pre> <p>(hg cat file.txt outputs the most recently committed version of file.txt)</p> <p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p> <pre><code>$ hg cat file.txt | gvimdiff...
[ { "answer_id": 78459, "author": "Mark Hattarki", "author_id": 14424, "author_profile": "https://Stackoverflow.com/users/14424", "pm_score": 2, "selected": false, "text": "<p>There is also the commands module:</p>\n\n<pre><code>import commands\n\nstatus, output = commands.getstatusoutput(...
2008/09/16
[ "https://Stackoverflow.com/questions/78431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12650/" ]
I would like to replicate this in python: ``` gvimdiff <(hg cat file.txt) file.txt ``` (hg cat file.txt outputs the most recently committed version of file.txt) I know how to pipe the file to gvimdiff, but it won't accept another file: ``` $ hg cat file.txt | gvimdiff file.txt - Too many edit arguments: "-" ``` ...
It can be done. As of Python 2.5, however, this mechanism is Linux-specific and not portable: ``` import subprocess import sys file = sys.argv[1] p1 = subprocess.Popen(['hg', 'cat', file], stdout=subprocess.PIPE) p2 = subprocess.Popen([ 'gvimdiff', '/proc/self/fd/%s' % p1.stdout.fileno(), file]) p2.wait()...
78,447
<p>How to create a DOM from a User's input in PHP5?</p>
[ { "answer_id": 78465, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 2, "selected": false, "text": "<p>I would use the DOM API that has been part of the core since 5. For an XML string $xml, you can build a DOM object wit...
2008/09/16
[ "https://Stackoverflow.com/questions/78447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12854/" ]
How to create a DOM from a User's input in PHP5?
I would use the DOM API that has been part of the core since 5. For an XML string $xml, you can build a DOM object with ``` $dom = new DOMDocument(); $dom->loadXML($xml); ``` Manipulate it with the rest of the DOM API, defined at <http://uk.php.net/DOM>
78,450
<p>I'm trying to use Python with ReportLab 2.2 to create a PDF report.<br> According to the <a href="http://www.reportlab.com/docs/userguide.pdf" rel="noreferrer">user guide</a>,</p> <blockquote> <p>Special TableStyle Indeces [sic]</p> <p>In any style command the first row index may be set to one of the special...
[ { "answer_id": 78702, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>[...] In any style command <strong>the first row\n index</strong> may be set to one of the special strings [....
2008/09/16
[ "https://Stackoverflow.com/questions/78450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14382/" ]
I'm trying to use Python with ReportLab 2.2 to create a PDF report. According to the [user guide](http://www.reportlab.com/docs/userguide.pdf), > > Special TableStyle Indeces [sic] > > > In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that...
Well, it looks as if I will be answering my own question. First, the documentation flat out lies where it reads "In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split table, or the first r...
78,468
<p>I am trying to understand left outer joins in LINQ to Entity. For example I have the following 3 tables:</p> <p>Company, CompanyProduct, Product</p> <p>The CompanyProduct is linked to its two parent tables, Company and Product.</p> <p>I want to return all of the Company records and the associated CompanyProduct w...
[ { "answer_id": 78714, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": 0, "selected": false, "text": "<p>Please try something like this:</p>\n\n<pre><code>from s in db.Employees\njoin e in db.Employees on s.ReportsTo equ...
2008/09/16
[ "https://Stackoverflow.com/questions/78468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to understand left outer joins in LINQ to Entity. For example I have the following 3 tables: Company, CompanyProduct, Product The CompanyProduct is linked to its two parent tables, Company and Product. I want to return all of the Company records and the associated CompanyProduct whether the CompanyProduc...
Solved it! **Final Output:** ``` theCompany.id: 1 theProduct.id: 14 theCompany.id: 2 theProduct.id: 14 theCompany.id: 3 ``` --- **Here is the Scenario** **1 - The Database** ```sql --Company Table CREATE TABLE [theCompany]( [id] [int] IDENTITY(1,1) NOT NULL, [value] [nvarchar](50) NULL, CONSTR...
78,474
<p>Using only ANSI C, what is the best way to, with fair certainty, determine if a C style string is either a integer or a real number (i.e float/double)?</p>
[ { "answer_id": 78485, "author": "nutbar", "author_id": 14425, "author_profile": "https://Stackoverflow.com/users/14425", "pm_score": 2, "selected": false, "text": "<p>I suppose you could step through the string and check if there are any <code>.</code> characters in it. That's just the ...
2008/09/16
[ "https://Stackoverflow.com/questions/78474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9418/" ]
Using only ANSI C, what is the best way to, with fair certainty, determine if a C style string is either a integer or a real number (i.e float/double)?
Don't use atoi and atof as these functions return 0 on failure. Last time I checked 0 is a valid integer and float, therefore no use for determining type. use the strto{l,ul,ull,ll,d} functions, as these set errno on failure, and also report where the converted data ended. strtoul: <http://www.opengroup.org/onlinepub...
78,497
<p>Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc.)?</p>
[ { "answer_id": 78509, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>Easy:\nuse python instead of shell scripts.\nYou get a near 100 fold increase in readablility, without having to complicate ...
2008/09/17
[ "https://Stackoverflow.com/questions/78497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14437/" ]
Does anyone know of any resources that talk about best practices or design patterns for shell scripts (sh, bash etc.)?
I wrote quite complex shell scripts and my first suggestion is "don't". The reason is that is fairly easy to make a small mistake that hinders your script, or even make it dangerous. That said, I don't have other resources to pass you but my personal experience. Here is what I normally do, which is overkill, but tend...
78,536
<p>I want to do something like:</p> <pre><code>MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone(); </code></pre> <p>And then make changes to the new object that are not reflected in the original object.</p> <p>I don't often need this functionality, so when it's been necessar...
[ { "answer_id": 78552, "author": "HappyDude", "author_id": 14266, "author_profile": "https://Stackoverflow.com/users/14266", "pm_score": 4, "selected": false, "text": "<p>In general, you implement the ICloneable interface and implement Clone yourself.\nC# objects have a built-in Memberwis...
2008/09/17
[ "https://Stackoverflow.com/questions/78536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3742/" ]
I want to do something like: ``` MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone(); ``` And then make changes to the new object that are not reflected in the original object. I don't often need this functionality, so when it's been necessary, I've resorted to creating a ne...
Whereas one approach is to implement the [`ICloneable`](http://msdn.microsoft.com/en-us/library/system.icloneable.aspx) interface (described [here](https://stackoverflow.com/questions/78536/cloning-objects-in-c/78568#78568), so I won't regurgitate), here's a nice deep clone object copier I found on [The Code Project](h...
78,548
<p>What is your way of passing data to Master Page (using ASP.NET MVC) without breaking MVC rules?</p> <p>Personally, I prefer to code abstract controller (base controller) or base class which is passed to all views.</p>
[ { "answer_id": 78571, "author": "Ian P", "author_id": 10853, "author_profile": "https://Stackoverflow.com/users/10853", "pm_score": 3, "selected": false, "text": "<p>Abstract controllers are a good idea, and I haven't found a better way. I'm interested to see what other people have done,...
2008/09/17
[ "https://Stackoverflow.com/questions/78548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/347616/" ]
What is your way of passing data to Master Page (using ASP.NET MVC) without breaking MVC rules? Personally, I prefer to code abstract controller (base controller) or base class which is passed to all views.
If you prefer your views to have strongly typed view data classes this might work for you. Other solutions are probably more *correct* but this is a nice balance between design and practicality IMHO. The master page takes a strongly typed view data class containing only information relevant to it: ``` public class Ma...
78,592
<p>In perl one would simply do the following to store and iterate over a list of names</p> <pre><code>my @fruit = (apple, orange, kiwi); foreach (@fruit) { print $_; } </code></pre> <p>What would the equivalent be in bash?</p>
[ { "answer_id": 78600, "author": "JBB", "author_id": 12332, "author_profile": "https://Stackoverflow.com/users/12332", "pm_score": 2, "selected": false, "text": "<pre>\nfor i in apple orange kiwi\ndo\n echo $i\ndone\n</pre>\n" }, { "answer_id": 78601, "author": "emk", "au...
2008/09/17
[ "https://Stackoverflow.com/questions/78592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10747/" ]
In perl one would simply do the following to store and iterate over a list of names ``` my @fruit = (apple, orange, kiwi); foreach (@fruit) { print $_; } ``` What would the equivalent be in bash?
bash (unlike POSIX sh) supports arrays: ``` fruits=(apple orange kiwi "dried mango") for fruit in "${fruits[@]}"; do echo "${fruit}" done ``` This has the advantage that array elements may contain spaces or other members of $IFS; as long as they were correctly inserted as separate elements, they are read out the s...
78,717
<p>I have a 'foreach' macro I use frequently in C++ that works for most STL containers:</p> <pre><code>#define foreach(var, container) \ for(typeof((container).begin()) var = (container).begin(); \ var != (container).end(); \ ++var) </code></pre> <p>(Note that 'typeof' is a gcc extension.) It is used li...
[ { "answer_id": 78754, "author": "Tyler", "author_id": 3561, "author_profile": "https://Stackoverflow.com/users/3561", "pm_score": 0, "selected": false, "text": "<p>You could define a template class that takes the type of mymap as a template parameter, and acts like an iterator over the v...
2008/09/17
[ "https://Stackoverflow.com/questions/78717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14528/" ]
I have a 'foreach' macro I use frequently in C++ that works for most STL containers: ``` #define foreach(var, container) \ for(typeof((container).begin()) var = (container).begin(); \ var != (container).end(); \ ++var) ``` (Note that 'typeof' is a gcc extension.) It is used like this: ``` std::vector<...
You can do this using two loops. The first declares the iterator, with a name which is a function of the container variable (and you can make this uglier if you're worried about conflicts with your own code). The second declares the value variable. ``` #define ci(container) container ## iter #define foreach_value(var,...
78,723
<p>Considering such code:</p> <pre><code>class ToBeTested { public: void doForEach() { for (vector&lt;Contained&gt;::iterator it = m_contained.begin(); it != m_contained.end(); it++) { doOnce(*it); doTwice(*it); doTwice(*it); } } void doOnce(Contained &amp; c) { // do something ...
[ { "answer_id": 78764, "author": "Doug R", "author_id": 3271, "author_profile": "https://Stackoverflow.com/users/3271", "pm_score": 0, "selected": false, "text": "<p>Some mocking frameworks allow you to set up ordered expectations, which lets you say exactly which function calls you expec...
2008/09/17
[ "https://Stackoverflow.com/questions/78723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14535/" ]
Considering such code: ``` class ToBeTested { public: void doForEach() { for (vector<Contained>::iterator it = m_contained.begin(); it != m_contained.end(); it++) { doOnce(*it); doTwice(*it); doTwice(*it); } } void doOnce(Contained & c) { // do something } void doTwice(Contai...
If you're interested in performance, I recommend that you write a test that measures performance. Check the current time, run the method you're concerned about, then check the time again. Assert that the total time taken is less than some value. The problem with check that methods are called in a certain order is tha...
78,752
<p>I have read that using database keys in a URL is a bad thing to do.</p> <p>For instance,</p> <p>My table has 3 fields: <code>ID:int</code>, <code>Title:nvarchar(5)</code>, <code>Description:Text</code></p> <p>I want to create a page that displays a record. Something like ...</p> <pre><code>http://server/viewite...
[ { "answer_id": 78760, "author": "Aaron Jensen", "author_id": 11229, "author_profile": "https://Stackoverflow.com/users/11229", "pm_score": 0, "selected": false, "text": "<p>It's a bit pedantic at times, but you want to use a unique business identifier for things rather than the surrogate...
2008/09/17
[ "https://Stackoverflow.com/questions/78752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14396/" ]
I have read that using database keys in a URL is a bad thing to do. For instance, My table has 3 fields: `ID:int`, `Title:nvarchar(5)`, `Description:Text` I want to create a page that displays a record. Something like ... ``` http://server/viewitem.aspx?id=1234 ``` 1. First off, could someone elaborate on why thi...
I think it's perfectly reasonable to use primary keys in the URL. Some considerations, however: 1) Avoid SQL injection attacks. If you just blindly accept the value of the id URL parameter and pass it into the DB, you are at risk. Make sure you sanitise the input so that it matches whatever format of key you have (e....
78,757
<p>How can I programmatically make a query in MS Access default to landscape when printed, specifically when viewing it as a PivotChart? I'm currently attempting this in MS Access 2003, but would like to see a solution for any version.</p>
[ { "answer_id": 79635, "author": "ahockley", "author_id": 8209, "author_profile": "https://Stackoverflow.com/users/8209", "pm_score": 3, "selected": true, "text": "<p>The following function should do the trick:</p>\n\n<pre><code>Function SetLandscape()\n Application.Printer.Orientation ...
2008/09/17
[ "https://Stackoverflow.com/questions/78757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3155/" ]
How can I programmatically make a query in MS Access default to landscape when printed, specifically when viewing it as a PivotChart? I'm currently attempting this in MS Access 2003, but would like to see a solution for any version.
The following function should do the trick: ``` Function SetLandscape() Application.Printer.Orientation = acPRORLandscape End Function ``` Should be able to call this from the autoexec function to ensure it always runs.
78,799
<p>What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right?</p> <p>I have code that looks something like this:</p> <p...
[ { "answer_id": 78858, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 8, "selected": true, "text": "<p>You might want to do this when the \"inner\" class is a one-off, which will never be used outside the <em>definition</em> of th...
2008/09/17
[ "https://Stackoverflow.com/questions/78799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
What I'm talking about here are nested classes. Essentially, I have two classes that I'm modeling. A DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right? I have code that looks something like this: ``` class Downlo...
You might want to do this when the "inner" class is a one-off, which will never be used outside the *definition* of the outer class. For example to use a metaclass, it's sometimes handy to do ``` class Foo(object): class __metaclass__(type): .... ``` instead of defining a metaclass separately, if you're...
78,801
<p>Running a rails site right now using SQLite3.</p> <p>About once every 500 requests or so, I get a</p> <p>ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked:...</p> <p>What's the way to fix this that would be minimally invasive to my code?</p> <p>I'm using SQLLite at the moment because you...
[ { "answer_id": 78817, "author": "Sargun Dhillon", "author_id": 10432, "author_profile": "https://Stackoverflow.com/users/10432", "pm_score": -1, "selected": false, "text": "<p>I believe this happens when a transaction times out. You really should be using a \"real\" database. Something l...
2008/09/17
[ "https://Stackoverflow.com/questions/78801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14559/" ]
Running a rails site right now using SQLite3. About once every 500 requests or so, I get a ActiveRecord::StatementInvalid (SQLite3::BusyException: database is locked:... What's the way to fix this that would be minimally invasive to my code? I'm using SQLLite at the moment because you can store the DB in source con...
By default, sqlite returns immediatly with a blocked, busy error if the database is busy and locked. You can ask for it to wait and keep trying for a while before giving up. This usually fixes the problem, unless you do have 1000s of threads accessing your db, when I agree sqlite would be inappropriate. ``` // se...
78,826
<p>How do you use <code>gen_udp</code> in Erlang to do <a href="https://en.wikipedia.org/wiki/Multicast" rel="nofollow noreferrer">multicasting</a>? I know its in the code, there is just no documentation behind it. Sending out data is obvious and simple. I was wondering on how to add memberships. Not only adding member...
[ { "answer_id": 78886, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 0, "selected": false, "text": "<p><strong>Multicast is specified by IP Address</strong></p>\n\n<p>It's the same in erlang as for all languages. The IP ...
2008/09/17
[ "https://Stackoverflow.com/questions/78826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10432/" ]
How do you use `gen_udp` in Erlang to do [multicasting](https://en.wikipedia.org/wiki/Multicast)? I know its in the code, there is just no documentation behind it. Sending out data is obvious and simple. I was wondering on how to add memberships. Not only adding memberships at start-up, but adding memberships while run...
Here is example code on how to listen in on Bonjour / Zeroconf traffic. ``` -module(zcclient). -export([open/2,start/0]). -export([stop/1,receiver/0]). open(Addr,Port) -> {ok,S} = gen_udp:open(Port,[{reuseaddr,true}, {ip,Addr}, {multicast_ttl,4}, {multicast_loop,false}, binary]), inet:setopts(S,[{add_membershi...