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
181,254
<p>If I have a style defined</p> <pre><code>.style1 { width: 140px; } </code></pre> <p>can I reference it from a second style?</p> <pre><code>.style2 { ref: .style1; } </code></pre> <p>Or is there a way via javascript/jQuery?</p> <p>--- Edit</p> <p>To clarify the problem, I am trying to apply whatever style...
[ { "answer_id": 181269, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 5, "selected": true, "text": "<p>There's no way to do it with CSS -- it's an oft-requested feature, but not included in the spec yet. You also can't ...
2008/10/08
[ "https://Stackoverflow.com/questions/181254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25372/" ]
If I have a style defined ``` .style1 { width: 140px; } ``` can I reference it from a second style? ``` .style2 { ref: .style1; } ``` Or is there a way via javascript/jQuery? --- Edit To clarify the problem, I am trying to apply whatever style is defined for a #x and #c to .x and .c without altering the C...
There's no way to do it with CSS -- it's an oft-requested feature, but not included in the spec yet. You also can't do it directly with JS, but there's sort of a hacky workaround: ``` $('.style2').addClass ('style1'); ```
181,268
<p>I have a simple iphone app that's based on the CrashLanding sample app. So basically you tap the title screen and do some stuff... all on the same "view". I want to add an "options" screen/page/view whatever with a few UISwitches. What's the easiest way to do this?</p> <p>Cheers!</p>
[ { "answer_id": 181327, "author": "fmsf", "author_id": 26004, "author_profile": "https://Stackoverflow.com/users/26004", "pm_score": 2, "selected": true, "text": "<p>Dunno if this will help I'm a bit new to objective-c and iPhone api.</p>\n\n<p>Maybe u can do something like this:\nUse the...
2008/10/08
[ "https://Stackoverflow.com/questions/181268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
I have a simple iphone app that's based on the CrashLanding sample app. So basically you tap the title screen and do some stuff... all on the same "view". I want to add an "options" screen/page/view whatever with a few UISwitches. What's the easiest way to do this? Cheers!
Dunno if this will help I'm a bit new to objective-c and iPhone api. Maybe u can do something like this: Use the interface builder: just type "Interface Builder" on the Spotlight (top right corner) to generate like "myOptions.xib" And then just implement it: like ``` @implementation myOptions -(void)awakeFromNib { ...
181,285
<p>Is it a problem if you use the global keyword on variables you don't end up using? Compare:</p> <pre><code>function foo() { global $fu; global $bah; if (something()) { $fu-&gt;doSomething(); } else { $bah-&gt;doSomething(); } } function bar() { if (something()) { glo...
[ { "answer_id": 181290, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 4, "selected": true, "text": "<p>If there is, it won't be (humanly) measurable, unless you are literally calling this function millions of times...
2008/10/08
[ "https://Stackoverflow.com/questions/181285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Is it a problem if you use the global keyword on variables you don't end up using? Compare: ``` function foo() { global $fu; global $bah; if (something()) { $fu->doSomething(); } else { $bah->doSomething(); } } function bar() { if (something()) { global $fu; $fu...
If there is, it won't be (humanly) measurable, unless you are literally calling this function millions of times. And even if it was a recursive function with that property, I still wouldn't use your second method for the maintainability aspects you already brought up. **Edit:** For arguments sake, I actually went and ...
181,309
<p>In a nutshell, there's a global stylesheet:</p> <pre><code>a { font-family: Arial; } </code></pre> <p>I want to use a different font family for a particular link:</p> <pre><code>&lt;a href="..." style="font-family: Helvetica;"&gt;...&lt;/a&gt; </code></pre> <p>or</p> <pre><code>&lt;span style="font-family: Helv...
[ { "answer_id": 181312, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "<p>Unless you have a specific font named Helvetica, you should realise that on some platforms (such as Windows, via <a href=\...
2008/10/08
[ "https://Stackoverflow.com/questions/181309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17216/" ]
In a nutshell, there's a global stylesheet: ``` a { font-family: Arial; } ``` I want to use a different font family for a particular link: ``` <a href="..." style="font-family: Helvetica;">...</a> ``` or ``` <span style="font-family: Helvetica;"><a href="...">...</a></span> ``` but nothing works. Is there an e...
Unless you have a specific font named Helvetica, you should realise that on some platforms (such as Windows, via [FontSubstitutes](http://technet.microsoft.com/en-us/library/cc757457.aspx)), Helvetica is aliased to Arial. That might be the source of the problem. Try another font and see.
181,342
<p>What is the best way to automatically install an MSI file or installer .exe? We want to do some automated testing from our build system on the installed copy of the product. Our installer has the usual license acceptance screen, install location, etc.</p> <hr> <p>As FryHard pointed out there are two options in par...
[ { "answer_id": 181365, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 4, "selected": false, "text": "<p>If you head over to one of your MSI packages in the command prompt and run a:</p>\n\n<pre><code>Myproduct.MSI /?\n</code></...
2008/10/08
[ "https://Stackoverflow.com/questions/181342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
What is the best way to automatically install an MSI file or installer .exe? We want to do some automated testing from our build system on the installed copy of the product. Our installer has the usual license acceptance screen, install location, etc. --- As FryHard pointed out there are two options in particular tha...
To automate the installation of an MSI package, you can use the /I option, like this: ``` msiexec.exe /qn /i mypackage.msi ``` Keep in mind that you need to specify the properties the MSI package expect the user to specify through the UI, and for which it does not have a default value. You can use the [Orca tool](h...
181,344
<p>We get sometimes the following error from our partner's database:</p> <pre><code>&lt;i&gt;ORA-01438: value larger than specified precision allows for this column&lt;/i&gt; </code></pre> <p>The full response looks like the following:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1251"?&gt; &lt;response&g...
[ { "answer_id": 181355, "author": "WW.", "author_id": 14663, "author_profile": "https://Stackoverflow.com/users/14663", "pm_score": 2, "selected": false, "text": "<p>This indicates you are trying to put something too big into a column. For example, you have a VARCHAR2(10) column and you ...
2008/10/08
[ "https://Stackoverflow.com/questions/181344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11104/" ]
We get sometimes the following error from our partner's database: ``` <i>ORA-01438: value larger than specified precision allows for this column</i> ``` The full response looks like the following: ``` <?xml version="1.0" encoding="windows-1251"?> <response> <status_code></status_code> <error_text>ORA-01438: val...
The number you are trying to store is too big for the field. Look at the SCALE and PRECISION. The difference between the two is the number of digits ahead of the decimal place that you can store. ``` select cast (10 as number(1,2)) from dual * ERROR at line 1: ORA-01438: value larger than specified precis...
181,348
<p>Let me start with a specific example of what I'm trying to do.</p> <p>I have an array of year, month, day, hour, minute, second and millisecond components in the form <code>[ 2008, 10, 8, 00, 16, 34, 254 ]</code>. I'd like to instantiate a Date object using the following standard constructor:</p> <pre><code>new Da...
[ { "answer_id": 181680, "author": "AnthonyWJones", "author_id": 17516, "author_profile": "https://Stackoverflow.com/users/17516", "pm_score": 3, "selected": false, "text": "<p>This is how you might solve the specific case:-</p>\n\n<pre><code>function writeLn(s)\n{\n //your code to writ...
2008/10/08
[ "https://Stackoverflow.com/questions/181348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23501/" ]
Let me start with a specific example of what I'm trying to do. I have an array of year, month, day, hour, minute, second and millisecond components in the form `[ 2008, 10, 8, 00, 16, 34, 254 ]`. I'd like to instantiate a Date object using the following standard constructor: ``` new Date(year, month, date [, hour, mi...
I've done more investigation of my own and came up with the conclusion that **this is an impossible feat**, due to how the Date class is implemented. I've inspected the [SpiderMonkey](http://www.mozilla.org/js/spidermonkey/) source code to see how Date was implemented. I think it all boils down to the following few li...
181,354
<p>In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument. </p> <p>How do you get the arguments from MSTest?</p>
[ { "answer_id": 181375, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 0, "selected": false, "text": "<p>Perhaps you can use <a href=\"http://msdn.microsoft.com/en-us/library/ms683156(VS.85).aspx\" rel=\"nofollow noreferrer\...
2008/10/08
[ "https://Stackoverflow.com/questions/181354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
In a Test project in Visual Studio 2008 (Pro), I created a Test project, and I want to configure the project properties to give a command line argument to the tests. I set the properties, but then realized I have no idea how to actually use the argument. How do you get the arguments from MSTest?
VS 2008 test are compiled into DLLs which can't directly receive command line arguments as far as I know. You could add a configuration file 'app.config' for the dll and use that instead. Just beware, mstest only copies .config files for the test container being run at the time. if you have the following... ``` m...
181,356
<p>What am I doing wrong here?</p> <pre><code>string q = "john s!"; string clean = Regex.Replace(q, @"([^a-zA-Z0-9]|^\s)", string.Empty); // clean == "johns". I want "john s"; </code></pre>
[ { "answer_id": 181362, "author": "zigdon", "author_id": 4913, "author_profile": "https://Stackoverflow.com/users/4913", "pm_score": 2, "selected": false, "text": "<p>I suspect ^ doesn't work the way you think it does outside of a character class.</p>\n\n<p>What you're telling it to do is...
2008/10/08
[ "https://Stackoverflow.com/questions/181356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1786/" ]
What am I doing wrong here? ``` string q = "john s!"; string clean = Regex.Replace(q, @"([^a-zA-Z0-9]|^\s)", string.Empty); // clean == "johns". I want "john s"; ```
just a FYI ``` string clean = Regex.Replace(q, @"[^a-zA-Z0-9\s]", string.Empty); ``` would actually be better like ``` string clean = Regex.Replace(q, @"[^\w\s]", string.Empty); ```
181,374
<p>I have a .net app that I've written in c#. On some forms I frequent update the display fields. In some cases every field on the form (textboxes, labels, picturebox, etc) has its value changed. Plus the frequency of the changes could possibly be every second. However, currently there is a horrible flickering everytim...
[ { "answer_id": 181382, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 1, "selected": false, "text": "<p>You didn't research this well. There is a DoubleBuffered property in every Form. Try setting that to true. If ...
2008/10/08
[ "https://Stackoverflow.com/questions/181374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a .net app that I've written in c#. On some forms I frequent update the display fields. In some cases every field on the form (textboxes, labels, picturebox, etc) has its value changed. Plus the frequency of the changes could possibly be every second. However, currently there is a horrible flickering everytime t...
the short answer is ``` SetStyle(ControlStyles.OptimizedDoubleBuffer, true); ``` the long answer is: see [MSDN](http://msdn.microsoft.com/en-us/library/3t7htc9c(VS.80).aspx?ppud=4) or [google](http://www.google.com/search?hl=en&q=C%23+form+double+buffer&aq=f&oq=) just for fun, try calling Application.DoEvents() aft...
181,406
<p>I have been using Ruby for a while now and I find, for bigger projects, it can take up a fair amount of memory. What are some best practices for reducing memory usage in Ruby?</p> <ul> <li>Please, let each answer have one "best practice" and let the community vote it up.</li> </ul>
[ { "answer_id": 181433, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "<p>Beware of C extensions which allocate large chunks of memory themselves.</p>\n\n<p>As an example, when you load an im...
2008/10/08
[ "https://Stackoverflow.com/questions/181406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
I have been using Ruby for a while now and I find, for bigger projects, it can take up a fair amount of memory. What are some best practices for reducing memory usage in Ruby? * Please, let each answer have one "best practice" and let the community vote it up.
Don't do this: ``` def method(x) x.split( doesn't matter what the args are ) end ``` or this: ``` def method(x) x.gsub( doesn't matter what the args are ) end ``` [Both will permanently leak memory in ruby 1.8.5 and 1.8.6](http://groups.google.com/group/god-rb/browse_thread/thread/1cca2b7c4a581c2/f0f040d41d7c...
181,408
<p>What is the best way to write bytes in the middle of a file using Java?</p>
[ { "answer_id": 181416, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 3, "selected": false, "text": "<p>Use <code>RandomAccessFile</code></p>\n\n<ul>\n<li><a href=\"http://java.sun.com/docs/books/tutorial/essential/io/rafs.h...
2008/10/08
[ "https://Stackoverflow.com/questions/181408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
What is the best way to write bytes in the middle of a file using Java?
Reading and Writing in the middle of a file is as simple as using a [`RandomAccessFile`](http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html) in Java. [`RandomAccessFile`](http://java.sun.com/javase/6/docs/api/java/io/RandomAccessFile.html), despite its name, is more like an `InputStream` and `OutputSt...
181,413
<p>Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface.</p> <p><strong>Edit:</strong> I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time...</p> <p...
[ { "answer_id": 181423, "author": "Toji", "author_id": 25968, "author_profile": "https://Stackoverflow.com/users/25968", "pm_score": 2, "selected": false, "text": "<p>In Windows: <a href=\"http://msdn.microsoft.com/en-us/library/ms686016(VS.85).aspx\" rel=\"nofollow noreferrer\">SetConsol...
2008/10/08
[ "https://Stackoverflow.com/questions/181413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16313/" ]
Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface. **Edit:** I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time... I am building a command-line ...
On \*nix, you can use the `signal` function to register a signal handler: ``` #include <signal.h> void signal_handler(int sig) { // Handle the signal } int main(void) { // Register the signal handler for the SIGINT signal (Ctrl+C) signal(SIGINT, signal_handler); ... } ``` Now, whenever someone hits `Ctrl`...
181,426
<p>I'm making a Stored Procedure that basically concatenates a long string with data from many records.</p> <p>I want to do:</p> <pre><code>set @output = @output + 'aaa' + LINEBREAK </code></pre> <p>How do I specify that line break?</p>
[ { "answer_id": 181430, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 6, "selected": true, "text": "<pre><code>DECLARE @LINEBREAK AS varchar(2)\nSET @LINEBREAK = CHAR(13) + CHAR(10)\n</code></pre>\n" }, { "answer_...
2008/10/08
[ "https://Stackoverflow.com/questions/181426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I'm making a Stored Procedure that basically concatenates a long string with data from many records. I want to do: ``` set @output = @output + 'aaa' + LINEBREAK ``` How do I specify that line break?
``` DECLARE @LINEBREAK AS varchar(2) SET @LINEBREAK = CHAR(13) + CHAR(10) ```
181,427
<p>I am currently having a hardtime understanding and implementing events in C# using delagates. I am used to the Java way of doing things:</p> <ol> <li>Define an interface for a listener type which would contain a number of method definitions</li> <li>Define adapter class for that interface to make things easier if ...
[ { "answer_id": 181451, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 3, "selected": false, "text": "<p>You'll have to define a single delegate for that</p>\n\n<pre><code>public delegate void ComputerEvent(object sender, Comput...
2008/10/08
[ "https://Stackoverflow.com/questions/181427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15075/" ]
I am currently having a hardtime understanding and implementing events in C# using delagates. I am used to the Java way of doing things: 1. Define an interface for a listener type which would contain a number of method definitions 2. Define adapter class for that interface to make things easier if I'm not interested i...
You'd create four events, and methods to raise them, along with a new EventArgs-based class to indicate the error: ``` public class ExceptionEventArgs : EventArgs { private readonly Exception error; public ExceptionEventArgs(Exception error) { this.error = error; } public Error { ...
181,432
<p>The class method to create an index path with one or more nodes is:</p> <pre><code>+ (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length </code></pre> <p>How do we create the "indexes" required in the first parameter? </p> <p>The documentation listed it as <em>Array of indexes to make up the ...
[ { "answer_id": 181440, "author": "Giao", "author_id": 14099, "author_profile": "https://Stackoverflow.com/users/14099", "pm_score": 3, "selected": false, "text": "<p>You assumption is correct. It's as simple as a C array of NSUInteger. The length parameter is the number of elements in th...
2008/10/08
[ "https://Stackoverflow.com/questions/181432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1987/" ]
The class method to create an index path with one or more nodes is: ``` + (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length ``` How do we create the "indexes" required in the first parameter? The documentation listed it as *Array of indexes to make up the index path* but it is expecting a (N...
You are correct. You might use it like this: ``` NSUInteger indexArr[] = {1,2,3,4}; NSIndexPath *indexPath = [NSIndexPath indexPathWithIndexes:indexArr length:4]; ```
181,442
<p>Actually, I wanted a custom cell which contains 2 image objects and 1 text object, and I decided to make a container for those objects. </p> <p>So is it possible to hold a image in object and insert that object in any of the collection objects, and later use that object to display inside cell?</p>
[ { "answer_id": 181475, "author": "Dre", "author_id": 23033, "author_profile": "https://Stackoverflow.com/users/23033", "pm_score": 1, "selected": false, "text": "<p>There should be no problem with that. Just make sure you are properly retaining it and what not in your class.</p>\n" },...
2008/10/08
[ "https://Stackoverflow.com/questions/181442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
Actually, I wanted a custom cell which contains 2 image objects and 1 text object, and I decided to make a container for those objects. So is it possible to hold a image in object and insert that object in any of the collection objects, and later use that object to display inside cell?
NSArray and NSDictionary both hold objects. These are most likely the collections you'll use with a table view. The best way to implement what you are trying to do is to use the UIImage class. UIImages wrap a CGImage and do all the memory management for you (if your app is running low on memory, the image data is purg...
181,459
<p>Is there a better way to do this?</p> <pre><code>-(NSDate *)getMidnightTommorow { NSCalendarDate *now = [NSCalendarDate date]; NSCalendarDate *tomorrow = [now dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; return [NSCalendarDate dateWithYear:[tomorrow yearOfCommonEra] ...
[ { "answer_id": 181495, "author": "mmalc", "author_id": 23233, "author_profile": "https://Stackoverflow.com/users/23233", "pm_score": 6, "selected": true, "text": "<p>From the <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCalendarDate_Class/Refere...
2008/10/08
[ "https://Stackoverflow.com/questions/181459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23033/" ]
Is there a better way to do this? ``` -(NSDate *)getMidnightTommorow { NSCalendarDate *now = [NSCalendarDate date]; NSCalendarDate *tomorrow = [now dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; return [NSCalendarDate dateWithYear:[tomorrow yearOfCommonEra] ...
From the [documentation](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCalendarDate_Class/Reference/Reference.html): > > Use of NSCalendarDate strongly > discouraged. It is not deprecated yet, > however it may be in the next major OS > release after Mac OS X v10.5. For > calendrica...
181,471
<p>The new awesome <kbd>Ctrl</kbd> + <kbd>.</kbd> keyboard shortcut to show smart tags has suddenly stopped working, a week or so after I discovered it :( </p> <p>I am missing it badly, having had to revert back to <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>F10</kbd>, which really just isn't the same.</p> <p>I recently ...
[ { "answer_id": 181495, "author": "mmalc", "author_id": 23233, "author_profile": "https://Stackoverflow.com/users/23233", "pm_score": 6, "selected": true, "text": "<p>From the <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCalendarDate_Class/Refere...
2008/10/08
[ "https://Stackoverflow.com/questions/181471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
The new awesome `Ctrl` + `.` keyboard shortcut to show smart tags has suddenly stopped working, a week or so after I discovered it :( I am missing it badly, having had to revert back to `Ctrl` + `Alt` + `F10`, which really just isn't the same. I recently installed F# CTP 1.9.6.2 Has anyone else * installed this CT...
From the [documentation](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCalendarDate_Class/Reference/Reference.html): > > Use of NSCalendarDate strongly > discouraged. It is not deprecated yet, > however it may be in the next major OS > release after Mac OS X v10.5. For > calendrica...
181,485
<p>I've incorporated Apple's Reachability sample into my own project so I know whether or not I have a network connection - if I don't have a network connection, I don't bother sending out and requests. I decided to go with the status notification implementation because it seemed easier to have the reachablity updated ...
[ { "answer_id": 181529, "author": "Chris Lundie", "author_id": 20685, "author_profile": "https://Stackoverflow.com/users/20685", "pm_score": 5, "selected": true, "text": "<p>Reachability notificataions didn't seem to be reliable for me either, for detecting Wi-Fi. So I just use polling in...
2008/10/08
[ "https://Stackoverflow.com/questions/181485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24168/" ]
I've incorporated Apple's Reachability sample into my own project so I know whether or not I have a network connection - if I don't have a network connection, I don't bother sending out and requests. I decided to go with the status notification implementation because it seemed easier to have the reachablity updated in ...
Reachability notificataions didn't seem to be reliable for me either, for detecting Wi-Fi. So I just use polling instead. Checking every 5 seconds seems to do no harm. ``` - (void) checkReachability { BOOL connected = ([[Reachability sharedReachability] localWiFiConnectionStatus] == ReachableViaWiFiNetwork); ...
181,498
<p>I need to sort tuples according to the second element of each tuple but apparently usort/1 only works with the first element. So I have to swap the elements, usort them and swap back.Is there an easier way?Also is there a way to sort in descending order (I know sorting and reversing can be done, but just want to kno...
[ { "answer_id": 181520, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 0, "selected": false, "text": "<p>It shouldn't be too hard to write your own sort function (adapted from a common example):</p>\n\n<pre><code>qsort([]) ...
2008/10/08
[ "https://Stackoverflow.com/questions/181498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2727/" ]
I need to sort tuples according to the second element of each tuple but apparently usort/1 only works with the first element. So I have to swap the elements, usort them and swap back.Is there an easier way?Also is there a way to sort in descending order (I know sorting and reversing can be done, but just want to know).
Have you tried [keysort/2](http://www.erlang.org/doc/man/lists.html#keysort-2) function (or its counterpart [ukeysort/2](http://www.erlang.org/doc/man/lists.html#ukeysort-2))? ``` > lists:reverse(lists:keysort(2, [{a,2}, {b,1}, {c, 3}])). [{c,3},{a,2},{b,1}] ``` If you don't sort very big lists this is probably the ...
181,530
<p>Sometimes I break long conditions in <code>if</code>s onto several lines. The most obvious way to do this is:</p> <pre><code> if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something </code></pre> <p>Isn't very very appealing visually, because the action blends wi...
[ { "answer_id": 181553, "author": "Federico A. Ramponi", "author_id": 18770, "author_profile": "https://Stackoverflow.com/users/18770", "pm_score": 5, "selected": false, "text": "<p>This doesn't improve so much but...</p>\n\n<pre><code>allCondsAreOK = (cond1 == 'val1' and cond2 == 'val2' ...
2008/10/08
[ "https://Stackoverflow.com/questions/181530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
Sometimes I break long conditions in `if`s onto several lines. The most obvious way to do this is: ``` if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something ``` Isn't very very appealing visually, because the action blends with the conditions. However, it is the...
You don't need to use 4 spaces on your second conditional line. Maybe use: ``` if (cond1 == 'val1' and cond2 == 'val2' and cond3 == 'val3' and cond4 == 'val4'): do_something ``` Also, don't forget the whitespace is more flexible than you might think: ``` if ( cond1 == 'val1' and cond2 == 'val2...
181,532
<p>I have a text string value that I'd like to persist from one web page to another without using query strings or the session/view states. I've been trying to get the ASP http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.aspx">HiddenField control to pass information from one web form to a ...
[ { "answer_id": 181540, "author": "Mez", "author_id": 20010, "author_profile": "https://Stackoverflow.com/users/20010", "pm_score": 0, "selected": false, "text": "<p>I would presume that the Response.Redirect() sends a Location: HTTP header to do a redirect.</p>\n\n<p>As HTTP is stateless...
2008/10/08
[ "https://Stackoverflow.com/questions/181532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26037/" ]
I have a text string value that I'd like to persist from one web page to another without using query strings or the session/view states. I've been trying to get the ASP http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hiddenfield.aspx">HiddenField control to pass information from one web form to a *dif...
If both pages live in the same application you can use Server.Transfer: firstpage.aspx: ``` protected void Page_Load(object sender, EventArgs e) { Server.Transfer("~/secondpage.aspx"); } ``` secondpage.aspx: ``` protected void Page_Load(object sender, EventArgs e) { Page previousPage = (Page) HttpContext.C...
181,537
<p>So basically we have lots of SharePoint usage log files generated by our SharePoint 2007 site and we would like to make sense of them. For that we're thinking of reading the log files and dumping into a database with the appropriate columns and all. Now I was going to make an SSIS package to read all the text files ...
[ { "answer_id": 181771, "author": "massimogentilini", "author_id": 11673, "author_profile": "https://Stackoverflow.com/users/11673", "pm_score": 2, "selected": false, "text": "<p>This is the script we use to load IIS log files in a SQL Server database:</p>\n\n<pre><code>LogParser \"SELECT...
2008/10/08
[ "https://Stackoverflow.com/questions/181537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
So basically we have lots of SharePoint usage log files generated by our SharePoint 2007 site and we would like to make sense of them. For that we're thinking of reading the log files and dumping into a database with the appropriate columns and all. Now I was going to make an SSIS package to read all the text files and...
This is the script we use to load IIS log files in a SQL Server database: ``` LogParser "SELECT * INTO <TABLENAME> FROM <LogFileName>" -o:SQL -server:<servername> -database:<databasename> -driver:"SQL Server" -username:sa -password:xxxxx -createTable:ON ``` The `<tablename>, <logfilename>, <servername>, <databasenam...
181,543
<p>There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I canno...
[ { "answer_id": 181593, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 3, "selected": false, "text": "<p>People worry it encourages an obfuscated style of programming, doing something that can be achieved with clearer me...
2008/10/08
[ "https://Stackoverflow.com/questions/181543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24530/" ]
There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot i...
As Guido says in his [The fate of reduce() in Python 3000](http://www.artima.com/weblogs/viewpost.jsp?thread=98196) post: > > So now reduce(). This is actually the one I've always hated most, because, apart from a few examples involving + or \*, almost every time I see a reduce() call with a non-trivial function argu...
181,573
<p>I would like to be able to display <code>Notebook</code> and a <code>TxtCtrl</code> wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like <code>wx.SplitterWindow</code>) to display the text box below the <code>Notebook</cod...
[ { "answer_id": 181591, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 1, "selected": false, "text": "<p>You can use a splitter, yes.</p>\n\n<p>Also, it makes sense to create a Panel, place your widgets in it (with sizer...
2008/10/08
[ "https://Stackoverflow.com/questions/181573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11596/" ]
I would like to be able to display `Notebook` and a `TxtCtrl` wx widgets in a single frame. Below is an example adapted from the wxpython wiki; is it possible to change their layout (maybe with something like `wx.SplitterWindow`) to display the text box below the `Notebook` in the same frame? ``` import wx import wx.l...
Making two widgets appear on the same frame is easy, actually. You should use sizers to accomplish this. In your example, you can change your `Notebook` class implementation to something like this: ``` class Notebook(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, tit...
181,579
<p>List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct.</p> <p>I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count ...
[ { "answer_id": 187158, "author": "sdkpoly", "author_id": 15640, "author_profile": "https://Stackoverflow.com/users/15640", "pm_score": 2, "selected": true, "text": "<p>CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. ...
2008/10/08
[ "https://Stackoverflow.com/questions/181579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19182/" ]
List Comprehension is a very useful code mechanism that is found in several languages, such as Haskell, Python, and Ruby (just to name a few off the top of my head). I'm familiar with the construct. I find myself working on an Open Office Spreadsheet and I need to do something fairly common: I want to count all of the...
CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. Alternatively you can use additional column with If to display 1 or 0 if the value fits in range or not accordingly: ``` =If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0) ``` Then only thing...
181,581
<p>How do you generate a X.509 public and private key pair and a signing request (CSR file) to be sent to a CA for signing in C#?</p>
[ { "answer_id": 187158, "author": "sdkpoly", "author_id": 15640, "author_profile": "https://Stackoverflow.com/users/15640", "pm_score": 2, "selected": true, "text": "<p>CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. ...
2008/10/08
[ "https://Stackoverflow.com/questions/181581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15158/" ]
How do you generate a X.509 public and private key pair and a signing request (CSR file) to be sent to a CA for signing in C#?
CountIf can count values equal to one chosen. Unfortunately it seems that there is no good candidate for such function. Alternatively you can use additional column with If to display 1 or 0 if the value fits in range or not accordingly: ``` =If(AND({list_cell}>=MinVal; {list_cell}<=MaxVal); 1; 0) ``` Then only thing...
181,585
<p>I'm using PowersHell to automate iTunes but find the error handling / waiting for com objects handling to be less than optimal.</p> <p>Example code</p> <pre><code>#Cause an RPC error $iTunes = New-Object -ComObject iTunes.Application $LibrarySource = $iTunes.LibrarySource # Get "playlist" objects for main sections...
[ { "answer_id": 182176, "author": "Jeffery Hicks", "author_id": 25508, "author_profile": "https://Stackoverflow.com/users/25508", "pm_score": 1, "selected": false, "text": "<p>COM support in PowerShell is not 100% reliable. But I think the real issue is iTunes itself. The application and ...
2008/10/08
[ "https://Stackoverflow.com/questions/181585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5330/" ]
I'm using PowersHell to automate iTunes but find the error handling / waiting for com objects handling to be less than optimal. Example code ``` #Cause an RPC error $iTunes = New-Object -ComObject iTunes.Application $LibrarySource = $iTunes.LibrarySource # Get "playlist" objects for main sections foreach ($PList in $...
Here's a function to retry operations, pausing in between failures: ``` function retry( [scriptblock]$action, [int]$wait=2, [int]$maxRetries=100 ) { $results = $null $currentRetry = 0 $success = $false while( -not $success ) { trap { # Set status variables at function scope. Set-Variable -scop...
181,596
<p>How do you convert a numerical number to an Excel column name in C# without using automation getting the value directly from Excel.</p> <p>Excel 2007 has a possible range of 1 to 16384, which is the number of columns that it supports. The resulting values should be in the form of excel column names, e.g. A, AA, AAA...
[ { "answer_id": 181610, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 3, "selected": false, "text": "<pre><code>int nCol = 127;\nstring sChars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nstring sCol = \"\";\nwhile (nCol &gt;= 2...
2008/10/08
[ "https://Stackoverflow.com/questions/181596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3851/" ]
How do you convert a numerical number to an Excel column name in C# without using automation getting the value directly from Excel. Excel 2007 has a possible range of 1 to 16384, which is the number of columns that it supports. The resulting values should be in the form of excel column names, e.g. A, AA, AAA etc.
Here's how I do it: ``` private string GetExcelColumnName(int columnNumber) { string columnName = ""; while (columnNumber > 0) { int modulo = (columnNumber - 1) % 26; columnName = Convert.ToChar('A' + modulo) + columnName; columnNumber = (columnNumber - modulo) / 26; } re...
181,605
<p>I wrote a wrapper for a COM object that only excepted strings as input, so in good OOP practice I wrapped the string up in a function so that it was easier to build and call.</p> <p>I was just wondering if anyone could think of a better way to do the following code. </p> <pre><code> Public Function OpenTable(By...
[ { "answer_id": 181616, "author": "Alexander Morland", "author_id": 4013, "author_profile": "https://Stackoverflow.com/users/4013", "pm_score": 0, "selected": false, "text": "<p>Since i dont know your programming language, im gonna keep this to pseudo code, but my general answer is to use...
2008/10/08
[ "https://Stackoverflow.com/questions/181605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I wrote a wrapper for a COM object that only excepted strings as input, so in good OOP practice I wrapped the string up in a function so that it was easier to build and call. I was just wondering if anyone could think of a better way to do the following code. ``` Public Function OpenTable(ByVal TablePath As Strin...
In this case it seems many of the parameters are just 'configuration values' (which end up being strings), you could modify it to accept a single class for all the configuration that you prepare before the call and that will return you the string accordingly. Something like ``` class COMConfiguration { private bo...
181,613
<p>This is the unabashed attempt of a similar <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">C#</a> question.</p> <p>So what are your favorite F# hidden (or not) features?</p> <p>Most of the features I've used so far aren't exactly hidden but have been quite refreshing. Like how trivial it is...
[ { "answer_id": 181633, "author": "ChaosSpeeder", "author_id": 205962, "author_profile": "https://Stackoverflow.com/users/205962", "pm_score": 1, "selected": false, "text": "<p>There are no hidden features, because F# is in design mode. All what we have is a Technical Preview, which chang...
2008/10/08
[ "https://Stackoverflow.com/questions/181613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280/" ]
This is the unabashed attempt of a similar [C#](https://stackoverflow.com/questions/9033/hidden-features-of-c) question. So what are your favorite F# hidden (or not) features? Most of the features I've used so far aren't exactly hidden but have been quite refreshing. Like how trivial it is to overload operators compa...
User defined numeric literals can be defined by providing a module whose name starts with `NumericLiteral` and which defines certain methods (`FromZero`, `FromOne`, etc.). In particular, you can use this to provide a much more readable syntax for calling `LanguagePrimitives.GenericZero` and `LanguagePrimitives.Generic...
181,643
<p>I basically need to show a wait window to the user. For this i have put two seperate window forms in the application. the first form is the main form with a button. The second one is a empty one with just a label text. On click of the button in Form1 i do the below </p> <pre><code>Form2 f = new Form2(); f.Show(); T...
[ { "answer_id": 181663, "author": "Ihar Bury", "author_id": 18001, "author_profile": "https://Stackoverflow.com/users/18001", "pm_score": 3, "selected": true, "text": "<p>That's because you probably do some lengthy operation in the same thread (UI thread). You should execute your code in ...
2008/10/08
[ "https://Stackoverflow.com/questions/181643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
I basically need to show a wait window to the user. For this i have put two seperate window forms in the application. the first form is the main form with a button. The second one is a empty one with just a label text. On click of the button in Form1 i do the below ``` Form2 f = new Form2(); f.Show(); Thread.Sleep(20...
That's because you probably do some lengthy operation in the same thread (UI thread). You should execute your code in a new thread (see Thread class) or at least call Application.DoEvents periodically from inside your lengthy operation to update the UI.
181,648
<p>I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work.</p> <p>The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get...
[ { "answer_id": 185678, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": true, "text": "<p>I think answers should go in the \"answer\" section rather than as an addendum to the question since that marks the qu...
2008/10/08
[ "https://Stackoverflow.com/questions/181648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I have problems opening a berkeley db in python using bdtables. As bdtables is used by the library I am using to access the database, I need it to work. The problem seems to be that the db environment I am trying to open (I got a copy of the database to open), is version 4.4 while libdb is version 4.6. I get the follo...
I think answers should go in the "answer" section rather than as an addendum to the question since that marks the question as having an answer on the various question-list pages. I'll do that for you but, if you also get around to doing it, leave a comment on my answer so I can delete it. Quoting "answer in question":...
181,652
<p>Let's say I have this model named <em>Product</em> with a field named <em>brand</em>. Suppose the values of <em>brand</em> are stored in the format <em>this_is_a_brand</em>. Can I define a method in the model (or anywhere else) that allows me to modify the value of <em>brand</em> before it is called. For example, if...
[ { "answer_id": 181665, "author": "Josh Moore", "author_id": 5004, "author_profile": "https://Stackoverflow.com/users/5004", "pm_score": 0, "selected": false, "text": "<p>In your model you can override the method call <code>brand</code>.</p>\n\n<pre><code>def brand\n#code to modify the va...
2008/10/08
[ "https://Stackoverflow.com/questions/181652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9776/" ]
Let's say I have this model named *Product* with a field named *brand*. Suppose the values of *brand* are stored in the format *this\_is\_a\_brand*. Can I define a method in the model (or anywhere else) that allows me to modify the value of *brand* before it is called. For example, if I call *@product.brand*, I want to...
I would recommend using the square bracket syntax (`[]` and `[]=`) instead of `read_attribute` and `write_attribute`. The square bracket syntax is shorter and [designed to wrap the **protected** read/write\_attribute methods](http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001375). ``` def brand original ...
181,693
<p>Apparently ;-) the standard containers provide some form of guarantees.</p> <p>What type of guarantees and what exactly are the differences between the different types of container?</p> <p>Working from <a href="http://www.sgi.com/tech/stl/" rel="noreferrer">the SGI page</a> (about <a href="http://en.wikipedia.org/wi...
[ { "answer_id": 181770, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 3, "selected": false, "text": "<p>I'm not aware of anything like a single table that lets you compare all of them in at one glance (I'm not sure suc...
2008/10/08
[ "https://Stackoverflow.com/questions/181693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14065/" ]
Apparently ;-) the standard containers provide some form of guarantees. What type of guarantees and what exactly are the differences between the different types of container? Working from [the SGI page](http://www.sgi.com/tech/stl/) (about [STL](http://en.wikipedia.org/wiki/Standard_Template_Library)) I have come up ...
I found the nice resource *[Standard C++ Containers](http://www.cs.northwestern.edu/~riesbeck/programming/c++/stl-summary.html)*. Probably this is what you all looking for. **VECTOR** **Constructors** ``` vector<T> v; Make an empty vector. O(1) vector<T> v(n); ...
181,718
<p>When I add a breakpoint and hit F5 to run in the debugger (I am using my debug build), a dialog pops up telling my my web.config file does not have debug=true in it (which is does) and I get 2 choices a) run without the debugger or b) let visual studio update my web.config file. If I choose b) the web.config is upda...
[ { "answer_id": 181736, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 3, "selected": true, "text": "<p>Open web.config manually and make sure the following line is in there</p>\n\n<pre><code>&lt;compilation defaultLanguag...
2008/10/08
[ "https://Stackoverflow.com/questions/181718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4012/" ]
When I add a breakpoint and hit F5 to run in the debugger (I am using my debug build), a dialog pops up telling my my web.config file does not have debug=true in it (which is does) and I get 2 choices a) run without the debugger or b) let visual studio update my web.config file. If I choose b) the web.config is updated...
Open web.config manually and make sure the following line is in there ``` <compilation defaultLanguage="c#" debug="true" /> ``` Now you should be able to debug from VS. If this does not work I suggest that you recreate the project. EDIT: perhaps from what you say it could be that web.config is screwed up, e.g.conta...
181,719
<p>How do I start a process, such as launching a URL when the user clicks a button?</p>
[ { "answer_id": 181727, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 5, "selected": false, "text": "<p>You can use the <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx\" rel=\"noref...
2008/10/08
[ "https://Stackoverflow.com/questions/181719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I start a process, such as launching a URL when the user clicks a button?
As suggested by Matt Hamilton, the quick approach where you have limited control over the process, is to use the static Start method on the System.Diagnostics.Process class... ``` using System.Diagnostics; ... Process.Start("process.exe"); ``` The alternative is to use an instance of the Process class. This allows m...
181,745
<p>Often when making changes to a VS2008 ASP.net project we get a message like:</p> <p>BC30560: 'mymodule_ascx' is ambiguous in the namespace 'ASP'.</p> <p>This goes away after a recompile or sometimes just waiting 10 seconds and refreshing the page. </p> <p>Any way to get rid of it?</p>
[ { "answer_id": 300955, "author": "Nathan", "author_id": 24954, "author_profile": "https://Stackoverflow.com/users/24954", "pm_score": 1, "selected": false, "text": "<p>I used to have this problem sometimes too. If I remember correctly it was caused by something like the following:</p>\n...
2008/10/08
[ "https://Stackoverflow.com/questions/181745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
Often when making changes to a VS2008 ASP.net project we get a message like: BC30560: 'mymodule\_ascx' is ambiguous in the namespace 'ASP'. This goes away after a recompile or sometimes just waiting 10 seconds and refreshing the page. Any way to get rid of it?
Another possibility: <http://channel9.msdn.com/forums/TechOff/157050-BC30560-mycontrolascx-is-ambiguous-in-the-namespace-ASP/> Seemed to have some success with changing ``` src="mycontrol.ascx.cs" ``` to ``` CodeBehind="mycontrol.ascx.cs" ```
181,775
<p>Not sure what exactly is going on here, but seems like in .NET 1.1 an uninitialized event delegate can run without issues, but in .NET 2.0+ it causes a NullReferenceException. Any ideas why. The code below will run fine without issues in 1.1, in 2.0 it gives a NullReferenceException. I'm curious why does it behav...
[ { "answer_id": 181790, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": true, "text": "<p>[updated] AFAIK, there was no change here to the fundamental delegate handling; the difference is in how DataTable ...
2008/10/08
[ "https://Stackoverflow.com/questions/181775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26050/" ]
Not sure what exactly is going on here, but seems like in .NET 1.1 an uninitialized event delegate can run without issues, but in .NET 2.0+ it causes a NullReferenceException. Any ideas why. The code below will run fine without issues in 1.1, in 2.0 it gives a NullReferenceException. I'm curious why does it behave diff...
[updated] AFAIK, there was no change here to the fundamental delegate handling; the difference is in how DataTable behaves. However! Be very careful using static events, especially if you are subscribing from instances (rather than static methods). This is a good way to keep huge swathes of objects alive and not be ga...
181,780
<p>I have an app where I would like to support device rotation in certain views but other don't particularly make sense in Landscape mode, so as I swapping the views out I would like to force the rotation to be set to portrait.</p> <p>There is an undocumented property setter on UIDevice that does the trick but obvious...
[ { "answer_id": 183348, "author": "Martin Gordon", "author_id": 2481, "author_profile": "https://Stackoverflow.com/users/2481", "pm_score": -1, "selected": false, "text": "<p>If you are using UIViewControllers, there is this method:</p>\n\n<pre><code>- (BOOL)shouldAutorotateToInterfaceOri...
2008/10/08
[ "https://Stackoverflow.com/questions/181780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4496/" ]
I have an app where I would like to support device rotation in certain views but other don't particularly make sense in Landscape mode, so as I swapping the views out I would like to force the rotation to be set to portrait. There is an undocumented property setter on UIDevice that does the trick but obviously generat...
This is no longer an issue on the later iPhone 3.1.2 SDK. It now appears to honor the requested orientation of the view being pushed back onto the stack. That likely means that you would need to detect older iPhone OS versions and only apply the setOrientation when it is prior to the latest release. It is not clear if...
181,805
<p>What's the difference between absolute path &amp; relative path when using any web server or Tomcat?</p>
[ { "answer_id": 181811, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 6, "selected": true, "text": "<p>Absolute paths start with / and refer to a location from the root of the current site (or virtual host).</p>\n\n<p...
2008/10/08
[ "https://Stackoverflow.com/questions/181805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15177/" ]
What's the difference between absolute path & relative path when using any web server or Tomcat?
Absolute paths start with / and refer to a location from the root of the current site (or virtual host). Relative paths do not start with / and refer to a location from the actual location of the document the reference is made. Examples, assuming root is <http://foo.com/site/> Absolute path, no matter where we are o...
181,810
<p>I am writing a custom ant task that extends Task. I am using the log() method in the task. What I want to do is use a unit test while deveoping the task, but I don't know how to set up a context for the task to run in to initialise the task as if it were running in ant.</p> <p>This is the custom Task:</p> <pre><co...
[ { "answer_id": 185806, "author": "abarax", "author_id": 24390, "author_profile": "https://Stackoverflow.com/users/24390", "pm_score": 2, "selected": true, "text": "<p>Looking at the Ant source code these are the two relevent classes: <a href=\"http://www.docjar.com/html/api/org/apache/to...
2008/10/08
[ "https://Stackoverflow.com/questions/181810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26063/" ]
I am writing a custom ant task that extends Task. I am using the log() method in the task. What I want to do is use a unit test while deveoping the task, but I don't know how to set up a context for the task to run in to initialise the task as if it were running in ant. This is the custom Task: ``` public class CopyA...
Looking at the Ant source code these are the two relevent classes: [ProjectComponent](http://www.docjar.com/html/api/org/apache/tools/ant/ProjectComponent.java.html) and [Task](http://www.docjar.com/html/api/org/apache/tools/ant/Task.java.html) You are calling the log method from Task: ``` public void log(String msg...
181,818
<p>According to the <a href="http://feedparser.org/docs/introduction.html" rel="noreferrer">feedparser documentation</a>, I can turn an RSS feed into a parsed object like this:</p> <pre><code>import feedparser d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') </code></pre> <p>but I can't find any...
[ { "answer_id": 181832, "author": "Andrea Ambu", "author_id": 21384, "author_profile": "https://Stackoverflow.com/users/21384", "pm_score": 0, "selected": false, "text": "<pre><code>from xml.dom import minidom\n\ndoc= minidom.parse('./your/file.xml')\nprint doc.toxml()\n</code></pre>\n\n<...
2008/10/08
[ "https://Stackoverflow.com/questions/181818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
According to the [feedparser documentation](http://feedparser.org/docs/introduction.html), I can turn an RSS feed into a parsed object like this: ``` import feedparser d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml') ``` but I can't find anything showing how to go the other way; I'd like to be ...
Appended is a not hugely-elegant, but working solution - it uses feedparser to parse the feed, you can then modify the entries, and it passes the data to PyRSS2Gen. It preserves *most* of the feed info (the important bits anyway, there are somethings that will need extra conversion, the parsed\_feed['feed']['image'] el...
181,829
<p>I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB.</p> <p>The problem is this part:</p> <pre><code>Month("10/01/2008") </code></pre> <p>On the servers, I get 10 (October) as the month (which is supposed to be cor...
[ { "answer_id": 181844, "author": "EggyBach", "author_id": 15475, "author_profile": "https://Stackoverflow.com/users/15475", "pm_score": 4, "selected": true, "text": "<p>This normally has to do with the regional settings, and more specifically the date/time formats. If you set these forma...
2008/10/08
[ "https://Stackoverflow.com/questions/181829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12984/" ]
I'm working in a web application using VB.NET. There is also VisualBasic code mixed in it, in particular the Date variable and the Month function of VB. The problem is this part: ``` Month("10/01/2008") ``` On the servers, I get 10 (October) as the month (which is supposed to be correct). On my machine, I get 1 (Ja...
This normally has to do with the regional settings, and more specifically the date/time formats. If you set these formats so that they are all the same on the machines you're testing on, the results should be consistent. Your idea of using ParseExact is definitely the better solution to go with, IMHO.
181,845
<p>I met a problem when deveoping a photo viewer application. I use ListBox to Show Images, which is contained in a ObservableCollection. I bind the ListBox's ItemsSource to the ObservableCollection.</p> <pre><code> &lt;DataTemplate DataType="{x:Type modeldata:ImageInfo}"&gt; &lt;Image Margin="6"...
[ { "answer_id": 181883, "author": "J c", "author_id": 25837, "author_profile": "https://Stackoverflow.com/users/25837", "pm_score": 2, "selected": false, "text": "<ol>\n<li><p>I am not familiar with this component, but in general there is going to be limitations on the number of items a l...
2008/10/08
[ "https://Stackoverflow.com/questions/181845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
I met a problem when deveoping a photo viewer application. I use ListBox to Show Images, which is contained in a ObservableCollection. I bind the ListBox's ItemsSource to the ObservableCollection. ``` <DataTemplate DataType="{x:Type modeldata:ImageInfo}"> <Image Margin="6" Source="{B...
The problem is that your new Layout Panel is the WrapPanel and it doesn't support Virtualization! It is possible to create your own Virtualized WrapPanel... Read more [here](http://jerryclin.wordpress.com/2008/02/06/making-a-virtualizing-wrappanel/) Also read more about other issues like the implementation IScrollInfo...
181,853
<p>I am using Moq to mock my Repository layer so I can unit test.</p> <p>My repository layer Insert methods update the Id property of my entities when a successful db insert occurs.</p> <p>How do I configure moq to update the Id property of the entity when the Insert method is called? </p> <p>Repository code:-</p> ...
[ { "answer_id": 181863, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 4, "selected": true, "text": "<p>You can use the Callback method to mock side-effects. Something like:</p>\n\n<pre><code>accountRepository\n .Expect...
2008/10/08
[ "https://Stackoverflow.com/questions/181853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5691/" ]
I am using Moq to mock my Repository layer so I can unit test. My repository layer Insert methods update the Id property of my entities when a successful db insert occurs. How do I configure moq to update the Id property of the entity when the Insert method is called? Repository code:- ``` void IAccountRepository....
You can use the Callback method to mock side-effects. Something like: ``` accountRepository .Expect(r => r.InsertAccount(account)) .Callback(() => account.ID = 1); ``` That's untested but it's along the right lines.
181,894
<p>I'm testing the speed of some queries in MySQL. The database is caching these queries making it difficult for me to get reliable results when testing how fast these queries are.</p> <p>Is there a way to disable caching for a query?</p> <p>System: MySQL 4 on Linux webhosting, I have access to PHPMyAdmin.</p> <p>Th...
[ { "answer_id": 181905, "author": "Jarod Elliott", "author_id": 1061, "author_profile": "https://Stackoverflow.com/users/1061", "pm_score": 9, "selected": false, "text": "<p>Try using the <a href=\"https://dev.mysql.com/doc/refman/5.7/en/query-cache-in-select.html\" rel=\"noreferrer\">SQL...
2008/10/08
[ "https://Stackoverflow.com/questions/181894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm testing the speed of some queries in MySQL. The database is caching these queries making it difficult for me to get reliable results when testing how fast these queries are. Is there a way to disable caching for a query? System: MySQL 4 on Linux webhosting, I have access to PHPMyAdmin. Thanks
Try using the [SQL\_NO\_CACHE](https://dev.mysql.com/doc/refman/5.7/en/query-cache-in-select.html) (MySQL 5.7) option in your query. (MySQL 5.6 users click [HERE](https://dev.mysql.com/doc/refman/5.6/en/query-cache-in-select.html) ) eg. ``` SELECT SQL_NO_CACHE * FROM TABLE ``` This will stop MySQL caching the resul...
181,897
<p>I want to disable "Alert window" that I get from login page of one HTTPS site with "untrusted certificate".</p> <p>ServicePointManager is used for WebRequest/WebResponse:</p> <blockquote> <pre><code>&gt; public static bool &gt; ValidateServerCertificate(object &gt; sender, X509Certificate certificate, &gt; X509Cha...
[ { "answer_id": 182184, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>The ServicePointManager is for managed code; WebBrowser is a wrapper around shdocvw, so will almost certainly have...
2008/10/08
[ "https://Stackoverflow.com/questions/181897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25826/" ]
I want to disable "Alert window" that I get from login page of one HTTPS site with "untrusted certificate". ServicePointManager is used for WebRequest/WebResponse: > > > ``` > > public static bool > > ValidateServerCertificate(object > > sender, X509Certificate certificate, > > X509Chain chain, SslPolicyErrors > > ...
The ServicePointManager is for managed code; WebBrowser is a wrapper around shdocvw, so will almost certainly have a very different programming model. *if* you can automate this (and I'm not sure that you can), I would expect to have to reference the COM version to get the full API (see: AxWebBrowser). WebBrowser only...
181,901
<p>I try to add an addons system to my Windows.Net application using Reflection; but it fails when there is addon with dependencie.<br><br> Addon class have to implement an interface 'IAddon' and to have an empty constructor.<br> Main program load the addon using Reflection:</p> <pre><code>Assembly assembly = Assembl...
[ { "answer_id": 181907, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 1, "selected": false, "text": "<p>Couple of options:</p>\n\n<ol>\n<li>You can attach to <code>AppDomain.AssemblyResolve</code> to help the CLR resolv...
2008/10/08
[ "https://Stackoverflow.com/questions/181901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26071/" ]
I try to add an addons system to my Windows.Net application using Reflection; but it fails when there is addon with dependencie. Addon class have to implement an interface 'IAddon' and to have an empty constructor. Main program load the addon using Reflection: ``` Assembly assembly = Assembly.LoadFile(@"C:\Temp\...
If *MyTools.dll* is located in the same directory as *Addon.dll*, all you need to do is call `Assembly.LoadFrom` instead of `Assembly.LoadFile` to make your code work. Otherwise, handling the `AppDomain.AssemblyResolve` event is the way to go.
181,912
<p>There is a long running habit here where I work that the connection string lives in the web.config, a Sql Connection object is instantiated in a using block with that connection string and passed to the DataObjects constructor (via a CreateInstance Method as the constructor is private). Something like this:</p> <pr...
[ { "answer_id": 181925, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": true, "text": "<p>I like to code the classes in my data access layer so that they have one constructor that takes an IDbConnection as a ...
2008/10/08
[ "https://Stackoverflow.com/questions/181912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2083160/" ]
There is a long running habit here where I work that the connection string lives in the web.config, a Sql Connection object is instantiated in a using block with that connection string and passed to the DataObjects constructor (via a CreateInstance Method as the constructor is private). Something like this: ``` using(...
I like to code the classes in my data access layer so that they have one constructor that takes an IDbConnection as a parameter, and another that takes a (connection) string. That way the calling code can either construct its own SqlConnection and pass it in (handy for integration tests), mock an IDbConnection and pas...
181,928
<p>I have a treeview with nodes like this: "Foo (1234)", and want to allow the user to rename the nodes, but only the Foo part, without (1234). I first tried to change the node text in <code>BeforeLabelEdit</code> like this:</p> <pre><code>private void treeView1_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)...
[ { "answer_id": 181935, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 2, "selected": false, "text": "<p>Heh - I struck that one a few years back. I even left a <a href=\"https://connect.microsoft.com/VisualStudio/feedback...
2008/10/08
[ "https://Stackoverflow.com/questions/181928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23684/" ]
I have a treeview with nodes like this: "Foo (1234)", and want to allow the user to rename the nodes, but only the Foo part, without (1234). I first tried to change the node text in `BeforeLabelEdit` like this: ``` private void treeView1_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) { e.Node.Text = "Foo...
Finally I have found a [solution](http://www.codeproject.com/KB/tree/CustomizedLabelEdit.aspx) to this on [CodeProject](http://www.codeproject.com). Among the comments at the bottom, you will also find a portable solution.
181,930
<p>We have two Tables:</p> <ul> <li>Document: id, title, document_type_id, showon_id</li> <li>DocumentType: id, name</li> <li>Relationship: DocumentType hasMany Documents. (Document.document_type_id = DocumentType.id)</li> </ul> <p>We wish to retrieve a list of all document types for one given ShowOn_Id. </p> <p>We ...
[ { "answer_id": 181974, "author": "wmasm", "author_id": 26079, "author_profile": "https://Stackoverflow.com/users/26079", "pm_score": 4, "selected": false, "text": "<p>You can use a join:</p>\n\n<pre><code>SELECT DISTINCT DocumentType.*\nFROM DocumentType\nINNER JOIN Document\nON Document...
2008/10/08
[ "https://Stackoverflow.com/questions/181930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5005/" ]
We have two Tables: * Document: id, title, document\_type\_id, showon\_id * DocumentType: id, name * Relationship: DocumentType hasMany Documents. (Document.document\_type\_id = DocumentType.id) We wish to retrieve a list of all document types for one given ShowOn\_Id. We see two possiblities: ``` SELECT DocumentT...
From my point of view it should not make any difference inside SQL Server (but who knows how this is implemented). Think of it this way: to return the resultset the server needs to go into the Document table and retrieve all document\_type\_id WHERE showon\_id = 42. In the process of retrieving the document\_type\_id...
181,967
<p>I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows:</p> <pre><code>event (event_id, dtstart, dtend... *follows icalendar standard*) event_leave (event_id*, leave_type_id*, total_days) _leave_type (leave_type_id, name, max_carry_forw...
[ { "answer_id": 182017, "author": "Dave Mateer", "author_id": 26086, "author_profile": "https://Stackoverflow.com/users/26086", "pm_score": 0, "selected": false, "text": "<p>There is always a better design!! </p>\n\n<p>Does your current design work? How many users do you expect (ie does ...
2008/10/08
[ "https://Stackoverflow.com/questions/181967", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5742/" ]
I am currently working on a leave application (which is a subset of my e-scheduler project) and I have my database design as follows: ``` event (event_id, dtstart, dtend... *follows icalendar standard*) event_leave (event_id*, leave_type_id*, total_days) _leave_type (leave_type_id, name, max_carry_forward) _leave_a...
I'm not following the schema very well (it looks like each leave\_type would have a carry forward? There's no user on the event\* tables?) but you should be able to dynamically derive the balance at any point in time - including across years. AAMOF, normalization rules would require you to be able to *derive* the bal...
181,986
<p>Every software development professional (and especially project managers) has to deal with a never ending stream of e-mails. What is the best way of organising them in MS Outlook?</p> <p>Obviously some fancy issue tracking tools give more flexibility but I am interested in plain vanilla approach that can be deploye...
[ { "answer_id": 181995, "author": "tloach", "author_id": 14092, "author_profile": "https://Stackoverflow.com/users/14092", "pm_score": 2, "selected": false, "text": "<p>any email that is auto-generated gets auto-filtered to its own folder. Separate folders for each project, and more for...
2008/10/08
[ "https://Stackoverflow.com/questions/181986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22088/" ]
Every software development professional (and especially project managers) has to deal with a never ending stream of e-mails. What is the best way of organising them in MS Outlook? Obviously some fancy issue tracking tools give more flexibility but I am interested in plain vanilla approach that can be deployed within m...
Within my main inbox I have 3 sub folers: Do, Done, Defer and 3 macros to move the selected folder into the relevent folder. (alt-1 moves the selected mail to done and then selects the next mail). Each day I quickly filter my inbox into the three folders. I can process several hundred mails in 20 mins or so. Do, somet...
181,994
<p>In order to verify the data coming from the <a href="http://code.google.com/apis/safebrowsing/developers_guide.html" rel="nofollow noreferrer">Google Safe Browsing API</a>, you can calculate a Message Authentication Code (MAC) for each update. The instructions to do this (from Google) are:</p> <blockquote> <p>Th...
[ { "answer_id": 182099, "author": "Anders Waldenborg", "author_id": 24082, "author_profile": "https://Stackoverflow.com/users/24082", "pm_score": 2, "selected": true, "text": "<pre><code>c=\"8eirwN1kTwCzgWA2HxTaRQ==\".decode('base64')\n</code></pre>\n" }, { "answer_id": 184617, ...
2008/10/08
[ "https://Stackoverflow.com/questions/181994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4966/" ]
In order to verify the data coming from the [Google Safe Browsing API](http://code.google.com/apis/safebrowsing/developers_guide.html), you can calculate a Message Authentication Code (MAC) for each update. The instructions to do this (from Google) are: > > The MAC is computed from an MD5 Digest > over the following...
``` c="8eirwN1kTwCzgWA2HxTaRQ==".decode('base64') ```
182,011
<p>When accessing an object in a DataTable retrieved from a database, are there any reasons not to cast the object into your desired type, or are there reasons to use convert? I know the rule is cast when we know what data type we're working with, and convert when attempting to change the data type to something it isn'...
[ { "answer_id": 182029, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": true, "text": "<p>I would always cast, for the reasons you state. The gotchas I'm aware of that you need to handle are:</p>\n\n<ol>\n<li><p>Y...
2008/10/08
[ "https://Stackoverflow.com/questions/182011", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2179408/" ]
When accessing an object in a DataTable retrieved from a database, are there any reasons not to cast the object into your desired type, or are there reasons to use convert? I know the rule is cast when we know what data type we're working with, and convert when attempting to change the data type to something it isn't. ...
I would always cast, for the reasons you state. The gotchas I'm aware of that you need to handle are: 1. You obviously need to be able to handle DBNulls (e.g. by testing with Convert.IsDBNull) 2. In the case of ExecuteScalar I believe you need to check for null as well as DBNull. 3. SQL Servers @@IDENTITY and SCOPE\_I...
182,035
<p>Internet explorer 6 seems totally ignore CSS classes or rules on select, option or optgroup tags.</p> <p>Is there a way to bypass that limitation (except install a recent version of IE) ?</p> <p><strong>Edit</strong> : to be more precise, I'm trying to build a hierarchy between options like that example:</p> <p>H...
[ { "answer_id": 182054, "author": "Gene", "author_id": 22673, "author_profile": "https://Stackoverflow.com/users/22673", "pm_score": 2, "selected": false, "text": "<p>IE6 css implementation for options is buggy (as is the css implementation as a whole for IE6) But you CAN style options wi...
2008/10/08
[ "https://Stackoverflow.com/questions/182035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3122/" ]
Internet explorer 6 seems totally ignore CSS classes or rules on select, option or optgroup tags. Is there a way to bypass that limitation (except install a recent version of IE) ? **Edit** : to be more precise, I'm trying to build a hierarchy between options like that example: Here's the HTML snippet : ``` <select...
This won't do exactly what you want, but rather than using CSS, you could just use a number of ``` &nbsp ; ``` for the indents, or dashes so: Level 1 -Level 2 --Level 3 etc. If you don't particularly like that, you could surround them with ``` <!--[if lt IE 7]><![endif]--> ``` or ``` <!--[if IE 6]><![en...
182,040
<p>I want to create a route in my rails application along the lines of</p> <pre><code>/panda/blog /tiger/blog /dog/blog </code></pre> <p>where panda, tiger, and dog are all permalinks (for an animal class)</p> <p>The normal way of doing this</p> <pre><code>map.resources :animals do |animal| animal.resource :blog e...
[ { "answer_id": 182093, "author": "Bartosz Blimke", "author_id": 18715, "author_profile": "https://Stackoverflow.com/users/18715", "pm_score": 1, "selected": false, "text": "<p>You can use this plugin:</p>\n\n<p><a href=\"http://github.com/caring/default_routing/tree/master\" rel=\"nofoll...
2008/10/08
[ "https://Stackoverflow.com/questions/182040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]
I want to create a route in my rails application along the lines of ``` /panda/blog /tiger/blog /dog/blog ``` where panda, tiger, and dog are all permalinks (for an animal class) The normal way of doing this ``` map.resources :animals do |animal| animal.resource :blog end ``` would create routes along the lines...
In rails 3.x, you can add `path => ""` to any `resource` or `resources` call to remove the first segment from the generated path. ``` resources :animals, :path => "" ``` --- ``` $ rake routes animals GET / {:action=>"index", :controller=>"animals"} POST / {:...
182,044
<p>Can anyone give me an example of what the Artifact paths setting defined for a build configuration could look like if I want to create two artifacts dist and source where I am using the sln 2008 build runner and building my projects using the default bin/Release?</p> <pre> **/Source/Code/MyProject/bin/Release/*.* =...
[ { "answer_id": 190573, "author": "Scott Cowan", "author_id": 253, "author_profile": "https://Stackoverflow.com/users/253", "pm_score": 5, "selected": false, "text": "<p>So you'll just need:</p>\n\n<pre><code>Source\\Code\\MyProject\\bin\\Release\\* =&gt; dist\nSource\\**\\* =&gt; source\...
2008/10/08
[ "https://Stackoverflow.com/questions/182044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15771/" ]
Can anyone give me an example of what the Artifact paths setting defined for a build configuration could look like if I want to create two artifacts dist and source where I am using the sln 2008 build runner and building my projects using the default bin/Release? ``` **/Source/Code/MyProject/bin/Release/*.* => dist *...
So you'll just need: ``` Source\Code\MyProject\bin\Release\* => dist Source\**\* => source ``` This will put all the files in release into a artifact folder called dist and everything in Source into a artifact folder called source. If you have subfolders in Release try: ``` Source\Code\MyProject\bin\Release\**\* =...
182,060
<p>I have webservice which is passed an array of ints. I'd like to do the select statement as follows but keep getting errors. Do I need to change the array to a string?</p> <pre><code>[WebMethod] public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate) { command.CommandText = @"SELECT id, ...
[ { "answer_id": 182065, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 1, "selected": false, "text": "<p>Visit <a href=\"https://stackoverflow.com/questions/43249/t-sql-stored-procedure-that-accepts-multiple-id-values\">T-SQL st...
2008/10/08
[ "https://Stackoverflow.com/questions/182060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
I have webservice which is passed an array of ints. I'd like to do the select statement as follows but keep getting errors. Do I need to change the array to a string? ``` [WebMethod] public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate) { command.CommandText = @"SELECT id, ...
You can't (unfortunately) do that. A Sql Parameter can only be a single value, so you'd have to do: ``` WHERE buildingID IN (@buildingID1, @buildingID2, @buildingID3...) ``` Which, of course, requires you to know how many building ids there are, or to dynamically construct the query. As a workaround\*, I've done th...
182,066
<p>If I have two tables... Category and Pet. </p> <p>Is there a way in LINQ to SQL to make the result of the joined query map to a another strongly typed class (such as: PetWithCategoryName) so that I can strongly pass it to a MVC View?</p> <p>I currently have Category and Pet classes... should I make another one?</p...
[ { "answer_id": 182292, "author": "Giovanni Galbo", "author_id": 4050, "author_profile": "https://Stackoverflow.com/users/4050", "pm_score": 1, "selected": false, "text": "<p>If you use the LoadWith LoadOption then your Pet query will do an eager load on categories, so that you will be ab...
2008/10/08
[ "https://Stackoverflow.com/questions/182066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4481/" ]
If I have two tables... Category and Pet. Is there a way in LINQ to SQL to make the result of the joined query map to a another strongly typed class (such as: PetWithCategoryName) so that I can strongly pass it to a MVC View? I currently have Category and Pet classes... should I make another one? Maybe I missing so...
> > How would I go about using LoadWith? I'm not finding much help online. Any good resources? > > > I found this online: <http://blogs.msdn.com/wriju/archive/2007/10/04/linq-to-sql-change-in-datacontext-from-beta-1-to-beta-2.aspx> You would do something like: ``` var loadOption = new DataLoadOptions(); ...
182,073
<p>I am receiving an error from the Oracle JDBC driver (ojdbc14_g.jar) when trying to obtain a connection to a 10g database. The driver has an oracle.jdbc.driver.OracleLog class which could help but the Oracle documentation is unclear how best to use it. Has anyone had any success using this class? If so, some guidance...
[ { "answer_id": 182081, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>My initial thought would be to go with Javascript - if it's good enough for Google Maps, it's probably good enough for...
2008/10/08
[ "https://Stackoverflow.com/questions/182073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
I am receiving an error from the Oracle JDBC driver (ojdbc14\_g.jar) when trying to obtain a connection to a 10g database. The driver has an oracle.jdbc.driver.OracleLog class which could help but the Oracle documentation is unclear how best to use it. Has anyone had any success using this class? If so, some guidance o...
I don't think this is a question that will get you an objective answer - Flash developers will tell you Flash is better, web developers will say JavaScript. Trying to remain objective, I'd say that both technologies are suitable for what you describe, but have different advantages. Flash will definitely render faster,...
182,082
<p>I cureently have a set up like below </p> <pre><code>Public ClassA property _classB as ClassB End Class Public ClassB property _someProperty as someProperty End Class </code></pre> <p>what I want to do is to databind object A to a gridview with one of the columns being databound to ClassB._someProperty. W...
[ { "answer_id": 182113, "author": "Neil Hewitt", "author_id": 22178, "author_profile": "https://Stackoverflow.com/users/22178", "pm_score": 2, "selected": false, "text": "<p>Ordinary databinding doesn't generally allow for expressions. Under the hood the datagrid is using reflection (rath...
2008/10/08
[ "https://Stackoverflow.com/questions/182082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11802/" ]
I cureently have a set up like below ``` Public ClassA property _classB as ClassB End Class Public ClassB property _someProperty as someProperty End Class ``` what I want to do is to databind object A to a gridview with one of the columns being databound to ClassB.\_someProperty. When I try to databind it as ...
I found the way to do this is to use a template field and eval (see below) Set the datafield as property classB and then: ``` <asp:TemplateField HeaderText="_someProperty"> <ItemTemplate> <%#Eval("classB._someProperty")%> </ItemTemplate> </asp:TemplateField> ```
182,130
<p>I want to record user states and then be able to report historically based on the record of changes we've kept. I'm trying to do this in SQL (using PostgreSQL) and I have a proposed structure for recording user changes like the following.</p> <pre><code>CREATE TABLE users ( userid SERIAL NOT NULL PRIMARY KEY, ...
[ { "answer_id": 182255, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": true, "text": "<p>This can be done, but would be a lot more efficient if you stored the end date of each log. With your model you ha...
2008/10/08
[ "https://Stackoverflow.com/questions/182130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1087/" ]
I want to record user states and then be able to report historically based on the record of changes we've kept. I'm trying to do this in SQL (using PostgreSQL) and I have a proposed structure for recording user changes like the following. ``` CREATE TABLE users ( userid SERIAL NOT NULL PRIMARY KEY, name VARCHAR(4...
This can be done, but would be a lot more efficient if you stored the end date of each log. With your model you have to do something like: ``` select l1.userid from status_log l1 where l1.status='s' and l1.logcreated = (select max(l2.logcreated) from status_log l2 where l2.use...
182,133
<p>I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to...
[ { "answer_id": 182156, "author": "Jean", "author_id": 7898, "author_profile": "https://Stackoverflow.com/users/7898", "pm_score": 2, "selected": false, "text": "<p>what about this : </p>\n\n<pre><code>interface Validatable {\n void validate(Validator v);\n}\n\nclass Object1 implements V...
2008/10/08
[ "https://Stackoverflow.com/questions/182133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6414/" ]
I've never been so good at design because there are so many different possibilities and they all have pros and cons and I'm never sure which to go with. Anyway, here's my problem, I have a need for many different loosly related classes to have validation. However, some of these classes will need extra information to do...
what about this : ``` interface Validatable { void validate(Validator v); } class Object1 implements Validatable{ void validate(Validator v){ v.foo v.bar } } class Object1Converse implements Validator{ //.... } class Object2 implements Validatable{ void validate(Validator v){ //do whatever you n...
182,160
<p>I'm new to Spring Security. How do I add an event listener which will be called as a user logs in successfully? Also I need to get some kind of unique session ID in this listener which should be available further on. I need this ID to synchronize with another server.</p>
[ { "answer_id": 182203, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "<p>You need to define a Spring Bean which implements <a href=\"http://static.springframework.org/spring/docs/2.5.x/api/org/spri...
2008/10/08
[ "https://Stackoverflow.com/questions/182160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578/" ]
I'm new to Spring Security. How do I add an event listener which will be called as a user logs in successfully? Also I need to get some kind of unique session ID in this listener which should be available further on. I need this ID to synchronize with another server.
You need to define a Spring Bean which implements [ApplicationListener](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationListener.html). Then, in your code, do something like this: ```java public void onApplicationEvent(ApplicationEvent appEvent) { if (appEvent instan...
182,177
<p>Which Template-Engine and Ajax-Framework/-Toolkit is able to load template information from JAR-Files?</p>
[ { "answer_id": 182203, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "<p>You need to define a Spring Bean which implements <a href=\"http://static.springframework.org/spring/docs/2.5.x/api/org/spri...
2008/10/08
[ "https://Stackoverflow.com/questions/182177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Which Template-Engine and Ajax-Framework/-Toolkit is able to load template information from JAR-Files?
You need to define a Spring Bean which implements [ApplicationListener](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/context/ApplicationListener.html). Then, in your code, do something like this: ```java public void onApplicationEvent(ApplicationEvent appEvent) { if (appEvent instan...
182,181
<p>I'm trying to call the SQL statement below but get the following error:</p> <blockquote> <p>System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value '+@buildingIDs+' to data type int.</p> </blockquote> <pre><code>@"SELECT id, startDateTime, endDateTime FROM tb_bookings W...
[ { "answer_id": 182219, "author": "Bravax", "author_id": 13911, "author_profile": "https://Stackoverflow.com/users/13911", "pm_score": -1, "selected": false, "text": "<p>It's trying to compare an int with the string value '+@buildingsIDs+'<br>\nSo it tries to convert the string to convert...
2008/10/08
[ "https://Stackoverflow.com/questions/182181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
I'm trying to call the SQL statement below but get the following error: > > System.Data.SqlClient.SqlException: Conversion failed when converting > the varchar value '+@buildingIDs+' to data type int. > > > ``` @"SELECT id, startDateTime, endDateTime FROM tb_bookings WHERE buildingID IN ('+@buildingIDs+...
Bravax's way is a bit dangerous. I'd go with the following so you don't get attacked with SQL Injections: ``` int[] buildingIDs = new int[] { 1, 2, 3 }; /***/ @"SELECT id, startDateTime, endDateTime From tb_bookings WHERE buildingID IN (" + string.Join(", ", buildingIDs.Select(id => id.ToString()).ToArray()) ...
182,192
<p>ModRewrite can easily handle stripping the www off the front of my domain.<br> In .htaccess:</p> <pre><code>RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(....
[ { "answer_id": 182205, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>You can get certificates with multiple domain names in them. Get one with <code>mydomain.com</code> and <code>www.m...
2008/10/08
[ "https://Stackoverflow.com/questions/182192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11740/" ]
ModRewrite can easily handle stripping the www off the front of my domain. In .htaccess: ``` RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$...
You can get certificates with multiple domain names in them. Get one with `mydomain.com` and `www.mydomain.com`. I think it's also possible to buy "wildcard" certificates that will match any subdomain, but they cost much more.
182,229
<p>I'd like to run a script to populate my database. I'd like to access it through the Django database API.</p> <p>The only problem is that I don't know what I would need to import to gain access to this.</p> <p>How can this be achieved?</p>
[ { "answer_id": 182275, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 0, "selected": false, "text": "<p>In addition to your own models files, you need to import your settings module as well.</p>\n" }, { "answer_id"...
2008/10/08
[ "https://Stackoverflow.com/questions/182229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15616/" ]
I'd like to run a script to populate my database. I'd like to access it through the Django database API. The only problem is that I don't know what I would need to import to gain access to this. How can this be achieved?
Import your settings module too ``` import os os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" from mysite.polls.models import Poll, Choice ``` should do the trick.
182,243
<p>I am trying to recreate a Perl script in C# but have a problem creating a checksum value that a target system needs.</p> <p>In Perl this checksum is calculated using the <code>unpack</code> function:</p> <pre><code>while (&lt;PACKAGE&gt;) { $checksum += unpack("%32C*", $_); } $checksum %= 32767; close(PACKAGE)...
[ { "answer_id": 182254, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 3, "selected": false, "text": "<p>There seems to be a library in Mono called <a href=\"http://www.mono-project.com/Mono_DataConvert\" rel=\"nofollo...
2008/10/08
[ "https://Stackoverflow.com/questions/182243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to recreate a Perl script in C# but have a problem creating a checksum value that a target system needs. In Perl this checksum is calculated using the `unpack` function: ``` while (<PACKAGE>) { $checksum += unpack("%32C*", $_); } $checksum %= 32767; close(PACKAGE); ``` where `PACKAGE` is the .tar fi...
There seems to be a library in Mono called [DataConvert](http://www.mono-project.com/Mono_DataConvert) that was written to provide facilities similar to Perl's pack/unpack. Does this do what you need?
182,253
<p>I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me.</p> <p>I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubuntu linux, while dealing with string that repre...
[ { "answer_id": 182282, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": 2, "selected": false, "text": "<p>From a <code>os.path</code> documentation:</p>\n\n<p><strong>os.path.splitdrive(path)</strong><br>\nSplit the pathname pat...
2008/10/08
[ "https://Stackoverflow.com/questions/182253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9951/" ]
I love Python because it comes batteries included, and I use built-in functions, a lot, to do the dirty job for me. I have always been using happily the os.path module to deal with file path but recently I ended up with unexpected results on Python 2.5 under Ubuntu linux, while dealing with string that represent windo...
If you want to manipulate Windows paths on linux you should use the ntpath module (this is the module that is imported as os.path on windows - posixpath is imported as os.path on linux) ``` >>> import ntpath >>> filepath = r"c:\ttemp\FILEPA~1.EXE" >>> print ntpath.basename(filepath) FILEPA~1.EXE >>> print ntpath.split...
182,262
<p>Using Oracle, if a column value can be 'YES' or 'NO' is it possible to constrain a table so that only one row can have a 'YES' value?</p> <p>I would rather redesign the table structure but this is not possible.</p> <p>[UDPATE] Sadly, null values are not allowed in this table.</p>
[ { "answer_id": 182279, "author": "poezn", "author_id": 25842, "author_profile": "https://Stackoverflow.com/users/25842", "pm_score": 2, "selected": false, "text": "<p>It doesn't work on the table definition.</p>\n\n<p>However, if you update the table using a trigger calling a stored proc...
2008/10/08
[ "https://Stackoverflow.com/questions/182262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26108/" ]
Using Oracle, if a column value can be 'YES' or 'NO' is it possible to constrain a table so that only one row can have a 'YES' value? I would rather redesign the table structure but this is not possible. [UDPATE] Sadly, null values are not allowed in this table.
Use a function-based index: ``` create unique index only_one_yes on mytable (case when col='YES' then 'YES' end); ``` Oracle only indexes keys that are not completely null, and the CASE expression here ensures that all the 'NO' values are changed to nulls and so not indexed.
182,278
<p>I would like to be able to write a Java class in one package which can access non-public methods of a class in another package without having to make it a subclass of the other class. Is this possible?</p>
[ { "answer_id": 182285, "author": "NR.", "author_id": 11701, "author_profile": "https://Stackoverflow.com/users/11701", "pm_score": 1, "selected": false, "text": "<p>Not using a keyword or so.</p>\n\n<p>You could \"cheat\" using reflection etc., but I wouldn't recommend \"cheating\".</p>\...
2008/10/08
[ "https://Stackoverflow.com/questions/182278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4023/" ]
I would like to be able to write a Java class in one package which can access non-public methods of a class in another package without having to make it a subclass of the other class. Is this possible?
The 'friend' concept is useful in Java, for example, to separate an API from its implementation. It is common for implementation classes to need access to API class internals but these should not be exposed to API clients. This can be achieved using the 'Friend Accessor' pattern as detailed below: The class exposed th...
182,287
<p>Why can't I pass the table name to a prepared PDO statement?</p> <pre><code>$stmt = $dbh-&gt;prepare('SELECT * FROM :table WHERE 1'); if ($stmt-&gt;execute(array(':table' =&gt; 'users'))) { var_dump($stmt-&gt;fetchAll()); } </code></pre> <p>Is there another safe way to insert a table name into a SQL query? Wit...
[ { "answer_id": 182312, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 3, "selected": false, "text": "<p>Using the former isn't inherently more safe than the latter, you need to sanitize the input whether it's part of ...
2008/10/08
[ "https://Stackoverflow.com/questions/182287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
Why can't I pass the table name to a prepared PDO statement? ``` $stmt = $dbh->prepare('SELECT * FROM :table WHERE 1'); if ($stmt->execute(array(':table' => 'users'))) { var_dump($stmt->fetchAll()); } ``` Is there another safe way to insert a table name into a SQL query? With safe, I mean that I don't want to do...
**Table and Column names CANNOT be replaced by parameters in PDO.** In that case you will simply want to filter and sanitize the data manually. One way to do this is to pass in shorthand parameters to the function that will execute the query dynamically and then use a `switch()` statement to create a white list of val...
182,349
<p>I am trying to find the index of a substring in a string that matches another string under a specific culture (provided from a System.CultureInfo). </p> <p>For example the string "ass" matches the substring "aß" in "straße" under a German culture.</p> <p>I can find the index of the start of the match using</p> <...
[ { "answer_id": 182366, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>Does regular expressions handle that distinction of ss vs. ß?</p>\n" }, { "answer_id": 182376, "author...
2008/10/08
[ "https://Stackoverflow.com/questions/182349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19995/" ]
I am trying to find the index of a substring in a string that matches another string under a specific culture (provided from a System.CultureInfo). For example the string "ass" matches the substring "aß" in "straße" under a German culture. I can find the index of the start of the match using ``` culture.CompareInfo...
If you use a capture group, you can capture the exact match that was found, and from that you can determine how many characters were matched. I'm a bit timestressed right now to give an example, so I hope you can figure it out from my description. Perhaps I'll ammend my answer later. Dave
182,372
<p>What is the easiest way to check if events have been logged in the eventlog during a period of time?</p> <p>I want to perform a series of automated test steps and then check if any errors were logged to the Application Event Log, ignoring a few sources that I'm not interested in. I can use System.Diagnostics.EventL...
[ { "answer_id": 182590, "author": "Tim Farley", "author_id": 4425, "author_profile": "https://Stackoverflow.com/users/4425", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx\" rel=\"nofollow noreferrer\">S...
2008/10/08
[ "https://Stackoverflow.com/questions/182372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8479/" ]
What is the easiest way to check if events have been logged in the eventlog during a period of time? I want to perform a series of automated test steps and then check if any errors were logged to the Application Event Log, ignoring a few sources that I'm not interested in. I can use System.Diagnostics.EventLog and the...
Just to be a good Wiki citizen and strive for completion, there are other ways. I didn't suggest it earlier because it is complete overkill for something that is only going to be run in-house as part of a test suite, and you said right in the title you wanted something easy. But if you need to see events as they occur...
182,373
<p>I am currently creating a custom control that needs to handle animation in a C# project. It is basically a listbox that contains a fixed number of elements that are subject to move. An element (another user control with a background image and a couple of generated labels) can move upwards, downwards or be taken out ...
[ { "answer_id": 182463, "author": "FryHard", "author_id": 231, "author_profile": "https://Stackoverflow.com/users/231", "pm_score": 1, "selected": false, "text": "<p>A similar discussion took place this morning on this question. <a href=\"https://stackoverflow.com/questions/181374/visual-...
2008/10/08
[ "https://Stackoverflow.com/questions/182373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25152/" ]
I am currently creating a custom control that needs to handle animation in a C# project. It is basically a listbox that contains a fixed number of elements that are subject to move. An element (another user control with a background image and a couple of generated labels) can move upwards, downwards or be taken out of ...
your best bet for flicker-free animation is to do the painting yourself (use the Graphics object in the Paint event handler) and use double-buffering. In your custom control you will need code like this in the constructor: ``` this.SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlSt...
182,379
<p>I've got a column in a database table (SQL Server 2005) that contains data like this:</p> <pre><code>TQ7394 SZ910284 T r1534 su8472 </code></pre> <p>I would like to update this column so that the first two characters are uppercase. I would also like to remove any spaces between the first two characters. So <code>T...
[ { "answer_id": 182438, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 0, "selected": false, "text": "<pre><code>update Table set Column = case when len(rtrim(substring (Column , 1 , 2))) &lt; 2 \n then UPPER(sub...
2008/10/08
[ "https://Stackoverflow.com/questions/182379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944/" ]
I've got a column in a database table (SQL Server 2005) that contains data like this: ``` TQ7394 SZ910284 T r1534 su8472 ``` I would like to update this column so that the first two characters are uppercase. I would also like to remove any spaces between the first two characters. So `T q1234` would become `TQ1234`. ...
Here is a solution: **EDIT:** **Updated to support replacement of multiple spaces between the first and the second non-space characters** ``` /* TEST TABLE */ DECLARE @T AS TABLE(code Varchar(20)) INSERT INTO @T SELECT 'ab1234x1' UNION SELECT ' ab1234x2' UNION SELECT ' ab1234x3' UNION SELECT 'a b1234x4' ...
182,408
<p>Is there a manual for cross-compiling a C++ application from Linux to Windows?</p> <p>Just that. I would like some information (links, reference, examples...) to guide me to do that.</p> <p>I don't even know if it's possible. </p> <p>My objective is to compile a program in Linux and get a .exe file that I can run...
[ { "answer_id": 182456, "author": "richq", "author_id": 4596, "author_profile": "https://Stackoverflow.com/users/4596", "pm_score": 7, "selected": true, "text": "<p>The basics are not too difficult:</p>\n\n<pre><code>sudo apt-get install mingw32 \ncat &gt; main.c &lt;&lt;EOF\nint main(...
2008/10/08
[ "https://Stackoverflow.com/questions/182408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366094/" ]
Is there a manual for cross-compiling a C++ application from Linux to Windows? Just that. I would like some information (links, reference, examples...) to guide me to do that. I don't even know if it's possible. My objective is to compile a program in Linux and get a .exe file that I can run under Windows.
The basics are not too difficult: ``` sudo apt-get install mingw32 cat > main.c <<EOF int main() { printf("Hello, World!"); } EOF i586-mingw32msvc-cc main.c -o hello.exe ``` Replace `apt-get` with `yum`, or whatever your Linux distro uses. That will generate a `hello.exe` for Windows. Once you get your head a...
182,410
<p>I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be.</p> <p>But if I try to do a redirect or simply do an 'alert' on the link array element I get: </p> <blockquote> <p>f...
[ { "answer_id": 182445, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "<p>JSON decoding in JavaScript is simply an eval() if you trust the string or the more safe code you can find on <a href=...
2008/10/08
[ "https://Stackoverflow.com/questions/182410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20603/" ]
I have a JavaScript array that, among others, contains a URL. If I try to simply put the URL in the page (the array is in a project involving the Yahoo! Maps API) it shows the URL as it should be. But if I try to do a redirect or simply do an 'alert' on the link array element I get: > > function(){return JSON.encod...
``` var obj = jQuery.parseJSON('{"name":"John"}'); alert( obj.name === "John" ); ``` [See the jQuery API](http://api.jquery.com/jQuery.parseJSON/).
182,436
<p>Are there any tools available for validating a database schema against a set of design rules, naming conventions, etc.</p> <p>I'm not talking about comparing one database to another (as covered by <a href="https://stackoverflow.com/questions/165401/how-to-comparevalidate-sql-schema">this question</a>).</p> <p>I wa...
[ { "answer_id": 182445, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 1, "selected": false, "text": "<p>JSON decoding in JavaScript is simply an eval() if you trust the string or the more safe code you can find on <a href=...
2008/10/08
[ "https://Stackoverflow.com/questions/182436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1755/" ]
Are there any tools available for validating a database schema against a set of design rules, naming conventions, etc. I'm not talking about comparing one database to another (as covered by [this question](https://stackoverflow.com/questions/165401/how-to-comparevalidate-sql-schema)). I want to be able to say "What i...
``` var obj = jQuery.parseJSON('{"name":"John"}'); alert( obj.name === "John" ); ``` [See the jQuery API](http://api.jquery.com/jQuery.parseJSON/).
182,440
<p>This question is a follow-up from <a href="https://stackoverflow.com/questions/161822/how-to-indicate-that-a-method-was-unsuccessful">How to indicate that a method was unsuccessful</a>. The xxx() Tryxxx() pattern is something that can be very useful in many libraries. I am wondering what is the best way to offer bot...
[ { "answer_id": 182483, "author": "David Basarab", "author_id": 2469, "author_profile": "https://Stackoverflow.com/users/2469", "pm_score": 2, "selected": false, "text": "<p>The first example is correct if you are just going to catch the exception and not do anything but return false with...
2008/10/08
[ "https://Stackoverflow.com/questions/182440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5789/" ]
This question is a follow-up from [How to indicate that a method was unsuccessful](https://stackoverflow.com/questions/161822/how-to-indicate-that-a-method-was-unsuccessful). The xxx() Tryxxx() pattern is something that can be very useful in many libraries. I am wondering what is the best way to offer both implementati...
Making TrySomething just catch and swallow the exception is a really bad idea. Half the point of the TryXXX pattern is to avoid the performance hit of exceptions. If you don't need much information in the exception, you could make the DoSomething method just call TrySomething and throw an exception if it fails. If you...
182,455
<p>How do I remove a trailing comma from a string in ColdFusion?</p>
[ { "answer_id": 182464, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 3, "selected": false, "text": "<p>Check the rightmost char - if it's a comma, set the string to a substring of the original, with length -1.</p>\n\n<p>Trim...
2008/10/08
[ "https://Stackoverflow.com/questions/182455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26121/" ]
How do I remove a trailing comma from a string in ColdFusion?
To remove a trailing comma (if it exists): ``` REReplace(list, ",$", "") ``` To strip one or more trailing commas: ``` REReplace(list, ",+$", "") ```
182,475
<p>AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because of this I'm having rounding problems when comparing two Currency values, returning different results depending on the machine.</p> <p>For now I'm using the SameValue function passing a Epsilon parameter = 0.009, because ...
[ { "answer_id": 182509, "author": "Matt Lacey", "author_id": 1755, "author_profile": "https://Stackoverflow.com/users/1755", "pm_score": -1, "selected": false, "text": "<p>To avoid possible issues with currency rounding in Delphi use 4 decimal places.</p>\n\n<p>This will ensure that you n...
2008/10/08
[ "https://Stackoverflow.com/questions/182475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2089/" ]
AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because of this I'm having rounding problems when comparing two Currency values, returning different results depending on the machine. For now I'm using the SameValue function passing a Epsilon parameter = 0.009, because I only nee...
The Currency type in Delphi is a 64-bit integer scaled by 1/10,000; in other words, its smallest increment is equivalent to 0.0001. It is not susceptible to precision issues in the same way that floating point code is. However, if you are multiplying your Currency numbers by floating-point types, or dividing your Curr...
182,492
<p>I would like TortoiseSVN (1.5.3) to ignore certain folders, their contents and certain other files wherever they might appear in my directory hierarchy but I cannot get the global ignore string right.</p> <p>Whatever I do, it either adds to much or ignores too much</p> <p>What is the correct 'Global ignore pattern...
[ { "answer_id": 182508, "author": "PersistenceOfVision", "author_id": 6721, "author_profile": "https://Stackoverflow.com/users/6721", "pm_score": 7, "selected": true, "text": "<p>Currently I have the following in my Global Ignore Pattern:<br></p>\n\n<pre><code>bin obj CVS .cvsignore *.use...
2008/10/08
[ "https://Stackoverflow.com/questions/182492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11356/" ]
I would like TortoiseSVN (1.5.3) to ignore certain folders, their contents and certain other files wherever they might appear in my directory hierarchy but I cannot get the global ignore string right. Whatever I do, it either adds to much or ignores too much What is the correct 'Global ignore pattern' to ignore.... ...
Currently I have the following in my Global Ignore Pattern: ``` bin obj CVS .cvsignore *.user *.suo Debug Release *.pdb test.* Thumbs.db ``` Works really well to ignore several hidden or temp files/folders.... So for your specific requirements: * Folders: `bin obj release compile` * Files: `*.bak *.user *.suo` ...
182,497
<p>Please give me the direction of the best guidance on the Entity Framework.</p>
[ { "answer_id": 182508, "author": "PersistenceOfVision", "author_id": 6721, "author_profile": "https://Stackoverflow.com/users/6721", "pm_score": 7, "selected": true, "text": "<p>Currently I have the following in my Global Ignore Pattern:<br></p>\n\n<pre><code>bin obj CVS .cvsignore *.use...
2008/10/08
[ "https://Stackoverflow.com/questions/182497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11135/" ]
Please give me the direction of the best guidance on the Entity Framework.
Currently I have the following in my Global Ignore Pattern: ``` bin obj CVS .cvsignore *.user *.suo Debug Release *.pdb test.* Thumbs.db ``` Works really well to ignore several hidden or temp files/folders.... So for your specific requirements: * Folders: `bin obj release compile` * Files: `*.bak *.user *.suo` ...
182,519
<p>Ok I give up, I've been trying to write a regexp in ant to replace the version number from something that I have in a properties file. I have the following:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;feature id="some.feature.id" label="Some test feature" versi...
[ { "answer_id": 182537, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 0, "selected": false, "text": "<p>A Perl substitution regex would look something like this...</p>\n\n<pre><code>s/&lt;feature(.*?)version=\".*?\"/&lt;fe...
2008/10/08
[ "https://Stackoverflow.com/questions/182519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2309/" ]
Ok I give up, I've been trying to write a regexp in ant to replace the version number from something that I have in a properties file. I have the following: ``` <?xml version="1.0" encoding="UTF-8"?> <feature id="some.feature.id" label="Some test feature" version="1.0.0" pro...
Assuming you're using the `replaceregexp` task: ``` <replaceregexp file="whatever" match="(<feature\b[^<>]+?version=\")[^\"]+" replace="\1${feature.version}" /> ``` I'm also assuming there's only the one `<feature>` element.
182,528
<p>Leaving aside the question of whether you should serve single or multiple stylesheets, assuming you're sending just one, what do you think of this as a basic structure?</p> <p>/* Structure */</p> <p>Any template layout stuff should be put into here, so header, footer, body etc.</p> <p>/* Structure End */</p> <p>...
[ { "answer_id": 182565, "author": "Rimas Kudelis", "author_id": 25804, "author_profile": "https://Stackoverflow.com/users/25804", "pm_score": 0, "selected": false, "text": "<p>The structure you presented is exactly what I use. However, it seems to me that it still got too complex with new...
2008/10/08
[ "https://Stackoverflow.com/questions/182528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2977/" ]
Leaving aside the question of whether you should serve single or multiple stylesheets, assuming you're sending just one, what do you think of this as a basic structure? /\* Structure \*/ Any template layout stuff should be put into here, so header, footer, body etc. /\* Structure End \*/ /\* Common Components\*/ R...
That's similar to how I structure mine, however, I find that using sub-headings is the best way to do it, so I use this structure: /\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \* GLOBAL \* \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/ /\* All of the common stuff goes here under the appropriate sub head...
182,529
<p>I have have some code which adds new cells to a table and fills them with text boxes. </p> <p>The way I've coded it so far works fine:</p> <pre><code> TableCell tCell1 = new TableCell(); TableCell tCell2 = new TableCell(); TableCell tCell3 = new TableCell(); TableCell tCell4 = new Ta...
[ { "answer_id": 182551, "author": "Lars Mæhlum", "author_id": 960, "author_profile": "https://Stackoverflow.com/users/960", "pm_score": 0, "selected": false, "text": "<p>This should work fine?</p>\n\n<pre><code>for (int i = 0; i &lt; 6; i++)\n{\n TableCell tCell = new TableCell();\n ...
2008/10/08
[ "https://Stackoverflow.com/questions/182529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26126/" ]
I have have some code which adds new cells to a table and fills them with text boxes. The way I've coded it so far works fine: ``` TableCell tCell1 = new TableCell(); TableCell tCell2 = new TableCell(); TableCell tCell3 = new TableCell(); TableCell tCell4 = new TableCell(); Ta...
I think this should do it: ``` for (int i = 0; i < 7; i++) { TableCell tCell = new TableCell(); TextBox txt = new TextBox(); tCell.Controls.Add(txt); tRow.Cells.Add(tCell); } ``` Make sure that 6 is changed to a 7.
182,542
<p>What do you use to validate an email address on a ASP.NET form. I want to make sure that it contains no XSS exploits.</p> <p>This is ASP.NET 1.1</p>
[ { "answer_id": 182579, "author": "JacquesB", "author_id": 7488, "author_profile": "https://Stackoverflow.com/users/7488", "pm_score": 2, "selected": false, "text": "<p>Preventing XSS is a different issue from validating input.</p>\n\n<p>Regarding XSS: You should not try to check <em>inpu...
2008/10/08
[ "https://Stackoverflow.com/questions/182542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
What do you use to validate an email address on a ASP.NET form. I want to make sure that it contains no XSS exploits. This is ASP.NET 1.1
Any script tags posted on an ASP.NET web form will cause your site to throw and unhandled exception. You can use a asp regex validator to confirm input, just ensure you wrap your code behind method with a if(IsValid) clause in case your javascript is bypassed. If your client javascript is bypassed and script tags are ...
182,544
<p>SQL to find duplicate entries (within a group)</p> <p>I have a small problem and I'm not sure what would be the best way to fix it, as I only have limited access to the database (Oracle) itself. In our Table "EVENT" we have about 160k entries, each EVENT has a GROUPID and a normal entry has exactly 5 rows with the ...
[ { "answer_id": 182575, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>If your DBAs won't add an index to make this faster, ask them what they suggest you do (that's what they're paid for,...
2008/10/08
[ "https://Stackoverflow.com/questions/182544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3134/" ]
SQL to find duplicate entries (within a group) I have a small problem and I'm not sure what would be the best way to fix it, as I only have limited access to the database (Oracle) itself. In our Table "EVENT" we have about 160k entries, each EVENT has a GROUPID and a normal entry has exactly 5 rows with the same GROUP...
You can get the answer with a join instead of a subquery ``` select a.* from event as a inner join (select groupid from event group by groupid having count(*) <> 5) as b on a.groupid = b.groupid ``` This is a fairly common way of obtaining the all the information out of the rows in a gro...
182,569
<p>Sybase db tables do not have a concept of self updating row numbers. However , for one of the modules , I require the presence of rownumber corresponding to each row in the database such that max(Column) would always tell me the number of rows in the table.</p> <p>I thought I'll introduce an int column and keep upd...
[ { "answer_id": 182744, "author": "AdamH", "author_id": 21081, "author_profile": "https://Stackoverflow.com/users/21081", "pm_score": 2, "selected": false, "text": "<p>You can easily assign a unique number to each row by using an identity column. The identity can be a numeric or an intege...
2008/10/08
[ "https://Stackoverflow.com/questions/182569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18275/" ]
Sybase db tables do not have a concept of self updating row numbers. However , for one of the modules , I require the presence of rownumber corresponding to each row in the database such that max(Column) would always tell me the number of rows in the table. I thought I'll introduce an int column and keep updating this...
Delete trigger -------------- ``` CREATE TRIGGER tigger ON myTable FOR DELETE AS update myTable set id = id - (select count(*) from deleted d where d.id < t.id) from myTable t ``` To avoid locking problems ------------------------- You could add an extra table (which joins to your primary table) like this: ``...
182,573
<p>PowerShell v1.0 is obviously a console based administrative shell. It doesn't really require a GUI interface. If one is required, like the Exchange 2007 management GUI, it is built on top of PowerShell. You can create your own GUI using Windows Forms in a PowerShell script. My question is, "What sort of PowerShell s...
[ { "answer_id": 183053, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Isnt this mainly used by powershell guys who want to make there scripts pretty before handing to users or people who know n...
2008/10/08
[ "https://Stackoverflow.com/questions/182573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25508/" ]
PowerShell v1.0 is obviously a console based administrative shell. It doesn't really require a GUI interface. If one is required, like the Exchange 2007 management GUI, it is built on top of PowerShell. You can create your own GUI using Windows Forms in a PowerShell script. My question is, "What sort of PowerShell scri...
In answer to [monkut's suggestion](https://stackoverflow.com/questions/182573/powershell-cli-or-gui-which-do-you-need-or-prefer#185822), here's a simple function to get file paths using the WindowsForms `OpenFileDialog`: ``` [void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' ) function Select-F...
182,587
<p>Is there a best practice when it comes to setting client side "onclick" events when using ASP.Net controls? Simply adding the onclick attribute results in a Visual Studio warning that onclick is not a valid attribute of that control. Adding it during the Page_Load event through codebehind works, but is less clear ...
[ { "answer_id": 182642, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 1, "selected": false, "text": "<p>Setting the value for <code>WebControl.Attributes[\"onclick\"]</code> is okay. If ASP.NET needs a client-side <code>c...
2008/10/08
[ "https://Stackoverflow.com/questions/182587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/111/" ]
Is there a best practice when it comes to setting client side "onclick" events when using ASP.Net controls? Simply adding the onclick attribute results in a Visual Studio warning that onclick is not a valid attribute of that control. Adding it during the Page\_Load event through codebehind works, but is less clear than...
`**`*just a pre-note on the answer: HTML validation in VS is often BS. It complains about stuff that works IRL, even if that stuff is bad practice. But sometimes you gotta bend the rules to get stuff done.* Every ASP.NET page (2.0 and greater) comes with a [ClientScriptManager](http://msdn.microsoft.com/en-us/library/...
182,592
<p>I have a webapp that segfaults when the database in restarted and it tries to use the old connections. Running it under <code>gdb --args apache -X</code> leads to the following output:</p> <pre><code>Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1212868928 (LWP 16098)] 0xb7471c20 in mys...
[ { "answer_id": 182757, "author": "mpeters", "author_id": 12094, "author_profile": "https://Stackoverflow.com/users/12094", "pm_score": 2, "selected": false, "text": "<p>What this probably means is that there's a difference between your mod_perl environment and the one you were testing vi...
2008/10/08
[ "https://Stackoverflow.com/questions/182592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5349/" ]
I have a webapp that segfaults when the database in restarted and it tries to use the old connections. Running it under `gdb --args apache -X` leads to the following output: ``` Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1212868928 (LWP 16098)] 0xb7471c20 in mysql_send_query () from /us...
This is a known problem in old DBD::mysql. Upgrade it (4.008 is *not* up to date). There's a simple test script attached to <https://rt.cpan.org/Public/Bug/Display.html?id=37027> that will trigger this bug.
182,600
<p>If you had to iterate through a loop 7 times, would you use:</p> <pre><code>for (int i = 0; i &lt; 7; i++) </code></pre> <p>or:</p> <pre><code>for (int i = 0; i &lt;= 6; i++) </code></pre> <p>There are two considerations:</p> <ul> <li>performance</li> <li>readability </li> </ul> <p>For performance I'm assuming...
[ { "answer_id": 182606, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 3, "selected": false, "text": "<p>It makes no effective difference when it comes to performance. Therefore I would use whichever is easier to understan...
2008/10/08
[ "https://Stackoverflow.com/questions/182600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1533/" ]
If you had to iterate through a loop 7 times, would you use: ``` for (int i = 0; i < 7; i++) ``` or: ``` for (int i = 0; i <= 6; i++) ``` There are two considerations: * performance * readability For performance I'm assuming Java or C#. Does it matter if "less than" or "less than or equal to" is used? If you ha...
The first is more [idiomatic](http://en.wiktionary.org/wiki/idiomatic). In particular, it indicates (in a 0-based sense) the number of iterations. When using something 1-based (e.g. JDBC, IIRC) I might be tempted to use <=. So: ``` for (int i=0; i < count; i++) // For 0-based APIs for (int i=1; i <= count; i++) // Fo...
182,602
<p>I have a BulletedList in asp.net that is set to DisplayMode="LinkButton". I would like to trigger the first "bullet" from a javascript, can this be done? And if so, how?</p>
[ { "answer_id": 183374, "author": "Alex Gyoshev", "author_id": 25427, "author_profile": "https://Stackoverflow.com/users/25427", "pm_score": 3, "selected": true, "text": "<p>Say you have the BulletedList as</p>\n\n<pre><code>&lt;asp:BulletedList runat=\"server\" ID=\"MyLovelyBulletedList\...
2008/10/08
[ "https://Stackoverflow.com/questions/182602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1523/" ]
I have a BulletedList in asp.net that is set to DisplayMode="LinkButton". I would like to trigger the first "bullet" from a javascript, can this be done? And if so, how?
Say you have the BulletedList as ``` <asp:BulletedList runat="server" ID="MyLovelyBulletedList" DisplayMode="LinkButton"> <asp:ListItem Text="My Lovely Text 1" /> <asp:ListItem Text="My Lovely Text 2" /> </asp:BulletedList> ``` ... then you can fire the "onclick" event like this (cross-browser): ``` var lin...
182,615
<p>When reading my RSS feed with the Thunderbird feed reader, some entries are duplicated. <a href="https://en.wikipedia.org/wiki/Google_Reader" rel="nofollow noreferrer">Google Reader</a> does not have the same problem.</p> <p>Here is the faulty feed: <a href="http://plcoder.net/rss.php?rss=Blog" rel="nofollow norefer...
[ { "answer_id": 182646, "author": "Kip", "author_id": 18511, "author_profile": "https://Stackoverflow.com/users/18511", "pm_score": 4, "selected": true, "text": "<p>Try adding a <code>&lt;guid&gt;</code> tag to each item, giving it a permalink. i.e.:</p>\n\n<pre><code>&lt;item rdf:about=...
2008/10/08
[ "https://Stackoverflow.com/questions/182615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8404/" ]
When reading my RSS feed with the Thunderbird feed reader, some entries are duplicated. [Google Reader](https://en.wikipedia.org/wiki/Google_Reader) does not have the same problem. Here is the faulty feed: <http://plcoder.net/rss.php?rss=Blog> There is a problem, but where? I added a [GUID](https://en.wikipedia.org/...
Try adding a `<guid>` tag to each item, giving it a permalink. i.e.: ``` <item rdf:about="http://plcoder.net/?doc=2134&amp;amp;titre=mon-pc-se-la-pete"> <link>http://plcoder.net/?doc=2134&amp;amp;titre=mon-pc-se-la-pete</link> <guid>http://plcoder.net/?doc=2134&amp;amp;titre=mon-pc-se-la-pete</guid> ... </item> ...