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
100,860
<p>As most of you would know, if I drop a file named app_offline.htm in the root of an asp.net application, it takes the application offline <a href="http://asp-net-whidbey.blogspot.com/2006/04/aspnet-20-features-appofflinehtm.html" rel="nofollow noreferrer">as detailed here</a>.</p> <p>You would also know, that while...
[ { "answer_id": 100881, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 1, "selected": false, "text": "<p>You can try turning it off in the web.config.</p>\n\n<pre><code>&lt;httpRuntime enable = \"False\"/&gt;\n</code></pre>\n...
2008/09/19
[ "https://Stackoverflow.com/questions/100860", "https://Stackoverflow.com", "https://Stackoverflow.com/users/380/" ]
As most of you would know, if I drop a file named app\_offline.htm in the root of an asp.net application, it takes the application offline [as detailed here](http://asp-net-whidbey.blogspot.com/2006/04/aspnet-20-features-appofflinehtm.html). You would also know, that while this is great, IIS actually returns a 404 cod...
The handling of app\_offline.htm is hardcoded in the ASP.NET pipeline, and can't be modified: see `CheckApplicationEnabled()` in `HttpRuntime.cs`, where it throws a very non-configurable 404 error if the application is deemed to be offline. However, [creating your own HTTP module](http://support.microsoft.com/kb/30799...
100,898
<p>What's the best / simplest / most accurate way to detect the browser of a user?</p> <p>Ease of extendability and implementation is a plus.</p> <p>The less technologies used, the better.</p> <p>The solution can be server side, client side, or both. The results should eventually end up at the server, though.</p> <...
[ { "answer_id": 100908, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://jquery.thewikies.com/browser/\" rel=\"noreferrer\">JQuery Browser Plugin</a> will do it client-side ...
2008/09/19
[ "https://Stackoverflow.com/questions/100898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
What's the best / simplest / most accurate way to detect the browser of a user? Ease of extendability and implementation is a plus. The less technologies used, the better. The solution can be server side, client side, or both. The results should eventually end up at the server, though. The solution can be framework...
On the server you're pretty much limited to the UserAgent string the browser provides (which is fraught with problems, have a read about the [UserAgent string's history](http://www.webaim.org/blog/user-agent-string-history/)). On the client (ie in Javascript), you have more options. But the best option is to not actua...
100,904
<p>Per man pages, snprintf is returning number of bytes written from glibc version 2.2 onwards. But on lower versions of libc2.2 and HP-UX, it returns a positive integer, which could lead to a buffer overflow.</p> <p>How can one overcome this and write portable code?</p> <p>Edit : For want of more clarity</p> <p>Thi...
[ { "answer_id": 100936, "author": "finnw", "author_id": 12048, "author_profile": "https://Stackoverflow.com/users/12048", "pm_score": 0, "selected": false, "text": "<p>I have found one portable way to predict and/or limit the number of characters returned by sprintf and related functions,...
2008/09/19
[ "https://Stackoverflow.com/questions/100904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18657/" ]
Per man pages, snprintf is returning number of bytes written from glibc version 2.2 onwards. But on lower versions of libc2.2 and HP-UX, it returns a positive integer, which could lead to a buffer overflow. How can one overcome this and write portable code? Edit : For want of more clarity This code is working perfec...
you could create a snprintf wrapper that returns -1 for each case when there is not enough space in the buffer. See the [man page](http://linux.die.net/man/3/snprintf) for more docs. It has also an example which threats all the cases. ``` while (1) { /* Try to print in the allocated space. */ va_start(a...
100,917
<p>I'm trying to read data from a Delphi DBIV database, every time I access the database it creates a Paradox.lck and a Pdoxusrs.lck file. I'm using only a TQuery Object to do this (nothing else). can I access a Delphi DBIV database without it creating these lock files?</p>
[ { "answer_id": 100936, "author": "finnw", "author_id": 12048, "author_profile": "https://Stackoverflow.com/users/12048", "pm_score": 0, "selected": false, "text": "<p>I have found one portable way to predict and/or limit the number of characters returned by sprintf and related functions,...
2008/09/19
[ "https://Stackoverflow.com/questions/100917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to read data from a Delphi DBIV database, every time I access the database it creates a Paradox.lck and a Pdoxusrs.lck file. I'm using only a TQuery Object to do this (nothing else). can I access a Delphi DBIV database without it creating these lock files?
you could create a snprintf wrapper that returns -1 for each case when there is not enough space in the buffer. See the [man page](http://linux.die.net/man/3/snprintf) for more docs. It has also an example which threats all the cases. ``` while (1) { /* Try to print in the allocated space. */ va_start(a...
100,922
<p>Can someone explain to me the advantages of using an IOC container over simply hardcoding the default implementation into a default constructor?</p> <p>In other words, what is wrong about this code?</p> <pre><code>public class MyClass { private IMyInterface _myInterface; public MyClass() { _my...
[ { "answer_id": 100951, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 5, "selected": true, "text": "<p>The idea of IoC is to delegate part of your component's functionality to another part of the system. In IoC world, you have co...
2008/09/19
[ "https://Stackoverflow.com/questions/100922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
Can someone explain to me the advantages of using an IOC container over simply hardcoding the default implementation into a default constructor? In other words, what is wrong about this code? ``` public class MyClass { private IMyInterface _myInterface; public MyClass() { _myInterface = new Defau...
The idea of IoC is to delegate part of your component's functionality to another part of the system. In IoC world, you have components that don't know about each other. Your example violates this, as you're creating tight coupling between MyClass and some implementation of IMyInterface. **The main idea** is that your c...
100,948
<p>I installed MySQL via <a href="http://en.wikipedia.org/wiki/MacPorts" rel="noreferrer">MacPorts</a>. What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?</p>
[ { "answer_id": 100953, "author": "Dan", "author_id": 17121, "author_profile": "https://Stackoverflow.com/users/17121", "pm_score": 4, "selected": false, "text": "<p>Apparently you want:</p>\n\n<pre><code>sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop\n</code></pre>\n\n<p>Have a furthe...
2008/09/19
[ "https://Stackoverflow.com/questions/100948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]
I installed MySQL via [MacPorts](http://en.wikipedia.org/wiki/MacPorts). What is the command I need to stop the server (I need to test how my application behave when MySQL is dead)?
There are different cases depending on whether you installed [MySQL](http://en.wikipedia.org/wiki/MySQL) with the official binary installer, using [MacPorts](http://en.wikipedia.org/wiki/MacPorts), or using [Homebrew](http://brew.sh/): Homebrew -------- ``` brew services start mysql brew services stop mysql brew serv...
100,990
<p>How could I get the Fault Detail sent by a SoapFaultClientException ? I use a WebServiceTemplate as shown below :</p> <pre><code>WebServiceTemplate ws = new WebServiceTemplate(); ws.setMarshaller(client.getMarshaller()); ws.setUnmarshaller(client.getUnMarshaller()); try { MyResponse resp = (MyResponse) = ws.mar...
[ { "answer_id": 105872, "author": "John Meagher", "author_id": 3535, "author_profile": "https://Stackoverflow.com/users/3535", "pm_score": 1, "selected": false, "text": "<p>From the Javadocs for the <a href=\"http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframewor...
2008/09/19
[ "https://Stackoverflow.com/questions/100990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18714/" ]
How could I get the Fault Detail sent by a SoapFaultClientException ? I use a WebServiceTemplate as shown below : ``` WebServiceTemplate ws = new WebServiceTemplate(); ws.setMarshaller(client.getMarshaller()); ws.setUnmarshaller(client.getUnMarshaller()); try { MyResponse resp = (MyResponse) = ws.marshalSendAndRec...
I also had the problem that getFaultDetail() returned null (for a SharePoint web service). I could get the detail element out by using a method similar to this: ``` private Element getDetail(SoapFaultClientException e) throws TransformerException { TransformerFactory transformerFactory = TransformerFactory.newInst...
101,012
<p>Our rails app is designed as a single code base linking to multiple client databases. Based on the subdomain the app determines which db to connect to.</p> <p>We use liquid templates to customise the presentation for each client. We are unable to customise the generic 'We're Sorry, somethign went wrong..' message f...
[ { "answer_id": 101027, "author": "mislav", "author_id": 11687, "author_profile": "https://Stackoverflow.com/users/11687", "pm_score": 4, "selected": true, "text": "<p>For catching exceptions in Rails 2, <code>rescue_from</code> controller method is a great way to specify actions which ha...
2008/09/19
[ "https://Stackoverflow.com/questions/101012", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Our rails app is designed as a single code base linking to multiple client databases. Based on the subdomain the app determines which db to connect to. We use liquid templates to customise the presentation for each client. We are unable to customise the generic 'We're Sorry, somethign went wrong..' message for each cl...
For catching exceptions in Rails 2, `rescue_from` controller method is a great way to specify actions which handle various cases. ``` class ApplicationController < ActionController::Base rescue_from MyAppError, :with => :show_errors def show_errors render :action => "..." end end ``` This way you can make...
101,033
<p>I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? Can I call it from plain SQL?</p>
[ { "answer_id": 101064, "author": "Thilo", "author_id": 14955, "author_profile": "https://Stackoverflow.com/users/14955", "pm_score": 5, "selected": false, "text": "<p>I think you want to return a REFCURSOR:</p>\n\n<pre><code>create function test_cursor \n return sys_refcursor\...
2008/09/19
[ "https://Stackoverflow.com/questions/101033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? Can I call it from plain SQL?
Here is how to build a function that returns a result set that can be queried as if it were a table: ``` SQL> create type emp_obj is object (empno number, ename varchar2(10)); 2 / Type created. SQL> create type emp_tab is table of emp_obj; 2 / Type created. SQL> create or replace function all_emps return emp...
101,070
<p>If you are writing a <em>simple</em> little loop, what <em>should</em> you name the counter?</p> <p><em>Provide example loops!</em></p>
[ { "answer_id": 101071, "author": "just mike", "author_id": 12293, "author_profile": "https://Stackoverflow.com/users/12293", "pm_score": 4, "selected": false, "text": "<p>My experience is that most people use single letters, e.g.:\n<code>i</code>,\n<code>j</code>,\n<code>k</code>,\n...\n...
2008/09/19
[ "https://Stackoverflow.com/questions/101070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12293/" ]
If you are writing a *simple* little loop, what *should* you name the counter? *Provide example loops!*
I always use a **meaningful name** unless it's a single-level loop and the variable has no meaning other than "the number of times I've been through this loop", in which case I use `i`. When using meaningful names: * the code is more understandable to colleagues reading your code, * it's easier to find bugs in the lo...
101,072
<p>Was this an oversight? Or is it to do with the JVM?</p>
[ { "answer_id": 101084, "author": "Confusion", "author_id": 16784, "author_profile": "https://Stackoverflow.com/users/16784", "pm_score": 1, "selected": false, "text": "<p>I guess it has to do with the fact that the JVM is coded in C++. Apart from that, pointers and references are nearly ...
2008/09/19
[ "https://Stackoverflow.com/questions/101072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4857/" ]
Was this an oversight? Or is it to do with the JVM?
Java does indeed have pointers--pointers on which you cannot perform pointer arithmetic. From the venerable [JLS](http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.1): > > There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3). There are, corr...
101,096
<p>I have an Exchange mailbox linked as a table in an MS Access app. This is primarily used for reading, but I would also like to be able to "move" messages to another folder. </p> <p>Unfortunately this is not as simple as writing in a second linked mailbox, because apparently I can not edit some fields. Some critic...
[ { "answer_id": 102406, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 1, "selected": false, "text": "<p>Is this two problems? Mail can be moved using the Move method. Here is a snippet:</p>\n\n<pre><code> Set oApp = CreateO...
2008/09/19
[ "https://Stackoverflow.com/questions/101096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have an Exchange mailbox linked as a table in an MS Access app. This is primarily used for reading, but I would also like to be able to "move" messages to another folder. Unfortunately this is not as simple as writing in a second linked mailbox, because apparently I can not edit some fields. Some critical fields li...
Is this two problems? Mail can be moved using the Move method. Here is a snippet: ``` Set oApp = CreateObject("Outlook.Application") Set oNS = oApp.GetNamespace("MAPI") Set oMailItems = oNS.GetDefaultFolder(olFolderInbox) Set itm = oMailItems.Items(6) itm.Move oNS.GetDefaultFolder(olFolderDeletedItems) ``` Howeve...
101,125
<p>Is there a way to check if the user has a different version of the CSS cached by their browser and if so force their browser to pull the new version?</p>
[ { "answer_id": 101131, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 0, "selected": false, "text": "<p>You should possibly just share a common ancestor class, then you can flick it with a single js command if need be....
2008/09/19
[ "https://Stackoverflow.com/questions/101125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to check if the user has a different version of the CSS cached by their browser and if so force their browser to pull the new version?
I don´t know if it is correct usage, but I think you can force a reload of the css file using a query string: ``` <link href="mystyle.css?SOME_UNIQUE_TEXT" type="text/css" rel="stylesheet" /> ``` I remember I used this method years ago to force a reload of a web-cam image, but time has probably moved on...
101,128
<p>How do I read text from the (windows) clipboard with python?</p>
[ { "answer_id": 101143, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 2, "selected": false, "text": "<p>Try win32clipboard from the win32all package (that's probably installed if you're on ActiveState Python).</p>\n\n<p...
2008/09/19
[ "https://Stackoverflow.com/questions/101128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17493/" ]
How do I read text from the (windows) clipboard with python?
You can use the module called [win32clipboard](http://docs.activestate.com/activepython/2.5/pywin32/win32clipboard.html), which is part of [pywin32](https://github.com/mhammond/pywin32). Here is an example that first sets the clipboard data then gets it: ``` import win32clipboard # set clipboard data win32clipboard....
101,145
<p>How can someone validate that a specific element exists in an XML file? Say I have an ever changing XML file and I need to verify every element exists before reading/parsing it. </p>
[ { "answer_id": 101160, "author": "Chris James", "author_id": 3193, "author_profile": "https://Stackoverflow.com/users/3193", "pm_score": 6, "selected": false, "text": "<pre><code>if(doc.SelectSingleNode(\"//mynode\")==null)....\n</code></pre>\n\n<p>Should do it (where doc is your XmlDocu...
2008/09/19
[ "https://Stackoverflow.com/questions/101145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can someone validate that a specific element exists in an XML file? Say I have an ever changing XML file and I need to verify every element exists before reading/parsing it.
``` if(doc.SelectSingleNode("//mynode")==null).... ``` Should do it (where doc is your XmlDocument object, obviously) Alternatively you could use an XSD and validate against that
101,151
<p>I have the following scenario:</p> <pre> public class CarManager { .. public long AddCar(Car car) { try { string username = _authorizationManager.GetUsername(); ... long id = _carAccessor.AddCar(username, car.Id, car.Name, ....); if(id == 0) { ...
[ { "answer_id": 101190, "author": "Andreas Bakurov", "author_id": 7400, "author_profile": "https://Stackoverflow.com/users/7400", "pm_score": 1, "selected": false, "text": "<p>Unit Test should focus only to its corresponding class under testing. All attributes of class that are not of sam...
2008/09/19
[ "https://Stackoverflow.com/questions/101151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15771/" ]
I have the following scenario: ``` public class CarManager { .. public long AddCar(Car car) { try { string username = _authorizationManager.GetUsername(); ... long id = _carAccessor.AddCar(username, car.Id, car.Name, ....); if(id == 0) { thr...
There are two issues here: * Unit tests should do more than test methods one at a time. They should be designed to prove that your class can do the job it was designed for when integrated with the rest of the system. So you should mock out the dependencies and then write a test for each way in which you class will act...
101,156
<p>I need to count and check how much of some images is placed in folder od web server. Example- images get names from <code>user_id</code>, and on example I have <code>user_id 27</code>, and my images are:</p> <pre><code>27_1.jpg, 27_2.jpg, 27_3.jpg, ... </code></pre> <p>How to check and write to database this thing...
[ { "answer_id": 101230, "author": "hometoast", "author_id": 2009, "author_profile": "https://Stackoverflow.com/users/2009", "pm_score": 2, "selected": false, "text": "<p>Once you know your path you can use IO.Directory.GetFiles() method.</p>\n\n<pre><code>IO.Directory.GetFiles(\"\\transla...
2008/09/19
[ "https://Stackoverflow.com/questions/101156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/205368/" ]
I need to count and check how much of some images is placed in folder od web server. Example- images get names from `user_id`, and on example I have `user_id 27`, and my images are: ``` 27_1.jpg, 27_2.jpg, 27_3.jpg, ... ``` How to check and write to database this thing? Thanks
Once you know your path you can use IO.Directory.GetFiles() method. ``` IO.Directory.GetFiles("\translated\path","27_*.jpg").Count() ``` will give you what you're looking for.
101,162
<p>How do you return a serialized JSON object to the client side using ASP.NET MVC via an AJAX call?</p>
[ { "answer_id": 101256, "author": "David Bick", "author_id": 4914, "author_profile": "https://Stackoverflow.com/users/4914", "pm_score": 6, "selected": true, "text": "<p>From the controller you can just return a JsonResult:</p>\n\n<pre><code>public ActionResult MyAction()\n{\n ... // P...
2008/09/19
[ "https://Stackoverflow.com/questions/101162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you return a serialized JSON object to the client side using ASP.NET MVC via an AJAX call?
From the controller you can just return a JsonResult: ``` public ActionResult MyAction() { ... // Populate myObject return new JsonResult{ Data = myObject }; } ``` The form of the Ajax call will depend on which library you're using, of course. Using jQuery it would be something like: ``` $.getJSON("/control...
101,174
<p>In Python there is a really neat function called <code>zip</code> which can be used to iterate through two lists at the same time:</p> <pre><code>list1 = [1, 2, 3] list2 = ["a", "b", "c"] for v1, v2 in zip(list1, list2): print v1 + " " + v2 </code></pre> <p>The above code should produce the following:</p> <pr...
[ { "answer_id": 101207, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 3, "selected": false, "text": "<p>Nope, there is no such function in .NET. You have roll out your own. Note that C# doesn't support tuples, so python-like synt...
2008/09/19
[ "https://Stackoverflow.com/questions/101174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16047/" ]
In Python there is a really neat function called `zip` which can be used to iterate through two lists at the same time: ``` list1 = [1, 2, 3] list2 = ["a", "b", "c"] for v1, v2 in zip(list1, list2): print v1 + " " + v2 ``` The above code should produce the following: ``` 1 a 2 b 3 c ``` I wonder if there is a ...
Update: It is built-in in C# 4 as [System.Linq.Enumerable.Zip Method](https://msdn.microsoft.com/en-us/library/vstudio/dd267698(v=vs.110).aspx) Here is a C# 3 version: ``` IEnumerable<TResult> Zip<TResult,T1,T2> (IEnumerable<T1> a, IEnumerable<T2> b, Func<T1,T2,TResult> combine) { using (var f = a.G...
101,180
<p>I need to communicate with an XML-RPC server from a .NET 2.0 client. Can you recommend any libraries?</p> <p>EDIT: Having tried XML-RPC.Net, I like the way it generates dynamic proxies, it is very neat. Unfortunately, as always, things are not so simple. I am accessing an XML-RPC service which uses the unorthodox t...
[ { "answer_id": 101204, "author": "Matthias Kestenholz", "author_id": 317346, "author_profile": "https://Stackoverflow.com/users/317346", "pm_score": 2, "selected": false, "text": "<p>I've used the library from <a href=\"http://www.xml-rpc.net/\" rel=\"nofollow noreferrer\">www.xml-rpc.ne...
2008/09/19
[ "https://Stackoverflow.com/questions/101180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16881/" ]
I need to communicate with an XML-RPC server from a .NET 2.0 client. Can you recommend any libraries? EDIT: Having tried XML-RPC.Net, I like the way it generates dynamic proxies, it is very neat. Unfortunately, as always, things are not so simple. I am accessing an XML-RPC service which uses the unorthodox technique o...
If the method name is all that is changing (i.e., the method signature is static) XML-RPC.NET can handle this for you. This is addressed [in the FAQ](http://xml-rpc.net/faq/xmlrpcnetfaq.html#2.23), noting "However, there are some XML-RPC APIs which require the method name to be generated dynamically at runtime..." From...
101,184
<p>I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Oracle, and if possible, what version of Oracle they are running by sending a SQL statement to the datasource.</p>
[ { "answer_id": 101197, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 9, "selected": true, "text": "<p>Run this SQL:</p>\n\n<pre><code>select * from v$version;\n</code></pre>\n\n<p>And you'll get a result like: </p>...
2008/09/19
[ "https://Stackoverflow.com/questions/101184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10750/" ]
I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Oracle, and if possible, what version of Oracle they are running by sending a SQL statement to the datasource.
Run this SQL: ``` select * from v$version; ``` And you'll get a result like: ``` BANNER ---------------------------------------------------------------- Oracle Database 10g Release 10.2.0.3.0 - 64bit Production PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Production TNS for Solaris: Version 10.2....
101,198
<p>I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Postgres, and if possible, what version of Postgres they are running by sending a SQL statement to the datasource.</p>
[ { "answer_id": 101210, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 2, "selected": false, "text": "<pre><code>SELECT version();\n</code></pre>\n" }, { "answer_id": 101214, "author": "Matthias Kestenholz", ...
2008/09/19
[ "https://Stackoverflow.com/questions/101198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10750/" ]
I'm building an installer for an application. The user gets to select a datasource they have configured and nominate what type of database it is. I want to confirm that the database type is indeed Postgres, and if possible, what version of Postgres they are running by sending a SQL statement to the datasource.
Try this: ``` mk=# SELECT version(); version ----------------------------------------------------------------------------------------------- PostgreSQL 8.3.3 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubun...
101,212
<p>Net::HTTP can be rather cumbersome for the standard use case!</p>
[ { "answer_id": 101289, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>This is what I use: <a href=\"http://rubyforge.org/projects/restful-rails/\" rel=\"nofollow noreferrer\">http://rubyforge.o...
2008/09/19
[ "https://Stackoverflow.com/questions/101212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18751/" ]
Net::HTTP can be rather cumbersome for the standard use case!
If you only have to deal with REST, the [rest-client](https://github.com/rest-client/rest-client) library is fantastic. If the APIs you're using aren't completely RESTful - or even if they are - [HTTParty](http://railstips.org/2008/7/29/it-s-an-httparty-and-everyone-is-invited) is really worth checking out. It simplif...
101,244
<pre><code>/etc/init.d/* /etc/rc{1-5}.d/* </code></pre>
[ { "answer_id": 101246, "author": "px.", "author_id": 18769, "author_profile": "https://Stackoverflow.com/users/18769", "pm_score": 2, "selected": false, "text": "<p><code>/sbin/chkconfig</code> — The <code>/sbin/chkconfig</code> utility is a simple command line tool for maintaining the <...
2008/09/19
[ "https://Stackoverflow.com/questions/101244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18769/" ]
``` /etc/init.d/* /etc/rc{1-5}.d/* ```
in one word: `init`. This process always has pid of 1 and controls (spawns) all other processes in your unix according to the rules in `/etc/init.d`. init is usually called with a number as an argument, e.g. `init 3` This will make it run the contents of the `rc3.d` folder. For more information: [Wikipedia article f...
101,258
<p>I want to search for <code>$maximumTotalAllowedAfterFinish</code> and replace it with <code>$minimumTotalAllowedAfterFinish</code>. Instead of typing the long text:</p> <pre><code>:%s/$maximumTotalAllowedAfterFinish/$minimumTotalAllowedAfterFinish/g </code></pre> <p>Is there a way to COPY these long variable names...
[ { "answer_id": 101281, "author": "Johannes Hoff", "author_id": 3102, "author_profile": "https://Stackoverflow.com/users/3102", "pm_score": 4, "selected": false, "text": "<p>Type <code>q:</code> to get into history editing mode in a new buffer. Then edit the last line of the buffer and pr...
2008/09/19
[ "https://Stackoverflow.com/questions/101258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I want to search for `$maximumTotalAllowedAfterFinish` and replace it with `$minimumTotalAllowedAfterFinish`. Instead of typing the long text: ``` :%s/$maximumTotalAllowedAfterFinish/$minimumTotalAllowedAfterFinish/g ``` Is there a way to COPY these long variable names down into the search line, since, on the comman...
You can insert the contents of a numbered or named register by typing `CTRL``R` ``{0-9a-z"%#:-=.}``. By typing `CTRL-R` `CTRL-W` you can paste the current word under the cursor. See: ``` :he cmdline-editing ``` for more information.
101,265
<p>Inspired by another question asking about the missing <code>Zip</code> function:</p> <p>Why is there no <code>ForEach</code> extension method on the <code>IEnumerable</code> interface? Or anywhere? The only class that gets a <code>ForEach</code> method is <code>List&lt;&gt;</code>. Is there a reason why it's missing...
[ { "answer_id": 101274, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<p>Most of the LINQ extension methods return results. ForEach does not fit into this pattern as it returns nothing.</p>\n" ...
2008/09/19
[ "https://Stackoverflow.com/questions/101265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3820/" ]
Inspired by another question asking about the missing `Zip` function: Why is there no `ForEach` extension method on the `IEnumerable` interface? Or anywhere? The only class that gets a `ForEach` method is `List<>`. Is there a reason why it's missing, maybe performance?
There is already a `foreach` statement included in the language that does the job most of the time. I'd hate to see the following: ``` list.ForEach( item => { item.DoSomething(); } ); ``` Instead of: ``` foreach(Item item in list) { item.DoSomething(); } ``` The latter is clearer and easier to read **in...
101,267
<p>When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differentiate builds of the library. I got this by returning a #define in the code:</p> <p>C++:</p> <pre><code>#ifdef _BuildDateTime_ char* SomeCl...
[ { "answer_id": 101293, "author": "basszero", "author_id": 287, "author_profile": "https://Stackoverflow.com/users/287", "pm_score": 1, "selected": false, "text": "<p>Unless you want to run your Java source through a C/C++ Preprocessor (which is a BIG NO-NO), use the jar method. There are...
2008/09/19
[ "https://Stackoverflow.com/questions/101267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18744/" ]
When I used to write libraries in C/C++ I got into the habit of having a method to return the compile date/time. This was always a compiled into the library so would differentiate builds of the library. I got this by returning a #define in the code: C++: ``` #ifdef _BuildDateTime_ char* SomeClass::getBuildDateTime...
**I would favour the standards based approach.** Put your version information (along with other useful publisher stuff such as build number, subversion revision number, author, company details, etc) in the jar's [Manifest File](http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html). **This is a...
101,268
<p>What are the lesser-known but useful features of the Python programming language?</p> <ul> <li>Try to limit answers to Python core.</li> <li>One feature per answer.</li> <li>Give an example and short description of the feature, not just a link to documentation.</li> <li>Label the feature using a title as the first l...
[ { "answer_id": 101276, "author": "cleg", "author_id": 29503, "author_profile": "https://Stackoverflow.com/users/29503", "pm_score": 7, "selected": false, "text": "<p><strong>Main messages :)</strong></p>\n\n<pre><code>import this\n# btw look at this module's source :)\n</code></pre>\n\n<...
2008/09/19
[ "https://Stackoverflow.com/questions/101268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2679/" ]
What are the lesser-known but useful features of the Python programming language? * Try to limit answers to Python core. * One feature per answer. * Give an example and short description of the feature, not just a link to documentation. * Label the feature using a title as the first line. Quick links to answers: ----...
Chaining comparison operators: ------------------------------ ``` >>> x = 5 >>> 1 < x < 10 True >>> 10 < x < 20 False >>> x < 10 < x*10 < 100 True >>> 10 > x <= 9 True >>> 5 == x > 4 True ``` In case you're thinking it's doing `1 < x`, which comes out as `True`, and then comparing `True < 10`, which is also `True`,...
101,270
<p>I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild.</p> <p>I've created a batch file called build.bat which executes the devenv build like this:</p> <pre><code>devenv MySln.sln /Build Debug </code></pre> <p>In vim I've pointed the :make command to that batch...
[ { "answer_id": 102454, "author": "Jay Bazuzi", "author_id": 5314, "author_profile": "https://Stackoverflow.com/users/5314", "pm_score": 1, "selected": false, "text": "<p>Try running msbuild instead of devenv. This will open up a ton of power in how the build runs.</p>\n\n<p>Open a Visua...
2008/09/19
[ "https://Stackoverflow.com/questions/101270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4407/" ]
I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild. I've created a batch file called build.bat which executes the devenv build like this: ``` devenv MySln.sln /Build Debug ``` In vim I've pointed the :make command to that batch file: ``` :set makeprg=build.ba...
I have a blog post which walks through all the details of getting C# projects building in Vim, including the error format. You can find it here: <http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html> In short you need the following: ``` :set errorformat=\ %#%f(%l\\\,%c):\ %m :set makeprg=msbuild\ /nologo\ ...
101,326
<p>I've set up wildcard mapping on IIS 6, by adding "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll", and ensured "Verify that file exists" is not checked :</p> <ul> <li>on the "websites" directory in IIS</li> <li>on the website</li> </ul> <p>However, after a iisreset, when I go to <a href="http://mys...
[ { "answer_id": 101408, "author": "WebDude", "author_id": 15360, "author_profile": "https://Stackoverflow.com/users/15360", "pm_score": 0, "selected": false, "text": "<p>You can try use custom errors to do this.\nGo into Custom Errors in you Website properties and set the 404 to point to ...
2008/09/19
[ "https://Stackoverflow.com/questions/101326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/971/" ]
I've set up wildcard mapping on IIS 6, by adding "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet\_isapi.dll", and ensured "Verify that file exists" is not checked : * on the "websites" directory in IIS * on the website However, after a iisreset, when I go to <http://myserver/something.gif>, I still get IIS 404 ...
You need to add an HTTP Handler in your web config for gif files: ``` <system.web> <httpHandlers> <add path="*.gif" verb="GET,HEAD" type="System.Web.StaticFileHandler" validate="true"/> </httpHandlers> </system.web> ``` That forces .Net to handle the file, then you'll get the .Net error. Server Er...
101,329
<p>In particular, wouldn't there have to be some kind of function pointer in place anyway? </p>
[ { "answer_id": 101341, "author": "yrp", "author_id": 7228, "author_profile": "https://Stackoverflow.com/users/7228", "pm_score": 0, "selected": false, "text": "<p>There's no need for function pointers as it cant change during the runtime.</p>\n" }, { "answer_id": 101342, "aut...
2008/09/19
[ "https://Stackoverflow.com/questions/101329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
In particular, wouldn't there have to be some kind of function pointer in place anyway?
Non virtual member functions are really just a syntactic sugar as they are almost like an ordinary function but with access checking and an implicit object parameter. ``` struct A { void foo (); void bar () const; }; ``` is basically the same as: ``` struct A { }; void foo (A * this); void bar (A const * thi...
101,338
<p>Is it valid to have a 'choice' of 'group' elements when defining an XML Schema (XSD)</p> <p>i.e. is the following valid</p> <pre><code>&lt;xs:complexType name=&quot;HeaderType&quot;&gt; &lt;xs:sequence&gt; &lt;xs:element name=&quot;reservation-number&quot; type=&quot;ReservationNumberType&quot; minOccurs=&quot...
[ { "answer_id": 101410, "author": "mdb", "author_id": 8562, "author_profile": "https://Stackoverflow.com/users/8562", "pm_score": 1, "selected": false, "text": "<p>Whether this is valid depends on the content of the groups: if they're 'sequence' or 'choice' model groups, it's perfectly le...
2008/09/19
[ "https://Stackoverflow.com/questions/101338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15452/" ]
Is it valid to have a 'choice' of 'group' elements when defining an XML Schema (XSD) i.e. is the following valid ``` <xs:complexType name="HeaderType"> <xs:sequence> <xs:element name="reservation-number" type="ReservationNumberType" minOccurs="1" maxOccurs="1" nillable="false" /> <xs:choice minOccurs="1" ma...
I'm no XML expert, although I use it quite a lot. This isn't the way I'd generally do this sort of structure. I would prefer a separate complex types rather than a choice of two groups (see the very end of this answer). I suspect that the problem is that ReservationGroup and CancellationGroup start with the same eleme...
101,362
<p>How do you generate passwords?</p> <ul> <li>Random Characters?</li> <li>Passphrases?</li> <li>High Ascii?</li> </ul> <p>Something like this?</p> <pre><code>cat /dev/urandom | strings </code></pre>
[ { "answer_id": 101368, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 4, "selected": false, "text": "<p>A short python script to generate passwords, originally from the python cookbook.</p>\n\n<pre><code>#!/usr/bin/env...
2008/09/19
[ "https://Stackoverflow.com/questions/101362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18769/" ]
How do you generate passwords? * Random Characters? * Passphrases? * High Ascii? Something like this? ``` cat /dev/urandom | strings ```
Mac OS X's "Keychain Access" application gives you access to the nice OS X password generator. Hit command-N and click the key icon. You get to choose password style (memorable, numeric, alphanumeric, random, FIPS-181) and choose the length. It also warns you about weak passwords.
101,363
<p>I'm using Castle Windsor for dependency injection in my test project. I'm trying to create an instance one of my 'Repository' classes. "It works fine on my machine", but when I run a nightly build in TFS, my tests are not able to load said classes.</p> <pre><code>private static readonly WindsorContainer _container ...
[ { "answer_id": 101368, "author": "Douglas Leeder", "author_id": 3978, "author_profile": "https://Stackoverflow.com/users/3978", "pm_score": 4, "selected": false, "text": "<p>A short python script to generate passwords, originally from the python cookbook.</p>\n\n<pre><code>#!/usr/bin/env...
2008/09/19
[ "https://Stackoverflow.com/questions/101363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12756/" ]
I'm using Castle Windsor for dependency injection in my test project. I'm trying to create an instance one of my 'Repository' classes. "It works fine on my machine", but when I run a nightly build in TFS, my tests are not able to load said classes. ``` private static readonly WindsorContainer _container = new WindsorC...
Mac OS X's "Keychain Access" application gives you access to the nice OS X password generator. Hit command-N and click the key icon. You get to choose password style (memorable, numeric, alphanumeric, random, FIPS-181) and choose the length. It also warns you about weak passwords.
101,386
<p>Does PHP have a method of having auto-generated class variables? I <em>think</em> I've seen something like this before but I'm not certain.</p> <pre><code>public class TestClass { private $data = array(); public function TestClass() { $this-&gt;data['firstValue'] = "cheese"; } } </code></pre> ...
[ { "answer_id": 101404, "author": "Jan Hančič", "author_id": 185527, "author_profile": "https://Stackoverflow.com/users/185527", "pm_score": 5, "selected": true, "text": "<p>See here: <a href=\"http://www.php.net/manual/en/language.oop5.overloading.php\" rel=\"noreferrer\">http://www.php....
2008/09/19
[ "https://Stackoverflow.com/questions/101386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12870/" ]
Does PHP have a method of having auto-generated class variables? I *think* I've seen something like this before but I'm not certain. ``` public class TestClass { private $data = array(); public function TestClass() { $this->data['firstValue'] = "cheese"; } } ``` The `$this->data` array is always...
See here: <http://www.php.net/manual/en/language.oop5.overloading.php> What you want is the "\_\_get" method. There is an example for what you need on the link.
101,439
<p>What is the most efficient way given to raise an integer to the power of another integer in C?</p> <pre><code>// 2^3 pow(2,3) == 8 // 5^5 pow(5,5) == 3125 </code></pre>
[ { "answer_id": 101473, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 3, "selected": false, "text": "<p>An extremely specialized case is, when you need say 2^(-x to the y), where x, is of course is negative and y is too large...
2008/09/19
[ "https://Stackoverflow.com/questions/101439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8123/" ]
What is the most efficient way given to raise an integer to the power of another integer in C? ``` // 2^3 pow(2,3) == 8 // 5^5 pow(5,5) == 3125 ```
Exponentiation by squaring. ``` int ipow(int base, int exp) { int result = 1; for (;;) { if (exp & 1) result *= base; exp >>= 1; if (!exp) break; base *= base; } return result; } ``` This is the standard method for doing modular exponentiat...
101,449
<p>I'm guessing I need to implement an <code>NVelocityViewEngine</code> and <code>NVelocityView</code> - but before I do I wanted to check to see if anyone has already done this.</p> <p>I can't see anything in the <a href="http://mvccontrib.googlecode.com/svn/trunk/" rel="nofollow noreferrer">trunk</a> for <a href="htt...
[ { "answer_id": 101473, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 3, "selected": false, "text": "<p>An extremely specialized case is, when you need say 2^(-x to the y), where x, is of course is negative and y is too large...
2008/09/19
[ "https://Stackoverflow.com/questions/101449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8542/" ]
I'm guessing I need to implement an `NVelocityViewEngine` and `NVelocityView` - but before I do I wanted to check to see if anyone has already done this. I can't see anything in the [trunk](http://mvccontrib.googlecode.com/svn/trunk/) for [MVCContrib](http://www.codeplex.com/MVCContrib). I've already seen the post be...
Exponentiation by squaring. ``` int ipow(int base, int exp) { int result = 1; for (;;) { if (exp & 1) result *= base; exp >>= 1; if (!exp) break; base *= base; } return result; } ``` This is the standard method for doing modular exponentiat...
101,461
<p>Most languages (Ruby included) allow number literals to be written in at least three bases: decimal, octal and hexadecimal. Numbers in decimal base is the usual thing and are written as (most) people naturally write numbers, 96 is written as <code>96</code>. Numbers prefixed by a zero are usually interpreted as octa...
[ { "answer_id": 101479, "author": "Thelema", "author_id": 12874, "author_profile": "https://Stackoverflow.com/users/12874", "pm_score": 3, "selected": false, "text": "<p>From <a href=\"http://docs.huihoo.com/ruby/ruby-man-1.4/syntax.html#numeric\" rel=\"noreferrer\">this manual</a></p>\n\...
2008/09/19
[ "https://Stackoverflow.com/questions/101461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17801/" ]
Most languages (Ruby included) allow number literals to be written in at least three bases: decimal, octal and hexadecimal. Numbers in decimal base is the usual thing and are written as (most) people naturally write numbers, 96 is written as `96`. Numbers prefixed by a zero are usually interpreted as octal based: 96 wo...
use 0b prefix ``` >> 0b100 => 4 ```
101,463
<p>I know how to change the schema of a table in SQL server 2005:</p> <pre><code>ALTER SCHEMA NewSchama TRANSFER dbo.Table1 </code></pre> <p>But how can i check and/or alter stored procedures that use the old schema name?</p> <p>Sorry: I mean: There are stored procedures that have the old schema name of the table in...
[ { "answer_id": 101509, "author": "Josef", "author_id": 5581, "author_profile": "https://Stackoverflow.com/users/5581", "pm_score": 1, "selected": true, "text": "<p>Get a list of dependent objects by right-clicking on the table before you change the schema and then look at what is depende...
2008/09/19
[ "https://Stackoverflow.com/questions/101463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13262/" ]
I know how to change the schema of a table in SQL server 2005: ``` ALTER SCHEMA NewSchama TRANSFER dbo.Table1 ``` But how can i check and/or alter stored procedures that use the old schema name? Sorry: I mean: There are stored procedures that have the old schema name of the table in the sql of the stored procedure....
Get a list of dependent objects by right-clicking on the table before you change the schema and then look at what is dependent on the table, make a list and then change those. There is, however, always a possibility that you'll miss something because it is possible to break the dependencies SQL server tracks. But the ...
101,470
<p>Does anybody know if there is a feasible way on Windows XP to programmatically create and configure a user account so that after logging in from the console (no terminal services) a specific app is launched and the user is "locked" to that app ?</p> <p>The user should be prevented from doing anything else with the ...
[ { "answer_id": 104220, "author": "kervin", "author_id": 16549, "author_profile": "https://Stackoverflow.com/users/16549", "pm_score": 0, "selected": false, "text": "<p>I guess you're building a windows kiosk?</p>\n\n<p>Here's some background in replacing the windows login shell - <a href...
2008/09/19
[ "https://Stackoverflow.com/questions/101470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18780/" ]
Does anybody know if there is a feasible way on Windows XP to programmatically create and configure a user account so that after logging in from the console (no terminal services) a specific app is launched and the user is "locked" to that app ? The user should be prevented from doing anything else with the system (e....
SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon has two values UserInit points to the application that is executed upon successful logon. The default app there, userinit.exe processes domain logon scripts (if any) and then launches the specified Shell= application. By creating or replacing those entries in HKEY\...
101,487
<p>I have some code which collects points (consed integers) from a loop which looks something like this:</p> <pre><code>(loop for x from 1 to 100 for y from 100 downto 1 collect `(,x . ,y)) </code></pre> <p>My question is, is it correct to use <code>`(,x . ,y)</code> in this situation?</p> <p>E...
[ { "answer_id": 101503, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 1, "selected": false, "text": "<p>Why not just</p>\n\n<pre><code>(cons x y)\n</code></pre>\n\n<p>By the way, I tried to run your code in CLISP and it did...
2008/09/19
[ "https://Stackoverflow.com/questions/101487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7780/" ]
I have some code which collects points (consed integers) from a loop which looks something like this: ``` (loop for x from 1 to 100 for y from 100 downto 1 collect `(,x . ,y)) ``` My question is, is it correct to use ``(,x . ,y)` in this situation? Edit: This sample is not about generating a t...
It would be much 'better' to just do (cons x y). But to **answer the question**, there is nothing wrong with doing that :) (except making it a tad slower).
101,532
<p>When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working.</p> <p>So for supportability re...
[ { "answer_id": 101953, "author": "Richard Szalay", "author_id": 3603, "author_profile": "https://Stackoverflow.com/users/3603", "pm_score": 7, "selected": true, "text": "<p>There is no way to be notified on uncaught exceptions in Flex 3. Adobe are aware of the problem but I don't know if...
2008/09/19
[ "https://Stackoverflow.com/questions/101532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7524/" ]
When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working. So for supportability reasons, I w...
There is no way to be notified on uncaught exceptions in Flex 3. Adobe are aware of the problem but I don't know if they plan on creating a workaround. The only solution as it stands is to put try/catch in logical places and make sure you are listening to the ERROR (or FAULT for webservices) event for anything that di...
101,533
<p>I have created a C# class file by using a XSD-file as an input. One of my properties look like this:</p> <pre><code> private System.DateTime timeField; [System.Xml.Serialization.XmlElementAttribute(DataType="time")] public System.DateTime Time { get { return this.timeField; } set { ...
[ { "answer_id": 101598, "author": "Jeffrey L Whitledge", "author_id": 10174, "author_profile": "https://Stackoverflow.com/users/10174", "pm_score": 5, "selected": true, "text": "<p>You could create a string property that does the translation to/from your timeField field and put the serial...
2008/09/19
[ "https://Stackoverflow.com/questions/101533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2257/" ]
I have created a C# class file by using a XSD-file as an input. One of my properties look like this: ``` private System.DateTime timeField; [System.Xml.Serialization.XmlElementAttribute(DataType="time")] public System.DateTime Time { get { return this.timeField; } set { this.timeFi...
You could create a string property that does the translation to/from your timeField field and put the serialization attribute on that instead the the real DateTime property that the rest of the application uses.
101,569
<p>I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The algorithm should work for Chinese, Japanese, English and German language or be language independent. How can I accomp...
[ { "answer_id": 101605, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": false, "text": "<p>You can use or at last study <a href=\"http://docs.python.org/lib/module-difflib.html\" rel=\"noreferrer\" title=\"diffl...
2008/09/19
[ "https://Stackoverflow.com/questions/101569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17451/" ]
I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The algorithm should work for Chinese, Japanese, English and German language or be language independent. How can I accomplis...
Bayesian filters have exactly this purpose. That's the techno you'll find in most tools that identify spam. Example, to detect a language (from <http://sebsauvage.net/python/snyppets/#bayesian>) : ``` from reverend.thomas import Bayes guesser = Bayes() guesser.train('french','La souris est rentrée dans son trou.') gu...
101,574
<p>I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet.</p> <p>When a user clicks the link, I want the file to open. They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed.</p> <p>I've tried two things:</p> <ol>...
[ { "answer_id": 101586, "author": "diciu", "author_id": 2811, "author_profile": "https://Stackoverflow.com/users/2811", "pm_score": 2, "selected": false, "text": "<p><code>&lt;a href=\"file://server/directory/file.xlsx\" target=\"_blank\"&gt;</code> if I remember correctly.</p>\n" }, ...
2008/09/19
[ "https://Stackoverflow.com/questions/101574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet. When a user clicks the link, I want the file to open. They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed. I've tried two things: 1. The obvious and simple...
Try formatting the link like this (looks hellish, but it works in Firefox 3 under Vista for me) : ``` <a href="file://///SERVER/directory/file.ext">file.ext</a> ```
101,597
<p>Let's say I have the following HTML:</p> <pre><code>&lt;table id="foo"&gt; &lt;th class="sortasc"&gt;Header&lt;/th&gt; &lt;/table&gt; &lt;table id="bar"&gt; &lt;th class="sortasc"&gt;Header&lt;/th&gt; &lt;/table&gt; </code></pre> <p>I know that I can do the following to get all of the <strong>th</strong> elem...
[ { "answer_id": 101611, "author": "Fuzzy76", "author_id": 15932, "author_profile": "https://Stackoverflow.com/users/15932", "pm_score": 4, "selected": true, "text": "<p>table#foo th.sortasc</p>\n" }, { "answer_id": 101616, "author": "pjesi", "author_id": 1296737, "auth...
2008/09/19
[ "https://Stackoverflow.com/questions/101597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305/" ]
Let's say I have the following HTML: ``` <table id="foo"> <th class="sortasc">Header</th> </table> <table id="bar"> <th class="sortasc">Header</th> </table> ``` I know that I can do the following to get all of the **th** elements that have class="sortasc" ``` $$('th.sortasc').each() ``` However that gives me...
table#foo th.sortasc
101,693
<p>I get an error everytime I upload my webapp to the provider. Because of the customErrors mode, all I see is the default "Runtime error" message, instructing me to turn off customErrors to view more about the error.</p> <p>Exasperated, I've set my web.config to look like this:</p> <pre><code>&lt;?xml version="1.0"?...
[ { "answer_id": 101707, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 3, "selected": false, "text": "<p>If you're still getting that page, it's likely that it's blowing up before getting past the Web.Config</p>\n\n<p>Ma...
2008/09/19
[ "https://Stackoverflow.com/questions/101693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3263/" ]
I get an error everytime I upload my webapp to the provider. Because of the customErrors mode, all I see is the default "Runtime error" message, instructing me to turn off customErrors to view more about the error. Exasperated, I've set my web.config to look like this: ``` <?xml version="1.0"?> <configuration> <s...
This has been driving me insane for the past few days and couldn't get around it but have finally figured it out: In my machine.config file I had an entry under `<system.web>`: ``` <deployment retail="true" /> ``` This seems to override any other customError settings that you have specified in a web.config file, so...
101,708
<p>In VB.net I'm using the TcpClient to retrieve a string of data. I'm constantly checking the .Connected property to verify if the client is connected but even if the client disconnects this still returns true. What can I use as a workaround for this?</p> <p>This is a stripped down version of my current code:</p> ...
[ { "answer_id": 101759, "author": "Kevin Fairchild", "author_id": 3743, "author_profile": "https://Stackoverflow.com/users/3743", "pm_score": -1, "selected": false, "text": "<p>Instead of polling client.connected, maybe use of the NetworkStream's properties to see if there's no more data ...
2008/09/19
[ "https://Stackoverflow.com/questions/101708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77830/" ]
In VB.net I'm using the TcpClient to retrieve a string of data. I'm constantly checking the .Connected property to verify if the client is connected but even if the client disconnects this still returns true. What can I use as a workaround for this? This is a stripped down version of my current code: ``` Dim client a...
When NetworkStream.Read returns 0, then the connection has been closed. [Reference](http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.read(VS.71).aspx): > > If no data is available for reading, the NetworkStream.Read method will block until data is available. To avoid blocking, you can use the ...
101,742
<p>I have a Google App Engine app - <a href="http://mylovelyapp.appspot.com/" rel="noreferrer">http://mylovelyapp.appspot.com/</a> It has a page - mylovelypage</p> <p>For the moment, the page just does <code>self.response.out.write('OK')</code></p> <p>If I run the following Python at my computer:</p> <pre><code>impo...
[ { "answer_id": 102158, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>I'm not a python expert or a app engine expert. But did you try following the sample appl at <a href=\"http://code.google....
2008/09/19
[ "https://Stackoverflow.com/questions/101742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/477/" ]
I have a Google App Engine app - <http://mylovelyapp.appspot.com/> It has a page - mylovelypage For the moment, the page just does `self.response.out.write('OK')` If I run the following Python at my computer: ``` import urllib2 f = urllib2.urlopen("http://mylovelyapp.appspot.com/mylovelypage") s = f.read() print s f...
appcfg.py, the tool that uploads data to App Engine has to do exactly this to authenticate itself with the App Engine server. The relevant functionality is abstracted into appengine\_rpc.py. In a nutshell, the solution is: 1. Use the [Google ClientLogin API](http://code.google.com/apis/accounts/docs/AuthForInstalledAp...
101,752
<p>I used <code>git pull</code> and had a merge conflict:</p> <pre><code>unmerged: some_file.txt You are in the middle of a conflicted merge. </code></pre> <p>How do I abandon my changes to the file and keep only the pulled changes?</p>
[ { "answer_id": 101773, "author": "David Precious", "author_id": 4040, "author_profile": "https://Stackoverflow.com/users/4040", "pm_score": 7, "selected": false, "text": "<p>I think it's <code>git reset</code> you need.</p>\n\n<p>Beware that <code>git revert</code> means something very d...
2008/09/19
[ "https://Stackoverflow.com/questions/101752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18666/" ]
I used `git pull` and had a merge conflict: ``` unmerged: some_file.txt You are in the middle of a conflicted merge. ``` How do I abandon my changes to the file and keep only the pulled changes?
Since your `pull` was unsuccessful then `HEAD` (not `HEAD^`) is the last "valid" commit on your branch: ``` git reset --hard HEAD ``` The other piece you want is to let their changes over-ride your changes. Older versions of git allowed you to use the "theirs" merge strategy: ``` git pull --strategy=theirs remote...
101,767
<p>I'm trying to use cygwin as a build environment under Windows. I have some dependencies on 3rd party packages, for example, GTK+. </p> <p>Normally when I build under Linux, in my Makefile I can add a call to pkg-config as an argument to gcc, so it comes out like so:</p> <pre> gcc example.c `pkg-config --libs --cfl...
[ { "answer_id": 102136, "author": "Tobias Kunze", "author_id": 6070, "author_profile": "https://Stackoverflow.com/users/6070", "pm_score": 2, "selected": false, "text": "<p>Are you sure that you're using the make provided by Cygwin? Use</p>\n\n<pre><code>which make\nmake --version\n</code...
2008/09/19
[ "https://Stackoverflow.com/questions/101767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16080/" ]
I'm trying to use cygwin as a build environment under Windows. I have some dependencies on 3rd party packages, for example, GTK+. Normally when I build under Linux, in my Makefile I can add a call to pkg-config as an argument to gcc, so it comes out like so: ``` gcc example.c `pkg-config --libs --cflags gtk+-2.0` ...
> > That said, is there, say, some way I could have the Makefile store the result of pkg-config into a variable, and then use that variable, rather than using the back-tick operator? > > > GTK\_LIBS = $(shell pkg-config --libs gtk+-2.0)
101,777
<p>Let's say I have this code:</p> <pre><code>if (md5($_POST[$foo['bar']]) == $somemd5) { doSomethingWith(md5($_POST[$foo['bar']]); } </code></pre> <p>I could shorten that down by doing:</p> <pre><code>$value = md5($_POST[$foo['bar']]; if ($value == $somemd5) { doSomethingWith($value); } </code></pre> <p>But is...
[ { "answer_id": 101805, "author": "smo", "author_id": 16080, "author_profile": "https://Stackoverflow.com/users/16080", "pm_score": 4, "selected": true, "text": "<p>No, but since the assignment itself is an expression, you can use the assignment as the conditional expression for the if st...
2008/09/19
[ "https://Stackoverflow.com/questions/101777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15214/" ]
Let's say I have this code: ``` if (md5($_POST[$foo['bar']]) == $somemd5) { doSomethingWith(md5($_POST[$foo['bar']]); } ``` I could shorten that down by doing: ``` $value = md5($_POST[$foo['bar']]; if ($value == $somemd5) { doSomethingWith($value); } ``` But is there any pre-set variable that contains the fir...
No, but since the assignment itself is an expression, you can use the assignment as the conditional expression for the if statement. ``` if (($value = md5(..)) == $somemd5) { ... } ``` In general, though, you'll want to avoid embedding assignments into conditional expressions: * The code is denser and therefore ha...
101,783
<p>Anyone happen to have a sample script for recursing a given directory in a filesystem with Powershell? Ultimately what I'm wanting to do is create a script that will generate NSIS file lists for me given a directory. Something very similar to what was done <a href="http://blogs.oracle.com/duffblog/2006/12/dynamic_fi...
[ { "answer_id": 106413, "author": "halr9000", "author_id": 6637, "author_profile": "https://Stackoverflow.com/users/6637", "pm_score": 2, "selected": false, "text": "<p>This is a \"paraphrase\" port of that bash script.</p>\n\n<pre><code>$path = \"c:\\path\\to\\program\"\n$installFiles = ...
2008/09/19
[ "https://Stackoverflow.com/questions/101783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18831/" ]
Anyone happen to have a sample script for recursing a given directory in a filesystem with Powershell? Ultimately what I'm wanting to do is create a script that will generate NSIS file lists for me given a directory. Something very similar to what was done [here](http://blogs.oracle.com/duffblog/2006/12/dynamic_file_li...
As [halr9000](https://stackoverflow.com/questions/101783/recursing-the-file-system-with-powershell#106413) demonstrated, you can use the `-recurse` switch parameter of the `Get-ChildItem` cmdlet to retrieve all files and directories under a specified path. It looks like the bash script you linked to in your question s...
101,806
<p>I am working on an application that installs a system wide keyboard hook. I do not want to install this hook when I am running a debug build from inside the visual studio (or else it would hang the studio and eventually the system), and I can avoid this by checking if the DEBUG symbol is defined.</p> <p>However, wh...
[ { "answer_id": 101812, "author": "TraumaPony", "author_id": 18658, "author_profile": "https://Stackoverflow.com/users/18658", "pm_score": 7, "selected": true, "text": "<p>Try: <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.isattached.aspx\" rel=\"noreferrer...
2008/09/19
[ "https://Stackoverflow.com/questions/101806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17378/" ]
I am working on an application that installs a system wide keyboard hook. I do not want to install this hook when I am running a debug build from inside the visual studio (or else it would hang the studio and eventually the system), and I can avoid this by checking if the DEBUG symbol is defined. However, when I debug...
Try: [`System.Diagnostics.Debugger.IsAttached`](http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.isattached.aspx)
101,818
<p>When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types:</p> <pre><code> -int send_pkt(tpkt_t* pkt, void* opt_data); -void dump(tpkt_t* bp); +int send_pkt(tpkt_t * pkt, void *opt_data); +void dump(tpkt * bp); </code></pre>...
[ { "answer_id": 101835, "author": "Chris M.", "author_id": 6747, "author_profile": "https://Stackoverflow.com/users/6747", "pm_score": 4, "selected": false, "text": "<p><strong>Uncrustify</strong> </p>\n\n<p>Uncrustify has several options on how to indent your files. </p>\n\n<p>From the...
2008/09/19
[ "https://Stackoverflow.com/questions/101818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7685/" ]
When I run indent with various options I want against my source, it does what I want but also messes with the placement of \*s in pointer types: ``` -int send_pkt(tpkt_t* pkt, void* opt_data); -void dump(tpkt_t* bp); +int send_pkt(tpkt_t * pkt, void *opt_data); +void dump(tpkt * bp); ``` I know my placement ...
**Uncrustify** Uncrustify has several options on how to indent your files. From the config file: ``` indent_with_tabs How to use tabs when indenting code 0=spaces only 1=indent with tabs, align with spaces 2=indent and align with tabs ``` You can find it [here](http://unc...
101,825
<p>That is, I'd like to have a tuple of values.</p> <p>The use case on my mind:</p> <pre><code>Dictionary&lt;Pair&lt;string, int&gt;, object&gt; </code></pre> <p>or</p> <pre><code>Dictionary&lt;Triple&lt;string, int, int&gt;, object&gt; </code></pre> <p>Are there built-in types like Pair or Triple? Or what's the b...
[ { "answer_id": 101841, "author": "Grad van Horck", "author_id": 12569, "author_profile": "https://Stackoverflow.com/users/12569", "pm_score": 2, "selected": false, "text": "<p>I usually just create my own struct, containing the values. It's often a bit more readable ;)</p>\n" }, { ...
2008/09/19
[ "https://Stackoverflow.com/questions/101825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2351099/" ]
That is, I'd like to have a tuple of values. The use case on my mind: ``` Dictionary<Pair<string, int>, object> ``` or ``` Dictionary<Triple<string, int, int>, object> ``` Are there built-in types like Pair or Triple? Or what's the best way of implementing it? **Update** There are some general-purpose tuples im...
I have implemented a tuple library in C#. Visit <http://www.adventuresinsoftware.com/generics/> and click on the "tuples" link.
101,850
<p>Take this code:</p> <pre><code>&lt;?php if (isset($_POST['action']) &amp;&amp; !empty($_POST['action'])) { $action = $_POST['action']; } if ($action) { echo $action; } else { echo 'No variable'; } ?&gt; </code></pre> <p>And then access the file with ?action=test Is there any way of preventing $action...
[ { "answer_id": 101879, "author": "owenmarshall", "author_id": 9806, "author_profile": "https://Stackoverflow.com/users/9806", "pm_score": 6, "selected": true, "text": "<p>Check your php.ini for the <code>register_globals</code> setting. It is probably on, you want it off.</p>\n\n<blockqu...
2008/09/19
[ "https://Stackoverflow.com/questions/101850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15214/" ]
Take this code: ``` <?php if (isset($_POST['action']) && !empty($_POST['action'])) { $action = $_POST['action']; } if ($action) { echo $action; } else { echo 'No variable'; } ?> ``` And then access the file with ?action=test Is there any way of preventing $action from automatically being declared by th...
Check your php.ini for the `register_globals` setting. It is probably on, you want it off. > > Why would I want the variable to be declared for me? > > > [You don't.](http://us3.php.net/manual/en/security.globals.php) It's a horrible security risk. It makes the Environment, GET, POST, Cookie and Server variables ...
101,868
<p>Is there any easy to install/use (on unix) database migration tools like Rails Migrations? I really like the idea, but installing ruby/rails purely to manage my database migrations seems overkill.</p>
[ { "answer_id": 102353, "author": "Otto", "author_id": 9594, "author_profile": "https://Stackoverflow.com/users/9594", "pm_score": 1, "selected": false, "text": "<p>I haven't personally done it, but it should be possible to use ActiveRecord::Migration without any of the other Rails stuff....
2008/09/19
[ "https://Stackoverflow.com/questions/101868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3839/" ]
Is there any easy to install/use (on unix) database migration tools like Rails Migrations? I really like the idea, but installing ruby/rails purely to manage my database migrations seems overkill.
Just use ActiveRecord and a simple Rakefile. For example, if you put your migrations in a `db/migrate` directory and have a `database.yml` file that has your db config, this simple Rakefile should work: **Rakefile:** ``` require 'active_record' require 'yaml' desc "Migrate the database through scripts in db/migrate....
101,877
<p>How can I add Page transitions effects like IE in Safari for web pages?</p>
[ { "answer_id": 101961, "author": "Ilya Kochetov", "author_id": 15329, "author_profile": "https://Stackoverflow.com/users/15329", "pm_score": 3, "selected": true, "text": "<p>You could check out this example: <a href=\"http://sachiniscool.blogspot.com/2006/01/implementing-page-transitions...
2008/09/19
[ "https://Stackoverflow.com/questions/101877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
How can I add Page transitions effects like IE in Safari for web pages?
You could check out this example: <http://sachiniscool.blogspot.com/2006/01/implementing-page-transitions-in.html>. It describes how to emulate page transitions in Firefox using AJAX and CSS. The same method works for Safari as well. The code below is taken from that page and slightly formatted: ``` var xmlhttp; var t...
101,880
<ul> <li>I start up my application which uses a Jetty server, using port 9000.</li> <li>I then shut down my application with Ctrl-C</li> <li>I check with "netstat -a" and see that the port 9000 is no longer being used.</li> <li>I restart my application and get:</li> </ul> <blockquote> <pre><code>[ERROR,9/19 15:31:08] ...
[ { "answer_id": 101906, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 1, "selected": false, "text": "<p>You might want call <code>setReuseAddress(true)</code> before calling <code>bind()</code> on your socket object. This i...
2008/09/19
[ "https://Stackoverflow.com/questions/101880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
* I start up my application which uses a Jetty server, using port 9000. * I then shut down my application with Ctrl-C * I check with "netstat -a" and see that the port 9000 is no longer being used. * I restart my application and get: > > > ``` > [ERROR,9/19 15:31:08] java.net.BindException: Only one usage of each so...
During your first invocation of your program, did it accept at least one incoming connection? If so then what you are most likely seeing is the socket linger in effect. For the best explanation dig up a copy of TCP/IP Illustrated by Stevens [![alt text](https://i.stack.imgur.com/DNDVu.gif)](https://i.stack.imgur.co...
101,893
<p>This concept is a new one for me -- I first came across it at the <a href="http://developer.yahoo.com/yui/articles/hosting/#configure" rel="nofollow noreferrer">YUI dependency configurator</a>. Basically, instead of having multiple requests for many files, the files are chained into one http request to cut down on p...
[ { "answer_id": 101941, "author": "David McLaughlin", "author_id": 3404, "author_profile": "https://Stackoverflow.com/users/3404", "pm_score": 4, "selected": true, "text": "<p>There are various ways, the two most obvious would be:</p>\n\n<ol>\n<li>Build a tool like YUI which builds a besp...
2008/09/19
[ "https://Stackoverflow.com/questions/101893", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13243/" ]
This concept is a new one for me -- I first came across it at the [YUI dependency configurator](http://developer.yahoo.com/yui/articles/hosting/#configure). Basically, instead of having multiple requests for many files, the files are chained into one http request to cut down on page load time. Anyone know how to imple...
There are various ways, the two most obvious would be: 1. Build a tool like YUI which builds a bespoke, unique version based on the components you ticked as required so that you can still serve the file as static. MooTools and jQuery UI all provide package-builders like this when you download their package to give you...
101,935
<p>Is there a way (without installing any libraries) of validating XML using a custom DTD in PHP?</p>
[ { "answer_id": 101962, "author": "owenmarshall", "author_id": 9806, "author_profile": "https://Stackoverflow.com/users/9806", "pm_score": 4, "selected": true, "text": "<p>Take a look at <a href=\"http://us3.php.net/dom\" rel=\"noreferrer\">PHP's DOM</a>, especially <a href=\"http://us3.p...
2008/09/19
[ "https://Stackoverflow.com/questions/101935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18856/" ]
Is there a way (without installing any libraries) of validating XML using a custom DTD in PHP?
Take a look at [PHP's DOM](http://us3.php.net/dom), especially [DOMDocument::schemaValidate](http://us3.php.net/manual/en/domdocument.schemavalidate.php) and [DOMDocument::validate](http://us3.php.net/manual/en/domdocument.validate.php). The example for DOMDocument::validate is fairly simple: ``` <?php $dom = new DOM...
101,958
<p>I recently discovered that our company has a set of coding guidelines (hidden away in a document management system where no one can find it). It generally seems pretty sensible, and keeps away from the usual religious wars about where to put '{'s and whether to use hard tabs. However, it does suggest that "lines SHO...
[ { "answer_id": 101970, "author": "Sarien", "author_id": 1994377, "author_profile": "https://Stackoverflow.com/users/1994377", "pm_score": 2, "selected": false, "text": "<p>With a good editor their point is just not true. :)</p>\n\n<p>(See \"visual block\" mode for vim.)</p>\n\n<p>P.S.: O...
2008/09/19
[ "https://Stackoverflow.com/questions/101958", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1105/" ]
I recently discovered that our company has a set of coding guidelines (hidden away in a document management system where no one can find it). It generally seems pretty sensible, and keeps away from the usual religious wars about where to put '{'s and whether to use hard tabs. However, it does suggest that "lines SHOULD...
> > I'm torn. On the one hand, lining up > like this can make repetitive code > much easier to read. On the other > hand, it does make diffs harder to > read. > > > Well, since making code understandable is more important than making diffs understandable, you should not be torn. IMHO lining up similar lines d...
102,019
<p>We've got a product which utilizes multiple SQL Server 2005 databases with triggers. We're looking for a sustainable solution for deploying and upgrading the database schemas on customer servers.</p> <p>Currently, we're using Red Gate's SQL Packager, which appears to be the wrong tool for this particular job. Not o...
[ { "answer_id": 102816, "author": "Martin Marconcini", "author_id": 2684, "author_profile": "https://Stackoverflow.com/users/2684", "pm_score": 1, "selected": false, "text": "<p>I was looking for this product myself, knowing that RedGate solution worked fine for \"one\" DB; unfortunately ...
2008/09/19
[ "https://Stackoverflow.com/questions/102019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18871/" ]
We've got a product which utilizes multiple SQL Server 2005 databases with triggers. We're looking for a sustainable solution for deploying and upgrading the database schemas on customer servers. Currently, we're using Red Gate's SQL Packager, which appears to be the wrong tool for this particular job. Not only does S...
I was looking for this product myself, knowing that RedGate solution worked fine for "one" DB; unfortunately I have been unable to find such tool :( In the end, I had to roll my own solution to do something "similar". It was a *pain in the…* but it worked. My scenario was way simpler than yours, as we didn't have tr...
102,049
<p>For example:</p> <pre><code>me$ FOO="BAR * BAR" me$ echo $FOO BAR file1 file2 file3 file4 BAR </code></pre> <p>and using the <code>\</code> escape character:</p> <pre><code>me$ FOO="BAR \* BAR" me$ echo $FOO BAR \* BAR </code></pre> <p>I'm obviously doing something stupid.</p> <p>How do I get the output <code>B...
[ { "answer_id": 102073, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 3, "selected": false, "text": "<pre><code>FOO='BAR * BAR'\necho \"$FOO\"\n</code></pre>\n" }, { "answer_id": 102074, "author": "Rafał Dowgird", ...
2008/09/19
[ "https://Stackoverflow.com/questions/102049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2108/" ]
For example: ``` me$ FOO="BAR * BAR" me$ echo $FOO BAR file1 file2 file3 file4 BAR ``` and using the `\` escape character: ``` me$ FOO="BAR \* BAR" me$ echo $FOO BAR \* BAR ``` I'm obviously doing something stupid. How do I get the output `BAR * BAR`?
Quoting when setting `$FOO` is not enough. You need to quote the variable reference as well: ``` me$ FOO="BAR * BAR" me$ echo "$FOO" BAR * BAR ```
102,055
<p>I am trying to make a div, that when you click it turns into an input box, and focuses it. I am using prototype to achieve this. This works in both Chrome and Firefox, but not in IE. IE refuses to focus the newly added input field, even if I set a 1 second timeout.</p> <p>Basically the code works like this:</p> <p...
[ { "answer_id": 102097, "author": "x0n", "author_id": 6920, "author_profile": "https://Stackoverflow.com/users/6920", "pm_score": 0, "selected": false, "text": "<p>What version IE? What's your DocType set to? is it strict, standards or quirks mode? Any javascript errors appearing (check t...
2008/09/19
[ "https://Stackoverflow.com/questions/102055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3355/" ]
I am trying to make a div, that when you click it turns into an input box, and focuses it. I am using prototype to achieve this. This works in both Chrome and Firefox, but not in IE. IE refuses to focus the newly added input field, even if I set a 1 second timeout. Basically the code works like this: ``` var viewElem...
My guess is that IE hasn't updated the DOM yet when you make the call to focus(). Sometimes browsers will wait until a script has finished executing before updating the DOM. I would try doing the update, then doing ``` setTimeout("setFocus", 0); function setFocus() { editElement.focus(); } ``` Your other opti...
102,057
<p>I've got a Fitnesse RowFixture that returns a list of business objects. The object has a field which is a float representing a percentage between 0 and 1. The <em>consumer</em> of the business object will be a web page or report that comes from a designer, so the formatting of the percentage will be up to the desi...
[ { "answer_id": 105012, "author": "Tom Carr", "author_id": 14954, "author_profile": "https://Stackoverflow.com/users/14954", "pm_score": 0, "selected": false, "text": "<p>I'm not sure what the \"polution\" is. Either the requirement is that your Business Object returns a value expressed ...
2008/09/19
[ "https://Stackoverflow.com/questions/102057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6902/" ]
I've got a Fitnesse RowFixture that returns a list of business objects. The object has a field which is a float representing a percentage between 0 and 1. The *consumer* of the business object will be a web page or report that comes from a designer, so the formatting of the percentage will be up to the designer rather ...
You certainly don't want to modify your Business Logic just to make your tests look better. Good news however, there is a way to accomplish this that is not difficult, but not as easy as passing in a format specifier. Try to think of your Fit Fixture as a service boundary between FitNesse and your application code. Yo...
102,058
<p>The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug attribute for nearly every major component. The debug attribute is more or less verbose depending upon the number you give it, zero being least and 99 being most verbose. How does the debug level affect Tomcat's speed w...
[ { "answer_id": 105012, "author": "Tom Carr", "author_id": 14954, "author_profile": "https://Stackoverflow.com/users/14954", "pm_score": 0, "selected": false, "text": "<p>I'm not sure what the \"polution\" is. Either the requirement is that your Business Object returns a value expressed ...
2008/09/19
[ "https://Stackoverflow.com/questions/102058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug attribute for nearly every major component. The debug attribute is more or less verbose depending upon the number you give it, zero being least and 99 being most verbose. How does the debug level affect Tomcat's speed when s...
You certainly don't want to modify your Business Logic just to make your tests look better. Good news however, there is a way to accomplish this that is not difficult, but not as easy as passing in a format specifier. Try to think of your Fit Fixture as a service boundary between FitNesse and your application code. Yo...
102,059
<p>With previous versions of flash, entering the full screen mode increased the height and width of the stage to the dimensions of the screen. Now that hardware scaling has arrived, the height and width are set to the dimensions of the video (plus borders if the aspect ratio is different).</p> <p>That's fine, unless ...
[ { "answer_id": 106667, "author": "Brent", "author_id": 10680, "author_profile": "https://Stackoverflow.com/users/10680", "pm_score": -1, "selected": false, "text": "<pre><code>stage.align = StageAlign.TOP_LEFT; \nstage.scaleMode = StageScaleMode.NO_SCALE;\nstage.addEventListener(Even...
2008/09/19
[ "https://Stackoverflow.com/questions/102059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15371/" ]
With previous versions of flash, entering the full screen mode increased the height and width of the stage to the dimensions of the screen. Now that hardware scaling has arrived, the height and width are set to the dimensions of the video (plus borders if the aspect ratio is different). That's fine, unless you have co...
I've eventually found the answer to this. The problem is that the FLVPlayback component is now using the stage.fullScreenSourceRect property to enter a hardware-scaled full screen mode. When it does that, it stretches the rendered area given by stage.fullScreenSourceRect to fill the screen, rather than increasing the s...
102,072
<p>A friend of mine was explaining how they do ping-pong pairing with TDD at his workplace and he said that they take an "adversarial" approach. That is, when the test writing person hands the keyboard over to the implementer, the implementer tries to do the bare simplest (and sometimes wrong thing) to make the test pa...
[ { "answer_id": 102236, "author": "Heath Borders", "author_id": 9636, "author_profile": "https://Stackoverflow.com/users/9636", "pm_score": 1, "selected": false, "text": "<p>I've used this approach. It doesn't work with all pairs; some people are just naturally resistant and won't give i...
2008/09/19
[ "https://Stackoverflow.com/questions/102072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10862/" ]
A friend of mine was explaining how they do ping-pong pairing with TDD at his workplace and he said that they take an "adversarial" approach. That is, when the test writing person hands the keyboard over to the implementer, the implementer tries to do the bare simplest (and sometimes wrong thing) to make the test pass....
It is based on the team's personality. Every team has a personality that is the sum of its members. You have to be careful not to practice passive-aggressive implementations done with an air of superiority. Some developers are frustrated by implementations like > > `return "Sally";` > > > This frustration will l...
102,083
<p>Preferably free tools if possible.</p> <p>Also, the option of searching for multiple regular expressions and each replacing with different strings would be a bonus.</p>
[ { "answer_id": 102110, "author": "Oli", "author_id": 12870, "author_profile": "https://Stackoverflow.com/users/12870", "pm_score": 2, "selected": false, "text": "<p>Under Windows, I used to like <a href=\"http://www.wingrep.com\" rel=\"nofollow noreferrer\">WinGrep</a></p>\n\n<p>Under Ub...
2008/09/19
[ "https://Stackoverflow.com/questions/102083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13967/" ]
Preferably free tools if possible. Also, the option of searching for multiple regular expressions and each replacing with different strings would be a bonus.
Perl. Seriously, it makes sysadmin stuff so much easier. Here's an example: ``` perl -pi -e 's/something/somethingelse/g' *.log ```
102,084
<p>I have learned quite a bit browsing through <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden Features of C#</a> and was surprised when I couldn't find something similar for VB.NET.</p> <p>So what are some of its hidden or lesser known features?</p>
[ { "answer_id": 102111, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": false, "text": "<ul>\n<li>AndAlso/OrElse logical operators</li>\n</ul>\n\n<p>(EDIT: Learn more here: <a href=\"https://stackoverflow.c...
2008/09/19
[ "https://Stackoverflow.com/questions/102084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12842/" ]
I have learned quite a bit browsing through [Hidden Features of C#](https://stackoverflow.com/questions/9033/hidden-features-of-c) and was surprised when I couldn't find something similar for VB.NET. So what are some of its hidden or lesser known features?
The `Exception When` clause is largely unknown. Consider this: ``` Public Sub Login(host as string, user as String, password as string, _ Optional bRetry as Boolean = False) Try ssh.Connect(host, user, password) Catch ex as TimeoutException When Not bRetry ''//Try again, but only onc...
102,093
<p>I wrote a small <code>PHP</code> application several months ago that uses the <code>WordPress XMLRPC library</code> to synchronize two separate WordPress blogs. I have a general "RPCRequest" function that packages the request, sends it, and returns the server response, and I have several more specific functions tha...
[ { "answer_id": 104047, "author": "Novaktually", "author_id": 13243, "author_profile": "https://Stackoverflow.com/users/13243", "pm_score": 0, "selected": false, "text": "<p>Expat is the XML parser in PHP. Error code 5 is one of many expat error constants, in this case: <code>XML_ERROR_UN...
2008/09/19
[ "https://Stackoverflow.com/questions/102093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13604/" ]
I wrote a small `PHP` application several months ago that uses the `WordPress XMLRPC library` to synchronize two separate WordPress blogs. I have a general "RPCRequest" function that packages the request, sends it, and returns the server response, and I have several more specific functions that customize the type of re...
@Novak: Thanks for your suggestion. The problem turned out to be a memory issue; by retrieving all the posts from the remote location, the response exceeded the amount of memory PHP was allowed to utilize, hence the unclosed token error. The problem with the cryptic and incomplete error message was due to an outdated ...
102,171
<p>I'm looking for a method that computes the line number of a given text position in a JTextPane with wrapping enabled.</p> <p>Example:</p> <blockquote> <p>This a very very very very very very very very very very very very very very very very very very very very very very long line.<br> This is another very very...
[ { "answer_id": 102737, "author": "Richard", "author_id": 16475, "author_profile": "https://Stackoverflow.com/users/16475", "pm_score": 4, "selected": true, "text": "<p>Try this</p>\n\n<pre><code> /**\n * Return an int containing the wrapped line index at the given position\n * @param...
2008/09/19
[ "https://Stackoverflow.com/questions/102171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8330/" ]
I'm looking for a method that computes the line number of a given text position in a JTextPane with wrapping enabled. Example: > > This a very very very very very very very very very very very very very very very very very very very very very very long line. > > This is another very very very very very very very...
Try this ``` /** * Return an int containing the wrapped line index at the given position * @param component JTextPane * @param int pos * @return int */ public int getLineNumber(JTextPane component, int pos) { int posLine; int y = 0; try { Rectangle caretCoords = component.mo...
102,185
<p>MXML lets you do some really quite powerful data binding such as:</p> <pre><code>&lt;mx:Button id="myBtn" label="Buy an {itemName}" visible="{itemName!=null}"/&gt; </code></pre> <p>I've found that the BindingUtils class can bind values to simple properties, but neither of the bindings above do this. Is it possible...
[ { "answer_id": 102851, "author": "Marc Hughes", "author_id": 6791, "author_profile": "https://Stackoverflow.com/users/6791", "pm_score": 0, "selected": false, "text": "<p>I believe flex generates a small anonymous function to deal with this.</p>\n\n<p>You could do similar using a ChangeW...
2008/09/19
[ "https://Stackoverflow.com/questions/102185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13220/" ]
MXML lets you do some really quite powerful data binding such as: ``` <mx:Button id="myBtn" label="Buy an {itemName}" visible="{itemName!=null}"/> ``` I've found that the BindingUtils class can bind values to simple properties, but neither of the bindings above do this. Is it possible to do the same in AS3 code, or ...
The way to do it is to use `bindSetter`. That is also how it is done behind the scenes when the MXML in your example is transformed to ActionScript before being compiled. ``` // assuming the itemName property is defined on this: BindingUtils.bindSetter(itemNameChanged, this, ["itemName"]); // ... private function it...
102,198
<p>Is there a way to "align" columns in a data repeater control? </p> <p>I.E currently it looks like this:</p> <pre><code>user1 - colA colB colC colD colE user2 - colD colE </code></pre> <p>I want it to look like:</p> <pre><code> user1 -colA -colB -colC -colD -colE user1 -colD -colE </...
[ { "answer_id": 102233, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 2, "selected": false, "text": "<p>If you have access to how many columns are mising in the repeat, then just the following as the table tag. I you d...
2008/09/19
[ "https://Stackoverflow.com/questions/102198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to "align" columns in a data repeater control? I.E currently it looks like this: ``` user1 - colA colB colC colD colE user2 - colD colE ``` I want it to look like: ``` user1 -colA -colB -colC -colD -colE user1 -colD -colE ``` I need to columns for each record to align ...
If you have access to how many columns are mising in the repeat, then just the following as the table tag. I you don't have access to this, can you post the source for your data repeater and what DataSource you're going against? ``` <td colspan='<%# MissingCount(Contatiner.DataItem) %>'> ```
102,213
<p>I am getting ready to start a new asp.net web project, and I am going to LINQ-to-SQL. I have done a little bit of work getting my data layer setup using some info I found by <a href="http://mikehadlow.blogspot.com/" rel="nofollow noreferrer" title="Mike Hadlow">Mike Hadlow</a> that uses an Interface and generics to ...
[ { "answer_id": 103668, "author": "Squirrel", "author_id": 11835, "author_profile": "https://Stackoverflow.com/users/11835", "pm_score": 2, "selected": true, "text": "<p>I'd be tempted to suggest that whether you use concrete types or not shouldn't matter, as if your using dependency inje...
2008/09/19
[ "https://Stackoverflow.com/questions/102213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203/" ]
I am getting ready to start a new asp.net web project, and I am going to LINQ-to-SQL. I have done a little bit of work getting my data layer setup using some info I found by [Mike Hadlow](http://mikehadlow.blogspot.com/ "Mike Hadlow") that uses an Interface and generics to create a Repository for each table in the data...
I'd be tempted to suggest that whether you use concrete types or not shouldn't matter, as if your using dependency injection (castle?) to create the repositories (so you can wrap them with different caches etc) then your codebase will be none the wiser whichever way you've done it. Then just ask your DI for a reposito...
102,215
<p>What is the best way to add "Expires" in http header for static content? eg. images, css, js</p> <p>The web server is IIS 6.0; the language is classical ASP</p>
[ { "answer_id": 102302, "author": "Aaron", "author_id": 7659, "author_profile": "https://Stackoverflow.com/users/7659", "pm_score": -1, "selected": false, "text": "<p>I don't know if this is what you are looking for, but it does keep my pages from being cached.</p>\n\n<pre><code>&lt;META ...
2008/09/19
[ "https://Stackoverflow.com/questions/102215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100/" ]
What is the best way to add "Expires" in http header for static content? eg. images, css, js The web server is IIS 6.0; the language is classical ASP
You could try something like this: ``` @ECHO OFF REM --------------------------------------------------------------------------- REM Caching - sets the caching on static files in a web site REM syntax REM Caching.CMD 1 d:\sites\MySite\WWWRoot\*.CSS REM REM %1 is the WebSite ID REM %2 is the path & Wildcard ...
102,261
<p>First off, I'm working on an app that's written such that some of your typical debugging tools can't be used (or at least I can't figure out how :). </p> <p>JavaScript, html, etc are all "cooked" and encoded (I think; I'm a little fuzzy on how the process works) before being deployed, so I can't attach VS 2005 to i...
[ { "answer_id": 102295, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 2, "selected": false, "text": "<p>Have you tried changing this line</p>\n\n<pre><code>tblRows[i].style.display = (rowVisible) ? \"none\" : \"\";\n<...
2008/09/19
[ "https://Stackoverflow.com/questions/102261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18860/" ]
First off, I'm working on an app that's written such that some of your typical debugging tools can't be used (or at least I can't figure out how :). JavaScript, html, etc are all "cooked" and encoded (I think; I'm a little fuzzy on how the process works) before being deployed, so I can't attach VS 2005 to ie, and fir...
setAttribute is unreliable in IE. It treats attribute access and object property access as the same thing, so because the DOM property for the 'class' attribute is called 'className', you would have to use that instead on IE. This bug is fixed in the new IE8 beta, but it is easier simply to use the DOM Level 1 HTML pr...
102,271
<p>More information from <a href="http://en.wikipedia.org/wiki/Perl_6#Junctions" rel="noreferrer">the Perl 6 Wikipedia entry</a></p> <p><strong>Junctions</strong></p> <p>Perl 6 introduces the concept of junctions: values that are composites of other values.[24] In the earliest days of Perl 6's design, these were call...
[ { "answer_id": 117746, "author": "Brad Gilbert", "author_id": 1337, "author_profile": "https://Stackoverflow.com/users/1337", "pm_score": 5, "selected": true, "text": "<p>How many days are in a given month?</p>\n\n<pre><code>given( $month ){\n when any(qw'1 3 5 7 8 10 12') {\n $day =...
2008/09/19
[ "https://Stackoverflow.com/questions/102271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18446/" ]
More information from [the Perl 6 Wikipedia entry](http://en.wikipedia.org/wiki/Perl_6#Junctions) **Junctions** Perl 6 introduces the concept of junctions: values that are composites of other values.[24] In the earliest days of Perl 6's design, these were called "superpositions", by analogy to the concept in quantum ...
How many days are in a given month? ``` given( $month ){ when any(qw'1 3 5 7 8 10 12') { $day = 31 } when any(qw'4 6 9 11') { $day = 30 } when 2 { $day = 29 } } ```
102,278
<p>OK, so practically every database based application has to deal with "non-active" records. Either, soft-deletions or marking something as "to be ignored". I'm curious as to whether there are any radical alternatives thoughts on an `active' column (or a status column).</p> <p>For example, if I had a list of people</...
[ { "answer_id": 102297, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 0, "selected": false, "text": "<p>We use active flags quite often. If your database is going to be very large, I could see the value in migrating ina...
2008/09/19
[ "https://Stackoverflow.com/questions/102278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1087/" ]
OK, so practically every database based application has to deal with "non-active" records. Either, soft-deletions or marking something as "to be ignored". I'm curious as to whether there are any radical alternatives thoughts on an `active' column (or a status column). For example, if I had a list of people ``` CREATE...
You partition the table on the active flag, so that active records are in one partition, and inactive records are in the other partition. Then you create an active view for each table which automatically has the active filter on it. The database query engine automatically restricts the query to the partition that has t...
102,317
<p>I have two tables Organisation and Employee having one to many relation i.e one organisation can have multiple employees. Now I want to select all information of a particular organisation plus first name of all employees for this organisation. What’s the best way to do it? Can I get all of this in single record set ...
[ { "answer_id": 102361, "author": "Mike McAllister", "author_id": 16247, "author_profile": "https://Stackoverflow.com/users/16247", "pm_score": 0, "selected": false, "text": "<p>If you use Oracle you can create a PL/SQL function you can use in your query that accepts an organization_id as...
2008/09/19
[ "https://Stackoverflow.com/questions/102317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have two tables Organisation and Employee having one to many relation i.e one organisation can have multiple employees. Now I want to select all information of a particular organisation plus first name of all employees for this organisation. What’s the best way to do it? Can I get all of this in single record set or ...
The original question was database specific, but perhaps this is a good place to include a more generic answer. It's a common question. The concept that you are describing is often referred to as 'Group Concatenation'. There's no standard solution in SQL-92 or SQL-99. So you'll need a vendor-specific solution. * **MyS...
102,343
<p>I have a need to open a popup detail window from a gridview (VS 2005 / 2008). What I am trying to do is in the markup for my TemplateColumn have an asp:Button control, sort of like this:</p> <pre><code>&lt;asp:Button ID="btnShowDetails" runat="server" CausesValidation="false" CommandName="Details" Text="Order D...
[ { "answer_id": 102373, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 5, "selected": true, "text": "<p>I believe the way to do it is</p>\n\n<blockquote>\n<pre><code>onClientClick=&lt;%# string.Format(\"window.open('PubsOrd...
2008/09/19
[ "https://Stackoverflow.com/questions/102343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12253/" ]
I have a need to open a popup detail window from a gridview (VS 2005 / 2008). What I am trying to do is in the markup for my TemplateColumn have an asp:Button control, sort of like this: ``` <asp:Button ID="btnShowDetails" runat="server" CausesValidation="false" CommandName="Details" Text="Order Details" onClie...
I believe the way to do it is > > > ``` > onClientClick=<%# string.Format("window.open('PubsOrderDetails.aspx?OrderId={0}',scrollbars=yes,resizable=yes, width=350, height=550);", Eval("order_id")) %> > > ``` > >
102,382
<p>I use ssh-agent with password-protected keys on Linux. Every time I log into a certain machine, I do this:</p> <pre><code>eval `ssh-agent` &amp;&amp; ssh-add </code></pre> <p>This works well enough, but every time I log in and do this, I create another ssh-agent. Once in a while, I will do a <code>killall ssh-agen...
[ { "answer_id": 102420, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 2, "selected": false, "text": "<p>How much control do you have over this machine? One answer would be to run ssh-agent as a daemon process. Other opti...
2008/09/19
[ "https://Stackoverflow.com/questions/102382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I use ssh-agent with password-protected keys on Linux. Every time I log into a certain machine, I do this: ``` eval `ssh-agent` && ssh-add ``` This works well enough, but every time I log in and do this, I create another ssh-agent. Once in a while, I will do a `killall ssh-agent` to reap them. Is there a simple way ...
have a look at Keychain. It was written b people in a similar situation to yourself. [Keychain](http://www.gentoo.org/proj/en/keychain/)
102,394
<p>I am trying to sort a dict based on its key and return an iterator to the values from within an overridden iter method in a class. Is there a nicer and more efficient way of doing this than creating a new list, inserting into the list as I sort through the keys?</p>
[ { "answer_id": 102438, "author": "Thomas Wouters", "author_id": 17624, "author_profile": "https://Stackoverflow.com/users/17624", "pm_score": 2, "selected": false, "text": "<p>By far the easiest approach, and almost certainly the fastest, is something along the lines of:</p>\n\n<pre><cod...
2008/09/19
[ "https://Stackoverflow.com/questions/102394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
I am trying to sort a dict based on its key and return an iterator to the values from within an overridden iter method in a class. Is there a nicer and more efficient way of doing this than creating a new list, inserting into the list as I sort through the keys?
How about something like this: ``` def itersorted(d): for key in sorted(d): yield d[key] ```
102,457
<p>Given an existing valid SVG document, what's the best way to create "informational popups", so that when you hover or click on certain elements (let's say ) you popup a box with an arbitrary amount (i.e. not just a single line tooltip) of extra information?</p> <p>This should display correctly at least in Firefox a...
[ { "answer_id": 105636, "author": "Sparr", "author_id": 13675, "author_profile": "https://Stackoverflow.com/users/13675", "pm_score": 6, "selected": true, "text": "<pre><code>&lt;svg&gt;\n &lt;text id=\"thingyouhoverover\" x=\"50\" y=\"35\" font-size=\"14\"&gt;Mouse over me!&lt;/text&gt;...
2008/09/19
[ "https://Stackoverflow.com/questions/102457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2846/" ]
Given an existing valid SVG document, what's the best way to create "informational popups", so that when you hover or click on certain elements (let's say ) you popup a box with an arbitrary amount (i.e. not just a single line tooltip) of extra information? This should display correctly at least in Firefox and be invi...
``` <svg> <text id="thingyouhoverover" x="50" y="35" font-size="14">Mouse over me!</text> <text id="thepopup" x="250" y="100" font-size="30" fill="black" visibility="hidden">Change me <set attributeName="visibility" from="hidden" to="visible" begin="thingyouhoverover.mouseover" end="thingyouhoverover.mouseout"/...
102,468
<p>I'm trying to write a piece of code that will do the following:</p> <p>Take the numbers 0 to 9 and assign one or more letters to this number. For example:</p> <pre><code>0 = N, 1 = L, 2 = T, 3 = D, 4 = R, 5 = V or F, 6 = B or P, 7 = Z, 8 = H or CH or J, 9 = G </code></pre> <p>When I have a code like 0123, it's an ea...
[ { "answer_id": 102510, "author": "David Pierre", "author_id": 18296, "author_profile": "https://Stackoverflow.com/users/18296", "pm_score": 3, "selected": false, "text": "<p>It can be done easily recursively.</p>\n\n<p>The idea is that to handle the whole code of size n, you must handle ...
2008/09/19
[ "https://Stackoverflow.com/questions/102468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18922/" ]
I'm trying to write a piece of code that will do the following: Take the numbers 0 to 9 and assign one or more letters to this number. For example: ``` 0 = N, 1 = L, 2 = T, 3 = D, 4 = R, 5 = V or F, 6 = B or P, 7 = Z, 8 = H or CH or J, 9 = G ``` When I have a code like 0123, it's an easy job to encode it. It will o...
The general structure you want to hold your number -> letter assignments is an array or arrays, similar to: ``` // 0 = N, 1 = L, 2 = T, 3 = D, 4 = R, 5 = V or F, 6 = B or P, 7 = Z, // 8 = H or CH or J, 9 = G $numberMap = new Array ( 0 => new Array("N"), 1 => new Array("L"), 2 => new Array("T"), 3 => n...
102,477
<p>Before, I have found the "Cost" in the execution plan to be a good indicator of relative execution time. Why is this case different? Am I a fool for thinking the execution plan has relevance? What specifically can I try to improve v_test performance?</p> <p>Thank you.</p> <p>Using Oracle 10g I have a simple query ...
[ { "answer_id": 102749, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 1, "selected": false, "text": "<p>One aspect of low-cost -- high execution time is that when you are looking at large data-sets, it is often more efficien...
2008/09/19
[ "https://Stackoverflow.com/questions/102477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736623/" ]
Before, I have found the "Cost" in the execution plan to be a good indicator of relative execution time. Why is this case different? Am I a fool for thinking the execution plan has relevance? What specifically can I try to improve v\_test performance? Thank you. Using Oracle 10g I have a simple query view defined bel...
As [the Oracle documentation says](http://download.oracle.com/docs/cd/A87860_01/doc/server.817/a76965/c20a_opt.htm#16287), the cost is the estimated cost relative to a particular execution plan. When you tweak the query, the particular execution plan that costs are calculated relative to can change. Sometimes dramatica...
102,514
<p>I'm trying to create the IDL for the IConverterSession interface and I'm confused by the definition of the <a href="http://msdn.microsoft.com/en-us/library/bb905204.aspx" rel="nofollow noreferrer">MIMETOMAPI</a> method. It specifies the <code>LPMESSAGE pmsg</code> parameter as [out] yet the comments state its the po...
[ { "answer_id": 103283, "author": "Alejandro Bologna", "author_id": 9263, "author_profile": "https://Stackoverflow.com/users/9263", "pm_score": 3, "selected": true, "text": "<p>I think in this case the documentation is misleading when it marks the parameter as [out]. You have to pass a va...
2008/09/19
[ "https://Stackoverflow.com/questions/102514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17516/" ]
I'm trying to create the IDL for the IConverterSession interface and I'm confused by the definition of the [MIMETOMAPI](http://msdn.microsoft.com/en-us/library/bb905204.aspx) method. It specifies the `LPMESSAGE pmsg` parameter as [out] yet the comments state its the pointer to the MAPI message to be loaded. Its unclea...
I think in this case the documentation is misleading when it marks the parameter as [out]. You have to pass a valid LPMESSAGE to the method, and that's why is not a double pointer. So i would go with [in] on your idl definition.
102,521
<p>I know that <a href="http://wiki.lessthandot.com/index.php/How_to_find_the_first_and_last_days_in_years,_months_etc" rel="nofollow noreferrer">Sql Server has some handy built-in quarterly</a> stuff, but what about the .Net native <a href="http://msdn.microsoft.com/en-us/library/system.datetime_members(VS.80).aspx" r...
[ { "answer_id": 102712, "author": "Ben Dunlap", "author_id": 8722, "author_profile": "https://Stackoverflow.com/users/8722", "pm_score": 2, "selected": false, "text": "<p>How about this:</p>\n\n<pre><code>Dim nextQuarter As DateTime = DateTime.Now.AddMonths(3);\n</code></pre>\n" }, { ...
2008/09/19
[ "https://Stackoverflow.com/questions/102521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1414/" ]
I know that [Sql Server has some handy built-in quarterly](http://wiki.lessthandot.com/index.php/How_to_find_the_first_and_last_days_in_years,_months_etc) stuff, but what about the .Net native [DateTime](http://msdn.microsoft.com/en-us/library/system.datetime_members(VS.80).aspx) object? What is the best way to add, su...
I know you can calculate the quarter of a date by: ``` Dim quarter As Integer = (someDate.Month - 1) \ 3 + 1 ``` If you're using Visual Studio 2008, you could try bolting additional functionality on to the DateTime class by taking a look at [Extension Methods](http://msdn.microsoft.com/en-us/library/bb384936.aspx).
102,531
<p>Within an XSLT document, is it possible to loop over a set of files in the current directory?</p> <p>I have a situation where I have a directory full of xml files that need some analysis done to generate a report. I have my stylesheet operating on a single document fine, but I'd like to extend that without going t...
[ { "answer_id": 102944, "author": "Dave DuPlantis", "author_id": 8174, "author_profile": "https://Stackoverflow.com/users/8174", "pm_score": 0, "selected": false, "text": "<p>I don't think XSL is set up to work that way: it's designed to be used by something else on one or more documents,...
2008/09/19
[ "https://Stackoverflow.com/questions/102531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672/" ]
Within an XSLT document, is it possible to loop over a set of files in the current directory? I have a situation where I have a directory full of xml files that need some analysis done to generate a report. I have my stylesheet operating on a single document fine, but I'd like to extend that without going to another t...
In XSLT 2.0, and with Saxon, you can do this with the `collection()` function: ``` <xsl:for-each select="file:///path/to/directory"> <!-- process the documents --> </xsl:for-each> ``` See [http://www.saxonica.com/documentation/sourcedocs/collections.html](http://www.saxonica.com/documentation/sourcedocs/collection...
102,534
<p>Here is the situation: I have 2 pages.</p> <p>What I want is to have a number of text links(<code>&lt;a href=""&gt;</code>) on page 1 all directing to page 2, but I want each link to send a different value.</p> <p>On page 2 I want to show that value like this: </p> <blockquote> <p>Hello you clicked {value}</p> ...
[ { "answer_id": 102564, "author": "Haabda", "author_id": 16292, "author_profile": "https://Stackoverflow.com/users/16292", "pm_score": 0, "selected": false, "text": "<p>You might be able to accomplish this using HTML Anchors.</p>\n\n<p><a href=\"http://www.w3schools.com/HTML/html_links.as...
2008/09/19
[ "https://Stackoverflow.com/questions/102534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here is the situation: I have 2 pages. What I want is to have a number of text links(`<a href="">`) on page 1 all directing to page 2, but I want each link to send a different value. On page 2 I want to show that value like this: > > Hello you clicked {value} > > > Another point to take into account is that I ...
Can you use any scripting? Something like Javascript. If you can, then pass the values along in the query string (just add a "?ValueName=Value") to the end of your links. Then on the target page retrieve the query string value. The following site shows how to parse it out: [Parsing the Query String](http://adamv.com/de...
102,535
<p>I'm starting to learn Python and I've come across generator functions, those that have a yield statement in them. I want to know what types of problems that these functions are really good at solving.</p>
[ { "answer_id": 102612, "author": "Nickolay", "author_id": 1026, "author_profile": "https://Stackoverflow.com/users/1026", "pm_score": 5, "selected": false, "text": "<p>See the \"Motivation\" section in <a href=\"http://www.python.org/dev/peps/pep-0255/\" rel=\"noreferrer\">PEP 255</a>.</...
2008/09/19
[ "https://Stackoverflow.com/questions/102535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4834/" ]
I'm starting to learn Python and I've come across generator functions, those that have a yield statement in them. I want to know what types of problems that these functions are really good at solving.
Generators give you lazy evaluation. You use them by iterating over them, either explicitly with 'for' or implicitly by passing it to any function or construct that iterates. You can think of generators as returning multiple items, as if they return a list, but instead of returning them all at once they return them one...
102,547
<p>I am trying to add a new hello world service to amfphp, I am developing locally</p> <pre><code>&lt;?php /** * First tutorial class */ class HelloWorld { /** * first simple method * @returns a string saying 'Hello World!' */ function sayHello() { return "Hello World!"; } } ?&gt; ...
[ { "answer_id": 104013, "author": "Antti", "author_id": 6037, "author_profile": "https://Stackoverflow.com/users/6037", "pm_score": 0, "selected": false, "text": "<p>You're trying to access a variable/method that's null. The code here is fine so the problem is somewhere else..</p>\n" },...
2008/09/19
[ "https://Stackoverflow.com/questions/102547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to add a new hello world service to amfphp, I am developing locally ``` <?php /** * First tutorial class */ class HelloWorld { /** * first simple method * @returns a string saying 'Hello World!' */ function sayHello() { return "Hello World!"; } } ?> ``` when exploring...
I recommend [Charles](http://www.charlesproxy.com/) for solving this type of problem, this let's you see what's going across the wire. In your case it's likely something simple as a syntax error in the php file. PHP will output the error information into what the Service Browser expects to be amf-encoded data, wreaking...
102,567
<p>What's the best way to shut down the computer from a C# program?</p> <p>I've found a few methods that work - I'll post them below - but none of them are very elegant. I'm looking for something that's simpler and natively .net.</p>
[ { "answer_id": 102580, "author": "RichS", "author_id": 6247, "author_profile": "https://Stackoverflow.com/users/6247", "pm_score": 3, "selected": false, "text": "<p>You can launch the shutdown process:</p>\n\n<ul>\n<li><code>shutdown -s -t 0</code> - Shutdown</li>\n<li><code>shutdown -...
2008/09/19
[ "https://Stackoverflow.com/questions/102567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3464/" ]
What's the best way to shut down the computer from a C# program? I've found a few methods that work - I'll post them below - but none of them are very elegant. I'm looking for something that's simpler and natively .net.
Taken from: [a Geekpedia post](http://www.geekpedia.com/code36_Shut-down-system-using-Csharp.html) This method uses [WMI](http://en.wikipedia.org/wiki/Windows_Management_Instrumentation) to shutdown windows. You'll need to add a reference to System.Management to your project to use this. ``` using System.Management;...
102,568
<p>I'm trying to understand someone else's Perl code without knowing much Perl myself. I would appreciate your help.</p> <p>I've encountered a Perl function along these lines:</p> <pre><code>MyFunction($arg1,$arg2__size,$arg3) </code></pre> <p>Is there a meaning to the double-underscore syntax in <code>$arg2</code>,...
[ { "answer_id": 102582, "author": "Haabda", "author_id": 16292, "author_profile": "https://Stackoverflow.com/users/16292", "pm_score": 1, "selected": false, "text": "<p>I'm fairly certain arg2__size is just the name of a variable.</p>\n" }, { "answer_id": 102636, "author": "Ma...
2008/09/19
[ "https://Stackoverflow.com/questions/102568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10261/" ]
I'm trying to understand someone else's Perl code without knowing much Perl myself. I would appreciate your help. I've encountered a Perl function along these lines: ``` MyFunction($arg1,$arg2__size,$arg3) ``` Is there a meaning to the double-underscore syntax in `$arg2`, or is it just part of the name of the secon...
There is no specific meaning to the use of a \_\_ inside of a perl variable name. It's likely programmer preference, especially in the case that you've cited in your question. You can see more information about perl variable naming [here](http://perldoc.perl.org/perlvar.html#Technical-Note-on-the-Syntax-of-Variable-Nam...
102,591
<p>In my database (SQL 2005) I have a field which holds a comment but in the comment I have an id and I would like to strip out just the id, and IF possible convert it to an int:</p> <p><code>activation successful of id 1010101</code></p> <p>The line above is the exact structure of the data in the db field.</p> <p>A...
[ { "answer_id": 102687, "author": "Cervo", "author_id": 16219, "author_profile": "https://Stackoverflow.com/users/16219", "pm_score": 0, "selected": false, "text": "<pre><code>-- Test table, you will probably use some query \nDECLARE @testTable TABLE(comment VARCHAR(255)) \nINSERT INTO ...
2008/09/19
[ "https://Stackoverflow.com/questions/102591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1841427/" ]
In my database (SQL 2005) I have a field which holds a comment but in the comment I have an id and I would like to strip out just the id, and IF possible convert it to an int: `activation successful of id 1010101` The line above is the exact structure of the data in the db field. And no I don't want to do this in th...
This should do the trick: ``` SELECT SUBSTRING(column, PATINDEX('%[0-9]%', column), 999) FROM table ``` Based on your sample data, this that there is only one occurence of an integer in the string and that it is at the end.
102,606
<p>Below is part of the XML which I am processing with <a href="http://php.net/XSLTProcessor" rel="nofollow noreferrer">PHP's XSLTProcessor</a>:</p> <pre><code>&lt;result&gt; &lt;uf x="20" y="0"/&gt; &lt;uf x="22" y="22"/&gt; &lt;uf x="4" y="3"/&gt; &lt;uf x="15" y="15"/&gt; &lt;/result&gt; </code></pr...
[ { "answer_id": 102707, "author": "Oliver Mellet", "author_id": 12001, "author_profile": "https://Stackoverflow.com/users/12001", "pm_score": 1, "selected": false, "text": "<pre><code>count('/result/uf[@x = @y]')\n</code></pre>\n" }, { "answer_id": 102708, "author": "Mike Tunn...
2008/09/19
[ "https://Stackoverflow.com/questions/102606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14645/" ]
Below is part of the XML which I am processing with [PHP's XSLTProcessor](http://php.net/XSLTProcessor): ``` <result> <uf x="20" y="0"/> <uf x="22" y="22"/> <uf x="4" y="3"/> <uf x="15" y="15"/> </result> ``` I need to know how many "uf" nodes exist where x == y. In the above example, that would be ...
``` <xsl:value-of select="count(/result/uf[@y=@x])" /> ```
102,614
<p>I am looking for a way to have some control over the shape of a simple MessageBox in Winforms. I would like to control where the passed in text wraps so that the dialog rect is narrower. Windows seems to want to make the dialog as wide as possible before wrapping the text. Is there an easy way to control the maximum...
[ { "answer_id": 102622, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 3, "selected": true, "text": "<p>You can embed newlines in the text to force it to wrap at a certain point. e.g.</p>\n\n<pre><code>\"message text...\\nmo...
2008/09/19
[ "https://Stackoverflow.com/questions/102614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12281/" ]
I am looking for a way to have some control over the shape of a simple MessageBox in Winforms. I would like to control where the passed in text wraps so that the dialog rect is narrower. Windows seems to want to make the dialog as wide as possible before wrapping the text. Is there an easy way to control the maximum wi...
You can embed newlines in the text to force it to wrap at a certain point. e.g. ``` "message text...\nmore text..." ``` update: I posted that thinking it was a win32 API question, but I think the principle should still apply. I assume WinForms eventually calls MessageBox().
102,626
<p>I get this error when I do a <strong>bulk insert</strong> with <code>select * from [table_name]</code>, and another table name:</p> <pre><code>the locale id '0' of the source column 'PAT_NUM_ADT' and the locale id '1033' of the destination column 'PAT_ID_OLD' do not match </code></pre> <p>I tried resetting my db ...
[ { "answer_id": 102675, "author": "hova", "author_id": 2170, "author_profile": "https://Stackoverflow.com/users/2170", "pm_score": 0, "selected": false, "text": "<p>I would check what your default locale settings are. Also, you'll need to check the locale of both tables using sp_help to...
2008/09/19
[ "https://Stackoverflow.com/questions/102626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I get this error when I do a **bulk insert** with `select * from [table_name]`, and another table name: ``` the locale id '0' of the source column 'PAT_NUM_ADT' and the locale id '1033' of the destination column 'PAT_ID_OLD' do not match ``` I tried resetting my db collation but this did not help. Has anyone seen...
If you are copying less than a full set of fields from one table to another, whether that table is on another domain across the world, or is collocated in the same database, you just have to select them in order. SqlBulkCopyColumnMappings do not work. Yes, I tried. I used all four possible constructors, and I used them...