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
249,775
<p>Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory?</p> <p>What I want to do is the copy a file if it's on a different, but move it if it's the same. For example:</p> <pre><code>target_directory = "/Volumes/externa...
[ { "answer_id": 249796, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 5, "selected": true, "text": "<p>In C, you would use <code>stat()</code> and compare the <code>st_dev</code> field. In python, <code>os.stat</code> should...
2008/10/30
[ "https://Stackoverflow.com/questions/249775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
Say I have an input file, and a target directory. How do I determine if the input file is on the same hard-drive (or partition) as the target directory? What I want to do is the copy a file if it's on a different, but move it if it's the same. For example: ``` target_directory = "/Volumes/externalDrive/something/" in...
In C, you would use `stat()` and compare the `st_dev` field. In python, `os.stat` should do the same. ``` import os def same_partition(f1, f2): return os.stat(f1).st_dev == os.stat(f2).st_dev ```
249,779
<p>I'm using a <code>BindingList&lt;T&gt;</code> in my Windows Forms that contains a list of "<code>IComparable&lt;Contact&gt;</code>" Contact-objects. Now I'd like the user to be able to sort by any column displayed in the grid.</p> <p>There is a way described on MSDN online which shows how to implement a custom coll...
[ { "answer_id": 249816, "author": "Darren C", "author_id": 32339, "author_profile": "https://Stackoverflow.com/users/32339", "pm_score": 0, "selected": false, "text": "<p>Not for custom objects. In .Net 2.0, I had to roll my on sorting using BindingList. There may be something new in .Net...
2008/10/30
[ "https://Stackoverflow.com/questions/249779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17713/" ]
I'm using a `BindingList<T>` in my Windows Forms that contains a list of "`IComparable<Contact>`" Contact-objects. Now I'd like the user to be able to sort by any column displayed in the grid. There is a way described on MSDN online which shows how to implement a custom collection based on `BindingList<T>` which allow...
I higly appreciate [Matthias' solution](https://stackoverflow.com/a/281324/3834) for its simplicity and beauty. However, while this gives excellent results for low data volumes, when working with large data volumes the performance is not so good, due to reflection. I ran a test with a collection of simple data object...
249,780
<p>I have a really simple search form with the following</p> <ul> <li>Label ("Search")</li> <li>Textbox (fixed width)</li> <li>Submit button</li> <li>"Advanced" link</li> </ul> <p>Label, textbox and submit are all on one horizontal line and centered. Now I would like my advanced link to be under the submit button.</p...
[ { "answer_id": 249790, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 3, "selected": true, "text": "<p>If I understand the question you want:</p>\n\n<pre><code> Search [xxxxxxxxxxxxxxxx] [Submit]\n ...
2008/10/30
[ "https://Stackoverflow.com/questions/249780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I have a really simple search form with the following * Label ("Search") * Textbox (fixed width) * Submit button * "Advanced" link Label, textbox and submit are all on one horizontal line and centered. Now I would like my advanced link to be under the submit button. Any ideas?
If I understand the question you want: ``` Search [xxxxxxxxxxxxxxxx] [Submit] Advanced ``` You'll have to add some more elements in to do that: ``` <div style="width: 300px; margin: auto; text-align: center;"> Search [xxxxxxxxxxxxxxx] [Submit] <div style...
249,785
<p>Simply moving the file to <code>~/.Trash/</code> will not work, as if the file os on an external drive, it will move the file to the main system drive..</p> <p>Also, there are other conditions, like files on external drives get moved to <code>/Volumes/.Trash/501/</code> (or whatever the current user's ID is)</p> <...
[ { "answer_id": 249800, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 2, "selected": false, "text": "<p>The File Manager API has a pair of functions called FSMoveObjectToTrashAsync and FSPathMoveObjectToTrashSync.</p>...
2008/10/30
[ "https://Stackoverflow.com/questions/249785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
Simply moving the file to `~/.Trash/` will not work, as if the file os on an external drive, it will move the file to the main system drive.. Also, there are other conditions, like files on external drives get moved to `/Volumes/.Trash/501/` (or whatever the current user's ID is) Given a file or folder path, what is ...
Alternatively, if you're on OS X 10.5, you could use Scripting Bridge to delete files via the Finder. I've done this in Ruby code [here](http://osx-trash.rubyforge.org/git?p=osx-trash.git;a=blob;f=bin/trash;h=26911131eacafd659b4d760bda1bd4c99dc2f918;hb=HEAD) via RubyCocoa. The the gist of it is: ``` url = NSURL.fileUR...
249,787
<p>I am in the process of moving from VSS to SVN and I'm not sure how to share files in SVN.</p> <p>Basically we have the following structure in VSS</p> <pre><code>$MOSS - Components - ComponentA - bin - ComponentB - bin - GAC Mirror </code></pre> <p>GAC Mirror holds a shared copy of all the ...
[ { "answer_id": 249808, "author": "RickL", "author_id": 7261, "author_profile": "https://Stackoverflow.com/users/7261", "pm_score": 1, "selected": false, "text": "<p>We had the same problem. The simple answer is that you can't share files in SVN - in the end we had to restructure our dir...
2008/10/30
[ "https://Stackoverflow.com/questions/249787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26792/" ]
I am in the process of moving from VSS to SVN and I'm not sure how to share files in SVN. Basically we have the following structure in VSS ``` $MOSS - Components - ComponentA - bin - ComponentB - bin - GAC Mirror ``` GAC Mirror holds a shared copy of all the Dlls from the bin folders of the ...
Is svn:externals what you're after? <http://svnbook.red-bean.com/en/1.0/ch07s03.html>
249,791
<p>How do I get the substring <code>" It's big \"problem "</code> using a regular expression?</p> <pre><code>s = ' function(){ return " It\'s big \"problem "; }'; </code></pre>
[ { "answer_id": 249804, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "<pre><code>/([\"\\']).*?(?&lt;!\\\\)(\\\\\\\\)*\\1/is\n</code></pre>\n\n<p>should work with any quoted string</p>\n" }, { ...
2008/10/30
[ "https://Stackoverflow.com/questions/249791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I get the substring `" It's big \"problem "` using a regular expression? ``` s = ' function(){ return " It\'s big \"problem "; }'; ```
``` /"(?:[^"\\]|\\.)*"/ ``` Works in The Regex Coach and PCRE Workbench. Example of test in JavaScript: ```js var s = ' function(){ return " Is big \\"problem\\", \\no? "; }'; var m = s.match(/"(?:[^"\\]|\\.)*"/); if (m != null) alert(m); ```
249,794
<p>I'me looking for a function that would receive a time and would round it to the next/previous hour / half-hour / quarter / minute.</p>
[ { "answer_id": 249828, "author": "IAdapter", "author_id": 30453, "author_profile": "https://Stackoverflow.com/users/30453", "pm_score": 6, "selected": true, "text": "<p>Try this function</p>\n\n<pre><code>CREATE FUNCTION [dbo].[RoundTime] (@Time datetime, @RoundTo float)\nRETURNS datetim...
2008/10/30
[ "https://Stackoverflow.com/questions/249794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1842864/" ]
I'me looking for a function that would receive a time and would round it to the next/previous hour / half-hour / quarter / minute.
Try this function ``` CREATE FUNCTION [dbo].[RoundTime] (@Time datetime, @RoundTo float) RETURNS datetime AS BEGIN DECLARE @RoundedTime smalldatetime DECLARE @Multiplier float SET @Multiplier= 24.0/@RoundTo SET @RoundedTime= ROUND(CAST(CAST(CONVERT(varchar,@Time,121) AS datetime) AS float) * @Multiplier,...
249,797
<p>I'm currently using the ActiveRecord-based session store for my Rails app and I have a background process which clears out inactive sessions every 30 minutes.</p> <p>I'd like to switch to Rails' new cookie-based session store but how do I set the expiry time of the session to 30 minutes, as opposed to the default '...
[ { "answer_id": 249830, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 2, "selected": false, "text": "<p>The <a href=\"http://wiki.rubyonrails.org/rails/pages/HowtoChangeSessionOptions\" rel=\"nofollow noreferrer\">session op...
2008/10/30
[ "https://Stackoverflow.com/questions/249797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1174/" ]
I'm currently using the ActiveRecord-based session store for my Rails app and I have a background process which clears out inactive sessions every 30 minutes. I'd like to switch to Rails' new cookie-based session store but how do I set the expiry time of the session to 30 minutes, as opposed to the default 'at end of ...
I stumbled across this question after a conversation in the office. Just for the sake of completeness, I've discovered that it is possible to expire sessions after a period of inactivity and it's built into Rails. In config/environment.rb, do something along the lines of: ``` config.action_controller.session = { :ke...
249,819
<p>I have the following sql query for transforming data but is it possible to save the value of the int in some variable to avoid casting multiple times?</p> <pre><code>update prospekts set sni_kod = case when cast(sni_kod as int) &gt;= 1000 and cast(sni_kod as int) &lt;= 1499 or cast(sni_kod as int) &gt;= ...
[ { "answer_id": 249836, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 1, "selected": false, "text": "<p>you can use a subquery or CTE:</p>\n\n<pre><code>With xxx AS (\n i_sni_kod = cast(sni_kod as int)\n ...)\nU...
2008/10/30
[ "https://Stackoverflow.com/questions/249819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22092/" ]
I have the following sql query for transforming data but is it possible to save the value of the int in some variable to avoid casting multiple times? ``` update prospekts set sni_kod = case when cast(sni_kod as int) >= 1000 and cast(sni_kod as int) <= 1499 or cast(sni_kod as int) >= 1600 and cast(sni_kod a...
Ok... here's my rewrite of your code... ``` UPDATE prospekts SET sni_kod = CASE WHEN ISNUMERIC(@sni_kod)=1 THEN CASE WHEN cast(@sni_kod as int) BETWEEN 1000 AND 1499 OR cast(@sni_kod as int) BETWEEN 1600 AND 2439 THEN '1' WHEN cast(@sni_kod as int) BETWEEN 7000...
249,860
<p>How can i restrict adding controls in Panel in C# window controls? I have to restrict user to add controls in a panel at design time.</p>
[ { "answer_id": 249890, "author": "Echostorm", "author_id": 12862, "author_profile": "https://Stackoverflow.com/users/12862", "pm_score": -1, "selected": false, "text": "<p>Set AllowDrop to false.</p>\n" }, { "answer_id": 249934, "author": "Rune Grimstad", "author_id": 303...
2008/10/30
[ "https://Stackoverflow.com/questions/249860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31159/" ]
How can i restrict adding controls in Panel in C# window controls? I have to restrict user to add controls in a panel at design time.
If you want to limit the types of controls or number of controls one can add to the panel you can make your own subclass of the panel and check the Control type or Control count in an overload of the Controls.Add method. Edit: Overloading the Controls.Add method was not as easy as I thought, but you can make a new cl...
249,865
<p>We're seeing the error message ORA-00936 Missing Expression for the following SQL:</p> <p>Note that this is just a cut-down version of a much bigger SQL so rewriting it to a inner join or similar is not really in the scope of this:</p> <p>This is the SQL that fails:</p> <pre><code>select (select count(*) from gt_...
[ { "answer_id": 249915, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 2, "selected": true, "text": "<p>That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different...
2008/10/30
[ "https://Stackoverflow.com/questions/249865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/267/" ]
We're seeing the error message ORA-00936 Missing Expression for the following SQL: Note that this is just a cut-down version of a much bigger SQL so rewriting it to a inner join or similar is not really in the scope of this: This is the SQL that fails: ``` select (select count(*) from gt_roster where ROS_ROSTERPLAN_...
That should work, assuming the column names are not ambiguous (and even if they were that would lead to a different error). I ran an equivalent statement and got a result without error: ``` SQL> select (select count(*) from emp2 where empdeptno = deptno) 2 from dept 3 where deptno=10 4 / (SELECTCOUNT(*)FROME...
249,866
<p>I'm creating a <code>Path</code> in <em>Silverlight</em>, and adding elements to it on mouse events. But, although the elements are there in memory, the screen doesn't get updated until something else causes a screen repaint to happen.</p> <p>Here's the relevant code - I'm responding to a mouse event, and I keep a ...
[ { "answer_id": 250873, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 0, "selected": false, "text": "<p>What kind of element is your layout root? I copied your code and used a Canvas as the layout root and it works great in ...
2008/10/30
[ "https://Stackoverflow.com/questions/249866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6483/" ]
I'm creating a `Path` in *Silverlight*, and adding elements to it on mouse events. But, although the elements are there in memory, the screen doesn't get updated until something else causes a screen repaint to happen. Here's the relevant code - I'm responding to a mouse event, and I keep a class member of the path I'm...
I needed something very similar but drawing on the new Silverlight VE Map Control. Your code above worked fine without any fiddling other properties to 'force a redraw'. Code here for your reference: ``` using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Microsoft.VirtualEarth...
249,867
<p>I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object?</p> <p>The scenario is as follows</p> <pre><code>pulbic class SillyClassName { object moo; ... public void method1(){ synchronized(moo) { .... method2(); ...
[ { "answer_id": 249888, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>In java, the <code>synchronized</code> keyword on a method basically synchronizes on the current object, so in effect it's ...
2008/10/30
[ "https://Stackoverflow.com/questions/249867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20400/" ]
I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object? The scenario is as follows ``` pulbic class SillyClassName { object moo; ... public void method1(){ synchronized(moo) { .... method2(); .... } ...
Reentrant ========= Synchronized blocks use *reentrant* locks, which means if the thread already holds the lock, it can re-aquire it without problems. Therefore your code will work as you expect. See the bottom of the [Java Tutorial](https://docs.oracle.com/javase/tutorial/index.html) page [Intrinsic Locks and Synchr...
249,883
<p>I have two XML files with two different XSD schemas and different namespaces. They have both an identical substructure. And now i need to copy that node (and all childs) from one XML document to the other one. </p> <p>Clone would do, if the namespaces were the same. Is there a nice way to do it? (The substructure ...
[ { "answer_id": 250057, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "<p>Basically, you need an XSL transformation that creates new elements with equal names, but a different namespace.</p>\n\n...
2008/10/30
[ "https://Stackoverflow.com/questions/249883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32726/" ]
I have two XML files with two different XSD schemas and different namespaces. They have both an identical substructure. And now i need to copy that node (and all childs) from one XML document to the other one. Clone would do, if the namespaces were the same. Is there a nice way to do it? (The substructure will chang...
Basically, you need an XSL transformation that creates new elements with equal names, but a different namespace. Consider the following input XML: ``` <?xml version="1.0" encoding="UTF-8"?> <test xmlns="http://tempuri.org/ns_old"> <child attrib="value">text</child> </test> ``` Now you need a template that says ...
249,926
<pre><code>&lt;a id="lblShowTimings" runat="server" title='&lt;%# Eval("SHOW_Name") %&gt;' onclick='PopulateTicketDiv(&lt;%#Eval("SHOW_ID") %&gt;)'&gt; &lt;-- this is the problem %#Eval("SHOW_Time") %&gt; &lt;/a&gt; </code></pre> <p>Can Eval be passed as an argument to a javascript function? If so wh...
[ { "answer_id": 249986, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 6, "selected": true, "text": "<p>Yes. What you want to do is this, though:</p>\n\n<pre><code>onclick='&lt;%# \"PopulateTicketDiv(\" +Eval(\"SHOW_ID\"...
2008/10/30
[ "https://Stackoverflow.com/questions/249926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
``` <a id="lblShowTimings" runat="server" title='<%# Eval("SHOW_Name") %>' onclick='PopulateTicketDiv(<%#Eval("SHOW_ID") %>)'> <-- this is the problem %#Eval("SHOW_Time") %> </a> ``` Can Eval be passed as an argument to a javascript function? If so whats the syntax?
Yes. What you want to do is this, though: ``` onclick='<%# "PopulateTicketDiv(" +Eval("SHOW_ID") + " );" %>' ```
249,927
<p>How can I restart(recycle) IIS Application Pool from C# (.net 2)?</p> <p>Appreciate if you post sample code?</p>
[ { "answer_id": 249942, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 7, "selected": true, "text": "<p>If you're on <strong>IIS7</strong> then this will do it if it is stopped. I assume you can adjust for restarting without h...
2008/10/30
[ "https://Stackoverflow.com/questions/249927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I restart(recycle) IIS Application Pool from C# (.net 2)? Appreciate if you post sample code?
If you're on **IIS7** then this will do it if it is stopped. I assume you can adjust for restarting without having to be shown. ``` // Gets the application pool collection from the server. [ModuleServiceMethod(PassThrough = true)] public ArrayList GetApplicationPoolCollection() { // Use an ArrayList to transfer ob...
249,968
<p>I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest).</p> <p>Most of the time, this works fine. The request is sent with an <strong>X-Requested-With</strong> value of <strong>XMLHttpRequest</strong>. My PHP controller code uses apache_request_headers() to che...
[ { "answer_id": 250242, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 0, "selected": false, "text": "<p>Double-check that the missing header is not in the superglobal <code>$_SERVER</code>. In general, I wouldn't rely on apache_...
2008/10/30
[ "https://Stackoverflow.com/questions/249968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24106/" ]
I have written a web app in PHP which makes use of Ajax requests (made using YUI.util.Connect.asyncRequest). Most of the time, this works fine. The request is sent with an **X-Requested-With** value of **XMLHttpRequest**. My PHP controller code uses apache\_request\_headers() to check whether an incoming request is Aj...
I'm not sure why the apache\_request\_headers() and firebug mismatching, but in order to read request headers you can use the $\_SERVER super global each header that is being sent by a client (and it doesn't matter how is the client) will arrive to the $*SERVER array. The key of that header will be with HTTP* prefix, ...
249,971
<p>Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ?</p> <p>Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform <strong>the points</strong> of the PathGeometry object <strong>in pla...
[ { "answer_id": 250028, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": -1, "selected": false, "text": "<p>There are two things you have to consider:</p>\n\n<ol>\n<li>Geometry inherits from Freezable, you can't modify the geometry ...
2008/10/30
[ "https://Stackoverflow.com/questions/249971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4685/" ]
Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ? Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform **the points** of the PathGeometry object **in place** using a transform, and n...
You could try and use Geometry.Combine. It applies a transform during the combine. One catch is that Combine only works if your Geometry has area, so single lines will not work. Here is a sample that worked for me. ``` PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(new PathFigure(new Point(10, 10), ...
249,979
<p>In the below code snippet can i replace char * to const char * and remove the strdup() function call and directly take the optarg value set by getopt()? I am advised to use const char * to skip the strdup function usage. Appreciate the help in advance.</p> <pre><code>/* Code Snippet */ char *dir = NULL; char *bld ...
[ { "answer_id": 250028, "author": "Nir", "author_id": 3509, "author_profile": "https://Stackoverflow.com/users/3509", "pm_score": -1, "selected": false, "text": "<p>There are two things you have to consider:</p>\n\n<ol>\n<li>Geometry inherits from Freezable, you can't modify the geometry ...
2008/10/30
[ "https://Stackoverflow.com/questions/249979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18657/" ]
In the below code snippet can i replace char \* to const char \* and remove the strdup() function call and directly take the optarg value set by getopt()? I am advised to use const char \* to skip the strdup function usage. Appreciate the help in advance. ``` /* Code Snippet */ char *dir = NULL; char *bld = NULL; int...
You could try and use Geometry.Combine. It applies a transform during the combine. One catch is that Combine only works if your Geometry has area, so single lines will not work. Here is a sample that worked for me. ``` PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(new PathFigure(new Point(10, 10), ...
249,991
<p>I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example:</p> <pre><code>#someElement { foo: 'bar'; } </code></pre> <p>I have managed to get its value with the currentStyle property in IE7:</p> <pre><code>var elem...
[ { "answer_id": 250140, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 4, "selected": true, "text": "<p>Firefox does not carry over tags, attributes or CSS styles it does not understand from the code to the DOM. That is ...
2008/10/30
[ "https://Stackoverflow.com/questions/249991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27741/" ]
I am trying to read a custom (non-standard) CSS property, set in a stylesheet (not the inline style attribute) and get its value. Take this CSS for example: ``` #someElement { foo: 'bar'; } ``` I have managed to get its value with the currentStyle property in IE7: ``` var element = document.getElementById('someEl...
Firefox does not carry over tags, attributes or CSS styles it does not understand from the code to the DOM. That is by design. Javascript only has access to the DOM, not the code. So no, there is no way to access a property from javascript that the browser itself does not support.
249,994
<p>I have a dump of a windows service i made. The exception is that my code can't move a file (for some reason). Now, in my code there's a number of places where i move files around the filesystem. So, using Windbg, i'm trying to see the code where the exception occurs.</p> <p>here's my !clrstack dump..</p> <pre><cod...
[ { "answer_id": 250140, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 4, "selected": true, "text": "<p>Firefox does not carry over tags, attributes or CSS styles it does not understand from the code to the DOM. That is ...
2008/10/30
[ "https://Stackoverflow.com/questions/249994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I have a dump of a windows service i made. The exception is that my code can't move a file (for some reason). Now, in my code there's a number of places where i move files around the filesystem. So, using Windbg, i'm trying to see the code where the exception occurs. here's my !clrstack dump.. ``` 0:016> !clrstack -p...
Firefox does not carry over tags, attributes or CSS styles it does not understand from the code to the DOM. That is by design. Javascript only has access to the DOM, not the code. So no, there is no way to access a property from javascript that the browser itself does not support.
250,001
<p>Can someone define what exactly 'POCO' means? I am encountering the term more and more often, and I'm wondering if it is only about plain classes or it means something more?</p>
[ { "answer_id": 250006, "author": "David Mohundro", "author_id": 4570, "author_profile": "https://Stackoverflow.com/users/4570", "pm_score": 9, "selected": true, "text": "<p>\"Plain Old C# Object\"</p>\n\n<p>Just a normal class, no attributes describing infrastructure concerns or other re...
2008/10/30
[ "https://Stackoverflow.com/questions/250001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30726/" ]
Can someone define what exactly 'POCO' means? I am encountering the term more and more often, and I'm wondering if it is only about plain classes or it means something more?
"Plain Old C# Object" Just a normal class, no attributes describing infrastructure concerns or other responsibilities that your domain objects shouldn't have. EDIT - as other answers have stated, it is technically "Plain Old CLR Object" but I, like David Arno comments, prefer "Plain Old Class Object" to avoid ties to...
250,037
<p>I have a gridview and I need to sort its elements when the user clicks on the header.<br> Its datasource is a List object.</p> <p>The aspx is defined this way :</p> <pre><code>&lt;asp:GridView ID="grdHeader" AllowSorting="true" AllowPaging="false" AutoGenerateColumns="false" Width="780" runat="server" OnSort...
[ { "answer_id": 250571, "author": "Michael DeLorenzo", "author_id": 1383003, "author_profile": "https://Stackoverflow.com/users/1383003", "pm_score": 1, "selected": false, "text": "<p>It's been awhile since I used a GridView, but I think you need to set the grid's SortDirection property t...
2008/10/30
[ "https://Stackoverflow.com/questions/250037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28544/" ]
I have a gridview and I need to sort its elements when the user clicks on the header. Its datasource is a List object. The aspx is defined this way : ``` <asp:GridView ID="grdHeader" AllowSorting="true" AllowPaging="false" AutoGenerateColumns="false" Width="780" runat="server" OnSorting="grdHeader_OnSorting"...
You can use a session variable to store the latest Sort Expression and when you sort the grid next time compare the sort expression of the grid with the Session variable which stores last sort expression. If the columns are equal then check the direction of the previous sort and sort in the opposite direction. **Exam...
250,038
<p>I would like to be able to add a hook to my setup.py that will be run post-install (either when easy_install'ing or when doing python setup.py install).</p> <p>In my project, <a href="http://code.google.com/p/pysmell" rel="noreferrer">PySmell</a>, I have some support files for Vim and Emacs. When a user installs Py...
[ { "answer_id": 253103, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": true, "text": "<p>It depends on how the user installs your package. If the user actually runs \"setup.py install\", it's fairly ea...
2008/10/30
[ "https://Stackoverflow.com/questions/250038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32617/" ]
I would like to be able to add a hook to my setup.py that will be run post-install (either when easy\_install'ing or when doing python setup.py install). In my project, [PySmell](http://code.google.com/p/pysmell), I have some support files for Vim and Emacs. When a user installs PySmell the usual way, these files get ...
It depends on how the user installs your package. If the user actually runs "setup.py install", it's fairly easy: Just add another subcommand to the install command (say, install\_vim), whose run() method will copy the files you want in the places where you want them. You can add your subcommand to install.sub\_command...
250,082
<p>I have a makefile template to compile a single DLL (for a plugin system). The makefile of the user looks like this:</p> <pre><code>EXTRA_SRCS=file1 file2 include makefile.in </code></pre> <p>In the <code>makefile.in</code> I have:</p> <pre><code>plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS)) </code></pre>...
[ { "answer_id": 250163, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 5, "selected": true, "text": "<p>Use the \"wildcard\" function:</p>\n\n<pre><code>$(wildcard *.h)\n</code></pre>\n\n<p>EDIT: in order to match a specific...
2008/10/30
[ "https://Stackoverflow.com/questions/250082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7136/" ]
I have a makefile template to compile a single DLL (for a plugin system). The makefile of the user looks like this: ``` EXTRA_SRCS=file1 file2 include makefile.in ``` In the `makefile.in` I have: ``` plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS)) ``` Where `plugin.os` is the main C++ file to be compiled. ...
Use the "wildcard" function: ``` $(wildcard *.h) ``` EDIT: in order to match a specific list, do ``` $(wildcard $(HEADER_FILES)) ``` There is no need to use $(filter ...), the wildcard function automatically filters files which don't exist.
250,096
<p>I'm trying to code opposite action to this:</p> <pre><code>std::ostream outs; // properly initialized of course std::set&lt;int&gt; my_set; // ditto outs &lt;&lt; my_set.size(); std::copy( my_set.begin(), my_set.end(), std::ostream_iterator&lt;int&gt;( outs ) ); </code></pre> <p>it should be something like this:<...
[ { "answer_id": 250160, "author": "sdg", "author_id": 3529, "author_profile": "https://Stackoverflow.com/users/3529", "pm_score": 0, "selected": false, "text": "<p>(Edited: I should have read the question closer...)</p>\n\n<p>While somewhat suspect, you can get approximately the right beh...
2008/10/30
[ "https://Stackoverflow.com/questions/250096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21009/" ]
I'm trying to code opposite action to this: ``` std::ostream outs; // properly initialized of course std::set<int> my_set; // ditto outs << my_set.size(); std::copy( my_set.begin(), my_set.end(), std::ostream_iterator<int>( outs ) ); ``` it should be something like this: ``` std::istream ins; std::set<int>::size_...
You could derive from the istream\_iterator<T>. Though using [Daemin generator method](https://stackoverflow.com/questions/250096/how-to-read-arbitrary-number-of-bytes-using-stdcopy#250380) is another option, though I would generate directly into the set rather than use an intermediate vector. ``` #include <set> #i...
250,137
<p>I have the following legacy code:</p> <pre><code>public class MyLegacyClass { private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource" public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj) { // do stuff using jndiName } } </code></pre> <p>This c...
[ { "answer_id": 250146, "author": "Robin", "author_id": 21925, "author_profile": "https://Stackoverflow.com/users/21925", "pm_score": 2, "selected": false, "text": "<p>Refactor the code to use dependency injection. Then use you preferred DI framework (Spring, Guice, ...) to inject your r...
2008/10/30
[ "https://Stackoverflow.com/questions/250137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32749/" ]
I have the following legacy code: ``` public class MyLegacyClass { private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource" public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj) { // do stuff using jndiName } } ``` This class is working in a J2EE-...
Just to make @Robin's suggestion of a strategy pattern more concrete: (Notice that the public API of your original question remains unchanged.) ``` public class MyLegacyClass { private static Strategy strategy = new JNDIStrategy(); public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj) {...
250,157
<p>When you have a complex property, should you instantiate it or leave it to the user to instantiate it?</p> <p>For example (C#)</p> <p>A)</p> <pre><code> class Xyz{ List&lt;String&gt; Names {get; set;} } </code></pre> <p>When I try to use, I have to set it.</p> <pre><code>... Xyz xyz = new Xyz(); xyz.Name ...
[ { "answer_id": 250193, "author": "kͩeͣmͮpͥ ͩ", "author_id": 26479, "author_profile": "https://Stackoverflow.com/users/26479", "pm_score": 2, "selected": false, "text": "<p>This is my normal solution:</p>\n\n<pre><code>class XYZ \n{\n public XYZ () { Names = new List&lt;string&gt;(); }\...
2008/10/30
[ "https://Stackoverflow.com/questions/250157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2017/" ]
When you have a complex property, should you instantiate it or leave it to the user to instantiate it? For example (C#) A) ``` class Xyz{ List<String> Names {get; set;} } ``` When I try to use, I have to set it. ``` ... Xyz xyz = new Xyz(); xyz.Name = new List<String>(); xyz.Name.Add("foo"); ... ``` Wher...
This is my normal solution: ``` class XYZ { public XYZ () { Names = new List<string>(); } public List<string> Names { get; private set; } } ``` ~~(Note that it doesn't work with XmlSerialization, as you need getters and setters on all XmlSerialized properties.) (You can override this, but it seems like too mu...
250,166
<p>I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions...
[ { "answer_id": 250173, "author": "toolkit", "author_id": 3295, "author_profile": "https://Stackoverflow.com/users/3295", "pm_score": 7, "selected": true, "text": "<p>The -jar option is mutually exclusive of -classpath. See an old description <a href=\"http://download.java.net/jdk8u20/doc...
2008/10/30
[ "https://Stackoverflow.com/questions/250166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13140/" ]
I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions: ``...
The -jar option is mutually exclusive of -classpath. See an old description [here](http://download.java.net/jdk8u20/docs/technotes/tools/windows/java.html) > > -jar > > > Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file instead of a startup class name. In order for this opt...
250,191
<p>I have a menu of product brands that I want to split over 4 columns. So if I have 39 brands, then I want the maximum item count for each column to be 10 (with a single gap in the last column. Here's how I'm calculating the item count for a column (using C#):</p> <pre><code>int ItemCount = Convert.ToInt32(Math.Cei...
[ { "answer_id": 250205, "author": "GavinCattell", "author_id": 21644, "author_profile": "https://Stackoverflow.com/users/21644", "pm_score": 3, "selected": false, "text": "<p>A longer alternative with Mod.</p>\n\n<pre><code>ItemCount = BrandCount / 4;\nif (BrandCount%4 &gt; 0) ItemCount++...
2008/10/30
[ "https://Stackoverflow.com/questions/250191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/203/" ]
I have a menu of product brands that I want to split over 4 columns. So if I have 39 brands, then I want the maximum item count for each column to be 10 (with a single gap in the last column. Here's how I'm calculating the item count for a column (using C#): ``` int ItemCount = Convert.ToInt32(Math.Ceiling(Convert.ToD...
You can cast: ``` int ItemCount = (int) Math.Ceiling( (decimal)BrandCount / 4m ); ``` Also, because `int`/`decimal` results in a `decimal` you can remove one of the casts: ``` int ItemCount = (int) Math.Ceiling( BrandCount / 4m ); ```
250,197
<p>I am attempting to compose a style sheet that, given an XML input (obviously) and a parameter that specifies a "target", will produce a list of commands that match that target. Here is the style sheet as written:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Tr...
[ { "answer_id": 250337, "author": "Tim C", "author_id": 7585, "author_profile": "https://Stackoverflow.com/users/7585", "pm_score": 6, "selected": true, "text": "<p>If I have understood the question correctly, I think you need to use 'stringparam' as the option to call xsltproc, assuming ...
2008/10/30
[ "https://Stackoverflow.com/questions/250197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19674/" ]
I am attempting to compose a style sheet that, given an XML input (obviously) and a parameter that specifies a "target", will produce a list of commands that match that target. Here is the style sheet as written: ``` <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> ...
If I have understood the question correctly, I think you need to use 'stringparam' as the option to call xsltproc, assuming you are passing a string value to match, and not an XPath expression. ``` xsltproc --stringparam target cora_cmd gen-commands.xsl commands.xml ```
250,207
<p>How to host the WCF service in windows service?</p> <p>Thanks Sekar</p>
[ { "answer_id": 250229, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I just saw this today come across Channel 9:</p>\n\n<p><a href=\"http://channel9.msdn.com/shows/Endpoint/endpointtv-Screenc...
2008/10/30
[ "https://Stackoverflow.com/questions/250207", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to host the WCF service in windows service? Thanks Sekar
I thought this article did a pretty good job of covering the steps required: [WCF Link](http://msdn.microsoft.com/en-us/library/ms733069.aspx) To summarize: * To start with you need to create a new visual studio project of the type "Windows Service". * Next to be able to install the service, you also need to write an...
250,209
<p>I'm relatively new to the Python world, but this seems very straight forward.</p> <p>Google is yelling at me that this code needs to be optimized:</p> <pre><code>class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(...
[ { "answer_id": 250294, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 2, "selected": false, "text": "<p>Looks pretty tight to me.</p>\n\n<p>I see one thing that may make a small improvement.\nYour calling, \"self.request.get...
2008/10/30
[ "https://Stackoverflow.com/questions/250209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9094/" ]
I'm relatively new to the Python world, but this seems very straight forward. Google is yelling at me that this code needs to be optimized: ``` class AddLinks(webapp.RequestHandler): def post(self): # Hash the textarea input to generate pseudo-unique value hash = md5.new(self.request.get('lin...
The main overhead here is the multiple individual puts to the datastore. If you can, store the links as a single entity, as Andre suggests. You can always split the links into an array and store it in a ListProperty. If you do need an entity for each link, try this: ``` # For each line in the input, add to the databa...
250,214
<p>I am updating a VBA program (excel). At startup the program checks if it can find a directory which is on the office file server using:</p> <pre><code>FileSystemObject.FolderExists("\\servername\path") </code></pre> <p>If this is not found the program switches to offline mode and saves its output to the local hard...
[ { "answer_id": 250224, "author": "Kevin Fairchild", "author_id": 3743, "author_profile": "https://Stackoverflow.com/users/3743", "pm_score": 3, "selected": true, "text": "<p><strong>If you're on a domain:</strong></p>\n\n<p>Check the LOGONSERVER environmental variable.</p>\n\n<p>If there...
2008/10/30
[ "https://Stackoverflow.com/questions/250214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32763/" ]
I am updating a VBA program (excel). At startup the program checks if it can find a directory which is on the office file server using: ``` FileSystemObject.FolderExists("\\servername\path") ``` If this is not found the program switches to offline mode and saves its output to the local hard disk (for later transfer)...
**If you're on a domain:** Check the LOGONSERVER environmental variable. If there are two '\' symbols before the server name, it's connected to active directory and so you should do your check. Otherwise, it isn't logged into the office network, so you can bypass the check. **If you aren't on a domain:** Probably ...
250,216
<p>Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled.</p> <p>The only way I've found to do this is to open a window from javascript, check to see i...
[ { "answer_id": 250247, "author": "Codebeef", "author_id": 12037, "author_profile": "https://Stackoverflow.com/users/12037", "pm_score": 1, "selected": false, "text": "<p>I don't think there is any way of detecting this without attempting to open a window, as popup blockers don't add anyt...
2008/10/30
[ "https://Stackoverflow.com/questions/250216", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2849/" ]
Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled. The only way I've found to do this is to open a window from javascript, check to see if it's ope...
Read [Detect a popup blocker using Javascript](http://www.visitor-stats.com/articles/detect-popup-blocker.php): Basically you check if the 'window.open' method returns a handle to a newly-opened window. Looks like this: ``` var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no'); if(mine) var...
250,228
<p>I have a page with many forms on it. could be 1..200. None of these forms have buttons and they are built programatically. I am using jquery to submit all the forms that are checked.</p> <pre><code> function FakeName() { $("input:checked").parent("form").submit(); } </code></pre> <p>My forms l...
[ { "answer_id": 250259, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 3, "selected": true, "text": "<p>The <code>onsubmit</code> handler is deliberately not triggered when you programatically submit the form. This is to avoi...
2008/10/30
[ "https://Stackoverflow.com/questions/250228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
I have a page with many forms on it. could be 1..200. None of these forms have buttons and they are built programatically. I am using jquery to submit all the forms that are checked. ``` function FakeName() { $("input:checked").parent("form").submit(); } ``` My forms look like: ``` ...
The `onsubmit` handler is deliberately not triggered when you programatically submit the form. This is to avoid infinite recursion if an event handler would cause the event to be triggered again (and therefore the event handler to be called again) However, of course you can call the `processRow()` function yourself in...
250,234
<p>I have been trying to get PEAR::mail to successfully deliver emails to hotmail users without being flagged as SPAM and ending up in the junk folder, i have no problems with yahoo/gmail only with hotmail.</p> <p>google suggested that this is a common problem with hotmail and that possible causes can include</p> <ul...
[ { "answer_id": 250243, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 1, "selected": false, "text": "<p>I have always used <a href=\"http://phpmailer.codeworxtech.com/\" rel=\"nofollow noreferrer\">PHPMailer</a> in my proje...
2008/10/30
[ "https://Stackoverflow.com/questions/250234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2083/" ]
I have been trying to get PEAR::mail to successfully deliver emails to hotmail users without being flagged as SPAM and ending up in the junk folder, i have no problems with yahoo/gmail only with hotmail. google suggested that this is a common problem with hotmail and that possible causes can include * incorrect rever...
My company does professional e-mail marketting campaigns (through strongmail servers) we send thousands of (sollicited) emails a day to all kinds of addresses. The problem you are facing is that you have no authority. You could just be some spammer trying to send loads of spam. The thing you need to do is: * Add un...
250,238
<p>We have a git project which has quite a big history.</p> <p>Specifically, early in the project there were quite a lot of binary resource files in the project, these have now been removed as they're effectively external resources.</p> <p>However, the size of our repository is >200MB (the total checkout is currently...
[ { "answer_id": 250365, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 3, "selected": false, "text": "<p>Is <code>git-fast-export</code> what you are looking for?</p>\n\n<pre><code>NAME\n git-fast-export - Git data exporte...
2008/10/30
[ "https://Stackoverflow.com/questions/250238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31582/" ]
We have a git project which has quite a big history. Specifically, early in the project there were quite a lot of binary resource files in the project, these have now been removed as they're effectively external resources. However, the size of our repository is >200MB (the total checkout is currently ~20MB) due to ha...
You can remove the binary bloat and keep the rest of your history. Git allows you to reorder and 'squash' prior commits, so you can combine just the commits that add and remove your big binary files. If the adds were all done in one commit and the removals in another, this will be much easier than dealing with each fil...
250,244
<p>I have a simple application with the following code:</p> <pre><code> FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles(); List&lt;Thread&gt; threads = new List&lt;Thread&gt;(files.Length); foreach (FileInfo f in files) { Thread t = new Thread(delegate() { Consol...
[ { "answer_id": 250249, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": 5, "selected": true, "text": "<p>The anonymous method keeps a <strong>reference</strong> to the variable in the enclosing block -- not the actual v...
2008/10/30
[ "https://Stackoverflow.com/questions/250244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30006/" ]
I have a simple application with the following code: ``` FileInfo[] files = (new DirectoryInfo(initialDirectory)).GetFiles(); List<Thread> threads = new List<Thread>(files.Length); foreach (FileInfo f in files) { Thread t = new Thread(delegate() { Console.WriteLine(f.FullName); ...
The anonymous method keeps a **reference** to the variable in the enclosing block -- not the actual value of the variable. By the time the methods are actually executed (when you start the threads) `f` has been assigned to point to the last value in the collection, so all 3 threads print that last value.
250,256
<p>I have problem in some JavaScript that I am writing where the Switch statement does not seem to be working as expected.</p> <pre><code>switch (msg.ResultType) { case 0: $('#txtConsole').val("Some Val 0"); break; case 1: $('#txtConsole').val("Some Val 1"); break; case 2: $('#txtConsole').te...
[ { "answer_id": 250263, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I ran into a similar problem and the issue turned out to be that where as it was showing as an int value, the switch statem...
2008/10/30
[ "https://Stackoverflow.com/questions/250256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4820/" ]
I have problem in some JavaScript that I am writing where the Switch statement does not seem to be working as expected. ``` switch (msg.ResultType) { case 0: $('#txtConsole').val("Some Val 0"); break; case 1: $('#txtConsole').val("Some Val 1"); break; case 2: $('#txtConsole').text("Some Val 2...
I'm sure that a switch uses === for comparison in Actionscript and since JS and AS both follow the ECMAScript standard, I guess the same applies to JS. My guess is that the value is not actually a Number, but perhaps a String. You could try to use parseInt(msg.ResultType) in the switch or use strings in the cases.
250,271
<p>How can I get the start and end positions of all matches using the <code>re</code> module? For example given the pattern <code>r'[a-z]'</code> and the string <code>'a1b2c3d4'</code> I'd want to get the positions where it finds each letter. Ideally, I'd like to get the text of the match back too.</p>
[ { "answer_id": 250303, "author": "Peter Hoffmann", "author_id": 720, "author_profile": "https://Stackoverflow.com/users/720", "pm_score": 9, "selected": true, "text": "<pre><code>import re\np = re.compile(\"[a-z]\")\nfor m in p.finditer('a1b2c3d4'):\n print(m.start(), m.group())\n</co...
2008/10/30
[ "https://Stackoverflow.com/questions/250271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13009/" ]
How can I get the start and end positions of all matches using the `re` module? For example given the pattern `r'[a-z]'` and the string `'a1b2c3d4'` I'd want to get the positions where it finds each letter. Ideally, I'd like to get the text of the match back too.
``` import re p = re.compile("[a-z]") for m in p.finditer('a1b2c3d4'): print(m.start(), m.group()) ```
250,283
<p>What's the most pythonic way to scp a file in Python? The only route I'm aware of is </p> <pre><code>os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) </code></pre> <p>which is a hack, and which doesn't work outside Linux-like systems, and which needs help from the Pexpect module to avoid passw...
[ { "answer_id": 250402, "author": "Blauohr", "author_id": 22176, "author_profile": "https://Stackoverflow.com/users/22176", "pm_score": 3, "selected": false, "text": "<p>if you install putty on win32 you get an pscp (putty scp).</p>\n\n<p>so you can use the os.system hack on win32 too.</p...
2008/10/30
[ "https://Stackoverflow.com/questions/250283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4105/" ]
What's the most pythonic way to scp a file in Python? The only route I'm aware of is ``` os.system('scp "%s" "%s:%s"' % (localfile, remotehost, remotefile) ) ``` which is a hack, and which doesn't work outside Linux-like systems, and which needs help from the Pexpect module to avoid password prompts unless you alre...
Try the [Python scp module for Paramiko](https://github.com/jbardin/scp.py). It's very easy to use. See the following example: ``` import paramiko from scp import SCPClient def createSSHClient(server, port, user, password): client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_ho...
250,304
<p>A VBScript cannot edit the registry by default on Vista. How do I get elevation (even if the user has to do something when they run the script) so that the script can edit the registry?</p> <p>The error is:</p> <pre><code>--------------------------- Windows Script Host --------------------------- Script: blah bla...
[ { "answer_id": 250343, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "<p>To make it work with native VBScript, you will most likely need a code signing certificate and sign your script with th...
2008/10/30
[ "https://Stackoverflow.com/questions/250304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1490/" ]
A VBScript cannot edit the registry by default on Vista. How do I get elevation (even if the user has to do something when they run the script) so that the script can edit the registry? The error is: ``` --------------------------- Windows Script Host --------------------------- Script: blah blah blah.vbs Line: 6 C...
My understanding was that you could edit HKCU as a normal user, but the others were restricted. I could be wrong. Regardless, there are a couple of example [here](http://www.winhelponline.com/articles/185/1/VBScripts-and-UAC-elevation.html) to do what you want to do.
250,324
<p>I am wondering what the best way is using php to obtain a list of all the rows in the database, and when clicking on a row show the information in more detail, such as a related image etc.</p> <p>Should I use frames to do this? Are there good examples of this somewhere?</p> <p>Edit:</p> <p>I need much simpler ins...
[ { "answer_id": 250329, "author": "Thomas Owens", "author_id": 572, "author_profile": "https://Stackoverflow.com/users/572", "pm_score": 2, "selected": false, "text": "<p>I use tables and JavaScript to do this.</p>\n\n<p>Data in a SQL database is, by nature, tabular. So I just select the ...
2008/10/30
[ "https://Stackoverflow.com/questions/250324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
I am wondering what the best way is using php to obtain a list of all the rows in the database, and when clicking on a row show the information in more detail, such as a related image etc. Should I use frames to do this? Are there good examples of this somewhere? Edit: I need much simpler instructions, as I am not a...
Contrary to other's recommendations, I would not recommend a framework or abstraction level. It will insulate you from understanding how php works and requires that you learn php and the framework structure/process at the same time. An abstraction layer is good practice in a commercial environment, but from the vibe of...
250,335
<p>I've created a batch job that running in 32bit mode as it using 32bit COM objectes, this need to connect to SharePoint to make updates to list. It works in my development environment as it is full 32bit. But in my test and prodution environment we use 64bit SharePoint and this is what I get from SPSite:</p> <pre><c...
[ { "answer_id": 250579, "author": "AdamBT", "author_id": 22426, "author_profile": "https://Stackoverflow.com/users/22426", "pm_score": 1, "selected": false, "text": "<p>I don't think this is a 32/64bit issue as I am in the same situation as far as developing on 32bit and deploying to 64bi...
2008/10/30
[ "https://Stackoverflow.com/questions/250335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24595/" ]
I've created a batch job that running in 32bit mode as it using 32bit COM objectes, this need to connect to SharePoint to make updates to list. It works in my development environment as it is full 32bit. But in my test and prodution environment we use 64bit SharePoint and this is what I get from SPSite: ``` System.IO....
You simply need to run your batch job in a 64-bit process. The problem is that SharePoint has many COM objects under the hood which are compiled for 64-bit in your test and production environment. The SPSite and SPWeb objects actually wrap the COM objects which is why they fail in your 32-bit process. One work-around...
250,357
<p>I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word.</p> <p>For example:</p> <pre> Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." </pre> <p>I'm looking for a way to accomplish the "...
[ { "answer_id": 250373, "author": "Adam", "author_id": 30084, "author_profile": "https://Stackoverflow.com/users/30084", "pm_score": 7, "selected": true, "text": "<p>I actually wrote a solution for this on a recent project of mine. I've compressed the majority of it down to be a little s...
2008/10/30
[ "https://Stackoverflow.com/questions/250357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24998/" ]
I am looking for a way to truncate a string in Python that will not cut off the string in the middle of a word. For example: ``` Original: "This is really awesome." "Dumb" truncate: "This is real..." "Smart" truncate: "This is really..." ``` I'm looking for a way to accomplish the "smart" truncate from...
I actually wrote a solution for this on a recent project of mine. I've compressed the majority of it down to be a little smaller. ``` def smart_truncate(content, length=100, suffix='...'): if len(content) <= length: return content else: return ' '.join(content[:length+1].split(' ')[0:-1]) + suf...
250,375
<p>for some reason, templatetags do not render in templates for django admin.</p> <p>with this snippet from: <a href="http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-for-simple-tags" rel="nofollow noreferrer">http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-fo...
[ { "answer_id": 250479, "author": "Brett", "author_id": 11958, "author_profile": "https://Stackoverflow.com/users/11958", "pm_score": 3, "selected": false, "text": "<p>That's only an example, the <code>is_logged_in</code> variable is not actually defined in any templates unless you put it...
2008/10/30
[ "https://Stackoverflow.com/questions/250375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
for some reason, templatetags do not render in templates for django admin. with this snippet from: <http://docs.djangoproject.com/en/dev/ref/templates/api/?from=olddocs#shortcut-for-simple-tags> ``` {% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{% endif %} ``` when placed in admin index.html, i...
That's only an example, the `is_logged_in` variable is not actually defined in any templates unless you put it in the context. If you added that line and got `Please log in.` it does mean that the tag is rendering. If it fails the `if` and goes to the `else` it is clearly being run. You need to find something in the t...
250,398
<p>I can't find any proper documentation on how to specify relations using the declarative syntax of SQLAlchemy.. Is it unsupported? That is, should I use the "traditional" syntax?<br> I am looking for a way to specify relations at a higher level, avoiding having to mess with foreign keys etc.. I'd like to just declare...
[ { "answer_id": 251077, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 3, "selected": true, "text": "<p>Assuming you are referring to <a href=\"http://www.sqlalchemy.org/docs/04/plugins.html#plugins_declarative\" rel=\"no...
2008/10/30
[ "https://Stackoverflow.com/questions/250398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3497/" ]
I can't find any proper documentation on how to specify relations using the declarative syntax of SQLAlchemy.. Is it unsupported? That is, should I use the "traditional" syntax? I am looking for a way to specify relations at a higher level, avoiding having to mess with foreign keys etc.. I'd like to just declare "ad...
Assuming you are referring to [the declarative plugin](http://www.sqlalchemy.org/docs/04/plugins.html#plugins_declarative), where everything I am about to say is documented with examples: ``` class User(Base): __tablename__ = 'users' id = Column('id', Integer, primary_key=True) addresses = relation("Addre...
250,404
<p>I found <a href="https://stackoverflow.com/questions/122778/capture-console-output-for-debugging-in-vs">this question</a>, but what I want to know is different - does the output from Console.WriteLine go anywhere when debugging? I know that for it to go to the output window I should should Debug.WriteLine() or other...
[ { "answer_id": 250411, "author": "chills42", "author_id": 23855, "author_profile": "https://Stackoverflow.com/users/23855", "pm_score": 0, "selected": false, "text": "<p>It goes to the console (standard output) or to the stream that the console is set to.</p>\n" }, { "answer_id":...
2008/10/30
[ "https://Stackoverflow.com/questions/250404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I found [this question](https://stackoverflow.com/questions/122778/capture-console-output-for-debugging-in-vs), but what I want to know is different - does the output from Console.WriteLine go anywhere when debugging? I know that for it to go to the output window I should should Debug.WriteLine() or other methods, but ...
The console can redirect it's output to any textwriter. If you implement a textwriter that writes to Diagnostics.Debug, you are all set. Here's a textwriter that writes to the debugger. ``` using System.Diagnostics; using System.IO; using System.Text; namespace TestConsole { public class DebugTextWriter : TextWr...
250,408
<p>I tried the example from Rails Cookbook and managed to get it to work. However the <code>text_field_with_auto_complete</code> works only for one value.</p> <pre><code>class Expense &lt; ActiveRecord::Base has_and_belongs_to_many :categories end </code></pre> <p>In the New Expense View rhtml</p> <pre><code>&lt;%...
[ { "answer_id": 265211, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>If you are just trying to support multiple instances of autocomplete per field, you can pass a delimiter to the autocomplet...
2008/10/30
[ "https://Stackoverflow.com/questions/250408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
I tried the example from Rails Cookbook and managed to get it to work. However the `text_field_with_auto_complete` works only for one value. ``` class Expense < ActiveRecord::Base has_and_belongs_to_many :categories end ``` In the New Expense View rhtml ``` <%= text_field_with_auto_complete :category, :name %> `...
If you are just trying to support multiple instances of autocomplete per field, you can pass a delimiter to the autocomplete options with the symbol :token. This provides a delimiter to allow multiple results. Stackoverflow would use :token => ' ' (there should be a space between the quotes, but the autoformat is remov...
250,421
<p>I am writing a macro for Visual studio that will generate some code.</p> <p>I would like for the macro to generate for both C# and VB, is there a way to determine what language is being used in the active (current) document?</p>
[ { "answer_id": 250437, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "<p>Have you considered using <a href=\"http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationB...
2008/10/30
[ "https://Stackoverflow.com/questions/250421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30492/" ]
I am writing a macro for Visual studio that will generate some code. I would like for the macro to generate for both C# and VB, is there a way to determine what language is being used in the active (current) document?
I just located a bit of code, it seems that it's a hidden property: ``` DTE.ActiveDocument.Language = "CSharp" ```
250,423
<p>I'm a web developer with no formal computing background behind me, I've been writing code now some years now, but every time I need to create a new class / function / variable, I spend about two minutes just deciding on a name and then how to type it.</p> <p>For instance, if I write a function to sum up a bunch of ...
[ { "answer_id": 250430, "author": "chills42", "author_id": 23855, "author_profile": "https://Stackoverflow.com/users/23855", "pm_score": 3, "selected": false, "text": "<p>You're looking for <a href=\"http://code.msdn.microsoft.com/sourceanalysis\" rel=\"nofollow noreferrer\">StyleCop</a>....
2008/10/30
[ "https://Stackoverflow.com/questions/250423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
I'm a web developer with no formal computing background behind me, I've been writing code now some years now, but every time I need to create a new class / function / variable, I spend about two minutes just deciding on a name and then how to type it. For instance, if I write a function to sum up a bunch of numbers. S...
Classes should be in camel notation with the first letter capitalized ``` public class MyClass ``` Functions and Methods in C# should act in a similar fashion except for private methods ``` public void MyMethod() private void myPrivateMethod() ``` Variables I tend to do a little differently: Member Variables ``...
250,468
<p>Is the SqlClient.SqlDataReader a .NET managed object or not? Why do we have to call the Close() method explicitly close an open connection? Shouldn't running out of scope for such an object automatically close this? Shouldn't garbage collector clean it up anyway?</p> <p>Please help me understand what is the best pr...
[ { "answer_id": 250478, "author": "wprl", "author_id": 17847, "author_profile": "https://Stackoverflow.com/users/17847", "pm_score": 6, "selected": true, "text": "<p>Sure, it will be collected when it goes out of scope (if their are no other references to it). When it is collected, it wi...
2008/10/30
[ "https://Stackoverflow.com/questions/250468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13370/" ]
Is the SqlClient.SqlDataReader a .NET managed object or not? Why do we have to call the Close() method explicitly close an open connection? Shouldn't running out of scope for such an object automatically close this? Shouldn't garbage collector clean it up anyway? Please help me understand what is the best practise her...
Sure, it will be collected when it goes out of scope (if their are no other references to it). When it is collected, it will be closed through its Dispose() method. However, you never really know when the GC is going to deallocate things; if you don't close your readers, you very quickly run out of available connection...
250,494
<p>I have a class that downloads, examines and saves some large XML files. Sometimes I want the UI to tell me what's going on, but sometimes I will use the class and ignore the events. So I have placed lines of code like this in a dozen places:</p> <pre><code>RaiseEvent Report("Sending request: " &amp; queryString) R...
[ { "answer_id": 250504, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<p>There might be a small amount of overhead, but I wouldn't worry about it. Certainly the actual action is going to ...
2008/10/30
[ "https://Stackoverflow.com/questions/250494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16415/" ]
I have a class that downloads, examines and saves some large XML files. Sometimes I want the UI to tell me what's going on, but sometimes I will use the class and ignore the events. So I have placed lines of code like this in a dozen places: ``` RaiseEvent Report("Sending request: " & queryString) RaiseEvent Report("...
There is no magic, the code hiding under RaiseEvent does exactly what you'd expect, it iterates through a collection of handlers, and executes each one. The overhead of checking to see are there any handlers is trivial, don't worry about it. If your **REAL** question is "To save time, should I check that the events ha...
250,506
<p>I made a class that derives from Component:</p> <pre><code>public class MyComponent: System.ComponentModel.Component { } </code></pre> <p>I saw that Visual Studio put this code in for me:</p> <pre><code>protected override void Dispose(bool disposing) { try { if (disposing &amp;&amp; (components ...
[ { "answer_id": 250541, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 3, "selected": true, "text": "<p>Change:</p>\n\n<pre><code>if (disposing &amp;&amp; (components != null))\n{\n components.Dispose();\n}\n</cod...
2008/10/30
[ "https://Stackoverflow.com/questions/250506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I made a class that derives from Component: ``` public class MyComponent: System.ComponentModel.Component { } ``` I saw that Visual Studio put this code in for me: ``` protected override void Dispose(bool disposing) { try { if (disposing && (components != null)) { components.Dis...
Change: ``` if (disposing && (components != null)) { components.Dispose(); } ``` to be: ``` if (disposing && (components != null)) { _dataset.Dispose(); components.Dispose(); } ```
250,508
<p>I am trying to pull data from an ACD call data system, <code>Nortel Contact Center 6.0</code> to be exact, and if you use that particular system what I am trying to capture is the daily call by call data. However when I use this code</p> <p>(sCW is a common word string that equals <code>eCallByCallStat</code> and ...
[ { "answer_id": 250888, "author": "Kevin Fairchild", "author_id": 3743, "author_profile": "https://Stackoverflow.com/users/3743", "pm_score": 1, "selected": false, "text": "<p>Seems like an error with the query itself...</p>\n\n<p>If you can step through your code and post the contents of...
2008/10/30
[ "https://Stackoverflow.com/questions/250508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32790/" ]
I am trying to pull data from an ACD call data system, `Nortel Contact Center 6.0` to be exact, and if you use that particular system what I am trying to capture is the daily call by call data. However when I use this code (sCW is a common word string that equals `eCallByCallStat` and sDate is `dDate = Format(Month...
Seems like an error with the query itself... If you can step through your code and post the contents of sSql, it would probably help troubleshoot... When you go through it, be sure quotes are getting escaped properly.
250,509
<p>Is there a way that you can have SERVEROUTPUT set to ON in sqlplus but somehow repress the message "PL/SQL procedure successfully completed" that is automatically generated upon completed execution of a plsql procedure?</p>
[ { "answer_id": 250540, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 7, "selected": true, "text": "<p>Use the command:</p>\n\n<pre><code>SET FEEDBACK OFF\n</code></pre>\n\n<p>before running the procedure. And afterwa...
2008/10/30
[ "https://Stackoverflow.com/questions/250509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5658/" ]
Is there a way that you can have SERVEROUTPUT set to ON in sqlplus but somehow repress the message "PL/SQL procedure successfully completed" that is automatically generated upon completed execution of a plsql procedure?
Use the command: ``` SET FEEDBACK OFF ``` before running the procedure. And afterwards you can turn it back on again: ``` SET FEEDBACK ON ```
250,550
<p>this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc.</p> <p>My goal is to do something like:</p> <pre><code>cap host1 st...
[ { "answer_id": 250747, "author": "Jon Wood", "author_id": 25258, "author_profile": "https://Stackoverflow.com/users/25258", "pm_score": 2, "selected": false, "text": "<pre><code>require 'my_extension'\n</code></pre>\n\n<p>Save your extensions in my_extension.rb</p>\n" }, { "answe...
2008/10/30
[ "https://Stackoverflow.com/questions/250550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8243/" ]
this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc. My goal is to do something like: ``` cap host1 stage deploy cap host2 ...
I just experimented with it a little more and what I discovered is that you have to: ``` load 'config/my_module' ``` I can put all of my common definitions here and just load it into my deploy.rb. It appears from the docs that load loads and executes the file. Alternatively, require attempts to load the library spe...
250,553
<p>I'd like something like</p> <pre><code>int minIndex = list.FindMin(delegate (MyClass a, MyClass b) {returns a.CompareTo(b);}); </code></pre> <p>Is there a builtin way to do this in .NET?</p>
[ { "answer_id": 250567, "author": "Nicholas Mancuso", "author_id": 8945, "author_profile": "https://Stackoverflow.com/users/8945", "pm_score": 6, "selected": true, "text": "<p>Try looking at these:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/bb909313.aspx\" rel=\"noreferre...
2008/10/30
[ "https://Stackoverflow.com/questions/250553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I'd like something like ``` int minIndex = list.FindMin(delegate (MyClass a, MyClass b) {returns a.CompareTo(b);}); ``` Is there a builtin way to do this in .NET?
Try looking at these: [Min](http://msdn.microsoft.com/en-us/library/bb909313.aspx) [Max](http://msdn.microsoft.com/en-us/library/bb909073.aspx) As long as your class implements IComparable, all you have to do is: ``` List<MyClass> list = new List(); //add whatever you need to add MyClass min = list.Min(); MyClass ...
250,576
<p>In Visual Studio, is there any way to make the debugger break whenever a certain file (or class) is entered? Please don't answer "just set a breakpoint at the beginning of every method" :)</p> <p>I am using C#.</p>
[ { "answer_id": 250584, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 1, "selected": false, "text": "<p>No. Or rather, yes, but it involves setting a breakpoint at the beginning of every method.</p>\n" }, { "answer_i...
2008/10/30
[ "https://Stackoverflow.com/questions/250576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
In Visual Studio, is there any way to make the debugger break whenever a certain file (or class) is entered? Please don't answer "just set a breakpoint at the beginning of every method" :) I am using C#.
Macros can be your friend. Here is a macro that will add a breakpoint to every method in the current class (put the cursor somewhere in the class before running it). ``` Public Module ClassBreak Public Sub BreakOnAnyMember() Dim debugger As EnvDTE.Debugger = DTE.Debugger Dim sel As EnvDTE.TextSelec...
250,577
<p>I have an Ant script with a junit target where I want it to start up the VM with a different working directory than the basedir. How would I do this?</p> <p>Here's a pseudo version of my target.</p> <pre><code>&lt;target name="buildWithClassFiles"&gt; &lt;mkdir dir="${basedir}/UnitTest/junit-reports"/&gt; ...
[ { "answer_id": 250651, "author": "James Van Huis", "author_id": 31828, "author_profile": "https://Stackoverflow.com/users/31828", "pm_score": 3, "selected": false, "text": "<p>Have you tried:</p>\n\n<pre><code> &lt;junit fork=\"true\" printsummary=\"yes\" dir=\"workingdir\"&gt;\n</code><...
2008/10/30
[ "https://Stackoverflow.com/questions/250577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I have an Ant script with a junit target where I want it to start up the VM with a different working directory than the basedir. How would I do this? Here's a pseudo version of my target. ``` <target name="buildWithClassFiles"> <mkdir dir="${basedir}/UnitTest/junit-reports"/> <junit fork="true" printsummary="...
Have you tried: ``` <junit fork="true" printsummary="yes" dir="workingdir"> ```
250,583
<p>I'm trying to get all property names / values from an Outlook item. I have custom properties in addition to the default outlook item properties. I'm using redemption to get around the Outlook warnings but I'm having some problems with the GetNamesFromIDs method on a Redemption.RDOMail Item....</p> <p>I'm using my r...
[ { "answer_id": 250595, "author": "Marko", "author_id": 31141, "author_profile": "https://Stackoverflow.com/users/31141", "pm_score": 2, "selected": false, "text": "<p>Whatever you are most familiar with.</p>\n\n<p>Or whatever have better set of ready to go components, so either Java (Net...
2008/10/30
[ "https://Stackoverflow.com/questions/250583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1385358/" ]
I'm trying to get all property names / values from an Outlook item. I have custom properties in addition to the default outlook item properties. I'm using redemption to get around the Outlook warnings but I'm having some problems with the GetNamesFromIDs method on a Redemption.RDOMail Item.... I'm using my redemption ...
Ruby on Rails will do simple CRUD operations **very** easily - although doing more than that can be a little more complex (would require some reading about RoR's way of doing things). The latest version of Rails automatically uses sqlite databases, and in fact the whole database, and CRUD GUI code can be created with o...
250,597
<p>I have a WPF TreeView with just 1 level of items. The TreeView is data bound to an ObservableCollection of strings. How can I ensure that the same icon appears to the left of each node in the TreeView?</p>
[ { "answer_id": 253243, "author": "James Osborn", "author_id": 6686, "author_profile": "https://Stackoverflow.com/users/6686", "pm_score": 4, "selected": false, "text": "<p>I think the best approach is to set a Style on the TreeView that will change the Template of the TreeViewItems to ha...
2008/10/30
[ "https://Stackoverflow.com/questions/250597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/132931/" ]
I have a WPF TreeView with just 1 level of items. The TreeView is data bound to an ObservableCollection of strings. How can I ensure that the same icon appears to the left of each node in the TreeView?
I think the best approach is to set a Style on the TreeView that will change the Template of the TreeViewItems to have the Image that you want. The Template will probably need to be a StackPanel with an Image and a label control, you bind the image to your icon, and the label text to the strings from the Observable co...
250,599
<p>In the following code, used to get a list of products in a particular line, the command only returns results when I hard code (concatenate) <code>productLine</code> into the SQL. The parameter substitution never happens.</p> <pre><code> + "lineName = '@productLine' " +...
[ { "answer_id": 250611, "author": "Rune Grimstad", "author_id": 30366, "author_profile": "https://Stackoverflow.com/users/30366", "pm_score": 2, "selected": false, "text": "<p>Remove the apostrophes (spelling?). The ' around the parameter. They should not be needed.</p>\n" }, { "...
2008/10/30
[ "https://Stackoverflow.com/questions/250599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
In the following code, used to get a list of products in a particular line, the command only returns results when I hard code (concatenate) `productLine` into the SQL. The parameter substitution never happens. ``` + "lineName = '@productLine' " + "and isVisible = 1 "; ...
``` + "lineName = ?productLine " + "and isVisible = 1 "; MySqlDataAdapter adap = new MySqlDataAdapter(sql, msc); adap.SelectCommand.Parameters.Add("?productLine", productLine); ``` 1. Remove the apostrophes ('). 2. Change @ to ?, which is the prefix of parameters in MySq...
250,603
<p>I'm sure I'm going to have to write supporting javascript code to do this. I have an autocomplete extender set up that selects values from a database table, when a selection is made, i would like it to set the ID of the value selected to a hidden control. I can do that by handling a value change on the text box an...
[ { "answer_id": 265532, "author": "stephenbayer", "author_id": 18893, "author_profile": "https://Stackoverflow.com/users/18893", "pm_score": 3, "selected": true, "text": "<p>No one was able to give me an answer. This has been an ongoing saga. It started when I was trying to find a <a hre...
2008/10/30
[ "https://Stackoverflow.com/questions/250603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
I'm sure I'm going to have to write supporting javascript code to do this. I have an autocomplete extender set up that selects values from a database table, when a selection is made, i would like it to set the ID of the value selected to a hidden control. I can do that by handling a value change on the text box and mak...
No one was able to give me an answer. This has been an ongoing saga. It started when I was trying to find a [solution not using drop down lists for large amounts of data](https://stackoverflow.com/questions/247438/alternative-ui-control-for-large-data-lists-instead-of-dropdownlist). I have run into issues with this so ...
250,616
<p>A <a href="https://stackoverflow.com/questions/217618/construct-vs-sameasclassname-for-constructor-in-php">similar question discusses <code>__construct</code></a>, but I left it in my title for people searching who find this one.</p> <p>Apparently, __get and __set take a parameter that is the variable being gotten ...
[ { "answer_id": 250637, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://uk.php.net/manual/en/language.oop5.overloading.php\" rel=\"nofollow noreferrer\">This page</a> will probabl...
2008/10/30
[ "https://Stackoverflow.com/questions/250616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
A [similar question discusses `__construct`](https://stackoverflow.com/questions/217618/construct-vs-sameasclassname-for-constructor-in-php), but I left it in my title for people searching who find this one. Apparently, \_\_get and \_\_set take a parameter that is the variable being gotten or set. However, you have to...
[This page](http://uk.php.net/manual/en/language.oop5.overloading.php) will probably be useful. (Note that what you say is incorrect - `__set()` takes as a parameter both the name of the variable and the value. `__get()` just takes the name of the variable). `__get()` and `__set()` are useful in library functions wher...
250,622
<p>I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style:</p> <pre><code>&lt;Style TargetTy...
[ { "answer_id": 252450, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 3, "selected": true, "text": "<p>The problem is indeed due to the default template for the ComboBox. If you use <a href=\"http://www.red-gate.com/prod...
2008/10/30
[ "https://Stackoverflow.com/questions/250622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21186/" ]
I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style: ``` <Style TargetType="ComboBox"> ...
The problem is indeed due to the default template for the ComboBox. If you use [Reflector](http://www.red-gate.com/products/reflector/) to open the PresentationFramework.Aero assembly you can take a look at the ButtonChrome class. There is a method called OnRenderMouseOverChanged that is hiding the Red background. Eve...
250,643
<p>I want to attach a 'click' event handler to the first child of an element with ID 'foo' using <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow noreferrer">jQuery</a>. I understand that the syntax for doing this is:</p> <pre><code>$('#foo:first-child').bind('click', function(event) { // I want to acce...
[ { "answer_id": 250656, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "<pre><code>$(this).doStuff()\n</code></pre>\n" }, { "answer_id": 250661, "author": "Greg", "author_id": 24181, ...
2008/10/30
[ "https://Stackoverflow.com/questions/250643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I want to attach a 'click' event handler to the first child of an element with ID 'foo' using [jQuery](http://en.wikipedia.org/wiki/JQuery). I understand that the syntax for doing this is: ``` $('#foo:first-child').bind('click', function(event) { // I want to access the first child here }) ``` Within the handler...
Just use "this": ``` $('#foo:first-child').bind('click', function(event) { alert(this === $('#foo:first-child')); // True this.style.color = "red"; // First child now has red text. }) ```
250,652
<p>I use <code>_vimrc</code> to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting).</p> <p>I would like the background color for...
[ { "answer_id": 250686, "author": "robert", "author_id": 32805, "author_profile": "https://Stackoverflow.com/users/32805", "pm_score": 7, "selected": true, "text": "<pre class=\"lang-vim prettyprint-override\"><code>highlight LineNr ctermfg=grey ctermbg=white\n</code></pre>\n" }, { ...
2008/10/30
[ "https://Stackoverflow.com/questions/250652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
I use `_vimrc` to configure my vim 7.2 (windows) default settings. One setting "set number" will display line numbers on the left side. My vim background color is white (I cannot find setting for this. Maybe the default is white. Anyway I accept this setting). I would like the background color for line numbers to be G...
```vim highlight LineNr ctermfg=grey ctermbg=white ```
250,688
<p>I have the following HTML node structure:</p> <pre><code>&lt;div id="foo"&gt; &lt;div id="bar"&gt;&lt;/div&gt; &lt;div id="baz"&gt; &lt;div id="biz"&gt;&lt;/div&gt; &lt;/div&gt; &lt;span&gt;&lt;/span&gt; &lt;/div&gt; </code></pre> <p>How do I count the number of immediate children of <code>foo</code>, ...
[ { "answer_id": 250694, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 9, "selected": true, "text": "<pre><code>$(\"#foo &gt; div\").length\n</code></pre>\n\n<p>Direct children of the element with the id 'foo' which are ...
2008/10/30
[ "https://Stackoverflow.com/questions/250688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have the following HTML node structure: ``` <div id="foo"> <div id="bar"></div> <div id="baz"> <div id="biz"></div> </div> <span></span> </div> ``` How do I count the number of immediate children of `foo`, that are of type `div`? In the example above, the result should be two (`bar` and `baz`).
``` $("#foo > div").length ``` Direct children of the element with the id 'foo' which are divs. Then retrieving the size of the wrapped set produced.
250,690
<p>I'm looking for a good JavaScript RegEx to convert names to proper cases. For example:</p> <pre><code>John SMITH = John Smith Mary O'SMITH = Mary O'Smith E.t MCHYPHEN-SMITH = E.T McHyphen-Smith John Middlename SMITH = John Middlename SMITH </code></pre> <p>Well you get the idea.</p> <p>Anyone come up with a...
[ { "answer_id": 250707, "author": "harriyott", "author_id": 5744, "author_profile": "https://Stackoverflow.com/users/5744", "pm_score": 0, "selected": false, "text": "<p>Unfortunately there are too many different name formats to do this correctly. John-Joe MacDonald is always going to be ...
2008/10/30
[ "https://Stackoverflow.com/questions/250690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/262775/" ]
I'm looking for a good JavaScript RegEx to convert names to proper cases. For example: ``` John SMITH = John Smith Mary O'SMITH = Mary O'Smith E.t MCHYPHEN-SMITH = E.T McHyphen-Smith John Middlename SMITH = John Middlename SMITH ``` Well you get the idea. Anyone come up with a comprehensive solution?
Something like this? ``` function fix_name(name) { var replacer = function (whole,prefix,word) { ret = []; if (prefix) { ret.push(prefix.charAt(0).toUpperCase()); ret.push(prefix.substr(1).toLowerCase()); } ret.push(word.charAt(0).toUpperCase()); ret....
250,700
<p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like:</p> <pre><code>sudo mod args </code></pre> <p>where mod is a perl...
[ { "answer_id": 250804, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 1, "selected": false, "text": "<p>The simplest thing to do would be the run the controlling script (the Python script) via <code>sudo</code>. Are you able...
2008/10/30
[ "https://Stackoverflow.com/questions/250700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7949/" ]
I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is run like: ``` sudo mod args ``` where mod is a perl script; so in python I wo...
I would choose to go with Pexpect. ``` import pexpect child = pexpect.spawn ('sudo mod -p -c noresource -u dtt -Q') child.expect ('First question:') child.sendline ('Y') child.expect ('Second question:') child.sendline ('Yup') ```
250,713
<p>Why would a stored procedure that returns a table with 9 columns, 89 rows using this code take 60 seconds to execute (.NET 1.1) when it takes &lt; 1 second to run in SQL Server Management Studio? It's being run on the local machine so little/no network latency, fast dev machine</p> <pre><code>Dim command As SqlCom...
[ { "answer_id": 250734, "author": "Marcus King", "author_id": 19840, "author_profile": "https://Stackoverflow.com/users/19840", "pm_score": 1, "selected": false, "text": "<p>Why not make it a DataReader instead of DataAdapter, it looks like you have a singel result set and if you aren't g...
2008/10/30
[ "https://Stackoverflow.com/questions/250713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3256/" ]
Why would a stored procedure that returns a table with 9 columns, 89 rows using this code take 60 seconds to execute (.NET 1.1) when it takes < 1 second to run in SQL Server Management Studio? It's being run on the local machine so little/no network latency, fast dev machine ``` Dim command As SqlCommand = New SqlComm...
First, make sure you are profiling the performance properly. For example, run the query twice from ADO.NET and see if the second time is much faster than the first time. This removes the overhead of waiting for the app to compile and the debugging infrastructure to ramp up. Next, check the default settings in ADO.NET ...
250,717
<p>I'm trying to write a log parsing script to extract failed events. I can pull these with grep:</p> <pre><code>$ grep -A5 "FAILED" log.txt 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33 :FAILED err:023 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 20 74 65 7...
[ { "answer_id": 250761, "author": "Michael Gundlach", "author_id": 4105, "author_profile": "https://Stackoverflow.com/users/4105", "pm_score": 3, "selected": true, "text": "<pre><code>grep -A 5 FAILED log.txt | \\ # Get FAILED and dst and other lines\n egrep '(FAILED|dst=)...
2008/10/30
[ "https://Stackoverflow.com/questions/250717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to write a log parsing script to extract failed events. I can pull these with grep: ``` $ grep -A5 "FAILED" log.txt 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 3a 46 41 49 4c 45 44 20 20 65 72 72 3a 30 32 33 :FAILED err:023 2008-08-19 17:50:07 [7052] [14] DEBUG: data: 20 74 65 78 74 3a 20 00 ...
``` grep -A 5 FAILED log.txt | \ # Get FAILED and dst and other lines egrep '(FAILED|dst=)' | \ # Just the FAILED/dst lines egrep -o "err:[0-9]*|dst=[0-9]*" | \ # Just the err: and dst= phrases cut -d':' -f 2 | \ # Strip "err:" from err: lines cut -d '=' -f 2...
250,718
<p>If I grant execute permissions to a role via</p> <pre><code>GRANT EXECUTE ON [DBO].[MYPROC] TO MY_ROLE </code></pre> <p>what's the equivalent syntax to remove them?</p>
[ { "answer_id": 250723, "author": "mathieu", "author_id": 971, "author_profile": "https://Stackoverflow.com/users/971", "pm_score": 5, "selected": true, "text": "<p>REVOKE EXECUTE ON [DBO].[MYPROC] TO MY_ROLE</p>\n" }, { "answer_id": 250724, "author": "Godeke", "author_id"...
2008/10/30
[ "https://Stackoverflow.com/questions/250718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
If I grant execute permissions to a role via ``` GRANT EXECUTE ON [DBO].[MYPROC] TO MY_ROLE ``` what's the equivalent syntax to remove them?
REVOKE EXECUTE ON [DBO].[MYPROC] TO MY\_ROLE
250,755
<p>I'm trying to export a Crystal Report to an HTML file, but when I call the Export method, I immediately get this error:</p> <blockquote> <p><strong>Source</strong>: Crystal Reports ActiveX Designer </p> <p><strong>Description</strong>: Failed to export the report.</p> </blockquote> <p>I have tried both crEF...
[ { "answer_id": 269715, "author": "user35193", "author_id": 35193, "author_profile": "https://Stackoverflow.com/users/35193", "pm_score": 2, "selected": true, "text": "<p>I'm not sure what you have in the <code>[...]</code> section but your code should include a call to open the report wi...
2008/10/30
[ "https://Stackoverflow.com/questions/250755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21263/" ]
I'm trying to export a Crystal Report to an HTML file, but when I call the Export method, I immediately get this error: > > **Source**: Crystal Reports ActiveX Designer > > > **Description**: Failed to export the report. > > > I have tried both crEFTHTML40 and crEFTHTML32Standard as export format types - and b...
I'm not sure what you have in the `[...]` section but your code should include a call to open the report with an instance of the CRAXDRT Application. ``` Dim objCRReport As CRAXDRT.Report '*********************************** Dim objCRApp As New CRAXDRT.Application objCRReport = objCRApp.OpenReport("<YOUR REPORT FILE...
250,757
<p>I'm writing an application using Qt4.</p> <p>I need to download a very short text file from a given http address.</p> <p>The file is short and is needed for my app to be able to continue, so I would like to make sure the download is blocking (or will timeout after a few seconds if the file in not found/not availab...
[ { "answer_id": 250950, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>you have to call <code>QThread::quit()</code> or <code>exit()</code> if you are done - otherwise your thread will run forev...
2008/10/30
[ "https://Stackoverflow.com/questions/250757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2796/" ]
I'm writing an application using Qt4. I need to download a very short text file from a given http address. The file is short and is needed for my app to be able to continue, so I would like to make sure the download is blocking (or will timeout after a few seconds if the file in not found/not available). I wanted to...
Instead of using a thread you can just go into a loop which calls `processEvents`: ``` while (notFinished) { qApp->processEvents(QEventLoop::WaitForMore | QEventLoop::ExcludeUserInput); } ``` Where `notFinished` is a flag which can be set from the `onRequestFinished` slot. The `ExcludeUserInput` will ensure that...
250,789
<p>I have a CSV data file with rows that may have lots of columns 500+ and some with a lot less. I need to transpose it so that each row becomes a column in the output file. The problem is that the rows in the original file may not all have the same number of columns so when I try the transpose method of array I get:...
[ { "answer_id": 250926, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 4, "selected": true, "text": "<p>I would insert nulls to fill the holes in your matrix, something such as:</p>\n\n<pre><code>a = [[1, 2, 3], [3, 4]]\n\n# T...
2008/10/30
[ "https://Stackoverflow.com/questions/250789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6805/" ]
I have a CSV data file with rows that may have lots of columns 500+ and some with a lot less. I need to transpose it so that each row becomes a column in the output file. The problem is that the rows in the original file may not all have the same number of columns so when I try the transpose method of array I get: > ...
I would insert nulls to fill the holes in your matrix, something such as: ``` a = [[1, 2, 3], [3, 4]] # This would throw the error you're talking about # a.transpose # Largest row size = a.max { |r1, r2| r1.size <=> r2.size }.size # Enlarge matrix inserting nils as needed a.each { |r| r[size - 1] ||= nil } # So no...
250,790
<p>So I'm creating some HTML using javascript based on where the user clicks on the page. On page load the script replaces an empty div with a ul and some data. The user clicks on that data to receive more and so on. Now when the user navigates off the page and then hits the back button to go back to the page, IE displ...
[ { "answer_id": 250926, "author": "bltxd", "author_id": 11892, "author_profile": "https://Stackoverflow.com/users/11892", "pm_score": 4, "selected": true, "text": "<p>I would insert nulls to fill the holes in your matrix, something such as:</p>\n\n<pre><code>a = [[1, 2, 3], [3, 4]]\n\n# T...
2008/10/30
[ "https://Stackoverflow.com/questions/250790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
So I'm creating some HTML using javascript based on where the user clicks on the page. On page load the script replaces an empty div with a ul and some data. The user clicks on that data to receive more and so on. Now when the user navigates off the page and then hits the back button to go back to the page, IE displays...
I would insert nulls to fill the holes in your matrix, something such as: ``` a = [[1, 2, 3], [3, 4]] # This would throw the error you're talking about # a.transpose # Largest row size = a.max { |r1, r2| r1.size <=> r2.size }.size # Enlarge matrix inserting nils as needed a.each { |r| r[size - 1] ||= nil } # So no...
250,801
<p>Hi does anybody know how to initialize two list at the same time with ajax?</p> <p>This is my code</p> <pre><code>&lt;html&gt; &lt;body onload="iniciaListas()"&gt; &lt;script type="text/javascript"&gt; var xmlHttp function iniciaListas() { muestraListaPaises(); muestraListaProfesiones(); } functio...
[ { "answer_id": 250820, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 2, "selected": false, "text": "<p>I would recommend using a different ID for the Ocupation node, and double the adding:</p>\n\n<p>JS Snip - grab th...
2008/10/30
[ "https://Stackoverflow.com/questions/250801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi does anybody know how to initialize two list at the same time with ajax? This is my code ``` <html> <body onload="iniciaListas()"> <script type="text/javascript"> var xmlHttp function iniciaListas() { muestraListaPaises(); muestraListaProfesiones(); } function muestraListaProfesiones() { //Se ...
I would recommend using a different ID for the Ocupation node, and double the adding: JS Snip - grab the other list, add to both: ``` //Se obtine el id de la lista var obCon = document.getElementById("pais"); var obOcupation = document.getElementById("ocupation"); ... for (var i=0; i<obCod.length;i++) { obCon.op...
250,818
<p>How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal)</p> <p>Edit:</p> <p>I'm using Sybase version 11.2</p>
[ { "answer_id": 250862, "author": "Graeme Perrow", "author_id": 1821, "author_profile": "https://Stackoverflow.com/users/1821", "pm_score": 3, "selected": false, "text": "<p>In SQL Anywhere and Sybase IQ:</p>\n\n<pre><code>select * from SYS.SYSPROCEDURE where proc_defn like '%whatever%'\n...
2008/10/30
[ "https://Stackoverflow.com/questions/250818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5472/" ]
How do I find a stored procedure in a Sybase database given a text string that appears somewhere in the proc? I want to see if any other proc in the db has similar logic to the one I'm looking at, and I think I have a pretty unique search string (literal) Edit: I'm using Sybase version 11.2
Two variations on Graeme's answer (So this also won't work on 11.2): This lists the name of the sproc too, but will return multiple rows for each sproc if the text appears several times: ``` select object_name(id),* from syscomments where texttype = 0 and text like '%whatever%' ``` This lists each sproc just on...
250,840
<p>The TextWrapping property of the TextBox has three possible values:</p> <ul> <li>Wrap</li> <li>NoWrap</li> <li>WrapWithOverflow</li> </ul> <p>I would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is ...
[ { "answer_id": 250959, "author": "DCNYAM", "author_id": 30419, "author_profile": "https://Stackoverflow.com/users/30419", "pm_score": -1, "selected": false, "text": "<p>I assume you are talking about .NET. I don't think databinding will work here because the values are not of the same t...
2008/10/30
[ "https://Stackoverflow.com/questions/250840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12919/" ]
The TextWrapping property of the TextBox has three possible values: * Wrap * NoWrap * WrapWithOverflow I would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is not checked, I want to set the TextWrapping ...
If you want to do this all in xaml you need to use a [Style](http://msdn.microsoft.com/en-us/library/system.windows.style.aspx) and a [DataTrigger](http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx). ``` <StackPanel> <CheckBox x:Name="WordWrap">Word Wrap</CheckBox> <TextBlock Width="50"> ...
250,850
<p>I've got a little c# windows service that periodically pulls xml from a web service and stores the data in a database table.</p> <p>Unfortunately it's failing because the web service has occasional bad data in it - strings instead of decimals. I don't have any control over the web service (unvalidated user input f...
[ { "answer_id": 250859, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Pre-process the XML provided by the\n web service before loading into the\n validating XML reader, removin...
2008/10/30
[ "https://Stackoverflow.com/questions/250850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12744/" ]
I've got a little c# windows service that periodically pulls xml from a web service and stores the data in a database table. Unfortunately it's failing because the web service has occasional bad data in it - strings instead of decimals. I don't have any control over the web service (unvalidated user input from softwar...
> > Pre-process the XML provided by the > web service before loading into the > validating XML reader, removing any > bad nodes entirely. > > > This is the option I would choose, it would allow you to grab the bad input before the exception and store it somewhere so it can be looked at later. Then you can find ...
250,867
<p>Assuming a table of tags like the stackoverflow question tags:</p> <blockquote> <p>TagID (bigint), QuestionID (bigint), Tag (varchar)</p> </blockquote> <p>What is the most efficient way to get the 25 most used tags using LINQ? In SQL, a simple GROUP BY will do:</p> <pre><code>SELECT Tag, COUNT(Tag) FROM Tags G...
[ { "answer_id": 250906, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 4, "selected": true, "text": "<p>I'm pretty sure you've got it right. And, the SQL that LINQ generates and will send to your db will look just lik...
2008/10/30
[ "https://Stackoverflow.com/questions/250867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/192/" ]
Assuming a table of tags like the stackoverflow question tags: > > TagID (bigint), QuestionID (bigint), Tag (varchar) > > > What is the most efficient way to get the 25 most used tags using LINQ? In SQL, a simple GROUP BY will do: ``` SELECT Tag, COUNT(Tag) FROM Tags GROUP BY Tag ``` I've written some LINQ tha...
I'm pretty sure you've got it right. And, the SQL that LINQ generates and will send to your db will look just like the SQL you started with, so while you're doing a bit more typing, your database isn't doing any more work.
250,868
<p>I've heard that there are some things one cannot do as a computer programmer, but I don't know what they are. One thing that occurred to me recently was: wouldn't it be nice to have a class that could make a copy of the source of the program it runs, modify that program and add a method to the class that it is, and ...
[ { "answer_id": 250872, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 3, "selected": false, "text": "<p>Sure it is. That's how a lot of viruses work!</p>\n" }, { "answer_id": 250876, "author": "Toon Krijth...
2008/10/30
[ "https://Stackoverflow.com/questions/250868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29182/" ]
I've heard that there are some things one cannot do as a computer programmer, but I don't know what they are. One thing that occurred to me recently was: wouldn't it be nice to have a class that could make a copy of the source of the program it runs, modify that program and add a method to the class that it is, and the...
Start by looking at [quines](http://en.wikipedia.org/wiki/Quines), then at Macro-Assemblers and then [lex & yacc](http://www.google.com/search?q=lex+yacc), and [flex & bison](http://www.google.com/search?q=flex+bison). Then consider [self-modifying code](http://en.wikipedia.org/wiki/Self-modifying_code). Here's a quin...
250,874
<p>How do implement the iterator pattern in <a href="http://en.wikipedia.org/wiki/Visual_Basic_.NET" rel="nofollow noreferrer">VB.NET</a>, which does not have the <code>yield</code> keyword?</p>
[ { "answer_id": 250899, "author": "Jeff Atwood", "author_id": 1, "author_profile": "https://Stackoverflow.com/users/1", "pm_score": 1, "selected": false, "text": "<p>Hmm, looks like you might be <a href=\"http://weblogs.asp.net/jgaylord/archive/2007/10/17/vb-net-s-quot-yield-return-quot.a...
2008/10/30
[ "https://Stackoverflow.com/questions/250874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31766/" ]
How do implement the iterator pattern in [VB.NET](http://en.wikipedia.org/wiki/Visual_Basic_.NET), which does not have the `yield` keyword?
This is now supported in VS 2010 SP1, with the Async CTP, see: [Iterators (C# and Visual Basic) on MSDN](http://msdn.microsoft.com/en-us/vstudio/gg497937) and [download Visual Studio Async CTP (Version 3)](http://www.microsoft.com/en-us/download/details.aspx?id=9983). Code such as this, works: ``` Private Iterator F...
250,911
<p>An application I am working on reads information from files to populate a database. Some of the characters in the files are non-English, for example accented French characters.</p> <p>The application is working fine in Windows but on our Solaris machine it is failing to recognise the special characters and is throw...
[ { "answer_id": 250944, "author": "sakana", "author_id": 28921, "author_profile": "https://Stackoverflow.com/users/28921", "pm_score": 2, "selected": false, "text": "<p>Try to use</p>\n\n<pre><code>java -Dfile.encoding=UTF-8 ...\n</code></pre>\n\n<p>when starting the application in both s...
2008/10/30
[ "https://Stackoverflow.com/questions/250911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22061/" ]
An application I am working on reads information from files to populate a database. Some of the characters in the files are non-English, for example accented French characters. The application is working fine in Windows but on our Solaris machine it is failing to recognise the special characters and is throwing an exc...
Try to use ``` java -Dfile.encoding=UTF-8 ... ``` when starting the application in both systems. Another way to solve the problem is to change the encoding from both system to UTF-8, but i prefer the first option (less intrusive on the system). EDIT: Check this answer on stackoverflow, It might help either: [Cha...
250,931
<p>I have some HTML that displays fine on FireFox3/Opera/Safari but not with IE7. The snippet is as follows:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt;&lt;/...
[ { "answer_id": 251049, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 0, "selected": false, "text": "<p>I'm not quite sure why that is happening. What layout are you trying to achieve, does it really need to be a tab...
2008/10/30
[ "https://Stackoverflow.com/questions/250931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14260/" ]
I have some HTML that displays fine on FireFox3/Opera/Safari but not with IE7. The snippet is as follows: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body bgcolor="#AA5566" >...
What if you try it like this: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body bgcolor="#AA5566" > <table width="100%" border='1'> <tr> <td valign="top"> ...
250,932
<p>I have a hyper link like this :</p> <pre><code>&lt;A Href=My_Java_Servlet?User_Action=Admin_Download_Records&amp;User_Id=Admin onClick=\"Check_Password();\" target=_blank&gt;Download Records&lt;/A&gt; </code></pre> <p>When a user clicks on it, a password window will open, the user can try 3 times for the right pas...
[ { "answer_id": 250941, "author": "Geo", "author_id": 31610, "author_profile": "https://Stackoverflow.com/users/31610", "pm_score": 0, "selected": false, "text": "<p>Why are you returning <strong>\"false\"</strong> instead of <strong>false</strong> ?</p>\n" }, { "answer_id": 25094...
2008/10/30
[ "https://Stackoverflow.com/questions/250932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32834/" ]
I have a hyper link like this : ``` <A Href=My_Java_Servlet?User_Action=Admin_Download_Records&User_Id=Admin onClick=\"Check_Password();\" target=_blank>Download Records</A> ``` When a user clicks on it, a password window will open, the user can try 3 times for the right password. The Javascript looks like this : ...
Clientside JavaScript is perhaps the worst possible way to provide "security". Users can just view the source to see all of your passwords, or just disable JavaScript altogether. **Do not do this.**
250,937
<p>I have a very simple ASP.Net page that acts as a front end for a stored procedure. It just runs the procedure and shows the output using a gridview control: less than 40 lines of total code, including aspx markup. The stored procedure itself is very... volatile. It's used for a number of purposes and the output f...
[ { "answer_id": 250958, "author": "Mischa Kroon", "author_id": 30600, "author_profile": "https://Stackoverflow.com/users/30600", "pm_score": 0, "selected": false, "text": "<p>You can use the isDate() function to see if something is a valid date and then use dateformatting options to make ...
2008/10/30
[ "https://Stackoverflow.com/questions/250937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3043/" ]
I have a very simple ASP.Net page that acts as a front end for a stored procedure. It just runs the procedure and shows the output using a gridview control: less than 40 lines of total code, including aspx markup. The stored procedure itself is very... volatile. It's used for a number of purposes and the output format ...
If you are auto generating the columns which it sounds like you are. The procedure for using the grids formatting is awful. You would need to loop through all the columns of the grid, probably in the databound event and apply a formatting expression to any column you find is a date column. If you are not auto generat...
250,970
<p>The object I’m working on is instantiated in JavaScript, but used in VBScript. In one code path, the variable <code>M.DOM.IPt</code> is defined and has a value, in the other however it is not. I need to detect if it has been defined or not. I checked that <code>M.DOM</code> is defined and accessable in both code pat...
[ { "answer_id": 251062, "author": "Joseph Bui", "author_id": 3275, "author_profile": "https://Stackoverflow.com/users/3275", "pm_score": 0, "selected": false, "text": "<p>Have you tried On Error Goto label?</p>\n" }, { "answer_id": 251107, "author": "Arvo", "author_id": 35...
2008/10/30
[ "https://Stackoverflow.com/questions/250970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/80/" ]
The object I’m working on is instantiated in JavaScript, but used in VBScript. In one code path, the variable `M.DOM.IPt` is defined and has a value, in the other however it is not. I need to detect if it has been defined or not. I checked that `M.DOM` is defined and accessable in both code paths. Every test I have tri...
``` Function SupportsMember(object, memberName) On Error Resume Next Dim x Eval("x = object."+memberName) If Err = 438 Then SupportsMember = False Else SupportsMember = True End If On Error Goto 0 'clears error End Function ```
250,973
<p>I wanted to write a Visual Studio Macro or something similar which can fetch function name and insert into preset location in the error report part. It's clearer if you look at the example</p> <pre><code>Class SampleClass { public void FunctionA() { try { //Do some work here ...
[ { "answer_id": 251001, "author": "Ovidiu Pacurar", "author_id": 28419, "author_profile": "https://Stackoverflow.com/users/28419", "pm_score": 1, "selected": false, "text": "<p>Take a look at System.Diagnostics.StackTrace and then you can create just one log call getting the function from...
2008/10/30
[ "https://Stackoverflow.com/questions/250973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20007/" ]
I wanted to write a Visual Studio Macro or something similar which can fetch function name and insert into preset location in the error report part. It's clearer if you look at the example ``` Class SampleClass { public void FunctionA() { try { //Do some work here } ...
Take a look at System.Diagnostics.StackTrace and then you can create just one log call getting the function from the stack.
251,030
<p>In <a href="https://stackoverflow.com/questions/226206/alternating-item-style">this question</a>, I was given a really cool answer to alternating an image and its description between left and right, respectively. Now I want to apply styling to both, e.g. padding-top, padding-bottom etc. How do I apply a style to bo...
[ { "answer_id": 251037, "author": "changelog", "author_id": 5646, "author_profile": "https://Stackoverflow.com/users/5646", "pm_score": 5, "selected": false, "text": "<p>Here's how you do it:</p>\n\n<pre><code>.ProductAltItemStyle, .ProductItemStyle {\n // CSS Rules that apply to both ...
2008/10/30
[ "https://Stackoverflow.com/questions/251030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8741/" ]
In [this question](https://stackoverflow.com/questions/226206/alternating-item-style), I was given a really cool answer to alternating an image and its description between left and right, respectively. Now I want to apply styling to both, e.g. padding-top, padding-bottom etc. How do I apply a style to both the RowStyle...
Alternatively you can do this: ``` <AlternatingRowStyle CssClass="ProductAltItemStyle ProductCommonStyle" /> <RowStyle CssClass="ProductItemStyle ProductCommonStyle" /> ``` ProductCommonStyle contains formatting that is common to both alternating and standard rows. Even better, you can assign a style to your wh...
251,033
<p>How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL?</p> <p>Thank you.</p>
[ { "answer_id": 251045, "author": "bobwienholt", "author_id": 24257, "author_profile": "https://Stackoverflow.com/users/24257", "pm_score": 5, "selected": true, "text": "<pre><code>select convert(datetime, '20081030')\n</code></pre>\n" }, { "answer_id": 251046, "author": "JGW"...
2008/10/30
[ "https://Stackoverflow.com/questions/251033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL? Thank you.
``` select convert(datetime, '20081030') ```
251,090
<p>I like Vim's visual mode. <kbd>v</kbd> for highlight/select chars or lines, <kbd>Ctrl</kbd><kbd>v</kbd> for rectangle highlighting, as far as I know (I am a beginner). Is there any way to use visual mode to highlight last two chars, for example, on each line for some selected lines? The selected lines are in differe...
[ { "answer_id": 251132, "author": "ryan_s", "author_id": 13728, "author_profile": "https://Stackoverflow.com/users/13728", "pm_score": 2, "selected": false, "text": "<p>I can't think of a way to do this in visual mode, but you could use a command like this to do it...</p>\n\n<pre><code>:1...
2008/10/30
[ "https://Stackoverflow.com/questions/251090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62776/" ]
I like Vim's visual mode. `v` for highlight/select chars or lines, `Ctrl``v` for rectangle highlighting, as far as I know (I am a beginner). Is there any way to use visual mode to highlight last two chars, for example, on each line for some selected lines? The selected lines are in different length. Basically, I would ...
My approach to this sort of problem is to use line selection (shift-V, cursor movement) to select the lines-of-interest, then type: ``` :s/..$// ``` That's a substitution, using the regex `..$` which will match the last two characters at the end of the line. Then substitute 'nothing' i.e. delete. In vim, once you ...
251,091
<p>I've got a small web form with 2 radio buttons, call them PickFromList and EnterValue. When PickFromList is checked I want to show a GridView that I've configured to bind to an ObjectDataSource. When EnterValue is checked I want the GridView to disappear.</p> <p>This form is laid out using a table and want to hid...
[ { "answer_id": 251170, "author": "the-undefined", "author_id": 32792, "author_profile": "https://Stackoverflow.com/users/32792", "pm_score": 0, "selected": false, "text": "<p>hmm.. not quite sure but something which has got me a few times is have the AutoWireEvents set to false, its at t...
2008/10/30
[ "https://Stackoverflow.com/questions/251091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12260/" ]
I've got a small web form with 2 radio buttons, call them PickFromList and EnterValue. When PickFromList is checked I want to show a GridView that I've configured to bind to an ObjectDataSource. When EnterValue is checked I want the GridView to disappear. This form is laid out using a table and want to hide/show the a...
Why dont you just show/hide the TRs with javascript? That way you won't have this problem and you'll have a much more responsive UI. With jQuery: $('.classOnShowRadioButton').click(function(){ $('.trToShow').show(); $('.trToHide').hide(); }); then obviously do the reverse for the other radio button.
251,110
<p>I tried this:</p> <pre><code>ALTER TABLE My.Table DROP MyField </code></pre> <p>and got this error:</p> <p>-MyField is not a constraint.</p> <p>-Could not drop constraint. See previous errors.</p> <p>There is just one row of data in the table and the field was just added.</p> <p><strong>EDIT:</strong> Just to ...
[ { "answer_id": 251114, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 3, "selected": false, "text": "<p>I think you are just missing the COLUMN keyword:</p>\n\n<pre><code>ALTER TABLE TableName DROP COLUMN ColumnName\n<...
2008/10/30
[ "https://Stackoverflow.com/questions/251110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2631856/" ]
I tried this: ``` ALTER TABLE My.Table DROP MyField ``` and got this error: -MyField is not a constraint. -Could not drop constraint. See previous errors. There is just one row of data in the table and the field was just added. **EDIT:** Just to follow up, the sql was missing COLUMN indeed. Now I get even more s...
Brian solved your original problem - for your new problem (The object 'some\_object\_\_somenumbers' is dependent on column 'MyField') it means you have a dependancy issue. Something like an index, foreign key reference, default value, etc. To drop the constraint use: ``` ALTER TABLE TableName DROP ConstraintName ``` ...
251,115
<p>I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example,</p> <p>this is the token 9,999,999.99</p> <p>So here's is how I am approaching th...
[ { "answer_id": 251131, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 2, "selected": false, "text": "<p>I think you've got the right idea in chunking the file. You may want to read chunks in at line breaks rather tha...
2008/10/30
[ "https://Stackoverflow.com/questions/251115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am working on a project where I search through a large text file (large is relative, file size is about 1 Gig) for a piece of data. I am looking for a token and I want a dollar value immediately after that token. For example, this is the token 9,999,999.99 So here's is how I am approaching this problem. After a lit...
I think you've got the right idea in chunking the file. You may want to read chunks in at line breaks rather than a set number of bytes, though. In your current implementation, if the token lies on a 1000 byte boundary it could get cut in half, preventing you from finding it. The same thing could cause the data to be c...
251,116
<p>I use Eclipse with "external" projects - i.e. projects created from existing source.</p> <p>Poking around in the workspace files, I cannot find any reference to these projects. My question is: how does Eclipse keep track of these projects?</p> <p>I'd like to be able to add such a project to the workspace automatic...
[ { "answer_id": 251129, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 8, "selected": true, "text": "<p>Windows:</p>\n<pre><code>&lt;workspace&gt;\\.metadata\\.plugins\\org.eclipse.core.resources\\.projects\\\n</code></pre>\n<p>L...
2008/10/30
[ "https://Stackoverflow.com/questions/251116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16977/" ]
I use Eclipse with "external" projects - i.e. projects created from existing source. Poking around in the workspace files, I cannot find any reference to these projects. My question is: how does Eclipse keep track of these projects? I'd like to be able to add such a project to the workspace automatically (by generati...
Windows: ``` <workspace>\.metadata\.plugins\org.eclipse.core.resources\.projects\ ``` Linux / osx: ``` <workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/ ``` Your project can exist outside the workspace, but all Eclipse-specific `metadata` are stored in that `org.eclipse.core.resources\.projects...
251,117
<p>So yeah, I'm a Java guy in this crazy iPhone world. When it comes to memory management I stiill don't have a very good idea of what I'm doing. </p> <p>I have an app that uses a navigation controller, and when it's time to go on to the next view I have code that looks like this:</p> <pre><code>UIViewController *myC...
[ { "answer_id": 251233, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 3, "selected": false, "text": "<p>The problem is (most likely) you're releasing your viewController <em>before</em> the Navigation Controller has a ch...
2008/10/30
[ "https://Stackoverflow.com/questions/251117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
So yeah, I'm a Java guy in this crazy iPhone world. When it comes to memory management I stiill don't have a very good idea of what I'm doing. I have an app that uses a navigation controller, and when it's time to go on to the next view I have code that looks like this: ``` UIViewController *myController = [[MyViewC...
@Ben Gottlieb why do you need to autorelease before pushing it? Retain count at object allocation is 1, autorelease before or after pushing doesn't affect the retain count, though generally autoreleasing as a matter of style is applied afer object alloc/init: ``` [[[object alloc] init] autorelease]; ``` @bpapa, 2)...