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
112,102
<p>Is there a secure way of logging into a Gmail account on a web browser, from an external Java program? I know the following works, but is there a safer alternative?</p> <pre><code>Desktop.getDesktop().browse(new URI( "https://www.google.com/accounts/ServiceLoginAuth?continue=http://mail.google.com/gmail" + ...
[ { "answer_id": 112108, "author": "Armin Ronacher", "author_id": 19990, "author_profile": "https://Stackoverflow.com/users/19990", "pm_score": 1, "selected": false, "text": "<p>If you are afraid that the link is visible in the Page, create a javascript document that sends a POST request t...
2008/09/21
[ "https://Stackoverflow.com/questions/112102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20029/" ]
Is there a secure way of logging into a Gmail account on a web browser, from an external Java program? I know the following works, but is there a safer alternative? ``` Desktop.getDesktop().browse(new URI( "https://www.google.com/accounts/ServiceLoginAuth?continue=http://mail.google.com/gmail" + "&serv...
Depending of how much you want to integrate, you can check Google single sign-on (SSO) api. I'm studing how to use it and the best way to integrate it <http://code.google.com/apis/apps/sso/saml_reference_implementation.html> Victor UPDATED: As a better option, you should check this link as well <http://esoeproject....
112,158
<p>On my team, we usually do string concatentation like this:</p> <pre><code>var url = // some dynamically generated URL var sb = new StringBuffer(); sb.append("&lt;a href='").append(url).append("'&gt;click here&lt;/a&gt;"); </code></pre> <p>Obviously the following is much more readable:</p> <pre><code>var url = // ...
[ { "answer_id": 112164, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 5, "selected": false, "text": "<p>Yes it's true but you shouldn't care. Go with the one that's easier to read. If you have to benchmark your app, then fo...
2008/09/21
[ "https://Stackoverflow.com/questions/112158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
On my team, we usually do string concatentation like this: ``` var url = // some dynamically generated URL var sb = new StringBuffer(); sb.append("<a href='").append(url).append("'>click here</a>"); ``` Obviously the following is much more readable: ``` var url = // some dynamically generated URL var sb = "<a href=...
Internet Explorer is the only browser which really suffers from this in today's world. (Versions 5, 6, and 7 were dog slow. 8 does not show the same degradation.) What's more, IE gets slower and slower the longer your string is. If you have long strings to concatenate then definitely use an array.join technique. (Or s...
112,169
<p>For years I've been using ShellExecute() API to launch the default web browser from within my applications. Like this:</p> <pre><code>ShellExecute( hwnd, _T("open"), _T("http://www.winability.com/home/"), NULL, NULL, SW_NORMAL ); </code></pre> <p>It's been working fine until a couple of weeks ago, when G...
[ { "answer_id": 112213, "author": "Sergey Kornilov", "author_id": 10969, "author_profile": "https://Stackoverflow.com/users/10969", "pm_score": 3, "selected": true, "text": "<p>Here is the code that works across all browsers. The trick is to call WinExec if ShellExecute fails.</p>\n\n<pre...
2008/09/21
[ "https://Stackoverflow.com/questions/112169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17037/" ]
For years I've been using ShellExecute() API to launch the default web browser from within my applications. Like this: ``` ShellExecute( hwnd, _T("open"), _T("http://www.winability.com/home/"), NULL, NULL, SW_NORMAL ); ``` It's been working fine until a couple of weeks ago, when Google released its Chrome ...
Here is the code that works across all browsers. The trick is to call WinExec if ShellExecute fails. ``` HINSTANCE GotoURL(LPCTSTR url, int showcmd) { TCHAR key[MAX_PATH + MAX_PATH]; // First try ShellExecute() HINSTANCE result = 0; CString strURL = url; if ( strURL.Find(".htm") <0 && strURL.Fin...
112,197
<p>I want to create a hidden field and create a link in one helper and then output both to my erb.</p> <pre><code>&lt;%= my_cool_helper "something", form %&gt; </code></pre> <p>Should out put the results of</p> <pre><code>link_to "something", a_path form.hidden_field "something".tableize, :value =&gt; "something" </...
[ { "answer_id": 112210, "author": "Sixty4Bit", "author_id": 1681, "author_profile": "https://Stackoverflow.com/users/1681", "pm_score": 4, "selected": false, "text": "<p>So far the best I have come up with is:</p>\n\n<pre><code>def my_cool_helper(name, form)\n out = capture { link_to nam...
2008/09/21
[ "https://Stackoverflow.com/questions/112197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1681/" ]
I want to create a hidden field and create a link in one helper and then output both to my erb. ``` <%= my_cool_helper "something", form %> ``` Should out put the results of ``` link_to "something", a_path form.hidden_field "something".tableize, :value => "something" ``` What would the definition of the helper lo...
There are several ways to do this. Remember that the existing rails helpers like `link_to`, etc, just output strings. You can concatenate the strings together and return that (which is what I do most of the time, if things are simple). EG: ``` link_to( "something", something_path ) + #NOTE THE PLUS FOR STRING CONCA...
112,224
<p>I made a panel and set it to fill the screen, now I can see the windows under it but I want it to be click through, meaning they could click a file or see a tool tip of another object through the transparency.</p> <blockquote> <blockquote> <p>RE: This may be too obvious, but have you tried sending the panel t...
[ { "answer_id": 112593, "author": "Phil Wright", "author_id": 6276, "author_profile": "https://Stackoverflow.com/users/6276", "pm_score": 6, "selected": true, "text": "<p>Creating a top level form that is transparent is very easy. Just make it fill the screen, or required area, and define...
2008/09/21
[ "https://Stackoverflow.com/questions/112224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18309/" ]
I made a panel and set it to fill the screen, now I can see the windows under it but I want it to be click through, meaning they could click a file or see a tool tip of another object through the transparency. > > > > > > RE: This may be too obvious, but have you tried sending the panel to the back by right clickin...
Creating a top level form that is transparent is very easy. Just make it fill the screen, or required area, and define it to have a TransparenyKey color and BackColor of the same value. Getting it to ignore the mouse is simple enough, you just need to override the WndProc and tell the WM\_HITTEST that all mouse posit...
112,234
<p>Let's say that I have two arrays (in Java),</p> <p>int[] numbers; and int[] colors;</p> <p>Each ith element of numbers corresponds to its ith element in colors. Ex, numbers = {4,2,1} colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc.</p> <p>I want to sort the numbers array...
[ { "answer_id": 112240, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 0, "selected": false, "text": "<p>You need to sort the colors array by its relative item in the numbers array. Specify a comparator that compares ...
2008/09/21
[ "https://Stackoverflow.com/questions/112234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16773/" ]
Let's say that I have two arrays (in Java), int[] numbers; and int[] colors; Each ith element of numbers corresponds to its ith element in colors. Ex, numbers = {4,2,1} colors = {0x11, 0x24, 0x01}; Means that number 4 is color 0x11, number 2 is 0x24, etc. I want to sort the numbers array, but then still have it so...
You could use sort() with a custom comparator if you kept a third array with the index, and sorted on that, leaving the data intact. Java code example: ``` Integer[] idx = new Integer[numbers.length]; for( int i = 0 ; i < idx.length; i++ ) idx[i] = i; Arrays.sort(idx, new Comparator<Integer>() { pub...
112,235
<p>There are certain Crystal Reports features that cannot be combined in the same report, for example SQL command objects and server side grouping. However, as far as I can find, the built-in help doesn't seem to clearly document these conflicts. For example, checking the help page for either of those features doesn't ...
[ { "answer_id": 112240, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 0, "selected": false, "text": "<p>You need to sort the colors array by its relative item in the numbers array. Specify a comparator that compares ...
2008/09/21
[ "https://Stackoverflow.com/questions/112235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20068/" ]
There are certain Crystal Reports features that cannot be combined in the same report, for example SQL command objects and server side grouping. However, as far as I can find, the built-in help doesn't seem to clearly document these conflicts. For example, checking the help page for either of those features doesn't men...
You could use sort() with a custom comparator if you kept a third array with the index, and sorted on that, leaving the data intact. Java code example: ``` Integer[] idx = new Integer[numbers.length]; for( int i = 0 ; i < idx.length; i++ ) idx[i] = i; Arrays.sort(idx, new Comparator<Integer>() { pub...
112,249
<p>I have a very large database table in PostgresQL and a column like "copied". Every new row starts uncopied and will later be replicated to another thing by a background programm. There is an partial index on that table "btree(ID) WHERE replicated=0". The background programm does a select for at most 2000 entries (LI...
[ { "answer_id": 112260, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 3, "selected": false, "text": "<p>How about adding a new table to store this replicated value (and a primary key to link each record to the main table). Then...
2008/09/21
[ "https://Stackoverflow.com/questions/112249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20088/" ]
I have a very large database table in PostgresQL and a column like "copied". Every new row starts uncopied and will later be replicated to another thing by a background programm. There is an partial index on that table "btree(ID) WHERE replicated=0". The background programm does a select for at most 2000 entries (LIMIT...
How about adding a new table to store this replicated value (and a primary key to link each record to the main table). Then you simply add a record for every replicated item, and delete records to remove the replicated flag. (Or maybe the other way around - a record for every non-replicated record, depending on which i...
112,277
<p>Static metaprogramming (aka "template metaprogramming") is a great C++ technique that allows the execution of programs at compile-time. A light bulb went off in my head as soon as I read this canonical metaprogramming example:</p> <pre><code>#include &lt;iostream&gt; using namespace std; template&lt; int n &gt; s...
[ { "answer_id": 112285, "author": "Maxim Ananyev", "author_id": 404206, "author_profile": "https://Stackoverflow.com/users/404206", "pm_score": 2, "selected": false, "text": "<p>google Alexandrescu, Modern C++ Design: Generic Programming and Design Patterns Applied</p>\n" }, { "an...
2008/09/21
[ "https://Stackoverflow.com/questions/112277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10559/" ]
Static metaprogramming (aka "template metaprogramming") is a great C++ technique that allows the execution of programs at compile-time. A light bulb went off in my head as soon as I read this canonical metaprogramming example: ``` #include <iostream> using namespace std; template< int n > struct factorial { enum { re...
*[Answering my own question]* The best introductions I've found so far are chapter 10, "Static Metaprogramming in C++" from *Generative Programming, Methods, Tools, and Applications* by Krzysztof Czarnecki and Ulrich W. Eisenecker, ISBN-13: 9780201309775; and chapter 17, "Metaprograms" of *C++ Templates: The Complete ...
112,372
<p>Is it possible to over interface? when designing an system now, I will start from interfaces and progressively write unit tests along with the interfaces until I have a pattern that works well.. I'll move onto writing some concrete classes and set the unit tests up against these..</p> <p>Now I'm someone who loves i...
[ { "answer_id": 112385, "author": "TonyOssa", "author_id": 3276, "author_profile": "https://Stackoverflow.com/users/3276", "pm_score": 0, "selected": false, "text": "<p>ISwissArmyKnife!</p>\n\n<p>Consult this:</p>\n\n<p><a href=\"http://thedailywtf.com/Articles/Classic-WTF-Implements-ISwi...
2008/09/21
[ "https://Stackoverflow.com/questions/112372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to over interface? when designing an system now, I will start from interfaces and progressively write unit tests along with the interfaces until I have a pattern that works well.. I'll move onto writing some concrete classes and set the unit tests up against these.. Now I'm someone who loves interfaces,...
Interfaces describe a contract for behavior. If you need to address some set of objects according to a behavioral pattern, interfaces are useful, not so much if you're simply describing the structure of objects. I think you need to have a good reason to use them, such as using a factory that creates behaviorally relate...
112,396
<p>I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit (<a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> and <a href="http://en.wikipedia.org/wiki/Apache_Subversion" rel="noreferrer">SVN</a>) to a remot...
[ { "answer_id": 112409, "author": "Torsten Marek", "author_id": 9567, "author_profile": "https://Stackoverflow.com/users/9567", "pm_score": 12, "selected": true, "text": "<p>Short answer:</p>\n\n<pre><code>$ ssh-keygen -p\n</code></pre>\n\n<p>This will then prompt you to enter the keyfile...
2008/09/21
[ "https://Stackoverflow.com/questions/112396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14191/" ]
I set a passphrase when creating a new SSH key on my laptop. But, as I realise now, this is quite painful when you are trying to commit ([Git](http://en.wikipedia.org/wiki/Git_%28software%29) and [SVN](http://en.wikipedia.org/wiki/Apache_Subversion)) to a remote location over SSH many times in an hour. One way I can t...
Short answer: ``` $ ssh-keygen -p ``` This will then prompt you to enter the keyfile location, the old passphrase, and the new passphrase (which can be left blank to have no passphrase). --- If you would like to do it all on one line without prompts do: ``` $ ssh-keygen -p [-P old_passphrase] [-N new_passphrase] ...
112,412
<p>I would like to use Visual Studio 2008 to the greatest extent possible while effectively compiling/linking/building/etc code as if all these build processes were being done by the tools provided with MASM 6.11. The exact version of MASM does not matter, so long as it's within the 6.x range, as that is what my colleg...
[ { "answer_id": 112600, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 1, "selected": false, "text": "<p>instead of batch files, why not use the a custom build step defined on the file?</p>\n" }, { "answer_id": 192118, ...
2008/09/21
[ "https://Stackoverflow.com/questions/112412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20110/" ]
I would like to use Visual Studio 2008 to the greatest extent possible while effectively compiling/linking/building/etc code as if all these build processes were being done by the tools provided with MASM 6.11. The exact version of MASM does not matter, so long as it's within the 6.x range, as that is what my college i...
There is a MASM rules file located at (32-bit system remove `(x86)`): ``` C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\masm.rules ``` Copy that file to your project directory, and add it to the Custom Build Rules for your project. Then "Modify Rule File...", select the MASM build rule and ...
112,433
<p>In a C++ project I'm working on, I have a <em>flag</em> kind of value which can have four values. Those four flags can be combined. Flags describe the records in database and can be:</p> <ul> <li>new record</li> <li>deleted record</li> <li>modified record</li> <li>existing record</li> </ul> <p>Now, for each record...
[ { "answer_id": 112445, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 2, "selected": false, "text": "<p>Even if you have to use 4 byte to store an enum (I'm not that familiar with C++ -- I know you can specify the und...
2008/09/21
[ "https://Stackoverflow.com/questions/112433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14690/" ]
In a C++ project I'm working on, I have a *flag* kind of value which can have four values. Those four flags can be combined. Flags describe the records in database and can be: * new record * deleted record * modified record * existing record Now, for each record I wish to keep this attribute, so I could use an enum: ...
Combine the strategies to reduce the disadvantages of a single approach. I work in embedded systems so the following solution is based on the fact that integer and bitwise operators are fast, low memory & low in flash usage. Place the enum in a namespace to prevent the constants from polluting the global namespace. `...
112,439
<p>If you had read my other <a href="https://stackoverflow.com/questions/111700/6502-cpu-emulation">question</a>, you'll know I've spent this weekend putting together a 6502 CPU emulator as a programming exercise.</p> <p>The CPU emulator is mostly complete, and seems to be fairly accurate from my limited testing, howe...
[ { "answer_id": 112467, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 2, "selected": false, "text": "<p>I would use the clock cycles to calculate time and them sleep the difference in time. Of course, to do this, you need...
2008/09/21
[ "https://Stackoverflow.com/questions/112439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
If you had read my other [question](https://stackoverflow.com/questions/111700/6502-cpu-emulation), you'll know I've spent this weekend putting together a 6502 CPU emulator as a programming exercise. The CPU emulator is mostly complete, and seems to be fairly accurate from my limited testing, however it is running inc...
I wrote a Z80 emulator many years ago, and to do cycle accurate execution, I divided the clock rate into a number of small blocks and had the core execute that many clock cycles. In my case, I tied it to the frame rate of the game system I was emulating. Each opcode knew how many cycles it took to execute and the core ...
112,440
<p>I'm getting a JS error on displaying a page: Nothing concrete is specified but the line where it seems to be thrown. When looking into the source code of the page, I see the error is thrown inside the following script, but I can't understand why! It's only about loading images!</p> <pre><code> &lt;SCRIPT languag...
[ { "answer_id": 112449, "author": "Florian Bösch", "author_id": 19435, "author_profile": "https://Stackoverflow.com/users/19435", "pm_score": 1, "selected": false, "text": "<p>Write proper xml with the \" around attributes.</p>\n\n<pre><code>&lt;script type=\"text/javascript\"&gt;\nfuncti...
2008/09/21
[ "https://Stackoverflow.com/questions/112440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19159/" ]
I'm getting a JS error on displaying a page: Nothing concrete is specified but the line where it seems to be thrown. When looking into the source code of the page, I see the error is thrown inside the following script, but I can't understand why! It's only about loading images! ``` <SCRIPT language=JavaScript> <!-...
Have you tried loading your scripts into a JS debugger such as [Aptana](http://www.aptana.com/) or Firefox plugin like [Firebug](https://addons.mozilla.org/en-US/firefox/addon/1843)?
112,503
<p>Given an array of <strong>n</strong> Objects, let's say it is an <strong>array of strings</strong>, and it has the following values:</p> <pre><code>foo[0] = "a"; foo[1] = "cc"; foo[2] = "a"; foo[3] = "dd"; </code></pre> <p>What do I have to do to delete/remove all the strings/objects equal to <strong>"a"</strong> ...
[ { "answer_id": 112507, "author": "Dustman", "author_id": 16398, "author_profile": "https://Stackoverflow.com/users/16398", "pm_score": 4, "selected": false, "text": "<p>Make a <code>List</code> out of the array with <code>Arrays.asList()</code>, and call <code>remove()</code> on all the ...
2008/09/21
[ "https://Stackoverflow.com/questions/112503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4358/" ]
Given an array of **n** Objects, let's say it is an **array of strings**, and it has the following values: ``` foo[0] = "a"; foo[1] = "cc"; foo[2] = "a"; foo[3] = "dd"; ``` What do I have to do to delete/remove all the strings/objects equal to **"a"** in the array?
[If you want some ready-to-use code, please scroll to my "Edit3" (after the cut). The rest is here for posterity.] To flesh out [Dustman's idea](https://stackoverflow.com/a/112507/13): ``` List<String> list = new ArrayList<String>(Arrays.asList(array)); list.removeAll(Arrays.asList("a")); array = list.toArray(array);...
112,517
<p>I have the following enum:</p> <pre><code>public enum Status implements StringEnum{ ONLINE("on"),OFFLINE("off"); private String status = null; private Status(String status) { this.status = status; } public String toString() { return this.status; } public static Stat...
[ { "answer_id": 112553, "author": "Frank Pape", "author_id": 10367, "author_profile": "https://Stackoverflow.com/users/10367", "pm_score": 4, "selected": true, "text": "<p>It's not possible to specify either constructors or static methods in an interface. For a good, concise explanation, ...
2008/09/21
[ "https://Stackoverflow.com/questions/112517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128/" ]
I have the following enum: ``` public enum Status implements StringEnum{ ONLINE("on"),OFFLINE("off"); private String status = null; private Status(String status) { this.status = status; } public String toString() { return this.status; } public static Status find(String...
It's not possible to specify either constructors or static methods in an interface. For a good, concise explanation, check out this article: [No static methods in interfaces](http://zoom.z3950.org/bind/java/comment/static.html)
112,532
<p>How would a go about making a program where the user enters a string, and the program generates a list of words beginning with that string?</p> <p>Ex:<br /> User: "abd"<br /> Program:abdicate, abdomen, abduct...</p> <p>Thanks!</p> <hr> <p>Edit: I'm using python, but I assume that this is a fairly language-indep...
[ { "answer_id": 112540, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": 1, "selected": false, "text": "<pre><code>var words = from word in dictionary\n where word.key.StartsWith(\"bla-bla-bla\");\n ...
2008/09/21
[ "https://Stackoverflow.com/questions/112532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
How would a go about making a program where the user enters a string, and the program generates a list of words beginning with that string? Ex: User: "abd" Program:abdicate, abdomen, abduct... Thanks! --- Edit: I'm using python, but I assume that this is a fairly language-independent problem.
If you on a debian[-like] machine, ``` #!/bin/bash echo -n "Enter a word: " read input grep "^$input" /usr/share/dict/words ``` Takes all of 0.040s on my P200.
112,564
<p>I recently discovered the genshi.builder module. It reminds me of Divmod Nevow's Stan module. How would one use genshi.builder.tag to build an HTML document with a particular doctype? Or is this even a good thing to do? If not, what is the <em>right</em> way?</p>
[ { "answer_id": 112659, "author": "alif", "author_id": 12650, "author_profile": "https://Stackoverflow.com/users/12650", "pm_score": 2, "selected": false, "text": "<p>Genshi.builder is for \"programmatically generating markup streams\"[1]. I believe the purpose of it is as a backend for t...
2008/09/21
[ "https://Stackoverflow.com/questions/112564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
I recently discovered the genshi.builder module. It reminds me of Divmod Nevow's Stan module. How would one use genshi.builder.tag to build an HTML document with a particular doctype? Or is this even a good thing to do? If not, what is the *right* way?
It's not possible to build an entire page using just `genshi.builder.tag` -- you would need to perform some surgery on the resulting stream to insert the doctype. Besides, the resulting code would look horrific. The recommended way to use Genshi is to use a separate template file, generate a stream from it, and then re...
112,582
<p>I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: </p> <pre><code>#include&lt;stdio.h&gt; #define MAX 255 int main(){ int arr[MAX]={0}; int idx=...
[ { "answer_id": 112586, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 2, "selected": false, "text": "<pre><code>arr[idx] &lt;= MAX\n</code></pre>\n\n<p>should be</p>\n\n<pre><code>idx &lt;= MAX\n</code></pre>\n" }, { ...
2008/09/21
[ "https://Stackoverflow.com/questions/112582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6992/" ]
I'm having a hard time understanding and therefore managing arrays and indexes manually in C. These are my two classic approaches but they doesn't seem to work as they keep looping when the condition is reached: ``` #include<stdio.h> #define MAX 255 int main(){ int arr[MAX]={0}; int idx=0; /* Approach ...
``` arr[idx] <= MAX ``` should be ``` idx < MAX ``` unless you are checking the item instead of the index. You are also always checking the "next" element for -1 (arr[idx] != -1) because you are incrementing idx prior to checking your added value. so if you had ``` arr[idx-1] != -1 ``` you would be fine.
112,601
<p>I want to select the topmost element in a document that has a given namespace (prefix).</p> <p>More specifically: I have XML documents that either start with /html/body (in the XHTML namespace) or with one of several elements in a particular namespace. I effectively want to strip out /html/body and just return the ...
[ { "answer_id": 112602, "author": "Craig Walker", "author_id": 3488, "author_profile": "https://Stackoverflow.com/users/3488", "pm_score": 2, "selected": false, "text": "<p>The XPath expression that I want is:</p>\n\n<pre><code>/html:html/html:body/node()|/foo:*\n</code></pre>\n\n<p>Where...
2008/09/21
[ "https://Stackoverflow.com/questions/112601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
I want to select the topmost element in a document that has a given namespace (prefix). More specifically: I have XML documents that either start with /html/body (in the XHTML namespace) or with one of several elements in a particular namespace. I effectively want to strip out /html/body and just return the body conte...
In XPath 2.0 and XQuery 1.0 you can test against the namespace prefix using the [in-scope-prefixes()](http://www.w3.org/TR/xquery-operators/#func-in-scope-prefixes) function in a predicate. e.g. ``` //*[in-scope-prefixes(.)='html'] ``` If you cant use v2, in XPath 1.0 you can use the [namespace-uri()](http://www.w3...
112,612
<p>I am hosting <a href="http://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference" rel="nofollow noreferrer">SpiderMonkey</a> in a current project and would like to have template functions generate some of the simple property get/set methods, eg:</p> <pre><code>template &lt;typename TClassImpl, int32 TClassImpl::*...
[ { "answer_id": 112679, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 0, "selected": false, "text": "<p>Try changing the JSObject * to another pointer type to see if that reproduces the error. Is JSObject defined at the ...
2008/09/22
[ "https://Stackoverflow.com/questions/112612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20135/" ]
I am hosting [SpiderMonkey](http://developer.mozilla.org/En/SpiderMonkey/JSAPI_Reference) in a current project and would like to have template functions generate some of the simple property get/set methods, eg: ``` template <typename TClassImpl, int32 TClassImpl::*mem> JSBool JS_DLL_CALLBACK WriteProp(JSContext* cx, J...
Pretty sure VC++ has "issues" here. Comeau and g++ 4.2 are both happy with the following program: ``` struct X { int i; void* p; }; template<int X::*P> void foo(X* t) { t->*P = 0; } template<void* X::*P> void foo(X* t) { t->*P = 0; } int main() { X x; foo<&X::i>(&x); foo<&X::p>(&x); } `...
112,643
<p>I know how to create a <code>SEL</code> at compile time using <code>@selector(MyMethodName:)</code> but what I want to do is create a selector dynamically from an <code>NSString</code>. Is this even possible?</p> <p>What I can do:</p> <pre><code>SEL selector = @selector(doWork:); [myobj respondsToSelector:selector...
[ { "answer_id": 112668, "author": "Torsten Marek", "author_id": 9567, "author_profile": "https://Stackoverflow.com/users/9567", "pm_score": 8, "selected": true, "text": "<p>I'm not an Objective-C programmer, merely a sympathizer, but maybe <a href=\"https://developer.apple.com/documentati...
2008/09/22
[ "https://Stackoverflow.com/questions/112643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18590/" ]
I know how to create a `SEL` at compile time using `@selector(MyMethodName:)` but what I want to do is create a selector dynamically from an `NSString`. Is this even possible? What I can do: ``` SEL selector = @selector(doWork:); [myobj respondsToSelector:selector]; ``` What I want to do: (pseudo code, this obvious...
I'm not an Objective-C programmer, merely a sympathizer, but maybe [NSSelectorFromString](https://developer.apple.com/documentation/foundation/1395294-nsselectorfromstring?language=objc) is what you need. It's mentioned explicity in the [Runtime Reference](http://developer.apple.com/documentation/Cocoa/Conceptual/Objec...
112,664
<p>I can connect to my SQL Server database via sqlcmd from a DOS command window, but not from a Cygwin window. From DOS:</p> <pre><code>F:\Cygnus&gt;sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS </code></pre> <hr> <p>a test</p> <p>(1 rows affected)</p> <pre><code>F:\Cygnus&gt; </code></pre> <p>=====================...
[ { "answer_id": 112688, "author": "PostMan", "author_id": 18405, "author_profile": "https://Stackoverflow.com/users/18405", "pm_score": 0, "selected": false, "text": "<p>You may have to allow remote connections for this, and give the full server name i.e SERVER\\SQLEXPRESS</p>\n" }, {...
2008/09/22
[ "https://Stackoverflow.com/questions/112664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8670/" ]
I can connect to my SQL Server database via sqlcmd from a DOS command window, but not from a Cygwin window. From DOS: ``` F:\Cygnus>sqlcmd -Q "select 'a test'" -S .\SQLEXPRESS ``` --- a test (1 rows affected) ``` F:\Cygnus> ``` ==================================================== From Cygwin: ``` $ sqlcmd -Q ...
The backslash is being eaten by cygwin's bash shell. Try doubling it: ``` sqlcmd -Q "select 'a test'" -S .\\SQLEXPRESS ```
112,707
<p>Whenever I indent <code>HTML</code> in <code>PHP</code> mode, <code>emacs (22.1.1, basic install on Redaht Linux over Putty-SSH)</code> pops up a frame and tells me to get <code>MUMODE</code> or <code>somesuch</code> extra add-on. I installed <code>PHP</code> Mode without a big hassle, but I don't know how to get t...
[ { "answer_id": 112906, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 3, "selected": true, "text": "<p>If you're running emacs 22, you should just be able to run:</p>\n\n<pre><code>M-x nxhtml-mumamo\n</code></pre>\n\n<p>wh...
2008/09/22
[ "https://Stackoverflow.com/questions/112707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
Whenever I indent `HTML` in `PHP` mode, `emacs (22.1.1, basic install on Redaht Linux over Putty-SSH)` pops up a frame and tells me to get `MUMODE` or `somesuch` extra add-on. I installed `PHP` Mode without a big hassle, but I don't know how to get this multi-mode rolling. --- I'd like to know 2 things ``` How to ...
If you're running emacs 22, you should just be able to run: ``` M-x nxhtml-mumamo ``` when editing an html document. You might want to add it to your auto-mode-alist to get it to automatically load for html docs. See here for more info: <http://www.emacswiki.org/cgi-bin/wiki/MuMaMo> <http://www.emacswiki.org/cgi...
112,721
<p>I've got the following situation</p> <ul> <li>A rails application that makes use of rjs / Scriptaculous to offer AJAX functionality</li> <li>Lot of nice javascript written using jQuery (for a separate application)</li> </ul> <p>I want to combine the two and use my jQuery based functionality in my Rails application...
[ { "answer_id": 112731, "author": "Jason Peacock", "author_id": 18381, "author_profile": "https://Stackoverflow.com/users/18381", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://ennerchi.com/projects/jrails\" rel=\"nofollow noreferrer\">jRails</a> is a drop-in replacement f...
2008/09/22
[ "https://Stackoverflow.com/questions/112721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16779/" ]
I've got the following situation * A rails application that makes use of rjs / Scriptaculous to offer AJAX functionality * Lot of nice javascript written using jQuery (for a separate application) I want to combine the two and use my jQuery based functionality in my Rails application, but I'm worried about jQuery and ...
``` jQuery.noConflict(); ``` Then use jQuery instead of $ to refer to jQuery. e.g., ``` jQuery('div.foo').doSomething() ``` If you need to adapt jQuery code that uses $, you can surround it with this: ``` (function($) { ...your code here... })(jQuery); ```
112,730
<p>I have a <code>n...n</code> structure for two tables, <strong><code>makes</code></strong> and <strong><code>models</code></strong>. So far no problem.</p> <p>In a third table (<strong><code>products</code></strong>) like:</p> <pre><code>id make_id model_id ... </code></pre> <p>My problem is creating a view for pr...
[ { "answer_id": 112868, "author": "JayTee", "author_id": 20153, "author_profile": "https://Stackoverflow.com/users/20153", "pm_score": 1, "selected": false, "text": "<p>Here's my hint: Try getting your query written in regular SQL before trying to reconstruct using the Cake library. In ...
2008/09/22
[ "https://Stackoverflow.com/questions/112730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2274/" ]
I have a `n...n` structure for two tables, **`makes`** and **`models`**. So far no problem. In a third table (**`products`**) like: ``` id make_id model_id ... ``` My problem is creating a view for products of one specifi **`make`** inside my `ProductsController` containing just that's make models: I thought this ...
The solution can be achieved with the use of the `with` operation in habtm array on the model. Using `with` you can define the "middle" table like: ``` $habtm = " ... 'with' => 'MakeModel', ... "; ``` And internally, in the Model or Controller, you can issue conditions to the `find` method. See: <http://www....
112,738
<p>Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented? </p>
[ { "answer_id": 112756, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 0, "selected": false, "text": "<p>I think it's a template class that declares a member variable for the arguments you want to bind and overloads () for ...
2008/09/22
[ "https://Stackoverflow.com/questions/112738", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
Without spending a long time reviewing the boost source code, could someone give me a quick rundown of how boost bind is implemented?
I like this piece of the `bind` source: ``` template<class R, class F, class L> class bind_t { public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {} #define BOOST_BIND_RETURN return #include <boost/bind/bind_template.hpp> #undef BOOST_BIND_RETURN }; ``` Tells you almost all you need...
112,768
<p>(ClientCookie is a module for (automatic) cookie-handling: <a href="http://wwwsearch.sourceforge.net/ClientCookie" rel="nofollow noreferrer">http://wwwsearch.sourceforge.net/ClientCookie</a>)</p> <pre><code># I encode the data I'll be sending: data = urllib.urlencode({'username': 'mandark', 'password': 'deedee'}) ...
[ { "answer_id": 112819, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 3, "selected": true, "text": "<p>Have you tried fetching the login page first?</p>\n\n<p>I would suggest using <a href=\"https://addons.mozilla.org/...
2008/09/22
[ "https://Stackoverflow.com/questions/112768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
(ClientCookie is a module for (automatic) cookie-handling: <http://wwwsearch.sourceforge.net/ClientCookie>) ``` # I encode the data I'll be sending: data = urllib.urlencode({'username': 'mandark', 'password': 'deedee'}) # And I send it and read the page: page = ClientCookie.urlopen('http://www.forum.com/ucp.php?mode=...
Have you tried fetching the login page first? I would suggest using [Tamper Data](https://addons.mozilla.org/en-US/firefox/addon/966) to have a peek at exactly what's being sent when you request the login page and then log in normally using a web browser from a fresh start, with no initial cookies in place, so that yo...
112,770
<p>Our subversion repository has been moved to a new host, and we have old applications that connect to that host. We CANNOT add an alias for the new server with the old name, how can we re-connect our checked out clients to the new repository?</p>
[ { "answer_id": 112773, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "<p>Look up the <a href=\"http://svnbook.red-bean.com/en/1.0/re27.html\" rel=\"noreferrer\">svn switch</a> command. In par...
2008/09/22
[ "https://Stackoverflow.com/questions/112770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20150/" ]
Our subversion repository has been moved to a new host, and we have old applications that connect to that host. We CANNOT add an alias for the new server with the old name, how can we re-connect our checked out clients to the new repository?
Example: ``` svn switch --relocate \ http://svn.example.com/path/to/repository/path/within/repository \ http://svnnew.example.com/new/repository/path/within/repository ``` One thing which is to remember, lets assume you checked out the project "path/within/repository" then you have to go to the **root of you...
112,775
<p>Is it possible to have a <code>MySQLi prepared statement</code> within the <code>fetch()</code> call of a previous statement? If not, what's the best way around it?</p> <p>Example code:</p> <pre><code>if($stmt = $link-&gt;prepare("SELECT item FROM data WHERE id = ?")) { $stmt-&gt;bind_param("i", $id); $stm...
[ { "answer_id": 112800, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 3, "selected": true, "text": "<p>You should be able to do that, although you make have to start a second connection. </p>\n" }, { "answer_id": 16753...
2008/09/22
[ "https://Stackoverflow.com/questions/112775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6305/" ]
Is it possible to have a `MySQLi prepared statement` within the `fetch()` call of a previous statement? If not, what's the best way around it? Example code: ``` if($stmt = $link->prepare("SELECT item FROM data WHERE id = ?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($item); ...
You should be able to do that, although you make have to start a second connection.
112,796
<p>Is there a way to view the key/value pairs of a NSDictionary variable through the Xcode debugger? Here's the extent of information when it is fully expanded in the variable window:</p> <pre><code>Variable Value Summary jsonDict 0x45c540 4 key/value pairs NSObject {...} isa 0xa06e0720 </code></pre> ...
[ { "answer_id": 112808, "author": "craigb", "author_id": 18590, "author_profile": "https://Stackoverflow.com/users/18590", "pm_score": 8, "selected": true, "text": "<p>In the gdb window you can use <code>po</code> to inspect the object.</p>\n\n<p>given:</p>\n\n<pre><code>NSMutableDictiona...
2008/09/22
[ "https://Stackoverflow.com/questions/112796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11292/" ]
Is there a way to view the key/value pairs of a NSDictionary variable through the Xcode debugger? Here's the extent of information when it is fully expanded in the variable window: ``` Variable Value Summary jsonDict 0x45c540 4 key/value pairs NSObject {...} isa 0xa06e0720 ``` I was expecting it to s...
In the gdb window you can use `po` to inspect the object. given: ``` NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; [dict setObject:@"foo" forKey:@"bar"]; [dict setObject:@"fiz" forKey:@"buz"]; ``` setting a breakpoint after the objects are added you can inspect what is in the dictionary ``` (gdb)...
112,812
<p>How do I access parameters passed into an Oracle Form via a URL. Eg given the url:</p> <blockquote> <p><a href="http://example.com/forms90/f90servlet?config=cust&amp;form=" rel="nofollow noreferrer">http://example.com/forms90/f90servlet?config=cust&amp;form=</a>'a_form'&amp;p1=something&amp;p2=else</p> </blockqu...
[ { "answer_id": 113990, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 2, "selected": true, "text": "<p>Within Forms you can refer to the parameters p1 an p2 as follows:</p>\n\n<ul>\n<li>:PARAMETER.p1</li>\n<li>:PARAMET...
2008/09/22
[ "https://Stackoverflow.com/questions/112812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1505600/" ]
How do I access parameters passed into an Oracle Form via a URL. Eg given the url: > > <http://example.com/forms90/f90servlet?config=cust&form=>'a\_form'&p1=something&p2=else > > > This will launch the 'a\_form' form, using the 'cust' configuration, but I can't work how (or even if it's possible) to access p1 (wi...
Within Forms you can refer to the parameters p1 an p2 as follows: * :PARAMETER.p1 * :PARAMETER.p2 e.g. ``` if :PARAMETER.p1 = 'something' then do_something; end if; ```
112,818
<p>I am creating a standalone asp.net page that needs to be embedded into a sharepoint site using the Page Viewer Web Part. The asp.net page is published to the same server on a different port, giving me the URL to embed.</p> <p>The requirement is that after a user is authenticated using Sharepoint authentication, th...
[ { "answer_id": 112828, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 0, "selected": false, "text": "<p>When it works in debug, is that being used in SharePoint?</p>\n\n<p>Your page and the Sharepoint site might as well be...
2008/09/22
[ "https://Stackoverflow.com/questions/112818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11703/" ]
I am creating a standalone asp.net page that needs to be embedded into a sharepoint site using the Page Viewer Web Part. The asp.net page is published to the same server on a different port, giving me the URL to embed. The requirement is that after a user is authenticated using Sharepoint authentication, they navigate...
If you want to retrieve the currently authenticated user from the SharePoint context, you need to remain within the SharePoint context. This means hosting your custom web application within SharePoint (see [http://msdn.microsoft.com/en-us/library/cc297200.aspx](http://msdn.microsoft.com/en-us/library/cc297200.aspx "Dep...
112,861
<p>According to the documentation the return value from a slot doesn't mean anything.<br> Yet in the generated moc code I see that if a slot returns a value this value is used for something. Any idea what does it do?</p> <hr> <p>Here's an example of what I'm talking about. this is taken from code generated by moc. 'm...
[ { "answer_id": 112960, "author": "David Dibben", "author_id": 5022, "author_profile": "https://Stackoverflow.com/users/5022", "pm_score": 4, "selected": false, "text": "<p>Looking through the Qt source it seems that when a slot is called from QMetaObject::invokeMethod the return type can...
2008/09/22
[ "https://Stackoverflow.com/questions/112861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
According to the documentation the return value from a slot doesn't mean anything. Yet in the generated moc code I see that if a slot returns a value this value is used for something. Any idea what does it do? --- Here's an example of what I'm talking about. this is taken from code generated by moc. 'message' is a...
Looking through the Qt source it seems that when a slot is called from QMetaObject::invokeMethod the return type can be specified and the return value obtained. (Have a look at invokeMethod in the Qt help) I could not find many examples of this actually being used in the Qt source. One I found was ``` bool QAbstractI...
112,892
<p>How would retrieve all customer's birthdays for a given month in SQL? What about MySQL? I was thinking of using the following with SQL server.</p> <pre><code>select c.name from cust c where datename(m,c.birthdate) = datename(m,@suppliedDate) order by c.name </code></pre>
[ { "answer_id": 112894, "author": "rickripe", "author_id": 20169, "author_profile": "https://Stackoverflow.com/users/20169", "pm_score": 2, "selected": false, "text": "<p>Personally I would use DATEPART instead of DATENAME as DATENAME is open to interpretation depending on locale.</p>\n" ...
2008/09/22
[ "https://Stackoverflow.com/questions/112892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5618/" ]
How would retrieve all customer's birthdays for a given month in SQL? What about MySQL? I was thinking of using the following with SQL server. ``` select c.name from cust c where datename(m,c.birthdate) = datename(m,@suppliedDate) order by c.name ```
don't forget the 29th February... ``` SELECT c.name FROM cust c WHERE ( MONTH(c.birthdate) = MONTH(@suppliedDate) AND DAY(c.birthdate) = DAY(@suppliedDate) ) OR ( MONTH(c.birthdate) = 2 AND DAY(c.birthdate) = 29 AND MONTH(@suppliedDate) = 3 AND DAY(@suppliedDate) = 1 AND (YEAR(@suppliedDate) % 4 = ...
112,897
<p>The code currently does this and the fgetpos does handle files larger than 4GB but the seek returns an error, so any idea how to seek to the end of a <code>file &gt; 4GB</code>?</p> <pre><code>fpos_t currentpos; sok=fseek(fp,0,SEEK_END); assert(sok==0,"Seek error!"); fgetpos(fp,&amp;currentpos); m_filesize=curren...
[ { "answer_id": 112910, "author": "Captain Segfault", "author_id": 18408, "author_profile": "https://Stackoverflow.com/users/18408", "pm_score": 1, "selected": false, "text": "<p>On linux, at least, you could use lseek64 instead of fseek.</p>\n" }, { "answer_id": 112913, "auth...
2008/09/22
[ "https://Stackoverflow.com/questions/112897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13676/" ]
The code currently does this and the fgetpos does handle files larger than 4GB but the seek returns an error, so any idea how to seek to the end of a `file > 4GB`? ``` fpos_t currentpos; sok=fseek(fp,0,SEEK_END); assert(sok==0,"Seek error!"); fgetpos(fp,&currentpos); m_filesize=currentpos; ```
If you're in Windows, you want [GetFileSizeEx (MSDN)](http://msdn.microsoft.com/en-us/library/aa364957(VS.85).aspx). The return value is a 64bit int. On linux [stat64 (manpage)](http://www.manpagez.com/man/2/stat64/) is correct. fstat if you're working with a FILE\*.
112,964
<p>Ubuntu has 8 run levels (0-6 and S), I want to add the run level 7.</p> <p>I have done the following:</p> <p>1.- Created the folder <strong>/etc/rc7.d/</strong>, which contains some symbolic links to <strong>/etc/init.d/</strong></p> <p>2.- Created the file <strong>/etc/event.d/rc7</strong> This is its content:</...
[ { "answer_id": 113005, "author": "Zathrus", "author_id": 16220, "author_profile": "https://Stackoverflow.com/users/16220", "pm_score": 3, "selected": true, "text": "<p>You cannot; the runlevels are hardcoded into the utilities. But why do you need to? Runlevel 4 is essentially unused. An...
2008/09/22
[ "https://Stackoverflow.com/questions/112964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7852/" ]
Ubuntu has 8 run levels (0-6 and S), I want to add the run level 7. I have done the following: 1.- Created the folder **/etc/rc7.d/**, which contains some symbolic links to **/etc/init.d/** 2.- Created the file **/etc/event.d/rc7** This is its content: ``` # rc7 - runlevel 7 compatibility # # This task runs the old...
You cannot; the runlevels are hardcoded into the utilities. But why do you need to? Runlevel 4 is essentially unused. And while it's not the best idea, you could repurpose either runlevel 3 or runlevel 5 depending on if you always/never use X. Note that some \*nix systems have support for more than 6 runlevels, but Li...
112,977
<p>I want to implement Generics in my Page Class like :</p> <pre><code>Public Class MyClass(Of TheClass) Inherits System.Web.UI.Page </code></pre> <p>But for this to work, I need to be able to instantiate the Class (with the correct Generic Class Type) and load the page, instead of a regular Response.Redirect. Is the...
[ { "answer_id": 113080, "author": "Costo", "author_id": 1130, "author_profile": "https://Stackoverflow.com/users/1130", "pm_score": 2, "selected": false, "text": "<p>I'm not sure to fully understand what you want to do.\nIf you want something like a generic Page, you can use a generic Bas...
2008/09/22
[ "https://Stackoverflow.com/questions/112977", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to implement Generics in my Page Class like : ``` Public Class MyClass(Of TheClass) Inherits System.Web.UI.Page ``` But for this to work, I need to be able to instantiate the Class (with the correct Generic Class Type) and load the page, instead of a regular Response.Redirect. Is there a way to do this ?
I'm not sure to fully understand what you want to do. If you want something like a generic Page, you can use a generic BasePage and put your generic methods into that BasePage: ``` Partial Public Class MyPage Inherits MyGenericBasePage(Of MyType) End Class Public Class MyGenericBasePage(Of T As New) Inherits...
112,983
<p>I want to display data like the following:</p> <pre><code> Title Subject Summary Date </code></pre> <p>So my <code>HTML</code> looks like:</p> <pre><code>&lt;div class="title"&gt;&lt;/div&gt; &lt;div class="subject"&gt;&lt;/div&gt; &lt;div class="summary"&gt;&lt;/div&gt; &lt;div class="date"&gt;&lt;/div...
[ { "answer_id": 112994, "author": "Andy Lester", "author_id": 8454, "author_profile": "https://Stackoverflow.com/users/8454", "pm_score": 5, "selected": false, "text": "<p>It looks like you're wanting to display a table, right? So go ahead and use the &lt;table&gt; tag.</p>\n" }, { ...
2008/09/22
[ "https://Stackoverflow.com/questions/112983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
I want to display data like the following: ``` Title Subject Summary Date ``` So my `HTML` looks like: ``` <div class="title"></div> <div class="subject"></div> <div class="summary"></div> <div class="date"></div> ``` The problem is, all the text doesn't appear on a single line. I tried adding `display...
It looks like you're wanting to display a table, right? So go ahead and use the <table> tag.
113,033
<p>I have three (C++) classes: Player, Hand, and Card.</p> <p>Player has a member, hand, that holds a Hand. It also has a method, getHand(), that returns the contents of hand.</p> <pre><code>Hand Player::getHand() { return hand; } </code></pre> <p>Hand has a method, addCard(Card c), that adds a card to the hand....
[ { "answer_id": 113035, "author": "Adam Mitz", "author_id": 2574, "author_profile": "https://Stackoverflow.com/users/2574", "pm_score": 2, "selected": false, "text": "<p>If getHand() returns by-value you're modifying a copy of the hand and not the original.</p>\n" }, { "answer_id"...
2008/09/22
[ "https://Stackoverflow.com/questions/113033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18420/" ]
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand, that holds a Hand. It also has a method, getHand(), that returns the contents of hand. ``` Hand Player::getHand() { return hand; } ``` Hand has a method, addCard(Card c), that adds a card to the hand. I want to do this: player1.get...
If getHand() is not returning a reference you will be in trouble.
113,045
<pre><code>SELECT GETDATE() </code></pre> <p>Returns: <code>2008-09-22 15:24:13.790</code></p> <p>I want that date part without the time part: <code>2008-09-22 00:00:00.000</code></p> <p>How can I get that?</p>
[ { "answer_id": 113051, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 6, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>SELECT CONVERT(VARCHAR(10),GETDATE(),111)\n</code></pre>\n\n<p>The above statement converts ...
2008/09/22
[ "https://Stackoverflow.com/questions/113045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5769/" ]
``` SELECT GETDATE() ``` Returns: `2008-09-22 15:24:13.790` I want that date part without the time part: `2008-09-22 00:00:00.000` How can I get that?
``` SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) ``` for example ``` SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) ``` gives me ``` 2008-09-22 00:00:00.000 ``` Pros: * No varchar<->datetime conversions required * No need to think about locale
113,077
<p>I am creating a site in which different pages can look very different depending upon certain conditions (ie logged in or not, form filled out or not, etc). This makes it necessary to output diferent blocks of html at different times.</p> <p>Doing that, however, makes my php code look horrific... it really messes w...
[ { "answer_id": 113081, "author": "da5id", "author_id": 14979, "author_profile": "https://Stackoverflow.com/users/14979", "pm_score": 0, "selected": false, "text": "<p>In cases like that I write everything incrementally into a variable or sometimes an array and then echo the variable/arra...
2008/09/22
[ "https://Stackoverflow.com/questions/113077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I am creating a site in which different pages can look very different depending upon certain conditions (ie logged in or not, form filled out or not, etc). This makes it necessary to output diferent blocks of html at different times. Doing that, however, makes my php code look horrific... it really messes with the for...
Don't panic, every fresh Web programmer face this problem. You HAVE TO separate your program logic from your display. First, try to make your own solution using two files for each Web page : * one with only PHP code (no HTML) that fills variables * another with HTML and very few PHP : this is your page design Then i...
113,103
<p>Can anyone explain the difference between the "name" property of a display object and the value found by <em>getChildByName("XXX")</em> function? They're the same 90% of the time, until they aren't, and things fall apart.</p> <p>For example, in the code below, I find an object by instance name only by directly exa...
[ { "answer_id": 113603, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 0, "selected": false, "text": "<p>I haven't really managed to understand what it is you're doing. But one thing I've found is that accessing MovieClip's c...
2008/09/22
[ "https://Stackoverflow.com/questions/113103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4969/" ]
Can anyone explain the difference between the "name" property of a display object and the value found by *getChildByName("XXX")* function? They're the same 90% of the time, until they aren't, and things fall apart. For example, in the code below, I find an object by instance name only by directly examining the child's...
It seems you fixed it yourself! With: ``` var do1:DisplayObject = gfx.amSword.getChildByName["amWeaponExchange"]; ``` You get the error: ``` ReferenceError: Error #1069: Property amWeaponExchange not found on builtin.as$0.MethodClosure and there is no default value. ``` Because the compiler is looking for the p...
113,131
<p>What WPF Calendar control would you recommend? I am looking for something that will let me display a variable amount of weeks potentially spanning multiple months.</p>
[ { "answer_id": 113188, "author": "Dominic Hopton", "author_id": 9475, "author_profile": "https://Stackoverflow.com/users/9475", "pm_score": 0, "selected": false, "text": "<p>I would take a look at <a href=\"http://j832.com/BagOTricks/\" rel=\"nofollow noreferrer\">Kevin's Bag-o-tricks</a...
2008/09/22
[ "https://Stackoverflow.com/questions/113131", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5618/" ]
What WPF Calendar control would you recommend? I am looking for something that will let me display a variable amount of weeks potentially spanning multiple months.
Microsoft has now released a WPF calendar control. ``` <c:Calendar> <c:DatePicker.BlackoutDates> <c:CalendarDateRange Start="4/1/2008" End="4/6/2008"/> <c:CalendarDateRange Start="4/14/2008" End="4/17/2008"/> </c:DatePicker.BlackoutDates> </c:Calendar> <c:DatePicker> <c:DatePicker.Blackout...
113,150
<p>I have the following situation:</p> <pre><code> class A { public: A(int whichFoo); int foo1(); int foo2(); int foo3(); int callFoo(); // cals one of the foo's depending on the value of whichFoo }; </code></pre> <p>In my current implementation I save the value of <code>whichFoo</code> in a data ...
[ { "answer_id": 113155, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "<p>How sure are you that calling a member function via a pointer is slower than just calling it directly? Can you measure ...
2008/09/22
[ "https://Stackoverflow.com/questions/113150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13313/" ]
I have the following situation: ``` class A { public: A(int whichFoo); int foo1(); int foo2(); int foo3(); int callFoo(); // cals one of the foo's depending on the value of whichFoo }; ``` In my current implementation I save the value of `whichFoo` in a data member in the constructor and use a `...
How sure are you that calling a member function via a pointer is slower than just calling it directly? Can you measure the difference? In general, you should not rely on your intuition when making performance evaluations. Sit down with your compiler and a timing function, and actually *measure* the different choices. ...
113,185
<p>I've installed <a href="http://www.owfs.org/" rel="nofollow noreferrer"><code>owfs</code></a> and am trying to read the data off a <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4088" rel="nofollow noreferrer">iButton temperature logger</a>.</p> <p><code>owfs</code> lets me mount the iButton as a fuse files...
[ { "answer_id": 117532, "author": "Armin Ronacher", "author_id": 19990, "author_profile": "https://Stackoverflow.com/users/19990", "pm_score": 2, "selected": false, "text": "<p>I don't think there is a clever way. owpython doesn't support that telling from the API documentation. I guess...
2008/09/22
[ "https://Stackoverflow.com/questions/113185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
I've installed [`owfs`](http://www.owfs.org/) and am trying to read the data off a [iButton temperature logger](http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4088). `owfs` lets me mount the iButton as a fuse filesystem and I can see all the data. I'm having trouble figuring out what is the best way to access the data ...
I don't think there is a clever way. owpython doesn't support that telling from the API documentation. I guess `/proc` is your safest bet. Maybe have a look at the source of the owpython module and check if you can find out how it works.
113,218
<p>I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer.</p> <p>Below is a small example of what I'm trying to achieve. Basically, there is a select box (with the...
[ { "answer_id": 113211, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 2, "selected": false, "text": "<p>I like <a href=\"http://www.gtk.org/\" rel=\"nofollow noreferrer\">GTK+</a> personally but that or any of the ones yo...
2008/09/22
[ "https://Stackoverflow.com/questions/113218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer. Below is a small example of what I'm trying to achieve. Basically, there is a select box (with the id "selectB...
I have both worked with PyQt and wxPython extensively. PyQt is better designed and comes with very good UI designer so that you can quickly assemble your UI wxPython has a very good demo and it can do pretty much anything which PyQT can do, I would anyday prefer PyQt but it may bot be free for commercial purpose but w...
113,253
<p>My web page sits in a DIV that is 960px wide, I center this DIV in the middle of the page by using the code: </p> <pre><code>html,body{background: url(images/INF_pageBg.gif) center top repeat-y #777777;text-align:center;} #container{background-color:#ffffff;width:960px;text-align:left;margin:0 auto 0 auto;} </co...
[ { "answer_id": 113268, "author": "dimarzionist", "author_id": 10778, "author_profile": "https://Stackoverflow.com/users/10778", "pm_score": 3, "selected": true, "text": "<p>Yeah, it's known issue. Unfortunately you only can fix div and image width, or use script to dynamically change sty...
2008/09/22
[ "https://Stackoverflow.com/questions/113253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/910/" ]
My web page sits in a DIV that is 960px wide, I center this DIV in the middle of the page by using the code: ``` html,body{background: url(images/INF_pageBg.gif) center top repeat-y #777777;text-align:center;} #container{background-color:#ffffff;width:960px;text-align:left;margin:0 auto 0 auto;} ``` I need the back...
Yeah, it's known issue. Unfortunately you only can fix div and image width, or use script to dynamically change stye.backgroundPosition property. Another trick is to put expression to the CSS class definition.
113,275
<p>Here is what I have:</p> <pre><code> context "Create ingredient from string" do context "1 cups butter" do setup do @ingredient = Ingredient.create(:ingredient_string =&gt; "1 cups butter") end should "return unit" do assert_equal @ingredient.unit, 'cups'...
[ { "answer_id": 113359, "author": "Andrew", "author_id": 17408, "author_profile": "https://Stackoverflow.com/users/17408", "pm_score": 0, "selected": false, "text": "<p>Personally for this test, I wouldn't use Shoulda.\nYou can easily remove duplication by using dynamic method creation as...
2008/09/22
[ "https://Stackoverflow.com/questions/113275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12448/" ]
Here is what I have: ``` context "Create ingredient from string" do context "1 cups butter" do setup do @ingredient = Ingredient.create(:ingredient_string => "1 cups butter") end should "return unit" do assert_equal @ingredient.unit, 'cups' end ...
Here's a solution to your specific problem. The idea is to create a class method (like Shoulda's context, setup and should). Encapsulate the repetition in a class method accepting all varying parts as arguments like this: ``` def self.should_get_unit_amount_and_name_from_string(unit, amount, name, string_to_analyze) ...
113,341
<p>I'm trying to create a character generation wizard for a game. In one class I calculate the attributes of the character. In a different class, I'm displaying to the user which specialties are available based on the attributes of the character. However, I can't remember how to pass variables between different classes...
[ { "answer_id": 113374, "author": "Antti Rasinen", "author_id": 8570, "author_profile": "https://Stackoverflow.com/users/8570", "pm_score": 0, "selected": false, "text": "<p>If I understood you correctly, then the answer is: You can't.</p>\n\n<p>intelligence should be an attribute of Wiza...
2008/09/22
[ "https://Stackoverflow.com/questions/113341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18676/" ]
I'm trying to create a character generation wizard for a game. In one class I calculate the attributes of the character. In a different class, I'm displaying to the user which specialties are available based on the attributes of the character. However, I can't remember how to pass variables between different classes. ...
You may have "Class" and "Instance" confused. It's not clear from your example, so I'll presume that you're using a lot of class definitions and don't have appropriate object instances of those classes. Classes don't really have usable attribute values. A class is just a common set of definitions for a collection of o...
113,349
<p>I have an AdvancedDataGrid with a GroupingCollection and a SummaryRow. How do I display the summary row data in bold? Below is my code:</p> <pre><code>&lt;mx:AdvancedDataGrid width="100%" height="100%" id="adg" defaultLeafIcon="{null}" &gt; &lt;mx:dataProvider&gt; &lt;mx:GroupingCollection id="gc" sou...
[ { "answer_id": 114323, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 0, "selected": false, "text": "<p>If I've understood <a href=\"http://livedocs.adobe.com/flex/3/html/advdatagrid_10.html\" rel=\"nofollow noreferrer\">...
2008/09/22
[ "https://Stackoverflow.com/questions/113349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16534/" ]
I have an AdvancedDataGrid with a GroupingCollection and a SummaryRow. How do I display the summary row data in bold? Below is my code: ``` <mx:AdvancedDataGrid width="100%" height="100%" id="adg" defaultLeafIcon="{null}" > <mx:dataProvider> <mx:GroupingCollection id="gc" source="{dataProvider}"> ...
in the past when I have need to do this I had to put a condition in my style function to try and determine if it is a summary row or not. ``` public function dataGrid_styleFunction (data:Object, column:AdvancedDataGridColumn) : Object { var output:Object; if ( data.children != null ) { ...
113,376
<p>How do you impose a character limit on a text input in HTML?</p>
[ { "answer_id": 113379, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 5, "selected": false, "text": "<p>there's a maxlength attribute</p>\n\n<pre><code>&lt;input type=\"text\" name=\"textboxname\" maxlength=\"100\" /&gt;\n</c...
2008/09/22
[ "https://Stackoverflow.com/questions/113376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5509/" ]
How do you impose a character limit on a text input in HTML?
There are 2 main solutions: The pure HTML one: ``` <input type="text" id="Textbox" name="Textbox" maxlength="10" /> ``` The JavaScript one (attach it to a onKey Event): ``` function limitText(limitField, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring...
113,384
<p>I have a marker interface defined as</p> <pre><code>public interface IExtender&lt;T&gt; { } </code></pre> <p>I have a class that implements IExtender</p> <pre><code>public class UserExtender : IExtender&lt;User&gt; </code></pre> <p>At runtime I recieve the UserExtender type as a parameter to my evaluating method...
[ { "answer_id": 113379, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 5, "selected": false, "text": "<p>there's a maxlength attribute</p>\n\n<pre><code>&lt;input type=\"text\" name=\"textboxname\" maxlength=\"100\" /&gt;\n</c...
2008/09/22
[ "https://Stackoverflow.com/questions/113384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4884/" ]
I have a marker interface defined as ``` public interface IExtender<T> { } ``` I have a class that implements IExtender ``` public class UserExtender : IExtender<User> ``` At runtime I recieve the UserExtender type as a parameter to my evaluating method ``` public Type Evaluate(Type type) // type == typeof(UserE...
There are 2 main solutions: The pure HTML one: ``` <input type="text" id="Textbox" name="Textbox" maxlength="10" /> ``` The JavaScript one (attach it to a onKey Event): ``` function limitText(limitField, limitNum) { if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring...
113,385
<p>Is there anyway to declare an object of a class before the class is created in C++? I ask because I am trying to use two classes, the first needs to have an instance of the second class within it, but the second class also contains an instance of the first class. I realize that you may think I might get into an in...
[ { "answer_id": 113391, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 3, "selected": false, "text": "<p>You can't declare an instance of an undefined class but you can declare a <strong>pointer</strong> to one:</p>\n\n<pr...
2008/09/22
[ "https://Stackoverflow.com/questions/113385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20229/" ]
Is there anyway to declare an object of a class before the class is created in C++? I ask because I am trying to use two classes, the first needs to have an instance of the second class within it, but the second class also contains an instance of the first class. I realize that you may think I might get into an infinit...
You can't do something like this: ``` class A { B b; }; class B { A a; }; ``` The most obvious problem is the compiler doesn't know how to large it needs to make class A, because the size of B depends on the size of A! You can, however, do this: ``` class B; // this is a "forward declaration" class A { ...
113,392
<p>I'm trying to wrap my head around asp.net. I have a background as a long time php developer, but I'm now facing the task of learning asp.net and I'm having some trouble with it. It might very well be because I'm trying to force the framework into something it is not intended for - so I'd like to learn how to do it "...
[ { "answer_id": 113411, "author": "Jesper Blad Jensen", "author_id": 11559, "author_profile": "https://Stackoverflow.com/users/11559", "pm_score": 0, "selected": false, "text": "<p>Well. If you can get out of creating controls dynamicly, then do so - otherwise, what i whould do is to use ...
2008/09/22
[ "https://Stackoverflow.com/questions/113392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17700/" ]
I'm trying to wrap my head around asp.net. I have a background as a long time php developer, but I'm now facing the task of learning asp.net and I'm having some trouble with it. It might very well be because I'm trying to force the framework into something it is not intended for - so I'd like to learn how to do it "the...
I agree with the other points made here "If you can get out of creating controls dynamically, then do so..." (by @[Jesper Blad Jenson aka](https://stackoverflow.com/users/11559/jesper-blad-jensen-aka-deldy)) but here is a trick I worked out with dynamically created controls in the past. The problem becomes chicken and...
113,395
<p>Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can pass in an exception like this:</p> <pre><code>[TestMethod] [ExpectedException(typeof(CriticalException))] public void GetOrganisation_MultipleOrganisations_ThrowsException() </code></pre> <p>You can also check for ...
[ { "answer_id": 113420, "author": "cruizer", "author_id": 6441, "author_profile": "https://Stackoverflow.com/users/6441", "pm_score": 2, "selected": false, "text": "<p>I think you can just do an explicit try-catch in your test code instead of relying on the ExpectedException attribute to ...
2008/09/22
[ "https://Stackoverflow.com/questions/113395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5790/" ]
Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can pass in an exception like this: ``` [TestMethod] [ExpectedException(typeof(CriticalException))] public void GetOrganisation_MultipleOrganisations_ThrowsException() ``` You can also check for the message contained with...
*Just* an opinion, but I would say the error text: * is part of the test, in which case getting it from the resource would be 'wrong' (otherwise you could end up with a consistantly mangled resource), so just update the test when you change the resource (or the test fails) * is not part of the test, and you should onl...
113,504
<p>Is there a way to be sure we hold a useable reference to an object i.e. being sure it has not been already freed leaving that non nil reference dangling.</p>
[ { "answer_id": 113512, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>Unfortunately there is no way to 100% guarantee that a pointer to anything is still valid, except by meticolously ...
2008/09/22
[ "https://Stackoverflow.com/questions/113504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to be sure we hold a useable reference to an object i.e. being sure it has not been already freed leaving that non nil reference dangling.
If you're using FastMM4 as your Memory Manager, you can check that the class is not **TFreeObject**. Or, in a more standard case, use a routine that will verify that your object is what it says it is by **checking the class VMT**. There have been such ValidateObj functions hannging around for some time (by Ray Lisc...
113,507
<p>I've written a control in C# that overrides the built-in DropDownList control. For this I need a javascript resource included, which I'm including as an embedded resource then adding the <code>WebResource</code> attribute, which works fine.</p> <p>However, I also need to reference a webservice, which I would norm...
[ { "answer_id": 113535, "author": "Dested", "author_id": 11137, "author_profile": "https://Stackoverflow.com/users/11137", "pm_score": 0, "selected": false, "text": "<p>If you know the page the usercontrol is in you can do a ((PageName)this.Page).scriptmanager.Services.Add() from the user...
2008/09/22
[ "https://Stackoverflow.com/questions/113507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
I've written a control in C# that overrides the built-in DropDownList control. For this I need a javascript resource included, which I'm including as an embedded resource then adding the `WebResource` attribute, which works fine. However, I also need to reference a webservice, which I would normally include in the scr...
You can add a ScriptManagerProxy in the code or the markup of your control and add the service reference through it. The settings in the ScriptManagerProxy are merged with the "real" ScriptManager at compile time.
113,511
<p>How do we decide on the best implementation of <code>hashCode()</code> method for a collection (assuming that equals method has been overridden correctly) ?</p>
[ { "answer_id": 113530, "author": "Chris Carruthers", "author_id": 1119, "author_profile": "https://Stackoverflow.com/users/1119", "pm_score": -1, "selected": false, "text": "<p>For a simple class it is often easiest to implement hashCode() based on the class fields which are checked by t...
2008/09/22
[ "https://Stackoverflow.com/questions/113511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11193/" ]
How do we decide on the best implementation of `hashCode()` method for a collection (assuming that equals method has been overridden correctly) ?
The best implementation? That is a hard question because it depends on the usage pattern. A for nearly all cases reasonable good implementation was proposed in *Josh Bloch*'s ***Effective Java*** in Item 8 (second edition). The best thing is to look it up there because the author explains there why the approach is goo...
113,534
<p>Is there a function in Python to split a string without ignoring the spaces in the resulting list? </p> <p>E.g:</p> <pre><code>s="This is the string I want to split".split() </code></pre> <p>gives me</p> <pre><code>&gt;&gt;&gt; s ['This', 'is', 'the', 'string', 'I', 'want', 'to', 'split'] </code></pre> <p>I wan...
[ { "answer_id": 113554, "author": "rossp", "author_id": 612, "author_profile": "https://Stackoverflow.com/users/612", "pm_score": 1, "selected": false, "text": "<p>The hard part with what you're trying to do is that you aren't giving it a character to split on. split() explodes a string o...
2008/09/22
[ "https://Stackoverflow.com/questions/113534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20211/" ]
Is there a function in Python to split a string without ignoring the spaces in the resulting list? E.g: ``` s="This is the string I want to split".split() ``` gives me ``` >>> s ['This', 'is', 'the', 'string', 'I', 'want', 'to', 'split'] ``` I want something like ``` ['This',' ','is',' ', 'the',' ','string', '...
``` >>> import re >>> re.split(r"(\s+)", "This is the string I want to split") ['This', ' ', 'is', ' ', 'the', ' ', 'string', ' ', 'I', ' ', 'want', ' ', 'to', ' ', 'split'] ``` Using the capturing parentheses in re.split() causes the function to return the separators as well.
113,542
<p>Is there a simple way to hook into the standard '<strong>Add or Remove Programs</strong>' functionality using PowerShell to <strong>uninstall an existing application</strong>? Or to check if the application is installed?</p>
[ { "answer_id": 113584, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "https://Stackoverflow.com/users/3950", "pm_score": 8, "selected": true, "text": "<pre class=\"lang-ps prettyprint-override\"><code>$app = Get-WmiObject -Class Win32_Product | Where-Object { \n $_.Na...
2008/09/22
[ "https://Stackoverflow.com/questions/113542", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571/" ]
Is there a simple way to hook into the standard '**Add or Remove Programs**' functionality using PowerShell to **uninstall an existing application**? Or to check if the application is installed?
```ps $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match "Software Name" } $app.Uninstall() ``` **Edit:** Rob found another way to do it with the Filter parameter: ```ps $app = Get-WmiObject -Class Win32_Product ` -Filter "Name = 'Software Name'" ```
113,565
<p>I've seen the following code many times:</p> <pre><code>try { ... // some code } catch (Exception ex) { ... // Do something throw new CustomException(ex); // or // throw; // or // throw ex; } </code></pre> <p>Can you please explain the purpose of re-throwing an exception? Is it follow...
[ { "answer_id": 113568, "author": "johnc", "author_id": 5302, "author_profile": "https://Stackoverflow.com/users/5302", "pm_score": 0, "selected": false, "text": "<p>Until I started using the EntLib ExceptionBlock, I was using them to log errors before throwing them. Kind of nasty when yo...
2008/09/22
[ "https://Stackoverflow.com/questions/113565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14611/" ]
I've seen the following code many times: ``` try { ... // some code } catch (Exception ex) { ... // Do something throw new CustomException(ex); // or // throw; // or // throw ex; } ``` Can you please explain the purpose of re-throwing an exception? Is it following a pattern/best practic...
Rethrowing the same exception is useful if you want to, say, log the exception, but not handle it. Throwing a new exception that wraps the caught exception is good for abstraction. e.g., your library uses a third-party library that throws an exception that the clients of your library shouldn't know about. In that case...
113,640
<p>I want to create a box like this with title:</p> <p><img src="https://i.stack.imgur.com/2rip1.gif" alt="CSS box with title"></p> <p>Can any one please let me know if there is a default CSS tag to do this? Or do I need to create my custom style?</p>
[ { "answer_id": 113656, "author": "Matthias Meid", "author_id": 17713, "author_profile": "https://Stackoverflow.com/users/17713", "pm_score": 2, "selected": false, "text": "<p>As far as I know (correct me if I'm wrong!), there isn't.</p>\n\n<p>I'd recommend you to use a div with a negativ...
2008/09/22
[ "https://Stackoverflow.com/questions/113640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20165/" ]
I want to create a box like this with title: ![CSS box with title](https://i.stack.imgur.com/2rip1.gif) Can any one please let me know if there is a default CSS tag to do this? Or do I need to create my custom style?
I believe you are looking for the `fieldset` HTML tag, which you can then style with CSS. E.g., ```html <fieldset style="border: 1px black solid"> <legend style="border: 1px black solid;margin-left: 1em; padding: 0.2em 0.8em ">title</legend> Text within the box <br /> Etc </fieldset> ```
113,655
<p>Is there a function in python to split a word into a list of single letters? e.g:</p> <pre><code>s = &quot;Word to Split&quot; </code></pre> <p>to get</p> <pre><code>wordlist = ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] </code></pre>
[ { "answer_id": 113662, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 9, "selected": true, "text": "<pre><code>&gt;&gt;&gt; list(\"Word to Split\")\n['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't']\n</code...
2008/09/22
[ "https://Stackoverflow.com/questions/113655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20211/" ]
Is there a function in python to split a word into a list of single letters? e.g: ``` s = "Word to Split" ``` to get ``` wordlist = ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] ```
``` >>> list("Word to Split") ['W', 'o', 'r', 'd', ' ', 't', 'o', ' ', 'S', 'p', 'l', 'i', 't'] ```
113,664
<p>I want to install PowerShell to 600 Window XP computers, and use it as the main processing shell. For example, for replacing batch scripts, VB scripts, and some other little programs. The installation process is not a problem. Some issues I think I'm going to come across are:</p> <ol> <li><p>Changing permissions to ...
[ { "answer_id": 114634, "author": "Tubs", "author_id": 11924, "author_profile": "https://Stackoverflow.com/users/11924", "pm_score": 0, "selected": false, "text": "<p>Changing permissions to allow Powershell scripts is possible to do via group policy. </p>\n\n<p>Microsoft provide ADM tem...
2008/09/22
[ "https://Stackoverflow.com/questions/113664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11924/" ]
I want to install PowerShell to 600 Window XP computers, and use it as the main processing shell. For example, for replacing batch scripts, VB scripts, and some other little programs. The installation process is not a problem. Some issues I think I'm going to come across are: 1. Changing permissions to allow PowerShel...
To speed up the start of PowerShell, Jeffrey Snover (the partner/architect responsible for PowerShell) provides an "Update-GAC" script [here](http://blogs.msdn.com/powershell/archive/2008/09/02/speeding-up-powershell-startup-updating-update-gac-ps1.aspx). Basically, it is just running through the assemblies that are l...
113,702
<p>How do I add a "last" class on the last <code>&lt;li&gt;</code> within a Views-generated list?</p>
[ { "answer_id": 113740, "author": "Tim C", "author_id": 7585, "author_profile": "https://Stackoverflow.com/users/7585", "pm_score": 4, "selected": true, "text": "<p>You could use the <strong>last-child</strong> pseudo-class on the li element to achieve this</p>\n\n<pre><code>&lt;html&gt;\...
2008/09/22
[ "https://Stackoverflow.com/questions/113702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20273/" ]
How do I add a "last" class on the last `<li>` within a Views-generated list?
You could use the **last-child** pseudo-class on the li element to achieve this ``` <html> <head> <style type="text/css"> ul li:last-child { font-weight:bold } </style> </head> <body> <ul> <li>IE</li> <li>Firefox</li> <li>Safari</li> </ul> </body> </html> ``` There is also a first-child pseudo class available. I am...
113,712
<p>Is there a way to combine a previous translation when extracting the csv file from an application? Or any other tool that could do this job for me? </p> <p>I can’t really see how could i use locbaml if i had to translate everything from scratch every time i add a new control in my application.</p>
[ { "answer_id": 113740, "author": "Tim C", "author_id": 7585, "author_profile": "https://Stackoverflow.com/users/7585", "pm_score": 4, "selected": true, "text": "<p>You could use the <strong>last-child</strong> pseudo-class on the li element to achieve this</p>\n\n<pre><code>&lt;html&gt;\...
2008/09/22
[ "https://Stackoverflow.com/questions/113712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15228/" ]
Is there a way to combine a previous translation when extracting the csv file from an application? Or any other tool that could do this job for me? I can’t really see how could i use locbaml if i had to translate everything from scratch every time i add a new control in my application.
You could use the **last-child** pseudo-class on the li element to achieve this ``` <html> <head> <style type="text/css"> ul li:last-child { font-weight:bold } </style> </head> <body> <ul> <li>IE</li> <li>Firefox</li> <li>Safari</li> </ul> </body> </html> ``` There is also a first-child pseudo class available. I am...
113,728
<p>Basically I am trying to restart a service from a php web page.</p> <p>Here is the code:</p> <pre><code>&lt;?php exec ('/usr/bin/sudo /etc/init.d/portmap restart'); ?&gt; </code></pre> <p>But, in <code>/var/log/httpd/error_log</code>, I get </p> <blockquote> <p>unable to change to sudoers gid: Operation not pe...
[ { "answer_id": 113764, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 3, "selected": false, "text": "<p>The error you are getting seems to be related to your SELinux configuration. You might try temporarily disabling tha...
2008/09/22
[ "https://Stackoverflow.com/questions/113728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Basically I am trying to restart a service from a php web page. Here is the code: ``` <?php exec ('/usr/bin/sudo /etc/init.d/portmap restart'); ?> ``` But, in `/var/log/httpd/error_log`, I get > > unable to change to sudoers gid: Operation not permitted > > > and in /var/log/messages, I get > > Sep 22 15:0...
The problem is not with sudo at the moment, but with [SELinux](http://en.wikipedia.org/wiki/Selinux), which is (reasonably) set to deny the HTTPD from gaining root privileges. You will need to either explicitly allow this (you can use [audit2allow](http://fedoraproject.org/wiki/SELinux/audit2allow) for this), or set...
113,731
<p>We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application.</p> <p>The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference ...
[ { "answer_id": 113743, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 2, "selected": false, "text": "<p>I use a <a href=\"http://nant.sourceforge.net/\" rel=\"nofollow noreferrer\">NAnt</a> <a href=\"http://www.cruisecontroln...
2008/09/22
[ "https://Stackoverflow.com/questions/113731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2972/" ]
We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application. The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference is specifi...
You have to use [NAnt](http://nant.sourceforge.net/) for those kind of stuff. Here is the [Task Reference of Nant](http://nant.sourceforge.net/release/latest/help/tasks/)..
113,737
<p>How do I use PowerShell to stop and start a "Generic Service" as seen in the Microsoft "Cluster Administrator" software?</p>
[ { "answer_id": 113797, "author": "Rob Paterson", "author_id": 11571, "author_profile": "https://Stackoverflow.com/users/11571", "pm_score": 2, "selected": false, "text": "<p>It turns out the answer is to simply use the command line tool CLUSTER.EXE to do this:</p>\n\n<p>cluster RES MyGen...
2008/09/22
[ "https://Stackoverflow.com/questions/113737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11571/" ]
How do I use PowerShell to stop and start a "Generic Service" as seen in the Microsoft "Cluster Administrator" software?
You can also use WMI. You can get all the Generic Services with: ``` $services = Get-WmiObject -Computer "Computer" -namespace 'root\mscluster' ` MSCluster_Resource | Where {$_.Type -eq "Generic Service"} ``` To stop and start a service: ``` $timeout = 15 $services[0].TakeOffline($timeout) $services[0].BringOnline(...
113,750
<p>I'm trying to implement a pop-up menu based on a click-and-hold, positioned so that a (really) slow click will still trigger the default action, and with the delay set so that a text-selection gesture won't usually trigger the menu. </p> <p>What I can't seem to do is cancel the text-selection in a way that doesn't...
[ { "answer_id": 113771, "author": "Craig Francis", "author_id": 6632, "author_profile": "https://Stackoverflow.com/users/6632", "pm_score": 3, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>var input = document.getElementById('myInputField');\nif (input) {\n input.onmousedo...
2008/09/22
[ "https://Stackoverflow.com/questions/113750", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to implement a pop-up menu based on a click-and-hold, positioned so that a (really) slow click will still trigger the default action, and with the delay set so that a text-selection gesture won't usually trigger the menu. What I can't seem to do is cancel the text-selection in a way that doesn't prevent te...
Try this: ``` var input = document.getElementById('myInputField'); if (input) { input.onmousedown = function(e) { if (!e) e = window.event; e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); } } ``` And if not, have a read of: <http://www.quirksmode.org/js/introeven...
113,755
<p>I have an application that is installed and updated via ClickOnce. The application downloads files via FTP, and therefore needs to be added as an exception to the windows firewall. Because of the way that ClickOnce works, the path to the EXE changes with every update, so the exception needs to change also. What w...
[ { "answer_id": 113781, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 4, "selected": false, "text": "<p>Not sure if this is the best way, but running <a href=\"https://learn.microsoft.com/en-us/previous-versions/windows/it-p...
2008/09/22
[ "https://Stackoverflow.com/questions/113755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6389/" ]
I have an application that is installed and updated via ClickOnce. The application downloads files via FTP, and therefore needs to be added as an exception to the windows firewall. Because of the way that ClickOnce works, the path to the EXE changes with every update, so the exception needs to change also. What would b...
I found this article, which has a complete wrapper class included for manipulating the windows firewall. [Adding an Application to the Exception list on the Windows Firewall](http://web.archive.org/web/20070707110141/http://www.dot.net.nz/Default.aspx?tabid=42&mid=404&ctl=Details&ItemID=8) ```cs /// /// Allows basic...
113,780
<p>I don’t think I’ve grokked currying yet. I understand what it does, and how to do it. I just can’t think of a situation I would use it.</p> <p>Where are you using currying in JavaScript (or where are the main libraries using it)? DOM manipulation or general application development examples welcome.</p> <p><a href=...
[ { "answer_id": 113790, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 1, "selected": false, "text": "<p>As for libraries using it, there's always <a href=\"http://osteele.com/sources/javascript/functional/\" rel=\"nofollow n...
2008/09/22
[ "https://Stackoverflow.com/questions/113780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9474/" ]
I don’t think I’ve grokked currying yet. I understand what it does, and how to do it. I just can’t think of a situation I would use it. Where are you using currying in JavaScript (or where are the main libraries using it)? DOM manipulation or general application development examples welcome. [One of the answers](http...
@Hank Gay In response to EmbiggensTheMind's comment: I can't think of an instance where [currying](http://en.wikipedia.org/wiki/Currying)—by itself—is useful in JavaScript; it is a technique for converting function calls with multiple arguments into chains of function calls with a single argument for each call, but J...
113,803
<p>If I have a table in MySQL which represents a base class, and I have a bunch of tables which represent the fields in the derived classes, each of which refers back to the base table with a foreign key, is there any way to get MySQL to enforce the one-to-one relationship between the derived table and the base table, ...
[ { "answer_id": 113811, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 1, "selected": false, "text": "<p>If you use MySQL 5.x you can use triggers for these kinds of constraints.</p>\n\n<p>Another (suboptimal) option would be ...
2008/09/22
[ "https://Stackoverflow.com/questions/113803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15004/" ]
If I have a table in MySQL which represents a base class, and I have a bunch of tables which represent the fields in the derived classes, each of which refers back to the base table with a foreign key, is there any way to get MySQL to enforce the one-to-one relationship between the derived table and the base table, or ...
To make sure that a product is or a cd or a dvd I would add a type column and make it part of the primary key. In the derived column you add a check constraint for the type. In the example I set cd to 1 and you could make dvd = 2 and so on for each derived table. ``` CREATE TABLE IF NOT EXISTS `product` ( `product_id`...
113,824
<p>Is it possible to automount a TrueCrypt volume when logging in to Ubuntu 8.04? It's already storing the wireless network keys using the Seahorse password manager. Could TrueCrypt be made to fetch its volume password from the same keyring? Currently this would seem like the most convenient way to store my source code...
[ { "answer_id": 114176, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 2, "selected": false, "text": "<p>Although I'm currently not a Gentoo user (on Ubuntu now), I used to be one, for years, and had learned, that it's...
2008/09/22
[ "https://Stackoverflow.com/questions/113824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16509/" ]
Is it possible to automount a TrueCrypt volume when logging in to Ubuntu 8.04? It's already storing the wireless network keys using the Seahorse password manager. Could TrueCrypt be made to fetch its volume password from the same keyring? Currently this would seem like the most convenient way to store my source code on...
I can't really remember where I found this solution, but it was working for me on Ubuntu Karmic with gdm. You have to edit the `/etc/gdm/Init` file and add the following: ``` if !(echo `mount` | grep -q "/home/your_username type") then truecrypt /dev/sdaxxx /home/your_username fi ``` Unfortunately it doesn'...
113,829
<p>How do I get timestamp from e.g. <code>22-09-2008</code>?</p>
[ { "answer_id": 113836, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 5, "selected": false, "text": "<p>Using <a href=\"http://php.net/mktime\" rel=\"noreferrer\">mktime</a>:</p>\n\n<pre><code>list($day, $month, $year) = explode...
2008/09/22
[ "https://Stackoverflow.com/questions/113829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205368/" ]
How do I get timestamp from e.g. `22-09-2008`?
*This method works on **both** Windows and Unix **and** is **time-zone** aware, which is probably what you want if you work with [dates](https://unix4lyfe.org/time/).* If you don't care about timezone, or want to use the time zone your server uses: ``` $d = DateTime::createFromFormat('d-m-Y H:i:s', '22-09-2008 00:00:...
113,860
<p>How can I make sure that a certain OLEDB driver is installed when I start my application? I use ADO from Delphi and would like to display a descriptive error message if the driver is missing. The error that's returned from ADO isn't always that user-friendly.</p> <p>There are probably a nice little function that re...
[ { "answer_id": 114072, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 1, "selected": false, "text": "<p>Wouldn't the easiest way just be trying to make a connection at start-up and catching the error?</p>\n\n<p>I mean you might...
2008/09/22
[ "https://Stackoverflow.com/questions/113860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4101/" ]
How can I make sure that a certain OLEDB driver is installed when I start my application? I use ADO from Delphi and would like to display a descriptive error message if the driver is missing. The error that's returned from ADO isn't always that user-friendly. There are probably a nice little function that returns all ...
Each provider has a GUID associated with its class. To find the guid, open regedit and search the registry for the provider name. For example, search for "Microsoft Jet 4.0 OLE DB Provider". When you find it, copy the key (the GUID value) and use that in a registry search in your application. ``` function OleDBExists...
113,873
<p>I want to extend the basic <code>ControlCollection</code> in VB.NET so I can just add images and text to a self-made control, and then automaticly convert them to pictureboxes and lables.</p> <p>So I made a class that inherits from ControlCollection, overrided the add method, and added the functionality.</p> <p>Bu...
[ { "answer_id": 113891, "author": "Nescio", "author_id": 14484, "author_profile": "https://Stackoverflow.com/users/14484", "pm_score": 3, "selected": true, "text": "<p>Why not inherit from <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx\" rel=\"nofo...
2008/09/22
[ "https://Stackoverflow.com/questions/113873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20261/" ]
I want to extend the basic `ControlCollection` in VB.NET so I can just add images and text to a self-made control, and then automaticly convert them to pictureboxes and lables. So I made a class that inherits from ControlCollection, overrided the add method, and added the functionality. But when I run the example, it...
Why not inherit from [UserControl](http://msdn.microsoft.com/en-us/library/system.windows.forms.usercontrol.aspx) to define a custom control that has properties like Text and Image?
113,886
<p>I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files. </p>
[ { "answer_id": 113892, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "<p>If you can use <code>scp</code> instead of <code>ftp</code>, the <code>-r</code> option will do this for you. I would ...
2008/09/22
[ "https://Stackoverflow.com/questions/113886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11708/" ]
I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.
You could rely on wget which usually handles ftp get properly (at least in my own experience). For example: ``` wget -r ftp://user:pass@server.com/ ``` You can also use `-m` which is suitable for mirroring. It is currently equivalent to `-r -N -l inf`. If you've some special characters in the credential details, yo...
113,897
<p>I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent?</p> <p>I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent ...
[ { "answer_id": 113908, "author": "Martijn", "author_id": 17439, "author_profile": "https://Stackoverflow.com/users/17439", "pm_score": 2, "selected": false, "text": "<p>If you call getImage too early, your component will not have been displayed yet and will still have a 0 width and heigh...
2008/09/22
[ "https://Stackoverflow.com/questions/113897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20298/" ]
I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent? I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent methods. ...
If you call getImage too early, your component will not have been displayed yet and will still have a 0 width and height. Have you made sure you're calling it at a sufficient late time? Try printing the component's size to stdout and see what its dimensions are.
113,899
<p>I want to create a c# application with multiple windows that are all transparent with some text on.</p> <p>The tricky part is making these forms sit on top of the desktop but under the desktop icons. Is this possible?</p>
[ { "answer_id": 113933, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "https://Stackoverflow.com/users/3950", "pm_score": 3, "selected": true, "text": "<p>Just making the window transparent is very straight forward:</p>\n\n<pre><code>this.BackColor = Color.Fuchsia;\nthis....
2008/09/22
[ "https://Stackoverflow.com/questions/113899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3585/" ]
I want to create a c# application with multiple windows that are all transparent with some text on. The tricky part is making these forms sit on top of the desktop but under the desktop icons. Is this possible?
Just making the window transparent is very straight forward: ``` this.BackColor = Color.Fuchsia; this.TransparencyKey = Color.Fuchsia; ``` You can do something like this to make it so you can still interact with the desktop or anything else under your window: ``` public const int WM_NCHITTEST = 0x84; public const i...
113,901
<p>In order to perform a case-sensitive search/replace on a table in a SQL Server 2000/2005 database, you must use the correct collation.</p> <p>How do you determine whether the default collation for a database is case-sensitive, and if it isn't, how to perform a case-sensitive search/replace?</p>
[ { "answer_id": 113909, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 5, "selected": true, "text": "<pre><code>SELECT testColumn FROM testTable \n WHERE testColumn COLLATE Latin1_General_CS_AS = 'example' \n\nSELECT test...
2008/09/22
[ "https://Stackoverflow.com/questions/113901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5152/" ]
In order to perform a case-sensitive search/replace on a table in a SQL Server 2000/2005 database, you must use the correct collation. How do you determine whether the default collation for a database is case-sensitive, and if it isn't, how to perform a case-sensitive search/replace?
``` SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS = 'example' SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS = 'EXAMPLE' SELECT testColumn FROM testTable WHERE testColumn COLLATE Latin1_General_CS_AS = 'eXaMpLe' ``` Don't assume the ...
113,915
<p>I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0_08. Note that this does not occur every time, but about 80% of the time:</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke at java.util.TreeMap.compare(TreeMap.java:1093...
[ { "answer_id": 113924, "author": "Epaga", "author_id": 6583, "author_profile": "https://Stackoverflow.com/users/6583", "pm_score": 3, "selected": true, "text": "<p>After doing some Googling on bugs.sun.com, this looks like this might be a JDK bug that was only fixed in JDK 6.</p>\n\n<p>S...
2008/09/22
[ "https://Stackoverflow.com/questions/113915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I'm getting a random unreproducible Error when initializing a JSplitPane in with JDK 1.5.0\_08. Note that this does not occur every time, but about 80% of the time: ``` Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.KeyStroke at java.util.TreeMap.compare(TreeMap.java:1093) at java.uti...
After doing some Googling on bugs.sun.com, this looks like this might be a JDK bug that was only fixed in JDK 6. See <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434148>
113,916
<p>If I need to choose a collation mode to work with, how do I know what collations are available?</p>
[ { "answer_id": 113917, "author": "Andrew Myhre", "author_id": 5152, "author_profile": "https://Stackoverflow.com/users/5152", "pm_score": 3, "selected": false, "text": "<p>Use this query to list the available collation modes:</p>\n\n<p>SELECT *\nFROM fn_helpcollations()</p>\n" }, { ...
2008/09/22
[ "https://Stackoverflow.com/questions/113916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5152/" ]
If I need to choose a collation mode to work with, how do I know what collations are available?
``` select distinct COLLATION_NAME from INFORMATION_SCHEMA.COLUMNS order by 1 ```
113,928
<p>When I enter an object into the DB with Linq-to-SQL can I get the id that I just inserted without making another db call? I am assuming this is pretty easy, I just don't know how. </p>
[ { "answer_id": 113948, "author": "Germstorm", "author_id": 18631, "author_profile": "https://Stackoverflow.com/users/18631", "pm_score": 9, "selected": true, "text": "<p>After you commit your object into the db the object receives a value in its ID field.</p>\n\n<p>So:</p>\n\n<pre><code>...
2008/09/22
[ "https://Stackoverflow.com/questions/113928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
When I enter an object into the DB with Linq-to-SQL can I get the id that I just inserted without making another db call? I am assuming this is pretty easy, I just don't know how.
After you commit your object into the db the object receives a value in its ID field. So: ``` myObject.Field1 = "value"; // Db is the datacontext db.MyObjects.InsertOnSubmit(myObject); db.SubmitChanges(); // You can retrieve the id from the object int id = myObject.ID; ```
113,951
<p>I am creating an appcation on Vista,which include a service and a Console application .Both running in same user account</p> <p>In service i am creating an event and waits for that event.In console application i am opening the same event (problem starts here) and calling <em>SetEvent</em> function. I can not open...
[ { "answer_id": 114009, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "<p>Are the service and the application running as the same user with different integrity levels, or are they runnin...
2008/09/22
[ "https://Stackoverflow.com/questions/113951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20316/" ]
I am creating an appcation on Vista,which include a service and a Console application .Both running in same user account In service i am creating an event and waits for that event.In console application i am opening the same event (problem starts here) and calling *SetEvent* function. I can not open the event (getting...
Are the service and the application running as the same user with different integrity levels, or are they running as different users? If it is the former, then this article from MSDN [which talks about integrity levels might help](http://msdn.microsoft.com/en-us/library/bb250462.aspx). They have some sample code for l...
113,989
<p>Is there an easy way (in .Net) to test if a Font is installed on the current machine?</p>
[ { "answer_id": 113998, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 5, "selected": false, "text": "<p><a href=\"https://stackoverflow.com/questions/89886/how-do-you-get-a-list-of-all-the-installed-fonts#89895\">How do you get a...
2008/09/22
[ "https://Stackoverflow.com/questions/113989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11492/" ]
Is there an easy way (in .Net) to test if a Font is installed on the current machine?
``` string fontName = "Consolas"; float fontSize = 12; using (Font fontTester = new Font( fontName, fontSize, FontStyle.Regular, GraphicsUnit.Pixel)) { if (fontTester.Name == fontName) { // Font exists } else { // Font doesn't exist } } ```
113,991
<p>A heap is a list where the following applies:</p> <pre><code>l[i] &lt;= l[2*i] &amp;&amp; l[i] &lt;= [2*i+1] </code></pre> <p>for <code>0 &lt;= i &lt; len(list)</code></p> <p>I'm looking for in-place sorting.</p>
[ { "answer_id": 114020, "author": "Antti Rasinen", "author_id": 8570, "author_profile": "https://Stackoverflow.com/users/8570", "pm_score": -1, "selected": false, "text": "<p>Read the items off the top of the heap one by one. Basically what you have then is heap sort.</p>\n" }, { ...
2008/09/22
[ "https://Stackoverflow.com/questions/113991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6899/" ]
A heap is a list where the following applies: ``` l[i] <= l[2*i] && l[i] <= [2*i+1] ``` for `0 <= i < len(list)` I'm looking for in-place sorting.
Well you are half way through a Heap Sort already, by having your data in a heap. You just need to implement the second part of the heap sort algorithm. This should be faster than using quicksort on the heap array. If you are feeling brave you could have a go at implementing [smoothsort](http://www.cs.utexas.edu/users...
113,992
<p>In what order are the following parameters tested (in C++)?</p> <pre><code>if (a || b &amp;&amp; c) { } </code></pre> <p>I've just seen this code in our application and I hate it, I want to add some brackets to just clarify the ordering. But I don't want to add the brackets until I know I'm adding them in the righ...
[ { "answer_id": 113995, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 3, "selected": true, "text": "<p>From <a href=\"http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm\" rel=\"nofollow noreferrer\">here</a>:</p>\n\...
2008/09/22
[ "https://Stackoverflow.com/questions/113992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
In what order are the following parameters tested (in C++)? ``` if (a || b && c) { } ``` I've just seen this code in our application and I hate it, I want to add some brackets to just clarify the ordering. But I don't want to add the brackets until I know I'm adding them in the right place. ***Edit: Accepted Answer...
From [here](http://www.difranco.net/compsci/C_Operator_Precedence_Table.htm): ``` a || (b && c) ``` This is the default precedence.
114,010
<p>Is there any way to create C# 3.0 anonymous object via Reflection at runtime in .NET 3.5? I'd like to support them in my serialization scheme, so I need a way to manipulate them programmatically.</p> <p><em>edited later to clarify the use case</em></p> <p>An extra constraint is that I will be running all of it ins...
[ { "answer_id": 114022, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 1, "selected": false, "text": "<p>Use reflection to get the Type, use GetConstructor on the type, use Invoke on the constructor.</p>\n\n<p>Edit: ...
2008/09/22
[ "https://Stackoverflow.com/questions/114010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9777/" ]
Is there any way to create C# 3.0 anonymous object via Reflection at runtime in .NET 3.5? I'd like to support them in my serialization scheme, so I need a way to manipulate them programmatically. *edited later to clarify the use case* An extra constraint is that I will be running all of it inside a Silverlight app, s...
Here is another way, seems more direct. ``` object anon = Activator.CreateInstance(existingObject.GetType()); ```
114,054
<p>Can you please clarify the folowing query? I am not sure if the way I am trying to code is correct. Kindly advise me if I am moving in the right/wrong direction.</p> <p>I am trying to develop an automation framework using <a href="http://en.wikipedia.org/wiki/HP_QuickTest_Professional" rel="nofollow noreferrer">Qui...
[ { "answer_id": 114133, "author": "Rob Cooper", "author_id": 832, "author_profile": "https://Stackoverflow.com/users/832", "pm_score": 1, "selected": false, "text": "<p>Well, it sounds like you already have the answer.. You just need to handle the expection that occurs when reading in the...
2008/09/22
[ "https://Stackoverflow.com/questions/114054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can you please clarify the folowing query? I am not sure if the way I am trying to code is correct. Kindly advise me if I am moving in the right/wrong direction. I am trying to develop an automation framework using [QuickTest Professional](http://en.wikipedia.org/wiki/HP_QuickTest_Professional), a testing tool. * The...
Well, it sounds like you already have the answer.. You just need to handle the expection that occurs when reading in the data within the main loop and make it stop there.. Now, I have not done VBScript for a LONG time so, to pseudo it: ``` While Not EndOfExcelSheet ReadDataFromExcel(); If errOccurred Then Tak...
114,149
<p>The point of const-correctness is to be able to provide a view of an instance that can't be altered or deleted by the user. The compiler supports this by pointing out when you break constness from within a const function, or try to use a non-const function of a const object. So without copying the const approach, is...
[ { "answer_id": 114155, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 2, "selected": false, "text": "<p>C# doesn't have such feature. You can pass argument by value or by reference. Reference itself is immutable unless you specif...
2008/09/22
[ "https://Stackoverflow.com/questions/114149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11801/" ]
The point of const-correctness is to be able to provide a view of an instance that can't be altered or deleted by the user. The compiler supports this by pointing out when you break constness from within a const function, or try to use a non-const function of a const object. So without copying the const approach, is th...
I've come across this issue a lot of times too and ended up using interfaces. I think it's important to drop the idea that C# is any form, or even an evolution of C++. They're two different languages that share almost the same syntax. I usually express 'const correctness' in C# by defining a read-only view of a class...
114,154
<p>XAML allows you to specify an attribute value using a string that contains curly braces. Here is an example that creates a <em>Binding</em> instance and assigns it to the <em>Text</em> property of the <em>TextBox</em> element.</p> <pre><code>&lt;TextBox Text="{Binding ElementName=Foo, Path=Bar}"/&gt; </code></pre> ...
[ { "answer_id": 114175, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": true, "text": "<p>take a look at markupextensions\n<a href=\"http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecust...
2008/09/22
[ "https://Stackoverflow.com/questions/114154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6276/" ]
XAML allows you to specify an attribute value using a string that contains curly braces. Here is an example that creates a *Binding* instance and assigns it to the *Text* property of the *TextBox* element. ``` <TextBox Text="{Binding ElementName=Foo, Path=Bar}"/> ``` I want to extend XAML so that the developer could...
take a look at markupextensions <http://blogs.msdn.com/wpfsdk/archive/2007/03/22/blogpost-text-creatingasimplecustommarkupextension.aspx>
114,165
<p>At work we use <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">WiX</a> for building installation packages. We want that installation of product X would result in uninstall of the previous version of that product on that machine.</p> <p>I've read on several places on the Internet about a major upgrade bu...
[ { "answer_id": 114736, "author": "Dror Helper", "author_id": 11361, "author_profile": "https://Stackoverflow.com/users/11361", "pm_score": 8, "selected": false, "text": "<p>Finally I found a solution - I'm posting it here for other people who might have the same problem (all 5 of you):</...
2008/09/22
[ "https://Stackoverflow.com/questions/114165", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11361/" ]
At work we use [WiX](http://en.wikipedia.org/wiki/WiX) for building installation packages. We want that installation of product X would result in uninstall of the previous version of that product on that machine. I've read on several places on the Internet about a major upgrade but couldn't get it to work. Can anyone ...
In the newest versions (from the 3.5.1315.0 beta), you can use the [MajorUpgrade element](http://wixtoolset.org/documentation/manual/v3/xsd/wix/majorupgrade.html "Major upgrade") instead of using your own. For example, we use this code to do automatic upgrades. It prevents downgrades, giving a localised error message,...
114,172
<p>I have a Windows executable (whoami) which is crashing every so often. It's called from another process to get details about the current user and domain. I'd like to know what parameters are passed when it fails.</p> <p>Does anyone know of an appropriate way to wrap the process and write it's command line argumen...
[ { "answer_id": 114199, "author": "Milan Babuškov", "author_id": 14690, "author_profile": "https://Stackoverflow.com/users/14690", "pm_score": 1, "selected": false, "text": "<p>You didn't note which programming language. It is not doable from a .bat file if that's what you wanted, but you...
2008/09/22
[ "https://Stackoverflow.com/questions/114172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2257098/" ]
I have a Windows executable (whoami) which is crashing every so often. It's called from another process to get details about the current user and domain. I'd like to know what parameters are passed when it fails. Does anyone know of an appropriate way to wrap the process and write it's command line arguments to log wh...
From a batch file: ``` echo Parameters: %* >> logfile.txt whoami.exe %* ``` With the caveat that you can have problems if the parameters contain spaces (and you passed the in escaping with "), because the command-line parser basically de-escapes them and they should be re-escaped before passed to an other executable...
114,179
<p>I got this síngleton cache object and it exposes an IEnumerable property which just returns a private IEnumerable variable.</p> <p>I have a static method on my singleton object that updates this member variable (that exists on the single 'Instance' instance of this cache object).</p> <p>Let's say some thread is c...
[ { "answer_id": 114193, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 2, "selected": false, "text": "<p>Since the getter <code>{ return sektioner; }</code> is called before the new value is put in the field, the old valu...
2008/09/22
[ "https://Stackoverflow.com/questions/114179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
I got this síngleton cache object and it exposes an IEnumerable property which just returns a private IEnumerable variable. I have a static method on my singleton object that updates this member variable (that exists on the single 'Instance' instance of this cache object). Let's say some thread is currently iterating...
The thread which is currently enumerating sektioner will continue to enumerate it even when you update the reference within the singleton. There is nothing special about objects which implement IEnumerable. You should perhaps add the [volatile](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keyword...
114,180
<p>What would be better practice when giving a function the original variable to work with:</p> <pre><code>unsigned long x = 4; void func1(unsigned long&amp; val) { val = 5; } func1(x); </code></pre> <p>or:</p> <pre><code>void func2(unsigned long* val) { *val = 5; } func2(&amp;x); </code></pre...
[ { "answer_id": 114189, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 9, "selected": true, "text": "<p>My rule of thumb is:</p>\n\n<p>Use pointers if you want to do pointer arithmetic with them (e.g. incrementing t...
2008/09/22
[ "https://Stackoverflow.com/questions/114180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20349/" ]
What would be better practice when giving a function the original variable to work with: ``` unsigned long x = 4; void func1(unsigned long& val) { val = 5; } func1(x); ``` or: ``` void func2(unsigned long* val) { *val = 5; } func2(&x); ``` IOW: Is there any reason to pick one over another?
My rule of thumb is: Use pointers if you want to do pointer arithmetic with them (e.g. incrementing the pointer address to step through an array) or if you ever have to pass a NULL-pointer. Use references otherwise.
114,204
<p>I've set up DAV in apache2, which works great. The thing is, all read/write operations are done with the apache user's credentials. Instead I want to use the HTTP authenticated user's credentials. If I authenticate as "john", all read and write operations should use the system user john's credentials (from /etc/...
[ { "answer_id": 114275, "author": "niXar", "author_id": 19979, "author_profile": "https://Stackoverflow.com/users/19979", "pm_score": 2, "selected": false, "text": "<p>Shot answer, and as far as I know: you don't.</p>\n<p>Long answer: it is possible to implement such a feature with an app...
2008/09/22
[ "https://Stackoverflow.com/questions/114204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13365/" ]
I've set up DAV in apache2, which works great. The thing is, all read/write operations are done with the apache user's credentials. Instead I want to use the HTTP authenticated user's credentials. If I authenticate as "john", all read and write operations should use the system user john's credentials (from /etc/passwd)...
We have been using davenport (<http://davenport.sourceforge.net/>) for years to provide access to Windows/samba shares over webdav. Samba/Windows gives a lot of control over this sort of thing, and the Davenport just makes it usable over the web over SSL without a VPN
114,208
<p>Let me explain: this is path to this folder: > <code>www.my_site.com/images</code></p> <p>And images are created by <code>user_id</code>, and for example, images of <code>user_id = 27</code> are, <code>27_1.jpg</code>, <code>27_2.jpg</code>, <code>27_3.jpg</code>! How to list and print images which start with <code...
[ { "answer_id": 114231, "author": "Torsten Marek", "author_id": 9567, "author_profile": "https://Stackoverflow.com/users/9567", "pm_score": 4, "selected": true, "text": "<p>Environment variables are inherited by processes in Unix. The files in /etc/profile.d are only executed (in the curr...
2008/09/22
[ "https://Stackoverflow.com/questions/114208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205368/" ]
Let me explain: this is path to this folder: > `www.my_site.com/images` And images are created by `user_id`, and for example, images of `user_id = 27` are, `27_1.jpg`, `27_2.jpg`, `27_3.jpg`! How to list and print images which start with `27_%.jpg`? I hope You have understood me! PS. I am totally beginmer in ASP.NET (...
Environment variables are inherited by processes in Unix. The files in /etc/profile.d are only executed (in the current shell, not in a subshell) when you log in. Just changing the value there and then restarting a process will not update the environment. Possible Fixes: * log out/log in, then start apache * source ...