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 |
|---|---|---|---|---|---|---|
138,948 | <p>I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support <code>äöå</code> etc. for regular Finnish text and Cyrillic alphabets like <code>ЦжФ</code> for special cases.</p>
<p>My setup is the following:</p>
<ul>
<li>Development environment: Windows XP</li>
<li>Production environm... | [
{
"answer_id": 138950,
"author": "kosoant",
"author_id": 15114,
"author_profile": "https://Stackoverflow.com/users/15114",
"pm_score": 10,
"selected": true,
"text": "<p><em>Answering myself as the FAQ of this site encourages it. This works for me: </em></p>\n\n<p>Mostly characters äåö ar... | 2008/09/26 | [
"https://Stackoverflow.com/questions/138948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15114/"
] | I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support `äöå` etc. for regular Finnish text and Cyrillic alphabets like `ЦжФ` for special cases.
My setup is the following:
* Development environment: Windows XP
* Production environment: Debian
Database used: MySQL 5.x
Users mainl... | *Answering myself as the FAQ of this site encourages it. This works for me:*
Mostly characters äåö are not a problematic as the default character set used by browsers and tomcat/java for webapps is latin1 ie. ISO-8859-1 which "understands" those characters.
To get UTF-8 working under Java+Tomcat+Linux/Windows+Mysql ... |
138,981 | <p>Is there any way to find out if a file is a directory?</p>
<p>I have the file name in a variable. In Perl I can do this:</p>
<pre><code>if(-d $var) { print "it's a directory\n" }
</code></pre>
| [
{
"answer_id": 138995,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 7,
"selected": true,
"text": "<p>You can do it like so:</p>\n\n<pre><code>IF EXIST %VAR%\\NUL ECHO It's a directory\n</code></pre>\n\n<p>However, this o... | 2008/09/26 | [
"https://Stackoverflow.com/questions/138981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234/"
] | Is there any way to find out if a file is a directory?
I have the file name in a variable. In Perl I can do this:
```
if(-d $var) { print "it's a directory\n" }
``` | You can do it like so:
```
IF EXIST %VAR%\NUL ECHO It's a directory
```
However, this only works for directories without spaces in their names. When you add quotes round the variable to handle the spaces it will stop working. To handle directories with spaces, convert the filename to short 8.3 format as follows:
``... |
138,994 | <p>I have a procedure with a lot of </p>
<pre><code>i := i +1;
</code></pre>
<p>in it and I think </p>
<pre><code> inc(i);
</code></pre>
<p>looks a lot better. Is there a performance difference or does the function call just get inlined by the compiler? I know this probably doesn't matter at all to my app, I'm ju... | [
{
"answer_id": 139008,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 4,
"selected": true,
"text": "<p>Modern compilers optimize the code.<br>\ninc(i) and i:= i+1; are pretty much the same.</p>\n\n<p>Use whichever you pref... | 2008/09/26 | [
"https://Stackoverflow.com/questions/138994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9077/"
] | I have a procedure with a lot of
```
i := i +1;
```
in it and I think
```
inc(i);
```
looks a lot better. Is there a performance difference or does the function call just get inlined by the compiler? I know this probably doesn't matter at all to my app, I'm just curious.
EDIT: I did some gauging of the perfor... | Modern compilers optimize the code.
inc(i) and i:= i+1; are pretty much the same.
Use whichever you prefer.
Edit: As Jim McKeeth corrected: with Overflow Checking there is a difference. Inc does not do a range checking. |
138,999 | <p>I just started learning JSP technology, and came across a wall.</p>
<p><em>How do you output HTML from a method in <%! ... %> JSP declaration block?</em></p>
<p>This doesn't work:</p>
<pre><code><%!
void someOutput() {
out.println("Some Output");
}
%>
...
<% someOutput(); %>
</code></pre>
<p>... | [
{
"answer_id": 139018,
"author": "Ashley Mercer",
"author_id": 13065,
"author_profile": "https://Stackoverflow.com/users/13065",
"pm_score": 5,
"selected": false,
"text": "<p>You can't use the 'out' variable (nor any of the other \"predeclared\" scriptlet variables) inside directives.</p... | 2008/09/26 | [
"https://Stackoverflow.com/questions/138999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1764/"
] | I just started learning JSP technology, and came across a wall.
*How do you output HTML from a method in <%! ... %> JSP declaration block?*
This doesn't work:
```
<%!
void someOutput() {
out.println("Some Output");
}
%>
...
<% someOutput(); %>
```
Server says there's no “out”.
**U:** I do know how to rewrite... | You can't use the 'out' variable (nor any of the other "predeclared" scriptlet variables) inside directives.
The JSP page gets translated by your webserver into a Java servlet. Inside tomcats, for instance, everything inside scriptlets (which start "<%"), along with all the static HTML, gets translated into one giant ... |
139,000 | <p>I hope someone might be able to help me here. I've tried to simplify my example as best I can.</p>
<p>I have an absolutely positioned DIV, which for this example I've made fill the browser window. This div has the overflow:auto attribute to provide scroll bars when the content is too big for the DIV to display.</p>... | [
{
"answer_id": 139024,
"author": "Patcouch22",
"author_id": 19226,
"author_profile": "https://Stackoverflow.com/users/19226",
"pm_score": 0,
"selected": false,
"text": "<p>This looks like it should fix your problem, as long as you are not apposed to condition statements. <a href=\"http:... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I hope someone might be able to help me here. I've tried to simplify my example as best I can.
I have an absolutely positioned DIV, which for this example I've made fill the browser window. This div has the overflow:auto attribute to provide scroll bars when the content is too big for the DIV to display.
Within the D... | I had a problem with excessive horizonal bar in IE7. I've used D Carter's solution slighty changed
```
<div style="zoom: 1; overflow: auto;">
<div id="myDiv" style="zoom: 1;">
<table style="width: 100%"...
...
</table>
</div>
</div>
```
To work in IE browser lesser than 7 you need add:
```
<... |
139,010 | <p>I need to find out the file/directory name that a .lnk is pointing to using c#.</p>
<p>What is the simplest way to do this?</p>
<p>Thanks.</p>
| [
{
"answer_id": 139032,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 4,
"selected": false,
"text": "<p>This may help:</p>\n\n<p><a href=\"http://www.neowin.net/forum/index.php?s=3ad7f1ffb995ba84999376f574e9250f&showtopic=65892... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to find out the file/directory name that a .lnk is pointing to using c#.
What is the simplest way to do this?
Thanks. | I wrote this for video browser, it works really well
```
#region Signitures imported from http://pinvoke.net
[DllImport("shfolder.dll", CharSet = CharSet.Auto)]
internal static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
[Flags()]
enum SLGP_FLAGS
{
... |
139,012 | <p>Does anyone know how I can achieve the following effect in OpenGL:</p>
<ul>
<li>Change the brightness of the rendered scene</li>
<li>Or implementing a Gamma setting in OpenGL</li>
</ul>
<p>I have tried by changing the ambient parameter of the light and the type of light (directional and omnidirectional) but the re... | [
{
"answer_id": 139038,
"author": "Harald Scheirich",
"author_id": 22080,
"author_profile": "https://Stackoverflow.com/users/22080",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://www.gamedev.net/community/forums/topic.asp?topic_id=435400\" rel=\"nofollow noreferrer\">http... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18564/"
] | Does anyone know how I can achieve the following effect in OpenGL:
* Change the brightness of the rendered scene
* Or implementing a Gamma setting in OpenGL
I have tried by changing the ambient parameter of the light and the type of light (directional and omnidirectional) but the result was not uniform. TIA.
Thanks ... | On win32 you can use SetDeviceGammaRamp to adjust the overall brightness / gamma. However, this affects the entire display so it's not a good idea unless your app is fullscreen.
The portable alternative is to either draw the entire scene brighter or dimmer (which is a hassle), or to slap a fullscreen alpha-blended qua... |
139,015 | <p>I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string.
To date I have been using this:</p>
<pre><code>my @search_results = `grep -i -l \"$string\" *.pdf`;
</code></pre>
<p>where $string is the text to look for.
However this fails for m... | [
{
"answer_id": 139077,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": true,
"text": "<p>The PerlMonks thread <a href=\"http://www.perlmonks.org/?node_id=582868\" rel=\"noreferrer\">here</a> talks about ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22654/"
] | I have a bunch of PDF files and my Perl program needs to do a full-text search of them to return which ones contain a specific string.
To date I have been using this:
```
my @search_results = `grep -i -l \"$string\" *.pdf`;
```
where $string is the text to look for.
However this fails for most pdf's because the file... | The PerlMonks thread [here](http://www.perlmonks.org/?node_id=582868) talks about this problem.
It seems that for your situation, it might be simplest to get **pdftotext** (the command line tool), then you can do something like:
```
my @search_results = `pdftotext myfile.pdf - | grep -i -l \"$string\"`;
``` |
139,046 | <p>I need to write code that picks up PGP-encrypted files from an FTP location and processes them. The files will be encrypted with my public key (not that I have one yet). Obviously, I need a PGP library that I can use from within Microsoft Access. Can you recommend one that is easy to use? </p>
<p>I'm looking for so... | [
{
"answer_id": 139104,
"author": "Birger",
"author_id": 11485,
"author_profile": "https://Stackoverflow.com/users/11485",
"pm_score": 1,
"selected": false,
"text": "<p>I would look for a command line encrypter / decrypter and just call the exe from within your Access application, with th... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21379/"
] | I need to write code that picks up PGP-encrypted files from an FTP location and processes them. The files will be encrypted with my public key (not that I have one yet). Obviously, I need a PGP library that I can use from within Microsoft Access. Can you recommend one that is easy to use?
I'm looking for something th... | A command line solution is good. If your database is an internal application, not to be redistributed, I can recommend [Gnu Privacy Guard](http://www.gnupg.org). This command-line based tool will allow you to do anything that you need to with regard to the OpenPGP standard.
Within Access, you can use the Shell() comma... |
139,055 | <p>I'm using Subversive plugin in Ganymede, but after today's update it stopped working - it just doesn't see any valid svn connectors (I've already been using 1.2.0 dev version of SVNKit, instead of a stable one, because Subversive / Ganymede could not handle it; now it can't handle even the dev one). Any ideas how to... | [
{
"answer_id": 139160,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 0,
"selected": false,
"text": "<p>I'm using <a href=\"http://subclipse.tigris.org/\" rel=\"nofollow noreferrer\">Subclipse</a> in Ganymede successfully,... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4688/"
] | I'm using Subversive plugin in Ganymede, but after today's update it stopped working - it just doesn't see any valid svn connectors (I've already been using 1.2.0 dev version of SVNKit, instead of a stable one, because Subversive / Ganymede could not handle it; now it can't handle even the dev one). Any ideas how to ma... | I had a similar problem right after the update. It turned out that I had been getting the connectors (the base connector and both the SVNKit and JavaHL connectors) from the Polarion site that had "ganymede" in the URL. Instead, I should have been using the general URL.
Checking my current configuration, you should be ... |
139,076 | <p>I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this?</p>
<pre><code>String unformattedXml = "<tag><nested>hello</nested></tag>";
String formattedXml = new [UnknownClass]().format(unforma... | [
{
"answer_id": 139096,
"author": "Lorenzo Boccaccia",
"author_id": 2273540,
"author_profile": "https://Stackoverflow.com/users/2273540",
"pm_score": 8,
"selected": false,
"text": "<pre class=\"lang-java prettyprint-override\"><code>Transformer transformer = TransformerFactory.newInstance... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2959/"
] | I have a Java String that contains XML, with no line feeds or indentations. I would like to turn it into a String with nicely formatted XML. How do I do this?
```
String unformattedXml = "<tag><nested>hello</nested></tag>";
String formattedXml = new [UnknownClass]().format(unformattedXml);
```
Note: My input is a **... | Now it's 2012 and Java can do more than it used to with XML, I'd like to add an alternative to my accepted answer. This has no dependencies outside of Java 6.
```
import org.w3c.dom.Node;
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSSerializ... |
139,088 | <p>when i use setDefaultLookAndFeelDecorated(true) method in Java
why is the Frame appear FullScreen when i maximize the Frame ?
and how can i disaple the FullScreen mode in this method ?</p>
| [
{
"answer_id": 139126,
"author": "pfranza",
"author_id": 22221,
"author_profile": "https://Stackoverflow.com/users/22221",
"pm_score": 0,
"selected": false,
"text": "<p>If you don't want your JFrame to be maximize-able then then call .setResizable(false); on it. </p>\n"
},
{
"an... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22634/"
] | when i use setDefaultLookAndFeelDecorated(true) method in Java
why is the Frame appear FullScreen when i maximize the Frame ?
and how can i disaple the FullScreen mode in this method ? | Setting `setDefaultLookAndFeelDecorated` to true causes the decorations to be handled by the look and feel; this means that a System look-and-feel on both Windows and Mac (I have no Linux at hand now) retains the borders you would expect them of a native window, e.g. staying clear of the taskbar in Windows.
When using... |
139,090 | <p>I have a DLL that's loaded into a 3rd party parent process as an extension. From this DLL I instantiate external processes (my own) by using CreateProcess API. This works great in 99.999% of the cases but sometimes this suddenly fails and stops working permanently (maybe a restart of the parent process would solve t... | [
{
"answer_id": 139230,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 1,
"selected": false,
"text": "<p>Quoting from the MSDN article on <a href=\"http://msdn.microsoft.com/en-us/library/aa915088.aspx\" rel=\"nofollow noreferr... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a DLL that's loaded into a 3rd party parent process as an extension. From this DLL I instantiate external processes (my own) by using CreateProcess API. This works great in 99.999% of the cases but sometimes this suddenly fails and stops working permanently (maybe a restart of the parent process would solve this... | Quoting from the MSDN article on [GetExitCodeProcess](http://msdn.microsoft.com/en-us/library/aa915088.aspx):
The following termination statuses can be returned if the process has terminated:
* The exit value specified in the
ExitProcess or TerminateProcess
function
* The return value from the
main or WinMain functio... |
139,115 | <p>Here is the scenario:</p>
<p>I have a winforms application using NHibernate. When launched, I populate a DataGridView with the results of a NHibernate query. This part works fine. If I update a record in that list and flush the session, the update takes in the database. Upon closing the form after the update, I... | [
{
"answer_id": 139133,
"author": "Richard",
"author_id": 20038,
"author_profile": "https://Stackoverflow.com/users/20038",
"pm_score": 0,
"selected": false,
"text": "<p>what about refresh? - see <a href=\"http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/manipulatingdata... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1117/"
] | Here is the scenario:
I have a winforms application using NHibernate. When launched, I populate a DataGridView with the results of a NHibernate query. This part works fine. If I update a record in that list and flush the session, the update takes in the database. Upon closing the form after the update, I call a method... | After your update, Evict the object from the first level cache.
```
Session.Update(obj);
Session.Evict(obj);
```
You may want to commit and/or flush first. |
139,118 | <p>Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:</p>
<pre><code>document.getElementById('iframe01').contentDocument.body.innerHTML
document.frames['iframe01'].document.body.innerHTML
document.getElementById('iframe01').contentWindow.document.body.innerHTML
</code></pre>
<p... | [
{
"answer_id": 139132,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 3,
"selected": false,
"text": "<p>If you take a look at <a href=\"http://www.jquery.com\" rel=\"noreferrer\">JQuery</a>, you can do something like:</p>\n\n... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:
```
document.getElementById('iframe01').contentDocument.body.innerHTML
document.frames['iframe01'].document.body.innerHTML
document.getElementById('iframe01').contentWindow.document.body.innerHTML
```
etc | I think this is what you want:
```
window.frames['iframe01'].document.body.innerHTML
```
**EDIT:**
I have it on good authority that this won't work in Chrome and Firefox although it works perfectly in IE, which is where I tested it. In retrospect, that was a big mistake
This will work:
```
window.frames[0].docum... |
139,131 | <p>i have a number of jsp files under web-inf folder. Inside my web.xml i specify an errorppage for 404 amd 403 and java.lang.exception. Do i need to include a page directive for each of my jsp's or will they automatically get forwarded to the exception handling page because they are under web-inf?</p>
<p>If this is t... | [
{
"answer_id": 139174,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 2,
"selected": true,
"text": "<p>You just need to have whatever errorpage you would like to use in your app available with all the other jsps. So in the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i have a number of jsp files under web-inf folder. Inside my web.xml i specify an errorppage for 404 amd 403 and java.lang.exception. Do i need to include a page directive for each of my jsp's or will they automatically get forwarded to the exception handling page because they are under web-inf?
If this is true does t... | You just need to have whatever errorpage you would like to use in your app available with all the other jsps. So in the following example you would just need to have the error pages in the root of the context path(where all of the other jsps are). Anytime the webapp receives a 404 or 403 error it will try to display on... |
139,157 | <p>I am building a menu in HTML/CSS/JS and I need a way to prevent the text in the menu from being highlighted when double-clicked on. I need a way to pass the id's of several divs into a function and have highlighting turned off within them. </p>
<p>So when the user accidentally (or on purpose) double clicks on the m... | [
{
"answer_id": 139185,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>You could:</p>\n\n<ul>\n<li>Give it (\"it\" being your text) a onclick event</li>\n<li>First click sets a variable to the c... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/315650/"
] | I am building a menu in HTML/CSS/JS and I need a way to prevent the text in the menu from being highlighted when double-clicked on. I need a way to pass the id's of several divs into a function and have highlighting turned off within them.
So when the user accidentally (or on purpose) double clicks on the menu, the m... | In (Mozilla, Firefox, Camino, Safari, Google Chrome) you can use this:
```
div.noSelect {
-moz-user-select: none; /* mozilla browsers */
-khtml-user-select: none; /* webkit browsers */
}
```
For IE there is no CSS option, but you can capture the ondragstart event, and return false;
**Update**
Browser support f... |
139,180 | <p>I have a Python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it.</p>
<p>I want to call the <code>help</code> function on each one. In Ruby I can do something like <code>ClassName.methods</code> to get a list of all the methods available on that class. I... | [
{
"answer_id": 139193,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 9,
"selected": false,
"text": "<p>You can use <code>dir(module)</code> to see all available methods/attributes. Also check out PyDocs.</p>\n"
},
{
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6527/"
] | I have a Python module installed on my system and I'd like to be able to see what functions/classes/methods are available in it.
I want to call the `help` function on each one. In Ruby I can do something like `ClassName.methods` to get a list of all the methods available on that class. Is there something similar in Py... | Use the [`inspect`](https://docs.python.org/3/library/inspect.html) module:
```
from inspect import getmembers, isfunction
from somemodule import foo
print(getmembers(foo, isfunction))
```
Also see the [`pydoc`](https://docs.python.org/3/library/pydoc.html) module, the `help()` function in the interactive interpret... |
139,199 | <p>I realize that parameterized SQL queries is the optimal way to sanitize user input when building queries that contain user input, but I'm wondering what is wrong with taking user input and escaping any single quotes and surrounding the whole string with single quotes. Here's the code:</p>
<pre><code>sSanitizedInput... | [
{
"answer_id": 139215,
"author": "Rob",
"author_id": 18505,
"author_profile": "https://Stackoverflow.com/users/18505",
"pm_score": -1,
"selected": false,
"text": "<p>It might work, but it seems a little hokey to me. I'd recommend verifing that each string is valid by testing it against a... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22392/"
] | I realize that parameterized SQL queries is the optimal way to sanitize user input when building queries that contain user input, but I'm wondering what is wrong with taking user input and escaping any single quotes and surrounding the whole string with single quotes. Here's the code:
```
sSanitizedInput = "'" & Repla... | First of all, it's just bad practice. Input validation is always necessary, but it's also always iffy.
Worse yet, blacklist validation is always problematic, it's much better to explicitly and strictly define what values/formats you accept. Admittedly, this is not always possible - but to some extent it must always ... |
139,212 | <p>I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will... | [
{
"answer_id": 145610,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 2,
"selected": true,
"text": "<p>If you read the <a href=\"https://pywebsvcs.svn.sourceforge.net/svnroot/pywebsvcs/trunk/zsi/ZSI/client.py\" rel=\"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17583/"
] | I've added cookie support to SOAPpy by overriding HTTPTransport. I need functionality beyond that of SOAPpy, so I was planning on moving to ZSI, but I can't figure out how to put the Cookies on the ZSI posts made to the service. Without these cookies, the server will think it is an unauthorized request and it will fail... | If you read the [\_Binding class in client.py of ZSI](https://pywebsvcs.svn.sourceforge.net/svnroot/pywebsvcs/trunk/zsi/ZSI/client.py) you can see that it has a variable cookies, which is an instance of [Cookie.SimpleCookie](http://docs.python.org/lib/module-Cookie.html). Following the [ZSI example](http://pywebsvcs.so... |
139,214 | <p>The most egregiously redundant code construct I often see involves using the code sequence</p>
<pre><code>if (condition)
return true;
else
return false;
</code></pre>
<p>instead of simply writing</p>
<pre><code>return (condition);
</code></pre>
<p>I've seen this beginner error in all sorts of languages: ... | [
{
"answer_id": 139231,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": 2,
"selected": false,
"text": "<p>Returning uselessly at the end:</p>\n\n<pre><code> // stuff\n return;\n}\n</code></pre>\n"
},
{
"answer_id": 13... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20520/"
] | The most egregiously redundant code construct I often see involves using the code sequence
```
if (condition)
return true;
else
return false;
```
instead of simply writing
```
return (condition);
```
I've seen this beginner error in all sorts of languages: from Pascal and C to PHP and Java. What other suc... | ```
if (foo == true)
{
do stuff
}
```
I keep telling the developer that does that that it should be
```
if ((foo == true) == true)
{
do stuff
}
```
but he hasn't gotten the hint yet. |
139,245 | <p>How to get the relative path in t sql? Take for example a <code>.sql</code> file is located in the folder <code>D:\temp</code>, I want to get path of the file hello.txt in the folder <code>D:\temp\App_Data</code>. How to use the relative path reference?</p>
<p>Let's say I am executing the sql file inside the SQL se... | [
{
"answer_id": 139431,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 3,
"selected": false,
"text": "<p>The .sql file is just.... a file. It doesn't have any sense of its own location. It's the thing that excutes it (w... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | How to get the relative path in t sql? Take for example a `.sql` file is located in the folder `D:\temp`, I want to get path of the file hello.txt in the folder `D:\temp\App_Data`. How to use the relative path reference?
Let's say I am executing the sql file inside the SQL server management studio. | The server is executing the t-sql. It doesn't know where the client loaded the file from. You'll have to have the path embedded within the script.
```
DECLARE @RelDir varchar(1000)
SET @RelDir = 'D:\temp\'
...
```
Perhaps you can programmatically place the path into the SET command within the .sql script file, or pe... |
139,260 | <p>I'm having a problem writing Norwegian characters into an XML file using C#. I have a string variable containing some Norwegian text (with letters like æøå). </p>
<p>I'm writing the XML using an XmlTextWriter, writing the contents to a MemoryStream like this:</p>
<pre><code>MemoryStream stream = new MemoryStream()... | [
{
"answer_id": 139307,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 2,
"selected": false,
"text": "<p>Which encoding do you use for displaying the result file? If it is not in ISO-8859-1, it will not display correctly.</p>\n... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5795/"
] | I'm having a problem writing Norwegian characters into an XML file using C#. I have a string variable containing some Norwegian text (with letters like æøå).
I'm writing the XML using an XmlTextWriter, writing the contents to a MemoryStream like this:
```
MemoryStream stream = new MemoryStream();
XmlTextWriter xmlTe... | Why are you writing the XML first to a MemoryStream and then writing that to the actual file stream? That's pretty inefficient. If you write directly to the FileStream it should work.
If you still want to do the double write, for whatever reason, do one of two things. Either
1. Make sure that the StreamReader and St... |
139,261 | <p>For testing purposes I have to generate a file of a certain size (to test an upload limit). </p>
<p>What is a command to create a file of a certain size on Linux?</p>
| [
{
"answer_id": 139278,
"author": "Grundlefleck",
"author_id": 4120,
"author_profile": "https://Stackoverflow.com/users/4120",
"pm_score": 5,
"selected": false,
"text": "<p>Use this command:</p>\n\n<pre>\ndd if=$INPUT-FILE of=$OUTPUT-FILE bs=$BLOCK-SIZE count=$NUM-BLOCKS\n</pre>\n\n<p>To ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] | For testing purposes I have to generate a file of a certain size (to test an upload limit).
What is a command to create a file of a certain size on Linux? | For small files:
```
dd if=/dev/zero of=upload_test bs=file_size count=1
```
Where `file_size` is the size of your test file in bytes.
For big files:
```
dd if=/dev/zero of=upload_test bs=1M count=size_in_megabytes
``` |
139,288 | <p>what is an efficient way to get a certain time for the next day in Java?
Let's say I want the long for tomorrow 03:30:00.
Setting Calendar fields and Date formatting are obvious.
Better or smarter ideas, thanks for sharing them!</p>
<p>Okami</p>
| [
{
"answer_id": 139319,
"author": "Brandon DuRette",
"author_id": 17834,
"author_profile": "https://Stackoverflow.com/users/17834",
"pm_score": 2,
"selected": false,
"text": "<p>I'm curious to hear what other people have to say about this one. My own experience is that taking shortcuts (i... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11450/"
] | what is an efficient way to get a certain time for the next day in Java?
Let's say I want the long for tomorrow 03:30:00.
Setting Calendar fields and Date formatting are obvious.
Better or smarter ideas, thanks for sharing them!
Okami | I take the brute force approach
```
// make it now
Calendar dateCal = Calendar.getInstance();
// make it tomorrow
dateCal.add(Calendar.DAY_OF_YEAR, 1);
// Now set it to the time you want
dateCal.set(Calendar.HOUR_OF_DAY, hours);
dateCal.set(Calendar.MINUTE, minutes);
dateCal.set(Calendar.SECOND, seconds);
dateCal.set(... |
139,325 | <p>How to set all the values in a <code>std::map</code> to the same value, without using a loop iterating over each value? </p>
| [
{
"answer_id": 139377,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "<p>Using a loop <em>is</em> by far the simplest method. In fact, it’s a one-liner:<sup>[C++17]</sup></p>\n<pre><code>f... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6841/"
] | How to set all the values in a `std::map` to the same value, without using a loop iterating over each value? | Using a loop *is* by far the simplest method. In fact, it’s a one-liner:[C++17]
```
for (auto& [_, v] : mymap) v = value;
```
Unfortunately C++ algorithm support for associative containers isn’t great pre-C++20. As a consequence, we can’t directly use `std::fill`.
To use them anyway (pre-C++20), we need to write ad... |
139,358 | <p>In a user defined wizard page, is there a way to capture change or focus events of the controls? I want to provide an immediate feedback on user input in some dropdowns (e.g. a message box)</p>
| [
{
"answer_id": 139404,
"author": "Otherside",
"author_id": 18697,
"author_profile": "https://Stackoverflow.com/users/18697",
"pm_score": 2,
"selected": false,
"text": "<p>Since the scripting in innosetup is loosely based on Delphi, the controls should have some events like <code>OnEnter<... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22114/"
] | In a user defined wizard page, is there a way to capture change or focus events of the controls? I want to provide an immediate feedback on user input in some dropdowns (e.g. a message box) | Took me some time to work it out, but after being pointed in the right direction by Otherside, I finally got it (works for version 5.2):
```
[Code]
var
MyCustomPage : TWizardPage;
procedure MyEditField_OnChange(Sender: TObject);
begin
MsgBox('TEST', mbError, MB_OK);
end;
function MyCustomPage_Create(Previ... |
139,365 | <p>I've begun to use TDD. As mentioned in <a href="https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#64402">an earlier question</a> the biggest difficulty is handling interface changes. How do you reduce the impact on your test cases as requirements change?</p>
| [
{
"answer_id": 139378,
"author": "Paul Whelan",
"author_id": 3050,
"author_profile": "https://Stackoverflow.com/users/3050",
"pm_score": 0,
"selected": false,
"text": "<p>You write the tests before you write the code for the new interface.</p>\n"
},
{
"answer_id": 139380,
"au... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16496/"
] | I've begun to use TDD. As mentioned in [an earlier question](https://stackoverflow.com/questions/64333/what-is-the-downside-to-test-driven-development#64402) the biggest difficulty is handling interface changes. How do you reduce the impact on your test cases as requirements change? | Changing an interface requires updating code that uses that interface. Test code isn't any different from non-test code in this respect. It's unavoidable that tests for that interface will need to change.
Often when an interface changes you find that "too many" tests break, i.e. tests for largely unrelated functionali... |
139,474 | <p>I'd like to capture the output of <a href="http://us3.php.net/manual/en/function.var-dump.php" rel="noreferrer"><code>var_dump</code></a> to a string.</p>
<p>The PHP documentation says;</p>
<blockquote>
<p>As with anything that outputs its result directly to the browser, the <a href="http://us3.php.net/manual/en... | [
{
"answer_id": 139491,
"author": "Eran Galperin",
"author_id": 10585,
"author_profile": "https://Stackoverflow.com/users/10585",
"pm_score": 10,
"selected": true,
"text": "<p>Use output buffering:</p>\n\n<pre><code><?php\nob_start();\nvar_dump($someVar);\n$result = ob_get_clean();\n?&... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | I'd like to capture the output of [`var_dump`](http://us3.php.net/manual/en/function.var-dump.php) to a string.
The PHP documentation says;
>
> As with anything that outputs its result directly to the browser, the [output-control functions](http://us3.php.net/manual/en/ref.outcontrol.php) can be used to capture the ... | Use output buffering:
```
<?php
ob_start();
var_dump($someVar);
$result = ob_get_clean();
?>
``` |
139,484 | <p>I have two (UNIX) programs A and B that read and write from stdin/stdout.</p>
<p>My first problem is how to connect the stdout of A to stdin of B <em>and</em> the stdout of B to the stdin of A. I.e., something like A | B but a bidirectional pipe. I suspect I could solve this by <a href="http://tldp.org/LDP/abs/html... | [
{
"answer_id": 139495,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://bisqwit.iki.fi/source/twinpipe.html\" rel=\"noreferrer\">http://bisqwit.iki.fi/source/twinpipe.html</a><... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22676/"
] | I have two (UNIX) programs A and B that read and write from stdin/stdout.
My first problem is how to connect the stdout of A to stdin of B *and* the stdout of B to the stdin of A. I.e., something like A | B but a bidirectional pipe. I suspect I could solve this by [using exec to redirect](http://tldp.org/LDP/abs/html/... | <http://bisqwit.iki.fi/source/twinpipe.html> |
139,513 | <p>I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework 3.5 SP1, in this case I extended the partial</p>
<pre><code>partial void UpdateMyTable(MyTable instance){
// Business logic
// Validation rules, etc.
}
</code></pre>
<p>My problem is when I execute db.SubmitChanges(), it executes UpdateMyTabl... | [
{
"answer_id": 139625,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": true,
"text": "<ul>\n<li>if you provide this method, you must perform the update in the method.</li>\n</ul>\n\n<hr>\n\n<p><a href=\"http://msd... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19710/"
] | I made a class from Linq to SQL Clasees with VS 2008 SP1 Framework 3.5 SP1, in this case I extended the partial
```
partial void UpdateMyTable(MyTable instance){
// Business logic
// Validation rules, etc.
}
```
My problem is when I execute db.SubmitChanges(), it executes UpdateMyTable and makes the validation... | * if you provide this method, you must perform the update in the method.
---
<http://msdn.microsoft.com/en-us/library/bb882671.aspx>
* If you implement the Insert, Update and Delete methods in your partial class, the LINQ to SQL runtime will call them **instead** of its own default methods when SubmitChanges is call... |
139,525 | <p>I have an Xtext/Xpand (oAW 4.3, Eclipse 3.4) generator plug-in, which I run together with the editor plug-in in a second workbench. There, I'd like to run Xpand workflows programmatically on the model file I create. If I set the model file using the absolute path of the IFile I have, e.g. with:</p>
<pre><code>Strin... | [
{
"answer_id": 192038,
"author": "Fabian Steeg",
"author_id": 18154,
"author_profile": "https://Stackoverflow.com/users/18154",
"pm_score": 1,
"selected": true,
"text": "<p>I found help at the <a href=\"http://openarchitectureware.org/forum/viewtopic.php?showtopic=10197\" rel=\"nofollow ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18154/"
] | I have an Xtext/Xpand (oAW 4.3, Eclipse 3.4) generator plug-in, which I run together with the editor plug-in in a second workbench. There, I'd like to run Xpand workflows programmatically on the model file I create. If I set the model file using the absolute path of the IFile I have, e.g. with:
```
String dslFile = fi... | I found help at the [openArchitectureWare forum](http://openarchitectureware.org/forum/viewtopic.php?showtopic=10197). Basically using
```
properties.put("modelFile", file.getLocation().makeAbsolute().toOSString());
```
works, but you need to specify looking it up via URI in the workflow you are calling:
```
<compo... |
139,580 | <p>I'm working on some code for a loosely coupled cluster. To achieve optimal performance during jobs, I have the cluster remap its data each time a child enters or exits. This will eventually be made optional, but for now it performs its data balancing by default. My balancing is basically just making sure that each c... | [
{
"answer_id": 139656,
"author": "zvrba",
"author_id": 2583,
"author_profile": "https://Stackoverflow.com/users/2583",
"pm_score": 2,
"selected": false,
"text": "<p>I think that your analysis is incorrect:</p>\n\n<ul>\n<li>walking through the list to find out the average is O(n)</li>\n<l... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8945/"
] | I'm working on some code for a loosely coupled cluster. To achieve optimal performance during jobs, I have the cluster remap its data each time a child enters or exits. This will eventually be made optional, but for now it performs its data balancing by default. My balancing is basically just making sure that each chil... | @zvrba: You do not even have to sort the list. When traversing the list the second time just move all items with less the average workload to the end of the list (you can keep a pointer to the last item at your first traversal). The order does not have to be perfect, it just changes when the iterators have to be augmen... |
139,592 | <p>I've got a generic dictionary <code>Dictionary<string, T></code> that I would like to essentially make a Clone() of ..any suggestions. </p>
| [
{
"answer_id": 139626,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": false,
"text": "<p>(Note: although the cloning version is potentially useful, for a simple shallow copy the constructor I mention in the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4398/"
] | I've got a generic dictionary `Dictionary<string, T>` that I would like to essentially make a Clone() of ..any suggestions. | Okay, the .NET 2.0 answers:
If you don't need to clone the values, you can use the constructor overload to Dictionary which takes an existing IDictionary. (You can specify the comparer as the existing dictionary's comparer, too.)
If you *do* need to clone the values, you can use something like this:
```
public stati... |
139,593 | <p>I have the following code:</p>
<pre><code>info = new System.Diagnostics.ProcessStartInfo("TheProgram.exe", String.Join(" ", args));
info.CreateNoWindow = true;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
System... | [
{
"answer_id": 139604,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 7,
"selected": false,
"text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx\" rel=\"noreferrer\">doc... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] | I have the following code:
```
info = new System.Diagnostics.ProcessStartInfo("TheProgram.exe", String.Join(" ", args));
info.CreateNoWindow = true;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
System.Diagnostics.Process p = System.D... | The problem is that if you redirect `StandardOutput` and/or `StandardError` the internal buffer can become full. Whatever order you use, there can be a problem:
* If you wait for the process to exit before reading `StandardOutput` the process can block trying to write to it, so the process never ends.
* If you read fr... |
139,623 | <p>How do I cause the page to make the user jump to a new web page after X seconds. If possible I'd like to use HTML but a niggly feeling tells me it'll have to be Javascript.</p>
<p>So far I have the following but it has no time delay</p>
<pre><code><body onload="document.location='newPage.html'">
</code></pre... | [
{
"answer_id": 139660,
"author": "slashnick",
"author_id": 21030,
"author_profile": "https://Stackoverflow.com/users/21030",
"pm_score": 5,
"selected": true,
"text": "<p>A meta refresh is ugly but will work. The following will go to the new url after 5 seconds: </p>\n\n<pre><code><me... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | How do I cause the page to make the user jump to a new web page after X seconds. If possible I'd like to use HTML but a niggly feeling tells me it'll have to be Javascript.
So far I have the following but it has no time delay
```
<body onload="document.location='newPage.html'">
``` | A meta refresh is ugly but will work. The following will go to the new url after 5 seconds:
```
<meta http-equiv="refresh" content="5;url=http://example.com/"/>
```
<http://en.wikipedia.org/wiki/Meta_refresh> |
139,630 | <p>What's the difference between <code>TRUNCATE</code> and <code>DELETE</code> in SQL?</p>
<p>If your answer is platform specific, please indicate that.</p>
| [
{
"answer_id": 139633,
"author": "David Aldridge",
"author_id": 6742,
"author_profile": "https://Stackoverflow.com/users/6742",
"pm_score": 9,
"selected": true,
"text": "<p>Here's a list of differences. I've highlighted Oracle-specific features, and hopefully the community can add in oth... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6742/"
] | What's the difference between `TRUNCATE` and `DELETE` in SQL?
If your answer is platform specific, please indicate that. | Here's a list of differences. I've highlighted Oracle-specific features, and hopefully the community can add in other vendors' specific difference also. Differences that are common to most vendors can go directly below the headings, with differences highlighted below.
---
General Overview
================
If you wan... |
139,639 | <p>I am working with Reporting Services and Sharepoint, I have an application that leverages reporting services however a client would like our application integrated into sharepoint. Currently we are tightly coupled to the ReportService.asmx webservice which exposes various methods for performing operations. Reporting... | [
{
"answer_id": 139633,
"author": "David Aldridge",
"author_id": 6742,
"author_profile": "https://Stackoverflow.com/users/6742",
"pm_score": 9,
"selected": true,
"text": "<p>Here's a list of differences. I've highlighted Oracle-specific features, and hopefully the community can add in oth... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4950/"
] | I am working with Reporting Services and Sharepoint, I have an application that leverages reporting services however a client would like our application integrated into sharepoint. Currently we are tightly coupled to the ReportService.asmx webservice which exposes various methods for performing operations. Reporting Se... | Here's a list of differences. I've highlighted Oracle-specific features, and hopefully the community can add in other vendors' specific difference also. Differences that are common to most vendors can go directly below the headings, with differences highlighted below.
---
General Overview
================
If you wan... |
139,650 | <p>I have normally hand written xml like this:</p>
<pre><code><tag><?= $value ?></tag>
</code></pre>
<p>Having found tools such as simpleXML, should I be using those instead? What's the advantage of doing it using a tool like that?</p>
| [
{
"answer_id": 139671,
"author": "DGentry",
"author_id": 4761,
"author_profile": "https://Stackoverflow.com/users/4761",
"pm_score": 4,
"selected": true,
"text": "<p>Good XML tools will ensure that the resulting XML file properly validates against the DTD you are using.</p>\n\n<p>Good XM... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] | I have normally hand written xml like this:
```
<tag><?= $value ?></tag>
```
Having found tools such as simpleXML, should I be using those instead? What's the advantage of doing it using a tool like that? | Good XML tools will ensure that the resulting XML file properly validates against the DTD you are using.
Good XML tools also save a bunch of repetitive typing of tags. |
139,670 | <p>In SQL SERVER Is it possible to store data with carriage return in a table and then retrieve it back again with carriage return.</p>
<p>Eg:</p>
<pre><code>insert into table values ('test1
test2
test3
test4');
</code></pre>
<p>When I retrieve it, I get the message in a line </p>
<p>test1 test2 test3 test4<... | [
{
"answer_id": 139687,
"author": "Dejan",
"author_id": 11471,
"author_profile": "https://Stackoverflow.com/users/11471",
"pm_score": 2,
"selected": false,
"text": "<p>Can you please clarify how you retrieve the data back from the database? What tool do you use? The data probably contains... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21968/"
] | In SQL SERVER Is it possible to store data with carriage return in a table and then retrieve it back again with carriage return.
Eg:
```
insert into table values ('test1
test2
test3
test4');
```
When I retrieve it, I get the message in a line
test1 test2 test3 test4
The carriage return is treated as a single... | You can store Carriage return in the database. The problem here is that you are using SQL Server Management Studio to display the results of your query. You probably have it configured to show the results in a grid. Change the configuration of SSMS to show results to text and you will see the carriage returns.
Right c... |
139,686 | <p>The maintenance problems that uninitialised locals cause (particularly pointers) will be obvious to anyone who has done a bit of c/c++ maintenance or enhancement, but I still see them and occasionally hear performance implications given as their justification.</p>
<p>It's easy to demonstrate in c that redundant ini... | [
{
"answer_id": 139731,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 2,
"selected": false,
"text": "<p>Sometimes you need a variable as a placeholder (e.g. using the <code>ftime</code> functions), so it doesn't make sense to i... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22640/"
] | The maintenance problems that uninitialised locals cause (particularly pointers) will be obvious to anyone who has done a bit of c/c++ maintenance or enhancement, but I still see them and occasionally hear performance implications given as their justification.
It's easy to demonstrate in c that redundant initialisatio... | Short answer: declare the variable as close to first use as possible and initialize to "zero" if you still need to.
Long answer: If you declare a variable at the start of a function, and don't use it until later, you should reconsider your placement of the variable to as local a scope as possible. You can then usually... |
139,739 | <p>I've been doing a massive code review and one pattern I notice all over the place is this:</p>
<pre><code>public bool MethodName()
{
bool returnValue = false;
if (expression)
{
// do something
returnValue = MethodCall();
}
else
{
// do something else
returnVal... | [
{
"answer_id": 139754,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 2,
"selected": false,
"text": "<p>I would have used ternary, to reduce control structures...</p>\n\n<pre>\n<code>\nreturn expression ? MethodCall() : Expre... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] | I've been doing a massive code review and one pattern I notice all over the place is this:
```
public bool MethodName()
{
bool returnValue = false;
if (expression)
{
// do something
returnValue = MethodCall();
}
else
{
// do something else
returnValue = Expressio... | I would have used ternary, to reduce control structures...
```
return expression ? MethodCall() : Expression;
``` |
139,759 | <p>Is there any way to list all the files that have changed between two tags in CVS?</p>
<p>Every time we do a release we apply a tag to all the files in that release. I want to find all the files that changed between releases.</p>
<p>It would also work if I could find all files that had changed between two dates.</p... | [
{
"answer_id": 139871,
"author": "Decio Lira",
"author_id": 12423,
"author_profile": "https://Stackoverflow.com/users/12423",
"pm_score": 6,
"selected": true,
"text": "<p>I suppose this command would help:</p>\n\n<pre><code>cvs diff -N -c -r RELEASE_1_0 -r RELEASE_1_1 > diffs\n</code>... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3464/"
] | Is there any way to list all the files that have changed between two tags in CVS?
Every time we do a release we apply a tag to all the files in that release. I want to find all the files that changed between releases.
It would also work if I could find all files that had changed between two dates. | I suppose this command would help:
```
cvs diff -N -c -r RELEASE_1_0 -r RELEASE_1_1 > diffs
```
where `RELEASE_1_0` and `RELEASE_1_1` are the names of your tags.
You can find a little more information on cvs diff command [here](http://www.network-theory.co.uk/docs/cvsmanual/diffexamples.html)
plus it should be fai... |
139,794 | <p>Let's say we have <code>index.php</code> and it is stored in <code>/home/user/public/www</code> and <code>index.php</code> calls the class <code>Foo->bar()</code> from the file <code>inc/app/Foo.class.php</code>. </p>
<p>I'd like the bar function in the <code>Foo</code> class to get a hold of the path <code>/hom... | [
{
"answer_id": 139825,
"author": "RobbieGee",
"author_id": 6752,
"author_profile": "https://Stackoverflow.com/users/6752",
"pm_score": 1,
"selected": false,
"text": "<p>Found it. getcwd().</p>\n"
},
{
"answer_id": 139830,
"author": "Devon",
"author_id": 13850,
"author... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6752/"
] | Let's say we have `index.php` and it is stored in `/home/user/public/www` and `index.php` calls the class `Foo->bar()` from the file `inc/app/Foo.class.php`.
I'd like the bar function in the `Foo` class to get a hold of the path `/home/user/public/www` in this instance — I don't want to use a global variable, pass a ... | Wouldn't this get you the directory of the running script more easily?
```
$dir=dirname($_SERVER["SCRIPT_FILENAME"])
``` |
139,809 | <p>I have a Console application hosting a WCF service. I would like to be able to fire an event from a method in the WCF service and handle the event in the hosting process of the WCF service. Is this possible? How would I do this? Could I derive a custom class from ServiceHost?</p>
| [
{
"answer_id": 139886,
"author": "Franci Penov",
"author_id": 17028,
"author_profile": "https://Stackoverflow.com/users/17028",
"pm_score": 5,
"selected": true,
"text": "<p>You don't need to inherit from <code>ServiceHost</code>. There are other approaches to your problem.</p>\n\n<p>You ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8033/"
] | I have a Console application hosting a WCF service. I would like to be able to fire an event from a method in the WCF service and handle the event in the hosting process of the WCF service. Is this possible? How would I do this? Could I derive a custom class from ServiceHost? | You don't need to inherit from `ServiceHost`. There are other approaches to your problem.
You can pass an instance of the service class, instead of a type to `ServiceHost`. Thus, you can create the instance before you start the `ServiceHost`, and add your own event handlers to any events it exposes.
Here's some sampl... |
139,819 | <p>The following test fails:</p>
<pre><code>#!/usr/bin/env python
def f(*args):
"""
>>> t = 1, -1
>>> f(*map(lambda i: lambda: i, t))
[1, -1]
>>> f(*(lambda: i for i in t)) # -> [-1, -1]
[1, -1]
>>> f(*[lambda: i for i in t]) # -> [-1, -1]
[1, -... | [
{
"answer_id": 139880,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 3,
"selected": false,
"text": "<p>The lambda captures variables, not values, hence the code</p>\n\n<pre><code>lambda : i\n</code></pre>\n\n<p>will always ret... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279/"
] | The following test fails:
```
#!/usr/bin/env python
def f(*args):
"""
>>> t = 1, -1
>>> f(*map(lambda i: lambda: i, t))
[1, -1]
>>> f(*(lambda: i for i in t)) # -> [-1, -1]
[1, -1]
>>> f(*[lambda: i for i in t]) # -> [-1, -1]
[1, -1]
"""
alist = [a() for a in args]
print(ali... | They are different, because the value of `i` in both the generator expression and the list comp are evaluated lazily, i.e. when the anonymous functions are invoked in `f`.
By that time, `i` is bound to the last value if `t`, which is -1.
So basically, this is what the list comprehension does (likewise for the genex... |
139,821 | <p>What is the bare minimum I need to put in web.config to get WCF working with REST? I have annotated my methods with [WebGet], but they are not getting the message.</p>
| [
{
"answer_id": 139965,
"author": "willem",
"author_id": 22702,
"author_profile": "https://Stackoverflow.com/users/22702",
"pm_score": 2,
"selected": false,
"text": "<p>Ensure that you use a webHttpBinding on your endpoint (and not an httpBinding or wsHttpBinding). Here's my endpoint conf... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21784/"
] | What is the bare minimum I need to put in web.config to get WCF working with REST? I have annotated my methods with [WebGet], but they are not getting the message. | I discovered that you can add the following to the ServiceHost directive in the \*.svc file, and it will automatically setup WebHttpBinding and WebHttpBehavior for you:
```
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
```
Note that the namespace is a little different from what is mentioned elsewher... |
139,833 | <p>I am using StringReplace to replace &gt and &lt by the char itself in a generated XML like this:</p>
<pre><code>StringReplace(xml.Text,'&gt;','>',[rfReplaceAll]) ;
StringReplace(xml.Text,'&lt;','<',[rfReplaceAll]) ;
</code></pre>
<p>The thing is it takes way tooo long to replace every occuren... | [
{
"answer_id": 139876,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is that you are iterating the entire string size twice (one for replacing &gt; by > and another on... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19224/"
] | I am using StringReplace to replace > and < by the char itself in a generated XML like this:
```
StringReplace(xml.Text,'>','>',[rfReplaceAll]) ;
StringReplace(xml.Text,'<','<',[rfReplaceAll]) ;
```
The thing is it takes way tooo long to replace every occurence of >.
Do you purpose any better idea to ma... | Try [FastStrings.pas](http://www.koders.com/delphi/fidFB386C5C240FD5E72013C882ADD7600FDF60E6C7.aspx?s=socket) from Peter Morris. |
139,835 | <p>I have a C# WinForms borderless window, for which I override WndProc and handle the WM_NCHITTEST message. For an area of that form, my hit test function returns HTSYSMENU. Double-clicking that area successfully closes the form, but right-clicking it does not show the window's system menu, nor does it show up when ri... | [
{
"answer_id": 139970,
"author": "Martin Marconcini",
"author_id": 2684,
"author_profile": "https://Stackoverflow.com/users/2684",
"pm_score": 0,
"selected": false,
"text": "<p>I have the same properties in my application and Right click doesn't work either, so this is not <em>your probl... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4898/"
] | I have a C# WinForms borderless window, for which I override WndProc and handle the WM\_NCHITTEST message. For an area of that form, my hit test function returns HTSYSMENU. Double-clicking that area successfully closes the form, but right-clicking it does not show the window's system menu, nor does it show up when righ... | A borderless window, if I am not mistaken, is flagged such that it offers no system menu, and that it does not appear in the taskbar.
The fact that any given window does not have a border and does not appear in the taskbar is the result of the style flags set on the window. These particular Style flags can be set usi... |
139,859 | <p>On <strong>Linux/NPTL</strong>, threads are created as some kind of process.</p>
<p>I can see some of my process have a weird cmdline:</p>
<pre><code>cat /proc/5590/cmdline
hald-addon-storage: polling /dev/scd0 (every 2 sec)
</code></pre>
<p>Do you have an idea how I could do that for each thread of my process? Tha... | [
{
"answer_id": 139935,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "<p><code>argv</code> points to writable strings. Just write stuff to them:</p>\n\n<pre><code>#include <string.h>\n#inc... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1277510/"
] | On **Linux/NPTL**, threads are created as some kind of process.
I can see some of my process have a weird cmdline:
```
cat /proc/5590/cmdline
hald-addon-storage: polling /dev/scd0 (every 2 sec)
```
Do you have an idea how I could do that for each thread of my process? That would be very helpful for debugging.
*/m... | If you want to do this in a portable way, something that will work across multiple Unix variations, there are very few options available.
What you have to do is that your caller process must call exec with the `argv [0]` argument pointing to the name that you would like to see in the process output, and the filename p... |
139,867 | <p>Does anyone know of a freely available java 1.5 package that provides a list of ISO 3166-1 country codes as a enum or EnumMap? Specifically I need the "ISO 3166-1-alpha-2 code elements", i.e. the 2 character country code like "us", "uk", "de", etc. Creating one is simple enough (although tedious), but if there's a... | [
{
"answer_id": 140235,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 6,
"selected": false,
"text": "<p>This code gets 242 countries in Sun Java 6:</p>\n\n<pre><code>String[] countryCodes = Locale.getISOCountries();\n</code></... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12531/"
] | Does anyone know of a freely available java 1.5 package that provides a list of ISO 3166-1 country codes as a enum or EnumMap? Specifically I need the "ISO 3166-1-alpha-2 code elements", i.e. the 2 character country code like "us", "uk", "de", etc. Creating one is simple enough (although tedious), but if there's a stan... | Now an implementation of country code ([ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) [alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)/[alpha-3](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)/[numeric](http://en.wikipedia.org/wiki/ISO_3166-1_numeric)) list as Java enum is available at GitHub under Ap... |
139,889 | <p>I'm setting up a number sites right now and many of them have multiple domains. The question is: do I alias the domain (with <a href="http://httpd.apache.org/docs/2.0/mod/core.html#serveralias" rel="noreferrer">ServerAlias</a>) or do I <a href="http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect" rel="nore... | [
{
"answer_id": 139911,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 6,
"selected": true,
"text": "<p>Redirecting is better, then there is always one, canonical domain for your content. <strike>I hear Google penalises mul... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15948/"
] | I'm setting up a number sites right now and many of them have multiple domains. The question is: do I alias the domain (with [ServerAlias](http://httpd.apache.org/docs/2.0/mod/core.html#serveralias)) or do I [Redirect](http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect) the request?
Obviously ServerAlias is... | Redirecting is better, then there is always one, canonical domain for your content. I hear Google penalises multiple domains hosting the same content, but I can't find a source for that at the moment (edit, [here's one article](http://www.searchenginejournal.com/duplicate-content-penalty-how-to-lose-google-ranking-fast... |
139,909 | <p>I have a problem with setting the TTL on my Datagram packets. I am calling the setTTL(...) method on the packet before sending the packet to the multicastSocket but if I capture the packet with ethereal the TTL field is always set to 0</p>
| [
{
"answer_id": 139917,
"author": "pfranza",
"author_id": 22221,
"author_profile": "https://Stackoverflow.com/users/22221",
"pm_score": 4,
"selected": true,
"text": "<p>Basically you have to set an special system property telling the JVM to use an IPv4 stack:</p>\n\n<pre><code>-Djava.net.... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem with setting the TTL on my Datagram packets. I am calling the setTTL(...) method on the packet before sending the packet to the multicastSocket but if I capture the packet with ethereal the TTL field is always set to 0 | Basically you have to set an special system property telling the JVM to use an IPv4 stack:
```
-Djava.net.preferIPv4Stack=true
``` |
139,948 | <p>I have a page using .NETs server-side input validation controls. This page also has a javascript confirm box that fires when the form is submitted. Currently when the Submit button is selected, the javascript confirm box appears, and once confirmed the ASP.NET server-side validation controls are fired. I would li... | [
{
"answer_id": 139977,
"author": "Dean",
"author_id": 11802,
"author_profile": "https://Stackoverflow.com/users/11802",
"pm_score": 1,
"selected": false,
"text": "<p>can you not use the EnableClientScript property for the validator control allowing you to carry out the validation on the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a page using .NETs server-side input validation controls. This page also has a javascript confirm box that fires when the form is submitted. Currently when the Submit button is selected, the javascript confirm box appears, and once confirmed the ASP.NET server-side validation controls are fired. I would like to ... | This seems to be a very common problem.
The workaround:
Validate the page first, then call `confirm`, as shown [here](http://www.codedigest.com/CodeDigest/73-Fire-Validator-Controls-Before-JavaScript-Confirm-Box-Fires-in-ASP-Net-Page.aspx) and [here](http://www.stevekinsey.com/2007/06/04/onclientclick-and-form-valida... |
139,954 | <p>I've started with ASP.NET MVC recently, reading blogs, tutorials, trying some routes, etc. Now, i've stumbled on a issue where i need some help.</p>
<p>Basically, i have an URL like /products.aspx?categoryid=foo&productid=bar</p>
<p>Most tutorials/examples propose to map this to something like: /products/categ... | [
{
"answer_id": 139986,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 4,
"selected": true,
"text": "<p><em>(your English is just fine, no need to apologize!)</em></p>\n\n<p>You can define a route like this:</p>\n\n<pre>... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19610/"
] | I've started with ASP.NET MVC recently, reading blogs, tutorials, trying some routes, etc. Now, i've stumbled on a issue where i need some help.
Basically, i have an URL like /products.aspx?categoryid=foo&productid=bar
Most tutorials/examples propose to map this to something like: /products/category/foo/bar where "pr... | *(your English is just fine, no need to apologize!)*
You can define a route like this:
```
routes.MapRoute("productsByCategory", "products/{category}/{productid}",
new { controller="products", action="findByCategory" })
```
This will match
`products/foo/bar` and call an action looking like this:
```
public clas... |
139,979 | <p>I have a C# interface with certain method parameters declared as <code>object</code> types. However, the actual type passed around can differ depending on the class implementing the interface:</p>
<pre><code>public interface IMyInterface
{
void MyMethod(object arg);
}
public class MyClass1 : IMyInterface
{
... | [
{
"answer_id": 139994,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 4,
"selected": false,
"text": "<blockquote>\n <p>The problem with MyClass2 is that the\n conversion of byte[] to and from\n object is boxing and unboxi... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2576/"
] | I have a C# interface with certain method parameters declared as `object` types. However, the actual type passed around can differ depending on the class implementing the interface:
```
public interface IMyInterface
{
void MyMethod(object arg);
}
public class MyClass1 : IMyInterface
{
public void MyMethod(obj... | I'm not sure how it is implemented in mono, but generic interfaces will help because the compiler creates a new function of the specific type for each different type used (internally, there are a few cases where it can utilize the same generated function). If a function of the specific type is generated, there is no ne... |
139,991 | <p>I have two functions, <code>f</code> and <code>g</code>, which call each other recursively. Unfortunately, when <code>f</code> calls <code>g</code>, it has not yet been declared, so I get an "unbound variable" error. How can I prototype (or whatever the equivalent vocabulary is) this function in SML/NJ?</p>
| [
{
"answer_id": 140386,
"author": "nlucaroni",
"author_id": 157,
"author_profile": "https://Stackoverflow.com/users/157",
"pm_score": 2,
"selected": false,
"text": "<p>Mutual Recursion. Use <strong><code>and</code></strong> instead of <strong><code>fun</code></strong> between the two func... | 2008/09/26 | [
"https://Stackoverflow.com/questions/139991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10307/"
] | I have two functions, `f` and `g`, which call each other recursively. Unfortunately, when `f` calls `g`, it has not yet been declared, so I get an "unbound variable" error. How can I prototype (or whatever the equivalent vocabulary is) this function in SML/NJ? | Use `and`:
```
fun f x = ...
and g x = ...
```
More info [here](http://www.dcs.napier.ac.uk/~cs66/course-notes/sml/lesson8.htm). |
140,000 | <p>I don't want to change how the Status field works I just want to change the labels to
the states that the old system uses. (the old systems consists of spreadsheets and paper :P
<br>
We are using 3.0</p>
<pre>
* UNCONFIRMED --> PRELIMARY
* NEW --> DESIGN REVIEW
* ASSIGNED --> STR1
* RESOLVED --> ... | [
{
"answer_id": 140168,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 2,
"selected": false,
"text": "<p>If you log into the bugzilla system as an administrator you'll see on the bottom a link that says \"Field Values\", cl... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6539/"
] | I don't want to change how the Status field works I just want to change the labels to
the states that the old system uses. (the old systems consists of spreadsheets and paper :P
We are using 3.0
```
* UNCONFIRMED --> PRELIMARY
* NEW --> DESIGN REVIEW
* ASSIGNED --> STR1
* RESOLVED --> STR2
* REOPEN... | I think this can be done by modifying the templates look here:
<http://www.bugzilla.org/docs/2.22/html/cust-templates.html>
specifically:
**global/variables.none.tmpl** |
140,002 | <p>I'm trying to return a dictionary from a function. I believe the function is working correctly, but I'm not sure how to utilize the returned dictionary.</p>
<p>Here is the relevant part of my function:</p>
<pre><code>Function GetSomeStuff()
'
' Get a recordset...
'
Dim stuff
Set stuff = CreateObject("Sc... | [
{
"answer_id": 140064,
"author": "Rob",
"author_id": 7872,
"author_profile": "https://Stackoverflow.com/users/7872",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried:</p>\n\n<pre><code>Dim returnedStuff\nSet returnedStuff = GetSomeStuff()\n</code></pre>\n\n<p>Then \"For Each\... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2441/"
] | I'm trying to return a dictionary from a function. I believe the function is working correctly, but I'm not sure how to utilize the returned dictionary.
Here is the relevant part of my function:
```
Function GetSomeStuff()
'
' Get a recordset...
'
Dim stuff
Set stuff = CreateObject("Scripting.Dictionary")
... | I wasn't too sure of what was your problem, so I experimented a bit.
It appears that you just missed that to assign a reference to an object, you have to use `set`, even for a return value:
```
Function GetSomeStuff
Dim stuff
Set stuff = CreateObject("Scripting.Dictionary")
stuff.Add "A", "Anaconda"
stuff... |
140,033 | <p>Assume I have a class foo, and wish to use a std::map to store some boost::shared_ptrs, e.g.:</p>
<pre><code>class foo;
typedef boost::shared_ptr<foo> foo_sp;
typeded std::map<int, foo_sp> foo_sp_map;
foo_sp_map m;
</code></pre>
<p>If I add a new foo_sp to the map but the key used already exists, wil... | [
{
"answer_id": 140048,
"author": "Seb Rose",
"author_id": 12405,
"author_profile": "https://Stackoverflow.com/users/12405",
"pm_score": 4,
"selected": true,
"text": "<p>First off, your question title says boost::auto_ptr, but you actually mean boost::shared_ptr</p>\n\n<p>And yes, the ori... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Assume I have a class foo, and wish to use a std::map to store some boost::shared\_ptrs, e.g.:
```
class foo;
typedef boost::shared_ptr<foo> foo_sp;
typeded std::map<int, foo_sp> foo_sp_map;
foo_sp_map m;
```
If I add a new foo\_sp to the map but the key used already exists, will the existing entry be deleted? For... | First off, your question title says boost::auto\_ptr, but you actually mean boost::shared\_ptr
And yes, the original pointer will be freed (if there are no further shared references to it). |
140,043 | <p>How do I loop into all the resources in the resourcemanager?</p>
<p>Ie:
foreach (string resource in ResourceManager)
//Do something with the recource.</p>
<p>Thanks</p>
| [
{
"answer_id": 140060,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 6,
"selected": true,
"text": "<p>Use ResourceManager.<a href=\"http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.getresourceset.aspx\"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17766/"
] | How do I loop into all the resources in the resourcemanager?
Ie:
foreach (string resource in ResourceManager)
//Do something with the recource.
Thanks | Use ResourceManager.[GetResourceSet](http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.getresourceset.aspx)() for a list of all resources for a given culture. The returned ResourceSet implements IEnumerable (you can use foreach).
---
To answer Nico's question: you can count the elements of an `... |
140,044 | <p>I need to create a user control in either vb.net or c# to search a RightNow CRM database. I have the documentation on their XML API, but I'm not sure how to post to their parser and then catch the return data and display it on the page.</p>
<p>Any sample code would be greatly appreciated!</p>
<p>Link to API: <a hr... | [
{
"answer_id": 148494,
"author": "csgero",
"author_id": 21764,
"author_profile": "https://Stackoverflow.com/users/21764",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know RightNow CRM, but according to the documentation you can send the XML requests using HTTP post. The simples... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20483/"
] | I need to create a user control in either vb.net or c# to search a RightNow CRM database. I have the documentation on their XML API, but I'm not sure how to post to their parser and then catch the return data and display it on the page.
Any sample code would be greatly appreciated!
Link to API: <http://community.righ... | I don't know RightNow CRM, but according to the documentation you can send the XML requests using HTTP post. The simplest way to do this in .NET is using the WebClient class. Alternatively you might want to take a look at the HttpWebRequest/HttpWebResponse classes. Here is some sample code using WebClient:
```
using S... |
140,054 | <p>I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently.</p>
<p>Is there are way to do something like this:</p>
<pre><code>installutil.exe myservice.exe /customarg1=username /customarg2=password
</code></p... | [
{
"answer_id": 140086,
"author": "blowdart",
"author_id": 2525,
"author_profile": "https://Stackoverflow.com/users/2525",
"pm_score": 0,
"selected": false,
"text": "<p>No, installutil doesn't support that.</p>\n\n<p>Of course if you wrote an installer; with a <a href=\"http://arcanecode.... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3106/"
] | I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently.
Is there are way to do something like this:
```
installutil.exe myservice.exe /customarg1=username /customarg2=password
``` | Bravo to my co-worker (Bruce Eddy). He found a way we can make this command-line call:
```
installutil.exe /user=uname /password=pw myservice.exe
```
It is done by overriding OnBeforeInstall in the installer class:
```
namespace Test
{
[RunInstaller(true)]
public class TestInstaller : Installer
{
... |
140,104 | <p>If something goes wrong in a WCF REST call, such as the requested resource is not found, how can I play with the HTTP response code (setting it to something like HTTP 404, for example) in my OperationContract method?</p>
| [
{
"answer_id": 140154,
"author": "Eric Schoonover",
"author_id": 3957,
"author_profile": "https://Stackoverflow.com/users/3957",
"pm_score": 8,
"selected": true,
"text": "<p>There is a <a href=\"http://msdn.microsoft.com/en-us/library/system.servicemodel.web.weboperationcontext.aspx\" re... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21784/"
] | If something goes wrong in a WCF REST call, such as the requested resource is not found, how can I play with the HTTP response code (setting it to something like HTTP 404, for example) in my OperationContract method? | There is a [`WebOperationContext`](http://msdn.microsoft.com/en-us/library/system.servicemodel.web.weboperationcontext.aspx) that you can access and it has a [`OutgoingResponse`](http://msdn.microsoft.com/en-us/library/system.servicemodel.web.weboperationcontext.outgoingresponse.aspx) property of type [`OutgoingWebResp... |
140,131 | <p>I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array.</p>
<p>I couldn't have phrased it better than the person that posted <a href="http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21062554.html" rel="noreferrer">the same question here</... | [
{
"answer_id": 140147,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 7,
"selected": false,
"text": "<p>The Hex class in commons-codec should do that for you.</p>\n\n<p><a href=\"http://commons.apache.org/codec/\" rel=\"no... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11798/"
] | I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array.
I couldn't have phrased it better than the person that posted [the same question here](http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21062554.html).
But to keep it original, I'll phr... | Update (2021) - **Java 17** now includes [`java.util.HexFormat`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/HexFormat.html) (only took 25 years):
`HexFormat.of().parseHex(s)`
---
For older versions of Java:
Here's a solution that I think is better than any posted so far:
```
/* s must be... |
140,133 | <p>I want to raise an event when a popup window is closed, or preferably, just before closing. I'm storing the popup window object as an object, but I don't know of any way to bind to the close event, or an event just before the window is closed.</p>
<pre><code>var popupWindow = window.open("/popup.aspx", "popupWindow... | [
{
"answer_id": 140183,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 0,
"selected": false,
"text": "<p>Use <a href=\"http://developer.mozilla.org/en/DOM/window.onunload\" rel=\"nofollow noreferrer\">window.onUnload</a></p>\n"
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I want to raise an event when a popup window is closed, or preferably, just before closing. I'm storing the popup window object as an object, but I don't know of any way to bind to the close event, or an event just before the window is closed.
```
var popupWindow = window.open("/popup.aspx", "popupWindow", "height=550... | I created a watcher that checks if the window has been closed:
```
var w = window.open("http://www.google.com", "_blank", 'top=442,width=480,height=460,resizable=yes', true);
var watchClose = setInterval(function() {
if (w.closed) {
clearTimeout(watchClose);
//Do something here...
}
}, 200);
``` |
140,137 | <p>I'm working on a client site who is using Umbraco as a CMS. I need to create a custom 404 error page. I've tried doing it in the IIS config but umbraco overrides that. </p>
<p>Does anyone know how to create a custom 404 error page in Umbraco?
Is there a way to create a custom error page for runtime errors?</p>
| [
{
"answer_id": 140169,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 4,
"selected": false,
"text": "<p>In <code>/config/umbracoSettings.config</code> modify <code><error404>1</error404></code> \"<em>1</em>\" with... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20483/"
] | I'm working on a client site who is using Umbraco as a CMS. I need to create a custom 404 error page. I've tried doing it in the IIS config but umbraco overrides that.
Does anyone know how to create a custom 404 error page in Umbraco?
Is there a way to create a custom error page for runtime errors? | In `/config/umbracoSettings.config` modify `<error404>1</error404>` "*1*" with the id of the page you want to show.
```
<errors>
<error404>1</error404>
</errors>
```
Other ways to do it can be found at [Not found handlers](http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler "Umbraco not fou... |
140,149 | <p>I have a custom performance counter category. Visual Studio Server Explorer refuses to delete it, claiming it is 'not registered or a system category'. Short of doing it programmatically, how can I delete the category? Is there a registry key I can delete?</p>
| [
{
"answer_id": 140185,
"author": "Jaykul",
"author_id": 8718,
"author_profile": "https://Stackoverflow.com/users/8718",
"pm_score": 6,
"selected": true,
"text": "<p>As far as I know, there <strong>is no way</strong> to safely delete them except programatically (they're intended for apps ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16881/"
] | I have a custom performance counter category. Visual Studio Server Explorer refuses to delete it, claiming it is 'not registered or a system category'. Short of doing it programmatically, how can I delete the category? Is there a registry key I can delete? | As far as I know, there **is no way** to safely delete them except programatically (they're intended for apps to create and remove during install) but it is trivial to do from a [PowerShell](http://Microsoft.com/PowerShell) command-line console. Just run this command:
```
[Diagnostics.PerformanceCounterCategory]::Dele... |
140,162 | <p>In a servlet I do the following:</p>
<pre><code> Context context = new InitialContext();
value = (String) context.lookup("java:comp/env/propertyName");
</code></pre>
<p>On an Apache Geronimo instance (WAS CE 2.1) how do i associate a value with the key <em>propertyName</em>?</p>
<p>In Websphere AS 6 i can conf... | [
{
"answer_id": 143749,
"author": "Mike Spross",
"author_id": 17862,
"author_profile": "https://Stackoverflow.com/users/17862",
"pm_score": 1,
"selected": false,
"text": "<p>One possibility is to add the properties to your web.xml file (in the WEB-INF directory), using one or more <code>&... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2985/"
] | In a servlet I do the following:
```
Context context = new InitialContext();
value = (String) context.lookup("java:comp/env/propertyName");
```
On an Apache Geronimo instance (WAS CE 2.1) how do i associate a value with the key *propertyName*?
In Websphere AS 6 i can configure these properties for JNDI lookup u... | One possibility is to add the properties to your web.xml file (in the WEB-INF directory), using one or more `<env-entry>` tags. For example, something like the following:
```
<env-entry>
<description>My string property</descriptor>
<env-entry-name>propertyName</env-entry-name>
<env-entry-type>java.lang.String... |
140,182 | <p>When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value... </p>
<p>Right now I'm doing this...</p>
<pre><code>def getExpandedText(pattern, text, replaceValue):
"""
One liner... really ugly b... | [
{
"answer_id": 140208,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 1,
"selected": false,
"text": "<p>Of course. See the 'sub' and 'subn' methods of compiled regular expressions, or the 're.sub' and 're.subn' funct... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/293/"
] | When using regular expressions we generally, if not always use them to extract some kind of information. What I need is to replace the match value with some other value...
Right now I'm doing this...
```
def getExpandedText(pattern, text, replaceValue):
"""
One liner... really ugly but it's only used in ... | ```
sub (replacement, string[, count = 0])
```
[sub](https://docs.python.org/howto/regex.html#search-and-replace) returns the string obtained by replacing the leftmost non-overlapping occurrences of the RE in string by the replacement replacement. If the pattern isn't found, string is returned unchanged.
```
p =... |
140,204 | <p>Given a typical class:</p>
<pre>
struct Whatever
{
void Doit();
};
Whatever w;
</pre>
<p>what is the best way to get the member function to be called by a C void* based callback such as pthread_create() or a signal handler ?</p>
<pre>
pthread_t pid;
pthread_create(&pid, 0, ... &w.Doit() ... );
</pre>
| [
{
"answer_id": 140230,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 1,
"selected": false,
"text": "<p>The member function MUST be static. Non-static have an implied \"this\" argument. Pass the pointer to your Whatev... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22725/"
] | Given a typical class:
```
struct Whatever
{
void Doit();
};
Whatever w;
```
what is the best way to get the member function to be called by a C void\* based callback such as pthread\_create() or a signal handler ?
```
pthread_t pid;
pthread_create(&pid, 0, ... &w.Doit() ... );
``` | Most C callbacks allow to specify an argument e.g.
```
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void*), void *arg);
```
So you could have
```
void myclass_doit(void* x)
{
MyClass* c = reinterpret_cast<MyClass*>(x);
c->doit();
}
pthread_create(... |
140,205 | <p>I'm working on a query that needs to have some data rows combined based on date ranges. These rows are duplicated in all the data values, except the date ranges are split. For example the table data may look like</p>
<pre><code>StudentID StartDate EndDate Field1 Field2
1 9/3/2007 10/20/2007 ... | [
{
"answer_id": 140222,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 0,
"selected": false,
"text": "<p>In my experience, I have to combine the ranges in post-processing (not in SQL but in my script). I'm not sure th... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18891/"
] | I'm working on a query that needs to have some data rows combined based on date ranges. These rows are duplicated in all the data values, except the date ranges are split. For example the table data may look like
```
StudentID StartDate EndDate Field1 Field2
1 9/3/2007 10/20/2007 3 True
1 ... | The following code should work. I've made a few assumptions as follows: there are no overlaps of date ranges, there are no NULL values in any of the fields, and the start date for a given row is always less than the end date. If your data doesn't fit these criteria, you'll need to adjust this method, but it should poin... |
140,217 | <p>As a developer, how do you use gdb to track down bugs within your code? What techniques tricks do you use to make your life easier?</p>
| [
{
"answer_id": 140316,
"author": "Andrew Johnson",
"author_id": 5109,
"author_profile": "https://Stackoverflow.com/users/5109",
"pm_score": 2,
"selected": false,
"text": "<p>In general you find something that isn't how it should be, and work backwards until you understand why.</p>\n\n<p>... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16044/"
] | As a developer, how do you use gdb to track down bugs within your code? What techniques tricks do you use to make your life easier? | In general you find something that isn't how it should be, and work backwards until you understand why.
The most obvious is the most useful: Setting a breakpoint on a function or line number and walking through the code line by line.
Another handy tip is to have show functions for all your structures/objects even if ... |
140,303 | <p>What is the cause of this exception in ASP.NET? Obviously it is a viewstate exception, but I can't reproduce the error on the page that is throwing the exception (a simple two TextBox form with a button and navigation links).</p>
<p>FWIW, I'm not running a web farm.</p>
<h2>Exception</h2>
<blockquote>
<p>Error... | [
{
"answer_id": 140517,
"author": "Chris Van Opstal",
"author_id": 7264,
"author_profile": "https://Stackoverflow.com/users/7264",
"pm_score": 5,
"selected": true,
"text": "<p>The most likely cause of this error is when a postback is stopped before all the viewstate loads (the user hits t... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17847/"
] | What is the cause of this exception in ASP.NET? Obviously it is a viewstate exception, but I can't reproduce the error on the page that is throwing the exception (a simple two TextBox form with a button and navigation links).
FWIW, I'm not running a web farm.
Exception
---------
>
> Error Message: Unable to validat... | The most likely cause of this error is when a postback is stopped before all the viewstate loads (the user hits the stop or back buttons), the viewstate will fail to validate and throw the error.
Other potential causes:
* An application pool recycling between the time the viewstate was generated and the time that th... |
140,329 | <p>I am currently working on an web application that uses ASP.NET 2.0 framework. I need to redirect to a certain page, say SessionExpired.aspx, when the user session expires. There are lot of pages in the project, so adding code to every page of the site is not really a good solution. I have MasterPages though, which I... | [
{
"answer_id": 140398,
"author": "Pseudo Masochist",
"author_id": 8529,
"author_profile": "https://Stackoverflow.com/users/8529",
"pm_score": 3,
"selected": false,
"text": "<p>I usually add an HtmlMeta control to the Page.Header.Controls collection on the master page when the user has \"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14710/"
] | I am currently working on an web application that uses ASP.NET 2.0 framework. I need to redirect to a certain page, say SessionExpired.aspx, when the user session expires. There are lot of pages in the project, so adding code to every page of the site is not really a good solution. I have MasterPages though, which I th... | You can handle this in global.asax in the Session\_Start event. You can check for a session cookie in the request there. If the session cookie exists, the session has expired:
```
public void Session_OnStart()
{
if (HttpContext.Current.Request.Cookies.Contains("ASP.NET_SessionId") != null)
{
... |
140,331 | <p>I have a following SQL Server 2005 database schema:</p>
<pre><code>CREATE TABLE Messages (
MessageID int,
Subject varchar(500),
Text varchar(max) NULL,
UserID NULL
)
</code></pre>
<p>The column "UserID" - which can be null - is a foreign key and links to the table</p>
<pre><code>CREATE TABLE Users (
... | [
{
"answer_id": 140385,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": -1,
"selected": false,
"text": "<p>I suspect your relationship is not 1 to 1.</p>\n"
},
{
"answer_id": 140424,
"author": "Orion Adrian",
"... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a following SQL Server 2005 database schema:
```
CREATE TABLE Messages (
MessageID int,
Subject varchar(500),
Text varchar(max) NULL,
UserID NULL
)
```
The column "UserID" - which can be null - is a foreign key and links to the table
```
CREATE TABLE Users (
UserID int,
...
)
```
Now I ha... | You forgot to include the declaration of your "Message" class but I suspect that the UserID property in that class is not declared as a nullable type. If that is the case, change it from "int" to "int?" (nullable int). |
140,347 | <p>I know there is a function somewhere that will accept a client rect and it will convert it into a window rect for you. I just can't find / remember it!</p>
<p>Does anyone know what it is?</p>
<p>It will do something similar to:</p>
<pre><code>const CRect client(0, 0, 200, 200);
const CRect window = ClientRectToWi... | [
{
"answer_id": 140373,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 4,
"selected": true,
"text": "<p>You're probably thinking of <a href=\"http://msdn.microsoft.com/en-us/library/ms632667(VS.85).aspx\" rel=\"noreferrer\"><code>... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] | I know there is a function somewhere that will accept a client rect and it will convert it into a window rect for you. I just can't find / remember it!
Does anyone know what it is?
It will do something similar to:
```
const CRect client(0, 0, 200, 200);
const CRect window = ClientRectToWindowRect(client);
SetWindowP... | You're probably thinking of [`AdjustWindowRectEx()`](http://msdn.microsoft.com/en-us/library/ms632667(VS.85).aspx). Keep in mind, this is intended for use when *creating* a window - there's no guarantee that it will produce an accurate set of window dimensions for an existing window; for that, use [`GetWindowRect()`](h... |
140,439 | <p>How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears.</p>
<p>I can't even bind to perform a simple query:</p>
<pre><code>import sys
import ldap
Server = "ldap://my-ldap-server"
DN, Secret, un = sys.argv[1:4]
Base = "dc=mydomain,dc=co,... | [
{
"answer_id": 140495,
"author": "1729",
"author_id": 4319,
"author_profile": "https://Stackoverflow.com/users/4319",
"pm_score": 7,
"selected": true,
"text": "<p>I was missing </p>\n\n<pre><code>l.set_option(ldap.OPT_REFERRALS, 0)\n</code></pre>\n\n<p>From the init.</p>\n"
},
{
... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4319/"
] | How do I authenticate against AD using Python + LDAP. I'm currently using the python-ldap library and all it is producing is tears.
I can't even bind to perform a simple query:
```
import sys
import ldap
Server = "ldap://my-ldap-server"
DN, Secret, un = sys.argv[1:4]
Base = "dc=mydomain,dc=co,dc=uk"
Scope = ldap.SC... | I was missing
```
l.set_option(ldap.OPT_REFERRALS, 0)
```
From the init. |
140,460 | <p>We have a typical web application that is essentially a data entry application with lots of screens some of which have some degree of complexity. We need to provide that standard capability on making sure if the user forgets to click the "Save" button before navigating away or closing their browser they get a warni... | [
{
"answer_id": 140508,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 4,
"selected": false,
"text": "<p>One piece of the puzzle:</p>\n\n<pre><code>/**\n * Determines if a form is dirty by comparing the current value of... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22732/"
] | We have a typical web application that is essentially a data entry application with lots of screens some of which have some degree of complexity. We need to provide that standard capability on making sure if the user forgets to click the "Save" button before navigating away or closing their browser they get a warning a... | One piece of the puzzle:
```
/**
* Determines if a form is dirty by comparing the current value of each element
* with its default value.
*
* @param {Form} form the form to be checked.
* @return {Boolean} <code>true</code> if the form is dirty, <code>false</code>
* otherwise.
*/
function formI... |
140,490 | <p>Which gets called first - the base constructor or "other stuff here"?</p>
<pre><code>public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
</code></pre>
| [
{
"answer_id": 140497,
"author": "Mastermind",
"author_id": 22213,
"author_profile": "https://Stackoverflow.com/users/22213",
"pm_score": 3,
"selected": false,
"text": "<p>I'd say base</p>\n\n<p>EDIT see:</p>\n\n<p><a href=\"http://www.c-sharpcorner.com/UploadFile/rajeshvs/ConsNDestructo... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16872/"
] | Which gets called first - the base constructor or "other stuff here"?
```
public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
``` | The base constructor will be called first.
try it:
```
public class MyBase
{
public MyBase()
{
Console.WriteLine("MyBase");
}
}
public class MyDerived : MyBase
{
public MyDerived():base()
{
Console.WriteLine("MyDerived");
}
}
``` |
140,602 | <p>I am trying to call a WCF webservice (which I developed) from a Silverlight application. For some reason the Silverlight app does not make the http soap call to the service. I know this because I am sniffing all http traffic with Fiddler (and it is not a localhost call).</p>
<p>This my configuration in the server r... | [
{
"answer_id": 140646,
"author": "Bill Reiss",
"author_id": 18967,
"author_profile": "https://Stackoverflow.com/users/18967",
"pm_score": 0,
"selected": false,
"text": "<p>You wouldn't happen to be running from the filesystem would you? If you are serving up the silverlight application y... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19010/"
] | I am trying to call a WCF webservice (which I developed) from a Silverlight application. For some reason the Silverlight app does not make the http soap call to the service. I know this because I am sniffing all http traffic with Fiddler (and it is not a localhost call).
This my configuration in the server relevant to... | If the Silverlight application is not hosted in the same domain that exposes the Web service you want to call, then cross-domain restrictions applies.
If you want the Silverlight application to be hosted in another domain than the web service, you may want to have a look on [this post](http://timheuer.com/blog/archive... |
140,616 | <p>Is there a NAnt task that will echo out all property names and values that are currently set during a build? Something equivalent to the Ant <a href="http://ant.apache.org/manual/Tasks/echoproperties.html" rel="noreferrer">echoproperties</a> task maybe?</p>
| [
{
"answer_id": 140739,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 1,
"selected": false,
"text": "<p>You can't prove a negative, but I can't find one and haven't seen one. I've traditionally rolled my own property echo... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1853/"
] | Is there a NAnt task that will echo out all property names and values that are currently set during a build? Something equivalent to the Ant [echoproperties](http://ant.apache.org/manual/Tasks/echoproperties.html) task maybe? | Try this snippet:
```
<project>
<property name="foo" value="bar"/>
<property name="fiz" value="buz"/>
<script language="C#" prefix="util" >
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
foreach (DictionaryEntry entry in proje... |
140,627 | <p>I just wrote my first web service so lets make the assumption that my web service knowlege is non existant. I want to try to call a dbClass function from the web service. However I need some params that are in the session. Is there any way I can get these call these session variables from the webservice??</p>
| [
{
"answer_id": 140644,
"author": "Yitzchok",
"author_id": 5723,
"author_profile": "https://Stackoverflow.com/users/5723",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe this will work HttpContext.Current.Session[\"Name]\nOr else you might have to take in some parameters or store the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16820/"
] | I just wrote my first web service so lets make the assumption that my web service knowlege is non existant. I want to try to call a dbClass function from the web service. However I need some params that are in the session. Is there any way I can get these call these session variables from the webservice?? | If you are using ASP.NET web services and you want to have a session environment maintained for you, you need to embellish your web service method with an attribute that indicates you require a session.
```
[WebMethod(EnableSession = true)]
public void MyWebService()
{
Foo foo;
Session["MyObjectName"] = new Fo... |
140,643 | <p>When I try to execute a view that includes tables from different schemas an ORA-001031 Insufficient privileges is thrown. These tables have execute permission for the schema where the view was created. If I execute the view's SQL Statement it works. What am I missing?</p>
| [
{
"answer_id": 140665,
"author": "Steve K",
"author_id": 739,
"author_profile": "https://Stackoverflow.com/users/739",
"pm_score": 5,
"selected": true,
"text": "<p>As the table owner you need to grant SELECT access on the underlying tables to the user you are running the SELECT statement... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22769/"
] | When I try to execute a view that includes tables from different schemas an ORA-001031 Insufficient privileges is thrown. These tables have execute permission for the schema where the view was created. If I execute the view's SQL Statement it works. What am I missing? | As the table owner you need to grant SELECT access on the underlying tables to the user you are running the SELECT statement as.
```
grant SELECT on TABLE_NAME to READ_USERNAME;
``` |
140,728 | <p>It often happens that characters such as <em>é</em> gets transformed to <em>é</em>, even though the collation for the MySQL DB, table and field is set to utf8_general_ci. The encoding in the <em>Content-Type</em> for the page is also set to UTF8.</p>
<p>I know about utf8_encode/decode, but I'm not quite sure about ... | [
{
"answer_id": 141011,
"author": "Stefan Gehrig",
"author_id": 11354,
"author_profile": "https://Stackoverflow.com/users/11354",
"pm_score": 5,
"selected": true,
"text": "<p>On the first look at <a href=\"http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet\" rel=\"noreferrer\">htt... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6681/"
] | It often happens that characters such as *é* gets transformed to *é*, even though the collation for the MySQL DB, table and field is set to utf8\_general\_ci. The encoding in the *Content-Type* for the page is also set to UTF8.
I know about utf8\_encode/decode, but I'm not quite sure about where and how to use it.
I... | On the first look at <http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet> I think that one important thing is missing (perhaps I overlooked this one).
Depending on your MySQL installation and/or configuration you have to set the connection encoding so that MySQL knows what encoding you're expecting on the clien... |
140,734 | <p>What would be the best practice way to handle the caching of images using PHP.</p>
<p>The filename is currently stored in a MySQL database which is renamed to a GUID on upload, along with the original filename and alt tag.</p>
<p>When the image is put into the HTML pages it is done so using a url such as '/images/... | [
{
"answer_id": 140767,
"author": "sgibbons",
"author_id": 2327,
"author_profile": "https://Stackoverflow.com/users/2327",
"pm_score": 0,
"selected": false,
"text": "<p>Your approach seems quite reasonable - I would add that some mechanism should be put into place to check that the date t... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22776/"
] | What would be the best practice way to handle the caching of images using PHP.
The filename is currently stored in a MySQL database which is renamed to a GUID on upload, along with the original filename and alt tag.
When the image is put into the HTML pages it is done so using a url such as '/images/get/200x200/{guid... | There is two typos in Dan Udey's rewrite example (and I can't comment on it), it should rather be :
```
RewriteCond %{REQUEST_URI} ^/images/cached/
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.*) /images/generate.php?$1 [L]
```
Regards. |
140,758 | <p>In Java you can do <code>File.listFiles()</code> and receive all of the files in a directory. You can then easily recurse through directory trees.</p>
<p>Is there an analogous way to do this in Python?</p>
| [
{
"answer_id": 140778,
"author": "florin",
"author_id": 18308,
"author_profile": "https://Stackoverflow.com/users/18308",
"pm_score": 2,
"selected": false,
"text": "<p>Straight from Python's Refererence Library</p>\n\n<pre><code>>>> import glob\n>>> glob.glob('./[0-9].*... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | In Java you can do `File.listFiles()` and receive all of the files in a directory. You can then easily recurse through directory trees.
Is there an analogous way to do this in Python? | Yes, there is. The Python way is even better.
There are three possibilities:
**1) Like File.listFiles():**
Python has the function os.listdir(path). It works like the Java method.
**2) pathname pattern expansion with glob:**
The module glob contains functions to list files on the file system using Unix shell like ... |
140,786 | <p>The code is</p>
<pre><code>return min + static_cast<int>(static_cast<double>(max - min + 1.0) *
(number / (UINT_MAX + 1.0)));
</code></pre>
<p>number is a random number obtained by rand_s. min and max are ints and represent minimum and maximum values (inclusive).</p>
<p>If you provide a solution not... | [
{
"answer_id": 140812,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 1,
"selected": false,
"text": "<p>How about <a href=\"http://www.boost.org/doc/libs/1_36_0/libs/random/index.html\" rel=\"nofollow noreferrer\">Boost... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | The code is
```
return min + static_cast<int>(static_cast<double>(max - min + 1.0) *
(number / (UINT_MAX + 1.0)));
```
number is a random number obtained by rand\_s. min and max are ints and represent minimum and maximum values (inclusive).
If you provide a solution not using unsigned int as a number, please also... | The `static_cast<double>` is redundant because the "+1.0"s will cause promotion to double anyway. |
140,820 | <p>Assuming I'm trying to automate the installation of something on windows and I want to try to test whether another installation is in progress before attempting install. I don't have control over the installer and have to do this in the automation framework. Is there a better way to do this, some win32 api?, than ju... | [
{
"answer_id": 140875,
"author": "Mike Dimmick",
"author_id": 6970,
"author_profile": "https://Stackoverflow.com/users/6970",
"pm_score": 4,
"selected": true,
"text": "<p>See the description of the <a href=\"http://msdn.microsoft.com/en-us/library/aa372909(VS.85).aspx\" rel=\"noreferrer\... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/332/"
] | Assuming I'm trying to automate the installation of something on windows and I want to try to test whether another installation is in progress before attempting install. I don't have control over the installer and have to do this in the automation framework. Is there a better way to do this, some win32 api?, than just ... | See the description of the [\_MSIExecute Mutex](http://msdn.microsoft.com/en-us/library/aa372909(VS.85).aspx) on MSDN. |
140,825 | <p>Can you define a macro that accesses a normal variable, but in a read-only fashion (other than defining it as a call to a function)? For example, can the VALUE macro in the following code be defined in such a way that the dostuff() function causes a compile error?</p>
<pre><code>struct myobj {
int value;
}
/* Th... | [
{
"answer_id": 140853,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 4,
"selected": true,
"text": "<p>If the variable is always numeric, this works:</p>\n\n<pre><code>#define VALUE(x) (x+0)\n</code></pre>\n\n<p>or in the... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14732/"
] | Can you define a macro that accesses a normal variable, but in a read-only fashion (other than defining it as a call to a function)? For example, can the VALUE macro in the following code be defined in such a way that the dostuff() function causes a compile error?
```
struct myobj {
int value;
}
/* This macro does ... | If the variable is always numeric, this works:
```
#define VALUE(x) (x+0)
```
or in the context of your example,
```
#define VALUE(x) (x->value+0)
``` |
140,926 | <p>I have a data stream that may contain \r, \n, \r\n, \n\r or any combination of them. Is there a simple way to normalize the data to make all of them simply become \r\n pairs to make display more consistent?</p>
<p>So something that would yield this kind of translation table:</p>
<pre><code>\r --> \r\n
\n ... | [
{
"answer_id": 140952,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 2,
"selected": false,
"text": "<p>A Regex would help.. could do something roughly like this..</p>\n\n<p>(\\r\\n|\\n\\n|\\n\\r|\\r|\\n) replace w... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13154/"
] | I have a data stream that may contain \r, \n, \r\n, \n\r or any combination of them. Is there a simple way to normalize the data to make all of them simply become \r\n pairs to make display more consistent?
So something that would yield this kind of translation table:
```
\r --> \r\n
\n --> \r\n
\n\n --> \r... | I believe this will do what you need:
```
using System.Text.RegularExpressions;
// ...
string normalized = Regex.Replace(originalString, @"\r\n|\n\r|\n|\r", "\r\n");
```
I'm not 100% sure on the exact syntax, and I don't have a .Net compiler handy to check. I wrote it in perl, and converted it into (hopefully correc... |
140,935 | <p>Anyone knows if is possible to have partial class definition on C++ ?</p>
<p>Something like:</p>
<p>file1.h:</p>
<pre>
class Test {
public:
int test1();
};
</pre>
<p>file2.h: </p>
<pre>
class Test {
public:
int test2();
};
</pre>
<p>For me it seems quite useful for definining multi-p... | [
{
"answer_id": 140942,
"author": "Jamie",
"author_id": 22748,
"author_profile": "https://Stackoverflow.com/users/22748",
"pm_score": 4,
"selected": false,
"text": "<p>Try inheritance</p>\n\n<p>Specifically</p>\n\n<pre><code>class AllPlatforms {\npublic:\n int common();\n};\n</code></p... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18623/"
] | Anyone knows if is possible to have partial class definition on C++ ?
Something like:
file1.h:
```
class Test {
public:
int test1();
};
```
file2.h:
```
class Test {
public:
int test2();
};
```
For me it seems quite useful for definining multi-platform classes that have common functio... | This is not possible in C++, it will give you an error about redefining already-defined classes. If you'd like to share behavior, consider inheritance. |
140,996 | <p>In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this:</p>
<pre><code><TextBlock><Hyperlink Command="local:MyCommands.ViewDetails" CommandParameter="{Binding}">Object Name</Hyperlink&g... | [
{
"answer_id": 141008,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 9,
"selected": true,
"text": "<p>It looks strange, but it works. We do it in about 20 different places in our app. <code>Hyperlink</code> implicitly const... | 2008/09/26 | [
"https://Stackoverflow.com/questions/140996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22789/"
] | In WPF, I want to create a hyperlink that navigates to the details of an object, and I want the text of the hyperlink to be the name of the object. Right now, I have this:
```
<TextBlock><Hyperlink Command="local:MyCommands.ViewDetails" CommandParameter="{Binding}">Object Name</Hyperlink></TextBlock>
```
But I want ... | It looks strange, but it works. We do it in about 20 different places in our app. `Hyperlink` implicitly constructs a `<Run/>` if you put text in its "content", but in .NET 3.5 `<Run/>` won't let you bind to it, so you've got to explicitly use a `TextBlock`.
```
<TextBlock>
<Hyperlink Command="local:MyCommands.Vie... |
141,007 | <p>Is there a way to add a resource to a ResourceDictionary from code without giving it a resource key?</p>
<p>For instance, I have this resource in XAML:</p>
<pre><code><TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}"
ItemsSource="{Binding Path=Value.Valu... | [
{
"answer_id": 141018,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 0,
"selected": false,
"text": "<p>Use the type that you want the template to apply to as the key:</p>\n\n<pre><code>this.Resources.Add(FieldPropertyIn... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999/"
] | Is there a way to add a resource to a ResourceDictionary from code without giving it a resource key?
For instance, I have this resource in XAML:
```
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}"
ItemsSource="{Binding Path=Value.Values}">
<TextBlock T... | Use the type that you want the template to apply to as the key:
```
HierarchicalDataTemplate fieldPropertyTemplate = new
HierarchicalDataTemplate("FieldProperyInfo");
fieldPropertyTemplate.SetBinding(
HierarchialDataTemplate.ItemSourceProperty,
new Binding("Value.Values");
this.Resources.Add(FieldProperty... |
141,045 | <p>I want to replace the first occurrence in a given string. </p>
<p>How can I accomplish this in .NET?</p>
| [
{
"answer_id": 141062,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 4,
"selected": false,
"text": "<p>Take a look at <a href=\"http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.replace.aspx\" rel=... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to replace the first occurrence in a given string.
How can I accomplish this in .NET? | ```
string ReplaceFirst(string text, string search, string replace)
{
int pos = text.IndexOf(search);
if (pos < 0)
{
return text;
}
return text.Substring(0, pos) + replace + text.Substring(pos + search.Length);
}
```
Example:
```
string str = "The brown brown fox jumps over the lazy dog";
str = Replac... |
141,068 | <p>I have an Image column (Allow Null = true) in SQL Server 2005. I am using Crystal Reports designer (ver 10.5) that comes with Visual Studio 2008. Crystal sees the column as blob field and puts an image object for the column.
When I am trying to limit the record selection by using </p>
<pre><code> NOT ISNULL({Empl... | [
{
"answer_id": 141178,
"author": "Keng",
"author_id": 730,
"author_profile": "https://Stackoverflow.com/users/730",
"pm_score": 0,
"selected": false,
"text": "<p>since no one is jumping in on this I'll try (note: i can't test these possibilities at the moment).</p>\n\n<ul>\n<li><p>if you... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18169/"
] | I have an Image column (Allow Null = true) in SQL Server 2005. I am using Crystal Reports designer (ver 10.5) that comes with Visual Studio 2008. Crystal sees the column as blob field and puts an image object for the column.
When I am trying to limit the record selection by using
```
NOT ISNULL({Employee.Picture})
... | The `ISNULL` function is more like the `SWITCH` function in in VB. What you are looking for is probably something more along the lines of:
```
WHERE NOT Employee.Picture IS NULL
```
Two separate words for `IS NULL`. |
141,088 | <p>I've seen a few different ways to iterate over a dictionary in C#. Is there a standard way?</p>
| [
{
"answer_id": 141098,
"author": "Pablo Fernandez",
"author_id": 7595,
"author_profile": "https://Stackoverflow.com/users/7595",
"pm_score": 13,
"selected": true,
"text": "<pre class=\"lang-cs prettyprint-override\"><code>foreach(KeyValuePair<string, string> entry in myDictionary)\... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9311/"
] | I've seen a few different ways to iterate over a dictionary in C#. Is there a standard way? | ```cs
foreach(KeyValuePair<string, string> entry in myDictionary)
{
// do something with entry.Value or entry.Key
}
``` |
141,108 | <p>Is it possible to find the <code>foreach</code> index?</p>
<p>in a <code>for</code> loop as follows:</p>
<pre><code>for ($i = 0; $i < 10; ++$i) {
echo $i . ' ';
}
</code></pre>
<p><code>$i</code> will give you the index.</p>
<p>Do I have to use the <code>for</code> loop or is there some way to get the inde... | [
{
"answer_id": 141114,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 11,
"selected": true,
"text": "<pre><code>foreach($array as $key=>$value) {\n // do stuff\n}\n</code></pre>\n\n<p><code>$key</code> is the index of each... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18334/"
] | Is it possible to find the `foreach` index?
in a `for` loop as follows:
```
for ($i = 0; $i < 10; ++$i) {
echo $i . ' ';
}
```
`$i` will give you the index.
Do I have to use the `for` loop or is there some way to get the index in the `foreach` loop? | ```
foreach($array as $key=>$value) {
// do stuff
}
```
`$key` is the index of each `$array` element |
141,136 | <p>I have a .net 2.0 ascx control with a start time and end time textboxes. The data is as follows: </p>
<p>txtStart.Text = 09/19/2008 07:00:00</p>
<p>txtEnd.Text = 09/19/2008 05:00:00</p>
<p>I would like to calculate the total time (hours and minutes) in JavaScript then display it in a textbox on the page. </p>
| [
{
"answer_id": 141159,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 4,
"selected": true,
"text": "<p>Once your textbox date formats are known in advance, you can use <a href=\"http://www.mattkruse.com/javascript/date/\" rel... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4096/"
] | I have a .net 2.0 ascx control with a start time and end time textboxes. The data is as follows:
txtStart.Text = 09/19/2008 07:00:00
txtEnd.Text = 09/19/2008 05:00:00
I would like to calculate the total time (hours and minutes) in JavaScript then display it in a textbox on the page. | Once your textbox date formats are known in advance, you can use [Matt Kruse's Date functions](http://www.mattkruse.com/javascript/date/) in Javascript to convert the two to a timestamp, subtract and then write to the resulting text box.
Equally the [JQuery Date Input](http://jonathanleighton.com/projects/date-input#d... |
141,140 | <p>The following method does not work because the inner block declares a variable of the same name as one in the outer block. Apparently variables belong to the method or class in which they are declared, not to the block in which they are declared, so I therefore can't write a short little temporary block for debuggin... | [
{
"answer_id": 141150,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 3,
"selected": false,
"text": "<p>It leads to bugs that are hard to spot, I guess. It's similar in C#.</p>\n\n<p>Pascal does not support this, since ... | 2008/09/26 | [
"https://Stackoverflow.com/questions/141140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | The following method does not work because the inner block declares a variable of the same name as one in the outer block. Apparently variables belong to the method or class in which they are declared, not to the block in which they are declared, so I therefore can't write a short little temporary block for debugging t... | I believe the rationale is that most of the time, that isn't intentional, it is a programming or logic flaw.
in an example as trivial as yours, its obvious, but in a large block of code, accidentally redeclaring a variable may not be obvious.
ETA: it might also be related to exception handling in java. i thought part... |