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
123,159
<p>Has anyone done this? Basically, I want to use the html by keeping basic tags such as h1, h2, em, etc; clean all non http addresses in the img and a tags; and HTMLEncode every other tag. </p> <p>I'm stuck at the HTML Encoding part. I know to remove a node you do a "node.ParentNode.RemoveChild(node);" where node ...
[ { "answer_id": 123522, "author": "Derek Slager", "author_id": 18636, "author_profile": "https://Stackoverflow.com/users/18636", "pm_score": 1, "selected": false, "text": "<p>You would need to remove the node representing the element you don't want. The encoded HTML would then need to be ...
2008/09/23
[ "https://Stackoverflow.com/questions/123159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
Has anyone done this? Basically, I want to use the html by keeping basic tags such as h1, h2, em, etc; clean all non http addresses in the img and a tags; and HTMLEncode every other tag. I'm stuck at the HTML Encoding part. I know to remove a node you do a "node.ParentNode.RemoveChild(node);" where node is the object...
You would need to remove the node representing the element you don't want. The encoded HTML would then need to be re-added as a text node. If you don't want to process the children of the elements that you want to throw away, you should be able to just use OuterHtml ... something like this might work: ``` node.Append...
123,181
<p>Is there a way to test if an object is a dictionary?</p> <p>In a method I'm trying to get a value from a selected item in a list box. In some circumstances, the list box might be bound to a dictionary, but this isn't known at compile time.</p> <p>I would like to do something similar to this:</p> <pre><code>if (l...
[ { "answer_id": 123191, "author": "Guvante", "author_id": 16800, "author_profile": "https://Stackoverflow.com/users/16800", "pm_score": 4, "selected": false, "text": "<p>Check to see if it implements IDictionary.</p>\n\n<p>See the definition of System.Collections.IDictionary to see what t...
2008/09/23
[ "https://Stackoverflow.com/questions/123181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12999/" ]
Is there a way to test if an object is a dictionary? In a method I'm trying to get a value from a selected item in a list box. In some circumstances, the list box might be bound to a dictionary, but this isn't known at compile time. I would like to do something similar to this: ``` if (listBox.ItemsSource is Diction...
It should be something like the following. I wrote this in the answer box so the syntax may not be exactly right, but I've made it Wiki editable so anybody can fix up. ``` if (listBox.ItemsSource.IsGenericType && typeof(IDictionary<,>).IsAssignableFrom(listBox.ItemsSource.GetGenericTypeDefinition())) { var me...
123,188
<p>In C# when I am done entering the fields of a snippet, I can hit Enter to get to the next line. What is the equivalent Key in VB?</p> <p>Edit: I prefer not to use the mouse.</p>
[ { "answer_id": 123195, "author": "torial", "author_id": 13990, "author_profile": "https://Stackoverflow.com/users/13990", "pm_score": 1, "selected": false, "text": "<p>Don't know the key, but I use <em>right-click -> Hide Snippet Highlighting</em>.</p>\n" }, { "answer_id": 123243...
2008/09/23
[ "https://Stackoverflow.com/questions/123188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
In C# when I am done entering the fields of a snippet, I can hit Enter to get to the next line. What is the equivalent Key in VB? Edit: I prefer not to use the mouse.
Wow... I sure hope they improve this soon. Meanwhile, in case anyone cares, I created an additional replacement field ($Enter$) at the end of my custom snippet. This allows me to [tab] through the fields and then type [DownArrow] [Enter] when I reach the end of the list. Something like.... ``` private _$PropertyName...
123,198
<p>How do I copy a file in Python?</p>
[ { "answer_id": 123212, "author": "Swati", "author_id": 12682, "author_profile": "https://Stackoverflow.com/users/12682", "pm_score": 13, "selected": true, "text": "<p><a href=\"http://docs.python.org/3/library/shutil.html\" rel=\"noreferrer\"><code>shutil</code></a> has many methods you ...
2008/09/23
[ "https://Stackoverflow.com/questions/123198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
How do I copy a file in Python?
[`shutil`](http://docs.python.org/3/library/shutil.html) has many methods you can use. One of which is: ``` import shutil shutil.copyfile(src, dst) # 2nd option shutil.copy(src, dst) # dst can be a folder; use shutil.copy2() to preserve timestamp ``` * Copy the contents of the file named `src` to a file named `ds...
123,216
<p>I can't make td "Date" to have fixed height. If there is less in Body section td Date element is bigger than it should be - even if I set Date height to 10% and Body height to 90%. Any suggestions?</p> <pre><code>&lt;tr&gt; &lt;td class="Author" rowspan="2"&gt; &lt;a href="#"&gt;Claude&lt;/a&gt;&lt;br /&gt; ...
[ { "answer_id": 123245, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 0, "selected": false, "text": "<p>CSS</p>\n\n<pre><code>.Date {\n height: 50px;\n}\n</code></pre>\n" }, { "answer_id": 123248, "autho...
2008/09/23
[ "https://Stackoverflow.com/questions/123216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3182/" ]
I can't make td "Date" to have fixed height. If there is less in Body section td Date element is bigger than it should be - even if I set Date height to 10% and Body height to 90%. Any suggestions? ``` <tr> <td class="Author" rowspan="2"> <a href="#">Claude</a><br /> <a href="#"><img src="Users/4/Avatar.jpeg...
Oli is right! Give then screenshot you posted, you are using the wrong markup. You could use something more like this: ``` <div class="post"> <div class="author"> <a href="#">Claude</a><br /> <a href="#"><img src="Users/4/Avatar.jpeg" /></a> </div> <div class="content"> <div class="date">Sent...
123,235
<p>I was trying to remove all the lines of a file except the last line but the following command did not work, although file.txt is not empty.</p> <pre><code>$cat file.txt |tail -1 &gt; file.txt $cat file.txt </code></pre> <p>Why is it so?</p>
[ { "answer_id": 123249, "author": "Lewis Baumstark", "author_id": 12000, "author_profile": "https://Stackoverflow.com/users/12000", "pm_score": 0, "selected": false, "text": "<p>It seems to not like the fact you're writing it back to the same filename. If you do the following it works:</...
2008/09/23
[ "https://Stackoverflow.com/questions/123235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I was trying to remove all the lines of a file except the last line but the following command did not work, although file.txt is not empty. ``` $cat file.txt |tail -1 > file.txt $cat file.txt ``` Why is it so?
Redirecting from a file through a pipeline back to the same file is unsafe; if `file.txt` is overwritten by the shell when setting up the last stage of the pipeline before `tail` starts reading off the first stage, you end up with empty output. Do the following instead: ``` tail -1 file.txt >file.txt.new && mv file.t...
123,236
<p>We have a customer requesting data in XML format. Normally this is not required as we usually just hand off an Access database or csv files and that is sufficient. However in this case I need to automate the exporting of proper XML from a dozen tables.</p> <p>If I can do it out of SQL Server 2005, that would be pre...
[ { "answer_id": 123282, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 0, "selected": false, "text": "<p>There's an outline <a href=\"http://www.microsoft.com/technet/scriptcenter/resources/officetips/oct05/tips1020.mspx\" rel...
2008/09/23
[ "https://Stackoverflow.com/questions/123236", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8345/" ]
We have a customer requesting data in XML format. Normally this is not required as we usually just hand off an Access database or csv files and that is sufficient. However in this case I need to automate the exporting of proper XML from a dozen tables. If I can do it out of SQL Server 2005, that would be preferred. Ho...
Look into using FOR XML AUTO. Depending on your requirements, you might need to use EXPLICIT. As a quick example: ``` SELECT * FROM Customers INNER JOIN Orders ON Orders.CustID = Customers.CustID FOR XML AUTO ``` This will generate a nested XML document with the orders inside the customers. You could then u...
123,239
<p>This is a sample (edited slightly, but you get the idea) of my XML file:</p> <pre><code>&lt;HostCollection&gt; &lt;ApplicationInfo /&gt; &lt;Hosts&gt; &lt;Host&gt; &lt;Name&gt;Test&lt;/Name&gt; &lt;IP&gt;192.168.1.1&lt;/IP&gt; &lt;/Host&gt; &lt;Host&gt; &lt;Name&gt;Test&lt;/Name&gt...
[ { "answer_id": 123275, "author": "kitsune", "author_id": 13466, "author_profile": "https://Stackoverflow.com/users/13466", "pm_score": 3, "selected": true, "text": "<p>You could load them into an XmlDocument and use an XPath statement to fill a NodeList...</p>\n\n<pre><code>Dim doc As Xm...
2008/09/23
[ "https://Stackoverflow.com/questions/123239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5473/" ]
This is a sample (edited slightly, but you get the idea) of my XML file: ``` <HostCollection> <ApplicationInfo /> <Hosts> <Host> <Name>Test</Name> <IP>192.168.1.1</IP> </Host> <Host> <Name>Test</Name> <IP>192.168.1.2</IP> </Host> </Hosts> </HostCollection> ``` When my ap...
You could load them into an XmlDocument and use an XPath statement to fill a NodeList... ``` Dim doc As XmlDocument = New XmlDocument() doc.Load("hosts.xml") Dim nodeList as XmlNodeList nodeList = doc.SelectNodes("/HostCollectionInfo/Hosts/Host") ``` Then loop through the nodes
123,263
<p>I'm reading text from a flat file in c# and need to test whether certain values are dates. They could be in either YYYYMMDD format or MM/DD/YY format. What is the simplest way to do this in .Net?</p>
[ { "answer_id": 123270, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ch92fbc1.aspx\" rel=\"nofollow noreferrer\">DateTime.TryParse</a...
2008/09/23
[ "https://Stackoverflow.com/questions/123263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20625/" ]
I'm reading text from a flat file in c# and need to test whether certain values are dates. They could be in either YYYYMMDD format or MM/DD/YY format. What is the simplest way to do this in .Net?
```cs string[] formats = {"yyyyMMdd", "MM/dd/yy"}; var Result = DateTime.ParseExact(input, formats, CultureInfo.CurrentCulture, DateTimeStyles.None); ``` or ```cs DateTime result; string[] formats = {"yyyyMMdd", "MM/dd/yy"}; DateTime.TryParseExact(input, formats, CultureInfo.CurrentCulture, DateTimeStyles.None, out ...
123,334
<p>NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need. Feel free to suggest any other program.</p> <p>I have a form with nearly 100 fields that I would like to auto-fill with PHP. I know how to do the autofill, but I would like to avoid manually adding the...
[ { "answer_id": 123373, "author": "Zsolt Botykai", "author_id": 11621, "author_profile": "https://Stackoverflow.com/users/11621", "pm_score": 2, "selected": false, "text": "<p><code>:%s:\\(&lt;input name=\"\\([^\"]\\+\\)\" id=\"[^\"]\\+\" type=\"text\" \\)/&gt;:\\1value=\"&lt;?php echo $d...
2008/09/23
[ "https://Stackoverflow.com/questions/123334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16292/" ]
NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need. Feel free to suggest any other program. I have a form with nearly 100 fields that I would like to auto-fill with PHP. I know how to do the autofill, but I would like to avoid manually adding the needed te...
Taking some ideas from Zsolt Botykai and Mark Biek: ``` :%s:<input\(.* id="\([^"]*\)".*\) />:<input \1 value="<?php echo $data['\2']; ?> />:g ```
123,336
<p>How can you strip non-ASCII characters from a string? (in C#)</p>
[ { "answer_id": 123340, "author": "philcruz", "author_id": 3784, "author_profile": "https://Stackoverflow.com/users/3784", "pm_score": 10, "selected": true, "text": "<pre><code>string s = \"søme string\";\ns = Regex.Replace(s, @\"[^\\u0000-\\u007F]+\", string.Empty);\n</code></pre>\n" }...
2008/09/23
[ "https://Stackoverflow.com/questions/123336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3784/" ]
How can you strip non-ASCII characters from a string? (in C#)
``` string s = "søme string"; s = Regex.Replace(s, @"[^\u0000-\u007F]+", string.Empty); ```
123,378
<p>Is there a good command-line UNIX charting / graphing / plotting tool out there? I'm looking for something that will plot xy points on an ASCII graph.</p> <p>Just to clarify, I'm looking for something that will output a graph in ASCII (like ascii-art style), so I can use it over an interactive shell session withou...
[ { "answer_id": 123396, "author": "Palmin", "author_id": 5949, "author_profile": "https://Stackoverflow.com/users/5949", "pm_score": 8, "selected": true, "text": "<p>Try <a href=\"http://www.gnuplot.info/\" rel=\"noreferrer\">gnuplot</a>. It has very powerful graphing possibilities.</p>\n...
2008/09/23
[ "https://Stackoverflow.com/questions/123378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21339/" ]
Is there a good command-line UNIX charting / graphing / plotting tool out there? I'm looking for something that will plot xy points on an ASCII graph. Just to clarify, I'm looking for something that will output a graph in ASCII (like ascii-art style), so I can use it over an interactive shell session without needing X...
Try [gnuplot](http://www.gnuplot.info/). It has very powerful graphing possibilities. It can output to your terminal in the following way: ``` gnuplot> set terminal dumb Terminal type set to 'dumb' Options are 'feed 79 24' gnuplot> plot sin(x) 1 ++----------------**---------------+----**-----------+--------**----...
123,391
<p>I would like to know how to unload an assembly that is loaded into the main AppDomain.</p> <p>I have the following code:</p> <pre><code>var assembly = Assembly.LoadFrom( FilePathHere ); </code></pre> <p>I need/want to be able to unload this assembly when I am done.</p> <p>Thanks for your help.</p>
[ { "answer_id": 123397, "author": "Philip Rieck", "author_id": 12643, "author_profile": "https://Stackoverflow.com/users/12643", "pm_score": 5, "selected": false, "text": "<p><strong>For .net versions core 3.0 and later:</strong></p>\n<p>You can now unload assemblies. Note that appdomain...
2008/09/23
[ "https://Stackoverflow.com/questions/123391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14164/" ]
I would like to know how to unload an assembly that is loaded into the main AppDomain. I have the following code: ``` var assembly = Assembly.LoadFrom( FilePathHere ); ``` I need/want to be able to unload this assembly when I am done. Thanks for your help.
**For .net versions core 3.0 and later:** You can now unload assemblies. Note that appdomains are no longer available in .net core. Instead, you can create one or more AssemblyLoadContext, load your assemblies via that context, then unload that context. See [AssemblyLoadContext](https://learn.microsoft.com/en-us/dotne...
123,394
<p>I know I can do this:</p> <pre><code>IDateTimeFactory dtf = MockRepository.GenerateStub&lt;IDateTimeFactory&gt;(); dtf.Now = new DateTime(); DoStuff(dtf); // dtf.Now can be called arbitrary number of times, will always return the same value dtf.Now = new DateTime()+new TimeSpan(0,1,0); // 1 minute later DoStuff(dt...
[ { "answer_id": 123515, "author": "Judah Gabriel Himango", "author_id": 536, "author_profile": "https://Stackoverflow.com/users/536", "pm_score": 0, "selected": false, "text": "<p>You can use Expect.Call to accomplish this. Here's an example using the record/playback model:</p>\n\n<pre><c...
2008/09/23
[ "https://Stackoverflow.com/questions/123394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I know I can do this: ``` IDateTimeFactory dtf = MockRepository.GenerateStub<IDateTimeFactory>(); dtf.Now = new DateTime(); DoStuff(dtf); // dtf.Now can be called arbitrary number of times, will always return the same value dtf.Now = new DateTime()+new TimeSpan(0,1,0); // 1 minute later DoStuff(dtf); //ditto from abo...
George, Using your updated code, I got this to work: ``` MockRepository mocks = new MockRepository(); [Test] public void Test() { IDateTimeFactory dtf = mocks.DynamicMock<IDateTimeFactory>(); DateTime desiredNowTime = DateTime.Now; using (mocks.Record()) { SetupResult.For(dtf.GetNow()).Do((F...
123,401
<p>Using jQuery, how do you bind a click event to a table cell (below, <code>class="expand"</code>) that will change the <code>image src</code> (which is in the clicked cell - original will be plus.gif, alternating with minus.gif) and <code>hide/show</code> the row immediately below it based on whether that row has a c...
[ { "answer_id": 123518, "author": "neuroguy123", "author_id": 12529, "author_profile": "https://Stackoverflow.com/users/12529", "pm_score": 5, "selected": true, "text": "<p>You don't need the show and hide tags:</p>\n\n<pre><code>$(document).ready(function(){ \n $('.expand').click(fu...
2008/09/23
[ "https://Stackoverflow.com/questions/123401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
Using jQuery, how do you bind a click event to a table cell (below, `class="expand"`) that will change the `image src` (which is in the clicked cell - original will be plus.gif, alternating with minus.gif) and `hide/show` the row immediately below it based on whether that row has a class of `hide`. (show it if it has a...
You don't need the show and hide tags: ``` $(document).ready(function(){ $('.expand').click(function() { if( $(this).hasClass('hidden') ) $('img', this).attr("src", "plus.jpg"); else $('img', this).attr("src", "minus.jpg"); $(this).toggleClass('hidden'); ...
123,489
<p>I am using REPLACE in an SQL view to remove the spaces from a property number. The function is setup like this REPLACE(pin, ' ', ''). On the green-screen the query looked fine. In anything else we get the hex values of the characters in the field. I am sure it is an encoding thing, but how do I fix it?</p> <p>Here ...
[ { "answer_id": 123498, "author": "Mike McAllister", "author_id": 16247, "author_profile": "https://Stackoverflow.com/users/16247", "pm_score": 0, "selected": false, "text": "<p>Try using NULL rather than an empty string. i.e. REPLACE(RCAPIN, ' ', NULL)</p>\n" }, { "answer_id": 12...
2008/09/23
[ "https://Stackoverflow.com/questions/123489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2535/" ]
I am using REPLACE in an SQL view to remove the spaces from a property number. The function is setup like this REPLACE(pin, ' ', ''). On the green-screen the query looked fine. In anything else we get the hex values of the characters in the field. I am sure it is an encoding thing, but how do I fix it? Here is the sta...
We ended up using concat and substring to get the results we wanted. ``` CREATE VIEW RLIC2GIS AS SELECT CONCAT(SUBSTR(RCAPIN,1,3),CONCAT(SUBSTR(RCAPIN,5,2), CONCAT(SUBSTR(RCAPIN,8,2), CONCAT(SUBSTR(RCAPIN,11,3), SUBSTR(RCAPIN, 15,3))))) AS CAPIN13, RLICNO, RONAME, ROA...
123,499
<p>I've got the directive</p> <pre><code>&lt;VirtualHost *&gt; &lt;Location /&gt; AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users &lt;Limit GET&gt; Require valid-user &lt;/Limit&gt; &lt;/Location&gt; WSGIScript...
[ { "answer_id": 123526, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 5, "selected": true, "text": "<p>add <code>WSGIPassAuthorization On</code>:</p>\n\n<pre><code>&lt;VirtualHost *&gt;\n &lt;Location /&gt;\n AuthT...
2008/09/23
[ "https://Stackoverflow.com/questions/123499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19435/" ]
I've got the directive ``` <VirtualHost *> <Location /> AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users <Limit GET> Require valid-user </Limit> </Location> WSGIScriptAlias / /some/script.wsgi WSGIDaemonProc...
add `WSGIPassAuthorization On`: ``` <VirtualHost *> <Location /> AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users <Limit GET> Require valid-user </Limit> </Location> WSGIPassAuthorization On WSGIScriptAlias ...
123,503
<p>I'm writing an iPhone app with Cocoa in xcode. I can't find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can I find good info?</p> <p>Thanks!</p>
[ { "answer_id": 123590, "author": "jblocksom", "author_id": 20626, "author_profile": "https://Stackoverflow.com/users/20626", "pm_score": 2, "selected": false, "text": "<p>The <code>UIImagePickerController</code> class lets you take pictures or choose them from the photo library. Specify...
2008/09/23
[ "https://Stackoverflow.com/questions/123503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing an iPhone app with Cocoa in xcode. I can't find any tutorials or sample code that shows how to take photos with the built in camera. How do I do this? Where can I find good info? Thanks!
Just Copy and paste following code into your project to get fully implemented functionality. where **takePhoto** and **chooseFromLibrary** are my own method names which will be called on button touch. Make sure to reference outlets of appropriate buttons to these methods. ``` -(IBAction)takePhoto :(id)sender { ...
123,504
<p>In wxWidgets, how can you find the pixels per inch on a wxDC? I'd like to be able to scale things by a real world number like inches. That often makes it easier to use the same code for printing to the screen and the printer.</p>
[ { "answer_id": 123590, "author": "jblocksom", "author_id": 20626, "author_profile": "https://Stackoverflow.com/users/20626", "pm_score": 2, "selected": false, "text": "<p>The <code>UIImagePickerController</code> class lets you take pictures or choose them from the photo library. Specify...
2008/09/23
[ "https://Stackoverflow.com/questions/123504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17693/" ]
In wxWidgets, how can you find the pixels per inch on a wxDC? I'd like to be able to scale things by a real world number like inches. That often makes it easier to use the same code for printing to the screen and the printer.
Just Copy and paste following code into your project to get fully implemented functionality. where **takePhoto** and **chooseFromLibrary** are my own method names which will be called on button touch. Make sure to reference outlets of appropriate buttons to these methods. ``` -(IBAction)takePhoto :(id)sender { ...
123,506
<p>I have a ASP.NET application running on a remote web server and I just started getting this error:</p> <pre><code>Method not found: 'Void System.Collections.Generic.ICollection`1..ctor()'. </code></pre> <p>I disassembled the code in the DLL and it seems like the compiler is incorrectly optimizing the code. (Note ...
[ { "answer_id": 123538, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 1, "selected": false, "text": "<p>Are you sure that the assembly you're looking at was actually generated from the source code in question? Are you...
2008/09/23
[ "https://Stackoverflow.com/questions/123506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10475/" ]
I have a ASP.NET application running on a remote web server and I just started getting this error: ``` Method not found: 'Void System.Collections.Generic.ICollection`1..ctor()'. ``` I disassembled the code in the DLL and it seems like the compiler is incorrectly optimizing the code. (Note that Set is a class that im...
Ahh, ILMerge - that extra info in your question really helps with your problem. While I wouldn't ever expect the .net compiler to fail in this way I would expect to occasionally see this sort of thing with ILMerge (given what it's doing). My guess is that two of your assemblies are using the same optimisation 'trick',...
123,557
<p>I need to select a bunch of data into a temp table to then do some secondary calculations; To help make it work more efficiently, I would like to have an IDENTITY column on that table. I know I could declare the table first with an identity, then insert the rest of the data into it, but is there a way to do it in 1...
[ { "answer_id": 123642, "author": "Hector Sosa Jr", "author_id": 12829, "author_profile": "https://Stackoverflow.com/users/12829", "pm_score": -1, "selected": false, "text": "<p>IIRC, the INSERT INTO command uses the schema of the source table to create the temp table. That's part of the ...
2008/09/23
[ "https://Stackoverflow.com/questions/123557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19305/" ]
I need to select a bunch of data into a temp table to then do some secondary calculations; To help make it work more efficiently, I would like to have an IDENTITY column on that table. I know I could declare the table first with an identity, then insert the rest of the data into it, but is there a way to do it in 1 ste...
Oh ye of little faith: ``` SELECT *, IDENTITY( int ) AS idcol INTO #newtable FROM oldtable ``` <http://msdn.microsoft.com/en-us/library/aa933208(SQL.80).aspx>
123,558
<p>Is it possible to disable a trigger for a batch of commands and then enable it when the batch is done?</p> <p>I'm sure I could drop the trigger and re-add it but I was wondering if there was another way.</p>
[ { "answer_id": 123566, "author": "Matt Rogish", "author_id": 2590, "author_profile": "https://Stackoverflow.com/users/2590", "pm_score": 7, "selected": true, "text": "<pre><code>DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL }\nON { object_name | DATABASE | ALL SERVER }...
2008/09/23
[ "https://Stackoverflow.com/questions/123558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
Is it possible to disable a trigger for a batch of commands and then enable it when the batch is done? I'm sure I could drop the trigger and re-add it but I was wondering if there was another way.
``` DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL SERVER } [ ; ] ``` <http://msdn.microsoft.com/en-us/library/ms189748(SQL.90).aspx> followed by the inverse: ``` ENABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL...
123,559
<p>I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following:</p> <ul> <li><code>1-234-567-8901</code></li> <li><code>1-234-567-8901 x1234</code></li> <li><code>1-234-567-8901 ext1234</code></li> <li...
[ { "answer_id": 123565, "author": "Nicholas Trandem", "author_id": 765, "author_profile": "https://Stackoverflow.com/users/765", "pm_score": 4, "selected": false, "text": "<p>Here's my best try so far. It handles the formats above but I'm sure I'm missing some other possible formats.</p>\...
2008/09/23
[ "https://Stackoverflow.com/questions/123559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/765/" ]
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following: * `1-234-567-8901` * `1-234-567-8901 x1234` * `1-234-567-8901 ext1234` * `1 (234) 567-8901` * `1.234.567.8901` * `1/234/567/8901` * `1234567...
Better option... just strip all non-digit characters on input (except 'x' and leading '+' signs), taking care because of the British tendency to write numbers in the non-standard form `+44 (0) ...` when asked to use the international prefix (in that specific case, you should discard the `(0)` entirely). Then, you end ...
123,598
<p>I have an Enum called Status defined as such:</p> <pre><code>public enum Status { VALID("valid"), OLD("old"); private final String val; Status(String val) { this.val = val; } public String getStatus() { return val; } } </code></pre> <p>I would like to access the value ...
[ { "answer_id": 130002, "author": "IaCoder", "author_id": 17337, "author_profile": "https://Stackoverflow.com/users/17337", "pm_score": 5, "selected": false, "text": "\n\n<p>So to get my problem fully resolved I needed to do the following:</p>\n\n<pre class=\"lang-xml prettyprint-override...
2008/09/23
[ "https://Stackoverflow.com/questions/123598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
I have an Enum called Status defined as such: ``` public enum Status { VALID("valid"), OLD("old"); private final String val; Status(String val) { this.val = val; } public String getStatus() { return val; } } ``` I would like to access the value of `VALID` from a JSTL tag...
A simple comparison against string works: ```xml <c:when test="${someModel.status == 'OLD'}"> ```
123,632
<pre><code>devenv mysolution.sln /build "Release|Win32" /project myproject </code></pre> <p>When building from the command line, it seems I have the option of doing a <code>/build</code> or <code>/rebuild</code>, but no way of saying I want to do "project only" (i.e. not build or rebuild the specified project's depend...
[ { "answer_id": 123649, "author": "Ben Straub", "author_id": 1319, "author_profile": "https://Stackoverflow.com/users/1319", "pm_score": 2, "selected": false, "text": "<p>Don't call <code>devenv</code>, use the genericized build tool instead:</p>\n\n<pre><code>vcbuild subproject.vcproj \"...
2008/09/23
[ "https://Stackoverflow.com/questions/123632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
``` devenv mysolution.sln /build "Release|Win32" /project myproject ``` When building from the command line, it seems I have the option of doing a `/build` or `/rebuild`, but no way of saying I want to do "project only" (i.e. not build or rebuild the specified project's dependencies as well). Does anyone know of a wa...
Depending on the structure of your build system, this may be what you're looking for: ``` msbuild /p:BuildProjectReferences=false project.proj ```
123,639
<p>Suppose I use the [RemoteClass] tag to endow a custom Flex class with serialization intelligence. </p> <p>What happens when I need to change my object (add a new field, remove a field, rename a field, etc)?</p> <p>Is there a design pattern for handling this in an elegant way?</p>
[ { "answer_id": 127521, "author": "Marc Hughes", "author_id": 6791, "author_profile": "https://Stackoverflow.com/users/6791", "pm_score": 1, "selected": false, "text": "<p>Adding or removing generally works. </p>\n\n<p>You'll get runtime warnings in your trace about properties either bei...
2008/09/23
[ "https://Stackoverflow.com/questions/123639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1750627/" ]
Suppose I use the [RemoteClass] tag to endow a custom Flex class with serialization intelligence. What happens when I need to change my object (add a new field, remove a field, rename a field, etc)? Is there a design pattern for handling this in an elegant way?
Your best bet is to do code generation against your backend classes to generation ActionScript counterparts for them. If you generate a base class with all of your object properties and then create a subclass for it which is never modified, you can still add custom code while regenerating only the parts of your class t...
123,648
<p>I know that a SQL Server full text index can not index more than one table. But, I have relationships in tables that I would like to implement full text indexes on.</p> <p>Take the 3 tables below...</p> <pre><code>Vehicle Veh_ID - int (Primary Key) FK_Atr_VehicleColor - int Veh_Make - nvarchar(20) Veh_Model - nvar...
[ { "answer_id": 123814, "author": "Cowan", "author_id": 17041, "author_profile": "https://Stackoverflow.com/users/17041", "pm_score": 0, "selected": false, "text": "<p>As I understand it (I've used SQL Server a lot but never full-text indexing) SQL Server 2005 allows you to create full te...
2008/09/23
[ "https://Stackoverflow.com/questions/123648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/576/" ]
I know that a SQL Server full text index can not index more than one table. But, I have relationships in tables that I would like to implement full text indexes on. Take the 3 tables below... ``` Vehicle Veh_ID - int (Primary Key) FK_Atr_VehicleColor - int Veh_Make - nvarchar(20) Veh_Model - nvarchar(50) Veh_LicenseP...
I believe it's a common practice to have separate denormalized table specifically for full-text indexing. This table is then updated by triggers or, as it was in our case, by SQL Server's scheduled task. This was SQL Server 2000. In SQL Server you can have an [indexed view](http://www.microsoft.com/technet/prodtechnol...
123,657
<p>I would like to know if there is some way to share a variable or an object between two or more Servlets, I mean some "standard" way. I suppose that this is not a good practice but is a easier way to build a prototype.</p> <p>I don't know if it depends on the technologies used, but I'll use Tomcat 5.5</p> <hr> <p>...
[ { "answer_id": 123696, "author": "yalestar", "author_id": 2177, "author_profile": "https://Stackoverflow.com/users/2177", "pm_score": 1, "selected": false, "text": "<p>Couldn't you just put the object in the HttpSession and then refer to it by its attribute name in each of the servlets?<...
2008/09/23
[ "https://Stackoverflow.com/questions/123657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19689/" ]
I would like to know if there is some way to share a variable or an object between two or more Servlets, I mean some "standard" way. I suppose that this is not a good practice but is a easier way to build a prototype. I don't know if it depends on the technologies used, but I'll use Tomcat 5.5 --- I want to share a ...
I think what you're looking for here is request, session or application data. In a servlet you can add an object as an attribute to the request object, session object or servlet context object: ``` protected void doGet(HttpServletRequest request, HttpServletResponse response) { String shared = "shared"; reque...
123,661
<p>Consider a <em>hypothetical</em> method of an object that does stuff for you:</p> <pre><code>public class DoesStuff { BackgroundWorker _worker = new BackgroundWorker(); ... public void CancelDoingStuff() { _worker.CancelAsync(); //todo: Figure out a way to wait for BackgroundWorke...
[ { "answer_id": 123684, "author": "Seb Nilsson", "author_id": 2429, "author_profile": "https://Stackoverflow.com/users/2429", "pm_score": 2, "selected": false, "text": "<p>You can check into the <strong>RunWorkerCompletedEventArgs</strong> in the <strong>RunWorkerCompletedEventHandler</st...
2008/09/23
[ "https://Stackoverflow.com/questions/123661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
Consider a *hypothetical* method of an object that does stuff for you: ``` public class DoesStuff { BackgroundWorker _worker = new BackgroundWorker(); ... public void CancelDoingStuff() { _worker.CancelAsync(); //todo: Figure out a way to wait for BackgroundWorker to be cancelled. ...
If I understand your requirement right, you could do something like this (code not tested, but shows the general idea): ``` private BackgroundWorker worker = new BackgroundWorker(); private AutoResetEvent _resetEvent = new AutoResetEvent(false); public Form1() { InitializeComponent(); worker.DoWork += worker...
123,672
<p>In <a href="http://msdn.microsoft.com/en-us/library/ms155365%28SQL.90%29.aspx" rel="nofollow noreferrer">this MSDN article</a>, MS explains how to specify other delimiters besides commas for csv-type exports from SSRS 2005, however, literal tab characters are stripped by the config file parser, and it doesn't appear...
[ { "answer_id": 124523, "author": "Leo Moore", "author_id": 6336, "author_profile": "https://Stackoverflow.com/users/6336", "pm_score": 1, "selected": false, "text": "<p>I used a select query to format the data and BCP to extract the data out into a file. In my case I encapsulated it all ...
2008/09/23
[ "https://Stackoverflow.com/questions/123672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19239/" ]
In [this MSDN article](http://msdn.microsoft.com/en-us/library/ms155365%28SQL.90%29.aspx), MS explains how to specify other delimiters besides commas for csv-type exports from SSRS 2005, however, literal tab characters are stripped by the config file parser, and it doesn't appear that MS has provided a workaround. [...
In case anyone needs it this is working very well for me. ``` <Extension Name="Tabs" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering"> <OverrideNames> <Name Language="en-US">Tab-delimited</Name> </OverrideNames> <Configuration> <DeviceInfo> ...
123,718
<p>How can i check to see if a static class has been declared? ex Given the class</p> <pre><code>class bob { function yippie() { echo "skippie"; } } </code></pre> <p>later in code how do i check:</p> <pre><code>if(is_a_valid_static_object(bob)) { bob::yippie(); } </code></pre> <p>so i don't get:...
[ { "answer_id": 123731, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://us2.php.net/class_exists\" rel=\"nofollow noreferrer\"><code>bool class_exists( string $class_name...
2008/09/23
[ "https://Stackoverflow.com/questions/123718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5261/" ]
How can i check to see if a static class has been declared? ex Given the class ``` class bob { function yippie() { echo "skippie"; } } ``` later in code how do i check: ``` if(is_a_valid_static_object(bob)) { bob::yippie(); } ``` so i don't get: Fatal error: Class 'bob' not found in file.php o...
You can also check for existence of a specific method, even without instantiating the class ``` echo method_exists( bob, 'yippie' ) ? 'yes' : 'no'; ``` If you want to go one step further and verify that "yippie" is actually static, use the [Reflection API](http://us3.php.net/language.oop5.reflection) (PHP5 only) ``...
123,758
<p>Let's say I have the following <code>class X</code> where I want to return access to an internal member:</p> <pre><code>class Z { // details }; class X { std::vector&lt;Z&gt; vecZ; public: Z&amp; Z(size_t index) { // massive amounts of code for validating index Z&amp; ret = vecZ[i...
[ { "answer_id": 123765, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 7, "selected": true, "text": "<p>Yes, it is possible to avoid the code duplication. You need to use the const member function to have the logic and have the...
2008/09/23
[ "https://Stackoverflow.com/questions/123758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6386/" ]
Let's say I have the following `class X` where I want to return access to an internal member: ``` class Z { // details }; class X { std::vector<Z> vecZ; public: Z& Z(size_t index) { // massive amounts of code for validating index Z& ret = vecZ[index]; // even more code for d...
Yes, it is possible to avoid the code duplication. You need to use the const member function to have the logic and have the non-const member function call the const member function and re-cast the return value to a non-const reference (or pointer if the functions returns a pointer): ``` class X { std::vector<Z> vec...
123,773
<p>I will choose Java as an example, most people know it, though every other OO language was working as well.</p> <p>Java, like many other languages, has interface inheritance and implementation inheritance. E.g. a Java class can inherit from another one and every method that has an implementation there (assuming the ...
[ { "answer_id": 123800, "author": "Xian", "author_id": 4642, "author_profile": "https://Stackoverflow.com/users/4642", "pm_score": 2, "selected": false, "text": "<p>You could also use composition and the strategy pattern.<a href=\"http://en.wikipedia.org/wiki/Strategy_pattern\" rel=\"nofo...
2008/09/23
[ "https://Stackoverflow.com/questions/123773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15809/" ]
I will choose Java as an example, most people know it, though every other OO language was working as well. Java, like many other languages, has interface inheritance and implementation inheritance. E.g. a Java class can inherit from another one and every method that has an implementation there (assuming the parent is ...
Short answer: Yes it is possible. But you have to do it on purpose and no by chance ( using final, abstract and design with inheritance in mind, etc. ) Long answer: Well, inheritance is not actually for "code re-use", it is for class "specialization", I think this is a misinterpretation. For instance is it a very b...
123,783
<p>Many websites have the concept of sending messages from user to user. When you send a message to another user, the message would show up in their inbox. You could respond to the message, and it would show up as a new entry in that message thread. </p> <p>You should be able to see if you've read a given message a...
[ { "answer_id": 123799, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": true, "text": "<pre><code>user\n id\n name\n\nmessages\n id\n to_user_id\n from_user_id\n title\n date\n\nmessage_post\n id\n message_id\n user...
2008/09/23
[ "https://Stackoverflow.com/questions/123783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076/" ]
Many websites have the concept of sending messages from user to user. When you send a message to another user, the message would show up in their inbox. You could respond to the message, and it would show up as a new entry in that message thread. You should be able to see if you've read a given message already, and m...
``` user id name messages id to_user_id from_user_id title date message_post id message_id user_id message date ``` classes would reflect this sort of schema
123,809
<p>If my code throws an exception, sometimes - not everytime - the jsf presents a blank page. I´m using facelets for layout. A similar error were reported at this <a href="http://forums.sun.com/thread.jspa?messageID=10237827" rel="nofollow noreferrer">Sun forumn´s post</a>, but without answers. Anyone else with the sam...
[ { "answer_id": 123932, "author": "William", "author_id": 9193, "author_profile": "https://Stackoverflow.com/users/9193", "pm_score": 3, "selected": true, "text": "<p>I think this largely depends on your JSF implementation. I've heard that some will render blank screens.</p>\n\n<p>The one...
2008/09/23
[ "https://Stackoverflow.com/questions/123809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21370/" ]
If my code throws an exception, sometimes - not everytime - the jsf presents a blank page. I´m using facelets for layout. A similar error were reported at this [Sun forumn´s post](http://forums.sun.com/thread.jspa?messageID=10237827), but without answers. Anyone else with the same problem, or have a solution? ;) Due t...
I think this largely depends on your JSF implementation. I've heard that some will render blank screens. The one we were using would throw error 500's with a stack trace. Other times out buttons wouldn't work without any error for the user. This was all during our development phase. But the best advice I can give yo...
123,838
<p>Our clients will be uploading images to be printed on their documents and we have been asked to come up with a way to get the resolution of the image in order to warn them if the image has too low of a resolution and will look pixalated in the end-product</p> <p>If it comes to it we could also go with the dimension...
[ { "answer_id": 123854, "author": "Xian", "author_id": 4642, "author_profile": "https://Stackoverflow.com/users/4642", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx\" rel=\"noreferrer\">System.Drawing.Image</a></p>...
2008/09/23
[ "https://Stackoverflow.com/questions/123838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2486/" ]
Our clients will be uploading images to be printed on their documents and we have been asked to come up with a way to get the resolution of the image in order to warn them if the image has too low of a resolution and will look pixalated in the end-product If it comes to it we could also go with the dimensions if anyon...
[System.Drawing.Image](http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx) ``` Image newImage = Image.FromFile("SampImag.jpg"); newImage.HorizontalResolution ```
123,902
<p>I have a self-signed root certificate with just the code signing extension (no other extensions) in my Mac keychain; I use it to sign all code coming out of ∞labs using Apple's codesign tool and it works great.</p> <p>I was looking to expand myself a little and doing some Java development. I know Apple provides a K...
[ { "answer_id": 137559, "author": "bd808", "author_id": 8171, "author_profile": "https://Stackoverflow.com/users/8171", "pm_score": 1, "selected": false, "text": "<p>I think that your keystore entry alias must be wrong. Are you using the alias name of a keystore object with an entry type ...
2008/09/23
[ "https://Stackoverflow.com/questions/123902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6061/" ]
I have a self-signed root certificate with just the code signing extension (no other extensions) in my Mac keychain; I use it to sign all code coming out of ∞labs using Apple's codesign tool and it works great. I was looking to expand myself a little and doing some Java development. I know Apple provides a KeyStore im...
I think that your keystore entry alias must be wrong. Are you using the alias name of a keystore object with an entry type of "keyEntry"? The same command works perfectly for me. From the jarsigner man page: > > When using jarsigner to sign a JAR file, you must specify the alias for the keystore entry containing the...
123,918
<p>System.IO.BinaryReader reads values in a little-endian format.</p> <p>I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find that dealing with this on the client side is awkward, particu...
[ { "answer_id": 123942, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 1, "selected": false, "text": "<p>I built a custom BinaryReader to handle all of this. It's available as <a href=\"http://www.assembla.com/wiki/...
2008/09/23
[ "https://Stackoverflow.com/questions/123918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21374/" ]
System.IO.BinaryReader reads values in a little-endian format. I have a C# application connecting to a proprietary networking library on the server side. The server-side sends everything down in network byte order, as one would expect, but I find that dealing with this on the client side is awkward, particularly for u...
There is no built-in converter. Here's my wrapper (as you can see, I only implemented the functionality I needed but the structure is pretty easy to change to your liking): ``` /// <summary> /// Utilities for reading big-endian files /// </summary> public class BigEndianReader { public BigEndianReader(BinaryReader...
123,927
<p>I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to.</p> <p>I might explore using Nullsoft or MSI for install, but since I'm mostly familiar with...
[ { "answer_id": 123948, "author": "Kent Boogaart", "author_id": 5380, "author_profile": "https://Stackoverflow.com/users/5380", "pm_score": 5, "selected": true, "text": "<p>You could use:</p>\n\n<pre><code>from driveInfo in DriveInfo.GetDrives()\nwhere driveInfo.DriveType == DriveType.Rem...
2008/09/23
[ "https://Stackoverflow.com/questions/123927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124/" ]
I'm writing a setup program to install an application to a USB drive. The application is meant to be used only from USB drives, so it would save an extra step for the user by automatically selecting USB drive to install to. I might explore using Nullsoft or MSI for install, but since I'm mostly familiar with .NET I in...
You could use: ``` from driveInfo in DriveInfo.GetDrives() where driveInfo.DriveType == DriveType.Removable && driveInfo.IsReady select driveInfo.RootDirectory.FullName ```
123,936
<p>Some of my colleagues use special comments on their bug fixes, for example:</p> <pre><code>// 2008-09-23 John Doe - bug 12345 // &lt;short description&gt; </code></pre> <p>Does this make sense?<br> Do you comment bug fixes in a special way?</p> <p>Please let me know.</p>
[ { "answer_id": 123949, "author": "perimosocordiae", "author_id": 10601, "author_profile": "https://Stackoverflow.com/users/10601", "pm_score": 2, "selected": false, "text": "<p>Only if the solution was particularly clever or hard to understand.</p>\n" }, { "answer_id": 123952, ...
2008/09/23
[ "https://Stackoverflow.com/questions/123936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2012356/" ]
Some of my colleagues use special comments on their bug fixes, for example: ``` // 2008-09-23 John Doe - bug 12345 // <short description> ``` Does this make sense? Do you comment bug fixes in a special way? Please let me know.
I don't put in comments like that, the source control system already maintains that history and I am already able to log the history of a file. I do put in comments that describe why something non-obvious is being done though. So if the bug fix makes the code less predictable and clear, then I explain why.
123,958
<p>In python is it possible to get or set a logical directory (as opposed to an absolute one).</p> <p>For example if I have:</p> <pre><code>/real/path/to/dir </code></pre> <p>and I have</p> <pre><code>/linked/path/to/dir </code></pre> <p>linked to the same directory.</p> <p>using os.getcwd and os.chdir will alway...
[ { "answer_id": 123985, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 5, "selected": true, "text": "<p>The underlying operational system / shell reports real paths to python. </p>\n\n<p>So, there really is no way around it, ...
2008/09/23
[ "https://Stackoverflow.com/questions/123958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3051/" ]
In python is it possible to get or set a logical directory (as opposed to an absolute one). For example if I have: ``` /real/path/to/dir ``` and I have ``` /linked/path/to/dir ``` linked to the same directory. using os.getcwd and os.chdir will always use the absolute path ``` >>> import os >>> os.chdir('/linke...
The underlying operational system / shell reports real paths to python. So, there really is no way around it, since `os.getcwd()` is a wrapped call to C Library `getcwd()` function. There are some workarounds in the spirit of the one that you already know which is launching `pwd`. Another one would involve using `o...
123,979
<p>I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like:</p> <pre><code>var clipName = "barLeft42" </code></pre> <p>which is held inside another movie clip called 'thing'.</p> <p>I have been able to get hold of a reference using:</p> <pre><...
[ { "answer_id": 124010, "author": "Ronnie", "author_id": 193, "author_profile": "https://Stackoverflow.com/users/193", "pm_score": 3, "selected": true, "text": "<p>Movie clips are collections in actionscript (like most and similar to javascript, everything is basically key-value pairs). Y...
2008/09/23
[ "https://Stackoverflow.com/questions/123979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21214/" ]
I have created a bunch of movie clips which all have similar names and then after some other event I have built up a string like: ``` var clipName = "barLeft42" ``` which is held inside another movie clip called 'thing'. I have been able to get hold of a reference using: ``` var movieClip = Eval( "_root.thing." + ...
Movie clips are collections in actionscript (like most and similar to javascript, everything is basically key-value pairs). You can index into the collection using square brackets and a string for the key name like: ``` _root.thing[ "barLeft42" ] ``` That should do the trick for you...
123,986
<p>I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers).</p> <p>is it possible to check that specific USB card is inserted on windows using .NET 2.0? how?</p> <p>if I find it through WMI, can I somehow determine ...
[ { "answer_id": 124087, "author": "fryguybob", "author_id": 4592, "author_profile": "https://Stackoverflow.com/users/4592", "pm_score": 0, "selected": false, "text": "<p>Perhaps #usblib:</p>\n\n<p><a href=\"http://www.icsharpcode.net/OpenSource/SharpUSBLib/\" rel=\"nofollow noreferrer\">h...
2008/09/23
[ "https://Stackoverflow.com/questions/123986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19124/" ]
I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers). is it possible to check that specific USB card is inserted on windows using .NET 2.0? how? if I find it through WMI, can I somehow determine which drive lette...
**EDIT:** Added code to print drive letter. --- Check if this example works for you. It uses WMI. ``` Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]); ... Console.WriteLine(" Name: {0}", c["Name"]); // here it will print drive letter ``` The full code sample: ``` namespace WMISample { usin...
123,994
<p>I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being passed via the QueryString. Is there any way to handle...
[ { "answer_id": 124004, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": 1, "selected": false, "text": "<p>If you URLEncode the string before adding it to the URL you will not have any of those problems (the automatic URLDecode will...
2008/09/23
[ "https://Stackoverflow.com/questions/123994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7819/" ]
I'm trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the "+" (plus) sign is being replaced by a space. It appears that the automatic URLDecode process is doing this. I have no control over what is being passed via the QueryString. Is there any way to handle th...
You could manually replace the value (`argument.Replace(' ', '+')`) or consult the `HttpRequest.ServerVariables["QUERY_STRING"]` (even better the HttpRequest.Url.Query) and parse it yourself. You should however try to solve the problem where the URL is given; a plus sign needs to get encoded as "%2B" in the URL becaus...
123,999
<p>Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the <strong>viewport</strong>)?</p> <p>(The question refers to Firefox.)</p>
[ { "answer_id": 125106, "author": "Prestaul", "author_id": 5628, "author_profile": "https://Stackoverflow.com/users/5628", "pm_score": 10, "selected": true, "text": "<p><strong>Update:</strong> Time marches on and so have our browsers. <strong>This technique is no longer recommended</stro...
2008/09/23
[ "https://Stackoverflow.com/questions/123999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21290/" ]
Is there an efficient way to tell if a DOM element (in an HTML document) is currently visible (appears in the **viewport**)? (The question refers to Firefox.)
**Update:** Time marches on and so have our browsers. **This technique is no longer recommended** and you should use [Dan's solution](https://stackoverflow.com/questions/123999/how-can-i-tell-if-a-dom-element-is-visible-in-the-current-viewport/7557433#7557433) if you do not need to support version of Internet Explorer ...
124,035
<p>I recently converted a ruby library to a gem, which seemed to break the command line usability</p> <p>Worked fine as a library</p> <pre><code> $ ruby -r foobar -e 'p FooBar.question' # =&gt; "answer" </code></pre> <p>And as a gem, irb knows how to require a gem from command-line switches</p> <pre><code> $ irb ...
[ { "answer_id": 124069, "author": "JasonTrue", "author_id": 13433, "author_profile": "https://Stackoverflow.com/users/13433", "pm_score": 4, "selected": true, "text": "<p>-rubygems is actually the same as -r ubygems.</p>\n\n<p>It doesn't mess with your search path, as far as I understand,...
2008/09/23
[ "https://Stackoverflow.com/questions/124035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4615/" ]
I recently converted a ruby library to a gem, which seemed to break the command line usability Worked fine as a library ``` $ ruby -r foobar -e 'p FooBar.question' # => "answer" ``` And as a gem, irb knows how to require a gem from command-line switches ``` $ irb -rubygems -r foobar irb(main):001:0> FooBar.q...
-rubygems is actually the same as -r ubygems. It doesn't mess with your search path, as far as I understand, but I think it doesn't add anything to your -r search path either. I was able to do something like this: ``` ruby -rubygems -r /usr/lib/ruby/gems/myhelpfulclass-0.0.1/lib/MyHelpfulClass -e "puts MyHelpfulClass...
124,067
<p>In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# <code>System.Text.StringBuilder</code> and Java <code>java.lang.StringBuilder</code>.</p> <p>Does php (...
[ { "answer_id": 124084, "author": "paan", "author_id": 2976, "author_profile": "https://Stackoverflow.com/users/2976", "pm_score": -1, "selected": false, "text": "<p>no such limitation in php,\nphp can concatenate strng with the dot(.) operator</p>\n\n<pre><code>$a=\"hello \";\n$b=\"world...
2008/09/23
[ "https://Stackoverflow.com/questions/124067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21388/" ]
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time. In said languages, there are library classes to reduce this cost such as C# `System.Text.StringBuilder` and Java `java.lang.StringBuilder`. Does php (4 or 5; I'm interested in both) s...
No, there is no type of stringbuilder class in PHP, since strings are mutable. That being said, there are different ways of building a string, depending on what you're doing. echo, for example, will accept comma-separated tokens for output. ``` // This... echo 'one', 'two'; // Is the same as this echo 'one'; echo '...
124,079
<p>I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. </p> <p>I've tried developing and benchmarking various Ruby scripts to process these files, and always end up with glacial result...
[ { "answer_id": 124088, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "<p>This question reminds me of Tim Bray's <a href=\"http://www.tbray.org/ongoing/When/200x/2007/09/20/Wide-Finder\" rel=...
2008/09/23
[ "https://Stackoverflow.com/questions/124079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21275/" ]
I'd like to slice and dice large datafiles, up to a gig, in a fairly quick and efficient manner. If I use something like UNIX's "CUT", it's extremely fast, even in a CYGWIN environment. I've tried developing and benchmarking various Ruby scripts to process these files, and always end up with glacial results. What w...
Why not combine them together - using cut to do what it does best and ruby to provide the glue/value add with the results from CUT? you can run shell scripts by putting them in backticks like this: ``` puts `cut somefile > foo.fil` # process each line of the output from cut f = File.new("foo.fil") f.each{|line| } ```
124,118
<p>We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?</p>
[ { "answer_id": 124338, "author": "Pseudo Masochist", "author_id": 8529, "author_profile": "https://Stackoverflow.com/users/8529", "pm_score": 0, "selected": false, "text": "<p>My understanding is that there was a virtual address space limitation of 3 GB in ASP.NET 1.1, and that it was ne...
2008/09/23
[ "https://Stackoverflow.com/questions/124118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
We want to switch a web server from Windows 2003 to Windows 2003 Enterprise (64 bits) to use 8GB of RAM. Will IIS 6.0 and an ASPNET 1.1 application be able to benefit from the change?
Since ASP.Net 1.1 has no x64 support, you are limited to running IIS 6 using 32 bit worker processes. The /3GB switch doesn't do anything on x64, but x64 natively gives 32bit processes 4 GB instead of 2GB, so you will have more memory available for your worker proces. You will need to set the AppPools to 32 bit: ``` ...
124,121
<p>I saw an article on creating Excel UDFs in VSTO managed code, using VBA: <a href="http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx</a>. </p> <p>However I want to get this working in a C# Excel add-in using VSTO 2005 ...
[ { "answer_id": 125984, "author": "Romain Verdier", "author_id": 4687, "author_profile": "https://Stackoverflow.com/users/4687", "pm_score": 1, "selected": false, "text": "<p>Creating UDF using a simple automation addin is quite easy. You will have to create a dedicated assembly and make ...
2008/09/23
[ "https://Stackoverflow.com/questions/124121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17584/" ]
I saw an article on creating Excel UDFs in VSTO managed code, using VBA: <http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx>. However I want to get this working in a C# Excel add-in using VSTO 2005 SE, can any one help? I tried the technique Romain pointed out but when trying to load Excel I get the follo...
You should also have a look at ExcelDna - <http://www.codeplex.com/exceldna>. ExcelDna allows managed assemblies to expose user-defined functions (UDFs) and macros to Excel through the native .xll interface. The project is open-source and freely allows commercial use. Your user-defined functions can be written in C#, ...
124,123
<p>Imagine I have the folling XML file:</p> <p>&lt;a&gt;before&lt;b&gt;middle&lt;/b&gt;after&lt;/a&gt;</p> <p>I want to convert it into something like this:</p> <p>&lt;a&gt;beforemiddleafter&lt;/a&gt;</p> <p>In other words I want to get all the child nodes of a certain node, and move them to the parent node in orde...
[ { "answer_id": 124215, "author": "Rahul", "author_id": 16308, "author_profile": "https://Stackoverflow.com/users/16308", "pm_score": 2, "selected": false, "text": "<p>In XSLT, you could just write:</p>\n\n<pre><code>&lt;xsl:template match=\"a\"&gt;&lt;a&gt;&lt;xsl:apply-templates /&gt;&l...
2008/09/23
[ "https://Stackoverflow.com/questions/124123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161922/" ]
Imagine I have the folling XML file: <a>before<b>middle</b>after</a> I want to convert it into something like this: <a>beforemiddleafter</a> In other words I want to get all the child nodes of a certain node, and move them to the parent node in order. This is like doing this command: "mv ./directory/\* .", but for ...
If your actual goal is to remove the links from a web page, then you should use a stylesheet like this, which matches all XHTML `<a>` elements (I'm assuming you're using XHTML?) and simply applies templates to their content: ``` <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:h...
124,143
<p>I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions.<br/> <strong>What is the main reason of the difference between Java and C# in throwing exceptions?</strong><br/> In Java the signature of a method that throws an exception has to use the "throws"...
[ { "answer_id": 124173, "author": "Derek Slager", "author_id": 18636, "author_profile": "https://Stackoverflow.com/users/18636", "pm_score": 4, "selected": false, "text": "<p>The basic design philosophy of C# is that actually catching exceptions is rarely useful, whereas cleaning up resou...
2008/09/23
[ "https://Stackoverflow.com/questions/124143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/68336/" ]
I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions. **What is the main reason of the difference between Java and C# in throwing exceptions?** In Java the signature of a method that throws an exception has to use the "throws" keyword, while in C...
Because the response to checked exceptions is almost always: ``` try { // exception throwing code } catch(Exception e) { // either log.error("Error fooing bar",e); // OR throw new RuntimeException(e); } ``` If you actually know that there is something you can do if a particular exception is thrown, the...
124,148
<p>Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue:</p> <pre><code>int i = 4; ... if (i == 10) doStuff(); </code></pre> <p>Later on you figure that you want the variable <em>i</em> to be either defined or un...
[ { "answer_id": 124190, "author": "rmeador", "author_id": 10861, "author_profile": "https://Stackoverflow.com/users/10861", "pm_score": 3, "selected": false, "text": "<p>Firstly, switching from using a primitive to using an object just to get the ability to set it to null is probably a ba...
2008/09/23
[ "https://Stackoverflow.com/questions/124148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8683/" ]
Mixing the use of primitive data types and their respective wrapper classes, in Java, can lead to a lot of bugs. The following example illustrates the issue: ``` int i = 4; ... if (i == 10) doStuff(); ``` Later on you figure that you want the variable *i* to be either defined or undefined, so you change the above ...
Using the boxed types *does* have both performance and memory issues. When doing comparisons (eg `(i == 10)` ), java has to unbox the type before doing the comparison. Even using `i.equals(TEN)` uses a method call, which is costlier and (IMO) uglier than the == syntax. Re memory, the object has to be stored on the he...
124,167
<p>Please explain to me why the very last <code>echo</code> statement is blank? I expect that <code>XCODE</code> is incremented in the while loop to a value of 1:</p> <pre><code>#!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "S...
[ { "answer_id": 124211, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 2, "selected": false, "text": "<pre><code> #!/bin/bash\n OUTPUT=\"name1 ip ip status\"\n+export XCODE=0;\n if [ -z \"$OUTPUT\" ]\n----\n\n ...
2008/09/23
[ "https://Stackoverflow.com/questions/124167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14230/" ]
Please explain to me why the very last `echo` statement is blank? I expect that `XCODE` is incremented in the while loop to a value of 1: ``` #!/bin/bash OUTPUT="name1 ip ip status" # normally output of another command with multi line output if [ -z "$OUTPUT" ] then echo "Status WARN: No messages from SMcli" ...
Because you're piping into the while loop, a sub-shell is created to run the while loop. Now this child process has its own copy of the environment and can't pass any variables back to its parent (as in any unix process). Therefore you'll need to restructure so that you're not piping into the loop. Alternatively you ...
124,205
<p>I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In <code>MySQL</code> I would use <code>SHOW TABLES LIKE "Datasheet%"</code>, but in <code>T-SQL</code> this throws an error (it tries to look for a <code>SHOW</code> stored procedure and fails).</p> <p>Is this possibl...
[ { "answer_id": 124216, "author": "Mladen", "author_id": 21404, "author_profile": "https://Stackoverflow.com/users/21404", "pm_score": 3, "selected": false, "text": "<p>Try this :</p>\n\n<pre><code>select * from information_schema.columns\nwhere table_name = 'yourTableName'\n</code></pre>...
2008/09/23
[ "https://Stackoverflow.com/questions/124205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21402/" ]
I would like to do a lookup of tables in my SQL Server 2005 Express database based on table name. In `MySQL` I would use `SHOW TABLES LIKE "Datasheet%"`, but in `T-SQL` this throws an error (it tries to look for a `SHOW` stored procedure and fails). Is this possible, and if so, how?
This will give you a list of the tables in the current database: ``` Select Table_name as "Table name" From Information_schema.Tables Where Table_type = 'BASE TABLE' and Objectproperty (Object_id(Table_name), 'IsMsShipped') = 0 ``` Some other useful T-SQL bits can be found here: <http://www.devx.com/tips/Tip/28529>
124,207
<p>I currently filter some message from my inbox with these steps:</p> <pre><code>select inbox pick messages set \Deleted tag </code></pre> <p>and then repeat the process after selecting Trash.</p> <p>Is there a more direct way of disposing of these messages? Or is it just the feature of the Mail server that deleti...
[ { "answer_id": 124245, "author": "mopoke", "author_id": 14054, "author_profile": "https://Stackoverflow.com/users/14054", "pm_score": 2, "selected": false, "text": "<p>Not sure exactly where you're doing these operations. IMAP itself doesn't specify that you move things to a Trash folder...
2008/09/23
[ "https://Stackoverflow.com/questions/124207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
I currently filter some message from my inbox with these steps: ``` select inbox pick messages set \Deleted tag ``` and then repeat the process after selecting Trash. Is there a more direct way of disposing of these messages? Or is it just the feature of the Mail server that deleting a message puts it in the trash,...
I believe you have to call EXPUNGE after setting the tag Deleted. [RFC 3501](http://www.faqs.org/rfcs/rfc3501.html)
124,240
<p>Been using <strong>PHP/MySQL</strong> for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using <code>mysql_fetch_object()</code> vs <code>mysql_fetch_assoc()</code> / <code>mysql_fetch_array()</code>.</p>
[ { "answer_id": 124262, "author": "Steve Paulo", "author_id": 9414, "author_profile": "https://Stackoverflow.com/users/9414", "pm_score": 2, "selected": false, "text": "<p>Fetching an array with <code>mysql_fetch_array()</code> lets you loop through the result set via either a foreach loo...
2008/09/23
[ "https://Stackoverflow.com/questions/124240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2227/" ]
Been using **PHP/MySQL** for a little while now, and I'm wondering if there are any specific advantages (performance or otherwise) to using `mysql_fetch_object()` vs `mysql_fetch_assoc()` / `mysql_fetch_array()`.
Performance-wise it doesn't matter what you use. The difference is that mysql\_fetch\_object returns object: ``` while ($row = mysql_fetch_object($result)) { echo $row->user_id; echo $row->fullname; } ``` mysql\_fetch\_assoc() returns associative array: ``` while ($row = mysql_fetch_assoc($result)) { ec...
124,266
<p>What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this.</p> <pre><code>$sortedObjectArary = sort($unsortedObjectArray, $Object-&gt;weight); </code></pre> <p>Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional...
[ { "answer_id": 124283, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 7, "selected": true, "text": "<p>Almost verbatim from the manual: </p>\n\n<pre><code>function compare_weights($a, $b) { \n if($a-&gt;weight == $b...
2008/09/23
[ "https://Stackoverflow.com/questions/124266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8880/" ]
What is an elegant way to sort objects in PHP? I would love to accomplish something similar to this. ``` $sortedObjectArary = sort($unsortedObjectArray, $Object->weight); ``` Basically specify the array I want to sort as well as the field I want to sort on. I looked into multidimensional array sorting and there migh...
Almost verbatim from the manual: ``` function compare_weights($a, $b) { if($a->weight == $b->weight) { return 0; } return ($a->weight < $b->weight) ? -1 : 1; } usort($unsortedObjectArray, 'compare_weights'); ``` If you want objects to be able to sort themselves, see example 3 here: <http://p...
124,269
<p>What is the simplest SOAP example using Javascript?</p> <p>To be as useful as possible, the answer should:</p> <ul> <li>Be functional (in other words actually work)</li> <li>Send at least one parameter that can be set elsewhere in the code</li> <li>Process at least one result value that can be read elsewhere in th...
[ { "answer_id": 124663, "author": "Constantin", "author_id": 20310, "author_profile": "https://Stackoverflow.com/users/20310", "pm_score": 1, "selected": false, "text": "<p>Simplest example would consist of:</p>\n\n<ol>\n<li>Getting user input.</li>\n<li><p>Composing XML SOAP message simi...
2008/09/23
[ "https://Stackoverflow.com/questions/124269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15985/" ]
What is the simplest SOAP example using Javascript? To be as useful as possible, the answer should: * Be functional (in other words actually work) * Send at least one parameter that can be set elsewhere in the code * Process at least one result value that can be read elsewhere in the code * Work with most modern brow...
This is the simplest JavaScript SOAP Client I can create. ``` <html> <head> <title>SOAP JavaScript Client Test</title> <script type="text/javascript"> function soap() { var xmlhttp = new XMLHttpRequest(); xmlhttp.open('POST', 'https://somesoapurl.com/', true); // b...
124,275
<p>I'm tired of using: </p> <pre><code>tail -f development.log </code></pre> <p>To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message.</p> <p>Does anyone know of a GUI tool for displaying rails logs. Idea...
[ { "answer_id": 124287, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 2, "selected": true, "text": "<p>FWIW I started <a href=\"http://github.com/SamSaffron/logviewer/tree/master\" rel=\"nofollow noreferrer\">this proje...
2008/09/23
[ "https://Stackoverflow.com/questions/124275", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17174/" ]
I'm tired of using: ``` tail -f development.log ``` To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message. Does anyone know of a GUI tool for displaying rails logs. Ideally I would like a standalone app...
FWIW I started [this project](http://github.com/SamSaffron/logviewer/tree/master) at GitHub to try and solve this problem, its far from functional.
124,291
<p>I need to do some simple timezone calculation in mod_perl. DateTime isn't an option. What I need to do is easily accomplished by setting $ENV{TZ} and using localtime and POSIX::mktime, but under a threaded MPM, I'd need to make sure only one thread at a time was mucking with the environment. (I'm not concerned ab...
[ { "answer_id": 125010, "author": "pjf", "author_id": 19422, "author_profile": "https://Stackoverflow.com/users/19422", "pm_score": 1, "selected": false, "text": "<p>If you're using apache 1.3, then you shouldn't need to resort to mutexes. Apache 1.3 spawns of a number of worker processe...
2008/09/23
[ "https://Stackoverflow.com/questions/124291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17389/" ]
I need to do some simple timezone calculation in mod\_perl. DateTime isn't an option. What I need to do is easily accomplished by setting $ENV{TZ} and using localtime and POSIX::mktime, but under a threaded MPM, I'd need to make sure only one thread at a time was mucking with the environment. (I'm not concerned about o...
(repeating what I said over at PerlMonks...) ``` BEGIN { my $mutex; sub that { $mutex ||= APR::ThreadMutex->new( $r->pool() ); $mutex->lock(); $ENV{TZ}= ...; ... $mutex->unlock(); } } ``` But, of course, lock() should happen in a c'tor and unlock() should happen...
124,295
<p>Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locations? I tried creating the assembly with the dll the project built in SQL, and while it d...
[ { "answer_id": 124528, "author": "Kevin Crumley", "author_id": 1818, "author_profile": "https://Stackoverflow.com/users/1818", "pm_score": 4, "selected": true, "text": "<p>Copy your assembly DLL file to the local drive on your various servers. Then register your assembly with the databa...
2008/09/23
[ "https://Stackoverflow.com/questions/124295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4539/" ]
Everything I have read says that when making a managed stored procedure, to right click in Visual Studio and choose deploy. That works fine, but what if I want to deploy it outside of Visual Studio to a number of different locations? I tried creating the assembly with the dll the project built in SQL, and while it did ...
Copy your assembly DLL file to the local drive on your various servers. Then register your assembly with the database: ``` create assembly [YOUR_ASSEMBLY] from '(PATH_TO_DLL)' ``` ...then you create a function referencing the appropriate public method in the DLL: ``` create proc [YOUR_FUNCTION] as external name [YO...
124,313
<p>I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that is performing web-service updates simultaneously...
[ { "answer_id": 124601, "author": "Aaron Jensen", "author_id": 11229, "author_profile": "https://Stackoverflow.com/users/11229", "pm_score": 1, "selected": false, "text": "<p>I believe you're actually wanting Serializable isolation level. The problem is that two threads can get past the H...
2008/09/23
[ "https://Stackoverflow.com/questions/124313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16454/" ]
I'm working on an application that is supposed to create products (like shipping insurance policies) when PayPal Instant Payment Notifications are received. Unfortunately, PayPal sometimes sends duplicate notifications. Furthermore, there is another third-party that is performing web-service updates simultaneously when...
It would be safer and cleaner if `insert into Policy` just hit some uniqueness table constraint on attempt to insert duplicate. Raising isolation level can lower concurrency and lead to other nasty issues like deadlocks. Another way is to always insert Policy row, then roll it back if Package has been attached to a Po...
124,314
<p>I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value "usedBuilding".</p> <p>Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is faster and does it actually matter which way ...
[ { "answer_id": 124324, "author": "mopoke", "author_id": 14054, "author_profile": "https://Stackoverflow.com/users/14054", "pm_score": 2, "selected": false, "text": "<p>If usedBuilding is indexed, it will be quicker to use the where clause since it will only access/update rows where usedB...
2008/09/23
[ "https://Stackoverflow.com/questions/124314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
I have a table that holds information about cities in a game, you can build one building each turn and this is recorded with the value "usedBuilding". Each turn I will run a script that alters usedBuilding to 0, the question is, which of the following two ways is faster and does it actually matter which way is used? ...
In general, the 2nd case (with the WHERE) clause would be faster - as it won't cause trigger evaluation, transaction logging, index updating, etc. on the unused rows. Potentially - depending on the distribution of 0/1 values, it could actually be faster to update all rows rather than doing the comparison - but that's ...
124,325
<p>I'm trying to grasp the concept of .NET Generics and actually use them in my own code but I keep running into a problem.</p> <p>Can someone try to explain to me why the following setup does not compile?</p> <pre><code>public class ClassA { ClassB b = new ClassB(); public void MethodA&lt;T&gt;(IRepo&lt;T&g...
[ { "answer_id": 124382, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 2, "selected": false, "text": "<p>The problem is a tricky one to get your head around. DetailType may inherit from ITypeEntity, but isn't actually ITyp...
2008/09/23
[ "https://Stackoverflow.com/questions/124325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/384853/" ]
I'm trying to grasp the concept of .NET Generics and actually use them in my own code but I keep running into a problem. Can someone try to explain to me why the following setup does not compile? ``` public class ClassA { ClassB b = new ClassB(); public void MethodA<T>(IRepo<T> repo) where T : ITypeEntity ...
Inheritance doesn't work the same when using generics. As Smashery points out, even if TypeA inherits from TypeB, myType<TypeA> doesn't inherit from myType<TypeB>. As such, you can't make a call to a method defined as MethodA(myType<TypeB> b) expecting a myType<TypeB> and give it a myType<TypeA> instead. The types in...
124,326
<p>JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"?</p> <p>This works:</p> <pre><code>var foo = function() { return 1; }; foo.baz = "qqqq"; </code></p...
[ { "answer_id": 124359, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": -1, "selected": false, "text": "<blockquote>\n <p>JavaScript allows functions to be\n treated as objects--you can add a\n property to a function. How do you...
2008/09/23
[ "https://Stackoverflow.com/questions/124326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11543/" ]
JavaScript allows functions to be treated as objects--if you first define a variable as a function, you can subsequently add properties to that function. How do you do the reverse, and add a function to an "object"? This works: ``` var foo = function() { return 1; }; foo.baz = "qqqq"; ``` At this point, `foo()` cal...
It's easy to be confused here, but you can't (easily or clearly or as far as I know) do what you want. Hopefully this will help clear things up. First, every object in Javascript inherits from the Object object. ``` //these do the same thing var foo = new Object(); var bar = {}; ``` Second, functions **ARE** object...
124,332
<p>I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like </p> <pre><code>P = C^d % n = 62^65 % 133 </code></pre> <p>Now that is really the only calculations that ill be doing. I have tried using Matt McC...
[ { "answer_id": 124344, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 1, "selected": false, "text": "<p>A long int is typically 64 bits which would probably not be enough to handle an integer that large. You'll probably n...
2008/09/23
[ "https://Stackoverflow.com/questions/124332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like ``` P = C^d % n = 62^65 % 133 ``` Now that is really the only calculations that ill be doing. I have tried using Matt McCutchen's BigInteger Librar...
I'd suggest using [gmp](http://gmplib.org/), it can handle arbitrarily long ints and has decent C++ bindings. afaik on current hardware/sofware long longs are 64bit, so unsigned can handle numbers up to (2\*\*64)-1 == 18446744073709551615 which is quite a bit smaller than numbers you'd have to deal with with RSA.
124,336
<p>I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type will have additional functionality that the p...
[ { "answer_id": 124347, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 6, "selected": true, "text": "<p>Not soundly, in \"managed\" languages. This is <em>downcasting</em>, and there is no sane down way to handle it, for e...
2008/09/23
[ "https://Stackoverflow.com/questions/124336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13688/" ]
I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type will have additional functionality that the pare...
Not soundly, in "managed" languages. This is *downcasting*, and there is no sane down way to handle it, for exactly the reason you described (subclasses provide more than base classes - where does this "more" come from?). If you really want a similar behaviour for a particular hierarchy, you could use constructors for ...
124,358
<p>Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the existing application?</p> <p>I defined the models, I defined controllers and views. They all wo...
[ { "answer_id": 124452, "author": "zadam", "author_id": 410357, "author_profile": "https://Stackoverflow.com/users/410357", "pm_score": 4, "selected": true, "text": "<p>I have done this previously, not with asp.net MVC but with pure asp.net web forms. I used a home-grown MVP (Model-View-...
2008/09/23
[ "https://Stackoverflow.com/questions/124358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1796/" ]
Although my question might seem abstract I hope it's not. Suppose I develop an application, an ASP.NET MVC site and later I am tasked to build an Winforms client for this application how much and how can I reuse from the existing application? I defined the models, I defined controllers and views. They all work well. ...
I have done this previously, not with asp.net MVC but with pure asp.net web forms. I used a home-grown MVP (Model-View-Presenter) pattern, and the absolute most important thing to allow the Presenter (== Controller in your case) to be used in a WinForms app was to not reference *anything* to do with system.web So the ...
124,374
<p>I need to recursively search directories and replace a string (say <a href="http://development:port/URI" rel="nofollow noreferrer">http://development:port/URI</a>) with another (say <a href="http://production:port/URI" rel="nofollow noreferrer">http://production:port/URI</a>) in all the files where ever it's found. ...
[ { "answer_id": 124400, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https://Stackoverflow.com/users/5314", "pm_score": 2, "selected": false, "text": "<p>It sounds like you would benefit from a layer of indirection. (But then, who wouldn't?) </p>\n\n<p>I'm thinking that...
2008/09/23
[ "https://Stackoverflow.com/questions/124374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1408/" ]
I need to recursively search directories and replace a string (say <http://development:port/URI>) with another (say <http://production:port/URI>) in all the files where ever it's found. Can anyone help? It would be much better if that script can print out the files that it modified and takes the search/replace pattern...
Try this: ``` find . -type f | xargs grep -l development | xargs perl -i.bak -p -e 's(http://development)(http://production)g' ``` Another approach with slightly more feedback: ``` find . -type f | while read file do grep development $file && echo "modifying $file" && perl -i.bak -p -e 's(http://development)(ht...
124,378
<p>I'm running my workstation on Server 2008 and a few servers in Hyper-V VM's on that server. I connect to my corporate LAN using VPN from the main OS (the host) but my VM's aren't seeing the servers in the corporate LAN. Internet and local access to my home network work fine. Each of the VMs has one virtual network a...
[ { "answer_id": 124495, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 0, "selected": false, "text": "<p>Setup some routes in your routing tablke. It really depends on how its setup but if you can access your corp network f...
2008/09/23
[ "https://Stackoverflow.com/questions/124378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21420/" ]
I'm running my workstation on Server 2008 and a few servers in Hyper-V VM's on that server. I connect to my corporate LAN using VPN from the main OS (the host) but my VM's aren't seeing the servers in the corporate LAN. Internet and local access to my home network work fine. Each of the VMs has one virtual network adap...
Like I said you need to setup some routes. Add a route to your Corp LAN via your Host as the gateway. Just the fact alone you telling me that it gets it from home DHCPP tells me that is the issue. Your VM's only see 1 default gateway, and that is to the internet. The VM's have no idea whatsoever that the Host has a VPN...
124,411
<p>But here's an example:</p> <pre><code>Dim desiredType as Type if IsNumeric(desiredType) then ... </code></pre> <p><strong>EDIT:</strong> I only know the Type, not the Value as a string.</p> <p>Ok, so unfortunately I have to cycle through the TypeCode.</p> <p>But this is a nice way to do it:</p> <pre><code> if (...
[ { "answer_id": 124443, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 5, "selected": false, "text": "<p>You can find out if a variable is numeric using the <code>Type.GetTypeCode()</code> method:</p>\n\n<pre><code>TypeCode t...
2008/09/23
[ "https://Stackoverflow.com/questions/124411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
But here's an example: ``` Dim desiredType as Type if IsNumeric(desiredType) then ... ``` **EDIT:** I only know the Type, not the Value as a string. Ok, so unfortunately I have to cycle through the TypeCode. But this is a nice way to do it: ``` if ((desiredType.IsArray)) return 0; switch (Type.GetTypeCod...
A few years late here, but here's my solution (you can choose whether to include boolean). Solves for the Nullable case. XUnit test included ``` /// <summary> /// Determines if a type is numeric. Nullable numeric types are considered numeric. /// </summary> /// <remarks> /// Boolean is not considered numeric. /// </r...
124,417
<p>I want to write a query like this:</p> <pre><code>SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o </code></pre> <p>But this isn't how the <code>MAX</code> function works, right? It is an aggregate function so it expects a single parameter and then returns the MAX of all rows. </p> <p>Do...
[ { "answer_id": 124441, "author": "Scott Langham", "author_id": 11898, "author_profile": "https://Stackoverflow.com/users/11898", "pm_score": 7, "selected": false, "text": "<p>I don't think so. I wanted this the other day. The closest I got was:</p>\n\n<pre><code>SELECT\n o.OrderId,\n C...
2008/09/23
[ "https://Stackoverflow.com/questions/124417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I want to write a query like this: ``` SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o ``` But this isn't how the `MAX` function works, right? It is an aggregate function so it expects a single parameter and then returns the MAX of all rows. Does anyone know how to do it my way?
You'd need to make a `User-Defined Function` if you wanted to have syntax similar to your example, but could you do what you want to do, inline, fairly easily with a `CASE` statement, as the others have said. The `UDF` could be something like this: ``` create function dbo.InlineMax(@val1 int, @val2 int) returns int a...
124,455
<p>I've got a Lua program that seems to be slower than it ought to be. I suspect the issue is that I'm adding values to an associative array one at a time and the table has to allocate new memory each time. </p> <p>There did seem to be a table.setn function, but it fails under Lua 5.1.3:</p> <pre><code>stdin:1: 'se...
[ { "answer_id": 124536, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 3, "selected": false, "text": "<p>I don't think you can - it's not an array, it's an associative array, like a perl hash or an awk array.</p>\n\n<p><a hr...
2008/09/23
[ "https://Stackoverflow.com/questions/124455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
I've got a Lua program that seems to be slower than it ought to be. I suspect the issue is that I'm adding values to an associative array one at a time and the table has to allocate new memory each time. There did seem to be a table.setn function, but it fails under Lua 5.1.3: ``` stdin:1: 'setn' is obsolete stack t...
Let me focus more on your question: > > adding values to an associative array > one at a time > > > Tables in Lua are associative, but using them in an array form (1..N) is optimized. They have double faces, internally. So.. If you indeed are adding values associatively, follow the rules above. If you are usin...
124,457
<p>I have limited experience with .net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to:</p> <p>"Register the following as a startup script:"</p> <pre><code>Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upp...
[ { "answer_id": 124466, "author": "Chris Ballance", "author_id": 1551, "author_profile": "https://Stackoverflow.com/users/1551", "pm_score": 0, "selected": false, "text": "<p>Put it in the header portion of the page</p>\n" }, { "answer_id": 124470, "author": "Wayne", "auth...
2008/09/23
[ "https://Stackoverflow.com/questions/124457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
I have limited experience with .net. My app throws an error this.dateTimeFormat is undefined which I tracked down to a known ajax bug. The workaround posted said to: "Register the following as a startup script:" ``` Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upperAbbrMonths) { this._u...
You would use [ClientScriptManager.RegisterStartupScript()](http://msdn.microsoft.com/en-us/library/z9h4dk8y.aspx) ``` string str = @"Sys.CultureInfo.prototype._getAbbrMonthIndex = function(value) { if (!this._upperAbbrMonths) { this._upperAbbrMonths = this._toUpperArray(this.dateTimeFormat.AbbreviatedMo...
124,462
<p>Is there a way in PHP to make asynchronous HTTP calls? I don't care about the response, I just want to do something like <code>file_get_contents()</code>, but not wait for the request to finish before executing the rest of my code. This would be super useful for setting off "events" of a sort in my application, or t...
[ { "answer_id": 124557, "author": "Internet Friend", "author_id": 18037, "author_profile": "https://Stackoverflow.com/users/18037", "pm_score": 5, "selected": false, "text": "<p>You can do trickery by using exec() to invoke something that can do HTTP requests, like <code>wget</code>, but ...
2008/09/23
[ "https://Stackoverflow.com/questions/124462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10680/" ]
Is there a way in PHP to make asynchronous HTTP calls? I don't care about the response, I just want to do something like `file_get_contents()`, but not wait for the request to finish before executing the rest of my code. This would be super useful for setting off "events" of a sort in my application, or triggering long...
The answer I'd previously accepted didn't work. It still waited for responses. This does work though, taken from [How do I make an asynchronous GET request in PHP?](https://stackoverflow.com/questions/962915/how-do-i-make-an-asynchronous-get-request-in-php) ``` function post_without_wait($url, $params) { foreach (...
124,492
<p>I need a short code snippet to get a directory listing from an HTTP server.</p> <p>Thanks</p>
[ { "answer_id": 124498, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "<p><strong>Basic understanding:</strong></p>\n\n<p>Directory listings are just HTML pages generated by a web server.\...
2008/09/23
[ "https://Stackoverflow.com/questions/124492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need a short code snippet to get a directory listing from an HTTP server. Thanks
A few important considerations before the code: 1. The HTTP Server has to be configured to allow directories listing for the directories you want; 2. Because directory listings are normal HTML pages there is no standard that defines the format of a directory listing; 3. Due to consideration **2** you are in the land w...
124,585
<p>This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no class should have more than x fields" won't help. </p> <...
[ { "answer_id": 124598, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 5, "selected": true, "text": "<p>If you did want to whitelist for performance reasons, consider using an annotation to indicate which fields to compare. A...
2008/09/23
[ "https://Stackoverflow.com/questions/124585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402777/" ]
This question is specifically related to overriding the equals() method for objects with a large number of fields. First off, let me say that this large object cannot be broken down into multiple components without violating OO principles, so telling me "no class should have more than x fields" won't help. Moving on,...
If you did want to whitelist for performance reasons, consider using an annotation to indicate which fields to compare. Also, this implementation won't work if your fields don't have good implementations for `equals()`. P.S. If you go this route for `equals()`, don't forget to do something similar for `hashCode()`. P...
124,606
<p>I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like:</p> <pre> $sql = sqlf("SELECT * FROM Users WHERE name= :1 AND email= :2",'Big "John"','bj@example.com') ; </pre> <p>For various reasons, I cannot use prepared statements, but I would like to emulate the...
[ { "answer_id": 124611, "author": "neouser99", "author_id": 10669, "author_profile": "https://Stackoverflow.com/users/10669", "pm_score": 4, "selected": true, "text": "<p>Null is the only value that you can guarantee is not in the set. How come it is not an option? Anything else can be se...
2008/09/23
[ "https://Stackoverflow.com/questions/124606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20512/" ]
I have a function that I use called sqlf(), it emulates prepared statements. For instance I can do things like: ``` $sql = sqlf("SELECT * FROM Users WHERE name= :1 AND email= :2",'Big "John"','bj@example.com') ; ``` For various reasons, I cannot use prepared statements, but I would like to emulate them. The problem...
Null is the only value that you can guarantee is not in the set. How come it is not an option? Anything else can be seen as part of the potential set, they are all values.
124,615
<p>Lets say I have a class that stores user information complete with getters and setters, and it is populated with data from an XML file. How would I iterate over all of the instances of that class like you would do with java beans and tag libraries?</p>
[ { "answer_id": 124783, "author": "Ta01", "author_id": 7280, "author_profile": "https://Stackoverflow.com/users/7280", "pm_score": 0, "selected": false, "text": "<p>This assumes you can acquire all instances of your class and add them to a Generic List.</p>\n\n<pre><code>List&lt;YourClass...
2008/09/23
[ "https://Stackoverflow.com/questions/124615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2066/" ]
Lets say I have a class that stores user information complete with getters and setters, and it is populated with data from an XML file. How would I iterate over all of the instances of that class like you would do with java beans and tag libraries?
For outputting formatted HTML, you have a few choices. What I would probably do is make a property on the code-behind that accesses the collection of objects you want to iterate over. Then, I'd write the logic for iterating and formatting them on the .aspx page itself. For example, the .aspx page: ``` [snip] <body> ...
124,630
<p>I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code:</p> <pre><code>public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new MemoryImageSource(width, height, pixels, 0...
[ { "answer_id": 124957, "author": "Steve Moyer", "author_id": 17008, "author_profile": "https://Stackoverflow.com/users/17008", "pm_score": 2, "selected": false, "text": "<p>I've had good success using java.awt.Robot to grab a screen shot (or a segment of the screen), but to work with Ima...
2008/09/24
[ "https://Stackoverflow.com/questions/124630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1119/" ]
I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code: ``` public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new MemoryImageSource(width, height, pixels, 0, width); ...
You can create the image without using ImageIO. Just create a BufferedImage using an image type matching the contents of the pixel array. ``` public static Image getImageFromArray(int[] pixels, int width, int height) { BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); ...
124,638
<p>I found an article on getting active tcp/udp connections on a machine.</p> <p><a href="http://www.codeproject.com/KB/IP/iphlpapi.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/IP/iphlpapi.aspx</a></p> <p>My issue however is I need to be able to determine active connections remotely - to see if a par...
[ { "answer_id": 124641, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 2, "selected": false, "text": "<p>There is no way to know which ports are open without the remote computer knowing it. But you can determine the in...
2008/09/24
[ "https://Stackoverflow.com/questions/124638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I found an article on getting active tcp/udp connections on a machine. <http://www.codeproject.com/KB/IP/iphlpapi.aspx> My issue however is I need to be able to determine active connections remotely - to see if a particular port is running or listening without tampering with the machine. Is this possible? Doesn't s...
There is no way to know which ports are open without the remote computer knowing it. But you can determine the information without the program running on the port knowing it (i.e. without interfering with the program). **Use SYN scanning:** To establish a connection, TCP uses a three-way handshake. This can be exploi...
124,647
<p>Say I have an array that represents a set of points:</p> <pre><code>x = [2, 5, 8, 33, 58] </code></pre> <p>How do I generate an array of all the pairwise distances? </p>
[ { "answer_id": 124734, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": 4, "selected": true, "text": "<pre><code>x = [2, 5, 8, 33, 58]\nprint x.collect {|n| x.collect {|i| (n-i).abs}}.flatten\n</code></pre>\n\n<p>I think tha...
2008/09/24
[ "https://Stackoverflow.com/questions/124647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
Say I have an array that represents a set of points: ``` x = [2, 5, 8, 33, 58] ``` How do I generate an array of all the pairwise distances?
``` x = [2, 5, 8, 33, 58] print x.collect {|n| x.collect {|i| (n-i).abs}}.flatten ``` I think that would do it.
124,649
<p>In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl_Loaded event is firing, the TextBox control isn't getting focus. I've included my very simple code b...
[ { "answer_id": 124778, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 1, "selected": false, "text": "<p>You code to set the focus is correct since if you add a button that calls the same code it works perfectly:</p>\n\n<pre>...
2008/09/24
[ "https://Stackoverflow.com/questions/124649", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4115/" ]
In my Silverlight application, I can't seem to bring focus to a TextBox control. On the recommendation of various posts, I've set the IsTabStop property to True and I'm using TextBox.Focus(). Though the UserControl\_Loaded event is firing, the TextBox control isn't getting focus. I've included my very simple code below...
I found this on silverlight.net, and was able to get it to work for me by adding a call to System.Windows.Browser.HtmlPage.Plugin.Focus() prior to calling RegularTextBox.Focus(): ``` private void UserControl_Loaded(object sender, RoutedEventArgs e) { System.Windows.Browser.HtmlPage.Plugin.Focus(); ...
124,671
<p>How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. Solutions for other languages are also welcome. </p>
[ { "answer_id": 124687, "author": "Swaroop C H", "author_id": 4869, "author_profile": "https://Stackoverflow.com/users/4869", "pm_score": 1, "selected": false, "text": "<p>Since you said \"Solutions for other languages are also welcome\", here's the version for Python:</p>\n\n<pre><code>&...
2008/09/24
[ "https://Stackoverflow.com/questions/124671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21445/" ]
How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. Solutions for other languages are also welcome.
``` int size = myHashSet.size(); int item = new Random().nextInt(size); // In real life, the Random object should be rather more shared than this int i = 0; for(Object obj : myhashSet) { if (i == item) return obj; i++; } ```
124,682
<p>Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators?</p> <p>For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.</p>
[ { "answer_id": 125127, "author": "sontek", "author_id": 17176, "author_profile": "https://Stackoverflow.com/users/17176", "pm_score": 1, "selected": false, "text": "<p>What you can do is hook into the validator and assign a new evaluate method, like this:</p>\n\n<pre><code> &lt;script t...
2008/09/24
[ "https://Stackoverflow.com/questions/124682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For instance use a asp:RequiredFieldValidator leave the server side code alone but implement your own client notification using jQuery to highlight the field or background color for example.
The standard **CustomValidator** has a **[ClientValidationFunction](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.clientvalidationfunction.aspx)** property for that: ``` <asp:CustomValidator ControlToValidate="Text1" ClientValidationFunction="onValidate" /> <s...
124,742
<p>Is there a documented max to the length of the string data you can use in the send method of an <code>XMLHttpRequest</code> for the major browser implementations?</p> <p>I am running into an issue with a JavaScript <code>XMLHttpRequest</code> Post failing in FireFox 3 when the data is over approx 3k. I was assuming...
[ { "answer_id": 124766, "author": "Zack The Human", "author_id": 18265, "author_profile": "https://Stackoverflow.com/users/18265", "pm_score": 4, "selected": true, "text": "<p>I believe the maximum length depends not only on the browser, but also on the web server. For example, the Apache...
2008/09/24
[ "https://Stackoverflow.com/questions/124742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7121/" ]
Is there a documented max to the length of the string data you can use in the send method of an `XMLHttpRequest` for the major browser implementations? I am running into an issue with a JavaScript `XMLHttpRequest` Post failing in FireFox 3 when the data is over approx 3k. I was assuming the Post would behave the same ...
I believe the maximum length depends not only on the browser, but also on the web server. For example, the Apache HTTP server has a [LimitRequestBody directive](http://httpd.apache.org/docs/2.0/mod/core.html#limitrequestbody) which allows anywhere from 0 bytes to 2GB worth of data.
124,786
<p>I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET and came across something odd I don't understand.</p> <p>Let's start with this encantation:</p> <pre><code> Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivat...
[ { "answer_id": 124823, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 4, "selected": true, "text": "<p>Check to see if the file you are opening has a <a href=\"http://en.wikipedia.org/wiki/Byte-order_mark\" rel=\"noreferre...
2008/09/24
[ "https://Stackoverflow.com/questions/124786", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91911/" ]
I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET and came across something odd I don't understand. Let's start with this encantation: ``` Private Declare Unicode Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringW" ( _ ...
Check to see if the file you are opening has a [byte order mark](http://en.wikipedia.org/wiki/Byte-order_mark) (a few bytes marking the type of text encoding). These Windows API calls don't seem to grok byte order marks and is causes them to miss the first section (hence everything works fine if there is a blank line)...
124,841
<p>I have written the following simple test in trying to learn Castle Windsor's Fluent Interface:</p> <pre><code>using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class MyComponent : IMyComponent { public MyCompon...
[ { "answer_id": 124846, "author": "Eric Schoonover", "author_id": 3957, "author_profile": "https://Stackoverflow.com/users/3957", "pm_score": 8, "selected": true, "text": "<p>Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you thin...
2008/09/24
[ "https://Stackoverflow.com/questions/124841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I have written the following simple test in trying to learn Castle Windsor's Fluent Interface: ``` using NUnit.Framework; using Castle.Windsor; using System.Collections; using Castle.MicroKernel.Registration; namespace WindsorSample { public class MyComponent : IMyComponent { public MyComponent(int start_...
Is the assembly in the Global Assembly Cache (GAC) or any place the might be overriding the assembly that you think is being loaded? This is usually the result of an incorrect assembly being loaded, for me it means I usually have something in the GAC overriding the version I have in bin/Debug.
124,854
<p>I have an <code>&lt;img&gt;</code> in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript?</p> <p>I only need it to work in Mozilla, but any and all information is welcome.</p> <p><em>EDIT: The reason I want to select the...
[ { "answer_id": 124867, "author": "Mike Stone", "author_id": 122, "author_profile": "https://Stackoverflow.com/users/122", "pm_score": -1, "selected": false, "text": "<p>You can swap the source of the image, as in img.src = \"otherimage.png\";</p>\n\n<p>I actually did this at one point, a...
2008/09/24
[ "https://Stackoverflow.com/questions/124854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7441/" ]
I have an `<img>` in an HTML document that I would like to highlight as though the user had highlighted it using the mouse. Is there a way to do that using JavaScript? I only need it to work in Mozilla, but any and all information is welcome. *EDIT: The reason I want to select the image is actually not so that it app...
Here's an example which selects the first image on the page (which will be the Stack Overflow logo if you test it out on this page in Firebug): ``` var s = window.getSelection() var r = document.createRange(); r.selectNode(document.images[0]); s.addRange(r) ``` Relevant documentation: * <http://developer.mozilla.or...
124,856
<p>I'd like to ensure my RAII class is always allocated on the stack.</p> <p>How do I prevent a class from being allocated via the 'new' operator?</p>
[ { "answer_id": 124857, "author": "Kevin", "author_id": 6386, "author_profile": "https://Stackoverflow.com/users/6386", "pm_score": 6, "selected": false, "text": "<p>All you need to do is declare the class' new operator private:</p>\n\n<pre><code>class X\n{\n private: \n // Preven...
2008/09/24
[ "https://Stackoverflow.com/questions/124856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6386/" ]
I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from being allocated via the 'new' operator?
All you need to do is declare the class' new operator private: ``` class X { private: // Prevent heap allocation void * operator new (size_t); void * operator new[] (size_t); void operator delete (void *); void operator delete[] (void*); // ... // The rest of the imp...
124,865
<p>At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file.</p> <p>Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema?</p> <p>We would prefer free tools...
[ { "answer_id": 124933, "author": "John", "author_id": 13895, "author_profile": "https://Stackoverflow.com/users/13895", "pm_score": 2, "selected": false, "text": "<p>I use Xerces:</p>\n\n<p><a href=\"http://xerces.apache.org/xerces-c/\" rel=\"nofollow noreferrer\">http://xerces.apache.or...
2008/09/24
[ "https://Stackoverflow.com/questions/124865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5113/" ]
At the office we are currently writing an application that will generate XML files against a schema that we were given. We have the schema in an .XSD file. Are there tool or libraries that we can use for automated testing to check that the generated XML matches the schema? We would prefer free tools that are appropri...
After some research, I think the best answer is [Xerces](http://xerces.apache.org/), as it implements all of XSD, is cross-platform and widely used. I've created a [small Java project on github](https://github.com/amouat/xsd-validator) to validate from the command line using the default JRE parser, which is normally Xe...
124,880
<p>Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap?</p>
[ { "answer_id": 124903, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 4, "selected": false, "text": "<p>You could make the constructor <code>private</code>, then provide a <code>public</code> static factory method to crea...
2008/09/24
[ "https://Stackoverflow.com/questions/124880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to prevent stack allocation of an object and only allow it to be instiated with 'new' on the heap?
One way you could do this would be to make the constructors private and only allow construction through a static method that returns a pointer. For example: ``` class Foo { public: ~Foo(); static Foo* createFoo() { return new Foo(); } private: Foo(); Foo(const Foo&); Foo& operator=(...
124,935
<p>I'm using scriptaculous's Ajax.Autocompleter for a search with different filters. </p> <p><a href="http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter" rel="nofollow noreferrer">http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter</a></p> <p>The filters are requiring me to pass data into...
[ { "answer_id": 125027, "author": "Jonny Buchanan", "author_id": 6760, "author_profile": "https://Stackoverflow.com/users/6760", "pm_score": 1, "selected": false, "text": "<p>Having looked at the Scriptaculous source to see <a href=\"http://github.com/madrobby/scriptaculous/tree/master/sr...
2008/09/24
[ "https://Stackoverflow.com/questions/124935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21456/" ]
I'm using scriptaculous's Ajax.Autocompleter for a search with different filters. <http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter> The filters are requiring me to pass data into the autocompleter dynamically, which I've successfully learned to do from the following link. <http://www.simpltry.com...
To answer my own question: fake a key press. It ensures that the request is made, and that the dropdown box becomes visible. Here's my function to fake the key press, which takes into account the differences in IE and Firefox. ``` function fakeKeyPress(input_id) { var input = $(input_id); if(input.fireEvent...
124,946
<p>My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, wri...
[ { "answer_id": 125059, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I haven't had time to test this but I think you may need to call the Flush method of the BinaryWriter</p>\n\n<pre><code>Fil...
2008/09/24
[ "https://Stackoverflow.com/questions/124946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
My question is based off of inheriting a great deal of legacy code that I can't do very much about. Basically, I have a device that will produce a block of data. A library which will call the device to create that block of data, for some reason I don't entirely understand and cannot change even if I wanted to, writes t...
Your consumer must specify FileShare.ReadWrite. By trying to open the file as FileShare.Read in the consumer you are saying "I want to open the file and let others read it at the same time" ... since there is **already** a writer that call fails, you have to allow concurrent writes with the reader.
124,958
<p>I'm trying to display an array of files in order of date (last modified).</p> <p>I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?</p>
[ { "answer_id": 125047, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 8, "selected": true, "text": "<blockquote>\n <p><strong>Warning</strong> <code>create_function()</code> has been DEPRECATED as of PHP 7.2.0. Relying on this...
2008/09/24
[ "https://Stackoverflow.com/questions/124958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/910/" ]
I'm trying to display an array of files in order of date (last modified). I have done this buy looping through the array and sorting it into another array, but is there an easier (more efficient) way to do this?
> > **Warning** `create_function()` has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged. > > > For the sake of posterity, in case the forum post linked in the accepted answer is lost or unclear to some, the relevant code needed is: ``` <?php $myarray = glob("*.*"); usort($myarray...
124,959
<p>Whats the available solutions for PHP to create word document in linux environment?</p>
[ { "answer_id": 125009, "author": "Sergey Kornilov", "author_id": 10969, "author_profile": "https://Stackoverflow.com/users/10969", "pm_score": 5, "selected": false, "text": "<h3>real Word documents</h3>\n\n<p>If you need to produce \"real\" Word documents you need a Windows-based web ser...
2008/09/24
[ "https://Stackoverflow.com/questions/124959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Whats the available solutions for PHP to create word document in linux environment?
### real Word documents If you need to produce "real" Word documents you need a Windows-based web server and COM automation. I highly recommend [Joel's article](http://www.joelonsoftware.com/items/2008/02/19.html) on this subject. ### *fake* HTTP headers for tricking Word into opening raw HTML A rather common (but u...
124,975
<p>I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too.</p> <p>Does anyone know of a premade component that could do this?</p>
[ { "answer_id": 125051, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 3, "selected": false, "text": "<p>Take a look at the <a href=\"http://www.icsharpcode.net/OpenSource/SD/\" rel=\"noreferrer\">SharpDevelop</a> C# compiler/IDE ...
2008/09/24
[ "https://Stackoverflow.com/questions/124975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
I'm looking for a free winforms component for an application I'm writing. I basicly need a textbox that contains line numbers in a side column. Being able to tabulate data within it would be a major plus too. Does anyone know of a premade component that could do this?
Referencing [Wayne's post](https://stackoverflow.com/questions/124975/windows-forms-textbox-that-has-line-numbers#125093), here is the relevant code. It is using GDI to draw line numbers next to the text box. ``` Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. Initialize...
125,034
<p>In Python, I want to make <strong>selected</strong> instance attributes of a class be readonly to code outside of the class. I want there to be no way outside code can alter the attribute, except indirectly by invoking methods on the instance. I want the syntax to be concise. What is the best way? (I give my current...
[ { "answer_id": 125053, "author": "Dan Udey", "author_id": 21450, "author_profile": "https://Stackoverflow.com/users/21450", "pm_score": 1, "selected": false, "text": "<p>There is no real way to do this. There are ways to make it more 'difficult', but there's no concept of completely hidd...
2008/09/24
[ "https://Stackoverflow.com/questions/125034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14028/" ]
In Python, I want to make **selected** instance attributes of a class be readonly to code outside of the class. I want there to be no way outside code can alter the attribute, except indirectly by invoking methods on the instance. I want the syntax to be concise. What is the best way? (I give my current best answer bel...
You should use the `@property` decorator. ``` >>> class a(object): ... def __init__(self, x): ... self.x = x ... @property ... def xval(self): ... return self.x ... >>> b = a(5) >>> b.xval 5 >>> b.xval = 6 Traceback (most recent call last): File "<stdin>", line 1, in <module> Att...
125,050
<p>...or are they the same thing? I notice that each has its own Wikipedia entry: <a href="http://en.wikipedia.org/wiki/Polymorphism_(computer_science)" rel="noreferrer">Polymorphism</a>, <a href="http://en.wikipedia.org/wiki/Multiple_dispatch" rel="noreferrer">Multiple Dispatch</a>, but I'm having trouble seeing how t...
[ { "answer_id": 125064, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 0, "selected": false, "text": "<p>Multiple Dispatch is a kind of polymorphism. In Java/C#/C++, there is polymorphism through inheritance and overriding...
2008/09/24
[ "https://Stackoverflow.com/questions/125050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
...or are they the same thing? I notice that each has its own Wikipedia entry: [Polymorphism](http://en.wikipedia.org/wiki/Polymorphism_(computer_science)), [Multiple Dispatch](http://en.wikipedia.org/wiki/Multiple_dispatch), but I'm having trouble seeing how the concepts differ. **Edit:** And how does [Overloading](h...
Polymorphism is the facility that allows a language/program to make decisions during runtime on which method to invoke based on the types of the parameters sent to that method. The number of parameters used by the language/runtime determines the 'type' of polymorphism supported by a language. Single dispatch is a t...