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 |
|---|---|---|---|---|---|---|
141,146 | <p>I want to know if my server is running Subversion 1.5.</p>
<p>How can I find that out?</p>
<p>Also would be nice to know my SVN client version number. <code>svn help</code> hasn't been helpful.</p>
<p><strong>Note:</strong> I don't want my <em>project's</em> revision number, etc. This question is about the <em>Su... | [
{
"answer_id": 141479,
"author": "PiedPiper",
"author_id": 19315,
"author_profile": "https://Stackoverflow.com/users/19315",
"pm_score": 5,
"selected": false,
"text": "<p>For an HTTP-based server there is a Python script to find the server version at:\n<a href=\"http://svn.apache.org/rep... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to know if my server is running Subversion 1.5.
How can I find that out?
Also would be nice to know my SVN client version number. `svn help` hasn't been helpful.
**Note:** I don't want my *project's* revision number, etc. This question is about the *Subversion software* itself. | To find the version of the subversion REPOSITORY you can:
1. Look to the repository on the web and on the bottom of the page it will say something like:
"Powered by Subversion version 1.5.2 (r32768)."
2. From the command line: <insert curl, grep oneliner here>
If not displayed, view source of the page
```
<svn ve... |
141,154 | <p>I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected to a particular instance.</p>
| [
{
"answer_id": 141166,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 6,
"selected": false,
"text": "<p>You could query this registry value to get the SQL version directly:</p>\n\n<pre><code>HKEY_LOCAL_MACHINE\\SOFTWAR... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | I'm trying to determine what instances of sql server/sql express I have installed (either manually or programmatically) but all of the examples are telling me to run a SQL query to determine this which assumes I'm already connected to a particular instance. | At a command line:
```
SQLCMD -L
```
or
```
OSQL -L
```
(Note: must be a capital L)
This will list all the sql servers installed on your network. There are configuration options you can set to prevent a SQL Server from showing in the list. To do this...
At command line:
```
svrnetcn
```
In the enabled proto... |
141,162 | <p>I need to see if a given process id is running, and it must work in either Java or JRuby (preferably a Ruby solution). It can be system dependent for Linux (specifically Debian and/or Ubuntu).</p>
<p>I already have the PID I am looking for, just need to see if it is currently running.</p>
<hr>
<p>UPDATE:</p>
<p... | [
{
"answer_id": 141165,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "<p>From <a href=\"https://stackoverflow.com/questions/138097/how-do-i-find-my-pid-in-java-or-jruby-on-linux#138098\">my ans... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I need to see if a given process id is running, and it must work in either Java or JRuby (preferably a Ruby solution). It can be system dependent for Linux (specifically Debian and/or Ubuntu).
I already have the PID I am looking for, just need to see if it is currently running.
---
UPDATE:
Thanks for all the respon... | [Darron's comment](https://stackoverflow.com/questions/141162/how-can-i-determine-if-a-different-process-id-is-running-using-java-or-jruby-on#141731) was spot on, but rather than calling the "kill" binary, you can just use Ruby's Process.kill method with the 0 signal:
```
#!/usr/bin/ruby
pid = ARGV[0].to_i
begin
... |
141,169 | <p>So I have a weird situation here... I have an System.Web.UI.WebControls.WebParts.EditorPart class. It renders a "Search" button, when you click this button, it's clickHandler method does a DB search, and dynamically creates a LinkButton for each row it returns, sets the CommandName and CommandArgument properties and... | [
{
"answer_id": 141195,
"author": "Mike J",
"author_id": 4443,
"author_profile": "https://Stackoverflow.com/users/4443",
"pm_score": 1,
"selected": false,
"text": "<p>You need to re-add the dynamically created controls, in the onload, so that they can be in the page hierarchy and fire the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19086/"
] | So I have a weird situation here... I have an System.Web.UI.WebControls.WebParts.EditorPart class. It renders a "Search" button, when you click this button, it's clickHandler method does a DB search, and dynamically creates a LinkButton for each row it returns, sets the CommandName and CommandArgument properties and ad... | This is my favorite trick :)
Our scenario is to first render a control. Then using some input from the user, render further controls and have them respond to events.
The key here is state - you need to know the state of the control when it arrives at PostBack - so we use ViewState. The issue becomes then a chicken-an... |
141,201 | <p>I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file as well.</p>
<p>I understand that establish_connection should... | [
{
"answer_id": 141314,
"author": "Terry G Lorber",
"author_id": 809,
"author_profile": "https://Stackoverflow.com/users/809",
"pm_score": 3,
"selected": false,
"text": "<p>Heh. I was right! More cleanly:</p>\n\n<pre><code>class Foo < ActiveRecord::Base\n establish_connection \"fo... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809/"
] | I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file as well.
I understand that establish\_connection should be called, ... | Also, it is a good idea to subclass your model that uses different database, such as:
```
class AnotherBase < ActiveRecord::Base
self.abstract_class = true
establish_connection "anotherbase_#{RAILS_ENV}"
end
```
And in your model
```
class Foo < AnotherBase
end
```
It is useful when you need to add subsequent... |
141,203 | <p>I'm trying to grok the purpose of .NET's SecureString. From MSDN:</p>
<blockquote>
<p>An instance of the System.String class is both immutable and, when no longer needed, cannot be programmatically scheduled for garbage collection; that is, the instance is read-only after it is created and it is not possible to pre... | [
{
"answer_id": 141213,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 2,
"selected": false,
"text": "<p>I guess it's because the string is meant to be secure, i.e. a hacker should not be able to read it. If you initiali... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2258/"
] | I'm trying to grok the purpose of .NET's SecureString. From MSDN:
>
> An instance of the System.String class is both immutable and, when no longer needed, cannot be programmatically scheduled for garbage collection; that is, the instance is read-only after it is created and it is not possible to predict when the inst... | I would stop using SecureString . Looks like PG guys are dropping support for it. Possibly even pull it in the future - <https://github.com/dotnet/apireviews/tree/master/2015-07-14-securestring> .
>
> We should remove encryption from SecureString across all platforms in .NET Core - We should obsolete SecureString - W... |
141,204 | <p>I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here.</p>
<p>Specifically I'm wondering; in the case that an exception is thrown is the code that I have in the finally block enough to ensure that the connection is closed a... | [
{
"answer_id": 141215,
"author": "Sklivvz",
"author_id": 7028,
"author_profile": "https://Stackoverflow.com/users/7028",
"pm_score": 7,
"selected": true,
"text": "<p>Wrap your database handling code inside a \"using\"</p>\n\n<pre><code>using (SqlConnection conn = new SqlConnection (...))... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I use a pattern that looks something like this often. I'm wondering if this is alright or if there is a best practice that I am not applying here.
Specifically I'm wondering; in the case that an exception is thrown is the code that I have in the finally block enough to ensure that the connection is closed appropriatel... | Wrap your database handling code inside a "using"
```
using (SqlConnection conn = new SqlConnection (...))
{
// Whatever happens in here, the connection is
// disposed of (closed) at the end.
}
``` |
141,241 | <p>I've seen reference in some C# posted questions to a "using" clause.
Does java have the equivalent?</p>
| [
{
"answer_id": 141267,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 6,
"selected": true,
"text": "<p>Yes. Java 1.7 introduced the <a href=\"http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] | I've seen reference in some C# posted questions to a "using" clause.
Does java have the equivalent? | Yes. Java 1.7 introduced the [try-with-resources](http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) construct allowing you to write:
```
try(InputStream is1 = new FileInputStream("/tmp/foo");
InputStream is2 = new FileInputStream("/tmp/bar")) {
/* do stuff with is1 and is... |
141,251 | <p>This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still points to the same place even though the contents of the .url shows the correct address. I... | [
{
"answer_id": 144213,
"author": "DougN",
"author_id": 7442,
"author_profile": "https://Stackoverflow.com/users/7442",
"pm_score": 1,
"selected": false,
"text": "<p>.URL files are wierd (are they documented anywhere?)</p>\n\n<p>Mine look like this and I don't seem to have that problem (m... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1765/"
] | This is really annoying, we've switched our client downloads page to a different site and want to send a link out with our installer. When the link is created and overwrites the existing file, the metadata in windows XP still points to the same place even though the contents of the .url shows the correct address. I can... | Take a look at here: <http://www.cyanwerks.com/file-format-url.html>
It explains there's a Modified field you can add to the .url file. It also explains how to interpret it. |
141,278 | <p>I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like:</p>
<pre><code>WHERE id IN (SELECT id FROM ...)
</code></pre>
<p><strong>The refactored query runs about 100x faster.</strong> (~50 seconds to ~0.3) I expected an improvement, but can an... | [
{
"answer_id": 141290,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": false,
"text": "<p>Look at the query plan for each query.</p>\n\n<p><em>Where in</em> and <em>Join</em> can <strong>typically</strong> be impl... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521/"
] | I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like:
```
WHERE id IN (SELECT id FROM ...)
```
**The refactored query runs about 100x faster.** (~50 seconds to ~0.3) I expected an improvement, but can anyone explain why it was so drastic? The... | A "correlated subquery" (i.e., one in which the where condition depends on values obtained from the rows of the containing query) will execute once for each row. A non-correlated subquery (one in which the where condition is independent of the containing query) will execute once at the beginning. The SQL engine makes t... |
141,280 | <p>What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or links to real-life examples than actual code, but I certainly would... | [
{
"answer_id": 141311,
"author": "stephanea",
"author_id": 8776,
"author_profile": "https://Stackoverflow.com/users/8776",
"pm_score": 1,
"selected": false,
"text": "<p>Try to split you string on words and count the resulting words, then sort on the counts.</p>\n"
},
{
"answer_id... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] | What's the best and most efficient way to count keywords in JavaScript? Basically, I'd like to take a string and get the top N words or phrases that occur in the string, mainly for the use of suggesting tags. I'm looking more for conceptual hints or links to real-life examples than actual code, but I certainly wouldn't... | Cut, paste + execute demo:
```
var text = "Text to be examined to determine which n words are used the most";
// Find 'em!
var wordRegExp = /\w+(?:'\w{1,2})?/g;
var words = {};
var matches;
while ((matches = wordRegExp.exec(text)) != null)
{
var word = matches[0].toLowerCase();
if (typeof words[word] == "unde... |
141,288 | <p>Is it possible to use the Flex Framework and Components, without using MXML? I know ActionScript pretty decently, and don't feel like messing around with some new XML language just to get some simple UI in there. Can anyone provide an example consisting of an .as file which can be compiled (ideally via FlashDevelop,... | [
{
"answer_id": 141488,
"author": "Antti",
"author_id": 6037,
"author_profile": "https://Stackoverflow.com/users/6037",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, you just need to include the flex swc in your classpath. You can find flex.swc in the flex sdk in frameoworks/lib/flex... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14569/"
] | Is it possible to use the Flex Framework and Components, without using MXML? I know ActionScript pretty decently, and don't feel like messing around with some new XML language just to get some simple UI in there. Can anyone provide an example consisting of an .as file which can be compiled (ideally via FlashDevelop, th... | I did a simple bootstrap similar to Borek (see below). I would love to get rid of the mxml file, but if I don't have it, I don't get any of the standard themes that come with Flex (haloclassic.swc, etc). Does anybody know how to do what Theo suggests and still have the standard themes applied?
Here's my simplified boo... |
141,291 | <p>I want to be able to list only the directories inside some folder.
This means I don't want filenames listed, nor do I want additional sub-folders.</p>
<p>Let's see if an example helps. In the current directory we have:</p>
<pre><code>>>> os.listdir(os.getcwd())
['cx_Oracle-doc', 'DLLs', 'Doc', 'include', ... | [
{
"answer_id": 141313,
"author": "Mark Roddy",
"author_id": 9940,
"author_profile": "https://Stackoverflow.com/users/9940",
"pm_score": 4,
"selected": false,
"text": "<pre><code>directories=[d for d in os.listdir(os.getcwd()) if os.path.isdir(d)]\n</code></pre>\n"
},
{
"answer_id... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708/"
] | I want to be able to list only the directories inside some folder.
This means I don't want filenames listed, nor do I want additional sub-folders.
Let's see if an example helps. In the current directory we have:
```
>>> os.listdir(os.getcwd())
['cx_Oracle-doc', 'DLLs', 'Doc', 'include', 'Lib', 'libs', 'LICENSE.txt', ... | Filter the result using os.path.isdir() (and use os.path.join() to get the real path):
```
>>> [ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ]
['ctypes', 'distutils', 'encodings', 'lib-tk', 'config', 'idlelib', 'xml', 'bsddb', 'hotshot', 'logging', 'doc', 'test', 'compiler', 'curse... |
141,302 | <p>Is there a way to check if a file has been opened by ReWrite in Delphi? </p>
<p>Code would go something like this:</p>
<pre><code>AssignFile(textfile, 'somefile.txt');
if not textFile.IsOpen then
Rewrite(textFile);
</code></pre>
| [
{
"answer_id": 141339,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 5,
"selected": true,
"text": "<p>You can get the filemode. (One moment, I'll create an example).</p>\n\n<p>TTextRec(txt).Mode gives you the mode:</p... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075/"
] | Is there a way to check if a file has been opened by ReWrite in Delphi?
Code would go something like this:
```
AssignFile(textfile, 'somefile.txt');
if not textFile.IsOpen then
Rewrite(textFile);
``` | You can get the filemode. (One moment, I'll create an example).
TTextRec(txt).Mode gives you the mode:
```
55216 = closed
55217 = open read
55218 = open write
fmClosed = $D7B0;
fmInput = $D7B1;
fmOutput = $D7B2;
fmInOut = $D7B3;
```
Search TTextRec in the system unit for more information. |
141,315 | <p>Is there a way to check to see if a date/time is valid you would think these would be easy to check:</p>
<pre><code>$date = '0000-00-00';
$time = '00:00:00';
$dateTime = $date . ' ' . $time;
if(strtotime($dateTime)) {
// why is this valid?
}
</code></pre>
<p>what really gets me is this:</p>
<pre><code>echo d... | [
{
"answer_id": 141341,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>echo date('Y-m-d', strtotime($date));</p>\n \n <p>results in: \"1999-11-30\"</p>\n</blockquote>\n\n<p>T... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | Is there a way to check to see if a date/time is valid you would think these would be easy to check:
```
$date = '0000-00-00';
$time = '00:00:00';
$dateTime = $date . ' ' . $time;
if(strtotime($dateTime)) {
// why is this valid?
}
```
what really gets me is this:
```
echo date('Y-m-d', strtotime($date));
```... | From [php.net](http://php.net/manual/en/function.checkdate.php#78362)
```
<?php
function isValidDateTime($dateTime)
{
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) {
if (checkdate($matches[2], $matches[3], $matches[1])) {
return... |
141,332 | <p>I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this:</p>
<pre><code>sub _read_from_client
{
my ($file_handle) = @_;
while (my $li... | [
{
"answer_id": 141770,
"author": "xdg",
"author_id": 11800,
"author_profile": "https://Stackoverflow.com/users/11800",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://www.perlmonks.org/?node_id=529812\" rel=\"nofollow noreferrer\">This thread</a> on <a href=\"http://www.per... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7045/"
] | I'm writing some server code that talks to a client process via STDIN. I'm trying to write a snippet of perl code that asynchronously receives responses from the client's STDOUT. The blocking version of the code might look like this:
```
sub _read_from_client
{
my ($file_handle) = @_;
while (my $line = <$file_ha... | [This thread](http://www.perlmonks.org/?node_id=529812) on [Perlmonks](http://www.perlmonks.org) suggests you can make a socket nonblocking on Windows in Perl this way:
```
ioctl($socket, 0x8004667e, 1);
```
More details and resources in that thread |
141,344 | <p>How does one check if a directory is already present in the PATH environment variable? Here's a start. All I've managed to do with the code below, though, is echo the first directory in %PATH%. Since this is a FOR loop you'd think it would enumerate all the directories in %PATH%, but it only gets the first one.</p>
... | [
{
"answer_id": 141385,
"author": "Randy",
"author_id": 9361,
"author_profile": "https://Stackoverflow.com/users/9361",
"pm_score": 5,
"selected": false,
"text": "<p>This may work:</p>\n<pre><code>echo ;%PATH%; | find /C /I ";<string>;"\n</code></pre>\n<p>It should give yo... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16605/"
] | How does one check if a directory is already present in the PATH environment variable? Here's a start. All I've managed to do with the code below, though, is echo the first directory in %PATH%. Since this is a FOR loop you'd think it would enumerate all the directories in %PATH%, but it only gets the first one.
Is the... | First I will point out a number of issues that make this problem difficult to solve perfectly. Then I will present the most bullet-proof solution I have been able to come up with.
For this discussion I will use lower case path to represent a single folder path in the file system, and upper case PATH to represent the P... |
141,345 | <p>I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong.</p>
<pre><code><xsl:template match="one">
<xsl:variable name="varOne" select="@count" />
</xsl:template>
<xsl:template ma... | [
{
"answer_id": 141364,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 2,
"selected": false,
"text": "<p>I'm fairly certain that variables are scoped and therefore you can't declare a variable in one and then use it in th... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16354/"
] | I have a xsl file that is grabbing variables from xml and they seem to not be able to see each other. I know it is a scope issue, I just do not know what I am doing wrong.
```
<xsl:template match="one">
<xsl:variable name="varOne" select="@count" />
</xsl:template>
<xsl:template match="two">
<xsl:if test="$varOne =... | Remembering that xsl variables are immutable...
```
<!-- You may want to use absolute path -->
<xsl:variable name="varOne" select="one/@count" />
<xsl:template match="one">
<!-- // do something -->
</xsl:template>
<xsl:template match="two">
<xsl:if test="$varOne = 'Y'">
<xsl:value-of select="varTwo"/>
</xsl:... |
141,348 | <p>I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript <code>Date()</code> object so I can easily perform comparisons and other thi... | [
{
"answer_id": 141383,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 5,
"selected": false,
"text": "<p>Don't bother doing it yourself, just use <a href=\"http://www.datejs.com/\" rel=\"noreferrer\">datejs</a>.</p>\n"
},
{
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18986/"
] | I am working on a form widget for users to enter a time of day into a text input (for a calendar application). Using JavaScript (we are using jQuery FWIW), I want to find the best way to parse the text that the user enters into a JavaScript `Date()` object so I can easily perform comparisons and other things on it.
I ... | A quick solution which works on the input that you've specified:
```js
function parseTime( t ) {
var d = new Date();
var time = t.match( /(\d+)(?::(\d\d))?\s*(p?)/ );
d.setHours( parseInt( time[1]) + (time[3] ? 12 : 0) );
d.setMinutes( parseInt( time[2]) || 0 );
return d;
}
var tests = [
'1:0... |
141,351 | <p>My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a <a href="https://stackoverflow.com/questions/110259/python-memory-profiler">Python memory profiler</a> (specifically, Heapy) with some success in the development environment, but it c... | [
{
"answer_id": 142138,
"author": "joeld",
"author_id": 19104,
"author_profile": "https://Stackoverflow.com/users/19104",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know how to dump an entire python interpreter state and restore it. It would be useful, I'll keep my eye on this ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9585/"
] | My production system occasionally exhibits a memory leak I have not been able to reproduce in a development environment. I've used a [Python memory profiler](https://stackoverflow.com/questions/110259/python-memory-profiler) (specifically, Heapy) with some success in the development environment, but it can't help me wi... | I will expand on Brett's answer from my recent experience. [Dozer package](https://pypi.org/project/Dozer/) is [well maintained](https://github.com/mgedmin/dozer), and despite advancements, like addition of `tracemalloc` to stdlib in Python 3.4, its `gc.get_objects` counting chart is my go-to tool to tackle memory leak... |
141,368 | <p>Given two datetimes. What is the best way to calculate the number of working hours between them. Considering the working hours are Mon 8 - 5.30, and Tue-Fri 8.30 - 5.30, and that potentially any day could be a public holiday.</p>
<p>This is my effort, seem hideously inefficient but in terms of the number of iterati... | [
{
"answer_id": 141384,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>especially considering the IsWorkingDay method hits the DB to see if that day is a public holiday</... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/230/"
] | Given two datetimes. What is the best way to calculate the number of working hours between them. Considering the working hours are Mon 8 - 5.30, and Tue-Fri 8.30 - 5.30, and that potentially any day could be a public holiday.
This is my effort, seem hideously inefficient but in terms of the number of iterations and th... | Before you start optimizing it, ask yourself two questions.
a) Does it work?
b) Is it too slow?
Only if the answer to both question is "yes" are you ready to start optimizing.
Apart from that
* you only need to worry about minutes and hours on the start day and end day. Intervening days will obviously be a full 9/... |
141,370 | <p>What is the best way to specify a property name when using INotifyPropertyChanged? </p>
<p>Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little uneasy about the reflection overhead.</p>
| [
{
"answer_id": 141379,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 4,
"selected": false,
"text": "<p>The reflection overhead here is pretty much overkill especially since INotifyPropertyChanged gets called <strong>a l... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22813/"
] | What is the best way to specify a property name when using INotifyPropertyChanged?
Most examples hardcode the property name as an argument on the PropertyChanged Event. I was thinking about using MethodBase.GetCurrentMethod.Name.Substring(4) but am a little uneasy about the reflection overhead. | Don't forget one thing : `PropertyChanged` event is mainly consumed by components that will **use reflection** to get the value of the named property.
The most obvious example is databinding.
When you fire `PropertyChanged` event, passing the name of the property as a parameter, you should know that *the subscriber o... |
141,372 | <p>Emacs has a useful <code>transpose-words</code> command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation.</p>
<p>For example, ‘<code>stack |overflow</code>’ + M-t = ‘<code>overflow stack|</code>’ (‘<code>|</code>’ is the cursor position).</p>
<p><code><a&... | [
{
"answer_id": 141447,
"author": "Sam Martin",
"author_id": 19088,
"author_profile": "https://Stackoverflow.com/users/19088",
"pm_score": 3,
"selected": false,
"text": "<p>Depending on the situation, you can use the W or B commands, as in dWwP. The \"capital\" versions skip to the next/... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21055/"
] | Emacs has a useful `transpose-words` command which lets one exchange the word before the cursor with the word after the cursor, preserving punctuation.
For example, ‘`stack |overflow`’ + M-t = ‘`overflow stack|`’ (‘`|`’ is the cursor position).
`<a>|<p>` becomes `<p><a|>`.
Is it possible to emulate it in Vim? I know... | These are from my .vimrc and work well for me.
```
" swap two words
:vnoremap <C-X> <Esc>`.``gvP``P
" Swap word with next word
nmap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<cr><c-o><c-l> *N*
``` |
141,388 | <p>Our resident Flex expert is out for the day and I thought this would be a good chance to test this site out. I have a dropdown with a dataProvider that is working fine:</p>
<pre><code><ep:ComboBox id="dead_reason" selectedValue="{_data.dead_reason}"
dataProvider="{_data.staticData.dead_reason}"
labelFiel... | [
{
"answer_id": 141408,
"author": "bill d",
"author_id": 1798,
"author_profile": "https://Stackoverflow.com/users/1798",
"pm_score": 2,
"selected": false,
"text": "<p>Try using an <mx:Repeater> Something like:</p>\n\n<pre><code><mx:Repeater dataProvider=\"{_data.staticData.dead_... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Our resident Flex expert is out for the day and I thought this would be a good chance to test this site out. I have a dropdown with a dataProvider that is working fine:
```
<ep:ComboBox id="dead_reason" selectedValue="{_data.dead_reason}"
dataProvider="{_data.staticData.dead_reason}"
labelField="@label" width=... | Try using an <mx:Repeater> Something like:
```
<mx:Repeater dataProvider="{_data.staticData.dead_reason}">
<mx:RadioButton groupName="reasons" ...>
</mx:Repeater>
``` |
141,422 | <p>Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n'</p>
<pre><code>Ax^(n-1) + Bx^(n-2) + ... + Z
</code></pre>
<p>I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done t... | [
{
"answer_id": 141493,
"author": "Laplie Anderson",
"author_id": 14204,
"author_profile": "https://Stackoverflow.com/users/14204",
"pm_score": 0,
"selected": false,
"text": "<p>You have the equation:</p>\n\n<pre><code>y = Ax^(n-1) + Bx^(n-2) + ... + Z\n</code></pre>\n\n<p>In xy space, an... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287/"
] | Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n'
```
Ax^(n-1) + Bx^(n-2) + ... + Z
```
I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate... | The problem statement is slightly unclear, so first I will clarify my own interpretation of it:
You have a polynomial function
**f(x) = Cnxn + Cn-1xn-1 + ... + C0**
[I changed A, B, ... Z into Cn, Cn-1, ..., C0 to more easily work with linear algebra below.]
Then you also have a transformation such as: **z = ax +... |
141,432 | <p>I have created a brand new project in XCode and have the following in my AppDelegate.py file:</p>
<pre><code>from Foundation import *
from AppKit import *
class MyApplicationAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
NSLog("Application did finish launching.")
stat... | [
{
"answer_id": 142162,
"author": "Chris Lundie",
"author_id": 20685,
"author_profile": "https://Stackoverflow.com/users/20685",
"pm_score": 4,
"selected": true,
"text": "<p>I had to do this to make it work:</p>\n\n<ol>\n<li><p>Open MainMenu.xib. Make sure the class of the app delegate is... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183/"
] | I have created a brand new project in XCode and have the following in my AppDelegate.py file:
```
from Foundation import *
from AppKit import *
class MyApplicationAppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
NSLog("Application did finish launching.")
statusItem = NSSta... | I had to do this to make it work:
1. Open MainMenu.xib. Make sure the class of the app delegate is `MyApplicationAppDelegate`. I'm not sure if you will have to do this, but I did. It was wrong and so the app delegate never got called in the first place.
2. Add `statusItem.retain()` because it gets autoreleased right a... |
141,441 | <p>In JavaScript is it wrong to use a try-catch block and ignore the error rather than test many attributes in the block for null?</p>
<pre><code>try{
if(myInfo.person.name == newInfo.person.name
&& myInfo.person.address.street == newInfo.person.address.street
&& myInfo.person.address.z... | [
{
"answer_id": 141474,
"author": "pdavis",
"author_id": 7819,
"author_profile": "https://Stackoverflow.com/users/7819",
"pm_score": -1,
"selected": false,
"text": "<p>For the example given I would say it was bad practice. There are instances however where it may be more <strong>efficient... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22816/"
] | In JavaScript is it wrong to use a try-catch block and ignore the error rather than test many attributes in the block for null?
```
try{
if(myInfo.person.name == newInfo.person.name
&& myInfo.person.address.street == newInfo.person.address.street
&& myInfo.person.address.zip == newInfo.person.address.z... | Yes. For one, an exception could be thrown for any number of reasons besides missing arguments. The catch-all would hide those cases which probably isn't desired. |
141,449 | <p>How do I create a file-like object (same duck type as File) with the contents of a string?</p>
| [
{
"answer_id": 141451,
"author": "Daryl Spitzer",
"author_id": 4766,
"author_profile": "https://Stackoverflow.com/users/4766",
"pm_score": 8,
"selected": true,
"text": "<p>For Python 2.x, use the <a href=\"https://docs.python.org/2/library/stringio.html\" rel=\"noreferrer\">StringIO</a> ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | How do I create a file-like object (same duck type as File) with the contents of a string? | For Python 2.x, use the [StringIO](https://docs.python.org/2/library/stringio.html) module. For example:
```
>>> from cStringIO import StringIO
>>> f = StringIO('foo')
>>> f.read()
'foo'
```
I use cStringIO (which is faster), but note that it doesn't [accept Unicode strings that cannot be encoded as plain ASCII stri... |
141,450 | <p>I have a select element in a form, and I want to display something only if the dropdown is not visible. Things I have tried:</p>
<ul>
<li>Watching for click events, where odd clicks mean the dropdown is visible and even clicks mean the dropdown isn't. Misses other ways the dropdown could disappear (pressing escap... | [
{
"answer_id": 141535,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there's direct support. You could also sit on the onblur of the select -- it gets called when the selec... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10290/"
] | I have a select element in a form, and I want to display something only if the dropdown is not visible. Things I have tried:
* Watching for click events, where odd clicks mean the dropdown is visible and even clicks mean the dropdown isn't. Misses other ways the dropdown could disappear (pressing escape, tabbing to an... | Conditional-content, which is what you're asking about, isn't that difficult. The in the following example, I'll use [jQuery](http://www.jquery.com) to accomplish our goal:
```
<select id="theSelectId">
<option value="dogs">Dogs</option>
<option value="birds">Birds</option>
<option value="cats">Cats</option>
<... |
141,467 | <p>I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in .NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable. Anyone have any i... | [
{
"answer_id": 141495,
"author": "Torbjörn Gyllebring",
"author_id": 21182,
"author_profile": "https://Stackoverflow.com/users/21182",
"pm_score": 0,
"selected": false,
"text": "<pre><code>static class EnumerableExtensions\n{\n public static IEnumerable<T> Flatten<T>(this ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18049/"
] | I could probably write this myself, but the specific way I'm trying to accomplish it is throwing me off. I'm trying to write a generic extension method similar to the others introduced in .NET 3.5 that will take a nested IEnumerable of IEnumerables (and so on) and flatten it into one IEnumerable. Anyone have any ideas?... | Hmm... I'm not sure *exactly* what you want here, but here's a "one level" option:
```
public static IEnumerable<TElement> Flatten<TElement,TSequence> (this IEnumerable<TSequence> sequences)
where TSequence : IEnumerable<TElement>
{
foreach (TSequence sequence in sequences)
{
foreach(TElement elem... |
141,484 | <p>I'm looking to write a config file that allows for RESTful services in WCF, but I still want the ability to 'tap into' the membership provider for username/password authentication.</p>
<p>The below is part of my current config using basicHttp binding or wsHttp w/out WS Security, how will this change w/ REST based s... | [
{
"answer_id": 143738,
"author": "Darrel Miller",
"author_id": 6819,
"author_profile": "https://Stackoverflow.com/users/6819",
"pm_score": 1,
"selected": false,
"text": "<p>Before you continue down this path of fighting to implement REST over WCF, I suggest you read <a href=\"http://www.... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I'm looking to write a config file that allows for RESTful services in WCF, but I still want the ability to 'tap into' the membership provider for username/password authentication.
The below is part of my current config using basicHttp binding or wsHttp w/out WS Security, how will this change w/ REST based services?
... | **UPDATE 01/23/2012**
Since I wrote this question I've seen a much better approach to securing REST like web services in the wild. It sounded complex when I first heard about it but the idea is simple and all over the web for both web services and other secure communication.
It requires the use of public/private keys... |
141,487 | <pre><code>class Foo(models.Model):
title = models.CharField(max_length=20)
slug = models.SlugField()
</code></pre>
<p>Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin.</p>
| [
{
"answer_id": 141505,
"author": "Nick Sergeant",
"author_id": 22468,
"author_profile": "https://Stackoverflow.com/users/22468",
"pm_score": 2,
"selected": false,
"text": "<p>For pre-1.0:</p>\n\n<pre><code>slug = models.SlugField(prepopulate_from=('title',))\n</code></pre>\n\n<p>should w... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] | ```
class Foo(models.Model):
title = models.CharField(max_length=20)
slug = models.SlugField()
```
Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the Admin and outside of the Admin. | for Admin in Django 1.0 and up, you'd need to use
```
prepopulated_fields = {'slug': ('title',), }
```
in your admin.py
Your key in the prepopulated\_fields dictionary is the field you want filled, and the value is a tuple of fields you want concatenated.
Outside of admin, you can use the `slugify` function in you... |
141,519 | <p>We have a pair of applications. One is written in C# and uses something like:</p>
<pre><code> string s = "alpha\r\nbeta\r\ngamma\r\ndelta";
// Actually there's wrapper code here to make sure this works.
System.Windows.Forms.Clipboard.SetDataObject(s, true);
</code></pre>
<p>To put a list of items onto the clipb... | [
{
"answer_id": 141516,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 3,
"selected": false,
"text": "<p>I use <code>print_r()</code> because I like the pretty array structure... but <code>var_dump</code> does give you a bit more... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8173/"
] | We have a pair of applications. One is written in C# and uses something like:
```
string s = "alpha\r\nbeta\r\ngamma\r\ndelta";
// Actually there's wrapper code here to make sure this works.
System.Windows.Forms.Clipboard.SetDataObject(s, true);
```
To put a list of items onto the clipboard. Another application (... | I always use the Xdebug extended var\_dump. It gives out a lot of verbose output.
See: <http://xdebug.org/docs/display> for more details. |
141,525 | <p>I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)...</p>
<p>At a core level, what does bit-shifting (<code><<</code>, <code>>></code>, <code>>>></code>) do, what problems can it help solve, and what gotchas... | [
{
"answer_id": 141576,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 8,
"selected": false,
"text": "<p>Let's say we have a single byte:</p>\n\n<pre><code>0110110\n</code></pre>\n\n<p>Applying a single left bitshift gets us:<... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14048/"
] | I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)...
At a core level, what does bit-shifting (`<<`, `>>`, `>>>`) do, what problems can it help solve, and what gotchas lurk around the bend? In other words, an absolute beginner's g... | The bit shifting operators do exactly what their name implies. They shift bits. Here's a brief (or not-so-brief) introduction to the different shift operators.
The Operators
-------------
* `>>` is the arithmetic (or signed) right shift operator.
* `>>>` is the logical (or unsigned) right shift operator.
* `<<` is th... |
141,545 | <p>Let's say I have a class that has a member called data which is a list. </p>
<p>I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list.</p>
<p>What's your technique for doing this?</p>
<p>Do you just check the type by looking at... | [
{
"answer_id": 141565,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "<p>A better way would be to use isinstance and type conversion. If I'm understanding you right, you want this:</p>\n\n... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1179/"
] | Let's say I have a class that has a member called data which is a list.
I want to be able to initialize the class with, for example, a filename (which contains data to initialize the list) or with an actual list.
What's your technique for doing this?
Do you just check the type by looking at `__class__`?
Is there s... | A much neater way to get 'alternate constructors' is to use classmethods. For instance:
```
>>> class MyData:
... def __init__(self, data):
... "Initialize MyData from a sequence"
... self.data = data
...
... @classmethod
... def fromfilename(cls, filename):
... "Initialize MyD... |
141,560 | <p>I have a loop that looks something like this:</p>
<pre><code>for (int i = 0; i < max; i++) {
String myString = ...;
float myNum = Float.parseFloat(myString);
myFloats[i] = myNum;
}
</code></pre>
<p>This is the main content of a method whose sole purpose is to return the array of floats. I want this ... | [
{
"answer_id": 141577,
"author": "Jamie",
"author_id": 22748,
"author_profile": "https://Stackoverflow.com/users/22748",
"pm_score": 2,
"selected": false,
"text": "<p>In your examples there is no functional difference. I find your first example more readable.</p>\n"
},
{
"answer... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13531/"
] | I have a loop that looks something like this:
```
for (int i = 0; i < max; i++) {
String myString = ...;
float myNum = Float.parseFloat(myString);
myFloats[i] = myNum;
}
```
This is the main content of a method whose sole purpose is to return the array of floats. I want this method to return `null` if th... | All right, after [Jeffrey L Whitledge said](https://stackoverflow.com/questions/141560/should-trycatch-go-inside-or-outside-a-loop#141652) that there was no performance difference (as of 1997), I went and tested it. I ran this small benchmark:
```
public class Main {
private static final int NUM_TESTS = 100;
... |
141,562 | <p>I can select all the distinct values in a column in the following ways:</p>
<ul>
<li><code>SELECT DISTINCT column_name FROM table_name;</code></li>
<li><code>SELECT column_name FROM table_name GROUP BY column_name;</code></li>
</ul>
<p>But how do I get the row count from that query? Is a subquery required?</p>
| [
{
"answer_id": 141573,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 4,
"selected": false,
"text": "<pre><code>select Count(distinct columnName) as columnNameCount from tableName \n</code></pre>\n"
},
{
"answer_id": 14... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] | I can select all the distinct values in a column in the following ways:
* `SELECT DISTINCT column_name FROM table_name;`
* `SELECT column_name FROM table_name GROUP BY column_name;`
But how do I get the row count from that query? Is a subquery required? | You can use the `DISTINCT` keyword within the [`COUNT`](http://technet.microsoft.com/en-us/library/ms175997%28v=sql.90%29.aspx) aggregate function:
```
SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name
```
This will count only the distinct values for that column. |
141,598 | <p>I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: <code>School</code>, <code>Course</code>, and <code>Student</code>, which are defined as follows:</p>
<pre><code... | [
{
"answer_id": 141624,
"author": "Instantsoup",
"author_id": 9861,
"author_profile": "https://Stackoverflow.com/users/9861",
"pm_score": 0,
"selected": false,
"text": "<p>From experience, XML isn't the best to store relational data. Have you investigated <a href=\"http://www.yaml.org/\" ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317/"
] | I'm wondering what the best practices are for storing a relational data structure in XML. Particulary, I am wondering about best practices for enforcing node order. For example, say I have three objects: `School`, `Course`, and `Student`, which are defined as follows:
```
class School
{
List<Course> Courses;
L... | Don't think in SQL or relational when working with XML, because there are no order constraints.
You can however query using XPath to any portion of the XML document at any time. You want the courses first, then "//Courses/Course". You want the students enrollments next, then "//Students/Student/EnrolledIn/Course".
T... |
141,599 | <p>What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'. </p>
<p>Is there an easy way to accomplish this in Subversion besides grep-ing the svn log output for the timestamp?</p>
<p>Example:</p>
<pre><code>sv... | [
{
"answer_id": 141619,
"author": "Zsolt Botykai",
"author_id": 11621,
"author_profile": "https://Stackoverflow.com/users/11621",
"pm_score": 7,
"selected": true,
"text": "<p>Very first hit by google for \"svn log date range\": <a href=\"http://svn.haxx.se/users/archive-2006-08/0737.shtml... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] | What I would like is be able to generate a simple report that is the output of svn log for a certain date range. Specifically, all the changes since 'yesterday'.
Is there an easy way to accomplish this in Subversion besides grep-ing the svn log output for the timestamp?
Example:
```
svn -v log -d 2008-9-23:2008-9:2... | Very first hit by google for "svn log date range": <http://svn.haxx.se/users/archive-2006-08/0737.shtml>
>
> So `svn log <url> -r
> {2008-09-19}:{2008-09-26}` will get
> all changes for the past week,
> including today.
>
>
>
And if you want to generate reports for a repo, there's a solution: [Statsvn](http://... |
141,606 | <p>Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note to the top of the page with an explanation and possibly a link to some refe... | [
{
"answer_id": 141613,
"author": "Anders Sandvig",
"author_id": 1709,
"author_profile": "https://Stackoverflow.com/users/1709",
"pm_score": 0,
"selected": false,
"text": "<p>I just came to think of something. I guess I could render the note with JavaScript once the page is loaded?</p>\n"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709/"
] | Say that I write an article or document about a certain topic, but the content is meant for readers with certain prior knowledge about the topic. To help people who don't have the "required" background information, I would like to add a note to the top of the page with an explanation and possibly a link to some referen... | You can build that portion of the content dynamically using Javascript.
For example:
```
<html>
<body>
<div id="dynContent">
</div>
Rest of the content here.
</body>
<script language='javascript' type='text/javascript'>
var dyn = document.getElementById('dynContent');
dyn.innerHTML = "Put the dynamic cont... |
141,611 | <p>I have an Enum like this</p>
<pre><code>package com.example;
public enum CoverageEnum {
COUNTRY,
REGIONAL,
COUNTY
}
</code></pre>
<p>I would like to iterate over these constants in JSP without using scriptlet code. I know I can do it with scriptlet code like this:</p>
<pre><code><c:forEach var="t... | [
{
"answer_id": 141658,
"author": "Garth Gilmour",
"author_id": 2635682,
"author_profile": "https://Stackoverflow.com/users/2635682",
"pm_score": 3,
"selected": false,
"text": "<p>If you are using Tag Libraries you could encapsulate the code within an EL function. So the opening tag would... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have an Enum like this
```
package com.example;
public enum CoverageEnum {
COUNTRY,
REGIONAL,
COUNTY
}
```
I would like to iterate over these constants in JSP without using scriptlet code. I know I can do it with scriptlet code like this:
```
<c:forEach var="type" items="<%= com.example.CoverageEnum... | If you are using Tag Libraries you could encapsulate the code within an EL function. So the opening tag would become:
```
<c:forEach var="type" items="${myprefix:getValues()}">
```
EDIT: In response to discussion about an implementation that would work for multiple Enum types just sketched out this:
```
public stat... |
141,612 | <p>I'm working on database designs for a project management system as personal project and I've hit a snag.</p>
<p>I want to implement a ticket system and I want the tickets to look like the <a href="http://trac.edgewall.org/ticket/6436" rel="noreferrer">tickets in Trac</a>. What structure would I use to replicate thi... | [
{
"answer_id": 141621,
"author": "Pete Karl II",
"author_id": 22491,
"author_profile": "https://Stackoverflow.com/users/22491",
"pm_score": 1,
"selected": false,
"text": "<p>I'd say create some kind of event listening class that you ping every time something happens within your system &a... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16204/"
] | I'm working on database designs for a project management system as personal project and I've hit a snag.
I want to implement a ticket system and I want the tickets to look like the [tickets in Trac](http://trac.edgewall.org/ticket/6436). What structure would I use to replicate this system? (I have not had any success ... | I have implemented pure record change data using a "thin" design:
```
RecordID Table Column OldValue NewValue
-------- ----- ------ -------- --------
```
You may not want to use "Table" and "Column", but rather "Object" and "Property", and so forth, depending on your design.
This has the advantage of flexib... |
141,620 | <p>i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag.</p>
<p>i have this code in the application.rb:</p>
<p>def ... | [
{
"answer_id": 141721,
"author": "MatthewFord",
"author_id": 21596,
"author_profile": "https://Stackoverflow.com/users/21596",
"pm_score": 4,
"selected": true,
"text": "<p>just a guess but it seems that your session[:user] is just storing the id, you need to do:</p>\n\n<pre><code>@user =... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before\_filter to check that the user of the user in the session has a 'can\_access\_admin' flag.
i have this code in the application.rb:
def check\_role
@... | just a guess but it seems that your session[:user] is just storing the id, you need to do:
```
@user = User.find(session[:user])
```
or something along those lines to fetch the user from the database (along with its associations).
It's good to do the above in a before filter too. |
141,626 | <p>I've got a windows form in Visual Studio 2008 using .NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it?</p>
<p>The old win32 browser control had a Before_Navigate event which had PostData as o... | [
{
"answer_id": 144354,
"author": "mdb",
"author_id": 8562,
"author_profile": "https://Stackoverflow.com/users/8562",
"pm_score": 4,
"selected": true,
"text": "<p>That functionality isn't exposed by the .NET WebBrowser control. Fortunately, that control is mostly a wrapper around the 'old... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a windows form in Visual Studio 2008 using .NET 3.5 which has a WebBrowser control on it. I need to analyse the form's PostData in the Navigating event handler before the request is sent. Is there a way to get to it?
The old win32 browser control had a Before\_Navigate event which had PostData as one of its a... | That functionality isn't exposed by the .NET WebBrowser control. Fortunately, that control is mostly a wrapper around the 'old' control. This means you can subscribe to the BeforeNavigate2 event you know and love(?) using something like the following (after adding a reference to SHDocVw to your project):
```
Dim ie = ... |
141,630 | <p>If I drag and drop a selection of a webpage from Firefox to HTML-Kit, HTML-Kit asks me whether I want to paste as text or HTML. If I select "text," I get this:</p>
<pre><code>Version:0.9
StartHTML:00000147
EndHTML:00000516
StartFragment:00000181
EndFragment:00000480
SourceURL:http://en.wikipedia.org/wiki/Herodotus
... | [
{
"answer_id": 141727,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "<p>It is Microsoft specific, don't expect to see the same information in other OSes.<br>\nNote that you get the same format... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4965/"
] | If I drag and drop a selection of a webpage from Firefox to HTML-Kit, HTML-Kit asks me whether I want to paste as text or HTML. If I select "text," I get this:
```
Version:0.9
StartHTML:00000147
EndHTML:00000516
StartFragment:00000181
EndFragment:00000480
SourceURL:http://en.wikipedia.org/wiki/Herodotus
<html><body>
<... | For completeness, here is the P/Invoke Win32 API code to get RAW clipboard data
```
using System;
using System.Runtime.InteropServices;
using System.Text;
//--------------------------------------------------------------------------------
http://metadataconsulting.blogspot.com/2019/06/How-to-get-HTML-from-the-Windows-... |
141,637 | <p>I have this code:</p>
<pre><code>@PersistenceContext(name="persistence/monkey", unitName="deltaflow-pu")
...
@Stateless
public class GahBean implements GahRemote {
</code></pre>
<p>But when I use this:</p>
<pre><code>try{
InitialContext ic = new InitialContext();
System.out.println("Pissing me off * " + ic.look... | [
{
"answer_id": 141706,
"author": "arinte",
"author_id": 22763,
"author_profile": "https://Stackoverflow.com/users/22763",
"pm_score": 0,
"selected": false,
"text": "<p>If I inject it by the way it works fine, but everywhere I read about that they say it isn't threadsafe to do it that way... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22763/"
] | I have this code:
```
@PersistenceContext(name="persistence/monkey", unitName="deltaflow-pu")
...
@Stateless
public class GahBean implements GahRemote {
```
But when I use this:
```
try{
InitialContext ic = new InitialContext();
System.out.println("Pissing me off * " + ic.lookup("java:comp/env/persistent/monkey")... | This could be my ignorance about JPA showing, but you appear to have "persistence" in some places and "persistent" in others. I'd start by making sure the names match. |
141,642 | <p>Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures. </p>
<p>Some limitations are mentioned in the <a href="http://ivan.truemesh.com/archives/000411.html" rel="noreferrer">Closures in Python</a> (compared to Ruby's closures), but the article i... | [
{
"answer_id": 141670,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": false,
"text": "<p>The only difficulty I've seen people encounter with Python's in particular is when they try to mix non-functional f... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279/"
] | Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures.
Some limitations are mentioned in the [Closures in Python](http://ivan.truemesh.com/archives/000411.html) (compared to Ruby's closures), but the article is old and many limitations do not exist... | The most important limitation, currently, is that you cannot assign to an outer-scope variable. In other words, closures are read-only:
```
>>> def outer(x):
... def inner_reads():
... # Will return outer's 'x'.
... return x
... def inner_writes(y):
... # Will assign to a local 'x', no... |
141,650 | <p>I've seen <a href="https://stackoverflow.com/questions/129877/how-do-i-write-a-generic-memoize-function">the other post about this</a>, but is there a clean way of doing this in Haskell?</p>
<p>As a 2nd part, can it also be done without making the function monadic?</p>
| [
{
"answer_id": 142269,
"author": "mattiast",
"author_id": 8272,
"author_profile": "https://Stackoverflow.com/users/8272",
"pm_score": 1,
"selected": false,
"text": "<p>If your arguments are going to be natural numbers, you can do simply:</p>\n\n<pre><code>memo f = let values = map f [0..... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12887/"
] | I've seen [the other post about this](https://stackoverflow.com/questions/129877/how-do-i-write-a-generic-memoize-function), but is there a clean way of doing this in Haskell?
As a 2nd part, can it also be done without making the function monadic? | This largely follows <http://www.haskell.org/haskellwiki/Memoization>.
You want a function of type (a -> b). If it doesn't call itself, then
you can just write a simple wrapper that caches the return values. The
best way to store this mapping depends on what properties of a you can
exploit. Ordering is pretty much a ... |
141,682 | <p>I'm trying to test if a given default constraint exists. I don't want to use the sysobjects table, but the more standard INFORMATION_SCHEMA.</p>
<p>I've used this to check for tables and primary key constraints before, but I don't see default constraints anywhere.</p>
<p>Are they not there? (I'm using MS SQL Serve... | [
{
"answer_id": 141825,
"author": "user12861",
"author_id": 12861,
"author_profile": "https://Stackoverflow.com/users/12861",
"pm_score": 2,
"selected": false,
"text": "<p>Is the COLUMN_DEFAULT column of INFORMATION_SCHEMA.COLUMNS what you are looking for?</p>\n"
},
{
"answer_id":... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9052/"
] | I'm trying to test if a given default constraint exists. I don't want to use the sysobjects table, but the more standard INFORMATION\_SCHEMA.
I've used this to check for tables and primary key constraints before, but I don't see default constraints anywhere.
Are they not there? (I'm using MS SQL Server 2000).
EDIT: ... | As I understand it, default value constraints aren't part of the ISO standard, so they don't appear in INFORMATION\_SCHEMA. INFORMATION\_SCHEMA seems like the best choice for this kind of task because it is cross-platform, but if the information isn't available one should use the object catalog views (sys.\*) instead o... |
141,734 | <p>If I do not specify the following in my web.xml file:</p>
<pre><code><session-config>
<session-timeout>10</session-timeout>
</session-config>
</code></pre>
<p>What will be my default session timeout? (I am running Tomcat 6.0)</p>
| [
{
"answer_id": 141742,
"author": "JavadocMD",
"author_id": 9304,
"author_profile": "https://Stackoverflow.com/users/9304",
"pm_score": 3,
"selected": false,
"text": "<p>I'm sure it depends on your container. Tomcat is 30 minutes.</p>\n"
},
{
"answer_id": 141755,
"author": "Hu... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/318/"
] | If I do not specify the following in my web.xml file:
```
<session-config>
<session-timeout>10</session-timeout>
</session-config>
```
What will be my default session timeout? (I am running Tomcat 6.0) | If you're using Tomcat, it's 30 minutes. You can read more about it [here](http://forums.sun.com/thread.jspa?threadID=565341&messageID=2788327). |
141,752 | <p>My application is generating different floating point values when I compile it in release mode and in debug mode. The only reason that I found out is I save a binary trace log and the one from the release build is ever so slightly off from the debug build, it looks like the bottom two bits of the 32 bit float values... | [
{
"answer_id": 141771,
"author": "Branan",
"author_id": 13894,
"author_profile": "https://Stackoverflow.com/users/13894",
"pm_score": 2,
"selected": false,
"text": "<p>It's not a bug. Any floating point uperation has a certain imprecision. In Release mode, optimization will change the or... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13676/"
] | My application is generating different floating point values when I compile it in release mode and in debug mode. The only reason that I found out is I save a binary trace log and the one from the release build is ever so slightly off from the debug build, it looks like the bottom two bits of the 32 bit float values ar... | Release mode may have a different FP strategy set. There are different floating point arithmetic modes depending on the level of optimization you'd like. MSVC, for example, has strict, fast, and precise modes. |
141,779 | <p>The problem/comic in question: <a href="http://xkcd.com/287/" rel="nofollow noreferrer">http://xkcd.com/287/</a></p>
<p><img src="https://imgs.xkcd.com/comics/np_complete.png" alt="General solutions get you a 50% tip"></p>
<p>I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm... | [
{
"answer_id": 141858,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "<p>Read up on the <a href=\"http://en.wikipedia.org/wiki/Knapsack_problem\" rel=\"nofollow noreferrer\">Knapsack Pro... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751/"
] | The problem/comic in question: <http://xkcd.com/287/>

I'm not sure this is the best way to do it, but here's what I've come up with so far. I'm using CFML, but it should be readable by anyone.
```
<cffunction name="testCombo" return... | The point about an NP-complete problem is not that it's tricky on a small data set, but that the amount of work to solve it grows at a rate greater than polynomial, i.e. there is no O(n^x) algorithm.
If the time complexity is O(n!), as in (I believe) the two problems mentioned above, that is in NP. |
141,807 | <p>I've got a really large project I made for myself and rece3ntly a client asked for their own version of it with some modifications. The project name was rather silly and my client wants the source so I figured it'd be best if I renamed all my files from</p>
<pre><code>sillyname.h
sillyname.cpp
sillyname.dsp
</cod... | [
{
"answer_id": 141839,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 0,
"selected": false,
"text": "<p>You can simply rename the .vcproj or .dsp file and then either create a new workspace (sln dsw) and include the ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a really large project I made for myself and rece3ntly a client asked for their own version of it with some modifications. The project name was rather silly and my client wants the source so I figured it'd be best if I renamed all my files from
```
sillyname.h
sillyname.cpp
sillyname.dsp
```
etc..
Unfortun... | Here is a [Step by Step](http://www.platinumbay.com/blogs/dotneticated/archive/2008/01/01/renaming-and-copying-projects-and-solutions.aspx) on Steve Andrews' blog (he works on Visual Studio at Microsoft) |
141,808 | <p>I have a micro-mini-search engine that highlights the search terms in my rails app. The search ignores accents and the highlight is case insensitive. Almost perfect.
But, for instance if I have a record with the text "pão de queijo" and searches for "pao de queijo" the record <strong>is</strong> returned but the iex... | [
{
"answer_id": 141823,
"author": "Kolten",
"author_id": 13959,
"author_profile": "https://Stackoverflow.com/users/13959",
"pm_score": 0,
"selected": false,
"text": "<p>it sounds like you are using two different methods for deciding whether a match has occured or not: one for your search,... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | I have a micro-mini-search engine that highlights the search terms in my rails app. The search ignores accents and the highlight is case insensitive. Almost perfect.
But, for instance if I have a record with the text "pão de queijo" and searches for "pao de queijo" the record **is** returned but the iext **is not** hig... | I've just submitted a patch to Rails thats solves this.
<http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3593-patch-support-for-highlighting-with-ignoring-special-chars>
```
# Highlights one or more +phrases+ everywhere in +text+ by inserting it into
# a <tt>:highlighter</tt> string. The highli... |
141,864 | <p>I need help understanding some C++ operator overload statements. The class is declared like this: </p>
<pre><code>template <class key_t, class ipdc_t>
class ipdc_map_template_t : public ipdc_lockable_t
{
...
typedef map<key_t,
ipdc_t*,
less<key_t>> map_t;
...
<... | [
{
"answer_id": 141893,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "<p>The creator of the class has overridden the cast operators.\nSo by just assigning the iter to an object of the corr... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19719/"
] | I need help understanding some C++ operator overload statements. The class is declared like this:
```
template <class key_t, class ipdc_t>
class ipdc_map_template_t : public ipdc_lockable_t
{
...
typedef map<key_t,
ipdc_t*,
less<key_t>> map_t;
...
```
The creator of the class has... | These are typecast operators, so you can do this:
```
{
key_t key = iter;
ipdc_t *val = iter;
}
```
Or, since `ipdc_map_template::iterator` is a subclass of `std::map::iterator`, you can still use the original accessors (which I find more readable):
```
{
key_t key = (*iter).first;
ipdc_t *val =... |
141,875 | <p>What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like:</p>
<pre><code>number: (MONTH|... | [
{
"answer_id": 142009,
"author": "Douglas Mayle",
"author_id": 8458,
"author_profile": "https://Stackoverflow.com/users/8458",
"pm_score": 4,
"selected": true,
"text": "<p>The problem is that you seem to want to perform both syntactical and semantical checking in your lexer and/or your p... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12034/"
] | What is the simplest (shortest, fewest rules, and no warnings) way to parse both valid dates and numbers in the same grammar? My problem is that a lexer rule to match a valid month (1-12) will match any occurrence of 1-12. So if I just want to match a number, I need a parse rule like:
```
number: (MONTH|INT);
```
It... | The problem is that you seem to want to perform both syntactical and semantical checking in your lexer and/or your parser. It's a common mistake, and something that is only possible in very simple languages.
What you really need to do is accept more broadly in the lexer and parser, and then perform semantic checks. Ho... |
141,876 | <p>Platform: Windows XP
Development Platform: VB6</p>
<p>When trying to set an application title via the Project Properties dialog on the Make tab, it seems to silently cut off the title at a set number of characters. Also tried this via the App.Title property and it seems to suffer from the same problem. I wouldn't... | [
{
"answer_id": 142183,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 1,
"selected": false,
"text": "<p>It appears that VB6 limits the App.Title property to 40 characters. Unfortunately, I can't locate any documentation o... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] | Platform: Windows XP
Development Platform: VB6
When trying to set an application title via the Project Properties dialog on the Make tab, it seems to silently cut off the title at a set number of characters. Also tried this via the App.Title property and it seems to suffer from the same problem. I wouldn't care about ... | One solution using the Windows API
----------------------------------
**Disclaimer**: *IMHO this seems like overkill just to meet the requirement stated in the question, but in the spirit of giving a (hopefully) complete answer to the problem, here goes nothing...*
Here is a working version I came up with after looki... |
141,878 | <p>The following snippet is supposed to take the value of PROJECT (defined in the Makefile)
and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier_ir.h for PROJECTINCSTR</p>
<p>I find that this code works as long as I am not trying to use an underscore in the... | [
{
"answer_id": 141919,
"author": "hayalci",
"author_id": 16084,
"author_profile": "https://Stackoverflow.com/users/16084",
"pm_score": 0,
"selected": false,
"text": "<p>That barebone example works with gcc (v4.1.2) and tries to include \"PROJECT_ir.h\"</p>\n"
},
{
"answer_id": 14... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22781/"
] | The following snippet is supposed to take the value of PROJECT (defined in the Makefile)
and create an include file name. For example, if PROJECT=classifier, then it should at the end generate classifier\_ir.h for PROJECTINCSTR
I find that this code works as long as I am not trying to use an underscore in the suffix. ... | ```
#define QMAKESTR(x) #x
#define MAKESTR(x) QMAKESTR(x)
#define SMASH(x,y) x##y
#define MAKEINC(x) SMASH(x,_ir.h)
#define PROJECTINC MAKEINC(PROJECT)
#define PROJECTINCSTR MAKESTR(PROJECTINC)
``` |
141,913 | <p>I'm parsing XML results from an API call using PHP and xpath. </p>
<pre><code> $dom = new DOMDocument();
$dom->loadXML($response->getBody());
$xpath = new DOMXPath($dom);
$xpath->registerNamespace("a", "http://www.example.com");
$hrefs = $xpath->query('//a:Books/text()', $dom);
for ($i = 0; $i ... | [
{
"answer_id": 141933,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "<p>Could you query for the concatenation?</p>\n\n<pre><code>$xpath->query('concat(//a:Books/text(), //a:Books/@DeweyDe... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2863/"
] | I'm parsing XML results from an API call using PHP and xpath.
```
$dom = new DOMDocument();
$dom->loadXML($response->getBody());
$xpath = new DOMXPath($dom);
$xpath->registerNamespace("a", "http://www.example.com");
$hrefs = $xpath->query('//a:Books/text()', $dom);
for ($i = 0; $i < $hrefs->length; $i++) {
... | After doing some looking around I came across this solution. This way I can get the element text and access any attributes of the node.
```
$hrefs = $xpath->query('//a:Books', $dom);
for ($i = 0; $i < $hrefs->length; $i++) {
$arrBookTitle[$i] = $hrefs->item($i)->nodeValue;
$arrBookDewey[$i] = $hrefs->item($i)... |
141,939 | <p>I'm building a shared library with g++ 3.3.4. I cannot link to the library because I am getting </p>
<pre><code>./BcdFile.RHEL70.so: undefined symbol: _ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13insert_uniqueERKj
</code></pre>
<p>Which c++filt describes as </p>
<pre><code>std::_Rb_tree<unsigned int, unsi... | [
{
"answer_id": 141957,
"author": "Branan",
"author_id": 13894,
"author_profile": "https://Stackoverflow.com/users/13894",
"pm_score": 1,
"selected": false,
"text": "<p><code>std::_Rb_Tree</code> might be a red-black tree, which would most likely be from using <code>map</code>. It should ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17209/"
] | I'm building a shared library with g++ 3.3.4. I cannot link to the library because I am getting
```
./BcdFile.RHEL70.so: undefined symbol: _ZNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13insert_uniqueERKj
```
Which c++filt describes as
```
std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, ... | `std::_Rb_Tree` might be a red-black tree, which would most likely be from using `map`. It should be part of `libstdc++`, unless your library is linking against a different version of `libstdc++` than the application, which from what you've said so far seems unlikely.
EDIT: Just to clarify, the red-black tree is the u... |
141,970 | <p>I'm experimenting with generics and I'm trying to create structure similar to Dataset class.<br>
I have following code</p>
<pre><code>public struct Column<T>
{
T value;
T originalValue;
public bool HasChanges
{
get { return !value.Equals(originalValue); }
}
public void Accept... | [
{
"answer_id": 142115,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 0,
"selected": false,
"text": "<p>You could use reflection to iterate over the members and invoke HasChanges and AcceptChanges. The Record class could ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22569/"
] | I'm experimenting with generics and I'm trying to create structure similar to Dataset class.
I have following code
```
public struct Column<T>
{
T value;
T originalValue;
public bool HasChanges
{
get { return !value.Equals(originalValue); }
}
public void AcceptChanges()
{
... | As you asked for examples from functional languages; in lisp you could prevent the writing of all that code upon each addition of a column by using a macro to crank the code out for you. Sadly, I do not think that is possible in C#.
In terms of performance: the macro would be evaluated at compile time (thus slowing c... |
141,973 | <p>Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an _, but I have been unable to get any code working. Examples would be much appreciated. Th... | [
{
"answer_id": 142106,
"author": "Nick Johnson",
"author_id": 12030,
"author_profile": "https://Stackoverflow.com/users/12030",
"pm_score": 1,
"selected": false,
"text": "<p>You're correct - the key is stored as the property name prefixed with '_'. You should just be able to access it di... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] | Is there a way to get the key (or id) value of a db.ReferenceProperty, without dereferencing the actual entity it points to? I have been digging around - it looks like the key is stored as the property name preceeded with an \_, but I have been unable to get any code working. Examples would be much appreciated. Thanks.... | Actually, the way that you are advocating accessing the key for a ReferenceProperty might well not exist in the future. Attributes that begin with '\_' in python are generally accepted to be "protected" in that things that are closely bound and intimate with its implementation can use them, but things that are updated ... |
141,993 | <p>I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in and listen for the XML message to come out the other end.<... | [
{
"answer_id": 142004,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"http://xom.nu\" rel=\"noreferrer\">Xom</a> has a Canonicalizer utility which turns your DOMs into a regular ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1247/"
] | I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input messages in and listen for the XML message to come out the other end.
Whe... | Sounds like a job for XMLUnit
* <http://www.xmlunit.org/>
* <https://github.com/xmlunit>
Example:
```
public class SomeTest extends XMLTestCase {
@Test
public void test() {
String xml1 = ...
String xml2 = ...
XMLUnit.setIgnoreWhitespace(true); // ignore whitespace differences
// can also compar... |
142,000 | <p>I've got a page with a normal form with a submit button and some jQuery which binds to the form submit event and overrides it with <code>e.preventDefault()</code> and runs an AJAX command. This works fine when the submit button is clicked but when a link with <code>onclick='document.formName.submit();'</code> is cli... | [
{
"answer_id": 142021,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 4,
"selected": false,
"text": "<p>If you are using jQuery, you should be attaching events via it's own <a href=\"http://docs.jquery.com/Events\" re... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16624/"
] | I've got a page with a normal form with a submit button and some jQuery which binds to the form submit event and overrides it with `e.preventDefault()` and runs an AJAX command. This works fine when the submit button is clicked but when a link with `onclick='document.formName.submit();'` is clicked, the event is not ca... | A couple of suggestions:
* Overwrite the submit function to do your evil bidding
```
var oldSubmit = form.submit;
form.submit = function() {
$(form).trigger("submit");
oldSubmit.call(form, arguments);
}
```
* Why not bind to all the <a> tags? Then you don't have to do any monkey patchin... |
142,003 | <p>I have a scenario. (Windows Forms, C#, .NET)</p>
<ol>
<li>There is a main form which hosts some user control.</li>
<li>The user control does some heavy data operation, such that if I directly call the <code>UserControl_Load</code> method the UI become nonresponsive for the duration for load method execution.</li>
<l... | [
{
"answer_id": 142053,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": false,
"text": "<p>Controls in .NET are not generally thread safe. That means you shouldn't access a control from a thread other than... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22858/"
] | I have a scenario. (Windows Forms, C#, .NET)
1. There is a main form which hosts some user control.
2. The user control does some heavy data operation, such that if I directly call the `UserControl_Load` method the UI become nonresponsive for the duration for load method execution.
3. To overcome this I load data on d... | As per [Prerak K's update comment](https://stackoverflow.com/questions/142003/cross-thread-operation-not-valid-control-accessed-from-a-thread-other-than-the#142108) (since deleted):
>
> I guess I have not presented the question properly.
>
>
> Situation is this: I want to load data into a global variable based on t... |
142,010 | <p>Say I have the following XML...</p>
<pre><code><root>
<base>
<tent key="1" color="red"/>
<tent key="2" color="yellow"/>
<tent key="3" color="blue"/>
</base>
<bucket>
<tent key="1"/>
<tent key="3"/>
</bucket>
</root>
</code... | [
{
"answer_id": 142067,
"author": "Garth Gilmour",
"author_id": 2635682,
"author_profile": "https://Stackoverflow.com/users/2635682",
"pm_score": 2,
"selected": false,
"text": "<p>I think this will work:</p>\n\n<pre><code>/root/base/tent[/root/bucket/tent/@key = @key ]/@color\n</code></pr... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13930/"
] | Say I have the following XML...
```
<root>
<base>
<tent key="1" color="red"/>
<tent key="2" color="yellow"/>
<tent key="3" color="blue"/>
</base>
<bucket>
<tent key="1"/>
<tent key="3"/>
</bucket>
</root>
```
...what would the XPath be that returns that the "bucket" contains "red" and "bl... | If you're using XSLT, I'd recommend setting up a key:
```
<xsl:key name="tents" match="base/tent" use="@key" />
```
You can then get the `<tent>` within `<base>` with a particular `key` using
```
key('tents', $id)
```
Then you can do
```
key('tents', /root/bucket/tent/@key)/@color
```
or, if `$bucket` is a par... |
142,016 | <p>I'm looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure.</p>
<p>IE: given</p>
<pre><code>struct mstct {
int myfield;
int myfield2;
};
</code></pre>
<p>I could write:</p>
<pre><code>mstct thing;
printf("offset %lu\n", (unsig... | [
{
"answer_id": 142023,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 7,
"selected": true,
"text": "<p>How about the standard offsetof() macro (in stddef.h)?</p>\n\n<p>Edit: for people who might not have the offsetof()... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4777/"
] | I'm looking for a piece of code that can tell me the offset of a field within a structure without allocating an instance of the structure.
IE: given
```
struct mstct {
int myfield;
int myfield2;
};
```
I could write:
```
mstct thing;
printf("offset %lu\n", (unsigned long)(&thing.myfield2 - &thing));
```
... | How about the standard offsetof() macro (in stddef.h)?
Edit: for people who might not have the offsetof() macro available for some reason, you can get the effect using something like:
```
#define OFFSETOF(type, field) ((unsigned long) &(((type *) 0)->field))
``` |
142,042 | <p>I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like</p>
<pre><code><?xml-stylesheet type='text/xsl' href='/stylesheets/style.xslt' ?>
</code></pre>
<p>Normally, I'd use the <code>instruct!</code> method, but <code>:x... | [
{
"answer_id": 142077,
"author": "JasonTrue",
"author_id": 13433,
"author_profile": "https://Stackoverflow.com/users/13433",
"pm_score": 3,
"selected": true,
"text": "<p>I'm not sure this will solve your problem since I don't know the instruct! method of that object, but :'xml-stylesheet... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10026/"
] | I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like
```
<?xml-stylesheet type='text/xsl' href='/stylesheets/style.xslt' ?>
```
Normally, I'd use the `instruct!` method, but `:xml-stylesheet` is not a valid Ruby symbol.
XMLBu... | I'm not sure this will solve your problem since I don't know the instruct! method of that object, but :'xml-stylesheet' is a valid ruby symbol. |
142,090 | <p>I'm looking to create an ValidationRule class that validates properties on an entity type object. I'd really like to set the name of the property to inspect, and then give the class a delegate or a lambda expression that will be evaluated at runtime when the object runs its IsValid() method. Does anyone have a sni... | [
{
"answer_id": 142112,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<pre><code>class ValidationRule {\n public delegate bool Validator();\n\n private Validator _v;\n\n public Vali... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I'm looking to create an ValidationRule class that validates properties on an entity type object. I'd really like to set the name of the property to inspect, and then give the class a delegate or a lambda expression that will be evaluated at runtime when the object runs its IsValid() method. Does anyone have a snippet ... | Really, what you want to use is `Func<T,bool>` where T is the type of the item you want to validate. Then you would do something like this
```
validator.AddValidation(item => (item.HasEnoughInformation() || item.IsEmpty());
```
you could store them in a `List<Func<T,bool>>`. |
142,110 | <p>Basically I want to know how to set center alignment for a cell using VBScript...</p>
<p>I've been googling it and can't seem to find anything that helps.</p>
| [
{
"answer_id": 142170,
"author": "mistrmark",
"author_id": 19242,
"author_profile": "https://Stackoverflow.com/users/19242",
"pm_score": 1,
"selected": false,
"text": "<p>There are many ways to select a cell or a range of cells, but the following will work for a single cell.</p>\n\n<pre>... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Basically I want to know how to set center alignment for a cell using VBScript...
I've been googling it and can't seem to find anything that helps. | ```
Set excel = CreateObject("Excel.Application")
excel.Workbooks.Add() ' create blank workbook
Set workbook = excel.Workbooks(1)
' set A1 to be centered.
workbook.Sheets(1).Cells(1,1).HorizontalAlignment = -4108 ' xlCenter constant.
workbook.SaveAs("C:\NewFile.xls")
excel.Quit()
set excel = nothing
'If the scri... |
142,121 | <p>I have a class that processes a 2 xml files and produces a text file. </p>
<p>I would like to write a bunch of unit / integration tests that can individually pass or fail for this class that do the following:</p>
<ol>
<li>For input A and B, generate the output.</li>
<li>Compare the contents of the generated file ... | [
{
"answer_id": 142169,
"author": "Ray Hayes",
"author_id": 7093,
"author_profile": "https://Stackoverflow.com/users/7093",
"pm_score": 0,
"selected": false,
"text": "<p>Rather than call .AreEqual you could parse the two input streams yourself, keep a count of line and column and compare ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | I have a class that processes a 2 xml files and produces a text file.
I would like to write a bunch of unit / integration tests that can individually pass or fail for this class that do the following:
1. For input A and B, generate the output.
2. Compare the contents of the generated file to the contents expected ou... | As for the multiple tests with different data, use the NUnit RowTest extension:
```
using NUnit.Framework.Extensions;
[RowTest]
[Row("x1.xml", "x2.xml", "x-expected.xml")]
[Row("y1.xml", "y2.xml", "y-expected.xml")]
public void TestGenerate(string pathToInputA, string pathToInputB, string pathToExpectedResult)
{
... |
142,142 | <p>Is there a query in SQL Server 2005 I can use to get the server's IP or name?</p>
| [
{
"answer_id": 142144,
"author": "Pseudo Masochist",
"author_id": 8529,
"author_profile": "https://Stackoverflow.com/users/8529",
"pm_score": 3,
"selected": false,
"text": "<pre><code>select @@servername\n</code></pre>\n"
},
{
"answer_id": 142146,
"author": "Michał Piaskowski... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] | Is there a query in SQL Server 2005 I can use to get the server's IP or name? | ```
SELECT
CONNECTIONPROPERTY('net_transport') AS net_transport,
CONNECTIONPROPERTY('protocol_type') AS protocol_type,
CONNECTIONPROPERTY('auth_scheme') AS auth_scheme,
CONNECTIONPROPERTY('local_net_address') AS local_net_address,
CONNECTIONPROPERTY('local_tcp_port') AS local_tcp_port,
CONNECTIONPRO... |
142,147 | <p>I'm an experienced programmer but just starting out with Flash/Actionscript. I'm working on a project that for certain reasons requires me to use Actionscript 2 rather than 3.</p>
<p>When I run the following (I just put it in frame one of a new flash project), the output is a 3 rather than a 1 ? I need it to be a 1... | [
{
"answer_id": 142224,
"author": "gltovar",
"author_id": 2855,
"author_profile": "https://Stackoverflow.com/users/2855",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately Actionscript 2.0 does not have a strong scope... especially on the time line.</p>\n\n<pre><code>var fs:Arra... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm an experienced programmer but just starting out with Flash/Actionscript. I'm working on a project that for certain reasons requires me to use Actionscript 2 rather than 3.
When I run the following (I just put it in frame one of a new flash project), the output is a 3 rather than a 1 ? I need it to be a 1.
Why doe... | Unfortunately, AS2 is not that kind of language; it doesn't have that kind of closure. Functions aren't exactly first-class citizens in AS2, and one of the results of that is that a function doesn't retain its own scope, it has to be associated with some scope when it's called (usually the same scope where the function... |
142,240 | <p>Out of order execution in CPUs means that a CPU can reorder instructions to gain better performance and it means the CPU is having to do some very nifty bookkeeping and such. There are other processor approaches too, such as hyper-threading.</p>
<p>Some fancy compilers understand the (un)interrelatedness of instru... | [
{
"answer_id": 142277,
"author": "Adrian Mouat",
"author_id": 4332,
"author_profile": "https://Stackoverflow.com/users/4332",
"pm_score": 2,
"selected": false,
"text": "<p>Your best plan may be to look into <a href=\"http://openmp.org\" rel=\"nofollow noreferrer\">OpenMP</a>. It basicall... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15721/"
] | Out of order execution in CPUs means that a CPU can reorder instructions to gain better performance and it means the CPU is having to do some very nifty bookkeeping and such. There are other processor approaches too, such as hyper-threading.
Some fancy compilers understand the (un)interrelatedness of instructions to a... | It sounds like you ran into the same problem chip designers face: Executing a single instruction takes a lot of effort, but it involves a bunch of different steps that can be strung together in an [execution pipeline](http://en.wikipedia.org/wiki/Pipeline_(computing)). (It is easier to execute things in parallel when y... |
142,252 | <p>This code works (C# 3)</p>
<pre><code>double d;
if(d == (double)(int)d) ...;
</code></pre>
<ol>
<li>Is there a better way to do this?</li>
<li>For extraneous reasons I want to avoid the double cast so; what nice ways exist other than this? (even if they aren't as good)</li>
</ol>
<p><em>Note:</em> Several people ... | [
{
"answer_id": 142262,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>You don't need the extra (double) in there. This works:</p>\n\n<pre><code>if (d == (int)d) {\n //...\n}\n</code></pre>\n"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | This code works (C# 3)
```
double d;
if(d == (double)(int)d) ...;
```
1. Is there a better way to do this?
2. For extraneous reasons I want to avoid the double cast so; what nice ways exist other than this? (even if they aren't as good)
*Note:* Several people pointed out the (important) point that == is often probl... | ```
d == Math.Floor(d)
```
does the same thing in other words.
NB: Hopefully you're aware that you have to be very careful when doing this kind of thing; floats/doubles will very easily accumulate miniscule errors that make exact comparisons (like this one) fail for no obvious reason. |
142,317 | <p>I have the following code that shows either a bug or a misunderstanding on my part.</p>
<p>I sent the same list, but modified over an ObjectOutputStream. Once as [0] and other as [1]. But when I read it, I get [0] twice. I think this is caused by the fact that I am sending over the same object and ObjectOutputSt... | [
{
"answer_id": 142367,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 6,
"selected": true,
"text": "<p>The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you w... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] | I have the following code that shows either a bug or a misunderstanding on my part.
I sent the same list, but modified over an ObjectOutputStream. Once as [0] and other as [1]. But when I read it, I get [0] twice. I think this is caused by the fact that I am sending over the same object and ObjectOutputStream must be ... | The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you will only get one. And sending the same object twice separately will give you the same instance twice (each with the same data - which is what you're seeing).
See the reset() method if you want to reset t... |
142,319 | <p>This is a new gmail labs feature that lets you specify an RSS feed to grab random quotes from to append to your email signature. I'd like to use that to generate signatures programmatically based on parameters I pass in, the current time, etc. (For example, I have a script in pine that appends the current probabil... | [
{
"answer_id": 142367,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 6,
"selected": true,
"text": "<p>The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you w... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | This is a new gmail labs feature that lets you specify an RSS feed to grab random quotes from to append to your email signature. I'd like to use that to generate signatures programmatically based on parameters I pass in, the current time, etc. (For example, I have a script in pine that appends the current probabilities... | The stream has a reference graph, so an object which is sent twice will not give two objects on the other end, you will only get one. And sending the same object twice separately will give you the same instance twice (each with the same data - which is what you're seeing).
See the reset() method if you want to reset t... |
142,320 | <p>I'm setting up our new Dev server, what is the easiest way to assign multiple IP addresses to Windows 2008 Server Network Adapter?</p>
<p>I'm setting up our development machine, running IIS 7 and want to have the range between 192.168.1.200 - .254 available when I'm setting up a new website in IIS 7.</p>
| [
{
"answer_id": 142347,
"author": "David",
"author_id": 3351,
"author_profile": "https://Stackoverflow.com/users/3351",
"pm_score": 0,
"selected": false,
"text": "<p>Network Connections -> Local Area Network Connection Properties -> TCP/IP Properties -> Advanced -> IP Settings -> Add Butt... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] | I'm setting up our new Dev server, what is the easiest way to assign multiple IP addresses to Windows 2008 Server Network Adapter?
I'm setting up our development machine, running IIS 7 and want to have the range between 192.168.1.200 - .254 available when I'm setting up a new website in IIS 7. | The complete CMD.EXE loop:
```
FOR /L %b IN (200,1,254) DO netsh interface ip add address "your_adapter" 192.168.1.%b 255.255.255.0
```
In the code above, replace "your\_adapter" with the actual interface name (usually "Local Area Connection"). In addition, the netmask at the end is an assumption of /24 or Class C s... |
142,356 | <p>What is the most efficient way to get the default constructor (i.e. instance constructor with no parameters) of a System.Type?</p>
<p>I was thinking something along the lines of the code below but it seems like there should be a simplier more efficient way to do it.</p>
<pre><code>Type type = typeof(FooBar)
Bindin... | [
{
"answer_id": 142362,
"author": "Curt Hagenlocher",
"author_id": 533,
"author_profile": "https://Stackoverflow.com/users/533",
"pm_score": 8,
"selected": true,
"text": "<pre><code>type.GetConstructor(Type.EmptyTypes)\n</code></pre>\n"
},
{
"answer_id": 142442,
"author": "Ale... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12784/"
] | What is the most efficient way to get the default constructor (i.e. instance constructor with no parameters) of a System.Type?
I was thinking something along the lines of the code below but it seems like there should be a simplier more efficient way to do it.
```
Type type = typeof(FooBar)
BindingFlags flags = Bindin... | ```
type.GetConstructor(Type.EmptyTypes)
``` |
142,357 | <p>What are the best JVM settings you have found for running Eclipse?</p>
| [
{
"answer_id": 142384,
"author": "Dave L.",
"author_id": 3093,
"author_profile": "https://Stackoverflow.com/users/3093",
"pm_score": 0,
"selected": false,
"text": "<p>Here's what I use (though I have them in the shortcut instead of the settings file):</p>\n\n<p>eclipse.exe -showlocation ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15352/"
] | What are the best JVM settings you have found for running Eclipse? | It is that time of year again: "eclipse.ini take 3" the settings strike back!
Eclipse Helios 3.6 and 3.6.x settings
=====================================
[alt text http://www.eclipse.org/home/promotions/friends-helios/helios.png](http://www.eclipse.org/home/promotions/friends-helios/helios.png)
After settings for [... |
142,391 | <p>I am making extensive use of <code>boost:shared_ptr</code> in my code. In fact, most of the objects that are allocated on the heap are held by a <code>shared_ptr</code>. Unfortunately this means that I can't pass <code>this</code> into any function that takes a <code>shared_ptr</code>. Consider this code:</p>
<pre>... | [
{
"answer_id": 142397,
"author": "David Pierre",
"author_id": 18296,
"author_profile": "https://Stackoverflow.com/users/18296",
"pm_score": 4,
"selected": false,
"text": "<p>boost has a solution for this use case, check <a href=\"http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/enable... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1031/"
] | I am making extensive use of `boost:shared_ptr` in my code. In fact, most of the objects that are allocated on the heap are held by a `shared_ptr`. Unfortunately this means that I can't pass `this` into any function that takes a `shared_ptr`. Consider this code:
```
void bar(boost::shared_ptr<Foo> pFoo)
{
...
}
v... | You can derive from [enable\_shared\_from\_this](http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/enable_shared_from_this.html) and then you can use "shared\_from\_this()" instead of "this" to spawn a shared pointer to your own self object.
Example in the link:
```
#include <boost/enable_shared_from_this.hpp>
cla... |
142,400 | <p>I've had a hard time finding good ways of taking a time format and easily determining if it's valid then producing a resulting element that has some formatting using XSLT 1.0.</p>
<p>Given the following xml:</p>
<pre><code><root>
<srcTime>2300</srcTime>
</root>
</code></pre>
<p>It woul... | [
{
"answer_id": 142416,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 2,
"selected": false,
"text": "<p>XSLT 1.0 does not have any standard support for date/time manipulation.</p>\n\n<p>You must write a simple parsing and form... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4916/"
] | I've had a hard time finding good ways of taking a time format and easily determining if it's valid then producing a resulting element that has some formatting using XSLT 1.0.
Given the following xml:
```
<root>
<srcTime>2300</srcTime>
</root>
```
It would be great to produce the resulting xml:
```
<root>
... | There aren't any regular expressions in XSLT 1.0, so I'm afraid that pattern matching isn't going to be possible.
I'm not clear if `<srcTime>23:00</srcTime>` is supposed to be legal or not? If it is, try:
```
<dstTime>
<xsl:if test="string-length(srcTime) = 4 or
string-length(srcTime) = 5">
<xsl... |
142,407 | <p>I am testing a Ruby Rails website and wanted to get started with Unit and Functional testing.</p>
| [
{
"answer_id": 142540,
"author": "Sam Stokes",
"author_id": 20131,
"author_profile": "https://Stackoverflow.com/users/20131",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://github.com/aslakhellesoy/cucumber/wikis\" rel=\"nofollow noreferrer\">Cucumber</a> and <a href=\"ht... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22883/"
] | I am testing a Ruby Rails website and wanted to get started with Unit and Functional testing. | [Cucumber](http://github.com/aslakhellesoy/cucumber/wikis) and [RSpec](http://rspec.info/) are worth a look. They encourage testing in a [behaviour-driven](http://behaviour-driven.org/), example-based style.
RSpec is a library for unit-level testing:
```
describe "hello_world"
it "should say hello to the world" do
... |
142,417 | <p>Recently, <a href="https://stackoverflow.com/users/5200/lee-baldwin">Lee Baldwin</a> showed how to write a <a href="https://stackoverflow.com/questions/129877/how-do-i-write-a-generic-memoize-function#141689">generic, variable argument memoize function</a>. I thought it would be better to return a simpler function ... | [
{
"answer_id": 142424,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>I guess you could go into the debug info and determine this from the source-code, but basically it's a \"no\", sorry.</p>\n"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] | Recently, [Lee Baldwin](https://stackoverflow.com/users/5200/lee-baldwin) showed how to write a [generic, variable argument memoize function](https://stackoverflow.com/questions/129877/how-do-i-write-a-generic-memoize-function#141689). I thought it would be better to return a simpler function where only one parameter i... | I guess you could go into the debug info and determine this from the source-code, but basically it's a "no", sorry. |
142,420 | <p>I have a method lets say:</p>
<pre><code>private static String drawCellValue(
int maxCellLength, String cellValue, String align) { }
</code></pre>
<p>and as you can notice, I have a parameter called align. Inside this method I'm going to have some if condition on whether the value is a 'left' or 'right'.. sett... | [
{
"answer_id": 142428,
"author": "Carra",
"author_id": 21679,
"author_profile": "https://Stackoverflow.com/users/21679",
"pm_score": 7,
"selected": true,
"text": "<p>This should do it:</p>\n\n<pre><code>private enum Alignment { LEFT, RIGHT }; \nString drawCellValue (int maxCellLength,... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6618/"
] | I have a method lets say:
```
private static String drawCellValue(
int maxCellLength, String cellValue, String align) { }
```
and as you can notice, I have a parameter called align. Inside this method I'm going to have some if condition on whether the value is a 'left' or 'right'.. setting the parameter as Strin... | This should do it:
```
private enum Alignment { LEFT, RIGHT };
String drawCellValue (int maxCellLength, String cellValue, Alignment align){
if (align == Alignment.LEFT)
{
//Process it...
}
}
``` |
142,431 | <p>I'm setting up a server to offer JIRA and SVN. I figure, I'll use LDAP to keep the identity management simple. </p>
<p>So, before I write one.... is there a good app out there to let users change their ldap password? I want something that lets a user authenticate with ldap and update their password. A form wit... | [
{
"answer_id": 142428,
"author": "Carra",
"author_id": 21679,
"author_profile": "https://Stackoverflow.com/users/21679",
"pm_score": 7,
"selected": true,
"text": "<p>This should do it:</p>\n\n<pre><code>private enum Alignment { LEFT, RIGHT }; \nString drawCellValue (int maxCellLength,... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9950/"
] | I'm setting up a server to offer JIRA and SVN. I figure, I'll use LDAP to keep the identity management simple.
So, before I write one.... is there a good app out there to let users change their ldap password? I want something that lets a user authenticate with ldap and update their password. A form with username, old... | This should do it:
```
private enum Alignment { LEFT, RIGHT };
String drawCellValue (int maxCellLength, String cellValue, Alignment align){
if (align == Alignment.LEFT)
{
//Process it...
}
}
``` |
142,452 | <p>There are many scenarios where it would be useful to call a Win32 function or some other DLL from a PowerShell script. to Given the following function signature:</p>
<pre><code>bool MyFunction( char* buffer, int* bufferSize )
</code></pre>
<p>I hear there is something that makes this easier in PowerShell CTP 2, bu... | [
{
"answer_id": 142510,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 1,
"selected": false,
"text": "<p>There isn't any mechanism in PowerShell 1.0 to directly call Win32 API's. You could of course write a C# or VB.NET helper class... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4916/"
] | There are many scenarios where it would be useful to call a Win32 function or some other DLL from a PowerShell script. to Given the following function signature:
```
bool MyFunction( char* buffer, int* bufferSize )
```
I hear there is something that makes this easier in PowerShell CTP 2, but I'm curious how this is ... | To call unmanaged code from Powershell, use the Invoke-Win32 function created by Lee Holmes. You can find the source [here](http://www.leeholmes.com/blog/GetTheOwnerOfAProcessInPowerShellPInvokeAndRefOutParameters.aspx). There you can see an example of how to call a function that has pointers, but a more trivial usage ... |
142,508 | <p>I need my code to do different things based on the operating system on which it gets compiled. I'm looking for something like this:</p>
<pre><code>#ifdef OSisWindows
// do Windows-specific stuff
#else
// do Unix-specific stuff
#endif
</code></pre>
<p>Is there a way to do this? Is there a better way to do the same ... | [
{
"answer_id": 142522,
"author": "davenpcj",
"author_id": 4777,
"author_profile": "https://Stackoverflow.com/users/4777",
"pm_score": 0,
"selected": false,
"text": "<p>Some compilers will generate #defines that can help you with this. Read the compiler documentation to determine what the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10601/"
] | I need my code to do different things based on the operating system on which it gets compiled. I'm looking for something like this:
```
#ifdef OSisWindows
// do Windows-specific stuff
#else
// do Unix-specific stuff
#endif
```
Is there a way to do this? Is there a better way to do the same thing? | The **[Predefined Macros for OS](https://sourceforge.net/p/predef/wiki/OperatingSystems/)** site has a very complete list of checks. Here are a few of them, with links to where they're found:
[Windows](http://msdn.microsoft.com/en-us/library/b0084kay(VS.80).aspx)
-------------------------------------------------------... |
142,527 | <p>Is it possible to highlight text inside of a textarea using javascript? Either changing the background of just a portion of the text area or making a portion of the text <em>selected</em>?</p>
| [
{
"answer_id": 7599199,
"author": "Julien L",
"author_id": 690236,
"author_profile": "https://Stackoverflow.com/users/690236",
"pm_score": 4,
"selected": false,
"text": "<p>Try this piece of code I wrote this morning, it will highlight a defined set of words:</p>\n\n<pre><code><html&g... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/80/"
] | Is it possible to highlight text inside of a textarea using javascript? Either changing the background of just a portion of the text area or making a portion of the text *selected*? | Try this piece of code I wrote this morning, it will highlight a defined set of words:
```
<html>
<head>
<title></title>
<!-- Load jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<!-- The javascript xontaining t... |
142,545 | <p>The <code>__debug__</code> variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?</p>
<p>The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is upd... | [
{
"answer_id": 142561,
"author": "awatts",
"author_id": 22847,
"author_profile": "https://Stackoverflow.com/users/22847",
"pm_score": 1,
"selected": false,
"text": "<p>This sounds like modifying the <code>__builtin__</code> name space. To do it:</p>\n\n<pre><code>import __builtin__\n__b... | 2008/09/26 | [
"https://Stackoverflow.com/questions/142545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22897/"
] | The `__debug__` variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it?
The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd b... | I don't endorse this solution in any way, shape or form. But if you add a variable to the `__builtin__` module, it will be accessible as if a global from any other module that includes `__builtin__` -- which is all of them, by default.
a.py contains
```
print foo
```
b.py contains
```
import __builtin__
__builtin_... |
142,633 | <p>I have a Button inside an UpdatePanel. The button is being used as the OK button for a ModalPopupExtender. For some reason, the button click event is not firing. Any ideas? Am I missing something?</p>
<pre><code><asp:updatepanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1... | [
{
"answer_id": 142656,
"author": "Kyle Trauberman",
"author_id": 21461,
"author_profile": "https://Stackoverflow.com/users/21461",
"pm_score": 3,
"selected": false,
"text": "<p>It appears that a button that is used as the OK or CANCEL button for a ModalPopupExtender cannot have a click e... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21461/"
] | I have a Button inside an UpdatePanel. The button is being used as the OK button for a ModalPopupExtender. For some reason, the button click event is not firing. Any ideas? Am I missing something?
```
<asp:updatepanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:ModalPopupExtender ID="ModalDial... | Aspx
```
<ajax:ModalPopupExtender runat="server" ID="modalPop"
PopupControlID="pnlpopup"
TargetControlID="btnGo"
BackgroundCssClass="modalBackground"
DropShadow="true"
CancelControlID="btnCancel" X="470" Y="300" />
//Codebehind
protected void OkB... |
142,708 | <p>I can't seem to find any <em>useful</em> documentation from Microsoft about how one would use the <code>Delimiter</code> and <code>InheritsFromParent</code> attributes in the <code>UserMacro</code> element when defining user Macros in <code>.vsprops</code> property sheet files for Visual Studio.</p>
<p>Here's sampl... | [
{
"answer_id": 144032,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 0,
"selected": false,
"text": "<p>There's documentation on the UI version of this <a href=\"http://msdn.microsoft.com/en-us/library/a2zdt10t.aspx\" rel=\"n... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10559/"
] | I can't seem to find any *useful* documentation from Microsoft about how one would use the `Delimiter` and `InheritsFromParent` attributes in the `UserMacro` element when defining user Macros in `.vsprops` property sheet files for Visual Studio.
Here's sample usage:
```
<UserMacro Name="INCLUDEPATH" Value="$(VCROOT)\... | *[Answering my own question]*
`InheritsFromParent` means prepend. To verify this, I did an experiment that reveals how User Macros work in Visual Studio 2008. Here's the setup:
* Project `p.vcproj` includes the property sheet file `d.vsprops` ('d' for *derived*) using the `InheritedPropertySheets` tag.
* `d.vsprops` ... |
142,740 | <p>I want to do something like the following in spring:</p>
<pre><code><beans>
...
<bean id="bean1" ... />
<bean id="bean2">
<property name="propName" value="bean1.foo" />
...
</code></pre>
<p>I would think that this would access the getFoo() method of bean1 and call the se... | [
{
"answer_id": 142765,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": -1,
"selected": false,
"text": "<p>I think you have to inject bean1, then get <code>foo</code> manually because of a timing issue. When does the framework ... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22063/"
] | I want to do something like the following in spring:
```
<beans>
...
<bean id="bean1" ... />
<bean id="bean2">
<property name="propName" value="bean1.foo" />
...
```
I would think that this would access the getFoo() method of bean1 and call the setPropName() method of bean2, but this doesn't seem... | What I understood:
1. You have a bean (bean1) with a
property called "foo"
2. You have another bean (bean2) with a
property named "propName", wich also
has to have the same "foo" that in
bean1.
why not doing this:
```
<beans>
...
<bean id="foo" class="foopackage.foo"/>
<bean id="bean1" class="foopackage.bean1">
<p... |
142,750 | <p>I'm trying to get either CreateProcess or CreateProcessW to execute a process with a name < MAX_PATH characters but in a path that's greater than MAX_PATH characters. According to the docs at: <a href="http://msdn.microsoft.com/en-us/library/ms682425.aspx" rel="nofollow noreferrer"><a href="http://msdn.m... | [
{
"answer_id": 143399,
"author": "Zooba",
"author_id": 891,
"author_profile": "https://Stackoverflow.com/users/891",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see any reference in the CreateProcess documentation saying that the '\\\\?\\' syntax is valid for the module name. T... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9572/"
] | I'm trying to get either CreateProcess or CreateProcessW to execute a process with a name < MAX\_PATH characters but in a path that's greater than MAX\_PATH characters. According to the docs at: [<http://msdn.microsoft.com/en-us/library/ms682425.aspx>](http://msdn.microsoft.com/en-us/library/ms682425.aspx), I need to m... | Embedding the manifest and using GetShortPathNameW did it for me. One or the other on their own wasn't enough.
Before calling CreateProcessW using the \\?-prefixed absolute path name of the process to execute as the first argument, I check:
```
wchar_t *w_argv0;
wchar_t *w_short_argv0;
...
if (wcslen(w_argv0) >= M... |
142,772 | <p>What is the difference between the Project and SVN workingDirectory Config Blocks in CruiseControl.NET?</p>
<p>I setup Subversion and now I'm working on CruiseControl.NET and noticed there are two workingDirectory blocks in the config files. I've looked through their google groups and documentation and maybe I miss... | [
{
"answer_id": 142795,
"author": "JoshL",
"author_id": 20625,
"author_profile": "https://Stackoverflow.com/users/20625",
"pm_score": 1,
"selected": false,
"text": "<p>See <a href=\"http://confluence.public.thoughtworks.org/display/CCNET/Project+Configuration+Block\" rel=\"nofollow norefe... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] | What is the difference between the Project and SVN workingDirectory Config Blocks in CruiseControl.NET?
I setup Subversion and now I'm working on CruiseControl.NET and noticed there are two workingDirectory blocks in the config files. I've looked through their google groups and documentation and maybe I missed somethi... | I think the project working directory is used as the root folder for all commands in the CruiseControl block. So if I have a Nant task/script with relative folders, it will be appended to this root folder for actual execution.
>
> The Working Directory for the project
> (this is used by other blocks).
> Relative p... |
142,789 | <p>From the reading that I have done, Core Audio relies heavily on callbacks (and C++, but that's another story). </p>
<p>I understand the concept (sort of) of setting up a function that is called by another function repeatedly to accomplish a task. I just don't understand how they get set up and how they actually w... | [
{
"answer_id": 142792,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 2,
"selected": false,
"text": "<p>Callbacks in C are usually implemented using function pointers and an associated data pointer. You pass your functi... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22913/"
] | From the reading that I have done, Core Audio relies heavily on callbacks (and C++, but that's another story).
I understand the concept (sort of) of setting up a function that is called by another function repeatedly to accomplish a task. I just don't understand how they get set up and how they actually work. Any exa... | There is no "callback" in C - not more than any other generic programming concept.
They're implemented using function pointers. Here's an example:
```
void populate_array(int *array, size_t arraySize, int (*getNextValue)(void))
{
for (size_t i=0; i<arraySize; i++)
array[i] = getNextValue();
}
int getNext... |
142,813 | <p>I want to convert a number between 0 and 4096 ( 12-bits ) to its 3 character hexadecimal string representation in C#. </p>
<p>Example:</p>
<pre>
2748 to "ABC"
</pre>
| [
{
"answer_id": 142819,
"author": "Muxa",
"author_id": 10793,
"author_profile": "https://Stackoverflow.com/users/10793",
"pm_score": 3,
"selected": true,
"text": "<p>try</p>\n\n<pre><code>2748.ToString(\"X\")\n</code></pre>\n"
},
{
"answer_id": 142822,
"author": "TraumaPony",
... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609/"
] | I want to convert a number between 0 and 4096 ( 12-bits ) to its 3 character hexadecimal string representation in C#.
Example:
```
2748 to "ABC"
``` | try
```
2748.ToString("X")
``` |
142,820 | <p>I've create a WinForms control that inherits from System.Windows.Forms.UserControl...I've got some custom events on the control that I would like the consumer of my control to be able to see. I'm unable to actually get my events to show up in the Events tab of the Properties window during design time. This means the... | [
{
"answer_id": 142823,
"author": "Phil Wright",
"author_id": 6276,
"author_profile": "https://Stackoverflow.com/users/6276",
"pm_score": 6,
"selected": true,
"text": "<p>Make sure your events are exposed as public. For example...</p>\n\n<pre><code>[Browsable(true)]\npublic event EventHan... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4403/"
] | I've create a WinForms control that inherits from System.Windows.Forms.UserControl...I've got some custom events on the control that I would like the consumer of my control to be able to see. I'm unable to actually get my events to show up in the Events tab of the Properties window during design time. This means the on... | Make sure your events are exposed as public. For example...
```
[Browsable(true)]
public event EventHandler MyCustomEvent;
``` |
142,826 | <p>I've been working on a web crawling .NET app in my free time, and one of the features of this app that I wanted to included was a pause button to pause a specific thread.</p>
<p>I'm relatively new to multi-threading and I haven't been able to figure out a way to pause a thread indefinitely that is currently support... | [
{
"answer_id": 142833,
"author": "Shabbyrobe",
"author_id": 15004,
"author_profile": "https://Stackoverflow.com/users/15004",
"pm_score": 4,
"selected": false,
"text": "<p>The <a href=\"http://www.albahari.com/threading/part4.aspx#_Suspending_and_Resuming\" rel=\"noreferrer\">Threading i... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I've been working on a web crawling .NET app in my free time, and one of the features of this app that I wanted to included was a pause button to pause a specific thread.
I'm relatively new to multi-threading and I haven't been able to figure out a way to pause a thread indefinitely that is currently supported. I can'... | Never, ever use `Thread.Suspend`. The major problem with it is that 99% of the time you can't know what that thread is doing when you suspend it. If that thread holds a lock, you make it easier to get into a deadlock situation, etc. Keep in mind that code you are calling may be acquiring/releasing locks behind the scen... |
142,844 | <p>I would like to drag and drop my data file onto a Python script and have it process the file and generate output. The Python script accepts the name of the data file as a command-line parameter, but Windows Explorer doesn't allow the script to be a drop target.</p>
<p>Is there some kind of configuration that needs ... | [
{
"answer_id": 142854,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 7,
"selected": true,
"text": "<p>Sure. From a <a href=\"http://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/\"... | 2008/09/27 | [
"https://Stackoverflow.com/questions/142844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4859/"
] | I would like to drag and drop my data file onto a Python script and have it process the file and generate output. The Python script accepts the name of the data file as a command-line parameter, but Windows Explorer doesn't allow the script to be a drop target.
Is there some kind of configuration that needs to be done... | Sure. From a [mindless technology article called "Make Python Scripts Droppable in Windows"](http://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/), you can add a drop handler by adding a registry key:
>
> Here’s a registry import file that you can use to do this. Copy the
> fo... |