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 |
|---|---|---|---|---|---|---|
350,255 | <p>Heres my link:</p>
<p><a href="http://tinyurl.com/6j727e" rel="noreferrer">http://tinyurl.com/6j727e</a></p>
<p>If you click on the link in test.php, it opens in a modal box which is using the jquery 'facebox' script.</p>
<p>I'm trying to act upon a click event in this box, and if you view source of test.php you'... | [
{
"answer_id": 350289,
"author": "Ryan McGeary",
"author_id": 8985,
"author_profile": "https://Stackoverflow.com/users/8985",
"pm_score": 4,
"selected": true,
"text": "<p>First, the reason you're getting the alert on document load is because the <code>#click</code> method takes a functio... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | Heres my link:
<http://tinyurl.com/6j727e>
If you click on the link in test.php, it opens in a modal box which is using the jquery 'facebox' script.
I'm trying to act upon a click event in this box, and if you view source of test.php you'll see where I'm trying to loacte the link within the modal box.
```
$('#f... | First, the reason you're getting the alert on document load is because the `#click` method takes a function as an argument. Instead, you passed it the return value of `alert`, which immediately shows the alert dialog and returns null.
The reason the event binding isn't working is because at the time of document load, ... |
350,264 | <p>I have an Excel spreadsheet containing a list of strings. Each string is made up of several words, but the number of words in each string is different.</p>
<p>Using built in Excel functions (no VBA), is there a way to isolate the last word in each string?</p>
<p>Examples:</p>
<pre>
Are you classified as human? ... | [
{
"answer_id": 350296,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<pre><code>=RIGHT(A1,LEN(A1)-FIND(\"`*`\",SUBSTITUTE(A1,\" \",\"`*`\",LEN(A1)-LEN(SUBSTITUTE(A1,\" \",\"\"))))) \n</code></pre... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33686/"
] | I have an Excel spreadsheet containing a list of strings. Each string is made up of several words, but the number of words in each string is different.
Using built in Excel functions (no VBA), is there a way to isolate the last word in each string?
Examples:
```
Are you classified as human? -> human?
Negative, I ... | This one is tested and does work (based on Brad's original post):
```
=RIGHT(A1,LEN(A1)-FIND("|",SUBSTITUTE(A1," ","|",
LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))
```
If your original strings could contain a pipe "|" character, then replace both in the above with some other character that won't appear in your source... |
350,278 | <p>I have problem with starting processes in impersonated context in ASP.NET 2.0.</p>
<p>I am starting new Process in my web service code. IIS 5.1, .NET 2.0</p>
<pre><code>[WebMethod]
public string HelloWorld()
{
string path = @"C:\KB\GetWindowUser.exe";
ProcessStartInfo startInfo = new ProcessStartInfo();
... | [
{
"answer_id": 350316,
"author": "nicodemus13",
"author_id": 26463,
"author_profile": "https://Stackoverflow.com/users/26463",
"pm_score": 0,
"selected": false,
"text": "<p>What exactly are you trying to do? I can't quite see what the point of your code is in creating a different execut... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43178/"
] | I have problem with starting processes in impersonated context in ASP.NET 2.0.
I am starting new Process in my web service code. IIS 5.1, .NET 2.0
```
[WebMethod]
public string HelloWorld()
{
string path = @"C:\KB\GetWindowUser.exe";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WorkingDi... | You have to put privileged code into the GAC (or run in Full trust).
The code in the GAC must assert the XXXPermission, where XXX is what ever permission you are requesting, be it impersonation, access to the harddrive or what have you.
You should revert the assert immediately afterwords.
You should make sure that t... |
350,287 | <p>I've made an expose-clone for Vista that sometimes need to restore a minimized window.
I've managed to do this with the SetWindowPlacement function.
The problem is that this also repaints the window which looks like crap after the window nicely has slided into the screen.</p>
<p>This is the code i use to bring a wi... | [
{
"answer_id": 351105,
"author": "atzz",
"author_id": 23252,
"author_profile": "https://Stackoverflow.com/users/23252",
"pm_score": 2,
"selected": false,
"text": "<p>One way to do it is to use double-buffering technique: paint to an off-screen bitmap, then restore, then blit the bitmap t... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've made an expose-clone for Vista that sometimes need to restore a minimized window.
I've managed to do this with the SetWindowPlacement function.
The problem is that this also repaints the window which looks like crap after the window nicely has slided into the screen.
This is the code i use to bring a window to th... | One way to do it is to use double-buffering technique: paint to an off-screen bitmap, then restore, then blit the bitmap to the screen. But it seems like overkill if restoring a minimized window is the only scenario where it's needed. Maybe others will have better ideas?..
Also, if you paint entire window client area,... |
350,292 | <p>Given the following classes and controller action method:</p>
<pre><code>public School
{
public Int32 ID { get; set; }
publig String Name { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Street1 { get; set; }
public string City { get; set; }
public String ZipCod... | [
{
"answer_id": 350300,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 9,
"selected": true,
"text": "<p>From <a href=\"http://groups.google.com/group/jquery-en/browse_thread/thread/ba072168939b245a?pli=1\" rel=\"noreferrer\">Go... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32588/"
] | Given the following classes and controller action method:
```
public School
{
public Int32 ID { get; set; }
publig String Name { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Street1 { get; set; }
public string City { get; set; }
public String ZipCode { get; set; ... | From [Google Groups](http://groups.google.com/group/jquery-en/browse_thread/thread/ba072168939b245a?pli=1):
>
> Use two backslashes before each special character.
>
>
> A backslash in a jQuery selector escapes the next character. But you need
> two of them because backslash is also the escape character for JavaScr... |
350,308 | <p>I'm making a webpage with dynamic content that enters the view with AJAX polling. The page JS occasionally downloads updated information and renders it on the page while the user is reading other information. This sort of thing is costly to bandwidth and processing time. I would like to have the polling pause whe... | [
{
"answer_id": 350317,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>I've looked at that problem before for a research project. At the time (2-3 years ago) I did not find a way to get informat... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36093/"
] | I'm making a webpage with dynamic content that enters the view with AJAX polling. The page JS occasionally downloads updated information and renders it on the page while the user is reading other information. This sort of thing is costly to bandwidth and processing time. I would like to have the polling pause when the ... | Your best solution would be something like this:
```
var inactiveTimer;
var active = true;
function setTimer(){
inactiveTimer = setTimeOut("stopAjaxUpdateFunction()", 120000); //120 seconds
}
setTimer();
document.onmouseover = function() { clearTimeout ( inactiveTimer );
s... |
350,318 | <p>I have a single large table which I would like to optimize.
I'm using MS-SQL 2005 server. I'll try to describe how it is used and if anyone has any suggestions I would appreciate it very much.</p>
<p>The table is about 400GB, has 100 million rows and 1 million rows are inserted each day.
The table has 8 columns, 1 ... | [
{
"answer_id": 350337,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 2,
"selected": false,
"text": "<p>Why have you clustered on the primary key?<br>\nWhich columns can be NULL?<br>\nWhat are the VARCHAR lengths?<br>\nWhat ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34632/"
] | I have a single large table which I would like to optimize.
I'm using MS-SQL 2005 server. I'll try to describe how it is used and if anyone has any suggestions I would appreciate it very much.
The table is about 400GB, has 100 million rows and 1 million rows are inserted each day.
The table has 8 columns, 1 data col a... | As I hinted in a comment, I have done this with a single Oracle table approaching 8 TB consisting of over two billion rows growing at the rate of forty million rows per day. However, in my case, the users were two million (and growing) customers accessing this data over the web, 24x7, and literally ANY of the rows was ... |
350,323 | <p>I have a utility (grep) that gives me a list of filenames and a line numbers. After I have determined that devenv is the correct program to open a file, I would like to ensure that it is opened at the indicated line number. In emacs, this would be:</p>
<pre><code>emacs +140 filename.c
</code></pre>
<p>I have found... | [
{
"answer_id": 350401,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 1,
"selected": true,
"text": "<p>I can't figure out a way to do this with straight command-line options. It looks like you will have to write a macro... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10574/"
] | I have a utility (grep) that gives me a list of filenames and a line numbers. After I have determined that devenv is the correct program to open a file, I would like to ensure that it is opened at the indicated line number. In emacs, this would be:
```
emacs +140 filename.c
```
I have found nothing like this for Vis... | I can't figure out a way to do this with straight command-line options. It looks like you will have to write a macro for it. Supposedly, you can invoke them like so.
```
devenv /command "Macros.MyMacros.Module1.OpenFavoriteFiles"
```
So, you can probably create a macro that takes a filename and a line number, then o... |
350,345 | <p>Is there a way run Emacs from a USB drive? I am a Windows user and I would like to be able use it on any PC without an Emacs install.</p>
| [
{
"answer_id": 350369,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "https://Stackoverflow.com/users/4958",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, the \"normal\" Emacs distribution for Windows is precompiled and just runs without having to do any install. Just... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Is there a way run Emacs from a USB drive? I am a Windows user and I would like to be able use it on any PC without an Emacs install. | Yes, the "normal" Emacs distribution for Windows is precompiled and just runs without having to do any install. Just get [one of the \*.zip files from the usual place](http://ftp.gnu.org/gnu/windows/emacs/), unpack it onto a USB disk, and you can use it directly. (The actual binary is inside the "bin/" directory.)
The... |
350,348 | <p>I have wrist pain when I type and I would like to start writing SQL statements, stored procedure, and views using speech recognition.</p>
| [
{
"answer_id": 350349,
"author": "Keith Walton",
"author_id": 22448,
"author_profile": "https://Stackoverflow.com/users/22448",
"pm_score": 7,
"selected": true,
"text": "<p>Yes. SQL is well-suited to speech recognition (as well-suited as a programming language can be, that is), given it'... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22448/"
] | I have wrist pain when I type and I would like to start writing SQL statements, stored procedure, and views using speech recognition. | Yes. SQL is well-suited to speech recognition (as well-suited as a programming language can be, that is), given it's limited vocabulary and sentence-like structure. Aside from formatting the SQL so that it looks nice, I can dictate it much faster than typing. Dictating code isn't for everyone, however. It can be quite ... |
350,353 | <p>I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider. </p>
<p>I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n ... | [
{
"answer_id": 350435,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 3,
"selected": true,
"text": "<p>Any reason why this wouldn't work?\n<a href=\"http://msdn.microsoft.com/en-us/library/cc440943.aspx\" rel=\"nofollow ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got a project coming up that will involve connecting to one to many backend systems through the same interface; let's call it IBacksideProvider.
I'd like to use Unity to inject these providers at runtime. The problem is that since we're talking about 1...n backend systems, I'd need to register 1...n implementati... | Any reason why this wouldn't work?
<http://msdn.microsoft.com/en-us/library/cc440943.aspx>
>
> To retrieve a list of object instances from the container based on named registrations, use the ResolveAll method and specify a value for the object type (the registration type). The ResolveAll method returns an IEnumerable... |
350,354 | <p>Is there a .NET library I can use to programmatically generate my own GIF images?</p>
<p>At a minimum I'd like to build it pixel-by-pixel. Better would be support for text and shapes.</p>
<p>Here's an example of what I'm trying to do. I mocked this up in Photoshop…</p>
<p><a href="http://img143.imageshac... | [
{
"answer_id": 350382,
"author": "Tundey",
"author_id": 1453,
"author_profile": "https://Stackoverflow.com/users/1453",
"pm_score": 0,
"selected": false,
"text": "<p>Why not use a chart control instead of trying to generate GIFs? Unless the requirements are strictly to generate this part... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | Is there a .NET library I can use to programmatically generate my own GIF images?
At a minimum I'd like to build it pixel-by-pixel. Better would be support for text and shapes.
Here's an example of what I'm trying to do. I mocked this up in Photoshop…
[Number line graphic http://img143.imageshack.us/img143/5458/doll... | ```
Bitmap bmp = new Bitmap(xSize, ySize, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmp)) {
// Use g and/or bmp to set pixels, draw lines, show text, etc...
}
bmp.Save(filename, ImageFormat.Gif);
```
Job done |
350,377 | <p>I have three custom build configurations { Dev, Qs, Prd }. So, I have three app configs { Dev.config, Qs.config, Prd.config }. I know how to edit the .csproj file to output the correct one based on the current build configuration.</p>
<pre><code><Target Name="AfterBuild">
<Delete Files="$(TargetDir)$(Ta... | [
{
"answer_id": 350388,
"author": "Anthony Mastrean",
"author_id": 3619,
"author_profile": "https://Stackoverflow.com/users/3619",
"pm_score": 0,
"selected": false,
"text": "<p>The last solution I would like to employ is to create 6 app configs, 1 per custom configuration </p>\n\n<p>{ <co... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | I have three custom build configurations { Dev, Qs, Prd }. So, I have three app configs { Dev.config, Qs.config, Prd.config }. I know how to edit the .csproj file to output the correct one based on the current build configuration.
```
<Target Name="AfterBuild">
<Delete Files="$(TargetDir)$(TargetFileName).config" /... | Something along the lines of
```
<PropertyGroup Condition="'$(Configuration)'=='Dev_Debug' OR '$(Configuration)'=='Dev_Release'" >
<CfgFileName>Dev</CfgFileName>
</PropertyGroup>
<!-- similar for Qs & Prd -->
<Target ...>...$(CfgFileName).config...
``` |
350,400 | <p>I've got some blank values in my table, and I can't seem to catch them in an IF statement. </p>
<p>I've tried</p>
<p><code>IF @value = ''</code> and <code>if @value = NULL</code> and neither one catches the blank values. Is there any way to test whether or not a varchar is entirely whitespace?</p>
<p>AHA! Turns o... | [
{
"answer_id": 350407,
"author": "Kieveli",
"author_id": 15852,
"author_profile": "https://Stackoverflow.com/users/15852",
"pm_score": 2,
"selected": false,
"text": "<p>if length(@value) = 0 or @value is null </p>\n"
},
{
"answer_id": 350413,
"author": "no_one",
"author... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17917/"
] | I've got some blank values in my table, and I can't seem to catch them in an IF statement.
I've tried
`IF @value = ''` and `if @value = NULL` and neither one catches the blank values. Is there any way to test whether or not a varchar is entirely whitespace?
AHA! Turns out I was testing for null wrong. Thanks. | To compare with NULL, use the IS NULL keyword.
```
--Generic example:
SELECT *
FROM MY_TABLE
WHERE SOME_FIELD IS NULL;
--Instead of
SELECT *
FROM MY_TABLE
WHERE SOME_FIELD = NULL;
``` |
350,453 | <p>I want something similar to the following pseudocode:</p>
<pre><code>myGridView.SelectedIndex = myGridView.DataKeys.IndexOf("mySpecificKey");
</code></pre>
<p>I've done some Intellisense exploring, but I haven't found an obvious way to do this. I would want to set SelectedIndex to -1 if DataKey was not found.</p>... | [
{
"answer_id": 350477,
"author": "Larsenal",
"author_id": 337,
"author_profile": "https://Stackoverflow.com/users/337",
"pm_score": 5,
"selected": true,
"text": "<p>I've ended up with</p>\n\n<pre><code> For n As Integer = 0 To myGridView.DataKeys.Count - 1\n If myGridVi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | I want something similar to the following pseudocode:
```
myGridView.SelectedIndex = myGridView.DataKeys.IndexOf("mySpecificKey");
```
I've done some Intellisense exploring, but I haven't found an obvious way to do this. I would want to set SelectedIndex to -1 if DataKey was not found. | I've ended up with
```
For n As Integer = 0 To myGridView.DataKeys.Count - 1
If myGridView.DataKeys(n).Value = myKeyObj Then
myGridView.SelectedIndex = n
End If
Next
``` |
350,454 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c-sharp">How to properly clean up Excel interop objects in C#</a> </p>
</blockquote>
<p>I've read many of the other threads here about managing COM refer... | [
{
"answer_id": 350535,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 3,
"selected": true,
"text": "<p>I don't have the code to hand, but I did run into a similar problem.\nIf I recall correctly, I ended up retrievi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25571/"
] | >
> **Possible Duplicate:**
>
> [How to properly clean up Excel interop objects in C#](https://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c-sharp)
>
>
>
I've read many of the other threads here about managing COM references while using the .Net-Excel interop to make su... | I don't have the code to hand, but I did run into a similar problem.
If I recall correctly, I ended up retrieving the process id of the excel instance, and killing it (after a suitable wait period, and when the other method failed).
I think I used:
`GetWindowThreadProcessId` (via P/Invoke) on the excel object hwnd pr... |
350,463 | <p>I've got a simple application that shows pictures dragged onto it. I'd like the application to resize itself according to the picture it displays. The code below does just that:</p>
<pre><code>// Load the picture
Bitmap picture = new Bitmap(s);
// Calculate the size of the main form
this.Size = new Size(picture.... | [
{
"answer_id": 350548,
"author": "Eric Rosenberger",
"author_id": 41624,
"author_profile": "https://Stackoverflow.com/users/41624",
"pm_score": 3,
"selected": true,
"text": "<p>You could compute the difference in size between the old picture and the new picture, and then just adjust the ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32836/"
] | I've got a simple application that shows pictures dragged onto it. I'd like the application to resize itself according to the picture it displays. The code below does just that:
```
// Load the picture
Bitmap picture = new Bitmap(s);
// Calculate the size of the main form
this.Size = new Size(picture.Width +
... | You could compute the difference in size between the old picture and the new picture, and then just adjust the size of the form by that amount... as long as all the other stuff on the form stays the same size. |
350,482 | <p>Based on the answers to <a href="https://stackoverflow.com/questions/350081/how-do-i-supply-the-from-clause-of-a-select-statement-from-a-udf-parameter">this question about dynamically accessing tables</a>, I've decided to take a couple steps back and get some advice on the larger picture. </p>
<p>I am revisiting th... | [
{
"answer_id": 350551,
"author": "Cristian Vat",
"author_id": 20109,
"author_profile": "https://Stackoverflow.com/users/20109",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://rails-analyzer.rubyforge.org/\" rel=\"nofollow noreferrer\">http://rails-analyzer.rubyforge.org/<... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26140/"
] | Based on the answers to [this question about dynamically accessing tables](https://stackoverflow.com/questions/350081/how-do-i-supply-the-from-clause-of-a-select-statement-from-a-udf-parameter), I've decided to take a couple steps back and get some advice on the larger picture.
I am revisiting the database design of ... | [New Relic](http://www.newrelic.com/ruby) offers Rails profiling including a [free 'Lite'](http://www.newrelic.com/ruby) version. |
350,500 | <p>I did not find the TryParse method for the Guid. I’m wondering how others handle converting a guid in string format into a guid type.</p>
<pre><code>Guid Id;
try
{
Id = new Guid(Request.QueryString["id"]);
}
catch
{
Id = Guid.Empty;
}
</code></pre>
| [
{
"answer_id": 350504,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 9,
"selected": false,
"text": "<pre><code>new Guid(string)\n</code></pre>\n\n<p>You could also look at using a <code>TypeConverter</code>.</p>\n"
},
{... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19216/"
] | I did not find the TryParse method for the Guid. I’m wondering how others handle converting a guid in string format into a guid type.
```
Guid Id;
try
{
Id = new Guid(Request.QueryString["id"]);
}
catch
{
Id = Guid.Empty;
}
``` | ```
new Guid(string)
```
You could also look at using a `TypeConverter`. |
350,502 | <p>If an object has a property that is a collection, should the object create the collection object or make a consumer check for null? I know the consumer should not assume, just wondering if most people create the collection object if it is never added to.</p>
| [
{
"answer_id": 350512,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 1,
"selected": false,
"text": "<p>I create an empty collection. Sure, it has a slight memory cost, but not a large enough one to be concerned about it... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11907/"
] | If an object has a property that is a collection, should the object create the collection object or make a consumer check for null? I know the consumer should not assume, just wondering if most people create the collection object if it is never added to. | You can also use the "Lazy initailizer" pattern where the collection is not initialized until (and unless) someone accesses the property getter for it... This avoids the overhead of creating it in those cases where the parent object is instantiated for some other purpose that does not require the collection...
```
... |
350,507 | <p>I noticed that I can start a program with it's associated handler by writing <strong>start filename</strong>. However, for some files, all I get is a console, and I don't know why. I'm trying to populate a list control in MFC, and I want to have the program and it's associated handler to run when I double click the ... | [
{
"answer_id": 350530,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 1,
"selected": false,
"text": "<p>I believe start uses the file handler associated with the file's extension.</p>\n\n<p>Basically it will use the fil... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | I noticed that I can start a program with it's associated handler by writing **start filename**. However, for some files, all I get is a console, and I don't know why. I'm trying to populate a list control in MFC, and I want to have the program and it's associated handler to run when I double click the selection. Is th... | If the first parameter on the `start` command line is enclosed in double-quotes, it uses that as the window title instead of the command. It's lame, but that's what it does...
Try
```
string st = string("start \"\" \"")+std_str+string("\"");
```
instead.
But if you're trying to get the shell handler for a file to ... |
350,519 | <p>I need to get the lesser n numbers of a list in Python. I need this to be really fast because it's in a critical part for performance and it needs to be repeated a lot of times.</p>
<p>n is usually no greater than 10 and the list usually has around 20000 elements. The list is always different each time I call the f... | [
{
"answer_id": 350568,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 5,
"selected": true,
"text": "<p>You actually want a sorted sequence of mins.</p>\n\n<pre><code>mins = items[:n]\nmins.sort()\nfor i in items[n:]:\n if... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23657/"
] | I need to get the lesser n numbers of a list in Python. I need this to be really fast because it's in a critical part for performance and it needs to be repeated a lot of times.
n is usually no greater than 10 and the list usually has around 20000 elements. The list is always different each time I call the function. S... | You actually want a sorted sequence of mins.
```
mins = items[:n]
mins.sort()
for i in items[n:]:
if i < mins[-1]:
mins.append(i)
mins.sort()
mins= mins[:n]
```
This runs *much* faster because you aren't even looking at mins unless it's provably got a value larger than the given item. Ab... |
350,526 | <p>Every now and then, I accidentally hit C-x C-c in Emacs when I'm intending to just hit C-x or C-c. This, of course, closes all open frames and buffers with no confirmation. I know that I can make Emacs prompt "Are you sure you want to exit?", but I don't want to do that all the time, which would get annoying. I just... | [
{
"answer_id": 350607,
"author": "JasonFruit",
"author_id": 21778,
"author_profile": "https://Stackoverflow.com/users/21778",
"pm_score": 3,
"selected": false,
"text": "<p>This is what I use:</p>\n\n<pre><code>(defun count-buffers (&optional display-anyway)\n \"Display or return the... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Every now and then, I accidentally hit C-x C-c in Emacs when I'm intending to just hit C-x or C-c. This, of course, closes all open frames and buffers with no confirmation. I know that I can make Emacs prompt "Are you sure you want to exit?", but I don't want to do that all the time, which would get annoying. I just wa... | This is what I use:
```
(defun count-buffers (&optional display-anyway)
"Display or return the number of buffers."
(interactive)
(let ((buf-count (length (buffer-list))))
(if (or (interactive-p) display-anyway)
(message "%d buffers in this Emacs" buf-count)) buf-count))
```
I stole it ~~, but can't rem... |
350,587 | <p>In Access, I have a table like this one:</p>
<pre><code>Date | EmployeeNum | Award
11-JAN-08 | 34 | GoldStar
13-JAN-08 | 875 | BronzeTrophy
13-JAN-08 | 34 | BronzeTrophy
18-JAN-08 | 875 | BronzeTrophy
</code></pre>
<p>And I want to have a table count them like this:</p>
<pre... | [
{
"answer_id": 350625,
"author": "Birger",
"author_id": 11485,
"author_profile": "https://Stackoverflow.com/users/11485",
"pm_score": 2,
"selected": false,
"text": "<p>You will need a crosstab (aka pivot) query for that. Try the following SQL and modify to suit your needs:</p>\n\n<pre><c... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In Access, I have a table like this one:
```
Date | EmployeeNum | Award
11-JAN-08 | 34 | GoldStar
13-JAN-08 | 875 | BronzeTrophy
13-JAN-08 | 34 | BronzeTrophy
18-JAN-08 | 875 | BronzeTrophy
```
And I want to have a table count them like this:
```
EmployeeNum | GoldStar | Bronz... | You will need a crosstab (aka pivot) query for that. Try the following SQL and modify to suit your needs:
```
TRANSFORM Count(MyTable.EmployeeNum) AS AantalVanEmployeeNum
SELECT MyTable.EmployeeNum
FROM MyTable
GROUP BY MyTable.EmployeeNum
PIVOT MyTable.Award;
``` |
350,600 | <p>How do you add a new variable to be inserted into a Java code template. How do I add a variable to the list in Window->Preferences->Java->Code Style->Code Templates->Code->New Java Files->Edit->Insert Variable... ?</p>
<p>Currently my new files get created with:</p>
<pre><code>${filecomment}
${package_declaration}... | [
{
"answer_id": 350609,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 4,
"selected": true,
"text": "<p>I'm pretty sure that the list of \"variables\" is generated by Eclipse and there is no way to add a new template variable.<... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18995/"
] | How do you add a new variable to be inserted into a Java code template. How do I add a variable to the list in Window->Preferences->Java->Code Style->Code Templates->Code->New Java Files->Edit->Insert Variable... ?
Currently my new files get created with:
```
${filecomment}
${package_declaration}
${typecomment}
${typ... | I'm pretty sure that the list of "variables" is generated by Eclipse and there is no way to add a new template variable.
What do you want `${begin_filecomment}` and `${end_filecomment}` to be? Just type the content into the Edit box - there is nothing that says you cannot put static content in there. |
350,608 | <p>I have a database with 2 tables.</p>
<p>One of the tables holds a row containing numbers, from 0 to 10.</p>
<p>In PHP, I do this: </p>
<pre><code>$query = "SELECT ".$param." FROM issues WHERE ".$param." >=0";
$result = @mysql_query($query) or showError("query failed");
if (!($record = mysql_fetch_array($resul... | [
{
"answer_id": 350630,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not exactly sure what you are trying to achieve here, but I think what you want is:</p>\n\n<pre><code>// qu... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I have a database with 2 tables.
One of the tables holds a row containing numbers, from 0 to 10.
In PHP, I do this:
```
$query = "SELECT ".$param." FROM issues WHERE ".$param." >=0";
$result = @mysql_query($query) or showError("query failed");
if (!($record = mysql_fetch_array($result))) return null;
return $record... | I'm not exactly sure what you are trying to achieve here, but I think what you want is:
```
// query...
$records = array();
while($r = mysql_fetch_array($result)) {
$records[] = $r;
}
return $records;
``` |
350,611 | <p>I'm using Eclipse as an IDE for Ruby/Rails development (using Aptana plugin). I have one very, very large file that encompasses an initial data load of several thousand rows of data. When this file is open, everything grinds to a halt (on both Windows and Linux), presumably because Eclipse is tied up trying to parse... | [
{
"answer_id": 350630,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not exactly sure what you are trying to achieve here, but I think what you want is:</p>\n\n<pre><code>// qu... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9550/"
] | I'm using Eclipse as an IDE for Ruby/Rails development (using Aptana plugin). I have one very, very large file that encompasses an initial data load of several thousand rows of data. When this file is open, everything grinds to a halt (on both Windows and Linux), presumably because Eclipse is tied up trying to parse an... | I'm not exactly sure what you are trying to achieve here, but I think what you want is:
```
// query...
$records = array();
while($r = mysql_fetch_array($result)) {
$records[] = $r;
}
return $records;
``` |
350,617 | <p>In my database schema I have an entity that is identified. The identifier can be reused and thus there is a one-to-many relation with the entity. Example: A person can have a nickname. Nicknames are not unique and can be shared amongst many people. So the schema might look like:</p>
<pre><code>PERSON
id
name
nickna... | [
{
"answer_id": 350670,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure if an ORM can handle this, but in straight SQL you could:</p>\n\n<ol>\n<li>Create a table of name/nickname ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | In my database schema I have an entity that is identified. The identifier can be reused and thus there is a one-to-many relation with the entity. Example: A person can have a nickname. Nicknames are not unique and can be shared amongst many people. So the schema might look like:
```
PERSON
id
name
nickname_id
NICKNAM... | I'm not sure if an ORM can handle this, but in straight SQL you could:
1. Create a table of name/nickname pairs,
2. INSERT INTO NicknameTable SELECT Nickname FROM temp WHERE Nickname NOT IN (SELECT Nickname FROM NicknameTable)
3. Insert into main table knowing the Nickname exists.
In your example, you can just have a... |
350,620 | <p>I need to grep for lines with bunch of names, say <code>clientLogin=a@yahoo.com</code>, <code>clientLogin=b@gmail.com</code> from a file.txt.</p>
<p>file.txt has junk which is <code>email=a@yahoo.com email=b@gmail.com</code>. I need to filter these out</p>
<p>Once I get these lines I need to grep for gmail and yah... | [
{
"answer_id": 350687,
"author": "Rob Hruska",
"author_id": 29995,
"author_profile": "https://Stackoverflow.com/users/29995",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure you need the 'sh' and '-c'. I was able to get this to work:</p>\n\n<pre><code>def client = 'foo@bar.com... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37870/"
] | I need to grep for lines with bunch of names, say `clientLogin=a@yahoo.com`, `clientLogin=b@gmail.com` from a file.txt.
file.txt has junk which is `email=a@yahoo.com email=b@gmail.com`. I need to filter these out
Once I get these lines I need to grep for gmail and yahoo and get their counts
```
List l = new ArrayLis... | You're already using groovy, does using a regular expression that gives you your answer work?
```
def file = new File("file.txt")
file.delete() // clear out old version for multiple runs
file << """
foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
foobar email=a@yahoo.com baz quux
foobar email... |
350,628 | <p>I use a console application to write some test code:</p>
<pre><code> /// <summary>
/// Returns AD information for a specified userID.
/// </summary>
/// <param name="ntID"></param>
/// <returns></returns>
public ADUser GetUser(string ntID)
{ ... | [
{
"answer_id": 350687,
"author": "Rob Hruska",
"author_id": 29995,
"author_profile": "https://Stackoverflow.com/users/29995",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure you need the 'sh' and '-c'. I was able to get this to work:</p>\n\n<pre><code>def client = 'foo@bar.com... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I use a console application to write some test code:
```
/// <summary>
/// Returns AD information for a specified userID.
/// </summary>
/// <param name="ntID"></param>
/// <returns></returns>
public ADUser GetUser(string ntID)
{
DirectorySearcher search = new DirectoryS... | You're already using groovy, does using a regular expression that gives you your answer work?
```
def file = new File("file.txt")
file.delete() // clear out old version for multiple runs
file << """
foobar clientLogin=a@yahoo.com baz quux # should match a@yahoo.com
foobar email=a@yahoo.com baz quux
foobar email... |
350,639 | <p>Let me describe the problem in details:</p>
<p>I want to show an absolute positioned div when hovering over an element. That's really simple with jQuery and works just fine. But when the mouse goes over one of the child elements, it triggers the mouseout event of the containing div. How do I keep javascript from tr... | [
{
"answer_id": 350740,
"author": "Ryan McGeary",
"author_id": 8985,
"author_profile": "https://Stackoverflow.com/users/8985",
"pm_score": 4,
"selected": false,
"text": "<p>For simplicity sake, I would just reorganize the html a bit to put the newly displayed content inside the element th... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2172/"
] | Let me describe the problem in details:
I want to show an absolute positioned div when hovering over an element. That's really simple with jQuery and works just fine. But when the mouse goes over one of the child elements, it triggers the mouseout event of the containing div. How do I keep javascript from triggering t... | The question is a bit old, but I ran into this the other day.
The simplest way to do this with recent versions of jQuery is to use the `mouseenter` and `mouseleave` events rather than `mouseover` and `mouseout`.
You can test the behavior quickly with:
```
$(".myClass").on( {
'mouseenter':function() { console.log(... |
350,641 | <p>I need some help with XSLT syntax. Here is my scenario, I have an XML file that needs to be transformed in to a different look and feel of XML file, I have several sections where if particular node set don't contain any value the whole section shouldn't be processed.</p>
<p>Here is an example of XML:</p>
<pre><cod... | [
{
"answer_id": 350748,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 4,
"selected": false,
"text": "<p>You are trying to match xml elements with names \"Level1\", \"Level2\", etc... that don't exist in the document. ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41508/"
] | I need some help with XSLT syntax. Here is my scenario, I have an XML file that needs to be transformed in to a different look and feel of XML file, I have several sections where if particular node set don't contain any value the whole section shouldn't be processed.
Here is an example of XML:
```
<Dates>
<Date>
... | You are trying to match xml elements with names "Level1", "Level2", etc... that don't exist in the document. Then, you are looking for a VALUE1 attribute on the last element.
I *think* you want something like this:
```
<xsl:for-each select="Dates">
<MyDates>
<xsl:for-each select="Date">
<xsl:if te... |
350,645 | <p>Couldn't think of an intuitive way to paraphrase the topic for this question, and I apologize for that. My question is the following:</p>
<p>I have several UIViewController's which need to call in a UIDatePicker. I didn't want to subclass the Date Picker several times as it's the same interface. The problem I'm hav... | [
{
"answer_id": 350689,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 0,
"selected": false,
"text": "<p>You can have a \"base\" view controller, BaseViewController for example. This controller would have any datepicker speci... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | Couldn't think of an intuitive way to paraphrase the topic for this question, and I apologize for that. My question is the following:
I have several UIViewController's which need to call in a UIDatePicker. I didn't want to subclass the Date Picker several times as it's the same interface. The problem I'm having is fig... | It's not obvious from the question if you're creating a custom UIDatePicker subclass, or if you are just implementing UIDatePicker delegate methods in several different custom UIViewController subclasses.
In either case, I think some combination of a delegate and a protocol is what you're looking for.
>
> The paren... |
350,647 | <p>The function below takes a python file handle, reads in packed binary data from the file, creates a Python dictionary and returns it. If I loop it endlessly, it'll continually consume RAM. What's wrong with my RefCounting?</p>
<pre><code>static PyObject* __binParse_getDBHeader(PyObject *self, PyObject *args){
Py... | [
{
"answer_id": 350695,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 5,
"selected": true,
"text": "<p><code>PyDict_New()</code> returns a new reference, check the <a href=\"http://docs.python.org/c-api/dict.html\" rel=... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16363/"
] | The function below takes a python file handle, reads in packed binary data from the file, creates a Python dictionary and returns it. If I loop it endlessly, it'll continually consume RAM. What's wrong with my RefCounting?
```
static PyObject* __binParse_getDBHeader(PyObject *self, PyObject *args){
PyObject *o; //gen... | `PyDict_New()` returns a new reference, check the [docs](http://docs.python.org/c-api/dict.html) for `PyDict`. So if you increase the refcount immediately after creating it, you have two references to it. One is transferred to the caller when you return it as a result value, but the other one never goes aways.
You als... |
350,651 | <p>Treating my repository as a SVN repo, I get:</p>
<pre><code>svn co http://myrepo/foo/trunk foo
...
foo/
bar/
baz/ -> http://myrepo/baz/trunk
</code></pre>
<p>Treating it as a Git repo, I get:</p>
<pre><code>git svn clone http://myrepo/foo --trunk=trunk --branches=branches --tags=tags
...
foo/
bar/
</code... | [
{
"answer_id": 350982,
"author": "Paul",
"author_id": 23356,
"author_profile": "https://Stackoverflow.com/users/23356",
"pm_score": 5,
"selected": false,
"text": "<p>The best means of integrating svn externals with git-svn that I've seen is this <a href=\"http://github.com/andrep/git-svn... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | Treating my repository as a SVN repo, I get:
```
svn co http://myrepo/foo/trunk foo
...
foo/
bar/
baz/ -> http://myrepo/baz/trunk
```
Treating it as a Git repo, I get:
```
git svn clone http://myrepo/foo --trunk=trunk --branches=branches --tags=tags
...
foo/
bar/
```
I can clone baz to my local machine else... | The solution I ended up using was just to symlink to other `git-svn` clones on my local box. This worked pretty well: it allows me to commit changes back, and it allows me to make local changes on project A just to get them into project B. |
350,661 | <p>I haven't used vim in a Unix system in a while, but as I recall there was no \r, it was always \n.</p>
<p>I'm using gVim under windows and when I <i>search</i> for new line characters I use \n. Searching for \r returns nothing. But when I <i>replace</i> the characters I have to use \r's. \n's give me ^@</p>
<p>Can... | [
{
"answer_id": 350688,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 2,
"selected": false,
"text": "<p>Under unix, inside vim, <code>^V</code> + <code><enter></code> gives me a <code>^M</code> which is the <code>\\r</cod... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23829/"
] | I haven't used vim in a Unix system in a while, but as I recall there was no \r, it was always \n.
I'm using gVim under windows and when I *search* for new line characters I use \n. Searching for \r returns nothing. But when I *replace* the characters I have to use \r's. \n's give me ^@
Can anyone explain what's goin... | Lookup up:
```
:set fileformat=unix
:set fileformat=dos
```
This can be used on either platform to switch to the other encoding. |
350,697 | <p>I have some old databases i was handed that use SQL Server 2000 and they are getting SQL Injected with javascript script tags at the end of certain database fields. I need a trigger to strip out the injected on update until I have time to fix the front end that is allowing this. </p>
<p>I am a SQL Server novice ... | [
{
"answer_id": 350708,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>something like:</p>\n\n<p>UPDATE table<br>\nSET field = REPLACE(field, '</script>', REPLACE(field, '<script>... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] | I have some old databases i was handed that use SQL Server 2000 and they are getting SQL Injected with javascript script tags at the end of certain database fields. I need a trigger to strip out the injected on update until I have time to fix the front end that is allowing this.
I am a SQL Server novice - please help... | I think a constraint would be better. Anything that has compromised content would be better rejected.
Set up a constraint on the field something like
```
CHARINDEX('<script>',[fieldname]) = 0
``` |
350,701 | <p>I need to find a faster way to number lines in a file in a specific way using tools like awk and sed. I need the first character on each line to be numbered in this fashion: 1,2,3,1,2,3,1,2,3 etc.</p>
<p>For example, if the input was this:</p>
<pre><code>line 1
line 2
line 3
line 4
line 5
line 6
line 7
</code></p... | [
{
"answer_id": 350711,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 2,
"selected": false,
"text": "<p>Perl comes to mind:</p>\n\n<pre><code>perl -pe '$_ = (($.-1)%3)+1 . $_'\n</code></pre>\n\n<p>should work. No doubt the... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678/"
] | I need to find a faster way to number lines in a file in a specific way using tools like awk and sed. I need the first character on each line to be numbered in this fashion: 1,2,3,1,2,3,1,2,3 etc.
For example, if the input was this:
```
line 1
line 2
line 3
line 4
line 5
line 6
line 7
```
The output needs to look l... | It's slow because you are reading the same lines over and over. Also, you are starting up an `awk` process only to shut it down and start another one. Better to do the whole thing in one shot:
```
awk '{print ((NR-1)%3)+1 $0}' $1 > data.out
```
If you prefer to have a space after the number:
```
awk '{print ((NR-1)... |
350,753 | <p>I'd like to see a series of diffs for a file. I'd settle for simply the log listing restricted to only those entries that modified the file.</p>
| [
{
"answer_id": 350769,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<p><code>git log [filename]</code>. If you want to see what changed, <code>git log -p [filename]</code>.</p>\n"
},
{
"... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'd like to see a series of diffs for a file. I'd settle for simply the log listing restricted to only those entries that modified the file. | `svn log filename`
or
```
svn log URL
```
I also recommend adding `--limit N` to show only recent entries:
```
svn log main.cpp --limit 4
```
These can be applied to a file or project, BTW. |
350,780 | <p>I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION can be either 'login' or 'logout'. Only around 20% of the logins have an accompanying logout row. For those that do, I want to calculate the average duration.</p>
<p>I'm thinking of something like</p>
<pre><code>select avg(LL2.TIME... | [
{
"answer_id": 350791,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": 0,
"selected": false,
"text": "<p>Do you have a SessionManager type object that can timeout sessions? Because a timeout could be logged there, and you cou... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39092/"
] | I have a MySQL table LOGIN\_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION can be either 'login' or 'logout'. Only around 20% of the logins have an accompanying logout row. For those that do, I want to calculate the average duration.
I'm thinking of something like
```
select avg(LL2.TIMESTAMP - LL1.TIMESTAM... | Given the data you have, there probably isn't anything much faster you can do because you have to look at a LOGIN and a LOGOUT record, and ensure there is no other LOGIN (or LOGOUT?) record for the same user between the two.
Alternatively, find a way to ensure that a disconnect records a logout, so that the data is co... |
350,787 | <p>I have a stored procedure that needs to convert hexadecimal numbers to their decimal equivalent. I've read the documentation for the UNHEX() function, but it is returning a binary value. What I'm wanting to do is something like this:</p>
<pre><code>CREATE PROCEDURE foo( hex_val VARCHAR(10) )
BEGIN
DECLARE dec... | [
{
"answer_id": 350804,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 3,
"selected": false,
"text": "<pre><code>conv(hex_val, 16, 10)\n</code></pre>\n\n<p>Will convert a number of base 16 to base 10. The UNHEX functi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31319/"
] | I have a stored procedure that needs to convert hexadecimal numbers to their decimal equivalent. I've read the documentation for the UNHEX() function, but it is returning a binary value. What I'm wanting to do is something like this:
```
CREATE PROCEDURE foo( hex_val VARCHAR(10) )
BEGIN
DECLARE dec_val INTEGER;
... | You can use the [`CONV()`](http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_conv) function to convert between bases.
```
SET dec_val = CONV(hex_val, 16, 10);
``` |
350,794 | <p>I have a file upload form that is being posted back to a servlet (using multipart/form-data encoding). In the servlet, I am trying to use Apache Commons to handle the upload. However, I also have some other fields in the form that are just plain fields. How can I read those parameters from the request?</p>
<p>F... | [
{
"answer_id": 350801,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>Did you try request.getParam() yet?</p>\n"
},
{
"answer_id": 350857,
"author": "stian",
"author_id": 17542... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | I have a file upload form that is being posted back to a servlet (using multipart/form-data encoding). In the servlet, I am trying to use Apache Commons to handle the upload. However, I also have some other fields in the form that are just plain fields. How can I read those parameters from the request?
For example, in... | You could try something like this:
```
while (items.hasNext()) {
FileItem thisItem = (FileItem) items.next();
if (thisItem.isFormField()) {
if (thisItem.getFieldName().equals("somefieldname") {
String value = thisItem.getString();
// Do something with the val... |
350,799 | <p>If I have a Django form such as:</p>
<pre><code>class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
</code></pre>
<p>And I call the as_table() method of an instance of this form, Django will render the fields as the same order... | [
{
"answer_id": 350817,
"author": "Sam Corder",
"author_id": 2351,
"author_profile": "https://Stackoverflow.com/users/2351",
"pm_score": 0,
"selected": false,
"text": "<p>It has to do with the meta class that is used in defining the form class. I think it keeps an internal list of the fi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | If I have a Django form such as:
```
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
```
And I call the as\_table() method of an instance of this form, Django will render the fields as the same order as specified above.
My ... | I went ahead and answered my own question. Here's the answer for future reference:
In Django `form.py` does some dark magic using the `__new__` method to load your class variables ultimately into `self.fields` in the order defined in the class. `self.fields` is a Django `SortedDict` instance (defined in `datastructure... |
350,811 | <p>Is there an equivalent to the Java File method <strong>isDirectory()</strong> in MFC? I tried using this :</p>
<pre><code>
static bool isDirectory(CString &path) {
return GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY;
}
</code></pre>
<p>but it doesn't seem to work.</p>
| [
{
"answer_id": 350826,
"author": "Byron Whitlock",
"author_id": 42304,
"author_profile": "https://Stackoverflow.com/users/42304",
"pm_score": 2,
"selected": false,
"text": "<h1>CFileFind::IsDirectory()</h1>\n<p><a href=\"http://msdn.microsoft.com/en-us/library/scx99850(VS.80).aspx\" rel=... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | Is there an equivalent to the Java File method **isDirectory()** in MFC? I tried using this :
```
static bool isDirectory(CString &path) {
return GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY;
}
```
but it doesn't seem to work. | Sorry for possibly "inconsistency" of answer to question but may be you'll see it useful because anytime I need something like this in Windows I am NOT using MFC but regular Windows API:
```
//not completely tested but after some debug I'm sure it'll work
bool IsDirectory(LPCTSTR sDirName)
{
//First define specia... |
350,819 | <p>Is it possible to using "paging" functionality in Linq queries? Let's say I have some XML like this:</p>
<pre><code><Root>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">Choice One</Choice>
<Choice id="choice2">... | [
{
"answer_id": 350834,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 2,
"selected": false,
"text": "<pre><code>var pagedData = aDataSource.Skip(20).Take(10);\n</code></pre>\n\n<p>That way, you are skipping 20 element... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | Is it possible to using "paging" functionality in Linq queries? Let's say I have some XML like this:
```
<Root>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">Choice One</Choice>
<Choice id="choice2">Choice Two</Choice>
<Choice id="choice3">... | ```
var q = from X in Choices.Skip((page-1)*pageSize).Take(pageSize)
select X;
```
Now, if you need a where clause in it, it gets a bit trickier:
```
var q = (from X in Choices
where x.SomeField == SomeValue
select X).Skip((page-1)*pageSize).Take(pageSize);
``` |
350,848 | <p>Is it possible to save an integer array using NSUserDefaults on the iPhone? I have an array declared in my .h file as: <code>int playfield[9][11]</code> that gets filled with integers from a file and determines the layout of a game playfield. I want to be able to have several save slots where users can save their ... | [
{
"answer_id": 350906,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 2,
"selected": false,
"text": "<p>You'll have to convert this to an object. You can use NSArray or NSDictionary.</p>\n"
},
{
"answer_id": 350943,
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] | Is it possible to save an integer array using NSUserDefaults on the iPhone? I have an array declared in my .h file as: `int playfield[9][11]` that gets filled with integers from a file and determines the layout of a game playfield. I want to be able to have several save slots where users can save their games. If I do:
... | You can save and retrieve the array with a NSData wrapper
ie (w/o error handling)
Save
```
NSData *data = [NSData dataWithBytes:&playfield length:sizeof(playfield)];
[prefs setObject:data forKey:@"slot1Save"];
```
Load
```
NSData *data = [prefs objectForKey:@"slot1Save"];
memcpy(&playfield, data.bytes, data.lengt... |
350,858 | <p>using ASP.NET I need to update an excel template.</p>
<p>Our server is running Windows 2008 in 64 bit mode.</p>
<p>I am using the following code to access the excel file:</p>
<pre><code> ...
string connection =
@"Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ=" + path + ";";
...
</code><... | [
{
"answer_id": 660165,
"author": "Robert Jeppesen",
"author_id": 9436,
"author_profile": "https://Stackoverflow.com/users/9436",
"pm_score": 0,
"selected": false,
"text": "<p>There are no office drivers for 64bit released. </p>\n\n<p>The (currently) last post at this link:\n<a href=\"htt... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15683/"
] | using ASP.NET I need to update an excel template.
Our server is running Windows 2008 in 64 bit mode.
I am using the following code to access the excel file:
```
...
string connection =
@"Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)};DBQ=" + path + ";";
...
```
IF the application pool is set... | The Microsoft Office team has just **released** a **[64-bit driver](http://www.microsoft.com/downloads/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en)** |
350,860 | <p>I have a table where I'm recording if a user has viewed an object at least once, hence:</p>
<pre><code> HasViewed
ObjectID number (FK to Object table)
UserId number (FK to Users table)
</code></pre>
<p>Both fields are NOT NULL and together form the Primary Key.</p>
<p>My question is, since I don't c... | [
{
"answer_id": 350908,
"author": "kurosch",
"author_id": 30153,
"author_profile": "https://Stackoverflow.com/users/30153",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think there is a downside to your second option. I think it's a perfectly valid use of the named exception, pl... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12725/"
] | I have a table where I'm recording if a user has viewed an object at least once, hence:
```
HasViewed
ObjectID number (FK to Object table)
UserId number (FK to Users table)
```
Both fields are NOT NULL and together form the Primary Key.
My question is, since I don't care how many times someone has vi... | I would normally just insert and trap the DUP\_VAL\_ON\_INDEX exception, as this is the simplest to code. This is more efficient than checking for existence before inserting. I don't consider doing this a "bad smell" (horrible phrase!) because the exception we handle is raised by Oracle - it's not like raising your own... |
350,863 | <p>I have the following XAML code:</p>
<pre><code><Window x:Class="RichText_Wrapping.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1">
<Grid>
<RichTextBox Height="100" Margin="2" Name="richTextBox1">
... | [
{
"answer_id": 351026,
"author": "Artur Carvalho",
"author_id": 1013,
"author_profile": "https://Stackoverflow.com/users/1013",
"pm_score": 2,
"selected": false,
"text": "<p>I copy pasted your code and its not in a single column, Do you have a width somewhere that is small? Maybe defined... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42366/"
] | I have the following XAML code:
```
<Window x:Class="RichText_Wrapping.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1">
<Grid>
<RichTextBox Height="100" Margin="2" Name="richTextBox1">
<FlowDocument>
... | Try binding the FlowDocument's width (one way) to the width of the container RichTextBox.
Worked for me... |
350,868 | <p>I have an issue where when a <code>textField</code> is clicked on in a <code>UITableViewCell</code>, the method <code>tableView:didSelectRowAtIndexPath:</code> does not get invoked. The problem is, I need to scroll my <code>tableView</code> into proper position, otherwise the keyboard goes right over the first respo... | [
{
"answer_id": 350925,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 3,
"selected": false,
"text": "<p>You can set your controller as the delegate of your UITextField, then adjust your table view in either <code>textFieldDi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I have an issue where when a `textField` is clicked on in a `UITableViewCell`, the method `tableView:didSelectRowAtIndexPath:` does not get invoked. The problem is, I need to scroll my `tableView` into proper position, otherwise the keyboard goes right over the first responder.
I have to then move code like this:
```... | I found the following works well (It assumes you're in a table view controller)
```
- (void)textFieldDidBeginEditing:(UITextField *)textField{
CGPoint pnt = [self.tableView convertPoint:textField.bounds.origin fromView:textField];
NSIndexPath* path = [self.tableView indexPathForRowAtPoint:pnt];
[self.tab... |
350,885 | <p>What is the least amount of code you can write to create, sort (ascending), and print a list of 100 random positive integers? By least amount of code I mean characters contained in the entire source file, so get to minifying.</p>
<p>I'm interested in seeing the answers using any and all programming languages. Let'... | [
{
"answer_id": 350903,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 1,
"selected": false,
"text": "<p>C#:</p>\n\n<pre><code>using System;\nusing System.Collections.Generic;\n\nclass App\n{\n static void Main()\n {\n Li... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18941/"
] | What is the least amount of code you can write to create, sort (ascending), and print a list of 100 random positive integers? By least amount of code I mean characters contained in the entire source file, so get to minifying.
I'm interested in seeing the answers using any and all programming languages. Let's try to ke... | 10 characters in J:
```
/:~100?9e9
```
explanation:
`/:~` sorts an array (technically, applies a lists sorted permutation vector to itself)
`x ? limit` returns x random numbers less than limit
`9e9` (9000000000) is a reasonable upper limit expressible in 3 characters. !9 (9 factorial) is smaller, but requires one... |
350,901 | <p>I am working on a web application that allows users to upload attachments. These attachments are stored on a different drive than that of the web application. How can I create an alias (equivalent to Apache HTTP server's aliases) to this drive so that users can download these attachments?</p>
<p>Currently I am cr... | [
{
"answer_id": 352716,
"author": "Dan Polites",
"author_id": 43365,
"author_profile": "https://Stackoverflow.com/users/43365",
"pm_score": 4,
"selected": true,
"text": "<p>I spent a lot more time researching this and found a solution that solves the random deletion of the context files. ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43365/"
] | I am working on a web application that allows users to upload attachments. These attachments are stored on a different drive than that of the web application. How can I create an alias (equivalent to Apache HTTP server's aliases) to this drive so that users can download these attachments?
Currently I am creating a con... | I spent a lot more time researching this and found a solution that solves the random deletion of the context files. I found this excerpt on Apache's website under the host configuration section:
>
> You can nest one or more Context
> elements inside this Host element,
> each representing a different web
> applicat... |
350,907 | <p>I want to use git as a local repository against a remote SVN repository. I installed version 1.6.0.2 from <a href="http://code.google.com/p/msysgit/downloads/list" rel="noreferrer">http://code.google.com/p/msysgit/downloads/list</a>.</p>
<p>According to the documentation synchronization is done via the command </p>... | [
{
"answer_id": 350953,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": -1,
"selected": false,
"text": "<p>I don't know git, but I know that for Mercurial, for example, you have to have SVN installed to convert from SVN to Mer... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40347/"
] | I want to use git as a local repository against a remote SVN repository. I installed version 1.6.0.2 from <http://code.google.com/p/msysgit/downloads/list>.
According to the documentation synchronization is done via the command
```
git svn
```
or a separate command wrapper called
```
git-svn
```
Neither of the... | [This earlier version](http://msysgit.googlecode.com/files/Git-1.5.5-preview20080413.exe) has working git-svn. I thought that git-svn in the current version that you installed was fixed, but maybe not. Git-svn definitely did not work in the windows version of Git 1.5.6.1. |
350,914 | <p>Here is a simplified version of my application showing what I'm doing. </p>
<pre><code>/*
in my app's main():
Runner run = new Runner();
run.dowork();
*/
class Runner
{
private int totalWorkers = 2;
private int workersDone = 0;
public synchronized void workerDone()
{
workersDone... | [
{
"answer_id": 350955,
"author": "Dmitry Khalatov",
"author_id": 18174,
"author_profile": "https://Stackoverflow.com/users/18174",
"pm_score": 0,
"selected": false,
"text": "<p>IMHO you have improperly placed \"workersDone = 0\".</p>\n\n<pre><code>public synchronized void dowork()\n ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44410/"
] | Here is a simplified version of my application showing what I'm doing.
```
/*
in my app's main():
Runner run = new Runner();
run.dowork();
*/
class Runner
{
private int totalWorkers = 2;
private int workersDone = 0;
public synchronized void workerDone()
{
workersDone++;
no... | Working directly with `synchronized`, `wait()`, and `notify()` is definitely tricky.
Fortunately the [Java Concurrency API](http://java.sun.com/javase/6/docs/api/java/util/concurrent/package-summary.html) provides some excellent control objects for this sort of thing that are much more intuitive. In particular, look a... |
350,919 | <p>Here is the complete install command to CPAN and the output:</p>
<pre><code>sudo perl -MCPAN -e "install Bundle::CPAN"
CPAN: Storable loaded ok (v2.13)
Going to read /home/delgreco/.cpan/Metadata
Database was generated on Mon, 08 Dec 2008 03:27:10 GMT
CPAN: LWP::UserAgent loaded ok (v2.033)
CPAN: Time::HiRes load... | [
{
"answer_id": 350928,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 0,
"selected": false,
"text": "<p>At a guess:</p>\n\n<pre><code>sudo perl -MCPAN -e \"install YAML\"\n</code></pre>\n"
},
{
"answer_id": 350992... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26848/"
] | Here is the complete install command to CPAN and the output:
```
sudo perl -MCPAN -e "install Bundle::CPAN"
CPAN: Storable loaded ok (v2.13)
Going to read /home/delgreco/.cpan/Metadata
Database was generated on Mon, 08 Dec 2008 03:27:10 GMT
CPAN: LWP::UserAgent loaded ok (v2.033)
CPAN: Time::HiRes loaded ok (v1.55)
... | This looks important:
```
Your urllist is empty! The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/'
```
Perhaps run `sudo cpan`, then `o conf init` or `o conf urllist push http://cpan.yahoo.com/` (for example) to get your `urllist` straightened out? Then try to do your installs. |
350,920 | <p>I'm working with some old PHP code that has a lot of the following:</p>
<pre><code>$someVar =& new SomeClass();
</code></pre>
<p>Did the <strong>new</strong> operator ever return a value, um, not by reference? (That feels strange to type. I feel like I'm losing my mind.)</p>
| [
{
"answer_id": 350944,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 2,
"selected": false,
"text": "<p>Thats PHP4 code. \nFrom the documentation: (now removed)</p>\n\n<blockquote>\n <p>\"new\" does not return a reference by\n... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25213/"
] | I'm working with some old PHP code that has a lot of the following:
```
$someVar =& new SomeClass();
```
Did the **new** operator ever return a value, um, not by reference? (That feels strange to type. I feel like I'm losing my mind.) | It was one of those sort of optimization techniques taught in a lot of older books on OOP in PHP 4.
Basically, the initial object created in memory is one the application can't access unless you return the instance by reference. Otherwise you get a copy of the object - the only catch is that the original exists withou... |
350,922 | <p>I have a simple C++ program that reads <code>stdin</code> using <code>scanf</code> and returns results to <code>stdout</code> using <code>printf</code>:</p>
<pre><code>
#include <iostream>
using namespace std;
int main()
{
int n, x;
int f=0, s=0, t=0;
scanf("%d",&n); scanf("%d",&x);
for(int... | [
{
"answer_id": 351012,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>More information is needed here, as timhon asked, which environment are you working under? Linux, Windows, Mac? Also, wha... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3515/"
] | I have a simple C++ program that reads `stdin` using `scanf` and returns results to `stdout` using `printf`:
```
#include <iostream>
using namespace std;
int main()
{
int n, x;
int f=0, s=0, t=0;
scanf("%d",&n); scanf("%d",&x);
for(int index=0; index<n; index++)
{
scanf("%d",&f);
... | The end of line chars are:
```
System Hex Value Type
Mac 0D 13 CR
DOS 0D 0A 13 10 CR LF
Unix 0A 10 LF
```
For a end of line on each system you can:
```
printf("%c", 13);
printf("%c%c", 13, 10);
printf("%c", 10);
```
You can use this like
```
printf("empty");
printf("%c"... |
350,950 | <p>For example I have 2 tables, <code>Users</code> and <code>UserRelations</code>, and it is a one to many relationship.</p>
<p>For the <code>UserRelations</code> table, I can have an identity column and make it the primary key: </p>
<pre><code>[RelationID] [int] IDENTITY(1,1) NOT NULL,
[UserID] [int] NOT NULL,
[Targ... | [
{
"answer_id": 350964,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming you're doing a many-to-many relation between Users and Targets using the UserRelations table, the first one is inc... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32240/"
] | For example I have 2 tables, `Users` and `UserRelations`, and it is a one to many relationship.
For the `UserRelations` table, I can have an identity column and make it the primary key:
```
[RelationID] [int] IDENTITY(1,1) NOT NULL,
[UserID] [int] NOT NULL,
[TargetID] [int] NOT NULL,
```
Or I can design the table ... | If you use the former design, with the superfluous identity column, there's no constraint against inserting two rows with identical UserID and TargetID. You'd have to create a `UNIQUE` constraint over the other two columns, which creates a compound index anyway.
On the other hand, some frameworks (e.g. Rails) insist t... |
350,951 | <p>Using Visual Studio 2008 / C# / VS Unit Testing.</p>
<p>I have a very straightforward extension method, that will tell me if an object is of a specific type:</p>
<pre><code>public static bool IsTypeOf<T, O>(this T item, O other)
{
if (!(item.GetType() is O))
return false;
else
return ... | [
{
"answer_id": 350974,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>I am speculating here.</p>\n\n<p>Put a constraint on the method to see if that helps\n<code>\nPseudocode</p>\n\n<p>... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15906/"
] | Using Visual Studio 2008 / C# / VS Unit Testing.
I have a very straightforward extension method, that will tell me if an object is of a specific type:
```
public static bool IsTypeOf<T, O>(this T item, O other)
{
if (!(item.GetType() is O))
return false;
else
return true;
}
```
It would be c... | Usually, a `MissingMethodException` means that you are loading a different version of the dll to the one you referenced during build, and the actual dll you are loading (at run-time) doesn't have the method the compiler found (at compile-time).
Check that you haven't somehow got various versions of the dll referenced ... |
350,956 | <p>I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this the menu flickers as it's redrawn (Fil... | [
{
"answer_id": 351112,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 2,
"selected": false,
"text": "<p>There are calls on classes derived from <code>Control</code> for this purpose. They are <code>SuspendLayout</code> a... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working on a C#.Net application which has a somewhat annoying bug in it. The main window has a number of tabs, each of which has a grid on it. When switching from one tab to another, or selecting a different row in a grid, it does some background processing, and during this the menu flickers as it's redrawn (File, ... | There are calls on classes derived from `Control` for this purpose. They are `SuspendLayout` and `PerformLayout`. As they are on `Control` and `Form` is derived from `Control`, your `Form` has them too.
These calls suffice for most updates but in other circumstances, just hiding the control using `Visible = false` can... |
350,961 | <p>Ok, I'm not great in mysql, but I know an index would help me out here, however I've done some plugging and can't find one to help...</p>
<p>Anyone got any ideas?</p>
<pre><code> explain
select `users_usr`.`id_usr` AS `id_usr`,
`users_usr`.`firstname_usr` AS `firstname_usr`,
`users_usr`.`lastname_usr` AS `last... | [
{
"answer_id": 351112,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 2,
"selected": false,
"text": "<p>There are calls on classes derived from <code>Control</code> for this purpose. They are <code>SuspendLayout</code> a... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13704/"
] | Ok, I'm not great in mysql, but I know an index would help me out here, however I've done some plugging and can't find one to help...
Anyone got any ideas?
```
explain
select `users_usr`.`id_usr` AS `id_usr`,
`users_usr`.`firstname_usr` AS `firstname_usr`,
`users_usr`.`lastname_usr` AS `lastname_usr`,`users_usr`... | There are calls on classes derived from `Control` for this purpose. They are `SuspendLayout` and `PerformLayout`. As they are on `Control` and `Form` is derived from `Control`, your `Form` has them too.
These calls suffice for most updates but in other circumstances, just hiding the control using `Visible = false` can... |
350,977 | <p>I have a windows forms (.net 3.0) project that won't run on my customer's vista computer due to a DEP error. It runs on my vista machine, and in a clean version of vista sp1 in a virtual machine. I am having trouble tracking down ways to make my program DEP, Data Execution Prevention compatible. I really can't do an... | [
{
"answer_id": 351036,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 0,
"selected": false,
"text": "<p>Start by trying to figure out where and how your program is failing. Can you replicate the issue on your system? Wi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28343/"
] | I have a windows forms (.net 3.0) project that won't run on my customer's vista computer due to a DEP error. It runs on my vista machine, and in a clean version of vista sp1 in a virtual machine. I am having trouble tracking down ways to make my program DEP, Data Execution Prevention compatible. I really can't do anyth... | DEP runs in one of two modes:
1. Hardware DEP is for CPUs that can mark memory pages as non-executable. This helps to prevent certain exploits such as buffer overflows.
2. Software DEP is for CPUs that do not have hardware DEP support. It doesn't prevent execution of code in data pages, but instead stops SEH overwrite... |
350,978 | <p>My professor assigned a project where a simulation is ran through a GUI. To edit it, we need to create a "New" menu item. We haven't learned how to get data from a GUI, and our book does not cover it at all. </p>
<p>What I'm trying to do, is when the "New" command is hit, focus gets shifted back to the CMD prompt, ... | [
{
"answer_id": 351036,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 0,
"selected": false,
"text": "<p>Start by trying to figure out where and how your program is failing. Can you replicate the issue on your system? Wi... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My professor assigned a project where a simulation is ran through a GUI. To edit it, we need to create a "New" menu item. We haven't learned how to get data from a GUI, and our book does not cover it at all.
What I'm trying to do, is when the "New" command is hit, focus gets shifted back to the CMD prompt, where Syst... | DEP runs in one of two modes:
1. Hardware DEP is for CPUs that can mark memory pages as non-executable. This helps to prevent certain exploits such as buffer overflows.
2. Software DEP is for CPUs that do not have hardware DEP support. It doesn't prevent execution of code in data pages, but instead stops SEH overwrite... |
350,993 | <p>Hey I am coding using Visual Studio 2003. My program worked fine until I introduced a dll I made using CreateObject.
Code:</p>
<pre><code>Set docs2 = server.CreateObject("DocGetter.Form1")
docs2.GetDocument oXMLDom,numID
</code></pre>
<p>It appears to be getting stuck at this code. I've already used regasm to regi... | [
{
"answer_id": 351100,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>Can you clarify - is this a web app or a client (winform) app? Form1 sounds like a winform. ASP.NET runs at the se... | 2008/12/08 | [
"https://Stackoverflow.com/questions/350993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hey I am coding using Visual Studio 2003. My program worked fine until I introduced a dll I made using CreateObject.
Code:
```
Set docs2 = server.CreateObject("DocGetter.Form1")
docs2.GetDocument oXMLDom,numID
```
It appears to be getting stuck at this code. I've already used regasm to register the dll.
What else co... | Add a reference to the dll in your project and instantiate the object like this:
```
Dim docs2 As New DocGetter.Form1()
```
If that doesn't make sense, then fix it so it does. There's no good reason to use CreateObject in .Net code. (Okay, that's hyperbole. But the principal is sound). |
351,017 | <p>I want to create an array with a message.</p>
<pre><code>$myArray = array('my message');
</code></pre>
<p>But using this code, <code>myArray</code> will get overwritten if it already existed. </p>
<p>If I use <code>array_push</code>, it has to already exist.</p>
<pre><code>$myArray = array(); // <-- has to be... | [
{
"answer_id": 351029,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 5,
"selected": false,
"text": "<p>Here:</p>\n\n<pre><code>$myArray[] = 'my message';\n</code></pre>\n\n<p>$myArray have to be an array or not set. If it hold... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38241/"
] | I want to create an array with a message.
```
$myArray = array('my message');
```
But using this code, `myArray` will get overwritten if it already existed.
If I use `array_push`, it has to already exist.
```
$myArray = array(); // <-- has to be declared first.
array_push($myArray, 'my message');
```
Otherwise,... | Check if the array exists first, and if it doesn't, create it...then add the element, knowing that the array will surely be defined before hand :
```
if (!isset($myArray)) {
$myArray = array();
}
array_push($myArray, 'my message');
``` |
351,022 | <p>I have an application into which users can upload an XSD to describe certain kinds of user data. The application needs to parse this XSD to correctly initialise various bits of database metadata (e.g. translating xs:enumerations into lists of permitted values that will populate drop-down lists). The same user-entere... | [
{
"answer_id": 351044,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>You find it here: <a href=\"http://www.w3.org/2001/XMLSchema.xsd\" rel=\"nofollow noreferrer\">http://www.w3.org/2... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an application into which users can upload an XSD to describe certain kinds of user data. The application needs to parse this XSD to correctly initialise various bits of database metadata (e.g. translating xs:enumerations into lists of permitted values that will populate drop-down lists). The same user-entered X... | You find it here: <http://www.w3.org/2001/XMLSchema.xsd>
Just a hint, a schema starts with xsd:schema tag. And if correct, contains an attribute:
```
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
```
Follow the url and you find and information page, with a link to the dtd and the xsd. |
351,052 | <p>A co-worker has a C program that fails in a predictable manner because of some corrupted memory. He'd like to use <code>dbx</code> to monitor the memory location once it's allocated in order to pinpoint the code that causes the corruption.</p>
<p>Is this possible? If so what is the syntax to produce a breakpoint ... | [
{
"answer_id": 351098,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<p>I'm no Solaris dev, but you can do this with gdb and hardware breakpoints</p>\n"
},
{
"answer_id": 354722,
... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] | A co-worker has a C program that fails in a predictable manner because of some corrupted memory. He'd like to use `dbx` to monitor the memory location once it's allocated in order to pinpoint the code that causes the corruption.
Is this possible? If so what is the syntax to produce a breakpoint at the moment of corrup... | Having looked more deeply, it appears the solution on recent versions of `dbx` is something like:
```
stop access w <address>, <size>
```
Since `<address>` and `<size>` can be expressions, you can write commands like:
```
stop access w &p, sizeof(int)
```
This assumes `p` is a pointer and we want to monitor the f... |
351,058 | <p>Is this possible via CSS? </p>
<p>I'm trying </p>
<pre class="lang-css prettyprint-override"><code>tr.classname {
border-spacing: 5em;
}
</code></pre>
<p>to no avail. Maybe I'm doing something wrong?</p>
| [
{
"answer_id": 351063,
"author": "user37731",
"author_id": 37731,
"author_profile": "https://Stackoverflow.com/users/37731",
"pm_score": 9,
"selected": false,
"text": "<p>In the parent table, try setting</p>\n<pre class=\"lang-css prettyprint-override\"><code>border-collapse: separate; \... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419730/"
] | Is this possible via CSS?
I'm trying
```css
tr.classname {
border-spacing: 5em;
}
```
to no avail. Maybe I'm doing something wrong? | In the parent table, try setting
```css
border-collapse: separate;
border-spacing: 5em;
```
Plus a border declaration, and see if this achieves your desired effect.
Beware, though, that IE doesn't support the "separated borders" model. |
351,096 | <p>I have a community site which has around 10,000 listings at the moment. I am adopting a new url strategy something like</p>
<pre><code>example.com/products/category/some-product-name
</code></pre>
<p>As part of strategy, I am implementing a site map. Google already has a good index of my site, but the URLs will ch... | [
{
"answer_id": 351113,
"author": "OIS",
"author_id": 36175,
"author_profile": "https://Stackoverflow.com/users/36175",
"pm_score": 0,
"selected": false,
"text": "<p>Not an answer to your main question.</p>\n\n<p>You dont have to append .html. You can leave the URLs as they are. If you ca... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31399/"
] | I have a community site which has around 10,000 listings at the moment. I am adopting a new url strategy something like
```
example.com/products/category/some-product-name
```
As part of strategy, I am implementing a site map. Google already has a good index of my site, but the URLs will change. I use a php framewor... | Unless I'm missing something, I think you don't need to worry about it. I'm assuming that your list of product names doesn't change all *that* often -- on a scale of a day or so, not every second. The Google site-map should be read in a second or less, and the crawler isn't going to crawl you *instantly* after you upda... |
351,117 | <p>I know you can use the <code><jsp:useBean></code> tag to instantiate objects within JSPs without resorting to scriptlet code. However I'd like to instantiate an Integer who value is the result of an EL expression, something like:</p>
<pre><code><jsp:useBean id="total" class="java.lang.Integer">
<... | [
{
"answer_id": 351132,
"author": "James McMahon",
"author_id": 20774,
"author_profile": "https://Stackoverflow.com/users/20774",
"pm_score": 0,
"selected": false,
"text": "<p>If you have a bean, can you just update the bean with param1 and 2? Create a method, setAmount(param1, param2), a... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I know you can use the `<jsp:useBean>` tag to instantiate objects within JSPs without resorting to scriptlet code. However I'd like to instantiate an Integer who value is the result of an EL expression, something like:
```
<jsp:useBean id="total" class="java.lang.Integer">
<jsp:setProperty name="amount" value="${p... | **`<c:set var="amount" value="${param1 + param2}" scope="page" />`** |
351,122 | <p>Does anybody know how I can get the number of the elements (rows*cols) returned after I do an SQL query? If that can't be done, then is there something that's going to be relatively representative of the size of data I get back?</p>
<p>I'm trying to make a status bar that indicates how much of the returned data I ... | [
{
"answer_id": 351233,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 3,
"selected": true,
"text": "<p>That is frequently a problem when you wan to reserve dynamic memory to hold the entire result set. </p>\n\n<p>One techn... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28760/"
] | Does anybody know how I can get the number of the elements (rows\*cols) returned after I do an SQL query? If that can't be done, then is there something that's going to be relatively representative of the size of data I get back?
I'm trying to make a status bar that indicates how much of the returned data I have proce... | That is frequently a problem when you wan to reserve dynamic memory to hold the entire result set.
One technique is to return the count as part of the result set.
```
WITH
data AS
(
SELECT interesting-data
FROM interesting-table
WHERE some-condition
)
SELECT COUNT(*), data.*
from data
```
If you don... |
351,126 | <p>I've download an image from the Internet and converted to a String (This is not changeable)</p>
<pre><code>Dim Request As System.Net.WebRequest = _
System.Net.WebRequest.Create( _
"http://www.google.com/images/nav_logo.png")
Dim WebResponse As System.Net.HttpWebResponse = _
DirectCast(Request.GetResponse(), ... | [
{
"answer_id": 351156,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>Why have you converted binary (image) data to a string? This makes no sense... unless you are using base-64?</p>\n\... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41385/"
] | I've download an image from the Internet and converted to a String (This is not changeable)
```
Dim Request As System.Net.WebRequest = _
System.Net.WebRequest.Create( _
"http://www.google.com/images/nav_logo.png")
Dim WebResponse As System.Net.HttpWebResponse = _
DirectCast(Request.GetResponse(), System.Net.Htt... | Why have you converted binary (image) data to a string? This makes no sense... unless you are using base-64?
Anyway, to reverse what you have done, you could try using `new MemoryStream(Encoding.UTF8.GetBytes(text))`?
This will create a new MemoryStream primed with the string (via UTF8). Personally, I doubt it will w... |
351,134 | <p>How to get function's name from <a href="http://en.wikipedia.org/wiki/Function_pointer" rel="noreferrer">function's pointer</a> in C?</p>
<p>Edit: The real case is: I'm writing a linux kernel module and I'm calling kernel functions. Some of these functions are pointers and I want to inspect the code of that functio... | [
{
"answer_id": 351151,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": -1,
"selected": false,
"text": "<p>You can't. The function name isn't attached to the function by the time it's compiled and linked. It's all by memory add... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | How to get function's name from [function's pointer](http://en.wikipedia.org/wiki/Function_pointer) in C?
Edit: The real case is: I'm writing a linux kernel module and I'm calling kernel functions. Some of these functions are pointers and I want to inspect the code of that function in the kernel source. But I don't kn... | That's not directly possible without additional assistance.
You could:
1. maintain a table in your program mapping function pointers to names
2. examine the executable's symbol table, if it has one.
The latter, however, is hard, and is not portable. The method will depend on the operating system's binary format (ELF... |
351,149 | <p>I'm writing a helper method for ASP.NET MVC and I need to call <code>Url.Content</code> to get an appropriate URL for the context. However, in order to create a new <code>UrlHelper()</code> I need to get the current <code>RequestContext</code> (<code>System.Web.Routing.RequestContext</code> to be precise) and I'm n... | [
{
"answer_id": 353388,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 1,
"selected": false,
"text": "<p>Don't create a new one. Just extend the existing UrlHelper, just like you'd extend HtmlHelper:</p>\n\n<pre><code>pub... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | I'm writing a helper method for ASP.NET MVC and I need to call `Url.Content` to get an appropriate URL for the context. However, in order to create a new `UrlHelper()` I need to get the current `RequestContext` (`System.Web.Routing.RequestContext` to be precise) and I'm not sure how to grab it. Anyone know? | Noticed this was still unanswered. As of MVC 1.0 you can do:
```
public static string NewHelperMethod(this HtmlHelper helper)
{
UrlHelper url = new UrlHelper(helper.ViewContext.RequestContext);
``` |
351,161 | <p>I have a text file that contains a long list of entries (one on each line). Some of these are duplicates, and I would like to know if it is possible (and if so, how) to remove any duplicates. I am interested in doing this from within vi/vim, if possible.</p>
| [
{
"answer_id": 351175,
"author": "Sean",
"author_id": 44133,
"author_profile": "https://Stackoverflow.com/users/44133",
"pm_score": 5,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>:%s/^\\(.*\\)\\(\\n\\1\\)\\+$/\\1/\n</code></pre>\n\n<p>It searches for any line immediately f... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] | I have a text file that contains a long list of entries (one on each line). Some of these are duplicates, and I would like to know if it is possible (and if so, how) to remove any duplicates. I am interested in doing this from within vi/vim, if possible. | If you're OK with sorting your file, you can use:
```
:sort u
``` |
351,165 | <p>I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).</p>
<p>To perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the future etc. Once the <strong>C... | [
{
"answer_id": 351178,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 0,
"selected": false,
"text": "<p>You haven't mentioned the language, but I'll assume c#.\nI would probably pass them in as a struct (or class) a... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21966/"
] | I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).
To perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the future etc. Once the **Calculate()** met... | Most people suggest using a "Parameter Class", and a "Result Class". I agree with this approach, but it seems to me that your parameters fall into several categories. Perhaps you could create a parameter class for the required parameters, and a separate parameter class for the optional parameters or groups of optional ... |
351,172 | <p>How do you escape the forward slash character (<code>/</code>) in VBScript? For example, in the following string:</p>
<pre><code>bob = "VU administration/front desk"
</code></pre>
| [
{
"answer_id": 351177,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": true,
"text": "<p>You don't escape it: it doesn't mean anything special in php or vbscript, and therefore doesn't need to be escaped. ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | How do you escape the forward slash character (`/`) in VBScript? For example, in the following string:
```
bob = "VU administration/front desk"
``` | You don't escape it: it doesn't mean anything special in php or vbscript, and therefore doesn't need to be escaped. The only character you need to escape in vbscript is the double quote, which escapes itself:
```
MyString = "He said, ""Here's how you escape a double quote in vbscript. Slash characters -- both forward ... |
351,185 | <p>Is there a simple way to detect mouse or keyboard activity in Linux or Xorg or Qt4 or Kde4 environment? Obviously not only on a particular window but in the entire Xorg desktop.</p>
| [
{
"answer_id": 351212,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not familiar with the guts of the Qt4 or KDE API's.</p>\n\n<p>However in general terms, on any X11 system keyboard o... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39796/"
] | Is there a simple way to detect mouse or keyboard activity in Linux or Xorg or Qt4 or Kde4 environment? Obviously not only on a particular window but in the entire Xorg desktop. | You can use the XScreenSaver extension (`man Xss`). It can provide you with values into this struct using the function `XScreenSaverQueryInfo`:
```
typedef struct {
Window window; /∗ screen saver window */
int state; /∗ ScreenSaver{Off,On,Disabled} */
int kind;... |
351,205 | <p>Is it a bad idea to use exception chaining when throwing RemoteExceptions? We have an RMI server that does something like this:</p>
<pre><code>public Object doSomething() throws RemoteException
{
try
{
return getData();
}
catch (CustomException ex)
{
throw new RemoteException(ex... | [
{
"answer_id": 351279,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 4,
"selected": true,
"text": "<p>Rather than wrapping CustomException in RemoteException, you might modify your remote interface like this:</p>\n\n<pre><c... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1471/"
] | Is it a bad idea to use exception chaining when throwing RemoteExceptions? We have an RMI server that does something like this:
```
public Object doSomething() throws RemoteException
{
try
{
return getData();
}
catch (CustomException ex)
{
throw new RemoteException(ex);
}
}
```... | Rather than wrapping CustomException in RemoteException, you might modify your remote interface like this:
```
interface Foo extends Remote {
Object doSomething() throws CustomException, RemoteException;
}
```
The principle here is that only the RMI runtime should be raising RemoteExceptions; they signal some fa... |
351,228 | <p>When using FxCop 1.36 for a WPF application with a single window that has yet to be modified, I get the InterfaceMethodsShouldBeCallableByChildTypes error with the following details:</p>
<pre><code> Target : #System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object) (IntrospectionTarge... | [
{
"answer_id": 351227,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 0,
"selected": false,
"text": "<p>The only workaround (while retaining your strucure) is to have separate tables:</p>\n\n<pre><code>create table IntPro... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21862/"
] | When using FxCop 1.36 for a WPF application with a single window that has yet to be modified, I get the InterfaceMethodsShouldBeCallableByChildTypes error with the following details:
```
Target : #System.Windows.Markup.IComponentConnector.Connect(System.Int32,System.Object) (IntrospectionTargetMember)
R... | The design you're experimenting with is a variation of [Entity-Attribute-Value](http://en.wikipedia.org/wiki/Entity-attribute-value_model), and it comes with a whole lot of problems and inefficiencies. It's not a good solution for what you're doing, except as a last resort.
What could be a better solution is what fall... |
351,243 | <p>I have exported a COM+ application proxy, which generates MSI and CAB files, and I have successfully installed them on a few different Win XP and Vista machines. However, I have a WinXP box that isn't playing nicely. When I try and run the MSI it gives me the following error message:</p>
<p>"Error registering COM+ ... | [
{
"answer_id": 361261,
"author": "jac",
"author_id": 17776,
"author_profile": "https://Stackoverflow.com/users/17776",
"pm_score": 1,
"selected": false,
"text": "<p>Not much help, but try looking in the events log for more information.</p>\n"
},
{
"answer_id": 484702,
"author... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2640/"
] | I have exported a COM+ application proxy, which generates MSI and CAB files, and I have successfully installed them on a few different Win XP and Vista machines. However, I have a WinXP box that isn't playing nicely. When I try and run the MSI it gives me the following error message:
"Error registering COM+ Applicatio... | Unfortunately, this particular error can have many causes, mostly IT-related. Most typically, in my experience, it is permissions issues or a corrupted COM+ installation.
I follow a few basic steps for troubleshooting this generic error.
First, make sure that you can view the COM+ applications (in Component Services... |
351,244 | <p>Heres the issue.</p>
<p>I have a table(mySQL) that contains dates and some of them are null.
I know that I can use DateTime? or Nullable to allow nulls, but I'm not sure where to set it. </p>
<p>What I've tried:</p>
<p>I built the class in the dblm. The date propery has the following attributes set:</p>
<pre><co... | [
{
"answer_id": 351259,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 1,
"selected": false,
"text": "<p>I remember a <a href=\"http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic47934.aspx\... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7617/"
] | Heres the issue.
I have a table(mySQL) that contains dates and some of them are null.
I know that I can use DateTime? or Nullable to allow nulls, but I'm not sure where to set it.
What I've tried:
I built the class in the dblm. The date propery has the following attributes set:
```
Nullable : True
Server Data Type... | I remember a [problem](http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.adonet/topic47934.aspx) with mysql's ADO.NET driver, where it was not playing nice with nulled date/time fields at all.
Even IsDBNull was throwing exception on a field with null date/time.
It may be still an issue. |
351,258 | <p>I have a flex app that uploads files to a server. The server requires authentication to be able to upload. In IE the upload works fine. However in FF and Safari, it does not upload. I have seen people all over with this same problem but no answers. Don't fail me now stackoverflowers. </p>
| [
{
"answer_id": 351609,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 2,
"selected": false,
"text": "<p>The problem at least in Firefox is that the session cookies are not sent in the request when you invoke FileRefere... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34365/"
] | I have a flex app that uploads files to a server. The server requires authentication to be able to upload. In IE the upload works fine. However in FF and Safari, it does not upload. I have seen people all over with this same problem but no answers. Don't fail me now stackoverflowers. | I found this question while trying to find the answer myself. The solution was rather simple.
Based on the [flash player bug](http://bugs.adobe.com/jira/browse/FP-201) that others have linked, and the comments on that page, I decided to append session identifiers to my upload URL and give it a shot. It really was that... |
351,268 | <p><strong>back story:</strong> I am designing a portfolio website for myself. on its home page, the logo is front and center but on the sub pages the logo is top & right. </p>
<p>I thought it would be a nice visual cue (upon clicking a link to a sub page) to use jQuery to animate the movement of the logo from the... | [
{
"answer_id": 351302,
"author": "Cheese Daneish",
"author_id": 43396,
"author_profile": "https://Stackoverflow.com/users/43396",
"pm_score": 1,
"selected": false,
"text": "<p>You should be able to use the animate function listed here: <a href=\"http://docs.jquery.com/Effects/animate#par... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44443/"
] | **back story:** I am designing a portfolio website for myself. on its home page, the logo is front and center but on the sub pages the logo is top & right.
I thought it would be a nice visual cue (upon clicking a link to a sub page) to use jQuery to animate the movement of the logo from the middle to the corner of th... | You also need to return false or prevent the default action of the anchor click event otherwise the browser will just follow the href. Anyway agreed a live demo is better than 1000 words.
[See a live demo here](http://pastebin.me/493e1605948d4)
e.g
```
$('#myLink').click( function(ev){
//prevent the default acti... |
351,272 | <p>I have been using the partial class modifier for some time in order to put helper classes in their own file.</p>
<p>Today we got a new guy and he said that the last team he worked with didn't allow partial classes for this because modifying a helper class that is in a separate file would cause the main partial clas... | [
{
"answer_id": 351291,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not a very big fan of partial classes and don't use them myself. </p>\n\n<p>The one time I do find them helpful and... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16387/"
] | I have been using the partial class modifier for some time in order to put helper classes in their own file.
Today we got a new guy and he said that the last team he worked with didn't allow partial classes for this because modifying a helper class that is in a separate file would cause the main partial class file to ... | Partial classes are *primarily* for code-generator usage, such as designers - but I use the approach you have cited - in particular when an object implements multiple (non-trivial) interfaces, I find it useful to break it up 1 file per interface implementation. I also commonly have a file for the static methods, which ... |
351,306 | <p>I want to programmatically create a SHA1 checksum of audio files (MP3, Ogg Vorbis, Flac).
The requirement is that the checksum should be stable <strong>even if the header (eg. ID3) changes</strong>.<br/>
<em>Note: The audio files don't have CRCs</em></p>
<p>This is what I tried by now:</p>
<h3>1) Reading + Hashing... | [
{
"answer_id": 363738,
"author": "LarryF",
"author_id": 18518,
"author_profile": "https://Stackoverflow.com/users/18518",
"pm_score": 0,
"selected": false,
"text": "<p>Bene, If I were you, (And I am in the process of working on something very similar to what you want to do), I would hash... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4308/"
] | I want to programmatically create a SHA1 checksum of audio files (MP3, Ogg Vorbis, Flac).
The requirement is that the checksum should be stable **even if the header (eg. ID3) changes**.
*Note: The audio files don't have CRCs*
This is what I tried by now:
### 1) Reading + Hashing all MPEG frames using Perl and [MPE... | If you are looking for stable hashes for the actual music you might want to look at [libOFA](http://code.google.com/p/musicip-libofa/). Your current methods will give you different results because the formats can have embedded tags. Also if you want two different files with the same song to return the same hash you nee... |
351,314 | <p>I have to implement a homemade Trie and I'm stuck on the Iterator part. I can't seem to figure out the increment method for the trie.</p>
<p>I hope someone can help me clear things out.</p>
<p>Here's the code for the Iterator:</p>
<pre><code>template <typename T> class Trie<T>::IteratorPrefixe{
friend... | [
{
"answer_id": 351344,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 3,
"selected": false,
"text": "<p>I'm glad to see Tries are still taught, they're an important data structure that is often neglected.</p>\n\n<p>There may be... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44447/"
] | I have to implement a homemade Trie and I'm stuck on the Iterator part. I can't seem to figure out the increment method for the trie.
I hope someone can help me clear things out.
Here's the code for the Iterator:
```
template <typename T> class Trie<T>::IteratorPrefixe{
friend class Trie<T>;
public:
IteratorPref... | I'm glad to see Tries are still taught, they're an important data structure that is often neglected.
There may be a design problem in your code since you should probably have a Trie class and a Node class. The way you wrote it it looks like each node in your Trie is it's own trie, which can work, but will make some th... |
351,324 | <p>How can I rewrite or is there a way to writing my own custom function that simulates the Custom System.Collections.Generic.Contains but only factors in certain Public Properties of a Custom Object?</p>
<p>For example if I have a custom Object with Properties Name and ID, I would like my Unique Value List to contain... | [
{
"answer_id": 351329,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 4,
"selected": true,
"text": "<p>I like gmail because of the way it groups messages by conversation so I can just page down through a thread.</p... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | How can I rewrite or is there a way to writing my own custom function that simulates the Custom System.Collections.Generic.Contains but only factors in certain Public Properties of a Custom Object?
For example if I have a custom Object with Properties Name and ID, I would like my Unique Value List to contain all the D... | I like gmail because of the way it groups messages by conversation so I can just page down through a thread. |
351,340 | <p>3 fields: FirstName, MiddleName, LastName</p>
<p>Any field can be null, but I don't want extra spaces. Format should be "First Middle Last", "First Last", "Last", etc.</p>
| [
{
"answer_id": 351356,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 2,
"selected": false,
"text": "<pre><code>LTRIM(RTRIM(ISNULL(FirstName, '') + ' ' + LTRIM(ISNULL(MiddleName, '') + ' ' + \n ISNULL(LastName, ''))))\n</c... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22448/"
] | 3 fields: FirstName, MiddleName, LastName
Any field can be null, but I don't want extra spaces. Format should be "First Middle Last", "First Last", "Last", etc. | use a UDF:
```
`Select udfConcatName(First, Middle, Last) from foo`
```
That way all your logic for concatenating names is in one place and once you've gotten it written it's short to call. |
351,345 | <p>I have the same problem as <a href="http://forums.oreilly.com/content/C-3-0-in-a-Nutshell/775/Linq-To-Sql-Classes-With-Multiple-Relationships-To-A-Table/" rel="nofollow noreferrer">this guy</a>: </p>
<p>I have a table that has references my tblstaff table twice for two different people. Now that I have added this ... | [
{
"answer_id": 354655,
"author": "Frustrating Developments",
"author_id": 42975,
"author_profile": "https://Stackoverflow.com/users/42975",
"pm_score": 0,
"selected": false,
"text": "<p>By adding two references you are saying select all rows where the PK = this and the PK = that. Since t... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44449/"
] | I have the same problem as [this guy](http://forums.oreilly.com/content/C-3-0-in-a-Nutshell/775/Linq-To-Sql-Classes-With-Multiple-Relationships-To-A-Table/):
I have a table that has references my tblstaff table twice for two different people. Now that I have added this second reference neither of them work.
What is ... | I had to create a function to getStaffbyID and manually call it when I wanted the name instead of the id.
```
Dim id As String = 1
Session("BusinessPlanID") = id
Dim oLinq As New Linq
Dim bp As BusinessPlan = oLinq.getBusinessPlanById(id)
Dim assignedStaff As Staff = oLinq.getStaffById(bp.Assigne... |
351,360 | <p>I've got this small question - given a bitmask of weekdays (e.g., <code>Sunday = 0x01, Monday = 0x02, Tuesday = 0x04</code>, etc...) and today's day (in a form of <code>Sunday = 1, Monday = 2, Tuesday = 3</code>, etc...) - what's the most elegant way to find out the next day from today, that's set in the bitmask? By... | [
{
"answer_id": 351387,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "<p>I understand your question this way:</p>\n\n<pre><code>// returns t (today) if no weekday is set in the ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208/"
] | I've got this small question - given a bitmask of weekdays (e.g., `Sunday = 0x01, Monday = 0x02, Tuesday = 0x04`, etc...) and today's day (in a form of `Sunday = 1, Monday = 2, Tuesday = 3`, etc...) - what's the most elegant way to find out the next day from today, that's set in the bitmask? By elegant I mean, is there... | ```
int getNextDay(int days_mask, int today) {
if (!days_mask) return -1; // no days set
days_mask |= days_mask << 7; // duplicate days into next week
mask = 1 << (today % 7); // keep track of the day
while (!(mask & days_mask)) {
mask <<= 1;
++today;
}
return today % 7;
}
```
So that's ... |
351,368 | <p>I have an asp page that uses jQuery ajax to load member counts into a bunch of <code>div</code>s after a page is loaded.</p>
<p>It works perfectly well in FireFox, and with clients that have a small number of groups.</p>
<p>For the small number of clients that have many groups (500+), I am getting an error in IE. ... | [
{
"answer_id": 351387,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "<p>I understand your question this way:</p>\n\n<pre><code>// returns t (today) if no weekday is set in the ... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311247/"
] | I have an asp page that uses jQuery ajax to load member counts into a bunch of `div`s after a page is loaded.
It works perfectly well in FireFox, and with clients that have a small number of groups.
For the small number of clients that have many groups (500+), I am getting an error in IE. The ajax calls seem to be ru... | ```
int getNextDay(int days_mask, int today) {
if (!days_mask) return -1; // no days set
days_mask |= days_mask << 7; // duplicate days into next week
mask = 1 << (today % 7); // keep track of the day
while (!(mask & days_mask)) {
mask <<= 1;
++today;
}
return today % 7;
}
```
So that's ... |
351,371 | <p>You may have seen JavaScript sliders before:</p>
<p><a href="http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html" rel="nofollow noreferrer">http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html</a></p>
<p>What I'm envisioning is a circular slider. It would consist of a draggable button at one poi... | [
{
"answer_id": 351384,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": true,
"text": "<p>define a center point c\ncurrent mouse point at m</p>\n\n<p>in your mouse drag event handler, you'd have</p>\n\n<pre><code>v... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] | You may have seen JavaScript sliders before:
<http://dev.jquery.com/view/tags/ui/1.5b2/demos/ui.slider.html>
What I'm envisioning is a circular slider. It would consist of a draggable button at one point on the circle -- and that button can be dragged anywhere along the ring. The value depends on what position the bu... | define a center point c
current mouse point at m
in your mouse drag event handler, you'd have
```
var dx = m.x-c.x;
var dy = m.y-c.y;
var scale = radius/Math.sqrt(dx*dx+dy*dy);
slider.x = dx*scale + c.x;
slider.y = dy*scale + c.y;
```
radius would be some preset value of the slider, |
351,375 | <p>So we've been told that one source of <code>TM Enq</code> contention can be unindexed FK's. My question is which one.</p>
<p>I have an <code>INSERT INTO Table_B</code> that is recording <code>TM Enq Wait</code>.</p>
<p>It contains a <code>PK</code> that is the parent to other tables and it has columns that are <co... | [
{
"answer_id": 351637,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure about Oracle TM Contention, but I'd say normally both sides of a foreign key relation are indexed. Otherwise,... | 2008/12/08 | [
"https://Stackoverflow.com/questions/351375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So we've been told that one source of `TM Enq` contention can be unindexed FK's. My question is which one.
I have an `INSERT INTO Table_B` that is recording `TM Enq Wait`.
It contains a `PK` that is the parent to other tables and it has columns that are `FK` constrained to other `PK`s.
So which `FK`s need indexed: t... | Not sure about Oracle TM Contention, but I'd say normally both sides of a foreign key relation are indexed. Otherwise, the database will have to do table scans.
* The index on the parent record is used whenever you insert a new child record, to verify that the parent exists. Often this is a primary key as well, so of ... |
351,402 | <p>Lets say we have something like:</p>
<pre><code> <div class="row">
<div class="box">
<a class="more" href="#more"/>
</div>
<div class="hidden">
stuff
</div>
</div>
<div class="row">
<div class="box">
... | [
{
"answer_id": 351401,
"author": "rbrayb",
"author_id": 9922,
"author_profile": "https://Stackoverflow.com/users/9922",
"pm_score": 1,
"selected": false,
"text": "<p>Visual Studio 2005 Team Edition has a built in version (based on WinDiff?) but you can incorporate third party tools e.g.<... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27570/"
] | Lets say we have something like:
```
<div class="row">
<div class="box">
<a class="more" href="#more"/>
</div>
<div class="hidden">
stuff
</div>
</div>
<div class="row">
<div class="box">
<a class="more" href="#more"/>
</div>
<div class="hidde... | I use [WinMerge](http://www.winmerge.org). Not as good as Beyond Compare but it's free and open source.
Also check out [Visual Studio Comparison Tools](http://www.codeplex.com/ComparisonTools), it's a Visual Studio add-in that connects it to WinMerge. |
351,409 | <p>How do I append an object (such as a string or number) to an array in JavaScript? </p>
| [
{
"answer_id": 351421,
"author": "jdecuyper",
"author_id": 296,
"author_profile": "https://Stackoverflow.com/users/296",
"pm_score": 13,
"selected": true,
"text": "<p>Use the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push\" rel=\"nor... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8482/"
] | How do I append an object (such as a string or number) to an array in JavaScript? | Use the [`Array.prototype.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) method to append values to the end of an array:
```js
// initialize array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
// append new value to the array
arr.push("Hola");
console.log(arr);
``... |
351,415 | <p>I need to programatically find the users name using C#. Specifically, I want to get the system/network user attached to the current process. I'm writing a web application that uses windows integrated security.</p>
| [
{
"answer_id": 351430,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": "<p>Depends on the context of the application. You can use Environment.UserName (console) or HttpContext.Current.User.I... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | I need to programatically find the users name using C#. Specifically, I want to get the system/network user attached to the current process. I'm writing a web application that uses windows integrated security. | The abstracted view of identity is often the `IPrincipal`/`IIdentity`:
```
IPrincipal principal = Thread.CurrentPrincipal;
IIdentity identity = principal == null ? null : principal.Identity;
string name = identity == null ? "" : identity.Name;
```
This allows the same code to work in many different models (winform, ... |
351,456 | <p>The only reliable method that I a have found for using a script to download text from wikipedia is with cURL. So far the only way I have for doing that is to call <code>os.system()</code>. Even though the output appears properly in the python shell I can't seem to the function it to return anything other than the ex... | [
{
"answer_id": 351469,
"author": "Jake",
"author_id": 24730,
"author_profile": "https://Stackoverflow.com/users/24730",
"pm_score": 2,
"selected": false,
"text": "<p>Answering the question,\nPython has a subprocess module which allows you to interact with spawned processes.<a href=\"http... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26659/"
] | The only reliable method that I a have found for using a script to download text from wikipedia is with cURL. So far the only way I have for doing that is to call `os.system()`. Even though the output appears properly in the python shell I can't seem to the function it to return anything other than the exit code(`0`). ... | From [Dive into Python:](http://diveintopython.net/html_processing/extracting_data.html)
```
import urllib
sock = urllib.urlopen("http://en.wikipedia.org/wiki/Python_(programming_language)")
htmlsource = sock.read()
sock.close()
print htmlsource
```
That will print out the source code for the Python Wikipedia artic... |
351,473 | <pre><code>class Child
{
private override void Check_CheckedChanged(object sender, EventArgs e)
{
if (Check.Checked)
{
this.addName(this.FirstName);
this.disableControls();
}
else
{
this.addAddress(this.address);
//this.ac... | [
{
"answer_id": 351480,
"author": "Simon Wilson",
"author_id": 12875,
"author_profile": "https://Stackoverflow.com/users/12875",
"pm_score": 2,
"selected": false,
"text": "<p>A very simple solution would be to make the ActivateControls protected virtual on Parent and override it on the ch... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42564/"
] | ```
class Child
{
private override void Check_CheckedChanged(object sender, EventArgs e)
{
if (Check.Checked)
{
this.addName(this.FirstName);
this.disableControls();
}
else
{
this.addAddress(this.address);
//this.activatec... | A very simple solution would be to make the ActivateControls protected virtual on Parent and override it on the child, then you can call base.activatecontrols in the child method if not Check.Checked. |
351,483 | <p>How do I create a ListBox in ASP.NET MVC with single selection mode?</p>
| [
{
"answer_id": 351579,
"author": "Jeffrey Meyer",
"author_id": 2323,
"author_profile": "https://Stackoverflow.com/users/2323",
"pm_score": 6,
"selected": true,
"text": "<p>I am assuming you are looking for a select box visually like the ListBox, meaning with multiple rows displayed, but ... | 2008/12/09 | [
"https://Stackoverflow.com/questions/351483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | How do I create a ListBox in ASP.NET MVC with single selection mode? | I am assuming you are looking for a select box visually like the ListBox, meaning with multiple rows displayed, but functionally like the DropDownList (allowing for only one selection).
It looks like there is not a particularly easy way to pull this off using ListBox. I'd suggest using Html.DropdownList, similar to t... |