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
13,599
<p>Does anyone know how to transform a enum value to a human readable value?</p> <p>For example:</p> <blockquote> <p>ThisIsValueA should be "This is Value A".</p> </blockquote>
[ { "answer_id": 13602, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": false, "text": "<p>Most examples of this that I've seen involve marking your enum values up with [Description] attributes and using refle...
2008/08/17
[ "https://Stackoverflow.com/questions/13599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1154/" ]
Does anyone know how to transform a enum value to a human readable value? For example: > > ThisIsValueA should be "This is Value A". > > >
Converting this from a vb code snippet that a certain Ian Horwill left at a [blog post long ago](http://secretgeek.net/progr_purga.asp)... i've since used this in production successfully. ``` /// <summary> /// Add spaces to separate the capitalized words in the string, /// i.e. insert a space before each ...
13,615
<p>I need to validate an integer to know if is a valid enum value.</p> <p>What is the best way to do this in C#?</p>
[ { "answer_id": 13635, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 3, "selected": false, "text": "<p>Brad Abrams specifically warns against <strong><code>Enum.IsDefined</code></strong> in his post <a href=\"https://learn.m...
2008/08/17
[ "https://Stackoverflow.com/questions/13615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1154/" ]
I need to validate an integer to know if is a valid enum value. What is the best way to do this in C#?
You got to love these folk who assume that data not only always comes from a UI, but a UI within your control! `IsDefined` is fine for most scenarios, you could start with: ``` public static bool TryParseEnum<TEnum>(this int enumValue, out TEnum retVal) { retVal = default(TEnum); bool success = Enum.IsDefined(typeo...
13,620
<p>(assume php5) consider</p> <pre><code>&lt;?php $foo = 'some words'; //case 1 print "these are $foo"; //case 2 print "these are {$foo}"; //case 3 print 'these are ' . $foo; ?&gt; </code></pre> <p>Is there much of a difference between 1 and 2?</p> <p>If not, what about between 1/2 an...
[ { "answer_id": 13665, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 7, "selected": true, "text": "<p>Well, as with all \"What might be faster in real life\" questions, you can't beat a real life test.</p>\n\n<pre><code>f...
2008/08/17
[ "https://Stackoverflow.com/questions/13620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314/" ]
(assume php5) consider ``` <?php $foo = 'some words'; //case 1 print "these are $foo"; //case 2 print "these are {$foo}"; //case 3 print 'these are ' . $foo; ?> ``` Is there much of a difference between 1 and 2? If not, what about between 1/2 and 3?
Well, as with all "What might be faster in real life" questions, you can't beat a real life test. ``` function timeFunc($function, $runs) { $times = array(); for ($i = 0; $i < $runs; $i++) { $time = microtime(); call_user_func($function); $times[$i] = microtime() - $time; } return array_sum($ti...
13,753
<p>I'm missing something here:</p> <pre><code>$objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter = ("(objectclass=computer)") $computers = $objSearcher.findall() </code></pre> <p>So the question ...
[ { "answer_id": 13760, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 0, "selected": false, "text": "<p>I believe it has to do with the way that PS interpolates information in the \"\". Try this:</p>\n\n<p>\"Server name in quo...
2008/08/17
[ "https://Stackoverflow.com/questions/13753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1635/" ]
I'm missing something here: ``` $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter = ("(objectclass=computer)") $computers = $objSearcher.findall() ``` So the question is why do the two followin...
When you included $\_.properties.name in the string, it was returning the type name of the property. When a variable is included in a string and the string is evaluated, it calls the ToString method on that object referenced by the variable (not including the members specified after). In this case, the ToString metho...
13,763
<p>Is there a function like <code>document.getElementById("FirstDiv").clear()</code>?</p>
[ { "answer_id": 13766, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 0, "selected": false, "text": "<p>You should be able to use the .RemoveNode method of the node or the .RemoveChild method of the parent node.</p>\n" }, ...
2008/08/17
[ "https://Stackoverflow.com/questions/13763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
Is there a function like `document.getElementById("FirstDiv").clear()`?
To answer the original question - there are various ways to do this, but the following would be the simplest. If you already have a handle to the child node that you want to remove, i.e. you have a JavaScript variable that holds a reference to it: ``` myChildNode.parentNode.removeChild(myChildNode); ``` Obviously, ...
13,775
<p>I have a .net web application that has a Flex application embedded within a page. This flex application calls a .net webservice. I can trace the execution proccess through the debugger and all looks great until I get the response:</p> <pre><code> soap:ReceiverSystem.Web.Services.Protocols.SoapException: Server wa...
[ { "answer_id": 15292, "author": "James Avery", "author_id": 537, "author_profile": "https://Stackoverflow.com/users/537", "pm_score": 1, "selected": false, "text": "<p>It looks like you might be sending a poorly formed XML document to the service. Can you use Fiddler or something like th...
2008/08/17
[ "https://Stackoverflow.com/questions/13775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
I have a .net web application that has a Flex application embedded within a page. This flex application calls a .net webservice. I can trace the execution proccess through the debugger and all looks great until I get the response: ``` soap:ReceiverSystem.Web.Services.Protocols.SoapException: Server was unable to proc...
It looks like you might be sending a poorly formed XML document to the service. Can you use Fiddler or something like that to get a copy of the actual call that is going to the web service? That would be a huge help in figured out what the issue is.
13,791
<p>I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what...</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; mystring = r"This is \n a test \r" &gt;&gt;&gt; p = re.compile( "\...
[ { "answer_id": 13844, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 2, "selected": false, "text": "<p>Well, I think you might have missed the r or miscounted the backslashes...</p>\n\n<pre><code>\"\\\\n\" == r\"\\n\"...
2008/08/17
[ "https://Stackoverflow.com/questions/13791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1370/" ]
I am trying to implement string unescaping with Python regex and backreferences, and it doesn't seem to want to work very well. I'm sure it's something I'm doing wrong but I can't figure out what... ``` >>> import re >>> mystring = r"This is \n a test \r" >>> p = re.compile( "\\\\(\\S)" ) >>> p.sub( "\\1", mystring ) ...
Isn't that what Anders' second example does? In 2.5 there's also a `string-escape` encoding you can apply: ``` >>> mystring = r"This is \n a test \r" >>> mystring.decode('string-escape') 'This is \n a test \r' >>> print mystring.decode('string-escape') This is a test >>> ```
13,851
<p>I am having trouble with IE7. I have a header, which is an IMG. Under it I have a div that represents a menu, they have to be attached to each other without space in between. Both are 1000px width. In Opera and FireFox the header and the menu are neatly attached to each other. However, in IE7, there is a small space...
[ { "answer_id": 13854, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 3, "selected": true, "text": "<p>Try the IE Developer Toolbar, which will let you inspect what is going on with the elements and give you outlines of the a...
2008/08/17
[ "https://Stackoverflow.com/questions/13851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am having trouble with IE7. I have a header, which is an IMG. Under it I have a div that represents a menu, they have to be attached to each other without space in between. Both are 1000px width. In Opera and FireFox the header and the menu are neatly attached to each other. However, in IE7, there is a small space be...
Try the IE Developer Toolbar, which will let you inspect what is going on with the elements and give you outlines of the areas covered. It might give you a better understanding of the problem.
13,857
<p>I've been reading a lot about closures and I think I understand them, but without clouding the picture for myself and others, I am hoping someone can explain closures as succinctly and clearly as possible. I'm looking for a simple explanation that might help me understand where and why I would want to use them.</p>...
[ { "answer_id": 13875, "author": "Anders Eurenius", "author_id": 1421, "author_profile": "https://Stackoverflow.com/users/1421", "pm_score": 6, "selected": false, "text": "<p>It's simple: A function that references variables from a containing scope, potentially after flow-of-control has l...
2008/08/17
[ "https://Stackoverflow.com/questions/13857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1649/" ]
I've been reading a lot about closures and I think I understand them, but without clouding the picture for myself and others, I am hoping someone can explain closures as succinctly and clearly as possible. I'm looking for a simple explanation that might help me understand where and why I would want to use them.
[Closure on closures](http://mrevelle.blogspot.com/2006/10/closure-on-closures.html) > > Objects are data with methods > attached, closures are functions with > data attached. > > > ``` def make_counter(): i = 0 def counter(): # counter() is a closure nonlocal i i += 1 return i ...
13,938
<p><img src="https://i.stack.imgur.com/DibJS.jpg" alt="Visual Studio folder structure"></p> <p>I need some advice as to how I easily can separate test runs for unit tests and integration test in Visual Studio. Often, or always, I structure the solution as presented in the above picture: separate projects for unit test...
[ { "answer_id": 13953, "author": "Wilka", "author_id": 1367, "author_profile": "https://Stackoverflow.com/users/1367", "pm_score": 0, "selected": false, "text": "<p>This is a bit of fiddly solution, but you could configure some <a href=\"http://blogs.msdn.com/saraford/archive/2008/04/24/d...
2008/08/17
[ "https://Stackoverflow.com/questions/13938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446/" ]
![Visual Studio folder structure](https://i.stack.imgur.com/DibJS.jpg) I need some advice as to how I easily can separate test runs for unit tests and integration test in Visual Studio. Often, or always, I structure the solution as presented in the above picture: separate projects for unit tests and integration tests....
I actually found kind of a solution for this on my own by using keyboard command bound to a macro. The macro was recorded from the menu Tools>Macros>Record TemporaryMacro. While recording I selected my [Tests] folder and ran ReSharpers UnitTest.ContextRun. This resulted in the following macro, ``` Sub TemporaryMacro(...
13,941
<p>I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use <code>import os</code> and then use a command line speech program to say &quot;Process complete&quot;. I much rather it be a simple &quot;bell.&quot;</p> <p>I know that there's a function that can be...
[ { "answer_id": 13949, "author": "gbc", "author_id": 1667, "author_profile": "https://Stackoverflow.com/users/1667", "pm_score": 7, "selected": true, "text": "<p>Have you tried :</p>\n\n<pre><code>import sys\nsys.stdout.write('\\a')\nsys.stdout.flush()\n</code></pre>\n\n<p>That works for ...
2008/08/17
[ "https://Stackoverflow.com/questions/13941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I'd like to have a python program alert me when it has completed its task by making a beep noise. Currently, I use `import os` and then use a command line speech program to say "Process complete". I much rather it be a simple "bell." I know that there's a function that can be used in *Cocoa* apps, `NSBeep`, but I don'...
Have you tried : ``` import sys sys.stdout.write('\a') sys.stdout.flush() ``` That works for me here on Mac OS 10.5 Actually, I think your original attempt works also with a little modification: ``` print('\a') ``` (You just need the single quotes around the character sequence).
13,963
<p>I want to parse a config file sorta thing, like so:</p> <pre><code>[KEY:Value] [SUBKEY:SubValue] </code></pre> <p>Now I started with a <code>StreamReader</code>, converting lines into character arrays, when I figured there's gotta be a better way. So I ask you, humble reader, to help me.</p> <p>One restr...
[ { "answer_id": 13974, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 0, "selected": false, "text": "<p>It looks to me that you would be better off using an XML based config file as there are already .NET classes which can read ...
2008/08/17
[ "https://Stackoverflow.com/questions/13963", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
I want to parse a config file sorta thing, like so: ``` [KEY:Value] [SUBKEY:SubValue] ``` Now I started with a `StreamReader`, converting lines into character arrays, when I figured there's gotta be a better way. So I ask you, humble reader, to help me. One restriction is that it has to work in a Linux/Mon...
> > I considered it, but I'm not going to use XML. I am going to be writing this stuff by hand, and hand editing XML makes my brain hurt. :') > > > Have you looked at [YAML](http://www.yaml.org/)? You get the benefits of XML without all the pain and suffering. It's used extensively in the ruby community for thing...
14,118
<p>I'm writing my first Perl app -- an AOL Instant Messenger bot that talks to an Arduino microcontroller, which in turn controls a servo that will push the power button on our sysadmin's server, which freezes randomly every 28 hours or so. </p> <p>I've gotten all the hard stuff done, I'm just trying to add one last b...
[ { "answer_id": 14124, "author": "jj33", "author_id": 430, "author_profile": "https://Stackoverflow.com/users/430", "pm_score": 5, "selected": true, "text": "<p>The Perl built-in is <a href=\"http://perldoc.perl.org/functions/select.html\" rel=\"noreferrer\"><code>select()</code></a>, whi...
2008/08/18
[ "https://Stackoverflow.com/questions/14118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing my first Perl app -- an AOL Instant Messenger bot that talks to an Arduino microcontroller, which in turn controls a servo that will push the power button on our sysadmin's server, which freezes randomly every 28 hours or so. I've gotten all the hard stuff done, I'm just trying to add one last bit of code...
The Perl built-in is [`select()`](http://perldoc.perl.org/functions/select.html), which is a pass-through to the `select()` system call, but for sane people I recommend [`IO::Select`](http://search.cpan.org/dist/IO/lib/IO/Select.pm). Code sample: ``` #!/usr/bin/perl use IO::Select; $s = IO::Select->new(); $s->add(\...
14,165
<p>I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers.</p>
[ { "answer_id": 14169, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 5, "selected": true, "text": "<p>Check if your code is including the <strong>windows.h</strong> header file and either your code or other third-part...
2008/08/18
[ "https://Stackoverflow.com/questions/14165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
I'm seeing strange errors when my C++ code has min() or max() calls. I'm using Visual C++ compilers.
Check if your code is including the **windows.h** header file and either your code or other third-party headers have their own **min()**/**max()** definitions. If yes, then prepend your **windows.h** inclusion with a definition of **NOMINMAX** like this: ``` #define NOMINMAX #include <windows.h> ```
14,209
<p><code>System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.</code></p> <p>Anybody ever get this error and/or have any idea on it's cause and/or solution?</p> <p><a href="http://forums.micro...
[ { "answer_id": 14214, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "<p>You should add an explicit User Instance=true/false to your connection string</p>\n" }, { "answer_id": 1086442, ...
2008/08/18
[ "https://Stackoverflow.com/questions/14209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
`System.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.` Anybody ever get this error and/or have any idea on it's cause and/or solution? [This link may have relevant information.](http://forums...
Here is the answer to your problem: Very often old user instance creates some temp files that prevent a new SQL Express user instance to be created. When those files are deleted everything start working properly. First of all confirm that user instances are enabled by running the following SQL in SQL Server Managemen...
14,247
<p>I've only done a bit of Flex development thus far, but I've preferred the approach of creating controls programmatically over mxml files, because (and <em>please</em>, correct me if I'm wrong!) I've gathered that you can't have it both ways -- that is to say, have the class functionality in a separate ActionScript c...
[ { "answer_id": 14261, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 6, "selected": true, "text": "<p>Don't be afraid of MXML. It's great for laying out views. If you write your own <em>reusable</em> components then writing them...
2008/08/18
[ "https://Stackoverflow.com/questions/14247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/266/" ]
I've only done a bit of Flex development thus far, but I've preferred the approach of creating controls programmatically over mxml files, because (and *please*, correct me if I'm wrong!) I've gathered that you can't have it both ways -- that is to say, have the class functionality in a separate ActionScript class file ...
Don't be afraid of MXML. It's great for laying out views. If you write your own *reusable* components then writing them in ActionScript may sometimes give you a little more control, but for non-reusable views MXML is much better. It's more terse, bindings are extemely easy to set up, etc. However, bindings in pure Act...
14,278
<p>I'd like to provide some way of creating dynamically loadable plugins in my software. Typical way to do this is using the <a href="http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx" rel="noreferrer">LoadLibrary</a> WinAPI function to load a dll and calling <a href="http://msdn.microsoft.com/en-us/library/...
[ { "answer_id": 14282, "author": "Zooba", "author_id": 891, "author_profile": "https://Stackoverflow.com/users/891", "pm_score": 5, "selected": true, "text": "<p>The following code snippet (C#) constructs an instance of any concrete classes derived from <code>Base</code> found in class li...
2008/08/18
[ "https://Stackoverflow.com/questions/14278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1534/" ]
I'd like to provide some way of creating dynamically loadable plugins in my software. Typical way to do this is using the [LoadLibrary](http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx) WinAPI function to load a dll and calling [GetProcAddress](http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx) t...
The following code snippet (C#) constructs an instance of any concrete classes derived from `Base` found in class libraries (\*.dll) in the application path and stores them in a list. ``` using System.IO; using System.Reflection; List<Base> objects = new List<Base>(); DirectoryInfo dir = new DirectoryInfo(Application...
14,281
<p>I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files. </p> <p>Is there any python module which can do a regex match on the files without unzipping it. Is there a...
[ { "answer_id": 14304, "author": "jdd", "author_id": 242853, "author_profile": "https://Stackoverflow.com/users/242853", "pm_score": 0, "selected": false, "text": "<p>You could loop through the zip files, reading individual files using the zipfile module and running your regex on those, e...
2008/08/18
[ "https://Stackoverflow.com/questions/14281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448/" ]
I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files. Is there any python module which can do a regex match on the files without unzipping it. Is there a simple wa...
There's nothing that will automatically do what you want. However, there is a python zipfile module that will make this easy to do. Here's how to iterate over the lines in the file. ``` #!/usr/bin/python import zipfile f = zipfile.ZipFile('myfile.zip') for subfile in f.namelist(): print subfile data = f.rea...
14,287
<p>In my C/C++ program, I'm using <a href="http://opencvlibrary.sourceforge.net/" rel="noreferrer">OpenCV</a> to capture images from my webcam. The camera (<a href="http://en.wikipedia.org/wiki/Quickcam" rel="noreferrer">Logitech QuickCam IM</a>) can capture at resolutions <strong>320x240</strong>, <strong>640x480</str...
[ { "answer_id": 14290, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 5, "selected": true, "text": "<p>There doesn't seem to be a solution. The resolution can be increased to <strong>640x480</strong> using <a href=\"ht...
2008/08/18
[ "https://Stackoverflow.com/questions/14287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
In my C/C++ program, I'm using [OpenCV](http://opencvlibrary.sourceforge.net/) to capture images from my webcam. The camera ([Logitech QuickCam IM](http://en.wikipedia.org/wiki/Quickcam)) can capture at resolutions **320x240**, **640x480** and **1280x960**. But, for some strange reason, OpenCV gives me images of resolu...
There doesn't seem to be a solution. The resolution can be increased to **640x480** using [this hack](http://tech.groups.yahoo.com/group/OpenCV/message/28735) shared by *lifebelt77*. Here are the details reproduced: Add to **highgui.h**: ``` #define CV_CAP_PROP_DIALOG_DISPLAY 8 #define CV_CAP_PROP_DIALOG_FORMAT 9 #de...
14,300
<p>For example; with the old command prompt it would be:</p> <pre><code>cmd.exe /k mybatchfile.bat </code></pre>
[ { "answer_id": 14313, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 6, "selected": true, "text": "<p>Drop into a cmd instance (or indeed PowerShell itself) and type this:</p>\n\n<pre><code>powershell -?\n</code></pre>\n\...
2008/08/18
[ "https://Stackoverflow.com/questions/14300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/887/" ]
For example; with the old command prompt it would be: ``` cmd.exe /k mybatchfile.bat ```
Drop into a cmd instance (or indeed PowerShell itself) and type this: ``` powershell -? ``` You'll see that powershell.exe has a "-noexit" parameter which tells it not to exit after executing a "startup command".
14,330
<p>How do I convert the RGB values of a pixel to a single monochrome value?</p>
[ { "answer_id": 14331, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 6, "selected": true, "text": "<p>I found one possible solution in the <a href=\"http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html\" rel=\"...
2008/08/18
[ "https://Stackoverflow.com/questions/14330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
How do I convert the RGB values of a pixel to a single monochrome value?
I found one possible solution in the [Color FAQ](http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html). The *luminance component* Y (from the *CIE XYZ system*) captures what is most perceived by humans as color in one channel. So, use those coefficients: ``` mono = (0.2125 * color.r) + (0.7154 * color.g) + (0.0...
14,350
<p>I have a Flex swf hosted at <a href="http://www.a.com/a.swf" rel="nofollow noreferrer">http://www.a.com/a.swf</a>. I have a flash code on another doamin that tries loading the SWF:</p> <pre><code>_loader = new Loader(); var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf"); _loader.contentLoader...
[ { "answer_id": 14384, "author": "Rytmis", "author_id": 266, "author_profile": "https://Stackoverflow.com/users/266", "pm_score": 0, "selected": false, "text": "<p>Mayhaps <a href=\"http://livedocs.adobe.com/flex/15/flex_docs_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flex_Documenta...
2008/08/18
[ "https://Stackoverflow.com/questions/14350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1228206/" ]
I have a Flex swf hosted at <http://www.a.com/a.swf>. I have a flash code on another doamin that tries loading the SWF: ``` _loader = new Loader(); var req:URLRequest = new URLRequest("http://services.nuconomy.com/n.swf"); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaderFinish); _loader.load(req); `...
This is all described in [The Adobe Flex 3 Programming ActionScript 3 PDF](http://livedocs.adobe.com/flex/3/progAS_flex3.pdf) on page 550 (Chapter 27: Flash Player Security / Cross-scripting): > > If two SWF files written with ActionScript 3.0 are served from different domains—for example, <http://siteA.com/swfA.swf>...
14,373
<p>I am converting from existing CVS repository to SVN repository. CVS repository has few brances and I'd like to rename branches while converting.</p> <p>Wanted conversion is like this:</p> <pre><code>CVS branch SVN branch HEAD -&gt; branches/branchX branchA -&gt; trunk branchB -&gt; ...
[ { "answer_id": 14382, "author": "T Percival", "author_id": 954, "author_profile": "https://Stackoverflow.com/users/954", "pm_score": 1, "selected": false, "text": "<p>Subversion branches are directories, so you could just move the branches after the import has finished and no history wil...
2008/08/18
[ "https://Stackoverflow.com/questions/14373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1431/" ]
I am converting from existing CVS repository to SVN repository. CVS repository has few brances and I'd like to rename branches while converting. Wanted conversion is like this: ``` CVS branch SVN branch HEAD -> branches/branchX branchA -> trunk branchB -> branches/branchB branchC ...
> I am especially interested in preserving commit history. If I rename and move branches around in SVN after the conversion, will the history be preserved? Yes. Subversion also keeps track of changes to the directory structure, and all version history is preserved even if a file is moved in the tree. I recommend con...
14,375
<p>I'm using repository pattern with LINQ, have IRepository.DeleteOnSubmit(T Entity). It works fine, but when my entity class has interface, like this: </p> <pre><code>public interface IEntity { int ID {get;set;} } public partial class MyEntity: IEntity { public int ID { get { return this.IDfield; } ...
[ { "answer_id": 14381, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>using System.Data.Linq.Mapping;\n\npublic partial class MyEntity: IEntity \n { [Column(...
2008/08/18
[ "https://Stackoverflow.com/questions/14375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1407/" ]
I'm using repository pattern with LINQ, have IRepository.DeleteOnSubmit(T Entity). It works fine, but when my entity class has interface, like this: ``` public interface IEntity { int ID {get;set;} } public partial class MyEntity: IEntity { public int ID { get { return this.IDfield; } set { thi...
It appears Microsoft dropped support for `==` operator in interfaces when using linq-to-sql in MVC4 (or maybe it was never supported). You can however use `i.ID.Equals(someId)` in place of the `==` operator. Casting `IQueryable` to `IEnumerable` works but **should not be used!** The reason is: `IQueryable` has funky i...
14,378
<p>I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom in and out of a scene? How do I do that?</p>
[ { "answer_id": 14379, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 6, "selected": true, "text": "<p>Note that venerable <a href=\"http://www.xmission.com/~nate/glut.html\" rel=\"noreferrer\">Nate Robin's GLUT</a> li...
2008/08/18
[ "https://Stackoverflow.com/questions/14378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom in and out of a scene? How do I do that?
Note that venerable [Nate Robin's GLUT](http://www.xmission.com/~nate/glut.html) library doesn't support the scrollwheel. But, later implementations of GLUT like [FreeGLUT](http://freeglut.sourceforge.net/) do. Using the scroll wheel in FreeGLUT is dead simple. Here is how: Declare a callback function that shall be c...
14,386
<p>With the <em>Visual Studio 2005 C++ compiler</em>, I get the following warning when my code uses the <code>fopen()</code> and such calls:</p> <pre class="lang-none prettyprint-override"><code>1&gt;foo.cpp(5) : warning C4996: 'fopen' was declared deprecated 1&gt; c:\program files\microsoft visual studio 8\vc\i...
[ { "answer_id": 14387, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 8, "selected": true, "text": "<p>It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solut...
2008/08/18
[ "https://Stackoverflow.com/questions/14386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
With the *Visual Studio 2005 C++ compiler*, I get the following warning when my code uses the `fopen()` and such calls: ```none 1>foo.cpp(5) : warning C4996: 'fopen' was declared deprecated 1> c:\program files\microsoft visual studio 8\vc\include\stdio.h(234) : see declaration of 'fopen' 1> Message: 'Thi...
It looks like Microsoft has deprecated lots of calls which use buffers to improve code security. However, the solutions they're providing aren't portable. Anyway, if you aren't interested in using the secure version of their calls (like **fopen\_s**), you need to place a definition of **\_CRT\_SECURE\_NO\_DEPRECATE** b...
14,389
<p>I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example), grabs the episode name (from the www.thetvdb.com API) and automatically renames them into something nicer (Show Name - [01x02].avi)</p> <p>The script works fine, that is until you try and use it on files that have Unicode s...
[ { "answer_id": 14391, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 5, "selected": true, "text": "<p>Use a subrange of <code>[\\u0000-\\uFFFF]</code> for what you want.</p>\n\n<p>You can also use the <code>re.UNICODE</co...
2008/08/18
[ "https://Stackoverflow.com/questions/14389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example), grabs the episode name (from the www.thetvdb.com API) and automatically renames them into something nicer (Show Name - [01x02].avi) The script works fine, that is until you try and use it on files that have Unicode show-names ...
Use a subrange of `[\u0000-\uFFFF]` for what you want. You can also use the `re.UNICODE` compile flag. [The docs](http://docs.python.org/lib/re-syntax.html) say that if `UNICODE` is set, `\w` will match the characters `[0-9_]` plus whatever is classified as alphanumeric in the Unicode character properties database. ...
14,402
<p>In my simple OpenGL program I get the following error about exit redefinition:</p> <pre><code>1&gt;c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs 1&gt; c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\...
[ { "answer_id": 14403, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 7, "selected": true, "text": "<p><strong>Cause:</strong></p>\n\n<p>The <strong>stdlib.h</strong> which ships with the recent versions of Visual Stud...
2008/08/18
[ "https://Stackoverflow.com/questions/14402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
In my simple OpenGL program I get the following error about exit redefinition: ``` 1>c:\program files\microsoft visual studio 8\vc\include\stdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs 1> c:\program files\microsoft visual studio 8\vc\platformsdk\include\gl\glut.h(146) : see de...
**Cause:** The **stdlib.h** which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the **exit()** function. It clashes with the definition in **glut.h**. **Solution:** Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line...
14,413
<p>I want to use the functions exposed under the OpenGL extensions. I'm on Windows, how do I do this?</p>
[ { "answer_id": 14414, "author": "Ashwin Nanjappa", "author_id": 1630, "author_profile": "https://Stackoverflow.com/users/1630", "pm_score": 5, "selected": true, "text": "<p><strong>Easy solution</strong>: Use <a href=\"http://glew.sourceforge.net/\" rel=\"nofollow noreferrer\">GLEW</a>. ...
2008/08/18
[ "https://Stackoverflow.com/questions/14413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
I want to use the functions exposed under the OpenGL extensions. I'm on Windows, how do I do this?
**Easy solution**: Use [GLEW](http://glew.sourceforge.net/). See how [here](https://stackoverflow.com/questions/17370/using-glew-to-use-opengl-extensions-under-windows). **Hard solution**: If you have a **really strong reason** not to use GLEW, here's how to achieve the same without it: Identify the OpenGL extension ...
14,451
<p>What is the best way to make a delphi application (delphi 2007 for win32 here) go completely full screen, removing the application border and covering windows task bar ?</p> <p>I am looking for something similar to what IE does when you hit F11.</p> <p>I wish this to be a run time option for the user not a design ...
[ { "answer_id": 14458, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 2, "selected": false, "text": "<p>Maximize the form and <a href=\"http://delphi.about.com/cs/adptips2000/a/bltip0100_5.htm\" rel=\"nofollow noreferrer\">...
2008/08/18
[ "https://Stackoverflow.com/questions/14451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1724/" ]
What is the best way to make a delphi application (delphi 2007 for win32 here) go completely full screen, removing the application border and covering windows task bar ? I am looking for something similar to what IE does when you hit F11. I wish this to be a run time option for the user not a design time decision by ...
Well, this has always worked for me. Seems a bit simpler... ``` procedure TForm52.Button1Click(Sender: TObject); begin BorderStyle := bsNone; WindowState := wsMaximized; end; ```
14,464
<p>I have a structure which I need to populate and write to disk (several actually).</p> <p>An example is:</p> <pre><code>byte-6 bit0 - original_or_copy bit1 - copyright bit2 - data_alignment_indicator bit3 - PES_priority bit4-bit5 - PES_scrambling control. bit6-bit7 - reserved </code></pre> <p>In C ...
[ { "answer_id": 14466, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 2, "selected": false, "text": "<p>Could an Enum with the Flags Attribute help maybe? See here:</p>\n\n<p><a href=\"https://stackoverflow.com/questions/8447...
2008/08/18
[ "https://Stackoverflow.com/questions/14464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1006/" ]
I have a structure which I need to populate and write to disk (several actually). An example is: ``` byte-6 bit0 - original_or_copy bit1 - copyright bit2 - data_alignment_indicator bit3 - PES_priority bit4-bit5 - PES_scrambling control. bit6-bit7 - reserved ``` In C I might do something like the fol...
I'd probably knock together something using attributes, then a conversion class to convert suitably attributed structures to the bitfield primitives. Something like... ``` using System; namespace BitfieldTest { [global::System.AttributeUsage(AttributeTargets.Field, AllowMultiple = false)] sealed class Bitfiel...
14,491
<p>What is the proper way for an MFC application to cleanly close itself?</p>
[ { "answer_id": 14492, "author": "Mike", "author_id": 1743, "author_profile": "https://Stackoverflow.com/users/1743", "pm_score": 4, "selected": false, "text": "<pre><code>AfxGetMainWnd()-&gt;PostMessage(WM_CLOSE);\n</code></pre>\n" }, { "answer_id": 14663, "author": "Aidan Ry...
2008/08/18
[ "https://Stackoverflow.com/questions/14491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1743/" ]
What is the proper way for an MFC application to cleanly close itself?
Programatically Terminate an MFC Application ``` void ExitMFCApp() { // same as double-clicking on main window close box ASSERT(AfxGetMainWnd() != NULL); AfxGetMainWnd()->SendMessage(WM_CLOSE); } ``` <http://support.microsoft.com/kb/117320>
14,505
<p>In the Full .NET framework you can use the Color.FromArgb() method to create a new color with alpha blending, like this:</p> <pre><code>Color blended = Color.FromArgb(alpha, color); </code></pre> <p>or</p> <pre><code>Color blended = Color.FromArgb(alpha, red, green , blue); </code></pre> <p>However in the Compac...
[ { "answer_id": 14525, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 2, "selected": true, "text": "<p>Apparently, it's not quite that simple, but <a href=\"http://blogs.msdn.com/chrislorton/archive/2006/04/07/570649.aspx...
2008/08/18
[ "https://Stackoverflow.com/questions/14505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
In the Full .NET framework you can use the Color.FromArgb() method to create a new color with alpha blending, like this: ``` Color blended = Color.FromArgb(alpha, color); ``` or ``` Color blended = Color.FromArgb(alpha, red, green , blue); ``` However in the Compact Framework (2.0 specifically), neither of those ...
Apparently, it's not quite that simple, but [still possible](http://blogs.msdn.com/chrislorton/archive/2006/04/07/570649.aspx), if you have Windows Mobile 5.0 or newer.
14,527
<p>I need to be able to find the last occurrence of a character within an element.</p> <p>For example:</p> <pre><code>&lt;mediaurl&gt;http://www.blah.com/path/to/file/media.jpg&lt;/mediaurl&gt; </code></pre> <p>If I try to locate it through using <code>substring-before(mediaurl, '.')</code> and <code>substring-after...
[ { "answer_id": 14547, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 0, "selected": false, "text": "<p>How about tokenize with \"/\" and take the last element from the array ?</p>\n\n<pre><code>Example: tokenize(\"XPath is fun\...
2008/08/18
[ "https://Stackoverflow.com/questions/14527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/274/" ]
I need to be able to find the last occurrence of a character within an element. For example: ``` <mediaurl>http://www.blah.com/path/to/file/media.jpg</mediaurl> ``` If I try to locate it through using `substring-before(mediaurl, '.')` and `substring-after(mediaurl, '.')` then it will, of course, match on the first ...
The following is an example of a template that would produce the required output in XSLT 1.0: ``` <xsl:template name="getExtension"> <xsl:param name="filename"/> <xsl:choose> <xsl:when test="contains($filename, '.')"> <xsl:call-template name="getExtension"> <xsl:with-param name="filename" select="subs...
14,577
<p>Imagine the scene, you're updating some legacy Sybase code and come across a cursor. The stored procedure builds up a result set in a #temporary table which is all ready to be returned except that one of columns isn't terribly human readable, it's an alphanumeric code.</p> <p>What we need to do, is figure out the p...
[ { "answer_id": 14671, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 1, "selected": false, "text": "<p>Unless you are willing to duplicate the code in the xref proc, there is no way to avoid using a cursor.</p>\n" }, { "ans...
2008/08/18
[ "https://Stackoverflow.com/questions/14577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
Imagine the scene, you're updating some legacy Sybase code and come across a cursor. The stored procedure builds up a result set in a #temporary table which is all ready to be returned except that one of columns isn't terribly human readable, it's an alphanumeric code. What we need to do, is figure out the possible di...
You have to have a XRef table if you want to take out the cursor. Assuming you know the 100 distinct lookup values (and that they're static) it's simple to generate one by calling proc\_code\_xref 100 times and inserting the results into a table
14,614
<p>First off, I understand the reasons why an interface or abstract class (in the .NET/C# terminology) cannot have abstract static methods. My question is then more focused on the best design solution.</p> <p>What I want is a set of "helper" classes that all have their own static methods such that if I get objects A,...
[ { "answer_id": 14622, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 1, "selected": false, "text": "<p>In C# 3.0, static methods can be used on interfaces as if they were a part of them by using extension methods, as with...
2008/08/18
[ "https://Stackoverflow.com/questions/14614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1108/" ]
First off, I understand the reasons why an interface or abstract class (in the .NET/C# terminology) cannot have abstract static methods. My question is then more focused on the best design solution. What I want is a set of "helper" classes that all have their own static methods such that if I get objects A, B, and C f...
Looking at [your response](https://stackoverflow.com/questions/14614/static-methods-in-an-interfaceabstract-class#14655) I am thinking along the following lines: * You could just have a static method that takes a type parameter and performs the expected logic based on the type. * You could create a virtual method in y...
14,617
<p>I'm trying to retrieve a file from a server using SFTP (as opposed to FTPS) using Java. How can I do this?</p>
[ { "answer_id": 14629, "author": "David Hayes", "author_id": 1769, "author_profile": "https://Stackoverflow.com/users/1769", "pm_score": 5, "selected": false, "text": "<p>This was the solution I came up with\n<a href=\"http://sourceforge.net/projects/sshtools/\" rel=\"noreferrer\">http://...
2008/08/18
[ "https://Stackoverflow.com/questions/14617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1769/" ]
I'm trying to retrieve a file from a server using SFTP (as opposed to FTPS) using Java. How can I do this?
Another option is to consider looking at the [JSch library](http://www.jcraft.com/jsch/ "JSch library"). JSch seems to be the preferred library for a few large open source projects, including Eclipse, Ant and Apache Commons HttpClient, amongst others. It supports both user/pass and certificate-based logins nicely, as ...
14,698
<p>When I try to precompile a *.pc file that contains a #warning directive I recieve the following error:</p> <blockquote> <p>PCC-S-02014, Encountered the symbol "warning" when expecting one of the following: (bla bla bla).</p> </blockquote> <p>Can I somehow convince Pro*C to ignore the thing if it doesn't know wha...
[ { "answer_id": 14999, "author": "Jon Bright", "author_id": 1813, "author_profile": "https://Stackoverflow.com/users/1813", "pm_score": 0, "selected": false, "text": "<p>You can't. Pro*C only knows #if and #include. My best advice would be to preprocess the file as part of your build pr...
2008/08/18
[ "https://Stackoverflow.com/questions/14698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1733/" ]
When I try to precompile a \*.pc file that contains a #warning directive I recieve the following error: > > PCC-S-02014, Encountered the symbol "warning" when expecting one of the following: (bla bla bla). > > > Can I somehow convince Pro\*C to ignore the thing if it doesn't know what to do with it? I can't remov...
According to the *Pro\*C/C++ Programmer's Guide* (chapter 5 "Advanced Topics"), Pro\*C silently ignores a number of preprocessor directives including #error and #pragma, but sadly not #warning. Since your warning directives are included in a header file, you might be able to use the ORA\_PROC macro: ``` #ifndef ORA_P...
14,708
<p>What's the DOS FINDSTR equivalent for <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="noreferrer">PowerShell</a>? I need to search a bunch of log files for "ERROR".</p>
[ { "answer_id": 14724, "author": "Monroecheeseman", "author_id": 1351, "author_profile": "https://Stackoverflow.com/users/1351", "pm_score": 5, "selected": false, "text": "<p>Here's the quick answer </p>\n\n<pre><code>Get-ChildItem -Recurse -Include *.log | select-string ERROR \n</code></...
2008/08/18
[ "https://Stackoverflow.com/questions/14708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1351/" ]
What's the DOS FINDSTR equivalent for [PowerShell](http://en.wikipedia.org/wiki/Windows_PowerShell)? I need to search a bunch of log files for "ERROR".
Here's the quick answer ``` Get-ChildItem -Recurse -Include *.log | select-string ERROR ``` I found it [here](http://www.interact-sw.co.uk/iangblog/2006/06/03/pshfindstr) which has a great indepth answer!
14,717
<p>We're having sporadic, random query timeouts on our SQL Server 2005 cluster. I own a few apps that use it, so I'm helping out in the investigation. When watching the % CPU time in regular ol' Perfmon, you can certainly see it pegging out. However, SQL activity monitor only gives cumulative CPU and IO time used by a ...
[ { "answer_id": 14730, "author": "Yaakov Ellis", "author_id": 51, "author_profile": "https://Stackoverflow.com/users/51", "pm_score": 2, "selected": false, "text": "<p>Profiler may seem like a \"needle in a haystack\" approach, but it may turn up something useful. Try running it for a cou...
2008/08/18
[ "https://Stackoverflow.com/questions/14717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1212/" ]
We're having sporadic, random query timeouts on our SQL Server 2005 cluster. I own a few apps that use it, so I'm helping out in the investigation. When watching the % CPU time in regular ol' Perfmon, you can certainly see it pegging out. However, SQL activity monitor only gives cumulative CPU and IO time used by a pro...
This will give you the top 50 statements by average CPU time, check here for other scripts: <http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true> ``` SELECT TOP 50 qs.total_worker_time/qs.execution_count as [Avg CPU Time], SUBSTRING(qt.text,qs.statement_start_offset/...
14,731
<p>Normally I would just use:</p> <pre><code>HttpContext.Current.Server.UrlEncode("url"); </code></pre> <p>But since this is a console application, <code>HttpContext.Current</code> is always going to be <code>null</code>.</p> <p>Is there another method that does the same thing that I could use?</p>
[ { "answer_id": 14734, "author": "Patrik Svensson", "author_id": 936, "author_profile": "https://Stackoverflow.com/users/936", "pm_score": 2, "selected": false, "text": "<p>Try using the UrlEncode method in the HttpUtility class.</p>\n\n<ol>\n<li><a href=\"http://msdn.microsoft.com/en-us/...
2008/08/18
[ "https://Stackoverflow.com/questions/14731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1469/" ]
Normally I would just use: ``` HttpContext.Current.Server.UrlEncode("url"); ``` But since this is a console application, `HttpContext.Current` is always going to be `null`. Is there another method that does the same thing that I could use?
Try this! ``` Uri.EscapeUriString(url); ``` Or ``` Uri.EscapeDataString(data) ``` No need to reference System.Web. **Edit:** Please see [another](https://stackoverflow.com/a/34189188/7391) SO answer for more...
14,801
<p>Suppose you have the following EJB 3 interfaces/classes:</p> <pre><code>public interface Repository&lt;E&gt; { public void delete(E entity); } public abstract class AbstractRepository&lt;E&gt; implements Repository&lt;E&gt; { public void delete(E entity){ //... } } public interface FooRepository&l...
[ { "answer_id": 14920, "author": "Mike Deck", "author_id": 1247, "author_profile": "https://Stackoverflow.com/users/1247", "pm_score": 1, "selected": false, "text": "<p>Can you write a unit test against your FooRepository class just using it as a POJO. If that works as expected then I'm ...
2008/08/18
[ "https://Stackoverflow.com/questions/14801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1793/" ]
Suppose you have the following EJB 3 interfaces/classes: ``` public interface Repository<E> { public void delete(E entity); } public abstract class AbstractRepository<E> implements Repository<E> { public void delete(E entity){ //... } } public interface FooRepository<Foo> { //other methods } @Loc...
I tried it with a pojo and it seems to work. I had to modify your code a bit. I think your interfaces were a bit off, but I'm not sure. I assumed "Foo" was a concrete type, but if not I can do some more testing for you. I just wrote a main method to test this. I hope this helps! ``` public static void main(String[] ...
14,857
<p><strong>Bounty:</strong> I will send $5 via paypal for an answer that fixes this problem for me.</p> <p>I'm not sure what VS setting I've changed or if it's a web.config setting or what, but I keep getting this error in the error list and yet all solutions build fine. Here are some examples:</p> <pre> Error 5 ...
[ { "answer_id": 14861, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 0, "selected": false, "text": "<p>When asking for help diagnosing compilation problems, it often helps to post the offending source code :)</p>\n\n<p>T...
2008/08/18
[ "https://Stackoverflow.com/questions/14857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1414/" ]
**Bounty:** I will send $5 via paypal for an answer that fixes this problem for me. I'm not sure what VS setting I've changed or if it's a web.config setting or what, but I keep getting this error in the error list and yet all solutions build fine. Here are some examples: ``` Error 5 'CompilerGlobalScopeAttribut...
Based on the results of your gacutil output (thanks for doing that; I think it helps), I would say you need to try and run a repair on the .NET Framework install and Visual Studio 2005. I'm not sure if that will fix it, but as you can see from the output of the gacutil, you have none for 2.0. From my VS2005 Command Pr...
14,873
<p>I've noticed that a few Wordpress blogs have query statistics present in their footer that simply state the number of queries and the total time required to process them for the particular page, reading something like:</p> <blockquote> <p>23 queries. 0.448 seconds</p> </blockquote> <p>I was wondering how this is...
[ { "answer_id": 14972, "author": "pix0r", "author_id": 72, "author_profile": "https://Stackoverflow.com/users/72", "pm_score": 5, "selected": true, "text": "<p>Try adding this to the bottom of the footer in your template:</p>\n\n<pre><code>&lt;?php echo $wpdb-&gt;num_queries; ?&gt; &lt;?p...
2008/08/18
[ "https://Stackoverflow.com/questions/14873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1339/" ]
I've noticed that a few Wordpress blogs have query statistics present in their footer that simply state the number of queries and the total time required to process them for the particular page, reading something like: > > 23 queries. 0.448 seconds > > > I was wondering how this is accomplished. Is it through the...
Try adding this to the bottom of the footer in your template: ``` <?php echo $wpdb->num_queries; ?> <?php _e('queries'); ?>. <?php timer_stop(1); ?> <?php _e('seconds'); ?> ```
14,874
<p>For part of my application I have a need to create an image of a certain view and all of its subviews.</p> <p>To do this I'm creating a context that wraps a bitmap with the same-size as the view, but I'm unsure how to draw the view hierarchy into it. I can draw a single view just be setting the context and explicit...
[ { "answer_id": 14947, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 2, "selected": false, "text": "<p>You can use <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Refe...
2008/08/18
[ "https://Stackoverflow.com/questions/14874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1043/" ]
For part of my application I have a need to create an image of a certain view and all of its subviews. To do this I'm creating a context that wraps a bitmap with the same-size as the view, but I'm unsure how to draw the view hierarchy into it. I can draw a single view just be setting the context and explicitly calling...
I found that writing the drawing code myself was the best way to: * deal with potential transparency issues (some of the other options do add a white background to the whole image) * performance was much better The code below is not perfect, because it does not deal with scaling issues when going from bounds to frame...
14,884
<p>Say you have a shipment. It needs to go from point A to point B, point B to point C and finally point C to point D. You need it to get there in five days for the least amount of money possible. There are three possible shippers for each leg, each with their own different time and cost for each leg:</p> <pre><code>A...
[ { "answer_id": 14892, "author": "Baltimark", "author_id": 1179, "author_profile": "https://Stackoverflow.com/users/1179", "pm_score": 3, "selected": false, "text": "<p>Sounds like what you have is called a \"linear programming problem\". It also sounds like a homework problem, no offense...
2008/08/18
[ "https://Stackoverflow.com/questions/14884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
Say you have a shipment. It needs to go from point A to point B, point B to point C and finally point C to point D. You need it to get there in five days for the least amount of money possible. There are three possible shippers for each leg, each with their own different time and cost for each leg: ``` Array ( [le...
Could alter some of the [shortest path algorithms](http://en.wikipedia.org/wiki/Shortest_path_problem), like Dijkstra's, to weight each path by cost but also keep track of time and stop going along a certain path if the time exceeds your threshold. Should find the cheapest that gets you in under your threshold that way
14,923
<p>I'm thinking of learning the <code>ASP.NET MVC</code> framework for an upcoming project. Can I use the advanced routing to create long URLs based on the sitemap hierarchy?</p> <p>Example navigation path:</p> <p><strong>Home > Shop > Products > Household > Kitchen > Cookware > Cooksets > Nonstick</strong></p> <p>...
[ { "answer_id": 14991, "author": "J Wynia", "author_id": 1124, "author_profile": "https://Stackoverflow.com/users/1124", "pm_score": 2, "selected": false, "text": "<p>The MVC routing lets you define pretty much any structure you want, you just need to define what each of the pieces mean s...
2008/08/18
[ "https://Stackoverflow.com/questions/14923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/83/" ]
I'm thinking of learning the `ASP.NET MVC` framework for an upcoming project. Can I use the advanced routing to create long URLs based on the sitemap hierarchy? Example navigation path: **Home > Shop > Products > Household > Kitchen > Cookware > Cooksets > Nonstick** Typical (I think) MVC URL: <http://example.com...
Zack, if I understand right you want unlimited depth of the subcategories. No biggie, since MVC Preview 3 (I think 3 or 4) this has been solved. Just define a route like "{controller}/{action}/{\*categoryPath}" for an url such as : <http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick> you...
14,934
<p>.NET, Java and other high level database API's in various language often provide techniques known as prepared statements and parameter binding as opposed to sending plain text commands to the Database server. What I would like to know is what happens when you execute a statement like this:</p> <pre><code>SqlCommand...
[ { "answer_id": 14946, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html\" rel=\"nofollow noreferrer\">The M...
2008/08/18
[ "https://Stackoverflow.com/questions/14934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
.NET, Java and other high level database API's in various language often provide techniques known as prepared statements and parameter binding as opposed to sending plain text commands to the Database server. What I would like to know is what happens when you execute a statement like this: ``` SqlCommand cmd = new Sql...
[The MySQL manual page](http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statements.html) on prepared statements provides lots of information (which should apply to any other RDBMS). Basically, your statement is parsed and processed ahead of time, and the parameters are sent separately instead of being handled al...
14,943
<p>What is the best way to disable <kbd>Alt</kbd> + <kbd>F4</kbd> in a c# win form to prevent the user from closing the form?</p> <p>I am using a form as a popup dialog to display a progress bar and I do not want the user to be able to close it.</p>
[ { "answer_id": 14949, "author": "Timbo", "author_id": 1810, "author_profile": "https://Stackoverflow.com/users/1810", "pm_score": 4, "selected": false, "text": "<p>You could handle the <code>FormClosing</code> event and set <code>FormClosingEventArgs.Cancel</code> to <code>true</code>.</...
2008/08/18
[ "https://Stackoverflow.com/questions/14943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1375/" ]
What is the best way to disable `Alt` + `F4` in a c# win form to prevent the user from closing the form? I am using a form as a popup dialog to display a progress bar and I do not want the user to be able to close it.
This does the job: ``` private void Form1_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; } ``` Edit: In response to pix0rs concern - yes you are correct that you will not be able to programatically close the app. However, you can simply remove the event handler for the form\_closing event ...
15,023
<p>In WindowsForms world you can get a list of available image encoders/decoders with</p> <pre><code>System.Drawing.ImageCodecInfo.GetImageDecoders() / GetImageEncoders() </code></pre> <p>My question is, is there a way to do something analogous for the WPF world that would allow me to get a list of available </p> <p...
[ { "answer_id": 15388, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 1, "selected": false, "text": "<p>Hopefully someone will correct me if I'm wrong, but I don't think there's anything like that in WPF. But hopefully ...
2008/08/18
[ "https://Stackoverflow.com/questions/15023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In WindowsForms world you can get a list of available image encoders/decoders with ``` System.Drawing.ImageCodecInfo.GetImageDecoders() / GetImageEncoders() ``` My question is, is there a way to do something analogous for the WPF world that would allow me to get a list of available ``` System.Windows.Media.Imaging...
You've got to love .NET reflection. I worked on the WPF team and can't quite think of anything better off the top of my head. The following code produces this list on my machine: ``` Bitmap Encoders: System.Windows.Media.Imaging.BmpBitmapEncoder System.Windows.Media.Imaging.GifBitmapEncoder System.Windows.Media.Imagin...
15,034
<p>When building a VS 2008 solution with 19 projects I sometimes get:</p> <pre><code>The "GenerateResource" task failed unexpectedly. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapaci...
[ { "answer_id": 15055, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 1, "selected": true, "text": "<p>I used to hit this now and again with larger solutions. My tactic was to break the larger solution down into smaller solutions.</...
2008/08/18
[ "https://Stackoverflow.com/questions/15034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1365/" ]
When building a VS 2008 solution with 19 projects I sometimes get: ``` The "GenerateResource" task failed unexpectedly. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.set_Capacity(Int32 value) at System.IO.MemoryStream.EnsureCapacity(Int32 value...
I used to hit this now and again with larger solutions. My tactic was to break the larger solution down into smaller solutions. You could also try: <http://stevenharman.net/blog/archive/2008/04/29/hacking-visual-studio-to-use-more-than-2gigabytes-of-memory.aspx>
15,040
<p>I am using xampp on Windows, but I would like to use something closer to my server setup.</p> <p><a href="http://phpimpact.wordpress.com/2008/05/24/virtual-appliances-lamp-development-made-easy/" rel="nofollow noreferrer">Federico Cargnelutti tutorial</a> explains how to setup LAMP VMWARE appliance; it is a great i...
[ { "answer_id": 15044, "author": "Dinoboff", "author_id": 1771, "author_profile": "https://Stackoverflow.com/users/1771", "pm_score": 3, "selected": false, "text": "<p>Assuming you have VMware workstation, VMware player or anything that can run vmware appliance, you just need to:</p>\n\n<...
2008/08/18
[ "https://Stackoverflow.com/questions/15040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1771/" ]
I am using xampp on Windows, but I would like to use something closer to my server setup. [Federico Cargnelutti tutorial](http://phpimpact.wordpress.com/2008/05/24/virtual-appliances-lamp-development-made-easy/) explains how to setup LAMP VMWARE appliance; it is a great introduction to VMware appliances, but one of th...
This is my install scrpt, I use it on debian servers, but it will work in Ubuntu (Ubuntu is built on Debian) ``` apt-get -yq update apt-get -yq upgrade apt-get -yq install sudo apt-get -yq install gcc apt-get -yq install g++ apt-get -yq install make apt-get -yq install apache2 apt-get -yq install php5 apt-get -yq inst...
15,047
<p>I'm working on a WinForm .Net application with the basic UI that includes toolbar buttons, menu items and keystrokes that all initiate the same underlying code. Right now the event handlers for each of these call a common method to perform the function.</p> <p>From what I've read this type of action could be handle...
[ { "answer_id": 15103, "author": "ESV", "author_id": 150, "author_profile": "https://Stackoverflow.com/users/150", "pm_score": 1, "selected": false, "text": "<p>Try open source, .NET editors like <a href=\"http://sharpdevelop.net/OpenSource/SD/\" rel=\"nofollow noreferrer\">SharpDevelop</...
2008/08/18
[ "https://Stackoverflow.com/questions/15047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1752/" ]
I'm working on a WinForm .Net application with the basic UI that includes toolbar buttons, menu items and keystrokes that all initiate the same underlying code. Right now the event handlers for each of these call a common method to perform the function. From what I've read this type of action could be handled by the [...
Let's first make sure we know what the Command pattern is: > > Command pattern encapsulates a request > as an object and gives it a known > public interface. Command Pattern > ensures that every object receives its > own commands and provides a decoupling > between sender and receiver. A sender > is an object t...
15,053
<p>I'm trying to create a custom workflow action with an output parameter for error handling. Working from various examples, I can't get Parameter Direction="Out" to work. Everything seems right, but when I try to assign the output to the "error" variable in SharePoint Designer, it places asterisks around it and flags...
[ { "answer_id": 18993, "author": "Mauro", "author_id": 2208, "author_profile": "https://Stackoverflow.com/users/2208", "pm_score": 0, "selected": false, "text": "<p>Are you sure the issue is with the parameters and not maybe the variable in SPD? Certainly nothing looks wrong with your XM...
2008/08/18
[ "https://Stackoverflow.com/questions/15053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1533/" ]
I'm trying to create a custom workflow action with an output parameter for error handling. Working from various examples, I can't get Parameter Direction="Out" to work. Everything seems right, but when I try to assign the output to the "error" variable in SharePoint Designer, it places asterisks around it and flags it ...
I think you may want Direction="InOut" from the looks of the binding
15,056
<p>What are some macros that you have found useful in Visual Studio for code manipulation and automation? </p>
[ { "answer_id": 15107, "author": "RZachary", "author_id": 1393, "author_profile": "https://Stackoverflow.com/users/1393", "pm_score": 0, "selected": false, "text": "<p>You might want to add in code snippets as well, they help to speed up the development time and increase productivity.</p>...
2008/08/18
[ "https://Stackoverflow.com/questions/15056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1185/" ]
What are some macros that you have found useful in Visual Studio for code manipulation and automation?
This is one of the handy ones I use on HTML and XML files: ``` ''''replaceunicodechars.vb Option Strict Off Option Explicit Off Imports EnvDTE Imports System.Diagnostics Public Module ReplaceUnicodeChars Sub ReplaceUnicodeChars() DTE.ExecuteCommand("Edit.Find") ReplaceAllChar(ChrW(8230), "&#8230;...
15,062
<p>How do I convert function input parameters to the right type?</p> <p>I want to return a string that has part of the URL passed into it removed.</p> <p><strong>This works, but it uses a hard-coded string:</strong></p> <pre><code>function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") re...
[ { "answer_id": 15068, "author": "ESV", "author_id": 150, "author_profile": "https://Stackoverflow.com/users/150", "pm_score": 3, "selected": false, "text": "<pre><code>function CleanUrl([string] $url)\n{\n return $url.Replace(\"http://\", \"\")\n}\n</code></pre>\n" }, { "answe...
2008/08/18
[ "https://Stackoverflow.com/questions/15062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/636/" ]
How do I convert function input parameters to the right type? I want to return a string that has part of the URL passed into it removed. **This works, but it uses a hard-coded string:** ``` function CleanUrl($input) { $x = "http://google.com".Replace("http://", "") return $x } $SiteName = CleanUrl($HostHead...
The concept here is correct. The problem is with the variable name you have chosen. $input is a reserved variable used by PowerShell to represent an array of pipeline input. If you change your variable name, you should not have any problem. PowerShell does have [a replace operator](https://technet.microsoft.com/en-us...
15,163
<p>In some VB6 code, I have a handler for a TreeView's Collapse event:</p> <pre><code>Private Sub MyTree_Collapse(ByVal Node as MSComCtlLib.Node) </code></pre> <p>This is called whenever a node in the tree is collapsed, whether by the user or programmatically. As it turns out, through some roundabout execution, it m...
[ { "answer_id": 15591, "author": "Phil Bachmann", "author_id": 1855, "author_profile": "https://Stackoverflow.com/users/1855", "pm_score": 2, "selected": true, "text": "<p>I think that like many events in VB, it can't be switched off.</p>\n\n<p>Just set a boolean flag as you've suggested....
2008/08/18
[ "https://Stackoverflow.com/questions/15163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/863/" ]
In some VB6 code, I have a handler for a TreeView's Collapse event: ``` Private Sub MyTree_Collapse(ByVal Node as MSComCtlLib.Node) ``` This is called whenever a node in the tree is collapsed, whether by the user or programmatically. As it turns out, through some roundabout execution, it may happen that this handler...
I think that like many events in VB, it can't be switched off. Just set a boolean flag as you've suggested.
15,171
<p>In the linux file system, where should user scripts be placed?</p> <p>I'm thinking specifically python scripts to be called by cron.</p>
[ { "answer_id": 15177, "author": "Matt McMinn", "author_id": 1322, "author_profile": "https://Stackoverflow.com/users/1322", "pm_score": 4, "selected": false, "text": "<p>If you're talking about scripts created by a user that will be run from that users crontab, I typically put those in e...
2008/08/18
[ "https://Stackoverflow.com/questions/15171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/479/" ]
In the linux file system, where should user scripts be placed? I'm thinking specifically python scripts to be called by cron.
the information i got: ``` /usr/local/sbin custom script meant for root /usr/local/bin custom script meant for all users including non-root ``` chatlog snips from irc.debian.org #debian: ``` (02:48:49) c33s: question: where is the _correct_ location, to put custom scripts for the root user (like a script o...
15,204
<p>What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?</p>
[ { "answer_id": 15210, "author": "mbillard", "author_id": 810, "author_profile": "https://Stackoverflow.com/users/810", "pm_score": 6, "selected": true, "text": "<p>For C#:</p>\n\n<pre><code>foreach(ObjectType objectItem in objectTypeList)\n{\n // ...do some stuff\n}\n</code></pre>\n\n...
2008/08/18
[ "https://Stackoverflow.com/questions/15204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1224/" ]
What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?
For C#: ``` foreach(ObjectType objectItem in objectTypeList) { // ...do some stuff } ``` Answer for VB.NET from **Purple Ant**: ``` For Each objectItem as ObjectType in objectTypeList 'Do some stuff ' Next ```
15,219
<p>I'm using the Infragistics grid and I'm having a difficult time using a drop-down list as the value selector for one of my columns.</p> <p>I tried reading the documentation but Infragistics' documentation is not so good. I've also taken a look at this <a href="http://news.infragistics.com/forums/p/9063/45792.aspx" ...
[ { "answer_id": 16347, "author": "Erick B", "author_id": 1373, "author_profile": "https://Stackoverflow.com/users/1373", "pm_score": 2, "selected": false, "text": "<p>Here's an example from one of my pages:</p>\n\n<pre><code>UltraWebGrid uwgMyGrid = new UltraWebGrid();\nuwgMyGrid.Columns....
2008/08/18
[ "https://Stackoverflow.com/questions/15219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/810/" ]
I'm using the Infragistics grid and I'm having a difficult time using a drop-down list as the value selector for one of my columns. I tried reading the documentation but Infragistics' documentation is not so good. I've also taken a look at this [discussion](http://news.infragistics.com/forums/p/9063/45792.aspx) with n...
I've found what was wrong. The column must allow updates. ``` uwgMyGrid.Columns.FromKey("colTest").AllowUpdate = AllowUpdate.Yes; ```
15,240
<p>I'd like to make a debug logging function with the same parameters as <code>printf</code>. But one that can be removed by the pre-processor during optimized builds.</p> <p>For example:</p> <pre><code>Debug_Print("Warning: value %d &gt; 3!\n", value); </code></pre> <p>I've looked at variadic macros but those aren...
[ { "answer_id": 15248, "author": "Stu", "author_id": 414, "author_profile": "https://Stackoverflow.com/users/414", "pm_score": 1, "selected": false, "text": "<p>What platforms are they not available on? stdarg is part of the standard library:</p>\n\n<p><a href=\"http://www.opengroup.org/o...
2008/08/18
[ "https://Stackoverflow.com/questions/15240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1841/" ]
I'd like to make a debug logging function with the same parameters as `printf`. But one that can be removed by the pre-processor during optimized builds. For example: ``` Debug_Print("Warning: value %d > 3!\n", value); ``` I've looked at variadic macros but those aren't available on all platforms. `gcc` supports th...
I still do it the old way, by defining a macro (XTRACE, below) which correlates to either a no-op or a function call with a variable argument list. Internally, call vsnprintf so you can keep the printf syntax: ``` #include <stdio.h> void XTrace0(LPCTSTR lpszText) { ::OutputDebugString(lpszText); } void XTrace(LPC...
15,247
<p>Given a list of locations such as</p> <pre class="lang-html prettyprint-override"><code> &lt;td&gt;El Cerrito, CA&lt;/td&gt; &lt;td&gt;Corvallis, OR&lt;/td&gt; &lt;td&gt;Morganton, NC&lt;/td&gt; &lt;td&gt;New York, NY&lt;/td&gt; &lt;td&gt;San Diego, CA&lt;/td&gt; </code></pre> <p>What's the easies...
[ { "answer_id": 15257, "author": "mk.", "author_id": 1797, "author_profile": "https://Stackoverflow.com/users/1797", "pm_score": 1, "selected": false, "text": "<p>I guess more information would be needed to really give you an answer, but over at Django Pluggables there is a <a href=\"http...
2008/08/18
[ "https://Stackoverflow.com/questions/15247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
Given a list of locations such as ```html <td>El Cerrito, CA</td> <td>Corvallis, OR</td> <td>Morganton, NC</td> <td>New York, NY</td> <td>San Diego, CA</td> ``` What's the easiest way to generate a Google Map with pushpins for each location?
I'm assuming you have the basics for Maps in your code already with your API Key. ``` <head> <script type="text/javascript" href="http://maps.google.com/maps? file=api&v=2&key=xxxxx"> function createMap() { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.44...
15,254
<p>Is it possible to actually make use of placement new in portable code when using it for arrays?</p> <p>It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm that this is correct), but I don't see how you can allocate a ...
[ { "answer_id": 15273, "author": "Yossi Kreinin", "author_id": 1648, "author_profile": "https://Stackoverflow.com/users/1648", "pm_score": 1, "selected": false, "text": "<p>I think gcc does the same thing as MSVC, but of course this doesn't make it \"portable\".</p>\n\n<p>I think you can ...
2008/08/18
[ "https://Stackoverflow.com/questions/15254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739/" ]
Is it possible to actually make use of placement new in portable code when using it for arrays? It appears that the pointer you get back from new[] is not always the same as the address you pass in (5.3.4, note 12 in the standard seems to confirm that this is correct), but I don't see how you can allocate a buffer for...
Personally I'd go with the option of not using placement new on the array and instead use placement new on each item in the array individually. For example: ``` int main(int argc, char* argv[]) { const int NUMELEMENTS=20; char *pBuffer = new char[NUMELEMENTS*sizeof(A)]; A *pA = (A*)pBuffer; for(int i = 0; i ...
15,266
<p>Using <strong>NSURLRequest</strong>, I am trying to access a web site that has an expired certificate. When I send the request, my <strong>connection:didFailWithError</strong> delegate method is invoked with the following info:</p> <pre><code>-1203, NSURLErrorDomain, bad server certificate </code></pre> <p>My sear...
[ { "answer_id": 15963, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 1, "selected": false, "text": "<p>I've hit the same issue - I was developing a SOAP client, and the dev server has a \"homegrown\" certificate. I w...
2008/08/18
[ "https://Stackoverflow.com/questions/15266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/544/" ]
Using **NSURLRequest**, I am trying to access a web site that has an expired certificate. When I send the request, my **connection:didFailWithError** delegate method is invoked with the following info: ``` -1203, NSURLErrorDomain, bad server certificate ``` My searches have only turned up one solution: a hidden clas...
iPhone OS 3.0 introduced a supported way of doing this that doesn't require the lower-level CFNetwork APIs. More details here: [How to use NSURLConnection to connect with SSL for an untrusted cert?](https://stackoverflow.com/questions/933331/how-to-use-nsurlconnection-to-connect-with-ssl-for-an-untrusted-cert)
15,272
<p>I want a data structure that will allow querying <em>how many items in last <strong>X</strong> minutes</em>. An item may just be a simple identifier or a more complex data structure, preferably the timestamp of the item will be in the item, rather than stored outside (as a hash or similar, wouldn't want to have prob...
[ { "answer_id": 15316, "author": "dmo", "author_id": 1807, "author_profile": "https://Stackoverflow.com/users/1807", "pm_score": 2, "selected": false, "text": "<p>I think that an important consideration will be the frequency of querying vs. adding/removing. If you will do frequent queryi...
2008/08/18
[ "https://Stackoverflow.com/questions/15272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/163/" ]
I want a data structure that will allow querying *how many items in last **X** minutes*. An item may just be a simple identifier or a more complex data structure, preferably the timestamp of the item will be in the item, rather than stored outside (as a hash or similar, wouldn't want to have problems with multiple item...
A simple linked list can be used for this. Basically you add new items to the end, and remove too old items from the start, it is a cheap data structure. example-code: ``` list.push_end(new_data) while list.head.age >= age_limit: list.pop_head() ``` If the list will be busy enough to warrant chopping off large...
15,310
<p>First off I understand that it is a horrible idea to run extremely large/long running reports. I am aware that Microsoft has a rule of thumb stating that a SSRS report should take no longer than 30 seconds to execute. However sometimes gargantuan reports are a preferred evil due to external forces such complying wi...
[ { "answer_id": 16729, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 2, "selected": false, "text": "<blockquote>\n <ol>\n <li>Does anyone know of anyway to\n reduce/optimize the PDF export phase\n and or the size of...
2008/08/18
[ "https://Stackoverflow.com/questions/15310", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1644/" ]
First off I understand that it is a horrible idea to run extremely large/long running reports. I am aware that Microsoft has a rule of thumb stating that a SSRS report should take no longer than 30 seconds to execute. However sometimes gargantuan reports are a preferred evil due to external forces such complying with s...
> > 1. Does anyone know of anyway to > reduce/optimize the PDF export phase > and or the size of the PDF without > lowering the total page count? > > > I have a few ideas and questions: 1. Is this a graphics-heavy report? If not, do you have tables that start out as text but are converted into a graphic by t...
15,334
<p>I have recently started using Vim as my text editor and am currently working on my own customizations.</p> <p>I suppose keyboard mappings can do pretty much anything, but for the time being I'm using them as a sort of snippets facility almost exclusively.</p> <p>So, for example, if I type <code>def{TAB}</code> (<c...
[ { "answer_id": 15886, "author": "MDCore", "author_id": 1896, "author_profile": "https://Stackoverflow.com/users/1896", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://www.vim.org/scripts/script.php?script_id=1318\" rel=\"nofollow noreferrer\">SnippetsEmu</a> is a useful sni...
2008/08/18
[ "https://Stackoverflow.com/questions/15334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1670/" ]
I have recently started using Vim as my text editor and am currently working on my own customizations. I suppose keyboard mappings can do pretty much anything, but for the time being I'm using them as a sort of snippets facility almost exclusively. So, for example, if I type `def{TAB}` (`:imap def{TAB} def ():<ESC>3h...
[SnippetsEmu](http://www.vim.org/scripts/script.php?script_id=1318) is a useful snippets plugin.
15,390
<p>What are some standard practices for managing a medium-large JavaScript application? My concerns are both speed for browser download and ease and maintainability of development.</p> <p>Our JavaScript code is roughly "namespaced" as:</p> <pre><code>var Client = { var1: '', var2: '', accounts: { /* 1...
[ { "answer_id": 15402, "author": "Steve M", "author_id": 1693, "author_profile": "https://Stackoverflow.com/users/1693", "pm_score": 5, "selected": true, "text": "<p>The approach that I've found works for me is having seperate JS files for each class (just as you would in Java, C# and oth...
2008/08/18
[ "https://Stackoverflow.com/questions/15390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1848/" ]
What are some standard practices for managing a medium-large JavaScript application? My concerns are both speed for browser download and ease and maintainability of development. Our JavaScript code is roughly "namespaced" as: ``` var Client = { var1: '', var2: '', accounts: { /* 100's of functions and...
The approach that I've found works for me is having seperate JS files for each class (just as you would in Java, C# and others). Alternatively you can group your JS into application functional areas if that's easier for you to navigate. If you put all your JS files into one directory, you can have your server-side env...
15,395
<p>Linq To SQL or Entity framework both integrate nicely with SQL Server 2005.</p> <p>The SQL Server 2008 spec sheet promises even better integration - but I can't see it.</p> <p>What are some examples of what you can do Linq-wise when talking to a 2008 server that you can't when talking to SQL Server 2005?</p>
[ { "answer_id": 15431, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 0, "selected": false, "text": "<p>it has full support for the new data types. lol. beyond that you got me, other than possibilities of optimised queries (li...
2008/08/18
[ "https://Stackoverflow.com/questions/15395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1855/" ]
Linq To SQL or Entity framework both integrate nicely with SQL Server 2005. The SQL Server 2008 spec sheet promises even better integration - but I can't see it. What are some examples of what you can do Linq-wise when talking to a 2008 server that you can't when talking to SQL Server 2005?
There is a problem of paging over a joined set that SQL 2005 mis-interprets. ``` var orders = ( from c in Customers from o in c.Orders select new {c, o} ).Skip(10).Take(10).ToList(); ``` LINQ generates a ROW\_Number against the joined set. SQL2005 generates a bad plan from that code. Here's a link to the [discussion...
15,399
<p>My firm have a talented and smart operations staff who are working very hard. I'd like to give them a SQL-execution tool that helps them avoid common, easily-detected SQL mistakes that are easy to make when they are in a hurry. Can anyone suggest such a tool? Details follow.</p> <p>Part of the operations team remit...
[ { "answer_id": 15405, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 0, "selected": false, "text": "<p>You might find <a href=\"http://www.red-gate.com/Products/SQL_Prompt/index.htm\" rel=\"nofollow noreferrer\">SQL Prompt</a> f...
2008/08/18
[ "https://Stackoverflow.com/questions/15399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My firm have a talented and smart operations staff who are working very hard. I'd like to give them a SQL-execution tool that helps them avoid common, easily-detected SQL mistakes that are easy to make when they are in a hurry. Can anyone suggest such a tool? Details follow. Part of the operations team remit is writin...
If your people are using the mysql(1) program to run queries, you can use the [safe-updates](http://dev.mysql.com/doc/refman/5.1/en/mysql-tips.html) option (aka i-am-a-dummy) to get you part of what you need. Its name is somewhat misleading; it not only prevents UPDATE and DELETE without a WHERE (which you're not worri...
15,470
<p>I know this site is written using ASP.Net MVC and I do not see "/Home" in the url. This proves to me that it can be done. What special route and do I need?</p>
[ { "answer_id": 15474, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 5, "selected": true, "text": "<p>Just change \"Home\" to an empty string.</p>\n\n<pre><code>routes.MapRoute(\n \"Home\",\n \"\",\n new { action = ...
2008/08/19
[ "https://Stackoverflow.com/questions/15470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/692/" ]
I know this site is written using ASP.Net MVC and I do not see "/Home" in the url. This proves to me that it can be done. What special route and do I need?
Just change "Home" to an empty string. ``` routes.MapRoute( "Home", "", new { action = Index, controller = Home } ); ```
15,478
<p>GDI+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code, two line paths appear, that should be identical, because both of them are inside the clipping region. But when the clipping region is set, one of the line segment is not drawn. </p> <pre><code...
[ { "answer_id": 15813, "author": "TK.", "author_id": 1816, "author_profile": "https://Stackoverflow.com/users/1816", "pm_score": 0, "selected": false, "text": "<p>What appears to be the matter with the code?</p>\n\n<p>OK, the question should be... what should the code do that it doesn't a...
2008/08/19
[ "https://Stackoverflow.com/questions/15478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1873/" ]
GDI+ DrawLines function has a clipping bug that can be reproduced by running the following c# code. When running the code, two line paths appear, that should be identical, because both of them are inside the clipping region. But when the clipping region is set, one of the line segment is not drawn. ``` protected over...
It appears that this is a known bug... The following code appears to function as you requested: ``` protected override void OnPaint(PaintEventArgs e) { PointF[] points = new PointF[] { new PointF(73.36f, 196), new PointF(75.44f, 32), new PointF(77.52f, 32), new PointF(79.6f, ...
15,481
<p>Sometimes a labeled break or continue can make code a lot more readable. </p> <pre><code>OUTERLOOP: for ( ;/*stuff*/; ) { //...lots of code if ( isEnough() ) break OUTERLOOP; //...more code } </code></pre> <p>I was wondering what the common convention for the labels was. All caps? first cap? </p>
[ { "answer_id": 15501, "author": "RodeoClown", "author_id": 943, "author_profile": "https://Stackoverflow.com/users/943", "pm_score": 4, "selected": false, "text": "<p>The convention is to avoid labels altogether.</p>\n\n<p>There are very, very few valid reasons to use a label for breakin...
2008/08/19
[ "https://Stackoverflow.com/questions/15481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1870/" ]
Sometimes a labeled break or continue can make code a lot more readable. ``` OUTERLOOP: for ( ;/*stuff*/; ) { //...lots of code if ( isEnough() ) break OUTERLOOP; //...more code } ``` I was wondering what the common convention for the labels was. All caps? first cap?
If you have to use them use capitals, this draws attention to them and singles them out from being mistakenly interpreted as "Class" names. Drawing attention to them has the additional benefit of catching someone's eye that will come along and refactor your code and remove them. ;)
15,486
<p>So I came across an interesting problem today. We have a WCF web service that returns an IList. Not really a big deal until I wanted to sort it.</p> <p>Turns out the IList interface doesn't have a sort method built in. </p> <p>I ended up using the <code>ArrayList.Adapter(list).Sort(new MyComparer())</code> method ...
[ { "answer_id": 15491, "author": "Leon Bambrick", "author_id": 49, "author_profile": "https://Stackoverflow.com/users/49", "pm_score": 3, "selected": false, "text": "<p>You're going to have to do something like that i think (convert it into a more concrete type).</p>\n\n<p>Maybe take it i...
2008/08/19
[ "https://Stackoverflow.com/questions/15486", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
So I came across an interesting problem today. We have a WCF web service that returns an IList. Not really a big deal until I wanted to sort it. Turns out the IList interface doesn't have a sort method built in. I ended up using the `ArrayList.Adapter(list).Sort(new MyComparer())` method to solve the problem but it ...
How about using LINQ To Objects to sort for you? Say you have a `IList<Car>`, and the car had an `Engine` property, I believe you could sort as follows: ``` from c in list orderby c.Engine select c; ``` *Edit: You do need to be quick to get answers in here. As I presented a slightly different syntax to the other an...
15,514
<p>In my example below I'm using a <code>dijit.form.DateTextBox</code>:</p> <pre><code>&lt;input type="text" name="startDate" dojoType="dijit.form.DateTextBox" constraints="{datePattern:'MM/dd/yyyy'}" value='&lt;c:out value="${sessionScope.adminMessageForm.startDate}"/&gt;' /&gt; </code></pre> <p>So for example, if ...
[ { "answer_id": 15532, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 1, "selected": false, "text": "<p>My only suggestion is to programmatically remove the dojoType on the server-side or client-side. It is not possible to k...
2008/08/19
[ "https://Stackoverflow.com/questions/15514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/700/" ]
In my example below I'm using a `dijit.form.DateTextBox`: ``` <input type="text" name="startDate" dojoType="dijit.form.DateTextBox" constraints="{datePattern:'MM/dd/yyyy'}" value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>' /> ``` So for example, if the user starts to enter "asdf" into the date the...
Try overriding the validate method in your markup. This will work (just tested): ``` <input type="text" name="startDate" dojoType="dijit.form.DateTextBox" constraints="{datePattern:'MM/dd/yyyy'}" value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>' validate='return true;' /> ```
15,593
<p>I understand what <a href="http://msdn.microsoft.com/en-us/library/ms404247.aspx" rel="noreferrer">System.WeakReference</a> does, but what I can't seem to grasp is a practical example of what it might be useful for. The class itself seems to me to be, well, a hack. It seems to me that there are other, better means ...
[ { "answer_id": 15616, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": false, "text": "<p>I use it to implement a cache where unused entries are automatically garbage collected:</p>\n\n<pre><code>class Cache&...
2008/08/19
[ "https://Stackoverflow.com/questions/15593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1875/" ]
I understand what [System.WeakReference](http://msdn.microsoft.com/en-us/library/ms404247.aspx) does, but what I can't seem to grasp is a practical example of what it might be useful for. The class itself seems to me to be, well, a hack. It seems to me that there are other, better means of solving a problem where a Wea...
One useful example is the guys who run DB4O object oriented database. There, WeakReferences are used as a kind of light cache: it will keep your objects in memory only as long as your application does, allowing you to put a real cache on top. Another use would be in the implementation of weak event handlers. Currently...
15,656
<p>Another SSRS question here: <br /> We have a development, a QA, a Prod-Backup and a Production SSRS set of servers. <br /> On our production and prod-backup, SSRS will go to sleep if not used for a period of time. <br /><br /> This does not occur on our development or QA server. <br />In the corporate environme...
[ { "answer_id": 15659, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 0, "selected": false, "text": "<p>I vaguely recall having problems with SSRS on one machine when we changed the \"Enable HTTP Keep-Alives\" setting in I...
2008/08/19
[ "https://Stackoverflow.com/questions/15656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1580/" ]
Another SSRS question here: We have a development, a QA, a Prod-Backup and a Production SSRS set of servers. On our production and prod-backup, SSRS will go to sleep if not used for a period of time. This does not occur on our development or QA server. In the corporate environment we're in, we don't have ...
For anybody using the integrated webserver that is built into SQL Reporting Services (and hence IIS may not even be installed on the box), the setting to control this actually lives in: ``` C:\Program Files\Microsoft SQL Server\ MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\rsreportserver.config ``` ...
15,674
<p>When using Subversion (svn) for source control with multiple projects I've noticed that the revision number increases across all of my projects' directories. To illustrate my svn layout (using fictitious project names): </p> <pre> /NinjaProg/branches /tags /trunk /StealthApp/bra...
[ { "answer_id": 15676, "author": "John Downey", "author_id": 200, "author_profile": "https://Stackoverflow.com/users/200", "pm_score": 2, "selected": false, "text": "<p>This is due to how subversion works. Each revision is really a snapshot of the repository identified by that revision nu...
2008/08/19
[ "https://Stackoverflow.com/questions/15674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1339/" ]
When using Subversion (svn) for source control with multiple projects I've noticed that the revision number increases across all of my projects' directories. To illustrate my svn layout (using fictitious project names): ``` /NinjaProg/branches /tags /trunk /StealthApp/branches ...
I am surprised no has mentioned that this is discussed in Version Control with Subversion, which is available free online, [here](http://svnbook.red-bean.com/en/1.5/svn.reposadmin.planning.html). I read up on the issue awhile back and it really seems like a matter of personal choice, there is a good blog post on the s...
15,700
<p>I'm looking for a way to configure a DB connection at runtime; specifically using the Enterprise Library. I see that there's a *.Data.Configuration (or something close to this ... don't recall off the top of my head) assembly but am finding not much on the interwebs. Complicating matters is the fact that the API h...
[ { "answer_id": 15704, "author": "lomaxx", "author_id": 493, "author_profile": "https://Stackoverflow.com/users/493", "pm_score": 1, "selected": false, "text": "<p>If you're using a winforms app you could try using <a href=\"http://msdn.microsoft.com/en-us/library/aa221771(office.11).aspx...
2008/08/19
[ "https://Stackoverflow.com/questions/15700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1886/" ]
I'm looking for a way to configure a DB connection at runtime; specifically using the Enterprise Library. I see that there's a \*.Data.Configuration (or something close to this ... don't recall off the top of my head) assembly but am finding not much on the interwebs. Complicating matters is the fact that the API help ...
If you're using a winforms app you could try using [UserProperties](http://msdn.microsoft.com/en-us/library/aa221771(office.11).aspx) to store this info. Another possible solution could be [custom configuration sections](http://msdn.microsoft.com/en-us/library/2tw134k3.aspx).
15,709
<p>So for my text parsing in C# <a href="https://stackoverflow.com/questions/13963/best-method-of-textfile-parsing-in-c">question</a>, I got directed at YAML. I'm hitting a wall with this library I was recommended, so this is a quickie.</p> <pre><code>heading: name: A name taco: Yes age: 32 heading: name: Another...
[ { "answer_id": 15723, "author": "eplawless", "author_id": 1370, "author_profile": "https://Stackoverflow.com/users/1370", "pm_score": 2, "selected": false, "text": "<p>There appears to be a YAML validator called <a href=\"http://www.kuwata-lab.com/kwalify/\" rel=\"nofollow noreferrer\">K...
2008/08/19
[ "https://Stackoverflow.com/questions/15709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
So for my text parsing in C# [question](https://stackoverflow.com/questions/13963/best-method-of-textfile-parsing-in-c), I got directed at YAML. I'm hitting a wall with this library I was recommended, so this is a quickie. ``` heading: name: A name taco: Yes age: 32 heading: name: Another name taco: No age: 27 ...
Partially. YAML supports the notion of multiple consecutive "documents". If this is what you are trying to do here, then yes, it is correct - you have two documents (or document fragments). To make it more explicit, you should separate them with three dashes, like this: ``` --- heading: name: A name taco: Yes age: ...
15,716
<p>I have created a UserControl that has a <code>ListView</code> in it. The ListView is publicly accessible though a property. When I put the UserControl in a form and try to design the <code>ListView</code> though the property, the <code>ListView</code> stays that way until I compile again and it reverts back to the d...
[ { "answer_id": 15717, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 0, "selected": false, "text": "<p>Just so I'm clear, you've done something like this, right?</p>\n\n<pre><code>public ListView MyListView { get { return...
2008/08/19
[ "https://Stackoverflow.com/questions/15716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/788/" ]
I have created a UserControl that has a `ListView` in it. The ListView is publicly accessible though a property. When I put the UserControl in a form and try to design the `ListView` though the property, the `ListView` stays that way until I compile again and it reverts back to the default state. How do I get my desi...
You need to decorate the ListView property with the DesignerSerializationVisibility attribute, like so: ``` [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ListView MyListView { get { return this.listView1; } } ``` This tells the designer's code generator to output code for it.
15,729
<p>As I browse through the site, I find a lot of terms that many developers just starting out (and even some advanced developers) may be unfamiliar with.</p> <p>It would be great if people could post here with a term and definition that might be unknown to beginners or those from different programming backgrounds. </p...
[ { "answer_id": 15717, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 0, "selected": false, "text": "<p>Just so I'm clear, you've done something like this, right?</p>\n\n<pre><code>public ListView MyListView { get { return...
2008/08/19
[ "https://Stackoverflow.com/questions/15729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1693/" ]
As I browse through the site, I find a lot of terms that many developers just starting out (and even some advanced developers) may be unfamiliar with. It would be great if people could post here with a term and definition that might be unknown to beginners or those from different programming backgrounds. Some not-so...
You need to decorate the ListView property with the DesignerSerializationVisibility attribute, like so: ``` [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ListView MyListView { get { return this.listView1; } } ``` This tells the designer's code generator to output code for it.
15,732
<p>I'm generating some xml files that needs to conform to an xsd file that was given to me. How should I verify they conform?</p>
[ { "answer_id": 15739, "author": "SCdF", "author_id": 1666, "author_profile": "https://Stackoverflow.com/users/1666", "pm_score": 5, "selected": false, "text": "<p>Here's how to do it using <a href=\"http://xerces.apache.org/xerces2-j/\" rel=\"noreferrer\">Xerces2</a>. A tutorial for this...
2008/08/19
[ "https://Stackoverflow.com/questions/15732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1650/" ]
I'm generating some xml files that needs to conform to an xsd file that was given to me. How should I verify they conform?
The Java runtime library supports validation. Last time I checked this was the Apache Xerces parser under the covers. You should probably use a [javax.xml.validation.Validator](http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/Validator.html). ``` import javax.xml.XMLConstants; import javax.xml.transform.So...
15,744
<p>I'm wondering about instances when it makes sent to use #define and #if statements. I've known about it for a while, but never incorporated it into my way of coding. How exactly does this affect the compilation?</p> <blockquote> <p>Is #define the only thing that determines if the code is included when compiled? I...
[ { "answer_id": 15749, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 1, "selected": false, "text": "<p>Well, defines are used often for compile time constants and macros. This can make your code a bit faster as there are reall...
2008/08/19
[ "https://Stackoverflow.com/questions/15744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1888/" ]
I'm wondering about instances when it makes sent to use #define and #if statements. I've known about it for a while, but never incorporated it into my way of coding. How exactly does this affect the compilation? > > Is #define the only thing that determines if the code is included when compiled? If I have #define DEB...
In C# `#define` macros, like some of Bernard's examples, are not allowed. The only common use of `#define`/`#if`s in C# is for adding optional debug only code. For example: ``` static void Main(string[] args) { #if DEBUG //this only compiles if in DEBUG Console.WriteLine("DEBUG"...
15,774
<p>I run an ASP.NET website solution with a few other projects in it. I've known that MSBuild projects are capable of this, but is it the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better?</p> <p>When I build the site (using <a href="http://msdn.microsoft.com/en-us/asp.net/aa33...
[ { "answer_id": 15780, "author": "xanadont", "author_id": 1886, "author_profile": "https://Stackoverflow.com/users/1886", "pm_score": 1, "selected": false, "text": "<p>CruiseControl.NET solves a different problem (continuous integration) ... however, I've had great success with NAnt for s...
2008/08/19
[ "https://Stackoverflow.com/questions/15774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1888/" ]
I run an ASP.NET website solution with a few other projects in it. I've known that MSBuild projects are capable of this, but is it the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better? When I build the site (using [Web Deployment Projects](http://msdn.microsoft.com/en-us/asp.n...
Here's an example of a Web Deployment Project scripting this sort of task in the .wdproj file: ``` <Target Name="AfterBuild"> <!-- ============================ Script Compression============================ --> <MakeDir Directories="$(OutputPath)\compressed" /> <Exec Command="java -jar c:\yuicompressor-2...
15,798
<p>I need to validate an XML string (and not a file) against a DTD description file. </p> <p>How can that be done in <code>python</code>?</p>
[ { "answer_id": 15931, "author": "Michael Twomey", "author_id": 995, "author_profile": "https://Stackoverflow.com/users/995", "pm_score": 6, "selected": true, "text": "<p>Another good option is <a href=\"http://lxml.de/validation.html\" rel=\"noreferrer\">lxml's validation</a> which I fin...
2008/08/19
[ "https://Stackoverflow.com/questions/15798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446497/" ]
I need to validate an XML string (and not a file) against a DTD description file. How can that be done in `python`?
Another good option is [lxml's validation](http://lxml.de/validation.html) which I find quite pleasant to use. A simple example taken from the lxml site: ``` from StringIO import StringIO from lxml import etree dtd = etree.DTD(StringIO("""<!ELEMENT foo EMPTY>""")) root = etree.XML("<foo/>") print(dtd.validate(root)...
15,816
<p>I use VNC to connect to a Linux workstation at work. At work I have a 20" monitor that runs at 1600x1200, while at home I use my laptop with its resolution of 1440x900. If I set the vncserver to run at 1440x900 I miss out on a lot of space on my monitor, whereas if I set it to run at 1600x1200 it doesn't fit on the...
[ { "answer_id": 15824, "author": "BlaM", "author_id": 999, "author_profile": "https://Stackoverflow.com/users/999", "pm_score": 0, "selected": false, "text": "<p>As far as I know there's no way to change the client's resolution just using VNC, as it is just a \"monitor mirroring\" applica...
2008/08/19
[ "https://Stackoverflow.com/questions/15816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
I use VNC to connect to a Linux workstation at work. At work I have a 20" monitor that runs at 1600x1200, while at home I use my laptop with its resolution of 1440x900. If I set the vncserver to run at 1440x900 I miss out on a lot of space on my monitor, whereas if I set it to run at 1600x1200 it doesn't fit on the lap...
Real VNC server 4.4 includes support for Xrandr, which allows resizing the VNC. Start the server with: ``` vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768 ``` Then resize with: ``` xrandr -s 1600x1200 xrandr -s 1440x900 xrandr -s 1024x768 ```
15,828
<p>Is there a free or open source library to read Excel files (.xls) directly from a C# program? </p> <p>It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd l...
[ { "answer_id": 15835, "author": "Leon Bambrick", "author_id": 49, "author_profile": "https://Stackoverflow.com/users/49", "pm_score": 1, "selected": false, "text": "<p>you could write an excel spreadsheet that loads a given excel spreadsheet and saves it as csv (rather than doing it manu...
2008/08/19
[ "https://Stackoverflow.com/questions/15828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/838/" ]
Is there a free or open source library to read Excel files (.xls) directly from a C# program? It does not need to be too fancy, just to select a worksheet and read the data as strings. So far, I've been using Export to Unicode text function of Excel, and parsing the resulting (tab-delimited) file, but I'd like to eli...
``` var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirectory()); var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName); var adapter = new OleDbDataAdapter("SELECT * FROM [workSheetNameHere$]", connectionString); var ds...
15,838
<p>Can the performance of this sequential search algorithm (taken from <a href="http://books.google.co.uk/books?id=to6M9_dbjosC&amp;dq=the+practice+of+programming&amp;pg=PP1&amp;ots=3YH6Ggq0_a&amp;sig=F2-ajdO37xA4iRec2sCyQF55Jjc&amp;hl=en&amp;sa=X&amp;oi=book_result&amp;resnum=1&amp;ct=result" rel="noreferrer">The Pra...
[ { "answer_id": 15846, "author": "Grey Panther", "author_id": 1265, "author_profile": "https://Stackoverflow.com/users/1265", "pm_score": 6, "selected": true, "text": "<p>Yes, but only very slightly. A much bigger performance improvement can be achieved by using better algorithms (for exa...
2008/08/19
[ "https://Stackoverflow.com/questions/15838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/381/" ]
Can the performance of this sequential search algorithm (taken from [The Practice of Programming](http://books.google.co.uk/books?id=to6M9_dbjosC&dq=the+practice+of+programming&pg=PP1&ots=3YH6Ggq0_a&sig=F2-ajdO37xA4iRec2sCyQF55Jjc&hl=en&sa=X&oi=book_result&resnum=1&ct=result)) be improved using any of C's native utili...
Yes, but only very slightly. A much bigger performance improvement can be achieved by using better algorithms (for example keeping the list sorted and doing a binary search). In general optimizing a given algorithm only gets you so far. Choosing a better algorithm (even if it's not completely optimized) can give you a...
15,851
<p>After I was convinced that labeled breaks/continues are a total "nono" over <a href="https://stackoverflow.com/questions/15481/java-coding-standard-best-practices-labeled-brakecontinue#15501">here</a>, I need help to remove the label out of my code.</p> <p>I have a square matrix and a vector that has the same lengt...
[ { "answer_id": 15855, "author": "Patrick", "author_id": 429, "author_profile": "https://Stackoverflow.com/users/429", "pm_score": 1, "selected": false, "text": "<p>Easily, my good man.</p>\n\n<pre><code>for( int idx = 0; idx &lt; vectorLength; idx++) {\n if( conditionAtVectorPosition( v...
2008/08/19
[ "https://Stackoverflow.com/questions/15851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1870/" ]
After I was convinced that labeled breaks/continues are a total "nono" over [here](https://stackoverflow.com/questions/15481/java-coding-standard-best-practices-labeled-brakecontinue#15501), I need help to remove the label out of my code. I have a square matrix and a vector that has the same length. The vector has alr...
Looking at the solutions presented so far: * They all look less readable than the original, in that they involve spending more code on the mechanism of the code rather than on the algorithm itself * Some of them are broken, or were before they were edited. Most damning is the fact that people are having to think quite...
15,899
<p>I have a <code>XmlDocument</code> in java, created with the <code>Weblogic XmlDocument</code> parser.</p> <p>I want to replace the content of a tag in this <code>XMLDocument</code> with my own data, or insert the tag if it isn't there.</p> <pre><code>&lt;customdata&gt; &lt;tag1 /&gt; &lt;tag2&gt;mfkdslmlfkm&...
[ { "answer_id": 15961, "author": "alanl", "author_id": 1464, "author_profile": "https://Stackoverflow.com/users/1464", "pm_score": 0, "selected": false, "text": "<p>You should be able to do this with <code>query</code></p>\n\n<p>try </p>\n\n<pre><code> fn:replace(string,pattern,replace)\n...
2008/08/19
[ "https://Stackoverflow.com/questions/15899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/86/" ]
I have a `XmlDocument` in java, created with the `Weblogic XmlDocument` parser. I want to replace the content of a tag in this `XMLDocument` with my own data, or insert the tag if it isn't there. ``` <customdata> <tag1 /> <tag2>mfkdslmlfkm</tag2> <location /> <tag3 /> </customdata> ``` For example I wan...
How about an XPath based approach? I like this approach as the logic is super-easy to understand. The code is pretty much self-documenting. If your xml document is available to you as an org.w3c.dom.Document object (as most parsers return), then you could do something like the following: ``` // get the list of custom...
15,949
<p>I have a tomcat instance setup but the database connection I have configured in <code>context.xml</code> keeps dying after periods of inactivity.</p> <p>When I check the logs I get the following error:</p> <p>com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the s...
[ { "answer_id": 16168, "author": "ScArcher2", "author_id": 1310, "author_profile": "https://Stackoverflow.com/users/1310", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html\" rel=\"noreferrer\">Tomcat Documen...
2008/08/19
[ "https://Stackoverflow.com/questions/15949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22/" ]
I have a tomcat instance setup but the database connection I have configured in `context.xml` keeps dying after periods of inactivity. When I check the logs I get the following error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was68051 seconds ago....
[Tomcat Documentation](http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html) DBCP uses the Jakarta-Commons Database Connection Pool. It relies on number of Jakarta-Commons components: ``` * Jakarta-Commons DBCP * Jakarta-Commons Collections * Jakarta-Commons Pool ``` This attribute may help y...
15,954
<p>How can a <code>sdbm</code> hash function (such as <a href="http://www.cse.yorku.ca/~oz/hash.html" rel="nofollow noreferrer">this</a>) be implemented in C# ?</p>
[ { "answer_id": 15971, "author": "Timbo", "author_id": 1810, "author_profile": "https://Stackoverflow.com/users/1810", "pm_score": 2, "selected": false, "text": "<p>You can take the C code almost without changes:</p>\n\n<pre><code>uint sdbm( string str )\n{\n uint hash = 0;\n foreac...
2008/08/19
[ "https://Stackoverflow.com/questions/15954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1658/" ]
How can a `sdbm` hash function (such as [this](http://www.cse.yorku.ca/~oz/hash.html)) be implemented in C# ?
You can take the C code almost without changes: ``` uint sdbm( string str ) { uint hash = 0; foreach( char ch in str ) { hash = ch + (hash << 6) + (hash << 16) - hash; } return hash; } ``` Or did you think of something more sophisticated?
15,979
<p>I use solr to search for documents and when trying to search for documents using this query "<code>id:*</code>", I get this query parser exception telling that it cannot parse the query with * or ? as the first character. </p> <pre><code>HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse '...
[ { "answer_id": 16661, "author": "Ryan Ahearn", "author_id": 75, "author_profile": "https://Stackoverflow.com/users/75", "pm_score": 1, "selected": false, "text": "<p>I'm assuming with id:* you're just trying to match all documents, right?</p>\n\n<p>I've never used solr before, but in my ...
2008/08/19
[ "https://Stackoverflow.com/questions/15979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448/" ]
I use solr to search for documents and when trying to search for documents using this query "`id:*`", I get this query parser exception telling that it cannot parse the query with \* or ? as the first character. ``` HTTP Status 400 - org.apache.lucene.queryParser.ParseException: Cannot parse 'id:*': '*' or '?' not al...
If you want all documents, do a query on \*:\* If you want all documents with a certain field (e.g. id) try id:[\* TO \*]
15,995
<p>Does anyone here have any useful code which uses reduce() function in python? Is there any code other than the usual + and * that we see in the examples?</p> <p>Refer <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=98196" rel="noreferrer">Fate of reduce() in Python 3000</a> by GvR</p>
[ { "answer_id": 16049, "author": "Brendan", "author_id": 199, "author_profile": "https://Stackoverflow.com/users/199", "pm_score": 2, "selected": false, "text": "<p>Not sure if this is what you are after but you can <a href=\"http://www.google.com/codesearch\" rel=\"nofollow noreferrer\">...
2008/08/19
[ "https://Stackoverflow.com/questions/15995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1448/" ]
Does anyone here have any useful code which uses reduce() function in python? Is there any code other than the usual + and \* that we see in the examples? Refer [Fate of reduce() in Python 3000](http://www.artima.com/weblogs/viewpost.jsp?thread=98196) by GvR
The other uses I've found for it besides + and \* were with and and or, but now we have `any` and `all` to replace those cases. `foldl` and `foldr` do come up in Scheme a lot... Here's some cute usages: **Flatten a list** Goal: turn `[[1, 2, 3], [4, 5], [6, 7, 8]]` into `[1, 2, 3, 4, 5, 6, 7, 8]`. ``` reduce(lis...
16,007
<p>Basically I have some code to check a specific directory to see if an image is there and if so I want to assign a URL to the image to an ImageControl.</p> <pre><code>if (System.IO.Directory.Exists(photosLocation)) { string[] files = System.IO.Directory.GetFiles(photosLocation, "*.jpg"); if (files.Length &gt...
[ { "answer_id": 16031, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>So far as I know there's no single function which does this (maybe you were looking for the inverse of <a href=\"http://msdn...
2008/08/19
[ "https://Stackoverflow.com/questions/16007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1762/" ]
Basically I have some code to check a specific directory to see if an image is there and if so I want to assign a URL to the image to an ImageControl. ``` if (System.IO.Directory.Exists(photosLocation)) { string[] files = System.IO.Directory.GetFiles(photosLocation, "*.jpg"); if (files.Length > 0) { ...
As far as I know, there's no method to do what you want; at least not directly. I'd store the `photosLocation` as a path relative to the application; for example: `"~/Images/"`. This way, you could use MapPath to get the physical location, and `ResolveUrl` to get the URL (with a bit of help from `System.IO.Path`): ```...
16,096
<p>In WPF, how would I apply multiple styles to a <code>FrameworkElement</code>? For instance, I have a control which already has a style. I also have a separate style which I would like to add to it without blowing away the first one. The styles have different TargetTypes, so I can't just extend one with the other....
[ { "answer_id": 16108, "author": "Arcturus", "author_id": 900, "author_profile": "https://Stackoverflow.com/users/900", "pm_score": 5, "selected": false, "text": "<p>But you can extend from another.. take a look at the BasedOn property</p>\n\n<pre><code>&lt;Style TargetType=\"TextBlock\"&...
2008/08/19
[ "https://Stackoverflow.com/questions/16096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/93/" ]
In WPF, how would I apply multiple styles to a `FrameworkElement`? For instance, I have a control which already has a style. I also have a separate style which I would like to add to it without blowing away the first one. The styles have different TargetTypes, so I can't just extend one with the other.
**I think the simple answer is that you can't do (at least in this version of WPF) what you are trying to do.** *That is, for any particular element only one Style can be applied.* However, as others have stated above, maybe you can use `BasedOn` to help you out. Check out the following piece of loose xaml. In it you...
16,100
<p>What's the best way to convert a string to an enumeration value in C#?</p> <p>I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the corresponding enumeration value.</p> <p>In an ideal world...
[ { "answer_id": 16103, "author": "DavidWhitney", "author_id": 1297, "author_profile": "https://Stackoverflow.com/users/1297", "pm_score": 7, "selected": false, "text": "<p>You're looking for <a href=\"https://msdn.microsoft.com/en-us/library/aa328348.aspx\" rel=\"noreferrer\">Enum.Parse</...
2008/08/19
[ "https://Stackoverflow.com/questions/16100", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203/" ]
What's the best way to convert a string to an enumeration value in C#? I have an HTML select tag containing the values of an enumeration. When the page is posted, I want to pick up the value (which will be in the form of a string) and convert it to the corresponding enumeration value. In an ideal world, I could do so...
In .NET Core and .NET Framework ≥4.0 [there is a generic parse method](https://msdn.microsoft.com/en-us/library/dd783499%28v=vs.110%29.aspx): ``` Enum.TryParse("Active", out StatusEnum myStatus); ``` This also includes C#7's new inline `out` variables, so this does the try-parse, conversion to the explicit enum type...
16,110
<p>I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents. </p> <p>The contents need to be handle when enter is pushed. That part I think I have figured out but any suggestions would be welcome. </p> <p>Th...
[ { "answer_id": 16119, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 1, "selected": false, "text": "<p>OK, are you sure that is wise? I am picturing two scenarios here:</p>\n\n<ol>\n<li>There is a default button on the form,...
2008/08/19
[ "https://Stackoverflow.com/questions/16110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1629/" ]
I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents. The contents need to be handle when enter is pushed. That part I think I have figured out but any suggestions would be welcome. The part I need help ...
Hook into the KeyPress event on the TextBox, and when it encounters the Enter key, run your hardware setting code, and then highlight the full text of the textbox again (see below) - Windows will take care of clearing the text with the next keystroke for you. ``` TextBox1.Select(0, TextBox1.Text.Length); ```
16,155
<p><strong>Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface?</strong></p> <p>The Example:</p> <p>I'm probably doing something wrong, but here is what I have:</p> <pre><code>interface iVendor{ public function __construct($vendors_no = null); public...
[ { "answer_id": 16245, "author": "Ryan Ahearn", "author_id": 75, "author_profile": "https://Stackoverflow.com/users/75", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://stackoverflow.com/questions/16155/making-one-interface-overwrite-a-method-it-inherits-from-another-interf...
2008/08/19
[ "https://Stackoverflow.com/questions/16155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58/" ]
**Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface?** The Example: I'm probably doing something wrong, but here is what I have: ``` interface iVendor{ public function __construct($vendors_no = null); public function getName(); public function ...
[@cmcculloh](https://stackoverflow.com/questions/16155/making-one-interface-overwrite-a-method-it-inherits-from-another-interface-in-p#16196) Yeah, in Java you don't define constructors in Interfaces. This allows you to both extend interfaces and also have a class that implements multiple interfaces (both allowed, and ...