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 |
|---|---|---|---|---|---|---|
11,200 | <p>I'm guessing it needs to be something like:</p>
<pre><code>CONVERT(CHAR(24), lastModified, 101)
</code></pre>
<p>However I'm not sure of the right value for the third parameter.</p>
<p>Thanks!</p>
<hr>
<p>Well I'm trying to write a script to copy my sql server db to a sqlite file, which gets downloaded to an ai... | [
{
"answer_id": 11213,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 0,
"selected": false,
"text": "<p>Define \"last epoch\". Does this come close?</p>\n\n<p>Select Cast(lastModified As Integer)</p>\n"
},
{
"answer_id": 112... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I'm guessing it needs to be something like:
```
CONVERT(CHAR(24), lastModified, 101)
```
However I'm not sure of the right value for the third parameter.
Thanks!
---
Well I'm trying to write a script to copy my sql server db to a sqlite file, which gets downloaded to an air app, which then syncs the data to anoth... | I wound up using format 120 in MS SQL:
```
convert(char(24), lastModified, 120)
```
Each time I needed to a select a date in SQLite for non-display purposes I used:
```
strftime(\"%Y-%m-%d %H:%M:%S\", dateModified) as dateModified
```
Now I just need a readable/friendly way to display the date to the user!
edit... |
11,219 | <p>I'd like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of the developers where I work keep programming in Classic ASP. Ideally, then, for them to benefit from the advantages of a unique set of web APIs, ... | [
{
"answer_id": 11237,
"author": "SitWalkStand",
"author_id": 509,
"author_profile": "https://Stackoverflow.com/users/509",
"pm_score": 3,
"selected": false,
"text": "<p>Here are a few articles describing how to call a web service from a class ASP page:</p>\n\n<ul>\n<li><a href=\"https://... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/160/"
] | I'd like to start moving our application business layers into a collection of REST web services. However, most of our Intranet has been built using Classic ASP and most of the developers where I work keep programming in Classic ASP. Ideally, then, for them to benefit from the advantages of a unique set of web APIs, it ... | You could use a combination of JQuery with JSON calls to consume REST services from the client
or
if you need to interact with the REST services from the ASP layer you can use
MSXML2.ServerXMLHTTP
like:
```
Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP")
HttpReq.open "GET", "Rest_URI", False
HttpReq.send... |
11,267 | <h1>Outline</h1>
<p>OK, I have Google'd this and already expecting a big fat <strong>NO!!</strong> But I thought I should ask since I know sometimes there can be the odd little gem of knowledge lurking around in peoples heads ^_^</p>
<p>I am working my way through some excercises in a book for study, and this particu... | [
{
"answer_id": 11271,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 4,
"selected": true,
"text": "<p>I think to be honest you a better just boning up on your standard design patterns and applying them to the individual prob... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] | Outline
=======
OK, I have Google'd this and already expecting a big fat **NO!!** But I thought I should ask since I know sometimes there can be the odd little gem of knowledge lurking around in peoples heads ^\_^
I am working my way through some excercises in a book for study, and this particular exercise is User Co... | I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.
While there are common UI "themes" (such as dealing with modifier keys) the actual implementation may vary widely.
I have O'Reilly's [Head First Design Pa... |
11,279 | <p>I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the <strong>Publish</strong> properties of the project, I have it set to <em>Automatically increment revision with each publish</em>.</p>
<p>The issue is that it's only incrementing the revision in the Setup files... | [
{
"answer_id": 11284,
"author": "Patrik Svensson",
"author_id": 936,
"author_profile": "https://Stackoverflow.com/users/936",
"pm_score": 0,
"selected": false,
"text": "<p>I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*?\nThis should increase the revision... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | I have a small VB.NET application that I'm working on using the full version of Visual Studio 2005. In the **Publish** properties of the project, I have it set to *Automatically increment revision with each publish*.
The issue is that it's only incrementing the revision in the Setup files. It doesn't seem to be updati... | Change the code for the About box to
```
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString)
```
Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version". |
11,288 | <p>So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so what would be a best practice for solving this problem. </p>
<p>There are two or more object collections of different types. You want to combine them into a single sortable and filterable collection (withing having t... | [
{
"answer_id": 11284,
"author": "Patrik Svensson",
"author_id": 936,
"author_profile": "https://Stackoverflow.com/users/936",
"pm_score": 0,
"selected": false,
"text": "<p>I'm no VB.NET expert, but have you tried to set the value to for example 1.0.0.*?\nThis should increase the revision... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1346/"
] | So WPF doesn't support standard sorting or filtering behavior for views of CompositeCollections, so what would be a best practice for solving this problem.
There are two or more object collections of different types. You want to combine them into a single sortable and filterable collection (withing having to manually... | Change the code for the About box to
```
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Deployment.CurrentVersion.ToString)
```
Please note that all the other answers are correct for "how do I get my assembly version", not the stated question "how do I show my publish version". |
11,291 | <p>I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help? </p>
| [
{
"answer_id": 11312,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 5,
"selected": true,
"text": "<p>Generally, the way you implement it is simply to add the required function to your view's controller, and set its de... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344/"
] | I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help? | Generally, the way you implement it is simply to add the required function to your view's controller, and set its delegate. For example, if you want code to run when the view loads, you just delegate your view to the controller, and implement the awakeFromNib function.
So, to detect a key press in a text view, make su... |
11,305 | <p>I work in VBA, and want to parse a string eg</p>
<pre><code><PointN xsi:type='typens:PointN'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<X>24.365</X>
<Y>78.63</Y>
</PointN>
</code></pre>
<p>and get the X & Y... | [
{
"answer_id": 11325,
"author": "rjzii",
"author_id": 1185,
"author_profile": "https://Stackoverflow.com/users/1185",
"pm_score": 7,
"selected": true,
"text": "<p>This is a bit of a complicated question, but it seems like the most direct route would be to load the XML document or XML str... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/895/"
] | I work in VBA, and want to parse a string eg
```
<PointN xsi:type='typens:PointN'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<X>24.365</X>
<Y>78.63</Y>
</PointN>
```
and get the X & Y values into two separate integer variables.
I'm a newbie when it c... | This is a bit of a complicated question, but it seems like the most direct route would be to load the XML document or XML string via MSXML2.DOMDocument which will then allow you to access the XML nodes.
You can find more on MSXML2.DOMDocument at the following sites:
* [Manipulating XML files with Excel VBA & Xpath](h... |
11,311 | <p>Is it possible to format certain text in a WinForm Label instead of breaking the text into multiple labels? Please disregard the HTML tags within the label's text; it's only used to get my point out.</p>
<p>For example:</p>
<pre><code>Dim myLabel As New Label
myLabel.Text = "This is <b>bold</b> text. ... | [
{
"answer_id": 11320,
"author": "Martin",
"author_id": 770,
"author_profile": "https://Stackoverflow.com/users/770",
"pm_score": 1,
"selected": false,
"text": "<p>I Would also be interested in finding out if it is possible.</p>\n\n<p>When we couldn't find a solution we resorted to Compon... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] | Is it possible to format certain text in a WinForm Label instead of breaking the text into multiple labels? Please disregard the HTML tags within the label's text; it's only used to get my point out.
For example:
```
Dim myLabel As New Label
myLabel.Text = "This is <b>bold</b> text. This is <i>italicized</i> text."
... | That's not possible with a WinForms label as it is. The label has to have exactly one font, with exactly one size and one face. You have a couple of options:
1. Use separate labels
2. Create a new Control-derived class that does its own drawing via GDI+ and use that instead of Label; this is probably your best option,... |
11,318 | <p>Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?</p>
<ul>
<li>Invalidate the Form as soon as you are done drawing?</li>
<li>Setup a se... | [
{
"answer_id": 11329,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 2,
"selected": false,
"text": "<p>What you're doing is the only solution I've ever used in WinForms (a timer with constant redrawings). There are a b... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/322/"
] | Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?
* Invalidate the Form as soon as you are done drawing?
* Setup a second timer and invali... | In some situations, it's faster and more convenient to not draw using the paint event, but getting the Graphics object from the control/form and painting "on" that. This may give some troubles with opacity/anti aliasing/text etc, but could be worth the trouble in terms of not having to repaint the whole shabang. Someth... |
11,330 | <p>Let's say I'm creating a chess program. I have a function</p>
<pre><code>void foreachMove( void (*action)(chess_move*), chess_game* game);
</code></pre>
<p>which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? ... | [
{
"answer_id": 11335,
"author": "Antonio Haley",
"author_id": 390,
"author_profile": "https://Stackoverflow.com/users/390",
"pm_score": 3,
"selected": false,
"text": "<p>You'd probably need to redefine the function pointer to take additional arguments.</p>\n\n<pre><code>void foreachMove(... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | Let's say I'm creating a chess program. I have a function
```
void foreachMove( void (*action)(chess_move*), chess_game* game);
```
which will call the function pointer action on each valid move. This is all well and good, but what if I need to pass more parameters to the action function? For example:
```
chess_mo... | Ah, if only C supported closures...
Antonio is right; if you need to pass extra parameters, you'll need to redefine your function pointer to accept the additional arguments. If you don't know exactly what parameters you'll need, then you have at least three choices:
1. Have the last argument in your prototype be a vo... |
11,345 | <p>What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces? If I have a document where elements have been given a default namespace: </p>
<pre><code><foo xmlns="uri" />
</code></pre>
<p>It appears as though some of the XPath processor libraries won't recognize... | [
{
"answer_id": 11351,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 4,
"selected": false,
"text": "<p>You need local-name():</p>\n<p><a href=\"http://www.w3.org/TR/xpath#function-local-name\" rel=\"nofollow noreferrer\">http://www... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64/"
] | What is the story behind XPath and support for namespaces? Did XPath as a specification precede namespaces? If I have a document where elements have been given a default namespace:
```
<foo xmlns="uri" />
```
It appears as though some of the XPath processor libraries won't recognize `//foo` because of the namespace... | I tried something similar to what palehorse proposed and could not get it to work. Since I was getting data from a published service I couldn't change the xml. I ended up using XmlDocument and XmlNamespaceManager like so:
```
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlWithBogusNamespace);
XmlNames... |
11,405 | <p>The following code doesn't compile with gcc, but does with Visual Studio:</p>
<pre><code>template <typename T> class A {
public:
T foo;
};
template <typename T> class B: public A <T> {
public:
void bar() { cout << foo << endl; }
};
</code></pre>
<p>I get the error:</p>
<blockqu... | [
{
"answer_id": 11414,
"author": "David Joyner",
"author_id": 1146,
"author_profile": "https://Stackoverflow.com/users/1146",
"pm_score": 5,
"selected": true,
"text": "<p>This changed in <a href=\"http://gcc.gnu.org/gcc-3.4/changes.html#cplusplus\" rel=\"noreferrer\">gcc-3.4</a>. The C++... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/112/"
] | The following code doesn't compile with gcc, but does with Visual Studio:
```
template <typename T> class A {
public:
T foo;
};
template <typename T> class B: public A <T> {
public:
void bar() { cout << foo << endl; }
};
```
I get the error:
>
> test.cpp: In member function ‘void B::bar()’:
>
>
> test.c... | This changed in [gcc-3.4](http://gcc.gnu.org/gcc-3.4/changes.html#cplusplus). The C++ parser got much more strict in that release -- per the spec but still kinda annoying for people with legacy or multi-platform code bases. |
11,491 | <p>What is the best way people have found to do String to Lower case / Upper case in C++?</p>
<p>The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method?</p>
| [
{
"answer_id": 11502,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 6,
"selected": true,
"text": "<pre><code>#include <algorithm>\nstd::string data = \"Abc\";\nstd::transform(data.begin(), data.end(), data.begin(), ::t... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366/"
] | What is the best way people have found to do String to Lower case / Upper case in C++?
The issue is complicated by the fact that C++ isn't an English only programming language. Is there a good multilingual method? | ```
#include <algorithm>
std::string data = "Abc";
std::transform(data.begin(), data.end(), data.begin(), ::toupper);
```
<http://notfaq.wordpress.com/2007/08/04/cc-convert-string-to-upperlower-case/>
Also, CodeProject article for common string methods: <http://www.codeproject.com/KB/stl/STL_string_util.aspx> |
11,532 | <p>How can I find any unused functions in a PHP project?</p>
<p>Are there features or APIs built into PHP that will allow me to analyse my codebase - for example <a href="http://ie.php.net/manual/en/language.oop5.reflection.php" rel="noreferrer">Reflection</a>, <a href="http://php.net/manual/en/function.token-get-all.... | [
{
"answer_id": 14625,
"author": "Stacey Richards",
"author_id": 1142,
"author_profile": "https://Stackoverflow.com/users/1142",
"pm_score": 6,
"selected": true,
"text": "<p>Thanks Greg and Dave for the feedback. Wasn't quite what I was looking for, but I decided to put a bit of time into... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1142/"
] | How can I find any unused functions in a PHP project?
Are there features or APIs built into PHP that will allow me to analyse my codebase - for example [Reflection](http://ie.php.net/manual/en/language.oop5.reflection.php), [`token_get_all()`](http://php.net/manual/en/function.token-get-all.php)?
Are these APIs featu... | Thanks Greg and Dave for the feedback. Wasn't quite what I was looking for, but I decided to put a bit of time into researching it and came up with this quick and dirty solution:
```
<?php
$functions = array();
$path = "/path/to/my/php/project";
define_dir($path, $functions);
reference_dir($path, $func... |
11,561 | <p>I've used Apache CXF to expose about ten java classes as web services.</p>
<p>I've generated clients using CXF, Axis, and .NET.</p>
<p>In Axis and CXF a "Service" or "Locator" is generated.
From this service you can get a "Port".
The "Port" is used to make individual calls to the methods exposed by the web servic... | [
{
"answer_id": 11567,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 1,
"selected": false,
"text": "<p>As you already mentioned, those terms mean different things in different stacks - there is no one right generic answer fo... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] | I've used Apache CXF to expose about ten java classes as web services.
I've generated clients using CXF, Axis, and .NET.
In Axis and CXF a "Service" or "Locator" is generated.
From this service you can get a "Port".
The "Port" is used to make individual calls to the methods exposed by the web service.
In .NET the "... | I'd hop over to <http://www.w3.org/TR/wsdl.html> which I think explains Port, Service and Endpoint reasonably well. A locator is an implementation specific mechanism that some WS stacks use to provide access to service endpoints. |
11,562 | <p><code>std::swap()</code> is used by many std containers (such as <code>std::list</code> and <code>std::vector</code>) during sorting and even assignment.</p>
<p>But the std implementation of <code>swap()</code> is very generalized and rather inefficient for custom types.</p>
<p>Thus efficiency can be gained by ove... | [
{
"answer_id": 11599,
"author": "Wilka",
"author_id": 1367,
"author_profile": "https://Stackoverflow.com/users/1367",
"pm_score": 6,
"selected": false,
"text": "<p>You're not allowed (by the C++ standard) to overload std::swap, however you are specifically allowed to add template special... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366/"
] | `std::swap()` is used by many std containers (such as `std::list` and `std::vector`) during sorting and even assignment.
But the std implementation of `swap()` is very generalized and rather inefficient for custom types.
Thus efficiency can be gained by overloading `std::swap()` with a custom type specific implementa... | The right way to overload `std::swap`'s implemention (aka specializing it), is to write it in the same namespace as what you're swapping, so that it can be found via [argument-dependent lookup (ADL)](https://en.cppreference.com/w/cpp/language/adl). One particularly easy thing to do is:
```
class X
{
// ...
fri... |
11,574 | <p>I have an AppleScript program which creates XML tags and elements within an Adobe InDesign document. The data is in tables, and tagging each cell takes .5 seconds. The entire script takes several hours to complete.</p>
<p>I can post the inner loop code, but I'm not sure if SO is supposed to be generic or specific. ... | [
{
"answer_id": 11580,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I can post the inner loop code, but I'm not sure if SO is supposed to be generic or specific. I'll let th... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1019/"
] | I have an AppleScript program which creates XML tags and elements within an Adobe InDesign document. The data is in tables, and tagging each cell takes .5 seconds. The entire script takes several hours to complete.
I can post the inner loop code, but I'm not sure if SO is supposed to be generic or specific. I'll let t... | I figured this one out.
The document contains a bunch of data tables. In all, there are about 7,000 data points that need to be exported. I was creating one root element with 7,000 children.
Don't do that. Adding each child to the root element got slower and slower until at about 5,000 children AppleScript timed out ... |
11,585 | <p>For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine...</p>
<pre><code><%@OutputCache Duration="600" VaryByParam="*" %>
</code></pre>
<p>However, if someone posts a comment, I want to clear the cache so that the page is refreshed... | [
{
"answer_id": 11611,
"author": "John Christensen",
"author_id": 1194,
"author_profile": "https://Stackoverflow.com/users/1194",
"pm_score": 1,
"selected": false,
"text": "<p>Hmm. You can specify a VaryByCustom attribute on the OutputCache item. The value of this is passed as a parameter... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine...
```
<%@OutputCache Duration="600" VaryByParam="*" %>
```
However, if someone posts a comment, I want to clear the cache so that the page is refreshed and the comment can be seen.
H... | I've found the answer I was looking for:
```
HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx");
``` |
11,620 | <p>I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.</p>
<p>How can I kill all the connections to the database so that I can rename it?</p>
| [
{
"answer_id": 11623,
"author": "John Christensen",
"author_id": 1194,
"author_profile": "https://Stackoverflow.com/users/1194",
"pm_score": 2,
"selected": false,
"text": "<p>In MS SQL Server Management Studio on the object explorer, right click on the database. In the context menu that ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] | I want to rename a database, but keep getting the error that 'couldn't get exclusive lock' on the database, which implies there is some connection(s) still active.
How can I kill all the connections to the database so that I can rename it? | The reason that the approach that [Adam suggested](https://stackoverflow.com/questions/11620/how-do-you-kill-all-current-connections-to-a-sql-server-2005-database/11627#11627) won't work is that during the time that you are looping over the active connections new one can be established, and you'll miss those. You could... |
11,635 | <p>What is the best way of doing case-insensitive string comparison in C++ without transforming a string to all uppercase or all lowercase?</p>
<p>Please indicate whether the methods are Unicode-friendly and how portable they are.</p>
| [
{
"answer_id": 11653,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 3,
"selected": false,
"text": "<p>Assuming you are looking for a method and not a magic function that already exists, there is frankly no better way. W... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366/"
] | What is the best way of doing case-insensitive string comparison in C++ without transforming a string to all uppercase or all lowercase?
Please indicate whether the methods are Unicode-friendly and how portable they are. | Boost includes a handy algorithm for this:
```
#include <boost/algorithm/string.hpp>
// Or, for fewer header dependencies:
//#include <boost/algorithm/string/predicate.hpp>
std::string str1 = "hello, world!";
std::string str2 = "HELLO, WORLD!";
if (boost::iequals(str1, str2))
{
// Strings are identical
}
``` |
11,665 | <p>Here is the sample code for my accordion:</p>
<pre><code><mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion">
<mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
<mx:VBox width="100%" height="80%" paddingTop="2" ... | [
{
"answer_id": 12266,
"author": "Theo",
"author_id": 1109,
"author_profile": "https://Stackoverflow.com/users/1109",
"pm_score": 1,
"selected": false,
"text": "<p>You will have to create a custom header renderer, add a button to it and position it manually. Try something like this:</p>\n... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | Here is the sample code for my accordion:
```
<mx:Accordion x="15" y="15" width="230" height="599" styleName="myAccordion">
<mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
<mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1" verticalGa... | Thanks, I got it working using [FlexLib](http://code.google.com/p/flexlib/)'s CanvasButtonAccordionHeader. |
11,689 | <p>I am intentionally leaving this quite vague at first. I'm looking for discussion and what issues are important more than I'm looking for hard answers.</p>
<p>I'm in the middle of designing an app that does something like portfolio management. The design I have so far is</p>
<ul>
<li>Problem: a problem that needs... | [
{
"answer_id": 11694,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 2,
"selected": true,
"text": "<p>Hmm, sounds kind of like this site...</p>\n\n<p>As far as a database design would go, a versioning system kind of like... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I am intentionally leaving this quite vague at first. I'm looking for discussion and what issues are important more than I'm looking for hard answers.
I'm in the middle of designing an app that does something like portfolio management. The design I have so far is
* Problem: a problem that needs to be solved
* Solutio... | Hmm, sounds kind of like this site...
As far as a database design would go, a versioning system kind of like SVN, where you never actually do any updates, just inserts (with a version number) when things change, might be what you need. This is called MVCC, Multi-Value Concurrency Control. A wiki is another good exampl... |
11,699 | <p>I'm getting notifications to back up my encryption key for EFS in Vista, however i haven't enabled bit locker or drive encryption.</p>
<p>Anyone know how to find out what files may be encrypted or have an explanation for why it would notify me?</p>
| [
{
"answer_id": 11709,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>Clippy noticed that you have sensitive information in your files and automatically encrypted them.</p>\n\n<p>Are you sure ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/580/"
] | I'm getting notifications to back up my encryption key for EFS in Vista, however i haven't enabled bit locker or drive encryption.
Anyone know how to find out what files may be encrypted or have an explanation for why it would notify me? | To find out which files on your system have been encrypted with EFS, you can simply run this command:
```
CIPHER.EXE /U /N
``` |
11,720 | <p>What I would like to do is create a clean virtual machine image as the output of a build of an application.</p>
<p>So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output cop... | [
{
"answer_id": 11709,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "<p>Clippy noticed that you have sensitive information in your files and automatically encrypted them.</p>\n\n<p>Are you sure ... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] | What I would like to do is create a clean virtual machine image as the output of a build of an application.
So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a l... | To find out which files on your system have been encrypted with EFS, you can simply run this command:
```
CIPHER.EXE /U /N
``` |
11,761 | <p>I have a web service that queries data from this json file, but I don't want the web service to have to access the file every time. I'm thinking that maybe I can store the data somewhere else (maybe in memory) so the web service can just get the data from there the next time it's trying to query the same data. I kin... | [
{
"answer_id": 11779,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>ASP.NET caching works just as well with Web services so you can implement regular caching as explained here: <a href=\"http:... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1381/"
] | I have a web service that queries data from this json file, but I don't want the web service to have to access the file every time. I'm thinking that maybe I can store the data somewhere else (maybe in memory) so the web service can just get the data from there the next time it's trying to query the same data. I kinda ... | Extending on [Ice^^Heat](https://stackoverflow.com/questions/11761/persisting-data-in-net-web-service-memory#11779)'s idea, you might want to think about where you would cache - either cache the contents of the json file in the Application cache like so:
```
Context.Cache.Insert("foo", _
Foo, _
... |
11,762 | <p>I needed some simple string encryption, so I wrote the following code (with a great deal of "inspiration" from <a href="http://www.codeproject.com/KB/security/DotNetCrypto.aspx" rel="noreferrer">here</a>):</p>
<pre><code> // create and initialize a crypto algorithm
private static SymmetricAlgorithm getAlgori... | [
{
"answer_id": 11776,
"author": "David Wengier",
"author_id": 489,
"author_profile": "https://Stackoverflow.com/users/489",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, this is to be expected, or at least, its exactly what happens when our crypto routines get non-decryptable data</... | 2008/08/14 | [
"https://Stackoverflow.com/questions/11762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | I needed some simple string encryption, so I wrote the following code (with a great deal of "inspiration" from [here](http://www.codeproject.com/KB/security/DotNetCrypto.aspx)):
```
// create and initialize a crypto algorithm
private static SymmetricAlgorithm getAlgorithm(string password) {
SymmetricAl... | Although this have been already answered I think it would be a good idea to explain **why** it is to be expected.
A padding scheme is usually applied because most cryptographic filters are not semantically secure and to prevent some forms of cryptoatacks. For example, usually in RSA the [OAEP](http://en.wikipedia.org/... |
11,806 | <p>I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem ... | [
{
"answer_id": 11811,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 2,
"selected": false,
"text": "<p>In your ASP.NET app, you will need to impersonate a valid AD account with the correct permissions:</p>\n\n<p><a href=\"http://su... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/889/"
] | I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem tha... | Exchange 2007 doesn't allow you to impersonate a user for security reasons. This means that it is impossible (at the moment) to create mailboxes by impersonating a user. In order to get around this problem, I created a web service which runs under AD user which has permissions to create email acounts, etc. You can then... |
11,809 | <p>The only thing I've found has been;</p>
<pre class="lang-css prettyprint-override"><code>.hang {
text-indent: -3em;
margin-left: 3em;
}
</code></pre>
<p>The only way for this to work is putting text in a paragraph, which causes those horribly unsightly extra lines. I'd much rather just have them in a <cod... | [
{
"answer_id": 11815,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 5,
"selected": true,
"text": "<p><code><span></code> is an inline element. The term <em>hanging indent</em> is meaningless unless you're talking about a p... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/362/"
] | The only thing I've found has been;
```css
.hang {
text-indent: -3em;
margin-left: 3em;
}
```
The only way for this to work is putting text in a paragraph, which causes those horribly unsightly extra lines. I'd much rather just have them in a `<span class="hang"></span>` type of thing.
I'm also looking for... | `<span>` is an inline element. The term *hanging indent* is meaningless unless you're talking about a paragraph (which generally means a block element). You can, of course, change the margins on `<p>` or `<div>` or any other block element to get rid of extra vertical space between paragraphs.
You may want something li... |
11,820 | <p>This <a href="https://stackoverflow.com/questions/11782/file-uploads-via-web-services">question and answer</a> shows how to send a file as a byte array through an XML web service. How much overhead is generated by using this method for file transfer? I assume the data looks something like this:</p>
<pre><code><... | [
{
"answer_id": 11830,
"author": "Mark Glorie",
"author_id": 952,
"author_profile": "https://Stackoverflow.com/users/952",
"pm_score": 0,
"selected": false,
"text": "<p>I use this method for some internal corporate webservices, and I haven't noticed any major slow-downs (but that doesn't ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | This [question and answer](https://stackoverflow.com/questions/11782/file-uploads-via-web-services) shows how to send a file as a byte array through an XML web service. How much overhead is generated by using this method for file transfer? I assume the data looks something like this:
```
<?xml version="1.0" encoding="... | Typically a byte array is sent as a `base64` encoded string, not as individual bytes in tags.
<http://en.wikipedia.org/wiki/Base64>
The `base64` encoded version is about **137%** of the size of the original content. |
11,854 | <p>In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, which would be very easily achieved with polymorphism. The problem I have with it is that inheritance implies the <em>is... | [
{
"answer_id": 11859,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 0,
"selected": false,
"text": "<p>Sometimes it's worth giving up the ideal for the realistic. If it's going to cause a massive problem to \"do it right\" ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1256/"
] | In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, which would be very easily achieved with polymorphism. The problem I have with it is that inheritance implies the *is a* rela... | This can be accomplished using multiple inheritance. In your specific case (C++), you can use pure virtual classes as interfaces. This allows you to have multiple inheritance without creating scope/ambiguity problems. Example:
```
class Damage {
virtual void addDamage(int d) = 0;
virtual int getDamage() = 0;
}... |
11,879 | <p>Instead of returning a common string, is there a way to return classic objects?
If not: what are the best practices? Do you transpose your object to xml and rebuild the object on the other side? What are the other possibilities? </p>
| [
{
"answer_id": 11883,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 2,
"selected": false,
"text": "<p>Yes: in .NET they call this serialization, where objects are serialized into XML and then reconstructed by the consuming ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/391/"
] | Instead of returning a common string, is there a way to return classic objects?
If not: what are the best practices? Do you transpose your object to xml and rebuild the object on the other side? What are the other possibilities? | As mentioned, you can do this in .net via serialization. By default all native types are serializable so this happens automagically for you.
However if you have complex types, you need to mark the object with the [Serializable] attribute. The same goes with complex types as properties.
So for example you need to have... |
11,887 | <p>I get an Access is Denied error message when I use the strong name tool to create a new key to sign a .NET assembly. This works just fine on a Windows XP machine but it does not work on my Vista machine.</p>
<pre><code>PS C:\users\brian\Dev\Projects\BELib\BELib> sn -k keypair.snk
Microsoft (R) .NET Framework S... | [
{
"answer_id": 11891,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 2,
"selected": false,
"text": "<p>Are you running your PowerShell or Command Prompt as an Administrator? I found this to be the first place to look unti... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1254/"
] | I get an Access is Denied error message when I use the strong name tool to create a new key to sign a .NET assembly. This works just fine on a Windows XP machine but it does not work on my Vista machine.
```
PS C:\users\brian\Dev\Projects\BELib\BELib> sn -k keypair.snk
Microsoft (R) .NET Framework Strong Name Utility... | >
> Yes I have tried running PS and the
> regular command prompt as
> administrator. The same error message
> comes up.
>
>
>
Another possible solution could be that you need to give your user account access to the key container located at C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RS... |
11,926 | <p>I'm new to MVC (and ASP.Net routing). I'm trying to map <code>*.aspx</code> to a controller called <code>PageController</code>. </p>
<pre><code>routes.MapRoute(
"Page",
"{name}.aspx",
new { controller = "Page", action = "Index", id = "" }
);
</code></pre>
<p>Wouldn't the code above map *.aspx to <code>P... | [
{
"answer_id": 11937,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure how your controller looks, the error seems to be pointing to the fact that it can't find the controller. Did ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105/"
] | I'm new to MVC (and ASP.Net routing). I'm trying to map `*.aspx` to a controller called `PageController`.
```
routes.MapRoute(
"Page",
"{name}.aspx",
new { controller = "Page", action = "Index", id = "" }
);
```
Wouldn't the code above map \*.aspx to `PageController`? When I run this and type in any .aspx ... | >
> I just answered my own question. I had
> the routes backwards (Default was
> above page).
>
>
>
Yeah, you have to put all custom routes above the Default route.
>
> So this brings up the next question...
> how does the "Default" route match (I
> assume they use regular expressions
> here) the "Page" rou... |
11,930 | <p>How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?</p>
<p>This is somewhat easy in .NET if you know your way around. But how do you do it in Java?</p>
| [
{
"answer_id": 11943,
"author": "Brian",
"author_id": 725,
"author_profile": "https://Stackoverflow.com/users/725",
"pm_score": 1,
"selected": false,
"text": "<p>That is not as easy as it sounds. Java is platform independent, so I am not sure how to do it in Java. I am <em>guessing</em... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | How can I determine the IP of my router/gateway in Java? I can get my IP easily enough. I can get my internet IP using a service on a website. But how can I determine my gateway's IP?
This is somewhat easy in .NET if you know your way around. But how do you do it in Java? | Java doesn't make this as pleasant as other languages, unfortunately. Here's what I did:
```
import java.io.*;
import java.util.*;
public class ExecTest {
public static void main(String[] args) throws IOException {
Process result = Runtime.getRuntime().exec("traceroute -m 1 www.amazon.com");
Buff... |
11,974 | <p>Basically, something better than this:</p>
<pre><code><input type="file" name="myfile" size="50">
</code></pre>
<p>First of all, the <code>browse</code> button looks different on every browser. Unlike the <code>submit</code> button on a form, you have to come up with some <a href="http://www.quirksmode.org/... | [
{
"answer_id": 12005,
"author": "Yaakov Ellis",
"author_id": 51,
"author_profile": "https://Stackoverflow.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>It is true, the file upload control is definitely behind the times. Hopefully this will be addressed in a future asp.net ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/11974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1396/"
] | Basically, something better than this:
```
<input type="file" name="myfile" size="50">
```
First of all, the `browse` button looks different on every browser. Unlike the `submit` button on a form, you have to come up with some [hack-y](http://www.quirksmode.org/dom/inputfile.html) way to style it.
Secondly, there's... | File upload boxes is where we're currently at if you don't want to involve other technologies like Flash, Java or ActiveX.
With plain HTML you are pretty much limited to the experience you've described (no progress bar, double submits, etc). If you are willing to use some javascript, you can solve some of the problems... |
12,009 | <p>How can I pipe the new password to smbpasswd so I can automate my installation process.</p>
| [
{
"answer_id": 12016,
"author": "icco",
"author_id": 1063,
"author_profile": "https://Stackoverflow.com/users/1063",
"pm_score": -1,
"selected": false,
"text": "<p>using either <a href=\"http://en.wikipedia.org/wiki/Pipeline_(Unix)\" rel=\"nofollow noreferrer\">pipelines</a> or <a href=\... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | How can I pipe the new password to smbpasswd so I can automate my installation process. | Thanks to Mark I found the answer:
```
(echo newpassword; echo confirmNewPassword) | smbpasswd -s
```
BTW: (echo oldpasswd; echo newpasswd) | smbpasswd -s does not work. |
12,039 | <p>I have an application that sometimes causes a BSOD on a Win XP machine. Trying to find out more, I loaded up the resulting *.dmp file (from C:\Windows\Minidump), but get this message when in much of the readout when doing so:</p>
<pre><code>*********************************************************************
* Sy... | [
{
"answer_id": 12043,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 2,
"selected": false,
"text": "<p>you actually need to either download the symbols to your computer, or configure it to download as you go if you are online w... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an application that sometimes causes a BSOD on a Win XP machine. Trying to find out more, I loaded up the resulting \*.dmp file (from C:\Windows\Minidump), but get this message when in much of the readout when doing so:
```
*********************************************************************
* Symbols can not ... | Quick answer is to
c:\> set \_NT\_SYMBOL\_PATH=SRV\*C:\WINDOWS\Symbols\*http://msdl.microsoft.com/download/symbols
before starting windbg. |
12,051 | <p>If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?</p>
<p>For example, if I inherit from the Exception class I want to do something like this:</p>
<pre><code>class MyExceptionClass : Exception
{
public M... | [
{
"answer_id": 12052,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 12,
"selected": true,
"text": "<p>Modify your constructor to the following so that it calls the base class constructor properly:</p>\n\n<pre><code>public c... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | If I inherit from a base class and want to pass something from the constructor of the inherited class to the constructor of the base class, how do I do that?
For example, if I inherit from the Exception class I want to do something like this:
```
class MyExceptionClass : Exception
{
public MyExceptionClass(strin... | Modify your constructor to the following so that it calls the base class constructor properly:
```
public class MyExceptionClass : Exception
{
public MyExceptionClass(string message, string extrainfo) : base(message)
{
//other stuff here
}
}
```
Note that a constructor is not something that you c... |
12,095 | <p>Our team is creating a new recruitment workflow system to replace an old one. I have been tasked with migrating the old data into the new schema. I have decided to do this by creating a small Windows Forms project as the schema are radically different and straight TSQL scripts are not an adequate solution.</p>
<p>T... | [
{
"answer_id": 12104,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe you can try the BackgroundWorker component. It makes threading easier. Examples here:</p>\n\n<ul>\n<li><a href=\"http://ww... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2083160/"
] | Our team is creating a new recruitment workflow system to replace an old one. I have been tasked with migrating the old data into the new schema. I have decided to do this by creating a small Windows Forms project as the schema are radically different and straight TSQL scripts are not an adequate solution.
The main se... | @John
Thanks for the links.
@Will
There's no gain from threadpooling as I know it will only ever spawn one thread. The use of a thread is purely to have a responsive UI while SQL Server is being pounded with reads and writes. It's certainly not a short lived thread.
Regarding sledge-hammers you're right. But, as i... |
12,103 | <p>When I am running the following statement:</p>
<pre><code>@filtered = map {s/&nbsp;//g} @outdata;
</code></pre>
<p>it is returning an empty list instead of the filtered list that I expected. What I am trying to do is remove every occurrence of <code>&nbsp;</code> from an array of string (which is an XML f... | [
{
"answer_id": 12108,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>@filtered = map {s/&nbsp;//g; $_} @outdata;\n</code></pre>\n\n<p>The problem is the s op... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274/"
] | When I am running the following statement:
```
@filtered = map {s/ //g} @outdata;
```
it is returning an empty list instead of the filtered list that I expected. What I am trying to do is remove every occurrence of ` ` from an array of string (which is an XML file).
Obviously, I am not understanding somet... | Try this:
```
@filtered = map {s/ //g; $_} @outdata;
```
The problem is the s operator in perl modifies $\_ but actually returns the number of changes it made. So, the extra $\_ at the end causes perl to return the modified string for each element of @outdata. |
12,135 | <p>I'm using an XmlSerializer to deserialize a particular type in mscorelib.dll</p>
<pre><code>XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );
return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) );
</code></pre>
<p>This throws a caught <code>FileNotFoundException</co... | [
{
"answer_id": 12136,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 2,
"selected": false,
"text": "<p>The delay is because, having been unable to find the custom serializer dll, the system is building the equivalent code (wh... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | I'm using an XmlSerializer to deserialize a particular type in mscorelib.dll
```
XmlSerializer ser = new XmlSerializer( typeof( [.Net type in System] ) );
return ([.Net type in System]) ser.Deserialize( new StringReader( xmlValue ) );
```
This throws a caught `FileNotFoundException` when the assembly is loaded:
>
... | I'm guessing now. but:
1. The system might be generating a serializer for the whole of mscorlib, which could be very slow.
2. You could probably avoid this by wrapping the system type in your own type and serialising that instead - then you'd get a serializer for your own assembly.
3. You might be able to build the se... |
12,140 | <p>A database application that I'm currently working on, stores all sorts of settings in the database. Most of those settings are there to customize certain business rules, but there's also some other stuff in there.</p>
<p>The app contains objects that specifically do a certain task, e.g., a certain complicated calcu... | [
{
"answer_id": 12161,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 0,
"selected": false,
"text": "<p>Usually this is handled by an ini file or XML configuration file. Then you just have a class that reads the setting wh... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1037/"
] | A database application that I'm currently working on, stores all sorts of settings in the database. Most of those settings are there to customize certain business rules, but there's also some other stuff in there.
The app contains objects that specifically do a certain task, e.g., a certain complicated calculation. Th... | You could use Martin Fowlers ServiceLocator pattern. In php it could look like this:
```
class ServiceLocator {
private static $soleInstance;
private $globalSettings;
public static function load($locator) {
self::$soleInstance = $locator;
}
public static function globalSettings() {
if (!isset(self:... |
12,141 | <p>For example: Updating all rows of the customer table because you forgot to add the where clause.</p>
<ol>
<li>What was it like, realizing it and reporting it to your coworkers or customers? </li>
<li>What were the lessons learned?</li>
</ol>
| [
{
"answer_id": 12143,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I dropped the live database and deleted it.</p>\n\n<p>Lesson learned: ensure you know your SQL - and make sure that you back... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/990/"
] | For example: Updating all rows of the customer table because you forgot to add the where clause.
1. What was it like, realizing it and reporting it to your coworkers or customers?
2. What were the lessons learned? | I think my worst mistake was
```
truncate table Customers
truncate table Transactions
```
I didnt see what MSSQL server I was logged into, I wanted to clear my local copy out...The familiar "OH s\*\*t" when it was taking significantly longer than about half a second to delete, my boss noticed I went visibily white, ... |
12,176 | <p>Is there any way to include the SVN repository revision number in the version string of a .NET assembly? Something like Major.Minor.SVNRev</p>
<p>I've seen mention of doing this with something like CC.NET (although on ASP.NET actually), but is there any way to do it without any extra software? I've done similar t... | [
{
"answer_id": 12189,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 4,
"selected": true,
"text": "<p>Have a look at SubWCRev - <a href=\"http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html\" rel=\"noreferre... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | Is there any way to include the SVN repository revision number in the version string of a .NET assembly? Something like Major.Minor.SVNRev
I've seen mention of doing this with something like CC.NET (although on ASP.NET actually), but is there any way to do it without any extra software? I've done similar things in C/C... | Have a look at SubWCRev - <http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html>
The assembly version numbers are usually in assemblyinfo.cs |
12,225 | <p>I have a database that contains a date and we are using the MaskedEditExtender (MEE) and MaskedEditValidator to make sure the dates are appropriate. However, we want the Admins to be able to go in and change the data (specifically the date) if necessary. </p>
<p>How can I have the MEE field pre-populate with the ... | [
{
"answer_id": 12257,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 0,
"selected": false,
"text": "<p>Are you referring to the asp.Net Ajax toolkit extensions at:</p>\n\n<p><a href=\"http://www.asp.net/AJAX/AjaxControlToolkit/Sa... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I have a database that contains a date and we are using the MaskedEditExtender (MEE) and MaskedEditValidator to make sure the dates are appropriate. However, we want the Admins to be able to go in and change the data (specifically the date) if necessary.
How can I have the MEE field pre-populate with the database val... | We found out this morning why our code was mishandling the extender. Since the db was handling the date as a date/time it was returning the date in this format 99/99/9999 99:99:99 but we had the extender mask looking for this format 99/99/9999 99:99
```
Mask="99/99/9999 99:99:99"
```
the above code fixed the problem... |
12,271 | <p>I have created a template for Visual Studio 2008 and it currently shows up under File->New Project->Visual C#. However, it is only really specific to Visual C#/Windows but I can't work out how to get it to show up under the "Windows" category and not the more general "Visual C#".</p>
| [
{
"answer_id": 12292,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 0,
"selected": false,
"text": "<p>Categorization of templates depends on settings (for example, if you choose \"C#\" settings, all of a sudden all other languages... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/214/"
] | I have created a template for Visual Studio 2008 and it currently shows up under File->New Project->Visual C#. However, it is only really specific to Visual C#/Windows but I can't work out how to get it to show up under the "Windows" category and not the more general "Visual C#". | Check out MSDN "[How to: Locate and Organize Project and Item Templates](http://msdn.microsoft.com/en-us/library/y3kkate1.aspx)"
Create a folder within one of these
```
<VisualStudioInstallDir>\Common7\IDE\ItemTemplates\CSharp\
My Documents\Visual Studio 2008\Templates\ProjectTemplates\CSharp\
``` |
12,297 | <p>I've got a Repeater that lists all the <code>web.sitemap</code> child pages on an ASP.NET page. Its <code>DataSource</code> is a <code>SiteMapNodeCollection</code>. But, I don't want my registration form page to show up there.</p>
<pre><code>Dim Children As SiteMapNodeCollection = SiteMap.CurrentNode.ChildNodes
... | [
{
"answer_id": 12303,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 1,
"selected": false,
"text": "<p>Using Linq and .Net 3.5:</p>\n\n<pre><code>//this will now be an enumeration, rather than a read only collection\nDim children... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I've got a Repeater that lists all the `web.sitemap` child pages on an ASP.NET page. Its `DataSource` is a `SiteMapNodeCollection`. But, I don't want my registration form page to show up there.
```
Dim Children As SiteMapNodeCollection = SiteMap.CurrentNode.ChildNodes
'remove registration page from collection
For Eac... | Your shouldn't need CType
```
Dim children = _
From n In SiteMap.CurrentNode.ChildNodes.Cast(Of SiteMapNode)() _
Where n.Url <> "/Registration.aspx" _
Select n
``` |
12,304 | <p>This is a problem I have seen other people besides myself having, and I haven't found a good explanation.</p>
<p>Let's say you have a maintenance plan with a task to check the database, something like this:</p>
<pre><code>USE [MyDb]
GO
DBCC CHECKDB with no_infomsgs, all_errormsgs
</code></pre>
<p>If you go look i... | [
{
"answer_id": 12320,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 1,
"selected": false,
"text": "<p>For starters, always remember that <code>GO</code> is not a SQL keyword; it is merely a batch separator that is (generally) impl... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | This is a problem I have seen other people besides myself having, and I haven't found a good explanation.
Let's say you have a maintenance plan with a task to check the database, something like this:
```
USE [MyDb]
GO
DBCC CHECKDB with no_infomsgs, all_errormsgs
```
If you go look in your logs after the task execut... | For starters, always remember that `GO` is not a SQL keyword; it is merely a batch separator that is (generally) implemented/recognized by the client, not the server. So, depending on context and client, there really is no guarantee that the current database is preserved between batches. |
12,306 | <p>I'm trying to serialize a Type object in the following way:</p>
<pre><code>Type myType = typeof (StringBuilder);
var serializer = new XmlSerializer(typeof(Type));
TextWriter writer = new StringWriter();
serializer.Serialize(writer, myType);
</code></pre>
<p>When I do this, the call to Serialize throws the followin... | [
{
"answer_id": 12314,
"author": "AdamSane",
"author_id": 805,
"author_profile": "https://Stackoverflow.com/users/805",
"pm_score": 1,
"selected": false,
"text": "<p>Just looked at its definition, it is not marked as Serializable. If you really need this data to be serialize, then you may... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/767/"
] | I'm trying to serialize a Type object in the following way:
```
Type myType = typeof (StringBuilder);
var serializer = new XmlSerializer(typeof(Type));
TextWriter writer = new StringWriter();
serializer.Serialize(writer, myType);
```
When I do this, the call to Serialize throws the following exception:
>
> "The t... | I wasn't aware that a Type object could be created with only a string containing the fully-qualified name. To get the fully qualified name, you can use the following:
```
string typeName = typeof (StringBuilder).FullName;
```
You can then persist this string however needed, then reconstruct the type like this:
```
... |
12,319 | <p>I'm looking to the equivalent of Windows <a href="http://msdn.microsoft.com/fr-fr/library/yeby3zcb.aspx" rel="noreferrer"><code>_wfopen()</code></a> under Mac OS X. Any idea?</p>
<p>I need this in order to port a Windows library that uses <code>wchar*</code> for its File interface. As this is intended to be a cross... | [
{
"answer_id": 12367,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using Cocoa it's fairly easy with NSString. Just load the UTF16 data in using -initWithBytes:length:encoding: (... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/268/"
] | I'm looking to the equivalent of Windows [`_wfopen()`](http://msdn.microsoft.com/fr-fr/library/yeby3zcb.aspx) under Mac OS X. Any idea?
I need this in order to port a Windows library that uses `wchar*` for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client app... | POSIX API in Mac OS X are usable with UTF-8 strings. In order to convert a wchar\_t string to UTF-8, it is possible to use the CoreFoundation framework from Mac OS X.
Here is a class that will wrap an UTF-8 generated string from a wchar\_t string.
```
class Utf8
{
public:
Utf8(const wchar_t* wsz): m_utf8(NULL)
... |
12,368 | <p>The .NET garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <code>MyClass</code> to call</p>
<pre><code>MyClass.Dispose()
</code></pre>
<p>and free up all the used space by variables and objects in <code>MyClass</code>?</p>
| [
{
"answer_id": 12376,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.codeguru.com/csharp/.net/net_general/tipstricks/article.php/c7047/\" rel=\"nofollow noreferrer\" tit... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1271/"
] | The .NET garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class `MyClass` to call
```
MyClass.Dispose()
```
and free up all the used space by variables and objects in `MyClass`? | IDisposable has nothing to do with freeing memory. IDisposable is a pattern for freeing *unmanaged* resources -- and memory is quite definitely a managed resource.
The links pointing to GC.Collect() are the correct answer, though use of this function is generally discouraged by the Microsoft .NET documentation.
**Edi... |
12,374 | <p>We’ve found that the unit tests we’ve written for our C#/C++ code have really paid off.
But we still have thousands of lines of business logic in stored procedures, which only really get tested in anger when our product is rolled out to a large number of users. </p>
<p>What makes this worse is that some of these s... | [
{
"answer_id": 12387,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 3,
"selected": false,
"text": "<p>Have you tried <a href=\"http://dbunit.sourceforge.net/\" rel=\"nofollow noreferrer\">DBUnit</a>? It's designed to unit t... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1078/"
] | We’ve found that the unit tests we’ve written for our C#/C++ code have really paid off.
But we still have thousands of lines of business logic in stored procedures, which only really get tested in anger when our product is rolled out to a large number of users.
What makes this worse is that some of these stored proc... | I ran into this same issue a while back and found that if I created a simple abstract base class for data access that allowed me to inject a connection and transaction, I could unit test my sprocs to see if they did the work in SQL that I asked them to do and then rollback so none of the test data is left in the db.
... |
12,385 | <p>How would you attach a propertychanged callback to a property that is inherited? Like such:</p>
<pre><code>class A {
DependencyProperty prop;
}
class B : A {
//...
prop.AddListener(PropertyChangeCallback);
}
</code></pre>
| [
{
"answer_id": 12436,
"author": "Jon Galloway",
"author_id": 5,
"author_profile": "https://Stackoverflow.com/users/5",
"pm_score": 3,
"selected": true,
"text": "<p>(edited to remove recommendation to use DependencyPropertyDescriptor, which is not available in Silverlight)</p>\n\n<p><a hr... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93/"
] | How would you attach a propertychanged callback to a property that is inherited? Like such:
```
class A {
DependencyProperty prop;
}
class B : A {
//...
prop.AddListener(PropertyChangeCallback);
}
``` | (edited to remove recommendation to use DependencyPropertyDescriptor, which is not available in Silverlight)
[PropertyDescriptor AddValueChanged Alternative](http://agsmith.wordpress.com/2008/04/07/propertydescriptor-addvaluechanged-alternative/) |
12,428 | <p>Once I have my renamed files I need to add them to my project's wiki page. This is a fairly repetitive manual task, so I guess I could script it but I don't know where to start.</p>
<p>The process is:</p>
<pre><code>Got to appropriate page on the wiki
for each team member (DeveloperA, DeveloperB, DeveloperC)
{
... | [
{
"answer_id": 12439,
"author": "jsight",
"author_id": 1432,
"author_profile": "https://Stackoverflow.com/users/1432",
"pm_score": 1,
"selected": false,
"text": "<p>If you're writing in C#, the WebClient classes might be a good place to start. I bet people could give more specific advic... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/849/"
] | Once I have my renamed files I need to add them to my project's wiki page. This is a fairly repetitive manual task, so I guess I could script it but I don't know where to start.
The process is:
```
Got to appropriate page on the wiki
for each team member (DeveloperA, DeveloperB, DeveloperC)
{
for each of two fil... | Check if the wiki you mean to talk to supports [XMLRPC](http://www.jspwiki.org/wiki/WikiRPCInterface2), because if it does it should be a snap. I wrote a tool called [WikiUp](http://trac.gargoyle.ath.cx/trac/wiki/WikiUp) to solve a similar problem (updating a delineated section on a wiki page). |
12,482 | <p>I have CruiseControl.NET Version 1.4 set up on my development server. Whenever a developer checks in code, it makes a compile. </p>
<p>Now we're at a place where we can start giving our application to the testers. We'd like to use ClickOnce to distribute the application, with the idea being that when a tester go... | [
{
"answer_id": 12497,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": -1,
"selected": false,
"text": "<p>You want to use the ClickOnce manifest generation tasks in msbuild. The process is a little long winded, so I am just... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/702/"
] | I have CruiseControl.NET Version 1.4 set up on my development server. Whenever a developer checks in code, it makes a compile.
Now we're at a place where we can start giving our application to the testers. We'd like to use ClickOnce to distribute the application, with the idea being that when a tester goes to test th... | Thanks for all the help. The final solution we implemented took a bit from every answer.
We found it easier to handle working with multiple environments using simple batch files. I'm not suggesting this is the best way to do this, but for our given scenario and requirements, this worked well. Supplement "Project" with... |
12,489 | <p>How do you scan a directory for folders and files in C? It needs to be cross-platform.</p>
| [
{
"answer_id": 12500,
"author": "PW.",
"author_id": 927,
"author_profile": "https://Stackoverflow.com/users/927",
"pm_score": 3,
"selected": false,
"text": "<p>opendir/readdir are POSIX. If POSIX is not enough for the portability you want to achieve, check <a href=\"http://apr.apache.org... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | How do you scan a directory for folders and files in C? It needs to be cross-platform. | The following POSIX program will print the names of the files in the current directory:
```
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
int main (void)
{
DIR *dp;
struct dirent *ep;
dp = opendir ("./");
if (dp != NULL)
{
while ((ep = readdir (dp)) != NULL... |
12,516 | <p>This morning, I was reading <a href="http://steve.yegge.googlepages.com/when-polymorphism-fails" rel="noreferrer">Steve Yegge's: When Polymorphism Fails</a>, when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.</p>
<blockquote>
<p>As a... | [
{
"answer_id": 12538,
"author": "eplawless",
"author_id": 1370,
"author_profile": "https://Stackoverflow.com/users/1370",
"pm_score": 2,
"selected": false,
"text": "<p>String Tokenizer + LL(1) Parser will give you an expression tree... the polymorphism way might involve an abstract Arith... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25/"
] | This morning, I was reading [Steve Yegge's: When Polymorphism Fails](http://steve.yegge.googlepages.com/when-polymorphism-fails), when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
>
> As an example of polymorphism in
> action, let's lo... | **Polymorphic Tree Walking**, Python version
```
#!/usr/bin/python
class Node:
"""base class, you should not process one of these"""
def process(self):
raise('you should not be processing a node')
class BinaryNode(Node):
"""base class for binary nodes"""
def __init__(self, _left, _right):
... |
12,533 | <p>Is there a quick one-liner to call datepart in Sql Server and get back the name of the day instead of just the number?</p>
<pre><code>select datepart(dw, getdate());
</code></pre>
<p>This will return 1-7, with Sunday being 1. I would like 'Sunday' instead of 1.</p>
| [
{
"answer_id": 12541,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 0,
"selected": false,
"text": "<p>This is not possible without using the result to select the day yourself. For one thing the textual representation of... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | Is there a quick one-liner to call datepart in Sql Server and get back the name of the day instead of just the number?
```
select datepart(dw, getdate());
```
This will return 1-7, with Sunday being 1. I would like 'Sunday' instead of 1. | ```
select datename(weekday, getdate());
``` |
12,565 | <p>In Ruby, what's the difference between <code>{}</code> and <code>[]</code>?</p>
<p><code>{}</code> seems to be used for both code blocks and hashes.</p>
<p>Are <code>[]</code> only for arrays?</p>
<p>The documention isn't very clear.</p>
| [
{
"answer_id": 12575,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 3,
"selected": false,
"text": "<p>Broadly speaking, you're correct. As well as hashes, the general style is that curly braces <code>{}</code> are often ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1470/"
] | In Ruby, what's the difference between `{}` and `[]`?
`{}` seems to be used for both code blocks and hashes.
Are `[]` only for arrays?
The documention isn't very clear. | It depends on the context:
1. When on their own, or assigning to a variable, `[]` creates arrays, and `{}` creates hashes. e.g.
```
a = [1,2,3] # an array
b = {1 => 2} # a hash
```
2. `[]` can be overridden as a custom method, and is generally used to fetch things from hashes (the standard library sets up `[]` as a ... |
12,569 | <p>Let's say we have a simple function defined in a pseudo language.</p>
<pre><code>List<Numbers> SortNumbers(List<Numbers> unsorted, bool ascending);
</code></pre>
<p>We pass in an unsorted list of numbers and a boolean specifying ascending or descending sort order. In return, we get a sorted list of num... | [
{
"answer_id": 12571,
"author": "Justin Standard",
"author_id": 92,
"author_profile": "https://Stackoverflow.com/users/92",
"pm_score": 4,
"selected": true,
"text": "<p>Don't waste too much time trying to think of <em>every</em> boundry condition. Your tests won't be able to catch <em>e... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12081/"
] | Let's say we have a simple function defined in a pseudo language.
```
List<Numbers> SortNumbers(List<Numbers> unsorted, bool ascending);
```
We pass in an unsorted list of numbers and a boolean specifying ascending or descending sort order. In return, we get a sorted list of numbers.
In my experience, some people a... | Don't waste too much time trying to think of *every* boundry condition. Your tests won't be able to catch *every* bug first time around. The idea is to have tests that are *pretty good*, and then each time a bug *does* surface, write a new test specifically for that bug so that you never hear from it again.
Another no... |
12,576 | <p>What can I do to increase the performance/speed of my PHP scripts without installing software on my servers?</p>
| [
{
"answer_id": 12579,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 2,
"selected": false,
"text": "<p>There is no magic solution, and attempting to provide generic solutions could well just be a waste of time.</p>\n\n<p... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | What can I do to increase the performance/speed of my PHP scripts without installing software on my servers? | Profile. Profile. Profile. I'm not sure if there is anything out there for PHP, but it should be simple to write a little tool to insert profiling information in your code. You will want to profile function times and SQL query times.
So where you have a function:
```
function foo($stuff) {
...
return ...;
}
... |
12,591 | <p>Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a document’s DTD.</p>
| [
{
"answer_id": 13040,
"author": "Michael Twomey",
"author_id": 995,
"author_profile": "https://Stackoverflow.com/users/995",
"pm_score": 1,
"selected": false,
"text": "<p>Can you give an example? According to the <a href=\"http://codespeak.net/lxml/validation.html\" rel=\"nofollow norefe... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | Is there a way, when I parse an XML document using lxml, to validate that document against its DTD using an external catalog file? I need to be able to work the fixed attributes defined in a document’s DTD. | You can add the catalog to the `XML_CATALOG_FILES` environment variable:
```
os.environ['XML_CATALOG_FILES'] = 'file:///to/my/catalog.xml'
```
See [this thread](http://thread.gmane.org/gmane.comp.python.lxml.devel/5907). Note that entries in `XML_CATALOG_FILES` are space-separated URLs. You can use Python's `pathnam... |
12,592 | <p>Is it possible to write a <code>doctest</code> unit test that will check that an exception is raised?<br />
For example, if I have a function <code>foo(x)</code> that is supposed to raise an exception if <code>x < 0</code>, how would I write the <code>doctest</code> for that?</p>
| [
{
"answer_id": 12609,
"author": "cnu",
"author_id": 1448,
"author_profile": "https://Stackoverflow.com/users/1448",
"pm_score": 8,
"selected": true,
"text": "<p>Yes. You can do it. The <a href=\"https://docs.python.org/3/library/doctest.html\" rel=\"noreferrer\">doctest module documentat... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | Is it possible to write a `doctest` unit test that will check that an exception is raised?
For example, if I have a function `foo(x)` that is supposed to raise an exception if `x < 0`, how would I write the `doctest` for that? | Yes. You can do it. The [doctest module documentation](https://docs.python.org/3/library/doctest.html) and Wikipedia has an [example](http://en.wikipedia.org/wiki/Doctest#Example_2:_doctests_embedded_in_a_README.txt_file) of it.
```
>>> x
Traceback (most recent call last):
...
NameError: name 'x' is not ... |
12,613 | <p>I've been using Emacs's sql interactive mode to talk to the MySQL db server and gotten to enjoy it. A developer has set up another db on a new non-default port number but I don't know how to access it using sql-mysql.</p>
<p>How do I specify a port number when I'm trying to connect to a database?</p>
<p>It would b... | [
{
"answer_id": 12628,
"author": "Marcel Levy",
"author_id": 676,
"author_profile": "https://Stackoverflow.com/users/676",
"pm_score": 3,
"selected": false,
"text": "<pre><code>(setq sql-mysql-options (list \"-P <port number>\"))\n</code></pre>\n"
},
{
"answer_id": 12658,
... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | I've been using Emacs's sql interactive mode to talk to the MySQL db server and gotten to enjoy it. A developer has set up another db on a new non-default port number but I don't know how to access it using sql-mysql.
How do I specify a port number when I'm trying to connect to a database?
It would be even better if ... | After digging through the sql.el file, I found a variable that allows me to specify a port when I try to create a connection.
This option was added GNU Emacs 24.1.
>
> **sql-mysql-login-params**
>
>
> List of login parameters needed to connect to MySQL.
>
>
>
I added this to my Emacs init file:
```
(setq sql-... |
12,638 | <p>So basically I'm building an app for my company and it NEEDS to be built using MS Access and it needs to be built on SQL Server.</p>
<p>I've drawn up most of the plans but am having a hard time figuring out a way to handle the auditing system.</p>
<p>Since it is being used internally only and you won't even be abl... | [
{
"answer_id": 12644,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "<p>How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication?... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | So basically I'm building an app for my company and it NEEDS to be built using MS Access and it needs to be built on SQL Server.
I've drawn up most of the plans but am having a hard time figuring out a way to handle the auditing system.
Since it is being used internally only and you won't even be able to touch the db... | Does this work for you?
```
select user_name(),suser_sname()
```
---
Doh! I forgot to escape my code. |
12,642 | <p>I am trying to upload a file or stream of data to our web server and I cant find a decent way of doing this. I have tried both <code>WebClient</code> and <code>WebRequest</code> both have their problems. </p>
<p><strong>WebClient</strong><br>
Nice and easy but you do not get any notification that the asynchronous ... | [
{
"answer_id": 12649,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "<p>Matt Berseth had some thoughts in this, might help:</p>\n\n<p><a href=\"http://mattberseth.com/blog/2008/07/aspnet_file_upload_w... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1478/"
] | I am trying to upload a file or stream of data to our web server and I cant find a decent way of doing this. I have tried both `WebClient` and `WebRequest` both have their problems.
**WebClient**
Nice and easy but you do not get any notification that the asynchronous upload has completed, and the `UploadProgressCh... | The way i get around it is through INotifyPropertyChanged and event notification.
The essentials:
```
public void DoIt(){
this.IsUploading = True;
WebRequest postRequest = WebRequest.Create(new Uri(ServiceURL));
postRequest.BeginGetRequestStream(new AsyncCallback(RequestOpened), postRequest);
... |
12,647 | <p>Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:</p>
<pre><code>if (is_number($x))
{ ... }
</code></pre>
<p>would be ideal. A technique that won't throw warnings when the <code>-w</code> switch is being used is certainly preferred.</p>
| [
{
"answer_id": 12654,
"author": "farmerchris",
"author_id": 1317,
"author_profile": "https://Stackoverflow.com/users/1317",
"pm_score": 2,
"selected": false,
"text": "<p>Not perfect, but you can use a regex:</p>\n\n<pre><code>sub isnumber \n{\n shift =~ /^-?\\d+\\.?\\d*$/;\n}\n</code>... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/872/"
] | Is there a simple way in Perl that will allow me to determine if a given variable is numeric? Something along the lines of:
```
if (is_number($x))
{ ... }
```
would be ideal. A technique that won't throw warnings when the `-w` switch is being used is certainly preferred. | Use `Scalar::Util::looks_like_number()` which uses the internal Perl C API's looks\_like\_number() function, which is probably the most efficient way to do this.
Note that the strings "inf" and "infinity" are treated as numbers.
Example:
--------
```
#!/usr/bin/perl
use warnings;
use strict;
use Scalar::Util qw(loo... |
12,656 | <p>In a project that I'm about to wrap up, I've written and implemented an object-relational mapping solution for PHP. Before the doubters and dreamers cry out "how on earth?", relax -- I haven't found a way to make late static binding work -- I'm just working around it in the best way that I possibly can.</p>
<p>Anyw... | [
{
"answer_id": 13092,
"author": "John Downey",
"author_id": 200,
"author_profile": "https://Stackoverflow.com/users/200",
"pm_score": 5,
"selected": true,
"text": "<p>In PHP you can pass a variable number of arguments to a function or method by using <a href=\"http://www.php.net/call_use... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344/"
] | In a project that I'm about to wrap up, I've written and implemented an object-relational mapping solution for PHP. Before the doubters and dreamers cry out "how on earth?", relax -- I haven't found a way to make late static binding work -- I'm just working around it in the best way that I possibly can.
Anyway, I'm no... | In PHP you can pass a variable number of arguments to a function or method by using [`call_user_func_array`](http://www.php.net/call_user_func_array). An example for a method would be:
```
call_user_func_array(array(&$stmt, 'bindparams'), $array_of_params);
```
The function will be called with each member in the arr... |
12,657 | <p>I'm using the new ASP.Net ListView control to list database items that will be grouped together in sections based on one of their columns like so:</p>
<pre><code>region1
store1
store2
store3
region2
store4
region3
store5
store6
</code></pre>
<p>Is this possible to do with the ListView's Gro... | [
{
"answer_id": 12735,
"author": "Otto",
"author_id": 519,
"author_profile": "https://Stackoverflow.com/users/519",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't used GroupItemCount, but I have taken this example written up by <a href=\"http://mattberseth.com/\" rel=\"nofollow no... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1249/"
] | I'm using the new ASP.Net ListView control to list database items that will be grouped together in sections based on one of their columns like so:
```
region1
store1
store2
store3
region2
store4
region3
store5
store6
```
Is this possible to do with the ListView's GroupItemTemplate? Every exam... | I haven't used GroupItemCount, but I have taken this example written up by [Matt Berseth](http://mattberseth.com/) titled [Building a Grouping Grid with the ASP.NET 3.5 LinqDataSource and ListView Controls](http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html) and have grouped items by a key just like... |
12,661 | <p>What's the most efficient way to resize large images in PHP?</p>
<p>I'm currently using the <a href="http://en.wikipedia.org/wiki/GD_Graphics_Library" rel="noreferrer">GD</a> function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide b... | [
{
"answer_id": 12732,
"author": "phenry",
"author_id": 1482,
"author_profile": "https://Stackoverflow.com/users/1482",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://phpthumb.sourceforge.net/\" rel=\"noreferrer\">phpThumb</a> uses ImageMagick whenever possible for speed (... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477/"
] | What's the most efficient way to resize large images in PHP?
I'm currently using the [GD](http://en.wikipedia.org/wiki/GD_Graphics_Library) function imagecopyresampled to take high resolution images, and cleanly resize them down to a size for web viewing (roughly 700 pixels wide by 700 pixels tall).
This works great ... | People say that ImageMagick is much faster. At best just compare both libraries and measure that.
1. Prepare 1000 typical images.
2. Write two scripts -- one for GD, one
for ImageMagick.
3. Run both of them a few times.
4. Compare results (total execution
time, CPU and I/O usage, result
image quality).
Something whic... |
12,702 | <p>I have a WCF service from which I want to return a DataTable. I know that this is often a highly-debated topic, as far as whether or not returning DataTables is a good practice. Let's put that aside for a moment.</p>
<p>When I create a DataTable from scratch, as below, there are no problems whatsoever. The table is... | [
{
"answer_id": 12712,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 2,
"selected": false,
"text": "<p>The attribute you want is OperationContract (on interface) / Operation Behavior (on method):</p>\n\n<pre><code>[ServiceCon... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/940/"
] | I have a WCF service from which I want to return a DataTable. I know that this is often a highly-debated topic, as far as whether or not returning DataTables is a good practice. Let's put that aside for a moment.
When I create a DataTable from scratch, as below, there are no problems whatsoever. The table is created, ... | For anyone having similar problems, I have solved my issue. It was several-fold.
* As Darren suggested and Paul backed up, the Max..Size properties in the configuration needed to be enlarged. The SvcTraceViewer utility helped in determining this, but it still does not always give the most helpful error messages.
* It ... |
12,716 | <p>In C++ program, I am trying to #import TLB of .NET out-of-proc server.</p>
<p>I get errors like:</p>
<blockquote>
<p>z:\server.tlh(111) : error C2146: syntax error : missing ';' before identifier 'GetType'</p>
<p>z:\server.tlh(111) : error C2501: '_TypePtr' : missing storage-class or type specifiers</p>
<p>z:\server... | [
{
"answer_id": 12751,
"author": "jm.",
"author_id": 814,
"author_profile": "https://Stackoverflow.com/users/814",
"pm_score": 2,
"selected": true,
"text": "<p>Added no_namespace and raw_interfaces_only to my #import:</p>\n\n<pre><code>#import \"server.tlb\" no_namespace named_guids\n</co... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | In C++ program, I am trying to #import TLB of .NET out-of-proc server.
I get errors like:
>
> z:\server.tlh(111) : error C2146: syntax error : missing ';' before identifier 'GetType'
>
>
> z:\server.tlh(111) : error C2501: '\_TypePtr' : missing storage-class or type specifiers
>
>
> z:\server.tli(74) : error C21... | Added no\_namespace and raw\_interfaces\_only to my #import:
```
#import "server.tlb" no_namespace named_guids
```
Also using TLBEXP.EXE instead of REGASM.EXE seems to help this issue. |
12,718 | <p>When installing subversion as a service, I used this command:</p>
<pre><code>c:\>svnservice -install --daemon --root "c:\documents and settings\my_repository"
</code></pre>
<p>And then I got this error:</p>
<pre><code>Could not create service in service control manager.
</code></pre>
<p>After looking at some ... | [
{
"answer_id": 12727,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 0,
"selected": false,
"text": "<p>I've never used the command line installer for this. I assume you are downloading the latest from:</p>\n\n<p><a href... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | When installing subversion as a service, I used this command:
```
c:\>svnservice -install --daemon --root "c:\documents and settings\my_repository"
```
And then I got this error:
```
Could not create service in service control manager.
```
After looking at some MSDN docs on the service control manager, I tried gr... | [VisualSVN Server](http://www.visualsvn.com/server) installs as a Windows service. It is free, includes Apache, OpenSSL, and a repository / permission management tool. It can also integrate with Active Directory for user authentication. I highly recommend it for hosting SVN on Windows. |
12,765 | <p>This is driving me crazy.</p>
<p>I have this one php file on a test server at work which does not work.. I kept deleting stuff from it till it became </p>
<pre>
<?
print 'Hello';
?>
</pre>
<p>it outputs </p>
<blockquote>
<p>Hello</p>
</blockquote>
<p>if I create a new file and copy / paste the same scri... | [
{
"answer_id": 12769,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 5,
"selected": true,
"text": "<p>That's the <a href=\"http://en.wikipedia.org/wiki/Byte_Order_Mark\" rel=\"noreferrer\">BOM (Byte Order Mark)</a> you are seeing.<... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is driving me crazy.
I have this one php file on a test server at work which does not work.. I kept deleting stuff from it till it became
```
<?
print 'Hello';
?>
```
it outputs
>
> Hello
>
>
>
if I create a new file and copy / paste the same script to it it works!
Why does this one file give me th... | That's the [BOM (Byte Order Mark)](http://en.wikipedia.org/wiki/Byte_Order_Mark) you are seeing.
In your editor, there should be a way to force saving without BOM which will remove the problem. |
12,794 | <p>I'm trying to use <code>jQuery</code> to format code blocks, specifically to add a <code><pre></code> tag inside the <code><code></code> tag:</p>
<pre><code>$(document).ready(function() {
$("code").wrapInner("<pre></pre>");
});
</code></pre>
<p>Firefox applies the formatting correctly, b... | [
{
"answer_id": 12804,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 1,
"selected": false,
"text": "<p>Are you using the latest jQuery ?\nWhat if you try </p>\n\n<pre><code>$(\"code\").wrapInner(document.createElement(\"pre\"));\n<... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/311/"
] | I'm trying to use `jQuery` to format code blocks, specifically to add a `<pre>` tag inside the `<code>` tag:
```
$(document).ready(function() {
$("code").wrapInner("<pre></pre>");
});
```
Firefox applies the formatting correctly, but IE puts the entire code block on one line. If I add an alert
```
alert($("code... | That's the difference between [block and inline](http://www.w3.org/TR/html4/struct/global.html#h-7.5.3) elements. [`pre` is a block level element](http://www.w3.org/TR/html4/sgml/dtd.html#block). It's not legal to put it inside a `code` tag, which [can only contain inline content](http://www.w3.org/TR/html4/struct/text... |
12,855 | <p>I have a query where I am searching against a string:</p>
<pre><code>SELECT county FROM city WHERE UPPER(name) = 'SAN FRANCISCO';
</code></pre>
<p>Now, this works fine, but it doesn't scale well, and I need to optimize it. I have <a href="http://www.ibm.com/developerworks/db2/library/techarticle/0203adamache/0203... | [
{
"answer_id": 12886,
"author": "nsanders",
"author_id": 1244,
"author_profile": "https://Stackoverflow.com/users/1244",
"pm_score": 3,
"selected": false,
"text": "<p>You could add an indexed column holding a numerical hash key of the city name. (With duplicates allowed).</p>\n\n<p>Then... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I have a query where I am searching against a string:
```
SELECT county FROM city WHERE UPPER(name) = 'SAN FRANCISCO';
```
Now, this works fine, but it doesn't scale well, and I need to optimize it. I have [found an option](http://www.ibm.com/developerworks/db2/library/techarticle/0203adamache/0203adamache.html) alo... | You could add an indexed column holding a numerical hash key of the city name. (With duplicates allowed).
Then you could do a multi-clause where :
```
hash = [compute hash key for 'SAN FRANCISCO']
SELECT county
FROM city
WHERE cityHash = hash
AND UPPER(name) = 'SAN FRANCISCO' ;
```
Alternatively, go through y... |
12,865 | <p>Got a bluescreen in windows while cloning a mercurial repository.</p>
<p>After reboot, I now get this message for almost all hg commands:</p>
<pre>
c:\src\>hg commit
waiting for lock on repository c:\src\McVrsServer held by '\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
interru... | [
{
"answer_id": 12879,
"author": "jm.",
"author_id": 814,
"author_profile": "https://Stackoverflow.com/users/814",
"pm_score": 10,
"selected": true,
"text": "<p>When \"waiting for lock on repository\", delete the repository file: <code>.hg/wlock</code> (or it may be in <code><code>.hg/sto... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | Got a bluescreen in windows while cloning a mercurial repository.
After reboot, I now get this message for almost all hg commands:
```
c:\src\>hg commit
waiting for lock on repository c:\src\McVrsServer held by '\x00\x00\x00\x00\x00\
x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
interrupted!
```
Goo... | When "waiting for lock on repository", delete the repository file: `.hg/wlock` (or it may be in ``.hg/store/lock``)
When deleting the lock file, you must make sure nothing else is accessing the repository. (If the lock is a string of zeros or blank, this is almost certainly true). |
12,870 | <p>This is a nasty one for me... I'm a PHP guy working in Java on a JSP project. I know how to do what I'm attempting through too much code and a complete lack of finesse. </p>
<p>I'd prefer to do it right. Here is the situation:</p>
<p>I'm writing a small display to show customers what days they can water their ... | [
{
"answer_id": 12878,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 5,
"selected": true,
"text": "<p>You could do essentially the same code with Hashtables (or some other Map):</p>\n\n<pre><code>Hashtable<String, Hashtab... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172/"
] | This is a nasty one for me... I'm a PHP guy working in Java on a JSP project. I know how to do what I'm attempting through too much code and a complete lack of finesse.
I'd prefer to do it right. Here is the situation:
I'm writing a small display to show customers what days they can water their lawns based on their ... | You could do essentially the same code with Hashtables (or some other Map):
```
Hashtable<String, Hashtable<String, String>> schedule
= new Hashtable<String, Hashtable<String, String>>();
schedule.put("A", new Hashtable<String, String>());
schedule.put("B", new Hashtable<String, String>());
schedule.put("C", new H... |
12,877 | <p>I just get the beach ball all day long (it's been doing nothing for hours). It's not taking CPU, not reading from disk, not using the network.</p>
<p>I'm using <strong>Java 1.6</strong> on <strong>Mac OS X 10.5.4</strong>. It worked once, now even restarts of the computer won't help. Activity Monitor says it's "(No... | [
{
"answer_id": 12943,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 1,
"selected": false,
"text": "<p>The company <a href=\"http://www.navicat.com/\" rel=\"nofollow noreferrer\">Navicat</a> has released an Oracle cli... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/484/"
] | I just get the beach ball all day long (it's been doing nothing for hours). It's not taking CPU, not reading from disk, not using the network.
I'm using **Java 1.6** on **Mac OS X 10.5.4**. It worked once, now even restarts of the computer won't help. Activity Monitor says it's "(Not Responding)". Only thing that I ca... | I get the same problem after there's been an active connection sitting idle for a while. I solve it by restarting sql developer every once in a while.
I also have Toad for Oracle running on a vmware XP session, and it works great. If you don't mind the money, try that. |
12,890 | <p>I have a large database of normalized order data that is becoming very slow to query for reporting. Many of the queries that I use in reports join five or six tables and are having to examine tens or hundreds of thousands of lines.</p>
<p>There are lots of queries and most have been optimized as much as possible t... | [
{
"answer_id": 12900,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 1,
"selected": false,
"text": "<p>I know this is a bit tangential, but have you tried seeing if there are more indexes you can add?</p>\n\n<p>I don't have ... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1430/"
] | I have a large database of normalized order data that is becoming very slow to query for reporting. Many of the queries that I use in reports join five or six tables and are having to examine tens or hundreds of thousands of lines.
There are lots of queries and most have been optimized as much as possible to reduce se... | I know more about mssql that mysql, but I don't think the number of joins or number of rows you are talking about should cause you too many problems with the correct indexes in place. Have you analyzed the query plan to see if you are missing any?
<http://dev.mysql.com/doc/refman/5.0/en/explain.html>
That being said,... |
12,896 | <p>I'm looking for good/working/simple to use PHP code for parsing raw email into parts.</p>
<p>I've written a couple of brute force solutions, but every time, one small change/header/space/something comes along and my whole parser fails and the project falls apart.</p>
<p>And before I get pointed at PEAR/PECL, I need ... | [
{
"answer_id": 12965,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 6,
"selected": true,
"text": "<p>What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time wi... | 2008/08/15 | [
"https://Stackoverflow.com/questions/12896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/314/"
] | I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
I've written a couple of brute force solutions, but every time, one small change/header/space/something comes along and my whole parser fails and the project falls apart.
And before I get pointed at PEAR/PECL, I need actual code. My... | What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time with [RFC2822](http://www.faqs.org/rfcs/rfc2822.html) to understand the format of the mail, but here's the simplest rules for well formed email:
```
HEADERS\n
\n
BODY
```
That is, the first bla... |
12,905 | <p>I'm experimenting with creating an add-in for Infopath 2007. The documentation is very skimpy. What I'm trying to determine is what kind of actions an add-in can take while designing a form. Most of the discussion and samples are for when the user is filling out the form. Can I, for example, add a new field to the f... | [
{
"answer_id": 12965,
"author": "jj33",
"author_id": 430,
"author_profile": "https://Stackoverflow.com/users/430",
"pm_score": 6,
"selected": true,
"text": "<p>What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time wi... | 2008/08/16 | [
"https://Stackoverflow.com/questions/12905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9/"
] | I'm experimenting with creating an add-in for Infopath 2007. The documentation is very skimpy. What I'm trying to determine is what kind of actions an add-in can take while designing a form. Most of the discussion and samples are for when the user is filling out the form. Can I, for example, add a new field to the form... | What are you hoping to end up with at the end? The body, the subject, the sender, an attachment? You should spend some time with [RFC2822](http://www.faqs.org/rfcs/rfc2822.html) to understand the format of the mail, but here's the simplest rules for well formed email:
```
HEADERS\n
\n
BODY
```
That is, the first bla... |
12,906 | <p>I need to know how much space occupies all the databases inside an SQL Server 2000. I did some research but could not found any script to help me out.</p>
| [
{
"answer_id": 12911,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 0,
"selected": false,
"text": "<p>I know this might sound a little arcanine but why not just stat the directory that contains the database.</p>\n"
},
{
... | 2008/08/16 | [
"https://Stackoverflow.com/questions/12906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296/"
] | I need to know how much space occupies all the databases inside an SQL Server 2000. I did some research but could not found any script to help me out. | Source: <http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html>
Works with SQL2000,2005,2008
```
USE master;
GO
IF OBJECT_ID('dbo.sp_SDS', 'P') IS NOT NULL
DROP PROCEDURE dbo.sp_SDS;
GO
CREATE PROCEDURE dbo.sp_SDS
@TargetDatabase sysname = NULL, -- NULL: all dbs
@Level varchar(10) =... |
13,000 | <p>I want to define something like this in <em>php</em>:</p>
<pre><code>$EL = "\n<br />\n";
</code></pre>
<p>and then use that variable as an "endline" marker all over my site, like this:</p>
<pre><code>echo "Blah blah blah{$EL}";
</code></pre>
<p>How do I define $EL once (in only 1 file), include it on every... | [
{
"answer_id": 13003,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": true,
"text": "<p>Most PHP sites should have a file (I call it a header) that you include on every single page of the site. If you put that... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/103/"
] | I want to define something like this in *php*:
```
$EL = "\n<br />\n";
```
and then use that variable as an "endline" marker all over my site, like this:
```
echo "Blah blah blah{$EL}";
```
How do I define $EL once (in only 1 file), include it on every page on my site, and *not* have to reference it using the (st... | Most PHP sites should have a file (I call it a header) that you include on every single page of the site. If you put that first line of code in the header file, then include it like this on every page:
```
include 'header.php';
```
you won't have to use the global keyword or anything, the second line of code you wr... |
13,021 | <p>I've frequently encountered sites that put all of their JavaScript inside a <code>namespace</code> structure along the lines of:</p>
<pre><code>namespaces = { com : { example: { example.com's data} }
</code></pre>
<p>However, setting this up safely with respect to other namespaced frameworks seems to require a rel... | [
{
"answer_id": 13193,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 5,
"selected": true,
"text": "<p>Javascript doesn't have stand-alone namespaces. It has functions, which can provide scope for resolving names, and objects, whi... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/784/"
] | I've frequently encountered sites that put all of their JavaScript inside a `namespace` structure along the lines of:
```
namespaces = { com : { example: { example.com's data} }
```
However, setting this up safely with respect to other namespaced frameworks seems to require a relatively hefty amount of code (defined... | Javascript doesn't have stand-alone namespaces. It has functions, which can provide scope for resolving names, and objects, which can contribute to the named data accessible in a given scope.
Here's your example, corrected:
```
var namespaces = { com: { example: { /* example.com's data */ } } }
```
This is a varia... |
13,060 | <p>I'm looking for a clear, concise and accurate answer. </p>
<p>Ideally as the actual answer, although links to good explanations welcome.</p>
<p>This also applies to VB.Net, but the keywords are different - <code>ByRef</code> and <code>ByVal</code>.</p>
| [
{
"answer_id": 13061,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 2,
"selected": false,
"text": "<p><code>out</code> means that the parameter will be initialised by the method:</p>\n\n<pre><code>int result; //not initialised\n... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] | I'm looking for a clear, concise and accurate answer.
Ideally as the actual answer, although links to good explanations welcome.
This also applies to VB.Net, but the keywords are different - `ByRef` and `ByVal`. | By default (in C#), passing an object to a function actually passes a copy of the reference to that object. Changing the parameter itself only changes the value in the parameter, and not the variable that was specified.
```
void Test1(string param)
{
param = "new value";
}
string s1 = "initial value";
Test1(s1);
... |
13,109 | <p>In php, I often need to map a variable using an array ... but I can not seem to be able to do this in a one liner. c.f. example:</p>
<pre><code>// the following results in an error:
echo array('a','b','c')[$key];
// this works, using an unnecessary variable:
$variable = array('a','b','c');
echo $variable[$key];
</... | [
{
"answer_id": 13113,
"author": "onnodb",
"author_id": 1037,
"author_profile": "https://Stackoverflow.com/users/1037",
"pm_score": 5,
"selected": true,
"text": "<p>I wouldn't bother about that extra variable, really. If you want, though, you could also remove it from memory after you've ... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1532/"
] | In php, I often need to map a variable using an array ... but I can not seem to be able to do this in a one liner. c.f. example:
```
// the following results in an error:
echo array('a','b','c')[$key];
// this works, using an unnecessary variable:
$variable = array('a','b','c');
echo $variable[$key];
```
This is a ... | I wouldn't bother about that extra variable, really. If you want, though, you could also remove it from memory after you've used it:
```
$variable = array('a','b','c');
echo $variable[$key];
unset($variable);
```
Or, you could write a small function:
```
function indexonce(&$ar, $index) {
return $ar[$index];
}
`... |
13,160 | <p>I've created a webservice and when I want to use its methods I instantiate it in the a procedure, call the method, and I finally I dispose it, however I think also it could be okay to instantiate the webservice in the "private void Main_Load(object sender, EventArgs e)" event.</p>
<p>The thing is that if I do it th... | [
{
"answer_id": 13164,
"author": "Brandon Wood",
"author_id": 423,
"author_profile": "https://Stackoverflow.com/users/423",
"pm_score": 3,
"selected": true,
"text": "<p>It depends on how often you are going to be calling the web service. If you're going to be calling it almost constantly... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1130097/"
] | I've created a webservice and when I want to use its methods I instantiate it in the a procedure, call the method, and I finally I dispose it, however I think also it could be okay to instantiate the webservice in the "private void Main\_Load(object sender, EventArgs e)" event.
The thing is that if I do it the first w... | It depends on how often you are going to be calling the web service. If you're going to be calling it almost constantly, it would probably be better to use method #2. However, if it's not going to be getting called quite so often, you are better off using method #1, and only instantiating it when you need it. |
13,170 | <p>From time to time I get a System.Threading.ThreadStateException when attempting to restart a thread. The code in question is as follows:</p>
<pre><code>// Make sure the thread is done stopping
while (this.mThread.ThreadState == ThreadState.Running)
{
Thread.Sleep(0);
}
// Respawn a thread if the current one is... | [
{
"answer_id": 13207,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 1,
"selected": false,
"text": "<p>A ThreadStateException is thrown because you're trying to start a thread that's not in a startable state. The most lik... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1185/"
] | From time to time I get a System.Threading.ThreadStateException when attempting to restart a thread. The code in question is as follows:
```
// Make sure the thread is done stopping
while (this.mThread.ThreadState == ThreadState.Running)
{
Thread.Sleep(0);
}
// Respawn a thread if the current one is stopped or do... | The problem is that you have code that first checks if it should create a new thread object, and another piece of code that determines wether to start the thread object. Due to race conditions and similar things, your code might end up trying to call .Start on an existing thread object. Considering you don't post the d... |
13,204 | <p>I have a cron job on an Ubuntu Hardy VPS that only half works and I can't work out why. The job is a Ruby script that uses mysqldump to back up a MySQL database used by a Rails application, which is then gzipped and uploaded to a remote server using SFTP.</p>
<p>The gzip file is created and copied successfully but ... | [
{
"answer_id": 13220,
"author": "Judge Maygarden",
"author_id": 1491,
"author_profile": "https://Stackoverflow.com/users/1491",
"pm_score": 3,
"selected": true,
"text": "<p>Are you sure the temporary file is being created correctly when running as a cron job? The working directory for yo... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] | I have a cron job on an Ubuntu Hardy VPS that only half works and I can't work out why. The job is a Ruby script that uses mysqldump to back up a MySQL database used by a Rails application, which is then gzipped and uploaded to a remote server using SFTP.
The gzip file is created and copied successfully but it's alway... | Are you sure the temporary file is being created correctly when running as a cron job? The working directory for your script will either be specified in the HOME environment variable, or the /etc/passwd entry for the user that installed the cron job. If deploy does not have write permissions for the directory in which ... |
13,217 | <p>I am uploading multiple files using the BeginGetRequestStream of HttpWebRequest but I want to update the progress control I have written whilst I post up the data stream. </p>
<p>How should this be done, I have tried calling Dispatch.BeginInvoke (as below) from within the loop that pushes the data into the stream ... | [
{
"answer_id": 16648,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 2,
"selected": true,
"text": "<p>I was going to say that, I didn't think that Silverlight 2's HttpWebRequest supported streaming, because the request dat... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1478/"
] | I am uploading multiple files using the BeginGetRequestStream of HttpWebRequest but I want to update the progress control I have written whilst I post up the data stream.
How should this be done, I have tried calling Dispatch.BeginInvoke (as below) from within the loop that pushes the data into the stream but it lock... | I was going to say that, I didn't think that Silverlight 2's HttpWebRequest supported streaming, because the request data gets buffered into memory entirely. It had been a while since the last time I looked at it though, therefore I went back to see if Beta 2 supported it. Well turns out it does. I am glad I went back ... |
13,225 | <p>I've recently inherited a internationalized and text-heavy Struts 1.1 web application. Many of the JSP files look like:</p>
<pre class="lang-jsp prettyprint-override"><code><p>
<bean:message key="alert" />
</p>
</code></pre>
<p>and the properties files look like:</p>
<pre><code>messages.prop... | [
{
"answer_id": 13239,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps:</p>\n\n<pre><code>#\nalert=Please update your {0}address{1} and {2}contact information{3}.\n</code></pre>\n"
},
... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1557/"
] | I've recently inherited a internationalized and text-heavy Struts 1.1 web application. Many of the JSP files look like:
```jsp
<p>
<bean:message key="alert" />
</p>
```
and the properties files look like:
```
messages.properties
alert=Please update your <a href="/address.do">address</a> and <a href="/contact.do... | >
> Avoid creating links within long
> blocks of text. Prefer shorter text
> that can act as a logically complete
> and independent link.
>
>
>
Generally, it will lead to fewer problems. Sometimes you have to compromise your UI design to accommodate localization; sometimes you need to compromise your localizati... |
13,362 | <p>I've got a div that uses overflow:auto to keep the contents inside the div as it is resized and dragged around the page. I'm using some ajax to retrieve lines of text from the server, then append them to the end of the div, so the content is growing downwards. Every time this happens, I'd like to use JS to scroll th... | [
{
"answer_id": 13365,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 7,
"selected": true,
"text": "<p><code>scrollHeight</code> should be the total height of content. <code>scrollTop</code> specifies the pixel offset into that co... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384/"
] | I've got a div that uses overflow:auto to keep the contents inside the div as it is resized and dragged around the page. I'm using some ajax to retrieve lines of text from the server, then append them to the end of the div, so the content is growing downwards. Every time this happens, I'd like to use JS to scroll the d... | `scrollHeight` should be the total height of content. `scrollTop` specifies the pixel offset into that content to be displayed at the top of the element's client area.
So you really want (still using jQuery):
```
$("#thediv").each( function()
{
// certain browsers have a bug such that scrollHeight is too small
... |
13,396 | <p>I love list comprehensions in Python, because they concisely represent a transformation of a list.</p>
<p>However, in other languages, I frequently find myself writing something along the lines of:</p>
<pre><code>foreach (int x in intArray)
if (x > 3) //generic condition on x
x++
//do other processin... | [
{
"answer_id": 13399,
"author": "jdd",
"author_id": 242853,
"author_profile": "https://Stackoverflow.com/users/242853",
"pm_score": -1,
"selected": false,
"text": "<p>Depends on the language and what you need to do, a \"map\" as it's called in many languages could be what you're looking ... | 2008/08/16 | [
"https://Stackoverflow.com/questions/13396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1266/"
] | I love list comprehensions in Python, because they concisely represent a transformation of a list.
However, in other languages, I frequently find myself writing something along the lines of:
```
foreach (int x in intArray)
if (x > 3) //generic condition on x
x++
//do other processing
```
This example is ... | The increment in the original `foreach` loop will not affect the contents of the array, the only way to do this remains a `for` loop:
```
for(int i = 0; i < intArray.Length; ++i)
{
if(intArray[i] > 3) ++intArray[i];
}
```
Linq is not intended to modify existing collections or sequences. It creates new sequences ... |
13,454 | <p>I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes:</p>
<pre><code>cleaned = stringwithslashes
cleaned = cleaned.replace('\\n', '\n')
cleaned = cleaned.replace('\\r', '\n')
cleaned = cleaned.replace('\\', '')
</code></pre>
<p>How can I condense it? </p>
| [
{
"answer_id": 13456,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 0,
"selected": false,
"text": "<p>You can obviously concatenate everything together:</p>\n\n<pre><code>cleaned = stringwithslashes.replace(\"\\\\n\",\"\... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wrote a piece of code to convert PHP's striplashes into valid Python [backslash] escapes:
```
cleaned = stringwithslashes
cleaned = cleaned.replace('\\n', '\n')
cleaned = cleaned.replace('\\r', '\n')
cleaned = cleaned.replace('\\', '')
```
How can I condense it? | Not totally sure this is what you want, but..
```
cleaned = stringwithslashes.decode('string_escape')
``` |
13,470 | <p>I was reading <a href="https://stackoverflow.com/questions/6173/regular-expression-for-parsing-links-from-a-webpage">this question</a> about how to parse URLs out of web pages and had a question about the <a href="https://stackoverflow.com/questions/6173/regular-expression-for-parsing-links-from-a-webpage#6183">acce... | [
{
"answer_id": 13475,
"author": "Marius",
"author_id": 1585,
"author_profile": "https://Stackoverflow.com/users/1585",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think it has any purpose. But because RegEx is almost impossible to understand/decompose, people rarely point out e... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430/"
] | I was reading [this question](https://stackoverflow.com/questions/6173/regular-expression-for-parsing-links-from-a-webpage) about how to parse URLs out of web pages and had a question about the [accepted answer](https://stackoverflow.com/questions/6173/regular-expression-for-parsing-links-from-a-webpage#6183) which off... | @Jeff Atwood, your interpretation is a little off - the {1} means match exactly once, but has no effect on the "capturing" - the capturing occurs because of the parens - the braces only specify the number of times the pattern must match the source - once, as you say.
I agree with @Marius, even if his answer is a littl... |
13,473 | <p>I would like to sort an array in ascending order using <code>C/C++</code>. The outcome is an array containing element indexes. Each index is corespondent to the element location in the sorted array.</p>
<p><strong>Example</strong></p>
<pre><code>Input: 1, 3, 4, 9, 6
Output: 1, 2, 3, 5, 4
</code></pre>
<p><strong>Ed... | [
{
"answer_id": 13477,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 0,
"selected": false,
"text": "<p>Well, there's a trival n^2 solution.</p>\n\n<p>In python:</p>\n\n<pre><code>newArray = sorted(oldArray)\nblankArray = [0] * ... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/522/"
] | I would like to sort an array in ascending order using `C/C++`. The outcome is an array containing element indexes. Each index is corespondent to the element location in the sorted array.
**Example**
```
Input: 1, 3, 4, 9, 6
Output: 1, 2, 3, 5, 4
```
**Edit:** I am using shell sort procedure. The duplicate value i... | Since you're using C++, I would do it something like this. The `SortIntPointers` function can be any sort algorithm, the important part is that it sorts the array of pointers based on the `int` that they are pointing to. Once that is done, you can go through the array of pointers and assign their sorted index which wil... |
13,540 | <p>I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this:</p>
<pre><code>update myTable set Col1=@col1, Col2=@col2 where ID=@ID
if @@rowcount = 0
insert into myTable (Col1, Col2) values (@col1, @col2)
</code></pre>
<p>My logic behind writing... | [
{
"answer_id": 13554,
"author": "binOr",
"author_id": 990,
"author_profile": "https://Stackoverflow.com/users/990",
"pm_score": 7,
"selected": true,
"text": "<p>Your assumption is right, this is the optimal way to do it and it's called <a href=\"http://en.wikipedia.org/wiki/Upsert\" rel=... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I've written a stored proc that will do an update if a record exists, otherwise it will do an insert. It looks something like this:
```
update myTable set Col1=@col1, Col2=@col2 where ID=@ID
if @@rowcount = 0
insert into myTable (Col1, Col2) values (@col1, @col2)
```
My logic behind writing it in this way is that th... | Your assumption is right, this is the optimal way to do it and it's called [upsert/merge](http://en.wikipedia.org/wiki/Upsert).
[Importance of UPSERT - from sqlservercentral.com](http://www.sqlservercentral.com/articles/T-SQL/61773/):
>
> For every update in the case mentioned above we are removing one
> additiona... |
13,569 | <p>In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.</p>
<p>I prefer PDO for the single reason that it allows named parameters for prepared sta... | [
{
"answer_id": 13571,
"author": "Theo",
"author_id": 1109,
"author_profile": "https://Stackoverflow.com/users/1109",
"pm_score": 6,
"selected": false,
"text": "<p>Moving an application from one database to another isn't very common, but sooner or later you may find yourself working on an... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137/"
] | In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS.
I prefer PDO for the single reason that it allows named parameters for prepared statements, a... | Well, you could argue with the object oriented aspect, the prepared statements, the fact that it becomes a standard, etc. But I know that most of the time, convincing somebody works better with a killer feature. So there it is:
A really nice thing with PDO is you can fetch the data, injecting it automatically in an ob... |
13,578 | <p>The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn't find anything relevant with WMI (although I'm no expert with WMI, so I might have missed something).</p>
<p>Any ideas... | [
{
"answer_id": 13581,
"author": "Michał Piaskowski",
"author_id": 1534,
"author_profile": "https://Stackoverflow.com/users/1534",
"pm_score": 1,
"selected": false,
"text": "<p>In WMI do: \"select * from Win32_Session\"\nthere you'll have \"StartTime\" value.</p>\n\n<p>Hope that helps.</p... | 2008/08/17 | [
"https://Stackoverflow.com/questions/13578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1596/"
] | The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn't find anything relevant with WMI (although I'm no expert with WMI, so I might have missed something).
Any ideas? | For people not familiar with WMI (like me), here are some links:
* MSDN page on using WMI from various languages: <http://msdn.microsoft.com/en-us/library/aa393964(VS.85).aspx>
* reference about Win32\_Session: <http://msdn.microsoft.com/en-us/library/aa394422(VS.85).aspx>, but the objects in Win32\_session are of typ... |