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
288,794
<p>For instance, does the compiler know to translate</p> <pre><code>string s = "test " + "this " + "function"; </code></pre> <p>to</p> <pre><code>string s = "test this function"; </code></pre> <p>and thus avoid the performance hit with the string concatenation?</p>
[ { "answer_id": 288802, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Yes. This is guaranteed by the C# specification. It's in section 7.18 (of the C# 3.0 spec):</p>\n\n<blockquote>\n <p>...
2008/11/13
[ "https://Stackoverflow.com/questions/288794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
For instance, does the compiler know to translate ``` string s = "test " + "this " + "function"; ``` to ``` string s = "test this function"; ``` and thus avoid the performance hit with the string concatenation?
Yes. This is guaranteed by the C# specification. It's in section 7.18 (of the C# 3.0 spec): > > Whenever an expression fulfills the > requirements listed above, the > expression is evaluated at > compile-time. This is true even if the > expression is a sub-expression of a > larger expression that contains > non...
288,800
<p>I have this naive regex "&lt;([\s]|[^&lt;])+?>" (excluding the quotation marks). It seems so straightforward but it is indeed evil when it works against the below HTML text. It sends the Java regular expression engine to an infinite loop. </p> <p>I have another regex ("&lt;.+?>"), which does somewhat the same thing...
[ { "answer_id": 288843, "author": "localshred", "author_id": 29690, "author_profile": "https://Stackoverflow.com/users/29690", "pm_score": 2, "selected": false, "text": "<p>The regex <code>([\\s]|[^&lt;])</code> in plain terms means any single character that IS white-space or IS NOT a <co...
2008/11/13
[ "https://Stackoverflow.com/questions/288800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
I have this naive regex "<([\s]|[^<])+?>" (excluding the quotation marks). It seems so straightforward but it is indeed evil when it works against the below HTML text. It sends the Java regular expression engine to an infinite loop. I have another regex ("<.+?>"), which does somewhat the same thing, but it doesn't ki...
The reason the Java regex engine crashes is that this part of your regex causes a stack overflow (indeed!): ``` [\s]|[^<] ``` What happens here is that every character matched by \s can also be matched by [^<]. That means there are two ways to match each whitespace character. If we represent the two character classe...
288,810
<p>Getting the subdomain from a URL sounds easy at first.</p> <pre><code>http://www.domain.example </code></pre> <p>Scan for the first period then return whatever came after the "http://" ...</p> <p>Then you remember</p> <pre><code>http://super.duper.domain.example </code></pre> <p>Oh. So then you think, okay, fin...
[ { "answer_id": 288864, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 7, "selected": true, "text": "<blockquote>\n <p>Anyone have any great ideas besides\n storing a list of all TLDs?</p>\n</blockquote>\n\n<p>No, because...
2008/11/13
[ "https://Stackoverflow.com/questions/288810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37522/" ]
Getting the subdomain from a URL sounds easy at first. ``` http://www.domain.example ``` Scan for the first period then return whatever came after the "http://" ... Then you remember ``` http://super.duper.domain.example ``` Oh. So then you think, okay, find the last period, go back a word and get everything bef...
> > Anyone have any great ideas besides > storing a list of all TLDs? > > > No, because each TLD differs on what counts as a subdomain, second level domain, etc. Keep in mind that there are top level domains, second level domains, and subdomains. Technically speaking, everything except the TLD is a subdomain. I...
288,811
<p>I am seeing a strange problem:</p> <p>I have a linux machine, installed JDK1.6 on that machine, and some business went on, and some days later had to change the IP address of the machine. and now after some months... i am trying to get some spring application to work... and it seems the RMI Server is starting at my...
[ { "answer_id": 289344, "author": "Michael Rutherfurd", "author_id": 33889, "author_profile": "https://Stackoverflow.com/users/33889", "pm_score": 0, "selected": false, "text": "<p>Have you checked your spring config to ensure you don't have an old reference somewhere?</p>\n" }, { ...
2008/11/13
[ "https://Stackoverflow.com/questions/288811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10398/" ]
I am seeing a strange problem: I have a linux machine, installed JDK1.6 on that machine, and some business went on, and some days later had to change the IP address of the machine. and now after some months... i am trying to get some spring application to work... and it seems the RMI Server is starting at my old ip ad...
ok, thanks for the response... i really appreciate that...but i was probably too drunk to notice the entries in my /etc/hosts file were binding my hostname to the old IP address...so as soon as i removed that...things worked like a charm.
288,813
<p>In Delphi 2006, I am showing a modal form. User input in that form can change data that might be displayed currently on the parent form which is the mainform. To reflect those changes I need to force a repaint of some ownerdrawn components on the mainform. I tried to do that like this from the modal form:</p> <pre>...
[ { "answer_id": 288819, "author": "Kluge", "author_id": 8752, "author_profile": "https://Stackoverflow.com/users/8752", "pm_score": 0, "selected": false, "text": "<p>Is it possible that you are doing something in the child form to block messages? Does adding:</p>\n\n<pre><code>Applicatio...
2008/11/13
[ "https://Stackoverflow.com/questions/288813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35657/" ]
In Delphi 2006, I am showing a modal form. User input in that form can change data that might be displayed currently on the parent form which is the mainform. To reflect those changes I need to force a repaint of some ownerdrawn components on the mainform. I tried to do that like this from the modal form: ``` MainForm...
Maybe worth mentioning that if you are using a skinning library that can affect things too. I found that I had to get the skinning library to refresh, not the form.
288,814
<p>I have this code in my aspx page;</p> <pre><code>&lt;a href="javascript:void(0);" onclick=&lt;% Print(); %&gt; title="Print listings"&gt;Print&lt;/a&gt; </code></pre> <p>which presents a link to print a listings to a pdf when the user clicks on it; as you can note the script calls a function from the behind code.<...
[ { "answer_id": 288840, "author": "Dean Maughan", "author_id": 20112, "author_profile": "https://Stackoverflow.com/users/20112", "pm_score": 0, "selected": false, "text": "<p>Its a bit hard to tell exactly what is happening from your code snippet, but I would assume that you are outputtin...
2008/11/13
[ "https://Stackoverflow.com/questions/288814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1130097/" ]
I have this code in my aspx page; ``` <a href="javascript:void(0);" onclick=<% Print(); %> title="Print listings">Print</a> ``` which presents a link to print a listings to a pdf when the user clicks on it; as you can note the script calls a function from the behind code. The problem is that when I coded this it ha...
You want to use a HyperlinkControl and wire up the OnClick event handler to your code behind Print method. When the user then clicks on the link, the page will post back and the OnClick event gets raised. From there you can print your PDF. In your example the Print() function is getting evaluated when the page loads. ...
288,828
<p>I need to test a JDBC connection to a database. The java code to do that should be as simple as:</p> <pre><code>DriverManager.getConnection("jdbc connection URL", "username", "password"); </code></pre> <p>The driver manager will lookup the appropriate the driver for the given connection URL. However I need to be a...
[ { "answer_id": 288941, "author": "SaM", "author_id": 883, "author_profile": "https://Stackoverflow.com/users/883", "pm_score": 5, "selected": true, "text": "<p>From the article <a href=\"http://www.kfu.com/~nsayer/Java/dyn-jdbc.html\" rel=\"noreferrer\">Pick your JDBC driver at runtime</...
2008/11/14
[ "https://Stackoverflow.com/questions/288828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/883/" ]
I need to test a JDBC connection to a database. The java code to do that should be as simple as: ``` DriverManager.getConnection("jdbc connection URL", "username", "password"); ``` The driver manager will lookup the appropriate the driver for the given connection URL. However I need to be able to load the JDBC drive...
From the article [Pick your JDBC driver at runtime](http://www.kfu.com/~nsayer/Java/dyn-jdbc.html); I am just going to post the code here for reference. The idea is to trick the driver manager into thinking that the driver was loaded from the system classloader. To do this we use this class: ``` public class Delegati...
288,850
<p>I am using .Net framework 2.0 / jQuery to make an Ajax call to a 2.0 web service. No matter what I set the contentType to in the ajax call, the service always returns XML. I want it to return Json!</p> <p>Here is the call:</p> <pre><code> $(document).ready(function() { $.ajax({ type: "POS...
[ { "answer_id": 288862, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "<p>You probably can't do anything other than XML or binary serialization in .NET 2.0. If you're not using an autogenerat...
2008/11/14
[ "https://Stackoverflow.com/questions/288850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7232/" ]
I am using .Net framework 2.0 / jQuery to make an Ajax call to a 2.0 web service. No matter what I set the contentType to in the ajax call, the service always returns XML. I want it to return Json! Here is the call: ``` $(document).ready(function() { $.ajax({ type: "POST", url: ...
It's no problem to [return JSON from ASMX services in ASP.NET 2.0](http://encosia.com/2010/03/08/asmx-scriptservice-mistakes-installation-and-configuration/). You just need the ASP.NET AJAX Extensions installed. Do be sure to add the [ScriptService] decoration to your web service. That's what instructs the server side...
288,861
<p>Is there anyway to get Eclipse to automatically look for static imports? For example, now that I've finally upgraded to Junit 4, I'd like to be able to write:</p> <pre><code>assertEquals(expectedValue, actualValue); </code></pre> <p>hit <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd> and have Eclipse add:</p> <...
[ { "answer_id": 288923, "author": "Paul Croarkin", "author_id": 18995, "author_profile": "https://Stackoverflow.com/users/18995", "pm_score": 5, "selected": false, "text": "<p>Not exactly what I wanted, but I found a workaround. In Eclipse 3.4 (Ganymede), go to </p>\n\n<blockquote>\n <p...
2008/11/14
[ "https://Stackoverflow.com/questions/288861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995/" ]
Is there anyway to get Eclipse to automatically look for static imports? For example, now that I've finally upgraded to Junit 4, I'd like to be able to write: ``` assertEquals(expectedValue, actualValue); ``` hit `Ctrl` + `Shift` + `O` and have Eclipse add: ``` import static org.junit.Assert.assertEquals; ``` May...
I'm using Eclipse Europa, which also has the Favorite preference section: > > Window > Preferences > Java > Editor > Content Assist > Favorites > > > In mine, I have the following entries (when adding, use "New Type" and omit the `.*`): ``` org.hamcrest.Matchers.* org.hamcrest.CoreMatchers.* org.junit.* org.ju...
288,867
<p>I need to replace our <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> Modal Popup controls with a JavaScript equivalent. We use this as a simple context sensitive help type popup. I did a quick browse but didn't see quite what I was looking for. I just need some text and a sim...
[ { "answer_id": 288995, "author": "Esteban Küber", "author_id": 34813, "author_profile": "https://Stackoverflow.com/users/34813", "pm_score": 0, "selected": false, "text": "<p>Maybe you are looking for something like <a href=\"http://ui.jquery.com/repository/latest/demos/functional/#ui.di...
2008/11/14
[ "https://Stackoverflow.com/questions/288867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8816/" ]
I need to replace our [Ajax](http://en.wikipedia.org/wiki/Ajax_%28programming%29) Modal Popup controls with a JavaScript equivalent. We use this as a simple context sensitive help type popup. I did a quick browse but didn't see quite what I was looking for. I just need some text and a simple Close button/link, but I wo...
I can provide you the code. Do your modifications as necessary, OK? Page JavaScript: ``` function myPop() { this.square = null; this.overdiv = null; this.popOut = function(msgtxt) { //filter:alpha(opacity=25);-moz-opacity:.25;opacity:.25; this.overdiv = document.createElement("div"); ...
288,875
<p>C#: How would you cycle through items in a listview using next and previous buttons?</p> <p>Background:</p> <p>Let's say you have 10 items in a listview.</p> <p>Next to the listview there are two buttons titled previos and next.</p> <p>Problem:</p> <p>How would you cycle through those listview items after click...
[ { "answer_id": 288896, "author": "Mike Blandford", "author_id": 28643, "author_profile": "https://Stackoverflow.com/users/28643", "pm_score": -1, "selected": false, "text": "<p>Without testing it, I'm guessing this would work:</p>\n\n<pre><code> for(int i=0;i&lt;listView.Items.Count;i++)...
2008/11/14
[ "https://Stackoverflow.com/questions/288875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
C#: How would you cycle through items in a listview using next and previous buttons? Background: Let's say you have 10 items in a listview. Next to the listview there are two buttons titled previos and next. Problem: How would you cycle through those listview items after clicking the Next and or Previous button?
If you just want to select the next item (so with items a, b, c, go from b selected to c selected), you can do this: ``` if (listView.SelectedIndices.Count > 0) { int oldSelection = listView.SelectedIndices[0]; listView.SelectedIndices.Clear(); if (oldSelection + 1 ...
288,877
<p>Is there a way I can set up callbacks on (or automataically log) method parameters, entries, and exits without making explicit calls within each method? I basically want to log this information to my logger class (which is static) without having to do it manually for each method.</p> <p>Right now I have to call Log...
[ { "answer_id": 288888, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": -1, "selected": false, "text": "<p>you could use the magic function <code>__call</code>. It gets called when no functions match that name. Rename your method...
2008/11/14
[ "https://Stackoverflow.com/questions/288877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
Is there a way I can set up callbacks on (or automataically log) method parameters, entries, and exits without making explicit calls within each method? I basically want to log this information to my logger class (which is static) without having to do it manually for each method. Right now I have to call Logger::logEn...
use a wrapper class. this method has the following benefits: * no need to change your underlying class structure / method signatures * change logging? just update this class * update object calls vs inserting code into every class you want to log . ``` class LogWatch { function __construct($class) { $...
288,894
<p>I have a master / detail table and want to update some summary values in the master table against the detail table. I know I can update them like this:</p> <pre><code>update MasterTbl set TotalX = (select sum(X) from DetailTbl where DetailTbl.MasterID = MasterTbl.ID) update MasterTbl set TotalY = (select sum(Y) fr...
[ { "answer_id": 288910, "author": "Chris", "author_id": 34942, "author_profile": "https://Stackoverflow.com/users/34942", "pm_score": 3, "selected": false, "text": "<p>Why are you doing a group by on an update statement? Are you sure that's not the part that's causing the query to fail? T...
2008/11/14
[ "https://Stackoverflow.com/questions/288894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8752/" ]
I have a master / detail table and want to update some summary values in the master table against the detail table. I know I can update them like this: ``` update MasterTbl set TotalX = (select sum(X) from DetailTbl where DetailTbl.MasterID = MasterTbl.ID) update MasterTbl set TotalY = (select sum(Y) from DetailTbl wh...
Try this: ``` Update MasterTbl Set TotalX = Sum(D.X), TotalY = Sum(D.Y), TotalZ = Sum(D.Z) From MasterTbl M Join DetailTbl D On D.MasterID = M.MasterID ``` Depending on which database you are using, if that doesn't work, then try this (this is non-standard SQL but legal in SQL Server): ```...
288,900
<p>I have a string which holds a decimal value in it and I need to convert that string into a floating point variable. So an example of the string I have is "5.45" and I want a floating point equivalent so I can add .1 to it. I have searched around the internet, but I only see how to convert a string to an integer.</p>...
[ { "answer_id": 288907, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 8, "selected": true, "text": "<p>You don't need to convert it at all:</p>\n\n<pre><code>% perl -e 'print \"5.45\" + 0.1;'\n5.55\n</code></pre>\n" }, { ...
2008/11/14
[ "https://Stackoverflow.com/questions/288900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/340/" ]
I have a string which holds a decimal value in it and I need to convert that string into a floating point variable. So an example of the string I have is "5.45" and I want a floating point equivalent so I can add .1 to it. I have searched around the internet, but I only see how to convert a string to an integer.
You don't need to convert it at all: ``` % perl -e 'print "5.45" + 0.1;' 5.55 ```
288,942
<p>How to convert last 3 digits of number into 0</p> <p>example 3444678 to 3444000</p> <p>I can do like </p> <p>(int)(3444678/1000) * 1000= 3444000</p> <p>But division and multiplication could be costly...</p> <p>Any other solution????</p>
[ { "answer_id": 288946, "author": "Jesse Beder", "author_id": 112, "author_profile": "https://Stackoverflow.com/users/112", "pm_score": 5, "selected": true, "text": "<p>You could try</p>\n\n<pre><code>n - (n % 1000)\n</code></pre>\n\n<p>but the modulus operator might be as costly as a div...
2008/11/14
[ "https://Stackoverflow.com/questions/288942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33411/" ]
How to convert last 3 digits of number into 0 example 3444678 to 3444000 I can do like (int)(3444678/1000) \* 1000= 3444000 But division and multiplication could be costly... Any other solution????
You could try ``` n - (n % 1000) ``` but the modulus operator might be as costly as a division. In any case, this sounds an awful lot like a micro-optimization. Is this really your bottleneck?
288,954
<p>I'm fairly new to WPF and I've come across a problem that seems a bit tricky to solve. Basically I want a 4x4 grid thats scalable but keeps a square (or any other arbitrary) aspect ratio. This actually seems quite tricky to do, which surprises me because I would imagine its a reasonably common requirement.</p> <p...
[ { "answer_id": 289277, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": -1, "selected": false, "text": "<p>put 0.25* instead of * for each Column and RowWidth</p>\n" }, { "answer_id": 289425, "author": "Donnelle", ...
2008/11/14
[ "https://Stackoverflow.com/questions/288954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
I'm fairly new to WPF and I've come across a problem that seems a bit tricky to solve. Basically I want a 4x4 grid thats scalable but keeps a square (or any other arbitrary) aspect ratio. This actually seems quite tricky to do, which surprises me because I would imagine its a reasonably common requirement. I start wit...
You need to put the content (the grid) inside a [Viewbox](http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.aspx) and set the [Viewbox.Stretch Property](http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.stretch.aspx) to [Stretch.Uniform](http://msdn.microsoft.com/en-us/librar...
288,966
<p>How would you describe the running time of this sort, given a function <code>sorted</code> which returns True if the list is sorted that runs in O(n):</p> <pre><code>def sort(l): while not sorted(l): random.shuffle(l) </code></pre> <p>Assume shuffling is perfectly random. </p> <p>Would this be written in big-...
[ { "answer_id": 288971, "author": "Pyrolistical", "author_id": 21838, "author_profile": "https://Stackoverflow.com/users/21838", "pm_score": 3, "selected": false, "text": "<p>Believe it or not, there's a wiki entry for this:\n<a href=\"http://en.wikipedia.org/wiki/Bogosort\" rel=\"norefer...
2008/11/14
[ "https://Stackoverflow.com/questions/288966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
How would you describe the running time of this sort, given a function `sorted` which returns True if the list is sorted that runs in O(n): ``` def sort(l): while not sorted(l): random.shuffle(l) ``` Assume shuffling is perfectly random. Would this be written in big-O notation? Or is there some other way of ca...
This Algorithm is called [Bogosort](http://Wikipedia.Org/wiki/Bogosort "Bogosort"). It is an instance of a class of Algorithms called [Las Vegas Algorithms](http://Wikipedia.Org/wiki/Las_Vegas_algorithm "Las Vegas Algorithm"). Las Vegas Algorithms are [Randomized Algorithms](http://Wikipedia.Org/wiki/Randomized_algorit...
288,968
<p>Is it possible to perform a named-group match in Perl's regex syntax as with Python's? I always bind the <code>$n</code> values to proper names after matching, so I'd find it more convenient to do it in the regex itself if it's possible.</p> <p>Python does it like so:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;...
[ { "answer_id": 288983, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": false, "text": "<p>AFIK <a href=\"http://en.wikipedia.org/wiki/PCRE\" rel=\"noreferrer\">PCRE</a> has named group capturing as:...
2008/11/14
[ "https://Stackoverflow.com/questions/288968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
Is it possible to perform a named-group match in Perl's regex syntax as with Python's? I always bind the `$n` values to proper names after matching, so I'd find it more convenient to do it in the regex itself if it's possible. Python does it like so: ``` >>> import re >>> regex = re.compile(r'(?P<count>\d+)') >>> mat...
Perl uses `(?<NAME>pattern)` to specify names captures. You have to use the `%+` hash to retrieve them. ``` $variable =~ /(?<count>\d+)/; print "Count is $+{count}"; ``` This is only supported on Perl 5.10 and higher though.
288,988
<p>I was trying to follow some instructions today, and it starts with the comment </p> <pre><code> REM In SQLPlus I manually copy in each line and execute it. </code></pre> <p>That's nice, I don't have SQLPlus, I have SQLDeveloper. The lines that were pasted in were of the type:</p> <pre><code> @\\server\dir\dir\d...
[ { "answer_id": 289086, "author": "David Aldridge", "author_id": 6742, "author_profile": "https://Stackoverflow.com/users/6742", "pm_score": -1, "selected": false, "text": "<p>This would do it:</p>\n\n<pre><code>begin\n procedure_name ('parameter1', 'parameter2');\nend;\n/\n</code></pr...
2008/11/14
[ "https://Stackoverflow.com/questions/288988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22523/" ]
I was trying to follow some instructions today, and it starts with the comment ``` REM In SQLPlus I manually copy in each line and execute it. ``` That's nice, I don't have SQLPlus, I have SQLDeveloper. The lines that were pasted in were of the type: ``` @\\server\dir\dir\dir\commandfile1.txt; COMMIT; ``` ......
To run scripts in SQL Developer: ``` @"\Path\Scriptname.sql" ``` (You only need the quotes if there are any spaces) You can set a default Path: Tools menu > Preferences > Database > Worksheet > Select default path to look for scripts
288,998
<p>I was wondering if anyone can help me get started with creating a room in Sandy 3D. I know I can generate the planes, but I am unsure as to how to implement simple physics (i.e. the player cannot walk through a wall). Is there a simple way to do this, or should I look into something like WOW (3D physics engine for F...
[ { "answer_id": 289086, "author": "David Aldridge", "author_id": 6742, "author_profile": "https://Stackoverflow.com/users/6742", "pm_score": -1, "selected": false, "text": "<p>This would do it:</p>\n\n<pre><code>begin\n procedure_name ('parameter1', 'parameter2');\nend;\n/\n</code></pr...
2008/11/14
[ "https://Stackoverflow.com/questions/288998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21475/" ]
I was wondering if anyone can help me get started with creating a room in Sandy 3D. I know I can generate the planes, but I am unsure as to how to implement simple physics (i.e. the player cannot walk through a wall). Is there a simple way to do this, or should I look into something like WOW (3D physics engine for Flas...
To run scripts in SQL Developer: ``` @"\Path\Scriptname.sql" ``` (You only need the quotes if there are any spaces) You can set a default Path: Tools menu > Preferences > Database > Worksheet > Select default path to look for scripts
289,002
<p>I have a static class that I would like to raise an event as part of a try catch block within a static method of that class.</p> <p>For example in this method I would like to raise a custom event in the catch. </p> <pre><code>public static void saveMyMessage(String message) { try { //Do Database s...
[ { "answer_id": 289043, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Note: VS2008, C#</p>\n\n<p>Just declare an event as you normally would within the static class, but be sure to mark the eve...
2008/11/14
[ "https://Stackoverflow.com/questions/289002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34831/" ]
I have a static class that I would like to raise an event as part of a try catch block within a static method of that class. For example in this method I would like to raise a custom event in the catch. ``` public static void saveMyMessage(String message) { try { //Do Database stuff } catch (...
Important: be very careful about subscribing to a static event from instances. Static-to-static is fine, but a subscription from a static event to an instance handler is a great (read: very dangerous) way to keep that instance alive forever. GC will see the link, and will not collect the instance unless you unsubscribe...
289,003
<p>I have an Asp.Net 1.1 application that uses the following code to write out an image file to a pop up web page.</p> <pre><code> Response.ContentType="image/tiff" 'Only for Tif files Dim objStream As Object objStream = Server.CreateObject("ADODB.Stream") objStream.open() objStream.type = 1 o...
[ { "answer_id": 289015, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 0, "selected": false, "text": "<p>Have you tried setting the <a href=\"http://www.ietf.org/rfc/rfc2183.txt\" rel=\"nofollow noreferrer\">Content-Dispositi...
2008/11/14
[ "https://Stackoverflow.com/questions/289003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1688440/" ]
I have an Asp.Net 1.1 application that uses the following code to write out an image file to a pop up web page. ``` Response.ContentType="image/tiff" 'Only for Tif files Dim objStream As Object objStream = Server.CreateObject("ADODB.Stream") objStream.open() objStream.type = 1 objStream.loadf...
Well, it depends on your audience. But ideally, to support legacy browsers, you shouldn't assume they can handle a TIFF. At the very least, load the TIFF, select the first frame (page), do a DrawImage into a new bitmap, save the bitmap as JPG to a memory stream, and send that to Response. If you're not familiar with ...
289,006
<p>I am trying to write a console app that simply lists the number of lists at the sharepoint root.</p> <p>I tried doing it by using the following code, but the object SPContext.Current is null. Any ideas of how to get the web object?</p> <pre><code> SPWeb web = SPContext.Current.Site.OpenWeb("http://localhost") ; <...
[ { "answer_id": 289026, "author": "Nat", "author_id": 13813, "author_profile": "https://Stackoverflow.com/users/13813", "pm_score": 3, "selected": true, "text": "<pre><code>SPSite spSite = new SPSite(\"http://myurl\");\nSPWeb spMySite = spSite.Allwebs[\"mysite\"];\nSPWeb spRootsite = spsi...
2008/11/14
[ "https://Stackoverflow.com/questions/289006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12497/" ]
I am trying to write a console app that simply lists the number of lists at the sharepoint root. I tried doing it by using the following code, but the object SPContext.Current is null. Any ideas of how to get the web object? ``` SPWeb web = SPContext.Current.Site.OpenWeb("http://localhost") ; ```
``` SPSite spSite = new SPSite("http://myurl"); SPWeb spMySite = spSite.Allwebs["mysite"]; SPWeb spRootsite = spsite.RootWeb; ``` The console app will only run on the server as usual. Also, the url used <http://myurl> can be a url to a page and an SPSite object will be created. E.g. <http://myurl/mysite/pages/default...
289,010
<p>Similar to <a href="https://stackoverflow.com/questions/188141/c-list-orderby-alphabetical-order">List&lt;&gt; OrderBy Alphabetical Order</a>, we want to sort by one element, then another. we want to achieve the functional equivalent of </p> <pre><code>SELECT * from Table ORDER BY x, y </code></pre> <p>We have ...
[ { "answer_id": 289021, "author": "Toby", "author_id": 291137, "author_profile": "https://Stackoverflow.com/users/291137", "pm_score": 7, "selected": false, "text": "<p>For versions of .Net where you can use LINQ <code>OrderBy</code> and <a href=\"http://msdn.microsoft.com/en-us/library/v...
2008/11/14
[ "https://Stackoverflow.com/questions/289010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1811110/" ]
Similar to [List<> OrderBy Alphabetical Order](https://stackoverflow.com/questions/188141/c-list-orderby-alphabetical-order), we want to sort by one element, then another. we want to achieve the functional equivalent of ``` SELECT * from Table ORDER BY x, y ``` We have a class that contains a number of sorting fu...
Do keep in mind that you don't need a stable sort if you compare all members. The 2.0 solution, as requested, can look like this: ``` public void SortList() { MyList.Sort(delegate(MyClass a, MyClass b) { int xdiff = a.x.CompareTo(b.x); if (xdiff != 0) return xdiff; else return a.y...
289,030
<p>I am having a Html hyperlink. I need to link this hyperlink to another page.When I place the mouse over the link. It should show the image. how to do this</p>
[ { "answer_id": 289042, "author": "José Leal", "author_id": 37190, "author_profile": "https://Stackoverflow.com/users/37190", "pm_score": 0, "selected": false, "text": "<p>you can do this using javascript..</p>\n\n<p>This will create a square that follows your mouse on div or element hove...
2008/11/14
[ "https://Stackoverflow.com/questions/289030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I am having a Html hyperlink. I need to link this hyperlink to another page.When I place the mouse over the link. It should show the image. how to do this
That depends on where you need to display the image. If you are looking for something along the lines of an icon next to or behind the link, you could accomplish this through CSS using a background image on the hover state of the link: ``` a:link { background-image:none; } a:hover { background-image:url('images...
289,076
<p>Example C API signature:</p> <p><code>void Func(unsigned char* bytes);</code></p> <p>In C, when I want to pass a pointer to an array, I can do:</p> <pre><code>unsigned char* bytes = new unsigned char[1000]; Func(bytes); // call </code></pre> <p>How do I translate the above API to P/Invoke such that I can pass a ...
[ { "answer_id": 289088, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": "<p>You can use unsafe code:</p>\n\n<pre><code>unsafe \n{\n fixed(byte* pByte = byteArray)\n IntPtr intPtr = new IntP...
2008/11/14
[ "https://Stackoverflow.com/questions/289076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11238/" ]
Example C API signature: `void Func(unsigned char* bytes);` In C, when I want to pass a pointer to an array, I can do: ``` unsigned char* bytes = new unsigned char[1000]; Func(bytes); // call ``` How do I translate the above API to P/Invoke such that I can pass a pointer to C# byte array?
The easiest way to pass an array of bytes is to declare the parameter in your import statement as a byte array. ``` [DllImport EntryPoint="func" CharSet=CharSet.Auto, SetLastError=true] public extern static void Func(byte[]); byte[] ar = new byte[1000]; Func(ar); ``` You should also be able to declare the paramete...
289,082
<p>Given the following class, what is your opinion on the best way to handle create/edit where Attributes.Count can be any number.</p> <pre><code>public class Product { public int Id {get;set;} public string Name {get;set;} public IList&lt;Attribute&gt; Attributes {get;set;} } public class Attribute { public...
[ { "answer_id": 289090, "author": "Andrew Van Slaars", "author_id": 8087, "author_profile": "https://Stackoverflow.com/users/8087", "pm_score": 0, "selected": false, "text": "<p>Depends on the experience you are looking to create for the user. I have implemented something similar for tagg...
2008/11/14
[ "https://Stackoverflow.com/questions/289082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34133/" ]
Given the following class, what is your opinion on the best way to handle create/edit where Attributes.Count can be any number. ``` public class Product { public int Id {get;set;} public string Name {get;set;} public IList<Attribute> Attributes {get;set;} } public class Attribute { public string Name {get;set...
Use the FormCollection and iterate through the key/value pairs. Presumably you can use a naming scheme that will allow you to determine which key/value pairs belong to your attribute set. ``` [AcceptVerbs( HttpVerb.POST )] public ActionResult Whatever( FormCollection form ) { .... } ```
289,092
<p>How do I execute a command every time after ssh'ing from one machine to another?</p> <p>e.g</p> <pre><code>ssh mymachine stty erase ^H </code></pre> <p>I'd rather just have "stty erase ^H" execute every time after my ssh connection completes.</p> <p>This command can't simply go into my .zshrc file. i.e. for loc...
[ { "answer_id": 289099, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 0, "selected": false, "text": "<p>Assuming a linux target, put it in your <code>.profile</code> </p>\n" }, { "answer_id": 289100, "author":...
2008/11/14
[ "https://Stackoverflow.com/questions/289092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
How do I execute a command every time after ssh'ing from one machine to another? e.g ``` ssh mymachine stty erase ^H ``` I'd rather just have "stty erase ^H" execute every time after my ssh connection completes. This command can't simply go into my .zshrc file. i.e. for local sessions, I can't run the command (it ...
Put the commands in `~/.ssh/rc`
289,093
<p>I have a controller action that is being executed by a link that was created using 'Ajax.ActionLink()' the problem is that I can't tell in my action that the request is an AJAX request because <code>Request.IsMvcAjaxRequest()</code> is always returning false.</p> <p>Does <code>Request.IsMvcAjaxRequest()</code> not ...
[ { "answer_id": 289145, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 0, "selected": false, "text": "<p>Because \"IsMvcAjaxRequest\" just returns (request[\"__MVCASYNCPOST\"] == true), and that checks the query strin...
2008/11/14
[ "https://Stackoverflow.com/questions/289093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
I have a controller action that is being executed by a link that was created using 'Ajax.ActionLink()' the problem is that I can't tell in my action that the request is an AJAX request because `Request.IsMvcAjaxRequest()` is always returning false. Does `Request.IsMvcAjaxRequest()` not work with `Ajax.ActionLink()` ge...
There are no form parameters on a delete. Try adding \_\_MVCASYNCPOST=true as route data (query parameter in the url)
289,098
<p>Given the following domain classes:</p> <pre><code>class Post { SortedSet tags static hasMany = [tags: Tag] } class Tag { static belongsTo = Post static hasMany = [posts: Post] } </code></pre> <p>From my understanding so far, using a <code>hasMany</code> will result in hibernate <code>Set</code> mappi...
[ { "answer_id": 290124, "author": "Miguel Ping", "author_id": 22992, "author_profile": "https://Stackoverflow.com/users/22992", "pm_score": 0, "selected": false, "text": "<p>The ordering of the set is guaranteed by the <code>Set</code> implementation, ie, the <code>SortedSet</code>. Unles...
2008/11/14
[ "https://Stackoverflow.com/questions/289098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27163/" ]
Given the following domain classes: ``` class Post { SortedSet tags static hasMany = [tags: Tag] } class Tag { static belongsTo = Post static hasMany = [posts: Post] } ``` From my understanding so far, using a `hasMany` will result in hibernate `Set` mapping. However, in order to maintain uniqueness/ord...
There is no order ensured by Hibernate/GORM in the default mapping. Therefore, it doesn't have to load elements from the database in order to do the sorting. You will have your hands on a bunch of ids, but that's that extent of it. See 19.5.2: <http://www.hibernate.org/hib_docs/reference/en/html/performance-collection...
289,106
<p><a href="https://stackoverflow.com/questions/286584/can-i-specify-interfaces-when-i-declare-a-member#287669">Can I specify interfaces when I declare a member?</a></p> <p>After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined clas...
[ { "answer_id": 289141, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>I don't see the point. Why not be explicit that the class implements the interface and have done with it? Implemen...
2008/11/14
[ "https://Stackoverflow.com/questions/289106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32998/" ]
[Can I specify interfaces when I declare a member?](https://stackoverflow.com/questions/286584/can-i-specify-interfaces-when-i-declare-a-member#287669) After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an in...
Statically-typed languages, by definition, check types at *compile time*, not *run time*. One of the obvious problems with the system described above is that the compiler is going to check types when the program is compiled, not at run time. Now, you could build more intelligence into the compiler so it could *derive*...
289,122
<p>I have a chart with a series that denotes a large set (1000's) of discrete measurements. Some of these are bad measurements and I want to colour the line for the series based on another set of data that describes how accurate the measurements are. Bad measurements should be red and good measurements green and the in...
[ { "answer_id": 289203, "author": "Elijah", "author_id": 33611, "author_profile": "https://Stackoverflow.com/users/33611", "pm_score": 1, "selected": false, "text": "<p>Are you locked into VBA? One way this could be accomplished is by open up your OOXML .xlsx document archive (it is actua...
2008/11/14
[ "https://Stackoverflow.com/questions/289122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31045/" ]
I have a chart with a series that denotes a large set (1000's) of discrete measurements. Some of these are bad measurements and I want to colour the line for the series based on another set of data that describes how accurate the measurements are. Bad measurements should be red and good measurements green and the in be...
It is easy enough to colour a chart line in VBA. Here are some notes. ``` Dim cht As Chart Dim sc As Series Dim blnBad As Boolean Dim j j = 85 'RGB orange ' blnBad = False 'This is a chart called Chart 1, it would be possible ' 'to use the charts collection ' Set cht = ActiveSheet.ChartObjects("Chart 1").Chart 'A c...
289,171
<p>What is the point of an action returning ActionResult?</p>
[ { "answer_id": 289179, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>ActionResult is the base class for many different types of controller results. By returning the base class, the con...
2008/11/14
[ "https://Stackoverflow.com/questions/289171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the point of an action returning ActionResult?
Returning an ActionResult instead of "just doing whatever the ActionResult is doing" (i.e. using Response.Redirect directly or trying to render out a View through the Response OutputStream directly) gives you one really nice advantage: Unit Testing is really easy on that, especially since you normally do not need a web...
289,176
<p>I keep seeing the phrase "duck typing" bandied about, and even ran across a code example or two. I am way too <strike>lazy</strike> busy to do my own research, can someone tell me, briefly:</p> <ul> <li>the difference between a 'duck type' and an old-skool 'variant type', and </li> <li>provide an example of where I...
[ { "answer_id": 289189, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 3, "selected": false, "text": "<p>Duck typing is just another term for dynamic typing or late-binding. A variant object that parses/compiles with any m...
2008/11/14
[ "https://Stackoverflow.com/questions/289176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9345/" ]
I keep seeing the phrase "duck typing" bandied about, and even ran across a code example or two. I am way too lazy busy to do my own research, can someone tell me, briefly: * the difference between a 'duck type' and an old-skool 'variant type', and * provide an example of where I might prefer duck typing over variant ...
The simple answer is variant is weakly typed while duck typing is strongly typed. Duck typing can be summed up nicely as "if it walks like a duck, looks like a duck, acts like a duck, then it's a duck." It computer science terms consider duck to be the following interface. ``` interface IDuck { void Quack(); } ``...
289,187
<p>I have an Excel macro that deletes a sheet, copies another sheet and renames it to the same name of the deleted sheet. This works fine when run from Excel, but when I run it by calling the macro from Python I get the following error message:</p> <blockquote> <p>Run-time error '1004' - Cannot rename a sheet to the...
[ { "answer_id": 289313, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 2, "selected": false, "text": "<p>I ran the code inside Excel VBA.<br>\nI am guessing that the following line is failing.<br></p>\n\n<p><code>\nSheet...
2008/11/14
[ "https://Stackoverflow.com/questions/289187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an Excel macro that deletes a sheet, copies another sheet and renames it to the same name of the deleted sheet. This works fine when run from Excel, but when I run it by calling the macro from Python I get the following error message: > > Run-time error '1004' - Cannot rename a sheet to the same name as > ano...
I ran the code inside Excel VBA. I am guessing that the following line is failing. `Sheets("CC").Delete` And that is the reason, you can't give the new sheet same name as existing (non-deleted) sheet. Put `Application.DisplayAlerts = False` before `Sheets("CC").Delete` and `Application.DisplayAlerts ...
289,194
<p>We have an home-brewed XMPP server and I was asked what is our server's MSL (Maximum Segment Lifetime).<br> What does it mean and how can I obtain it? Is it something in the Linux <code>/proc</code> TCP settings?</p>
[ { "answer_id": 289238, "author": "Klathzazt", "author_id": 35223, "author_profile": "https://Stackoverflow.com/users/35223", "pm_score": 1, "selected": false, "text": "<p>This looks like it can answer your question:</p>\n\n<p><a href=\"http://seer.support.veritas.com/docs/264886.htm\" re...
2008/11/14
[ "https://Stackoverflow.com/questions/289194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have an home-brewed XMPP server and I was asked what is our server's MSL (Maximum Segment Lifetime). What does it mean and how can I obtain it? Is it something in the Linux `/proc` TCP settings?
The MSL (Maximum Segment Lifetime) is the longest time (in seconds) that a TCP segment is expected to exist in the network. It most notably comes into play during the closing of a TCP connection -- between the CLOSE\_WAIT and CLOSED state, the machine waits 2 MSL's (conceptually a round trip to the end of the internet ...
289,220
<p>Below is my (simplified) schema (in MySQL ver. 5.0.51b) and my strategy for updating it. There has got to be a better way. Inserting a new item requires 4 trips to the database and editing/updating an item takes up to <strong>7</strong>!</p> <p><strong>items</strong>: itemId, itemName <br /><strong>categories</stro...
[ { "answer_id": 289233, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 2, "selected": true, "text": "<p>Steps 6 &amp; 7 can be combined easily enough:</p>\n\n<pre><code>DELETE categories.*\nFROM categories\nLEFT JOIN ma...
2008/11/14
[ "https://Stackoverflow.com/questions/289220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356/" ]
Below is my (simplified) schema (in MySQL ver. 5.0.51b) and my strategy for updating it. There has got to be a better way. Inserting a new item requires 4 trips to the database and editing/updating an item takes up to **7**! **items**: itemId, itemName **categories**: catId, catName **map**: mapId\*, itemId, catId ...
Steps 6 & 7 can be combined easily enough: ``` DELETE categories.* FROM categories LEFT JOIN map USING (catId) WHERE map.catID IS NULL; ``` Steps 3 & 4 can also be combined: ``` INSERT IGNORE INTO map (mapId, itemId, catId) SELECT CONCAT('1|', c.catId), 1, c.catID FROM categories AS c WHERE c.catName IN...
289,241
<p>Forgive me for a potentially silly question here, but in other programming languages (scripting ones like PHP or Perl) it is often easy to dump everything contained within a variable.</p> <p>For instance, in PHP there are the <code>var_dump()</code> or <code>print_r()</code> functions. Perl has the <code>Data::Dump...
[ { "answer_id": 289250, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 3, "selected": false, "text": "<p>Use NSLog() to dump contents of objects. For example:</p>\n\n<pre><code>NSData* myData = //... assume this exists\nN...
2008/11/14
[ "https://Stackoverflow.com/questions/289241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
Forgive me for a potentially silly question here, but in other programming languages (scripting ones like PHP or Perl) it is often easy to dump everything contained within a variable. For instance, in PHP there are the `var_dump()` or `print_r()` functions. Perl has the `Data::Dumper` CPAN class, etc etc. Is there so...
In Cocoa, there is no "dump" like PHP's print\_r or python's **repr** since there is no textual format that "represents" an object as in those languages. If you use ``` NSLog(@"%@", myObj); ``` or ``` NSString *stringRep = [NSString stringWithFormat:@"%@",myObj]; ``` or ``` NSString *stringRep = [myObj descripti...
289,255
<p>Title says it mostly. I want to add a simple extension method to the base Dictionary class in C#. At first I was going to name it Pop(TKey key), kind of like the Stack method, but it accepts a key to use for lookup.</p> <p>Then I was going to do Take(TKey key), but it coincides with the LINQ method of the same name...
[ { "answer_id": 289260, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<p>anything in particular wrong with the <a href=\"http://msdn.microsoft.com/en-us/library/system.collections.idictio...
2008/11/14
[ "https://Stackoverflow.com/questions/289255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16387/" ]
Title says it mostly. I want to add a simple extension method to the base Dictionary class in C#. At first I was going to name it Pop(TKey key), kind of like the Stack method, but it accepts a key to use for lookup. Then I was going to do Take(TKey key), but it coincides with the LINQ method of the same name...and alt...
I reckon **Extract**, like when archaeologists *Find* a mummy in the ground, *Remove it* and then *Return* it to a museum :)
289,274
<p>I have included <code>&lt;zlib.h&gt;</code> in my iphone application and the source code I was mocking up the sample code of Molecules provided by Brad Larson, however, when I build the project, it returns the error as below. Can anyone point out for me whether this is a library linking problem or am I missing some...
[ { "answer_id": 289294, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 7, "selected": true, "text": "<p>In your Target's <code>Build Settings</code> tab, scroll down to the <code>Other Linker Flags</code> section and make...
2008/11/14
[ "https://Stackoverflow.com/questions/289274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35405/" ]
I have included `<zlib.h>` in my iphone application and the source code I was mocking up the sample code of Molecules provided by Brad Larson, however, when I build the project, it returns the error as below. Can anyone point out for me whether this is a library linking problem or am I missing something else? ``` "_de...
In your Target's `Build Settings` tab, scroll down to the `Other Linker Flags` section and make sure `-lz` is in the field. This will link against the built-in zlib, and your error should go away. After changing the Linker Flags you must select `Clean` from the `Product` menu before building again. [![lz screenshot](...
289,276
<p>Here's my code (note that this was given by a friend):</p> <pre><code>Private Sub Browse_Click() Dim textfile As String textfile = Space(255) GetFileNameFromBrowseW Me.hWnd, StrPtr(sSave), 255, StrPtr("c:\"), StrPtr("txt"), StrPtr("Apps (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)...
[ { "answer_id": 289303, "author": "Windows programmer", "author_id": 23705, "author_profile": "https://Stackoverflow.com/users/23705", "pm_score": 0, "selected": false, "text": "<p>Maybe sSave contains a pathname, but textfile contains 255 spaces.</p>\n" }, { "answer_id": 289325, ...
2008/11/14
[ "https://Stackoverflow.com/questions/289276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here's my code (note that this was given by a friend): ``` Private Sub Browse_Click() Dim textfile As String textfile = Space(255) GetFileNameFromBrowseW Me.hWnd, StrPtr(sSave), 255, StrPtr("c:\"), StrPtr("txt"), StrPtr("Apps (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)" + Chr$(0) + ...
From [here](http://allapi.mentalis.org/apilist/GetFileNameFromBrowse.shtml) I found this code and ran it. ``` Private Const VER_PLATFORM_WIN32_NT = 2 Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long ...
289,278
<p>If I have a string "12 23 34 56"</p> <p>What's the easiest way to change it to "\x12 \x23 \x34 \x56"?</p>
[ { "answer_id": 289291, "author": "Jesse Beder", "author_id": 112, "author_profile": "https://Stackoverflow.com/users/112", "pm_score": 2, "selected": false, "text": "<pre><code>string s = \"12 23 34 45\";\nstringstream str(s), out;\nint val;\nwhile(str &gt;&gt; val)\n out &lt;&lt; \"\...
2008/11/14
[ "https://Stackoverflow.com/questions/289278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If I have a string "12 23 34 56" What's the easiest way to change it to "\x12 \x23 \x34 \x56"?
``` string s = "12 23 34 45"; stringstream str(s), out; int val; while(str >> val) out << "\\x" << val << " "; // note: this puts an extra space at the very end also // you could hack that away if you want // here's your new string string modified = out.str(); ```
289,307
<p>Say I have two lists:</p> <pre><code>var list1 = new int[] {1, 2, 3}; var list2 = new string[] {"a", "b", "c"}; </code></pre> <p>Is it possible to write a LINQ statement that will generate the following list:</p> <pre><code>var result = new []{ new {i = 1, s = "a"}, new {i = 1, s = "b"}, new {i = 1, ...
[ { "answer_id": 289310, "author": "Preet Sangha", "author_id": 30225, "author_profile": "https://Stackoverflow.com/users/30225", "pm_score": 5, "selected": false, "text": "<pre><code>var result = from l1 in list1\n from l2 in list2 \n select new { i = l1, s =...
2008/11/14
[ "https://Stackoverflow.com/questions/289307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3820/" ]
Say I have two lists: ``` var list1 = new int[] {1, 2, 3}; var list2 = new string[] {"a", "b", "c"}; ``` Is it possible to write a LINQ statement that will generate the following list: ``` var result = new []{ new {i = 1, s = "a"}, new {i = 1, s = "b"}, new {i = 1, s = "c"}, new {i = 2, s = "a"}, ...
preetsangha's answer is entirely correct, but if you don't want a query expression then it's: ``` var result = list1.SelectMany(l1 => list2, (l1, l2) => new { i = l1, s = l2} ); ``` (That's what the compiler compiles the query expression into - they're identical.)
289,311
<p>I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). <code>java.util.SimpleDateFormat</code> does not seem to output timezone offsets in the <em>hour:minute</em> format, it excludes the colon. Is there a simple way to get that timestamp in Java?</p> <pre><code>// I want 2008-11-13T12:23...
[ { "answer_id": 289322, "author": "FoxyBOA", "author_id": 19347, "author_profile": "https://Stackoverflow.com/users/19347", "pm_score": 2, "selected": false, "text": "<pre><code>SimpleDateFormat format = new SimpleDateFormat(\"yyyy-MM-dd'T'h:m:ss.SZ\");\n</code></pre>\n\n<p>Is not what ex...
2008/11/14
[ "https://Stackoverflow.com/questions/289311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/680/" ]
I want to output a timestamp with a PST offset (e.g., 2008-11-13T13:23:30-08:00). `java.util.SimpleDateFormat` does not seem to output timezone offsets in the *hour:minute* format, it excludes the colon. Is there a simple way to get that timestamp in Java? ``` // I want 2008-11-13T12:23:30-08:00 String timestamp = new...
Starting in Java 7, there's the `X` pattern string for ISO8601 time zone. For strings in the format you describe, use `XXX`. [See the documentation](http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#iso8601timezone). Sample: ``` System.out.println(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"...
289,315
<p>In IE6 the paragraph following the empty paragraph is displayed with the background color of the empty paragraph, which I'm guessing is wrong! It works correctly in Firefox, but I haven't checked IE7.</p> <p>Is there a CSS solution to this problem, or do I have to remove the empty element?</p> <p>(I would rather ...
[ { "answer_id": 289336, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 1, "selected": false, "text": "<p>I just tested that in IE7 and can confirm that it happens there too.</p>\n\n<p>It looks like the unstyled paragraph <strong...
2008/11/14
[ "https://Stackoverflow.com/questions/289315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37572/" ]
In IE6 the paragraph following the empty paragraph is displayed with the background color of the empty paragraph, which I'm guessing is wrong! It works correctly in Firefox, but I haven't checked IE7. Is there a CSS solution to this problem, or do I have to remove the empty element? (I would rather not have to remove...
An empty paragraph is meaningless - which means you're probably writing the wrong HTML. Also, your example doesn't have a DOCTYPE - a valid DOCTYPE is essential for getting browsers to correctly interpret your code, without one you'll be stuck in quirks mode. But anyway, the simplest workaround for this bug is simply...
289,329
<p>I was trying to create a pseudo super struct to print array of structs. My basic structures are as follows.</p> <pre><code>/* Type 10 Count */ typedef struct _T10CNT { int _cnt[20]; } T10CNT; ... /* Type 20 Count */ typedef struct _T20CNT { long _cnt[20]; } T20CNT; ... </code></pre> <p>I created the bel...
[ { "answer_id": 289333, "author": "Ari Ronen", "author_id": 34957, "author_profile": "https://Stackoverflow.com/users/34957", "pm_score": -1, "selected": false, "text": "<p>C isn't my cup o'java, but I think your problem is that \"void *cmncnt\" should be CMNCNT *cmncnt.</p>\n\n<p>Feel fr...
2008/11/14
[ "https://Stackoverflow.com/questions/289329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18657/" ]
I was trying to create a pseudo super struct to print array of structs. My basic structures are as follows. ``` /* Type 10 Count */ typedef struct _T10CNT { int _cnt[20]; } T10CNT; ... /* Type 20 Count */ typedef struct _T20CNT { long _cnt[20]; } T20CNT; ... ``` I created the below struct to print the arr...
I think your design is going to fail, but I am also unconvinced that the other answers I see fully deal with the deeper reasons why. It appears that you are trying to use C to deal with generic types, something that always gets to be hairy. You can do it, if you are careful, but it isn't easy, and in this case, I doub...
289,347
<p>I have a string that I would like to tokenize. But the C <code>strtok()</code> function requires my string to be a <code>char*</code>. How can I do this simply?</p> <p>I tried:</p> <pre><code>token = strtok(str.c_str(), " "); </code></pre> <p>which fails because it turns it into a <code>const char*</code>, not a...
[ { "answer_id": 289354, "author": "DocMax", "author_id": 6234, "author_profile": "https://Stackoverflow.com/users/6234", "pm_score": 4, "selected": false, "text": "<p>Duplicate the string, tokenize it, then free it.</p>\n\n<pre><code>char *dup = strdup(str.c_str());\ntoken = strtok(dup, \...
2008/11/14
[ "https://Stackoverflow.com/questions/289347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a string that I would like to tokenize. But the C `strtok()` function requires my string to be a `char*`. How can I do this simply? I tried: ``` token = strtok(str.c_str(), " "); ``` which fails because it turns it into a `const char*`, not a `char*`
``` #include <iostream> #include <string> #include <sstream> int main(){ std::string myText("some-text-to-tokenize"); std::istringstream iss(myText); std::string token; while (std::getline(iss, token, '-')) { std::cout << token << std::endl; } return 0; } ``` Or, as mentioned, use ...
289,360
<p>I have a large UIScrollView into which I'm placing 3-4 rather large (320x1500 pixels or so) UIImageView image tiles. I'm adding these UIImageViews to the scroll view inside of my NIB files. I have one outlet on my controller, and that is to the UIScrollView. I'm using a property (nonatomic, retain) for this, and ...
[ { "answer_id": 289374, "author": "seanalltogether", "author_id": 26986, "author_profile": "https://Stackoverflow.com/users/26986", "pm_score": 0, "selected": false, "text": "<pre><code>- (void)dealloc {\n NSLog(@\"DAY Controller Dealloc'd\");\n [self.scrollView release];\n [supe...
2008/11/14
[ "https://Stackoverflow.com/questions/289360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35516/" ]
I have a large UIScrollView into which I'm placing 3-4 rather large (320x1500 pixels or so) UIImageView image tiles. I'm adding these UIImageViews to the scroll view inside of my NIB files. I have one outlet on my controller, and that is to the UIScrollView. I'm using a property (nonatomic, retain) for this, and sythes...
I've solved the mystery - and I'm pretty sure this is a bug on Apple's side. As Kendall suggested (thanks!), the problem lies in how InterfaceBuilder loads images from the NIB file. When you initFromNib, all UIImageViews will init with a UIImage using the imageNamed: method of UIImage. This call uses caching for the i...
289,409
<p>I have a layout that is working, but it has one very annoying problem.. when the content is taller than the screen, the background stops.</p> <p>This is the desired layout in bad-ASCII-art format:</p> <pre><code>_____________________ _ | | long |logo| | | | content | | | | | | | | ...
[ { "answer_id": 289419, "author": "Henrik Paul", "author_id": 2238, "author_profile": "https://Stackoverflow.com/users/2238", "pm_score": 1, "selected": false, "text": "<p>I just watched a video about <a href=\"http://developer.yahoo.com/yui/grids/\" rel=\"nofollow noreferrer\">YUI's grid...
2008/11/14
[ "https://Stackoverflow.com/questions/289409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I have a layout that is working, but it has one very annoying problem.. when the content is taller than the screen, the background stops. This is the desired layout in bad-ASCII-art format: ``` _____________________ _ | | long |logo| | | | content | | | | | | | | | | | |...
Given that you have your gradients in seperate columns to the left and right, you need to implement "**[faux columns](http://www.alistapart.com/articles/fauxcolumns/)**". If you're after elastic versions, have a look at [**Elastic Faux Columns**](http://nickcowie.com/2005/elastic-faux-columns/) and [**Multi-Column Lay...
289,432
<p>Basically, I'm trying to write the following (pseudocode) in an ASP.NET HttpModule:</p> <pre><code>*pre-code* try { handler.ProcessRequest(...) } catch (Exception) { *error-code* } finally { *post-code* } </code></pre> <p>I've found that I can hook into HttpModule.PreExecuteHandler for "pre-code" and .Error for "e...
[ { "answer_id": 292814, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": -1, "selected": false, "text": "<p>Add this to your Global.asax file:</p>\n\n<pre><code>protected void Application_PreRequestHandlerExecute(object...
2008/11/14
[ "https://Stackoverflow.com/questions/289432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7104/" ]
Basically, I'm trying to write the following (pseudocode) in an ASP.NET HttpModule: ``` *pre-code* try { handler.ProcessRequest(...) } catch (Exception) { *error-code* } finally { *post-code* } ``` I've found that I can hook into HttpModule.PreExecuteHandler for "pre-code" and .Error for "error-code". But PostExecut...
There is no way to do what you want (in a HttpModule, at least), other than to not call Response.End. [This article](http://www.west-wind.com/Weblog/posts/494.aspx) explains it pretty well and offers an alternative to Response.End in case it is a side-effect of your having called Server.Transfer.
289,433
<p>How can I prevent the user from being able to resize an image in designMode? (disable the handles when image is clicked)</p>
[ { "answer_id": 289453, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 4, "selected": true, "text": "<p>Say you turn contentEditable on like this:</p>\n\n<pre><code>document.body.contentEditable = true;\n</code></pre>\n\n<p>All ...
2008/11/14
[ "https://Stackoverflow.com/questions/289433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26181/" ]
How can I prevent the user from being able to resize an image in designMode? (disable the handles when image is clicked)
Say you turn contentEditable on like this: ``` document.body.contentEditable = true; ``` All you have to do is turn it off for all (or some) images. ``` var imgs = document.getElementsByTagName("IMG"); for (var i = 0; i < imgs.length; ++i) { imgs[i].contentEditable = false; } ```
289,434
<p>I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them persist for the entire lifetime of the application and both need to be running at the same time (one talks to the server, one talks to the user; when the app is fully started, I need <em>both</em> of them to wor...
[ { "answer_id": 289448, "author": "Klathzazt", "author_id": 35223, "author_profile": "https://Stackoverflow.com/users/35223", "pm_score": 2, "selected": false, "text": "<p>This applies to all languages:</p>\n\n<p>You want to have an event/listener model. You create a listener to wait for...
2008/11/14
[ "https://Stackoverflow.com/questions/289434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19746/" ]
I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them persist for the entire lifetime of the application and both need to be running at the same time (one talks to the server, one talks to the user; when the app is fully started, I need *both* of them to work). Howev...
I would really recommend that you go through a tutorial like [Sun's Java Concurrency](http://java.sun.com/docs/books/tutorial/essential/concurrency/) before you commence in the magical world of multithreading. There are also a number of good books out (google for "Concurrent Programming in Java", "Java Concurrency in ...
289,438
<p>My company is currently migrating some of their really old db's to sql server 2005. Some legacy apps have problems connecting to the new server. The connection string works in Asp.NET 2.0, probably because it assumes tcp:1433 automatically.</p> <p>I have to construct the connection string like this in ASP.NET 1.1 f...
[ { "answer_id": 289499, "author": "GeekyMonkey", "author_id": 29900, "author_profile": "https://Stackoverflow.com/users/29900", "pm_score": 0, "selected": false, "text": "<p>Perhaps your SQL Server is configured for multi-protocol, and it's trying to use the other protocol first and faili...
2008/11/14
[ "https://Stackoverflow.com/questions/289438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13466/" ]
My company is currently migrating some of their really old db's to sql server 2005. Some legacy apps have problems connecting to the new server. The connection string works in Asp.NET 2.0, probably because it assumes tcp:1433 automatically. I have to construct the connection string like this in ASP.NET 1.1 for it to w...
IIRC SQL Server 2005 defaults to find any-old-port that is available. On my laptop this means port 1212. To force it to a specific port you must go to Start->Programs->SQL Server 2005->Configuration Tools->SQL Server Configuration Manager From here you must go to SQL Server 2005 Network Configuration->Protocols for (...
289,440
<p>I have a quite big XML output from an application. I need to process it with my program and then feed it back to the original program. There are pieces in this XML which needs to be filled out our replaced. The interesting part looks like this:</p> <pre><code>&lt;sys:customtag sys:sid="1" sys:type="Processtart" /&g...
[ { "answer_id": 289451, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 7, "selected": true, "text": "<p>i believe the option to use is <code>RegexOptions.Singleline</code> instead of <code>RegexOptions.Multiline</code> (<a href=\...
2008/11/14
[ "https://Stackoverflow.com/questions/289440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968/" ]
I have a quite big XML output from an application. I need to process it with my program and then feed it back to the original program. There are pieces in this XML which needs to be filled out our replaced. The interesting part looks like this: ``` <sys:customtag sys:sid="1" sys:type="Processtart" /> <sys:tag>valu...
i believe the option to use is `RegexOptions.Singleline` instead of `RegexOptions.Multiline` ([src](http://www.regular-expressions.info/dot.html)). allowing (.) to match newlines should work in your case. > > ...the mode where the dot also matches newlines is called "single-line mode". This is a bit unfortunate, beca...
289,441
<p>Is it possible to set some image as title of Navigation bar?</p> <p>I think NYTimes application used a Navigation bar and title is look like image file (the reason why it's seems <code>UINavigationBar</code> is because they use right button to search).</p>
[ { "answer_id": 289446, "author": "Kendall Helmstetter Gelner", "author_id": 6330, "author_profile": "https://Stackoverflow.com/users/6330", "pm_score": 8, "selected": true, "text": "<p>You can use an <code>UIImageView</code> for the <code>UINavigationItem.titleView</code> property, somet...
2008/11/14
[ "https://Stackoverflow.com/questions/289441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
Is it possible to set some image as title of Navigation bar? I think NYTimes application used a Navigation bar and title is look like image file (the reason why it's seems `UINavigationBar` is because they use right button to search).
You can use an `UIImageView` for the `UINavigationItem.titleView` property, something like: ``` self.navigationItem.titleView = myImageView; ```
289,452
<p>Try as I might, I'm unable to resolve an address to IP. The code snippet is shown below. I keep getting the No such host is known exception, even though I could access google with my browser (The DNS server is almost certainly working). I'm however behind company's firewall.</p> <pre><code>try { foreach (IPAddre...
[ { "answer_id": 289459, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 2, "selected": false, "text": "<p>There is nothing wrong with your code. Given that you can access www.google.com from a web browser the next most like...
2008/11/14
[ "https://Stackoverflow.com/questions/289452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Try as I might, I'm unable to resolve an address to IP. The code snippet is shown below. I keep getting the No such host is known exception, even though I could access google with my browser (The DNS server is almost certainly working). I'm however behind company's firewall. ``` try { foreach (IPAddress address in ...
There is nothing wrong with your code. Given that you can access www.google.com from a web browser the next most likely problem is that the web browser is using a proxy server. The web browser is actually accessing www.google.com through the proxy server which is allowed through the firewall. The simple application you...
289,456
<p>I've been using Visual Studio as my main IDE for a while now (I still use Emacs for some personal projects, though).</p> <p>I like the way Emacs formats C/C++ code and I'd like to convince Visual Studio use similar conventions for C# code. For instance, in Emacs, a C function call looks like:</p> <pre><code>functi...
[ { "answer_id": 289457, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 5, "selected": true, "text": "<p>Tools > Options > Text Editor > C# > Formatting</p>\n\n<p>and</p>\n\n<p><a href=\"http://www.jetbrains.com/resharper/fe...
2008/11/14
[ "https://Stackoverflow.com/questions/289456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35420/" ]
I've been using Visual Studio as my main IDE for a while now (I still use Emacs for some personal projects, though). I like the way Emacs formats C/C++ code and I'd like to convince Visual Studio use similar conventions for C# code. For instance, in Emacs, a C function call looks like: ``` functionName(argument1, ...
Tools > Options > Text Editor > C# > Formatting and <http://www.jetbrains.com/resharper/features/code_formatting.html#Code_Formatting>
289,468
<p>I am working on an algorithm that will try to pick out, given an HTML file, what it thinks is the parent element that most likely contains the majority of the page's content text. For example, it would pick the div "content" in the following HTML:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;div id="header...
[ { "answer_id": 289476, "author": "Klathzazt", "author_id": 35223, "author_profile": "https://Stackoverflow.com/users/35223", "pm_score": 1, "selected": true, "text": "<p>You could create an app that looks for contiguous block of text disregarding formatting tags (if required). You could...
2008/11/14
[ "https://Stackoverflow.com/questions/289468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32140/" ]
I am working on an algorithm that will try to pick out, given an HTML file, what it thinks is the parent element that most likely contains the majority of the page's content text. For example, it would pick the div "content" in the following HTML: ``` <html> <body> <div id="header">This is the header we don't...
You could create an app that looks for contiguous block of text disregarding formatting tags (if required). You could do this by using a DOM parser and walking the tree, keeping track of the immediate parent (because that is your output). Start form parent nodes and traverse the tree for each node that is just formatt...
289,475
<p>I mean what the most efficient way to get information about the quantity of your page's items and make sql query with LIMIT that you need. or I should get all items and then crop array with php functions?</p> <p>now I do 2 queries: first to count all items and second to get items that I need with LIMIT. </p> <p...
[ { "answer_id": 289497, "author": "Josh Smeaton", "author_id": 10583, "author_profile": "https://Stackoverflow.com/users/10583", "pm_score": 2, "selected": true, "text": "<p>I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don...
2008/11/14
[ "https://Stackoverflow.com/questions/289475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37590/" ]
I mean what the most efficient way to get information about the quantity of your page's items and make sql query with LIMIT that you need. or I should get all items and then crop array with php functions? now I do 2 queries: first to count all items and second to get items that I need with LIMIT. OK, I'll be more co...
I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don't understand your need for the LIMIT in the context of your question. However, if you just want a count of how many rows have been found, use one of the following. You select the count of all rows such a...
289,483
<p>I have two machines setup to run Visual Studio 2008 (SP1) &amp; NET Framework 3.5 (SP1). If I create a .tt file in a console appliaction on machine #1 it automatically creates the sub .cs file for me, however if I do the exact same on machine #2 then no sub .cs file is created.</p> <p>I have tried toggling the "Sho...
[ { "answer_id": 289497, "author": "Josh Smeaton", "author_id": 10583, "author_profile": "https://Stackoverflow.com/users/10583", "pm_score": 2, "selected": true, "text": "<p>I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don...
2008/11/14
[ "https://Stackoverflow.com/questions/289483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25319/" ]
I have two machines setup to run Visual Studio 2008 (SP1) & NET Framework 3.5 (SP1). If I create a .tt file in a console appliaction on machine #1 it automatically creates the sub .cs file for me, however if I do the exact same on machine #2 then no sub .cs file is created. I have tried toggling the "Show All Files" o...
I'm assuming you want a count of the number of rows you'll be reading so as to do some pagination or similar? I don't understand your need for the LIMIT in the context of your question. However, if you just want a count of how many rows have been found, use one of the following. You select the count of all rows such a...
289,498
<p>How do I run a batch file each time windows boots up also I need to run it in the back ground(without that command window getting displayed)? I use Windows Xp. My actuall requirement is I want to start the Tracd server using the command line commands whenever Windows boots up.</p>
[ { "answer_id": 289500, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 6, "selected": true, "text": "<p>Add your program in the <a href=\"http://www.bleepingcomputer.com/tutorials/tutorial44.html\" rel=\"noreferrer\">registry</a>...
2008/11/14
[ "https://Stackoverflow.com/questions/289498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13440/" ]
How do I run a batch file each time windows boots up also I need to run it in the back ground(without that command window getting displayed)? I use Windows Xp. My actuall requirement is I want to start the Tracd server using the command line commands whenever Windows boots up.
Add your program in the [registry](http://www.bleepingcomputer.com/tutorials/tutorial44.html): Run - These are the most common startup locations for programs to install auto start from. By default these keys are not executed in Safe mode. If you prefix the value of these keys with an asterisk, \*, is will run in Safe ...
289,512
<p>I can't figure out how to define the default constructor (when it exists overloads) for a type in StructureMap (version 2.5) by code.</p> <p>I want to get an instance of a service and the container has to inject a Linq2Sql data context instance into it.</p> <p>I wrote this in my 'bootstrapper' method :</p> <pre><...
[ { "answer_id": 289574, "author": "Ed Blackburn", "author_id": 27962, "author_profile": "https://Stackoverflow.com/users/27962", "pm_score": 0, "selected": false, "text": "<p>I'm not sure how / if it can be done with the fluent interface / internal DSL. You can however use an attribute, i...
2008/11/14
[ "https://Stackoverflow.com/questions/289512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37592/" ]
I can't figure out how to define the default constructor (when it exists overloads) for a type in StructureMap (version 2.5) by code. I want to get an instance of a service and the container has to inject a Linq2Sql data context instance into it. I wrote this in my 'bootstrapper' method : ``` ForRequestedType<MyData...
You can specify a constructor with the ConstructedBy(). Please try this: ``` ForRequestedType<MyDataContext>().TheDefault. Is.ConstructedBy(() => new MyDataContext()); ``` This worked for me.
289,513
<p>I need a javascript regex pattern to match a person's height to check if the input is valid. Here are some sample input:</p> <p>5' 9"</p> <p>6'</p> <p>5'8"</p> <p>Any ideas?</p>
[ { "answer_id": 289516, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 1, "selected": false, "text": "<p>Something like:</p>\n\n<pre><code>\\d'(?:\\s*\\d+'')?\n</code></pre>\n\n<p>The second part refers to optional part of the he...
2008/11/14
[ "https://Stackoverflow.com/questions/289513", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need a javascript regex pattern to match a person's height to check if the input is valid. Here are some sample input: 5' 9" 6' 5'8" Any ideas?
If you want to make sure that no one mucks around with it, you could limit it to sensible ranges, eg: 3' to 7'11'' ``` /^(3-7)'(?:\s*(?:1[01]|0-9)(''|"))?$/ ``` I always thought that the "inches" mark was a double quote (`"`), compared to VonC's answer where he put it as two single quotes (`''`), so this regex takes...
289,518
<p>How do I make icons for my exe file when compiling my Python program?</p>
[ { "answer_id": 289544, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 2, "selected": false, "text": "<p>I was searching for this a while ago, and found this: <a href=\"http://www.mail-archive.com/pygame-users@seul.org/msg0561...
2008/11/14
[ "https://Stackoverflow.com/questions/289518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I make icons for my exe file when compiling my Python program?
I was searching for this a while ago, and found this: <http://www.mail-archive.com/pygame-users@seul.org/msg05619.html> Quote from above link: > > The setup.py File: PY\_PROG = > > > 'trek10.py' APP\_NAME = 'Trek\_Game' > > > cfg = { > > > > ``` > 'name':APP_NAME, > 'version':'1.0', > 'description':'', > 'aut...
289,523
<p>I want to use Oracle exception to handle errors that might happen in the code below. If a user provides the book ID and/or employee ID that doesn't exist in the database, NO_DATA_FOUND exception will be raised. Thus, how can I know which statement raises this exception.</p> <pre><code>CREATE OR REPLACE PROCEDURE T...
[ { "answer_id": 289530, "author": "Ali Ersöz", "author_id": 4215, "author_profile": "https://Stackoverflow.com/users/4215", "pm_score": 2, "selected": true, "text": "<p>You can set a variable before the given statements. Like;</p>\n\n<pre><code>CREATE OR REPLACE PROCEDURE TEST_EXCEPTION (...
2008/11/14
[ "https://Stackoverflow.com/questions/289523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1602746/" ]
I want to use Oracle exception to handle errors that might happen in the code below. If a user provides the book ID and/or employee ID that doesn't exist in the database, NO\_DATA\_FOUND exception will be raised. Thus, how can I know which statement raises this exception. ``` CREATE OR REPLACE PROCEDURE TEST_EXCEPTION...
You can set a variable before the given statements. Like; ``` CREATE OR REPLACE PROCEDURE TEST_EXCEPTION ( book_id_in IN book.book_id%TYPE, emp_id_in IN emp.emp_id%TYPE ) IS v_book_desc book.description%TYPE; v_emp_name emp.emp_name%TYPE; statementIndex number(1, 0); BEGIN statementIndex := 1; SELECT description in...
289,529
<p>I am new to decoding techniques and have just learnt about base64, sha-1, md5 and a few others yesterday. </p> <p>I have been trying to figure out what "orkut" worms actually contain. </p> <p>I was attacked by many orkut spammers and hackers in the past few days, and there is a similarity in the URLs that they sen...
[ { "answer_id": 289542, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>Haha, if it was that easy, it would not be worth a hack! You have to try a lot harder than just simply decoding it once...
2008/11/14
[ "https://Stackoverflow.com/questions/289529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37600/" ]
I am new to decoding techniques and have just learnt about base64, sha-1, md5 and a few others yesterday. I have been trying to figure out what "orkut" worms actually contain. I was attacked by many orkut spammers and hackers in the past few days, and there is a similarity in the URLs that they send to us. I don'...
> > The encoding above appears to be base64 but it is not, because when-ever I try to decode > it using online base64 decoders I get raw output and it doesn't decode accurately. > > > What makes you think that the decoding is incorrect? Typically you'd base64 or hex encode binary content so that it can be transpo...
289,537
<p>Does anyone know a simple algorithm to check if a Sudoku-Configuration is valid? The simplest algorithm I came up with is (for a board of size n) in Pseudocode</p> <pre><code>for each row for each number k in 1..n if k is not in the row (using another for-loop) return not-a-solution ..do the same for e...
[ { "answer_id": 289561, "author": "Luk", "author_id": 5789, "author_profile": "https://Stackoverflow.com/users/5789", "pm_score": 3, "selected": false, "text": "<p>Just a thought: don't you need to also check the numbers in each 3x3 square? </p>\n\n<p>I'm trying to figure out if it is pos...
2008/11/14
[ "https://Stackoverflow.com/questions/289537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18670/" ]
Does anyone know a simple algorithm to check if a Sudoku-Configuration is valid? The simplest algorithm I came up with is (for a board of size n) in Pseudocode ``` for each row for each number k in 1..n if k is not in the row (using another for-loop) return not-a-solution ..do the same for each column ``...
You need to check for all the constraints of Sudoku : * check the sum on each row * check the sum on each column * check for sum on each box * check for duplicate numbers on each row * check for duplicate numbers on each column * check for duplicate numbers on each box that's 6 checks altogether.. using a brute force...
289,568
<p>The C++ standard imposes an ordering on class member variables in memory. It says that the addresses of member variables have to increase in the order of declaration, but only inside one access section. Very specifically, this does not seem to prevent compilers from laying out access sections in an interleaved way...
[ { "answer_id": 290159, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "<p>And no, i think he is NOT trying to spam. This is a valid question and quite interesting i think. </p>\n...
2008/11/14
[ "https://Stackoverflow.com/questions/289568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37602/" ]
The C++ standard imposes an ordering on class member variables in memory. It says that the addresses of member variables have to increase in the order of declaration, but only inside one access section. Very specifically, this does not seem to prevent compilers from laying out access sections in an interleaved way. For...
I checked out the C++ standard. In section 9.2, paragraph (or clause or whatever) 12, it says "The order of allocation of nonstatic data members separated by an access-specifier is unspecified." "Unspecified" means implementation-dependent behavior that need not be documented. Therefore, the standard is explicitly say...
289,578
<p>Recently when I looked into iPhone memory management, I tried to compare the convenience method and init method on the same object. For example, I have UIImageView where it displays a downloaded NSData:</p> <p>Convenience method:</p> <pre><code>imageView.image = [UIImage imageWithData:[downloads dataAtIndex:0]]; <...
[ { "answer_id": 289633, "author": "Mike Akers", "author_id": 17188, "author_profile": "https://Stackoverflow.com/users/17188", "pm_score": 1, "selected": false, "text": "<p>The only difference that could be causing this is that imageWithData: doesn't use the system image cache, while init...
2008/11/14
[ "https://Stackoverflow.com/questions/289578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30883/" ]
Recently when I looked into iPhone memory management, I tried to compare the convenience method and init method on the same object. For example, I have UIImageView where it displays a downloaded NSData: Convenience method: ``` imageView.image = [UIImage imageWithData:[downloads dataAtIndex:0]]; ``` init method: ``...
Your autoreleased objects created by the convenience methods will not be released until the containing autorelease pool is drained. It is advisable to wrap memory intensive operations inside of an `NSAutoreleasePool` block if you will be making heavy use of them.
289,586
<p>How can I check which version of Apache is installed on a Debian machine? </p> <p>Is there a command for doing this?</p>
[ { "answer_id": 289589, "author": "Todd Gamblin", "author_id": 9122, "author_profile": "https://Stackoverflow.com/users/9122", "pm_score": 9, "selected": false, "text": "<p>Try apachectl -V:</p>\n\n<pre><code>$ apachectl -V\nServer version: Apache/2.2.9 (Unix)\nServer built: Sep 18 2008...
2008/11/14
[ "https://Stackoverflow.com/questions/289586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37603/" ]
How can I check which version of Apache is installed on a Debian machine? Is there a command for doing this?
Try apachectl -V: ``` $ apachectl -V Server version: Apache/2.2.9 (Unix) Server built: Sep 18 2008 21:54:05 Server's Module Magic Number: 20051115:15 Server loaded: APR 1.2.7, APR-Util 1.2.7 Compiled using: APR 1.2.7, APR-Util 1.2.7 ... etc ... ``` If it does not work for you, run the command with `sudo`.
289,601
<p><strong>Sorry answer found while typing</strong> </p> <p>I am trying to connect to an external webservice that requires username/password authentication through a proxy. I am using Visual Studio Express 2008 to generate a service reference</p> <ul> <li>I have connected to the same webservice using a web referen...
[ { "answer_id": 289607, "author": "KeesDijk", "author_id": 6434, "author_profile": "https://Stackoverflow.com/users/6434", "pm_score": 3, "selected": true, "text": "<p>Change the binding to :</p>\n\n<pre><code>&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;\n&lt;customBinding&gt;\n ...
2008/11/14
[ "https://Stackoverflow.com/questions/289601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6434/" ]
**Sorry answer found while typing** I am trying to connect to an external webservice that requires username/password authentication through a proxy. I am using Visual Studio Express 2008 to generate a service reference * I have connected to the same webservice using a web reference.We only had to set a larger timeou...
Change the binding to : ``` <?xml version="1.0" encoding="utf-8" ?> <customBinding> <binding name="AreaWebServiceSoap12" closeTimeout="00:01:00" openTimeout="00:10:00" receiveTimeout="00:20:00" sendTimeout="00:05:00"> <textMessageEncoding maxReadPoolSize="64" maxWritePoo...
289,626
<p>As being quite a newbie in linux, I have the follwing question. I have list of files (this time resulting from svn status) and i want to create a script to loop them all and replace tabs with 4 spaces.</p> <p>So I want from </p> <pre><code>.... D HTML/templates/t_bla.tpl M HTML/templates/t_list_markt.tpl...
[ { "answer_id": 289640, "author": "Dan Fego", "author_id": 34426, "author_profile": "https://Stackoverflow.com/users/34426", "pm_score": 2, "selected": false, "text": "<p>I would use sed, like so:</p>\n\n<pre><code>for i in files\ndo\n sed -i 's/\\t/ /' \"$i\"\ndone\n</code></pre>\n...
2008/11/14
[ "https://Stackoverflow.com/questions/289626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30759/" ]
As being quite a newbie in linux, I have the follwing question. I have list of files (this time resulting from svn status) and i want to create a script to loop them all and replace tabs with 4 spaces. So I want from ``` .... D HTML/templates/t_bla.tpl M HTML/templates/t_list_markt.tpl M HTML/template...
You can use this command: ``` svn st | cut -c8- | xargs ls ``` This will cut the first 8 characters leaving only a list of file names, without Subversion flags. You can also add `grep` before `cut` to filter only some type of changes, like `/^M/`. `xargs` will pass the list of files as arguments to a given command (...
289,628
<p>HI,</p> <p>I have 3 tables: <strong>Clips</strong>, <strong>Books</strong> and relationships between <strong>ClipBook</strong></p> <p><strong>Problem is:</strong> i need get <strong>book</strong> that has <strong>bookID=4</strong> with some clips i mean many-to-many</p> <p>in simple text sql it will be something ...
[ { "answer_id": 289640, "author": "Dan Fego", "author_id": 34426, "author_profile": "https://Stackoverflow.com/users/34426", "pm_score": 2, "selected": false, "text": "<p>I would use sed, like so:</p>\n\n<pre><code>for i in files\ndo\n sed -i 's/\\t/ /' \"$i\"\ndone\n</code></pre>\n...
2008/11/14
[ "https://Stackoverflow.com/questions/289628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2246271/" ]
HI, I have 3 tables: **Clips**, **Books** and relationships between **ClipBook** **Problem is:** i need get **book** that has **bookID=4** with some clips i mean many-to-many in simple text sql it will be something like this: `select * from Clips where clipID in (select clipID from ClipBook where bookID=4)` **Ques...
You can use this command: ``` svn st | cut -c8- | xargs ls ``` This will cut the first 8 characters leaving only a list of file names, without Subversion flags. You can also add `grep` before `cut` to filter only some type of changes, like `/^M/`. `xargs` will pass the list of files as arguments to a given command (...
289,649
<p>I'm trying to reorder/group a set of results using SQL. I have a few fields (which for the example have been renamed to something a bit less specific), and each logical group of records has a field which remains constant - the address field. There are also fields which are present for each address, these are the sam...
[ { "answer_id": 289658, "author": "Chad", "author_id": 37309, "author_profile": "https://Stackoverflow.com/users/37309", "pm_score": 0, "selected": false, "text": "<p>I'm not certain, but I think what you're trying to do is GROUP BY.</p>\n\n<pre><code>SELECT Address,Name FROM Table GROUP ...
2008/11/14
[ "https://Stackoverflow.com/questions/289649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30512/" ]
I'm trying to reorder/group a set of results using SQL. I have a few fields (which for the example have been renamed to something a bit less specific), and each logical group of records has a field which remains constant - the address field. There are also fields which are present for each address, these are the same f...
Assuming that the column headings "john", "lucy" etc are fixed, you can group by the address field and use if() functions combined with aggregate operators to get your results: ``` select max(if(forename='john',surname,null)) as john, max(if(forename='lucy',surname,null)) as lucy, max(if(forename='jenny'...
289,665
<p>I'm an avid vim user and have started to write some SQL code recently. I like to write my SQL statements in CAPS and sometimes forget to switch <kbd>CapsLock</kbd> 'off' and I then quickly wreak havoc on my code before I realise what's happening.</p> <p>I have so far not found any way to tell whether the <kbd>CapsL...
[ { "answer_id": 289706, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<p>What I did is bound my caps lock key to the \"Compose\" key, so my capslock key is effectively missing and I just ...
2008/11/14
[ "https://Stackoverflow.com/questions/289665", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34772/" ]
I'm an avid vim user and have started to write some SQL code recently. I like to write my SQL statements in CAPS and sometimes forget to switch `CapsLock` 'off' and I then quickly wreak havoc on my code before I realise what's happening. I have so far not found any way to tell whether the `CapsLock` key is on other th...
~~The best I can give you is to have vim toggle the background color whenever the CAPSLOCK key is hit in vim.~~ Vim can't detect the CAPSLOCK key alone. What I can give you is a mapping so you can use some other key (in this example, F3) to act like the CAPSLOCK key for insert mode, and change the background color whe...
289,668
<p>I don't know what commands to enter into the setup.py file when compiling a python program to use my icons. Can anyone help me? Thanks in advance.</p>
[ { "answer_id": 289723, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 2, "selected": false, "text": "<p>I haven't tried this, but here's a link I found:</p>\n\n<p><a href=\"http://www.py2exe.org/index.cgi/CustomIcons\"...
2008/11/14
[ "https://Stackoverflow.com/questions/289668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I don't know what commands to enter into the setup.py file when compiling a python program to use my icons. Can anyone help me? Thanks in advance.
``` from distutils.core import setup import py2exe setup( windows=[{"script": 'app.py', "icon_resources": [(1, "icon.ico")]}], options={"py2exe":{"unbuffered": True, "optimize": 2, "bundle_files" : 1, "dist_dir": "bin"}}, ...
289,672
<p>Delphi object inspector doesn't show TFrame descendants's additional properties by design. People tend to suggest using a known trick which is commonly used for showing TForm descendant's properties on the Object inspector. The trick is: registering custom module for TForm descendants to Delphi IDE via design time p...
[ { "answer_id": 289926, "author": "Oliver Giesen", "author_id": 9784, "author_profile": "https://Stackoverflow.com/users/9784", "pm_score": 0, "selected": false, "text": "<p>No, I don't think this is fully possible.</p>\n\n<p>What I usually do when I have similar needs is to simply instal...
2008/11/14
[ "https://Stackoverflow.com/questions/289672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37601/" ]
Delphi object inspector doesn't show TFrame descendants's additional properties by design. People tend to suggest using a known trick which is commonly used for showing TForm descendant's properties on the Object inspector. The trick is: registering custom module for TForm descendants to Delphi IDE via design time pack...
Which custom module class are you registering for your frame? Which version of Delphi are you using? From my experiments with Delphi 2007, the custom module class which seems to work is TFrameModule. This class is contained in delphivclide100.bpl. Since there is no corresponding delphivclide.dcp you have to load it ma...
289,680
<p>How do I get the difference in days between 2 dates in SQLite? I have already tried something like this:</p> <pre><code>SELECT Date('now') - DateCreated FROM Payment </code></pre> <p>It returns 0 every time.</p>
[ { "answer_id": 289686, "author": "Fred", "author_id": 33630, "author_profile": "https://Stackoverflow.com/users/33630", "pm_score": 8, "selected": true, "text": "<pre><code> SELECT julianday('now') - julianday(DateCreated) FROM Payment;\n</code></pre>\n" }, { "answer_id": 295665,...
2008/11/14
[ "https://Stackoverflow.com/questions/289680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I get the difference in days between 2 dates in SQLite? I have already tried something like this: ``` SELECT Date('now') - DateCreated FROM Payment ``` It returns 0 every time.
``` SELECT julianday('now') - julianday(DateCreated) FROM Payment; ```
289,688
<p>I have hit a classic problem of needing to do a string replace on a text field in an sql 2000 database. This could either be an update over a whole column or a single field I'm not fussy.</p> <p>I have found a few examples of how to use updatetext to achieve it but they tend to be in stored procedures, does anyone ...
[ { "answer_id": 289803, "author": "kristof", "author_id": 3241, "author_profile": "https://Stackoverflow.com/users/3241", "pm_score": 3, "selected": true, "text": "<p>I am afraid you cannot do it within a function</p>\n\n<p>When you try to declare a function like:</p>\n\n<pre><code>create...
2008/11/14
[ "https://Stackoverflow.com/questions/289688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
I have hit a classic problem of needing to do a string replace on a text field in an sql 2000 database. This could either be an update over a whole column or a single field I'm not fussy. I have found a few examples of how to use updatetext to achieve it but they tend to be in stored procedures, does anyone know of a ...
I am afraid you cannot do it within a function When you try to declare a function like: ``` create function dbo.textReplace( @inText as text) returns text as begin return 'a' -- just dummy code end ``` You will get the following error: ``` The text data type is invalid for return values. ``` In other words ...
289,702
<p>I am writing unit tests for a class, which has a static final variable. However, since the state of the static final var is modified in each test, I need some way to reinitialize it.</p> <p> How would this be possible? Would i need to use some sort of a custom classloader? </p> <p> The variable is initialized as -...
[ { "answer_id": 289707, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 2, "selected": false, "text": "<p>One (not very efficient) approach assuming you are using junit and ant.</p>\n\n<p>You could create a separate class for e...
2008/11/14
[ "https://Stackoverflow.com/questions/289702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14316/" ]
I am writing unit tests for a class, which has a static final variable. However, since the state of the static final var is modified in each test, I need some way to reinitialize it. How would this be possible? Would i need to use some sort of a custom classloader? The variable is initialized as - ``` static fin...
Of course you can hack around it with reflection or class loading, but "if I were you, I wouldn't be starting form here." Mutable statics are really evil (even those called singletons). So, design you code better by "parameterisation from above" - pass object into those that need them, rather than doing something hardw...
289,712
<p>As a long time Pascal and Delphi developer, I always line up my begin and ends thus :</p> <pre><code>begin if x = y then begin ... ... end else for i := 0 to 20 do begin ... ... end; end; </code></pre> <p>What drives me nuts is code formatted thus :</p> <pre><code>begin ...
[ { "answer_id": 289732, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>Everybody has different preferences. In my case, I learned Modula-2 before I learned Pascal. Modula-2 has no BEGIN key...
2008/11/14
[ "https://Stackoverflow.com/questions/289712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22712/" ]
As a long time Pascal and Delphi developer, I always line up my begin and ends thus : ``` begin if x = y then begin ... ... end else for i := 0 to 20 do begin ... ... end; end; ``` What drives me nuts is code formatted thus : ``` begin if x = y then begin ... .....
I personally use: ``` if Condition then begin DoThis; end else begin DoThat; end; ``` See [Object Pascal Style Guide](http://dn.codegear.com/article/10280#8.2.3). > > In compound if statements, put each > element separating statements on a new > line: Example: > > > ``` // INCORRECT if A < B then begin ...
289,715
<p>I am looking for the highest key value (a defined by the comparison operator) of a std::map.</p> <p>Is this guaranteed to be </p> <pre><code>map.rbegin()-&gt;first </code></pre> <p>? </p> <p>(I am a bit shaky on reverse iterators, and how much freedom there is in the implementation of std::map) </p> <p>If not, ...
[ { "answer_id": 289747, "author": "Steve Jessop", "author_id": 13005, "author_profile": "https://Stackoverflow.com/users/13005", "pm_score": 7, "selected": true, "text": "<p>Yes. Map is a sorted container, the reverse iterator must return the elements in reverse (i.e. decreasing) order of...
2008/11/14
[ "https://Stackoverflow.com/questions/289715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31317/" ]
I am looking for the highest key value (a defined by the comparison operator) of a std::map. Is this guaranteed to be ``` map.rbegin()->first ``` ? (I am a bit shaky on reverse iterators, and how much freedom there is in the implementation of std::map) If not, please advise. I cannot change the data structure.
Yes. Map is a sorted container, the reverse iterator must return the elements in reverse (i.e. decreasing) order of their keys. [Edit: as Charles Bailey points out in his answer, your code gives the greatest key **if it exists** - i.e. if the map is non-empty]
289,719
<p>I have a CUDA kernel which I'm compiling to a cubin file without any special flags:</p> <pre><code>nvcc text.cu -cubin </code></pre> <p>It compiles, though with this message:</p> <blockquote> <p>Advisory: Cannot tell what pointer points to, assuming global memory space</p> </blockquote> <p>and a reference to a...
[ { "answer_id": 298166, "author": "Morten Christiansen", "author_id": 4055, "author_profile": "https://Stackoverflow.com/users/4055", "pm_score": 0, "selected": false, "text": "<p>The problem seems to be associated with the char** parameter. Turning this into a char* solved the warning, s...
2008/11/14
[ "https://Stackoverflow.com/questions/289719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4055/" ]
I have a CUDA kernel which I'm compiling to a cubin file without any special flags: ``` nvcc text.cu -cubin ``` It compiles, though with this message: > > Advisory: Cannot tell what pointer points to, assuming global memory space > > > and a reference to a line in some temporary cpp file. I can get this to wor...
Arrays of pointers like char\*\* are problematic in kernels, since the kernels have no access to the host's memory. It is better to allocate a single **continuous** buffer and to divide it in a manner that enables parallel access. In this case I'd define a 1D array which contains all the strings positioned one a...
289,720
<p>I am trying to convert my web application into a fully dynamic system. One thing I am trying to do is to load a different logo (set in the masterpage template) depending on the host.</p> <p>But, even though the code is hit (in page_init), there is no image displayed on any page inheriting the masterpage - no image,...
[ { "answer_id": 298166, "author": "Morten Christiansen", "author_id": 4055, "author_profile": "https://Stackoverflow.com/users/4055", "pm_score": 0, "selected": false, "text": "<p>The problem seems to be associated with the char** parameter. Turning this into a char* solved the warning, s...
2008/11/14
[ "https://Stackoverflow.com/questions/289720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
I am trying to convert my web application into a fully dynamic system. One thing I am trying to do is to load a different logo (set in the masterpage template) depending on the host. But, even though the code is hit (in page\_init), there is no image displayed on any page inheriting the masterpage - no image, no red x...
Arrays of pointers like char\*\* are problematic in kernels, since the kernels have no access to the host's memory. It is better to allocate a single **continuous** buffer and to divide it in a manner that enables parallel access. In this case I'd define a 1D array which contains all the strings positioned one a...
289,729
<p>I'm just starting to try out phpunit on some existing code. The naming convention we use is that the MyClass class should be in MyClass.class.php. PHPUnit seems to require that the file should be called MyClass.php. </p> <p>Is there any way around this?</p> <p>I noticed it while trying to generate a skeleton test ...
[ { "answer_id": 289758, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": true, "text": "<p>Its not a requirement, its just assumptive. You can write your own test-cases. </p>\n\n<p>Skeleton just makes a moc...
2008/11/14
[ "https://Stackoverflow.com/questions/289729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11542/" ]
I'm just starting to try out phpunit on some existing code. The naming convention we use is that the MyClass class should be in MyClass.class.php. PHPUnit seems to require that the file should be called MyClass.php. Is there any way around this? I noticed it while trying to generate a skeleton test class: ``` phpun...
Its not a requirement, its just assumptive. You can write your own test-cases. Skeleton just makes a mock-up one "the easy way" that makes dummy functions for all your classes dummy functions. Also, ``` phpunit --skeleton-test MyClass MyClass.class.php ``` Might do what you want. ``` Usage: phpunit [switc...
289,731
<p>During navigation of the <code>java.lang.reflect.Method</code> class I came across the method <code>isBridge</code>. Its Javadoc says that it returns true only if the Java spec declares the method as true.</p> <p>Please help me understand what this is used for! Can a custom class declare its method as a bridge if r...
[ { "answer_id": 289745, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 6, "selected": true, "text": "<p>A bridge method may be created by the compiler when extending a parameterized type whose methods have parameterized arguments...
2008/11/14
[ "https://Stackoverflow.com/questions/289731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11614/" ]
During navigation of the `java.lang.reflect.Method` class I came across the method `isBridge`. Its Javadoc says that it returns true only if the Java spec declares the method as true. Please help me understand what this is used for! Can a custom class declare its method as a bridge if required?
A bridge method may be created by the compiler when extending a parameterized type whose methods have parameterized arguments. You can find in this class [BridgeMethodResolver](https://fisheye.springsource.org/browse/spring-framework/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java?r=02a44...
289,733
<p>I have a logical error. I provided the following as input:</p> <ul> <li>the salary is 30000</li> <li>the child n° is 9</li> </ul> <p>So the the net salary will be:</p> <ul> <li><p>the family bonus + salary - tax</p> <pre><code> (750) + (30000) - (3000) </code></pre></li> <li><p>but my program count them as...
[ { "answer_id": 289750, "author": "Glenner003", "author_id": 27760, "author_profile": "https://Stackoverflow.com/users/27760", "pm_score": 0, "selected": false, "text": "<p>Another problem seems to lie in the fact that you don't initialize familybonus when you say familybonus += 300. So e...
2008/11/14
[ "https://Stackoverflow.com/questions/289733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a logical error. I provided the following as input: * the salary is 30000 * the child n° is 9 So the the net salary will be: * the family bonus + salary - tax ``` (750) + (30000) - (3000) ``` * but my program count them as ``` (1500) + (30000) + (6000) ``` My program doubled (accumulated) th...
I took the existing code, and hard-wired the inputs (rather than using Console.ReadLine()), I get: > > You are 28 years old Salary= 30000 > Tax= 3000 Family bonus= 750 Net= 25500 > > > The main problem seems to be not initializing values - i.e. treating fields as variables: ``` public double getTax() { if (...
289,735
<pre><code>import sys words = { 1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten', 11 : 'eleven', 12 : 'twelve', 13 : 'thirteen', 14 : 'fourteen', 15 : 'fifteen', 16 : 'sixteen', 17 ...
[ { "answer_id": 289748, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>Two improvements come to mind:</p>\n\n<ul>\n<li>40 is spelled \"forty\", not \"fourty\"</li>\n<li>your program needs u...
2008/11/14
[ "https://Stackoverflow.com/questions/289735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11110/" ]
``` import sys words = { 1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five', 6 : 'six', 7 : 'seven', 8 : 'eight', 9 : 'nine', 10 : 'ten', 11 : 'eleven', 12 : 'twelve', 13 : 'thirteen', 14 : 'fourteen', 15 : 'fifteen', 16 : 'sixteen', 17 : 'seve...
You can't group digits into "segments" going from left-to-right. The `range(0,len(),3)` is not going to work out well. You'll have to write the same algorithm for inserting digit separators. You start from the right, picking off segments of digits. What's left over (on the left, get it?) will be 1, 2 or 3 digits. You'...
289,743
<p>Our coding standards ask that we minimise the use of C# var (suggests limiting it's use to being in conjunction with Linq). However there are times when using generics where it's reasonably convenient e.g.</p> <pre><code>Dictionary&lt;DateTime, Dictionary&lt;string, float&gt;&gt; allValues = ... // ... foreach (var...
[ { "answer_id": 289768, "author": "Bluenuance", "author_id": 33111, "author_profile": "https://Stackoverflow.com/users/33111", "pm_score": 2, "selected": false, "text": "<p>Resharper does this (only in version 4+ I'm sure of it)\nbut I don't know if its possible to simply convert var into...
2008/11/14
[ "https://Stackoverflow.com/questions/289743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5764/" ]
Our coding standards ask that we minimise the use of C# var (suggests limiting it's use to being in conjunction with Linq). However there are times when using generics where it's reasonably convenient e.g. ``` Dictionary<DateTime, Dictionary<string, float>> allValues = ... // ... foreach (var dateEntry in allValue) `...
I've got ReSharper 4.1, and it does offer this option (in either direction). Actually, I'd recommend challenging the standard... the former is far more readable than the latter (especially if you call the variable `pair` or something similar). I would't use "var" for `var i = 0`, but it is ideally suited to the above....
289,751
<p>During development I have to "clear cache" in Firefox all the time in order to make it use the latest version of JavaScript files.</p> <p>Is there some kind of setting (about:config) to turn off caching completely for JavaScript files? Or, if not, for all files?</p>
[ { "answer_id": 289753, "author": "some", "author_id": 36866, "author_profile": "https://Stackoverflow.com/users/36866", "pm_score": 4, "selected": false, "text": "<p>Have you tried to use <kbd>CTRL</kbd>-<kbd>F5</kbd> to update the page?</p>\n" }, { "answer_id": 289771, "auth...
2008/11/14
[ "https://Stackoverflow.com/questions/289751", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
During development I have to "clear cache" in Firefox all the time in order to make it use the latest version of JavaScript files. Is there some kind of setting (about:config) to turn off caching completely for JavaScript files? Or, if not, for all files?
Enter "about:config" into the Firefox address bar and set: ``` browser.cache.disk.enable = false browser.cache.memory.enable = false ``` If developing locally, or using HTML5's new manifest attribute you may have to also set the following in about:config - ``` browser.cache.offline.enable = false ```
289,770
<p>In the past I've always gone and called my namespace for a particular project the same as the project (and principle class) e.g.:</p> <pre><code>namespace KeepAlive { public partial class KeepAlive : ServiceBase {... </code></pre> <p>Then from other projects whenever i've called that class its always been:...
[ { "answer_id": 289777, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 2, "selected": false, "text": "<p>i name my namespaces with the common descriptor of all the things that go into that namespace.</p>\n" }, { ...
2008/11/14
[ "https://Stackoverflow.com/questions/289770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445/" ]
In the past I've always gone and called my namespace for a particular project the same as the project (and principle class) e.g.: ``` namespace KeepAlive { public partial class KeepAlive : ServiceBase {... ``` Then from other projects whenever i've called that class its always been: ``` KeepAlive.KeepAlive(...
We have this simple scheme: ``` CompanyName.ProductName ``` Then the application layer, e.g. ``` CompanyName.ProductName.Data CompanyName.ProductName.Web ``` etc. And inside divided per module and/or functionality, which normally correspond to folders ``` CompanyName.ProductName.Web.Shop CompanyName.P...
289,773
<p>I use the app.config file to store some values (path to a mapping database, data connection selections). These settings differ on the user machines and I would like the installer to set them right. Is there an installer that can work with .NET config files during setup and allow me to create some dialogs that would ...
[ { "answer_id": 289802, "author": "tgeros", "author_id": 4458, "author_profile": "https://Stackoverflow.com/users/4458", "pm_score": 0, "selected": false, "text": "<p>I've used the WIX toolset to produce an msi. The tool allows you to declaratively specify changes to XML files like app.co...
2008/11/14
[ "https://Stackoverflow.com/questions/289773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4694/" ]
I use the app.config file to store some values (path to a mapping database, data connection selections). These settings differ on the user machines and I would like the installer to set them right. Is there an installer that can work with .NET config files during setup and allow me to create some dialogs that would hel...
We use WIX to change the application's configuration file. It works really well, you'll need to add wixUtilExtension.dll in the reference. WIX sample: ``` <Component Id="ChangeConfig" Guid="[YOUR_GUID_HERE]"> <File Id="App.config" Name="MyApplication.exe.config" Vital="yes" KeyPath="yes" Source="[Path to project d...
289,779
<p>I am working on a project where I need to create a boundary around a group of rectangles.</p> <p>Let's use this picture as an example of what I want to accomplish.</p> <p>EDIT: Couldn't get the image tag to work properly, so here is the full link: <a href="http://www.flickr.com/photos/21093416@N04/3029621742/" rel...
[ { "answer_id": 289787, "author": "nullDev", "author_id": 6621, "author_profile": "https://Stackoverflow.com/users/6621", "pm_score": 0, "selected": false, "text": "<p>A simple trick should be:</p>\n\n<ol>\n<li>Create a region from the first rectangle</li>\n<li>Add the other rectangles to...
2008/11/14
[ "https://Stackoverflow.com/questions/289779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37346/" ]
I am working on a project where I need to create a boundary around a group of rectangles. Let's use this picture as an example of what I want to accomplish. EDIT: Couldn't get the image tag to work properly, so here is the full link: <http://www.flickr.com/photos/21093416@N04/3029621742/> We have rectangles A and C...
Using the example, where rectangles are perpendicular to each other and can therefore be presented by four values (two x coordinates and two y coordinates): ``` 1 2 3 4 5 6 1 +---+---+ | | 2 + A +---+---+ | | B | 3 + + +---+---+ | | | | | 4 +---+---...
289,792
<p>What is the best way to convert an Int value to the corresponding Char in Utf16, given that the Int is in the range of valid values?</p>
[ { "answer_id": 289814, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 6, "selected": false, "text": "<pre><code>int i = 65;\nchar c = Convert.ToChar(i);\n</code></pre>\n" }, { "answer_id": 289815, "author": "...
2008/11/14
[ "https://Stackoverflow.com/questions/289792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2892/" ]
What is the best way to convert an Int value to the corresponding Char in Utf16, given that the Int is in the range of valid values?
``` (char)myint; ``` for example: ``` Console.WriteLine("(char)122 is {0}", (char)122); ``` yields: > > (char)122 is z > > >
289,794
<p>I have an arraylist that contains items called Room. Each Room has a roomtype such as kitchen, reception etc. I want to check the arraylist to see if any rooms of that type exist before adding it to the list. Can anyone recommend a neat way of doing this without the need for multiple foreach loops?</p> <p>(.NET 2.0...
[ { "answer_id": 289810, "author": "Bluenuance", "author_id": 33111, "author_profile": "https://Stackoverflow.com/users/33111", "pm_score": 1, "selected": false, "text": "<pre><code>if (!rooms.Any (r =&gt; r.RoomType == typeToFind /*kitchen, ...*/))\n //add it or whatever\n</code></pre>\n...
2008/11/14
[ "https://Stackoverflow.com/questions/289794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35441/" ]
I have an arraylist that contains items called Room. Each Room has a roomtype such as kitchen, reception etc. I want to check the arraylist to see if any rooms of that type exist before adding it to the list. Can anyone recommend a neat way of doing this without the need for multiple foreach loops? (.NET 2.0) --- I ...
I would not use `ArrayList` here; since you have .NET 2.0, use `List<T>` and all becomes simple: ``` List<Room> rooms = ... string roomType = "lounge"; bool exists = rooms.Exists(delegate(Room room) { return room.Type == roomType; }); ``` Or with C# 3.0 (still targetting .NET 2.0) ``` bool exists = rooms.Exists(roo...
289,800
<p>I have installed m2eclipse plugin from <a href="http://web.archive.org/web/20150524020820/http://m2eclipse.codehaus.org/" rel="nofollow noreferrer">http://m2eclipse.codehaus.org/</a>. Now I want to use that as a standalone build tool but I am unable to find the installation directory. Can anyone help me in this?</p>...
[ { "answer_id": 289938, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 1, "selected": false, "text": "<p>I am not sure to understand what you want.\nm2eclipse is a <strong>plugin</strong> for Eclipse, thus it must be...
2008/11/14
[ "https://Stackoverflow.com/questions/289800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37626/" ]
I have installed m2eclipse plugin from [http://m2eclipse.codehaus.org/](http://web.archive.org/web/20150524020820/http://m2eclipse.codehaus.org/). Now I want to use that as a standalone build tool but I am unable to find the installation directory. Can anyone help me in this?
Execute the following command: ``` mvn --version ``` Example Result: ``` Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100) Maven home: `D:\apache-maven-3.0.5\bin`\.. Java version: 1.6.0_25, vendor: Sun Microsystems Inc. Java home: C:\Program Files\Java\jdk1.6.0_25\jre Defaul...
289,801
<p>I'm searching for a way of developing a MethodInterceptor which prints the caller class.</p> <p>Is there any way of getting the caller object into the method interceptor?</p>
[ { "answer_id": 289821, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 0, "selected": false, "text": "<p>You could do something crude with generating a stack trace and inspecting it, but that is ugly</p>\n" }, { ...
2008/11/14
[ "https://Stackoverflow.com/questions/289801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2937/" ]
I'm searching for a way of developing a MethodInterceptor which prints the caller class. Is there any way of getting the caller object into the method interceptor?
This might work, declare an exception and then use it to get a look at the stack at the time when your method is intercepted: ``` Throwable t = new Throwable(); StackTraceElement[] elements = t.getStackTrace(); String calleeMethod = elements[0].getMethodName(); String callerMethodName = elements[1].getMethodName(); ...
289,804
<p>I've written a program that counts lines, words, and characters in a text: it does this with threads. It works great sometimes, but not so great other times. What ends up happening is the variables pointing to the number of words and characters counted sometimes come up short and sometimes don't.</p> <p>It seems to...
[ { "answer_id": 289818, "author": "Chris Kimpton", "author_id": 48310, "author_profile": "https://Stackoverflow.com/users/48310", "pm_score": 2, "selected": false, "text": "<p>Sounds like a good question to me... I think the problem might be related to the atomicity of the chars += and w...
2008/11/14
[ "https://Stackoverflow.com/questions/289804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
I've written a program that counts lines, words, and characters in a text: it does this with threads. It works great sometimes, but not so great other times. What ends up happening is the variables pointing to the number of words and characters counted sometimes come up short and sometimes don't. It seems to me that t...
A different threaded design would make it easier to find and fix this kind of problem, and be more efficient into the bargain. This is a longish response, but the summary is "if you're doing threads in Java, check out [java.util.concurrent](http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.ht...
289,809
<p>how come this work </p> <pre><code>public IQueryable&lt;Category&gt; getCategories(int postId) { subnusMVCRepository&lt;Categories&gt; categories = new subnusMVCRepository&lt;Categories&gt;(); subnusMVCRepository&lt;Post_Category_Map&gt; postCategoryMap = new subnusMVCRepository&lt;Post_Category_Map...
[ { "answer_id": 289844, "author": "Alexandre Brisebois", "author_id": 18619, "author_profile": "https://Stackoverflow.com/users/18619", "pm_score": 0, "selected": false, "text": "<p>The problem is not the linq itself,\nyou need to be sure that the context or provider object is able to fet...
2008/11/14
[ "https://Stackoverflow.com/questions/289809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31296/" ]
how come this work ``` public IQueryable<Category> getCategories(int postId) { subnusMVCRepository<Categories> categories = new subnusMVCRepository<Categories>(); subnusMVCRepository<Post_Category_Map> postCategoryMap = new subnusMVCRepository<Post_Category_Map>(); var query = from c in categori...
The issue is most likely in the implementation of the query provider. pcm.PostId == 1 and pcm.PostId == postId actually have a big difference. In the expression tree the first is generated as a ConstantExpression which doesnt need to be evaulated. With the second, the compiler actually generates an inner class h...
289,825
<p>Why EAccessViolation is raised when executing the code below? </p> <pre><code>uses Generics.Collections; ... var list: TList&lt;TNotifyEvent&gt;; ... begin list := TList&lt;TNotifyEvent&gt;.Create(); try list.Add(myNotifyEvent); list.Remove(myNotifyEvent); // EAccessViolation at address... ...
[ { "answer_id": 289870, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>the above code is used in TForm1 ...</p>\n\n<pre><code>uses \n Generics.Collections;\n\nprocedure TForm1.Button1Click(Send...
2008/11/14
[ "https://Stackoverflow.com/questions/289825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Why EAccessViolation is raised when executing the code below? ``` uses Generics.Collections; ... var list: TList<TNotifyEvent>; ... begin list := TList<TNotifyEvent>.Create(); try list.Add(myNotifyEvent); list.Remove(myNotifyEvent); // EAccessViolation at address... finally FreeAndNil(lis...
It looks like a bug. If you compile with debug dcu's (normally don't do that unless you want to loose your sanity!) you see that a call to the comparer went wrong. A (possibly optional) third value of a compare function is not set and causes the access violation. So possibly you can't put method pointers in a generic...