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 |
|---|---|---|---|---|---|---|
98,224 | <p>After downloading files from a remote UNIX FTP server, you want to verify that you have downloaded all the files correctly. Minimal you will get information similar to "dir /s" command in Windows command prompt. The FTP client runs on Windows.</p>
| [
{
"answer_id": 98234,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 6,
"selected": true,
"text": "<p>Sadly this was written for Unix/Linux users :/</p>\n\n<p>Personally, I would install CYGWIN just to get Linux binari... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13584/"
] | After downloading files from a remote UNIX FTP server, you want to verify that you have downloaded all the files correctly. Minimal you will get information similar to "dir /s" command in Windows command prompt. The FTP client runs on Windows. | Sadly this was written for Unix/Linux users :/
Personally, I would install CYGWIN just to get Linux binaries of LFTP/RSYNC to work on windows, as there appears not to be anything that competes with it.
As @zadok.myopenid.com
mentioned rsync, this appears to be a windows build for it using CYGWIN ( if you manage to ... |
98,242 | <blockquote>
<p><strong>Possible Duplicate:</strong><br />
<a href="https://stackoverflow.com/questions/6457130/pre-post-increment-operator-behavior-in-c-c-java-c-sharp">Pre & post increment operator behavior in C, C++, Java, & C#</a></p>
</blockquote>
<p>Here is a test case:</p>
<pre><code>
void foo(int i, in... | [
{
"answer_id": 98256,
"author": "Benoit",
"author_id": 10703,
"author_profile": "https://Stackoverflow.com/users/10703",
"pm_score": 7,
"selected": true,
"text": "<p>This is an example of unspecified behavior. The standard does <strong>not</strong> say what order arguments should be eva... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | >
> **Possible Duplicate:**
>
> [Pre & post increment operator behavior in C, C++, Java, & C#](https://stackoverflow.com/questions/6457130/pre-post-increment-operator-behavior-in-c-c-java-c-sharp)
>
>
>
Here is a test case:
```
void foo(int i, int j)
{
printf("%d %d", i, j);
}
...
test = 0;
foo(test++, tes... | This is an example of unspecified behavior. The standard does **not** say what order arguments should be evaluated in. This is a compiler implementation decision. The compiler is free to evaluate the arguments to the function in any order.
In this case, it looks like actually processes the arguments right to left ins... |
98,274 | <p>Is it possible to integrate SSRS reports to the webforms..an example will be enough to keep me moving. </p>
| [
{
"answer_id": 98312,
"author": "user10635",
"author_id": 10635,
"author_profile": "https://Stackoverflow.com/users/10635",
"pm_score": 0,
"selected": false,
"text": "<p>this is a knowledge base article which describes how to render report output to an aspx page in a particular file form... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] | Is it possible to integrate SSRS reports to the webforms..an example will be enough to keep me moving. | Absolutely it is.
What you are looking for is the ReportViewer control, located in the Microsoft.Reporting.WebForms assembly. It will allow you to place a control right on your web form that will give people an interface for setting report parameters and getting the report.
Alternatively you can set all the parameter... |
98,320 | <p>My model layer is being used by a handful of different projects and I'd like to use a single XML Spring Configuration file for the model regardless of which project is using it.</p>
<p>My question is: Since not all beans are used in all projects am I wasting resources to any significant amount if there not being in... | [
{
"answer_id": 98456,
"author": "Dónal",
"author_id": 2648,
"author_profile": "https://Stackoverflow.com/users/2648",
"pm_score": 0,
"selected": false,
"text": "<p>By default Spring beans are singletons and are instantiated when the application context is created (at startup). So assumin... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | My model layer is being used by a handful of different projects and I'd like to use a single XML Spring Configuration file for the model regardless of which project is using it.
My question is: Since not all beans are used in all projects am I wasting resources to any significant amount if there not being instantiated... | Taken from the [Spring Reference Manual](http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-lazy-init):
>
> The default behavior for ApplicationContext implementations is to eagerly pre-instantiate all singleton beans at startup. Pre-instantiation means that an ApplicationContext w... |
98,340 | <p>An example of unspecified behavior in the C language is the order of evaluation of arguments to a function. It might be left to right or right to left, you just don't know. This would affect how <code>foo(c++, c)</code> or <code>foo(++c, c)</code> gets evaluated.</p>
<p>What other unspecified behavior is there tha... | [
{
"answer_id": 98351,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 1,
"selected": false,
"text": "<p>Be sure to always initialize your variables before you use them! When I had just started with C, that caused me a... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | An example of unspecified behavior in the C language is the order of evaluation of arguments to a function. It might be left to right or right to left, you just don't know. This would affect how `foo(c++, c)` or `foo(++c, c)` gets evaluated.
What other unspecified behavior is there that can surprise the unaware progra... | A language lawyer question. Hmkay.
My personal top3:
1. violating the strict aliasing rule
2. violating the strict aliasing rule
3. violating the strict aliasing rule
:-)
**Edit** Here is a little example that does it wrong twice:
(assume 32 bit ints and little endian)
```
float funky_float_abs (float a)
{
unsi... |
98,376 | <p>I need to store some simple properties in a file and access them from Ruby.</p>
<p>I absolutely love the .properties file format that is the standard for such things in Java (using the java.util.Properties class)... it is simple, easy to use and easy to read.</p>
<p>So, is there a Ruby class somewhere that will le... | [
{
"answer_id": 98415,
"author": "Ryan Bigg",
"author_id": 15245,
"author_profile": "https://Stackoverflow.com/users/15245",
"pm_score": 6,
"selected": true,
"text": "<p>Is this for a Rails application or a Ruby one?</p>\n\n<p>Really with either you may be able to stick your properties in... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I need to store some simple properties in a file and access them from Ruby.
I absolutely love the .properties file format that is the standard for such things in Java (using the java.util.Properties class)... it is simple, easy to use and easy to read.
So, is there a Ruby class somewhere that will let me load up some... | Is this for a Rails application or a Ruby one?
Really with either you may be able to stick your properties in a yaml file and then `YAML::Load(File.open("file"))` it.
---
**NOTE from Mike Stone:** It would actually be better to do:
```
File.open("file") { |yf| YAML::load(yf) }
```
or
```
YAML.load_file("file")
... |
98,394 | <p>I looked for the name of a procedure, which applies a tree structure of procedures to a tree structure of data, yielding a tree structure of results - all three trees having the same structure. </p>
<p>Such a procedure might have the signature: </p>
<pre>(map-tree data functree)</pre>
<p>Its return value woul... | [
{
"answer_id": 98520,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "<p>I don't have a very good name for the function. I'm pasting my implementation below (I've called it <code>map-traversing</c... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11886/"
] | I looked for the name of a procedure, which applies a tree structure of procedures to a tree structure of data, yielding a tree structure of results - all three trees having the same structure.
Such a procedure might have the signature:
```
(map-tree data functree)
```
Its return value would be the result of eleme... | I don't have a very good name for the function. I'm pasting my implementation below (I've called it `map-traversing`; others should suggest a better name). I've made the argument order mirror that of `map` itself.
```
(define (map-traversing func data)
(if (list? func)
(map map-traversing func data)
(fun... |
98,479 | <p>What is the maximum value of an int in ChucK? Is there a symbolic constant for it?</p>
| [
{
"answer_id": 98500,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://chuck.cs.princeton.edu/doc/program/stdlib.html\" rel=\"nofollow noreferrer\">The ChucK API referenc... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] | What is the maximum value of an int in ChucK? Is there a symbolic constant for it? | New in the latest version!
```
<<<Math.INT_MAX>>>;
```
For reference though, it uses the "`long`" keyword in C++ to represent integers.
So on 32-bit computers the max should be `0x7FFFFFFF`, or `2147483647`.
On 64-bit computers it will be `0x7FFFFFFFFFFFFFFFFF`, or `9223372036854775807`.
Answer from Kassen and Step... |
98,497 | <p>Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:</p>
<pre><code>function generateAccNo()
generate an account number between 100,000,000 and 999,999,999
if the account number already exists in the DB
call generateAccNo() /* recursive call */
else
return n... | [
{
"answer_id": 98502,
"author": "Esteban Araya",
"author_id": 781,
"author_profile": "https://Stackoverflow.com/users/781",
"pm_score": 4,
"selected": true,
"text": "<p>You realize this could very well cause a stack overflow, right? As the number of customesr increases, the probability o... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:
```
function generateAccNo()
generate an account number between 100,000,000 and 999,999,999
if the account number already exists in the DB
call generateAccNo() /* recursive call */
else
return new accout numb... | You realize this could very well cause a stack overflow, right? As the number of customesr increases, the probability of not finding a an acceptable account number increases.
Also, why can't you just do sequential account numbers and just increase by one every time? With this approach, you'd just have to read the max... |
98,559 | <pre><code>uint color;
bool parsedhex = uint.TryParse(TextBox1.Text, out color);
//where Text is of the form 0xFF0000
if(parsedhex)
//...
</code></pre>
<p>doesn't work. What am i doing wrong?</p>
| [
{
"answer_id": 98572,
"author": "Nescio",
"author_id": 14484,
"author_profile": "https://Stackoverflow.com/users/14484",
"pm_score": 8,
"selected": true,
"text": "<p>Try </p>\n\n<pre><code>Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment\n</code></pre>\n"
},
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1748529/"
] | ```
uint color;
bool parsedhex = uint.TryParse(TextBox1.Text, out color);
//where Text is of the form 0xFF0000
if(parsedhex)
//...
```
doesn't work. What am i doing wrong? | Try
```
Convert.ToUInt32(hex, 16) //Using ToUInt32 not ToUInt64, as per OP comment
``` |
98,597 | <p>I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).</p>
<p>So, does anyone have any good AHK ma... | [
{
"answer_id": 98926,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 2,
"selected": false,
"text": "<p>There are tons of good ones in the AutoHotKey Forum:</p>\n\n<p><a href=\"http://www.autohotkey.com/forum/forum-2.html&am... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10934/"
] | I use AutoHotKey for Windows macros. Most commonly I use it to define hotkeys that start/focus particular apps, and one to send an instant email message into my ToDo list. I also have an emergency one that kills all of my big memory-hogging apps (Outlook, Firefox, etc).
So, does anyone have any good AHK macros to shar... | Very simple and useful snippet:
```
SetTitleMatchMode RegEx ;
; Stuff to do when Windows Explorer is open
;
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; create new folder
;
^!n::Send !fwf
; create new text file
;
^!t::Send !fwt
; open 'cmd' in the current directory
;
^!c::... |
98,610 | <p>By default, Eclipse won't show my .htaccess file that I maintain in my project. It just shows an empty folder in the Package Viewer tree. How can I get it to show up? No obvious preferences.</p>
| [
{
"answer_id": 98625,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 3,
"selected": false,
"text": "<p>In your package explorer, pull down the menu and select \"Filters ...\". You can adjust what types of files are sho... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4223/"
] | By default, Eclipse won't show my .htaccess file that I maintain in my project. It just shows an empty folder in the Package Viewer tree. How can I get it to show up? No obvious preferences. | In the package explorer, in the upper right corner of the view, there is a little down arrow. Tool tip will say view menu. From that menu, select filters

From there, uncheck .\* resources.
So `Package Explorer -> View Menu -> Filters -> uncheck .* resources`.
Wit... |
98,622 | <p>In VisualStudio (Pro 2008), I have just noticed some inconsistent behaviour and wondered if there was any logical reasoning behind it</p>
<p>In a WinForms project, if I use the line</p>
<pre><code>if(myComboBox.Items[i] == myObject)
</code></pre>
<p>I get a compiler warning that I might get 'Possible unintended r... | [
{
"answer_id": 98708,
"author": "Jason Stevenson",
"author_id": 13368,
"author_profile": "https://Stackoverflow.com/users/13368",
"pm_score": 0,
"selected": false,
"text": "<p>Lagerdalek,</p>\n\n<p>The warning is generated because you need to cast the item from the Items collection back ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | In VisualStudio (Pro 2008), I have just noticed some inconsistent behaviour and wondered if there was any logical reasoning behind it
In a WinForms project, if I use the line
```
if(myComboBox.Items[i] == myObject)
```
I get a compiler warning that I might get 'Possible unintended references' as I am comparing type... | The compile warning for the first sample is because any custom == operator for your class would be ignored and the references compared (maybe not what you intended, hence the warning).
It's not possible to specify that an operator should be overridden on an interface, so this will *always* be a reference comparison. T... |
98,650 | <p>When asking about <a href="https://stackoverflow.com/questions/98340/what-are-the-common-undefinedunspecified-behavior-for-c-that-you-run-into">common undefined behavior in C</a>, people sometimes refer to the strict aliasing rule.<br>
What are they talking about?</p>
| [
{
"answer_id": 98666,
"author": "Jason Dagit",
"author_id": 5113,
"author_profile": "https://Stackoverflow.com/users/5113",
"pm_score": 4,
"selected": false,
"text": "<p>Strict aliasing is not allowing different pointer types to the same data.</p>\n\n<p><a href=\"http://cellperformance.b... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | When asking about [common undefined behavior in C](https://stackoverflow.com/questions/98340/what-are-the-common-undefinedunspecified-behavior-for-c-that-you-run-into), people sometimes refer to the strict aliasing rule.
What are they talking about? | A typical situation where you encounter strict aliasing problems is when overlaying a struct (like a device/network msg) onto a buffer of the word size of your system (like a pointer to `uint32_t`s or `uint16_t`s). When you overlay a struct onto such a buffer, or a buffer onto such a struct through pointer casting you ... |
98,705 | <p>I understand that the function is not allowed to change the state of the object, but I thought I read somewhere that the compiler was allowed to assume that if the function was called with the same arguments, it would return the same value and thus could reuse a cached value if it was available. e.g.</p>
<pre><code... | [
{
"answer_id": 98733,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 0,
"selected": false,
"text": "<p>I doubt it, the function could still call a global function that altered the state of the world and not violate c... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] | I understand that the function is not allowed to change the state of the object, but I thought I read somewhere that the compiler was allowed to assume that if the function was called with the same arguments, it would return the same value and thus could reuse a cached value if it was available. e.g.
```
class object
... | `const` is about program semantics and not about implementation details. You should mark a member function `const` when it does not change the visible state of the object, and should be callable on an object that is itself `const`. Within a `const` member function on a class `X`, the type of `this` is `X const *`: poin... |
98,774 | <p>I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this.</p>
<pre><code>//... | [
{
"answer_id": 98822,
"author": "Mark",
"author_id": 4405,
"author_profile": "https://Stackoverflow.com/users/4405",
"pm_score": 3,
"selected": false,
"text": "<p>If you have to create the file, I think that you can probably do something like this:</p>\n\n<pre><code>using (FileStream out... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this.
```
// Quick, and ve... | [FileStream.SetLength](http://msdn.microsoft.com/en-us/library/system.io.filestream.setlength) is the one you want. The syntax:
```
public override void SetLength(
long value
)
``` |
98,778 | <p>I need to execute a batch file as part of the un-install process in a Windows installer project (standard OOTB VS 2008 installer project-vdproj). One cannot execute a bat file directly from the Custom Actions in the installer project, so I wrote a quick vbs script to call the required bat file.<br>
vbs code: </p>
... | [
{
"answer_id": 98839,
"author": "Mike L",
"author_id": 12085,
"author_profile": "https://Stackoverflow.com/users/12085",
"pm_score": 0,
"selected": false,
"text": "<p>In your installer class, are you overriding the Uninstall method: </p>\n\n<pre><code> Public Overrides Sub Uninstall(ByVa... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18449/"
] | I need to execute a batch file as part of the un-install process in a Windows installer project (standard OOTB VS 2008 installer project-vdproj). One cannot execute a bat file directly from the Custom Actions in the installer project, so I wrote a quick vbs script to call the required bat file.
vbs code:
```
Set W... | I've run into this same problem and the issue is that you can't call WScript within the vbs file - you will need to JUST call CreateObject
ie.
```
Set WshShell = CreateObject( "WScript.Shell" )
command = "uninstall-windows-serivce.bat"
msgbox command
WshShell.Run ("cmd /C " & """" & command & """")
Set WshShell = Not... |
98,827 | <p>I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET
something like </p>
<pre><code>String^ speed;
String^ size;
</code></pre>
<p>"command SPEED=[speed] SIZE=[size]"</p>
<p>Right now I'm using IndexOf() and Substring() but it is quite ugly</p>
| [
{
"answer_id": 98946,
"author": "user10392",
"author_id": 10392,
"author_profile": "https://Stackoverflow.com/users/10392",
"pm_score": 0,
"selected": false,
"text": "<p>If you put all the variables in a class, you can use reflection to iterate over its fields, getting their names and va... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | I'm looking for a method to assign variables with patterns in regular expressions with C++ .NET
something like
```
String^ speed;
String^ size;
```
"command SPEED=[speed] SIZE=[size]"
Right now I'm using IndexOf() and Substring() but it is quite ugly | ```
String^ speed; String^ size;
Match m;
Regex theregex = new Regex (
"SPEED=(?<speed>(.*?)) SIZE=(?<size>(.*?)) ",
RegexOptions::ExplicitCapture);
m = theregex.Match (yourinputstring);
if (m.Success)
{
if (m.Groups["speed"].Success)
speed = m.Groups["speed"].Value;
if (m.Groups["size"].Success)
size =... |
98,895 | <p>I'm having problems refreshing .Net 2.0 with IIS 6.</p>
<p>I have been able to successfully execute "aspnet_regiis.exe -i", but when I try to register the aspnet_isapi.dll:</p>
<pre><code>regsvr32 “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
</code></pre>
<p>I get the error</p>
<bl... | [
{
"answer_id": 98907,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 0,
"selected": false,
"text": "<p>When you get the error, it means either:</p>\n\n<p>1 The DLL does not need to be registered</p>\n\n<p>or</p>\n\n<p>2 T... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10717/"
] | I'm having problems refreshing .Net 2.0 with IIS 6.
I have been able to successfully execute "aspnet\_regiis.exe -i", but when I try to register the aspnet\_isapi.dll:
```
regsvr32 “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"
```
I get the error
>
> C:\Windows..\aspnet\_isapi.dll was loaded, b... | In the end, I think the problem was caused by a step that is missed by the script when you refresh ASP.Net 2.0 with IIS 6.
I managed to resolve this using the following steps:
* Refresh the install using `C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -s /w3svc/1/root`
* Enable ASP.Net Web Service Extens... |
98,941 | <p>How to add a click event listener to my custom control made with wxWidgets? The custom control uses wxWindow as the base. On the event list I see </p>
<pre><code>wxEVT_LEFT_DOWN
wxEVT_LEFT_UP
wxEVT_LEFT_DCLICK
wxEVT_MIDDLE_DOWN
wxEVT_MIDDLE_UP
wxEVT_MIDDLE_DCLICK
wxEVT_RIGHT_DOWN
wxEVT_RIGHT_UP
wxEVT_RIGHT_DCLI... | [
{
"answer_id": 99659,
"author": "Zach Burlingame",
"author_id": 2233,
"author_profile": "https://Stackoverflow.com/users/2233",
"pm_score": 3,
"selected": true,
"text": "<p>Typically, there is no \"click\" event (and in the case of <a href=\"http://www.wxwidgets.org/\" rel=\"nofollow nor... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11238/"
] | How to add a click event listener to my custom control made with wxWidgets? The custom control uses wxWindow as the base. On the event list I see
```
wxEVT_LEFT_DOWN
wxEVT_LEFT_UP
wxEVT_LEFT_DCLICK
wxEVT_MIDDLE_DOWN
wxEVT_MIDDLE_UP
wxEVT_MIDDLE_DCLICK
wxEVT_RIGHT_DOWN
wxEVT_RIGHT_UP
wxEVT_RIGHT_DCLICK
wxEVT_MOTIO... | Typically, there is no "click" event (and in the case of [wxWidgets](http://www.wxwidgets.org/) - [there isn't](http://docs.wxwidgets.org/stable/wx_wxmouseevent.html#wxmouseevent)
). The action of clicking is broken into its two parts: Mouse Down and Mouse Up. Typically what you think of as a "left click" event is actu... |
98,944 | <p>How do I write a cpp macro which expands to include newlines?</p>
| [
{
"answer_id": 98956,
"author": "Branan",
"author_id": 13894,
"author_profile": "https://Stackoverflow.com/users/13894",
"pm_score": -1,
"selected": false,
"text": "<p>Use <code>\\</code>, like so:</p>\n\n<pre><code>#define my_multiline_macro(a, b, c) \\\nif (a) { \\\n b += c; \\\n}\n... | 2008/09/19 | [
"https://Stackoverflow.com/questions/98944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18458/"
] | How do I write a cpp macro which expands to include newlines? | I am working on a large project that involves a lot of preprocessor macro functions to synthesize any code that cannot be replaced by templates. Believe me, I am familiar with all sorts of template tricks, but as long as there is no standardized, type safe metaprogramming language that can directly create code, we will... |
99,045 | <p>We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.</p>
<p>Currently we use the commands in the test:</p>
<pre><code>// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.... | [
{
"answer_id": 99127,
"author": "Josh",
"author_id": 11702,
"author_profile": "https://Stackoverflow.com/users/11702",
"pm_score": 1,
"selected": false,
"text": "<p>If you are running in *iehta mode then you are going to run into some glitches here and there. We run Selenium at my job an... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] | We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.
Currently we use the commands in the test:
```
// force new window to open at this point - so we can select it later
selenium().getEval("this.browserbot.getCurrentWindow().op... | It works!! Just to make it easier for the folks who prefer selenese.
This worked for me using IE7(normal mode).
What a freaking hassle. Thank the spaghetti monster in the sky for SO or there is no way I would have got this working in IE.
```
<tr>
<td>getEval</td>
<td>selenium.browserbot.getCurrentWindow().o... |
99,074 | <p>Would it be useful to be able to provide method return value for null objects?</p>
<p>For a List the null return values might be:</p>
<pre><code>get(int) : null
size() : 0
iterator() : empty iterator
</code></pre>
<p>That would allow the following code that has less null checks.</p>
<pre><code>List items = null;... | [
{
"answer_id": 99112,
"author": "Tim Williscroft",
"author_id": 2789,
"author_profile": "https://Stackoverflow.com/users/2789",
"pm_score": 0,
"selected": false,
"text": "<p><strong>This is a good idea.</strong></p>\n\n<p>Smalltalk does this.</p>\n\n<p>There is a NULL object. It <em>doe... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | Would it be useful to be able to provide method return value for null objects?
For a List the null return values might be:
```
get(int) : null
size() : 0
iterator() : empty iterator
```
That would allow the following code that has less null checks.
```
List items = null;
if(something) {
items = ...
}
for(int... | It's a pattern called Null Object
<http://en.wikipedia.org/wiki/Null_Object_pattern> |
99,098 | <p>What is the best way to generate a current datestamp in Java? </p>
<p>YYYY-MM-DD:hh-mm-ss</p>
| [
{
"answer_id": 99105,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "<pre><code>Date d = new Date();\nString formatted = new SimpleDateFormat (\"yyyy-MM-dd:HH-mm-ss\").format (d);\nSystem.... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3020/"
] | What is the best way to generate a current datestamp in Java?
YYYY-MM-DD:hh-mm-ss | Using the standard JDK, you will want to use java.text.SimpleDateFormat
```
Date myDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd:HH-mm-ss");
String myDateString = sdf.format(myDate);
```
However, if you have the option to use the Apache Commons Lang package, you can use org.apache.common... |
99,118 | <p>Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of list.get(0) would automatically be casted to the type of the variable hi.</p>
<pre><code>List list = new ArrayList();
list.add("hi");
String hi = list.get(0);
</code></pre>
<p>I know tha... | [
{
"answer_id": 99135,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 3,
"selected": false,
"text": "<p>Casting is an explicit instruction to the Java compiler to ignore type safety so allowing automatic casts would remo... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of list.get(0) would automatically be casted to the type of the variable hi.
```
List list = new ArrayList();
list.add("hi");
String hi = list.get(0);
```
I know that generics allow you to re... | Casting is an explicit instruction to the Java compiler to ignore type safety so allowing automatic casts would remove one of the features purposely designed into the language.
I personally like compiler warnings and errors, since it's much harder to find this type of problem at run time (assuming the compiler somehow... |
99,132 | <p>I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it.</p>
<p>I mainly use mingw/msys but would like something that works across other shells/systems too.</p>
<p>I tried this but it didn't work, any ideas?</p... | [
{
"answer_id": 99156,
"author": "andrewdotnich",
"author_id": 10569,
"author_profile": "https://Stackoverflow.com/users/10569",
"pm_score": 4,
"selected": false,
"text": "<p>If having the directory already exist is not a problem for you, you could just redirect stderr for that command, g... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] | I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it.
I mainly use mingw/msys but would like something that works across other shells/systems too.
I tried this but it didn't work, any ideas?
```
ifeq (,$(findst... | On UNIX Just use this:
```
mkdir -p $(OBJDIR)
```
The -p option to mkdir prevents the error message if the directory exists. |
99,161 | <p>I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.</p>
<p>Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.</p>
<p>Can't I j... | [
{
"answer_id": 99182,
"author": "Lee H",
"author_id": 18201,
"author_profile": "https://Stackoverflow.com/users/18201",
"pm_score": 9,
"selected": false,
"text": "<p><code>:noh</code> (short for <code>nohighlight</code>) will temporarily clear the search highlight. The next search will s... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18446/"
] | I search for "nurple" in a file. I found it, great. But now, every occurrence of "nurple" is rendered in sick black on yellow. Forever.
Forever, that is, until I search for something I know won't be found, such as "asdhfalsdflajdflakjdf" simply so it clears the previous search highlighting.
Can't I just hit a magic k... | Just put this in your .vimrc
```
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
``` |
99,164 | <p>I often see code like:</p>
<pre><code>Iterator i = list.iterator();
while(i.hasNext()) {
...
}
</code></pre>
<p>but I write that (when Java 1.5 isn't available or for each can't be used) as:</p>
<pre><code>for(Iterator i = list.iterator(); i.hasNext(); ) {
...
}
</code></pre>
<p>because</p>
<ul>
<li>It ... | [
{
"answer_id": 99177,
"author": "scubabbl",
"author_id": 9450,
"author_profile": "https://Stackoverflow.com/users/9450",
"pm_score": 0,
"selected": false,
"text": "<p>Either is fine. I use for () myself, and I don't know if there are compile issues. I suspect they both get optimized down... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | I often see code like:
```
Iterator i = list.iterator();
while(i.hasNext()) {
...
}
```
but I write that (when Java 1.5 isn't available or for each can't be used) as:
```
for(Iterator i = list.iterator(); i.hasNext(); ) {
...
}
```
because
* It is shorter
* It keeps `i` in a smaller scope
* It reduces th... | I prefer the for loop because it also sets the scope of the iterator to just the for loop. |
99,211 | <p>I am trying to get Haml to work with my Ruby on Rails project. I am new to Ruby on Rails and I really like it. However, when I attempt to add an <code>aplication.html.haml</code> or <code>index.html.haml</code> for a view, I just receive errors.</p>
<p>I am using NetBeans as my IDE.</p>
| [
{
"answer_id": 105542,
"author": "Ryan McGeary",
"author_id": 8985,
"author_profile": "https://Stackoverflow.com/users/8985",
"pm_score": 5,
"selected": false,
"text": "<p>First, <strong>install haml</strong> as a gem in bundler by adding this to your <code>Gemfile</code>:</p>\n\n<pre><c... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to get Haml to work with my Ruby on Rails project. I am new to Ruby on Rails and I really like it. However, when I attempt to add an `aplication.html.haml` or `index.html.haml` for a view, I just receive errors.
I am using NetBeans as my IDE. | Haml with Rails 3
-----------------
For Rails 3 all you need to do is add `gem "haml", '3.0.25'` to your `Gemfile`. No need to install plugin or run `haml --rails .`.
Just:
```
$ cd awesome-rails-3-app.git
$ echo 'gem "haml"' >> Gemfile
```
And you're done. |
99,279 | <p>I want to parse a web page in Groovy and extract all of the href links and the associated text with it.</p>
<p>If the page contained these links:</p>
<pre><code><a href="http://www.google.com">Google</a><br />
<a href="http://www.apple.com">Apple</a>
</code></pre>
<p>the output would... | [
{
"answer_id": 99293,
"author": "William Keller",
"author_id": 17095,
"author_profile": "https://Stackoverflow.com/users/17095",
"pm_score": 2,
"selected": false,
"text": "<p>A quick google search turned up a nice looking possibility, <a href=\"http://blog.foosion.org/2008/06/09/parse-ht... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to parse a web page in Groovy and extract all of the href links and the associated text with it.
If the page contained these links:
```
<a href="http://www.google.com">Google</a><br />
<a href="http://www.apple.com">Apple</a>
```
the output would be:
```
Google, http://www.google.com<br />
Apple, http://www... | Assuming well-formed XHTML, slurp the xml, collect up all the tags, find the 'a' tags, and print out the href and text.
```
input = """<html><body>
<a href = "http://www.hjsoft.com/">John</a>
<a href = "http://www.google.com/">Google</a>
<a href = "http://www.stackoverflow.com/">StackOverflow</a>
</body></html>"""
do... |
99,285 | <p>Would it be useful to be able to mark objects where the value ofString.valueOf() would included in any stack trace. In my example below I used "trace". Variables that aren't declared at the point of the stack trace would just be ingored.
It would make debugging much easier and make it much easier to write programs ... | [
{
"answer_id": 99385,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "<p>this might be useful, but i think it clutters the code - presumably when the code is working you would want to remo... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | Would it be useful to be able to mark objects where the value ofString.valueOf() would included in any stack trace. In my example below I used "trace". Variables that aren't declared at the point of the stack trace would just be ingored.
It would make debugging much easier and make it much easier to write programs that... | this might be useful, but i think it clutters the code - presumably when the code is working you would want to remove the 'trace' keywords; perhaps some form of metadata would be more appropriate
then there's always print statements... |
99,315 | <p>What if a Java allow both static and dynamic types. That might allow the best of both worlds. i.e.:</p>
<pre><code>String str = "Hello";
var temp = str;
temp = 10;
temp = temp * 5;
</code></pre>
<ol>
<li>Would that be possible?</li>
<li>Would that be beneficial?</li>
<li>Do any languages currently support both and... | [
{
"answer_id": 99333,
"author": "jon",
"author_id": 12215,
"author_profile": "https://Stackoverflow.com/users/12215",
"pm_score": 1,
"selected": false,
"text": "<p>Can you explain the difference between your example and</p>\n\n<pre><code>String str = \"Hello\";\nObject temp = str;\ntemp ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6770/"
] | What if a Java allow both static and dynamic types. That might allow the best of both worlds. i.e.:
```
String str = "Hello";
var temp = str;
temp = 10;
temp = temp * 5;
```
1. Would that be possible?
2. Would that be beneficial?
3. Do any languages currently support both and how well does it work out?
Here is a be... | C# has a "var" keyword used in the manner you describe, but it ends up being a strongly typed variable based on the types of values that type checking suggests will go into it. |
99,318 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/1217088/what-does-mapname-mean-in-ruby">What does map(&:name) mean in Ruby?</a> </p>
</blockquote>
<p>I was watching a railscast and saw this code.</p>
<pre><code>[Category, Product].(&:delete_all)
</c... | [
{
"answer_id": 99336,
"author": "Alex M",
"author_id": 9652,
"author_profile": "https://Stackoverflow.com/users/9652",
"pm_score": 5,
"selected": true,
"text": "<p>This relies upon a Ruby 1.9 extension that can be done in 1.8 by including the following:</p>\n\n<pre><code>class Symbol\n ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9450/"
] | >
> **Possible Duplicate:**
>
> [What does map(&:name) mean in Ruby?](https://stackoverflow.com/questions/1217088/what-does-mapname-mean-in-ruby)
>
>
>
I was watching a railscast and saw this code.
```
[Category, Product].(&:delete_all)
```
In regards to clearing a database.
I asked about the line in IRC a... | This relies upon a Ruby 1.9 extension that can be done in 1.8 by including the following:
```
class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end
end
```
I believe Rails defines this in `ActiveSupport`. |
99,350 | <p>Is there an easy way to marshal a PHP associative array to and from XML? For example, I have the following array:</p>
<pre><code>$items = array("1", "2",
array(
"item3.1" => "3.1",
"item3.2" => "3.2"
"isawesome" => true
)
);
</code></pre>
<p>How would I turn it into somethi... | [
{
"answer_id": 99367,
"author": "cruizer",
"author_id": 6441,
"author_profile": "https://Stackoverflow.com/users/6441",
"pm_score": 2,
"selected": false,
"text": "<p>Have you seen the PEAR package XML_Serializer?</p>\n\n<p><a href=\"http://pear.php.net/package/XML_Serializer\" rel=\"nofo... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15004/"
] | Is there an easy way to marshal a PHP associative array to and from XML? For example, I have the following array:
```
$items = array("1", "2",
array(
"item3.1" => "3.1",
"item3.2" => "3.2"
"isawesome" => true
)
);
```
How would I turn it into something similar to the following XML in ... | For those of you not using the PEAR packages, but you've got PHP5 installed. This worked for me:
```
/**
* Build A XML Data Set
*
* @param array $data Associative Array containing values to be parsed into an XML Data Set(s)
* @param string $startElement Root Opening Tag, default fx_request
* @param string $xml_v... |
99,391 | <p>When I commit I get this error from Subversion:</p>
<pre><code>bash-2.05b$ svn commit -m "testing subversion, still"
Adding baz
svn: Commit failed (details follow):
svn: MKCOL of '/viper/!svn/wrk/6b9bcd38-b2fe-0310-95ff-9d1a44098866/sandboxes/ohammersmith/trunk/baz': 405 Method Not Allowed (http://svn.examp... | [
{
"answer_id": 99413,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 8,
"selected": true,
"text": "<p>This happens when you have added a directory that someone else has also added and already committed. The error message on a c... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] | When I commit I get this error from Subversion:
```
bash-2.05b$ svn commit -m "testing subversion, still"
Adding baz
svn: Commit failed (details follow):
svn: MKCOL of '/viper/!svn/wrk/6b9bcd38-b2fe-0310-95ff-9d1a44098866/sandboxes/ohammersmith/trunk/baz': 405 Method Not Allowed (http://svn.example.com)
``` | This happens when you have added a directory that someone else has also added and already committed. The error message on a commit is really confusing, but if you do an `svn up` instead you'll see this message:
```
bash-2.05b$ svn up
svn: Failed to add directory 'baz': object of the same name already exists
```
To r... |
99,468 | <p>I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL_SCROLLABLE. How do I do this with a UNION query (with two selects)?</p>
<p>The most likely server will be MS SQL Server (probably 2005). The code is C for the Win3... | [
{
"answer_id": 99628,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "<p>can you not define a view on the db server that does the union query for you, so from the client code it just looks... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3137/"
] | I am retrieving multiple rows into a listview control from an ODBC source. For simple SELECTs it seems to work well with a statement attribute of SQL\_SCROLLABLE. How do I do this with a UNION query (with two selects)?
The most likely server will be MS SQL Server (probably 2005). The code is C for the Win32 API.
This... | can you not define a view on the db server that does the union query for you, so from the client code it just looks like a single select?
if you can't, can you just issue the union operation as part of your select, e.g.
```
select some_fields from table1
union
select same_fields from table2
```
and treat the result... |
99,488 | <p>If I'm writing an application that wants to communicate some information through the use of color, how can I change the background and foreground colors of a given widget? I would like to know how to do this in glade if it's possible, as well as programmatically (to a computed color).</p>
<p>I want to know how to ... | [
{
"answer_id": 100266,
"author": "Tometzky",
"author_id": 15862,
"author_profile": "https://Stackoverflow.com/users/15862",
"pm_score": 4,
"selected": true,
"text": "<p>Example program:</p>\n\n<pre><code>#include <gtk/gtk.h>\n\nstatic void on_destroy(GtkWidget* widget, gpointer dat... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13564/"
] | If I'm writing an application that wants to communicate some information through the use of color, how can I change the background and foreground colors of a given widget? I would like to know how to do this in glade if it's possible, as well as programmatically (to a computed color).
I want to know how to do this to ... | Example program:
```
#include <gtk/gtk.h>
static void on_destroy(GtkWidget* widget, gpointer data)
{
gtk_main_quit ();
}
int main (int argc, char* argv[])
{
GtkWidget* window;
GtkWidget* button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_s... |
99,542 | <p>How do I correct for floating point error in the following physical simulation:</p>
<ul>
<li>Original point (x, y, z),</li>
<li>Desired point (x', y', z') after forces are applied.</li>
<li>Two triangles (A, B, C) and (B, C, D), who share edge BC</li>
</ul>
<p>I am using this method for collision detection:</p>
<... | [
{
"answer_id": 99562,
"author": "Statement",
"author_id": 2166173,
"author_profile": "https://Stackoverflow.com/users/2166173",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like you ain't including testing if it's ON the edge (you're writing \"Inside triangle edges\"). Try cha... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] | How do I correct for floating point error in the following physical simulation:
* Original point (x, y, z),
* Desired point (x', y', z') after forces are applied.
* Two triangles (A, B, C) and (B, C, D), who share edge BC
I am using this method for collision detection:
```
For each Triangle
If the original point... | This is an inevitable problem when shooting a single ray against some geometry with edges and vertices. It's amazing how physical simulations seem to seek out the smallest of numerical inaccuracies!
Some of the explanations and solutions proposed by other respondents will not work. In particular:
* Numerical inaccura... |
99,546 | <p>I read this <a href="http://smartprogrammer.blogspot.com/2006/04/15-exercises-for-learning-new.html" rel="nofollow noreferrer">article</a> and try to do the exercise in D Programming Language, but encounter a problem in the first exercise.</p>
<blockquote>
<p>(1) Display series of numbers
(1,2,3,4, 5....etc) in... | [
{
"answer_id": 99593,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "<p>D generally has all the C stdlib available (Tango or Phobos) so answers to this question for GNU C should work in D as well.</... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242644/"
] | I read this [article](http://smartprogrammer.blogspot.com/2006/04/15-exercises-for-learning-new.html) and try to do the exercise in D Programming Language, but encounter a problem in the first exercise.
>
> (1) Display series of numbers
> (1,2,3,4, 5....etc) in an infinite
> loop. The program should quit if
> some... | Here's how you do it in the D programming language:
```
import std.c.stdio;
import std.c.linux.termios;
termios ostate; /* saved tty state */
termios nstate; /* values for editor mode */
// Open stdin in raw mode
/* Adjust output channel */
tcgetat... |
99,552 | <p>I sometimes notice programs that crash on my computer with the error: "pure virtual function call".</p>
<p>How do these programs even compile when an object cannot be created of an abstract class?</p>
| [
{
"answer_id": 99567,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "<p>I'd guess there is a vtbl created for the abstract class for some internal reason (it might be needed for some sort of run tim... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | I sometimes notice programs that crash on my computer with the error: "pure virtual function call".
How do these programs even compile when an object cannot be created of an abstract class? | They can result if you try to make a virtual function call from a constructor or destructor. Since you can't make a virtual function call from a constructor or destructor (the derived class object hasn't been constructed or has already been destroyed), it calls the base class version, which in the case of a pure virtua... |
99,560 | <p>I am working on a Rails application that needs to handle dates and times in users' time zones. We have recently migrated it to Rails 2.1 and added time zone support, but there are numerous situations in which we use Time#utc and then compare against that time. Wouldn't that be the same as comparing against the origi... | [
{
"answer_id": 99829,
"author": "Ian Terrell",
"author_id": 9269,
"author_profile": "https://Stackoverflow.com/users/9269",
"pm_score": 0,
"selected": false,
"text": "<p>If your application has users in multiple time zones, you should always store your times in UTC (any timezone would wo... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7717/"
] | I am working on a Rails application that needs to handle dates and times in users' time zones. We have recently migrated it to Rails 2.1 and added time zone support, but there are numerous situations in which we use Time#utc and then compare against that time. Wouldn't that be the same as comparing against the original... | If you've set:
```
config.time_zone = 'UTC'
```
In your environment.rb (it's there by default), then times will automagically get converted into UTC when ActiveRecord stores them.
Then if you set Time.zone (in a before\_filter on application.rb is the usual place) to the user's Time Zone, all the times will be auto... |
99,623 | <p>I'd like to be able to do some drawing to the right of the menu bar, in the nonclient area of a window. </p>
<p>Is this possible, using C++ / MFC?</p>
| [
{
"answer_id": 99629,
"author": "Andrei Belogortseff",
"author_id": 17037,
"author_profile": "https://Stackoverflow.com/users/17037",
"pm_score": 2,
"selected": false,
"text": "<p>In order to draw in the non-client area, you need to get the \"window\" DC (rather than \"client\" DC), and ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to be able to do some drawing to the right of the menu bar, in the nonclient area of a window.
Is this possible, using C++ / MFC? | Charlie hit on the answer with `WM_NCPAINT`. If you're using MFC, the code would look something like this:
```
// in the message map
ON_WM_NCPAINT()
// ...
void CMainFrame::OnNcPaint()
{
// still want the menu to be drawn, so trigger default handler first
Default();
// get menu bar bounds
MENUBARINFO me... |
99,683 | <p>My question is what do most developers prefer for error handling, Exceptions or Error Return Codes. Please be language(or language family) specific and why you prefer one over the other.</p>
<p>I'm asking this out of curiosity. Personally I prefer Error Return Codes since they are less explosive and don't force use... | [
{
"answer_id": 99694,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 5,
"selected": false,
"text": "<p>I use both actually.</p>\n\n<p>I use return codes if it's a known, possible error. If it's a scenario that I know... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | My question is what do most developers prefer for error handling, Exceptions or Error Return Codes. Please be language(or language family) specific and why you prefer one over the other.
I'm asking this out of curiosity. Personally I prefer Error Return Codes since they are less explosive and don't force user code to ... | For some languages (i.e. C++) Resources leak should not be a reason
===================================================================
C++ is based on RAII.
If you have code that could fail, return or throw (that is, most normal code), then you should have your pointer wrapped inside a smart pointer (assuming you ha... |
99,684 | <p>The most basic task in an object oriented environment is executing a method on an object. To do this, you have to have a reference to the object on which you are invoking the method. Is the proper way to establish this reference to pass the object as a parameter to the constructor (or initializer method) of the call... | [
{
"answer_id": 99700,
"author": "scubabbl",
"author_id": 9450,
"author_profile": "https://Stackoverflow.com/users/9450",
"pm_score": 0,
"selected": false,
"text": "<p>Well, depending on the level of messaging, you could implement a messaging service. Objects listen for messages, or regis... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8092/"
] | The most basic task in an object oriented environment is executing a method on an object. To do this, you have to have a reference to the object on which you are invoking the method. Is the proper way to establish this reference to pass the object as a parameter to the constructor (or initializer method) of the calling... | Generally dependency injection is the way to go. If you're just talking about two objects communicating then pass an instance of one in as a paramter to the other, as in your first example. Passing in the constructor ensure the reference is always valid. Otherwise you'd have to test to ensure register had been called. ... |
99,732 | <p>Using reflection in .Net, what is the differnce between:</p>
<pre><code> if (foo.IsAssignableFrom(typeof(IBar)))
</code></pre>
<p>And</p>
<pre><code> if (foo.GetInterface(typeof(IBar).FullName) != null)
</code></pre>
<p>Which is more appropriate, why?<br></p>
<p>When could one or the other fail?</p>
| [
{
"answer_id": 99744,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 5,
"selected": true,
"text": "<p>If you just want to see if a type implements a given interface, either is fine, though GetInterface() is probably faste... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14484/"
] | Using reflection in .Net, what is the differnce between:
```
if (foo.IsAssignableFrom(typeof(IBar)))
```
And
```
if (foo.GetInterface(typeof(IBar).FullName) != null)
```
Which is more appropriate, why?
When could one or the other fail? | If you just want to see if a type implements a given interface, either is fine, though GetInterface() is probably faster since IsAssignableFrom() does more internal checks than GetInterface(). It'll probably even faster to check the results of Type.GetInterfaces() which returns the same internal list that both of the o... |
99,781 | <p>I have a client that is asking me to give them a listing of every file and folder in the source code (and then a brief explanation of the source tree). Is there an easy way to create some sort of decently formatted list like this from a subversion repository?</p>
| [
{
"answer_id": 99788,
"author": "Subimage",
"author_id": 10596,
"author_profile": "https://Stackoverflow.com/users/10596",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming it's available via HTTP - why not just give them a read-only login, and point them at the web address?</p>\n"
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1486/"
] | I have a client that is asking me to give them a listing of every file and folder in the source code (and then a brief explanation of the source tree). Is there an easy way to create some sort of decently formatted list like this from a subversion repository? | You'll want the list command. Assuming you're using the command line client
```
svn list -R http://example.com/path/to/repos
```
This will give you a full recursive list of everything that's in the repository. Redirect it to a text file
```
svn list -R http://example.com/path/to/repos > file.txt
```
and then form... |
99,796 | <p>I have recently learned about binary space partitioning trees and their application to 3d graphics and collision detection. I have also briefly perused material relating to quadtrees and octrees. When would you use quadtrees over bsp trees, or vice versa? Are they interchangeable? I would be satisfied if I had e... | [
{
"answer_id": 99817,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have much experience with BSPs, but I can say that you should go with octrees over quadtrees when you th... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] | I have recently learned about binary space partitioning trees and their application to 3d graphics and collision detection. I have also briefly perused material relating to quadtrees and octrees. When would you use quadtrees over bsp trees, or vice versa? Are they interchangeable? I would be satisfied if I had enough i... | There is no clear answer to your question. It depends entirely how your data is organized.
Something to keep in mind:
Quadtrees work best for data that is mostly two dimensional like map-rendering in navigation systems. In this case it's faster than octrees because it adapts better to the geometry and keeps the node-... |
99,827 | <p>I'm interested in tracing database calls made by LINQ to SQL back to the .NET code that generated the call. For instance, a DBA might have a concern that a particular cached execution plan is doing poorly. If for example a DBA were to tell a developer to address the following code...</p>
<pre><code>exec sp_executes... | [
{
"answer_id": 99839,
"author": "ethyreal",
"author_id": 18159,
"author_profile": "https://Stackoverflow.com/users/18159",
"pm_score": 1,
"selected": false,
"text": "<p>in the <a href=\"http://cftextmate.com/\" rel=\"nofollow noreferrer\">cftextmate</a> bundle you can type any cfml tag w... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360388/"
] | I'm interested in tracing database calls made by LINQ to SQL back to the .NET code that generated the call. For instance, a DBA might have a concern that a particular cached execution plan is doing poorly. If for example a DBA were to tell a developer to address the following code...
```
exec sp_executesql N'SELECT [t... | These are my favorite shortcuts:
* `cmd`+`t` Start typing name of a file to open it
* `ctrl`+`w` Select word
* `cmd`+`r` Run the ruby or php-script that is open
* `cmd`+`opt`+`m` Define a new macro
* `cmd`+`shift`+`m` Run the macro
* `opt` Switch to vertical selection mode
* `cmd`+`opt`+`a` Edit ends of selected lines |
99,866 | <p>I'm at the beginning/middle of a project that we chose to implement using GWT. Has anyone encountered any major pitfalls in using GWT (and GWT-EXT) that were unable to be overcome? How about from a performance perspective?</p>
<p>A couple things that we've seen/heard already include:</p>
<ul>
<li>Google not being ... | [
{
"answer_id": 99920,
"author": "Michael Neale",
"author_id": 699,
"author_profile": "https://Stackoverflow.com/users/699",
"pm_score": 3,
"selected": false,
"text": "<p>No major pitfalls that I haven't been able to overcome easily. Use hosted mode heavily. \nAs you are using GWT-ext you... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18402/"
] | I'm at the beginning/middle of a project that we chose to implement using GWT. Has anyone encountered any major pitfalls in using GWT (and GWT-EXT) that were unable to be overcome? How about from a performance perspective?
A couple things that we've seen/heard already include:
* Google not being able to index content... | I'll start by saying that I'm a massive GWT fan, but yes there are many pitfalls, but most if not all we were able to overcome:
**Problem:** Long compile times, as your project grows so does the amount of time it takes to compile it. I've heard of reports of 20 minute compiles, but mine are on average about 1 minute.
... |
99,876 | <p>I just wanted some opinions from people that have run Selenium (<a href="http://selenium.openqa.org" rel="nofollow noreferrer">http://selenium.openqa.org</a>) I have had a lot of experience with WaTiN and even wrote a recording suite for it. I had it producing some well-structured code but being only maintained by m... | [
{
"answer_id": 99965,
"author": "marcospereira",
"author_id": 4600,
"author_profile": "https://Stackoverflow.com/users/4600",
"pm_score": 6,
"selected": true,
"text": "<p>If you are using <a href=\"http://selenium-ide.openqa.org/\" rel=\"nofollow noreferrer\">Selenium IDE</a> to generate... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] | I just wanted some opinions from people that have run Selenium (<http://selenium.openqa.org>) I have had a lot of experience with WaTiN and even wrote a recording suite for it. I had it producing some well-structured code but being only maintained by me it seems my company all but abandoned it.
If you have run seleni... | If you are using [Selenium IDE](http://selenium-ide.openqa.org/) to generate code, then you just get a list of every action that selenium will execute. To me, Selenium IDE is a good way to start or do a fast "try and see" test. But, when you think about maintainability and more readable code, you must write your own co... |
99,880 | <p>I need to write a function that generates an id that is unique for a given machine running a Windows OS.</p>
<p>Currently, I'm using WMI to query various hardware parameters and concatenate them together and hash them to derive the unique id. My question is, what are the suggested parameters I should use?
Currentl... | [
{
"answer_id": 99889,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 1,
"selected": false,
"text": "<p>You should look into using the MAC address on the network card (if it exists). Those are usually unique but can be fabri... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/618/"
] | I need to write a function that generates an id that is unique for a given machine running a Windows OS.
Currently, I'm using WMI to query various hardware parameters and concatenate them together and hash them to derive the unique id. My question is, what are the suggested parameters I should use?
Currently, I'm usi... | Parse the [SMBIOS](http://www.dmtf.org/standards/smbios/) yourself and hash it to an arbitrary length. See the [PDF specification](http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf) for all SMBIOS structures available.
To query the SMBIOS info from Windows you could use [`EnumSystemFirmwareEntries`](... |
99,912 | <p>I am trying to use directory services to add a directory entry to an openldap server. The examples I have seen look pretty simple, but I keep getting the error "There is an naming violation". What does this message mean? How do I resolve it?</p>
<p>I have included the code, ldif file used to create the person cont... | [
{
"answer_id": 104942,
"author": "Michael",
"author_id": 13379,
"author_profile": "https://Stackoverflow.com/users/13379",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you need to include this?</p>\n\n<pre><code>SetADProperty(newUser, \"objectClass\", \"top\")\n</code></pre>\n\n<p... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to use directory services to add a directory entry to an openldap server. The examples I have seen look pretty simple, but I keep getting the error "There is an naming violation". What does this message mean? How do I resolve it?
I have included the code, ldif file used to create the person container.
```... | Maybe you need to include this?
```
SetADProperty(newUser, "objectClass", "top")
```
Also, check what the required fields for `organizationalPerson` and `person` are...you might be missing one. |
99,917 | <p>So I was reading these Asp.Net <a href="http://www.hanselman.com/blog/ASPNETInterviewQuestions.aspx" rel="nofollow noreferrer">interview questions</a> at Scott Hanselman's blog and I came across this question. Can anyone shed some light of what he's talking about.</p>
| [
{
"answer_id": 100102,
"author": "WebDude",
"author_id": 15360,
"author_profile": "https://Stackoverflow.com/users/15360",
"pm_score": 0,
"selected": false,
"text": "<p>I think what he's asking here is how you wire up javascript functions to work hand in hand with your ASP.NET postback f... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] | So I was reading these Asp.Net [interview questions](http://www.hanselman.com/blog/ASPNETInterviewQuestions.aspx) at Scott Hanselman's blog and I came across this question. Can anyone shed some light of what he's talking about. | ```
<asp:LinkButton ID="lbEdit" CssClass="button"
OnClientClick="javascript:alert('do something')"
onclick="OnEdit" runat="server">Edit</asp:LinkButton>
```
The `OnClientClick` attribute means you can add some JavaScript without losing PostBack functionality would be my answer in the interview. |
99,927 | <p>Can someone provide an explanation of variable scope in JS as it applies to objects, functions and closures? </p>
| [
{
"answer_id": 99949,
"author": "moltenform",
"author_id": 18506,
"author_profile": "https://Stackoverflow.com/users/18506",
"pm_score": 2,
"selected": false,
"text": "<p>Variables not declared with var are global in scope. \nFunctions introduce a scope, but note that if blocks and other... | 2008/09/19 | [
"https://Stackoverflow.com/questions/99927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56663/"
] | Can someone provide an explanation of variable scope in JS as it applies to objects, functions and closures? | ### Global variables
Every variable in Javascript is a named attribute of an object. For example:-
```
var x = 1;
```
x is added to the global object. The global object is provided by the script context and may already have a set of attributes. For example in a browser the global object is window. An equivalent to ... |
100,003 | <p>What are metaclasses? What are they used for?</p>
| [
{
"answer_id": 100037,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 9,
"selected": false,
"text": "<p><em>Note, this answer is for Python 2.x as it was written in 2008, metaclasses are slightly different in 3.x.</em></p>\n\... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] | What are metaclasses? What are they used for? | A metaclass is the class of a class. A class defines how an instance of the class (i.e. an object) behaves while a metaclass defines how a class behaves. A class is an instance of a metaclass.
While in Python you can use arbitrary callables for metaclasses (like [Jerub](https://stackoverflow.com/questions/100003/what-... |
100,007 | <p>When logging with Log4Net it's very easy to put class that called the log into the log file. I've found in the past that this makes it very easy to trace through the code and see the flow through the classes. In Log4Net I use the %logger property in the conversion pattern like so: </p>
<pre><code><conversionPa... | [
{
"answer_id": 100075,
"author": "Tom Carr",
"author_id": 14954,
"author_profile": "https://Stackoverflow.com/users/14954",
"pm_score": 1,
"selected": false,
"text": "<p>We havn't found an easy way without hitting the StackTrace. If it's an exception, we just grab from that:</p>\n\n<pre... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11908/"
] | When logging with Log4Net it's very easy to put class that called the log into the log file. I've found in the past that this makes it very easy to trace through the code and see the flow through the classes. In Log4Net I use the %logger property in the conversion pattern like so:
```
<conversionPattern value="%date ... | Add the calling method to the LogEntry's ExtendedProperties dictionary; assuming you haven't removed the ExtendedProperties tokens from the formatter template, of course.
Put something like this in a logging wrapper:
```
public void LogSomething(string msg)
{
LogEntry le = new LogEntry { Message = msg };
le.Exte... |
100,045 | <p>What is a good regular expression that can validate a text string to make sure it is a valid Windows filename? (AKA not have <code>\/:*?"<>|</code> characters).</p>
<p>I'd like to use it like the following:</p>
<pre><code>// Return true if string is invalid.
if (Regex.IsMatch(szFileName, "<your regex stri... | [
{
"answer_id": 100057,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 0,
"selected": false,
"text": "<p>Why not using the System.IO.FileInfo class, together with the DirectoryInfo class you have a set of usefull methods. </p>\n... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115/"
] | What is a good regular expression that can validate a text string to make sure it is a valid Windows filename? (AKA not have `\/:*?"<>|` characters).
I'd like to use it like the following:
```
// Return true if string is invalid.
if (Regex.IsMatch(szFileName, "<your regex string>"))
{
// Tell user to reformat the... | As answered already, GetInvalidFileNameChars should do it for you, and you don't even need the overhead of regular expressions:
```
if (proposedFilename.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) != -1)
{
MessageBox.Show("The filename is invalid");
return;
}
``` |
100,048 | <p>I have two unsorted lists and I need to produce another list which is sorted and where all the elements are unique.</p>
<p>The elements can occur multiple times in both lists and they are originally unsorted.</p>
<p>My function looks like this:</p>
<pre><code>(defun merge-lists (list-a list-b sort-fn)
"Merges... | [
{
"answer_id": 100077,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 1,
"selected": false,
"text": "<p>I think I would first sort the two lists separately and then merge them with a function that also skips over duplicates.... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7780/"
] | I have two unsorted lists and I need to produce another list which is sorted and where all the elements are unique.
The elements can occur multiple times in both lists and they are originally unsorted.
My function looks like this:
```
(defun merge-lists (list-a list-b sort-fn)
"Merges two lists of (x, y) coordin... | Our neighbourhood friendly Lisp guru pointed out the [remove-duplicates function](http://www.lispworks.com/documentation/HyperSpec/Body/f_rm_dup.htm).
He also provided the following snippet:
```
(defun merge-lists (list-a list-b sort-fn test-fn)
(sort (remove-duplicates (append list-a list-b) :test test-fn) sort-... |
100,053 | <p>I posted a <a href="https://stackoverflow.com/questions/81306/wcf-faults-exceptions-versus-messages">question</a> about using Messages versus Fault Exceptions to communicate business rules between services.</p>
<p>I was under the impression it carried overhead to throw this exception over the wire, but considering ... | [
{
"answer_id": 100088,
"author": "blowdart",
"author_id": 2525,
"author_profile": "https://Stackoverflow.com/users/2525",
"pm_score": 0,
"selected": false,
"text": "<p>It's just like a normal exception, and uses the same wrapping code as a normal exception would to marshal into a fault, ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15360/"
] | I posted a [question](https://stackoverflow.com/questions/81306/wcf-faults-exceptions-versus-messages) about using Messages versus Fault Exceptions to communicate business rules between services.
I was under the impression it carried overhead to throw this exception over the wire, but considering it's just a message t... | Well... In general you shouldn't be throwing exceptions for expected conditions, or anything you *expect* to happen regularly. They are massively slower than doing normal methods. E.g., if you expect a file open to fail, don't throw a that exception up to your caller, pass the back a failure code, or provide a "CanOpen... |
100,068 | <p>I'd like to know if there's an easier way to insert a record if it doesn't already exist in a table. I'm still trying to build my LINQ to SQL skills. </p>
<p>Here's what I've got, but it seems like there should be an easier way.</p>
<pre><code>public static TEntity InsertIfNotExists<TEntity>
(
DataContex... | [
{
"answer_id": 100496,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 5,
"selected": true,
"text": "<pre><code>public static void InsertIfNotExists<TEntity>\n (this Table<TEntity> table,\n ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | I'd like to know if there's an easier way to insert a record if it doesn't already exist in a table. I'm still trying to build my LINQ to SQL skills.
Here's what I've got, but it seems like there should be an easier way.
```
public static TEntity InsertIfNotExists<TEntity>
(
DataContext db,
Table<TEntity> ta... | ```
public static void InsertIfNotExists<TEntity>
(this Table<TEntity> table,
TEntity entity,
Expression<Func<TEntity,bool>> predicate)
where TEntity : class
{
if (!table.Any(predicate))
{
table.InsertOnSubmit(record);
table.Con... |
100,081 | <p>I have the following C# singleton pattern, is there any way of improving it? </p>
<pre><code> public class Singleton<T> where T : class, new()
{
private static object _syncobj = new object();
private static volatile T _instance = null;
public static T Instance
{
... | [
{
"answer_id": 100093,
"author": "EggyBach",
"author_id": 15475,
"author_profile": "https://Stackoverflow.com/users/15475",
"pm_score": 3,
"selected": false,
"text": "<p>Courtesy of Judith Bishop, <a href=\"http://patterns.cs.up.ac.za/\" rel=\"noreferrer\">http://patterns.cs.up.ac.za/</a... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | I have the following C# singleton pattern, is there any way of improving it?
```
public class Singleton<T> where T : class, new()
{
private static object _syncobj = new object();
private static volatile T _instance = null;
public static T Instance
{
get
... | According to Jon Skeet in [Implementing the Singleton Pattern in C#](https://csharpindepth.com/articles/Singleton) the code you posted is actually considered as bad code, because it appears broken when checked against the ECMA CLI standard.
Also watch out: everytime you instantiate your object with a new type of T, it... |
100,104 | <p>I've written a small hello world test app in Silverlight which i want to host on a Linux/Apache2 server. I want the data to come from MySQL (or some other linux compatible db) so that I can databind to things in the db.</p>
<p>I've managed to get it working by using the <a href="http://www.mysql.com/products/connec... | [
{
"answer_id": 100286,
"author": "cruizer",
"author_id": 6441,
"author_profile": "https://Stackoverflow.com/users/6441",
"pm_score": 2,
"selected": false,
"text": "<p>Silverlight does not have any capability to directly access database servers. What you can do is to expose your database ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8521/"
] | I've written a small hello world test app in Silverlight which i want to host on a Linux/Apache2 server. I want the data to come from MySQL (or some other linux compatible db) so that I can databind to things in the db.
I've managed to get it working by using the [MySQL Connector/.NET](http://www.mysql.com/products/co... | The easiest way to do what you want (having read through your edits now :)) will be to expose services that can be consumed. The pattern that Microsoft is REALLY pushing right now is to expose WCF services, but the truth is that your Silverlight client can use WCF to consume a lot of different types of services.
What ... |
100,106 | <pre><code>sub foo {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]%
@{$_[$==~/(?=)//!$`]}..$#{$_[$??!!$?:!$?]},($)?!$):!!$))..$_[$--$-]%@{
$_[$]/$]]}-(!!$++!$+)]:@{$_[!!$^^^!$^^]}]}
</code></pre>
<p>update: I thought the word "puzzle" would imply this, but: <em>I</em> know what it does - I wrote it. If the... | [
{
"answer_id": 100503,
"author": "nohat",
"author_id": 3101,
"author_profile": "https://Stackoverflow.com/users/3101",
"pm_score": 3,
"selected": false,
"text": "<p>It takes two arrayrefs and returns a new arrayref with the contents of the second array rearranged such that the second par... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17389/"
] | ```
sub foo {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]%
@{$_[$==~/(?=)//!$`]}..$#{$_[$??!!$?:!$?]},($)?!$):!!$))..$_[$--$-]%@{
$_[$]/$]]}-(!!$++!$+)]:@{$_[!!$^^^!$^^]}]}
```
update: I thought the word "puzzle" would imply this, but: *I* know what it does - I wrote it. If the puzzle doesn't interest yo... | ### Here is how you figure out how to de-obfuscate this subroutine.
*Sorry for the length*
First let's tidy up the code, and add useful comments.
```
sub foo {
[
(
# ($#{$_[1]})
$#{
$_[
! ( $| | $| )
# $OUTPUT_AUTOFLUSH === $|
# $| is usually 0
# ! ( ... |
100,107 | <p>I'm investigating the following <code>java.lang.VerifyError</code></p>
<pre><code>java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILjava/util/Collection;Ljava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/... | [
{
"answer_id": 100131,
"author": "Lars Westergren",
"author_id": 15627,
"author_profile": "https://Stackoverflow.com/users/15627",
"pm_score": 1,
"selected": false,
"text": "<p>This page may give you some hints -\n<a href=\"http://www.zanthan.com/itymbi/archives/000337.html\" rel=\"nofol... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15490/"
] | I'm investigating the following `java.lang.VerifyError`
```
java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILjava/util/Collection;Ljava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;Lorg/apache/s... | `java.lang.VerifyError` can be the result when you have compiled against a different library than you are using at runtime.
For example, this happened to me when trying to run a program that was compiled against Xerces 1, but Xerces 2 was found on the classpath. The required classes (in `org.apache.*` namespace) were ... |
100,161 | <p>I was happily using Eclipse 3.2 (or as happy as one can be using Eclipse) when for a forgotten reason I decided to upgrade to 3.4. I'm primarily using PyDev, Aptana, and Subclipse, very little Java development.</p>
<p>I've noticed 3.4 tends to really give my laptop a hernia compared to 3.2 (vista, core2duo, 2G). Is... | [
{
"answer_id": 100180,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 2,
"selected": false,
"text": "<p>Yes memory usage can get real high and you might run into problems with your JVM, as the default setting is a bit to low.\n... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | I was happily using Eclipse 3.2 (or as happy as one can be using Eclipse) when for a forgotten reason I decided to upgrade to 3.4. I'm primarily using PyDev, Aptana, and Subclipse, very little Java development.
I've noticed 3.4 tends to really give my laptop a hernia compared to 3.2 (vista, core2duo, 2G). Is memory us... | Yes memory usage can get real high and you might run into problems with your JVM, as the default setting is a bit to low.
Consider using this startup parameters when running eclipse:
```
-vmargs -XX:MaxPermSize=1024M -Xms256M -Xmx1024M
``` |
100,170 | <p>I have a folder on my server to which I had a number of symbolic links pointing. I've since created a new folder and I want to change all those symbolic links to point to the new folder. I'd considered replacing the original folder with a symlink to the new folder, but it seems that if I continued with that practice... | [
{
"answer_id": 100200,
"author": "skymt",
"author_id": 18370,
"author_profile": "https://Stackoverflow.com/users/18370",
"pm_score": 7,
"selected": true,
"text": "<p>I'd use the find command.</p>\n\n<pre><code>find . -lname /particular/folder\n</code></pre>\n\n<p>That will recursively se... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I have a folder on my server to which I had a number of symbolic links pointing. I've since created a new folder and I want to change all those symbolic links to point to the new folder. I'd considered replacing the original folder with a symlink to the new folder, but it seems that if I continued with that practice it... | I'd use the find command.
```
find . -lname /particular/folder
```
That will recursively search the current directory for symlinks to `/particular/folder`. Note that it will only find absolute symlinks. A similar command can be used to search for all symlinks pointing at objects called "folder":
```
find . -lname '... |
100,209 | <p>I have an OWL ontology and I am using Pellet to do reasoning over it. Like most ontologies it starts by including various standard ontologies:</p>
<pre><code><rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/20... | [
{
"answer_id": 103736,
"author": "Ian Terrell",
"author_id": 9269,
"author_profile": "https://Stackoverflow.com/users/9269",
"pm_score": 1,
"selected": false,
"text": "<p>Make local copies of the four files and replace the remote URLs with local URIs (i.e. file://... or serve them from y... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12405/"
] | I have an OWL ontology and I am using Pellet to do reasoning over it. Like most ontologies it starts by including various standard ontologies:
```
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#... | Pellet recognizes all of these namespaces when loading and should not attempt to dereference the URIs. If it does, it suggests the application using Pellet is doing something incorrectly.
You may find more help on [the pellet-users mailing list](http://lists.owldl.com/mailman/listinfo/pellet-users/). |
100,210 | <p>Given a <code>datetime.time</code> value in Python, is there a standard way to add an integer number of seconds to it, so that <code>11:34:59</code> + 3 = <code>11:35:02</code>, for example?</p>
<p>These obvious ideas don't work:</p>
<pre><code>>>> datetime.time(11, 34, 59) + 3
TypeError: unsupported oper... | [
{
"answer_id": 100250,
"author": "Nick Johnson",
"author_id": 12030,
"author_profile": "https://Stackoverflow.com/users/12030",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding a <code>datetime.datetime</code> to a <code>datetime.timedelta</code>. If you only want the time portio... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5536/"
] | Given a `datetime.time` value in Python, is there a standard way to add an integer number of seconds to it, so that `11:34:59` + 3 = `11:35:02`, for example?
These obvious ideas don't work:
```
>>> datetime.time(11, 34, 59) + 3
TypeError: unsupported operand type(s) for +: 'datetime.time' and 'int'
>>> datetime.time(... | You can use full `datetime` variables with `timedelta`, and by providing a dummy date then using `time` to just get the time value.
For example:
```
import datetime
a = datetime.datetime(100,1,1,11,34,59)
b = a + datetime.timedelta(0,3) # days, seconds, then other fields.
print(a.time())
print(b.time())
```
results... |
100,211 | <p>I just installed Glassfish V2 on my local machine just to play around with it.</p>
<p>I was wondering if there is a way to retrieve a param passed in by the GET HTTP method.</p>
<p>For instance,</p>
<pre><code>http://localhost:8080/HelloWorld/resources/helloWorld?name=ABC
</code></pre>
<p>How do I retrieve the "... | [
{
"answer_id": 100396,
"author": "tgdavies",
"author_id": 11002,
"author_profile": "https://Stackoverflow.com/users/11002",
"pm_score": 3,
"selected": true,
"text": "<p>Like this:</p>\n\n<pre><code>@Path(\"/helloWorld\")\n@Consumes({\"application/xml\", \"application/json\"})\n@Produces(... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4004/"
] | I just installed Glassfish V2 on my local machine just to play around with it.
I was wondering if there is a way to retrieve a param passed in by the GET HTTP method.
For instance,
```
http://localhost:8080/HelloWorld/resources/helloWorld?name=ABC
```
How do I retrieve the "name" param in my Java code? | Like this:
```
@Path("/helloWorld")
@Consumes({"application/xml", "application/json"})
@Produces({"application/xml", "application/json"})
@Singleton
public class MyService {
@GET
public String getRequest(@QueryParam("name") String name) {
return "Name was " + name;
}
}
``` |
100,216 | <p>I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on TFS.</p>
<p>In an attempt to make it self contained I would like to start the seleniumRC server only when it's needed from fitness.</p>
<p>I've seen that there is a "Command Line Fixture" but it's written in java can I use that?</p>... | [
{
"answer_id": 100638,
"author": "David Laing",
"author_id": 13238,
"author_profile": "https://Stackoverflow.com/users/13238",
"pm_score": 0,
"selected": false,
"text": "<p>What about writing a simple .NET app that does a Process.Start(\"selenumRC commandline\") which gets run by your bu... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11434/"
] | I'm trying to integrate running Fitnesse tests from MSBuild im my nightly build on TFS.
In an attempt to make it self contained I would like to start the seleniumRC server only when it's needed from fitness.
I've seen that there is a "Command Line Fixture" but it's written in java can I use that? | I think you might be able to. You can call any process easily in MSBuild using the task. However, the problem with doing this is that the exec task will wait for the Selinium process to finish before continuing, which is not the bahaviour you want. You want to run the process, keep it running during your build and the... |
100,228 | <p>I'm trying to set up part of a schema that's like a "Sequence" where all child elements are optional, but at least one of the elements <strong>must</strong> be present, and there could be more than one of them.</p>
<p>I tried doing the following, but XMLSpy complains that "The content model contains the elements &l... | [
{
"answer_id": 100313,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": 6,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code><xs:choice>\n <xs:sequence>\n <xs:element name=\"Elem1\" />\n <xs:el... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18603/"
] | I'm trying to set up part of a schema that's like a "Sequence" where all child elements are optional, but at least one of the elements **must** be present, and there could be more than one of them.
I tried doing the following, but XMLSpy complains that "The content model contains the elements <element name="DateConsta... | Try this:
```
<xs:choice>
<xs:sequence>
<xs:element name="Elem1" />
<xs:element name="Elem2" minOccurs="0" />
<xs:element name="Elem3" minOccurs="0" />
</xs:sequence>
<xs:sequence>
<xs:element name="Elem2" />
<xs:element name="Elem3" minOccurs="0" />
</xs:sequence>
<xs:element name="Elem3... |
100,235 | <p>For an open source project I am looking for a good, simple implementation of a Dictionary that is backed by a file. Meaning, if an application crashes or restarts the dictionary will keep its state. I would like it to update the underlying file every time the dictionary is touched. (Add a value or remove a value). A... | [
{
"answer_id": 100672,
"author": "chrisb",
"author_id": 8262,
"author_profile": "https://Stackoverflow.com/users/8262",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds cool, but how will you get around changes to the stored value (if it was a reference type) itself? If its immutabl... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | For an open source project I am looking for a good, simple implementation of a Dictionary that is backed by a file. Meaning, if an application crashes or restarts the dictionary will keep its state. I would like it to update the underlying file every time the dictionary is touched. (Add a value or remove a value). A Fi... | * [**bplustreedotnet**](http://bplusdotnet.sourceforge.net/)
The bplusdotnet package is a library of cross compatible data structure implementations in C#, java, and Python which are useful for applications which need to store and retrieve persistent information. The bplusdotnet data structures make it easy to **store... |
100,236 | <p>How can I insert ASCII special characters (e.g. with the ASCII value 0x01) into a string?</p>
<p>I ask because I am using the following:</p>
<pre><code>str.Replace( "<TAG1>", Convert.ToChar(0x01).ToString() );
</code></pre>
<p>and I feel that there must be a better way than this. Any Ideas?</p>
<p>Update:<... | [
{
"answer_id": 100244,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "<p>I believe you can use <code>\\uXXXX</code> to insert specified codes into your string.</p>\n\n<p>ETA: I just tested it and... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] | How can I insert ASCII special characters (e.g. with the ASCII value 0x01) into a string?
I ask because I am using the following:
```
str.Replace( "<TAG1>", Convert.ToChar(0x01).ToString() );
```
and I feel that there must be a better way than this. Any Ideas?
Update:
Also If I use this methodology, do I need to ... | I believe you can use `\uXXXX` to insert specified codes into your string.
ETA: I just tested it and it works. :-)
```
using System;
class Uxxxx {
public static void Main() {
Console.WriteLine("\u20AC");
}
}
``` |
100,242 | <p>You can use </p>
<p>SelectFolder() to get a folder</p>
<p>or </p>
<p>GetOpenFolderitem(filter as string) to get files</p>
<p>but can you select either a folder or file? ( or for that matter selecting multiple files )</p>
| [
{
"answer_id": 100251,
"author": "Enrique",
"author_id": 17134,
"author_profile": "https://Stackoverflow.com/users/17134",
"pm_score": -1,
"selected": false,
"text": "<p>Assuming you're using .Net I think you'll need to create your own control (or buy one). </p>\n"
},
{
"answer_i... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10472/"
] | You can use
SelectFolder() to get a folder
or
GetOpenFolderitem(filter as string) to get files
but can you select either a folder or file? ( or for that matter selecting multiple files ) | The MonkeyBread plugin allows this in the OpenDialogMBS class.
<http://www.monkeybreadsoftware.net/pluginhelp/navigation-opendialogmbs.shtml>
```
OpenDialogMBS.AllowFolderSelection as Boolean
property, Navigation, MBS Util Plugin (OpenDialog), class OpenDialogMBS, Plugin version: 7.5, Mac OS X: Works, Windows: Does n... |
100,247 | <p>I'm using C# in .Net 2.0, and I want to read in a PNG image file and check for the first row and first column that has non-transparent pixels. </p>
<p>What assembly and/or class should I use?</p>
| [
{
"answer_id": 100292,
"author": "Roy Tang",
"author_id": 18494,
"author_profile": "https://Stackoverflow.com/users/18494",
"pm_score": 1,
"selected": false,
"text": "<p>Of course I googled already and found the PngBitmapDecoder class, but it doesn't seem to be available in .Net 2.0? </p... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18494/"
] | I'm using C# in .Net 2.0, and I want to read in a PNG image file and check for the first row and first column that has non-transparent pixels.
What assembly and/or class should I use? | [Bitmap](http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx) class from System.Drawing.dll assembly:
```
Bitmap bitmap = new Bitmap(@"C:\image.png");
Color clr = bitmap.GetPixel(0, 0);
``` |
100,291 | <p>Imagine I have an function which goes through one million/billion strings and checks smth in them.</p>
<p>f.ex:</p>
<pre><code>foreach (String item in ListOfStrings)
{
result.add(CalculateSmth(item));
}
</code></pre>
<p>it consumes lot's of time, because CalculateSmth is very time consuming function.</p>
<p>... | [
{
"answer_id": 100307,
"author": "Tobi",
"author_id": 5422,
"author_profile": "https://Stackoverflow.com/users/5422",
"pm_score": 5,
"selected": true,
"text": "<p>You could try the <a href=\"http://msdn.microsoft.com/en-us/concurrency/default.aspx\" rel=\"noreferrer\">Parallel extensions... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5369/"
] | Imagine I have an function which goes through one million/billion strings and checks smth in them.
f.ex:
```
foreach (String item in ListOfStrings)
{
result.add(CalculateSmth(item));
}
```
it consumes lot's of time, because CalculateSmth is very time consuming function.
I want to ask: how to integrate multithr... | You could try the [Parallel extensions](http://msdn.microsoft.com/en-us/concurrency/default.aspx) (part of .NET 4.0)
These allow you to write something like:
```
Parallel.Foreach (ListOfStrings, (item) =>
result.add(CalculateSmth(item));
);
```
Of course result.add would need to be thread safe. |
100,365 | <p>In cake 1.2 there is a feature that allows the developer to no have to create models, but rather have cake do the detective work at run time and create the model for you. This process happens each time and is neat but in my case very hazardous. I read about this somewhere and now I'm experiencing the bad side of thi... | [
{
"answer_id": 100426,
"author": "deceze",
"author_id": 476,
"author_profile": "https://Stackoverflow.com/users/476",
"pm_score": 2,
"selected": false,
"text": "<p>There's always the possibility to actually create the model file and set var $useTable = false.<br>\nIf this is not what you... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | In cake 1.2 there is a feature that allows the developer to no have to create models, but rather have cake do the detective work at run time and create the model for you. This process happens each time and is neat but in my case very hazardous. I read about this somewhere and now I'm experiencing the bad side of this.
... | **Cake 1.2**
It's a hack and it's ugly cus you need to edit core cake files but this is how i do it:
\cake\libs\class\_registry.php : line 127ish
```
if (App::import($type, $plugin . $class)) {
${$class} =& new $class($options);
} elseif ($type === 'Model') {
/* Print out whatever debug info we have then exit... |
100,376 | <p>Anyone know how to do picture overlay or appear on top of each other in HTML? The effect will be something like the marker/icon appear on Google Map where the user can specify the coordinate of the second picture appear on the first picture.</p>
<p>Thanks.</p>
| [
{
"answer_id": 100402,
"author": "Subimage",
"author_id": 10596,
"author_profile": "https://Stackoverflow.com/users/10596",
"pm_score": 2,
"selected": false,
"text": "<p>Use a DIV tag and CSS absolute positioning, with the z-index property.</p>\n\n<p><a href=\"http://www.w3.org/TR/CSS2/v... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14790/"
] | Anyone know how to do picture overlay or appear on top of each other in HTML? The effect will be something like the marker/icon appear on Google Map where the user can specify the coordinate of the second picture appear on the first picture.
Thanks. | You can use `<div>` containers to seperate content into multiple layers. Therefore the div containers have to be positioned absolutely and marked with a z-index. for instance:
```
<div style="position: absolute; z-index:100">This is in background</div>
<div style="position: absolute; z-index:5000">This is in foregrou... |
100,415 | <p>I'm looking for an open source, cross platform (Windows & Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.</p>
<p>Ideally the XHTML should just wrap the code with <code><... | [
{
"answer_id": 100439,
"author": "PW.",
"author_id": 927,
"author_profile": "https://Stackoverflow.com/users/927",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.vim.org/\" rel=\"nofollow noreferrer\">Vim</a> can save any code it highlights to \"colored\" HTML (it run... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1304/"
] | I'm looking for an open source, cross platform (Windows & Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.
Ideally the XHTML should just wrap the code with `<span>` and `<div>` ta... | I can recommend [Pygments](http://pygments.org/). It's easy to work with and supports a lot of languages. It does what you want, i.e., it wraps the code in `<span>` tags:
```
from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
code = 'print "Hello World... |
100,416 | <p>In SQL Server 2000/2005,</p>
<p>Is it possible to force the default value to be written to already existing rows when adding a new column to a table <strong>without</strong> using NOT NULL on the new column?</p>
| [
{
"answer_id": 100560,
"author": "chrisb",
"author_id": 8262,
"author_profile": "https://Stackoverflow.com/users/8262",
"pm_score": 1,
"selected": false,
"text": "<p>I doubt it.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms190273(SQL.90).aspx\" rel=\"nofollow noreferrer\... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7241/"
] | In SQL Server 2000/2005,
Is it possible to force the default value to be written to already existing rows when adding a new column to a table **without** using NOT NULL on the new column? | You need two statements. First create the column with not null. Then change the not null constraint to nullable
```
alter table mytable add mycolumn varchar(10) not null default ('a value')
alter table mytable alter column mycolumn varchar(10) null
``` |
100,435 | <p>I'm using a ASP.NET menu control. I'd like the menu to look like this, where link 1 through 10 are in one sitemap file and link 11 through 20 in another. </p>
<pre><code>root
--link 1
(...)
--link 10
--link 11
(...)
--link 20
</code></pre>
<p>However, sitemap file MUST have a root which I cannot seem to suppress.... | [
{
"answer_id": 101374,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 2,
"selected": true,
"text": "<p>Is there any reason that you can't add a dummy root node and then subclass the ASP.NET menu control to ignore y... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6399/"
] | I'm using a ASP.NET menu control. I'd like the menu to look like this, where link 1 through 10 are in one sitemap file and link 11 through 20 in another.
```
root
--link 1
(...)
--link 10
--link 11
(...)
--link 20
```
However, sitemap file MUST have a root which I cannot seem to suppress.
Any thoughts?
-Edoode | Is there any reason that you can't add a dummy root node and then subclass the ASP.NET menu control to ignore your dummy "root" node?
You should be able to tell your SiteMapProvider to use different site maps for the menu.
The other question I have is what's the purpose of having multiple sitemap files? I'm sure you ... |
100,444 | <p>I'm trying to automate a gdb session using the <code>--command</code> flag. I'm trying to set a breakpoint on a function in a shared library (the Unix equivalent of a DLL) . My cmds.gdb looks like this:</p>
<pre><code>set args /home/shlomi/conf/bugs/kde/font-break.txt
b IA__FcFontMatch
r
</code></pre>
<p>However, ... | [
{
"answer_id": 100501,
"author": "Shlomi Fish",
"author_id": 7709,
"author_profile": "https://Stackoverflow.com/users/7709",
"pm_score": 8,
"selected": true,
"text": "<p>Replying to myself, I'd like to give the answer that someone gave me on IRC:</p>\n\n<pre>\n(gdb) apropos pending\nacti... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7709/"
] | I'm trying to automate a gdb session using the `--command` flag. I'm trying to set a breakpoint on a function in a shared library (the Unix equivalent of a DLL) . My cmds.gdb looks like this:
```
set args /home/shlomi/conf/bugs/kde/font-break.txt
b IA__FcFontMatch
r
```
However, I'm getting the following:
```
shlo... | Replying to myself, I'd like to give the answer that someone gave me on IRC:
```
(gdb) apropos pending
actions -- Specify the actions to be taken at a tracepoint
set breakpoint -- Breakpoint specific settings
set breakpoint pending -- Set debugger's behavior regarding pending breakpoints
show breakpoint -- Breakpoint... |
100,504 | <p>Say I have a table called myTable. What is the SQL command to return all of the field names of this table? If the answer is database specific then I need SQL Server right now but would be interested in seeing the solution for other database systems as well.</p>
| [
{
"answer_id": 100513,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": "<p>MySQL 3 and 4 (and 5):</p>\n\n<pre><code>desc tablename\n</code></pre>\n\n<p>which is an alias for</p>\n\n<pre><co... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1856916/"
] | Say I have a table called myTable. What is the SQL command to return all of the field names of this table? If the answer is database specific then I need SQL Server right now but would be interested in seeing the solution for other database systems as well. | MySQL 3 and 4 (and 5):
```
desc tablename
```
which is an alias for
```
show fields from tablename
```
SQL Server (from 2000) and MySQL 5:
```
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'tablename'
```
Completing the answer: like people below have said, in SQL Server you can also us... |
100,533 | <p>Is it possible to do like this:</p>
<pre><code>interface IDBBase {
DataTable getDataTableSql(DataTable curTable,IDbCommand cmd);
...
}
class DBBase : IDBBase {
public DataTable getDataTableSql(DataTable curTable, SqlCommand cmd) {
...
}
}
</code></pre>
<p>I want to use the interface t... | [
{
"answer_id": 100562,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>No it's not possible. Method should have same signature that one declared in the interface.</p>\n\n<p>However you can use typ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to do like this:
```
interface IDBBase {
DataTable getDataTableSql(DataTable curTable,IDbCommand cmd);
...
}
class DBBase : IDBBase {
public DataTable getDataTableSql(DataTable curTable, SqlCommand cmd) {
...
}
}
```
I want to use the interface to implement to d/t provide... | No it's not possible. Method should have same signature that one declared in the interface.
However you can use type parameter constraints:
```
interface IDBClass<T> where T:IDbCommand
{
void Test(T cmd);
}
class DBClass:IDBClass<SqlCommand>
{
public void Test(SqlCommand cmd)
{
}
}
``` |
100,624 | <p>How to wait for multiple child processes in Python on Windows, without active wait (polling)? Something like this <em>almost</em> works for me:</p>
<pre><code>proc1 = subprocess.Popen(['python','mytest.py'])
proc2 = subprocess.Popen(['python','mytest.py'])
proc1.wait()
print "1 finished"
proc2.wait()
print "2 f... | [
{
"answer_id": 100886,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 5,
"selected": true,
"text": "<p>It might seem overkill, but, here it goes:</p>\n\n<pre><code>import Queue, thread, subprocess\n\nresults= Queue.Queue()\ndef ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12166/"
] | How to wait for multiple child processes in Python on Windows, without active wait (polling)? Something like this *almost* works for me:
```
proc1 = subprocess.Popen(['python','mytest.py'])
proc2 = subprocess.Popen(['python','mytest.py'])
proc1.wait()
print "1 finished"
proc2.wait()
print "2 finished"
```
The pr... | It might seem overkill, but, here it goes:
```
import Queue, thread, subprocess
results= Queue.Queue()
def process_waiter(popen, description, que):
try: popen.wait()
finally: que.put( (description, popen.returncode) )
process_count= 0
proc1= subprocess.Popen( ['python', 'mytest.py'] )
thread.start_new_thread... |
100,631 | <p>After our Ruby on Rails application has run for a while, it starts throwing 500s with "MySQL server has gone away". Often this happens overnight. It's started doing this recently, with no obvious change in our server configuration.</p>
<pre><code> Mysql::Error: MySQL server has gone away: SELECT * FROM `widgets`
</... | [
{
"answer_id": 100688,
"author": "David Precious",
"author_id": 4040,
"author_profile": "https://Stackoverflow.com/users/4040",
"pm_score": 1,
"selected": false,
"text": "<p>The connection to the MySQL server is probably timing out.</p>\n\n<p>You should be able to increase the timeout in... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18666/"
] | After our Ruby on Rails application has run for a while, it starts throwing 500s with "MySQL server has gone away". Often this happens overnight. It's started doing this recently, with no obvious change in our server configuration.
```
Mysql::Error: MySQL server has gone away: SELECT * FROM `widgets`
```
Restarting... | This is probably caused by the persistent connections to MySQL going away (time out is likely if it's happening over night) and Ruby on Rails is failing to restore the connection, which it should be doing by default:
In the file vendor/rails/actionpack/lib/action\_controller/dispatcher.rb is the code:
```
if defined?... |
100,633 | <p>Why is it bad practice to declare variables on one line?</p>
<p>e.g.</p>
<pre><code>private String var1, var2, var3
</code></pre>
<p>instead of: </p>
<pre><code>private String var1;
private String var2;
private String var3;
</code></pre>
| [
{
"answer_id": 100639,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 3,
"selected": false,
"text": "<p>Because in some languages, var2 and var3 in your example would <em>not</em> be strings, they would be variants (untype... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15352/"
] | Why is it bad practice to declare variables on one line?
e.g.
```
private String var1, var2, var3
```
instead of:
```
private String var1;
private String var2;
private String var3;
``` | I think that there are various reasons, but they all boil down to that the first is just less readable and more prone to failure because a single line is doing more than one thing.
And all that for no real gain, and don't you tell me you find two lines of saved space is a real gain.
It's a similar thing to what happe... |
100,645 | <p>Are there any tools available for calculating Cyclomatic Complexity in Javascript? </p>
<p>I've found it a very helpful metric in the past while working on server side code, and would like to be able to use it for the client side Javascript I write.</p>
| [
{
"answer_id": 198179,
"author": "kentaromiura",
"author_id": 27340,
"author_profile": "https://Stackoverflow.com/users/27340",
"pm_score": 3,
"selected": false,
"text": "<p>Since cyclomatic complexity is evaluated counting the number of keyword\n\"if, switch, while for break\" etc.. eve... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2932/"
] | Are there any tools available for calculating Cyclomatic Complexity in Javascript?
I've found it a very helpful metric in the past while working on server side code, and would like to be able to use it for the client side Javascript I write. | I helped write a tool to perform software complexity analysis on JavaScript projects:
[complexity-report](https://github.com/escomplex/complexity-report)
It reports a bunch of different complexity metrics: lines of code, number of parameters, cyclomatic complexity, cyclomatic density, Halstead complexity measures, th... |
100,654 | <p>I've got a c# application that plays simple wav files through directsound. With the test data I had, the code worked fine. However when I used real-world data, it produced a very unhelpful error on creation of the secondary buffer: "ArgumentException: Value does not fall within the expected range."</p>
<p>The tes... | [
{
"answer_id": 100675,
"author": "Mark Heath",
"author_id": 7532,
"author_profile": "https://Stackoverflow.com/users/7532",
"pm_score": 4,
"selected": true,
"text": "<p>Not all soundcards support 24 bit sample playback, and even when they do, they often have to be exclusively opened in t... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11801/"
] | I've got a c# application that plays simple wav files through directsound. With the test data I had, the code worked fine. However when I used real-world data, it produced a very unhelpful error on creation of the secondary buffer: "ArgumentException: Value does not fall within the expected range."
The test wavs had a... | Not all soundcards support 24 bit sample playback, and even when they do, they often have to be exclusively opened in that mode. There is a similar issue with sample rates. Your soundcard may be operating at 44.1kHz, in which case 48kHz needs to be resampled to be played.
I have written an open source .NET audio libra... |
100,678 | <pre><code>LRESULT result = ::SendMessage(hWnd, s_MaxGetTaskInterface, (WPARAM)&pUnkReturn, 0);
</code></pre>
<p>The value of result after the call is 0</p>
<p>I expect it to return with a valid value of pUnkReturn , but it returns with a NULL value .</p>
<p>Necessary Information before this call :</p>
<pre><c... | [
{
"answer_id": 100692,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "<p>When I Googled for <code>NI:Max:GetTaskInterface</code> I couldn't find anything. In general, how a window will handle a ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
LRESULT result = ::SendMessage(hWnd, s_MaxGetTaskInterface, (WPARAM)&pUnkReturn, 0);
```
The value of result after the call is 0
I expect it to return with a valid value of pUnkReturn , but it returns with a NULL value .
Necessary Information before this call :
```
const UINT CMotionUtils::s_MaxGetTaskInterfac... | I think the & in &pUnkReturn is needed, based on the hungarian prefix. I expect pUnkReturn to have type IUnknown\*. The message receiver will provide the IUnknown\*. The address where it will store that IUnknown\* is an IUnknown\*\*. Hence, this code passes in &pUnkReturn and the message receiver writes to \*(IUnknown\... |
100,689 | <p>I have a problem that confuses my users, being that although an item is highlighted (by the hover style) when the user mouses over it, they have to mouse over the actual item text, sometimes quite small compared to the item. Is there a way to make the whole item clickable?</p>
| [
{
"answer_id": 100706,
"author": "David Heggie",
"author_id": 4309,
"author_profile": "https://Stackoverflow.com/users/4309",
"pm_score": 3,
"selected": true,
"text": "<p>Add some padding to the A element? Or if it's in a menu contained within a block-level element, make the A display as... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | I have a problem that confuses my users, being that although an item is highlighted (by the hover style) when the user mouses over it, they have to mouse over the actual item text, sometimes quite small compared to the item. Is there a way to make the whole item clickable? | Add some padding to the A element? Or if it's in a menu contained within a block-level element, make the A display as block too:
```
a {
display: block;
width: 100%;
}
``` |
100,721 | <p>I am using <code>DirectoryInfo.GetDirectories()</code> recursively to find the all the sub-directories under a given path.
However, I want to exclude the System folders and there is no clear way for that.
In FindFirstFile/FindNextFile things were clearer with the attributes.</p>
| [
{
"answer_id": 100760,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 0,
"selected": false,
"text": "<p>You'd probably have to loop through the results and reject those with the attributes that you don't want (use the Attrib... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using `DirectoryInfo.GetDirectories()` recursively to find the all the sub-directories under a given path.
However, I want to exclude the System folders and there is no clear way for that.
In FindFirstFile/FindNextFile things were clearer with the attributes. | @rslite is right, .NET doesn't give such filtering out-of-box, but it's not hard to implement:
```
static IEnumerable<string> GetNonSystemDirs(string path)
{
var dirs = from d in Directory.GetDirectories(path)
let inf = new DirectoryInfo(d)
where (inf.Attributes & FileAttributes.Syste... |
100,732 | <p>I've seen several examples of code like this:</p>
<pre><code>if not someobj:
#do something
</code></pre>
<p>But I'm wondering why not doing:</p>
<pre><code>if someobj == None:
#do something
</code></pre>
<p>Is there any difference? Does one have an advantage over the other?</p>
| [
{
"answer_id": 100762,
"author": "Sylvain Defresne",
"author_id": 5353,
"author_profile": "https://Stackoverflow.com/users/5353",
"pm_score": 9,
"selected": true,
"text": "<p>In the first test, Python try to convert the object to a <code>bool</code> value if it is not already one. Roughl... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] | I've seen several examples of code like this:
```
if not someobj:
#do something
```
But I'm wondering why not doing:
```
if someobj == None:
#do something
```
Is there any difference? Does one have an advantage over the other? | In the first test, Python try to convert the object to a `bool` value if it is not already one. Roughly, **we are asking the object : are you meaningful or not ?** This is done using the following algorithm :
1. If the object has a `__nonzero__` special method (as do numeric built-ins, `int` and `float`), it calls thi... |
100,774 | <p>The following JavaScript supposes to read the popular tags from an XML file and applies the XSL Stylesheet and output to the browser as HTML.</p>
<pre><code>function ShowPopularTags() {
xml = XMLDocLoad("http://localhost/xml/tags/popular.xml?s=94987898");
xsl = XMLDocLoad("http://localhost/xml/xsl/popular-tag... | [
{
"answer_id": 100887,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 0,
"selected": false,
"text": "<p>Well, that code follows entirely different paths for IE and everything-else. I assume the problem is limited to one of them... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17074/"
] | The following JavaScript supposes to read the popular tags from an XML file and applies the XSL Stylesheet and output to the browser as HTML.
```
function ShowPopularTags() {
xml = XMLDocLoad("http://localhost/xml/tags/popular.xml?s=94987898");
xsl = XMLDocLoad("http://localhost/xml/xsl/popular-tags.xsl");
if... | Are you forced into the synchronous solution you are using now, or is an asynchronous solution an option as well? I recall Firefox has had it's share of problems with synchronous calls in the past, and I don't know how much of that is still carried with it. I have seen situations where the entire Firefox interface woul... |
100,808 | <p>I want to receive the following <code>HTTP</code> request in <code>PHP:</code></p>
<pre><code>Content-type: multipart/form-data;boundary=main_boundary
--main_boundary
Content-type: text/xml
<?xml version='1.0'?>
<content>
Some content goes here
</content>
--main_boundary
Content-type: multipart/... | [
{
"answer_id": 100825,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": -1,
"selected": false,
"text": "<p>Uploadeds files will be accessible through the $_FILE global variable, other parameters will be accessible trough the $_GE... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] | I want to receive the following `HTTP` request in `PHP:`
```
Content-type: multipart/form-data;boundary=main_boundary
--main_boundary
Content-type: text/xml
<?xml version='1.0'?>
<content>
Some content goes here
</content>
--main_boundary
Content-type: multipart/mixed;boundary=sub_boundary
--sub_boundary
Conten... | `$HTTP_GET_VARS`, `$HTTP_POST_VARS`, etc. is an obsolete notation, you should be using `$_GET`, `$_POST`, etc.
Now, the file contents should be in the `$_FILES` global array, whereas, if there are no element names, I'm not sure about whether the rest of the content will show up in `$_POST`. Anyway, if `always_populate... |
100,812 | <p>Not for the first time, I've accidentally done "svn switch" from somewhere below the root of my project. This switches that subdirectory only, but how do I undo this?</p>
<p>If I try switching the subdirectory back to the original branch I get:</p>
<pre><code>"svn: Directory 'subdir\_svn' containing working copy a... | [
{
"answer_id": 100823,
"author": "Alexander",
"author_id": 16724,
"author_profile": "https://Stackoverflow.com/users/16724",
"pm_score": 3,
"selected": false,
"text": "<p>Quick hack: Delete the directory, go one level up, and run svn update.</p>\n"
},
{
"answer_id": 100870,
"... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17641/"
] | Not for the first time, I've accidentally done "svn switch" from somewhere below the root of my project. This switches that subdirectory only, but how do I undo this?
If I try switching the subdirectory back to the original branch I get:
```
"svn: Directory 'subdir\_svn' containing working copy admin area is missing"... | Quick hack: Delete the directory, go one level up, and run svn update. |
100,824 | <p>The code below shows a sample that I've used recently to explain the different behaviour of structs and classes to someone brand new to development. Is there a better way of doing so? (Yes - the code uses public fields - that's purely for brevity)</p>
<pre><code>namespace StructsVsClasses
{
class Program
{
... | [
{
"answer_id": 100856,
"author": "Grimtron",
"author_id": 17378,
"author_profile": "https://Stackoverflow.com/users/17378",
"pm_score": 1,
"selected": false,
"text": "<p>I guess it's OK to show the difference as far as value/reference types are concerned this way. It might be a little bi... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7872/"
] | The code below shows a sample that I've used recently to explain the different behaviour of structs and classes to someone brand new to development. Is there a better way of doing so? (Yes - the code uses public fields - that's purely for brevity)
```
namespace StructsVsClasses
{
class Program
{
static... | The difference might be easier to understand when the struct/class is a member of another class.
Example with class:
```
class PointClass {
int double X;
int double Y;
}
class Circle {
PointClass Center = new PointClass() { X = 0, Y = 0; }
}
static void Main() {
Circle c = new Circle();
Console.WriteLine(... |
100,829 | <p>I'm trying to write a script to allow me to log in to a console servers 48 ports so that I can quickly determine what devices are connected to each serial line.</p>
<p>Essentially I want to be able to have a script that, given a list of hosts/ports, telnets to the first device in the list and leaves me in interacti... | [
{
"answer_id": 100842,
"author": "stephanea",
"author_id": 8776,
"author_profile": "https://Stackoverflow.com/users/8776",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps you could try bash -i to force the session to be in interactive mode.</p>\n"
},
{
"answer_id": 100879,
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6306/"
] | I'm trying to write a script to allow me to log in to a console servers 48 ports so that I can quickly determine what devices are connected to each serial line.
Essentially I want to be able to have a script that, given a list of hosts/ports, telnets to the first device in the list and leaves me in interactive mode so... | You need to redirect the Terminal input to the `telnet` process. This should be `/dev/tty`. So your script will look something like:
```
#!/bin/bash
for HOST in `cat`
do
echo Connecting to $HOST...
telnet $HOST </dev/tty
done
``` |
100,832 | <p>I would like to repeatedly capture snippets of audio on a Nokia mobile phone with a Java Midlet. My current experience is that using the code in Sun's documentation (see: <a href="http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/RecordControl.html" rel="nofollow noreferrer">http://ja... | [
{
"answer_id": 100871,
"author": "Sarien",
"author_id": 1994377,
"author_profile": "https://Stackoverflow.com/users/1994377",
"pm_score": 0,
"selected": false,
"text": "<p>I think you should file a bugreport instead of trying to work around that.</p>\n"
},
{
"answer_id": 109485,
... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18699/"
] | I would like to repeatedly capture snippets of audio on a Nokia mobile phone with a Java Midlet. My current experience is that using the code in Sun's documentation (see: <http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/RecordControl.html>) and wrapping this in a "while(true)" loop wor... | There is a known memory leak with the N-series Nokia devices. It is not specific to Java and is in the underbelly of the OS somewhere.
Recently working on a game that targeted the Nokia N90, I had similar problems. I would run into memory problems that would accumulate over several different restarts of the applicatio... |
100,853 | <p>While editing an aspx file I found both these opening tags used for seemingly the same thing. Is there a difference and if yes, what is it?</p>
| [
{
"answer_id": 100875,
"author": "Sergio Acosta",
"author_id": 2954,
"author_profile": "https://Stackoverflow.com/users/2954",
"pm_score": 1,
"selected": false,
"text": "<p>The difference is that the # symbol specifies a data binding directive, that is resolved at data binding time (for ... | 2008/09/19 | [
"https://Stackoverflow.com/questions/100853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5018/"
] | While editing an aspx file I found both these opening tags used for seemingly the same thing. Is there a difference and if yes, what is it? | `<%=` is a equivalent to `<% Repsonse.Write()`
You can write any content out here: for example
```
<%=myProperty + " additional Text" %>
```
`<%#` is a binding expression. You can retrieve any public value in the current context (for example in GridViews). But you cannot mix content here.
Take a look at [MSDN](ht... |