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
291,117
<p>So I've got a program that needs to be multilingual. The only difference between what I'm needing and what I've found on the web is that all the computers my program will run on are set to the localization of EN.</p> <p>We have spanish speaking employees that will use the program just like the english speaking empl...
[ { "answer_id": 291133, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": true, "text": "<p>You can set the culture you want in code, e.g.:</p>\n\n<pre><code>Thread.CurrentThread.CurrentUICulture = new CultureInfo(\"...
2008/11/14
[ "https://Stackoverflow.com/questions/291117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21828/" ]
So I've got a program that needs to be multilingual. The only difference between what I'm needing and what I've found on the web is that all the computers my program will run on are set to the localization of EN. We have spanish speaking employees that will use the program just like the english speaking employees. So ...
You can set the culture you want in code, e.g.: ``` Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES"); ``` See [this MSDN article](http://msdn.microsoft.com/en-us/library/b28bx3bh(VS.80).aspx) for more info.
291,132
<p>Are there any things to be careful about when defining the <code>method_missing</code> method in Ruby? I'm wondering whether there are some not-so-obvious interactions from inheritance, exception throwing, performance, or anything else.</p>
[ { "answer_id": 291718, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 7, "selected": true, "text": "<p>A somewhat obvious one: always redefine <code>respond_to?</code> if you redefine <code>method_missing</code>. If <...
2008/11/14
[ "https://Stackoverflow.com/questions/291132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
Are there any things to be careful about when defining the `method_missing` method in Ruby? I'm wondering whether there are some not-so-obvious interactions from inheritance, exception throwing, performance, or anything else.
A somewhat obvious one: always redefine `respond_to?` if you redefine `method_missing`. If `method_missing(:sym)` works, `respond_to?(:sym)` should always return true. There are many libraries that rely on this. *Later:* An example: ``` # Wrap a Foo; don't expose the internal guts. # Pass any method that starts with...
291,135
<pre><code> ArrayList filters = new ArrayList(); filters.Add(new string[] { "Name", "Equals", "John" }); ObjectDataSource1.SelectParameters.Add("AppliedFilters", string.Join(",",(string[])filters.ToArray(typeof(string)))); </code></pre> <p>Am trying to add a parameter to my object data source which ...
[ { "answer_id": 291718, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 7, "selected": true, "text": "<p>A somewhat obvious one: always redefine <code>respond_to?</code> if you redefine <code>method_missing</code>. If <...
2008/11/14
[ "https://Stackoverflow.com/questions/291135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` ArrayList filters = new ArrayList(); filters.Add(new string[] { "Name", "Equals", "John" }); ObjectDataSource1.SelectParameters.Add("AppliedFilters", string.Join(",",(string[])filters.ToArray(typeof(string)))); ``` Am trying to add a parameter to my object data source which is bound to my selec...
A somewhat obvious one: always redefine `respond_to?` if you redefine `method_missing`. If `method_missing(:sym)` works, `respond_to?(:sym)` should always return true. There are many libraries that rely on this. *Later:* An example: ``` # Wrap a Foo; don't expose the internal guts. # Pass any method that starts with...
291,152
<p>I'm using an UpdatePanel and want to put a CompareValidator on two text boxes, to verify that the user-entered password and confirmation are the same.</p> <p>This is working fine (I have VS2008 and am using .NET 3.5) out of the box, with one minor problem:</p> <p>The validation is firing as soon as the user clicks...
[ { "answer_id": 291156, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 3, "selected": false, "text": "<p>Some very large projects are succesfully running on SVN or GIT. </p>\n\n<p>I would be inclined to use different...
2008/11/14
[ "https://Stackoverflow.com/questions/291152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23902/" ]
I'm using an UpdatePanel and want to put a CompareValidator on two text boxes, to verify that the user-entered password and confirmation are the same. This is working fine (I have VS2008 and am using .NET 3.5) out of the box, with one minor problem: The validation is firing as soon as the user clicks out of the first...
Good question(s). I've never used TFS but all this certainly is possible with a number of tools. The biggest hurdle is the culture and mindset of the company and developers. I am pro SVN. (But TFS would work I am sure) I'd suggest very light intrusion on daily tasks. Having sandboxes or promotion rules from one br...
291,162
<p>I have a form that contains a bunch of checkboxes. Before submitting the form, I'd like to grab the values of the checkboxes and stick them into a text field, then submit that.</p> <p>So I might have: Red Orange X Yellow Blue X Green</p> <p>And I'd like my textfield to end up with the content "Yellow, ...
[ { "answer_id": 291181, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 0, "selected": false, "text": "<p>First hack at it (without testing):</p>\n\n<pre><code>var serializedCheckboxes = '';\n$(\"input type='checkbox'\").eac...
2008/11/14
[ "https://Stackoverflow.com/questions/291162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a form that contains a bunch of checkboxes. Before submitting the form, I'd like to grab the values of the checkboxes and stick them into a text field, then submit that. So I might have: Red Orange X Yellow Blue X Green And I'd like my textfield to end up with the content "Yellow, Green" . This doesn't se...
Just use this code: ``` $(function(){ $('#YourFormID').bind('submit',function(){ var serializedCheckboxes = ''; $("input[type=checkbox]").each(function() { if($(this).attr("checked")) { serializedCheckboxes += (serializedCheckboxes != '' ? ', ' : '') + $(this).attr("value"); ...
291,163
<p>I'm having a hard time determining what characters <strong>must</strong> be escaped when using Perl's qr{} construct</p> <p>I'm attempting to create a multi-line precompiled regex for text that contains a myriad of normally escaped characters (#*.>:[]) and also contains another precompiled regex. Additionally I nee...
[ { "answer_id": 291194, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 5, "selected": true, "text": "<p>You have to escape the delimiter for qr//, and you have to escape any regex metacharacters that you want to use ...
2008/11/14
[ "https://Stackoverflow.com/questions/291163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1214705/" ]
I'm having a hard time determining what characters **must** be escaped when using Perl's qr{} construct I'm attempting to create a multi-line precompiled regex for text that contains a myriad of normally escaped characters (#\*.>:[]) and also contains another precompiled regex. Additionally I need to match as strictly...
You have to escape the delimiter for qr//, and you have to escape any regex metacharacters that you want to use as literals. If you want those to be literal \*'s, you need to escape them since the \* is a regex quantifier. Your problem here is the various regex flags that you've added. The /m doesn't do anything becau...
291,169
<p>I am trying to use the Event Log to write some debug information and I can't make it works. It complains about not being able to find the Event Source. Do I have to install something on the OS?</p>
[ { "answer_id": 291174, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 3, "selected": true, "text": "<p>Here a code that I modified from one of our application. This might help you to start with the creation. <...
2008/11/14
[ "https://Stackoverflow.com/questions/291169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21386/" ]
I am trying to use the Event Log to write some debug information and I can't make it works. It complains about not being able to find the Event Source. Do I have to install something on the OS?
Here a code that I modified from one of our application. This might help you to start with the creation. ``` System.Diagnostics.EventLog eventLog1 = new System.Diagnostics.EventLog(); string eventLogName = "StackOverFlowEventName"; string eventLogSource = "StackOverFlowWebsite"; //This code HERE will create the Even...
291,172
<p>I'm trying to get the following SQL statement to work:</p> <pre><code>UPDATE myschema.tableA update_tableA SET field_id = ( SELECT src.field_id FROM myschema.srcTable src INNER JOIN myschema.tableB tableB ON update_tableA.id = tableB.id AND SDO_ANYINTERACT( tableB...
[ { "answer_id": 291258, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>Looking at the SQL above, here is what I am thinking</p>\n\n<p>1) myschema.tableA doesn't have ID column (it could ...
2008/11/14
[ "https://Stackoverflow.com/questions/291172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133/" ]
I'm trying to get the following SQL statement to work: ``` UPDATE myschema.tableA update_tableA SET field_id = ( SELECT src.field_id FROM myschema.srcTable src INNER JOIN myschema.tableB tableB ON update_tableA.id = tableB.id AND SDO_ANYINTERACT( tableB.shape, src.sh...
I don't believe you can JOIN on a column (i.e. use it in the ON clause) that's not in one of the tables being joined. Additional predicates need to be in a WHERE clause. Try this: ``` UPDATE myschema.tableA update_tableA SET field_id = ( SELECT src.field_id FROM myschema.srcTable src INNER J...
291,189
<p>It has to be simple, here's my CSS: </p> <pre><code>.progressImage { position:relative; top:50%; } .progressPanel { height:100%; width:100%; text-align:center; display:none; } &lt;asp:Panel ID="pnlProgress" runat="server" CssClass="progressPanel"&gt; &lt;asp:Image ID="Image1" runat="server" CssClass="progres...
[ { "answer_id": 291245, "author": "Mauro", "author_id": 2208, "author_profile": "https://Stackoverflow.com/users/2208", "pm_score": 2, "selected": false, "text": "<p>Ensure the parents container is also set to position: relative and has a height specified, without it the position wont wor...
2008/11/14
[ "https://Stackoverflow.com/questions/291189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3661/" ]
It has to be simple, here's my CSS: ``` .progressImage { position:relative; top:50%; } .progressPanel { height:100%; width:100%; text-align:center; display:none; } <asp:Panel ID="pnlProgress" runat="server" CssClass="progressPanel"> <asp:Image ID="Image1" runat="server" CssClass="progressImage" ImageUrl="~/Ima...
Set the position of `.progressPanel` to relative, and the position of `.progressImage` to absolute. The following works for me in FF, IE, Safari. Set the negative margins to half the width/height of your image for perfect centering. Note that some parent of the progressPanel (body in this case) needs a height so that t...
291,249
<p>I need to store a tree data structure in my database, for which I plan on using <a href="http://code.google.com/p/django-treebeard/" rel="noreferrer">django-treebeard</a> or possibly <a href="http://code.google.com/p/django-mptt/" rel="noreferrer">django-mptt</a>. My source of confusion is that each node could be o...
[ { "answer_id": 291981, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 2, "selected": false, "text": "<p>Your three types are probably easiest handled as FK associations with the fundamental tree.</p>\n\n<p>The tree can be ho...
2008/11/14
[ "https://Stackoverflow.com/questions/291249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1595/" ]
I need to store a tree data structure in my database, for which I plan on using [django-treebeard](http://code.google.com/p/django-treebeard/) or possibly [django-mptt](http://code.google.com/p/django-mptt/). My source of confusion is that each node could be one of three different possible types: root nodes will always...
How about using a [generic relation](http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1) from the model which will hold the tree structure to the content object for the node it represents? ``` from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.co...
291,274
<p>I am using the Html.TextBox helper to create textboxes. I want to set attributes on the textbox, which I understand is done using the following overload: </p> <p><code>Html.TextBox (string name, object value, object htmlAttributes)</code></p> <p>However, I want to maintain the functionality where the HTML helper ...
[ { "answer_id": 291295, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 7, "selected": true, "text": "<p>[EDIT] After looking at the <a href=\"http://www.codeplex.com/aspnet/\" rel=\"noreferrer\">source code</a>, it appea...
2008/11/14
[ "https://Stackoverflow.com/questions/291274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37786/" ]
I am using the Html.TextBox helper to create textboxes. I want to set attributes on the textbox, which I understand is done using the following overload: `Html.TextBox (string name, object value, object htmlAttributes)` However, I want to maintain the functionality where the HTML helper automatically uses the value ...
[EDIT] After looking at the [source code](http://www.codeplex.com/aspnet/), it appears that all you need to do is specify the value as null in the signature that takes a name, value, and htmlAttributes. If the value is null, it will attempt to use the value from the ViewData. ``` Html.TextBox( "name", null, new { @cla...
291,286
<p>We're using Spring/Hibernate on a Websphere Application Server for AIX. On my Windows machine, the problem doesn't occur--only when running off AIX. When a user logs in with an account number, if they prefix the '0' to their login ID, the application rejects the login. In the DB2 table, the column is of numeric t...
[ { "answer_id": 291290, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Well there's an awful lot of things going on there. You really need to try to isolate the problem - work out what's b...
2008/11/14
[ "https://Stackoverflow.com/questions/291286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13435/" ]
We're using Spring/Hibernate on a Websphere Application Server for AIX. On my Windows machine, the problem doesn't occur--only when running off AIX. When a user logs in with an account number, if they prefix the '0' to their login ID, the application rejects the login. In the DB2 table, the column is of numeric type, a...
SOLUTION ======== A co-worker did some research on Spring updates, and apparently this error was correct in v. 2.5.3: > > CustomNumberEditor treats number with leading zeros as decimal (removed unwanted octal support while preserving hex) > > > We were using Spring 2.0.5. We simply replaced the jars with Spring ...
291,304
<p>I'm having an issue with JQuery and Safari (Windows Version). The code works on FF/IE7/Chrome but not Safari.</p> <p>I have a simple <code>&lt;li&gt;</code> that has a <code>&lt;div&gt;</code> embedded in to - clicking the <code>&lt;li&gt;</code> should expose the hidden <code>div</code>, but not in Safari.</p> <...
[ { "answer_id": 291417, "author": "Pseudo Masochist", "author_id": 8529, "author_profile": "https://Stackoverflow.com/users/8529", "pm_score": 1, "selected": false, "text": "<p>How accurate is your HTML pasting?</p>\n\n<p>You never closed your \"moreFacetsLink\" anchor tag, which probably...
2008/11/14
[ "https://Stackoverflow.com/questions/291304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm having an issue with JQuery and Safari (Windows Version). The code works on FF/IE7/Chrome but not Safari. I have a simple `<li>` that has a `<div>` embedded in to - clicking the `<li>` should expose the hidden `div`, but not in Safari. The HTML: ``` <ul> <li>something</li> <li>something2</li> <li class="more"> ...
How accurate is your HTML pasting? You never closed your "moreFacetsLink" anchor tag, which probably makes Safari think that it was implicitly closed, and the "bunch of text" is surrounded by an additional, HREF-less Class-less Unclosed anchor tag... evidenced by the fact that this: ``` $(".moreFacetsLink").click(fun...
291,326
<p>I'm using the command line compiler for builds. One problem I see is that the paths mentioned there seem to need to be the short versions of the filenames such that they don't contain any spaces. I don't know so much about this even though I have used it for some time.</p> <p>I recently upgraded to d2009 and the ...
[ { "answer_id": 291441, "author": "schnaader", "author_id": 34065, "author_profile": "https://Stackoverflow.com/users/34065", "pm_score": 3, "selected": true, "text": "<p>You could try to put the paths in quotes, that's the standard way of handling path-/filenames with spaces in Windows, ...
2008/11/14
[ "https://Stackoverflow.com/questions/291326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14031/" ]
I'm using the command line compiler for builds. One problem I see is that the paths mentioned there seem to need to be the short versions of the filenames such that they don't contain any spaces. I don't know so much about this even though I have used it for some time. I recently upgraded to d2009 and the problem star...
You could try to put the paths in quotes, that's the standard way of handling path-/filenames with spaces in Windows, though I never tried that in Delphi DCUs. So, instead of ``` $(BDS)\Lib\Indy10 ``` try ``` "$(BDS)\Lib\Indy10" ``` You could also try ``` "C:\Program Files\CodeGear\RAD Studio\5.0\lib\Indy10" ...
291,328
<p>I am trying to create a delegate protocol for a custom UIView. Here is my first attempt:</p> <pre><code>@protocol FunViewDelegate @optional - (void) funViewDidInitialize:(FunView *)funView; @end @interface FunView : UIView { @private } @property(nonatomic, assign) id&lt;FunViewDelegate&gt; delegate; @end </...
[ { "answer_id": 291408, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": false, "text": "<p>It would seem that you can forward declare protocols:</p>\n\n<pre><code>@protocol FunViewDelegate;\n\n@interface FunV...
2008/11/14
[ "https://Stackoverflow.com/questions/291328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338/" ]
I am trying to create a delegate protocol for a custom UIView. Here is my first attempt: ``` @protocol FunViewDelegate @optional - (void) funViewDidInitialize:(FunView *)funView; @end @interface FunView : UIView { @private } @property(nonatomic, assign) id<FunViewDelegate> delegate; @end ``` This doesn't work...
Forward class syntax is `@class Foo;`, not `@interface Foo;`.
291,336
<p>I have a folder in NTFS that contains tens of thousands of files. I've deleted all files in that folder, save 1. I ran contig.exe to defragment that folder so now it's in 1 fragment only. However, the size of that folder is still 8MB in size. This implies that there's a lot of gap in the index. Why is that? If I del...
[ { "answer_id": 292402, "author": "Mike G.", "author_id": 18901, "author_profile": "https://Stackoverflow.com/users/18901", "pm_score": 4, "selected": true, "text": "<p>I guess this is one way in which NTFS is just like almost every other FS - none of them seem to like shrinking directori...
2008/11/14
[ "https://Stackoverflow.com/questions/291336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13484/" ]
I have a folder in NTFS that contains tens of thousands of files. I've deleted all files in that folder, save 1. I ran contig.exe to defragment that folder so now it's in 1 fragment only. However, the size of that folder is still 8MB in size. This implies that there's a lot of gap in the index. Why is that? If I delete...
I guess this is one way in which NTFS is just like almost every other FS - none of them seem to like shrinking directories. So you should apply a high-tech method that involves using that advanced language, "BAT" :) collapse.bat ``` REM Invoke as "collapse dirname" ren dirname dirname.old mkdir dirname cd dirname.ol...
291,340
<p>Is there a simple attribute or data contract that I can assign to a function parameter that prevents <code>null</code> from being passed in C#/.NET? Ideally this would also check at compile time to make sure the literal <code>null</code> isn't being used anywhere for it and at run-time throw <code>ArgumentNullExcep...
[ { "answer_id": 291357, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>There's nothing available at compile-time, unfortunately.</p>\n\n<p>I have a bit of a <a href=\"https://web.archive.or...
2008/11/14
[ "https://Stackoverflow.com/questions/291340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9642/" ]
Is there a simple attribute or data contract that I can assign to a function parameter that prevents `null` from being passed in C#/.NET? Ideally this would also check at compile time to make sure the literal `null` isn't being used anywhere for it and at run-time throw `ArgumentNullException`. Currently I write somet...
There's nothing available at compile-time, unfortunately. I have a bit of a [hacky solution](https://web.archive.org/web/20081231232311/http://msmvps.com/blogs/jon_skeet/archive/2008/10/06/non-nullable-reference-types.aspx) which I posted on my blog recently, which uses a new struct and conversions. In .NET 4.0 with ...
291,343
<p><strong>SpousesTable</strong> <em>SpouseID</em></p> <p><strong>SpousePreviousAddressesTable</strong> <em>PreviousAddressID</em>, <em>SpouseID</em>, FromDate, AddressTypeID</p> <p>What I have now is updating the most recent for the whole table and assigning the most recent regardless of SpouseID the AddressTypeID =...
[ { "answer_id": 291358, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<pre><code>UPDATE spa SET spa.AddressTypeID = 1 \n WHERE spa.SpouseID IN (\n SELECT DISTINCT s1.SpouseID FROM Sp...
2008/11/14
[ "https://Stackoverflow.com/questions/291343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30930/" ]
**SpousesTable** *SpouseID* **SpousePreviousAddressesTable** *PreviousAddressID*, *SpouseID*, FromDate, AddressTypeID What I have now is updating the most recent for the whole table and assigning the most recent regardless of SpouseID the AddressTypeID = 1 I want to assign the most recent SpousePreviousAddress.Addre...
Presuming you are using SQLServer 2005 (based on the error message you got from the previous attempt) probably the most straightforward way to do this would be to use the ROW\_NUMBER() Function couple with a Common Table Expression, I think this might do what you are looking for: ``` WITH result AS ( SELECT ROW_N...
291,344
<p>Are they the same thing? Just finished to watch <a href="https://www.asp.net/mvc/videos/mvc-1/aspnet-mvc-storefront/aspnet-mvc-storefront-part-1-architectural-discussion-and-overview" rel="noreferrer">Rob Connery's Storefront tutorial</a> and they seem to be similar techinques. I mean, when I implement a DAL object ...
[ { "answer_id": 291539, "author": "remotefacade", "author_id": 29091, "author_profile": "https://Stackoverflow.com/users/29091", "pm_score": 0, "selected": false, "text": "<p>From what I understand they can mean basically the same thing - but the naming varies based on context.</p>\n\n<p>...
2008/11/14
[ "https://Stackoverflow.com/questions/291344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37795/" ]
Are they the same thing? Just finished to watch [Rob Connery's Storefront tutorial](https://www.asp.net/mvc/videos/mvc-1/aspnet-mvc-storefront/aspnet-mvc-storefront-part-1-architectural-discussion-and-overview) and they seem to be similar techinques. I mean, when I implement a DAL object I have the GetStuff, Add/Delete...
You're definitely not the one who confuses things. :-) I think the answer to the question depends on how much of a purist you want to be. If you want a strict DDD point of view, that will take you down one path. If you look at the repository as a pattern that has helped us standardize the interface of the layer that...
291,359
<p>I am writing a Clone method using reflection. How do I detect that a property is an indexed property using reflection? For example:</p> <pre><code>public string[] Items { get; set; } </code></pre> <p>My method so far:</p> <pre><code>public static T Clone&lt;T&gt;(T from, List&lt;string&gt; propertiesToIgno...
[ { "answer_id": 291380, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 7, "selected": true, "text": "<pre><code>if (propertyInfo.GetIndexParameters().Length &gt; 0)\n{\n // Property is an indexer\n}\n</code></pre>\n" }, ...
2008/11/14
[ "https://Stackoverflow.com/questions/291359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37797/" ]
I am writing a Clone method using reflection. How do I detect that a property is an indexed property using reflection? For example: ``` public string[] Items { get; set; } ``` My method so far: ``` public static T Clone<T>(T from, List<string> propertiesToIgnore) where T : new() { T to = new T(); Typ...
``` if (propertyInfo.GetIndexParameters().Length > 0) { // Property is an indexer } ```
291,387
<p>I'm new to .net and c#, so I want to make sure i'm using the right tool for the job.</p> <p>The XML i'm receiving is a description of a directory tree on another machine, so it go many levels deep. What I need to do now is to take the XML and create a structure of objects (custom classes) and populate them with inf...
[ { "answer_id": 291389, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 1, "selected": false, "text": "<p>Load your XML into an XMLDocument. You can then walk the XMLDocuments DOM using recursion.</p>\n\n<p>You might want to al...
2008/11/14
[ "https://Stackoverflow.com/questions/291387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37794/" ]
I'm new to .net and c#, so I want to make sure i'm using the right tool for the job. The XML i'm receiving is a description of a directory tree on another machine, so it go many levels deep. What I need to do now is to take the XML and create a structure of objects (custom classes) and populate them with info from the...
I would use the XLINQ classes in System.Xml.Linq (this is the namespace and the assembly you will need to reference). Load the XML into and XDocument: ``` XDocument doc = XDocument.Parse(someString); ``` Next you can either use recursion or a pseudo-recursion loop to iterate over the child nodes. You can choose you ...
291,391
<p>Thanks for reading this.</p> <p>I am dynamically generating some data which includes a select drop-down with a text box next to it. If the user clicks the select, I am dynamically populating it (code below). I have a class on the select and I was hoping the following code would work. I tested it with an ID on the s...
[ { "answer_id": 291412, "author": "Josh", "author_id": 2204759, "author_profile": "https://Stackoverflow.com/users/2204759", "pm_score": 0, "selected": false, "text": "<p>That is matching one select. You need to match multiple elements so you want</p>\n\n<pre><code>$(\"select[class='class...
2008/11/14
[ "https://Stackoverflow.com/questions/291391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
Thanks for reading this. I am dynamically generating some data which includes a select drop-down with a text box next to it. If the user clicks the select, I am dynamically populating it (code below). I have a class on the select and I was hoping the following code would work. I tested it with an ID on the select and ...
`$(this)` is only relevant within the scope of the function. outside of the function though, it loses that reference: ``` $('.classSelect').one("click", function() { $(this); // refers to $('.classSelect') $.ajax({ // content $(this); // does not refer to $('.classSelect') }); }); ``` a better way...
291,395
<p>I'm working with an XML file that subscribes to an industry standard. The standards document for the schema defines one of the fields as a rational number and its data is represented as two integers, typically with the second value being a 1 (e.g. <code>&lt;foo&gt;20 1&lt;/foo&gt;</code>). I've been hunting around w...
[ { "answer_id": 291436, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 1, "selected": false, "text": "<p>i'm glad they didn't accept this proposal as a standard! the guy proposing to base all other numbers on a 'rationa...
2008/11/14
[ "https://Stackoverflow.com/questions/291395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31167/" ]
I'm working with an XML file that subscribes to an industry standard. The standards document for the schema defines one of the fields as a rational number and its data is represented as two integers, typically with the second value being a 1 (e.g. `<foo>20 1</foo>`). I've been hunting around without a great deal of suc...
This isn't exactly an answer to the XML-side of things, but if you are wanting a C# class for representing rational numbers, I write a very flexible one a while back as part of my [ExifUtils library](https://github.com/mckamey/exif-utils.net) (since most EXIF values are represented as rational numbers). * `Rational<T>...
291,405
<p>When building a multi-lingual website (with ASP.NET web forms), I'll use an HTTP module to rewrite the URLs to end up with something friendly (for humans &amp; search engines) like:</p> <pre><code>uk/products/product_category_one/sub_category_one/index.aspx uk/products/product_category_one/sub_category_one/widget_m...
[ { "answer_id": 291692, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 5, "selected": true, "text": "<p>The URL can take almost any other form you like. For more info, check <a href=\"http://weblogs.asp.net/scottgu/archive/2007/...
2008/11/14
[ "https://Stackoverflow.com/questions/291405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14072/" ]
When building a multi-lingual website (with ASP.NET web forms), I'll use an HTTP module to rewrite the URLs to end up with something friendly (for humans & search engines) like: ``` uk/products/product_category_one/sub_category_one/index.aspx uk/products/product_category_one/sub_category_one/widget_mk5.aspx es/product...
The URL can take almost any other form you like. For more info, check [ASP.NET MVC Framework (Part 2): URL Routing](http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx). Just for starting (since I am not sure if it is the optimum solution), you can add two new routes in your ...
291,406
<p>When extracting files from a ZIP file I was using the following.</p> <pre><code>Sub Unzip(strFile) ' This routine unzips a file. NOTE: The files are extracted to a folder ' ' in the same location using the name of the file minus the extension. ' ' EX. C:\Test.zip will be extracted to C:\Test ' 'strFile (String) = ...
[ { "answer_id": 291514, "author": "Mike Blandford", "author_id": 28643, "author_profile": "https://Stackoverflow.com/users/28643", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23022290.html\" rel=\"n...
2008/11/14
[ "https://Stackoverflow.com/questions/291406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When extracting files from a ZIP file I was using the following. ``` Sub Unzip(strFile) ' This routine unzips a file. NOTE: The files are extracted to a folder ' ' in the same location using the name of the file minus the extension. ' ' EX. C:\Test.zip will be extracted to C:\Test ' 'strFile (String) = Full path and ...
All above solutions are accurate, but they are not definitive. If you are trying to extract a *zipped file* into a temporary folder, a folder that displays "Temporary Folder For YOURFILE.zip" will immediately be created (in `C:\Documents` and `Settings\USERNAME\Local Settings\Temp`) for **EACH FILE** contained within...
291,413
<p>I am looking for the VB.NET equivalent of</p> <pre><code>var strings = new string[] {"abc", "def", "ghi"}; </code></pre>
[ { "answer_id": 291423, "author": "David Mohundro", "author_id": 4570, "author_profile": "https://Stackoverflow.com/users/4570", "pm_score": 3, "selected": false, "text": "<pre><code>Dim strings As String() = New String() {\"abc\", \"def\", \"ghi\"}\n</code></pre>\n" }, { "answer_...
2008/11/14
[ "https://Stackoverflow.com/questions/291413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191/" ]
I am looking for the VB.NET equivalent of ``` var strings = new string[] {"abc", "def", "ghi"}; ```
``` Dim strings() As String = {"abc", "def", "ghi"} ```
291,444
<p>I'm trying to inject a dynamic where clause in my Linq to SQL query and I get an overload exception. The same expression work when added in the query proper?</p> <pre><code> qry.Where(Function(c) c.CallDate &lt; Date.Now.AddDays(-1)) </code></pre> <p>Any thoughts on how to this to work?</p> <p>The exception read...
[ { "answer_id": 291505, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "<p><code>CommandLineToArgvW()</code> is in shell32.dll. I'd guessthat the Shell developers created the function for ...
2008/11/14
[ "https://Stackoverflow.com/questions/291444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25121/" ]
I'm trying to inject a dynamic where clause in my Linq to SQL query and I get an overload exception. The same expression work when added in the query proper? ``` qry.Where(Function(c) c.CallDate < Date.Now.AddDays(-1)) ``` Any thoughts on how to this to work? The exception reads: ``` Overload resolution failed be...
Apparently you can use [`__argv`](https://learn.microsoft.com/lt-lt/cpp/c-runtime-library/argc-argv-wargv?view=msvc-160) outside `main()` to access the pre-parsed argument vector...
291,445
<p>I'm trying to grab data from a MySQL database.</p> <p>Approach 2 - apply/map style</p> <p>I'm using the <a href="http://dev.mysql.com/doc/refman/5.1/en/connector-net-examples-mysqlcommand.html" rel="nofollow noreferrer" title="MySQL Reference Site">MySQL ADO Reference</a> to try to build this system. In particular...
[ { "answer_id": 291588, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 2, "selected": false, "text": "<p>It can be hard to work with imperative APIs in a non-imperative way. I don't have MySql handy, but I made an approxmiati...
2008/11/14
[ "https://Stackoverflow.com/questions/291445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26227/" ]
I'm trying to grab data from a MySQL database. Approach 2 - apply/map style I'm using the [MySQL ADO Reference](http://dev.mysql.com/doc/refman/5.1/en/connector-net-examples-mysqlcommand.html "MySQL Reference Site") to try to build this system. In particular, the example found at 21.2.3.1.7. (using a pseudo code) `...
The Seq type has a neat function for handling database cursors called generate\_using (see [F# Manual](http://research.microsoft.com/fsharp/manual/FSharp.PowerPack/Microsoft.FSharp.Compatibility.Seq.html) and the Data Access chapter in [Foundations of F#](http://apress.com/book/view/9781590597576)). This is a higher or...
291,459
<p>I have an application where I'm dynamically loading routes by a model, and calling <code>ActionController::Routing::Routes.reload!</code> after creating/updating that model. The problem is that after doing this, I'm receiving the following error when I try to hit that new route:</p> <pre><code>ActionController::Met...
[ { "answer_id": 291462, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 7, "selected": true, "text": "<p>It turns out, the answer is that what I'm seeing is a <a href=\"http://en.wikipedia.org/wiki/Byte_Order_Mark\" re...
2008/11/14
[ "https://Stackoverflow.com/questions/291459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6705/" ]
I have an application where I'm dynamically loading routes by a model, and calling `ActionController::Routing::Routes.reload!` after creating/updating that model. The problem is that after doing this, I'm receiving the following error when I try to hit that new route: ``` ActionController::MethodNotAllowed Only get, h...
It turns out, the answer is that what I'm seeing is a [Byte Order Mark](http://en.wikipedia.org/wiki/Byte_Order_Mark), which is a character that tells whatever is loading the document what it is encoded in. In my case, it's encoded in utf-8, so the corresponding BOM was `EF BB BF`, as shown below. To remove it, I opene...
291,466
<p>I am using jQuery to make an AJAX request to a remote endpoint. That endpoint will return a JSON object if there is a failure and that object will describe the failure. If the request is successful it will return HTML or XML.</p> <p>I see how to define the expected request type in jQuery as part of the <code>$.aj...
[ { "answer_id": 291548, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>By the time it calls your success handler, the data has already been deserialized for you. You need to always retur...
2008/11/14
[ "https://Stackoverflow.com/questions/291466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
I am using jQuery to make an AJAX request to a remote endpoint. That endpoint will return a JSON object if there is a failure and that object will describe the failure. If the request is successful it will return HTML or XML. I see how to define the expected request type in jQuery as part of the `$.ajax()` call. Is th...
Have you application generate correct Content-Type headers (application/json, text/xml, etc) and handle those in your success callback. Maybe something like this will work? ``` xhr = $.ajax( { //SNIP success: function(data) { var ct = xhr.getResponseHeader('Content-Type'); ...
291,475
<p>I have a win form (c#) with a datagridview. I set the grid's datasource to a datatable.</p> <p>The user wants to check if some data in the datatable exists in another source, so we loop through the table comparing rows to the other source and set the rowerror on the datatable to a short message. The datagridview ...
[ { "answer_id": 293620, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": -1, "selected": false, "text": "<p>I believe that the errors will only show on editing. What you could do is add a bool column to your DataTable, w...
2008/11/14
[ "https://Stackoverflow.com/questions/291475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a win form (c#) with a datagridview. I set the grid's datasource to a datatable. The user wants to check if some data in the datatable exists in another source, so we loop through the table comparing rows to the other source and set the rowerror on the datatable to a short message. The datagridview is not showi...
Check that `AutoSizeRowsMode` is set to `DataGridViewAutoSizeRowsMode.None`. I have found that the row `Errortext` preview icon is not displayed when `AutoSizeRowsMode` is not set to the default of none. ``` DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None ```
291,493
<p>I've been struggling with this check constraint for a few hours and was hoping someone would be kind enough to explain why this check constraint isn't doing what I think it should be doing.</p> <pre><code>ALTER TABLE CLIENTS add CONSTRAINT CHK_DISABILITY_INCOME_TYPE_ID CHECK ((IS_DISABLED IS NULL AND DISABILITY_INC...
[ { "answer_id": 291504, "author": "Eddie Awad", "author_id": 17273, "author_profile": "https://Stackoverflow.com/users/17273", "pm_score": 1, "selected": false, "text": "<p>Try using <a href=\"http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions110.htm#SQLRF00684\" rel...
2008/11/14
[ "https://Stackoverflow.com/questions/291493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/455213/" ]
I've been struggling with this check constraint for a few hours and was hoping someone would be kind enough to explain why this check constraint isn't doing what I think it should be doing. ``` ALTER TABLE CLIENTS add CONSTRAINT CHK_DISABILITY_INCOME_TYPE_ID CHECK ((IS_DISABLED IS NULL AND DISABILITY_INCOME_TYPE_ID IS...
While I do not have Oracle, I did a quick test with PostgreSQL and your first example (`IS_DISABLED` being `NULL` and `DISABILITY_INCOME_TYPE_ID` being 1): ``` postgres=> select (null is null and 1 is null); ?column? ---------- f (1 registro) postgres=> select (null is null and 1 is null) or (null = 0 and 1 is null...
291,508
<p>When A Python exception is thrown by code that spans multiple lines, e.g.:</p> <pre><code> myfoos = [foo("bar", "baz", "quux", i) for i in range(10)] </code></pre> <p>Python will report the line number of the last line, and will show the code fragment from that li...
[ { "answer_id": 291579, "author": "dragonjujo", "author_id": 37344, "author_profile": "https://Stackoverflow.com/users/37344", "pm_score": 0, "selected": false, "text": "<p>In a try/except block you can except NameError and try setting NameError.lineno, though I'm not exactly sure if or h...
2008/11/14
[ "https://Stackoverflow.com/questions/291508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
When A Python exception is thrown by code that spans multiple lines, e.g.: ``` myfoos = [foo("bar", "baz", "quux", i) for i in range(10)] ``` Python will report the line number of the last line, and will show the code fragment from that line: ``` Traceback (most r...
Finding the beginning of the line will be really hard. You'll have to either parse the Python or maybe dig into the compiled byte code. There are modules in the standard library for parsing Python, but I can tell you from experience that interpreting their output is a black art. And I'm not sure the compiled byte code ...
291,519
<p>In the Windows registry, how does <code>CurrentControlSet</code> differ from <code>ControlSet001</code> and <code>ControlSet002</code>? Which should be set when installing for all users?</p> <p>We are trying to add an environment variable for all users. Is this correct?</p> <pre><code>HKLM\SYSTEM\CurrentControlSet\C...
[ { "answer_id": 291528, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 7, "selected": true, "text": "<p>Yes, you only need to update the <code>CurrentControlSet</code> key...</p>\n\n<p><code>ControlSet001</code> and <cod...
2008/11/14
[ "https://Stackoverflow.com/questions/291519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17975/" ]
In the Windows registry, how does `CurrentControlSet` differ from `ControlSet001` and `ControlSet002`? Which should be set when installing for all users? We are trying to add an environment variable for all users. Is this correct? ``` HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Envinronment ```
Yes, you only need to update the `CurrentControlSet` key... `ControlSet001` and `ControlSet002` are alternating backups of `CurrentControlSet`, you don't need to update them. Edit: As K noted, `CurrentControlSet` is an alternating symbolic link to either `ControlSet001` or `ControlSet002`. The other key is kept as a ...
291,522
<p>I have a simple WPF application with a menu. I need to add menu items dynamically at runtime. When I simply create a new menu item, and add it onto its parent MenuItem, it does not display in the menu, regardless of if UpdateLayout is called.</p> <p>What must happen to allow a menu to have additional items dynami...
[ { "answer_id": 291550, "author": "Whytespot", "author_id": 33185, "author_profile": "https://Stackoverflow.com/users/33185", "pm_score": 6, "selected": true, "text": "<pre><code>//Add to main menu\nMenuItem newMenuItem1 = new MenuItem();\nnewMenuItem1.Header = \"Test 123\";\nthis.MainMen...
2008/11/14
[ "https://Stackoverflow.com/questions/291522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18313/" ]
I have a simple WPF application with a menu. I need to add menu items dynamically at runtime. When I simply create a new menu item, and add it onto its parent MenuItem, it does not display in the menu, regardless of if UpdateLayout is called. What must happen to allow a menu to have additional items dynamically added ...
``` //Add to main menu MenuItem newMenuItem1 = new MenuItem(); newMenuItem1.Header = "Test 123"; this.MainMenu.Items.Add(newMenuItem1); //Add to a sub item MenuItem newMenuItem2 = new MenuItem(); MenuItem newExistMenuItem = (MenuItem)this.MainMenu.Items[0]; newMenuItem2.Header = "Test 456"; newExistMenuItem.Items.Add(...
291,527
<p>I'm working on a website that uses not just frames, but frames within frames (ew, I know, but I don't get to choose). It actually works OK most of the time, but I'm running into a problem with some of the frames within frames in Safari (only).</p> <p>Some of the two-deep frames render in Safari with a small space ...
[ { "answer_id": 291550, "author": "Whytespot", "author_id": 33185, "author_profile": "https://Stackoverflow.com/users/33185", "pm_score": 6, "selected": true, "text": "<pre><code>//Add to main menu\nMenuItem newMenuItem1 = new MenuItem();\nnewMenuItem1.Header = \"Test 123\";\nthis.MainMen...
2008/11/14
[ "https://Stackoverflow.com/questions/291527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18860/" ]
I'm working on a website that uses not just frames, but frames within frames (ew, I know, but I don't get to choose). It actually works OK most of the time, but I'm running into a problem with some of the frames within frames in Safari (only). Some of the two-deep frames render in Safari with a small space on the righ...
``` //Add to main menu MenuItem newMenuItem1 = new MenuItem(); newMenuItem1.Header = "Test 123"; this.MainMenu.Items.Add(newMenuItem1); //Add to a sub item MenuItem newMenuItem2 = new MenuItem(); MenuItem newExistMenuItem = (MenuItem)this.MainMenu.Items[0]; newMenuItem2.Header = "Test 456"; newExistMenuItem.Items.Add(...
291,537
<p>As a followup to <a href="https://stackoverflow.com/questions/290335/how-can-i-position-an-element-at-the-bottom-of-its-container-in-firefox">this question</a> on absolute positioning within a table cell, I'm trying to get something working in Firefox. Once again, I'm about 95% there, and there's just 1 little thin...
[ { "answer_id": 291597, "author": "Varun Mehta", "author_id": 31537, "author_profile": "https://Stackoverflow.com/users/31537", "pm_score": 0, "selected": false, "text": "<p>Are you just trying to get the backrground to match the same colour? and not alignment, then you can use a backgrou...
2008/11/14
[ "https://Stackoverflow.com/questions/291537", "https://Stackoverflow.com", "https://Stackoverflow.com/users/96/" ]
As a followup to [this question](https://stackoverflow.com/questions/290335/how-can-i-position-an-element-at-the-bottom-of-its-container-in-firefox) on absolute positioning within a table cell, I'm trying to get something working in Firefox. Once again, I'm about 95% there, and there's just 1 little thing that's keepin...
You could put (the same) fixed height on the table cell & wrap div thusly: ``` <style type="text/css"> table { width:500px; border-collapse:collapse} th, td { height:200px; border:1px solid black; vertical-align: top; } th { width:100px; } td { background:#ccc; } .wrap { position:relative; height:200px; padding-bottom...
291,559
<p>I'm building a project along with a Dll.</p> <p>The Dll must support native code so I declared it as a /clr. My project was initialy also a /clr project and everything was fine. However I'd like to include some NUnit testing so I had to switch my main project from /clr to /clr:pure.</p> <p>Everything still compile...
[ { "answer_id": 291660, "author": "Eric", "author_id": 6367, "author_profile": "https://Stackoverflow.com/users/6367", "pm_score": 3, "selected": true, "text": "<p>Ok everything is working now</p>\n\n<p>In fact, it has been working from the beginning.</p>\n\n<p>Moral : don't try to cast a...
2008/11/14
[ "https://Stackoverflow.com/questions/291559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6367/" ]
I'm building a project along with a Dll. The Dll must support native code so I declared it as a /clr. My project was initialy also a /clr project and everything was fine. However I'd like to include some NUnit testing so I had to switch my main project from /clr to /clr:pure. Everything still compiles but any Dll cal...
Ok everything is working now In fact, it has been working from the beginning. Moral : don't try to cast a char\* into a std::string Weird thing : its ok in /clr until you return from the function. It crashes right away in /clr:pure
291,574
<p>I want a query that returns a list of all the (user) stored procedures in a database by name, with the number of lines of code for each one.</p> <p>i.e.</p> <pre><code>sp_name lines_of_code -------- ------------- DoStuff1 120 DoStuff2 50 DoStuff3 30 </code></pre> <p>Any ideas how to do this?</p>
[ { "answer_id": 291633, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 7, "selected": true, "text": "<pre><code>select t.sp_name, sum(t.lines_of_code) - 1 as lines_ofcode, t.type_desc\nfrom\n(\n select o.name as sp_na...
2008/11/14
[ "https://Stackoverflow.com/questions/291574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161040/" ]
I want a query that returns a list of all the (user) stored procedures in a database by name, with the number of lines of code for each one. i.e. ``` sp_name lines_of_code -------- ------------- DoStuff1 120 DoStuff2 50 DoStuff3 30 ``` Any ideas how to do this?
``` select t.sp_name, sum(t.lines_of_code) - 1 as lines_ofcode, t.type_desc from ( select o.name as sp_name, (len(c.text) - len(replace(c.text, char(10), ''))) as lines_of_code, case when o.xtype = 'P' then 'Stored Procedure' when o.xtype in ('FN', 'IF', 'TF') then 'Function' end as type_desc f...
291,582
<p>Using strictly SQL (no PHP or anything else), is it possible to create a table <strong>and insert default data into that table</strong> only if that table doesn't exist?</p>
[ { "answer_id": 291626, "author": "Paul Morgan", "author_id": 16322, "author_profile": "https://Stackoverflow.com/users/16322", "pm_score": 3, "selected": true, "text": "<p>Use the CREATE TABLE ... SELECT format:</p>\n\n<pre>create table if not exists tablename as\nselect * from defaultda...
2008/11/14
[ "https://Stackoverflow.com/questions/291582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32881/" ]
Using strictly SQL (no PHP or anything else), is it possible to create a table **and insert default data into that table** only if that table doesn't exist?
Use the CREATE TABLE ... SELECT format: ``` create table if not exists tablename as select * from defaultdata; ```
291,603
<p>How can I tell the preprocessor not to replace a specific macro?</p> <p>The specific problem is the following: Windows header files define the GetMessage macro.</p> <p>My C++ header files with my API have a GetMessage method. I do not want to rename my method. But when using the API on Windows, including windows.h...
[ { "answer_id": 291615, "author": "ShoeLace", "author_id": 3825, "author_profile": "https://Stackoverflow.com/users/3825", "pm_score": 3, "selected": false, "text": "<p>have you tried just doing an</p>\n\n<pre>#undef GetMessage</pre>\n\n<p>or even</p>\n\n<pre>#ifdef GetMessage\n#undef Get...
2008/11/14
[ "https://Stackoverflow.com/questions/291603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37820/" ]
How can I tell the preprocessor not to replace a specific macro? The specific problem is the following: Windows header files define the GetMessage macro. My C++ header files with my API have a GetMessage method. I do not want to rename my method. But when using the API on Windows, including windows.h replaces my GetM...
have you tried just doing an ``` #undef GetMessage ``` or even ``` #ifdef GetMessage #undef GetMessage #endif ``` and then calling the windows GetMessageA or GetMessageW directly, whichever is appropriate. you should know if you are using char\* for wchar\_t8.. (thanks don.neufeld) Brian also says that Jus some ...
291,605
<p>I am being sent an xml feed via multicast, but I don't know the multicast group address. Can I just use localhost instead?</p> <pre><code>Socket socket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp); IPEndPoint ip = new IPEndPoint(IPAddress.Any,8888); socket.Bind(ip); socket.SetSock...
[ { "answer_id": 291627, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>No.</p>\n\n<p>You (your client) needs to join the multicast group, you'll AddMembership to the multicast group IP, then c...
2008/11/14
[ "https://Stackoverflow.com/questions/291605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am being sent an xml feed via multicast, but I don't know the multicast group address. Can I just use localhost instead? ``` Socket socket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp); IPEndPoint ip = new IPEndPoint(IPAddress.Any,8888); socket.Bind(ip); socket.SetSocketOption (...
No. You (your client) needs to join the multicast group, you'll AddMembership to the multicast group IP, then connect. Otherwise you won't be able to receive the multicast feed. Your code would work with a UDP broadcast though.
291,620
<p>When you assign a date to a named SQL parameter Hibernate automatically converts it to GMT time. How do you make it use the current server timezone for all dates?</p> <p>Lets say you have a query:</p> <pre><code>Query q = session.createQuery("from Table where date_field &lt; :now"); q.setDate("now", new java.util....
[ { "answer_id": 291644, "author": "Clay", "author_id": 37104, "author_profile": "https://Stackoverflow.com/users/37104", "pm_score": 2, "selected": false, "text": "<p>Hibernate is ignorant of timezones. Any timezone conversion should be done prior to executing the query. </p>\n\n<p>E.g., ...
2008/11/14
[ "https://Stackoverflow.com/questions/291620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128/" ]
When you assign a date to a named SQL parameter Hibernate automatically converts it to GMT time. How do you make it use the current server timezone for all dates? Lets say you have a query: ``` Query q = session.createQuery("from Table where date_field < :now"); q.setDate("now", new java.util.Date()); ``` "now" wil...
As it turned out Hibernate doesn't convert dates to GMT automatically, it just cuts off time if you use `query.setDate()`, so if you pass "2009-01-16 12:13:14" it becomes "2009-01-16 00:00:00". To take time into consideration you need to use `query.setTimestamp("date", dateObj)` instead.
291,623
<p>I am trying to design a location lookup in which the user can specify a location to any desired level of accuracy. eg. one of Country, State, City, Borough etc,</p> <p>I have a used a common location table, which will then be used in a lookup with the table name selected dynamically, but was wondering if there is a...
[ { "answer_id": 291634, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 3, "selected": true, "text": "<p>You might consider something like:</p>\n\n<pre><code>locations\n id int\n parentId int\n name varchar(45)\n</code></pre>\...
2008/11/14
[ "https://Stackoverflow.com/questions/291623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36670/" ]
I am trying to design a location lookup in which the user can specify a location to any desired level of accuracy. eg. one of Country, State, City, Borough etc, I have a used a common location table, which will then be used in a lookup with the table name selected dynamically, but was wondering if there is a feasible ...
You might consider something like: ``` locations id int parentId int name varchar(45) ``` From this perspective you could load any type of location with any level depth.
291,624
<p>I need to extract some bitmaps from an .msstyles file (the Windows XP visual style files) and I'm not sure where to start. I can't seem to find any documentation on how to do it, and the file format seems to be binary and not easily parsed. I have been able to extract the bitmap by itself using:</p> <pre><code>IntP...
[ { "answer_id": 291850, "author": "waynecolvin", "author_id": 35658, "author_profile": "https://Stackoverflow.com/users/35658", "pm_score": 3, "selected": true, "text": "<p><a href=\"http://filext.com/file-extension/MSSTYLES\" rel=\"nofollow noreferrer\" title=\"File Extensions\">This</a>...
2008/11/14
[ "https://Stackoverflow.com/questions/291624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
I need to extract some bitmaps from an .msstyles file (the Windows XP visual style files) and I'm not sure where to start. I can't seem to find any documentation on how to do it, and the file format seems to be binary and not easily parsed. I have been able to extract the bitmap by itself using: ``` IntPtr p = LoadLib...
[This](http://filext.com/file-extension/MSSTYLES "File Extensions") site claims the file format is documented though not by Microsoft. Also found this in the [Wine Crossreference](http://source.winehq.org/source/dlls/uxtheme/msstyles.c "msstyles.c"). Hope that helps!
291,631
<p>I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had been using <a href="http://web.archive.org/web/20001205122400/http&#58;//www.eccentrica.org/gabr/gpprofile/gpprofile.htm" rel="noreferrer">GpProfile by Primoz Gabrijelcic</a> as a profiler and <a href="http://web.archive.org/web/20031204135824/htt...
[ { "answer_id": 291672, "author": "mghie", "author_id": 30568, "author_profile": "https://Stackoverflow.com/users/30568", "pm_score": 1, "selected": false, "text": "<p>It's true, for profiling I miss Primoz' GpProfile, and haven't found a good replacement. I once tried AQTime, but wasn't...
2008/11/14
[ "https://Stackoverflow.com/questions/291631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30176/" ]
I recently upgraded from Delphi 4 to Delphi 2009. With Delphi 4 I had been using [GpProfile by Primoz Gabrijelcic](http://web.archive.org/web/20001205122400/http://www.eccentrica.org/gabr/gpprofile/gpprofile.htm) as a profiler and [Memory Sleuth by Turbo Power](http://web.archive.org/web/20031204135824/http://www.turbo...
For the price, you cannot beat FastMM4 as a memory tracker. It's simple to use yet powerful and well integrated with Delphi. I guess that you know that, without downloading, installing or changing anything else, just putting this line ``` ReportMemoryLeaksOnShutDown := True; ``` anywhere in your code, will enable...
291,647
<p>I embedded a swf in my html page, but I would like it to swap to another swf when I clicked on a button in html. I used swfobject.js to embed the swf, and I use prototype to write the javascript. I thought I can just do this</p> <pre><code>$('movie').value = 'swf/bhts.swf'; alert($('movie').value); </code></pre> <...
[ { "answer_id": 291656, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>Using swfObject:</p>\n\n<pre><code>&lt;div id='flashContent'&gt;\n&lt;/div&gt;\n\n&lt;script type='text/javascript'&gt; ...
2008/11/14
[ "https://Stackoverflow.com/questions/291647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34797/" ]
I embedded a swf in my html page, but I would like it to swap to another swf when I clicked on a button in html. I used swfobject.js to embed the swf, and I use prototype to write the javascript. I thought I can just do this ``` $('movie').value = 'swf/bhts.swf'; alert($('movie').value); ``` the value did change to ...
Using swfObject: ``` <div id='flashContent'> </div> <script type='text/javascript'> // Setup your initial flash var so = new SwfObject(.....); so.write ('flashContent'); // Some event handler someElement.onclick = function () { // Load up the new SWF so = new swfObject(...
291,673
<p>I'd love to do this:</p> <pre><code>UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n; </code></pre> <p>Is there code available to do this? I known this should be possible as the <a href="http://dev.mysql.com/doc/refman/5.0/en/udf-compiling.html" rel="nofollow noreferrer">MySQL Docs</a> include an ...
[ { "answer_id": 291808, "author": "andyuk", "author_id": 2108, "author_profile": "https://Stackoverflow.com/users/2108", "pm_score": 2, "selected": false, "text": "<p>I don't know of any function like that as part of MySQL.\nAre you just trying to retreive HTML data from many URLs?</p>\n\...
2008/11/14
[ "https://Stackoverflow.com/questions/291673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I'd love to do this: ``` UPDATE table SET blobCol = HTTPGET(urlCol) WHERE whatever LIMIT n; ``` Is there code available to do this? I known this should be possible as the [MySQL Docs](http://dev.mysql.com/doc/refman/5.0/en/udf-compiling.html) include an example of adding a function that does a DNS lookup. MySQL / w...
No, thank goodness — it would be a security horror. Every SQL injection hole in an application could be leveraged to start spamming connections to attack other sites. You could, I suppose, write it in C and compile it as a UDF. But I don't think it really gets you anything in comparison to just SELECTing in your appli...
291,696
<p>Have you ever had alternating background colors in a Jasper report and then exported it to Excel? The Excel export seems to ignore the alternating color.</p> <p>I've got a Jasper report where the rows alternating background color using the procedure referenced <a href="http://www.brianburridge.com/2006/06/19/highl...
[ { "answer_id": 291907, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "<p>Did you try the idea suggested in the <a href=\"http://www.brianburridge.com/2006/06/19/highlighting-odd-even-rows-jasperrepo...
2008/11/14
[ "https://Stackoverflow.com/questions/291696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23904/" ]
Have you ever had alternating background colors in a Jasper report and then exported it to Excel? The Excel export seems to ignore the alternating color. I've got a Jasper report where the rows alternating background color using the procedure referenced [HERE](http://www.brianburridge.com/2006/06/19/highlighting-odd-e...
Did you try the idea suggested in the [comment](http://www.brianburridge.com/2006/06/19/highlighting-odd-even-rows-jasperreports/comment-page-2/#comment-8837) of the very procedure you are referring to ? First how to create new report style with condition: > > Recent releases of JasperReports include report styles, ...
291,704
<p>We have an advanced webpage (ASP.NET, C#), and a application which needs to be installed on the client computer in order to utilize the webpage to its fullest. The application is a tray app, and has primarily two tasks. Detect when certain events happen on the webserver (for instance invited to a meeting, or notify ...
[ { "answer_id": 291747, "author": "JohnFx", "author_id": 30018, "author_profile": "https://Stackoverflow.com/users/30018", "pm_score": 3, "selected": false, "text": "<p>When installing your client-side app you could modify the browser configuration to include another request header in HTT...
2008/11/14
[ "https://Stackoverflow.com/questions/291704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33431/" ]
We have an advanced webpage (ASP.NET, C#), and a application which needs to be installed on the client computer in order to utilize the webpage to its fullest. The application is a tray app, and has primarily two tasks. Detect when certain events happen on the webserver (for instance invited to a meeting, or notify of ...
If you want to detect with javascript inside the browser, you can probably use the collection "navigator.plugins". It works with Firefox, Opera and Chrome but unfortunately not with IE. Update: In FF, Opera and Chrome you can test it easily like this: ``` if (navigator.plugins["Adobe Acrobat"]) { // do some stuff if...
291,705
<p>Someone posted a great little function here the other day that separated the full path of a file into several parts that looked like this:</p> <pre><code>Function BreakDown(Full As String, FName As String, PName As String, Ext As String) As Integer If Full = "" Then BreakDown = False Exit Function End If If In...
[ { "answer_id": 291732, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 0, "selected": false, "text": "<p>If you just have blank characters then just add this as the first line</p>\n\n<pre><code>Full = Trim(Full)\n</code></pre>\n...
2008/11/14
[ "https://Stackoverflow.com/questions/291705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Someone posted a great little function here the other day that separated the full path of a file into several parts that looked like this: ``` Function BreakDown(Full As String, FName As String, PName As String, Ext As String) As Integer If Full = "" Then BreakDown = False Exit Function End If If InStr(Full, "\")...
``` Dot% = InStrRev(Full, ".") ' First . from end of string If Dot% <> 0 Then Ext = Mid$(Full, Dot%, 3) Else Ext = "" End If ``` Mid$ syntax: Mid(string, start[, length])
291,744
<p>I've created a windows forms control, which is hosted in a web page viewable with Internet Explorer.</p> <p>My control reads from a com port and it writes to the event log. Both of these operations by default fail when the framework requests proper permissions. This web application will always be running in the i...
[ { "answer_id": 291782, "author": "Aaron Fischer", "author_id": 5618, "author_profile": "https://Stackoverflow.com/users/5618", "pm_score": 2, "selected": true, "text": "<p>You would need to create an installer or have your users grant a higher trust level for your website. These settings...
2008/11/14
[ "https://Stackoverflow.com/questions/291744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9266/" ]
I've created a windows forms control, which is hosted in a web page viewable with Internet Explorer. My control reads from a com port and it writes to the event log. Both of these operations by default fail when the framework requests proper permissions. This web application will always be running in the intranet zone...
You would need to create an installer or have your users grant a higher trust level for your website. These settings are editable under Microsoft .NET Framework configuration. under Administrative Tools. You can also take a look at [Chris Sells Wahoo](http://www.sellsbrothers.com/wahoo/) which uses an installer to gran...
291,774
<p>What is the regex for a alpha numeric word, at least 6 characters long (but at most 50).</p>
[ { "answer_id": 291783, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 0, "selected": false, "text": "<p>With PCRE regex you could do this:</p>\n\n<pre><code>/[a-zA-Z0-9]{6,50}/\n</code></pre>\n\n<p>It would be very hard to ...
2008/11/14
[ "https://Stackoverflow.com/questions/291774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the regex for a alpha numeric word, at least 6 characters long (but at most 50).
``` /[a-zA-Z0-9]{6,50}/ ``` You can use word boundaries at the beginning/end (\b) if you want to actually match a word within text. ``` /\b[a-zA-Z0-9]{6,50}\b/ ```
291,780
<p>Hey, I'm really new to Haskell and have been using more classic programming languages my whole life. I have no idea what is going on here. I'm trying to make a very simple Viterbi algorithm implementation, but for only two states (honest and dishonest casino)</p> <p>I have a problem where I want to address my arr...
[ { "answer_id": 291836, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 4, "selected": false, "text": "<p>I copied the code from the edit window (something in stackoverflow's parser is eating part of the code) and tried it on ...
2008/11/14
[ "https://Stackoverflow.com/questions/291780", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37840/" ]
Hey, I'm really new to Haskell and have been using more classic programming languages my whole life. I have no idea what is going on here. I'm trying to make a very simple Viterbi algorithm implementation, but for only two states (honest and dishonest casino) I have a problem where I want to address my array, but I do...
I copied the code from the edit window (something in stackoverflow's parser is eating part of the code) and tried it on ghci, which found several errors. The first error was: ``` foo.hs:34:71: Couldn't match expected type `[e]' against inferred type `(a, b)' In the second argument of `listArray', namely ...
291,792
<p>I am creating my textbox with these options. I can Copy / Cut / Paste / Undo, but when I hit <strong>Select All</strong> it doesn't select all. I can right click and click <strong>Select All</strong> but <kbd>CTRL</kbd> + <kbd>A</kbd> doesn't do anything. Why?</p> <pre><code>wnd = CreateWindow(&quot;EDIT&quot;, 0, ...
[ { "answer_id": 291798, "author": "BoltBait", "author_id": 20848, "author_profile": "https://Stackoverflow.com/users/20848", "pm_score": 2, "selected": false, "text": "<p>You need to capture that keystroke and do the select all yourself.</p>\n\n<p>Here is some C# code for use with a RichT...
2008/11/14
[ "https://Stackoverflow.com/questions/291792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am creating my textbox with these options. I can Copy / Cut / Paste / Undo, but when I hit **Select All** it doesn't select all. I can right click and click **Select All** but `CTRL` + `A` doesn't do anything. Why? ``` wnd = CreateWindow("EDIT", 0, WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_HSCROLL | WS_VSCROLL |...
I tend to use MFC (forgive me) instead of Win32 so I cannot answer this definitively, but I noticed this comment added to a page on an MS site concerning talking with an Edit control (a simple editor within the Edit control): > > The edit control uses `WM_CHAR` for > accepting characters, not `WM_KEYDOWN` > etc. You ...
291,793
<p>Is there a way to recursively add all "non added" files to SVN?</p> <p>I want to do something like</p> <pre><code>svn add trunk/ </code></pre> <p>to add all new files, without getting:</p> <pre><code>svn: warning: 'trunk' is already under version control </code></pre> <p>If this is not possible, is there a way ...
[ { "answer_id": 291800, "author": "Jonas Kongslund", "author_id": 37548, "author_profile": "https://Stackoverflow.com/users/37548", "pm_score": 5, "selected": true, "text": "<p>Use the --force option.</p>\n\n<p>Example:</p>\n\n<pre><code>svn add * --force\n</code></pre>\n" }, { "a...
2008/11/14
[ "https://Stackoverflow.com/questions/291793", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
Is there a way to recursively add all "non added" files to SVN? I want to do something like ``` svn add trunk/ ``` to add all new files, without getting: ``` svn: warning: 'trunk' is already under version control ``` If this is not possible, is there a way to get a list of all files that are not under version co...
Use the --force option. Example: ``` svn add * --force ```
291,828
<p>I wrote a function in C that converts a string to an integer and returns the integer. When I call the function I also want it to let me know if the string is not a valid number. In the past I returned -1 when this error occurred, because I didn't need to convert strings to negative numbers. But now I want it to conv...
[ { "answer_id": 291830, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 4, "selected": false, "text": "<p>a common way is to pass a pointer to a success flag like this:</p>\n\n<pre><code>int my_function(int *ok) {\n /* ...
2008/11/15
[ "https://Stackoverflow.com/questions/291828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/813/" ]
I wrote a function in C that converts a string to an integer and returns the integer. When I call the function I also want it to let me know if the string is not a valid number. In the past I returned -1 when this error occurred, because I didn't need to convert strings to negative numbers. But now I want it to convert...
There are several ways. All have their pluses and minuses. * Have the function return an error code and pass in a pointer to a location to return the result. The nice thing about this there's no overloading of the result. The bad thing is that you can't use the real result of the function directly in an expression. [...
291,829
<p>I have a file with several thousand rows and several columns separated with tabs What I'd like to do is loop through each individually, Drop the columns into an array so that I can place them in another application individually, then move onto the next line. Unfortunately I got about as far as this:</p> <pre><code...
[ { "answer_id": 291837, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 0, "selected": false, "text": "<p>Use the split command</p>\n\n<pre><code>Dim StringArray as Variant\n\nOpen mytextfile.txt For Input As #FileHandle\n Do Whi...
2008/11/15
[ "https://Stackoverflow.com/questions/291829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a file with several thousand rows and several columns separated with tabs What I'd like to do is loop through each individually, Drop the columns into an array so that I can place them in another application individually, then move onto the next line. Unfortunately I got about as far as this: ``` Open mytextfil...
``` Dim str() as String Open mytextfile.txt For Input As #FileHandle Do While Not EOF(FileHandle) Line Input #FileHandle, IndividualLine str = Split(IndividualLine, vbTab) Debug.Print str(0) 'First array element Loop ``` To clarify: I would avoid the use of Variants and use vbTab.
291,841
<p>For example, will the first piece of code perform a full search twice, or is it smart enough to cache results if no DOM changes have occurred?</p> <pre><code>if ($("#navbar .heading").text() &gt; "") { $("#navbar .heading").hide(); } </code></pre> <p>and </p> <pre><code>var $heading = $("#navbar .heading"); if...
[ { "answer_id": 291859, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 2, "selected": false, "text": "<p>i don't believe jquery does any caching of selectors, instead relying on xpath/javascript underneath to handle that. that be...
2008/11/15
[ "https://Stackoverflow.com/questions/291841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
For example, will the first piece of code perform a full search twice, or is it smart enough to cache results if no DOM changes have occurred? ``` if ($("#navbar .heading").text() > "") { $("#navbar .heading").hide(); } ``` and ``` var $heading = $("#navbar .heading"); if ($heading.text() > "") { $heading.hid...
jQuery doesn't, but there's the possibility of assigning to variables within your expression and then use re-using those in subsequent expressions. So, cache-ifying your example ... ``` if ((cached = $("#navbar .heading")).text() > "") { cached.hide(); } ``` Downside is it makes the code a bit fuglier and difficul...
291,844
<p>Which is faster? This:</p> <pre><code>bool isEqual = (MyObject1 is MyObject2) </code></pre> <p>Or this:</p> <pre><code>bool isEqual = ("blah" == "blah1") </code></pre> <p>It would be helpful to figure out which one is faster. Obviously, if you apply .ToUpper() to each side of the string comparison like programme...
[ { "answer_id": 291852, "author": "HanClinto", "author_id": 26933, "author_profile": "https://Stackoverflow.com/users/26933", "pm_score": 0, "selected": false, "text": "<p>How about you tell me? :)</p>\n\n<p>Take the code from <a href=\"http://www.codinghorror.com/blog/archives/001178.htm...
2008/11/15
[ "https://Stackoverflow.com/questions/291844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28661/" ]
Which is faster? This: ``` bool isEqual = (MyObject1 is MyObject2) ``` Or this: ``` bool isEqual = ("blah" == "blah1") ``` It would be helpful to figure out which one is faster. Obviously, if you apply .ToUpper() to each side of the string comparison like programmers often do, that would require reallocating memo...
I'm a little confused here. As other answers have noted, you're comparing apples and oranges. `::rimshot::` If you want to determine if an object is of a certain type use the `is` operator. If you want to compare strings use the `==` operator (or other appropriate comparison method if you need something fancy like c...
291,849
<p>What is the simplest way in VB6 to loop through all the files in a specified folder directory and get their names?</p>
[ { "answer_id": 291882, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 5, "selected": true, "text": "<pre><code>sFilename = Dir(sFoldername)\n\nDo While sFilename &gt; \"\"\n\n debug.print sFilename \n sFilename = Dir()\n\nLoo...
2008/11/15
[ "https://Stackoverflow.com/questions/291849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4872/" ]
What is the simplest way in VB6 to loop through all the files in a specified folder directory and get their names?
``` sFilename = Dir(sFoldername) Do While sFilename > "" debug.print sFilename sFilename = Dir() Loop ```
291,853
<p>Doesn't an ORM usually involve doing something like a select *?</p> <p>If I have a table, MyThing, with column A, B, C, D, etc, then there typically would be an object, MyThing with properties A, B, C, D. </p> <p>It would be evil if that object were incompletely instantiated by a select statement that looked lik...
[ { "answer_id": 291863, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 0, "selected": false, "text": "<p>SELECT * is not bad. Did you ask whoever considered it to be bad \"why?\".</p>\n" }, { "answer_id": 291864, ...
2008/11/15
[ "https://Stackoverflow.com/questions/291853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
Doesn't an ORM usually involve doing something like a select \*? If I have a table, MyThing, with column A, B, C, D, etc, then there typically would be an object, MyThing with properties A, B, C, D. It would be evil if that object were incompletely instantiated by a select statement that looked like this, only fetch...
In my limited experience, things are as you describe--it's a messy situation and the usual cop-out "it depends" answer applies. A good example would be the online store that I work for. It has a `Brand` object, and on the main page of the Web site, all of the brands that the store sells are listed on the left side. To...
291,868
<p>Is there a built in function equivalent to .NET's</p> <pre><code>Guid.NewGuid(); </code></pre> <p>in Cocoa?</p> <p>My desire is to produce a string along the lines of <code>550e8400-e29b-41d4-a716-446655440000</code> which represents a unique identifier.</p>
[ { "answer_id": 291892, "author": "waynecolvin", "author_id": 35658, "author_profile": "https://Stackoverflow.com/users/35658", "pm_score": 2, "selected": false, "text": "<p>Check out the <a href=\"http://en.wikipedia.org/wiki/UUID\" rel=\"nofollow noreferrer\" title=\"GUID\">Wikipedia</a...
2008/11/15
[ "https://Stackoverflow.com/questions/291868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
Is there a built in function equivalent to .NET's ``` Guid.NewGuid(); ``` in Cocoa? My desire is to produce a string along the lines of `550e8400-e29b-41d4-a716-446655440000` which represents a unique identifier.
UUIDs are handled in Core Foundation, by the CFUUID library. The function you are looking for is [CFUUIDCreate](http://Developer.Apple.Com/documentation/CoreFoundation/Reference/CFUUIDRef/Reference/reference.html#//apple_ref/c/func/CFUUIDCreate). FYI for further searches: these are most commonly known as UUIDs, the te...
291,871
<p>Is there a way to cancel a pending operation (without disconnect) or set a timeout for the boost library functions?</p> <p>I.e. I want to set a timeout on blocking socket in boost asio?</p> <p>socket.read_some(boost::asio::buffer(pData, maxSize), error_);</p> <p>Example: I want to read some from the socket, but I...
[ { "answer_id": 292183, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": -1, "selected": false, "text": "<p>On *nix, you'd use alarm() so your socket call would fail with EINTR</p>\n" }, { "answer_id": 292438, "aut...
2008/11/15
[ "https://Stackoverflow.com/questions/291871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
Is there a way to cancel a pending operation (without disconnect) or set a timeout for the boost library functions? I.e. I want to set a timeout on blocking socket in boost asio? socket.read\_some(boost::asio::buffer(pData, maxSize), error\_); Example: I want to read some from the socket, but I want to throw an erro...
Under Linux/BSD the timeout on I/O operations on sockets is directly supported by the operating system. The option can be enabled via `setsocktopt()`. I don't know if `boost::asio` provides a method for setting it or exposes the socket scriptor to allow you to directly set it -- the latter case is not really portable. ...
291,885
<p>Sounds like a weird question, but say I have something like this:</p> <pre><code>$.post( "/myajax.php", { "param1": value1, "param2": value2 }, function( data, status ) { if( status == "success" ) { $("#someid").html( data ); } }, "html" ); </code></pre...
[ { "answer_id": 291890, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 0, "selected": false, "text": "<p>Check out <a href=\"http://www.ja-sig.org/products/cas/index.html\" rel=\"nofollow noreferrer\">JA-SIG CAS</a>. Eve...
2008/11/15
[ "https://Stackoverflow.com/questions/291885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1821/" ]
Sounds like a weird question, but say I have something like this: ``` $.post( "/myajax.php", { "param1": value1, "param2": value2 }, function( data, status ) { if( status == "success" ) { $("#someid").html( data ); } }, "html" ); ``` While myajax.php is ...
When a user accesses an application URL without a session cookie, he is redirected to the SSO system. He then logs into the SSO form, which then redirects him back to your app with a ticket ID that you can look up in the SSO system to get cridentials. Also, take a look at [Crowd](http://www.atlassian.com/software/crow...
291,888
<p>I've got a stock standard ASP.NET website. Anyone can read/view any page (except the admin section) but when someone wants to contribute, they need to be logged in. Just like most contribution sites out there.</p> <p>So, if i have my OWN login control or username/password/submit input fields, why would i want to ha...
[ { "answer_id": 291913, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>You can authorize your users how ever you want. FormAuthentication is used to set the session identity and the auth...
2008/11/15
[ "https://Stackoverflow.com/questions/291888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
I've got a stock standard ASP.NET website. Anyone can read/view any page (except the admin section) but when someone wants to contribute, they need to be logged in. Just like most contribution sites out there. So, if i have my OWN login control or username/password/submit input fields, why would i want to have forms a...
You can authorize your users how ever you want. FormAuthentication is used to set the session identity and the authentication cookie that allows users to stay logged in until they logout or the session expires. You don't need to use the membership providers to use FormsAuthentication. It sounds like you are just replic...
291,908
<p>I would like to match &quot;approximate&quot; matches in Web.SiteMap</p> <p>The Web.Sitemap static sitemap provider works well, except for one thing. IT'S STATIC!</p> <p>So, if I would have to have a sitemapnode for each of the 10,000 articles on my page like so :</p> <ul> <li>site.com/articles/1/article-title</li>...
[ { "answer_id": 301744, "author": "user39603", "author_id": 39603, "author_profile": "https://Stackoverflow.com/users/39603", "pm_score": 2, "selected": false, "text": "<p>This is not entirely an answer to your question I think, but maybe it gives you an idea. I once wrote a DynamicSiteMa...
2008/11/15
[ "https://Stackoverflow.com/questions/291908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26931/" ]
I would like to match "approximate" matches in Web.SiteMap The Web.Sitemap static sitemap provider works well, except for one thing. IT'S STATIC! So, if I would have to have a sitemapnode for each of the 10,000 articles on my page like so : * site.com/articles/1/article-title * site.com/articles/2/another-article-ti...
This is in response to the comment above. I can't post the full code, but this is basically how my provider works. Suppose you have a page article.aspx, and it uses query string parameter "id" to retrieve and display an article title and body. Then this is in Web.sitemap: ``` <siteMapNode url="/article.aspx" title="(...
291,922
<p>I have a nested function to show/hide paragraphs news-ticker-style.</p> <p>The problem is that when the loop starts over (line 4), the opacity effects stop working correctly so the paragraphs appear abruptly. </p> <p>Any jquery masters know about this? Am I making this too hard?</p> <pre><code>$('#special-ticker ...
[ { "answer_id": 292020, "author": "Owen", "author_id": 4853, "author_profile": "https://Stackoverflow.com/users/4853", "pm_score": 4, "selected": true, "text": "<p>the problem is line 9:</p>\n\n<pre><code>$(this).animate({opacity:100},10000,null,function(){\n//...\n</code></pre>\n\n<p>opa...
2008/11/15
[ "https://Stackoverflow.com/questions/291922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33822/" ]
I have a nested function to show/hide paragraphs news-ticker-style. The problem is that when the loop starts over (line 4), the opacity effects stop working correctly so the paragraphs appear abruptly. Any jquery masters know about this? Am I making this too hard? ``` $('#special-ticker p').hide(); var a=0; functio...
the problem is line 9: ``` $(this).animate({opacity:100},10000,null,function(){ //... ``` opacity should be "1" (opacity is a value between 0 and 1) ``` $(this).animate({ opacity : 1 }, 10000, null, function() { ```
291,927
<p>I have a Canvas in a Flex application which has items inside it that cover only about 50% of the area of the main canvas.</p> <p>i want the canvas to respond to <code>rollOver</code> events for the full area, and not just the area that is covered by the items inside.</p> <p>I have been setting the following attrib...
[ { "answer_id": 291959, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": -1, "selected": false, "text": "<p>You could do this:</p>\n\n<pre>\n<code>\n\nimport flash.event.MouseEvent;\n...\ncanvas.addEventListener(MouseEvent.ROLL_...
2008/11/15
[ "https://Stackoverflow.com/questions/291927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I have a Canvas in a Flex application which has items inside it that cover only about 50% of the area of the main canvas. i want the canvas to respond to `rollOver` events for the full area, and not just the area that is covered by the items inside. I have been setting the following attributes to achieve this : ``` ...
What you are doing is perfectly acceptable, although using the arbitrary alpha value of 0.01 is unnecessary, you can set it's backgroundAlpha to a simple 0. I routinely use Canvases for complicated multi layered UI's and set up my default Canvas style via css to have a backgroundAlpha of 0 and a backgroundColor of #ff...
291,938
<p>i did this in msvc 2005.</p> <pre><code>typedef void (*cleanup_t)(); void func(cleanup_t clean) { cleanup_t(); } </code></pre> <p>Why does this compile? and not give me a warning? ok, it gave me a unreferenced formal parameter warning but originally i did this when clean was in a class no there was no unrefer...
[ { "answer_id": 291952, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 4, "selected": false, "text": "<p>I think it's an expression that evaluates to a default value for a cleanup_t type. In other words, an expression ...
2008/11/15
[ "https://Stackoverflow.com/questions/291938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i did this in msvc 2005. ``` typedef void (*cleanup_t)(); void func(cleanup_t clean) { cleanup_t(); } ``` Why does this compile? and not give me a warning? ok, it gave me a unreferenced formal parameter warning but originally i did this when clean was in a class no there was no unreferenced formal parameter whe...
It's executing a default initializer for the cleanup\_t type to create a temporary of that type, and then never actually using that temporary. It's a lot like a constructor call, the "MyClass()" part of "MyClass c = MyClass();", except that pointer-to-function types don't actually have constructors. Of course in my c...
291,939
<p>while exploring jQuery I came up with the following weird script. I don't see myself doing this really however concatenating strings to achieve a variable name is not unusual in JavaScript. </p> <p>Any feedback welcome.</p> <pre><code>... &lt;script type="text/javascript"&gt; var a = 'y'; $(doc...
[ { "answer_id": 291948, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 3, "selected": true, "text": "<p>Short answer is no, there aren't side-effects. Your example is quirky, but as you said you were just exploring to...
2008/11/15
[ "https://Stackoverflow.com/questions/291939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34565/" ]
while exploring jQuery I came up with the following weird script. I don't see myself doing this really however concatenating strings to achieve a variable name is not unusual in JavaScript. Any feedback welcome. ``` ... <script type="text/javascript"> var a = 'y'; $(document).ready(function() { ...
Short answer is no, there aren't side-effects. Your example is quirky, but as you said you were just exploring to see what you could do. I have used string concatenation and function value returns inside jQuery selectors before, it can be a useful technique for managing sets of related elements which reside in differen...
291,945
<p>Say I have the following in my <code>models.py</code>:</p> <pre><code>class Company(models.Model): name = ... class Rate(models.Model): company = models.ForeignKey(Company) name = ... class Client(models.Model): name = ... company = models.ForeignKey(Company) base_rate = models.ForeignKey(Rate) ...
[ { "answer_id": 291968, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 9, "selected": true, "text": "<p>ForeignKey is represented by django.forms.ModelChoiceField, which is a ChoiceField whose choices are a model QuerySet. S...
2008/11/15
[ "https://Stackoverflow.com/questions/291945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3715/" ]
Say I have the following in my `models.py`: ``` class Company(models.Model): name = ... class Rate(models.Model): company = models.ForeignKey(Company) name = ... class Client(models.Model): name = ... company = models.ForeignKey(Company) base_rate = models.ForeignKey(Rate) ``` I.e. there are mult...
ForeignKey is represented by django.forms.ModelChoiceField, which is a ChoiceField whose choices are a model QuerySet. See the reference for [ModelChoiceField](http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield). So, provide a QuerySet to the field's `queryset` attribute. Depends on how your form ...
291,946
<p>Is it possible to use a TabContainer inside a templated FormView like so: </p> <pre><code> &lt;ItemTemplate&gt; &lt;cc1:TabContainer ID="TabContainer1" runat="server"&gt; &lt;cc1:TabPanel ID="Tab1" runat="server"&gt; &lt;HeaderTemplate&gt;Tab One&lt;/H...
[ { "answer_id": 291989, "author": "Bobby Borszich", "author_id": 35585, "author_profile": "https://Stackoverflow.com/users/35585", "pm_score": 1, "selected": false, "text": "<p>Haven't used the Tab container much but you need to define unique ID's for each element on the page. </p>\n\n<pr...
2008/11/15
[ "https://Stackoverflow.com/questions/291946", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22556/" ]
Is it possible to use a TabContainer inside a templated FormView like so: ``` <ItemTemplate> <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabPanel ID="Tab1" runat="server"> <HeaderTemplate>Tab One</HeaderTemplate> <ContentTemp...
Haven't used the Tab container much but you need to define unique ID's for each element on the page. ``` <cc1:TabContainer ID="TabContainer1" runat="server"> <cc1:TabContainer ID="TabContainer2" runat="server"> ```
291,976
<p>Having a relative path, how do I turn it into an absolute one from the location where the elisp file that I'm loading is. That is, I have an elisp file that I'm loading, it has an relative path and I need an absolute one.</p>
[ { "answer_id": 292001, "author": "Emerick Rogul", "author_id": 33837, "author_profile": "https://Stackoverflow.com/users/33837", "pm_score": 3, "selected": false, "text": "<p>You can use the <code>expand-file-name</code> function to convert a relative filename or path into an absolute fi...
2008/11/15
[ "https://Stackoverflow.com/questions/291976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6068/" ]
Having a relative path, how do I turn it into an absolute one from the location where the elisp file that I'm loading is. That is, I have an elisp file that I'm loading, it has an relative path and I need an absolute one.
``` 'file-truename ``` From the documentation: > > Return the truename of FILENAME, which > should be absolute. The truename of a > file name is found by chasing symbolic > links both at the level of the file > and at the level of the directories > containing it, until no links are left > at any level. > > ...
291,978
<p>What <strong>exactly</strong> are the Python scoping rules?</p> <p>If I have some code:</p> <pre><code>code1 class Foo: code2 def spam..... code3 for code4..: code5 x() </code></pre> <p>Where is <code>x</code> found? Some possible choices include the list below:</p> <ol> <li>In t...
[ { "answer_id": 292002, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": false, "text": "<p>Python resolves your variables with -- generally -- three namespaces available. </p>\n\n<blockquote>\n <p>At any time ...
2008/11/15
[ "https://Stackoverflow.com/questions/291978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1320510/" ]
What **exactly** are the Python scoping rules? If I have some code: ``` code1 class Foo: code2 def spam..... code3 for code4..: code5 x() ``` Where is `x` found? Some possible choices include the list below: 1. In the enclosing source file 2. In the class namespace 3. In the functio...
Actually, a concise rule for Python Scope resolution, from [Learning Python, 3rd. Ed.](https://rads.stackoverflow.com/amzn/click/com/0596513984). (These rules are specific to variable names, not attributes. If you reference it without a period, these rules apply.) **LEGB Rule** * **L**ocal — Names assigned in any way...
292,016
<p>I've been asked to find a way to connect from a Linux system to one of several Windows servers. What we need to do ideally is connect to whatever Windows server is causing the trouble, kill a process, and restart the process. Ideally, it would be something that could be put into a script that could be run from the...
[ { "answer_id": 292023, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 2, "selected": false, "text": "<p>I use <a href=\"http://www.cygwin.com/\" rel=\"nofollow noreferrer\">Cygwin</a> with OpenSSH server on the Windows b...
2008/11/15
[ "https://Stackoverflow.com/questions/292016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29801/" ]
I've been asked to find a way to connect from a Linux system to one of several Windows servers. What we need to do ideally is connect to whatever Windows server is causing the trouble, kill a process, and restart the process. Ideally, it would be something that could be put into a script that could be run from the Linu...
Cygwin's default ps/kill doesn't allow you to access Windows processes to kill them. Use [cygwin + openssh + windows services](http://pigtail.net/LRP/printsrv/cygwin-sshd.html) to get an SSH user on the machine. Once you're in an SSH commandline, you can use standard Win32 tools to kill a process, for instance - ```...
292,037
<p>I'm trying to highlight the search results but I want to include the surrounding text that is limited by the enclosing tags.</p> <p>So if the $term is "cool" the preg_replace should end up with:</p> <pre><code>&lt;div&gt;&lt;span style="background: #f00"&gt;My hair cut so cool!&lt;/span&gt;&lt;/div&gt; </code></pr...
[ { "answer_id": 292136, "author": "qualbeen", "author_id": 36975, "author_profile": "https://Stackoverflow.com/users/36975", "pm_score": -1, "selected": false, "text": "<p>Why the need of preg_replace?</p>\n\n<p>This is how i would have solved the problem:</p>\n\n<p>Case 1: <strong>Highli...
2008/11/15
[ "https://Stackoverflow.com/questions/292037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to highlight the search results but I want to include the surrounding text that is limited by the enclosing tags. So if the $term is "cool" the preg\_replace should end up with: ``` <div><span style="background: #f00">My hair cut so cool!</span></div> ``` Unfortunately my regex doesn't seem to capture th...
Finding a term and everything up to the HTML tags before and after it is the same as finding the term an all characters before and after it that aren't angular brackets. This is trivial with a regex: ``` $pattern = "/[^<>]*$term[^<>]*/i"; $replace = "<span style=\"background: #f00\">$0</span>"; ```
292,066
<p>This code is blunderous, as it adds a class to an array and later tries to pull it and manipulate it as if it were an object.</p> <pre><code>private function fail(event:Event):void { var myObj:MyClass; var a:ArrayCollection = new ArrayCollection(); var x:MyClass; var y:MyClass; myObj = new MyCl...
[ { "answer_id": 292077, "author": "Rob Walker", "author_id": 3631, "author_profile": "https://Stackoverflow.com/users/3631", "pm_score": 3, "selected": false, "text": "<p>I assume the exception occurred at the last line of your sample, not the error you have flagged 'BAD'.</p>\n\n<p>What ...
2008/11/15
[ "https://Stackoverflow.com/questions/292066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24734/" ]
This code is blunderous, as it adds a class to an array and later tries to pull it and manipulate it as if it were an object. ``` private function fail(event:Event):void { var myObj:MyClass; var a:ArrayCollection = new ArrayCollection(); var x:MyClass; var y:MyClass; myObj = new MyClass; a.add...
The question seems to me to be equivalent to,"Why can I use a class as a value?" It's a good question. There are two major things you can do with a class in ActionScript; you can *instantiate* it, and you can *access static properites* of it. (Okay, there are other things, but those are the obvious ones.) Instantiati...
292,068
<p>I have seen a lot of <code>ob_get_clean()</code> the last while. Typically I have done <code>$test .= 'test'</code></p> <p>I'm wondering if one is faster and/or better than the other.</p> <p>Here is the code using <code>ob_get_clean()</code>:</p> <pre><code>ob_start(); foreach($items as $item) { echo '&lt;di...
[ { "answer_id": 292087, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 3, "selected": false, "text": "<p>The results are the same, and I'd imagine the performance differences are negligible if any. Basically, a matter ...
2008/11/15
[ "https://Stackoverflow.com/questions/292068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I have seen a lot of `ob_get_clean()` the last while. Typically I have done `$test .= 'test'` I'm wondering if one is faster and/or better than the other. Here is the code using `ob_get_clean()`: ``` ob_start(); foreach($items as $item) { echo '<div>' . $item . '</div>'; } $test = ob_get_clean(); ``` Here is...
Output buffers have all the pitfalls of global variables. You have to be aware of all execution paths from the `ob_start()` to the `ob_get_clean()`. Are you sure it will get there, and that any buffers opened in between will have been closed? Keep in mind that code can throw exceptions. That can be a really fun bug for...
292,071
<p>I'm working on a game for the iPhone that has a drawing/paint mechanic involved and I'm having problems trying to create a tool that would erase things already painted.</p> <p>The main problem is that the background being painted on is not a solid color but a static image or animation. I've tried using different bl...
[ { "answer_id": 292140, "author": "Whaledawg", "author_id": 23829, "author_profile": "https://Stackoverflow.com/users/23829", "pm_score": 2, "selected": false, "text": "<p>You don't give much info, but I assume that your storing whatever they \"paint\" into a buffer and then drawing it on...
2008/11/15
[ "https://Stackoverflow.com/questions/292071", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37863/" ]
I'm working on a game for the iPhone that has a drawing/paint mechanic involved and I'm having problems trying to create a tool that would erase things already painted. The main problem is that the background being painted on is not a solid color but a static image or animation. I've tried using different blending opt...
Draw a full-screen textured quad over your scene. When the user draws a brush stroke, use `glTexSubImage2D` to update the your texture. glReadPixels/glDrawPixels is slow. Using FrameBufferObjects is even better, but I doubt this extention is available on the iPhone (then again, I don't know for sure, so maybe try it...
292,091
<p>How can I delete all the tables in a web page? The tables don't have any ids associated with them.</p>
[ { "answer_id": 292096, "author": "Kyle West", "author_id": 34133, "author_profile": "https://Stackoverflow.com/users/34133", "pm_score": 2, "selected": false, "text": "<p>If you're using jQuery it is pretty easy ...</p>\n\n<pre><code>$(document).ready(function() {\n $(\"table\").remove(...
2008/11/15
[ "https://Stackoverflow.com/questions/292091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
How can I delete all the tables in a web page? The tables don't have any ids associated with them.
Very simple version: ``` var tables = document.getElementsByTagName("TABLE"); for (var i=tables.length-1; i>=0;i-=1) if (tables[i]) tables[i].parentNode.removeChild(tables[i]); ```
292,095
<p>How can I poll the keyboard from a console python app? Specifically, I would like to do something akin to this in the midst of a lot of other I/O activities (socket selects, serial port access, etc.):</p> <pre><code>while True: # doing amazing pythonic embedded stuff # ... # periodically do a non-blocki...
[ { "answer_id": 292119, "author": "Rizwan Kassim", "author_id": 35335, "author_profile": "https://Stackoverflow.com/users/35335", "pm_score": 2, "selected": false, "text": "<p>You might look at how <a href=\"http://books.google.com/books?id=W8T2f7F_rs0C&amp;pg=PA147&amp;lpg=PA147&amp;dq=p...
2008/11/15
[ "https://Stackoverflow.com/questions/292095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33263/" ]
How can I poll the keyboard from a console python app? Specifically, I would like to do something akin to this in the midst of a lot of other I/O activities (socket selects, serial port access, etc.): ``` while True: # doing amazing pythonic embedded stuff # ... # periodically do a non-blocking check to s...
The standard approach is to use the [select](https://docs.python.org/2/library/select.html) module. However, this doesn't work on Windows. For that, you can use the [msvcrt](https://docs.python.org/2/library/msvcrt.html#console-i-o) module's keyboard polling. Often, this is done with multiple threads -- one per devic...
292,097
<p>I wanted to grep for java process and then find the max heap memory used. I tried this</p> <pre><code>def ex =['sh','-c','ps -aef | grep Xmx'] String str = ex.execute().text </code></pre> <p>while <code>str</code> has something like <em>java -Xmx1024M /kv/classes/bebo/ -Xms512M</em> How do I extract the value <em...
[ { "answer_id": 292286, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 0, "selected": false, "text": "<p>In Java:</p>\n\n<pre><code>String ResultString = null;\nPattern regex = Pattern.compile(\"-Xmx(\\\\d+M)\");\nMatc...
2008/11/15
[ "https://Stackoverflow.com/questions/292097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37870/" ]
I wanted to grep for java process and then find the max heap memory used. I tried this ``` def ex =['sh','-c','ps -aef | grep Xmx'] String str = ex.execute().text ``` while `str` has something like *java -Xmx1024M /kv/classes/bebo/ -Xms512M* How do I extract the value *1024M*? I was planning to user java regex but ...
Here's a groovy version that doesn't need the grep (or the sed :) : ``` ("ps -aef".execute().text =~ /.*-Xmx([0-9]+M).*/).each { full, match -> println match } ```
292,098
<p>VB 6: How can I execute a .bat file but wait until its done running before moving on?</p>
[ { "answer_id": 292108, "author": "Mitch Wheat", "author_id": 16076, "author_profile": "https://Stackoverflow.com/users/16076", "pm_score": 4, "selected": true, "text": "<p>You will need to use Win32 API calls to <a href=\"http://msdn.microsoft.com/en-us/library/bb762154(VS.85).aspx\" rel...
2008/11/15
[ "https://Stackoverflow.com/questions/292098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
VB 6: How can I execute a .bat file but wait until its done running before moving on?
You will need to use Win32 API calls to [ShellExecuteEx](http://msdn.microsoft.com/en-us/library/bb762154(VS.85).aspx) and WaitForSingleObject on the process handle returned from ShellExecuteEx in the SHELLEXECUTEINFO structure. This is old code which I've pulled out of a project. It was working 100% but I may not have...
292,101
<p>I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the <a href="http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html" rel="noreferrer">standard</a>, even as <a ...
[ { "answer_id": 292122, "author": "Elle H", "author_id": 23666, "author_profile": "https://Stackoverflow.com/users/23666", "pm_score": 4, "selected": false, "text": "<p>Adding a new Option type works at least IE6 and up</p>\n\n<pre><code>function addOption(selectID, display, value)\n{\n ...
2008/11/15
[ "https://Stackoverflow.com/questions/292101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25191/" ]
I just learned something interesting. The add method for the javascript select object in IE 6 takes only one parameter. It throws an error when you pass it two parameters which I believe is the [standard](http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html.html), even as [documented](http://msdn.microsoft...
You can use a try-catch block for doing this : ``` try { //Standards compliant list.add(optionTag, null); } catch (err) { //IE list.add(optionTag); } ```
292,109
<p>With Linux/GCC/C++, I'd like to record something to stderr whenever malloc/free/new/delete are called. I'm trying to understand a library's memory allocations, and so I'd like to generate this output while I'm running unit tests. I use valgrind for mem leak detection, but I can't find an option to make it just log...
[ { "answer_id": 292129, "author": "Emerick Rogul", "author_id": 33837, "author_profile": "https://Stackoverflow.com/users/33837", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://www.informit.com/guides/content.aspx?g=cplusplus&amp;seqNum=40\" rel=\"nofollow noreferrer\">Thi...
2008/11/15
[ "https://Stackoverflow.com/questions/292109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23524/" ]
With Linux/GCC/C++, I'd like to record something to stderr whenever malloc/free/new/delete are called. I'm trying to understand a library's memory allocations, and so I'd like to generate this output while I'm running unit tests. I use valgrind for mem leak detection, but I can't find an option to make it just log allo...
[`malloc_hook(3)`](http://linux.die.net/man/3/malloc_hook) allows you to globally interpose your own `malloc` function. (There's `__realloc_hook` `__free_hook` etc. as well, I've just left them out for simplicity.) ``` #include <stdio.h> #include <malloc.h> static void *(*old_malloc_hook)(size_t, const void *); stat...
292,150
<p>We use COM objects to access excel spreadsheets in an NT service (via the Windows Scripting Host). Prior to Vista, this worked beautifully, but starting with Vista, we receive this error:</p> <p>Microsoft Office Excel cannot access the file 'c:\myfiles\test.xls'. There are several possible reasons:</p> <ul> <li>T...
[ { "answer_id": 314981, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 1, "selected": false, "text": "<p>just some further questions:</p>\n\n<ul>\n<li>Which version of Excel are you using? </li>\n<li>Have you tried runn...
2008/11/15
[ "https://Stackoverflow.com/questions/292150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We use COM objects to access excel spreadsheets in an NT service (via the Windows Scripting Host). Prior to Vista, this worked beautifully, but starting with Vista, we receive this error: Microsoft Office Excel cannot access the file 'c:\myfiles\test.xls'. There are several possible reasons: * The file name or path d...
just some further questions: * Which version of Excel are you using? * Have you tried running the service with elevated privileges?
292,167
<p>I have the following regex expression to match html links:</p> <pre><code>&lt;a\s*href=['|"](http:\/\/(.*?)\S['|"]&gt; </code></pre> <p>it kind of works. Except not really. Because it grabs everything after the &lt; a href... and just keeps going. I want to exclude the quote characters from that last \S match. Is ...
[ { "answer_id": 292192, "author": "Marcos Lara", "author_id": 30626, "author_profile": "https://Stackoverflow.com/users/30626", "pm_score": 0, "selected": false, "text": "<p>Why are you trying to match HTML links with a regex?</p>\n\n<p>Depending on what you're trying to do the appropriat...
2008/11/15
[ "https://Stackoverflow.com/questions/292167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
I have the following regex expression to match html links: ``` <a\s*href=['|"](http:\/\/(.*?)\S['|"]> ``` it kind of works. Except not really. Because it grabs everything after the < a href... and just keeps going. I want to exclude the quote characters from that last \S match. Is there any way of doing that? **EDI...
I don't think your regex is doing what you want. ``` <a\s*href=['|"](http:\/\/(.*?)\S['|"]> ``` This captures anything non-greedily from http:// up to the first non-space character before a quote, single quote, or pipe. For that matter, I'm not sure how it parses, as it doesn't seem to have enough close parens. If ...
292,171
<p>I type </p> <pre><code>ArrayList memberNames = new ArrayList() { "Jim", "John", "George" }; </code></pre> <p>and Visual Studio tells me "ArrayList" cannot be found so I have to manually go to the top of the file and type</p> <pre><code>using System.Collections; </code></pre> <p>Is there a way to get Visual Studi...
[ { "answer_id": 292174, "author": "ckramer", "author_id": 20504, "author_profile": "https://Stackoverflow.com/users/20504", "pm_score": 3, "selected": true, "text": "<p>SHIFT-ALT-F10 Will activate the Smart Tag on the class, which will give you the options \"using System.Collections\", an...
2008/11/15
[ "https://Stackoverflow.com/questions/292171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
I type ``` ArrayList memberNames = new ArrayList() { "Jim", "John", "George" }; ``` and Visual Studio tells me "ArrayList" cannot be found so I have to manually go to the top of the file and type ``` using System.Collections; ``` Is there a way to get Visual Studio to do this automatically? In FlashDevelop, for...
SHIFT-ALT-F10 Will activate the Smart Tag on the class, which will give you the options "using System.Collections", and "System.Collections.ArrayList". It's typically two keystrokes to add a using. Edit: Seems I had a mangled keyboard profile. Updated the key combo to the default. Thanks to Alan for pointing it out.
292,230
<p>I have the following table structure</p> <pre><code>CREATE TABLE `table` ( `id` int(11) NOT NULL auto_increment, `date_expired` datetime NOT NULL, `user_id` int(11) NOT NULL, `foreign_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `date_expired` (`date_expired`,`user_id`,`foreign_id`), KEY `use...
[ { "answer_id": 292236, "author": "ypnos", "author_id": 21974, "author_profile": "https://Stackoverflow.com/users/21974", "pm_score": 1, "selected": false, "text": "<p>Having several indexes including one field is not bad at all (essentially, they do index different things). It has a slig...
2008/11/15
[ "https://Stackoverflow.com/questions/292230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I have the following table structure ``` CREATE TABLE `table` ( `id` int(11) NOT NULL auto_increment, `date_expired` datetime NOT NULL, `user_id` int(11) NOT NULL, `foreign_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `date_expired` (`date_expired`,`user_id`,`foreign_id`), KEY `user_id` (`user_i...
I believe if you created your unique index as (`user_id`, `date_expired`, `foreign_id`), you'll get the same benefit of having a normal index on `user_id` with just the unique index. MySQL can use the first columns of any index to pare down the number of rows in the join in the same manner as an index on `user_id`. S...
292,233
<p>I'm pretty green with web services and WCF, and I'm using Windows integrated authentication - how do I get the username on the server-side interface? I believe that I'm supposed to implement a custom Behavior, or perhaps something with WCF Sessions? Any clues would be super-handy.</p>
[ { "answer_id": 292266, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": -1, "selected": false, "text": "<p>have you tried <code>WindowsIdentity.GetCurrent();</code>?</p>\n" }, { "answer_id": 292311, "author": ...
2008/11/15
[ "https://Stackoverflow.com/questions/292233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5728/" ]
I'm pretty green with web services and WCF, and I'm using Windows integrated authentication - how do I get the username on the server-side interface? I believe that I'm supposed to implement a custom Behavior, or perhaps something with WCF Sessions? Any clues would be super-handy.
Here is a snippet of service code that shows how you could retrieve and use the WindowsIdentity associated with the caller of a WCF service. This code is assuming that you are accepting most of the defaults with your configuration. It should work without any problems with the Named Pipe or the Net TCP binding. the p...
292,254
<p>Trying to create a random string, x characters in length using 0-9 and a-z/A-Z and can't seem to find a good example, any ideas?</p>
[ { "answer_id": 292255, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>I forgot all my VB6 (thank God) but in pseudocode it's pretty easy:</p>\n\n<pre>\n all_chars = an array of all...
2008/11/15
[ "https://Stackoverflow.com/questions/292254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Trying to create a random string, x characters in length using 0-9 and a-z/A-Z and can't seem to find a good example, any ideas?
``` Function RandomString(cb As Integer) As String Randomize Dim rgch As String rgch = "abcdefghijklmnopqrstuvwxyz" rgch = rgch & UCase(rgch) & "0123456789" Dim i As Long For i = 1 To cb RandomString = RandomString & Mid$(rgch, Int(Rnd() * Len(rgch) + 1), 1) Next End Function ```...
292,256
<p>I'm a simple soul with simple needs, and I'm trying to configure a form. I detest forms.</p> <p>It needs to have JavaScript to transfer the data, it needs to send an e-mail with the data to an e-mail address, and it needs to redirect visitors to a pdf. CGI has always been confusing to me, and I don't know much Ja...
[ { "answer_id": 292275, "author": "Elle H", "author_id": 23666, "author_profile": "https://Stackoverflow.com/users/23666", "pm_score": 0, "selected": false, "text": "<p>OK, first thing's first, we need to clarify you're wording. JavaScript and Java are two significantly different languag...
2008/11/15
[ "https://Stackoverflow.com/questions/292256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm a simple soul with simple needs, and I'm trying to configure a form. I detest forms. It needs to have JavaScript to transfer the data, it needs to send an e-mail with the data to an e-mail address, and it needs to redirect visitors to a pdf. CGI has always been confusing to me, and I don't know much JavaScript. I...
SOunds like you need to validate the form and then send it to a server wich then revalidates (javascript can not be thrusted) and sends the mail-request to an e-mail server. I'd recommend PHP for the server that revalidates the form and sends the request to the e-mail server because it's easy and wide supported. Sa...
292,265
<p>What are the coolest new features that you guys are looking for, or that you've heard are releasing in c# 4.0.</p>
[ { "answer_id": 292267, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 2, "selected": false, "text": "<p>the dynamic keyword looks like it can bridge the gap between dynamic languages like IronRuby or IronPython quite ni...
2008/11/15
[ "https://Stackoverflow.com/questions/292265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37881/" ]
What are the coolest new features that you guys are looking for, or that you've heard are releasing in c# 4.0.
The dynamic stuff sounds cool *if you need it* but I don't expect to use it very often. The generic variance for delegates and interfaces is similar - the lack of variance is a headache at the moment, but many of the places where it's a pain won't be covered by the limited variance available in C# 4. The COM features...
292,274
<p>I read through the Wikipedia article <em><a href="https://en.wikipedia.org/wiki/Type_system#Existential_types" rel="noreferrer">Existential types</a></em>. I gathered that they're called existential types because of the existential operator (∃). I'm not sure what the point of it is, though. What's the difference bet...
[ { "answer_id": 292293, "author": "user35910", "author_id": 35910, "author_profile": "https://Stackoverflow.com/users/35910", "pm_score": -1, "selected": false, "text": "<p>As I understand it's a math way to describe interfaces/abstract class.</p>\n\n<p>As for T = ∃X { X a; int f(X); }</p...
2008/11/15
[ "https://Stackoverflow.com/questions/292274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
I read through the Wikipedia article *[Existential types](https://en.wikipedia.org/wiki/Type_system#Existential_types)*. I gathered that they're called existential types because of the existential operator (∃). I'm not sure what the point of it is, though. What's the difference between ``` T = ∃X { X a; int f(X); } ...
When someone defines a universal type `∀X` they're saying: *You can plug in whatever type you want, I don't need to know anything about the type to do my job, I'll only refer to it opaquely as `X`*. When someone defines an existential type `∃X` they're saying: *I'll use whatever type I want here; you won't know anythi...
292,279
<p>I have a function which gets a key from the user and generates a Hashtable (on a pattern specified by the key). After creating a Hashtable, I would like to populate a JTable so that each each column represents a key and every rows represents the values associated with the key. I tried everything but couldn't get thi...
[ { "answer_id": 292287, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 3, "selected": true, "text": "<p>See <a href=\"http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data\" rel=\"nofollow noreferrer...
2008/11/15
[ "https://Stackoverflow.com/questions/292279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
I have a function which gets a key from the user and generates a Hashtable (on a pattern specified by the key). After creating a Hashtable, I would like to populate a JTable so that each each column represents a key and every rows represents the values associated with the key. I tried everything but couldn't get this w...
See [How to Use Tables: Creating a Table Model](http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data). > > The JTable constructor used by > SimpleTableDemo creates its table > model with code like this: > > > ``` new AbstractTableModel() { public String getColumnName(int col) { ...
292,295
<p>We are supposed to instantiate our entities through a factory since they are set up differently on the client and server. I want to make sure this is the case but cant quite get it to work.</p> <pre><code>public interface IEntityFactory { TEntity Create&lt;TEntity&gt;() where TEntity : new(); } public abstract...
[ { "answer_id": 292334, "author": "DocMax", "author_id": 6234, "author_profile": "https://Stackoverflow.com/users/6234", "pm_score": 0, "selected": false, "text": "<p>The problem is that the factory method type is resolved at runtime, so the method is considered an \"open\" one. In that ...
2008/11/15
[ "https://Stackoverflow.com/questions/292295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37889/" ]
We are supposed to instantiate our entities through a factory since they are set up differently on the client and server. I want to make sure this is the case but cant quite get it to work. ``` public interface IEntityFactory { TEntity Create<TEntity>() where TEntity : new(); } public abstract class Entity { ...
Is possible to address this structurally instead of at runtime? Can you segregate your entities and the factory in a different assembly, then give the entity constructors `internal` scoping so that only the factory is able to invoke them?
292,298
<p>Here's my situation: I'm trying to understand how msbuild works by looking at the build files located in the .NET framework install path:</p> <pre><code>C:\Windows\Microsoft.NET\Framework\v3.5&gt;dir /s/b microsoft* Microsoft.Build.Tasks.v3.5.xml Microsoft.Build.xsd Microsoft.Common.targets Microsoft.Common.Tasks ...
[ { "answer_id": 292304, "author": "Brian", "author_id": 19299, "author_profile": "https://Stackoverflow.com/users/19299", "pm_score": 1, "selected": false, "text": "<p>It \"starts\" with your .vbproj file. Take a look at that file, it will &lt;Import> the Microsoft.VisualBasic.targets, w...
2008/11/15
[ "https://Stackoverflow.com/questions/292298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here's my situation: I'm trying to understand how msbuild works by looking at the build files located in the .NET framework install path: ``` C:\Windows\Microsoft.NET\Framework\v3.5>dir /s/b microsoft* Microsoft.Build.Tasks.v3.5.xml Microsoft.Build.xsd Microsoft.Common.targets Microsoft.Common.Tasks Microsoft.CSharp.t...
It "starts" with your .vbproj file. Take a look at that file, it will <Import> the Microsoft.VisualBasic.targets, which in turn will <Import> Microsoft.Common.targets.
292,307
<p>How do I select the unique elements from the list <code>{0, 1, 2, 2, 2, 3, 4, 4, 5}</code> so that I get <code>{0, 1, 3, 5}</code>, effectively removing <em>all instances of</em> the repeated elements <code>{2, 4}</code>?</p>
[ { "answer_id": 292310, "author": "CVertex", "author_id": 209, "author_profile": "https://Stackoverflow.com/users/209", "pm_score": 4, "selected": false, "text": "<pre><code>var nums = new int{ 0...4,4,5};\nvar distinct = nums.Distinct();\n</code></pre>\n\n<p>make sure you're using Linq a...
2008/11/15
[ "https://Stackoverflow.com/questions/292307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/976/" ]
How do I select the unique elements from the list `{0, 1, 2, 2, 2, 3, 4, 4, 5}` so that I get `{0, 1, 3, 5}`, effectively removing *all instances of* the repeated elements `{2, 4}`?
``` var numbers = new[] { 0, 1, 2, 2, 2, 3, 4, 4, 5 }; var uniqueNumbers = from n in numbers group n by n into nGroup where nGroup.Count() == 1 select nGroup.Key; // { 0, 1, 3, 5 } ```
292,308
<p>I always see the code like this in the blogs: </p> <pre><code>$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "WebService.asmx/HelloWorld", data: "{}", dataType: "json", ...
[ { "answer_id": 292321, "author": "mavera", "author_id": 439507, "author_profile": "https://Stackoverflow.com/users/439507", "pm_score": 0, "selected": false, "text": "<p>I already know this article, but It couldn't help me.</p>\n\n<p>In my sample app, I use these codes:</p>\n\n<p><strong...
2008/11/15
[ "https://Stackoverflow.com/questions/292308", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
I always see the code like this in the blogs: ``` $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "WebService.asmx/HelloWorld", data: "{}", dataType: "json", success: fun...
You need to add this attribute to your webserver class ``` [System.Web.Script.Services.ScriptService] public class Service : System.Web.Services.WebService ``` and this attribute to your functions ``` [ScriptMethod(ResponseFormat = ResponseFormat.Json)] ``` You don't technically need to specify the responseformat...