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
191,351
<p>I am trying to rename all the files present in a Windows directory using <strong>FOR</strong> command as follows at the command prompt:</p> <pre><code>for %1 in (*.*) do ren %1 test%1 </code></pre> <p>E.g. This renames a file <strong>enc1.ctl</strong> to <strong>testenc1.ctl</strong> <strong>enc2.ctl</strong> to...
[ { "answer_id": 191420, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 2, "selected": true, "text": "<p>If you know the number of files, (say 10), you can use</p>\n\n<pre><code>for /L %1 in (1,1,10) do ren enc%1.ctl test...
2008/10/10
[ "https://Stackoverflow.com/questions/191351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
I am trying to rename all the files present in a Windows directory using **FOR** command as follows at the command prompt: ``` for %1 in (*.*) do ren %1 test%1 ``` E.g. This renames a file **enc1.ctl** to **testenc1.ctl** **enc2.ctl** to **testenc2.ctl** Thats not what i want. What i want is **enc1.ctl** renamed...
If you know the number of files, (say 10), you can use ``` for /L %1 in (1,1,10) do ren enc%1.ctl test%1.ctl ```
191,359
<p>I need to convert a bunch of files to utf-8 in Python, and I have trouble with the "converting the file" part.</p> <p>I'd like to do the equivalent of:</p> <pre><code>iconv -t utf-8 $file &gt; converted/$file # this is shell code </code></pre> <p>Thanks!</p>
[ { "answer_id": 191403, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 7, "selected": true, "text": "<p>You can use the <a href=\"https://docs.python.org/2/library/codecs.html\" rel=\"noreferrer\">codecs module</a>, like this:...
2008/10/10
[ "https://Stackoverflow.com/questions/191359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2797/" ]
I need to convert a bunch of files to utf-8 in Python, and I have trouble with the "converting the file" part. I'd like to do the equivalent of: ``` iconv -t utf-8 $file > converted/$file # this is shell code ``` Thanks!
You can use the [codecs module](https://docs.python.org/2/library/codecs.html), like this: ``` import codecs BLOCKSIZE = 1048576 # or some other, desired size in bytes with codecs.open(sourceFileName, "r", "your-source-encoding") as sourceFile: with codecs.open(targetFileName, "w", "utf-8") as targetFile: ...
191,364
<p>Trying to debug an issue with a server and my only log file is a 20GB log file (with no timestamps even! Why do people use <code>System.out.println()</code> as logging? In production?!)</p> <p>Using grep, I've found an area of the file that I'd like to take a look at, line 347340107.</p> <p>Other than doing someth...
[ { "answer_id": 191385, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "<p>with GNU-grep you could just say </p>\n\n<pre>grep --context=10 ...</pre>\n" }, { "answer_id": 191397, "author":...
2008/10/10
[ "https://Stackoverflow.com/questions/191364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
Trying to debug an issue with a server and my only log file is a 20GB log file (with no timestamps even! Why do people use `System.out.println()` as logging? In production?!) Using grep, I've found an area of the file that I'd like to take a look at, line 347340107. Other than doing something like ``` head -<$LINENU...
with GNU-grep you could just say ``` grep --context=10 ... ```
191,368
<p>I can reset FPU's CTRL registers with this:</p> <p><a href="http://support.microsoft.com/kb/326219" rel="nofollow noreferrer">http://support.microsoft.com/kb/326219</a></p> <p>But how can I save current registers, and restore them later?</p> <p>It's from .net code..</p> <p>What I'm doing, is from Delphi calling ...
[ { "answer_id": 191454, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 3, "selected": false, "text": "<p>Same function you use to change them: <code>_controlfp()</code>. If you pass in a mask of 0, the current value won't be alter...
2008/10/10
[ "https://Stackoverflow.com/questions/191368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3308/" ]
I can reset FPU's CTRL registers with this: <http://support.microsoft.com/kb/326219> But how can I save current registers, and restore them later? It's from .net code.. What I'm doing, is from Delphi calling an .net dll as an COM module. Checking the `Ctrl` registers in delphi yield one value, checking with control...
``` uses SysUtils; var SavedCW: Word; begin SavedCW := Get8087CW; try Set8087CW($027f); // Call .NET code here finally Set8087CW(SavedCW); end; end; ```
191,376
<p>I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution. </p> <p>I have an accounts system with multiple account types. We have restaurant, hotel, service_provider, and consumer account types. Im sure ...
[ { "answer_id": 191386, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 1, "selected": false, "text": "<p>I'd suggest aggregation rather than inheritance here for the relationship between account and profile, but have an Acc...
2008/10/10
[ "https://Stackoverflow.com/questions/191376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution. I have an accounts system with multiple account types. We have restaurant, hotel, service\_provider, and consumer account types. Im sure there wil...
I'd suggest aggregation rather than inheritance here for the relationship between account and profile, but have an Account base class that is inherited into multiple account types. The account contains a profile object, which can be set in the constructor of each polymorphic account type. You could wrap the account ...
191,383
<p>For PHP</p> <p>I have a date I want line wrapped.</p> <p>I have $date = '2008-09-28 9:19 pm'; I need the first space replaced with a br to become </p> <pre><code>2008-09-28&lt;br&gt;9:19 pm </code></pre> <p>If it wasn't for that second space before PM, I would just str_replace() it. </p>
[ { "answer_id": 191386, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 1, "selected": false, "text": "<p>I'd suggest aggregation rather than inheritance here for the relationship between account and profile, but have an Acc...
2008/10/10
[ "https://Stackoverflow.com/questions/191383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13704/" ]
For PHP I have a date I want line wrapped. I have $date = '2008-09-28 9:19 pm'; I need the first space replaced with a br to become ``` 2008-09-28<br>9:19 pm ``` If it wasn't for that second space before PM, I would just str\_replace() it.
I'd suggest aggregation rather than inheritance here for the relationship between account and profile, but have an Account base class that is inherited into multiple account types. The account contains a profile object, which can be set in the constructor of each polymorphic account type. You could wrap the account ...
191,399
<p>How do I change the Read-only file attribute for each file in a folder using c#?</p> <p>Thanks</p>
[ { "answer_id": 191423, "author": "Jeffrey L Whitledge", "author_id": 10174, "author_profile": "https://Stackoverflow.com/users/10174", "pm_score": 4, "selected": false, "text": "<pre><code>foreach (string fileName in System.IO.Directory.GetFiles(path))\n{\n System.IO.FileInfo fileInfo...
2008/10/10
[ "https://Stackoverflow.com/questions/191399", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I change the Read-only file attribute for each file in a folder using c#? Thanks
``` foreach (string fileName in System.IO.Directory.GetFiles(path)) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName); fileInfo.Attributes |= System.IO.FileAttributes.ReadOnly; // or fileInfo.IsReadOnly = true; } ```
191,400
<p>I have around 25 worksheets in my workbook (Excel spreadsheet). Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time...
[ { "answer_id": 191416, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 5, "selected": true, "text": "<p>I don't believe there's a way to do it without using VBA. If you are interested in a VBA solution, here is the code...
2008/10/10
[ "https://Stackoverflow.com/questions/191400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17266/" ]
I have around 25 worksheets in my workbook (Excel spreadsheet). Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time co...
I don't believe there's a way to do it without using VBA. If you are interested in a VBA solution, here is the code: ``` Dim ws as Worksheet Dim pwd as String pwd = "" ' Put your password here For Each ws In Worksheets ws.Protect Password:=pwd Next ws ``` Unprotecting is virtually the same: ``` Dim ws as Works...
191,404
<p>I have been asking myself this question for a long time now. Thought of posting it. C# doesn't support Multiple Inheritance(this is the fact). All classes created in C# derive out of 'Object' class(again a fact).</p> <p>So if C# does not support Multiple inheritance, then how are we able to extend a class even thou...
[ { "answer_id": 191418, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": false, "text": "<p>You're confusing mutliple inheritance with an inheritance tree. You can inherit from something other than Object. ...
2008/10/10
[ "https://Stackoverflow.com/questions/191404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21995/" ]
I have been asking myself this question for a long time now. Thought of posting it. C# doesn't support Multiple Inheritance(this is the fact). All classes created in C# derive out of 'Object' class(again a fact). So if C# does not support Multiple inheritance, then how are we able to extend a class even though it alre...
Joel's answer is correct. There is a difference between multiple inheritance and an inhertance tree (or derivation chain). In your example, you actually show an inhertance tree: One object inherits (derives) from another object higher in the tree. Multiple inheritance allows one object to inherit from multiple base cla...
191,413
<p>I'm just starting to wean myself from ASP.NET UpdatePanels. I'm using jQuery and jTemplates to bind the results of a web service to a grid, and everything works fine. </p> <p>Here's the thing: I'm trying to show a spinner GIF while the table is being refreshed (à la UpdateProgress in ASP.NET) I've got it all workin...
[ { "answer_id": 191435, "author": "Steve g", "author_id": 12092, "author_profile": "https://Stackoverflow.com/users/12092", "pm_score": 0, "selected": false, "text": "<p>Are you doing a synchronous call or asynchronous call? synchronous calls do cause the browser to seemingly lock up for...
2008/10/10
[ "https://Stackoverflow.com/questions/191413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I'm just starting to wean myself from ASP.NET UpdatePanels. I'm using jQuery and jTemplates to bind the results of a web service to a grid, and everything works fine. Here's the thing: I'm trying to show a spinner GIF while the table is being refreshed (à la UpdateProgress in ASP.NET) I've got it all working, except ...
It's not the Ajax call that's freezing the browser. It's the success handler (applyTemplate). Inserting HTML into a document like that can freeze IE, depending on how much HTML there is. It's because the IE UI is single threaded; if you notice, the actual IE menus are frozen too while this is happening. As a test, try...
191,421
<p>I am using SQL Server 2005. I want to constrain the values in a column to be unique, while allowing NULLS.</p> <p>My current solution involves a unique index on a view like so:</p> <pre><code>CREATE VIEW vw_unq WITH SCHEMABINDING AS SELECT Column1 FROM MyTable WHERE Column1 IS NOT NULL CREATE UNIQ...
[ { "answer_id": 191520, "author": "willasaywhat", "author_id": 12234, "author_profile": "https://Stackoverflow.com/users/12234", "pm_score": 6, "selected": true, "text": "<p>Pretty sure you can't do that, as it violates the purpose of uniques.</p>\n\n<p>However, this person seems to have ...
2008/10/10
[ "https://Stackoverflow.com/questions/191421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20959/" ]
I am using SQL Server 2005. I want to constrain the values in a column to be unique, while allowing NULLS. My current solution involves a unique index on a view like so: ``` CREATE VIEW vw_unq WITH SCHEMABINDING AS SELECT Column1 FROM MyTable WHERE Column1 IS NOT NULL CREATE UNIQUE CLUSTERED INDEX unq...
Pretty sure you can't do that, as it violates the purpose of uniques. However, this person seems to have a decent work around: <http://sqlservercodebook.blogspot.com/2008/04/multiple-null-values-in-unique-index-in.html>
191,428
<p>Is it possible to change the language of system messages from PostgreSQL?</p> <p>In MSSQL for instance this is possible with the SQL statement <a href="http://msdn.microsoft.com/en-us/library/ms174398.aspx" rel="noreferrer">SET LANGUAGE</a>.</p>
[ { "answer_id": 191958, "author": "Milen A. Radev", "author_id": 15785, "author_profile": "https://Stackoverflow.com/users/15785", "pm_score": 6, "selected": false, "text": "<pre><code>SET lc_messages TO 'en_US.UTF-8';\n</code></pre>\n\n<p>More info on requirements and limitations <a href...
2008/10/10
[ "https://Stackoverflow.com/questions/191428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3565/" ]
Is it possible to change the language of system messages from PostgreSQL? In MSSQL for instance this is possible with the SQL statement [SET LANGUAGE](http://msdn.microsoft.com/en-us/library/ms174398.aspx).
``` SET lc_messages TO 'en_US.UTF-8'; ``` More info on requirements and limitations [here](http://www.postgresql.org/docs/current/static/runtime-config-client.html#GUC-LC-MESSAGES).
191,429
<p>I'm trying to use <a href="http://www.glish.com/css/9.asp" rel="nofollow noreferrer">this</a> layout with two 50% column width instead. But it seems that when the right columns reaches its 'min-width', it goes under the left column. Is there any way to use the 'shim' technique to set a min-width to the wrapper so bo...
[ { "answer_id": 191518, "author": "David Arno", "author_id": 7122, "author_profile": "https://Stackoverflow.com/users/7122", "pm_score": -1, "selected": false, "text": "<p>Use a 2 column table. It will do exactly what you want. Div's are supposed to be used to simply divide up logically d...
2008/10/10
[ "https://Stackoverflow.com/questions/191429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25371/" ]
I'm trying to use [this](http://www.glish.com/css/9.asp) layout with two 50% column width instead. But it seems that when the right columns reaches its 'min-width', it goes under the left column. Is there any way to use the 'shim' technique to set a min-width to the wrapper so both columns stop resizing. Thus, eliminat...
I was able to come up with a "no HTML tables required" solution based off of a technique by Stu Nicholls at CSS Play and I personally like it because not only does it work in IE6+ and FF2+, it is also valid CSS that does not require any hacks. For my argument on why a CSS-based layout is preferable over HTML tables, se...
191,443
<p>I've run into this issue quite a few times and never liked the solution chosen. Let's say you have a list of States (just as a simple example) in the database. In your code-behind, you want to be able to reference a State by ID and have the list of them available via Intellisense. </p> <p>For example:</p> <pre>...
[ { "answer_id": 191489, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Personally, I would store lookup data in a database, and simply try to avoid the type of hard coding that binds ru...
2008/10/10
[ "https://Stackoverflow.com/questions/191443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22303/" ]
I've run into this issue quite a few times and never liked the solution chosen. Let's say you have a list of States (just as a simple example) in the database. In your code-behind, you want to be able to reference a State by ID and have the list of them available via Intellisense. For example: ``` States.Arizona.Id ...
I believe that if it shows up in Intellisense, then, by definition, it is hard-coded into your program. That said, if your goal is make the hard-coding as painless as possible, on thing you might try is auto-generating your enumeration based on what's in the database. That is, you can write a program that reads the da...
191,463
<p>This seems like the most basic question in the world, but damned if I can find an answer.</p> <p>Is there a keyboard shortcut, either native to Visual Studio or through Code Rush or other third-party plug-in, to wrap the current selection with an HTML tag? I'm tired of typing the opening tag, cutting the misplaced ...
[ { "answer_id": 191606, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>When faced with this situation, I often type the closing tag first, then the opening tag. This prevents the IDE fro...
2008/10/10
[ "https://Stackoverflow.com/questions/191463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1923/" ]
This seems like the most basic question in the world, but damned if I can find an answer. Is there a keyboard shortcut, either native to Visual Studio or through Code Rush or other third-party plug-in, to wrap the current selection with an HTML tag? I'm tired of typing the opening tag, cutting the misplaced closing ta...
Visual Studio 2015 comes with a new shortcut, Shift+Alt+W, that wraps the current selection with a div. This shortcut leaves the text "div" selected, making it seamlessly changeable to any desired tag. This coupled with the automatic end tag replacement makes for a quick solution. ### UPDATE This shortcut is availabl...
191,482
<p>I'm trying to build a similar 'slider' as demoed here <a href="http://ui.jquery.com/repository/real-world/product-slider/" rel="nofollow noreferrer">http://ui.jquery.com/repository/real-world/product-slider/</a> but I'm trying to use interior divs inside of the list items (<code>&lt;li&gt;</code>). it seems as if t...
[ { "answer_id": 196871, "author": "Rudi", "author_id": 22830, "author_profile": "https://Stackoverflow.com/users/22830", "pm_score": 2, "selected": false, "text": "<p>I think I <em>sort of</em> have a working example of what you're trying to do, but there are a couple issues.</p>\n\n<p>Us...
2008/10/10
[ "https://Stackoverflow.com/questions/191482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534/" ]
I'm trying to build a similar 'slider' as demoed here <http://ui.jquery.com/repository/real-world/product-slider/> but I'm trying to use interior divs inside of the list items (`<li>`). it seems as if this demo breaks if you're not using an image or block element (`<p>`,`<div>`,etc.) Anyone have any quick solutions to...
I think I *sort of* have a working example of what you're trying to do, but there are a couple issues. Using the example you posted as a base, you can replace the HTML markup of the LI's in a UL to be DIV's in a container DIV. For example: ``` <div class="sliderGallery"> <div class="div-that-gets-cr...
191,483
<p>I want to check the login status of a user through an ajax request. Depending wether the user is logged in I want to display either the username/password input or the username. Currently the request is sent on body.onload and a prgoress indicator is shown until the response arrives. Is there a better way?</p> <hr> ...
[ { "answer_id": 191499, "author": "Steve g", "author_id": 12092, "author_profile": "https://Stackoverflow.com/users/12092", "pm_score": 1, "selected": false, "text": "<p>Why not check before the user is even given the html?</p>\n\n<p>If you're just running static HTML w/ Javascript, I wou...
2008/10/10
[ "https://Stackoverflow.com/questions/191483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
I want to check the login status of a user through an ajax request. Depending wether the user is logged in I want to display either the username/password input or the username. Currently the request is sent on body.onload and a prgoress indicator is shown until the response arrives. Is there a better way? --- Let's a...
If you don't want to depend on a toolkit, you can create your own DOMReady function that looks kinda like this: ``` /* Usage: DOMReady(ajaxFunc); */ function DOMReady(f) { if (!document.all) { document.addEventListener("DOMContentLoaded", f, false); } else { if (document.readystate == 'complet...
191,493
<p>I often need to design a dialog in Delphi/C++Builder that allows various properties of an object to be modified, and the code to use it typically looks like this.</p> <pre><code>Dialog.Edit1.Text := MyObject.Username; Dialog.Edit2.Text := MyObject.Password; // ... many more of the same if (Dialog.ShowModal = mrOk)...
[ { "answer_id": 191610, "author": "akalenuk", "author_id": 25459, "author_profile": "https://Stackoverflow.com/users/25459", "pm_score": 0, "selected": false, "text": "<p>Delphi at least have 'With', though it doesn't solve the problem completely.</p>\n\n<pre><code>if (Dialog.ShowModal = ...
2008/10/10
[ "https://Stackoverflow.com/questions/191493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1737/" ]
I often need to design a dialog in Delphi/C++Builder that allows various properties of an object to be modified, and the code to use it typically looks like this. ``` Dialog.Edit1.Text := MyObject.Username; Dialog.Edit2.Text := MyObject.Password; // ... many more of the same if (Dialog.ShowModal = mrOk) begin MyOb...
well, something that I feel completely invaluable is the [GExperts](http://www.gexperts.org) plugin wizard "Reverse Statement" which is invoked after installing GExperts by pressing Shift + ALT + R What it does is automatically switch the assignments around for the highlighted block. For example: ``` edit1.text := db...
191,503
<p>I'm using the following code to loop through a directory to print out the names of the files. However, not all of the files are displayed. I have tried using <strong>clearstatcache</strong> with no effect.</p> <pre><code> $str = ''; $ignore = array('.', '..'); $dh = @opendir( $path ); if ($dh === FA...
[ { "answer_id": 191535, "author": "Jacco", "author_id": 22674, "author_profile": "https://Stackoverflow.com/users/22674", "pm_score": 2, "selected": true, "text": "<p>Your <code>break</code> keywords messes up your code:<br>\nYour loop very likely first encounters the '.' directory and t...
2008/10/10
[ "https://Stackoverflow.com/questions/191503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/840/" ]
I'm using the following code to loop through a directory to print out the names of the files. However, not all of the files are displayed. I have tried using **clearstatcache** with no effect. ``` $str = ''; $ignore = array('.', '..'); $dh = @opendir( $path ); if ($dh === FALSE) { // error...
Your `break` keywords messes up your code: Your loop very likely first encounters the '.' directory and than breaks out of your while loop. try replacing it with a `continue` and you should be fine.
191,592
<p>I'm working on a simple 2D game engine in Java, and having no trouble with FSEM, buffer strategies, and so on; my issue is with the mouse cursor. In windowed mode, I can hide the mouse cursor, no problem, by using setCursor() from my JFrame to set a wholly-transparent cursor. However, after a call to device.setFullS...
[ { "answer_id": 191634, "author": "Antonio Louro", "author_id": 15528, "author_profile": "https://Stackoverflow.com/users/15528", "pm_score": 0, "selected": false, "text": "<p>I don't know if this knowledge applies but in a old VB6 app I had the same problem and I got rid of it moving the...
2008/10/10
[ "https://Stackoverflow.com/questions/191592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7426/" ]
I'm working on a simple 2D game engine in Java, and having no trouble with FSEM, buffer strategies, and so on; my issue is with the mouse cursor. In windowed mode, I can hide the mouse cursor, no problem, by using setCursor() from my JFrame to set a wholly-transparent cursor. However, after a call to device.setFullScre...
I think I've finally found the solution: ``` System.setProperty("apple.awt.fullscreenhidecursor","true"); ``` This is an Apple-proprietary system property that hides the mouse cursor when an application is in full-screen mode. It's the only way I've found to fix it.
191,609
<p>Where would you write an error log file, say <code>ErrorLog.txt</code>, in Windows? Keep in mind the path would need to be open to basic users for file write permissions.</p> <p>I know the eventlog is a possible location for writing errors, but does it work for "user" level permissions?</p> <p>EDIT: I am targetin...
[ { "answer_id": 191618, "author": "workmad3", "author_id": 16035, "author_profile": "https://Stackoverflow.com/users/16035", "pm_score": 0, "selected": false, "text": "<p>%TEMP% is always a good location for logs I find.</p>\n" }, { "answer_id": 191624, "author": "StingyJack",...
2008/10/10
[ "https://Stackoverflow.com/questions/191609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1048/" ]
Where would you write an error log file, say `ErrorLog.txt`, in Windows? Keep in mind the path would need to be open to basic users for file write permissions. I know the eventlog is a possible location for writing errors, but does it work for "user" level permissions? EDIT: I am targeting Windows 2003, but I was pos...
Have you considered logging the event viewer instead? If you want to write your own log, I suggest the users local app setting directory. Make a product directory under there. It's different on different version of Windows. On Vista, you cannot put files like this under c:\program files. You will run into a lot of pro...
191,640
<p>I wish to search a database table on a nullable column. Sometimes the value I'm search for is itself NULL. Since Null is equal to nothing, even NULL, saying</p> <pre><code>where MYCOLUMN=SEARCHVALUE </code></pre> <p>will fail. Right now I have to resort to</p> <pre><code>where ((MYCOLUMN=SEARCHVALUE) OR (MYCO...
[ { "answer_id": 191646, "author": "DCookie", "author_id": 8670, "author_profile": "https://Stackoverflow.com/users/8670", "pm_score": 2, "selected": false, "text": "<p>Try </p>\n\n<pre><code>WHERE NVL(mycolumn,'NULL') = NVL(searchvalue,'NULL')\n</code></pre>\n" }, { "answer_id": 1...
2008/10/10
[ "https://Stackoverflow.com/questions/191640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12725/" ]
I wish to search a database table on a nullable column. Sometimes the value I'm search for is itself NULL. Since Null is equal to nothing, even NULL, saying ``` where MYCOLUMN=SEARCHVALUE ``` will fail. Right now I have to resort to ``` where ((MYCOLUMN=SEARCHVALUE) OR (MYCOLUMN is NULL and SEARCHVALUE is NULL)) ...
You can do the IsNull or NVL stuff, but it's just going to make the engine do more work. You'll be calling functions to do column conversions which then have to have the results compared. Use what you have ``` where ((MYCOLUMN=SEARCHVALUE) OR (MYCOLUMN is NULL and SEARCHVALUE is NULL)) ```
191,644
<p>I've googled around a bit, but maybe I didn't put the correct magik incantation into the search box. </p> <p>Does anyone know how to get output parameters from a stored procedure in Python? I'm using pymssql to call a stored procedure, and I'm not sure of the correct syntax to get the output parameter back. I don't...
[ { "answer_id": 192032, "author": "Milen A. Radev", "author_id": 15785, "author_profile": "https://Stackoverflow.com/users/15785", "pm_score": 2, "selected": false, "text": "<p>I'm not a python expert but after a brief perusing of the <a href=\"http://www.python.org/dev/peps/pep-0249/\" r...
2008/10/10
[ "https://Stackoverflow.com/questions/191644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13380/" ]
I've googled around a bit, but maybe I didn't put the correct magik incantation into the search box. Does anyone know how to get output parameters from a stored procedure in Python? I'm using pymssql to call a stored procedure, and I'm not sure of the correct syntax to get the output parameter back. I don't think I c...
I'm not a python expert but after a brief perusing of the [DB-API 2.0](http://www.python.org/dev/peps/pep-0249/) I believe you should use the "callproc" method of the cursor like this: ``` cur.callproc('my_stored_proc', (first_param, second_param, an_out_param)) ``` Then you'll have the result in the returned value ...
191,652
<p>I work a lot with serial communications with a variety of devices, and so I often have to analyze hex dumps in log files. Currently, I do this manually by looking at the dumps, looking at the protocol spec, and writing down the results. However, this is tedious and error-prone, especially whem messages contain hun...
[ { "answer_id": 191659, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 0, "selected": false, "text": "<p>I'm pretty sure I saw something like that on CPAN. I could be more vague if you like. :-)</p>\n\n<p><strong>Update:...
2008/10/10
[ "https://Stackoverflow.com/questions/191652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
I work a lot with serial communications with a variety of devices, and so I often have to analyze hex dumps in log files. Currently, I do this manually by looking at the dumps, looking at the protocol spec, and writing down the results. However, this is tedious and error-prone, especially whem messages contain hundreds...
[Wireshark](http://www.wireshark.org/) is quite good at opening network protocols.
191,690
<p>I have a table, we'll call <code>Users</code>. This table has a single primary key defined in SQL Server - an autoincrement <code>int ID</code>.</p> <p>Sometimes, my LINQ queries against this table fail with an <code>"Index was outside the range"</code> error - even the most simplest of queries. The query itself do...
[ { "answer_id": 192720, "author": "Dan Goldstein", "author_id": 23427, "author_profile": "https://Stackoverflow.com/users/23427", "pm_score": 0, "selected": false, "text": "<p>The exception occurs in a System library and your story makes me think the problem isn't in your code. Has the sc...
2008/10/10
[ "https://Stackoverflow.com/questions/191690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17803/" ]
I have a table, we'll call `Users`. This table has a single primary key defined in SQL Server - an autoincrement `int ID`. Sometimes, my LINQ queries against this table fail with an `"Index was outside the range"` error - even the most simplest of queries. The query itself doesn't use any indexers. For example: ```...
This almost certainly won't be everyone's root cause, but I encountered this exact same exception in my project - and found that the root cause was that an exception was being thrown during construction of an entity class. Oddly, the true exception is "lost" and instead manifests as an ArgumentOutOfRange exception orig...
191,692
<p>Is there a method to get all of the .aspx files in my website? Maybe iterate through the site's file structure and add to an array?</p>
[ { "answer_id": 191696, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 1, "selected": false, "text": "<p>using Directory.GetFiles(\"*.aspx\"), you can get all the files in the directory. And you can make it recursive to grab a...
2008/10/10
[ "https://Stackoverflow.com/questions/191692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
Is there a method to get all of the .aspx files in my website? Maybe iterate through the site's file structure and add to an array?
``` Directory.GetFiles(HttpContext.Current.Server.MapPath(@"/"), "*.aspx", SearchOption.AllDirectories); ```
191,697
<p>In our industrial automation application, we need to capture and display the data in the milliseconds.</p> <p>We have data binding between data grid control and a DataTable object. We have around three hundred records which needs to be display in the grid. So we update the 300 records every time we get the records....
[ { "answer_id": 191758, "author": "zendar", "author_id": 25732, "author_profile": "https://Stackoverflow.com/users/25732", "pm_score": 2, "selected": false, "text": "<p>You should seriously reconsider your user interface:</p>\n\n<ul>\n<li>Is it really necessary to display 300 values? Ordi...
2008/10/10
[ "https://Stackoverflow.com/questions/191697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In our industrial automation application, we need to capture and display the data in the milliseconds. We have data binding between data grid control and a DataTable object. We have around three hundred records which needs to be display in the grid. So we update the 300 records every time we get the records. Example...
You should seriously reconsider your user interface: * Is it really necessary to display 300 values? Ordinary human cannot concentrate on more than 7 things simultaneously, * Even if you lower number of parameters, there is frequency of refresh that seems to high to be practical. You probably should do following: * ...
191,704
<p>I want to use regular expressions (Perl compatible) to be able to find a pattern surrounded by two other patterns, but not include the strings matching the surrounding patterns in the match.</p> <p>For example, I want to be able to find occurrences of strings like:</p> <blockquote> <p>Foo Bar Baz</p> </blockquot...
[ { "answer_id": 191724, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": false, "text": "<p>Parentheses define the groupings.</p>\n\n<pre><code>\"Foo (Bar) Baz\"\n</code></pre>\n\n<p>Example</p>\n\n<pre><c...
2008/10/10
[ "https://Stackoverflow.com/questions/191704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4849/" ]
I want to use regular expressions (Perl compatible) to be able to find a pattern surrounded by two other patterns, but not include the strings matching the surrounding patterns in the match. For example, I want to be able to find occurrences of strings like: > > Foo Bar Baz > > > But only have the match include ...
In the general case, you probably can't. The simplest approach is to match everything and use backreferences to capture the portion of interest: ``` Foo\s+(Bar)\s+Baz ``` This isn't the same as not including the surrounding text in the match though. That probably doesn't matter if all you want to do is extract "Bar"...
191,732
<p>I'm passing /file:c:\myfile.doc and I'm getting back "/file:c:\myfile.doc" instead of "C:\myfile.doc", could someone please advise where I am going wrong?</p> <pre><code> if (entry.ToUpper().IndexOf("FILE") != -1) { //override default log location MyFileLocatio...
[ { "answer_id": 191743, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>You are splitting on \"=\" instead of \":\"</p>\n\n<p>Try </p>\n\n<pre><code> if (entry.ToUpper().IndexOf(\"FILE:...
2008/10/10
[ "https://Stackoverflow.com/questions/191732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm passing /file:c:\myfile.doc and I'm getting back "/file:c:\myfile.doc" instead of "C:\myfile.doc", could someone please advise where I am going wrong? ``` if (entry.ToUpper().IndexOf("FILE") != -1) { //override default log location MyFileLocation = entry.Spli...
You are splitting on "=" instead of ":" Try ``` if (entry.ToUpper().IndexOf("FILE:") == 0) { //override default log location MyFileLocation location = entry.Split(new char[] {':'},2)[1]; } ```
191,740
<p>I'm using SqlServer for the first time, and in every single one of our create procedure scripts there is a block of code like below to remove the procedure if it already exists:</p> <pre><code>IF EXISTS (SELECT * FROM information_schema.routines WHERE routine_name = 'SomeProcedureName' ...
[ { "answer_id": 191753, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p>its missing quotes, try adding them in with an exec statement.</p>\n\n<pre><code>EXEC( 'DROP PROCEDURE ''' + @procNa...
2008/10/10
[ "https://Stackoverflow.com/questions/191740", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24063/" ]
I'm using SqlServer for the first time, and in every single one of our create procedure scripts there is a block of code like below to remove the procedure if it already exists: ``` IF EXISTS (SELECT * FROM information_schema.routines WHERE routine_name = 'SomeProcedureName' AND routin...
The full answer is: ``` DECLARE @SQL VARCHAR(8000) SELECT @SQL = 'USE ' + DB_NAME() + CHAR(10) SET @SQL = @SQL + 'DROP PROCEDURE ' + @procName --PRINT @SQL EXEC(@SQL) ``` The one given by Andrew will only work if the default database for your login is set to the database you want. When using dynamic sql you get a n...
191,746
<p>Given the following HTML:</p> <pre><code>&lt;select name="my_dropdown" id="my_dropdown"&gt; &lt;option value="1"&gt;displayed text 1&lt;/option&gt; &lt;/select&gt; </code></pre> <p>How do I grab the string "displayed text 1" using Javascript/the DOM?</p>
[ { "answer_id": 191755, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 1, "selected": false, "text": "<p>The displayed text is a child node of the option node. You can use:</p>\n\n<pre><code>myOptionNode.childNodes[0]...
2008/10/10
[ "https://Stackoverflow.com/questions/191746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26848/" ]
Given the following HTML: ``` <select name="my_dropdown" id="my_dropdown"> <option value="1">displayed text 1</option> </select> ``` How do I grab the string "displayed text 1" using Javascript/the DOM?
``` var sel = document.getElementById("my_dropdown"); //get the selected option var selectedText = sel.options[sel.selectedIndex].text; //or get the first option var optionText = sel.options[0].text; //or get the option with value="1" for(var i=0; i<sel.options.length; i++){ if(sel.options[i].value == "1"){ ...
191,757
<p>I thought this would be really simple, but it's presenting some difficulties. If I have</p> <pre><code>std::string name = &quot;John&quot;; int age = 21; </code></pre> <p>How do I combine them to get a single string <code>&quot;John21&quot;</code>?</p>
[ { "answer_id": 191775, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 2, "selected": false, "text": "<p>Common Answer: <a href=\"http://www.cplusplus.com/reference/clibrary/cstdlib/itoa.html\" rel=\"nofollow noreferrer\">i...
2008/10/10
[ "https://Stackoverflow.com/questions/191757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
I thought this would be really simple, but it's presenting some difficulties. If I have ``` std::string name = "John"; int age = 21; ``` How do I combine them to get a single string `"John21"`?
In alphabetical order: ``` std::string name = "John"; int age = 21; std::string result; // 1. with Boost result = name + boost::lexical_cast<std::string>(age); // 2. with C++11 result = name + std::to_string(age); // 3. with FastFormat.Format fastformat::fmt(result, "{0}{1}", name, age); // 4. with FastFormat.Writ...
191,787
<p>I want to find a sql command or something that can do this where I have a table named tblFoo and I want to name it tblFooBar. However, I want the primary key to also be change, for example, currently it is:</p> <pre><code>CONSTRAINT [PK_tblFoo] PRIMARY KEY CLUSTERED </code></pre> <p>And I want a name change to ch...
[ { "answer_id": 191815, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 1, "selected": false, "text": "<p>SQL Server won't do this directly as far as I am aware. You would have to manually build the script ...
2008/10/10
[ "https://Stackoverflow.com/questions/191787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7952/" ]
I want to find a sql command or something that can do this where I have a table named tblFoo and I want to name it tblFooBar. However, I want the primary key to also be change, for example, currently it is: ``` CONSTRAINT [PK_tblFoo] PRIMARY KEY CLUSTERED ``` And I want a name change to change it to: ``` CONSTRAIN...
This is just off the top of my head and isn't complete (you'd need to add similar code for indexes). Also, you would need to either add code to avoid renaming objects from a table with the same base name, but additional characters - for example, this code would also list tblFoo2 and all of its associated objects. Hopef...
191,791
<p>I am hoping to find a way to do this in vb.net: </p> <p>Say you have function call getPaint(Color). You want the call to be limited to the parameter values of (red,green,yellow). When they enter that parameter, the user is provided the available options, like how a boolean parameter functions.</p> <p>Any ideas? <...
[ { "answer_id": 191811, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 2, "selected": false, "text": "<p>Hope I am not missing something from your question. Use an enumeration like this:</p>\n\n<pre><code>Enum Color\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/191791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44449/" ]
I am hoping to find a way to do this in vb.net: Say you have function call getPaint(Color). You want the call to be limited to the parameter values of (red,green,yellow). When they enter that parameter, the user is provided the available options, like how a boolean parameter functions. Any ideas?
to limit a enum with a large number of values, to just a few you could do the following C# -- ``` List<Color> allow = new List<Color> { Color.Red, Color.Green, Color.Yellow }; if (!allow.Contains(color)) { throw new ArguementException("Invalid Color"); } ``` VB -- ``` Dim allow As New List(Of Color)() allow.Ad...
191,817
<p>I'm roughing a layout together and doing some browser testing. Never came across this issue before, check out the contact form in the footer of this page</p> <p><a href="http://staging.terrilynn.com/fundraising/" rel="nofollow noreferrer"><a href="http://staging.terrilynn.com/fundraising/" rel="nofollow noreferrer"...
[ { "answer_id": 191878, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 0, "selected": false, "text": "<p>Have you tried not floating the <code>&lt;p&gt;</code> elements to the left? Why are you actually doing this? It i...
2008/10/10
[ "https://Stackoverflow.com/questions/191817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26858/" ]
I'm roughing a layout together and doing some browser testing. Never came across this issue before, check out the contact form in the footer of this page [<http://staging.terrilynn.com/fundraising/>](http://staging.terrilynn.com/fundraising/) There is a div with a width of 298px floated to the right that comes first ...
I guess I found the problem: screen.css (line 382) ``` #footer-contact-form div { margin:0 300px 10px 0; overflow:hidden; } ``` "overflow:hidden" causes the problem.
191,826
<p>I'm actually developing a Web Service in Java using Axis 2. I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions :</p> <pre><code>public class MyService { public Object myMethod() throws MyException { [...] } } </code></pre> <p>I then generated the WSDL using...
[ { "answer_id": 192363, "author": "extraneon", "author_id": 24582, "author_profile": "https://Stackoverflow.com/users/24582", "pm_score": 3, "selected": true, "text": "<p>I don't really think there is a problem. Your Client calls a method on the server. That method results in an exception...
2008/10/10
[ "https://Stackoverflow.com/questions/191826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26859/" ]
I'm actually developing a Web Service in Java using Axis 2. I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions : ``` public class MyService { public Object myMethod() throws MyException { [...] } } ``` I then generated the WSDL using Axis2 ant task. With the ...
I don't really think there is a problem. Your Client calls a method on the server. That method results in an exception. Axis transforms this exception to something which can be send to the client to indicate the error. All exceptions, as far as I know, are wrapped into an AxisFault which is then transmitted to the cli...
191,842
<p>If I have a native C++ windows program (i.e. the entry point is WinMain) how do I view output from console functions like std::cout?</p>
[ { "answer_id": 191850, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 0, "selected": false, "text": "<p>Since there's no console window, this is <strike>impossible</strike> difficult. (Learn something new every day - I ne...
2008/10/10
[ "https://Stackoverflow.com/questions/191842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23120/" ]
If I have a native C++ windows program (i.e. the entry point is WinMain) how do I view output from console functions like std::cout?
Check out [Adding Console I/O to a Win32 GUI App](http://dslweb.nwnexus.com/~ast/dload/guicon.htm). This may help you do what you want. If you don't have, or can't modify the code, try the suggestions found [here](http://support.microsoft.com/kb/110930/en-us) to redirect console output to a file. --- **Edit:** bit ...
191,844
<p>I have a Java array such as: </p> <pre><code>String[] arr = new String[] {"123","doc","projectReport.doc"}; </code></pre> <p>In my opinion the natural way to access would be: </p> <pre><code> #set($att_id = $arr[0]) #set($att_type = $arr[1]) #set($att_name = $arr[2]) </code></pre> <p>But that it is not working...
[ { "answer_id": 192018, "author": "Brian", "author_id": 8959, "author_profile": "https://Stackoverflow.com/users/8959", "pm_score": 3, "selected": false, "text": "<p>You could wrap the array in a <a href=\"http://docs.oracle.com/javase/1.5.0/docs/api/java/util/List.html\" rel=\"nofollow n...
2008/10/10
[ "https://Stackoverflow.com/questions/191844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I have a Java array such as: ``` String[] arr = new String[] {"123","doc","projectReport.doc"}; ``` In my opinion the natural way to access would be: ``` #set($att_id = $arr[0]) #set($att_type = $arr[1]) #set($att_name = $arr[2]) ``` But that it is not working. I have come with this workaround. But it a bit ...
You can use use Velocity 1.6: for an array named `$array` one can simply do `$array.get($index)`. In the upcoming Velocity 1.7, one will be able to do `$array[$index]` (as well as `$list[$index]` and `$map[$key]`).
191,845
<p>Currently, I've got images (max. 6MB) stored as BLOB in a InnoDB table. As the size of the data is growing, the nightly backup is growing slower and slower hindering normal performance.</p> <p>So, the binary data needs to go to the file system. (pointers to the files will be kept in the DB.)</p> <p>The data has a ...
[ { "answer_id": 191863, "author": "Node", "author_id": 7190, "author_profile": "https://Stackoverflow.com/users/7190", "pm_score": 6, "selected": true, "text": "<p>Just split your userid from behind. e.g.</p>\n\n<pre><code>UserID = 6435624 \nPath = /images/24/56/6435624\n</code></pre>\n\n...
2008/10/10
[ "https://Stackoverflow.com/questions/191845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22674/" ]
Currently, I've got images (max. 6MB) stored as BLOB in a InnoDB table. As the size of the data is growing, the nightly backup is growing slower and slower hindering normal performance. So, the binary data needs to go to the file system. (pointers to the files will be kept in the DB.) The data has a tree like relatio...
Just split your userid from behind. e.g. ``` UserID = 6435624 Path = /images/24/56/6435624 ``` As for the backup you could use MySQL Replication and backup the slave database to avoid problems (e.g. locks) while backuping.
191,855
<p>If I have added/removed/modified a large number of files in my local ClearCase view, how can I be certain that all the files have been added to source control?</p>
[ { "answer_id": 191857, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 3, "selected": false, "text": "<p>Use <code>cleartool ls -view_only -r</code> from the your local view VOB directory.</p>\n\n<p>To add any files recur...
2008/10/10
[ "https://Stackoverflow.com/questions/191855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9254/" ]
If I have added/removed/modified a large number of files in my local ClearCase view, how can I be certain that all the files have been added to source control?
Your answer is correct, for ***snapshot*** views (which you call 'local view' ?) In a dynamic view, a simple ``` cleartool lsprivate ``` would suffice. But that would leave out *hijacked* files (which are already added to source control, but may have been modified without ClearCase knowing it) So I would recomm...
191,879
<p>Eg.</p> <pre><code>ConnectionDetails cd = new ConnectionDetails (); cd.ProviderName = "System.Data.OleDb"; cd.DataSource = "serverAddress"; cd.Catalog = "database"; cd.UserId = "userId"; cd.Password = "password"; string connectionString = cs.CreateConnectionString(); // Should return: // "Provider=SQLOLEDB;Data So...
[ { "answer_id": 191932, "author": "harpo", "author_id": 4525, "author_profile": "https://Stackoverflow.com/users/4525", "pm_score": 2, "selected": false, "text": "<p>The closest thing I know of is <a href=\"http://msdn.microsoft.com/en-us/library/system.data.common.dbconnectionstringbuild...
2008/10/10
[ "https://Stackoverflow.com/questions/191879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9825/" ]
Eg. ``` ConnectionDetails cd = new ConnectionDetails (); cd.ProviderName = "System.Data.OleDb"; cd.DataSource = "serverAddress"; cd.Catalog = "database"; cd.UserId = "userId"; cd.Password = "password"; string connectionString = cs.CreateConnectionString(); // Should return: // "Provider=SQLOLEDB;Data Source=serverAdd...
The closest thing I know of is [DbConnectionStringBuilder](http://msdn.microsoft.com/en-us/library/system.data.common.dbconnectionstringbuilder.aspx). Because the properties required by different providers vary, it uses an associative array (name value collection) rather than fixed properties. So your example would l...
191,881
<p>I need to <a href="https://en.wikipedia.org/wiki/Serialization" rel="noreferrer">serialize</a> an object to <a href="https://www.json.org/" rel="noreferrer">JSON</a>. I'm using <a href="https://api.jquery.com/" rel="noreferrer">jQuery</a>. Is there a "standard" way to do this?</p> <p>My specific situation: I have a...
[ { "answer_id": 191911, "author": "Tahir Akhtar", "author_id": 18027, "author_profile": "https://Stackoverflow.com/users/18027", "pm_score": 6, "selected": false, "text": "<p>I haven't used it but you might want to try the <strong><a href=\"http://jollytoad.googlepages.com/json.js\" rel=\...
2008/10/10
[ "https://Stackoverflow.com/questions/191881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I need to [serialize](https://en.wikipedia.org/wiki/Serialization) an object to [JSON](https://www.json.org/). I'm using [jQuery](https://api.jquery.com/). Is there a "standard" way to do this? My specific situation: I have an array defined as shown below: ``` var countries = new Array(); countries[0] = 'ga'; countri...
[JSON-js](https://github.com/douglascrockford/JSON-js) - JSON in JavaScript. To convert an object to a string, use `JSON.stringify`: ``` var json_text = JSON.stringify(your_object, null, 2); ``` To convert a JSON string to object, use `JSON.parse`: ``` var your_object = JSON.parse(json_text); ``` It was recently...
191,883
<p>I want to be able to do the following:</p> <pre><code>$normal_array = array(); $array_of_arrayrefs = array( &amp;$normal_array ); // Here I want to access the $normal_array reference **as a reference**, // but that doesn't work obviously. How to do it? end( $array_of_arrayrefs )["one"] = 1; // choking on thi...
[ { "answer_id": 191939, "author": "Joe Scylla", "author_id": 25771, "author_profile": "https://Stackoverflow.com/users/25771", "pm_score": -1, "selected": false, "text": "<p>The line:</p>\n\n<blockquote>\n <p>end( $array_of_arrayrefs )[\"one\"] = 1; // choking on this one</p>\n</blockquo...
2008/10/10
[ "https://Stackoverflow.com/questions/191883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7891/" ]
I want to be able to do the following: ``` $normal_array = array(); $array_of_arrayrefs = array( &$normal_array ); // Here I want to access the $normal_array reference **as a reference**, // but that doesn't work obviously. How to do it? end( $array_of_arrayrefs )["one"] = 1; // choking on this one print $norm...
`end()` doesn't return a reference of the last value, but rather the last value itself. Here is a workaround: ``` $normal_array = array(); $array_of_arrayrefs = array( &$normal_array ); $refArray = &end_byref( $array_of_arrayrefs ); $refArray["one"] = 1; print $normal_array["one"]; // should output 1 function...
191,894
<p>I have the following component </p> <pre><code>public class MyTimer : IMyTimer { public MyTimer(TimeSpan timespan){...} } </code></pre> <p>Where timespan should be provided by the property ISettings.MyTimerFrequency.</p> <p>How do I wire this up in windsor container xml? I thought I could do something like this...
[ { "answer_id": 193193, "author": "RKitson", "author_id": 16947, "author_profile": "https://Stackoverflow.com/users/16947", "pm_score": 0, "selected": false, "text": "<p>Wouldn't the simplest solution be to add a method which wraps the property?</p>\n" }, { "answer_id": 197501, ...
2008/10/10
[ "https://Stackoverflow.com/questions/191894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I have the following component ``` public class MyTimer : IMyTimer { public MyTimer(TimeSpan timespan){...} } ``` Where timespan should be provided by the property ISettings.MyTimerFrequency. How do I wire this up in windsor container xml? I thought I could do something like this: ``` <component id="setting...
The solution actually came to me in a dream. Keep in mind that properties are not a CLR construct but rather C# syntactic sugar. If you don't believe me just try compiling ``` public class MyClass { public object Item { get; } public object get_Item() {return null;} } ``` results in a Error: **Type 'TestAp...
191,897
<p>I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I'm currently using SqlServer and a CTE to recursively examine all the nodes and their upstream components and this works as long as the upstream path doesn't fork alot. How...
[ { "answer_id": 191948, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 2, "selected": false, "text": "<p>Traditionally graphs are either represented by a matrix or a vector. The matrix takes more space, but is easier to ...
2008/10/10
[ "https://Stackoverflow.com/questions/191897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16623/" ]
I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I'm currently using SqlServer and a CTE to recursively examine all the nodes and their upstream components and this works as long as the upstream path doesn't fork alot. Howeve...
I know nothing about flood control facilities. But I would take the first facility. And use a temp table and a while loop to generate the path. ``` -- Pseudo Code TempTable (LastNode, CurrentNode, N) ``` DECLARE @intN INT SET @intN = 1 INSERT INTO TempTable(LastNode, CurrentNode, N) -- Insert first item in list wi...
191,923
<p>I have an XML file loaded into a DOM document, I wish to iterate through all 'foo' tags, getting values from every tag below it. I know I can get values via </p> <pre><code>$element = $dom-&gt;getElementsByTagName('foo')-&gt;item(0); foreach($element-&gt;childNodes as $node){ $data[$node-&gt;nodeName] = $node-...
[ { "answer_id": 192015, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 7, "selected": true, "text": "<p>Not tested, but what about:</p>\n\n<pre><code>$elements = $dom-&gt;getElementsByTagName('foo');\n$data = array();\nforeach($el...
2008/10/10
[ "https://Stackoverflow.com/questions/191923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4224/" ]
I have an XML file loaded into a DOM document, I wish to iterate through all 'foo' tags, getting values from every tag below it. I know I can get values via ``` $element = $dom->getElementsByTagName('foo')->item(0); foreach($element->childNodes as $node){ $data[$node->nodeName] = $node->nodeValue; } ``` Howeve...
Not tested, but what about: ``` $elements = $dom->getElementsByTagName('foo'); $data = array(); foreach($elements as $node){ foreach($node->childNodes as $child) { $data[] = array($child->nodeName => $child->nodeValue); } } ```
191,929
<p>If I were to use more than one, what order should I use modifier keywords such as:</p> <p><code>public</code>, <code>private</code>, <code>protected</code>, <code>virtual</code>, <code>abstract</code>, <code>override</code>, <code>new</code>, <code>static</code>, <code>internal</code>, <code>sealed</code>, and any ...
[ { "answer_id": 191942, "author": "Chris Charabaruk", "author_id": 5697, "author_profile": "https://Stackoverflow.com/users/5697", "pm_score": 2, "selected": false, "text": "<p>I usually start off with the access modifier first, then virtual/abstract/sealed, then override/new/etc. althoug...
2008/10/10
[ "https://Stackoverflow.com/questions/191929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
If I were to use more than one, what order should I use modifier keywords such as: `public`, `private`, `protected`, `virtual`, `abstract`, `override`, `new`, `static`, `internal`, `sealed`, and any others I'm forgetting.
I had a look at Microsoft's [Framework Design Guidelines](https://msdn.microsoft.com/en-us/library/ms229042%28v=vs.100%29) and couldn't find any references to what order modifiers should be put on members. Likewise, a look at the [C# 5.0 language specification](https://www.microsoft.com/en-gb/download/details.aspx?id=7...
191,940
<p>Is it possible to define a class in C# such that</p> <pre><code>class GenericCollection&lt;T&gt; : SomeBaseCollection&lt;T&gt; where T : Delegate </code></pre> <p>I couldn't for the life of me accomplish this last night in .NET 3.5. I tried using</p> <p><code>delegate, Delegate, Action&lt;T&gt; and Func&lt;T, T&g...
[ { "answer_id": 191949, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "<p>A number of classes are unavailable as generic contraints - Enum being another.</p>\n\n<p>For delegates, the closes...
2008/10/10
[ "https://Stackoverflow.com/questions/191940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8945/" ]
Is it possible to define a class in C# such that ``` class GenericCollection<T> : SomeBaseCollection<T> where T : Delegate ``` I couldn't for the life of me accomplish this last night in .NET 3.5. I tried using `delegate, Delegate, Action<T> and Func<T, T>` It seems to me that this should be allowable in some way....
A number of classes are unavailable as generic contraints - Enum being another. For delegates, the closest you can get is ": class", perhaps using reflection to check (for example, in the static constructor) that the T *is* a delegate: ``` static GenericCollection() { if (!typeof(T).IsSubclassOf(typeof(Delegate))...
191,950
<p>In my project I have a class that is inherited by many other classes. We'll call it ClassBase.</p> <pre><code>public class ClassInheritFromBase : ClassBase </code></pre> <p>When ClassBase is being inherited, <a href="http://en.wikipedia.org/wiki/ReSharper" rel="noreferrer">ReSharper</a> throws an "Ambiguous refere...
[ { "answer_id": 263760, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I've seen this bug in ReSharper 4.1. It happens when the base class is in the App_Code directory. I don't know how to fix i...
2008/10/10
[ "https://Stackoverflow.com/questions/191950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1215/" ]
In my project I have a class that is inherited by many other classes. We'll call it ClassBase. ``` public class ClassInheritFromBase : ClassBase ``` When ClassBase is being inherited, [ReSharper](http://en.wikipedia.org/wiki/ReSharper) throws an "Ambiguous reference" warning on the ClassBase, and anything inside the...
This is a bug in ReSharper 4.1 and is fixed in one of the later nightly builds. Download the last nightly build at <http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds>.
191,952
<p>If I have the following Linq code:</p> <pre><code>context.Table1s.InsertOnSubmit(t); context.Table1s.InsertOnSubmit(t2); context.Table1s.InsertOnSubmit(t3); context.SubmitChanges(); </code></pre> <p>And I get a database error due to the 2nd insert, Linq throws an exception that there was an error. But, is there ...
[ { "answer_id": 263760, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I've seen this bug in ReSharper 4.1. It happens when the base class is in the App_Code directory. I don't know how to fix i...
2008/10/10
[ "https://Stackoverflow.com/questions/191952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3291/" ]
If I have the following Linq code: ``` context.Table1s.InsertOnSubmit(t); context.Table1s.InsertOnSubmit(t2); context.Table1s.InsertOnSubmit(t3); context.SubmitChanges(); ``` And I get a database error due to the 2nd insert, Linq throws an exception that there was an error. But, is there a way to find out that it w...
This is a bug in ReSharper 4.1 and is fixed in one of the later nightly builds. Download the last nightly build at <http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds>.
191,955
<p>What is the correct way to do this? For example, how would I change a stored procedure with this signature:</p> <pre><code>CREATE PROCEDURE dbo.MyProcedure @Param BIT = NULL AS SELECT * FROM dbo.SomeTable T WHERE T.SomeColumn = @Param </code></pre> <p>So that giving @Param with a value of 1 or 0 performs t...
[ { "answer_id": 191971, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "<p>Assuming that NULL means \"don't care\" then use</p>\n\n<pre><code>CREATE PROCEDURE dbo.MyProcedure \n @Param BIT =...
2008/10/10
[ "https://Stackoverflow.com/questions/191955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6651/" ]
What is the correct way to do this? For example, how would I change a stored procedure with this signature: ``` CREATE PROCEDURE dbo.MyProcedure @Param BIT = NULL AS SELECT * FROM dbo.SomeTable T WHERE T.SomeColumn = @Param ``` So that giving @Param with a value of 1 or 0 performs the filter, but not specify...
Assuming that NULL means "don't care" then use ``` CREATE PROCEDURE dbo.MyProcedure @Param BIT = NULL AS SELECT * FROM dbo.SomeTable T WHERE T.SomeColumn = @Param OR @Param IS NULL ```
191,984
<p>I am writing a little application, which is writing jpeg images at a constant rate on a SD card. I choose an EXT3 filesystem, but the same behaviour was observed with an EXT2 filesystem.</p> <p>My writing loop looks like this :</p> <pre><code>get_image() fwrite() fsync() </code></pre> <p>Or like this :</p> <pre>...
[ { "answer_id": 192102, "author": "rmeador", "author_id": 10861, "author_profile": "https://Stackoverflow.com/users/10861", "pm_score": 1, "selected": false, "text": "<p>I'm not very knowledgeable in this area, but the symptoms you describe sound an awful lot like filling up a buffer. Yo...
2008/10/10
[ "https://Stackoverflow.com/questions/191984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11589/" ]
I am writing a little application, which is writing jpeg images at a constant rate on a SD card. I choose an EXT3 filesystem, but the same behaviour was observed with an EXT2 filesystem. My writing loop looks like this : ``` get_image() fwrite() fsync() ``` Or like this : ``` get_image() fopen() fwrite() fsync() ...
Is it necessary to `fsync()` after every file? You may have better luck letting the OS decide when a good time is to write out all enqueued images to the SD card (amortizing the startup cost of manipulating the SD card filesystem over many images, rather than incurring it for every image). Can you provide some more de...
191,998
<p>In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would like to step into the HttpClient code. I've downloaded the source code and tried to attach it in the normal fashion (CTRL-click on the method name and use the Attach Source button). I've tried to attach both as external file ...
[ { "answer_id": 192054, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 2, "selected": false, "text": "<p>Try attaching the src.zip instead of the unzipped src?</p>\n" }, { "answer_id": 192240, "author": "Dave Dunk...
2008/10/10
[ "https://Stackoverflow.com/questions/191998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995/" ]
In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would like to step into the HttpClient code. I've downloaded the source code and tried to attach it in the normal fashion (CTRL-click on the method name and use the Attach Source button). I've tried to attach both as external file and...
Try pointing it at a directory containing the top level package directly, "D:/Data/Download/commons-httpclient-3.1/src/java" for you. What worked for me was creating a new src zip file containing the "org" folder and everything beneath it. Here's my .classpath entry, (which works for me) in case it helps: ``` <classp...
192,028
<p>I am trying to use concat_ws inside a group_concat command. With a query, which simplified looks like: </p> <pre><code>SELECT item.title, GROUP_CONCAT( CONCAT_WS( ',', attachments.id, attachments.type, attachments.name ) ) as attachments FROM story AS item LEFT OUTER JOIN story_attachment AS attachments ON it...
[ { "answer_id": 192057, "author": "Wayne", "author_id": 8236, "author_profile": "https://Stackoverflow.com/users/8236", "pm_score": 3, "selected": true, "text": "<p>You need to cast as a char..</p>\n\n<pre><code>SELECT item.title, GROUP_CONCAT( CAST(CONCAT_WS(',', attachments.id, \nattach...
2008/10/10
[ "https://Stackoverflow.com/questions/192028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
I am trying to use concat\_ws inside a group\_concat command. With a query, which simplified looks like: ``` SELECT item.title, GROUP_CONCAT( CONCAT_WS( ',', attachments.id, attachments.type, attachments.name ) ) as attachments FROM story AS item LEFT OUTER JOIN story_attachment AS attachments ON item.id = atta...
You need to cast as a char.. ``` SELECT item.title, GROUP_CONCAT( CAST(CONCAT_WS(',', attachments.id, attachments.type, attachments.name ) as CHAR ) ) as attachments FROM story AS item LEFT OUTER JOIN story_attachment AS attachments ON item.id = attachments.item_id GROUP BY item.id ```
192,048
<p>I understand that an id must be unique within an HTML/XHTML page.</p> <p>For a given element, can I assign multiple ids to it?</p> <pre><code>&lt;div id=&quot;nested_element_123 task_123&quot;&gt;&lt;/div&gt; </code></pre> <p>I realize I have an easy solution with simply using a class. I'm just curious about using i...
[ { "answer_id": 192058, "author": "Robert K", "author_id": 24950, "author_profile": "https://Stackoverflow.com/users/24950", "pm_score": 0, "selected": false, "text": "<p>That's interesting, but as far as I know the answer is a firm no. I don't see why you need a nested ID, since you'll ...
2008/10/10
[ "https://Stackoverflow.com/questions/192048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6349/" ]
I understand that an id must be unique within an HTML/XHTML page. For a given element, can I assign multiple ids to it? ``` <div id="nested_element_123 task_123"></div> ``` I realize I have an easy solution with simply using a class. I'm just curious about using ids in this manner.
No. From the [XHTML 1.0 Spec](http://www.w3.org/TR/xhtml1/#h-4.10) > > In XML, fragment identifiers are of > type ID, and there can only be a > single attribute of type ID per > element. Therefore, in XHTML 1.0 the > id attribute is defined to be of type > ID. In order to ensure that XHTML 1.0 > documents are w...
192,073
<p>What are the differences between pipes in Windows and Linux?</p>
[ { "answer_id": 192187, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 6, "selected": true, "text": "<p>One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a dir...
2008/10/10
[ "https://Stackoverflow.com/questions/192073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
What are the differences between pipes in Windows and Linux?
One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a directory listing, they have a special type), whereas on Windows they are stored in some magical repository somewhere (they are all accessed via the path "\\.\pipe\". Secondly, in Linux you can just ...
192,077
<p>I created a simple class with a DependencyProperty. When setting the value, I observe that ValidateValueCallback is called before CoerceValueCallback.</p> <p>On <a href="http://wpftutorial.net/How+does+a+DependencyProperty+resolve+its+value.htm" rel="nofollow noreferrer">wpftutorial</a> and in other books, it is st...
[ { "answer_id": 192187, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 6, "selected": true, "text": "<p>One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a dir...
2008/10/10
[ "https://Stackoverflow.com/questions/192077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1624/" ]
I created a simple class with a DependencyProperty. When setting the value, I observe that ValidateValueCallback is called before CoerceValueCallback. On [wpftutorial](http://wpftutorial.net/How+does+a+DependencyProperty+resolve+its+value.htm) and in other books, it is stated that coercion is called before validation.
One difference that I know of, is that named pipes under Linux are actual entries in the filesystem (you'll see it in a directory listing, they have a special type), whereas on Windows they are stored in some magical repository somewhere (they are all accessed via the path "\\.\pipe\". Secondly, in Linux you can just ...
192,078
<p>Shouldn't this be a pretty straightforward operation? However, I see there's neither a <code>size()</code> nor <code>length()</code> method.</p>
[ { "answer_id": 192094, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 7, "selected": false, "text": "<pre><code>ResultSet rs = ps.executeQuery();\nint rowcount = 0;\nif (rs.last()) {\n rowcount = rs.getRow();\n rs.beforeFi...
2008/10/10
[ "https://Stackoverflow.com/questions/192078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
Shouldn't this be a pretty straightforward operation? However, I see there's neither a `size()` nor `length()` method.
Do a `SELECT COUNT(*) FROM ...` query instead. OR ``` int size =0; if (rs != null) { rs.last(); // moves cursor to the last row size = rs.getRow(); // get row id } ``` In either of the case, you won't have to loop over the entire data.
192,083
<p>We have PHP 5.2.6 deployed to c:\php and in that folder there is the php.ini file. On Windows, can a website override these settings similar to the way that apache has .htaccess? e.g.</p> <pre><code>DirectoryIndex index.php index.html &lt;IfModule mod_php5.c&gt; php_flag magic_quotes_gpc off php_flag register_glo...
[ { "answer_id": 192093, "author": "Darryl Hein", "author_id": 5441, "author_profile": "https://Stackoverflow.com/users/5441", "pm_score": 3, "selected": true, "text": "<p>I would recommend doing all you can to avoid changing r<code>egister_globals</code> to on as it's a major security hol...
2008/10/10
[ "https://Stackoverflow.com/questions/192083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
We have PHP 5.2.6 deployed to c:\php and in that folder there is the php.ini file. On Windows, can a website override these settings similar to the way that apache has .htaccess? e.g. ``` DirectoryIndex index.php index.html <IfModule mod_php5.c> php_flag magic_quotes_gpc off php_flag register_globals off </IfModule>...
I would recommend doing all you can to avoid changing r`egister_globals` to on as it's a major security hole. But you can try using `init_set()` to change the settings within your PHP code, although some settings cannot be changed once PHP has started running. (These are somewhat server dependent I believe.)
192,085
<p>I am writing a diagnostic page for SiteScope and one area we need to test is if the connection to the file/media assets are accesible from the web server. One way I think I can do this is load the image via code behind and test to see if the IIS status message is 200. </p> <p>So basically I should be able to navi...
[ { "answer_id": 192141, "author": "Greg Dean", "author_id": 1200558, "author_profile": "https://Stackoverflow.com/users/1200558", "pm_score": 7, "selected": true, "text": "<p>Just use HEAD. No need to download the entire image if you don't need it. Here some boilerplate code.</p>\n\n<pr...
2008/10/10
[ "https://Stackoverflow.com/questions/192085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/648/" ]
I am writing a diagnostic page for SiteScope and one area we need to test is if the connection to the file/media assets are accesible from the web server. One way I think I can do this is load the image via code behind and test to see if the IIS status message is 200. So basically I should be able to navigate to with...
Just use HEAD. No need to download the entire image if you don't need it. Here some boilerplate code. ``` HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url"); request.Method = "HEAD"; bool exists; try { request.GetResponse(); exists = true; } catch { exists = false; } ```
192,092
<p>When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.</p> <p>I'm currently <em>fixing</em> the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding p...
[ { "answer_id": 192112, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 2, "selected": false, "text": "<p>You can use <code>__FILE__</code> to get the full absolute path to the executing file itself:</p>\n\n<pre><code>&lt;?php\n...
2008/10/10
[ "https://Stackoverflow.com/questions/192092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314/" ]
When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue. I'm currently *fixing* the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding paths into stuff l...
``` chdir(dirname(__FILE__)); ```
192,109
<p>So what I'm looking for here is something like PHP's <a href="http://us2.php.net/print_r" rel="noreferrer">print_r</a> function.</p> <p>This is so I can debug my scripts by seeing what's the state of the object in question.</p>
[ { "answer_id": 192116, "author": "Joe Skora", "author_id": 14057, "author_profile": "https://Stackoverflow.com/users/14057", "pm_score": 5, "selected": false, "text": "<p>You can use the \"dir()\" function to do this.</p>\n\n<pre><code>&gt;&gt;&gt; import sys\n&gt;&gt;&gt; dir(sys)\n['__...
2008/10/10
[ "https://Stackoverflow.com/questions/192109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10708/" ]
So what I'm looking for here is something like PHP's [print\_r](http://us2.php.net/print_r) function. This is so I can debug my scripts by seeing what's the state of the object in question.
You are really mixing together two different things. Use [`dir()`](https://docs.python.org/3/library/functions.html#dir), [`vars()`](https://docs.python.org/3/library/functions.html#vars) or the [`inspect`](https://docs.python.org/3/library/inspect.html) module to get what you are interested in (I use `__builtins__` a...
192,111
<p>In PHP, I am able to use a normal function as a variable without problem, but I haven't figured out how to use a static method. Am I just missing the right syntax, or is this not possible?</p> <p>(EDIT: the first suggested answer does not seem to work. I've extended my example to show the errors returned.)</p> <...
[ { "answer_id": 192123, "author": "Peter Bailey", "author_id": 8815, "author_profile": "https://Stackoverflow.com/users/8815", "pm_score": 6, "selected": true, "text": "<p>PHP handles callbacks as strings, not function pointers. The reason your first test works is because the PHP interpr...
2008/10/10
[ "https://Stackoverflow.com/questions/192111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
In PHP, I am able to use a normal function as a variable without problem, but I haven't figured out how to use a static method. Am I just missing the right syntax, or is this not possible? (EDIT: the first suggested answer does not seem to work. I've extended my example to show the errors returned.) ``` function foo1...
PHP handles callbacks as strings, not function pointers. The reason your first test works is because the PHP interpreter assumes **foo1** as a string. If you have E\_NOTICE level error enabled, you should see proof of that. "Use of undefined constant foo1 - assumed 'foo1'" You can't call static methods this way, unfo...
192,121
<p>I want to use the DateTime.TryParse method to get the datetime value of a string into a Nullable. But when I try this:</p> <pre><code>DateTime? d; bool success = DateTime.TryParse("some date text", out (DateTime)d); </code></pre> <p>the compiler tells me </p> <blockquote> <p>'out' argument is not classified as...
[ { "answer_id": 192146, "author": "Jason Kealey", "author_id": 20893, "author_profile": "https://Stackoverflow.com/users/20893", "pm_score": 8, "selected": true, "text": "<pre><code>DateTime? d=null;\nDateTime d2;\nbool success = DateTime.TryParse(\"some date text\", out d2);\nif (success...
2008/10/10
[ "https://Stackoverflow.com/questions/192121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767/" ]
I want to use the DateTime.TryParse method to get the datetime value of a string into a Nullable. But when I try this: ``` DateTime? d; bool success = DateTime.TryParse("some date text", out (DateTime)d); ``` the compiler tells me > > 'out' argument is not classified as a variable > > > Not sure what I need t...
``` DateTime? d=null; DateTime d2; bool success = DateTime.TryParse("some date text", out d2); if (success) d=d2; ``` (There might be more elegant solutions, but why don't you simply do something as above?)
192,122
<p>This may seem a bit trivial, but I have not been able to figure it out. I am opening up a SPSite and then trying to open up a SPWeb under that SPSite. This is working fine on the VPC, which has the same Site Collection/Site hierarchy, but on production, I get an exception telling me that the URL is invalid when I ...
[ { "answer_id": 192611, "author": "Eugene Katz", "author_id": 1533, "author_profile": "https://Stackoverflow.com/users/1533", "pm_score": 3, "selected": true, "text": "<p>Looks at the examples table at the bottom of <a href=\"http://msdn.microsoft.com/en-us/library/ms955307.aspx\" rel=\"n...
2008/10/10
[ "https://Stackoverflow.com/questions/192122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22426/" ]
This may seem a bit trivial, but I have not been able to figure it out. I am opening up a SPSite and then trying to open up a SPWeb under that SPSite. This is working fine on the VPC, which has the same Site Collection/Site hierarchy, but on production, I get an exception telling me that the URL is invalid when I try t...
Looks at the examples table at the bottom of [this page](http://msdn.microsoft.com/en-us/library/ms955307.aspx). Try not sending any parameters into the OpenWeb() method (2nd row).
192,124
<p>I need specifically to load a JPG image that was saved as a blob. GDI+ makes it very easy to retrieve images from files but not from databases...</p>
[ { "answer_id": 192139, "author": "Jason Kealey", "author_id": 20893, "author_profile": "https://Stackoverflow.com/users/20893", "pm_score": 0, "selected": false, "text": "<p>First fetch your blog into a byte array then use something like this:</p>\n\n<pre><code>public static Image Create...
2008/10/10
[ "https://Stackoverflow.com/questions/192124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4880/" ]
I need specifically to load a JPG image that was saved as a blob. GDI+ makes it very easy to retrieve images from files but not from databases...
Take a look at [Image::Image(IStream \*, BOOL)](http://msdn.microsoft.com/en-us/library/ms535410(VS.85).aspx). This takes a pointer to a COM object implementing the IStream interface. You can get one of these by allocating some global memory with [GlobalAlloc](http://msdn.microsoft.com/en-us/library/aa366574(VS.85).asp...
192,126
<p>I have a method that needs to accept an array of country names, and return a list of records that match one of those country names. I'm trying this</p> <pre><code>Public Shared Function GetConcessions(ByVal Countries As String()) As IEnumerable Dim CountryList As String = Utility.JoinArray(Countries) ' turns st...
[ { "answer_id": 192167, "author": "sepang", "author_id": 25930, "author_profile": "https://Stackoverflow.com/users/25930", "pm_score": 3, "selected": false, "text": "<p>You can use SqlMethods.Like </p>\n\n<p>e.g. </p>\n\n<pre><code>Where SqlMethods.Like(t.country, \"%Sweden%\")\n</code></...
2008/10/10
[ "https://Stackoverflow.com/questions/192126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I have a method that needs to accept an array of country names, and return a list of records that match one of those country names. I'm trying this ``` Public Shared Function GetConcessions(ByVal Countries As String()) As IEnumerable Dim CountryList As String = Utility.JoinArray(Countries) ' turns string array int...
I think what you want to do is construct a List from Countries and use ``` List<string> ListOfCountries = new List(Countries) ...ListOfCountries.Contains(t.Country) ``` This would translate into ``` t.Country IN ('yyy','zzz',...) ``` Please excuse my C#-ishness..
192,128
<p>I am working on an Actionscript 2 project - trying to use the XML object to find a url which is returned as a 302 redirect. Is there a way to do this in actionscript 2?</p> <p>code:</p> <pre><code>var urlone:XML = new XML(); urlone.load("http://mydomain.com/file.py"); urlone.onLoad = function (success) { trac...
[ { "answer_id": 192167, "author": "sepang", "author_id": 25930, "author_profile": "https://Stackoverflow.com/users/25930", "pm_score": 3, "selected": false, "text": "<p>You can use SqlMethods.Like </p>\n\n<p>e.g. </p>\n\n<pre><code>Where SqlMethods.Like(t.country, \"%Sweden%\")\n</code></...
2008/10/10
[ "https://Stackoverflow.com/questions/192128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26888/" ]
I am working on an Actionscript 2 project - trying to use the XML object to find a url which is returned as a 302 redirect. Is there a way to do this in actionscript 2? code: ``` var urlone:XML = new XML(); urlone.load("http://mydomain.com/file.py"); urlone.onLoad = function (success) { trace("I want to print the...
I think what you want to do is construct a List from Countries and use ``` List<string> ListOfCountries = new List(Countries) ...ListOfCountries.Contains(t.Country) ``` This would translate into ``` t.Country IN ('yyy','zzz',...) ``` Please excuse my C#-ishness..
192,134
<p>I have to check some code and run it. I have the URL:</p> <pre><code>svn+ssh://myuser@www.myclient.com/home/svn/project/trunk </code></pre> <p>I have a file with their private key. What do I do to get this code?</p>
[ { "answer_id": 192186, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 1, "selected": false, "text": "<p>Add the private key to your <code>~/.ssh/</code> folder and then run <code>ssh-agent $SHELL; ssh-add;</code>, and the...
2008/10/10
[ "https://Stackoverflow.com/questions/192134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
I have to check some code and run it. I have the URL: ``` svn+ssh://myuser@www.myclient.com/home/svn/project/trunk ``` I have a file with their private key. What do I do to get this code?
The private key goes on the client machine, often named as `~/.ssh/id_rsa`, `~/.ssh/id_dsa`, or `~/.ssh/identity` depending on the SSH version and the type of key. However, you can just use `ssh -i path/to/private.key`. This is presuming that the corresponding public key exists on the server in `~/.ssh/authorized_keys...
192,153
<p>I would like to access the Rails session secret programmatically (I am using it to generate a sign-on token).</p> <p>Here's what I've come up with:</p> <pre><code>ActionController::Base.session.first[:secret] </code></pre> <p>This returns the session secret. However, every time you call ActionController::Base.ses...
[ { "answer_id": 192270, "author": "whoisjake", "author_id": 2609, "author_profile": "https://Stackoverflow.com/users/2609", "pm_score": 3, "selected": true, "text": "<pre><code>ActionController::Base.session_options_for(request,params[:action])[:secret]\n</code></pre>\n" }, { "ans...
2008/10/10
[ "https://Stackoverflow.com/questions/192153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17965/" ]
I would like to access the Rails session secret programmatically (I am using it to generate a sign-on token). Here's what I've come up with: ``` ActionController::Base.session.first[:secret] ``` This returns the session secret. However, every time you call ActionController::Base.session it adds another entry to an ...
``` ActionController::Base.session_options_for(request,params[:action])[:secret] ```
192,200
<p>I have to do a cross site POST (with a redirection, so not using a XMLHTTPRequest), and the base platform is ASP.NET. I don't want to POST all of the controls in the ASP.NET FORM to this other site, so I was considering dynamicly creating a new form element using javascript and just posting that.</p> <p>Has anyone ...
[ { "answer_id": 192212, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I do this all the time. Works really well. You will have to look through the Request's parameters manually, though...
2008/10/10
[ "https://Stackoverflow.com/questions/192200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I have to do a cross site POST (with a redirection, so not using a XMLHTTPRequest), and the base platform is ASP.NET. I don't want to POST all of the controls in the ASP.NET FORM to this other site, so I was considering dynamicly creating a new form element using javascript and just posting that. Has anyone tried this...
I do this all the time. Works really well. You will have to look through the Request's parameters manually, though, unless you get creative with what you pass as the parameters won't map onto controls on that page. You could also do this in a REST way by passing the parameters in the query string, but I prefer the form...
192,203
<p>How do I do this</p> <pre><code>Select top 10 Foo from MyTable </code></pre> <p>in Linq to SQL?</p>
[ { "answer_id": 192209, "author": "David Alpert", "author_id": 8997, "author_profile": "https://Stackoverflow.com/users/8997", "pm_score": 8, "selected": true, "text": "<p>In VB:</p>\n\n<pre><code>from m in MyTable\ntake 10\nselect m.Foo\n</code></pre>\n\n<p>This assumes that MyTable impl...
2008/10/10
[ "https://Stackoverflow.com/questions/192203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
How do I do this ``` Select top 10 Foo from MyTable ``` in Linq to SQL?
In VB: ``` from m in MyTable take 10 select m.Foo ``` This assumes that MyTable implements IQueryable. You may have to access that through a DataContext or some other provider. It also assumes that Foo is a column in MyTable that gets mapped to a property name. See <http://blogs.msdn.com/vbteam/archive/2008/01/08/...
192,213
<p>This is the SQL that I want to accomplish:</p> <pre><code>WHERE domain_nm + '\' + group_nm in ('DOMAINNAME\USERNAME1','DOMAINNAME2\USERNAME2') </code></pre> <p>I can't for the life of me find an appropriate Expression for this. And I don't think I can use two expressions as the domain name and the group name need...
[ { "answer_id": 214260, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 2, "selected": false, "text": "<p>Can you not use two Expressions?</p>\n\n<pre><code>criteria\n .Add(Expression.In(\"DomainName\", new string[] { \"D...
2008/10/10
[ "https://Stackoverflow.com/questions/192213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26896/" ]
This is the SQL that I want to accomplish: ``` WHERE domain_nm + '\' + group_nm in ('DOMAINNAME\USERNAME1','DOMAINNAME2\USERNAME2') ``` I can't for the life of me find an appropriate Expression for this. And I don't think I can use two expressions as the domain name and the group name need to be concatenated. Than...
Can you not use two Expressions? ``` criteria .Add(Expression.In("DomainName", new string[] { "DOMAINNAME", "DOMAINNAME2" })) .Add(Expression.In("GroupName", new string[] { "USERNAME1", "USERNAME2" }) ``` The other option is to use Expression.Sql.
192,220
<p>Assume you have a flat table that stores an ordered tree hierarchy:</p> <pre><code>Id Name ParentId Order 1 'Node 1' 0 10 2 'Node 1.1' 1 10 3 'Node 2' 0 20 4 'Node 1.1.1' 2 10 5 'Node 2.1' 3 10 6 'Node 1.2' ...
[ { "answer_id": 192252, "author": "wcm", "author_id": 2173, "author_profile": "https://Stackoverflow.com/users/2173", "pm_score": 2, "selected": false, "text": "<p>Assuming that you know that the root elements are zero, here's the pseudocode to output to text:</p>\n\n<pre><code>function P...
2008/10/10
[ "https://Stackoverflow.com/questions/192220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18771/" ]
Assume you have a flat table that stores an ordered tree hierarchy: ``` Id Name ParentId Order 1 'Node 1' 0 10 2 'Node 1.1' 1 10 3 'Node 2' 0 20 4 'Node 1.1.1' 2 10 5 'Node 2.1' 3 10 6 'Node 1.2' 1 20 `...
Now that [MySQL 8.0 supports recursive queries](https://dev.mysql.com/doc/refman/8.0/en/with.html), we can say that [all popular SQL databases support recursive queries](https://stackoverflow.com/questions/324935/mysql-with-clause/325243#325243) in standard syntax. ``` WITH RECURSIVE MyTree AS ( SELECT * FROM MyTa...
192,228
<p>I'm not much of a coder, but I need to write a simple <em>preg_replace</em> statement in PHP that will help me with a WordPress plugin. Basically, I need some code that will search for a string, pull out the video ID, and return the embed code with the video id inserted into it. </p> <p>In other words, I'm search...
[ { "answer_id": 192239, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<pre><code>$str = preg_replace('/\\[youtube=.*?v=([a-z0-9_-]+?)&amp;.*?\\]/i', 'param name=\"movie\" value=\"http://www.youtu...
2008/10/10
[ "https://Stackoverflow.com/questions/192228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm not much of a coder, but I need to write a simple *preg\_replace* statement in PHP that will help me with a WordPress plugin. Basically, I need some code that will search for a string, pull out the video ID, and return the embed code with the video id inserted into it. In other words, I'm searching for this: ``...
BE CAREFUL! If this is a BBCode-style system with user input, these other two solutions would leave you vulnerable to XSS attacks. You have several ways to protect yourself against this. Have the regex explicitly disallow the characters that could get you in trouble (or, allow only those valid for a youtube video id)...
192,241
<p>Good morning everyone, </p> <p>I'm running into an issue using a SharePoint workflow project (C#, VS 2008) and connecting to a database. Here is my database connection string:</p> <pre><code>Data Source=DBSERVER;Initial Catalog=DBNAME;Integrated Security=True; </code></pre> <p>When I attempt to run the followi...
[ { "answer_id": 193964, "author": "Nico", "author_id": 22970, "author_profile": "https://Stackoverflow.com/users/22970", "pm_score": 1, "selected": false, "text": "<p>Are the web front end and the SQL server on the same box ?</p>\n\n<p>If not, you'll have to set up Kerberos to allow crede...
2008/10/10
[ "https://Stackoverflow.com/questions/192241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Good morning everyone, I'm running into an issue using a SharePoint workflow project (C#, VS 2008) and connecting to a database. Here is my database connection string: ``` Data Source=DBSERVER;Initial Catalog=DBNAME;Integrated Security=True; ``` When I attempt to run the following code I get the following error...
Any DB access should run as a Windows Service account for security and connection pooling reasons. Regarding the Workflow Security Context, see: SharePoint, Workflows and Security <http://cglessner.blogspot.com/2008/09/sharepoint-workflows-and-security.html> Declarative Workflows and User Context <http://blogs.msdn...
192,249
<p>Say, I have a script that gets called with this line:</p> <pre><code>./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile </code></pre> <p>or this one:</p> <pre><code>./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile </code></pre> <p>What's the accepted way of parsing this such that in each case (o...
[ { "answer_id": 192266, "author": "Matt J", "author_id": 18528, "author_profile": "https://Stackoverflow.com/users/18528", "pm_score": 7, "selected": false, "text": "<p><code>getopt()</code>/<code>getopts()</code> is a good option. Copied from <a href=\"http://aplawrence.com/Unix/getopts...
2008/10/10
[ "https://Stackoverflow.com/questions/192249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
Say, I have a script that gets called with this line: ``` ./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile ``` or this one: ``` ./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile ``` What's the accepted way of parsing this such that in each case (or some combination of the two) `$v`, `$f`, an...
#### Bash Space-Separated (e.g., `--option argument`) ```sh cat >/tmp/demo-space-separated.sh <<'EOF' #!/bin/bash POSITIONAL_ARGS=() while [[ $# -gt 0 ]]; do case $1 in -e|--extension) EXTENSION="$2" shift # past argument shift # past value ;; -s|--searchpath) SEARCHPATH="$2" ...
192,256
<p>What would be the best method to implement extra functionality in a database layer that uses Linq-to-SQL? Currently I'm looking at implementing functions for adding information based on presets and similar tasks?</p> <p>Inserts, updates and deletes requires access to the <code>DataContext</code> and in the <code>Ta...
[ { "answer_id": 192338, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I hate to say it, but what about stored procedures? </p>\n\n<p>On my project, whatever extra functionality we want to prov...
2008/10/10
[ "https://Stackoverflow.com/questions/192256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26746/" ]
What would be the best method to implement extra functionality in a database layer that uses Linq-to-SQL? Currently I'm looking at implementing functions for adding information based on presets and similar tasks? Inserts, updates and deletes requires access to the `DataContext` and in the `Table` classes you don't hav...
Entity classes in Linq to SQL are partial. You could extend them with the rules you need. Or you could build your own business entities from the Linq to SQL entities. Your business entities would then contain the rules on when to do what.
192,260
<p>I am currently working on a website to track projects. In it, it is possible to create Service Level Agreements (SLAs). These are configurable with days of the week that a project can be worked on and also the timespan on each of those days. Eg. on Monday it might be between 08:00 and 16:00 and then on friday from 1...
[ { "answer_id": 192307, "author": "Ian Jacobs", "author_id": 22818, "author_profile": "https://Stackoverflow.com/users/22818", "pm_score": 1, "selected": false, "text": "<p>There's a recursive solution that could work, try thinking along these lines:</p>\n\n<pre><code>public DateTime getD...
2008/10/10
[ "https://Stackoverflow.com/questions/192260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26841/" ]
I am currently working on a website to track projects. In it, it is possible to create Service Level Agreements (SLAs). These are configurable with days of the week that a project can be worked on and also the timespan on each of those days. Eg. on Monday it might be between 08:00 and 16:00 and then on friday from 10:0...
Here's some C# code which might help, it could be much cleaner, but it's a quick first draft. ``` class Program { static void Main(string[] args) { // Test DateTime deadline = DeadlineManager.CalculateDeadline(DateTime.Now, new TimeSpan(4, 0, 0)); Console.Wri...
192,261
<p>Using something like this:</p> <pre><code>try: # Something... except Exception as excep: logger = logging.getLogger("component") logger.warning("something raised an exception: " + excep) logger.info("something raised an exception: " + excep) </code></pre> <p>I would rather not have it on the error-leve...
[ { "answer_id": 193153, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 8, "selected": true, "text": "<p>From the <a href=\"http://docs.python.org/library/logging.html#logging.Logger.debug\" rel=\"noreferrer\">logging do...
2008/10/10
[ "https://Stackoverflow.com/questions/192261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26905/" ]
Using something like this: ``` try: # Something... except Exception as excep: logger = logging.getLogger("component") logger.warning("something raised an exception: " + excep) logger.info("something raised an exception: " + excep) ``` I would rather not have it on the error-level cause in my special case...
From the [logging documentation](http://docs.python.org/library/logging.html#logging.Logger.debug): > > There are three keyword arguments in `kwargs` which are inspected: `exc_info`, `stack_info`, and `extra`. > > > If `exc_info` does not evaluate as false, it causes exception information to be added to the logging...
192,264
<p>I have a page that is hitting a webservice every 5 seconds to update the information on the page. I'm using the DynamicPopulateExtender from the Ajax Control Toolkit to just populate a panel with some text.</p> <p>What I was wanting to do, is if a certain condition is met, to refresh the page completely. </p> <p>A...
[ { "answer_id": 192316, "author": "Jason Kealey", "author_id": 20893, "author_profile": "https://Stackoverflow.com/users/20893", "pm_score": 3, "selected": true, "text": "<ul>\n<li>You can't do anything from your ASMX.</li>\n<li>You can refresh the page from JavaScript by using a conventi...
2008/10/10
[ "https://Stackoverflow.com/questions/192264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
I have a page that is hitting a webservice every 5 seconds to update the information on the page. I'm using the DynamicPopulateExtender from the Ajax Control Toolkit to just populate a panel with some text. What I was wanting to do, is if a certain condition is met, to refresh the page completely. Am I going to be a...
* You can't do anything from your ASMX. * You can refresh the page from JavaScript by using a conventional page reload or by doing a postback that would perform server-side changes and then update via your UpdatePanel or, more simply, a Response.Redirect.
192,292
<p>The way you would normally include a script is with "source"</p> <p>eg:</p> <p>main.sh:</p> <pre><code>#!/bin/bash source incl.sh echo "The main script" </code></pre> <p>incl.sh:</p> <pre><code>echo "The included script" </code></pre> <p>The output of executing "./main.sh" is:</p> <pre><code>The included sc...
[ { "answer_id": 192305, "author": "Chris Boran", "author_id": 25660, "author_profile": "https://Stackoverflow.com/users/25660", "pm_score": 9, "selected": true, "text": "<p>I tend to make my scripts all be relative to one another. \nThat way I can use dirname:</p>\n\n<pre><code>#!/bin/sh\...
2008/10/10
[ "https://Stackoverflow.com/questions/192292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16258/" ]
The way you would normally include a script is with "source" eg: main.sh: ``` #!/bin/bash source incl.sh echo "The main script" ``` incl.sh: ``` echo "The included script" ``` The output of executing "./main.sh" is: ``` The included script The main script ``` ... Now, if you attempt to execute that shell s...
I tend to make my scripts all be relative to one another. That way I can use dirname: ``` #!/bin/sh my_dir="$(dirname "$0")" "$my_dir/other_script.sh" ```
192,319
<p>How can I determine the name of the Bash script file inside the script itself?</p> <p>Like if my script is in file <code>runme.sh</code>, then how would I make it to display "You are running runme.sh" message without hardcoding that?</p>
[ { "answer_id": 192337, "author": "Tanktalus", "author_id": 23512, "author_profile": "https://Stackoverflow.com/users/23512", "pm_score": 11, "selected": true, "text": "<pre><code>me=`basename \"$0\"`\n</code></pre>\n\n<p>For reading through a symlink<sup>1</sup>, which is usually not wha...
2008/10/10
[ "https://Stackoverflow.com/questions/192319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20390/" ]
How can I determine the name of the Bash script file inside the script itself? Like if my script is in file `runme.sh`, then how would I make it to display "You are running runme.sh" message without hardcoding that?
``` me=`basename "$0"` ``` For reading through a symlink1, which is usually not what you want (you usually don't want to confuse the user this way), try: ``` me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" ``` IMO, that'll produce confusing output. "I ran foo.sh, but it's saying I'm running bar.sh...
192,329
<p>I have boiled down an issue I'm seeing in one of my applications to an incredibly simple reproduction sample. I need to know if there's something amiss or something I'm missing.</p> <p>Anyway, below is the code. The behavior is that the code runs and steadily grows in memory until it crashes with an OutOfMemoryExce...
[ { "answer_id": 192421, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 0, "selected": false, "text": "<p><strong>Edit 2:</strong> Obviously not the answer, but was part of the back-and-forth among answers and comments he...
2008/10/10
[ "https://Stackoverflow.com/questions/192329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13322/" ]
I have boiled down an issue I'm seeing in one of my applications to an incredibly simple reproduction sample. I need to know if there's something amiss or something I'm missing. Anyway, below is the code. The behavior is that the code runs and steadily grows in memory until it crashes with an OutOfMemoryException. Tha...
I was able to reproduce your problem using the code you provided. Memory keeps growing because the Canvas objects are never released; a memory profiler indicates that the Dispatcher's ContextLayoutManager is holding on to them all (so that it can invoke OnRenderSizeChanged when necessary). It seems that a simple worka...
192,332
<p>What I am looking for is a way to call a method after another method has been invoked but before it is entered. Example:</p> <pre><code>public class Test { public void Tracer ( ... ) { } public int SomeFunction( string str ) { return 0; } public void TestFun() { SomeFunction( "" ); } }...
[ { "answer_id": 192355, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 2, "selected": false, "text": "<p>Use a *Core method:</p>\n\n<pre><code>public int SomeFunction(string str)\n{\n Tracer();\n return SomeFunctionCore...
2008/10/10
[ "https://Stackoverflow.com/questions/192332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2415/" ]
What I am looking for is a way to call a method after another method has been invoked but before it is entered. Example: ``` public class Test { public void Tracer ( ... ) { } public int SomeFunction( string str ) { return 0; } public void TestFun() { SomeFunction( "" ); } } ``` In the ...
You can use a dynamic proxy ([Castle's DynamicProxy](http://www.castleproject.org/dynamicproxy/index.html) for example) to intercept the call, run whatever code you wish, and then either invoke your method or not, depending on your needs.
192,366
<p>Is it possible to grab activedirectory credentials for the user on a client machine from within a web application?</p> <p>To clarify, I am designing a web application which will be hosted on a client's intranet. </p> <p>There is a requirement that the a user of the application not be prompted for credentials when...
[ { "answer_id": 192405, "author": "Simurr", "author_id": 3478, "author_profile": "https://Stackoverflow.com/users/3478", "pm_score": 1, "selected": false, "text": "<p>Maybe .NET has a more direct way to do it, but with PHP I just access our Active Directory server as an LDAP server.</p>\n...
2008/10/10
[ "https://Stackoverflow.com/questions/192366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26527/" ]
Is it possible to grab activedirectory credentials for the user on a client machine from within a web application? To clarify, I am designing a web application which will be hosted on a client's intranet. There is a requirement that the a user of the application not be prompted for credentials when accessing the app...
Absolutely. This is especially useful for intranet applications. Since you did not specify your environment, I'll assume it is .NET, but that isn't the only way possible of course. Active Directory can be queried easily using [LDAP](http://en.wikipedia.org/wiki/LDAP). If you're using .NET, you can do something like i...
192,367
<p>I have the following two models:</p> <pre><code>class Activity(models.Model): name = models.CharField(max_length=50, help_text='Some help.') entity = models.ForeignKey(CancellationEntity) ... class Cancellation(models.Model): activity = models.ForeignKey(Activity) date = models.DateField(defau...
[ { "answer_id": 192525, "author": "willurd", "author_id": 1943957, "author_profile": "https://Stackoverflow.com/users/1943957", "pm_score": 5, "selected": true, "text": "<p>What you want to look into is <a href=\"http://docs.djangoproject.com/en/dev/ref/signals/\" rel=\"noreferrer\">Djang...
2008/10/10
[ "https://Stackoverflow.com/questions/192367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10825/" ]
I have the following two models: ``` class Activity(models.Model): name = models.CharField(max_length=50, help_text='Some help.') entity = models.ForeignKey(CancellationEntity) ... class Cancellation(models.Model): activity = models.ForeignKey(Activity) date = models.DateField(default=datetime.now...
What you want to look into is [Django's signals](http://docs.djangoproject.com/en/dev/ref/signals/) (check out [this page](http://docs.djangoproject.com/en/dev/topics/signals/) too), specifically the model signals--more specifically, the **post\_save** signal. Signals are Django's version of a plugin/hook system. The p...
192,375
<p>When using <code>before_filter :login_required</code> to protect a particular page, the <code>link_to_unless_current</code> method in the application layout template renders the "Login" link for the login page as a hyperlink instead of just text.</p> <p>The "Login" text/link problem only occurs when redirected to t...
[ { "answer_id": 198104, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Appreciate the responses and you can tell by the nature of the question that we're new to rails. By the way, we posted the ...
2008/10/10
[ "https://Stackoverflow.com/questions/192375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When using `before_filter :login_required` to protect a particular page, the `link_to_unless_current` method in the application layout template renders the "Login" link for the login page as a hyperlink instead of just text. The "Login" text/link problem only occurs when redirected to the Login Page via the `before_fi...
You can use a route helper method to perform the page redirection: ``` redirect_to login_url ``` If a "named route" for login is defined (which is done by adding an explicit path to "/login" in your "config/routes.rb" file). This path is actually the same as that generated by: new\_session\_url For a detailed lo...
192,398
<p>I am selecting from a table that has an XML column using T-SQL. I would like to select a certain type of node and have a row created for each one.</p> <p>For instance, suppose I am selecting from a <em>people</em> table. This table has an XML column for <em>addresses</em>. The XML is formated similar to the followi...
[ { "answer_id": 192445, "author": "Wyatt", "author_id": 26626, "author_profile": "https://Stackoverflow.com/users/26626", "pm_score": -1, "selected": false, "text": "<p>If you can use it, the linq api is convenient for XML:</p>\n\n<pre><code>var addresses = dataContext.People.Addresses\n ...
2008/10/10
[ "https://Stackoverflow.com/questions/192398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3645/" ]
I am selecting from a table that has an XML column using T-SQL. I would like to select a certain type of node and have a row created for each one. For instance, suppose I am selecting from a *people* table. This table has an XML column for *addresses*. The XML is formated similar to the following: ``` <address> <st...
Here is your solution: ``` /* TEST TABLE */ DECLARE @PEOPLE AS TABLE ([Name] VARCHAR(20), [Address] XML ) INSERT INTO @PEOPLE SELECT 'Joel', '<address> <street>Street 1</street> <city>City 1</city> <state>State 1</state> <zipcode>Zip Code 1</zipcode> </address> <address> ...
192,413
<p>I have a RichTextBox where I need to update the Text property frequently, but when I do so the RichTextBox "blinks" annoyingly as it refreshes all throughout a method call.</p> <p>I was hoping to find an easy way to temporarily suppress the screen refresh until my method is done, but the only thing I've found on th...
[ { "answer_id": 192423, "author": "BKimmel", "author_id": 13776, "author_profile": "https://Stackoverflow.com/users/13776", "pm_score": -1, "selected": false, "text": "<p>Try this out:</p>\n\n<pre><code>myRichTextBox.SuspendLayout();\nDoStuff();\nmyRichTextBox.ResumeLayout();\n</code></pr...
2008/10/10
[ "https://Stackoverflow.com/questions/192413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a RichTextBox where I need to update the Text property frequently, but when I do so the RichTextBox "blinks" annoyingly as it refreshes all throughout a method call. I was hoping to find an easy way to temporarily suppress the screen refresh until my method is done, but the only thing I've found on the web is t...
I asked the original question, and the answer that worked best for me was BoltBait's use of SendMessage() with WM\_SETREDRAW. It seems to have fewer side effects than the use of the WndProc method, and in my application performs twice as fast as LockWindowUpdate. Within my extended RichTextBox class, I just added the...
192,432
<p>I've tried to use the new <a href="http://groovy.codehaus.org/Grape" rel="noreferrer">Groovy Grape</a> capability in Groovy 1.6-beta-2 but I get an error message;</p> <pre><code>unable to resolve class com.jidesoft.swing.JideSplitButton </code></pre> <p>from the Groovy Console (/opt/groovy/groovy-1.6-beta-2/bin/gr...
[ { "answer_id": 194403, "author": "shemnon", "author_id": 8020, "author_profile": "https://Stackoverflow.com/users/8020", "pm_score": 4, "selected": true, "text": "<p>There is still some kinks in working out the startup/kill switch routine. For Beta-2 do this in it's own script first:</p...
2008/10/10
[ "https://Stackoverflow.com/questions/192432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6580/" ]
I've tried to use the new [Groovy Grape](http://groovy.codehaus.org/Grape) capability in Groovy 1.6-beta-2 but I get an error message; ``` unable to resolve class com.jidesoft.swing.JideSplitButton ``` from the Groovy Console (/opt/groovy/groovy-1.6-beta-2/bin/groovyConsole) when running the stock example; ``` impo...
There is still some kinks in working out the startup/kill switch routine. For Beta-2 do this in it's own script first: ``` groovy.grape.Grape.initGrape() ``` Another issue you will run into deals with the joys of using an unbounded upper range. Jide-oss from 2.3.0 onward has been compiling their code to Java 6 bytec...
192,454
<p>I have TortoiseSVN set up to use KDiff3 as the conflict resolution tool (I find it shows more information useful to the merge than the built-in TortoiseMerge does).</p> <p>When I open a file with Tortoise's "Edit Conflicts" command it shows me the three files and I have to select "Merge->Merge Current File" manuall...
[ { "answer_id": 192558, "author": "Owen", "author_id": 4790, "author_profile": "https://Stackoverflow.com/users/4790", "pm_score": 3, "selected": false, "text": "<p>Turns out I just needed a more specific command line. I had it set simply to the path to <code>kdiff3.exe</code>, and hoped ...
2008/10/10
[ "https://Stackoverflow.com/questions/192454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
I have TortoiseSVN set up to use KDiff3 as the conflict resolution tool (I find it shows more information useful to the merge than the built-in TortoiseMerge does). When I open a file with Tortoise's "Edit Conflicts" command it shows me the three files and I have to select "Merge->Merge Current File" manually. The pro...
Mine is a bit longer: ``` "C:\Program Files\KDiff3\kdiff3.exe" %base %mine %theirs -o %merged --L1 Base --L2 Mine --L3 Theirs ```
192,456
<p>I would like to set the log file name for a log4j and log4net appender to have the current date. We are doing Daily rollovers but the current log file does not have a date. The log file name format would be </p> <pre><code>logname.2008-10-10.log </code></pre> <p>Anyone know the best way for me to do this?</p> <...
[ { "answer_id": 192548, "author": "gedevan", "author_id": 20225, "author_profile": "https://Stackoverflow.com/users/20225", "pm_score": 7, "selected": true, "text": "<p>DailyRollingFileAppender is what you exactly searching for.</p>\n\n<pre><code>&lt;appender name=\"roll\" class=\"org.apa...
2008/10/10
[ "https://Stackoverflow.com/questions/192456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387361/" ]
I would like to set the log file name for a log4j and log4net appender to have the current date. We are doing Daily rollovers but the current log file does not have a date. The log file name format would be ``` logname.2008-10-10.log ``` Anyone know the best way for me to do this? edit: I forgot to mention that we...
DailyRollingFileAppender is what you exactly searching for. ``` <appender name="roll" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="application.log" /> <param name="DatePattern" value=".yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="Convers...
192,539
<p>I have a .NET application that processes around 300,000 records in a batch import, and it takes a few seconds per record so I would like to parallelize this. In the following code, what's the difference between <code>ProcessWithAnsycDelegates()</code> and <code>ProcessWithThreadPool()</code>?</p> <pre><code>public ...
[ { "answer_id": 192580, "author": "chadmyers", "author_id": 10862, "author_profile": "https://Stackoverflow.com/users/10862", "pm_score": 4, "selected": true, "text": "<p>In this case, not a lot as they both use the threadpool under the hood. I'd say that the <code>QueueUserWorkItem()</co...
2008/10/10
[ "https://Stackoverflow.com/questions/192539", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1659/" ]
I have a .NET application that processes around 300,000 records in a batch import, and it takes a few seconds per record so I would like to parallelize this. In the following code, what's the difference between `ProcessWithAnsycDelegates()` and `ProcessWithThreadPool()`? ``` public class ResultNotification { public E...
In this case, not a lot as they both use the threadpool under the hood. I'd say that the `QueueUserWorkItem()` is easier to read and see what's going on vs. `BeginInvoke()`. This link may help. It's older information, but still mostly applicable: <https://jonskeet.uk/csharp/threads/threadpool.html>
192,549
<p>I have a controller method that returns a list for a drop down that gets rendered in a partial, but depending on where the partial is being used, the RJS template needs to be different. Can I pass a parameter to the controller that will determine which RJS gets used?</p> <p>Here is the controller method, it is very...
[ { "answer_id": 192867, "author": "Mike Breen", "author_id": 22346, "author_profile": "https://Stackoverflow.com/users/22346", "pm_score": 1, "selected": false, "text": "<p>something like:</p>\n\n<pre><code>if params[:use_alternate]\n render :template =&gt; alternate.rjs and return\nend\...
2008/10/10
[ "https://Stackoverflow.com/questions/192549", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
I have a controller method that returns a list for a drop down that gets rendered in a partial, but depending on where the partial is being used, the RJS template needs to be different. Can I pass a parameter to the controller that will determine which RJS gets used? Here is the controller method, it is very simple: ...
What about placing the conditional logic in **one** rjs template? ``` # services.rjs if @type == "your conditions" # your rjs updates else # your other rjs updates end ``` This gives you a cleaner controller and saves you the headache of maintaining multiple rjs templates.
192,553
<p>I am currently in the process of making a new ASP.net MVC website, and find myself using Html.Encode all over the place, which is good practice, but gets pretty messy. I think a good way to clean this up would be if I could overload an operator to automatically do Html encoding. </p> <p>Previously:</p> <pre><code>...
[ { "answer_id": 192564, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": -1, "selected": false, "text": "<p><strong>NOTE: This is an ugly and untested hack, I don't think I'd ever do this</strong></p>\n\n<pre><code>public static...
2008/10/10
[ "https://Stackoverflow.com/questions/192553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24841/" ]
I am currently in the process of making a new ASP.net MVC website, and find myself using Html.Encode all over the place, which is good practice, but gets pretty messy. I think a good way to clean this up would be if I could overload an operator to automatically do Html encoding. Previously: ``` <%= Html.Encode( View...
It's not so clean as an operator overload, but I used the following extension method: ``` public static string Safe(this string sz) { return HttpUtility.HtmlEncode(sz); } ``` So in my aspx id do: ``` <%= this.ViewData["username"].Safe() %> ``` Tacking the extra method onto the end of the expression just looks...
192,570
<p>The project I'm working on uses a window.onerror event handler to report user problems. I've noticed a single user that just cannot seem to load the Google Analytics script. Our site doesn't see a lot of traffic so I'm not sure how widespread this is, but so far it seems to just effect one user. </p> <p>His user...
[ { "answer_id": 192581, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 2, "selected": false, "text": "<p>This is a rather random guess, but I wonder if the user is using an add-on like NoScript to control script execution a...
2008/10/10
[ "https://Stackoverflow.com/questions/192570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1423/" ]
The project I'm working on uses a window.onerror event handler to report user problems. I've noticed a single user that just cannot seem to load the Google Analytics script. Our site doesn't see a lot of traffic so I'm not sure how widespread this is, but so far it seems to just effect one user. His user agent is: "M...
This problem occurs when leaving a page in Firefox before all scripts have finished loading. So I assume that it is safe to ignore the error. You don't see this error in the Firefox error console, but you can make it visible by binding an alert to the window.onerror event. Then you will be able to see the alert box fo...
192,575
<p>How do I transfer the users of a vBulletin forum to a new installation of IceBB?</p>
[ { "answer_id": 192581, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 2, "selected": false, "text": "<p>This is a rather random guess, but I wonder if the user is using an add-on like NoScript to control script execution a...
2008/10/10
[ "https://Stackoverflow.com/questions/192575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5509/" ]
How do I transfer the users of a vBulletin forum to a new installation of IceBB?
This problem occurs when leaving a page in Firefox before all scripts have finished loading. So I assume that it is safe to ignore the error. You don't see this error in the Firefox error console, but you can make it visible by binding an alert to the window.onerror event. Then you will be able to see the alert box fo...
192,584
<p>I have a listbox that is databound to a Collection of objects. The listbox is configured to display an identifier property of each object. I would like to show a tooltip with information specific to the item within the listbox that is being hovered over rather than one tooltip for the listbox as a whole.</p> <p>I...
[ { "answer_id": 192654, "author": "Michael Lang", "author_id": 19452, "author_profile": "https://Stackoverflow.com/users/19452", "pm_score": 5, "selected": true, "text": "<p>There are two main sub-problems one must solve in order to solve this problem:</p>\n\n<ol>\n<li>Determine which ite...
2008/10/10
[ "https://Stackoverflow.com/questions/192584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19452/" ]
I have a listbox that is databound to a Collection of objects. The listbox is configured to display an identifier property of each object. I would like to show a tooltip with information specific to the item within the listbox that is being hovered over rather than one tooltip for the listbox as a whole. I am working ...
There are two main sub-problems one must solve in order to solve this problem: 1. Determine which item is being hovered over 2. Get the MouseHover event to fire when the user has hovered over one item, then moved the cursor within the listbox and hovered over another item. The first problem is rather simple to solve....
192,628
<p>i've been tasked with re-organizing a pure HTML site into a CMS. if all goes well, the new site will eventually become the main URL, and the old domain will be phased out. the old domain has a decent enough page rank, and the company wishes to mitigate any loss of page rank for that. in looking over the options avai...
[ { "answer_id": 192679, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 4, "selected": true, "text": "<p>If you really truly want to ensure that page rank is not lost, you will want to replace the old content with som...
2008/10/10
[ "https://Stackoverflow.com/questions/192628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4853/" ]
i've been tasked with re-organizing a pure HTML site into a CMS. if all goes well, the new site will eventually become the main URL, and the old domain will be phased out. the old domain has a decent enough page rank, and the company wishes to mitigate any loss of page rank for that. in looking over the options availab...
If you really truly want to ensure that page rank is not lost, you will want to replace the old content with something that performs a proper 301 redirect to the new location. With a 301 redirect the search spiders will know that the content is moved and the page rank typically carries over. It also helps external link...