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
389,211
<p>This is a followup to <a href="https://stackoverflow.com/questions/378281/latlon-distance-heading-latlon">this question</a>.</p> <p>I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the standard degree system OR by measuring a distance north fr...
[ { "answer_id": 389251, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 7, "selected": true, "text": "<p>You've got a serious case of the magic numbers in the code. The expression: </p>\n\n<pre><code> (60 * 1.1515 *...
2008/12/23
[ "https://Stackoverflow.com/questions/389211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47450/" ]
This is a followup to [this question](https://stackoverflow.com/questions/378281/latlon-distance-heading-latlon). I seem to be stuck on this. Basically, I need to be able to convert back and forth to referring to coordinates either in the standard degree system OR by measuring a distance north from the south pole alon...
You've got a serious case of the magic numbers in the code. The expression: ``` (60 * 1.1515 * 1.609344 * 1000) ``` appears twice, but there's not much explanation of it. With some help: 1.609344 is the number of kilometres in a mile; 60 is the number of minutes in a degree; 1000 is the number of metres in a kilom...
389,254
<p>Is it possible in Delphi to have a class method invoke an inherited instance method with the same name? For example, I tried something like this:</p> <pre><code>//... Skipped surrounding class definitions function TSomeAbstractDialogForm.Execute: Boolean; begin Result := ShowModal = mrOk; end; </code></pre> <p>...
[ { "answer_id": 389292, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 4, "selected": true, "text": "<p>You can try a hard cast. But it is better to rename the class function. (For example to CreateAndExecute).</p>\n\n<...
2008/12/23
[ "https://Stackoverflow.com/questions/389254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39348/" ]
Is it possible in Delphi to have a class method invoke an inherited instance method with the same name? For example, I tried something like this: ``` //... Skipped surrounding class definitions function TSomeAbstractDialogForm.Execute: Boolean; begin Result := ShowModal = mrOk; end; ``` I had a couple of speciali...
You can try a hard cast. But it is better to rename the class function. (For example to CreateAndExecute). The Execute in the child class hides the execute in the parent class (I think the compiler will give a warning for that). You can access this with a hard cast. But there is no way to distinguish between an instan...
389,289
<p>I am looking the fastest way to draw thousands of individually calculated pixels directly to the screen in an iPhone application that preforms extremely well.</p>
[ { "answer_id": 389314, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<p>Why don't you use OpenGL views?</p>\n" }, { "answer_id": 389327, "author": "joshperry", "author_id": 30587,...
2008/12/23
[ "https://Stackoverflow.com/questions/389289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30099/" ]
I am looking the fastest way to draw thousands of individually calculated pixels directly to the screen in an iPhone application that preforms extremely well.
Most probably using OpenGL, something like: ``` glBegin(GL_POINTS); glColor3f(...); glVertex3f(...); ... glEnd(); ``` Even faster would probably be to use [vertex arrays](http://www.opengl.org/sdk/docs/man/xhtml/glVertexPointer.xml) for specifying the points.
389,298
<p>Is there a way to update more than one Database having same schema using single ObjectDataSource in C#???</p> <p>i.e Just by providing more than one connection string is it some how possible to update more than one Database? I need to update/insert same record in multiple Database with same schema using ObjectDataS...
[ { "answer_id": 389326, "author": "user19371", "author_id": 19371, "author_profile": "https://Stackoverflow.com/users/19371", "pm_score": 0, "selected": false, "text": "<p>I would say no; I don't think that's possible as a SqlCommand must be associated with exactly one connection string.<...
2008/12/23
[ "https://Stackoverflow.com/questions/389298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47344/" ]
Is there a way to update more than one Database having same schema using single ObjectDataSource in C#??? i.e Just by providing more than one connection string is it some how possible to update more than one Database? I need to update/insert same record in multiple Database with same schema using ObjectDataSource in C...
Yes you can do it, since with an ObjectDataSource YOU ae the one writing the code that does the insert. Inside your "Update" and "Delete" methods you can simply perform two database actions, one for each database that you are working with. You can abstract this out to an operation that could be passed a connection to e...
389,341
<p>I have a WPF ListBox bound to a data object. Inside the listbox are a series of images with text. It is layed out in a horizontal fashion, and mousing over the left or right sides of the box scroll the items left or right respectively.</p> <p>let's say there are 20 items in the listbox. I'm trying to figure out how...
[ { "answer_id": 397871, "author": "Scott Weinstein", "author_id": 25201, "author_profile": "https://Stackoverflow.com/users/25201", "pm_score": 0, "selected": false, "text": "<p>There are a number of free and commercial WPF carousel implementations that do this. Take a look at this roundu...
2008/12/23
[ "https://Stackoverflow.com/questions/389341", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22451/" ]
I have a WPF ListBox bound to a data object. Inside the listbox are a series of images with text. It is layed out in a horizontal fashion, and mousing over the left or right sides of the box scroll the items left or right respectively. let's say there are 20 items in the listbox. I'm trying to figure out how when I hi...
The issue here is not really with the **ListBox**, but with the **ScrollViewer** inside its control template; therefore to make the items cycle you'll need to change the **ScrollViewer** in some way. I have written a control that derives from **ScrollViewer** that cycles in a vertical direction... but it should be easy...
389,342
<p>The <code>image.size</code> attribute of <code>UIImageView</code> gives the size of the original <code>UIImage</code>. I would like to find out the size of the autoscaled image when it is put in the <code>UIImageView</code> (typically smaller than the original). </p> <p>For example, I have the image set to <code>As...
[ { "answer_id": 389498, "author": "leonho", "author_id": 30883, "author_profile": "https://Stackoverflow.com/users/30883", "pm_score": -1, "selected": false, "text": "<p>How about just get the UIImageView size from its frame? i.e. imageView.frame?</p>\n" }, { "answer_id": 389507, ...
2008/12/23
[ "https://Stackoverflow.com/questions/389342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The `image.size` attribute of `UIImageView` gives the size of the original `UIImage`. I would like to find out the size of the autoscaled image when it is put in the `UIImageView` (typically smaller than the original). For example, I have the image set to `Aspect Fit`. Now I want to know its new height and width on t...
**Objective-C:** ``` -(CGRect)frameForImage:(UIImage*)image inImageViewAspectFit:(UIImageView*)imageView { float imageRatio = image.size.width / image.size.height; float viewRatio = imageView.frame.size.width / imageView.frame.size.height; if(imageRatio < viewRatio) { float scale = imageView.fr...
389,343
<p>Currently, I'm working on a project to manage maintenance windows on a database of servers, etc. Basically, I only need to be accurate down to the hour, but allow for them to be set to allow, or disallow, for each day of the week.</p> <p>I've had a few ideas on how to do this, but since I work by myself, I'm not wa...
[ { "answer_id": 389357, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 0, "selected": false, "text": "<p>Maybe something like </p>\n\n<pre><code>TABLE:\n StartTime DATETIME PrimaryKey,\n EndTime DATETIME P...
2008/12/23
[ "https://Stackoverflow.com/questions/389343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17091/" ]
Currently, I'm working on a project to manage maintenance windows on a database of servers, etc. Basically, I only need to be accurate down to the hour, but allow for them to be set to allow, or disallow, for each day of the week. I've had a few ideas on how to do this, but since I work by myself, I'm not wanting to c...
I would consider for (1) using a format that includes both start and end times, and an integer field for the day of the week. I know you stated the blocks will always be one hour, but that can be enforced by your code. Also, if your requirements change one day, you'll have a lot less to worry about in step (2) than if ...
389,348
<p>Consider this example table (assuming SQL Server 2005):</p> <pre><code>create table product_bill_of_materials ( parent_product_id int not null, child_product_id int not null, quantity int not null ) </code></pre> <p>I'm considering a composite primary key containing the two product_id columns (I'll def...
[ { "answer_id": 389356, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": false, "text": "<p>The real question here is what will you be querying on the most? If you will be looking for both values all th...
2008/12/23
[ "https://Stackoverflow.com/questions/389348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26414/" ]
Consider this example table (assuming SQL Server 2005): ``` create table product_bill_of_materials ( parent_product_id int not null, child_product_id int not null, quantity int not null ) ``` I'm considering a composite primary key containing the two product\_id columns (I'll definitely want a unique con...
As has already been said by several others, it depends on how you will access the table. Keep in mind though, that any RDBMS out there should be able to use the clustered index for searching by a single column as long as that column appears first. For example, if your clustered index is on (parent\_id, child\_id) you d...
389,361
<p>We know that IIS caches ConfigurationManager.AppSettings so it reads the disk only once until the web.config is changed. This is done for performance purposes.</p> <p>Someone at:</p> <p><a href="http://forums.asp.net/p/1080926/1598469.aspx#1598469" rel="noreferrer">http://forums.asp.net/p/1080926/1598469.aspx#1598...
[ { "answer_id": 389366, "author": "John Sonmez", "author_id": 45365, "author_profile": "https://Stackoverflow.com/users/45365", "pm_score": 2, "selected": false, "text": "<p>It doesn't matter if it does or not. Don't fix a performance problem if there isn't one. </p>\n" }, { "ans...
2008/12/23
[ "https://Stackoverflow.com/questions/389361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
We know that IIS caches ConfigurationManager.AppSettings so it reads the disk only once until the web.config is changed. This is done for performance purposes. Someone at: <http://forums.asp.net/p/1080926/1598469.aspx#1598469> stated that .NET Framework doesn't do the same for app.config, but it reads from the disk ...
A quick test seems to show that these settings are only loaded at application startup. ``` //edit the config file now. Console.ReadLine(); Console.WriteLine(ConfigurationManager.AppSettings["ApplicationName"].ToString()); Console.WriteLine("Press enter to redisplay"); //edit the config file again now. Console.ReadLi...
389,393
<p>I've been watching Douglas Crockford's talks at YUI Theater, and I have a question about JavaScript inheritance...</p> <p>Douglas gives this example to show that "Hoozit" inherits from "Gizmo":</p> <pre><code>function Hoozit(id) { this.id = id; } Hoozit.prototype = new Gizmo(); Hoozit.prototype.test = function...
[ { "answer_id": 389402, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 5, "selected": true, "text": "<p>The reason is that using <code>Hoozit.prototype = Gizmo.prototype</code> would mean that modifying Hoozit's prototyp...
2008/12/23
[ "https://Stackoverflow.com/questions/389393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7595/" ]
I've been watching Douglas Crockford's talks at YUI Theater, and I have a question about JavaScript inheritance... Douglas gives this example to show that "Hoozit" inherits from "Gizmo": ``` function Hoozit(id) { this.id = id; } Hoozit.prototype = new Gizmo(); Hoozit.prototype.test = function (id) { return th...
The reason is that using `Hoozit.prototype = Gizmo.prototype` would mean that modifying Hoozit's prototype object would also modify objects of type Gizmo, which is not expected behavior. `Hoozit.prototype = new Gizmo()` inherits from Gizmo, and then leaves Gizmo alone.
389,398
<p>I have a little python script that pulls emails from a POP mail address and dumps them into a file (one file one email)</p> <p>Then a PHP script runs through the files and displays them.</p> <p>I am having an issue with ISO-8859-1 (Latin-1) encoded email</p> <p>Here's an example of the text i get: =?iso-8859-1?Q?...
[ { "answer_id": 389408, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 0, "selected": false, "text": "<p>That's MIME content, and that's how the email actually looks like, not a bug somewhere. You have to use a MIME de...
2008/12/23
[ "https://Stackoverflow.com/questions/389398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22459/" ]
I have a little python script that pulls emails from a POP mail address and dumps them into a file (one file one email) Then a PHP script runs through the files and displays them. I am having an issue with ISO-8859-1 (Latin-1) encoded email Here's an example of the text i get: =?iso-8859-1?Q?G=EDsli\_Karlsson?= and ...
You can use the python email library (python 2.5+) to avoid these problems: ``` import email import poplib import random from cStringIO import StringIO from email.generator import Generator pop = poplib.POP3(server) mail_count = len(pop.list()[1]) for message_num in xrange(mail_count): message = "\r\n".join(pop...
389,403
<p>How can you access and display the row index of a gridview item as the command argument in a buttonfield column button?</p> <pre><code>&lt;gridview&gt; &lt;Columns&gt; &lt;asp:ButtonField ButtonType="Button" CommandName="Edit" Text="Edit" Visible="True" CommandArgument=" ? ? ? " /&gt; ..... <...
[ { "answer_id": 389424, "author": "Dillie-O", "author_id": 71, "author_profile": "https://Stackoverflow.com/users/71", "pm_score": 0, "selected": false, "text": "<p>I typically bind this data using the RowDatabound event with the GridView:</p>\n\n<pre><code>protected void FormatGridView(o...
2008/12/23
[ "https://Stackoverflow.com/questions/389403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
How can you access and display the row index of a gridview item as the command argument in a buttonfield column button? ``` <gridview> <Columns> <asp:ButtonField ButtonType="Button" CommandName="Edit" Text="Edit" Visible="True" CommandArgument=" ? ? ? " /> ..... ```
Here is a very simple way: ```html <asp:ButtonField ButtonType="Button" CommandName="Edit" Text="Edit" Visible="True" CommandArgument='<%# Container.DataItemIndex %>' /> ```
389,425
<p>I am trying to layout a header for a web site and I would like to have 4 containers in the header for dropping various user controls into.</p> <p>The 4 containers need to be positioned top left, top right, bottom left and bottom right inside the main the header container.</p> <p>So far I can acheive this, the bit ...
[ { "answer_id": 389452, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>Your positioning between <code>bottomLeft</code> and <code>bottomRight</code> is not consistent:</p>\n\n<pre><cod...
2008/12/23
[ "https://Stackoverflow.com/questions/389425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1127460/" ]
I am trying to layout a header for a web site and I would like to have 4 containers in the header for dropping various user controls into. The 4 containers need to be positioned top left, top right, bottom left and bottom right inside the main the header container. So far I can acheive this, the bit I can't do is tha...
Sorry I can't be of more help, but I'm not sure this is possible given the constraints that you have. The main problem is that you want to align to the bottom of the `bottom` div, but since both `bottomRight` and `bottomLeft` are positioned `absolute`, the items overflow the `bottom` div. Therefore, using the `bottom` ...
389,426
<p>Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I am about to ask can be answered by a little bit of testing, but I was wondering if anybody could post a decent explanation (or links, too).</p> <p>If you create a class:</p> <pre><code>Public Class ReferenceClass Private my...
[ { "answer_id": 389516, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": false, "text": "<p>I can't put much time into this answer now - typing on a train with a toddler on my knee - but I have a couple of a...
2008/12/23
[ "https://Stackoverflow.com/questions/389426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1271/" ]
Somewhat unclear to me are references (pointers?) to classes in VB.NET. The question I am about to ask can be answered by a little bit of testing, but I was wondering if anybody could post a decent explanation (or links, too). If you create a class: ``` Public Class ReferenceClass Private myBooleanValue As Boole...
A reference points to an instance of an object, it is not an instance of an object. Making a copy of the directions to the object does not create another object, it creates another reference that also points to the same object.
389,434
<p>My (.NET) app allows users to tweak database values. They will then need to generate reports based on their edits, either Crystal or Reporting Services, but that's not important - what is important is that the generation won't definitely be able occur on their local box, e.g. they might not have Crystal Reports (or ...
[ { "answer_id": 389442, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 0, "selected": false, "text": "<p>Tried using impersonation within the application?</p>\n\n<p>More crudely you could runas your application.</p>\n" }, {...
2008/12/23
[ "https://Stackoverflow.com/questions/389434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2902/" ]
My (.NET) app allows users to tweak database values. They will then need to generate reports based on their edits, either Crystal or Reporting Services, but that's not important - what is important is that the generation won't definitely be able occur on their local box, e.g. they might not have Crystal Reports (or wha...
``` Process p = new Process(); p.StartInfo.UseShellExecute = false; SecureString password = new SecureString(); string pwd = "mysecret123"; foreach (char c in pwd) { password.AppendChar(c); } p.StartInfo.Domain = "DomainHere"; p.StartInfo.UserName = "Natthawut"; p.Star...
389,437
<p>From MS AJAX source code,</p> <pre><code>Type.isClass = function Type$isClass(type) { /// &lt;summary locid="M:J#Type.isClass" /&gt; /// &lt;param name="type" mayBeNull="true"&gt;&lt;/param&gt; /// &lt;returns type="Boolean"&gt;&lt;/returns&gt; var e = Function._validateParams(arguments, [ {name: "type", mayBeN...
[ { "answer_id": 389441, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 0, "selected": false, "text": "<p>Guaranteed safe boolean conversion.</p>\n" }, { "answer_id": 389443, "author": "Kenan Banks", "author_...
2008/12/23
[ "https://Stackoverflow.com/questions/389437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
From MS AJAX source code, ``` Type.isClass = function Type$isClass(type) { /// <summary locid="M:J#Type.isClass" /> /// <param name="type" mayBeNull="true"></param> /// <returns type="Boolean"></returns> var e = Function._validateParams(arguments, [ {name: "type", mayBeNull: true} ]); if (e) throw e; if ((typeof(t...
The author must not have thought `type.__class` was guaranteed to be a boolean value. Since you can pass any object to `Type.isClass()`: ``` Type.isClass(3); Type.isClass({}); Type.isClass(AnActualClassFunction); ``` ...there's really no guarantee that `type.__class` will have a boolean value. Of course, parameters...
389,438
<p>I have a page which has a rectangular area with text and icons in it and the whole thing is clickable. The anchor tag is set to display: block. One of the icons has an onclick handler. If a person clicks on an icon, I just want the icon's onclick handler to run and not to actually activate the containing anchor t...
[ { "answer_id": 389447, "author": "idrosid", "author_id": 17876, "author_profile": "https://Stackoverflow.com/users/17876", "pm_score": 0, "selected": false, "text": "<p>Try to change your anchor to:</p>\n\n<pre><code>&lt;a href=\"javascript:void(0)\"&gt; &lt;img src=\"...\" onclick=\"..\...
2008/12/23
[ "https://Stackoverflow.com/questions/389438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28565/" ]
I have a page which has a rectangular area with text and icons in it and the whole thing is clickable. The anchor tag is set to display: block. One of the icons has an onclick handler. If a person clicks on an icon, I just want the icon's onclick handler to run and not to actually activate the containing anchor tag. F...
I would just use a `<span>`, but I think returning `false` from the event handler should also do the trick.
389,451
<p>I have a page in my application that refreshes some content (a list of users currently signed in) from the server every 10 seconds. This data is loaded using the <a href="http://docs111.mootools.net/Remote/Ajax.js" rel="nofollow noreferrer">Ajax</a> class from the <a href="http://docs111.mootools.net/" rel="nofollow...
[ { "answer_id": 389479, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 3, "selected": true, "text": "<p>This is probably a memory/resource leak in IE. The most common source of these are closures in your code or framework...
2008/12/23
[ "https://Stackoverflow.com/questions/389451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I have a page in my application that refreshes some content (a list of users currently signed in) from the server every 10 seconds. This data is loaded using the [Ajax](http://docs111.mootools.net/Remote/Ajax.js) class from the [mootools framework](http://docs111.mootools.net/), specifically with Javascript that looks ...
This is probably a memory/resource leak in IE. The most common source of these are closures in your code or framework code. I always check the issue tracker for my javascript framework for reported bugs. Many times I have been saved by bug-reports & fixes from other users. To try track the problem, you could try somet...
389,456
<p>I have two websites, let's say they're <code>example.com</code> and <code>anotherexample.net</code>. On <code>anotherexample.net/page.html</code>, I have an <code>IFRAME SRC="http://example.com/someform.asp"</code>. That IFRAME displays a form for the user to fill out and submit to <code>http://example.com/process.a...
[ { "answer_id": 389458, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 10, "selected": true, "text": "<p>I got it to work, but the solution is a bit complex, so bear with me.</p>\n\n<h1>What's happening</h1...
2008/12/23
[ "https://Stackoverflow.com/questions/389456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19746/" ]
I have two websites, let's say they're `example.com` and `anotherexample.net`. On `anotherexample.net/page.html`, I have an `IFRAME SRC="http://example.com/someform.asp"`. That IFRAME displays a form for the user to fill out and submit to `http://example.com/process.asp`. When I open the form ("`someform.asp`") in its ...
I got it to work, but the solution is a bit complex, so bear with me. What's happening ================ As it is, Internet Explorer gives lower level of trust to IFRAME pages (IE calls this "third-party" content). If the page inside the IFRAME doesn't have a Privacy Policy, its cookies are blocked (which is indicated...
389,459
<p>I am trying to write operator overload for custom class and don't know how to handle null comparison.</p> <pre><code>Class Customer { int id; public static bool operator ==(Customer a, Customer b) { //When both a and b are null don't know how to compare as can't use == in here as //it w...
[ { "answer_id": 389472, "author": "Steven Robbins", "author_id": 26507, "author_profile": "https://Stackoverflow.com/users/26507", "pm_score": 1, "selected": false, "text": "<p>I'm not 100% sure I understand the problem, but you should be able to do:</p>\n\n<pre><code>if (((object)a == nu...
2008/12/23
[ "https://Stackoverflow.com/questions/389459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48695/" ]
I am trying to write operator overload for custom class and don't know how to handle null comparison. ``` Class Customer { int id; public static bool operator ==(Customer a, Customer b) { //When both a and b are null don't know how to compare as can't use == in here as //it will fall into ...
``` if (Object.ReferenceEquals(a,b)) return true; ``` ReferenceEquals() checks if they are pointing to the exact same object (or if they are both null) (As a general rule, it's good to start an Equals() method with a call to ReferenceEquals, particularly if the rest of the method is complicated. It will make th...
389,473
<p>I'm trying to control the titles of my xterm windows and my cleverness has finally outpaced my knowledge. :-)</p> <p>I have three functions: one which sets the title of the window; one which takes a passed command, calls the title function, and executes the command; and one which resumes a job after using <code>jo...
[ { "answer_id": 389805, "author": "cheng81", "author_id": 46754, "author_profile": "https://Stackoverflow.com/users/46754", "pm_score": 5, "selected": true, "text": "<p>Roughly, JPA is a standard from the java community, <a href=\"http://jcp.org/aboutJava/communityprocess/final/jsr220/ind...
2008/12/23
[ "https://Stackoverflow.com/questions/389473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46387/" ]
I'm trying to control the titles of my xterm windows and my cleverness has finally outpaced my knowledge. :-) I have three functions: one which sets the title of the window; one which takes a passed command, calls the title function, and executes the command; and one which resumes a job after using `jobs` to determine...
Roughly, JPA is a standard from the java community, [here the specs](http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html "JSR220"), which has been implemented (and extended) by the Hibernate guys ([some info here](http://www.hibernate.org/397.html)). Being a spec, you will not be using JPA directly, but a...
389,488
<p>Let's consider the following program and try to compile it under Cygwin:</p> <pre><code>#include &lt;GL/glut.h&gt; int main(int argc, char** argv) { glutInit(&amp;argc, argv); glLoadIdentity(); } </code></pre> <p>It compiles and runs just fine. <code>-I/usr/include/opengl</code> seems to be terribly importan...
[ { "answer_id": 389958, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 1, "selected": false, "text": "<p>It sounds like you want to link against the native Win32 libraries instead of X11. Add <em>-L/lib/w32api</em>. Ot...
2008/12/23
[ "https://Stackoverflow.com/questions/389488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19336/" ]
Let's consider the following program and try to compile it under Cygwin: ``` #include <GL/glut.h> int main(int argc, char** argv) { glutInit(&argc, argv); glLoadIdentity(); } ``` It compiles and runs just fine. `-I/usr/include/opengl` seems to be terribly important. ``` g++ -I/usr/include/opengl -I../includ...
I had a similar issue a while ago, and I found that there are two ways to compile opengl code under Cygwin. The first links against the native win32api libraries glut32 glu32 opengl32 (also glui). Those are somewhat older: glut v3.7.6 opengl v1.1 glui 2.11 The second way uses the X11 libraries glut gl...
389,501
<p>I have a listview that is binded to a ThreadSafeObservableCollection. The background of each of these items is set to an enum that is run through a color converter, here's the code for these 2 settings.</p> <pre><code>&lt;UserControl.Resources&gt; &lt;EncoderView:EncoderStatusToColorConverter x:Key="ColorConve...
[ { "answer_id": 389569, "author": "Sailing Judo", "author_id": 42620, "author_profile": "https://Stackoverflow.com/users/42620", "pm_score": 1, "selected": false, "text": "<p>Have you tried using a DataTemplateSelector? I use it to change which template is used for a ListBoxItem, which i...
2008/12/23
[ "https://Stackoverflow.com/questions/389501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29849/" ]
I have a listview that is binded to a ThreadSafeObservableCollection. The background of each of these items is set to an enum that is run through a color converter, here's the code for these 2 settings. ``` <UserControl.Resources> <EncoderView:EncoderStatusToColorConverter x:Key="ColorConverter"/> <Style x:Key...
The issue is that the Binding to Background is taking the entire Encoder object, which doesn't change unless you remove and add it. Even if Encoder implements INotifyPropertyChanged, the Binding is still looking at the whole Encoder object and has no way of knowing which properties of Encoder are relevant to your Encod...
389,503
<p>If you use an WebHandler inheriting IHttpAsyncHandler, you shouldn't notice that under undetermined specific circumstances the browser MS IE6 won't display it, the request will never finish. Is there a fix for it?</p>
[ { "answer_id": 389521, "author": "Jader Dias", "author_id": 48465, "author_profile": "https://Stackoverflow.com/users/48465", "pm_score": 3, "selected": true, "text": "<p>I'll answer it myself, but i took 3 days to solve it when I first met this problem.</p>\n\n<p>When the image is reque...
2008/12/23
[ "https://Stackoverflow.com/questions/389503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
If you use an WebHandler inheriting IHttpAsyncHandler, you shouldn't notice that under undetermined specific circumstances the browser MS IE6 won't display it, the request will never finish. Is there a fix for it?
I'll answer it myself, but i took 3 days to solve it when I first met this problem. When the image is requested through the "src" property of an "img" HTML tag, in certain conditions the browser MS IE6 needs the Content-Length to finish the request and display the result. Synchronous ASHX generated images, automatica...
389,504
<p>I have a child form that is throwing an ApplicationException in the Load event handler (intentionally for testing purposes). The parent form wraps the ChildForm.Show() method in a Try...Catch ex As Exception block. The catch block simply displays a message and closes the child form. All works as expected when deb...
[ { "answer_id": 389538, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 0, "selected": false, "text": "<p>I apologize for the C# (I don't know the Vb syntax)</p>\n\n<p>are you doing something like this:</p>\n\n<pre><code...
2008/12/23
[ "https://Stackoverflow.com/questions/389504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30419/" ]
I have a child form that is throwing an ApplicationException in the Load event handler (intentionally for testing purposes). The parent form wraps the ChildForm.Show() method in a Try...Catch ex As Exception block. The catch block simply displays a message and closes the child form. All works as expected when debugged ...
The Form.Load event behaves the same way as most other events in Windows Forms. It is dispatched by the message loop, in this case when Windows sends the WM\_SHOWWINDOW message. There is an exception handler in the message loop that prevents an uncaught exception from terminating the message loop. That exception handle...
389,528
<p>I am making a configuration page, that splits a category tree over 3 columns for easy browsing like:</p> <pre><code>**Column 1** **Column 2** **Column3** Category1 Category3 Category5 *SubCategory1* Category4 *SubCategory5* Cat...
[ { "answer_id": 389553, "author": "Vasil", "author_id": 7883, "author_profile": "https://Stackoverflow.com/users/7883", "pm_score": 0, "selected": false, "text": "<p>I'm presuming the structure gets modified by drag and drop. You can make an ajax call every time a change in the structure ...
2008/12/23
[ "https://Stackoverflow.com/questions/389528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/314728/" ]
I am making a configuration page, that splits a category tree over 3 columns for easy browsing like: ``` **Column 1** **Column 2** **Column3** Category1 Category3 Category5 *SubCategory1* Category4 *SubCategory5* Category2 ...
I recently had to do something similar on a personal project of mine, but never ended up actually using the feature I was writing it for, but here's the code I used: ``` function refactor() { var array = jQuery.makeArray($('ul#remapped > li:not(.target)')); var mappedArray = jQuery.map(array, function(i) { ...
389,535
<p>I need to query a table for values given a string. The table is case sensitive but I want to do a ToLower() in the comparison. </p> <p>Suppose I have a classes table with the following data.</p> <pre><code>class teacher ----------------- Mat101 Smith MAT101 Jones mat101 Abram ENG102 Smith </code></pre> ...
[ { "answer_id": 389554, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 0, "selected": false, "text": "<p>The downside of the kind of query you are talking about is that it cannot use an index on class (as an index lookup, t...
2008/12/23
[ "https://Stackoverflow.com/questions/389535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to query a table for values given a string. The table is case sensitive but I want to do a ToLower() in the comparison. Suppose I have a classes table with the following data. ``` class teacher ----------------- Mat101 Smith MAT101 Jones mat101 Abram ENG102 Smith ``` My query should be something ...
No; it would be better to improve the data: create a numeric ID that represents these seemingly meaningless variations of class (and probably an associated lookup table to get the ID). Use the ID column in the where clause and you should be hitting an indexed numeric column. If that's no an option, consider a function...
389,541
<p>Is there a way to select rows in Postgresql that aren't locked? I have a multi-threaded app that will do:</p> <pre><code>Select... order by id desc limit 1 for update </code></pre> <p>on a table. </p> <p>If multiple threads run this query, they both try to pull back the same row. </p> <p>One gets the row lock, t...
[ { "answer_id": 389577, "author": "Steven Behnke", "author_id": 42588, "author_profile": "https://Stackoverflow.com/users/42588", "pm_score": 0, "selected": false, "text": "<p>Looks like you're looking for a SELECT FOR SHARE.</p>\n\n<p><a href=\"http://www.postgresql.org/docs/8.3/interact...
2008/12/23
[ "https://Stackoverflow.com/questions/389541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14059/" ]
Is there a way to select rows in Postgresql that aren't locked? I have a multi-threaded app that will do: ``` Select... order by id desc limit 1 for update ``` on a table. If multiple threads run this query, they both try to pull back the same row. One gets the row lock, the other blocks and then fails after the...
This feature, `SELECT ... SKIP LOCKED` is being implemented in Postgres 9.5. <http://www.depesz.com/2014/10/10/waiting-for-9-5-implement-skip-locked-for-row-level-locks/>
389,575
<p>My technical lead insists on this exception mechanism:</p> <pre><code>try { DoSth(); } catch (OurException) { throw; } catch (Exception ex) { Util.Log(ex.Message, "1242"); // 1242 is unique to this catch block throw new OurException(ex); } </code></pre> <p>1242 here is an identifier of the catch me...
[ { "answer_id": 389595, "author": "Eduardo Crimi", "author_id": 48132, "author_profile": "https://Stackoverflow.com/users/48132", "pm_score": 0, "selected": false, "text": "<p>I think that having a hard coded number on the throw line is not a good practice, how do you know whether that nu...
2008/12/23
[ "https://Stackoverflow.com/questions/389575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
My technical lead insists on this exception mechanism: ``` try { DoSth(); } catch (OurException) { throw; } catch (Exception ex) { Util.Log(ex.Message, "1242"); // 1242 is unique to this catch block throw new OurException(ex); } ``` 1242 here is an identifier of the catch method which we handle an ex...
You can also look into the [Exception Handling Application block.](http://msdn.microsoft.com/en-us/library/cc309505.aspx) I have used it in a few projects and it is very useful. Especially if you want to later change how your exception handling works, and what information to capture.
389,581
<p>I am attempting to get the information from one table (games) and count the entries in another table (tickets) that correspond to each entry in the first. I want each entry in the first table to be returned even if there aren't any entries in the second. My query is as follows:</p> <pre><code>SELECT g.*, count(*)...
[ { "answer_id": 389587, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 4, "selected": true, "text": "<p>You need to do a left-join:</p>\n\n<pre><code>SELECT g.Game_Number, g.PutColumnsHere, count(t.Game_Number) \nFROM games ...
2008/12/23
[ "https://Stackoverflow.com/questions/389581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30133/" ]
I am attempting to get the information from one table (games) and count the entries in another table (tickets) that correspond to each entry in the first. I want each entry in the first table to be returned even if there aren't any entries in the second. My query is as follows: ``` SELECT g.*, count(*) FROM games g, ...
You need to do a left-join: ``` SELECT g.Game_Number, g.PutColumnsHere, count(t.Game_Number) FROM games g LEFT JOIN tickets t ON g.Game_Number = t.Game_Number GROUP BY g.Game_Number, g.PutColumnsHere ``` Alternatively, I think this is a little clearer with a correlated subquery: ``` SELECT g.Game_Number, G.PutColu...
389,582
<p>I've been searching for information for a common kernel implementation of queues, that is, first-in-first-out data structures. I thought there may be one since it's likely something that's common to use, and there's a standard for linked lists (in the form of the list_head structure). Is there some standard queue ...
[ { "answer_id": 389602, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 4, "selected": true, "text": "<p>You're right, the Linux kernel typically uses linked lists to implement queues. This makes sense, because li...
2008/12/23
[ "https://Stackoverflow.com/questions/389582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34426/" ]
I've been searching for information for a common kernel implementation of queues, that is, first-in-first-out data structures. I thought there may be one since it's likely something that's common to use, and there's a standard for linked lists (in the form of the list\_head structure). Is there some standard queue impl...
You're right, the Linux kernel typically uses linked lists to implement queues. This makes sense, because linked lists offer the required behavior. See this example from kernel/workqueue.c: ``` INIT_LIST_HEAD(&wq->list); // ... case CPU_UP_CANCELED: list_for_each_entry(wq, &workqueues, list) { ...
389,591
<p>Since the <code>OleDbParameter</code> does not use named parameters (due to its nature), why is it that the .NET <code>OleDbParameter</code> class expects a name? <code>(string parametername ...)</code> </p> <p>All constructors require a parameter name, and I'm never sure what name to give it; my name is ok? or my ...
[ { "answer_id": 389647, "author": "Ricardo Villamil", "author_id": 19314, "author_profile": "https://Stackoverflow.com/users/19314", "pm_score": 1, "selected": false, "text": "<p>Just like everything else in programming, name it something meaningful to your context! (name, orderid, city, ...
2008/12/23
[ "https://Stackoverflow.com/questions/389591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Since the `OleDbParameter` does not use named parameters (due to its nature), why is it that the .NET `OleDbParameter` class expects a name? `(string parametername ...)` All constructors require a parameter name, and I'm never sure what name to give it; my name is ok? or my grandmothers name?
Although the OleDb/Odbc providers use positional parameters instead of named parameters - 1. the parameters will need to be identified in some way inside the OleDbParameter collection should you need to reference them. 2. importantly when the parameterised sql statement is constructed, a variable for each parameter is...
389,644
<p>The following code for a co-worker throws the following error when he tries to compile it using VS 2008:</p> <p>Error:</p> <blockquote> <p>A new expression requires () or [] after type</p> </blockquote> <p>Code:</p> <p>MyClass Structure:</p> <pre><code>public class MyClass { public MyClass() {} pub...
[ { "answer_id": 389651, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 2, "selected": false, "text": "<p>Is his project targetting .NET 3.5? If not, that error would be thrown on the x.Add(new MyClass line because the new...
2008/12/23
[ "https://Stackoverflow.com/questions/389644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
The following code for a co-worker throws the following error when he tries to compile it using VS 2008: Error: > > A new expression requires () or [] > after type > > > Code: MyClass Structure: ``` public class MyClass { public MyClass() {} public string Property1 { get; set; } public string Pro...
Here's what seems to be the only similar, but not exactly the same, error available in VS.2008: > > Compiler Error CS1526 : A new > expression requires (), []**, or {}** > after type > > > Note those `{}` in error message, which are part of c# 3.0 syntax. This is not related to framework version, but to the ver...
389,660
<p>I can use:</p> <pre><code>select * from sys.tables </code></pre> <p>in mssql to show a list of all tables in the current database. Is there anyways I can use similar syntax to show list of tables in another database?</p> <p>Say I am using A with:</p> <pre><code>use A </code></pre> <p>statement, can I show table...
[ { "answer_id": 389668, "author": "Daniel Schaffer", "author_id": 2596, "author_profile": "https://Stackoverflow.com/users/2596", "pm_score": 5, "selected": true, "text": "<p>This does it for me (MS SQL 2005 and newer):</p>\n\n<pre><code>select * from your_database_name.sys.tables\n</code...
2008/12/23
[ "https://Stackoverflow.com/questions/389660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10088/" ]
I can use: ``` select * from sys.tables ``` in mssql to show a list of all tables in the current database. Is there anyways I can use similar syntax to show list of tables in another database? Say I am using A with: ``` use A ``` statement, can I show tables in database B?
This does it for me (MS SQL 2005 and newer): ``` select * from your_database_name.sys.tables ``` Keep in mind that you (or whatever authentication context you're using) will still need read permission on that database. To use your example: ``` use a; go select * from sys.tables; -- selects table info from a selec...
389,677
<p>Anyone know how to query for a specific date within entity framework ? I tried following code, but it gives me NotSupportedException.</p> <pre><code>var deposit = (from tempDeposit in entities.Deposit where !tempDeposit.IsApproved &amp;&amp; tempDeposit.CreatedDate.Date == DateTime.Today select tempDeposit).FirstOr...
[ { "answer_id": 389870, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 5, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>var d1 = DateTime.Today;\nvar d2 = d1.AddDays(1);\nvar deposit = (from tempDeposit in e...
2008/12/23
[ "https://Stackoverflow.com/questions/389677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37509/" ]
Anyone know how to query for a specific date within entity framework ? I tried following code, but it gives me NotSupportedException. ``` var deposit = (from tempDeposit in entities.Deposit where !tempDeposit.IsApproved && tempDeposit.CreatedDate.Date == DateTime.Today select tempDeposit).FirstOrDefault(); ``` I als...
Try this: ``` var d1 = DateTime.Today; var d2 = d1.AddDays(1); var deposit = (from tempDeposit in entities.Deposit where !tempDeposit.IsApproved && tempDeposit.CreatedDate >= d1 && tempDeposit.CreatedDate < d2 select tempDeposit).FirstOrDefault();...
389,692
<p>I'm trying to connect to an Oracle DB which is currently offline. When it's online it's not a problem, however, now that it's offline my program is getting hung up on the $connection = oci_connect() line and timing out. How do I simply check the connectio and bail out if it's not there?</p>
[ { "answer_id": 389712, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>You could select null from dual.</p>\n\n<p>OK, now I see what your asking, I think. </p>\n\n<p>You want to know how to tell...
2008/12/23
[ "https://Stackoverflow.com/questions/389692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39653/" ]
I'm trying to connect to an Oracle DB which is currently offline. When it's online it's not a problem, however, now that it's offline my program is getting hung up on the $connection = oci\_connect() line and timing out. How do I simply check the connectio and bail out if it's not there?
Try this (fill in your ip and port): ``` if ( @fsockopen($db_ip,$db_port ) ) { //connect to database } else { // didn't work } ```
389,709
<p>I'm trying to write a notification service (for completely legit non-spam purposes) in .NET using SmtpClient. Initially I just looped through each message and sent it, however this is slow and I would like to improve the speed. So, I switched to using 'SendAsync', but now get the following error on the second cal...
[ { "answer_id": 389717, "author": "Tamas Czinege", "author_id": 8954, "author_profile": "https://Stackoverflow.com/users/8954", "pm_score": 2, "selected": false, "text": "<p>Obviously, this is not an attempt to stop mass mailers.</p>\n\n<p>The reason is that the SmtpClient class is not th...
2008/12/23
[ "https://Stackoverflow.com/questions/389709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47225/" ]
I'm trying to write a notification service (for completely legit non-spam purposes) in .NET using SmtpClient. Initially I just looped through each message and sent it, however this is slow and I would like to improve the speed. So, I switched to using 'SendAsync', but now get the following error on the second call: ``...
According to the [documentation](http://msdn.microsoft.com/en-us/library/x5x13z6h.aspx): > > After calling SendAsync, you must wait > for the e-mail transmission to > complete before attempting to send > another e-mail message using Send or > SendAsync. > > > So to send multiple mails at the same time you nee...
389,710
<p>XAML:</p> <pre><code>&lt;ToolBarTray Name="tlbTray" ButtonBase.Click="tlbTray_Click"&gt; &lt;ToolBar Name="tlbFile"&gt; &lt;Button Name="btnOpen"&gt;&lt;Image Source="images\folder.png" Stretch="None" /&gt;&lt;/Button&gt; &lt;Button Name="btnSave"&gt;&lt;Image Source="images\disk.png" Stretch="None" /&gt;&...
[ { "answer_id": 389733, "author": "Nate", "author_id": 3413, "author_profile": "https://Stackoverflow.com/users/3413", "pm_score": 1, "selected": false, "text": "<p>In your handler use:</p>\n\n<pre><code>Button test = (Button)sender;\nif(test.Name==\"btnOpen\")\n{\n //Do something\n}\n</...
2008/12/23
[ "https://Stackoverflow.com/questions/389710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2172/" ]
XAML: ``` <ToolBarTray Name="tlbTray" ButtonBase.Click="tlbTray_Click"> <ToolBar Name="tlbFile"> <Button Name="btnOpen"><Image Source="images\folder.png" Stretch="None" /></Button> <Button Name="btnSave"><Image Source="images\disk.png" Stretch="None" /></Button> </ToolBar> </ToolBarTray> ``` Code: ``` pri...
Owkay, I found it! ``` private void tlbTray_Click(object sender, RoutedEventArgs e) { Button button = (Button)e.OriginalSource; } ```
389,737
<p>I have a Database table that I want to display in a DataGridView. However, it has several foreign keys and I don't want to show the integer that represents the other Table to the user.</p> <p>I have this DataTable with a column userId I have another DataTable with a column id, and a column username</p> <p>I want t...
[ { "answer_id": 389769, "author": "Eduardo Crimi", "author_id": 48132, "author_profile": "https://Stackoverflow.com/users/48132", "pm_score": 1, "selected": false, "text": "<p>You can create a Stored Procedure that make the requiered joins to get the names of the user, or whatever field y...
2008/12/23
[ "https://Stackoverflow.com/questions/389737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12243/" ]
I have a Database table that I want to display in a DataGridView. However, it has several foreign keys and I don't want to show the integer that represents the other Table to the user. I have this DataTable with a column userId I have another DataTable with a column id, and a column username I want the DataGridView t...
How are you populating the DataTable? You can specify custom SQL with the joins and appropriate columns to the .SelectCommand of a DataAdapter or specify the custom SQL in the .CommandText of a xxxCommand object. Eg ``` myAdapter.SelectCommand = "Select a.column1, a.column2, b.username from tablea a inner join tableb...
389,741
<p>I saw this keyword for the first time and I was wondering if someone could explain to me what it does.</p> <ul> <li>What is the <code>continue</code> keyword?</li> <li>How does it work?</li> <li>When is it used?</li> </ul>
[ { "answer_id": 389744, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 10, "selected": true, "text": "<p>A <code><a href=\"https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.16\" rel=\"nofollow n...
2008/12/23
[ "https://Stackoverflow.com/questions/389741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33911/" ]
I saw this keyword for the first time and I was wondering if someone could explain to me what it does. * What is the `continue` keyword? * How does it work? * When is it used?
A `[continue](https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.16)` statement without a label will re-execute from the condition the innermost `while` or `do` loop, and from the update expression of the innermost `for` loop. It is often used to early-terminate a loop's processing and thereby avoid d...
389,743
<p>I need to limit the jquery ui date picker to only have future Tuesdays and Thursdays as selectable days. </p> <p>How can I accomplish this?</p>
[ { "answer_id": 389756, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>Provide an onSelect handler to the datepicker and have your handler validate that the dates fit your defined criteria...
2008/12/23
[ "https://Stackoverflow.com/questions/389743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40149/" ]
I need to limit the jquery ui date picker to only have future Tuesdays and Thursdays as selectable days. How can I accomplish this?
Provide an onSelect handler to the datepicker and have your handler validate that the dates fit your defined criteria. I'm not sure where the onSelect fires so you may have "undo" the selection if you can't stop the event and alert the user. One way of doing this would be to develop a custom date validator class that ...
389,759
<p>What is the easiest way to use post-commit hook with VisualSVN Server to export from the repository to a directory for staging / testing after a developer commits his changes?</p>
[ { "answer_id": 389888, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Will do the reading on Cruise Control integration with Subversion - first I've heard of it, though I do hate to throw yet a...
2008/12/23
[ "https://Stackoverflow.com/questions/389759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the easiest way to use post-commit hook with VisualSVN Server to export from the repository to a directory for staging / testing after a developer commits his changes?
Do the following in the **VisualSVN Server Manager** MMC console: 1. Select your **repository** 2. Right click **Properties** 3. Select the **Hooks** tab 4. Select the **post-commit hook** 5. Click the **Edit** button. Enter a line like this into the **textbox**: ``` "%VISUALSVN_SERVER%bin\svn.exe" export https://sv...
389,761
<p>What is the best method to determine if the current time is AM or PM using VB.NET?</p> <p>Currently I'm using If Date.Today.ToString.Contains("AM") but I'm sure there is a better method.</p> <pre><code>Good &lt;%If Date.Today.ToString.Contains("AM") Then Response.Write("Morning") Else Response.Write("Afternoon")%&...
[ { "answer_id": 389765, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 5, "selected": true, "text": "<p><code>If Date.Now.Hour &lt; 12 Then</code> ... perhaps?</p>\n" }, { "answer_id": 389771, "author": "Col...
2008/12/23
[ "https://Stackoverflow.com/questions/389761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3747/" ]
What is the best method to determine if the current time is AM or PM using VB.NET? Currently I'm using If Date.Today.ToString.Contains("AM") but I'm sure there is a better method. ``` Good <%If Date.Today.ToString.Contains("AM") Then Response.Write("Morning") Else Response.Write("Afternoon")%> ```
`If Date.Now.Hour < 12 Then` ... perhaps?
389,763
<p>I know that <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/" rel="nofollow noreferrer">CodeRush Xpress</a> is intended to be used on VS 2008 and not on VS 2005.<br> But since I can't migrate to VS2008 yet, I want to install it on VS2005 and don't care it's not supposed to work.<br></p> <...
[ { "answer_id": 442951, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Bad notice!</p>\n\n<p>It's not possible because the plugin is for .NET Framework 3 and Visual Studio 2008 aka Orcas.</p>\n\...
2008/12/23
[ "https://Stackoverflow.com/questions/389763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26042/" ]
I know that [CodeRush Xpress](http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/) is intended to be used on VS 2008 and not on VS 2005. But since I can't migrate to VS2008 yet, I want to install it on VS2005 and don't care it's not supposed to work. My base assumption is that it can be done, this ...
It is possible, and here what you need to do it. Make sure VS is closed. Install [RefactorCpp](http://devexpress.com/Products/Visual_Studio_Add-in/RefactorCPP/). Install [CodeRush Xpress](http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/). Apply this registry patch: ``` Windows Registry E...
389,767
<p>I'm reading the book "LINQ Pocket Reference" and there is a particular example (slightly modified below) that I'm having difficulty getting my head around... The explanation in the book is a bit brief, so I was wondering if someone could break it down step-by-step for me so that it makes sense...</p> <pre><code> ...
[ { "answer_id": 389780, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 4, "selected": true, "text": "<p>What happens with the first example is that the value of vowel is captured into a local (to the scope of the for-lo...
2008/12/23
[ "https://Stackoverflow.com/questions/389767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40410/" ]
I'm reading the book "LINQ Pocket Reference" and there is a particular example (slightly modified below) that I'm having difficulty getting my head around... The explanation in the book is a bit brief, so I was wondering if someone could break it down step-by-step for me so that it makes sense... ``` IEnumerable<c...
What happens with the first example is that the value of vowel is captured into a local (to the scope of the for-loop) variable. The where-clause for the query will then use that captured variable. Where-clauses like this uses an anonymous method/lambda method, which can capture local variables. What happens then is t...
389,788
<p>so i've got this, roughly:</p> <pre><code>&lt;div id="A"&gt; &lt;ul&gt; &lt;li id="B"&gt;foo&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="C"&gt; ... &lt;/div&gt; </code></pre> <p>These are positioned so that B and C overlap.</p> <p>A has a <code>z-index</code> of <code>90</code>, B has a <c...
[ { "answer_id": 389815, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 5, "selected": true, "text": "<p>Using <code>z-index</code> is only relevant for elements in the same container. Since B is contained inside A, B'...
2008/12/23
[ "https://Stackoverflow.com/questions/389788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56817/" ]
so i've got this, roughly: ``` <div id="A"> <ul> <li id="B">foo</li> </ul> </div> <div id="C"> ... </div> ``` These are positioned so that B and C overlap. A has a `z-index` of `90`, B has a `z-index` of `92`, and C has a `z-index` of `91`. But C shows up in front of B. What am i doing wrong? (L...
Using `z-index` is only relevant for elements in the same container. Since B is contained inside A, B's z-index will only apply when resolving other elements inside A. As far as C is concerned, both B and A are rendered at z-index 90. However if C is placed inside A, then B will render in front.
389,797
<p>Visual Studio compiles this code fine, but gcc only lets it compile without the Template operator. With the Template operator it gives the following errors:</p> <p>Line 29: error: expected `;' before "itrValue"</p> <pre><code>class Test { public: Test&amp; operator&lt;&lt;(const char* s) {return *this;} // no...
[ { "answer_id": 389811, "author": "Pieter", "author_id": 5822, "author_profile": "https://Stackoverflow.com/users/5822", "pm_score": 4, "selected": false, "text": "<p>GCC is right, const_iterator is a type, and template dependant in the template operator&lt;&lt;, you need to tell the comp...
2008/12/23
[ "https://Stackoverflow.com/questions/389797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Visual Studio compiles this code fine, but gcc only lets it compile without the Template operator. With the Template operator it gives the following errors: Line 29: error: expected `;' before "itrValue" ``` class Test { public: Test& operator<<(const char* s) {return *this;} // not implemented yet Test& opera...
GCC is right, const\_iterator is a type, and template dependant in the template operator<<, you need to tell the compiler it's a type and not a variable: ``` typename std::list<T>::const_iterator ```
389,813
<p>I need to sort some objects according to their contents (in fact according to one of their properties, which is NOT the key and may be duplicated between different objects).</p> <p>.NET provides two classes (<a href="https://msdn.microsoft.com/en-us/library/f7fta44c(v=vs.110).aspx" rel="noreferrer">SortedDictionary...
[ { "answer_id": 389872, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>What I need is a SortedList class with\n a RefreshPosition(int index) to move\n only the changed (o...
2008/12/23
[ "https://Stackoverflow.com/questions/389813", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47341/" ]
I need to sort some objects according to their contents (in fact according to one of their properties, which is NOT the key and may be duplicated between different objects). .NET provides two classes ([SortedDictionary](https://msdn.microsoft.com/en-us/library/f7fta44c(v=vs.110).aspx) and [SortedList](https://msdn.mic...
Maybe I'm slow, but isn't *this* the easiest implementation ever? ``` class SortedList<T> : List<T> { public new void Add(T item) { Insert(~BinarySearch(item), item); } } ``` <http://msdn.microsoft.com/en-us/library/w4e7fxsh.aspx> --- Unfortunately, `Add` wasn't overrideable so I had to `new` i...
389,821
<p>I'm still having a hard time not wanting to use Tables to do my Details View Layout in HTML. I want to run some samples by people and get some opinions.</p> <p>What you would prefer to see in the html for a Details View? Which one has the least hurddles cross browser? Which is the most compliant? Which one look...
[ { "answer_id": 389869, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>Actually I take that back for simple textbox only inputs I find that the Fieldset option works well.</p>\n\n<p>...
2008/12/23
[ "https://Stackoverflow.com/questions/389821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37881/" ]
I'm still having a hard time not wanting to use Tables to do my Details View Layout in HTML. I want to run some samples by people and get some opinions. What you would prefer to see in the html for a Details View? Which one has the least hurddles cross browser? Which is the most compliant? Which one looks better if a ...
Those approaches aren't mutually exclusive, personally I'd mix them up a bit: ``` <fieldset> <label for="name">XXX <input type="text" id="name"/></label> <label for="email">XXX <input type="text" id="email"/></label> </fieldset> ``` Although to get a right aligned label (something I'd personally avoid because it...
389,822
<p>I'm currently writing a data access layer for an application. The access layer makes extensive use of linq classes to return data. Currently in order to reflect data back to the database I've added a private data context member and a public save method. The code looks something like this:</p> <pre><code>private Dat...
[ { "answer_id": 389835, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>DataContext is pretty lightweight and is intended for unit of work application as you are using it. I don't think ...
2008/12/23
[ "https://Stackoverflow.com/questions/389822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2191/" ]
I'm currently writing a data access layer for an application. The access layer makes extensive use of linq classes to return data. Currently in order to reflect data back to the database I've added a private data context member and a public save method. The code looks something like this: ``` private DataContext myDb;...
It actually doesn't matter too much. I asked Matt Warren from the LINQ to SQL team about this a while ago, and here's the reply: > > There are a few reasons we implemented > IDisposable: > > > If application logic needs to hold > onto an entity beyond when the > DataContext is expected to be used or > valid you...
389,825
<p>I am trying to recreate something similar to the popup keyboard used in safari.</p> <p><img src="https://dl.getdropbox.com/u/22784/keyboardToolbar.png" alt="alt text"></p> <p>I am able to visually reproduce it by placeing a toolbar over my view and the appropriate buttons, however i cant figure out any way to dism...
[ { "answer_id": 389830, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 6, "selected": true, "text": "<p>Have you tried:</p>\n\n<pre><code>[viewReceivingKeys resignFirstResponder];\n</code></pre>\n\n<p>where <code>viewRecei...
2008/12/23
[ "https://Stackoverflow.com/questions/389825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8918/" ]
I am trying to recreate something similar to the popup keyboard used in safari. ![alt text](https://dl.getdropbox.com/u/22784/keyboardToolbar.png) I am able to visually reproduce it by placeing a toolbar over my view and the appropriate buttons, however i cant figure out any way to dismiss the keyboard once the user ...
Have you tried: ``` [viewReceivingKeys resignFirstResponder]; ``` where `viewReceivingKeys` is the UIView that is receiving the text input?
389,827
<p>Is there a way to (ab)use the <strong>C</strong> preprocessor to emulate namespaces in <strong>C</strong>?</p> <p>I'm thinking something along these lines:</p> <pre><code>#define NAMESPACE name_of_ns some_function() { some_other_function(); } </code></pre> <p>This would get translated to:</p> <pre><code>name...
[ { "answer_id": 389838, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": false, "text": "<p>You could use the ## operator:</p>\n\n<pre><code>#define FUN_NAME(namespace,name) namespace ## name\n</code></pre>\n\n<p>an...
2008/12/23
[ "https://Stackoverflow.com/questions/389827", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46450/" ]
Is there a way to (ab)use the **C** preprocessor to emulate namespaces in **C**? I'm thinking something along these lines: ``` #define NAMESPACE name_of_ns some_function() { some_other_function(); } ``` This would get translated to: ``` name_of_ns_some_function() { name_of_ns_some_other_function(); } ```
When using namespace prefixes, I normally add macros for the shortened names which can be activated via `#define NAMESPACE_SHORT_NAMES` before inclusion of the header. A header foobar.h might look like this: ``` // inclusion guard #ifndef FOOBAR_H_ #define FOOBAR_H_ // long names void foobar_some_func(int); void foob...
389,831
<p>I tried both of the following options:</p> <p>1.</p> <pre><code>BufferedImage Buffered_Image; MemoryCacheImageOutputStream MemoryCache_OutputStream = new MemoryCacheImageOutputStream(new FileOutputStream("C:/Test.mov",false)); while (notFinished) // Main recording loop. { Buffered_Image=robot.createScre...
[ { "answer_id": 389907, "author": "Marc Novakowski", "author_id": 27020, "author_profile": "https://Stackoverflow.com/users/27020", "pm_score": 2, "selected": false, "text": "<p>It looks like you're trying to create a video (MOV) file by writing multiple PNG files in a row. This isn't go...
2008/12/23
[ "https://Stackoverflow.com/questions/389831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32834/" ]
I tried both of the following options: 1. ``` BufferedImage Buffered_Image; MemoryCacheImageOutputStream MemoryCache_OutputStream = new MemoryCacheImageOutputStream(new FileOutputStream("C:/Test.mov",false)); while (notFinished) // Main recording loop. { Buffered_Image=robot.createScreenCapture(); ...
It looks like you're trying to create a video (MOV) file by writing multiple PNG files in a row. This isn't going to work. You'll probably have to find a third-party library for encoding your images into a video file (which is itself may be a good SO question). EDIT: I should also note that you may actually be able to...
389,832
<p>I would like to know if we can reuse the same Statement object for executing more than one query. Or, should we create a new statement for different queries.</p> <p>For example,</p> <pre><code>Connection con = getDBConnection(); Statement st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_...
[ { "answer_id": 389839, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_profile": "https://Stackoverflow.com/users/4725", "pm_score": 4, "selected": false, "text": "<p>Yes, you can. However, it is very much better to use <code>PreparedStatement</code> to avoid SQL injection ...
2008/12/23
[ "https://Stackoverflow.com/questions/389832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48725/" ]
I would like to know if we can reuse the same Statement object for executing more than one query. Or, should we create a new statement for different queries. For example, ``` Connection con = getDBConnection(); Statement st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); int i = s...
I came across the response I was looking for in the Javadoc for [`Statement`](https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Statement.html): > > By default, only one `ResultSet` object per `Statement` object can be open at the same time. Therefore, if the reading of one `ResultSet` object is in...
389,844
<p>Is there any way to have a Windows batch file directly input SQL statements without calling a script? I want the batch file to login to SQL and then enter in the statements directly.</p> <p><strong>EDIT:</strong> I'm using Oracle v10g</p>
[ { "answer_id": 389857, "author": "Dave Costa", "author_id": 6568, "author_profile": "https://Stackoverflow.com/users/6568", "pm_score": 3, "selected": true, "text": "<p>For a single command you can use this trick:</p>\n\n<pre><code>echo select * from dual; | sqlplus user/pw@db\n</code></...
2008/12/23
[ "https://Stackoverflow.com/questions/389844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459442/" ]
Is there any way to have a Windows batch file directly input SQL statements without calling a script? I want the batch file to login to SQL and then enter in the statements directly. **EDIT:** I'm using Oracle v10g
For a single command you can use this trick: ``` echo select * from dual; | sqlplus user/pw@db ```
389,905
<p>I've created a user control using WPF and I want to add it to window. I've done that, but I can't make my control have a height higher than the height it has in its own xaml file. My MaxWidth and MaxHeight are both infinity, but I can't make the control any taller than what it is in its xaml file.</p> <p>To get aro...
[ { "answer_id": 389928, "author": "Rob", "author_id": 18505, "author_profile": "https://Stackoverflow.com/users/18505", "pm_score": 0, "selected": false, "text": "<p>Why do you want your control to have a height higher than the height it has in its own XAML file? Couldn't you just remove ...
2008/12/23
[ "https://Stackoverflow.com/questions/389905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18927/" ]
I've created a user control using WPF and I want to add it to window. I've done that, but I can't make my control have a height higher than the height it has in its own xaml file. My MaxWidth and MaxHeight are both infinity, but I can't make the control any taller than what it is in its xaml file. To get around this, ...
Removing the height and width is the way to go. The designer(blend) has some special designer width and height properties that they can use to design in, but won't set the height for runtime. ``` xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibil...
389,922
<p>Why do we need both <code>using namespace</code> and <code>include</code> directives in C++ programs?</p> <p>For example, </p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello world"; } </code></pre> <p>Why is it not enough to just have <code>#include &lt;iostream&gt;...
[ { "answer_id": 389944, "author": "Tim", "author_id": 10755, "author_profile": "https://Stackoverflow.com/users/10755", "pm_score": 6, "selected": true, "text": "<p>In <code>C++</code> the concepts are separate. This is by design and useful.</p>\n\n<p>You can include things that without ...
2008/12/23
[ "https://Stackoverflow.com/questions/389922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363902/" ]
Why do we need both `using namespace` and `include` directives in C++ programs? For example, ``` #include <iostream> using namespace std; int main() { cout << "Hello world"; } ``` Why is it not enough to just have `#include <iostream>` or just have `using namespace std` and get rid of the other? (I am thinking...
In `C++` the concepts are separate. This is by design and useful. You can include things that without namespaces would be ambiguous. With namespaces you can refer to two different classes that have the same name. Of course in that case you would not use the `using` directive or if you did you would have to specify th...
389,945
<p>I've often seen people use Perl data structures in lieu of configuration files; i.e. a lone file containing only:</p> <pre><code>%config = ( 'color' =&gt; 'red', 'numbers' =&gt; [5, 8], qr/^spam/ =&gt; 'eggs' ); </code></pre> <p>What's the best way to convert the contents of these files into Python-equ...
[ { "answer_id": 389970, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 4, "selected": false, "text": "<p>Is using pure Python a requirement? If not, you can load it in Perl and convert it to YAML or JSON. Then use PyYAML o...
2008/12/23
[ "https://Stackoverflow.com/questions/389945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
I've often seen people use Perl data structures in lieu of configuration files; i.e. a lone file containing only: ``` %config = ( 'color' => 'red', 'numbers' => [5, 8], qr/^spam/ => 'eggs' ); ``` What's the best way to convert the contents of these files into Python-equivalent data structures, using pure...
Not sure what the use case is. Here's my assumption: you're going to do a one-time conversion from Perl to Python. Perl has this ``` %config = ( 'color' => 'red', 'numbers' => [5, 8], qr/^spam/ => 'eggs' ); ``` In Python, it would be ``` config = { 'color' : 'red', 'numbers' : [5, 8], re.co...
389,957
<p>I'm trying to create proper header files which don't include too many other files to keep them clean and to speed up compile time.</p> <p>I encountered two problems while doing this:</p> <ol> <li><p>Forward declaration on base classes doesn't work.</p> <pre><code>class B; class A : public B { // ... } </cod...
[ { "answer_id": 389962, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 2, "selected": false, "text": "<p>In both cases the compiler needs to know the size of the type. Therefore, a forward declaration will not suffice....
2008/12/23
[ "https://Stackoverflow.com/questions/389957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47064/" ]
I'm trying to create proper header files which don't include too many other files to keep them clean and to speed up compile time. I encountered two problems while doing this: 1. Forward declaration on base classes doesn't work. ``` class B; class A : public B { // ... } ``` 2. Forward declaration on STD clas...
The first problem you can't solve. The second problem is not anything to do with standard library classes. It's because you declare an instance of the class as a member of your own class. Both problems are due to the requirement that the compiler must be able to find out the total size of a class from its definition....
389,993
<p>Is there any straightforward way to get the mantissa and exponent from a double in c# (or .NET in general)?</p> <p>I found <a href="https://jonskeet.uk/csharp/DoubleConverter.cs" rel="nofollow noreferrer">this example</a> using Google, but I'm not sure how robust it would be. Could the binary representation for a d...
[ { "answer_id": 390005, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 1, "selected": false, "text": "<p>The representation is a IEEE standard and shouldn't change.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/aa6...
2008/12/23
[ "https://Stackoverflow.com/questions/389993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6219/" ]
Is there any straightforward way to get the mantissa and exponent from a double in c# (or .NET in general)? I found [this example](https://jonskeet.uk/csharp/DoubleConverter.cs) using Google, but I'm not sure how robust it would be. Could the binary representation for a double change in some future version of the fram...
The binary format shouldn't change - it would certainly be a breaking change to existing specifications. It's defined to be in IEEE754 / IEC 60559:1989 format, as Jimmy said. (C# 3.0 language spec section 1.3; ECMA 335 section 8.2.2). The code in DoubleConverter should be fine and robust. For the sake of future refere...
390,000
<p>Whats the best way to separate the string, "Parisi, Kenneth" into "Kenneth" and "Parisi"? <br>I am still learning how to parse strings with these regular expressions, but not too familiar with how to set vars equal to the matched string &amp; output of the matched (or mismatched) string.</p>
[ { "answer_id": 390009, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 2, "selected": false, "text": "<p>Something like this should do the trick for names without unicode characters:</p>\n\n<pre><code>my ($lname,$fname) = ...
2008/12/23
[ "https://Stackoverflow.com/questions/390000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42229/" ]
Whats the best way to separate the string, "Parisi, Kenneth" into "Kenneth" and "Parisi"? I am still learning how to parse strings with these regular expressions, but not too familiar with how to set vars equal to the matched string & output of the matched (or mismatched) string.
``` my ($lname, $fname) = split(/,\s*/, $fullname, 2); ``` Note the third argument, which limits the results to two. Not strictly required but a good practice nonetheless imho.
390,017
<p>I have a ListView inside another ListView, and I'd like to hide a table column in the inner ListView whenever a particular parameter is passed. Given the setup below, how would I hide the ID column (both the header and the data) if the URL contains "...?id=no"?</p> <pre><code>&lt;asp:ListView ID="ProcedureListView"...
[ { "answer_id": 390042, "author": "flesh", "author_id": 27805, "author_profile": "https://Stackoverflow.com/users/27805", "pm_score": 1, "selected": false, "text": "<p>you could wrap them in a placeholder and then dynamically set the visibility of the placeholder to remove the column... (...
2008/12/23
[ "https://Stackoverflow.com/questions/390017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
I have a ListView inside another ListView, and I'd like to hide a table column in the inner ListView whenever a particular parameter is passed. Given the setup below, how would I hide the ID column (both the header and the data) if the URL contains "...?id=no"? ``` <asp:ListView ID="ProcedureListView" runat="server"> ...
if you are trying to do this from the code behind then you could do this: On the onBind event for the outer ListView you would find the inner listview control, and then find the label you want and change the visible property to false. i answered this on your other question. good luck!
390,033
<p>Hey everyone, I'm working on a PHP application that needs to parse a .tpl file with HTML in it and I'm making it so that the HTML can have variables and basic if statements in it. An if statement look something like this: `</p> <pre><code>&lt;!--if({VERSION} == 2)--&gt; Hello World &lt;!--endif --&gt; </code></pre>...
[ { "answer_id": 390055, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 2, "selected": false, "text": "<p>You have a space between <code>endif</code> and <code>--&gt;</code> but your regular expression doesn't allow this.</p>\n\...
2008/12/23
[ "https://Stackoverflow.com/questions/390033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29291/" ]
Hey everyone, I'm working on a PHP application that needs to parse a .tpl file with HTML in it and I'm making it so that the HTML can have variables and basic if statements in it. An if statement look something like this: ` ``` <!--if({VERSION} == 2)--> Hello World <!--endif --> ``` To parse that, I've tried using `...
I think you meant to do this: ``` '/<!--if\(([^)]*)\)-->([^<]*)<!--endif-->/' ``` Your regex has only one character class in it: ``` [^\]*)\)-->([^<] ``` Here's what's happening: * The first closing square bracket is escaped by the backslash, so it's matched literally. * The parentheses that were supposed close ...
390,044
<p>We've built up an application infrastructure based on ActiveMQ.</p> <p>We can send and receive messages just fine, and for the most part things are pretty fast and OK.</p> <p>However, we've noticed that if we submit a batch of messages "at once", say 5,000 messages - that ActiveMQ will get the messages to the 3rd ...
[ { "answer_id": 402488, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 0, "selected": false, "text": "<p>I'd suggest reporting this to the <a href=\"http://activemq.apache.org/camel/discussion-forums.html\" rel=\"...
2008/12/23
[ "https://Stackoverflow.com/questions/390044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33886/" ]
We've built up an application infrastructure based on ActiveMQ. We can send and receive messages just fine, and for the most part things are pretty fast and OK. However, we've noticed that if we submit a batch of messages "at once", say 5,000 messages - that ActiveMQ will get the messages to the 3rd party application...
Turns out, we think we know a bit more now what this is about. When our VB.NET WinForms app that uses the ActiveMQ DLL eventually crashes, which it tends to do a few times a week, we have a watchdog program that uses the Winternals pslist and pskill utilities to reap the zombie, and then start a new client connection....
390,051
<p>I want to write an Exception to an MS Message Queue. When I attempt it I get an exception. So I tried simplifying it by using the XmlSerializer which still raises an exception, but it gave me a bit more info:</p> <blockquote> <p>{"There was an error reflecting type 'System.Exception'."}</p> </blockquote> <p>wi...
[ { "answer_id": 390060, "author": "Otávio Décio", "author_id": 48684, "author_profile": "https://Stackoverflow.com/users/48684", "pm_score": 2, "selected": false, "text": "<p>Why? Are you instantiating an Exception upon retrieving it from the message queue? If not, just send the exception...
2008/12/23
[ "https://Stackoverflow.com/questions/390051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16260/" ]
I want to write an Exception to an MS Message Queue. When I attempt it I get an exception. So I tried simplifying it by using the XmlSerializer which still raises an exception, but it gave me a bit more info: > > {"There was an error reflecting type > 'System.Exception'."} > > > with InnerException: > > {"Can...
I think you basically have two options: 1. Do your own manual serialization (probably do NOT want to do that). XML serialization will surely not work due to the exact message you get in the inner exception. 2. Create your own custom (serializable) exception class, inject data from the thrown Exception into your custom...
390,083
<p>Have just started playing with ASP.NET MVC and have stumbled over the following situation. It feels a lot like a bug but if its not, an explanation would be appreciated :)</p> <p>The View contains pretty basic stuff</p> <pre><code>&lt;%=Html.DropDownList("MyList", ViewData["MyListItems"] as SelectList)%&gt; &lt;%...
[ { "answer_id": 390339, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 4, "selected": true, "text": "<p>After a bunch of hemming and hawing it boils down to the following line of code</p>\n\n<pre><code>if (ViewData.ModelS...
2008/12/23
[ "https://Stackoverflow.com/questions/390083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8262/" ]
Have just started playing with ASP.NET MVC and have stumbled over the following situation. It feels a lot like a bug but if its not, an explanation would be appreciated :) The View contains pretty basic stuff ``` <%=Html.DropDownList("MyList", ViewData["MyListItems"] as SelectList)%> <%=Html.TextBox("MyTextBox")%> `...
After a bunch of hemming and hawing it boils down to the following line of code ``` if (ViewData.ModelState.TryGetValue(key, out modelState)) ``` which means MVC is trying to resolve the value by only looking at the ViewData Dictionary<> object and not traversing down into the ViewData.Model object. Whether that's ...
390,103
<p>This is related to my <a href="https://stackoverflow.com/questions/390017/hide-a-table-column-in-a-nested-listview">earlier question</a>, but I thought I'd simplify it and make a challenge out of it. Given the code below, can you change the value of "ChangeThisLabel" from the code behind?</p> <pre><code>&lt;asp:Lis...
[ { "answer_id": 390117, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 1, "selected": false, "text": "<p>In your DataBound (or something like it) event handler use <code>FindControl(\"ChangeThisLabel\")</code> to get a reference...
2008/12/23
[ "https://Stackoverflow.com/questions/390103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23935/" ]
This is related to my [earlier question](https://stackoverflow.com/questions/390017/hide-a-table-column-in-a-nested-listview), but I thought I'd simplify it and make a challenge out of it. Given the code below, can you change the value of "ChangeThisLabel" from the code behind? ``` <asp:ListView ID="OuterListView" run...
as it was mentioned in the other answer. in the code behind, on load, you can do this: ``` `OuterListView.FindControl("InnerListView").FindControl("ChangeThisLabel") ``` then cast it as a label and change the text. obviously you would iterate this code inside a loop so you do it for every label in ever inner list vi...
390,105
<p>I've have finally got the datepicker to work on my MVC demo site. One thing though it doesn't work when browsing with IE7, I havn't testet with IE6 yet. Does anyone know how to fix this problem or can't I use jQuery if I want IE users to be able to pick dates?</p> <p>It works like a charm on Safari and Firefox, exc...
[ { "answer_id": 390134, "author": "SquidScareMe", "author_id": 30921, "author_profile": "https://Stackoverflow.com/users/30921", "pm_score": 0, "selected": false, "text": "<p><a href=\"https://stackoverflow.com/questions/385269/jquery-ui-datepicker-in-aspnet-mvc\">Is this helpful at all?<...
2008/12/23
[ "https://Stackoverflow.com/questions/390105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/459417/" ]
I've have finally got the datepicker to work on my MVC demo site. One thing though it doesn't work when browsing with IE7, I havn't testet with IE6 yet. Does anyone know how to fix this problem or can't I use jQuery if I want IE users to be able to pick dates? It works like a charm on Safari and Firefox, except for it...
If I'm not mistaken, you have a trailing comma in your parameter list. IE will choke on trailing commas all the time in js. Try this: ``` $(function() { $("#Date").datepicker($.extend({}, $.datepicker.regional["sv"], { onSelect: function(date) { }, minDate:...
390,106
<p>It seems to be a common requirement nowadays to have a search feature that can search almost anything you want. Can anyone give me samples or tips as to how to go about building a one stop search for an application?</p> <p>For example: you have 3 tables customers, products, employees. The application has a master p...
[ { "answer_id": 390137, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 1, "selected": false, "text": "<p>One way would be to <a href=\"http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm\" rel=\"nofollow noreferrer\">f...
2008/12/23
[ "https://Stackoverflow.com/questions/390106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37494/" ]
It seems to be a common requirement nowadays to have a search feature that can search almost anything you want. Can anyone give me samples or tips as to how to go about building a one stop search for an application? For example: you have 3 tables customers, products, employees. The application has a master page that h...
[Lucene.NET](http://incubator.apache.org/lucene.net/) is an extremely fast full text search engine. Sample usage: See [Source code](http://code.google.com/p/dotnetkicks/) of [DotNetKicks](http://www.dotnetkicks.com/) starting from [codebehind of search page](http://code.google.com/p/dotnetkicks/source/browse/trunk/D...
390,108
<p>What are general guidelines on when user-defined implicit conversion could, should, or should not be defined?</p> <p>I mean things like, for example, "an implicit conversion should never lose information", "an implicit conversion should never throw exceptions", or "an implicit conversion should never instantiate ne...
[ { "answer_id": 390125, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "<p>I'd agree with the first definitely - the second most of the time (\"never say never\"), but wouldn't get excited ...
2008/12/23
[ "https://Stackoverflow.com/questions/390108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9204/" ]
What are general guidelines on when user-defined implicit conversion could, should, or should not be defined? I mean things like, for example, "an implicit conversion should never lose information", "an implicit conversion should never throw exceptions", or "an implicit conversion should never instantiate new objects"...
The first isn't as simple as you might expect. Here's an example: ``` using System; class Test { static void Main() { long firstLong = long.MaxValue - 2; long secondLong = firstLong - 1; double firstDouble = firstLong; double secondDouble = secondLong; // Prints False...
390,115
<p>What have others done to get around the fact that the Commons Logging project (for both .NET and Java) do not support Mapped or Nested Diagnostic Contexts as far as I know?</p>
[ { "answer_id": 396062, "author": "Barend", "author_id": 49489, "author_profile": "https://Stackoverflow.com/users/49489", "pm_score": 2, "selected": false, "text": "<p><b>Exec summary: </b></p>\n\n<p>We opted to use the implementor logging framework directly (in our case, log4j).</p>\n\n...
2008/12/23
[ "https://Stackoverflow.com/questions/390115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4458/" ]
What have others done to get around the fact that the Commons Logging project (for both .NET and Java) do not support Mapped or Nested Diagnostic Contexts as far as I know?
For the sake of completeness, I ended up writing my own very simple generic interface: ``` public interface IDiagnosticContextHandler { void Set(string name, string value); } ``` then implemented a Log4Net specific version: ``` public class Log4NetDiagnosticContextHandler : IDiagnosticContextHandler { priva...
390,118
<p>I have the following 3 classes </p> <pre><code>Book Product SpecialOptions </code></pre> <p>There are many Books, and there are many Products per Book. Likewise in a Product there are many SpecialOptions. There are other properties of each of these three classes so each class has the following interface</p> <pre>...
[ { "answer_id": 396062, "author": "Barend", "author_id": 49489, "author_profile": "https://Stackoverflow.com/users/49489", "pm_score": 2, "selected": false, "text": "<p><b>Exec summary: </b></p>\n\n<p>We opted to use the implementor logging framework directly (in our case, log4j).</p>\n\n...
2008/12/23
[ "https://Stackoverflow.com/questions/390118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22777/" ]
I have the following 3 classes ``` Book Product SpecialOptions ``` There are many Books, and there are many Products per Book. Likewise in a Product there are many SpecialOptions. There are other properties of each of these three classes so each class has the following interface ``` Public Interface IBook Priva...
For the sake of completeness, I ended up writing my own very simple generic interface: ``` public interface IDiagnosticContextHandler { void Set(string name, string value); } ``` then implemented a Log4Net specific version: ``` public class Log4NetDiagnosticContextHandler : IDiagnosticContextHandler { priva...
390,135
<p>How do you search for a specific text inside a text run (in Docx using the OpenXML SDK 2.0) and once you find it how do you insert a comment surrounding the 'search text'. The 'search text' can be a sub string of an existing run. All example in the samples insert comments around the first paragraph or something simp...
[ { "answer_id": 549807, "author": "herskinduk", "author_id": 63411, "author_profile": "https://Stackoverflow.com/users/63411", "pm_score": 2, "selected": false, "text": "<p>You have to break it up into separate runs. Try using the DocumentReflector - it even genereates C# code - to look a...
2008/12/23
[ "https://Stackoverflow.com/questions/390135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48753/" ]
How do you search for a specific text inside a text run (in Docx using the OpenXML SDK 2.0) and once you find it how do you insert a comment surrounding the 'search text'. The 'search text' can be a sub string of an existing run. All example in the samples insert comments around the first paragraph or something simple ...
You have to break it up into separate runs. Try using the DocumentReflector - it even genereates C# code - to look at a document created with word. The structure should look something like this (simplified): ``` <paragraph> <run>...</run> <commentRangeStart /> <run>search text</run> <commentRangeEnd /> <run>...
390,148
<p>I have a web application that is generating hundreds of PDFs in batch, using ColdFusion 8 on a Windows/IIS server.</p> <p>The process runs fine on my development and staging servers, but of course the client is cheap and is only paying for shared hosting, which isn't as fast as my dev/staging boxes. As a result, PD...
[ { "answer_id": 402124, "author": "Isaac Dealey", "author_id": 50355, "author_profile": "https://Stackoverflow.com/users/50355", "pm_score": 2, "selected": false, "text": "<p>I don't think there is a way to make the thread live longer on a shared host where you don't have access to the cf...
2008/12/23
[ "https://Stackoverflow.com/questions/390148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/751/" ]
I have a web application that is generating hundreds of PDFs in batch, using ColdFusion 8 on a Windows/IIS server. The process runs fine on my development and staging servers, but of course the client is cheap and is only paying for shared hosting, which isn't as fast as my dev/staging boxes. As a result, PDF generati...
While this doesn't directly answer my original question of increasing the timeout of a thread, I have been able to make the process work (prevent timeouts) by improving PDF generation time. According to the [livedocs](http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_d-e_05.html#3765835), ColdFusion 8 added a `loca...
390,150
<p>I have a simple task of authenticating against Active Directory using Java. Just verifying credentials and nothing else. Let's say my domain is "fun.xyz.tld", OU path is unknown, and username/password is testu/testp. </p> <p>I know there's a few Java libraries out there that simplify this task, but I wasn't success...
[ { "answer_id": 390169, "author": "Anthony", "author_id": 48463, "author_profile": "https://Stackoverflow.com/users/48463", "pm_score": 2, "selected": false, "text": "<p>Are you just verifying credentials? In that case you could just do plain <code>kerberos</code> and not bother with <cod...
2008/12/23
[ "https://Stackoverflow.com/questions/390150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18406/" ]
I have a simple task of authenticating against Active Directory using Java. Just verifying credentials and nothing else. Let's say my domain is "fun.xyz.tld", OU path is unknown, and username/password is testu/testp. I know there's a few Java libraries out there that simplify this task, but I wasn't successful at imp...
Here's the code I put together based on example from this blog: [LINK](https://community.oracle.com/blogs/kohsuke/2008/06/12/more-active-directory-integration-java) and this source: [LINK](https://github.com/jenkinsci/active-directory-plugin/blob/master/src/main/java/hudson/plugins/active_directory/ActiveDirectoryUnixA...
390,164
<p>Say I need to call a javascript file in the <code>&lt;head&gt;</code> of an ERb template. My instinct is to do the usual:</p> <pre><code>&lt;head&gt; &lt;%= javascript_include_tag :defaults %&gt; &lt;!-- For example --&gt; &lt;/head&gt; </code></pre> <p>in my application's layout. The problem of course becoming th...
[ { "answer_id": 390182, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 1, "selected": false, "text": "<p>I usually have the following in the layout file:</p>\n\n<pre><code>&lt;head&gt;\n &lt;%= javascript_include_tag :defaul...
2008/12/23
[ "https://Stackoverflow.com/questions/390164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2293/" ]
Say I need to call a javascript file in the `<head>` of an ERb template. My instinct is to do the usual: ``` <head> <%= javascript_include_tag :defaults %> <!-- For example --> </head> ``` in my application's layout. The problem of course becoming that these javascript files are loaded into every page in my applicat...
I would use [content\_for](http://apidock.com/rails/ActionView/Helpers/CaptureHelper/content_for). For instance, specify the place to insert it in the application layout: ``` <head> <title>Merry Christmas!</title> <%= yield(:head) -%> </head> ``` And send it there from a view: ``` <%- content_for(:head) do -%> <%=...
390,174
<p>I have a file with a bunch of lines. I have recorded a macro that performs an operation on a single line. I want to repeat that macro on all of the remaining lines in the file. Is there a quick way to do this?</p> <p>I tried Ctrl+Q, highlighted a set of lines, and pressed @@, but that didn't seem to do the trick...
[ { "answer_id": 390194, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 10, "selected": true, "text": "<p>Use the <a href=\"http://vimdoc.sourceforge.net/htmldoc/various.html#:normal\" rel=\"noreferrer\">normal</a> comm...
2008/12/23
[ "https://Stackoverflow.com/questions/390174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20133/" ]
I have a file with a bunch of lines. I have recorded a macro that performs an operation on a single line. I want to repeat that macro on all of the remaining lines in the file. Is there a quick way to do this? I tried Ctrl+Q, highlighted a set of lines, and pressed @@, but that didn't seem to do the trick.
Use the [normal](http://vimdoc.sourceforge.net/htmldoc/various.html#:normal) command in Ex mode to execute the macro on multiple/all lines: Execute the macro stored in register **a** on lines 5 through 10. ``` :5,10norm! @a ``` Execute the macro stored in register **a** on lines 5 through the end of the file. ``` ...
390,176
<p>I know that the f# list is not the same at the c# List. What do I need to do to be able to pass a list of ints from a c# application to an f# library? I'd like to be able to use pattern matching on the data once it's in the f# code.</p>
[ { "answer_id": 390198, "author": "t3rse", "author_id": 64, "author_profile": "https://Stackoverflow.com/users/64", "pm_score": 0, "selected": false, "text": "<p>You can reference C# Assemblies from F# projects. Expose your list via a referenced assembly.</p>\n" }, { "answer_id": ...
2008/12/23
[ "https://Stackoverflow.com/questions/390176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26339/" ]
I know that the f# list is not the same at the c# List. What do I need to do to be able to pass a list of ints from a c# application to an f# library? I'd like to be able to use pattern matching on the data once it's in the f# code.
Here is how I ended up doing it. The FSharp code: ``` let rec FindMaxInList list = match list with | [x] -> x | h::t -> max h (FindMaxInList t) | [] -> failwith "empty list" let rec FindMax ( array : ResizeArray<int>) = let list = List.ofSeq(array) FindMaxInList list ``` The c Sharp code: ``` ...
390,181
<p>I'm working on a project, written in Java, which requires that I build a very large 2-D sparse array. Very sparse, if that makes a difference. Anyway: the most crucial aspect for this application is efficency in terms of time (assume loads of memory, though not nearly so unlimited as to allow me to use a standard ...
[ { "answer_id": 391121, "author": "Osama Al-Maadeed", "author_id": 25544, "author_profile": "https://Stackoverflow.com/users/25544", "pm_score": 2, "selected": false, "text": "<p>This seems to be simple.</p>\n\n<p>You could use a binary tree of the data using row*maxcolums+column as an in...
2008/12/23
[ "https://Stackoverflow.com/questions/390181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47450/" ]
I'm working on a project, written in Java, which requires that I build a very large 2-D sparse array. Very sparse, if that makes a difference. Anyway: the most crucial aspect for this application is efficency in terms of time (assume loads of memory, though not nearly so unlimited as to allow me to use a standard 2-D a...
Sparsed arrays built with hashmaps are very inefficient for frequently read data. The most efficient implementations uses a Trie that allows access to a single vector where segments are distributed. A Trie can compute if an element is present in the table by performing only read-only TWO array indexing to get the effe...
390,187
<p>When attempting to copy a framework into the Frameworks folder of my project in Xcode, I get the error</p> <blockquote> <p>Could not copy /Developer/Platforms/.../Frameworks/OpenAL.framework to /Users/.../OpenAL.framework</p> </blockquote> <p>I had accidentally copied the wrong framework with the same name into ...
[ { "answer_id": 391121, "author": "Osama Al-Maadeed", "author_id": 25544, "author_profile": "https://Stackoverflow.com/users/25544", "pm_score": 2, "selected": false, "text": "<p>This seems to be simple.</p>\n\n<p>You could use a binary tree of the data using row*maxcolums+column as an in...
2008/12/23
[ "https://Stackoverflow.com/questions/390187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21293/" ]
When attempting to copy a framework into the Frameworks folder of my project in Xcode, I get the error > > Could not copy /Developer/Platforms/.../Frameworks/OpenAL.framework to /Users/.../OpenAL.framework > > > I had accidentally copied the wrong framework with the same name into the project earlier and deleted ...
Sparsed arrays built with hashmaps are very inefficient for frequently read data. The most efficient implementations uses a Trie that allows access to a single vector where segments are distributed. A Trie can compute if an element is present in the table by performing only read-only TWO array indexing to get the effe...
390,192
<p>When I define an object of a class using new like this</p> <pre><code>$blah = new Whatever(); </code></pre> <p>I get autocomplete for $blah. <strong>But how do I do it when I have $blah as a function parameter?</strong> Without autocomplete I am incomplete.</p> <p><strong>Edit</strong>: <strong>How do I do it if ...
[ { "answer_id": 390211, "author": "maxnk", "author_id": 45862, "author_profile": "https://Stackoverflow.com/users/45862", "pm_score": 3, "selected": false, "text": "<p>Try to pass parameter class definition into the function:</p>\n\n<pre><code>function myFunction(Whatever $blah) {\n}\n</c...
2008/12/23
[ "https://Stackoverflow.com/questions/390192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
When I define an object of a class using new like this ``` $blah = new Whatever(); ``` I get autocomplete for $blah. **But how do I do it when I have $blah as a function parameter?** Without autocomplete I am incomplete. **Edit**: **How do I do it if it's in an include and PDT or Netbeans can't figure it out?** Is ...
Method in first comment is called "type hinting", but you should use that wisely. Better solution is phpDoc. ``` /** * Some description of function behaviour. * * @param Whatever $blah */ public function myFunction($blah) { $blah-> // Now $blah is Whatever object, autocompletion will work. } ``` You can...
390,195
<p>We have an old Classic ASP application that we have been using Visual Studio 6 to maintain. This has worked fine, but we're ready to step out of the stone age and I'd like to see if I can use Visual Studio 2008 (SP1) to maintain the application.</p> <p>In the past, multiple developers could work on the application...
[ { "answer_id": 390211, "author": "maxnk", "author_id": 45862, "author_profile": "https://Stackoverflow.com/users/45862", "pm_score": 3, "selected": false, "text": "<p>Try to pass parameter class definition into the function:</p>\n\n<pre><code>function myFunction(Whatever $blah) {\n}\n</c...
2008/12/23
[ "https://Stackoverflow.com/questions/390195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48760/" ]
We have an old Classic ASP application that we have been using Visual Studio 6 to maintain. This has worked fine, but we're ready to step out of the stone age and I'd like to see if I can use Visual Studio 2008 (SP1) to maintain the application. In the past, multiple developers could work on the application and it was...
Method in first comment is called "type hinting", but you should use that wisely. Better solution is phpDoc. ``` /** * Some description of function behaviour. * * @param Whatever $blah */ public function myFunction($blah) { $blah-> // Now $blah is Whatever object, autocompletion will work. } ``` You can...
390,205
<p>I'm trying to convert all instances of the > character to its HTML entity equivalent, &gt;, within a string of HTML that contains HTML tags. The furthest I've been able to get with a solution for this is using a regex.</p> <p>Here's what I have so far:</p> <pre><code> public static readonly Regex HtmlAngleB...
[ { "answer_id": 390229, "author": "Jeff.Crossett", "author_id": 44746, "author_profile": "https://Stackoverflow.com/users/44746", "pm_score": 1, "selected": false, "text": "<p>Maybe read your HTML into an XML parser which should take care of the conversions for you.</p>\n" }, { "a...
2008/12/23
[ "https://Stackoverflow.com/questions/390205", "https://Stackoverflow.com", "https://Stackoverflow.com/users/769/" ]
I'm trying to convert all instances of the > character to its HTML entity equivalent, >, within a string of HTML that contains HTML tags. The furthest I've been able to get with a solution for this is using a regex. Here's what I have so far: ``` public static readonly Regex HtmlAngleBracketNotPartOfTag = new...
The trick is to capture everything that *isn't* the target, then plug it back in along with the changed text, like this: ``` Regex.Replace(str, @"\G((?>[^<>]+|<[^>]*>)*)>", "$1&gt;"); ``` But Anthony's right: right angle brackets in text nodes shouldn't cause any problems. And matching HTML with regexes is tricky; f...
390,238
<p>I'm looking for ways to display a single row of data as a single column (with multiple rows). For example,</p> <pre> FieldA FieldB ------- --------- 1 Some Text [row] Header Value [col] ------ ------ FieldA 1 [row1] FieldB SomeText [row2] </pre> <p>Is there a way to do this with SQL Server 20...
[ { "answer_id": 390254, "author": "dkretz", "author_id": 31641, "author_profile": "https://Stackoverflow.com/users/31641", "pm_score": 3, "selected": true, "text": "<p>Yup, there's a TSQL command, PIVOT. And there are several existing threads on this topic; but I can't find one offhand.</...
2008/12/23
[ "https://Stackoverflow.com/questions/390238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28413/" ]
I'm looking for ways to display a single row of data as a single column (with multiple rows). For example, ``` FieldA FieldB ------- --------- 1 Some Text [row] Header Value [col] ------ ------ FieldA 1 [row1] FieldB SomeText [row2] ``` Is there a way to do this with SQL Server 2005?
Yup, there's a TSQL command, PIVOT. And there are several existing threads on this topic; but I can't find one offhand. My usual answer (probably 5 or 6 of those threads) is to think about using Excel or Access if appropriate - it's a pretty easy way to deliver value to end-users. But YMMV.
390,250
<p>When writing custom classes it is often important to allow equivalence by means of the <code>==</code> and <code>!=</code> operators. In Python, this is made possible by implementing the <code>__eq__</code> and <code>__ne__</code> special methods, respectively. The easiest way I've found to do this is the following ...
[ { "answer_id": 390280, "author": "Vasil", "author_id": 7883, "author_profile": "https://Stackoverflow.com/users/7883", "pm_score": 3, "selected": false, "text": "<p>You don't have to override both <code>__eq__</code> and <code>__ne__</code> you can override only <code>__cmp__</code> but ...
2008/12/23
[ "https://Stackoverflow.com/questions/390250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38140/" ]
When writing custom classes it is often important to allow equivalence by means of the `==` and `!=` operators. In Python, this is made possible by implementing the `__eq__` and `__ne__` special methods, respectively. The easiest way I've found to do this is the following method: ``` class Foo: def __init__(self, ...
Consider this simple problem: ``` class Number: def __init__(self, number): self.number = number n1 = Number(1) n2 = Number(1) n1 == n2 # False -- oops ``` So, Python by default uses the object identifiers for comparison operations: ``` id(n1) # 140400634555856 id(n2) # 140400634555920 ``` Overridi...
390,263
<p>I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse.</p> <p>For example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614).</p> <p>How can I get the numerical amount from excel or how can I conv...
[ { "answer_id": 390304, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 0, "selected": false, "text": "<p>I tried this with Excel 2007 and VBA. It is giving correct value.</p>\n\n<p>1) Try pasting this value in a new exce...
2008/12/23
[ "https://Stackoverflow.com/questions/390263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse. For example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614). How can I get the numerical amount from excel or how can I convert this tuple va...
Try this: ``` import struct try: import decimal except ImportError: divisor= 10000.0 else: divisor= decimal.Decimal(10000) def xl_money(i1, i2): byte8= struct.unpack(">q", struct.pack(">ii", i1, i2))[0] return byte8 / divisor >>> xl_money(1, 1194857614) Decimal("548982.491") ``` Money in Microsoft ...
390,265
<p>I always seem to see if a string (querystring value usually) has a value but first I have to check that it is not nothing first so I end up with 2 if then statements - am I missing somethign here - there has to be a better way to do this:</p> <pre><code>If Not String.IsNullOrEmpty(myString) Then If CBool(myStrin...
[ { "answer_id": 390271, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>The boolean \"and\" operator in your language of choice? Conditionals generally short-circuit so if the first one fails, th...
2008/12/23
[ "https://Stackoverflow.com/questions/390265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I always seem to see if a string (querystring value usually) has a value but first I have to check that it is not nothing first so I end up with 2 if then statements - am I missing somethign here - there has to be a better way to do this: ``` If Not String.IsNullOrEmpty(myString) Then If CBool(myString) Then //co...
In VB.Net, And does not short-circuit, but [AndAlso](http://msdn.microsoft.com/en-us/library/cb8x3kfz(VS.80).aspx) does. (same for Or and OrElse) So your code should look something like ``` If Not String.IsNullOrEmpty(myString) AndAlso CBool(myString) Then .... End If ```
390,276
<p>Here's a problem that I've been running into lately - a misconfigured apache on a webhost. This means that all scripts that rely on <code>$_SERVER['DOCUMENT_ROOT']</code> break. The easiest workaround that I've found is just set the variable in some global include files that is shared, but it's a pain not to forget ...
[ { "answer_id": 390295, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>PHP <em>should</em> be setting the current directory to the one the script is in, so as long as that's not broken you shoul...
2008/12/23
[ "https://Stackoverflow.com/questions/390276", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27610/" ]
Here's a problem that I've been running into lately - a misconfigured apache on a webhost. This means that all scripts that rely on `$_SERVER['DOCUMENT_ROOT']` break. The easiest workaround that I've found is just set the variable in some global include files that is shared, but it's a pain not to forget it. My questio...
Based on <http://www.helicron.net/php/>: ``` $localpath=getenv("SCRIPT_NAME"); $absolutepath=getenv("SCRIPT_FILENAME"); $_SERVER['DOCUMENT_ROOT']=substr($absolutepath,0,strpos($absolutepath,$localpath)); ``` I had to change the basename/realpath trick because it returned an empty string on my host. Instead, I u...
390,278
<p>I'm setting up a new PC and I installed my project to work with. It is a .NET Remoting 2.0 application that uses the ASP.NET development server to host the server side while developing. I'm getting the following error when I make requests to the server:</p> <p>"The remote server returned an error: (403) Forbidden. ...
[ { "answer_id": 390318, "author": "NotMe", "author_id": 2424, "author_profile": "https://Stackoverflow.com/users/2424", "pm_score": 2, "selected": false, "text": "<p>What is the error subcode?</p>\n\n<pre><code>403 - Forbidden. IIS defines several different 403 errors that indicate a more...
2008/12/23
[ "https://Stackoverflow.com/questions/390278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31017/" ]
I'm setting up a new PC and I installed my project to work with. It is a .NET Remoting 2.0 application that uses the ASP.NET development server to host the server side while developing. I'm getting the following error when I make requests to the server: "The remote server returned an error: (403) Forbidden. " I've ch...
OK. I've found the answer ... better part of a day shot though. Turns out the 403 error is thrown by one of our channel sink providers that filters on IP values. The channel sink provider was written with some big assumptions. First off, it is looking for the address of the calling machine and comparing it to an ip wh...
390,284
<p>Using Flex 3 with the ColdFusion plugin, can I not write a standalone ColdFusion class which I can invoke from my flex website (mxml)?</p> <p>Thanks</p>
[ { "answer_id": 400548, "author": "Brett", "author_id": 47581, "author_profile": "https://Stackoverflow.com/users/47581", "pm_score": 2, "selected": false, "text": "<p>You can invoke methods in a standalone ColdFusion CFC using RemoteObject. Note these methods should be marked with access...
2008/12/23
[ "https://Stackoverflow.com/questions/390284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
Using Flex 3 with the ColdFusion plugin, can I not write a standalone ColdFusion class which I can invoke from my flex website (mxml)? Thanks
You can invoke methods in a standalone ColdFusion CFC using RemoteObject. Note these methods should be marked with access="remote" in ColdFusion. ``` <mx:Script> <![CDATA[ private function callMethod():void { ro.MethodName; } private function resultHandler(evt:ResultEvent):void { ...
390,286
<p>I am trying to write a generic Parse method that converts and returns a strongly typed value from a NamedValueCollection. I tried two methods but both of these methods are going through boxing and unboxing to get the value. Does anyone know a way to avoid the boxing? If you saw this in production would you not li...
[ { "answer_id": 390312, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 5, "selected": false, "text": "<pre><code>public static T Parse&lt;T&gt;(this NameValueCollection col, string key)\n{\n return (T)Convert.ChangeTy...
2008/12/23
[ "https://Stackoverflow.com/questions/390286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37881/" ]
I am trying to write a generic Parse method that converts and returns a strongly typed value from a NamedValueCollection. I tried two methods but both of these methods are going through boxing and unboxing to get the value. Does anyone know a way to avoid the boxing? If you saw this in production would you not like it,...
I think you are over estimating the impact of the boxing/unboxing. The parse method will have a much bigger overhead (string parsing), dwarfing the boxing overhead. Also all the if statements will have a bigger impact. Reflection has the biggest impact of all. I'd would not like to see this kind of code in production,...
390,289
<p>I just refactored some code that was in a different section of the class I was working on because it was a series of nested conditional operators (?:) that was made a ton clearer by a fairly simple switch statement (C#). </p> <p>When will you touch code that isn't directly what you are working on to make it more c...
[ { "answer_id": 390294, "author": "Robert C. Barth", "author_id": 9209, "author_profile": "https://Stackoverflow.com/users/9209", "pm_score": 3, "selected": false, "text": "<p>Whenever I come across it and I don't think changing it will cause problems (e.g. I can understand it enough that...
2008/12/23
[ "https://Stackoverflow.com/questions/390289", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13100/" ]
I just refactored some code that was in a different section of the class I was working on because it was a series of nested conditional operators (?:) that was made a ton clearer by a fairly simple switch statement (C#). When will you touch code that isn't directly what you are working on to make it more clear?
I once was refactoring and came across something like this code: ``` string strMyString; try { strMyString = Session["MySessionVar"].ToString(); } catch { strMyString = ""; } ``` Resharper pointed out that the .ToString() was redundant, so I took it out. Unfortunately, that ended up breaking the code. Whenever M...
390,307
<p>What are the cons and pros of windows services vs scheduled tasks for running a program repeatedly (e.g. every two minutes)?</p>
[ { "answer_id": 390319, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 2, "selected": false, "text": "<p>A Windows service doesn't need to have anyone logged in, and Windows has facilities for stopping, starting, and loggi...
2008/12/23
[ "https://Stackoverflow.com/questions/390307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
What are the cons and pros of windows services vs scheduled tasks for running a program repeatedly (e.g. every two minutes)?
**Update:** **Nearly four years after my original answer and this answer is very out of date. Since [TopShelf](http://docs.topshelf-project.com/en/latest/overview/faq.html) came along Windows Services development got easy. Now you just need to figure out how to support failover...** Original Answer: I'm really not a...
390,326
<p>I have a base class with a virtual method, and multiple subclasses that override that method.</p> <p>When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there s...
[ { "answer_id": 390341, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 1, "selected": false, "text": "<p>Why should it print \"Foo\"? That is not the purpose of virtual methods. The whole point is that the derived classes can ...
2008/12/23
[ "https://Stackoverflow.com/questions/390326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6054/" ]
I have a base class with a virtual method, and multiple subclasses that override that method. When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be a...
``` class Foo { public virtual void virtualPrintMe() { nonVirtualPrintMe(); } public void nonVirtualPrintMe() { Console.Writeline("FOO"); } } class Bar : Foo { public override void virtualPrintMe() { Console.Writeline("BAR"); } } List<Foo> list = new List...
390,354
<p>I am using .NET 2.0 and SQL Server 2005. For historical reasons, the app code is using SQLTransaction but some of the stored procedures are also using T-SQL begin/commit/rollback tran statements. The idea is that the DBTransaction can span many stored procedures, which each individual sproc controls what's happening...
[ { "answer_id": 390341, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 1, "selected": false, "text": "<p>Why should it print \"Foo\"? That is not the purpose of virtual methods. The whole point is that the derived classes can ...
2008/12/23
[ "https://Stackoverflow.com/questions/390354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48776/" ]
I am using .NET 2.0 and SQL Server 2005. For historical reasons, the app code is using SQLTransaction but some of the stored procedures are also using T-SQL begin/commit/rollback tran statements. The idea is that the DBTransaction can span many stored procedures, which each individual sproc controls what's happening in...
``` class Foo { public virtual void virtualPrintMe() { nonVirtualPrintMe(); } public void nonVirtualPrintMe() { Console.Writeline("FOO"); } } class Bar : Foo { public override void virtualPrintMe() { Console.Writeline("BAR"); } } List<Foo> list = new List...
390,362
<p>I've got a sproc (MSSQL 2k5) that will take a variable for a LIKE claus like so:</p> <pre><code>DECLARE @SearchLetter2 char(1) SET @SearchLetter = 't' SET @SearchLetter2 = @SearchLetter + '%' SELECT * FROM BrandNames WHERE [Name] LIKE @SearchLetter2 and IsVisible = 1 --WHERE [Name] LIKE 't%' and IsVis...
[ { "answer_id": 390397, "author": "Eric Sabine", "author_id": 1493157, "author_profile": "https://Stackoverflow.com/users/1493157", "pm_score": 6, "selected": true, "text": "<p>Joel is it that @SearchLetter hasn't been declared yet? Also the length of @SearchLetter2 isn't long enough for...
2008/12/23
[ "https://Stackoverflow.com/questions/390362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42568/" ]
I've got a sproc (MSSQL 2k5) that will take a variable for a LIKE claus like so: ``` DECLARE @SearchLetter2 char(1) SET @SearchLetter = 't' SET @SearchLetter2 = @SearchLetter + '%' SELECT * FROM BrandNames WHERE [Name] LIKE @SearchLetter2 and IsVisible = 1 --WHERE [Name] LIKE 't%' and IsVisible = 1 ...
Joel is it that @SearchLetter hasn't been declared yet? Also the length of @SearchLetter2 isn't long enough for 't%'. Try a varchar of a longer length.
390,368
<p>Is there a way to stop Google from indexing a site? <br /></p>
[ { "answer_id": 390379, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 8, "selected": true, "text": "<p>robots.txt</p>\n\n<pre><code>User-agent: *\nDisallow: /\n</code></pre>\n\n<p>this will block all search bots from indexing...
2008/12/23
[ "https://Stackoverflow.com/questions/390368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
Is there a way to stop Google from indexing a site?
robots.txt ``` User-agent: * Disallow: / ``` this will block all search bots from indexing. for more info see: <http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40360>
390,375
<p>In PHP, if you define a class, and then instantiate an object of that class, it's possible to later arbitrarily add new members to that class. For example:</p> <pre><code>class foo { public $bar = 5; } $A = new foo; $A-&gt;temp = 10; </code></pre> <p>However, I'd like the ability to make it impossible to add...
[ { "answer_id": 390388, "author": "UnkwnTech", "author_id": 115, "author_profile": "https://Stackoverflow.com/users/115", "pm_score": 0, "selected": false, "text": "<p>I have to ask why you need to do this? If a member is assigned and does not exist it does not affect the methods, and if...
2008/12/23
[ "https://Stackoverflow.com/questions/390375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20903/" ]
In PHP, if you define a class, and then instantiate an object of that class, it's possible to later arbitrarily add new members to that class. For example: ``` class foo { public $bar = 5; } $A = new foo; $A->temp = 10; ``` However, I'd like the ability to make it impossible to add new members this way. Basical...
No. There's no better way than `__set` in a base class — yet. This is a known problem and is [planned to be addressed in the future](http://wiki.php.net/todo/php53): > > Introduce concept of “strict classes” that do not permit dynamic property creation > > >
390,381
<p>I am writing a small applescript which retrieves all "unread" messages in the viewer and loops them.</p> <p>I have two goals to complete:</p> <ol> <li><p>I need to get the subject of each message and perform a regular expression to see if it's suitable for step 2 (ex: get emails with subject {.*})</p></li> <li><p>...
[ { "answer_id": 390549, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 2, "selected": false, "text": "<p>The following applescript works for me, but I'm not sure how to do the regex matching. You can use the unix 'grep' func...
2008/12/23
[ "https://Stackoverflow.com/questions/390381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48780/" ]
I am writing a small applescript which retrieves all "unread" messages in the viewer and loops them. I have two goals to complete: 1. I need to get the subject of each message and perform a regular expression to see if it's suitable for step 2 (ex: get emails with subject {.\*}) 2. I need to open each message on a se...
The following applescript works for me, but I'm not sure how to do the regex matching. You can use the unix 'grep' function with applescript's '`do shell script`' command, but I'm no expert in how to use grep properly. I'll leave that for someone else to answer. ``` on run tell application "Mail" set myIn...
390,385
<p>If I create a file:</p> <p>test.cpp:</p> <pre><code>void f(double **a) { } int main() { double var[4][2]; f(var); } </code></pre> <p>And then run: g++ test.cpp -o test</p> <p>I get</p> <pre><code>test.cpp: In function `int main()': test.cpp:8: error: cannot convert `double (*)[2]' to `double**' for ar...
[ { "answer_id": 390417, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": false, "text": "<p><a href=\"https://stackoverflow.com/questions/308279/c-vs#308724\">C++ strings: [] vs. *</a></p>\n\n<p>L...
2008/12/23
[ "https://Stackoverflow.com/questions/390385", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48782/" ]
If I create a file: test.cpp: ``` void f(double **a) { } int main() { double var[4][2]; f(var); } ``` And then run: g++ test.cpp -o test I get ``` test.cpp: In function `int main()': test.cpp:8: error: cannot convert `double (*)[2]' to `double**' for argument `1' to `void f(double**)' ``` Why is that...
[C++ strings: [] vs. \*](https://stackoverflow.com/questions/308279/c-vs#308724) Look at the *Excursion: Multi Dimensional Arrays* which describes how you pass multi dimensional arrays to functions as arguments. Basicially you want to change your code into this: ``` // same as void f(double (*a)[2]) { void f(double a...