qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
547,552
<p>I've got a table of keywords that I regularly refresh against a remote search API, and I have another table that gets a row each each time I refresh one of the keywords. I use this table to block multiple processes from stepping on each other and refreshing the same keyword, as well as stat collection. So when I spi...
[ { "answer_id": 547604, "author": "Kristen", "author_id": 65703, "author_profile": "https://Stackoverflow.com/users/65703", "pm_score": 0, "selected": false, "text": "<p>Dunno about MySQL but in MSSQL the lines of attack I would take are:</p>\n\n<p>1) Create a covering index on KeywordsRe...
2009/02/13
[ "https://Stackoverflow.com/questions/547552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got a table of keywords that I regularly refresh against a remote search API, and I have another table that gets a row each each time I refresh one of the keywords. I use this table to block multiple processes from stepping on each other and refreshing the same keyword, as well as stat collection. So when I spin u...
It seems your most selective index on `Keywords` is one on `KeywordRequest.created`. Try to rewrite query this way: ``` SELECT Keyword.id, Keyword.keyword FROM `keywords` as Keyword LEFT OUTER JOIN ( SELECT * FROM `keywords_requests` as kr WHERE created > FROM_UNIXTIME(1234567890) /* Happy unix_time! */ ) AS Ke...
547,575
<p>Will calling close on my WCF service kill all resources or set them up for GC or should I set it to null also?</p>
[ { "answer_id": 547593, "author": "MichaelGG", "author_id": 27012, "author_profile": "https://Stackoverflow.com/users/27012", "pm_score": 0, "selected": false, "text": "<p>You only need to set a variable to null if it's going to be reachable for a long time afterwards. Say, a field on a l...
2009/02/13
[ "https://Stackoverflow.com/questions/547575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39677/" ]
Will calling close on my WCF service kill all resources or set them up for GC or should I set it to null also?
Firstly, WCF proxies are `IDisposable`, so you can *kind of* use `using`: ``` using(var proxy = new MyProxy()) { // see below - not quite enough // use proxy } ``` **Unfortunately**, WCF also has a buggy `Dispose()` implementation that regularly throws exceptions. However, [here's a really cool trick](http://www....
547,598
<p>I want to rewrite this query so that if @UserName gets passed in a null value then it leaves the Client_User out of the search criteria. I only want it to search by name if the user enters a name in the username textbox on the webform. I'm not sure how to do this.</p> <pre><code>select * from weblogs.dbo.vwlogs ...
[ { "answer_id": 547606, "author": "Carlton Jenke", "author_id": 1215, "author_profile": "https://Stackoverflow.com/users/1215", "pm_score": 0, "selected": false, "text": "<pre><code>select * \nfrom weblogs.dbo.vwlogs \nwhere Log_time between @BeginDate and @EndDAte \n and (client_user=@U...
2009/02/13
[ "https://Stackoverflow.com/questions/547598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to rewrite this query so that if @UserName gets passed in a null value then it leaves the Client\_User out of the search criteria. I only want it to search by name if the user enters a name in the username textbox on the webform. I'm not sure how to do this. ``` select * from weblogs.dbo.vwlogs where Log_time ...
select \* from weblogs.dbo.vwlogs where Log\_time between @BeginDate and @EndDAte and **(@UserName IS NULL OR client\_user=@UserName)**
547,599
<p>I've written a java application that utilizes JAXB for XSL transforms. I've included the saxon9.jar in my classpath so that I can use XSLT 2.0 rather than XSLT 1.0 on the command line.</p> <pre><code>java -classpath ./lib/saxon9.jar:./ -jar myApp.jar </code></pre> <p>I've included code in my XSL to report the XSL...
[ { "answer_id": 547656, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 2, "selected": false, "text": "<p>Have you tried placing your jar in the <a href=\"http://java.sun.com/j2se/1.4.2/docs/guide/standards/\" rel=\"nofo...
2009/02/13
[ "https://Stackoverflow.com/questions/547599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
I've written a java application that utilizes JAXB for XSL transforms. I've included the saxon9.jar in my classpath so that I can use XSLT 2.0 rather than XSLT 1.0 on the command line. ``` java -classpath ./lib/saxon9.jar:./ -jar myApp.jar ``` I've included code in my XSL to report the XSLT used. ``` <xsl:comment><...
Have you tried placing your jar in the [endorsed](http://java.sun.com/j2se/1.4.2/docs/guide/standards/) directory? If you don't want the effect to be global, use the following option: ``` -Djava.endorsed.dirs=my_dir ``` in the command line.
547,611
<p>I am trying to replace multiple rows in an Access database to follow a new set of data rules. For instance, the word Fort in Fort Myers is listed as Ft., Ft and Fort. I would like to make a global change to the group. I am familiar with the SQL replace command, but wondering if anyone has done something similar w...
[ { "answer_id": 547656, "author": "kgiannakakis", "author_id": 24054, "author_profile": "https://Stackoverflow.com/users/24054", "pm_score": 2, "selected": false, "text": "<p>Have you tried placing your jar in the <a href=\"http://java.sun.com/j2se/1.4.2/docs/guide/standards/\" rel=\"nofo...
2009/02/13
[ "https://Stackoverflow.com/questions/547611", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37126/" ]
I am trying to replace multiple rows in an Access database to follow a new set of data rules. For instance, the word Fort in Fort Myers is listed as Ft., Ft and Fort. I would like to make a global change to the group. I am familiar with the SQL replace command, but wondering if anyone has done something similar with a ...
Have you tried placing your jar in the [endorsed](http://java.sun.com/j2se/1.4.2/docs/guide/standards/) directory? If you don't want the effect to be global, use the following option: ``` -Djava.endorsed.dirs=my_dir ``` in the command line.
547,622
<p>First of all, I swear this is not homework, it's a question I was asked in an interview. I think I made a mess of it (though I did realise the solution requires recursion). Here is the question:</p> <p>Implement the count() method which returns the number of nodes in a tree. If a node doesn't have either a left or ...
[ { "answer_id": 547636, "author": "David Hanak", "author_id": 42136, "author_profile": "https://Stackoverflow.com/users/42136", "pm_score": 4, "selected": false, "text": "<p>A trivial recursive solution:</p>\n\n<pre><code>int count() {\n Tree l = getLeftTree();\n Tree r = getRightTree...
2009/02/13
[ "https://Stackoverflow.com/questions/547622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
First of all, I swear this is not homework, it's a question I was asked in an interview. I think I made a mess of it (though I did realise the solution requires recursion). Here is the question: Implement the count() method which returns the number of nodes in a tree. If a node doesn't have either a left or right chil...
``` int count() { Tree right = getRightChild(); Tree left = getLeftChild(); int c = 1; // count yourself! if ( right != null ) c += right.count(); // count sub trees if ( left != null ) c += left.count(); // .. return c; } ```
547,625
<h3>The Problem</h3> <p>When using asp.net server controls id attributes such as the following are automatically generated.</p> <pre><code>&lt;img id=&quot;ctl00_body_ULRepeater_ctl01_LIRepeater_ctl00_PartImg&quot; src=&quot;img.png&quot; /&gt; </code></pre> <p>While I'm not averse to id attributes in general, I try to...
[ { "answer_id": 547648, "author": "Jim Petkus", "author_id": 38053, "author_profile": "https://Stackoverflow.com/users/38053", "pm_score": 3, "selected": true, "text": "<p>I believe that one of the features coming in asp.net 4.0 will be the ability to better control the IDs that are gener...
2009/02/13
[ "https://Stackoverflow.com/questions/547625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/208/" ]
### The Problem When using asp.net server controls id attributes such as the following are automatically generated. ``` <img id="ctl00_body_ULRepeater_ctl01_LIRepeater_ctl00_PartImg" src="img.png" /> ``` While I'm not averse to id attributes in general, I try to stay away from using these unnecessarily verbose type...
I believe that one of the features coming in asp.net 4.0 will be the ability to better control the IDs that are generated. For now, you are going to get the name mangling for any server generated control. This is what allows asp.net to guarantee the uniqueness of your control's ID. You can always use straight HTML ma...
547,629
<p>I've got some SQL which performs complex logic on combinations of GL account numbers and cost centers like this:</p> <pre><code>WHEN (@IntGLAcct In ( 882001, 882025, 83000154, 83000155, 83000120, 83000130, 83000140, 83000157, 83000010, 83000159, 83000160, 83000161, 83000162, 83000011, 83000166, 83000168, 8...
[ { "answer_id": 547672, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 0, "selected": false, "text": "<p>What if you used a conditional split transform on your incoming data set and then used expressions or something similar (I'm...
2009/02/13
[ "https://Stackoverflow.com/questions/547629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
I've got some SQL which performs complex logic on combinations of GL account numbers and cost centers like this: ``` WHEN (@IntGLAcct In ( 882001, 882025, 83000154, 83000155, 83000120, 83000130, 83000140, 83000157, 83000010, 83000159, 83000160, 83000161, 83000162, 83000011, 83000166, 83000168, 83000169, 82504...
Try this: ``` Array.IndexOf(New Integer() {90605, 90607, 90610}, IntGLAcct) >-1 ```
547,634
<p>I am interacting with a web server using a desktop client program in C# and .Net 3.5. I am using Fiddler to see what traffic the web browser sends, and emulate that. Sadly this server is old, and is a bit confused about the notions of charsets and utf-8. Mostly it uses Latin-1.</p> <p>When I enter data into the Web...
[ { "answer_id": 547663, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 4, "selected": false, "text": "<p>Rich Strahl just posted a blog post, <a href=\"http://west-wind.com/weblog/posts/617930.aspx\" rel=\"noreferrer\">Html and...
2009/02/13
[ "https://Stackoverflow.com/questions/547634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5599/" ]
I am interacting with a web server using a desktop client program in C# and .Net 3.5. I am using Fiddler to see what traffic the web browser sends, and emulate that. Sadly this server is old, and is a bit confused about the notions of charsets and utf-8. Mostly it uses Latin-1. When I enter data into the Web browser c...
It seems horribly inefficient, but the only way I can think to do that is to look through each character: ``` public static string MyHtmlEncode(string value) { // call the normal HtmlEncode first char[] chars = HttpUtility.HtmlEncode(value).ToCharArray(); StringBuilder encodedValue = new StringBuilder(); f...
547,658
<p>Good day,</p> <p>In visual studio 2005, when I drop a webcontrol in the designer, I have to manually set the CssClass property. Is there a way to automatically set that property? The thing is, 90% of the time, I want to apply a css to my controls, but not always, so I cannot really use css style in html head. I tho...
[ { "answer_id": 547671, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 0, "selected": false, "text": "<p>Take a look at the laughably-named-but-still-an-improvement <a href=\"http://www.asp.net/CssAdapters/\" rel=\"nofollow...
2009/02/13
[ "https://Stackoverflow.com/questions/547658", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42848/" ]
Good day, In visual studio 2005, when I drop a webcontrol in the designer, I have to manually set the CssClass property. Is there a way to automatically set that property? The thing is, 90% of the time, I want to apply a css to my controls, but not always, so I cannot really use css style in html head. I thought about...
I would think another way to achieve this (and because they are being applied 90% of the time) is by applying them as the default in your css file: ie for a button ``` #page input { color: #454545; border: 1px solid #cccccc; width: 98%; } ``` and then only set the CssClass to the ones that you don't want ``` .Rand...
547,665
<p>In the most recent version (4.1, released October 2008) of The Microsoft Enterprise Library's Exception Handling Application Block, there are two HandleException() method signatures, and I am a bit lost on the intent for these, especially since neither the documentation, intellisense, nor the QuickStart apps intimat...
[ { "answer_id": 944169, "author": "Paul Berry", "author_id": 116523, "author_profile": "https://Stackoverflow.com/users/116523", "pm_score": 3, "selected": true, "text": "<p>If you use a replace handler in the enterprise library config, your replacement exception is returned by means of t...
2009/02/13
[ "https://Stackoverflow.com/questions/547665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1790/" ]
In the most recent version (4.1, released October 2008) of The Microsoft Enterprise Library's Exception Handling Application Block, there are two HandleException() method signatures, and I am a bit lost on the intent for these, especially since neither the documentation, intellisense, nor the QuickStart apps intimate a...
If you use a replace handler in the enterprise library config, your replacement exception is returned by means of the second signature .. , out Exception exceptionToThrow).
547,668
<p>Here's the situation:</p> <p>We have some generic graphics code that we use for one of our projects. After doing some clean-up of the code, it seems like something isn't working anymore (The graphics output looks completely wrong).</p> <p>I ran a diff against the last version of the code that gave the correct out...
[ { "answer_id": 547680, "author": "Daniel LeCheminant", "author_id": 62055, "author_profile": "https://Stackoverflow.com/users/62055", "pm_score": 6, "selected": true, "text": "<p>Sounds like you don't have sufficient unit tests :]</p>\n\n<p>Unfortunately, your statement </p>\n\n<p>\"Noth...
2009/02/13
[ "https://Stackoverflow.com/questions/547668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66258/" ]
Here's the situation: We have some generic graphics code that we use for one of our projects. After doing some clean-up of the code, it seems like something isn't working anymore (The graphics output looks completely wrong). I ran a diff against the last version of the code that gave the correct output, and it looks ...
Sounds like you don't have sufficient unit tests :] Unfortunately, your statement "Nothing in the code has changed except for some syntactic shortcuts" is wrong, and I'm guessing that's where your problem is. (It's certainly one of your problems!) Yes, ``` a *= b; ``` is equivalent to ``` a = a * b; ``` bu...
547,670
<p>I have a query that runs each night on a table with a bunch of records (200,000+). This application simply iterates over the results (using a DbDataReader in a C# app if that's relevant) and processes each one. The processing is done outside of the database altogether. During the time that the application is iter...
[ { "answer_id": 547698, "author": "cmsjr", "author_id": 23114, "author_profile": "https://Stackoverflow.com/users/23114", "pm_score": 1, "selected": false, "text": "<p>It depends what Isolation Level you are using. You might try doing your selects using the With (NoLock) hint, that will ...
2009/02/13
[ "https://Stackoverflow.com/questions/547670", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26302/" ]
I have a query that runs each night on a table with a bunch of records (200,000+). This application simply iterates over the results (using a DbDataReader in a C# app if that's relevant) and processes each one. The processing is done outside of the database altogether. During the time that the application is iterating ...
If you're using SQL Server 2005+, then how about giving the new MVCC snapshot isolation a try. I've had good results with it: ``` ALTER DATABASE SET SINGLE_USER WITH ROLLBACK IMMEDIATE; ALTER DATABASE SET READ_COMMITTED_SNAPSHOT ON; ALTER DATABASE SET MULTI_USER; ``` It will stop readers blocking writers and vic...
547,679
<p>I came across this line in some code and can't find the syntax defined anywhere:</p> <pre><code>*(float *)csCoord.nX = lImportHeight* .04f; /* magic number to scale font size */ </code></pre> <p>If I remove the <code> f </code> from <code> .04f </code> then the compiler gives a warning about possible data loss due...
[ { "answer_id": 547688, "author": "Ryan Graham", "author_id": 62525, "author_profile": "https://Stackoverflow.com/users/62525", "pm_score": 4, "selected": true, "text": "<p>The trailing f indicates to the compiler that it is a float type literal, just like \"\" indicate a literal string a...
2009/02/13
[ "https://Stackoverflow.com/questions/547679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35767/" ]
I came across this line in some code and can't find the syntax defined anywhere: ``` *(float *)csCoord.nX = lImportHeight* .04f; /* magic number to scale font size */ ``` If I remove the `f` from `.04f` then the compiler gives a warning about possible data loss due to a conversion from 'double' to 'float'. I ass...
The trailing f indicates to the compiler that it is a float type literal, just like "" indicate a literal string and the L suffix indicates a long int. The [C++ spec for literals](http://cpp.comsci.us/etymology/literals.html) is the same.
547,684
<p>My table has a timestamp column named "RowVer" which LINQ maps to type System.Data.Linq.Binary. This data type seems useless to me because (unless I'm missing something) I can't do things like this:</p> <pre><code>// Select all records that changed since the last time we inserted/updated. IEnumerable&lt;UserSession...
[ { "answer_id": 547706, "author": "B Z", "author_id": 25020, "author_profile": "https://Stackoverflow.com/users/25020", "pm_score": 3, "selected": true, "text": "<blockquote>\n <blockquote>\n <p>// Select all records that changed since the last time we inserted/updated.</p>\n \n ...
2009/02/13
[ "https://Stackoverflow.com/questions/547684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16387/" ]
My table has a timestamp column named "RowVer" which LINQ maps to type System.Data.Linq.Binary. This data type seems useless to me because (unless I'm missing something) I can't do things like this: ``` // Select all records that changed since the last time we inserted/updated. IEnumerable<UserSession> rows = db.UserS...
> > > > > > // Select all records that changed since the last time we inserted/updated. > > > > > > Is there a better work-around? > > > > > > > > > Why not have two columns, one for createddate another for lastmodifieddate. I would say that is more traditional way to handle this scenario.
547,691
<p>The idea being that, once the brightness passes a certain level, one could switch to a different visual scheme to give greater visibility. Also, if it could be some sort of listener type thing, that would be even better, but I'll take what I can get. </p>
[ { "answer_id": 547733, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>I am not a mac guy, but does /proc exist in the filesystem? You might want to look in that virtual file directory if it e...
2009/02/13
[ "https://Stackoverflow.com/questions/547691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
The idea being that, once the brightness passes a certain level, one could switch to a different visual scheme to give greater visibility. Also, if it could be some sort of listener type thing, that would be even better, but I'll take what I can get.
epatel was pretty close, I just had to change the AppleGraphicsControlBacklight keyword to something else to get it to work on my macbook, so I'd guess that this is something that might change between OSX versions and/or macbook versions. I threw together a short ruby script to print out a little visual indicator on t...
547,693
<p>I have a query that searches by date. the dates in the database include the time. How do I search on just the date only. </p> <pre><code>select * from weblogs.dbo.vwlogs where Log_time between @BeginDate and @EndDAte and (client_user=@UserName or @UserName Is null) order by Log_time desc </code></pre> <p...
[ { "answer_id": 547725, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "<p>Leave your sql mostly as is and just fix your parameters:</p>\n\n<pre><code>cmd.Parameters.Add(\"@BeginDate\", SqlD...
2009/02/13
[ "https://Stackoverflow.com/questions/547693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a query that searches by date. the dates in the database include the time. How do I search on just the date only. ``` select * from weblogs.dbo.vwlogs where Log_time between @BeginDate and @EndDAte and (client_user=@UserName or @UserName Is null) order by Log_time desc ``` ``` cmd.Parameters.AddWithVa...
Leave your sql mostly as is and just fix your parameters: ``` cmd.Parameters.Add("@BeginDate", SqlDbType.DateTime).Value = DateTime.Parse(txtBeginDate.Text).Date; cmd.Parameters.Add("@EndDAte", SqlDbType.DateTime).Value = // add one to make search inclusive DateTime.Parse(txtEndDate.Text).Date.AddDa...
547,710
<p>Syntactic sugar, IMHO, generally makes programs much more readable and easier to understand than coding from a very minimalistic set of primitives. I don't really see a downside to good, well thought out syntactic sugar. Why do some people basically think that syntactic sugar is at best superfluous and at worst so...
[ { "answer_id": 547726, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 1, "selected": false, "text": "<p>Possibly because it leads to confusion in programmers who don't know what is really happening behind the scenes, which coul...
2009/02/13
[ "https://Stackoverflow.com/questions/547710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
Syntactic sugar, IMHO, generally makes programs much more readable and easier to understand than coding from a very minimalistic set of primitives. I don't really see a downside to good, well thought out syntactic sugar. Why do some people basically think that syntactic sugar is at best superfluous and at worst somethi...
Syntactic sugar can in some cases interact in unpleasant ways. some specific examples: The first is c# (or java) specific, Auto boxing and the lock/synchronized construct ``` private int i; private object o = new object(); private void SomethingNeedingLocking(bool b) { object lk = b ? i : o; lock (lk) { /* ...
547,716
<p>At the beginning of my app, I am initializing a UIViewController with a NIB.</p> <p>At some point, I am removing the view from the screen, then releasing it, so it no longer takes up memory. (At this point I am also saving the state of the view in the UIViewController)</p> <p>At a later point, I want to recreate ...
[ { "answer_id": 547781, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 3, "selected": true, "text": "<p>If you need that level of control, you dont really want to use IB. Because, as you noted, if remove the view and the...
2009/02/13
[ "https://Stackoverflow.com/questions/547716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48311/" ]
At the beginning of my app, I am initializing a UIViewController with a NIB. At some point, I am removing the view from the screen, then releasing it, so it no longer takes up memory. (At this point I am also saving the state of the view in the UIViewController) At a later point, I want to recreate the view and bring...
If you need that level of control, you dont really want to use IB. Because, as you noted, if remove the view and then later recreate it, you would have to do it in code then anyway. Just design most of the views in IB, then write some code that generates just this view. Then you can call that same method again later to...
547,719
<p>So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would only have to type</p> <pre><code>mv foo.c ~/bar/baz/ </code></pre> <p>and everything would work out? It seems like y...
[ { "answer_id": 547736, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 4, "selected": false, "text": "<p>You can use <code>mkdir</code>:</p>\n<pre><code>mkdir -p ~/bar/baz/ &amp;&amp; \\\nmv foo.c ~/bar/baz/\n</code></pre>\n...
2009/02/13
[ "https://Stackoverflow.com/questions/547719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85/" ]
So, if I'm in my home directory and I want to move foo.c to ~/bar/baz/foo.c , but those directories don't exist, is there some way to have those directories automatically created, so that you would only have to type ``` mv foo.c ~/bar/baz/ ``` and everything would work out? It seems like you could alias mv to a sim...
How about this one-liner (in bash): ``` mkdir --parents ./some/path/; mv yourfile.txt $_ ``` Breaking that down: ```sh mkdir --parents ./some/path # if it doesn't work; try mkdir -p ./some/path ``` creates the directory (including all intermediate directories), after which: ``` mv yourfile.txt $_ ``` moves the...
547,720
<p>I've been playing around lately with SQL Data Services. Although (or perhaps because) I can knock out a well-structured relational database in my sleep, I'm struggling to get my head round how to design a performant database in an environment that has (for example) no enforcement of referential integrity and no inde...
[ { "answer_id": 547736, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 4, "selected": false, "text": "<p>You can use <code>mkdir</code>:</p>\n<pre><code>mkdir -p ~/bar/baz/ &amp;&amp; \\\nmv foo.c ~/bar/baz/\n</code></pre>\n...
2009/02/13
[ "https://Stackoverflow.com/questions/547720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15825/" ]
I've been playing around lately with SQL Data Services. Although (or perhaps because) I can knock out a well-structured relational database in my sleep, I'm struggling to get my head round how to design a performant database in an environment that has (for example) no enforcement of referential integrity and no indexes...
How about this one-liner (in bash): ``` mkdir --parents ./some/path/; mv yourfile.txt $_ ``` Breaking that down: ```sh mkdir --parents ./some/path # if it doesn't work; try mkdir -p ./some/path ``` creates the directory (including all intermediate directories), after which: ``` mv yourfile.txt $_ ``` moves the...
547,739
<p>I would like to serve /foo and /foo/ locally, but proxy requests for /foo/* to a remote server. However, the following rule matches all of the above. What am I doing wrong?</p> <pre><code>RewriteRule ^/foo/(.+)$ http://remote.host/$1 [P,L] </code></pre>
[ { "answer_id": 547776, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 0, "selected": false, "text": "<p>Well, since mod_rewrite normally strips leading slashes from the matched text, I suspect you're either transcribing/anony...
2009/02/13
[ "https://Stackoverflow.com/questions/547739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to serve /foo and /foo/ locally, but proxy requests for /foo/\* to a remote server. However, the following rule matches all of the above. What am I doing wrong? ``` RewriteRule ^/foo/(.+)$ http://remote.host/$1 [P,L] ```
You will need to escape for the first couple of conditions so that they don't all send them off to the remote host. Try this: ``` RewriteEngine On RewriteRule ^foo$ /$1 [L] RewriteRule ^foo/$ /$1 [L] RewriteRule ^foo/([a-zA-Z0-9].*)$ http://example.com/$1 [L] ``` First rule checks the first condition to be plainly `...
547,769
<p>I have a database that uses natural keys (i.e. business oriented keys). Unfortunately, because of this, the primary keys for these objects may change over time. </p> <p>I am currently researching the use of NHibernate for an O/RM for this database. However, in my testing I have noticed that there is no apparent way...
[ { "answer_id": 547940, "author": "RKitson", "author_id": 16947, "author_profile": "https://Stackoverflow.com/users/16947", "pm_score": 0, "selected": false, "text": "<p>Have you tried using a <a href=\"http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html#mappin...
2009/02/13
[ "https://Stackoverflow.com/questions/547769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4307/" ]
I have a database that uses natural keys (i.e. business oriented keys). Unfortunately, because of this, the primary keys for these objects may change over time. I am currently researching the use of NHibernate for an O/RM for this database. However, in my testing I have noticed that there is no apparent way to change...
I'm actually kicking myself that I even asked this question because I can easily mitigate this by doing a delete-insert type of operation. This was more of a proof-of-concept with an existing database. Thanks for your input!
547,777
<p>What is the best way to do this in Access?</p> <pre><code>Create table tmp ( plant int, material vchar(20), workcenter int, setuptime vchar(20) ) insert into tmp values( 1, mat1, 2, 30) insert into tmp values( 1, mat1, 3, 30) insert into tmp values( 1, mat2, 3, 30) insert into tmp values( 1, mat2, 4, 30) i...
[ { "answer_id": 547784, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "<p>I don't know access syntax well enough to give you a complete answer, but for help with your own investigations I c...
2009/02/13
[ "https://Stackoverflow.com/questions/547777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2526/" ]
What is the best way to do this in Access? ``` Create table tmp ( plant int, material vchar(20), workcenter int, setuptime vchar(20) ) insert into tmp values( 1, mat1, 2, 30) insert into tmp values( 1, mat1, 3, 30) insert into tmp values( 1, mat2, 3, 30) insert into tmp values( 1, mat2, 4, 30) insert into tmp...
From what I understand of the problem you want to solve I don't think it's feasible using a standard SQL query (at least not in Access). I tried to hack some code that does what you want (I think). **How to use it** Just copy/paste the code below in a VBA module. From code, or, from the VBA IDE Immediate window i...
547,791
<p>Whatever is inside finally blocks is executed (almost) always, so what's the difference between enclosing code into it or leaving it unclosed?</p>
[ { "answer_id": 547792, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 4, "selected": false, "text": "<p>Because finally will get executed even if you do not handle an exception in a catch block.</p>\n" }, { "ans...
2009/02/13
[ "https://Stackoverflow.com/questions/547791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14006/" ]
Whatever is inside finally blocks is executed (almost) always, so what's the difference between enclosing code into it or leaving it unclosed?
The code inside a finally block will get executed regardless of whether or not there is an exception. This comes in very handy when it comes to certain housekeeping functions you need to always run like closing connections. Now, I'm *guessing* your question is why you should do this: ``` try { doSomething(); } c...
547,796
<p>Here's the issue. I'm using ASP.NET Forms Authentication for an account balance type website. Once a user logs in, they are able to make a payment against their account by going to a 3rd party website (3pw). When the user clicks to make a payment, this is what happens:</p> <ol> <li>My website makes a request to the...
[ { "answer_id": 547792, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 4, "selected": false, "text": "<p>Because finally will get executed even if you do not handle an exception in a catch block.</p>\n" }, { "ans...
2009/02/13
[ "https://Stackoverflow.com/questions/547796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9809/" ]
Here's the issue. I'm using ASP.NET Forms Authentication for an account balance type website. Once a user logs in, they are able to make a payment against their account by going to a 3rd party website (3pw). When the user clicks to make a payment, this is what happens: 1. My website makes a request to the 3pw passing ...
The code inside a finally block will get executed regardless of whether or not there is an exception. This comes in very handy when it comes to certain housekeeping functions you need to always run like closing connections. Now, I'm *guessing* your question is why you should do this: ``` try { doSomething(); } c...
547,797
<p>Is there a way in Vim (or a plugin) to search for a term and iterate through the search results (as per <code>n</code> in Vim), by column, rather than row? So if my file was this:</p> <pre><code>foo1 bar bar baz baz foo3 baz baz foo4 foo2 bar bar </code></pre> <p>If I search for <code>foo</code> I w...
[ { "answer_id": 548185, "author": "yungchin", "author_id": 25756, "author_profile": "https://Stackoverflow.com/users/25756", "pm_score": 2, "selected": false, "text": "<p>EDIT: I just found an overview of using vim regular expressions for tables <a href=\"http://www.geocities.com/volontir...
2009/02/13
[ "https://Stackoverflow.com/questions/547797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23070/" ]
Is there a way in Vim (or a plugin) to search for a term and iterate through the search results (as per `n` in Vim), by column, rather than row? So if my file was this: ``` foo1 bar bar baz baz foo3 baz baz foo4 foo2 bar bar ``` If I search for `foo` I want to iterate through the results in order 1,2,3...
After seeing this question I decided to try and write a vim plugin to handle it. It's my first vim plugin, so it's probably very bad. However, it does work for the example you gave. You can download the plugin from vim.org: [SearchCols.vim](http://www.vim.org/scripts/script.php?script_id=2543) Note that it also requi...
547,798
<p>I have a block of text, and for every regex match, I want to substitute that match with the return value from another function. The argument to this function is of course the matched text.</p> <p>I have been having trouble trying to come up with a one pass solution to this problem. It feels like it should be pret...
[ { "answer_id": 547817, "author": "oefe", "author_id": 49793, "author_profile": "https://Stackoverflow.com/users/49793", "pm_score": 5, "selected": true, "text": "<p>Right from <a href=\"http://docs.python.org/library/re.html#re.sub\" rel=\"noreferrer\">the documentation</a>:</p>\n\n<pre>...
2009/02/13
[ "https://Stackoverflow.com/questions/547798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28486/" ]
I have a block of text, and for every regex match, I want to substitute that match with the return value from another function. The argument to this function is of course the matched text. I have been having trouble trying to come up with a one pass solution to this problem. It feels like it should be pretty simple.
Right from [the documentation](http://docs.python.org/library/re.html#re.sub): ``` >>> def dashrepl(matchobj): ... if matchobj.group(0) == '-': return ' ' ... else: return '-' >>> re.sub('-{1,2}', dashrepl, 'pro----gram-files') 'pro--gram files' ```
547,804
<p>here's what I'd like to do in mySQL... I'm getting the feeling that this is simply not feasible, but would love to be wrong...</p> <pre><code>create procedure foo(IN MYTABLE varchar(50) , IN COLNAME varchar (50), IN MYTYPE varchar(50)) begin IF (select count(*) from information_schema.columns where table_name =MY...
[ { "answer_id": 547857, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 4, "selected": true, "text": "<p>Don't know why on Earth you would want it, but it's possible:</p>\n\n<pre><code>DELIMITER //\nDROP PROCEDURE foo//\nCRE...
2009/02/13
[ "https://Stackoverflow.com/questions/547804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59947/" ]
here's what I'd like to do in mySQL... I'm getting the feeling that this is simply not feasible, but would love to be wrong... ``` create procedure foo(IN MYTABLE varchar(50) , IN COLNAME varchar (50), IN MYTYPE varchar(50)) begin IF (select count(*) from information_schema.columns where table_name =MYTABLE and colu...
Don't know why on Earth you would want it, but it's possible: ``` DELIMITER // DROP PROCEDURE foo// CREATE PROCEDURE foo(IN MYTABLE varchar(50) , IN COLNAME varchar (50), IN MYTYPE varchar(50)) BEGIN SET @ddl = CONCAT('alter table ', MYTABLE, ' add column (', COLNAME, ' ', MYTYPE, ')'); PREPARE STMT FROM @ddl; E...
547,805
<p>In Maven2, to exclude a single transitive dependency, I have to do something like this:</p> <pre><code>&lt;dependency&gt; &lt;groupId&gt;sample.group&lt;/groupId&gt; &lt;artifactId&gt;sample-artifactB&lt;/artifactId&gt; &lt;version&gt;1&lt;/version&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;g...
[ { "answer_id": 547818, "author": "Esko Luontola", "author_id": 62130, "author_profile": "https://Stackoverflow.com/users/62130", "pm_score": 2, "selected": false, "text": "<p>What is your reason for excluding all transitive dependencies?</p>\n\n<p>If there is a particular artifact (such ...
2009/02/13
[ "https://Stackoverflow.com/questions/547805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2011/" ]
In Maven2, to exclude a single transitive dependency, I have to do something like this: ``` <dependency> <groupId>sample.group</groupId> <artifactId>sample-artifactB</artifactId> <version>1</version> <exclusions> <exclusion> <groupId>sample.group</groupId> <artifactId>sample-artifactAB</art...
For maven2 there isn't a way to do what you describe. For maven 3, there is. If you are using maven 3 please see [another answer for this question](https://stackoverflow.com/a/7556707/46375) For maven 2 I'd recommend creating your own custom pom for the dependency that has your <exclusions>. For projects that need to ...
547,821
<p>I have two <em>submit</em> buttons in a form. How do I determine which one was hit serverside?</p>
[ { "answer_id": 547824, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 10, "selected": true, "text": "<p>If you give each one a name, the clicked one will be sent through as any other input.</p>\n\n<pre><code>&lt;input type=\"s...
2009/02/13
[ "https://Stackoverflow.com/questions/547821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85185/" ]
I have two *submit* buttons in a form. How do I determine which one was hit serverside?
If you give each one a name, the clicked one will be sent through as any other input. ``` <input type="submit" name="button_1" value="Click me"> ```
547,829
<p>Given a string of a Python class, e.g. <code>my_package.my_module.MyClass</code>, what is the best possible way to load it?</p> <p>In other words I am looking for a equivalent <code>Class.forName()</code> in Java, function in Python. It needs to work on Google App Engine.</p> <p>Preferably this would be a function...
[ { "answer_id": 547865, "author": "oefe", "author_id": 49793, "author_profile": "https://Stackoverflow.com/users/49793", "pm_score": -1, "selected": false, "text": "<pre><code>module = __import__(\"my_package/my_module\")\nthe_class = getattr(module, \"MyClass\")\nobj = the_class()\n</cod...
2009/02/13
[ "https://Stackoverflow.com/questions/547829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1296737/" ]
Given a string of a Python class, e.g. `my_package.my_module.MyClass`, what is the best possible way to load it? In other words I am looking for a equivalent `Class.forName()` in Java, function in Python. It needs to work on Google App Engine. Preferably this would be a function that accepts the FQN of the class as a...
From the python documentation, here's the function you want: ``` def my_import(name): components = name.split('.') mod = __import__(components[0]) for comp in components[1:]: mod = getattr(mod, comp) return mod ``` The reason a simple `__import__` won't work is because any import of anything ...
547,833
<p>I have an interesting problem. Consider this class hierachy:</p> <pre><code>class Base { public: virtual float GetMember( void ) const =0; virtual void SetMember( float p ) =0; }; class ConcreteFoo : public Base { public: ConcreteFoo( "foo specific stuff here" ); virtual float GetMember( void ) const...
[ { "answer_id": 547836, "author": "deft_code", "author_id": 28817, "author_profile": "https://Stackoverflow.com/users/28817", "pm_score": 0, "selected": false, "text": "<p>Add special functions to <code>Base</code>.</p>\n\n<p>The simplest and most unacceptable solution is to add\nfoo_spec...
2009/02/13
[ "https://Stackoverflow.com/questions/547833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28817/" ]
I have an interesting problem. Consider this class hierachy: ``` class Base { public: virtual float GetMember( void ) const =0; virtual void SetMember( float p ) =0; }; class ConcreteFoo : public Base { public: ConcreteFoo( "foo specific stuff here" ); virtual float GetMember( void ) const; virtual vo...
The cast would be faster than most other solutions, however: in Base Class add: ``` void passthru( const string &concreteClassName, const string &functionname, vector<string*> args ) { if( concreteClassName == className ) runPassThru( functionname, args ); } private: string className; map<string...
547,878
<p>I have a simple use for RadGrid that involves binding it to a list of strings </p> <pre><code> i.e. using: list&lt;string&gt; </code></pre> <p>The bind works OK and the data displays in the grid. However, the header says "Item", and there are other aspects of the column I'd like to be able to customize. I've t...
[ { "answer_id": 547942, "author": "GregD", "author_id": 38317, "author_profile": "https://Stackoverflow.com/users/38317", "pm_score": 1, "selected": false, "text": "<p>You have to try something like this with the RadGrid:</p>\n\n<pre><code>&lt;Columns&gt;\n &lt;telerik:GridBoundColumn ...
2009/02/13
[ "https://Stackoverflow.com/questions/547878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61639/" ]
I have a simple use for RadGrid that involves binding it to a list of strings ``` i.e. using: list<string> ``` The bind works OK and the data displays in the grid. However, the header says "Item", and there are other aspects of the column I'd like to be able to customize. I've tried to set the "DataField" proper...
I think you should use a GridBoundColumn instead of the GridTemplateColumn and disable AutoGenerateColumns. E.g. the following works for me: ASPX: ``` <telerik:RadGrid ID="grid" runat="server" AutoGenerateColumns="false"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="" HeaderText="MyHea...
547,903
<p>I have a feeling the answer to this is going to be "not possible", but I'll give it a shot... I am in the unenviable position of modifying a legacy VB6 app with some enhancements. Converting to a smarter language isn't an option. The app relies on a large collection of user defined types to move data around. I wou...
[ { "answer_id": 548748, "author": "RS Conley", "author_id": 7890, "author_profile": "https://Stackoverflow.com/users/7890", "pm_score": 2, "selected": false, "text": "<p>If you change all your Types to Classes. You have options. The big pitfall of changing from a type to a class is that y...
2009/02/13
[ "https://Stackoverflow.com/questions/547903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64304/" ]
I have a feeling the answer to this is going to be "not possible", but I'll give it a shot... I am in the unenviable position of modifying a legacy VB6 app with some enhancements. Converting to a smarter language isn't an option. The app relies on a large collection of user defined types to move data around. I would li...
Contrary to what others have said, it IS possible to get run-time type information for UDT's in VB6 (although it is not a built-in language feature). Microsoft's [TypeLib Information Object Library](http://msdn.microsoft.com/en-us/magazine/bb985086.aspx) (tlbinf32.dll) allows you to programmatically inspect COM type in...
547,904
<p>According to <a href="https://stackoverflow.com/users/58880/cdonner">cdonner</a>, in his answer <a href="https://stackoverflow.com/questions/547693/sql-date-search-without-time/547761#547761">here</a> and on his <a href="http://cdonner.com/why-not-to-use-between-for-datetime-comparisons-in-sql-server-2007.htm" rel="...
[ { "answer_id": 547918, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 4, "selected": true, "text": "<p>In Oracle:</p>\n\n<pre><code>select\n case when '1/1/08' between '1/1/08' and '2/1/08'\n then 'in' else 'out'...
2009/02/13
[ "https://Stackoverflow.com/questions/547904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
According to [cdonner](https://stackoverflow.com/users/58880/cdonner), in his answer [here](https://stackoverflow.com/questions/547693/sql-date-search-without-time/547761#547761) and on his [blog](http://cdonner.com/why-not-to-use-between-for-datetime-comparisons-in-sql-server-2007.htm). He claims that BETWEEN with da...
In Oracle: ``` select case when '1/1/08' between '1/1/08' and '2/1/08' then 'in' else 'out' end as s1, case when '1/1/08' between '12/31/07' and '1/1/08' then 'in' else 'out' end as s2 FROM dual in out ``` You are comparing strings here, not dates. There is nothing `BETWEEN` `12/31/07 and 1...
547,915
<p>I'd like to use . to call sql script from inside a stored proc like so...</p> <pre><code>delimiter /// create procedure append_procedure() BEGIN \. test.sql; END; /// delimiter ; </code></pre> <p>I'm getting a "failed to open 'test.sql;' " error when I run it this way. I've also tried ! but then I get a permi...
[ { "answer_id": 547929, "author": "matt_dev", "author_id": 39086, "author_profile": "https://Stackoverflow.com/users/39086", "pm_score": 0, "selected": false, "text": "<p>If you're on Sql Sevrer 2005 you can use the xp_cmdshell command.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/...
2009/02/13
[ "https://Stackoverflow.com/questions/547915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59947/" ]
I'd like to use . to call sql script from inside a stored proc like so... ``` delimiter /// create procedure append_procedure() BEGIN \. test.sql; END; /// delimiter ; ``` I'm getting a "failed to open 'test.sql;' " error when I run it this way. I've also tried ! but then I get a permission denied error. However...
There is a set of commands that are builtin to the mysql client. They're documented under "[`mysql` Commands](http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html)." These include DELIMITER, SOURCE, HELP, CONNECT, USE, QUIT, etc. The `\.` (or `SOURCE`) command is one of these builtins. **You can't execute these ...
547,919
<p>In this <a href="https://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sql-query-why-should-i">question</a>, a user commented to never use the With block in VB. Why?</p>
[ { "answer_id": 547957, "author": "Dan Blanchard", "author_id": 5460, "author_profile": "https://Stackoverflow.com/users/5460", "pm_score": 0, "selected": false, "text": "<p>The <em>with</em> keyword is only sideswiped in a passing reference <a href=\"http://www.theregister.co.uk/2009/02/...
2009/02/13
[ "https://Stackoverflow.com/questions/547919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16951/" ]
In this [question](https://stackoverflow.com/questions/542510/how-do-i-create-a-parameterized-sql-query-why-should-i), a user commented to never use the With block in VB. Why?
"Never" is a strong word. I think it fine as long as you don't abuse it (like nesting) IMHO - this is better: ``` With MyCommand.Parameters .Count = 1 .Item(0).ParameterName = "@baz" .Item(0).Value = fuz End With ``` Than: ``` MyCommand.Parameters.Count = 1 MyCommand.Parameters.Item(0).ParameterName =...
547,920
<p>Here's the routes.rb: </p> <pre><code>map.resources :assignments, :shallow =&gt; true do |assignment| assignment.resources :problems end </code></pre> <p>How do i get the url to edit a problem (/assignments/xyz/problems/abc/edit), in code? I have tried both<br> edit_assignment_problem_path(assignme...
[ { "answer_id": 547970, "author": "Alex Wayne", "author_id": 62076, "author_profile": "https://Stackoverflow.com/users/62076", "pm_score": 4, "selected": false, "text": "<p>Run this at your command line:</p>\n\n<pre><code>rake routes\n</code></pre>\n\n<p>It will tell you all the routes th...
2009/02/13
[ "https://Stackoverflow.com/questions/547920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356145/" ]
Here's the routes.rb: ``` map.resources :assignments, :shallow => true do |assignment| assignment.resources :problems end ``` How do i get the url to edit a problem (/assignments/xyz/problems/abc/edit), in code? I have tried both edit\_assignment\_problem\_path(assignment,problem) and edit\_probl...
Run this at your command line: ``` rake routes ``` It will tell you all the routes that you have defined, and how they map. Very handy.
547,922
<p>I am a Haskell newbie, though had a previous Lisp/Scheme experience. Right now I am looking at the examples from SICP and trying to implement them in Haskell to get more hands-on experience. In the lecture 3b authors present a function for computing the derivatives symbolically. It contains, among others, the follow...
[ { "answer_id": 547948, "author": "Morendil", "author_id": 61168, "author_profile": "https://Stackoverflow.com/users/61168", "pm_score": 1, "selected": false, "text": "<p>I don't think you can do that. Lisp is <a href=\"http://en.wikipedia.org/wiki/Homoiconicity\" rel=\"nofollow noreferre...
2009/02/13
[ "https://Stackoverflow.com/questions/547922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3894/" ]
I am a Haskell newbie, though had a previous Lisp/Scheme experience. Right now I am looking at the examples from SICP and trying to implement them in Haskell to get more hands-on experience. In the lecture 3b authors present a function for computing the derivatives symbolically. It contains, among others, the following...
Your Scheme examples don't actually examine Scheme functions. I recently did some symbolic differentiation in Haskell over values of the following type: ``` data Exp a = Lit a | Exp a :*: Exp a | Exp a :+: Exp a | Var String deriving Eq ``` Instead of discriminating using `atom?` o...
547,934
<p>I don't really know much about the internals of compiler and JIT optimizations, but I usually try to use "common sense" to guess what could be optimized and what couldn't. So there I was writing a simple unit test method today:</p> <pre><code>@Test // [Test] in C# public void testDefaultConstructor() { new MyO...
[ { "answer_id": 547958, "author": "Matt Briggs", "author_id": 10771, "author_profile": "https://Stackoverflow.com/users/10771", "pm_score": 3, "selected": false, "text": "<p>I think if you are worried about it getting optimized away, you may be doing a bit of testing overkill.</p>\n\n<p>I...
2009/02/13
[ "https://Stackoverflow.com/questions/547934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
I don't really know much about the internals of compiler and JIT optimizations, but I usually try to use "common sense" to guess what could be optimized and what couldn't. So there I was writing a simple unit test method today: ``` @Test // [Test] in C# public void testDefaultConstructor() { new MyObject(); } ``...
Don't worry about it. It's not allowed to ever optimize anything that can make a difference to your system (except for speed). If you new an object, code gets called, memory gets allocated, it HAS to work. If you had it protected by an if(false), where false is a final, it could be optimized out of the system complete...
547,944
<p>I've got a game which dumps state information to a database. Eg. Connected, Lost Connection, Grabbed Screen Dump, etc.</p> <p>Each state is defined by a field called <code>StateTypeId</code>, which is a foreign key to a simple lookup table <code>'StateTypes'</code>.</p> <p>Now, i'm trying to find all the people wh...
[ { "answer_id": 547969, "author": "Thorsten", "author_id": 25320, "author_profile": "https://Stackoverflow.com/users/25320", "pm_score": 3, "selected": true, "text": "<p>What you are looking for is the \"most recent\" entry having a StateType of 1 or 2:</p>\n\n<p>Then you are looking to i...
2009/02/13
[ "https://Stackoverflow.com/questions/547944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I've got a game which dumps state information to a database. Eg. Connected, Lost Connection, Grabbed Screen Dump, etc. Each state is defined by a field called `StateTypeId`, which is a foreign key to a simple lookup table `'StateTypes'`. Now, i'm trying to find all the people who are currently '`Connected`' (eg. Stat...
What you are looking for is the "most recent" entry having a StateType of 1 or 2: Then you are looking to identify the "last" one for each user: ``` select UserName, max(DateAdded) as LastDate from UserData where State IN ('Connected', 'LostConnection') Group by UserName ``` Then you need to check the state of thes...
547,946
<p>Is there a better way to check if a file is not locked then to open the file to catch an exception. I have a filewatcher running on a directory and I need to do something to the file after the file has completely moved/created in the location. Aren't throwing an exception a performance hit? Is there a better way?</p...
[ { "answer_id": 547968, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>Just how often are you going to be doing this? To put it in context, suppose you check once every 50 milliseconds - wh...
2009/02/13
[ "https://Stackoverflow.com/questions/547946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51719/" ]
Is there a better way to check if a file is not locked then to open the file to catch an exception. I have a filewatcher running on a directory and I need to do something to the file after the file has completely moved/created in the location. Aren't throwing an exception a performance hit? Is there a better way? ``` ...
Just how often are you going to be doing this? To put it in context, suppose you check once every 50 milliseconds - which is pretty frequently. My laptop (last time I checked) was able to throw over 100 exceptions *per millisecond*... so the cost of throwing the exception would be less than 0.02% of the overall time - ...
547,981
<p>I have been tasked with finding out what is causing an issue with this bit of code:</p> <pre><code>public static ArrayList GetEthernetMacAddresses() { ArrayList addresses = new ArrayList(); ManagementClass mc = new ManagementClass("Win32_NetworkAdapter"); // This causes GetInstances(options) // to...
[ { "answer_id": 548172, "author": "jdigital", "author_id": 37231, "author_profile": "https://Stackoverflow.com/users/37231", "pm_score": 0, "selected": false, "text": "<p>Why are the two returning different results? It's possible that due to the different user accounts, you'll get differ...
2009/02/13
[ "https://Stackoverflow.com/questions/547981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30862/" ]
I have been tasked with finding out what is causing an issue with this bit of code: ``` public static ArrayList GetEthernetMacAddresses() { ArrayList addresses = new ArrayList(); ManagementClass mc = new ManagementClass("Win32_NetworkAdapter"); // This causes GetInstances(options) // to return all su...
Okay, so I wrote this code to test the issue: ``` public void GetWin32_NetworkAdapter() { DataTable dt = new DataTable(); dt.Columns.Add("AdapterName", typeof(string)); dt.Columns.Add("ServiceName", typeof(string)); dt.Columns.Add("AdapterType", typeof(string)); dt.Columns.Add("IPEnabled", typeof(b...
548,024
<p>If I have a script that is a wrapper for another program (e.g., <a href="https://stackoverflow.com/questions/525247/how-do-i-daemonize">a daemonizer wrapper</a> or <a href="https://stackoverflow.com/questions/148057/calling-a-math">a wrapper for mathematica</a>), it is sometimes useful to trap signals in the wrapper...
[ { "answer_id": 548107, "author": "slacy", "author_id": 66289, "author_profile": "https://Stackoverflow.com/users/66289", "pm_score": 2, "selected": false, "text": "<p>There are many signals that would be dangerous to just \"pass through\" in this way. \"man 7 signal\" and look at things...
2009/02/13
[ "https://Stackoverflow.com/questions/548024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4234/" ]
If I have a script that is a wrapper for another program (e.g., [a daemonizer wrapper](https://stackoverflow.com/questions/525247/how-do-i-daemonize) or [a wrapper for mathematica](https://stackoverflow.com/questions/148057/calling-a-math)), it is sometimes useful to trap signals in the wrapper program and pass them al...
There are many signals that would be dangerous to just "pass through" in this way. "man 7 signal" and look at things like SIGPIPE, SIGILL, SIGCHILD, etc. It's very likely that you just don't want to touch those guys. So, the real question becomes: What is the behavior you're looking for? I bet all you really want is ...
548,048
<p>In my Rails app, I have a script that updates some records in the database. When I send a SIGTERM to kill the script, it occasionally receives that signal while ActiveRecord is executing a query. This leads to an ActiveRecord::StatementInvalid exception being raised. </p> <p>I'd like to catch StatementInvalid ex...
[ { "answer_id": 548216, "author": "Martin Carpenter", "author_id": 39443, "author_profile": "https://Stackoverflow.com/users/39443", "pm_score": 0, "selected": false, "text": "<p>It sounds like this \"script\" is external to the Rails app (<code>script/runner</code> or similar?), so perha...
2009/02/13
[ "https://Stackoverflow.com/questions/548048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
In my Rails app, I have a script that updates some records in the database. When I send a SIGTERM to kill the script, it occasionally receives that signal while ActiveRecord is executing a query. This leads to an ActiveRecord::StatementInvalid exception being raised. I'd like to catch StatementInvalid exceptions that...
If you trap the TERM signal, I believe you will avoid the exception. You can do this at the beginning of your script (or really anywhere for that matter, but you only need to do it once). ``` Signal.trap("TERM") do Kernel.exit! end ``` The reason you get the StatementInvalid error is Ruby handles the signal by ...
548,060
<p>I have a string that consists of </p> <pre><code>"some text \\computername.example.com\admin$". </code></pre> <p>How would I do a replace so my final result would be just "computername"</p> <p>My problems appears to not knowing how to escape two backslashes. To keep things simple I would prefer not to use regexp ...
[ { "answer_id": 548245, "author": "Steven Murawski", "author_id": 1233, "author_profile": "https://Stackoverflow.com/users/1233", "pm_score": 3, "selected": false, "text": "<p>I don't think you're going to get away from regular expressions in this case.</p>\n\n<p>I would use this pattern:...
2009/02/13
[ "https://Stackoverflow.com/questions/548060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66308/" ]
I have a string that consists of ``` "some text \\computername.example.com\admin$". ``` How would I do a replace so my final result would be just "computername" My problems appears to not knowing how to escape two backslashes. To keep things simple I would prefer not to use regexp :) EDIT: Actually looks like sta...
first, there is absolutely nothing wrong with the Regex method that is presented. However, if you are deadset against it, Check this: ``` $test = "some text \\computername.example.com\admin$" $test.Split('\')[2].Split('.')[0] ``` Very simplistic testing shows that the split is marginally faster on my machine for wha...
548,063
<p>After opening a pipe to a process with <code>popen</code>, is there a way to kill the process that has been started? (Using <code>pclose</code> is not what I want because that will wait for the process to finish, but I need to kill it.)</p>
[ { "answer_id": 548095, "author": "Andrew Grant", "author_id": 1043, "author_profile": "https://Stackoverflow.com/users/1043", "pm_score": 0, "selected": false, "text": "<p>The obvious way is system(\"pkill process_name\");</p>\n\n<p>Clearly this is problematic if you have more than one i...
2009/02/13
[ "https://Stackoverflow.com/questions/548063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49485/" ]
After opening a pipe to a process with `popen`, is there a way to kill the process that has been started? (Using `pclose` is not what I want because that will wait for the process to finish, but I need to kill it.)
Don't use `popen()`, write your own wrapper that does what you'd like. It's fairly straightforward to `fork()`, and then replace `stdin` & `stdout` by using `dup2()`, and then calling `exec()` on your child. That way, your parent will have the exact child PID, and you can use `kill()` on that. Google search for "po...
548,067
<p>Scenario: Our install package used to add User DSN. We changed this to install System DSNs due to Terminal Servers and Citrix.</p> <p>The problem is that some of these old User DSNs are floating around, and our application automatically chooses the User before the System and the connection info has changed as we u...
[ { "answer_id": 548189, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 2, "selected": false, "text": "<p>The information about user DSN(s) are stored in the registry. Have you considered simply doing a couple registry rea...
2009/02/13
[ "https://Stackoverflow.com/questions/548067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/411/" ]
Scenario: Our install package used to add User DSN. We changed this to install System DSNs due to Terminal Servers and Citrix. The problem is that some of these old User DSNs are floating around, and our application automatically chooses the User before the System and the connection info has changed as we upgraded ser...
See RegistryValues() in the PowerBuilder Help. The following isn't exactly what you want but it does show a couple of working calls... ``` integer li_RC string ls_odbc_ini[] li_RC = RegistryValues ( & "HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", & ls_odbc_ini ) IF li_RC <> 1 THEN Message...
548,082
<p>Alright, i promised myself i would learn Regex one day.. but today is not that day. </p> <p>What is the correct expression for matching <code>#_</code> (where _ is any character EXCEPT {)?</p> <hr> <p>Clarification:</p> <p>I am working on a syntax highlighting system for Ruby and i am defining the rules for comm...
[ { "answer_id": 548092, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 2, "selected": false, "text": "<p>In PCRE syntax, <code>#[^{]</code></p>\n" }, { "answer_id": 548097, "author": "Fabian Steeg", "author_i...
2009/02/13
[ "https://Stackoverflow.com/questions/548082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18811/" ]
Alright, i promised myself i would learn Regex one day.. but today is not that day. What is the correct expression for matching `#_` (where \_ is any character EXCEPT {)? --- Clarification: I am working on a syntax highlighting system for Ruby and i am defining the rules for comments. The specification that the '{...
You define a character class inside [ ] and negate with ^: ``` [^{] // i.e. a single character that is not { ``` If you add the hash mark in the beginning this results in: ``` #[^{] // i.e. # and then a single character that is not { ```
548,090
<p>What are the real world pros and cons of executing a dynamic SQL command in a stored procedure in SQL Server using</p> <pre><code>EXEC (@SQL) </code></pre> <p>versus</p> <pre><code>EXEC SP_EXECUTESQL @SQL </code></pre> <p>?</p>
[ { "answer_id": 548099, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 5, "selected": false, "text": "<p>The big thing about SP_EXECUTESQL is that it allows you to create parameterized queries which is very good if you care abou...
2009/02/13
[ "https://Stackoverflow.com/questions/548090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35615/" ]
What are the real world pros and cons of executing a dynamic SQL command in a stored procedure in SQL Server using ``` EXEC (@SQL) ``` versus ``` EXEC SP_EXECUTESQL @SQL ``` ?
`sp_executesql` is more likely to promote query plan reuse. When using `sp_executesql`, parameters are explicitly identified in the calling signature. This excellent article descibes this [process](http://technet.microsoft.com/en-au/library/cc966425.aspx). The oft cited reference for many aspects of dynamic sql is Erl...
548,091
<p>I'm using 2005 Windows Forms in C#. I've only been working at this for a day, so go easy please.</p> <p>I'd like to have a submit button that saves changes to a DataGridView. I've gotten data into the DGV and can edit, but am stuck on the Update().</p> <p>I've created an .xsd named scDB and one DataTable called ...
[ { "answer_id": 548100, "author": "FerranB", "author_id": 40441, "author_profile": "https://Stackoverflow.com/users/40441", "pm_score": 1, "selected": false, "text": "<p>Update on a table-adapter needs a <strong>DataSet</strong>.</p>\n\n<p>You need to instantiate a <em>scDB</em> <em>DataS...
2009/02/13
[ "https://Stackoverflow.com/questions/548091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37379/" ]
I'm using 2005 Windows Forms in C#. I've only been working at this for a day, so go easy please. I'd like to have a submit button that saves changes to a DataGridView. I've gotten data into the DGV and can edit, but am stuck on the Update(). I've created an .xsd named scDB and one DataTable called - SSIS Configuratio...
Sam, the update needs a table so you could try something like: ``` TableType table = (TableType) stagingGrid.DataSource; myStagingTableAdapter.Update(table); ``` where you'll have to substitute TableType with something appropriate. But a better approach would be to use drag-and-drop and learn form the code. 1. Se...
548,102
<p>I want to manually create a binary script and then save it as binary file.</p> <p>I want to append all of the following bytes and create a binary file out of them. </p> <pre><code>&amp;HF0 &amp;HF1 &amp;HF2 </code></pre> <p>I want to able to do something like this : </p> <pre><code>Dim generateData(3) As Byte ge...
[ { "answer_id": 548127, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 2, "selected": true, "text": "<p>I have seen something along these lines used:</p>\n\n<pre><code>Sub WriteBinary(FileName, Buf) \n\n Dim I, aBuf,...
2009/02/13
[ "https://Stackoverflow.com/questions/548102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
I want to manually create a binary script and then save it as binary file. I want to append all of the following bytes and create a binary file out of them. ``` &HF0 &HF1 &HF2 ``` I want to able to do something like this : ``` Dim generateData(3) As Byte generateData(0) = &HFF generateData(1) = &HFE generateData...
I have seen something along these lines used: ``` Sub WriteBinary(FileName, Buf) Dim I, aBuf, Size, bStream Size = UBound(Buf): ReDim aBuf(Size \ 2) For I = 0 To Size - 1 Step 2 aBuf(I \ 2) = ChrW(Buf(I + 1) * 256 + Buf(I)) Next If I = Size Then aBuf(I \ 2) = ChrW(Buf(I)) ...
548,106
<p>I'm working on a javascript app that has a form with a button that processes inputs in the browser. It is important that the data never accidentally get sent to the server when the button is pushed. Situations where this might happen is the browser may not have javascript enabled or the DOM implementation may have...
[ { "answer_id": 548113, "author": "Andrew M", "author_id": 66293, "author_profile": "https://Stackoverflow.com/users/66293", "pm_score": 0, "selected": false, "text": "<p>Surely some kind of image button would do? Style up a nice looking image, and use an onclick event to post back? Would...
2009/02/13
[ "https://Stackoverflow.com/questions/548106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10393/" ]
I'm working on a javascript app that has a form with a button that processes inputs in the browser. It is important that the data never accidentally get sent to the server when the button is pushed. Situations where this might happen is the browser may not have javascript enabled or the DOM implementation may have a bu...
``` <input type="button"> ``` does not submit a form, unlike ``` <input type="submit"> ```
548,129
<p>The TreeView is a nice way to present a hierarchy to users, but imagine the following scenario with the hierarchy depicted below:</p> <pre><code>Building 1 -Tenant 1 - Payment 1 - Payment 2 Building 2 -Tenant 1 - Payment 1 -Tenant 2 - Payment 1 - Payment 2 </code></pre> <p>where you need to do a...
[ { "answer_id": 548136, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 4, "selected": true, "text": "<p>I find the best way to handle additional data is to subclass TreeNode. I create a BaseNode class that contains the shared...
2009/02/13
[ "https://Stackoverflow.com/questions/548129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19799/" ]
The TreeView is a nice way to present a hierarchy to users, but imagine the following scenario with the hierarchy depicted below: ``` Building 1 -Tenant 1 - Payment 1 - Payment 2 Building 2 -Tenant 1 - Payment 1 -Tenant 2 - Payment 1 - Payment 2 ``` where you need to do an insert to a database whe...
I find the best way to handle additional data is to subclass TreeNode. I create a BaseNode class that contains the shared data I want to maintain, and inherit further from that for any specific node types. The value of subclassing is that you can maintain strong data types and complex data types just like any other cl...
548,132
<p>I have this but there is an error, I don't get it :(. I'm relatively new to Java.</p> <pre><code>package hw; import java.util.Scanner; public class Problem1 { public static void main (String [] args) { int cost; int number; double cost_unit; double total; Scanner entrada = new Scanner(Syst...
[ { "answer_id": 548143, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 1, "selected": false, "text": "<p>Some hints:</p>\n\n<pre><code>while (cost&gt;0)\n</code></pre>\n\n<p>Do you really want a <code>while</code>-loop...
2009/02/13
[ "https://Stackoverflow.com/questions/548132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59998/" ]
I have this but there is an error, I don't get it :(. I'm relatively new to Java. ``` package hw; import java.util.Scanner; public class Problem1 { public static void main (String [] args) { int cost; int number; double cost_unit; double total; Scanner entrada = new Scanner(System.in); ...
In printf, `%d` is for a signed decimal integer, whereas `cost_unit` and `total` are doubles. You should use `%f` instead. ``` System.out.printf("Cost per unit will be $ %f\n",cost_unit); System.out.printf("Cost per unit will be $ %f\n",total); ```
548,137
<p>In Preview 5, here are the actionlinks that worked fine:</p> <ol> <li><pre><code> listing is the controller and about is the action </code></pre></li> </ol> <p>2.</p> <p>var values = new RouteValueDictionary();</p> <pre><code> text and actionname are both strings </code></pre> <p>Htm...
[ { "answer_id": 548290, "author": "Chad Moran", "author_id": 25416, "author_profile": "https://Stackoverflow.com/users/25416", "pm_score": 1, "selected": false, "text": "<p>Maybe I don't understand your question but your above example should work just fine with ASP.NET MVC RC.</p>\n" },...
2009/02/13
[ "https://Stackoverflow.com/questions/548137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In Preview 5, here are the actionlinks that worked fine: 1. ``` listing is the controller and about is the action ``` 2. var values = new RouteValueDictionary(); ``` text and actionname are both strings ``` Html.ActionLink(text, actionName, values); What would I convert these to get ...
Maybe I don't understand your question but your above example should work just fine with ASP.NET MVC RC.
548,156
<p>The pertinent part of my .htaccess looks like this:</p> <pre><code>Options -Indexes &lt;FilesMatch include&gt; Order allow,deny Deny from all &lt;/FilesMatch&gt; RedirectMatch 404 ^/include(/.*)$ </code></pre> <p>And it's generating the following responses:</p> <ul> <li>/include 403 </li> <li>/include/ 4...
[ { "answer_id": 548166, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 1, "selected": false, "text": "<p>Don't you want '^/include(/.*)?$'</p>\n\n<p>This part is a guess, but what would happen if you put the RedirectMatch above...
2009/02/13
[ "https://Stackoverflow.com/questions/548156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13834/" ]
The pertinent part of my .htaccess looks like this: ``` Options -Indexes <FilesMatch include> Order allow,deny Deny from all </FilesMatch> RedirectMatch 404 ^/include(/.*)$ ``` And it's generating the following responses: * /include 403 * /include/ 404 * /include/config.inc 403 I can tell by looking at my ...
I can understand why the /include isn't caught by your RedirectMatch, you aren't making the end '/' optional, however the /include/config.inc part is a bit on the puzzling side. Here is what I got to work on Apache 2.2: ``` <FilesMatch /include(/?|/.*)> Order allow,deny Deny from all </FilesMatch> RedirectMa...
548,158
<p>I need to store fixed-length (up to 8 digits) numbers produced from a variable length strings. The hash need not be unique. It just needs to change when input string changes. Is there a hash function in .Net that does this? </p> <p>Thanks<br> Kishore.</p>
[ { "answer_id": 548174, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 3, "selected": false, "text": "<p>Simple approach (note that this is <a href=\"http://msdn.microsoft.com/en-us/library/system.string.gethashcode.as...
2009/02/13
[ "https://Stackoverflow.com/questions/548158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18169/" ]
I need to store fixed-length (up to 8 digits) numbers produced from a variable length strings. The hash need not be unique. It just needs to change when input string changes. Is there a hash function in .Net that does this? Thanks Kishore.
I assume you are doing this because you need to store the value elsewhere and compare against it. Thus Zach's answer (while entirely correct) may cause you issues since the contract for String.GetHashCode() is explicit about its scope for changing. Thus here is a fixed and easily repeatable in other languages version....
548,164
<p>Can someone provide an example were casting a pointer from one type to another fails due to mis-alignment?</p> <p>In the comments to <a href="https://stackoverflow.com/questions/544928/reading-integer-size-bytes-from-a-char-array/544964#544964">this answer</a>, bothie states that doing something like</p> <pre><cod...
[ { "answer_id": 548179, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": "<pre><code>char *foo = \"....\";\nfoo++;\nint *bar = (int *)foo;\n</code></pre>\n\n<p>The compiler would put foo on a w...
2009/02/14
[ "https://Stackoverflow.com/questions/548164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48015/" ]
Can someone provide an example were casting a pointer from one type to another fails due to mis-alignment? In the comments to [this answer](https://stackoverflow.com/questions/544928/reading-integer-size-bytes-from-a-char-array/544964#544964), bothie states that doing something like ``` char * foo = ...; int bar = *(...
There is an additional condition, not mentioned, for EFLAGS.AC to actually take effect. CR0.AM must be set to prevent INT 17h from tripping on older OSes predating the 486 that have no handler for this exception. Unfortunately, Windows do not set it by default, you need to write a kernel-mode driver to set it.
548,180
<p>can anyone think of a good way to ignore the single click that comes with a double-click in Java ? </p> <p>I'm looking to have different behaviors for each such that:</p> <ul> <li>single-click paints crosshairs on the click point</li> <li>double-click selects an object on the screen, but should <strong>not</strong...
[ { "answer_id": 548209, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 0, "selected": false, "text": "<p>Have you tried implementing the MouseListener interface already?</p>\n\n<p>I think MouseEvent has a click count method...
2009/02/14
[ "https://Stackoverflow.com/questions/548180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64696/" ]
can anyone think of a good way to ignore the single click that comes with a double-click in Java ? I'm looking to have different behaviors for each such that: * single-click paints crosshairs on the click point * double-click selects an object on the screen, but should **not** paint crosshairs on the click point .....
Indeed you'll need to set up a Timer in your overridden mouseClicked() method of your MouseAdapter to detect the time interval between the two clicks. The default interval in ms can be found by querying `Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval")`. If another mouse click is detected before...
548,188
<p>I have this function, to create a DIV on-the-fly. But now, I want to destroy this object on <em>onclick</em> event, but I just don't know how.</p> <pre><code>function creatediv(id) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.onclick=function(){this=null;}; //bad...
[ { "answer_id": 548194, "author": "Chris Ballance", "author_id": 1551, "author_profile": "https://Stackoverflow.com/users/1551", "pm_score": 0, "selected": false, "text": "<pre><code>function removeElement(divNum) {\n var d = document.getElementById('myDiv');\n var olddiv = document.get...
2009/02/14
[ "https://Stackoverflow.com/questions/548188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
I have this function, to create a DIV on-the-fly. But now, I want to destroy this object on *onclick* event, but I just don't know how. ``` function creatediv(id) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.onclick=function(){this=null;}; //bad function documen...
Just setting it null will not destroy it. You need to remove it from the document tree while making sure there are no references pointing to it. ``` function creatediv(id) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); newdiv.onclick=function(e) { this.parentNode.remov...
548,208
<p>I need to call a couple of methods asynchronously with different priorities.</p> <p>My first idea was to use the ThreadPool and change the priority of the Thread like this:</p> <pre><code>static void Run() { ThreadPool.QueueUserWorkItem(new WaitCallback(SomeMethod)); } static void SomeMethod(object o) { Threa...
[ { "answer_id": 548213, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 0, "selected": false, "text": "<p>I think to be clean you should also restore the thread priority back when you get out of the method! (use try ... f...
2009/02/14
[ "https://Stackoverflow.com/questions/548208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44741/" ]
I need to call a couple of methods asynchronously with different priorities. My first idea was to use the ThreadPool and change the priority of the Thread like this: ``` static void Run() { ThreadPool.QueueUserWorkItem(new WaitCallback(SomeMethod)); } static void SomeMethod(object o) { Thread.CurrentThread.Prior...
According to <http://msdn.microsoft.com/en-us/library/0ka9477y.aspx>, it won't work if you are targeting 2.0, it alludes to there being some differences in 3.5 but doesn't specifically mention priority: > > **When Not to Use Thread Pool Threads** > > > There are several scenarios in which it is appropriate to creat...
548,212
<p>I have a host page that dynamically loads multiple instances of the same user control by assigning different IDs.</p> <p>After the UC loads, I will need to use JS to get a reference to a textbox. For this, I need the User control Client ID. I do have access to the UC Client ID on the server side and can set a hidde...
[ { "answer_id": 548230, "author": "Carter", "author_id": 49294, "author_profile": "https://Stackoverflow.com/users/49294", "pm_score": 0, "selected": false, "text": "<p>If I understand correctly you can get access to the ID by throwing this in between some script tags on your page...</p>\...
2009/02/14
[ "https://Stackoverflow.com/questions/548212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a host page that dynamically loads multiple instances of the same user control by assigning different IDs. After the UC loads, I will need to use JS to get a reference to a textbox. For this, I need the User control Client ID. I do have access to the UC Client ID on the server side and can set a hidden form var...
One approach is to emit the js code server side. For example if you need to call a function on that textbox - simple example: Say you have some javascript: ``` function ShowMeTheId(id) { alert(id); } ``` In code behind you can put something like this to call it from a button and pass in your textbox id : ``` MyBu...
548,214
<p>I'm trying to write some code that reads a file and ignores the line breaks (\n), so far I have:</p> <pre><code>c = fgetc(fp); for(int loop = 0; c != EOF; loop++) { if((c != '\n') &amp;&amp; (c != '\\')) { buffer[loop] = c; } c = fgetc(fp); } </code></pre> <p>but its just not seeming to ign...
[ { "answer_id": 548223, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 4, "selected": true, "text": "<p>Which operating system you are running this on? \\n on Windows is two characters (\\r\\n) . If you only want to igno...
2009/02/14
[ "https://Stackoverflow.com/questions/548214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66321/" ]
I'm trying to write some code that reads a file and ignores the line breaks (\n), so far I have: ``` c = fgetc(fp); for(int loop = 0; c != EOF; loop++) { if((c != '\n') && (c != '\\')) { buffer[loop] = c; } c = fgetc(fp); } ``` but its just not seeming to ignore the '\n' bits (not sure about ...
Which operating system you are running this on? \n on Windows is two characters (\r\n) . If you only want to ignore newlines, the second condition is not needed. But another problem is that you **increment loop variable every time**! You should increment 'loop' only when you add stuff to the buffer! Take 'loop++' away...
548,232
<p>I have a small list of checkboxes (see below), and I noticed I can use an input element with type="reset" and it will uncheck all the boxes. I know using the input would be better than an "onClick" event of the link, because I wouldn't be relying on JavaScript, but for this example I have both.</p> <pre><code>&lt;...
[ { "answer_id": 548244, "author": "brendan", "author_id": 225, "author_profile": "https://Stackoverflow.com/users/225", "pm_score": 0, "selected": false, "text": "<p>Correct, there is no HTML way. You'd have to use JavaScript or another language to implement it.</p>\n" }, { "answe...
2009/02/14
[ "https://Stackoverflow.com/questions/548232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58957/" ]
I have a small list of checkboxes (see below), and I noticed I can use an input element with type="reset" and it will uncheck all the boxes. I know using the input would be better than an "onClick" event of the link, because I wouldn't be relying on JavaScript, but for this example I have both. ``` <a onclick="javasc...
Yeah, you'd use JS. ``` for(var ix = 0; ix < document.myList.elements.count; ix++) if(document.myList.elements[ix].type == 'checkbox') document.myList.elements[ix].checked = true; ```
548,249
<p>I haven't had the chance to take any serious low-level programming courses in school. (I know I really should get going on learning the "behind-the-scenes" to be a better programmer.) I appreciate the conveniences of Java, including the ability to stick anything into a <code>System.out.print</code> statement. Howeve...
[ { "answer_id": 548264, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 2, "selected": false, "text": "<p>It is better if you need to control the precision of your floating-point numbers, do padding etc. System.out.print ...
2009/02/14
[ "https://Stackoverflow.com/questions/548249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37519/" ]
I haven't had the chance to take any serious low-level programming courses in school. (I know I really should get going on learning the "behind-the-scenes" to be a better programmer.) I appreciate the conveniences of Java, including the ability to stick anything into a `System.out.print` statement. However, is there an...
The [`printf`](http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html#printf(java.lang.String,%20java.lang.Object...)) method of the [PrintStream](http://java.sun.com/javase/6/docs/api/java/io/PrintStream.html) class provides [string formatting](http://java.sun.com/developer/technicalArticles/Programming/sprint...
548,289
<p>I am working with Apple's <code>ScriptingBridge</code> framework, and have generated a header file for iTunes that contains several <code>enum</code>s like this:</p> <pre><code>typedef enum { iTunesESrcLibrary = 'kLib', iTunesESrcIPod = 'kPod', iTunesESrcAudioCD = 'kACD', iTunesESrcMP3CD = 'kMCD', ...
[ { "answer_id": 548300, "author": "Steve Fallows", "author_id": 18882, "author_profile": "https://Stackoverflow.com/users/18882", "pm_score": 3, "selected": false, "text": "<p>The single quotes indicate characters, rather than strings in C. So each of the enums will have a 32 bit value co...
2009/02/14
[ "https://Stackoverflow.com/questions/548289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2399475/" ]
I am working with Apple's `ScriptingBridge` framework, and have generated a header file for iTunes that contains several `enum`s like this: ``` typedef enum { iTunesESrcLibrary = 'kLib', iTunesESrcIPod = 'kPod', iTunesESrcAudioCD = 'kACD', iTunesESrcMP3CD = 'kMCD', iTunesESrcDevice = 'kDev', iT...
C99, TC3 reads: 6.4.4.4 §2: > > An integer character constant is a sequence of **one or more** multibyte characters enclosed in single-quotes, as in 'x'. [...] > > > 6.4.4.4 §10: > > An integer character constant has type int. The value of an integer character constant containing a single character that maps t...
548,314
<p>I have a WSDL file and I am trying to create a web service that conforms to the WSDL.</p> <p>I've created clients using WSDL files that consume an existing service, but I've never created a web service that needed to follow a specific WSDL.</p> <p>I've gone as far as using:</p> <p><code>wsdl.exe mywsdl.wsdl /l:VB...
[ { "answer_id": 549538, "author": "John Saunders", "author_id": 76337, "author_profile": "https://Stackoverflow.com/users/76337", "pm_score": 2, "selected": false, "text": "<p>All you need to do is create a class that inherits from the interface that WSDL.EXE has generated, and then imple...
2009/02/14
[ "https://Stackoverflow.com/questions/548314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32892/" ]
I have a WSDL file and I am trying to create a web service that conforms to the WSDL. I've created clients using WSDL files that consume an existing service, but I've never created a web service that needed to follow a specific WSDL. I've gone as far as using: `wsdl.exe mywsdl.wsdl /l:VB /serverInterface` Now I've ...
If you already created interfaces you need to implement those interfaces. Just create a new web service and add the interface that you generated so that it inherits from that interface. Visual Studio can automatically generate stubs for every method in interface. Mark them with the WebMethod attribute and put some c...
548,331
<p>I have a small problem. I have a set of ComboBox's that are bound to lists which are associated with a set of dictionaries that provide int values for a math equation. I need to filter the result of cb_test_2 based on the selection of cb_test_1. I think I am close. What happens when I change the value in cb_test_1 i...
[ { "answer_id": 548342, "author": "joshperry", "author_id": 30587, "author_profile": "https://Stackoverflow.com/users/30587", "pm_score": 0, "selected": false, "text": "<p>You don't want to rebind the source dropdown on a postback... in your Load method add a guard around your binding cod...
2009/02/14
[ "https://Stackoverflow.com/questions/548331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45151/" ]
I have a small problem. I have a set of ComboBox's that are bound to lists which are associated with a set of dictionaries that provide int values for a math equation. I need to filter the result of cb\_test\_2 based on the selection of cb\_test\_1. I think I am close. What happens when I change the value in cb\_test\_...
In InitializeCableSizeCB0(), make sure that you first remove any items from cable\_size0, e.g: ``` private void InitializeCableSizeCB0() { //Cable List, No Exclusions cable_size0.Clear(); cable_size0.Add("Please Select Cable Size"); ... ``` Otherwise you will re-add the same it...
548,346
<p>I'm hoping there are some fellow doctrine users out there.<br /> Here is a simplified YAML of my relationships:</p> <pre><code>Collection: columns: id: { type: integer(4), notnull: true, primary: true, autoincrement: true } name: { type: string(255), notnull: true, unique: true } relat...
[ { "answer_id": 653986, "author": "deresh", "author_id": 11851, "author_profile": "https://Stackoverflow.com/users/11851", "pm_score": 0, "selected": false, "text": "<p>did you try:</p>\n\n<pre><code>foreach($collection-&gt;Items as $item)\n{\n // do something with $item\n}\n</code></p...
2009/02/14
[ "https://Stackoverflow.com/questions/548346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/64381/" ]
I'm hoping there are some fellow doctrine users out there. Here is a simplified YAML of my relationships: ``` Collection: columns: id: { type: integer(4), notnull: true, primary: true, autoincrement: true } name: { type: string(255), notnull: true, unique: true } relations: Items: ...
you have to change the hydration mode to HYDRATE\_SCALAR: > > This hydration mode creates a > flat/rectangular result set that can > contain duplicate data. > > > ``` $res = $q->execute(array(), Doctrine::HYDRATE_SCALAR); ``` (or to HYDRATE\_NONE) as stated in <http://www.doctrine-project.org/documentation/m...
548,353
<p>Is there a function like <code>GETDATE()</code> in Sql Server 2005 that let's you get the max possible date?</p> <p>I do not want to find the highest date in a table. I want to get the max possible date that sql server will be able to store. </p> <p>Basically, I want an expiration date of never</p>
[ { "answer_id": 548359, "author": "Jim Counts", "author_id": 36737, "author_profile": "https://Stackoverflow.com/users/36737", "pm_score": 3, "selected": false, "text": "<p>Consult the documentation.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms187819.aspx\" rel=\"norefer...
2009/02/14
[ "https://Stackoverflow.com/questions/548353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a function like `GETDATE()` in Sql Server 2005 that let's you get the max possible date? I do not want to find the highest date in a table. I want to get the max possible date that sql server will be able to store. Basically, I want an expiration date of never
The [documentation](http://msdn.microsoft.com/en-us/library/ms187819.aspx) says the range is January 1, 1753, through December 31, 9999. I don't think there is a built in function, but you could create one that returns the maximum datetime value. ``` CREATE FUNCTION fn_max_date RETURNS datetime AS return cast('12/31/...
548,354
<p>I'm new to Wicket and was trying the following configuration:</p> <pre><code>class User { private String password; ... public void setPassword(String password) { this.password = MD5.encode(password); } ... } </code></pre> <p>After trying to use the following to bind to the password and findin...
[ { "answer_id": 548549, "author": "Mike Spross", "author_id": 17862, "author_profile": "https://Stackoverflow.com/users/17862", "pm_score": 5, "selected": true, "text": "<p><code>PropertyModel</code> will do what you want already. When a <code>PropertyModel</code> is queried for its value...
2009/02/14
[ "https://Stackoverflow.com/questions/548354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I'm new to Wicket and was trying the following configuration: ``` class User { private String password; ... public void setPassword(String password) { this.password = MD5.encode(password); } ... } ``` After trying to use the following to bind to the password and finding out that the default imp...
`PropertyModel` will do what you want already. When a `PropertyModel` is queried for its value, it looks in two places: * If a "getter" method exists for the given property, the `PropertyModel` calls the getter to retrieve the property's value. Specifically, the `PropertyModel` looks for a method named `get<Property>`...
548,360
<p>I'm trying to create an animated ambient abstract background for my game. I'm picturing something very similar to what Winamp has when you turn on it's visualization plug-in. Here's a link to some <a href="http://www.nullsoft.com/free/milkdrop/screenshots.html" rel="nofollow noreferrer">screenshots</a>. </p> <p>...
[ { "answer_id": 548549, "author": "Mike Spross", "author_id": 17862, "author_profile": "https://Stackoverflow.com/users/17862", "pm_score": 5, "selected": true, "text": "<p><code>PropertyModel</code> will do what you want already. When a <code>PropertyModel</code> is queried for its value...
2009/02/14
[ "https://Stackoverflow.com/questions/548360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61248/" ]
I'm trying to create an animated ambient abstract background for my game. I'm picturing something very similar to what Winamp has when you turn on it's visualization plug-in. Here's a link to some [screenshots](http://www.nullsoft.com/free/milkdrop/screenshots.html). I can handle tweaking the idea once I get somethin...
`PropertyModel` will do what you want already. When a `PropertyModel` is queried for its value, it looks in two places: * If a "getter" method exists for the given property, the `PropertyModel` calls the getter to retrieve the property's value. Specifically, the `PropertyModel` looks for a method named `get<Property>`...
548,363
<p>I'm a bit of a database novice, so pardon my naivety here. I have following sql statement:</p> <pre><code>SELECT DISTINCT dbo.tb_user.familyName, dbo.user_email.email FROM dbo.tb_user INNER JOIN dbo.user_email ON (dbo.tb_user.id = dbo.user_email.userID) </code></pre> <p>This returns records where an email addre...
[ { "answer_id": 548367, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 4, "selected": true, "text": "<p>You need to use a left outer join..</p>\n\n<pre><code>SELECT DISTINCT dbo.tb_user.familyName,dbo.user_email.email \n...
2009/02/14
[ "https://Stackoverflow.com/questions/548363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17510/" ]
I'm a bit of a database novice, so pardon my naivety here. I have following sql statement: ``` SELECT DISTINCT dbo.tb_user.familyName, dbo.user_email.email FROM dbo.tb_user INNER JOIN dbo.user_email ON (dbo.tb_user.id = dbo.user_email.userID) ``` This returns records where an email address exists. What I would l...
You need to use a left outer join.. ``` SELECT DISTINCT dbo.tb_user.familyName,dbo.user_email.email FROM dbo.tb_user LEFT OUTER JOIN dbo.user_email ON (dbo.tb_user.id = dbo.user_email.userID) ```
548,366
<p>I've got an HTTP handler set up in the web.config file:</p> <pre><code> &lt;add verb="*" path="*_*.aspx" type="SeoHandler"/&gt; </code></pre> <p>And have a file SeoHandler.ashx in the root of my web site that points to a SeoHandler.ashx.cs in the App_Code folder (the web site isn't a Web Application project...
[ { "answer_id": 548389, "author": "Colin Bowern", "author_id": 79842, "author_profile": "https://Stackoverflow.com/users/79842", "pm_score": 1, "selected": false, "text": "<p>I am able to get it to work on IIS 7. Are you using a shared hosting provider that have something like URLScan in...
2009/02/14
[ "https://Stackoverflow.com/questions/548366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
I've got an HTTP handler set up in the web.config file: ``` <add verb="*" path="*_*.aspx" type="SeoHandler"/> ``` And have a file SeoHandler.ashx in the root of my web site that points to a SeoHandler.ashx.cs in the App\_Code folder (the web site isn't a Web Application project). When I run the site locally...
Check in IIS on the server that the .NET handler is not set to verify the requested path physically exists: * Go to Properties of the web site or virtual directory * Home Directory tab * Click "Configuration" in the lower section * Find the extension for .ASPX and click edit, there is a checkbox that says "Verify that...
548,390
<p>I'm trying to find a good reference to help me convert this TSQL statement to Linq:</p> <p>EXAMPLE:</p> <pre><code>SELECT * FROM Categories WHERE ProductID IN (SELECT ProductID FROM ProductCategories WHERE CatID = 23) </code></pre> <p>I can't find anywhere that references how to do the WHERE "IN" part.</p>
[ { "answer_id": 548400, "author": "Eric King", "author_id": 18938, "author_profile": "https://Stackoverflow.com/users/18938", "pm_score": 3, "selected": true, "text": "<p>While it's not <em>exactly</em> a TSQL to LINQ reference, I have found the <a href=\"http://msdn.microsoft.com/en-us/v...
2009/02/14
[ "https://Stackoverflow.com/questions/548390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47167/" ]
I'm trying to find a good reference to help me convert this TSQL statement to Linq: EXAMPLE: ``` SELECT * FROM Categories WHERE ProductID IN (SELECT ProductID FROM ProductCategories WHERE CatID = 23) ``` I can't find anywhere that references how to do the WHERE "IN" part.
While it's not *exactly* a TSQL to LINQ reference, I have found the [101 LINQ Samples](http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx) page on MSDN helpful for this purpose. See also [this related question](https://stackoverflow.com/questions/51339/how-can-you-handle-an-in-sub-query-with-linq-to-sql)
548,402
<p>Out of no particular reason I decided to look for an algorithm that produces all possible choices of k integers between 1...n, where the order amongst the k integer doesn't matter (the n choose k thingy). </p> <p>From the exact same reason, which is no reason at all, I also implemented it in C#. My question is:</p>...
[ { "answer_id": 548471, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": -1, "selected": false, "text": "<p>Here's a relatively simple/efficient nCr program I wrote a while ago in C:</p>\n\n<pre><code>main(n,k){float t=0,r=1;f...
2009/02/14
[ "https://Stackoverflow.com/questions/548402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6827/" ]
Out of no particular reason I decided to look for an algorithm that produces all possible choices of k integers between 1...n, where the order amongst the k integer doesn't matter (the n choose k thingy). From the exact same reason, which is no reason at all, I also implemented it in C#. My question is: *Do you see ...
In C++ given the following routine: ``` template <typename Iterator> inline bool next_combination(const Iterator first, Iterator k, const Iterator last) { /* Credits: Thomas Draper */ if ((first == last) || (first == k) || (last == k)) return false; Iterator itr1 = first; Iterator itr2 = last; ++i...
548,406
<p><strong>SYMPTOM:</strong></p> <p>I have <strong>Test_virtual.asp</strong> with the following:</p> <pre><code>&lt;body&gt;&amp;nbsp; included content starts here: &lt;!--#include virtual="/test_included.txt"--&gt; &lt;/body&gt; </code></pre> <p><strong>test_included.txt</strong> contains only:</p> <blockquote> ...
[ { "answer_id": 548433, "author": "Bert Lamb", "author_id": 282, "author_profile": "https://Stackoverflow.com/users/282", "pm_score": 0, "selected": false, "text": "<p>Try using file instead of virtual:</p>\n\n<pre><code>&lt;!--#include file=\"../test_included.txt\"--&gt;\n</code></pre>\n...
2009/02/14
[ "https://Stackoverflow.com/questions/548406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4906/" ]
**SYMPTOM:** I have **Test\_virtual.asp** with the following: ``` <body>&nbsp; included content starts here: <!--#include virtual="/test_included.txt"--> </body> ``` **test\_included.txt** contains only: > > This is the included file > > > When I browse to test\_virtual.asp, I don't see the included file's te...
More info: it looks like the issue is that Includes are disabled by default. I figured out that I can get to the Handler Setting in the IIS7 Manager but it's telling me that I have to manage them direclty in the config file b/c the site is in a shared app pool running in Classsic mode. How many programmers does it ta...
548,414
<p>Is there any plugin for emacs to automatically update the TAGS file in my C project (for example on buffer save or access) or create a new one if there is no TAGS file present? </p> <p>I am running on Windows (without Cygwin), so all the fancy shell scripting does not help. I was hoping for a native emacs solution ...
[ { "answer_id": 548436, "author": "Steve Rowe", "author_id": 40744, "author_profile": "https://Stackoverflow.com/users/40744", "pm_score": 2, "selected": false, "text": "<p>Why not add an execution of ctags to your build script? You really only need a new tags file when you compile (at t...
2009/02/14
[ "https://Stackoverflow.com/questions/548414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2386/" ]
Is there any plugin for emacs to automatically update the TAGS file in my C project (for example on buffer save or access) or create a new one if there is no TAGS file present? I am running on Windows (without Cygwin), so all the fancy shell scripting does not help. I was hoping for a native emacs solution not using ...
Here is how I generate a TAGS file for a C project: 1. M-x cd YOUR\_DIRECTORY 2. M-x compile 3. find . -name "\*.[chCH]" -print | etags - That will create a TAGS file in the current directory for all sub directories and files. Here is a emacs function that does the exact same thing: ``` (defun compile-tags () "co...
548,420
<p>I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script.</p> <p>The files have the following structure:</p> <pre><code>field 1, field 2, ... field n data </code></pre>...
[ { "answer_id": 548434, "author": "jrockway", "author_id": 8457, "author_profile": "https://Stackoverflow.com/users/8457", "pm_score": 3, "selected": false, "text": "<p>You are unlikely to notice any speed difference between Perl, Python,\nand sed. Your script will spend most of its time...
2009/02/14
[ "https://Stackoverflow.com/questions/548420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18300/" ]
I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script. The files have the following structure: ``` field 1, field 2, ... field n data ``` and, given the likelihood of...
To edit the first 10 lines ``` sed -i -e '1,10s/ /_/g' ``` In Perl, you can use the flip-flop operator in scalar context: ``` perl -i -pe 's/ /_/g if 1 .. 10' ```
548,442
<p>A friend and I have been toying around with various Python C++ wrappers lately, trying to find one that meets the needs of both some professional and hobby projects. We've both honed in on <a href="http://cxx.sourceforge.net/" rel="nofollow noreferrer">PyCxx</a> as a good balance between being lightweight and easy t...
[ { "answer_id": 551927, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>I've only done a tiny bit of work with PyCxx, and I'm not at a compiler, but I suspect what you're seeing is similar to the...
2009/02/14
[ "https://Stackoverflow.com/questions/548442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25968/" ]
A friend and I have been toying around with various Python C++ wrappers lately, trying to find one that meets the needs of both some professional and hobby projects. We've both honed in on [PyCxx](http://cxx.sourceforge.net/) as a good balance between being lightweight and easy to interface with while hiding away some ...
You must declare `kitty` as `class new_style_class: public Py::PythonClass< new_style_class >`. See `simple.cxx` and the Python test case at <http://cxx.svn.sourceforge.net/viewvc/cxx/trunk/CXX/Demo/Python3/>. Python 2.2 introduced new-style classes which among other things allow the user to subclass built-in types (l...
548,446
<p>I've got a file INPUT that has the following contents:</p> <pre><code>123\n 456\n 789 </code></pre> <p>I want to run my script like so: script.rb &lt; INPUT and have it convert the contents of the INPUT file to an array, splitting on the new line character. So, I'd having something like myArray = [123,456,789]. He...
[ { "answer_id": 548450, "author": "manveru", "author_id": 8367, "author_profile": "https://Stackoverflow.com/users/8367", "pm_score": 1, "selected": false, "text": "<p>What your are after is <em>using</em> <code>$stdin</code> instead of $stdin.to_s</p>\n\n<pre><code>ruby -e 'p $stdin.read...
2009/02/14
[ "https://Stackoverflow.com/questions/548446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66348/" ]
I've got a file INPUT that has the following contents: ``` 123\n 456\n 789 ``` I want to run my script like so: script.rb < INPUT and have it convert the contents of the INPUT file to an array, splitting on the new line character. So, I'd having something like myArray = [123,456,789]. Here's what I've tried to do an...
You want ``` myArray = $stdin.readlines ``` That'll get all of $stdin into an array with one array entry per line of input. Note that this is spectacularly inefficient (memory wise) with large input files, so you're far better off using something like: ``` $stdin.each_line do |l| ... end ``` instead of ``` a ...
548,462
<p>I'm trying to work out how to validate a user in my application but i don't know how. I wish create a form with Username and Password to enter in the application(WPF) using Linq toSql to store and validate Username and password in the database but i don't know so much about Linq to Sql so i keep in stuck now. I have...
[ { "answer_id": 548474, "author": "xcud", "author_id": 61396, "author_profile": "https://Stackoverflow.com/users/61396", "pm_score": 1, "selected": false, "text": "<pre><code>validUser = (query.Count() == 0);\n</code></pre>\n" }, { "answer_id": 548476, "author": "Elijah Glover...
2009/02/14
[ "https://Stackoverflow.com/questions/548462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65403/" ]
I'm trying to work out how to validate a user in my application but i don't know how. I wish create a form with Username and Password to enter in the application(WPF) using Linq toSql to store and validate Username and password in the database but i don't know so much about Linq to Sql so i keep in stuck now. I have a ...
Firstly its a best practice to Hash Passwords(one way encryption) with a Salt (random string you tag on the end of your password), I know it sounds complex but it isn't. It isn't a good practice to wrap everything around with try, unless you are The Linq Code Would Be ``` public bool ValidateApplicationUser(string u...
548,465
<p>I am trying to run 500 clients that send some request to the server simultaneously for load testing purpose. The client is a ruby program again. Sounds trivial. But I am facing weird problem with ruby threads. My code looks like this - </p> <pre><code>n = 10 n.times do Thread.new do `calc` end end </code><...
[ { "answer_id": 548501, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>The \"Matz\" C implementation of Ruby (MRI) does not use native threads up through 1.8.6. I believe this is changed in Rub...
2009/02/14
[ "https://Stackoverflow.com/questions/548465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45942/" ]
I am trying to run 500 clients that send some request to the server simultaneously for load testing purpose. The client is a ruby program again. Sounds trivial. But I am facing weird problem with ruby threads. My code looks like this - ``` n = 10 n.times do Thread.new do `calc` end end ``` The code is a sa...
The "Matz" C implementation of Ruby (MRI) does not use native threads up through 1.8.6. I believe this is changed in Ruby 1.9, but I understand we're probably still not going to see great multi-threaded performance due to the Global Interpreter Lock. If you really need good multi-threaded support, and for your softwar...
548,475
<p>Should I use LINQ's <code>Skip()</code> and <code>Take()</code> method for paging, or implement my own paging with a SQL query?</p> <p>Which is most efficient? Why would I choose one over the other?</p> <p>I'm using SQL Server 2008, ASP.NET MVC and LINQ.</p>
[ { "answer_id": 548506, "author": "mandreko", "author_id": 36299, "author_profile": "https://Stackoverflow.com/users/36299", "pm_score": 3, "selected": false, "text": "<p>LinqToSql will automatically convert a .Skip(N1).Take(N2) into the TSQL syntax for you. In fact, every \"query\" you ...
2009/02/14
[ "https://Stackoverflow.com/questions/548475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44533/" ]
Should I use LINQ's `Skip()` and `Take()` method for paging, or implement my own paging with a SQL query? Which is most efficient? Why would I choose one over the other? I'm using SQL Server 2008, ASP.NET MVC and LINQ.
Trying to give you a brief answer to your doubt, if you execute the `skip(n).take(m)` methods on linq (with SQL 2005 / 2008 as database server) your query will be using the `Select ROW_NUMBER() Over ...` statement, with is somehow direct paging in the SQL engine. Giving you an example, I have a db table called `mtcity...
548,487
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/340383/can-a-javascript-object-have-a-prototype-chain-but-also-be-a-function">Can a JavaScript object have a prototype chain, but also be a function?</a> </p> </blockquote> <p>I'm looking to make a callable Jav...
[ { "answer_id": 548589, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 5, "selected": true, "text": "<p>There's nothing to stop you from adding arbitrary properties to a function, eg.</p>\n\n<pre><code>function bar(o) {\n var ...
2009/02/14
[ "https://Stackoverflow.com/questions/548487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10728/" ]
> > **Possible Duplicate:** > > [Can a JavaScript object have a prototype chain, but also be a function?](https://stackoverflow.com/questions/340383/can-a-javascript-object-have-a-prototype-chain-but-also-be-a-function) > > > I'm looking to make a callable JavaScript object, with an arbitrary prototype chain, ...
There's nothing to stop you from adding arbitrary properties to a function, eg. ``` function bar(o) { var f = function() { return "Hello World!"; } o.__proto__ = f.__proto__; f.__proto__ = o; return f; } var o = { x: 5 }; var foo = bar(o); assert(foo() === "Hello World!"); delete foo.x; assert(foo.x =...
548,492
<p>I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ?...
[ { "answer_id": 548598, "author": "gbarry", "author_id": 19512, "author_profile": "https://Stackoverflow.com/users/19512", "pm_score": 0, "selected": false, "text": "<p>The flash drive is only available if the BIOS supports it. And if it does, it would probably let you boot from it alrea...
2009/02/14
[ "https://Stackoverflow.com/questions/548492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65928/" ]
I have recently been studying some bootstrap code which was intended for use with a floppy drive. My goal is to modify the program so that it uses my USB flash drive. Now I see how the INT 13H function has been used with the floppy device, but I guess my question is, how will communicating with the USB drive differ? F...
The simple answer is that if the BIOS can boot from the USB flash drive the same BIOS functions for floppy disk / hard drive access can be used. > > > The happy answer is that a simple technique allows the same boot sector code to access a floppy disk image on a USB flash drive whether it was booted with floppy d...
548,493
<p>I am using mod-wsgi with django, and in django I use pylucene to do full text search.</p> <p>While mod-wsgi is configured to be embedded mode, there is no problem at all. But when mod-wsgi is configured to be daemon mode, the apache just gets stuck, and the browser just keep loading but nothing appears.</p> <p>Th...
[ { "answer_id": 548598, "author": "gbarry", "author_id": 19512, "author_profile": "https://Stackoverflow.com/users/19512", "pm_score": 0, "selected": false, "text": "<p>The flash drive is only available if the BIOS supports it. And if it does, it would probably let you boot from it alrea...
2009/02/14
[ "https://Stackoverflow.com/questions/548493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/65167/" ]
I am using mod-wsgi with django, and in django I use pylucene to do full text search. While mod-wsgi is configured to be embedded mode, there is no problem at all. But when mod-wsgi is configured to be daemon mode, the apache just gets stuck, and the browser just keep loading but nothing appears. Then I identity the...
The simple answer is that if the BIOS can boot from the USB flash drive the same BIOS functions for floppy disk / hard drive access can be used. > > > The happy answer is that a simple technique allows the same boot sector code to access a floppy disk image on a USB flash drive whether it was booted with floppy d...
548,494
<p>Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one.</p> <p>Similar to the EXPLAIN TABLE command in MySQL.</p> <p>Thank you.</p>
[ { "answer_id": 548683, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>All that metadata is held in the DB2 catalog tables in the <code>SYSIBM</code> 'schema'. It varies for the DB2/z main...
2009/02/14
[ "https://Stackoverflow.com/questions/548494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hello everybody I am learning DB2 and would like to know how to see a table's characteristics after I create one. Similar to the EXPLAIN TABLE command in MySQL. Thank you.
In addition to `DESCRIBE TABLE`, you can use the command below ``` DESCRIBE INDEXES FOR TABLE *tablename* SHOW DETAIL ``` to get information about the table's indexes. The most comprehensive detail about a table on Db2 for Linux, UNIX, and Windows can be obtained from the db2look utility, which you can run from a ...
548,505
<p>I have a jar file that runs this code:</p> <pre><code>public class InputOutput { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { boolean cont = true; BufferedReader in = new BufferedReader(new InputStreamReader(System.in...
[ { "answer_id": 548523, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": true, "text": "<p>Using Runtime.exec is platform dependent. </p>\n\n<p>If you're using windows try prepending:</p>\n\n<pre><code>cmd /c\n...
2009/02/14
[ "https://Stackoverflow.com/questions/548505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61664/" ]
I have a jar file that runs this code: ``` public class InputOutput { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { boolean cont = true; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); wh...
Using Runtime.exec is platform dependent. If you're using windows try prepending: ``` cmd /c ``` to ``` java -jar .... etc. et ``` Something like: ``` ...getRuntime().exec("cmd /c java -jar InputOutput.... ``` See this also: [Make system call and return stdout output.](https://stackoverflow.com/questions/2...
548,509
<p>I have check to see if the argument in <code>argv[1]</code> is valid for my file.</p> <p>I have a menu system in its own sub-routine called in main.</p> <p>Reading the file and so on is done in another sub-routine separate from the first, also called in main.</p> <p>How can I transfer the <code>argv[1]</code> to ...
[ { "answer_id": 548515, "author": "Antti Huima", "author_id": 64376, "author_profile": "https://Stackoverflow.com/users/64376", "pm_score": 1, "selected": false, "text": "<pre><code>const char *filename = argv[1];\n</code></pre>\n\n<p>Then pass the pointer to your subroutine. argv[1] rema...
2009/02/14
[ "https://Stackoverflow.com/questions/548509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40120/" ]
I have check to see if the argument in `argv[1]` is valid for my file. I have a menu system in its own sub-routine called in main. Reading the file and so on is done in another sub-routine separate from the first, also called in main. How can I transfer the `argv[1]` to the first sub-routine? Or even the second? `s...
The following code shows how to do exactly what you want, checking that argv[1] exists before passing it to functions as C char-pointers or C++ strings and using the value within that function. ``` #include <cstdlib> #include <iostream> #include <string> using namespace std; static void f1 (char *s) { cout << "1...
548,520
<p>When Mercurial is running under cygwin, it's a bit tricky to figure out how to spawn <a href="http://winmerge.org/" rel="noreferrer">WinMerge</a> to resolve merge conflicts. How can I do this?</p>
[ { "answer_id": 548525, "author": "Joel Spolsky", "author_id": 4, "author_profile": "https://Stackoverflow.com/users/4", "pm_score": 5, "selected": true, "text": "<p>The trick is that cygwin paths are not the same as Windows paths, so you need a little script that converts the cygwin path...
2009/02/14
[ "https://Stackoverflow.com/questions/548520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4/" ]
When Mercurial is running under cygwin, it's a bit tricky to figure out how to spawn [WinMerge](http://winmerge.org/) to resolve merge conflicts. How can I do this?
The trick is that cygwin paths are not the same as Windows paths, so you need a little script that converts the cygwin paths to Windows paths before passing them as arguments to WinMerge. Here's how to do it: (1) Create a shell script in `/usr/bin/winmerge` as follows: ``` #!/bin/sh "/cygdrive/c/Program Files/WinMer...
548,528
<p>Lately my queries before caching into memcache have been taking forever to process! In this example, it took 10 seconds. All I am trying to do is get the 10 most recent hits in this case. </p> <p>I am getting the feeling that it loads all 125,592 rows then only returns 10, am I right?</p> <pre># User@Host: root[ro...
[ { "answer_id": 548531, "author": "womble", "author_id": 60003, "author_profile": "https://Stackoverflow.com/users/60003", "pm_score": 2, "selected": false, "text": "<p>An index on <code>(campaign_id,id)</code> should take care of the first fairly well. But the distinct one is a bit tric...
2009/02/14
[ "https://Stackoverflow.com/questions/548528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59220/" ]
Lately my queries before caching into memcache have been taking forever to process! In this example, it took 10 seconds. All I am trying to do is get the 10 most recent hits in this case. I am getting the feeling that it loads all 125,592 rows then only returns 10, am I right? ``` # User@Host: root[root] @ localhost...
It seems your `campaign_id` index has low selectivity, i. e. there are lots of records with this value. Ordering so many record takes a lot of time. Try to use `INDEX SCAN` on the `PRIMARY KEY` for ordering: ``` /* Edited, as MySQL does not use live feed from the derived source with ORDER BY */ SELECT * FROM hits WH...
548,532
<p>I am using <strong>SQL Server</strong> for the first time and I see that a column property is called <strong>Is Identity</strong>.</p> <p>What does this mean?</p> <p>What are the advantages of marking a column property as <strong>Is Identity = Yes</strong>?</p>
[ { "answer_id": 548542, "author": "Godeke", "author_id": 28006, "author_profile": "https://Stackoverflow.com/users/28006", "pm_score": 6, "selected": true, "text": "<p>It simply means the column uses the <code>Identity(seed, increment)</code> function to provide values for a primary key (...
2009/02/14
[ "https://Stackoverflow.com/questions/548532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
I am using **SQL Server** for the first time and I see that a column property is called **Is Identity**. What does this mean? What are the advantages of marking a column property as **Is Identity = Yes**?
It simply means the column uses the `Identity(seed, increment)` function to provide values for a primary key (usually). It is also known as "Autonumber". The second line below is an example: ``` CREATE TABLE Table ( TableID bigint IDENTITY(1,1) NOT NULL, DateTimeStamp datetime NOT NULL DEFAULT (getdate()), Data nvarch...
548,541
<p>While executing an <code>INSERT</code> statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either:</p> <ul> <li><code>ON DUPLICATE KEY UPDATE</code> which implies an unnecessary update at some cost, or</li> <li><code>I...
[ { "answer_id": 548552, "author": "IEnumerator", "author_id": 34819, "author_profile": "https://Stackoverflow.com/users/34819", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://dev.mysql.com/doc/refman/5.0/en/replace.html\" rel=\"noreferrer\"><code>Replace</code></a> Into se...
2009/02/14
[ "https://Stackoverflow.com/questions/548541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62701/" ]
While executing an `INSERT` statement with many rows, I want to skip duplicate entries that would otherwise cause failure. After some research, my options appear to be the use of either: * `ON DUPLICATE KEY UPDATE` which implies an unnecessary update at some cost, or * `INSERT IGNORE` implies an invitation for other k...
I would recommend using `INSERT...ON DUPLICATE KEY UPDATE`. If you use `INSERT IGNORE`, then the row won't actually be inserted if it results in a duplicate key. But the statement won't generate an error. It generates a warning instead. These cases include: * Inserting a duplicate key in columns with `PRIMARY KEY` or...
548,576
<p>Is there a library for converting strings in as3 into the application/x-www-form-urlencoded format?</p> <p>Specifically, I am looking for the same functionality as the java URLEncoder <a href="http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html" rel="nofollow noreferrer">http://java.sun.com/javase/6/docs...
[ { "answer_id": 548681, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 4, "selected": true, "text": "<p>For encoding URL parameters, both %20 and + are valid representations of the space character, and both <a hre...
2009/02/14
[ "https://Stackoverflow.com/questions/548576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62255/" ]
Is there a library for converting strings in as3 into the application/x-www-form-urlencoded format? Specifically, I am looking for the same functionality as the java URLEncoder <http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html> Unfortunately, as3's escape and encodeURIComponent functions don't do it. Fo...
For encoding URL parameters, both %20 and + are valid representations of the space character, and both [URLVariables.toString()](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html#toString()) and [URLUtil.objectToString()](http://help.adobe.com/en_US/FlashPlatform/reference/a...
548,584
<p>I am wondering how to do this in a functional programming language. Maybe F# or Haskell. </p> <p>Can someone show me an example without using any function calls except for <code>find</code> and <code>rfind</code>?</p> <p>This function finds the next slash using <code>i</code> as the num of <code>slash</code> (&lt;...
[ { "answer_id": 548594, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 2, "selected": false, "text": "<p>So, uh, what is this? Does it just find the 'i'th slash (forward or backward) in the string (or the '-i'th from the end ...
2009/02/14
[ "https://Stackoverflow.com/questions/548584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am wondering how to do this in a functional programming language. Maybe F# or Haskell. Can someone show me an example without using any function calls except for `find` and `rfind`? This function finds the next slash using `i` as the num of `slash` (<0 for backwards). ``` size_t findSlash(const char *sz, size_t i...
In first, your code is broken. `size_t` is unsigned type and never can be `i<0`. In second, your code is ugly std library misuse and ineffective. There should be used regular expression library or such or use handcrafted scanner. Resulting code is far cleaner and faster. For example (I have not been using C for many y...
548,603
<p>Whenever I restrict anonymous access in my MVC site I get a 404 error: </p> <blockquote> <p>Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily...
[ { "answer_id": 548604, "author": "codybartfast", "author_id": 53252, "author_profile": "https://Stackoverflow.com/users/53252", "pm_score": 4, "selected": true, "text": "<p>The default Web.Config contains an error. It has:</p>\n\n<pre><code>&lt;authentication mode=\"Forms\"&gt;\n &lt...
2009/02/14
[ "https://Stackoverflow.com/questions/548603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53252/" ]
Whenever I restrict anonymous access in my MVC site I get a 404 error: > > Server Error in '/' Application. > The resource cannot be found. > Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please r...
The default Web.Config contains an error. It has: ``` <authentication mode="Forms"> <forms loginUrl="~/Account/Login"/> </authentication> ``` This should be: ``` <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn"/> </authentication> ``` (Excuse me asking and answering my own question but it t...
548,613
<p>I have an idea for a simple program to make that will help me with operator precedence in languages like C. The most difficult part of this is parenthesizing the expression. For example, I want this:</p> <pre><code>*a.x++ = *b.x++ </code></pre> <p>Converted to this:</p> <pre><code>((*(((a).(x))++)) = (*(((b).(x))...
[ { "answer_id": 548620, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 3, "selected": false, "text": "<p>You're going to need a parser of some sort that understands operator precendence. The usual version for C is Le...
2009/02/14
[ "https://Stackoverflow.com/questions/548613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
I have an idea for a simple program to make that will help me with operator precedence in languages like C. The most difficult part of this is parenthesizing the expression. For example, I want this: ``` *a.x++ = *b.x++ ``` Converted to this: ``` ((*(((a).(x))++)) = (*(((b).(x))++))) ``` Which I did manually in t...
Just pick up a parser for your selected language, for instance [C parser](http://code.google.com/p/pycparser/), parse the expression/source code and print the AST back in the way you want. test.c: ``` void main(void){ int c = 2; } ``` terminal: ``` $ python >>> import pycparser >>> test = pycparser.parse_file(...