qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
117,312 | <p>I work with a bunch of sets in order to generate constrained random traffic, but I want to be able to call a Specman macro that computes the complement of a set with syntax like:</p>
<pre><code>COMPLEMENT begin
domain=[0..10,24..30],
complementing_set=[2..3,27..30]
end
</code></pre>
<p>and have it generate:</p>
<pre><code>[0..1,4..10,24..26]
</code></pre>
<p>Every time I need the complement of a set I'm using fully populated lists (e.g. {0;1;2;3....} ) and then removing elements, instead of using Specman's built-in int_range_list object. And I'm also doing a lot of these set calculations at run-time instead of compile-time.</p>
| [
{
"answer_id": 146590,
"author": "Nathan Fellman",
"author_id": 1084,
"author_profile": "https://Stackoverflow.com/users/1084",
"pm_score": 2,
"selected": false,
"text": "var domain: list of int = {0..10, 24..30}; \nvar complementing_set: list of int = {2..3, 27..30};\nvar complement: li... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20712/"
] |
117,337 | <p>Let's assume that some developer in my team shelved his changes that he did in branch A. And I am working on branch B. Can I unshelve his changes into branch B? (By GUI or command prompt) </p>
| [
{
"answer_id": 117376,
"author": "Curt Hagenlocher",
"author_id": 533,
"author_profile": "https://Stackoverflow.com/users/533",
"pm_score": 8,
"selected": true,
"text": "C:\\src\\2\\Merlin\\Main>tfpt unshelve /?\ntfpt unshelve - Unshelve into workspace with pending changes\n\nAllows a sh... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11374/"
] |
117,346 | <p>I'm working on a C++ application that needs detailed timing information, down to the millisecond level. </p>
<p>We intend to gather the time to second accuracy using the standard <code>time()</code> function in <code><ctime></code>. We would like to additionally gather the milliseconds elapsed since the last second given by <code>time()</code>. </p>
<p>Does anyone know a convenient method for obtaining this information? </p>
| [
{
"answer_id": 117381,
"author": "jdmichal",
"author_id": 12275,
"author_profile": "https://Stackoverflow.com/users/12275",
"pm_score": 0,
"selected": false,
"text": "(c)time.h"
},
{
"answer_id": 117432,
"author": "Justin Rudd",
"author_id": 12968,
"author_profile": "... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20716/"
] |
117,348 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/506368/how-do-i-serialize-an-enum-value-as-an-int">How do I serialize an enum value as an int?</a> </p>
</blockquote>
<p>Hi, all!</p>
<p>I'm wondering if there's a way to force the serialization of an enum value into its integer value, instead of its string representation.</p>
<p>To put you into context:
We're using, in a web application that heavily relies on web services, a single baseclass for all our request headers, independantly of the type of request. </p>
<p>I want to add a Result field to the header, so we'll have a place to pass hints back to the calling app as to how the operation went on the web service side. We already have an enum declared to that effect, but since we have legacy apps that call on those web services that may not know about those enums, I'd like to send serialize those values as integers.</p>
<p>We've already had to cut down on the length of those headers by using the [XmlElement(ElementName = "string representationOfAttributeName")] because we occasionally exceeded IE maximum url length, and I wondered whether there's a similar Attributes to force the serialization of enum values into integers.</p>
<p>Anyone ever heard of such an attribute?</p>
<p>As ever, thanks for the help,
Pascal</p>
| [
{
"answer_id": 117374,
"author": "Matt Howells",
"author_id": 16881,
"author_profile": "https://Stackoverflow.com/users/16881",
"pm_score": 4,
"selected": true,
"text": "[XmlIgnore]\npublic MyThing MyThing { get; set; }\n\n[XmlElement(\"MyThing\")]\n[EditorBrowsable(EditorBrowsableState.... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3403/"
] |
117,352 | <p>I have this C-code to do multiplications over GF(8):</p>
<pre><code>int32_t GaloisMultiply (int32_t a, int32_t b)
{
int32_t i;
int32_t mask = 0x100;
int32_t y = 0;
for(i=0;i<8;i++)
{
if(b & mask)
{
y ^= a;
}
mask >>= 1;
y <<= 1;
}
if(b & 0x1)
{
y ^= a;
}
return(y);
}
</code></pre>
<p>That's more or less the text-book implementation.</p>
<p>I wonder if I there is a clever optimization for above algorithm if I can assert that a is always b, e.g. I do squaring instead of multiplication. I'm not after a cryptographic use btw. I just want to make use of the fact that x*x in GF(8) interleaves the bits of x with zero bits one by one.</p>
<p>There are already quite clever methods to do the bit interleaving, but since I've found out that x*x in GF(8) does the bit interleaving thing (by accident) I can't stop trying to use it for bit-interleaving optimizations.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 117473,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "int32_t GaloisMultiply( int32_t a ) \n{\n int32_t y = 0;\n int32_t b = a & 0x01ff;\n\n while ( b ) \n {\n if ( b & 1 ) ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15955/"
] |
117,355 | <p>I'm trying to find the most reusable, yet elegant, piece of code possible for determining if an IEnumerable. In the ideal, this should be a function I can call absolutely any time I need to tell if an IEnumerable is empty.</p>
<p>While I have developed an answer for .NET 3.5 that has worked well for me so far, my current thought is that there is no perfect answer, since an IEnumerable can technically encapsulate a collection (or queue of iterators) that modifies the underlying results as it iterates, which would cause problems. However, this would also be an impediment to implementing IEnumerable.Count(), and that didn't stop MS from providing it.</p>
<p>So I thought I'd put it to SO to see if someone has a better one, and in case someone else should find it useful.</p>
<p><strong>Edit:</strong> Wow, I can't believe I didn't know about IEnumerable.Any. I knew it existed, but never bothered to check what it did. Let this be a lesson. Read the documentation. Just because a method name doesn't imply it does what you want, doesn't mean it doesn't do what you want.</p>
| [
{
"answer_id": 117367,
"author": "Guvante",
"author_id": 16800,
"author_profile": "https://Stackoverflow.com/users/16800",
"pm_score": 6,
"selected": true,
"text": "!enumerable.Any()\n"
},
{
"answer_id": 117480,
"author": "Matt",
"author_id": 2338,
"author_profile": "... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2729/"
] |
117,356 | <p>I've currently got multiple select's on a page that are added dynamically with <code>ajax</code> calls using jquery.</p>
<p>The problem I've had is I could not get the change event to work on the added select unless I use the <code>onchange</code> inside the tag e.g. </p>
<pre><code><select id="Size" size="1" onchange="onChange(this);">
</code></pre>
<p>This works, but I'm wondering if there's a way to get it to be assigned by jquery. I've tried using <code>$('select').change(onChange($(this));</code> in the usual place of <code>$(document).ready</code> but that didn't work.</p>
<p>I've tried adding the event with bind after the ajax call but that did not work either.</p>
<p>Any better way to assign the event?</p>
| [
{
"answer_id": 117392,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": false,
"text": "$('select').change(onChange);\n"
},
{
"answer_id": 117404,
"author": "Gilean",
"author_id": 6305,
"author_pr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
117,361 | <p>I am trying to bind an event to a "method" of a particular instance of a Javascript "class" using jQuery. The requirement is that I in the event handler should be able to use the "this" keyword to refer to the instance I originally bound the event to.</p>
<p>In more detail, say I have a "class" as follows:</p>
<pre><code>function Car(owner) {
this.owner = owner;
}
Car.prototype = {
drive: function() {
alert("Driving "+this.owner+"s car!");
}
}
</code></pre>
<p>And an instance:</p>
<pre><code>var myCar = new Car("Bob");
</code></pre>
<p>I now want to bind an event to the drive "method" of my car so that when ever I click a button for example the drive "method" is called on the myCar instance of the Car "class".</p>
<p>Up until now I've been using the following function to create a closure that allows me to comfortably access instance members using the "this" keyword in my "methods".</p>
<pre><code>function createHandler( obj, method ) {
return function( event ) {
return obj[method](event||window.event);
}
}
</code></pre>
<p>I've used it as follows:</p>
<pre><code>document.getElementById("myButton")
.addEventListener("click", createHandler(myCar,"drive"));
</code></pre>
<p>How do I accomplish something like this with JQuery? </p>
<p>I'm specifically asking about associating "this" with a designated instance, the other cruft all around I can handle on my own.</p>
| [
{
"answer_id": 117456,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": true,
"text": "$(\"#myButton\").click(function() { myCar.drive(); });\n"
},
{
"answer_id": 33007772,
"author": "Ben Bozorg",
"au... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2105/"
] |
117,372 | <p>I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:</p>
<pre><code>$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition: attachment; filename=\"$basename\"");
header('Content-Length: '. filesize($filename));
if ( @readfile($filename)===false ) {
header("HTTP/1.0 500 Internal Server Error");
loadErrorPage('500');
}
</code></pre>
<p>Downloads works as charm in any Browser except IE, I have seen problems related to 'no-cache' headers but I don't send anything like that, they talk about utf-8 characters, but there is not any <code>utf-8 characters</code>(and the $filename has not any utf-8 characteres neither).</p>
| [
{
"answer_id": 117428,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 3,
"selected": true,
"text": "session_start();"
},
{
"answer_id": 117613,
"author": "levhita",
"author_id": 7946,
"author_profile"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7946/"
] |
117,378 | <p><strong>The situation</strong><br>
I have a Git repo and an SVN repo that both hold the same source code but different commit histories. The Git repo has a lot of small well commented submits... while the SVN repo has a few huge commits with comments like "Lots of stuff".
Both series of commits follow the same changes made in the code and are roughly equivalent.</p>
<p><strong>The desired outcome</strong><br>
I would like to switch to using Git-SVN <em>without</em> losing the detailed history from the current Git repo. This should be done by 'grafting' the history from the Git repo onto an SVN branch of the project (branched from the point I really started using Git).</p>
<p><strong>Why would you do that? (history)</strong><br>
A while ago I started to play with Git. I started by setting up a Git repo in a project I had under SVN control. With a little config, I had both Git and SVN working in parallel on the same source code.</p>
<p>This was a great way for me to learn and play with Git, while still having the safety net of SVN. It was a sandbox with real data basically. I didn't have the time to really <em>learn</em> Git but I really wanted to tinker with it. This was actually a pretty good way to learn Git for me.</p>
<p>At first, after doing some edits, I would commit to SVN and then to Git... then play with Git knowing my changes were safely in SVN. Soon I was committing more frequently to Git than SVN... Now, SVN commits have fallen to an annoying chore I have to do sometimes.</p>
<p>When learning the difference between <code>git revert</code> and <code>svn revert</code> I was <em>VERY</em> glad I had been checking in to the SVN repo. I almost lost a few weeks' work assuming that the two worked the same.</p>
<p>I now know the glories of Git-SVN and I am using it happily on several other projects.
I fully realized when I started that I might lose my Git repo and have to setup a new one 'properly' using <code>git-svn init</code>... but having played with Git for a while now, I'm sure there is some way of hacking the Git history into SVN.</p>
| [
{
"answer_id": 117593,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 2,
"selected": false,
"text": "git-svn clone path/to/your/svn/repo\ngit-commit -a -m 'my small change'\nvi some files to change.txt\ngit-commit -a -m ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
117,379 | <p>I'm successfully using VBScript within WScript to remotely read and write IIS configurations from the server. When I attempt to run these same scripts from my desk box they fail, though. Example:</p>
<pre><code>Dim vdir
Set vdir = GetObject("IIS://servername/w3svc/226/root")
</code></pre>
<p>Error = "Invalid syntax"</p>
<p>The code works perfectly when run from one IIS server to another, but I'd like to run it from my XP Workstation. It would seem reasonable that there's a download of ADSI available that will make things work from my desktop, but I cannot find one. I downloaded <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9688F8B9-1034-4EF6-A3E5-2A2A57B5C8E4&displaylang=en" rel="nofollow noreferrer">ADAM</a> but that only got me a small portion of the functionality I need. </p>
<p>Any hints out there? Thank you. </p>
| [
{
"answer_id": 117593,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 2,
"selected": false,
"text": "git-svn clone path/to/your/svn/repo\ngit-commit -a -m 'my small change'\nvi some files to change.txt\ngit-commit -a -m ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14127/"
] |
117,407 | <ul>
<li>You can use App.config; but it only supports key/value pairs.</li>
<li>You can use .Net configuration, configuration sections; but it can be really complex.</li>
<li>You can use Xml Serialization/Deserialization by yourself; your classes-your way.</li>
<li>You can use some other method; what can they be? ...</li>
</ul>
<p>Which of these or other methods (if there are) do you prefer? Why?</p>
| [
{
"answer_id": 117597,
"author": "JohnIdol",
"author_id": 1311500,
"author_profile": "https://Stackoverflow.com/users/1311500",
"pm_score": 5,
"selected": true,
"text": " public class CustomSection : ConfigurationSection\n {\n [ConfigurationProperty(\"LastName\",... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11374/"
] |
117,415 | <p>The subversion concept of branching appears to be focused on creating an [un]stable fork of the entire repository on which to do development. Is there a mechanism for creating branches of individual files?</p>
<p>For a use case, think of a common header (*.h) file that has multiple platform-specific source (*.c) implementations. This type of branch is a permanent one. All of these branches would see ongoing development with occasional cross-branch merging. This is in sharp contrast to unstable development/stable release branches which generally have a finite lifespan.</p>
<p>I <strong>do not</strong> want to branch the entire repository (cheap or not) as it would create an unreasonable amount of maintenance to continuously merge between the trunk and all the branches. At present I'm using ClearCase, which has a different concept of branching that makes this easy. I've been asked to consider transitioning to SVN but this paradigm difference is important. I'm much more concerned about being able to easily create alternate versions for individual files than about things like cutting a stable release branch.</p>
| [
{
"answer_id": 117442,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 1,
"selected": false,
"text": "svn copy myfile.c myfile_branch.c\n"
},
{
"answer_id": 117500,
"author": "crashmstr",
"author_id": 1441,
"a... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8233/"
] |
117,422 | <p>My Virtual Machine's clock drifts pretty significantly. There's documentation out there about dealing with this, but nothing seems to be working very well.</p>
<p>Anyone have any suggestions, things that worked well for them, ...</p>
<p>Supposedly updating regularly via ntp is not a good solution.</p>
| [
{
"answer_id": 117466,
"author": "GHad",
"author_id": 11705,
"author_profile": "https://Stackoverflow.com/users/11705",
"pm_score": -1,
"selected": false,
"text": "net time \\\\computer_name /set\n"
},
{
"answer_id": 15264654,
"author": "user2143026",
"author_id": 2143026... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] |
117,426 | <p>I am working on a project that has grown to a decent size, and I am the only developer. We currently don't use any version control, but I definitely need to start.</p>
<p>I want to use Subversion. What would be the best way to transfer an existing project to it?</p>
<p>I have a test server that I use for developing new features, then transfer those files to the 2 production servers. Is there a tool that will automate the upload to the test, then the deployment to the live servers?</p>
<p>All this is developed in ASP.NET using Visual Studio (if that matters)</p>
| [
{
"answer_id": 117556,
"author": "Hector Sosa Jr",
"author_id": 12829,
"author_profile": "https://Stackoverflow.com/users/12829",
"pm_score": 3,
"selected": false,
"text": "svn export C:\\MyReporitosy\\Path C:\\DestinationPath\n"
},
{
"answer_id": 155053,
"author": "bill_the_... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] |
117,429 | <p>What is the best way to handle large numeric inputs in C++ (for example <code>10^100</code>)? </p>
<p>For algorithms I usually switch over to ruby and I sometimes use strings.</p>
<p>Any other good methods?</p>
| [
{
"answer_id": 250736,
"author": "Abhishek Mishra",
"author_id": 8786,
"author_profile": "https://Stackoverflow.com/users/8786",
"pm_score": 3,
"selected": false,
"text": "#include <iostream>\n\nusing namespace std;\n\nstring add (string &s1, string &s2){\n int carry=0,sum,i;\n\n s... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20730/"
] |
117,461 | <p>I want alwaysPositive to be assigned a positive number with all possible values for lareValue1 and largeValue2 (these are at least 1).</p>
<p>The following statement causes a buffer overflow:</p>
<pre><code>int alwaysPositive = (largeValue1 + largeValue2) / 2;
</code></pre>
<p>I know I can prevent it by substracting and adding:</p>
<pre><code>int alwaysPositive = largeValue1 + ((largeValue2 - largeValue1) / 2);
</code></pre>
<p>But in other programming languages I can use an unsigned bitshift to do the trick:</p>
<pre><code>int alwaysPositive3 = (largeValue1 + largeValue2) >>> 1;
</code></pre>
<p>How can I do this in C#?</p>
<hr>
<p>The answers below all solve the problem. There are probably lots of ways to do this, but they all (including my solutions) have one thing in common: they all look obfuscated. </p>
| [
{
"answer_id": 117519,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 0,
"selected": false,
"text": "uint alwaysPositive = (uint)(largeValue1 + largeValue2) / 2;\n"
},
{
"answer_id": 117542,
"author": "Nils Pipenb... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13376/"
] |
117,467 | <p>I need to find a way to crawl one of our company's web applications and create a static site from it that can be burned to a cd and used by traveling sales people to demo the web site. The back end data store is spread across many, many systems so simply running the site on a VM on the sale person's laptop won't work. And they won't have access to the internet while at some clients (no internet, cell phone....primitive, I know).</p>
<p>Does anyone have any good recommendations for crawlers that can handle things like link cleanup, flash, a little ajax, css, etc? I know odds are slim, but I figured I'd throw the question out here before I jump into writing my own tool.</p>
| [
{
"answer_id": 48452213,
"author": "AsTeR",
"author_id": 172277,
"author_profile": "https://Stackoverflow.com/users/172277",
"pm_score": 3,
"selected": false,
"text": "wget --mirror --convert-links --adjust-extension --page-requisites \\\n--no-parent http://example.org\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17623/"
] |
117,469 | <p>Could anyone recommend a good BAML Decompiler / Viewer besides BAML Viewer plugin for Reflector, which doesn't handle path geometry/data?</p>
| [
{
"answer_id": 1194143,
"author": "mark",
"author_id": 80002,
"author_profile": "https://Stackoverflow.com/users/80002",
"pm_score": 2,
"selected": false,
"text": "Ricciolo.StylesExplorer.exe"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19268/"
] |
117,471 | <p>I have a database issue that i currently cannot wrap my head around with an easy solution. In my db I have a table that stores event values.. 0's and 1's with a timestamp. Issue being that it is possible for there to be the same event to occur twice as a business rule. Like below</p>
<ul>
<li>'2008-09-22 16:28:14.133', 0</li>
<li>'2008-09-22 16:28:35.233', 1</li>
<li>'2008-09-22 16:29:16.353', 1</li>
<li>'2008-09-22 16:31:37.273', 0</li>
<li>'2008-09-22 16:35:43.134', 0</li>
<li>'2008-09-22 16:36:39.633', 1</li>
<li>'2008-09-22 16:41:40.733', 0</li>
</ul>
<p>in real life these events are cycled and I’m trying to query over to get the cycles of these but I need to ignore the duplicate values ( 1,1 ) the current solution is using a SQL cursor to loop each and throw out the value if the previous was the same. I’ve considered using a trigger on the insert to clean up in a post processed table but I can’t think of an easy solution to do this set based.</p>
<p>Any ideas or suggestions?</p>
<p>Thanks</p>
| [
{
"answer_id": 117587,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "SELECT timestamp, value\nFROM yourtable\n"
},
{
"answer_id": 117681,
"author": "Cade Roux",
"author_i... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20737/"
] |
117,474 | <p>From time to time, I need to dump USB traffic under Windows, mostly to support hardware under Linux, so my primary goal is to produce dump files for protocol analysis.</p>
<p>For USB traffic, it seems that <a href="https://web.archive.org/web/20151218000528/http://www.pcausa.com/Utilities/UsbSnoop/default.htm" rel="noreferrer">SniffUsb</a> is the clear winner... It works under Windows XP (but <em>not</em> later) and has a much nicer GUI than earlier versions. It produces <em>huge</em> dump files, but everything is there.</p>
<p>However, my device is in fact a USB serial device, so I turned to <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx" rel="noreferrer">Portmon</a> which can sniff serial port traffic without the USB overhead.</p>
| [
{
"answer_id": 57109540,
"author": "Renat",
"author_id": 1075282,
"author_profile": "https://Stackoverflow.com/users/1075282",
"pm_score": 2,
"selected": false,
"text": "Device and Log File"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1081/"
] |
117,477 | <p>A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes, links and newlines/paragraphs only.</p>
<p>Unfortunately I lost the name of the library and was unable to Google it. Anyone any ideas?</p>
<p><strong>Edit:</strong> reStructuredText aka rst == docutils. That's not what I'm looking for :)</p>
| [
{
"answer_id": 117819,
"author": "sean lynch",
"author_id": 14232,
"author_profile": "https://Stackoverflow.com/users/14232",
"pm_score": 1,
"selected": false,
"text": "python markdown.py input_file.txt > output_file.html\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19990/"
] |
117,481 | <p>At work I'm using Perl 5.8.0 on Windows.</p>
<p>When I first put Perl on, I went to CPAN, downloaded all the sources, made a few changes (in the .MAK file(?) to support threads, or things like that), and did <code>nmake</code> / <code>nmake test</code> / <code>nmake install</code>. Then, bit by bit, I've downloaded individual modules from CPAN and done the nmake dance.</p>
<p>So, I'd like to upgrade to a more recent version, but the new one must not break any existing scripts. Notably, a bunch of "use" modules that I've installed must be installed in the new version.</p>
<p>What's the most reliable (and easiest) way to update my current version, ensuring that everything I've done with the nmake dance will still be there after updating?</p>
| [
{
"answer_id": 117577,
"author": "dland",
"author_id": 18625,
"author_profile": "https://Stackoverflow.com/users/18625",
"pm_score": 2,
"selected": false,
"text": "perl -le \"print for @INC\"\n"
},
{
"answer_id": 117938,
"author": "brian d foy",
"author_id": 2766176,
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8763/"
] |
117,484 | <p>Just a small SVN "problem" here.</p>
<p>I setup my own SVN server <a href="https://blog.codinghorror.com/setting-up-subversion-on-windows/" rel="nofollow noreferrer">Setting up Subversion on Windows</a></p>
<p>Now I made a rep in which all my projects will go.</p>
<p>Now, I checked the rep out in a folder called "Projects".</p>
<p>Now If I make a project and check it in, that project is revision 1. If I make a second project, and check it in, that Project is at revision 2. Thus, if I make a change to Project 1, that project will then be at Revision 3.</p>
<p>What I would really want is for each project to have its own revision scheme. How do I do this? </p>
| [
{
"answer_id": 117617,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 0,
"selected": false,
"text": "svnserve -r /path/to/repository \n\nsvn://hostname/ \n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
117,512 | <p>Given a simple (id, description) table t1, such as</p>
<pre><code>id description
-- -----------
1 Alice
2 Bob
3 Carol
4 David
5 Erica
6 Fred
</code></pre>
<p>And a parent-child relationship table t2, such as</p>
<pre><code>parent child
------ -----
1 2
1 3
4 5
5 6
</code></pre>
<p>Oracle offers a way of traversing this as a tree with some custom syntax extensions:</p>
<pre><code>select parent, child, sys_connect_by_path(child, '/') as "path"
from t2
connect by prior parent = child
</code></pre>
<p>The exact syntax is not important, and I've probably made a mistake in the above. The
important thing is that the above will produce something that looks like</p>
<pre><code>parent child path
------ ----- ----
1 2 /1/2
1 3 /1/3
4 5 /4/5
4 6 /4/5/6
5 6 /5/6
</code></pre>
<p>My question is this: is it possible to join another table within the sys_connect_by_path(), such as the t1 table above, to produce something like:</p>
<pre><code>parent child path
------ ----- ----
1 2 /Alice/Bob
1 3 /Alice/Carol
... and so on...
</code></pre>
| [
{
"answer_id": 117596,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 0,
"selected": false,
"text": "SELECT parent, child, parents.description||sys_connect_by_path(childs.description, '/') AS \"path\"\nFROM T1 parents, ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18625/"
] |
117,514 | <p>How do I properly represent a different timezone in my timezone? The below example only works because I know that EDT is one hour ahead of me, so I can uncomment the subtraction of myTimeZone()</p>
<pre><code>import datetime, re
from datetime import tzinfo
class myTimeZone(tzinfo):
"""docstring for myTimeZone"""
def utfoffset(self, dt):
return timedelta(hours=1)
def myDateHandler(aDateString):
"""u'Sat, 6 Sep 2008 21:16:33 EDT'"""
_my_date_pattern = re.compile(r'\w+\,\s+(\d+)\s+(\w+)\s+(\d+)\s+(\d+)\:(\d+)\:(\d+)')
day, month, year, hour, minute, second = _my_date_pattern.search(aDateString).groups()
month = [
'JAN', 'FEB', 'MAR',
'APR', 'MAY', 'JUN',
'JUL', 'AUG', 'SEP',
'OCT', 'NOV', 'DEC'
].index(month.upper()) + 1
dt = datetime.datetime(
int(year), int(month), int(day),
int(hour), int(minute), int(second)
)
# dt = dt - datetime.timedelta(hours=1)
# dt = dt - dt.tzinfo.utfoffset(myTimeZone())
return (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, 0, 0, 0)
def main():
print myDateHandler("Sat, 6 Sep 2008 21:16:33 EDT")
if __name__ == '__main__':
main()
</code></pre>
| [
{
"answer_id": 117615,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 5,
"selected": false,
"text": "babel"
},
{
"answer_id": 1893437,
"author": "Carlos H Romano",
"author_id": 268789,
"author_pro... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9338/"
] |
117,536 | <p>I've tried restarting apache and the cached pages still appear, so there must be a folder someplace. I don't have a 'public/cache', so what other places should I look? Is there a URL flag that could trigger this effect as well?</p>
| [
{
"answer_id": 118951,
"author": "johnp",
"author_id": 19837,
"author_profile": "https://Stackoverflow.com/users/19837",
"pm_score": 4,
"selected": true,
"text": "touch /webapps/mycook/tmp/restart.txt\n"
},
{
"answer_id": 48336423,
"author": "Arman Petrosyan",
"author_id"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13320/"
] |
117,547 | <p>Documentation can be found <a href="http://github.com/madrobby/scriptaculous/wikis/droppables" rel="nofollow noreferrer">here</a></p>
<p>It says in the example:</p>
<p><strong>onDrop:
Called whenever a Draggable is released over the Droppable and the Droppable is accepts it. The callback gets three parameters: the Draggable element, the Droppable element and the Event. You can extract additional information about the drop – like if the Ctrl or Shift keys were pressed – from the Event object.</strong></p>
<p>Then it gives some code</p>
<p>Droppables.add('shopping_cart', {
accept: 'products',
onDrop: function(element) {
$('shopping_cart_text').update('Dropped the ' + element.alt + ' on me.');
}
});</p>
<p>It uses the ambiguous word 'element' in the code. <strong>My question is, does anyone have a good example on how to reference the draggable element and the droppable element in this callback javascript function?</strong></p>
| [
{
"answer_id": 117583,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": true,
"text": "onDrop: function() { $('droppable_demo').highlight(); }\n"
},
{
"answer_id": 1429302,
"author": "Mark",
"author_... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
117,551 | <p>My website makes a lot of requests. I often need to cancel all current requests, so that the browser is not blocking relevant new requests.</p>
<p>I have 3 kinds of requests:</p>
<ul>
<li>Ajax</li>
<li>inserted script-tags (which do JSONP-Communication)</li>
<li>inserted image-tags (which cause the browser to request data from various servers)</li>
</ul>
<p>For Ajax its no problem as the XMLHttpRequest object supports canceling.
What I need is a way to make any browser stop loading resources, from DOM-Objects.</p>
<p>Looks like simply removing an object (eg. an image-tag) from the DOM only helps avoiding an request, if the request is not already running.</p>
<p><strong>UPDATE:</strong> a way to cancel all requests, which are irrelevant, instead of really any request would be perfect. </p>
| [
{
"answer_id": 117565,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "document.close()"
},
{
"answer_id": 117628,
"author": "toohool",
"author_id": 14334,
"author_pr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20711/"
] |
117,558 | <p>I am re-designing an application for a ASP.NET CMS that I really don't like. I have made som improvements in performance only to discover that not only does this CMS use MS SQL but some users "simply" use MS Access database.</p>
<p>The problem is that I have some tables which I inner join, that with the MS Access version are in two different files. I am not allowed to simply move the tables to the other mdb file.</p>
<p>I am now trying to figure out a good way to "inner join" across multiple access db files?</p>
<p>It would really be a pity if I have fetch all the data and the do it programmatically!</p>
<p>Thanks</p>
| [
{
"answer_id": 118234,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 4,
"selected": false,
"text": "SELECT MyTable.*\nFROM MyTable IN 'c:\\MyDBs\\Access.mdb'\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20032/"
] |
117,570 | <p>On our web application, the search results are displayed in sortable tables. The user can click on any column and sort the result. The problem is some times, the user does a broad search and gets a lot of data returned. To make the sortable part work, you probably need all the results, which takes a long time. Or I can retrieve few results at a time, but then sorting won't really work well. What's the best practice to display sortable tables that might contain lots of data? </p>
<hr>
<p>Thanks for all the advises. I will certainly going over these.</p>
<p>We are using an existing Javascript framework that has the sortable table; "lots" of results means hundreds. The problem is that our users are at some remote site and a lot of delay is the network time to send/receive data from the data center. Sorting the data at the database side and only send one page worth of results at a time is nice; but when the user clicks some column header, another round trip is done, which always add 3-4 seconds. </p>
<p>Well, I guess that might be the network team's problem :)</p>
| [
{
"answer_id": 118683,
"author": "Leo Moore",
"author_id": 6336,
"author_profile": "https://Stackoverflow.com/users/6336",
"pm_score": 2,
"selected": false,
"text": "CREATE PROCEDURE GetProductsInCategory\n(@CategoryID INT,\n@DescriptionLength INT,\n@PageNumber INT,\n@ProductsPerPage INT... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20460/"
] |
117,589 | <p>When we are developing new sites or testing changes in new ones that involve css after the new code is committed and someone goes to check the changes they always see a cached version of the old css. This is causing a lot of problems in testing because people never are sure if they have the latest css on screen (I know shift and clicking refresh clears this cache but I can't expect end users to know to do this). What are my possible solutions?</p>
| [
{
"answer_id": 117622,
"author": "Michael Cox",
"author_id": 372698,
"author_profile": "https://Stackoverflow.com/users/372698",
"pm_score": 2,
"selected": false,
"text": " <link href=\"/css/global.css?id=3939\" type=\"text/css\" rel=\"stylesheet\" />\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18926/"
] |
117,590 | <p>Does anyone have a good guide to capabilities of Windows Services under XP? In particular, I am trying to find out what happens when a program being run as a service tries to open windows, but hasn't been given permission to interact with the desktop.</p>
<p>Basically, I have a program that is/was a GUI application, that should be able to run as a service for long term background processing. Rewriting the program to not display the GUI elements when doing background processing is a major effort, so I'd like to see if there is just a way to ignore the UI elements. It is sort of working now, as long as too many windows aren't opened. I'm trying to figure out what limits I might be running into. Ideally, there would be an MSDN page that discusses this, but I've had no luck finding one yet.</p>
| [
{
"answer_id": 117605,
"author": "prakash",
"author_id": 123,
"author_profile": "https://Stackoverflow.com/users/123",
"pm_score": 2,
"selected": false,
"text": "Control Panel --> Administrative Tools"
},
{
"answer_id": 117692,
"author": "Max Caceres",
"author_id": 4842,
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7909/"
] |
117,623 | <p>Backstory: I'm using <a href="http://logging.apache.org/log4net/index.html" rel="noreferrer">log4net</a> to handle all logging for a project I'm working on. One particular method can be called under several different circumstances -- some that warrant the log messages to be errors and others that warrant the log messages to be warnings.</p>
<p>So, as an example, how could I turn</p>
<pre><code>Public Sub CheckDifference(ByVal A As Integer, ByVal B As Integer)
If (B - A) > 5 Then
log.ErrorFormat("Difference ({0}) is outside of acceptable range.", (B - A))
End If
End Sub
</code></pre>
<p>Into something more along the lines of:</p>
<pre><code>Public Sub CheckDifference(ByVal A As Integer, ByVal B As Integer, "Some delegate info here")
If (B - A) > 5 Then
**delegateinfo**.Invoke("Difference ({0}) is outside of acceptable range.", (B - A))
End If
End Sub
</code></pre>
<p>So that I could call it and pass either log.ErrorFormat or log.WarnFormat as the delegate?</p>
<p>I'm using VB.NET with VS 2008 and .NET 3.5 SP1. Also, I'm fairly new to delegates in general, so if this question should be worded differently to remove any ambiguities, let me know.</p>
<p>EDIT: Also, how could I initialize the delegate to either the ErrorFormat or the WarnFormat in the class constructor? Would it be as easy as <code>myDelegate = log.ErrorFormat</code>? I would imagine there is more to it than that (pardon my ignorance on the subject -- delegates are really something I want to learn more about, but so far they have eluded my understanding).</p>
| [
{
"answer_id": 117646,
"author": "MagicKat",
"author_id": 8505,
"author_profile": "https://Stackoverflow.com/users/8505",
"pm_score": 0,
"selected": false,
"text": "Public Delegate errorCall(ByVal error As String, Params objs As Objects())\nCheckDifference(10, 0, AddressOf log.ErrorForma... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1108/"
] |
117,632 | <p>What install tool can I use to create Virtual Directory on IIS? OpenSource, free or to do in C#. </p>
| [
{
"answer_id": 132967,
"author": "Tom",
"author_id": 20979,
"author_profile": "https://Stackoverflow.com/users/20979",
"pm_score": 0,
"selected": false,
"text": "Set objMimeMap = GetObject(\"IIS://localhost/w3svc\")\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12514/"
] |
117,651 | <h2>Problem</h2>
<p>Language: C# 2.0 or later</p>
<hr>
<p>I would like to register context handlers to create menues when the user right clicks certain files (in my case *.eic). What is the procedure to register, unregister (clean up) and handle events (clicks) from these menues?</p>
<p>I have a clue it's something to do with the windows registry, but considering how much stuff there is in .net, I wouldn't be surprised if there are handy methods to do this clean and easy.</p>
<p>Code snippets, website references, comments are all good. Please toss them at me.</p>
<h2>Update</h2>
<hr>
<p>Obviously there is a slight problem creating context menues in managed languages, as several users have commented. Is there any other preferred way of achieving the same behaviour, or should I spend time looking into these workarounds? I don't mind doing that at all, I'm glad people have put effort into making this possible - but I still want to know if there is a "proper/clean" way of achieving this.</p>
| [
{
"answer_id": 611126,
"author": "VoidPointer",
"author_id": 23424,
"author_profile": "https://Stackoverflow.com/users/23424",
"pm_score": 1,
"selected": false,
"text": "HKEY_CLASSES_ROOT\\.eic\\ShellEx\\ContextMenuHandlers\\MyShellExt\n (Default) -> {YOUR-COMPONENTS-CLSID}\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166173/"
] |
117,665 | <p>I got this bad feeling about how I insert larger amounts of HTML.
Lets assume we got:</p>
<p><code>var html="<table>..<a-lot-of-other-tags />..</table>"</code></p>
<p>and I want to put this into</p>
<p><code>$("#mydiv")</code></p>
<p>previously I did something like</p>
<p><code>var html_obj = $(html);</code>
<code>$("#mydiv").append(html_obj);</code></p>
<p>Is it correct that jQuery is parsing <code>html</code> to create DOM-Objects ? Well this is what I read somewhere <strong>(UPDATE:</strong> I meant that I have read, jQuery parses the html to create the whole DOM tree by hand - its nonsense right?!<strong>)</strong>, so I changed my code:</p>
<p><code>$("#mydiv").attr("innerHTML", $("#mydiv").attr("innerHTML") + html);</code></p>
<p>Feels faster, is it ? And is it correct that this is equivalent to:</p>
<p><code>document.getElementById("mydiv").innerHTML += html</code> ? or is jquery doing some additional expensive stuff in the background ?</p>
<p>Would love to learn alternatives as well.</p>
| [
{
"answer_id": 117705,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 3,
"selected": false,
"text": "document.createElement()"
},
{
"answer_id": 117988,
"author": "Prestaul",
"author_id": 5628,
"author_profile... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20711/"
] |
117,667 | <p>I know this is probably the dumbest question ever, however I am a total beginner when it comes to CSS; how do you hyperlink an image on a webpage using an image which is sourced from CSS? I am trying to set the title image on my website linkable to the frontpage. Thanks!</p>
<p><strong>Edit:</strong> Just to make it clear, I'm sourcing my image <em>from CSS</em>, the CSS code for the header div is as follows:-</p>
<pre><code>#header
{
width: 1000px;
margin: 0px auto;
padding: 0px 15px 0px 15px;
border: none;
background: url(images/title.png) no-repeat bottom;
width: 1000px;
height: 100px;
}
</code></pre>
<p>I want to know how to make this <em>div</em> hyperlinked on my webpage without having to make it an anchor rather than a div.</p>
| [
{
"answer_id": 117675,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 2,
"selected": false,
"text": "<a href=\"index.html\"><img src=\"foo\" class=\"whatever\" alt=\"foo alt\" /></a>\n"
},
{
"answer_id": 117680,
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] |
117,690 | <p>I have few asynchronous tasks running and I need to wait until at least one of them is finished (in the future probably I'll need to wait util M out of N tasks are finished).
Currently they are presented as Future, so I need something like</p>
<pre><code>/**
* Blocks current thread until one of specified futures is done and returns it.
*/
public static <T> Future<T> waitForAny(Collection<Future<T>> futures)
throws AllFuturesFailedException
</code></pre>
<p>Is there anything like this? Or anything similar, not necessary for Future. Currently I loop through collection of futures, check if one is finished, then sleep for some time and check again. This looks like not the best solution, because if I sleep for long period then unwanted delay is added, if I sleep for short period then it can affect performance.</p>
<p>I could try using </p>
<pre><code>new CountDownLatch(1)
</code></pre>
<p>and decrease countdown when task is complete and do </p>
<pre><code>countdown.await()
</code></pre>
<p>, but I found it possible only if I control Future creation. It is possible, but requires system redesign, because currently logic of tasks creation (sending Callable to ExecutorService) is separated from decision to wait for which Future. I could also override </p>
<pre><code><T> RunnableFuture<T> AbstractExecutorService.newTaskFor(Callable<T> callable)
</code></pre>
<p>and create custom implementation of RunnableFuture with ability to attach listener to be notified when task is finished, then attach such listener to needed tasks and use CountDownLatch, but that means I have to override newTaskFor for every ExecutorService I use - and potentially there will be implementation which do not extend AbstractExecutorService. I could also try wrapping given ExecutorService for same purpose, but then I have to decorate all methods producing Futures.</p>
<p>All these solutions may work but seem very unnatural. It looks like I'm missing something simple, like </p>
<pre><code>WaitHandle.WaitAny(WaitHandle[] waitHandles)
</code></pre>
<p>in c#. Are there any well known solutions for such kind of problem?</p>
<p>UPDATE:</p>
<p>Originally I did not have access to Future creation at all, so there were no elegant solution. After redesigning system I got access to Future creation and was able to add countDownLatch.countdown() to execution process, then I can countDownLatch.await() and everything works fine.
Thanks for other answers, I did not know about ExecutorCompletionService and it indeed can be helpful in similar tasks, but in this particular case it could not be used because some Futures are created without any executor - actual task is sent to another server via network, completes remotely and completion notification is received.</p>
| [
{
"answer_id": 117711,
"author": "jdmichal",
"author_id": 12275,
"author_profile": "https://Stackoverflow.com/users/12275",
"pm_score": 3,
"selected": true,
"text": "WaitHandle.WaitAny"
},
{
"answer_id": 118158,
"author": "Scott Stanchfield",
"author_id": 12541,
"auth... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5507/"
] |
117,691 | <p>Given an array of integers, what is the simplest way to iterate over it and figure out all the ranges it covers? for example, for an array such as:</p>
<pre><code>$numbers = array(1,3,4,5,6,8,11,12,14,15,16);
</code></pre>
<p>The ranges would be:</p>
<pre><code> 1,3-6,8,11-12,14-16
</code></pre>
| [
{
"answer_id": 117722,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "numbers = [1,3,4,5,6,8,11,12,14,15,16];\n\ndef is_predecessor(i1, i2):\n if i1 == i2 - 1:\n return True;\n ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10585/"
] |
117,708 | <p>The non-virtual interface idiom describes how the virtual methods are nonpublic customisation points, and public methods are nonvirtual to allow the base class to control at all times how the customisation points are called. </p>
<p>This is an elegant idiom and I like to use it, but how does it work if the derived class is a base class in itself</p>
| [
{
"answer_id": 117760,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 4,
"selected": true,
"text": "\nclass Parent\n{\npublic:\n int foo() {return bar();} // the non-virtual public interface\nprivate\n virtual int bar();\n};... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] |
117,732 | <p>Take this simple <em>C# LINQ</em> query, and imagine that <code>db.Numbers</code> is an <em>SQL</em> table with one column <code>Number</code>:</p>
<pre><code>var result =
from n in db.Numbers
where n.Number < 5
select n.Number;
</code></pre>
<p>This will run very efficiently in <em>C#</em>, because it generates an <em>SQL</em> query something like</p>
<pre><code>select Number from Numbers where Number < 5
</code></pre>
<p>What it <strong>doesn't</strong> do is select <em>all</em> the numbers from the database, and then filter them in <em>C#</em>, as it might appear to do at first.</p>
<p><em>Python</em> supports a similar syntax:</p>
<pre><code>result = [n.Number for n in Numbers if n.Number < 5]
</code></pre>
<p>But it the <code>if</code> clause here does the filtering on the client side, rather than the server side, which is much less efficient.</p>
<p>Is there something as efficient as <em>LINQ</em> in <em>Python</em>? (I'm currently evaluating <em>Python</em> vs. <em>IronPython</em> vs. <em>Boo</em>, so an answer that works in any of those languages is fine.)</p>
| [
{
"answer_id": 118350,
"author": "Tony Meyer",
"author_id": 4966,
"author_profile": "https://Stackoverflow.com/users/4966",
"pm_score": 3,
"selected": true,
"text": "Queryable.Select(Queryable.Where(someInputSequence, somePredicate), someFuncThatReturnsTheSequenceElement) \n"
},
{
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42219/"
] |
117,751 | <p>I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I'd like to use JBoss' own TransactionManager, and when running on Tomcat, I'd like to use JOTM.</p>
<p>I have both scenarios working, but I now find that I seem to need two separate Spring configurations for the two cases. With JOTM, I need to use Spring's <code>JotmFactoryBean</code>:</p>
<pre><code><bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction">
<bean class="org.springframework.transaction.jta.JotmFactoryBean"/>
</property>
</bean>
</code></pre>
<p>In JBoss, though, I just need to fetch "TransactionManager" from JNDI:</p>
<pre><code><bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef" value="true" />
<property name="jndiName" value="TransactionManager" />
<property name="expectedType"
value="javax.transaction.TransactionManager" />
</bean>
</property>
</bean>
</code></pre>
<p>Is there a way to configure this so that the appropriate TransactionManager - JBoss or JOTM - is used, without the need for two different configuration files?</p>
| [
{
"answer_id": 117871,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "<bean class=\"org.springframework.beans.factory.config.PropertyPlaceholderConfigurer\">\n <property name=\"systemProperti... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7034/"
] |
117,755 | <p>Here's the code I want to speed up. It's getting a value from an ADO recordset and converting it to a char*. But this is slow. Can I skip the creation of the _bstr_t?</p>
<pre><code> _variant_t var = pRs->Fields->GetItem(i)->GetValue();
if (V_VT(&var) == VT_BSTR)
{
char* p = (const char*) (_bstr_t) var;
</code></pre>
| [
{
"answer_id": 117780,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 2,
"selected": false,
"text": "USES_CONVERSION;\nchar *p=W2A(var.bstrVal);\n"
},
{
"answer_id": 117781,
"author": "gbjbaanb",
"aut... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
117,772 | <p>I'm trying to use the page-break-inside CSS directive, the class of which is to be attached to a div tag or a table tag (I think this may only work on block elements, in which case it would have to be the table).</p>
<p>I've tried all the tutorials that supposedly describe exactly how to do this, but nothing works. Is this an issue of browser support or has anyone actually gotten this working, the exact bit of CSS looks like this:</p>
<pre><code>@media print {
.noPageBreak {
page-break-inside : avoid;
}
}
</code></pre>
| [
{
"answer_id": 117878,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 0,
"selected": false,
"text": "<div>"
},
{
"answer_id": 117908,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflo... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20762/"
] |
117,776 | <p>I've used <a href="http://ondras.zarovi.cz/sql/" rel="nofollow noreferrer">WWW SQL Designer</a> several times to design databases for applications. I'm now in charge of working on an application with a lot of tables (100+ mysql tables) and I would love to be able to look at the relations between tables in a manner similar to what WWW SQL Designer provides. It seems that it comes with the provisions to hook up to a database and provide a diagram of its structure, but I've not yet been able to figure out exactly how one would do that. </p>
| [
{
"answer_id": 18035488,
"author": "Mickaël",
"author_id": 2649093,
"author_profile": "https://Stackoverflow.com/users/2649093",
"pm_score": 2,
"selected": false,
"text": "function setup_import() {\n define(\"SERVER\",\"localhost\");\n define(\"USER\",\"\");\n define(\"PASSWORD\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] |
117,792 | <p>I'm interested to know the best / common way of storing a <code>this</code> pointer for use in the <code>WndProc</code>. I know of several approaches, but each as I understand it have their own drawbacks. My questions are:</p>
<p>What different ways are there of producing this kind of code:</p>
<pre><code>CWindow::WndProc(UINT msg, WPARAM wParam, LPARAM)
{
this->DoSomething();
}
</code></pre>
<p>I can think of Thunks, HashMaps, Thread Local Storage and the Window User Data struct.</p>
<p>What are the pros / cons of each of these approaches?</p>
<p>Points awarded for code examples and recommendations.</p>
<p>This is purely for curiosities sake. After using MFC I've just been wondering how that works and then got to thinking about ATL etc.</p>
<p><strong>Edit:</strong> What is the earliest place I can validly use the <code>HWND</code> in the window proc? It is documented as <code>WM_NCCREATE</code> - but if you actually experiment, that's <em>not</em> the first message to be sent to a window.</p>
<p><strong>Edit:</strong> ATL uses a thunk for accessing the this pointer. MFC uses a hashtable lookup of <code>HWND</code>s.</p>
| [
{
"answer_id": 117832,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "GetWindowLongPtr()"
},
{
"answer_id": 117876,
"author": "Community",
"author_id": -1,
"author_pr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
117,800 | <p>For our Django App, we'd like to get an <code>AutoField</code> to start at a number other than 1. There doesn't seem to be an obvious way to do this. Any ideas?</p>
| [
{
"answer_id": 118402,
"author": "AdamKG",
"author_id": 16361,
"author_profile": "https://Stackoverflow.com/users/16361",
"pm_score": 5,
"selected": true,
"text": "ALTER SEQUENCE sequence_name RESTART WITH 12345;"
},
{
"answer_id": 6388329,
"author": "Gabriel Samfira",
"a... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9845/"
] |
117,810 | <p>My ASP.NET MVC application will take a lot of bandwidth and storage space. How can I setup an ASP.NET upload page so the file the user uploaded will go straight to Amazon S3 without using my web server's storage and bandwidth?</p>
| [
{
"answer_id": 35478577,
"author": "sambit.albus",
"author_id": 1254010,
"author_profile": "https://Stackoverflow.com/users/1254010",
"pm_score": 2,
"selected": false,
"text": "using System\nusing System.Collections.Generic\nusing System.Linq\nusing System.Web\nusing Amazon\nusing Amazon... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20067/"
] |
117,812 | <p>Anybody have any good FizzBuzz type questions that are not <em>the</em> FizzBuzz problem?</p>
<p>I am interviewing someone and FB is relatively well known and not that hard to memorize, so my first stop in a search for ideas is my new addiction SO.</p>
| [
{
"answer_id": 117949,
"author": "shelfoo",
"author_id": 3444,
"author_profile": "https://Stackoverflow.com/users/3444",
"pm_score": 5,
"selected": false,
"text": "Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/117812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3683/"
] |
117,844 | <p>I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform such an operation?</p>
| [
{
"answer_id": 117862,
"author": "Torlack",
"author_id": 5243,
"author_profile": "https://Stackoverflow.com/users/5243",
"pm_score": 3,
"selected": false,
"text": "char string[] = \"1101110100110100100000\";\nchar * end;\nlong int value = strtol (string,&end,2);\n"
},
{
"answer_i... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1582/"
] |
117,851 | <p>For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9.</p>
<p>The version number is very important...</p>
| [
{
"answer_id": 117980,
"author": "stephbu",
"author_id": 12702,
"author_profile": "https://Stackoverflow.com/users/12702",
"pm_score": 4,
"selected": true,
"text": "/// <summary>\n/// The GetForegroundWindow function returns a handle to the foreground window.\n/// </summary>\n[DllImport(... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44972/"
] |
117,864 | <p>I'm a total newbie, but I was writing a little program that worked on strings in C# and I noticed that if I did a few things differently, the code executed significantly faster.</p>
<p>So it had me wondering, how do you go about clocking your code's execution speed? Are there any (free)utilities? Do you go about it the old-fashioned way with a System.Timer and do it yourself?</p>
| [
{
"answer_id": 117883,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 4,
"selected": false,
"text": "Stopwatch"
},
{
"answer_id": 35558488,
"author": "Nikusha Kalatozi",
"author_id": 5397398,
"auth... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10288/"
] |
117,900 | <p>I have an application that loads external SWF files and plays them inside a Adobe Flex / Air application via the <a href="http://livedocs.adobe.com/flex/3/html/controls_15.html" rel="nofollow noreferrer">SWFLoader Flex component</a>. I have been trying to find a way to unload them from a button click event. I have Google'd far and wide and no one seems to have been able to do it without a hack. The combination of code I see people use is:</p>
<pre><code>swfLoader.source = ""; // Removes the external link to the SWF.
swfLoader.load(null); // Forces the loader to try to load nothing.
// Note: At this point sound from the SWF is still playing, and
// seems to still be playing in memory.
flash.media.SoundMixer.stopAll();
// Stops the sound. This works on my development machine, but not
// on the client's.
</code></pre>
<p>If the SWFs are closed (hidden) this way, eventually the program crashes.</p>
<p>Any ideas? I have found tons of posts in various forums with people having the same problem. I assume I will get one wrong/incomplete answer here, and than my post will sink into nothingness as usual, but either way, thanks in advance!</p>
<p><em>Edit 1</em>: I can't edit the actual SWF movies, they're created by the client. If I can't close any SWF opened through Flex, isn't that a problem with the Flex architecture? Is my only option sending the SWFs to the web browser?</p>
| [
{
"answer_id": 118026,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 1,
"selected": false,
"text": "MovieClip(event.target.content).loaderInfo.addEventListener(Event.UNLOAD, unloadMovieClipHandler);\nprivate function unl... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] |
117,931 | <p>I'm building a fairly large website and my .htaccess is starting to feel a bit bloated, is there a way of replacing my current system of - one rule for each of the possibile number of vars that could be passed, to one catch all expression that can account for varying numbers of inputs ?</p>
<p>for example I currently have:</p>
<pre><code>RewriteRule ^([a-z]+)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /index.php?mode=$1&id=$2&$3=$4&$5=$6
RewriteRule ^([a-z]+)/([^/]*)/([^/]*)/([^/]*)$ /index.php?mode=$1&id=$2&$3=$4
RewriteRule ^([a-z]+)/([^/]*)$ /index.php?mode=$1&id=$2
RewriteRule ^([a-z]+)$ /index.php?mode=$1
</code></pre>
<p>the first backreference is always the <em>mode</em> and (if any more exist) the second is always <em>id</em>, thereafter any further backreferences alternate between the name of the input and its value</p>
<pre><code>http://www.example.com/search
http://www.example.com/search/3039/sort_by/name_asc/page/23
</code></pre>
<p>I would love to be able to have one expression to gracefully handle all the inputs.</p>
| [
{
"answer_id": 117968,
"author": "daniels",
"author_id": 9789,
"author_profile": "https://Stackoverflow.com/users/9789",
"pm_score": 4,
"selected": true,
"text": " RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]\n"
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2083/"
] |
117,945 | <p>I've written a simple app in C# 2.0 using the .Net Framework 2.0 Serialport class to communicate with a controller card via COM1. </p>
<p>A problem occurred recently were the bytes returned by the Read method are incorrect. It returned the right amount of bytes, only the values were incorrect. A similar app written in Delphi still returned the correct values though. </p>
<p>I used <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx" rel="nofollow noreferrer">Portmon</a> to log the activity on the serial port of both apps, compared the two logs and there where some (apparently) minor different settings and I tried to the imitate the Delphi app as closely as possible, but to no avail.</p>
<p>So, what could affect the byte values returned by Read method ? </p>
<p>Most settings between the two apps are identical. </p>
<p>Here is a list of the lines which differed in the Portmon log :</p>
<p><strong>Delphi App :</strong></p>
<blockquote>
<p>IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS <strong>EOF:dc</strong>
ERR:0 BRK:0 <strong>EVT:0</strong> XON:11 XOFF:13<br>
IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0
Replace:0 <strong>XonLimit:256</strong>
<strong>XoffLimit:256</strong> IOCTL_SERIAL_SET_TIMEOUTS Serial0 SUCCESS RI:-1
<strong>RM:100</strong> RC:1000 <strong>WM:100</strong> WC:1000 IOCTL_SERIAL_SET_WAIT_MASK Serial0 SUCCESS Mask:
RXCHAR RXFLAG <strong>TXEMPTY</strong> CTS DSR RLSD
BRK ERR RING <strong>RX80FULL</strong></p>
</blockquote>
<p><strong>C# App :</strong></p>
<blockquote>
<p>IOCTL_SERIAL_SET_CHAR Serial0 SUCCESS <strong>EOF:1a</strong>
ERR:0 BRK:0 <strong>EVT:1a</strong> XON:11 XOFF:13
IOCTL_SERIAL_SET_HANDFLOW Serial0 SUCCESS Shake:0
Replace:0 <strong>XonLimit:1024</strong>
<strong>XoffLimit:1024</strong> IOCTL_SERIAL_SET_TIMEOUTS Serial0 SUCCESS RI:-1
<strong>RM:-1</strong> RC:1000 <strong>WM:0</strong> WC:1000 IOCTL_SERIAL_SET_WAIT_MASK Serial0 SUCCESS Mask:
RXCHAR RXFLAG CTS DSR RLSD BRK ERR
RING</p>
</blockquote>
<p>UPDATE:</p>
<p>The correct returned bytes were : 91, 1, 1, 3, 48, 48, 50, 69, 66, 51, 70, 55, 52, 93 (14 bytes).
The last value being a simple checksum.</p>
<p>The incorrect values returned were : 91, 241, 254, 252, 242, 146, 42, 201, 51, 70, 55, 52, 93 (13 bytes).</p>
<p>As you can see the first and the last five bytes returned correspond.</p>
<p>The ErrorReceived event indicates that a framing error occurred, which could explain the incorrect values. But the question is why would SerialPort encounter a framing error when the Delphi app apparently does not ?</p>
| [
{
"answer_id": 120525,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 0,
"selected": false,
"text": "SerialPort.Encoding = Encoding.GetEncoding(\"Latin1\")\n"
},
{
"answer_id": 183455,
"author": "jakdep",
"autho... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20101/"
] |
117,962 | <p>I have two tables, both with start time and end time fields. I need to find, for each row in the first table, all of the rows in the second table where the time intervals intersect.</p>
<p>For example:</p>
<pre><code> <-----row 1 interval------->
<---find this--> <--and this--> <--and this-->
</code></pre>
<p>Please phrase your answer in the form of a SQL <code>WHERE</code>-clause, AND consider the case where the end time in the second table may be <code>NULL</code>.</p>
<p>Target platform is SQL Server 2005, but solutions from other platforms may be of interest also.</p>
| [
{
"answer_id": 117977,
"author": "Khoth",
"author_id": 20686,
"author_profile": "https://Stackoverflow.com/users/20686",
"pm_score": 7,
"selected": true,
"text": "SELECT * \nFROM table1,table2 \nWHERE table2.start <= table1.end \nAND (table2.end IS NULL OR table2.end >= table1.start)\n"
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9345/"
] |
117,974 | <p>In SQL you can use </p>
<p>SELECT * FROM INFORMATION_SCHEMA.TABLES </p>
<p>etc to get information about the database structure. I need to know how to achieve the same thing for an Access database.</p>
| [
{
"answer_id": 27436989,
"author": "Terry",
"author_id": 1034974,
"author_profile": "https://Stackoverflow.com/users/1034974",
"pm_score": 1,
"selected": false,
"text": "#include <atldb.h>\n...\n // Standard way of obtaining table node info.\n CAccessorRowset<CDynamicAccess... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4403/"
] |
117,986 | <p>I'm searching a wsgi middleware which I can warp around a wsgi applications and which lets me monitor incoming and outgoing http requests and header fields.</p>
<p>Something like firefox live headers, but for the server side.</p>
| [
{
"answer_id": 118037,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "import sys\n\ndef log_headers(app, stream=None):\n if stream is None:\n stream = sys.stdout\n def prox... | 2008/09/22 | [
"https://Stackoverflow.com/questions/117986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/720/"
] |
118,051 | <p>I have a grid that is binded to a collection. For some reason that I do not know, now when I do some action in the grid, the grid doesn't update.</p>
<p>Situation : When I click a button in the grid, it increase a value that is in the same line. When I click, I can debug and see the value increment but the value doesn't change in the grid. <strong>BUT</strong> when I click the button, minimize and restore the windows, the value are updated... what do I have to do to have the value updated like it was before?</p>
<p><strong>UPDATE</strong>
This is NOT SOLVED but I accepted the best answer around here.</p>
<p>It's not solved because it works as usuall when the data is from the database but not from the cache. Objects are serialized and threw the process the event are lost. This is why I build them back and it works for what I know because I can interact with them BUT it seem that it doesn't work for the update of the grid for an unkown reason.</p>
| [
{
"answer_id": 118438,
"author": "Pop Catalin",
"author_id": 4685,
"author_profile": "https://Stackoverflow.com/users/4685",
"pm_score": 3,
"selected": true,
"text": "public string Name \n{\n get\n {\n return this._Name;\n }\n set\n {\n if (value != this._Name)\n {\n ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
118,091 | <p>I am trying to learn how to use MSBuild so we can use it to build our project. There's what seems to be a very big hole in the documentation, and I find the hole everywhere I look, the hole being how do you name or otherwise designate the MSBuild project file? </p>
<p>For example, the tutorial on MSBuild that can be downloaded from Microsoft goes into some detail on the contents of the build file. For example, here's a little bit of their Hello World project file.</p>
<pre><code><Project MSBuildVersion = "1.0" DefaultTargets = "Compile">
<Property appname = "HelloWorldCS"/>
<Item Type = "CSFile" Include = "consolehwcs1.cs"/>
<Target Name = "Compile">
<Task Name = "CSC" Sources = "@(CSFile)">
<OutputItem TaskParameter = "OutputAssembly" Type = "EXEFile" Include = "$(appname).exe"/>
</Task>
<Message Text="The output file is @(EXEFile)"/>
</Target>
</Project>
</code></pre>
<p>And it goes on blah, blah, blah Items blah blah blah tasks, here's how you do this and here's how you do that. Useless, completely useless. Because they never get around to saying how this xml file is supposed to be recognized by the MSBuild app. Is it supposed to be named in a particular way? Is it supposed to be placed in a particular directory? Both? Neither? </p>
<p>It isn't just the MS tutorial where they don't tell about it. I haven't been able to find it on MSDN, or on any link I can wring out of Groups.Google, either.</p>
<p>Does someone here know? I sure hope so.</p>
<blockquote>
<p><strong>Edited to add:</strong> I mistook the
.proj file included in the tutorial
to be the .csproj file and that is what
one fed to MSBuild, but it took the answer below before I saw this.
It should have been rather obvious, but I missed it.</p>
</blockquote>
| [
{
"answer_id": 118118,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 4,
"selected": true,
"text": "msbuild.exe /?\n\nMicrosoft (R) Build Engine Version 2.0.50727.3053\n[Microsoft .NET Framework, Version 2.0.50727.3053]\nCopy... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16964/"
] |
118,092 | <p>In PHP, replace one URL with another within a string e.g. </p>
<pre><code>New post on the site <a href="http://stackoverflow.com/xyz1">http://stackoverflow.com/xyz1</a></p>
</code></pre>
<p>becomes:</p>
<pre><code>New post on the site <a href="http://yahoo.com/abc1">http://yahoo.com/abc1</a></p>
</code></pre>
<p>Must work for repeating strings as above. Appreciate this is simple but struggling!</p>
| [
{
"answer_id": 118099,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "$text = str_replace('http://stackoverflow.com/xyz1', 'http://yahoo.com/abc1', $text);\n"
},
{
"answer_id": 118101,... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
118,096 | <p>I need to be able to take a string like:</p>
<pre><code>'''foo, bar, "one, two", three four'''
</code></pre>
<p>into:</p>
<pre><code>['foo', 'bar', 'one, two', 'three four']
</code></pre>
<p>I have an feeling (with hints from #python) that the solution is going to involve the shlex module.</p>
| [
{
"answer_id": 118132,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 1,
"selected": false,
"text": ">>> import re\n>>> pattern = re.compile(r'\\s*(\"[^\"]*\"|.*?)\\s*,')\n>>> def split(line):\n... return [x[1:-1] i... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18866/"
] |
118,100 | <p>do you use a tool? or just manually make them?</p>
| [
{
"answer_id": 692737,
"author": "Chris S",
"author_id": 21574,
"author_profile": "https://Stackoverflow.com/users/21574",
"pm_score": 5,
"selected": true,
"text": "http://chart.apis.google.com/chart?\nchs=600x250& // the size of the chart\nchtt=Burndown& // Title\ncht=lc& // The chart t... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10431/"
] |
118,126 | <p>Although ASP.NET MVC seems to have all the hype these days, WebForms are still quite pervasive. How do you keep your project sane? Let's collect some tips here.</p>
| [
{
"answer_id": 118188,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 2,
"selected": false,
"text": "<div>"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/118126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] |
118,130 | <p>I'm using Windows Vista and C#.net 3.5, but I had my friend run the program on XP and has the same problem.</p>
<p>So I have a C# program that I have running in the background with an icon in the SystemTray. I have a low level keyboard hook so when I press two keys (Ctr+windows in this case) it'll pull of the application's main form. The form is set to be full screen in the combo key press even handler:</p>
<pre><code>this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
</code></pre>
<p>So it basically works. When I hit CTR+Windows it brings up the form, no matter what program I have given focus to. But sometimes, the taskbar will still show up over the form, which I don't want. I want it to always be full screen when I hit that key combo.</p>
<p>I figure it has something to do with what application has focus originally. But even when I click on my main form, the taskbar sometimes stays there. So I wonder if focus really is the problem. It just seems like sometimes the taskbar is being stubborn and doesn't want to sit behind my program.</p>
<p>Anyone have any ideas how I can fix this?</p>
<p>EDIT: More details-
I'm trying to achieve the same effect that a web browser has when you put it into fullscreen mode, or when you put powerpoint into presentation mode.</p>
<p>In a windows form you do that by putting the border style to none and maximizing the window. But sometimes the window won't cover the taskbar for some reason. Half the time it will.</p>
<p>If I have the main window topmost, the others will fall behind it when I click on it, which I don't want if the taskbar is hidden.</p>
| [
{
"answer_id": 118159,
"author": "Paul Beesley",
"author_id": 14333,
"author_profile": "https://Stackoverflow.com/users/14333",
"pm_score": 0,
"selected": false,
"text": " Rectangle screenRect = Screen.GetBounds(this);\n this.Location = screenRect.Location;\n this.Si... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13713/"
] |
118,143 | <p>Not a competition, it is instead me trying to find why a certain regex works in one but not the other.</p>
<pre><code>(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
</code></pre>
<p>That's my Regex and I'm trying to run it on</p>
<pre><code>127.255.0.0
</code></pre>
<p>Using Pythons regex I get nothing, using PHP I match it, below are the two calls I am making (just incase it's something to do with that). Essentially I am trying to work out why it works in PHP but not Python.</p>
<pre><code>re.findall(regex, string)
preg_match_all($regex, $string, $matches);
</code></pre>
<p><hr>
Solution found, it was due to the way that I was iterating through the results, this regex turned them into groups and then it didn't want to print them out in the same way etc etc. Thank you all for your help, it's really appreciated.</p>
| [
{
"answer_id": 118163,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 4,
"selected": true,
"text": ">>> re.match(r'(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] |
118,144 | <p>What's the most efficient way to select the last n number of rows in a table using mySQL? The table contains millions of rows, and at any given time I don't know how large the table is (it is constantly growing). The table does have a column that is automatically incremented and used as a unique identifier for each row.</p>
| [
{
"answer_id": 118169,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 7,
"selected": true,
"text": "SELECT * FROM table_name ORDER BY auto_incremented_id DESC LIMIT n\n"
},
{
"answer_id": 118172,
"author":... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9076/"
] |
118,190 | <p>I have a SQL script that creates a package with a comment containing an ampersand (&). When I run the script from SQL Plus, I am prompted to enter a substitute value for the string starting with &. How do I disable this feature so that SQL Plus ignores the ampersand?</p>
| [
{
"answer_id": 118210,
"author": "Austin Salonen",
"author_id": 4068,
"author_profile": "https://Stackoverflow.com/users/4068",
"pm_score": 9,
"selected": true,
"text": "set define off\n"
},
{
"answer_id": 118217,
"author": "user19387",
"author_id": 19387,
"author_pro... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20625/"
] |
118,199 | <p>I have an application where 2 threads are running... Is there any certanty that when I change a global variable from one thread, the other will notice this change?
I don't have any syncronization or Mutual exclusion system in place... but should this code work all the time (imagine a global <strong>bool</strong> named <strong>dataUpdated</strong>):</p>
<p>Thread 1:</p>
<pre><code>while(1) {
if (dataUpdated)
updateScreen();
doSomethingElse();
}
</code></pre>
<p>Thread 2:</p>
<pre><code>while(1) {
if (doSomething())
dataUpdated = TRUE;
}
</code></pre>
<p>Does a compiler like gcc optimize this code in a way that it doesn't check for the global value, only considering it value at compile time (because it nevers get changed at the same thred)?</p>
<p>PS: Being this for a game-like application, it really doen't matter if there will be a read while the value is being written... all that matters is that the change gets noticed by the other thread.</p>
| [
{
"answer_id": 118204,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 2,
"selected": false,
"text": "volatile int myInteger;\n"
},
{
"answer_id": 118266,
"author": "1800 INFORMATION",
"author_id": 3146,
... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2731698/"
] |
118,235 | <p>I run my blog using Wordpress and all too recently became a <em>big</em> believer in SCM. I really want to put my site into subversion (that's what I'm using right now, maybe git will come later) but I can't think of the correct way to do it yet. Basically, my repository is set up currently with an 'implementation' directory and a 'resources' directory, with implementation holding what will eventually be published to the live site. I want to be able to preview my site locally without having to upload to the server for obvious reasons. However, to do this I found that I needed to actually install Wordpress locally (not just copy the remote site down to my local box). This was told to me over at Wordpress.org.</p>
<p>This brings up the problem of being able to use SCM with the install because I need to upgrade my local site every now and then but this generates inconsistencies with subversion because it can’t track what’s going on because an external system is messing with it’s repository structure. That just won’t work.</p>
<p>My initial inclination is to try to just SCM my theme information as this is really the only stuff that I ‘own’ while as everything else is really just part of my platform (no different than Apache or PHP, really). However, that’s where my understanding breaks down. How can I selectively SCM only part of that directory structure, and how can I maintain the configuration of Wordpress that I’m on?</p>
<p>Anyway, I’m sure other people have tackled this and the solution is probably applicable to many apps similar to Wordpress (Drupal, phpBB, phpMyAdmin, etc.). So, how do you do it?</p>
| [
{
"answer_id": 118552,
"author": "cori",
"author_id": 8151,
"author_profile": "https://Stackoverflow.com/users/8151",
"pm_score": 1,
"selected": false,
"text": "# svn co http://svn.automattic.com/wordpress/tags/2.6.2/ (replace the current rev here for the first check out).\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/118235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16562/"
] |
118,241 | <p>I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface?</p>
<p>If it's not built-in, my only idea is to create a table of widths for each character, but this is pretty unreasonable especially supporting <a href="http://en.wikipedia.org/wiki/Unicode" rel="noreferrer">Unicode</a> and different type sizes (and all browsers for that matter).</p>
| [
{
"answer_id": 118251,
"author": "CMPalmer",
"author_id": 14894,
"author_profile": "https://Stackoverflow.com/users/14894",
"pm_score": 10,
"selected": true,
"text": "var fontSize = 12;\nvar test = document.getElementById(\"Test\");\ntest.style.fontSize = fontSize;\nvar height = (test.cl... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8119/"
] |
118,243 | <p>How can I open multiple Eclipse workspaces at the same time on the Mac?</p>
<p>On other platforms, I can just launch extra Eclipse instances, but the Mac will not let me open the same application twice. Is there a better way than keeping two copies of Eclipse?</p>
| [
{
"answer_id": 118286,
"author": "Tim Visher",
"author_id": 16562,
"author_profile": "https://Stackoverflow.com/users/16562",
"pm_score": 8,
"selected": true,
"text": "cd /Applications/eclipse/"
},
{
"answer_id": 386470,
"author": "Milhous",
"author_id": 17712,
"autho... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] |
118,260 | <p>I'm trying to teach Komodo to fire up <a href="http://en.wikipedia.org/wiki/IDLE_(Python)" rel="noreferrer">IDLE</a> when I hit the right keystrokes. I can use the exact path of the shortcut in start menu in the Windows Explorer location bar to launch IDLE so I was hoping Komodo would be able to use it as well. But, giving this path to Komodo causes it to say that 1 is returned. This appears to be a failure as IDLE doesn't start up.</p>
<p>I thought I'd avoid the shortcut and just use the exact path. I go to the start menu, find the shortcut for IDLE, right click to look at the properties. The target is grayed out, but says "Python 2.5.2". The "Start in" is set to, "C:\Python25\". The "Open File Location" button is also grayed out.</p>
<p>How do I find out where this shortcut is really pointing? I have tried starting python.exe and pythonw.exe both in C:\Python25, but neither starts up IDLE.</p>
| [
{
"answer_id": 118275,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 7,
"selected": true,
"text": "idle.py"
},
{
"answer_id": 118308,
"author": "Dara Kong",
"author_id": 11292,
"author_profile": "... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5113/"
] |
118,261 | <p>E.g. we this code in the asp.net form codebihind:</p>
<pre><code>private void btnSendEmails_OnClick()
{
Send100000EmailsAndWaitForReplies();
}
</code></pre>
<p>This code execution will be killed by the timeout reason.
For resolving the problem I'd like to see something like this:</p>
<pre><code>private void btnSendEmails_OnClick()
{
var taskId = AsyncTask.Run( () => Send100000EmailsAndWaitForReplies() );
// Store taskId for future task execution status checking.
}
</code></pre>
<p>And this method will be executed for some way outside the w3wp.exe process within a special enveronment.</p>
<p>Does anybody know a framework/toolset for resolving this kind of issues?</p>
<p><strong>Update:</strong> The emails sending method is only an example of what I mean. In fact, I could have a lot of functionality need to be executed outside the asp.net working process. </p>
<p>E.g. this point is very important for an application which aggregates data from a couple of 3rd party services, do something with it and send it back to another service.</p>
| [
{
"answer_id": 118295,
"author": "Ash",
"author_id": 5023,
"author_profile": "https://Stackoverflow.com/users/5023",
"pm_score": 0,
"selected": false,
"text": "<%@ Page Language=\"C#\" Async=\"true\" %>\n<script runat=\"server\">\n\n protected void Page_Load(object sender, EventArgs e)\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9198/"
] |
118,280 | <p>I thought I had seen a bug report about this on the jQuery site, but now I cannot find it. I'm trying to resize a dialog in IE6. But when the element is resized, the content and title bar don't resize down. They will resize up if the dialog is made larger, however. The result is that the close button ends up being cut off and the content is clipped if the user resize the dialog to be smaller. </p>
<p>I've tried handling the resizeStop event and manually resizing the content and titlebar, but this can gave me weird results. The sizes and positions of elements in the content area were still off. Also, even though I resize the title bar, the close button still doesn't move back into view. Any ideas? If this is a bug in jQuery-ui, does anyone know a good workaround?</p>
<pre><code><html>
<head>
<title>Example of IE6 resize issue</title>
<link rel="stylesheet" type="text/css" href="http://ui.jquery.com/repository/latest/themes/flora/flora.all.css" />
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
google.load("jqueryui", "1");
google.setOnLoadCallback(
function() {
$(document).ready(function()
{
$("#main-dialog").dialog();
});
});
</script>
</head>
<body>
<div id="main-dialog">
This is just some simple content that will fill the dialog. This example is
sufficient to reproduce the problem in IE6. It does not seem to occur in IE7
or FF. I haven't tried with Opera or Safari.
</div>
</body>
</html>
</code></pre>
| [
{
"answer_id": 120050,
"author": "Dave Richardson",
"author_id": 3392,
"author_profile": "https://Stackoverflow.com/users/3392",
"pm_score": 0,
"selected": false,
"text": "<html>\n<head>\n<title>Example of IE6 resize issue</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"?.css\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6118/"
] |
118,289 | <p>I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and I want it to be parsed similar to the command line arguments when passed to Getopt::Long.</p>
<p>To elaborate:</p>
<p>I have a string</p>
<pre><code>$str = '--infile /tmp/infile_location --outfile /tmp/outfile'
</code></pre>
<p>I want it to be parsed by GetOptions so that it is easier for me to add new options.</p>
<p>One workaround I could think of is to split the string on whitespace and replace @ARGV with new array and then call GetOptions. something like ...</p>
<pre><code>my @arg_arr = split (/\s/, $input_line);
# This is done so that GetOptions reads these new arguments
@ARGV = @arg_arr;
print "ARGV is : @ARGV\n";
GetOptions (
'infile=s' => \$infile,
'outfile=s' => \$outfile
);
</code></pre>
<p>Is there any good/better way?</p>
| [
{
"answer_id": 118392,
"author": "Jagmal",
"author_id": 4406,
"author_profile": "https://Stackoverflow.com/users/4406",
"pm_score": 3,
"selected": false,
"text": "GetOptionsFromArray ([glob ($input_line)]);\n"
}
] | 2008/09/22 | [
"https://Stackoverflow.com/questions/118289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4406/"
] |
118,292 | <p>So I was writing some code today that basically looks like this:</p>
<pre><code>string returnString = s.Replace("!", " ")
.Replace("@", " ")
.Replace("#", " ")
.Replace("$", " ")
.Replace("%", " ")
.Replace("^", " ")
.Replace("*", " ")
.Replace("_", " ")
.Replace("+", " ")
.Replace("=", " ")
.Replace("\", " ")
</code></pre>
<p>Which isn't really nice. I was wondering if there's a regex or something that I could write that would replace all the calls to the <code>Replace()</code> function?</p>
| [
{
"answer_id": 118306,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 6,
"selected": true,
"text": "var returnString = Regex.Replace(s,@\"[!@#\\$%\\^*_\\+=\\\\]\",\" \");\n"
},
{
"answer_id": 118314,
"author":... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] |
118,305 | <p>How can UTF-8 strings (i.e. 8-bit string) be converted to/from XML-compatible 7-bit strings (i.e. printable ASCII with numeric entities)?</p>
<p>i.e. an <code>encode()</code> function such that:</p>
<pre><code>encode("“£”") -> "&#8220;&#163;&#8221;"
</code></pre>
<p><code>decode()</code> would also be useful:</p>
<pre><code>decode("&#8220;&#163;&#8221;") -> "“£”"
</code></pre>
<p>PHP's <code>htmlenties()</code>/<code>html_entity_decode()</code> pair does not do the right thing:</p>
<pre><code>htmlentities(html_entity_decode("&#8220;&#163;&#8221;")) ->
"&amp;#8220;&pound;&amp;#8221;"
</code></pre>
<p>Laboriously specifying types helps a little, but still returns XML-incompatible named entities, not numeric ones:</p>
<pre><code>htmlentities(html_entity_decode("&#8220;&#163;&#8221;", ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8") ->
"&ldquo;&pound;&rdquo;"
</code></pre>
| [
{
"answer_id": 193057,
"author": "Kris",
"author_id": 18565,
"author_profile": "https://Stackoverflow.com/users/18565",
"pm_score": 0,
"selected": false,
"text": "iconv()"
},
{
"answer_id": 194025,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Sta... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11543/"
] |
118,307 | <p>Tools like 'ps' and 'top' report various kinds of memory usages, such as the VM size and the Resident Set Size. However, none of those are the "real" memory usage:</p>
<ul>
<li>Program code is shared between multiple instances of the same program.</li>
<li>Shared library program code is shared between all processes that use that library.</li>
<li>Some apps fork off processes and share memory with them (e.g. via shared memory segments).</li>
<li>The virtual memory system makes the VM size report pretty much useless.</li>
<li>RSS is 0 when a process is swapped out, making it not very useful.</li>
<li>Etc etc.</li>
</ul>
<p>I've found that the private dirty RSS, as reported by Linux, is the closest thing to the "real" memory usage. This can be obtained by summing all <code>Private_Dirty</code> values in <code>/proc/somepid/smaps</code>.</p>
<p>However, do other operating systems provide similar functionality? If not, what are the alternatives? In particular, I'm interested in FreeBSD and OS X.</p>
| [
{
"answer_id": 1954774,
"author": "Mecki",
"author_id": 15809,
"author_profile": "https://Stackoverflow.com/users/15809",
"pm_score": 6,
"selected": false,
"text": "sudo vmmap <pid>\n"
},
{
"answer_id": 14191692,
"author": "Arvind",
"author_id": 291917,
"author_profil... | 2008/09/22 | [
"https://Stackoverflow.com/questions/118307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20816/"
] |
118,341 | <p>I have a Linq to objects statement</p>
<pre><code> var confirm = from l in lines.Lines
where (l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber)
select l;
</code></pre>
<p>The confirm object is returning an 'Object Null or Not A Reference' at at System.Linq.Enumerable.WhereListIterator`1.MoveNext()</p>
<p>If the result of the query was empty, it would just return an empty enumerator. I know for a fact that there are no null objects in the statement. Is it possible to step through the LINQ statement to see where it is falling over?</p>
<p><strong>EDIT</strong> When I said <em>I know for a fact that there are no null objects</em> it turns out I was lying :[, but the question remains, though I am asuming the answer will be 'you can't really'</p>
<p>LINQPad is a good idea, I used it to teach myself LINQ, but I may start looking at it again as a debug / slash and burn style tool</p>
| [
{
"answer_id": 118871,
"author": "Steve Steiner",
"author_id": 3892,
"author_profile": "https://Stackoverflow.com/users/3892",
"pm_score": 4,
"selected": false,
"text": "where"
},
{
"answer_id": 716060,
"author": "Community",
"author_id": -1,
"author_profile": "https:... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] |
118,342 | <p>I am aware of this command:
<code>cvs log -N -w<userid> -d"1 day ago"</code></p>
<p>Unfortunately this generates a formatted report with lots of newlines in it, such that the file-path, the file-version, and the comment-text are all on separate lines. Therefore it is difficult to scan it for all occurrences of comment text, (eg, grep), and correlate the matches to file/version.</p>
<p>(Note that the log output would be perfectly acceptable, if only cvs could perform the filtering natively.)</p>
<p>EDIT: Sample output. A block of text like this is reported for each repository file:</p>
<pre>
RCS file: /data/cvs/dps/build.xml,v
Working file: build.xml
head: 1.49
branch:
locks: strict
access list:
keyword substitution: kv
total revisions: 57; selected revisions: 1
description:
----------------------------
revision 1.48
date: 2008/07/09 17:17:32; author: noec; state: Exp; lines: +2 -2
Fixed src.jar references
----------------------------
revision 1.47
date: 2008/07/03 13:13:14; author: noec; state: Exp; lines: +1 -1
Fixed common-src.jar reference.
=============================================================================
</pre>
| [
{
"answer_id": 118397,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<Cmd> | egrep 'Filename:|Version:|Comment:'\n"
},
{
"answer_id": 381972,
"author": "s_t_e_v_e",
"author_... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14749/"
] |
118,343 | <p>Ruby on Rails has <a href="http://wiki.rubyonrails.com/rails/pages/Timestamping" rel="nofollow noreferrer">magic timestamping fields</a> that are automatically updated when a record is created or updated. I'm trying to find similar functionality in Entity Framework. I've considered database triggers and a SavingChanges event handler. Is there a more obvious method I'm overlooking?</p>
| [
{
"answer_id": 118397,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<Cmd> | egrep 'Filename:|Version:|Comment:'\n"
},
{
"answer_id": 381972,
"author": "s_t_e_v_e",
"author_... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/453303/"
] |
118,356 | <p>I have a custom program which preprocesses a C# file and generates a new C# file as output. I would like to invoke this from msbuild on each of the C# files in the project, then compile the output files instead of the original C# files. How would I go about this?</p>
| [
{
"answer_id": 119662,
"author": "Jivko Petiov",
"author_id": 11348,
"author_profile": "https://Stackoverflow.com/users/11348",
"pm_score": 0,
"selected": false,
"text": "<Exec Command=\"your executable\" />\n"
}
] | 2008/09/23 | [
"https://Stackoverflow.com/questions/118356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13193/"
] |
118,370 | <p>This came up in <a href="https://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a>, but I can't see good documentation or examples that explain how the feature works.</p>
| [
{
"answer_id": 118395,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 8,
"selected": true,
"text": "Ellipsis"
},
{
"answer_id": 118508,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "htt... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15677/"
] |
118,371 | <p>When a class field is accessed via a getter method by multiple threads, how do you maintain thread safety? Is the synchronized keyword sufficient?</p>
<p>Is this safe:</p>
<pre><code>public class SomeClass {
private int val;
public synchronized int getVal() {
return val;
}
private void setVal(int val) {
this.val = val;
}
}
</code></pre>
<p>or does the setter introduce further complications?</p>
| [
{
"answer_id": 118388,
"author": "Cowan",
"author_id": 17041,
"author_profile": "https://Stackoverflow.com/users/17041",
"pm_score": 5,
"selected": true,
"text": " int old = someThing.getVal();\n if (old == 1) {\n someThing.setVal(2);\n }\n"
},
{
"answer_id": 118452,
"auth... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1119/"
] |
118,374 | <p>For years, maybe 10, I've been fascinated with cryptography. I read a book about XOR bit-based encryption, and have been hooked ever since thing.</p>
<p>I guess it's more fair to say that I'm fascinated by those who can break various encryption methods, but I digress.</p>
<p>To the point -- what methods do you use when writing cryptography? Is obfuscation good in cryptography? </p>
<p>I use two key-based XOR encryption, various hashing techniques (SHA1) on the keys, and simple things such as reversing strings here and there, etc.</p>
<p>I'm interested to see what others think of and try when writing a not-so-out-of-the-box encryption method. Also -- any info on how the pros go about "breaking" various cryptography techniques would be interesting as well.</p>
<p><strong>To clarify -- I have no desire to use this in any production code, or any code of mine for that matter. I'm interesting in learning how it works through toying around, not reinventing the wheel. :)</strong></p>
<p>Ian</p>
| [
{
"answer_id": 118453,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "CipherTextArray = PlainTextArray ^ KeyArray;\n"
}
] | 2008/09/23 | [
"https://Stackoverflow.com/questions/118374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10853/"
] |
118,415 | <p>My database is located in e.g. california.
My user table has all the user's timezone e.g. -0700 UTC </p>
<p>How can I adjust the time from my database server whenever I display a date to the user who lives in e.g. new york? UTC/GMT -4 hours</p>
| [
{
"answer_id": 118432,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "DateTime.ToUniversalTime() -> server;\nDateTime.ToLocalTime() -> client\n"
},
{
"answer_id": 118437,
"author": "Laur... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
118,423 | <p>I've been impressed by the screencasts for Rails that demonstrate the built-in web server, and database to allow development and testing to occur on the local machine. How can I get an instance of Apache to execute a project directory as its DocumentRoot, and maybe serve up the files on port 8080 (or something similar)?</p>
<p>The reason why I'm asking is that I'm going to be trying out CodeIgniter, and I would like to use it for multiple projects. I would rather not clutter up my machine's DocumentRoot with each one. Suggestions on how to do database migrations are also welcome.</p>
<hr />
<p>Thank you for your responses so far. I should clarify that I'm on Mac OS X. It looks like WAMP is Windows-only. Also, XAMPP looks like a great way to install Apache and many other web tools, but I don't see a way of loading up an instance to serve up a project directory. Mac OS X has both Apache and PHP installed - I'm just looking for a way to get it to serve up a project on a non-standard port.</p>
<p>I just found <a href="http://www.mamp.info/en/mamp-pro/" rel="nofollow noreferrer">MAMP Pro</a> which does what I want, but a more minimalist approach would be better if it's possible. Does anyone have a <code>httpd.conf</code> file that can be edited and dropped into a project directory?</p>
<p>Also, sorry that I just threw in that database migration question. What I'm hoping to find is something that will enable me to push schema changes onto a live server without losing the existing data. I suspect that this is difficult and highly dependent on environmental factors.</p>
| [
{
"answer_id": 118522,
"author": "Bazman",
"author_id": 18521,
"author_profile": "https://Stackoverflow.com/users/18521",
"pm_score": 2,
"selected": false,
"text": "NameVirtualHost *:80\n\n<virtualhost *:80>\nServerName site1.mydyndns.dyndns.org\nDocumentRoot /site1/documentroot\n</virtu... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] |
118,443 | <p>I have an application that tracks high scores in a game. </p>
<p>I have a <strong>user_scores</strong> table that maps a user_id to a score.</p>
<p>I need to return the 5 highest scores, but only 1 high score for any <em>specific</em> user.</p>
<p>So if user X has the 5 highest scores on a purely numerical basis, I simply return the highest one and then the next 4 user scores.</p>
<p>I have tried to use:</p>
<pre><code>SELECT user_id, score
FROM user_scores
ORDER BY score DESC
GROUP BY user_id
LIMIT 5
</code></pre>
<p>But it seems that MySQL drops any user_id with more than 1 score. </p>
| [
{
"answer_id": 118451,
"author": "JustinD",
"author_id": 12063,
"author_profile": "https://Stackoverflow.com/users/12063",
"pm_score": 0,
"selected": false,
"text": "SELECT DISTINCT(user_id), score\nFROM user_scores\nORDER BY score DESC\nLIMIT 5\n"
},
{
"answer_id": 118457,
"... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14971/"
] |
118,458 | <p>Along the lines of my previous <a href="https://stackoverflow.com/questions/118096/how-can-i-parse-a-comma-delimited-string-into-a-list-caveat">question</a>, how can i join a list of strings into a string such that values get quoted cleanly. Something like:</p>
<pre><code>['a', 'one "two" three', 'foo, bar', """both"'"""]
</code></pre>
<p>into:</p>
<pre><code>a, 'one "two" three', "foo, bar", "both\"'"
</code></pre>
<p>I suspect that the csv module will come into play here, but i'm not sure how to get the output I want.</p>
| [
{
"answer_id": 118462,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 4,
"selected": true,
"text": "csv"
},
{
"answer_id": 118625,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stacko... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18866/"
] |
118,463 | <p>We are looking to do some heavy security requirements on our project, and we need to do a lot of encryption that is highly performant.</p>
<p>I think that I know that PKI is much slower and more complex than symmetric encryption, but I can't find the numbers to back up my feelings.</p>
| [
{
"answer_id": 118481,
"author": "Cristian Ciupitu",
"author_id": 12892,
"author_profile": "https://Stackoverflow.com/users/12892",
"pm_score": 4,
"selected": false,
"text": "speed"
}
] | 2008/09/23 | [
"https://Stackoverflow.com/questions/118463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20150/"
] |
118,474 | <p>Has anybody established a good naming convention for action in MVC? I was specifically looking at ASP.net MVC but it is a general question. For instance I have an action which displays the login screen (Login) and one which process the login request from that page (LoginTest). I'm not keen on the names and I have a lot of the applicaiton left to write. </p>
| [
{
"answer_id": 120227,
"author": "Paul Shannon",
"author_id": 11503,
"author_profile": "https://Stackoverflow.com/users/11503",
"pm_score": 7,
"selected": true,
"text": "* Index - the main \"landing\" page. This is also the default endpoint.\n* List - a list of whatever \"thing\" you're ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361/"
] |
118,487 | <p>Sorry the title isn't more help. I have a database of media-file URLs that came from two sources: </p>
<p>(1) RSS feeds and (2) manual entries. </p>
<p>I want to find the ten most-recently added URLs, but a maximum of one from any feed. To simplify, table '<code>urls</code>' has columns <code>'url, feed_id, timestamp'</code>. </p>
<p><code>feed_id=''</code> for any URL that was entered manually.</p>
<p>How would I write the query? Remember, I want the ten most-recent urls, but only one from any single <code>feed_id</code>.</p>
| [
{
"answer_id": 118523,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 0,
"selected": false,
"text": " (SELECT \n url, feed_id, timestamp \n FROM rss_items \n GROUP BY feed_id \n ORDER BY timestamp DESC \n ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17307/"
] |
118,490 | <p>Can anyone recommend a cheap and good RTF control for .Net 1.1 Windows development. It needs to be able to do print/preview and some basic text formatting, fonts etc but nothing too advanced.</p>
<p>Cheers</p>
<p>Andreas</p>
| [
{
"answer_id": 118523,
"author": "Aeon",
"author_id": 13289,
"author_profile": "https://Stackoverflow.com/users/13289",
"pm_score": 0,
"selected": false,
"text": " (SELECT \n url, feed_id, timestamp \n FROM rss_items \n GROUP BY feed_id \n ORDER BY timestamp DESC \n ... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
118,501 | <p>If I was, for example, going to <em>count</em> "activities" across many computers and show a rollup of that activity, what would the database look like to store the data? </p>
<p>Simply this? Seems too simple. I'm overthinking this.</p>
<pre><code>ACTIVITYID COUNT
---------- -----
</code></pre>
| [
{
"answer_id": 118672,
"author": "Guy Starbuck",
"author_id": 2194,
"author_profile": "https://Stackoverflow.com/users/2194",
"pm_score": 4,
"selected": true,
"text": "LOGID (PK) ACTIVITYID SOURCE DATELOGGED\n---------- ---------- ------ ----------\n"
}
] | 2008/09/23 | [
"https://Stackoverflow.com/questions/118501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6380/"
] |
118,506 | <p>The question is a fairly open one. I've been using Stored Procs with MS SQLServer for some time with classic ASP and ASP.net and love them, lots.</p>
<p>I have a small hobby project I'm working on and for various reasons have gone the LAMP route. Any hints/tricks/traps or good starting points to get into using stored procedures with MySQL and PHP5? My version of MySQL supports Stored Procedures.</p>
| [
{
"answer_id": 118582,
"author": "Gleb Popoff",
"author_id": 18076,
"author_profile": "https://Stackoverflow.com/users/18076",
"pm_score": 2,
"selected": false,
"text": "$mysqli = new MySQLI(user,pass,db);\n\n$result = $mysqli->query(\"CALL sp_mysp()\");\n"
},
{
"answer_id": 1202... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4665/"
] |
118,516 | <p>My issue is below but would be interested comments from anyone with experience with xlrd.</p>
<p>I just found xlrd and it looks like the perfect solution but I'm having a little problem getting started. I am attempting to extract data programatically from an Excel file I pulled from Dow Jones with current components of the Dow Jones Industrial Average (link: <a href="http://www.djindexes.com/mdsidx/?event=showAverages" rel="nofollow noreferrer">http://www.djindexes.com/mdsidx/?event=showAverages</a>)</p>
<p>When I open the file unmodified I get a nasty BIFF error (binary format not recognized)</p>
<p>However you can see in this screenshot that Excel 2008 for Mac thinks it is in 'Excel 1997-2004' format (screenshot: <a href="http://skitch.com/alok/ssa3/componentreport-dji.xls-properties" rel="nofollow noreferrer">http://skitch.com/alok/ssa3/componentreport-dji.xls-properties</a>)</p>
<p>If I instead open it in Excel manually and save as 'Excel 1997-2004' format explicitly, then open in python usig xlrd, everything is wonderful. Remember, Office thinks the file is already in 'Excel 1997-2004' format. All files are .xls</p>
<p>Here is a pastebin of an ipython session replicating the issue: <a href="http://pastie.textmate.org/private/jbawdtrvlrruh88mzueqdq" rel="nofollow noreferrer">http://pastie.textmate.org/private/jbawdtrvlrruh88mzueqdq</a></p>
<p>Any thoughts on:
How to trick xlrd into recognizing the file so I can extract data?
How to use python to automate the explicit 'save as' format to one that xlrd will accept?
Plan B?</p>
| [
{
"answer_id": 118803,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": -1,
"selected": false,
"text": "import pyExcelerator\nbook = pyExcelerator.parse_xls('DJIAMovers.xls')\n"
},
{
"answer_id": 125001,
"autho... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
118,526 | <p>How do you support optimistic / pessimistic concurrency using NHibernate?</p>
| [
{
"answer_id": 118539,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 5,
"selected": true,
"text": "ISession.Lock()"
}
] | 2008/09/23 | [
"https://Stackoverflow.com/questions/118526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
118,528 | <h2>I've actually solved this, but I'm posting it for posterity.</h2>
<p>I ran into a very odd issue with the DataGridView on my dual-monitor system. The issue manifests itself as an EXTREMELY slow repaint of the control (<em>like 30 seconds for a full repaint</em>), but only when it is on one of my screens. When on the other, the repaint speed is fine.</p>
<p>I have an Nvidia 8800 GT with the latest non-beta drivers (175. something). Is it a driver bug? I'll leave that up in the air, since I have to live with this particular configuration. (It does not happen on ATI cards, though...)</p>
<p>The paint speed has nothing to do with the cell contents, and custom drawing doesn't improve the performance at all - even when just painting a solid rectangle.</p>
<p>I later find out that placing a ElementHost (from the System.Windows.Forms.Integration namespace) on the form corrects the problem. It doesn't have to be messed with; it just needs to be a child of the form the DataGridView is also on. It can be resized to (0, 0) as long as the <em>Visible</em> property is true.</p>
<p>I don't want to explicitly add the .NET 3/3.5 dependency to my application; I make a method to create this control at runtime (if it can) using reflection. It works, and at least it fails gracefully on machines that don't have the required library - it just goes back to being slow.</p>
<p>This method also lets me apply to fix while the app is running, making it easier to see what the WPF libraries are changing on my form (using Spy++).</p>
<p>After a lot of trial and error, I notice that enabling double buffering on the control itself (as opposed to just the form) corrects the issue!</p>
<hr>
<p>So, you just need to make a custom class based off of DataGridView so you can enable its DoubleBuffering. That's it!</p>
<pre><code>class CustomDataGridView: DataGridView
{
public CustomDataGridView()
{
DoubleBuffered = true;
}
}
</code></pre>
<p>As long as all of my instances of the grid are using this custom version, all is well. If I ever run into a situation caused by this where I'm not able to use the subclass solution (if I don't have the code), I suppose I could try to inject that control onto the form :) (<em>although I'll be more likely to try using reflection to force the DoubleBuffered property on from the outside to once again avoid the dependency</em>).</p>
<p>It is sad that such a trivially simple thing ate up so much of my time...</p>
| [
{
"answer_id": 157386,
"author": "Benoit",
"author_id": 10703,
"author_profile": "https://Stackoverflow.com/users/10703",
"pm_score": 7,
"selected": true,
"text": "\nclass CustomDataGridView: DataGridView\n{\n public CustomDataGridView()\n {\n DoubleBuffered = true;\n } \... | 2008/09/23 | [
"https://Stackoverflow.com/questions/118528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5927/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.