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
248,603
<p>Anyone have a good resource or provide a sample of a natural order sort in C# for an <code>FileInfo</code> array? I am implementing the <code>IComparer</code> interface in my sorts.</p>
[ { "answer_id": 248613, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 8, "selected": true, "text": "<p>The easiest thing to do is just P/Invoke the built-in function in Windows, and use it as the comparison function in y...
2008/10/29
[ "https://Stackoverflow.com/questions/248603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
Anyone have a good resource or provide a sample of a natural order sort in C# for an `FileInfo` array? I am implementing the `IComparer` interface in my sorts.
The easiest thing to do is just P/Invoke the built-in function in Windows, and use it as the comparison function in your `IComparer`: ``` [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)] private static extern int StrCmpLogicalW(string psz1, string psz2); ``` Michael Kaplan has some [examples of how this functio...
248,615
<p>I have a private const int defined in a C# class. I want compilation to fail with an error if the value of this int mod 3 != 0. How can I accomplish this?</p>
[ { "answer_id": 248636, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "<p>Although there is an <a href=\"http://msdn.microsoft.com/en-us/library/x5hedts0.aspx\" rel=\"nofollow noreferrer\"><e...
2008/10/29
[ "https://Stackoverflow.com/questions/248615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a private const int defined in a C# class. I want compilation to fail with an error if the value of this int mod 3 != 0. How can I accomplish this?
Timothy Khouri almost got it. It should be this: ``` int compilerError = 1 / (MY_CONST % 3 == 0 ? 1 : 0); ```
248,617
<p>I'm wondering if it is possible to add methods in main program to an existing class defined in header file. For example: There is <code>class CFun</code> defined in file <code>CFun.hpp</code>, but in our <code>party.cpp</code> we want to add a method <code>void hello() {cout &lt;&lt; "hello" &lt;&lt; endl;};</code>w...
[ { "answer_id": 248622, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 0, "selected": false, "text": "<p>Not to my knowledge. Although, you could do some kind of jury-rigging and make a namespace-y solution.</p>\n" }, ...
2008/10/29
[ "https://Stackoverflow.com/questions/248617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32312/" ]
I'm wondering if it is possible to add methods in main program to an existing class defined in header file. For example: There is `class CFun` defined in file `CFun.hpp`, but in our `party.cpp` we want to add a method `void hello() {cout << "hello" << endl;};`without editing `CFun.hpp` Obviously (unfortunately) constr...
No, but you could add a method that takes a reference/pointer to a CFun class - you just won't have access to private data: ``` void Hello(CFun &fun) { cout << "hello" << endl; } ``` This is probably the best you'll be able to do. As pointed out by litb - this function has to be in the same namespace as CFun. Fo...
248,642
<p>I have a GridView control that I am dynamically creating at runtime. I am creating all the columns like this.</p> <pre><code>foreach (GridColumnConfig column in columns) { BoundField boundField = new BoundField(); boundField.HeaderText = column.Title; boundField.DataField = column.FieldName; boundFi...
[ { "answer_id": 248656, "author": "Paul Prewett", "author_id": 15751, "author_profile": "https://Stackoverflow.com/users/15751", "pm_score": 1, "selected": false, "text": "<p>The word-wrap CSS style works for me when I want to control wrapping. Here's a discussion that pretty well covers...
2008/10/29
[ "https://Stackoverflow.com/questions/248642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I have a GridView control that I am dynamically creating at runtime. I am creating all the columns like this. ``` foreach (GridColumnConfig column in columns) { BoundField boundField = new BoundField(); boundField.HeaderText = column.Title; boundField.DataField = column.FieldName; boundField.SortExpres...
The word-wrap CSS style works for me when I want to control wrapping. Here's a discussion that pretty well covers it. <http://bytes.com/forum/thread627827.html>
248,667
<p>Objective: take a UIImage, crop out a square in the middle, change size of square to 320x320 pixels, slice up the image into 16 80x80 images, save the 16 images in an array.</p> <p>Here's my code:</p> <pre><code>CGImageRef originalImage, resizedImage, finalImage, tmp; float imgWidth, imgHeight, diff; UIImage *squa...
[ { "answer_id": 249174, "author": "executor21", "author_id": 30952, "author_profile": "https://Stackoverflow.com/users/30952", "pm_score": 4, "selected": true, "text": "<p>After some more experimentation, I found the following solution (I still don't know why it didn't work as originally ...
2008/10/29
[ "https://Stackoverflow.com/questions/248667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30952/" ]
Objective: take a UIImage, crop out a square in the middle, change size of square to 320x320 pixels, slice up the image into 16 80x80 images, save the 16 images in an array. Here's my code: ``` CGImageRef originalImage, resizedImage, finalImage, tmp; float imgWidth, imgHeight, diff; UIImage *squareImage, *playImage; ...
After some more experimentation, I found the following solution (I still don't know why it didn't work as originally written, though.) But anyway, the slicing works after the resize code is put in place even when resizing is unnecessary: ``` if(newDim != 320.0){ CGSize finalSize = CGSizeMake(320.0, 320.0);...
248,668
<p>I've been trying to code a Perl script to substitute some text on all source files of my project. I'm in need of something like:</p> <pre><code>perl -p -i.bak -e "s/thisgoesout/thisgoesin/gi" *.{cs,aspx,ascx} </code></pre> <p>But that parses <strong>all</strong> the files of a directory <strong>recursively</strong...
[ { "answer_id": 248680, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>You could use <code>find</code>:</p>\n\n<pre><code>find . -name '*.{cs,aspx,ascx}' | xargs perl -p -i.bak -e \"s/thisg...
2008/10/29
[ "https://Stackoverflow.com/questions/248668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27959/" ]
I've been trying to code a Perl script to substitute some text on all source files of my project. I'm in need of something like: ``` perl -p -i.bak -e "s/thisgoesout/thisgoesin/gi" *.{cs,aspx,ascx} ``` But that parses **all** the files of a directory **recursively**. I just started a script: ``` use File::Find::Ru...
If you assign `@ARGV` before using `*ARGV` (aka the diamond `<>`), `$^I`/`-i` will work on those files instead of what was specified on the command line. ``` use File::Find::Rule; use strict; @ARGV = (File::Find::Rule->file()->name('*.cs', '*.aspx', '*.ascx')->in('.')); $^I = '.bak'; # or set `-i` in the #! line or ...
248,683
<p>I want to do a select in MySql that combines several columns... something like this pseudocode:</p> <pre><code>SELECT payment1_paid AND payment2_paid AS paid_in_full FROM denormalized_payments WHERE payment1_type = 'check'; </code></pre> <p><strong>Edit</strong>: payment1_paid and payment2_paid are booleans.</p>...
[ { "answer_id": 248685, "author": "Eric Hogue", "author_id": 4137, "author_profile": "https://Stackoverflow.com/users/4137", "pm_score": 2, "selected": false, "text": "<p>Just do </p>\n\n<pre><code>Select CONCAT(payment1_paid, payment2_paid) as paid_in_full \nfrom denormalized_payments \n...
2008/10/29
[ "https://Stackoverflow.com/questions/248683", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
I want to do a select in MySql that combines several columns... something like this pseudocode: ``` SELECT payment1_paid AND payment2_paid AS paid_in_full FROM denormalized_payments WHERE payment1_type = 'check'; ``` **Edit**: payment1\_paid and payment2\_paid are booleans. I can't use any other language for this...
Ok, for logical and you can do ``` Select (payment1_paid && payment2_paid) as paid_in_full from denormalized_payments where payment1_type = 'check'; ``` As seen [here](http://dev.mysql.com/doc/refman/5.0/en/logical-operators.html#operator_and).
248,693
<p>I just came onto a project with a pretty huge code base. </p> <p>I'm mostly dealing with C++ and a lot of the code they write uses double negation for their boolean logic. </p> <pre><code> if (!!variable &amp;&amp; (!!api.lookup("some-string"))) { do_some_stuff(); } </cod...
[ { "answer_id": 248698, "author": "Don Neufeld", "author_id": 13097, "author_profile": "https://Stackoverflow.com/users/13097", "pm_score": 8, "selected": true, "text": "<p>It's a trick to convert to bool.</p>\n" }, { "answer_id": 248701, "author": "Marcin", "author_id": 2...
2008/10/29
[ "https://Stackoverflow.com/questions/248693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3415/" ]
I just came onto a project with a pretty huge code base. I'm mostly dealing with C++ and a lot of the code they write uses double negation for their boolean logic. ``` if (!!variable && (!!api.lookup("some-string"))) { do_some_stuff(); } ``` I know these guys are intell...
It's a trick to convert to bool.
248,719
<p>We are a group of students doing our Master degree in field of computer science.</p> <p>This semester we should do a Software engineering project according to the following bottom explanation.</p> <p>we should exactly act and report as a real Software engineering Team.</p> <p>I have been chosen as a project manager ...
[ { "answer_id": 248755, "author": "Carl", "author_id": 2136, "author_profile": "https://Stackoverflow.com/users/2136", "pm_score": 2, "selected": false, "text": "<p>Your description is somewhat different from your initial question so it's a little confusing. I'll try my best to answer and...
2008/10/29
[ "https://Stackoverflow.com/questions/248719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We are a group of students doing our Master degree in field of computer science. This semester we should do a Software engineering project according to the following bottom explanation. we should exactly act and report as a real Software engineering Team. I have been chosen as a project manager of this group, I am g...
Your description is somewhat different from your initial question so it's a little confusing. I'll try my best to answer and give you a few tips ... As a **project manager or leader**, you should be trying to **get the best out of everyone** in your team. Each one of them will be good at something so try to find out w...
248,721
<p>I need to have a single instance application (as per this <a href="https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application#19326">answer</a>), but it needs to be deployed via click once.</p> <p>The problem is that I require that click once doesn't automatically dete...
[ { "answer_id": 248735, "author": "Richard Harrison", "author_id": 19624, "author_profile": "https://Stackoverflow.com/users/19624", "pm_score": 0, "selected": false, "text": "<p>I don't think you'll be able to do it quite like this as the check before run is outside of your code.</p>\n\n...
2008/10/29
[ "https://Stackoverflow.com/questions/248721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2918/" ]
I need to have a single instance application (as per this [answer](https://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application#19326)), but it needs to be deployed via click once. The problem is that I require that click once doesn't automatically detect an update an attem...
To tackle the problem, we built a prototype application which has the following two functionalities. 1. Multiple instances on one pc are disabled. A single instance application is deployed via clickonce. When a user tries to start a second instance of the app, a message will pop up indicating that "Another instance is...
248,748
<p>I'm building a site using ajax and am trying to decide where to put the files that supply the data for the ajax requests.</p> <p>For example, I am going to have a .js file that can be included in a page that will create country/state select boxes. I will have the .js file under /inc/js.</p> <p>However, I am not s...
[ { "answer_id": 248772, "author": "Nikola Stjelja", "author_id": 32582, "author_profile": "https://Stackoverflow.com/users/32582", "pm_score": 0, "selected": false, "text": "<p>Create a separate site (same server or on another) that will serve only as a REST service generating output for ...
2008/10/29
[ "https://Stackoverflow.com/questions/248748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
I'm building a site using ajax and am trying to decide where to put the files that supply the data for the ajax requests. For example, I am going to have a .js file that can be included in a page that will create country/state select boxes. I will have the .js file under /inc/js. However, I am not sure where I want t...
If you're planning on using a Model-View-Controller architecture, then you would place your ajax handler scripts where you maintain the remainder of the your controller scripts for the site. For example: ``` /application /default /controllers index.php index.ajax.php /views...
248,753
<p>This is the sequel to <a href="https://stackoverflow.com/questions/248683/how-can-i-do-boolean-logic-on-two-columns-in-mysql">this question</a>.</p> <p>I would like to combine three columns into one on a MySql select. The first two columns are boolean and the third is a string, which is sometimes null. This causes ...
[ { "answer_id": 248763, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": false, "text": "<p>I guess you want NULL to be false? Try <code>(payment_paid IS NULL || payment2_type = \"none\")</code></p>\n" }, { ...
2008/10/29
[ "https://Stackoverflow.com/questions/248753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8047/" ]
This is the sequel to [this question](https://stackoverflow.com/questions/248683/how-can-i-do-boolean-logic-on-two-columns-in-mysql). I would like to combine three columns into one on a MySql select. The first two columns are boolean and the third is a string, which is sometimes null. This causes strange results: ```...
If null is not interesting then for you then: ``` Select *, (payment1_paid && ((payment2_paid || (payment_type IS NOT NULL && payment_type="none"))) as paid_in_full from payments ``` Good luck!
248,754
<p>Back in the earlier days of the internet I remember that in certain browsers, every time you downloaded an image or a file, the URL of where that file was downloaded from would be written into that file's properties (I guess the summary tab?). I think Netscape v2 did this if I remember correctly.</p> <p>I really mi...
[ { "answer_id": 248794, "author": "Rafe", "author_id": 27497, "author_profile": "https://Stackoverflow.com/users/27497", "pm_score": -1, "selected": false, "text": "<p>For the IE Browser I use the hell out of Fidler to look at all traffic going across the wire. </p>\n\n<p>For FireFox, you...
2008/10/29
[ "https://Stackoverflow.com/questions/248754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1582/" ]
Back in the earlier days of the internet I remember that in certain browsers, every time you downloaded an image or a file, the URL of where that file was downloaded from would be written into that file's properties (I guess the summary tab?). I think Netscape v2 did this if I remember correctly. I really miss that ki...
If you use the [DownThemAll](https://addons.mozilla.org/en-US/firefox/addon/201)! extension for Firefox, you can tell it to prepend the URL of the site to the downloaded file name... thus you end up with files like: ``` download.com_utils_compression_ABCD32.exe ``` It also works really well when you want to downloa...
248,761
<p>Hopefully I can do the problem justice, because it was too difficult to summarise it in the title! (suggestions are welcome in the comments)</p> <p>Right, so here's my table:</p> <pre><code>Tasks task_id (number) job_id (number) to_do_by_date (date) task_name (varchar / text) status...
[ { "answer_id": 248831, "author": "Justin Cave", "author_id": 10397, "author_profile": "https://Stackoverflow.com/users/10397", "pm_score": 0, "selected": false, "text": "<p>Given your requirements, it's not obvious to me why job_id 2 should be returned in your results. There is one task...
2008/10/29
[ "https://Stackoverflow.com/questions/248761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5662/" ]
Hopefully I can do the problem justice, because it was too difficult to summarise it in the title! (suggestions are welcome in the comments) Right, so here's my table: ``` Tasks task_id (number) job_id (number) to_do_by_date (date) task_name (varchar / text) status (number) co...
Obviously you will have to fix this up a bit but I hope you get the idea. ``` SELECT task_id, job_id, to_do_by_date, task_name, status, completed_date FROM Tasks WHERE job_id IN ( SELECT job_id FROM Tasks WHERE status <> 'Done' GROUP BY job_id) OR job_id IN ( ...
248,768
<p>I am trying to to walk though the tree of PdfItem objects in an existing PDF document using PDFSharp in c#. </p> <p>I want to create a hierarchy of all the objects as I go along -- similar to what the "PDF Explorer" example does -- but I want it to be a tree instead of a flat list of all the objects.</p> <p>The ro...
[ { "answer_id": 255559, "author": "yfeldblum", "author_id": 12349, "author_profile": "https://Stackoverflow.com/users/12349", "pm_score": 0, "selected": false, "text": "<p>Read and analyze the entirety of the collection, and build an in-memory tree of your own. Then walk that tree.</p>\n"...
2008/10/29
[ "https://Stackoverflow.com/questions/248768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
I am trying to to walk though the tree of PdfItem objects in an existing PDF document using PDFSharp in c#. I want to create a hierarchy of all the objects as I go along -- similar to what the "PDF Explorer" example does -- but I want it to be a tree instead of a flat list of all the objects. The root node is docume...
This post by marihanzo on the PDFSharp forums has worked for us: <http://forum.pdfsharp.net/viewtopic.php?f=2&t=527&p=1603> The only issue we've had was handling fields with \r\n in them. Here is a copy of the code in case the forum post gets lost. PDFParser.cs ``` public class PDFParser { /// BT = Beginning of...
248,769
<p>I currently use Notepad++ for most of my development. I have been checking out other, more full-featured options and would like to switch (I'm in particular a fan of Aptana so far) but there is one thing about Notepad++ that I really like and I haven't been able to get so far. </p> <p>My current workflow is somet...
[ { "answer_id": 248793, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 2, "selected": false, "text": "<p>Not too sure but I found <a href=\"http://www.nusphere.com/\" rel=\"nofollow noreferrer\">PhpEd</a> better than Zend ...
2008/10/29
[ "https://Stackoverflow.com/questions/248769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30098/" ]
I currently use Notepad++ for most of my development. I have been checking out other, more full-featured options and would like to switch (I'm in particular a fan of Aptana so far) but there is one thing about Notepad++ that I really like and I haven't been able to get so far. My current workflow is something like th...
I think you're doing things a bit strange. You already have all your information in an SVN repository, so why not take advantage of that? You keep a working copy on your computer for development and testing. Save and commit your changes to SVN. On your server, do an SVN `export` (or `checkout`, with appropriate serve...
248,789
<p>So I'm reading The Art &amp; Science of Javascript, which is a good book, and it has a good section on JSONP. I've been reading all I can about it today, and even looking through every question here on StackOverflow. JSONP is a great idea, but it only seems to resolve the "Same Origin Problem" for <i>getting</i> dat...
[ { "answer_id": 248813, "author": "Duncan", "author_id": 25035, "author_profile": "https://Stackoverflow.com/users/25035", "pm_score": 3, "selected": true, "text": "<p>JSONP results in a SCRIPT tag being generated to another server with any parameters that might be required as a GET reque...
2008/10/29
[ "https://Stackoverflow.com/questions/248789", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31307/" ]
So I'm reading The Art & Science of Javascript, which is a good book, and it has a good section on JSONP. I've been reading all I can about it today, and even looking through every question here on StackOverflow. JSONP is a great idea, but it only seems to resolve the "Same Origin Problem" for *getting* data, but doesn...
JSONP results in a SCRIPT tag being generated to another server with any parameters that might be required as a GET request. e.g. ``` <script src="http://myserver.com/getjson?customer=232&callback=jsonp543354" type="text/javascript"> </script> ``` There is technically nothing to stop this sort of request altering da...
248,830
<p>Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem came with a natural recursive solution. Now it happens that, even for relatively small input, the sequences are several thousands, thus I would prefer to use my algorithm as a generator instead of using it to fill a li...
[ { "answer_id": 248854, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 8, "selected": true, "text": "<pre><code>def getPermutations(string, prefix=\"\"):\n if len(string) == 1:\n yield prefix + string\n ...
2008/10/29
[ "https://Stackoverflow.com/questions/248830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18770/" ]
Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem came with a natural recursive solution. Now it happens that, even for relatively small input, the sequences are several thousands, thus I would prefer to use my algorithm as a generator instead of using it to fill a list ...
``` def getPermutations(string, prefix=""): if len(string) == 1: yield prefix + string else: for i in xrange(len(string)): for perm in getPermutations(string[:i] + string[i+1:], prefix+string[i]): yield perm ``` Or without an accumulator: ``` def getPermutations(st...
248,838
<p>I need to write an extension method on a byte[]. Is that possible?</p>
[ { "answer_id": 248843, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 1, "selected": false, "text": "<p>Sure, just make the first parameter of type <code>byte[]</code>.</p>\n" }, { "answer_id": 248866, "autho...
2008/10/29
[ "https://Stackoverflow.com/questions/248838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3279/" ]
I need to write an extension method on a byte[]. Is that possible?
yes, just do : ``` public static class Extensions { public static void Method(this byte[] current) { } } ```
248,864
<p>I have a MySQL database table with a couple thousand rows. The table is setup like so:</p> <p><code>id | text</code></p> <p>The <code>id</code> column is an auto-incrementing integer, and the <code>text</code> column is a 200-character varchar.</p> <p>Say I have the following rows:</p> <p><code>3 | I think I'll ...
[ { "answer_id": 248873, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 0, "selected": false, "text": "<p>Extract to flat file and then use your favorite quick language, perl, python, ruby, etc to process the flat file.</p...
2008/10/29
[ "https://Stackoverflow.com/questions/248864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326176/" ]
I have a MySQL database table with a couple thousand rows. The table is setup like so: `id | text` The `id` column is an auto-incrementing integer, and the `text` column is a 200-character varchar. Say I have the following rows: `3 | I think I'll have duck tonight` `4 | Maybe the chicken will be alright` `5 | I h...
MySQL already does this for you. First make sure your table is a MyISAM table Define a FULLTEXT index on your column On a shell command line navigate to the folder where your MySQL data is stored, then type: ``` myisam_ftdump -c yourtablename 1 >wordfreq.dump ``` You can then process wordfreq.dump to eliminate th...
248,900
<p>When I press the standard Ctrl + E, C (an other variants) in VS2008 whilst editing a CSS file, it says that command is not available. How do I setup a shortcut to apply a plain old /* */ comment to selected text in VS? Thanks</p>
[ { "answer_id": 249339, "author": "Jeff Hillman", "author_id": 3950, "author_profile": "https://Stackoverflow.com/users/3950", "pm_score": 4, "selected": true, "text": "<p>Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and select...
2008/10/30
[ "https://Stackoverflow.com/questions/248900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1692/" ]
When I press the standard Ctrl + E, C (an other variants) in VS2008 whilst editing a CSS file, it says that command is not available. How do I setup a shortcut to apply a plain old /\* \*/ comment to selected text in VS? Thanks
Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and selecting Add|Add Module... Paste the following in the source editor: ``` Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports System.Diagnostics Public Module CommentCSS Sub CommentC...
248,903
<p>Is there any way to determine if an object is a generic list? I'm not going to know the type of the list, I just know it's a list. How can I determine that?</p>
[ { "answer_id": 248912, "author": "bioskope", "author_id": 29414, "author_profile": "https://Stackoverflow.com/users/29414", "pm_score": -1, "selected": false, "text": "<p>Theres a GetType() function in the System.Object class. Have you tried that?</p>\n" }, { "answer_id": 248915,...
2008/10/30
[ "https://Stackoverflow.com/questions/248903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11137/" ]
Is there any way to determine if an object is a generic list? I'm not going to know the type of the list, I just know it's a list. How can I determine that?
This will return "True" ``` List<int> myList = new List<int>(); Console.Write(myList.GetType().IsGenericType && myList is IEnumerable); ``` Do you care to know if it's exactly a "List"... or are you ok with it being IEnumerable, and Generic?
248,911
<p>I have a single HW interface I want to use from two applications (processes) on the same workstation. The HW requires a single initialization call then either app uses the same function (in the same library) to do many transactions with the HW. </p> <p>So each app should act like this:</p> <pre><code>main() /...
[ { "answer_id": 248930, "author": "florin", "author_id": 18308, "author_profile": "https://Stackoverflow.com/users/18308", "pm_score": 2, "selected": false, "text": "<p>Use the <a href=\"http://www.opengroup.org/onlinepubs/000095399/basedefs/semaphore.h.html\" rel=\"nofollow noreferrer\">...
2008/10/30
[ "https://Stackoverflow.com/questions/248911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23961/" ]
I have a single HW interface I want to use from two applications (processes) on the same workstation. The HW requires a single initialization call then either app uses the same function (in the same library) to do many transactions with the HW. So each app should act like this: ``` main() // I don't know if anot...
[POSIX semaphore](http://linux.die.net/man/7/sem_overview) is the way to go. Since you want to share the same semaphore across processes, you need to use a named semaphore.: > > A named semaphore is identified by a > name of the form /somename. Two > processes can operate on the same > named semaphore by passing t...
248,938
<p>I am looking to parse a URL to obtain a collection of the querystring parameters in Java. To be clear, I need to parse a given URL(or string value of a URL object), not the URL from a servlet request. </p> <p>It looks as if the <code>javax.servlet.http.HttpUtils.parseQueryString</code> method would be the obvious c...
[ { "answer_id": 248965, "author": "Vincent Ramdhanie", "author_id": 27439, "author_profile": "https://Stackoverflow.com/users/27439", "pm_score": 3, "selected": false, "text": "<p>I think the idea is to use the HttpServletRequest instead. There is the getParameterMap(), getParameterNames(...
2008/10/30
[ "https://Stackoverflow.com/questions/248938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14419/" ]
I am looking to parse a URL to obtain a collection of the querystring parameters in Java. To be clear, I need to parse a given URL(or string value of a URL object), not the URL from a servlet request. It looks as if the `javax.servlet.http.HttpUtils.parseQueryString` method would be the obvious choice, but it has bee...
Well, as you mention that the URL does not come from a servlet request, the right answer is, as usual, **it depends**. The problem with query part of an url is that there is no clear specification about how to handle parameters duplication. For example, consider an url like this one: ``` http://www.example.com?param...
248,949
<p>We have a character LCD (www.cloverlcd.com/pdf/S6A0069.pdf) that we got to work in 8 bit mode. However, now we are trying to get it to work in 4 bit mode but it doesn't seem to be displaying anything. I think the function set instruction isn't been written. Can somebody please check if I am approaching this the r...
[ { "answer_id": 248975, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 1, "selected": false, "text": "<p>It looks okay up to a point but I wonder about a couple of things:</p>\n\n<p>1/ Why do you output 0x20 twice to set t...
2008/10/30
[ "https://Stackoverflow.com/questions/248949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
We have a character LCD (www.cloverlcd.com/pdf/S6A0069.pdf) that we got to work in 8 bit mode. However, now we are trying to get it to work in 4 bit mode but it doesn't seem to be displaying anything. I think the function set instruction isn't been written. Can somebody please check if I am approaching this the right w...
It looks okay up to a point but I wonder about a couple of things: 1/ Why do you output 0x20 twice to set the CGRAM address in the 4-bit section? Surely this is needed only once. 2/ The other two writes (0x00 and 0xf0), I don't understand from the docs. Can you fix up the comments to indicate what they're meant to be...
248,961
<p>I am just looking at the using statement, I have always known what it does but until now not tried using it, I have come up with the below code:</p> <pre><code> using (SqlCommand cmd = new SqlCommand(reportDataSource, new SqlConnection(Settings.Default.qlsdat_extensionsConnectionString))) { cm...
[ { "answer_id": 248967, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "<p>using isn't about catching exceptions. It's about properly disposing of resources that are outside the view of the garbage...
2008/10/30
[ "https://Stackoverflow.com/questions/248961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16989/" ]
I am just looking at the using statement, I have always known what it does but until now not tried using it, I have come up with the below code: ``` using (SqlCommand cmd = new SqlCommand(reportDataSource, new SqlConnection(Settings.Default.qlsdat_extensionsConnectionString))) { cmd.CommandType ...
This code should be as follows to ensure timely closing of the connection. Closing just the command doesn't close the connection: ``` using (SqlConnection con = new SqlConnection(Settings.Default.qlsdat_extensionsConnectionString)) using (SqlCommand cmd = new SqlCommand(reportDataSource, con)) { ...
248,973
<p>I'd like to stick a class down in my folder hierarchy. The scenario is too trivial to warrant it's own project or separate website. However, I hate to clutter my top-level App_Code with something that's used by a tiny corner of the site.</p> <p>Is there a way in web.config to include another file or folder in the...
[ { "answer_id": 249005, "author": "tsilb", "author_id": 11112, "author_profile": "https://Stackoverflow.com/users/11112", "pm_score": 1, "selected": true, "text": "<pre><code>&lt;configuration&gt;\n &lt;system.web&gt;\n &lt;compilation&gt;\n &lt;assemblies&gt;\n ...
2008/10/30
[ "https://Stackoverflow.com/questions/248973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
I'd like to stick a class down in my folder hierarchy. The scenario is too trivial to warrant it's own project or separate website. However, I hate to clutter my top-level App\_Code with something that's used by a tiny corner of the site. Is there a way in web.config to include another file or folder in the compilatio...
``` <configuration> <system.web> <compilation> <assemblies> <add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/> </assemblies> </compilation> </system.web> </configuration> ```
248,982
<p>I have an app which could benefit from the user being able to choose to set an image as the wallpaper (the background image on the "slide to unlock" screen). </p> <p>Is there a way for non-jailbreak third-party apps to do this? A search for "wallpaper" in the iPhone documentation returns nothing. </p>
[ { "answer_id": 249005, "author": "tsilb", "author_id": 11112, "author_profile": "https://Stackoverflow.com/users/11112", "pm_score": 1, "selected": true, "text": "<pre><code>&lt;configuration&gt;\n &lt;system.web&gt;\n &lt;compilation&gt;\n &lt;assemblies&gt;\n ...
2008/10/30
[ "https://Stackoverflow.com/questions/248982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27951/" ]
I have an app which could benefit from the user being able to choose to set an image as the wallpaper (the background image on the "slide to unlock" screen). Is there a way for non-jailbreak third-party apps to do this? A search for "wallpaper" in the iPhone documentation returns nothing.
``` <configuration> <system.web> <compilation> <assemblies> <add assembly="<AssemblyName>, Version=<Version>, Culture=<Culture>, PublicKeyToken=<PublicKeyToken>"/> </assemblies> </compilation> </system.web> </configuration> ```
248,983
<p>I have databound a listbox to a simple custom object collection. Next, I added a button to remove the selected item from the object collection. The problem is that when certain items are removed and the listbox is showing the vertical scroll bar, the scrollbar appears to reset to a new position, although what I re...
[ { "answer_id": 249076, "author": "bioskope", "author_id": 29414, "author_profile": "https://Stackoverflow.com/users/29414", "pm_score": 0, "selected": false, "text": "<p>I can think of one way to dampen the error (note this might not be the most accurate solution) . I just added a few th...
2008/10/30
[ "https://Stackoverflow.com/questions/248983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have databound a listbox to a simple custom object collection. Next, I added a button to remove the selected item from the object collection. The problem is that when certain items are removed and the listbox is showing the vertical scroll bar, the scrollbar appears to reset to a new position, although what I really ...
You need to preserve the TopIndex property of the listbox when removing the item. Preserving SelectedIndex does not stop the scrollbar from jumping. The code below does what I think you want. ``` private void btnRemove_Click(object sender,EventArgs e) { int topIndex = listBox1.TopIndex; m_bLis...
248,985
<p>I'm writing an application that does async loading of images onto the screen. I have it set up to be NOT concurrent (that is, it spawns a thread and executes them one at a time), so I've only overridden the <code>[NSOperation main]</code> function in my NSOperation subclass. </p> <p>Anyway, so when I add all of the...
[ { "answer_id": 255661, "author": "Dave Verwer", "author_id": 4496, "author_profile": "https://Stackoverflow.com/users/4496", "pm_score": 0, "selected": false, "text": "<p>No idea why you are seeing this behaviour but as a pure workaround you could keep your own references to the individu...
2008/10/30
[ "https://Stackoverflow.com/questions/248985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28019/" ]
I'm writing an application that does async loading of images onto the screen. I have it set up to be NOT concurrent (that is, it spawns a thread and executes them one at a time), so I've only overridden the `[NSOperation main]` function in my NSOperation subclass. Anyway, so when I add all of these operations, I want...
I stepped through `-operations`, and found that it's basically doing: ``` [self->data->lock lock]; NSString* copy = [[self->data->operations copy] autorelease]; [self->data->lock unlock]; return copy; ``` except, after calling `-autorelease`, the subsequent instructions overwrite the register containing the only poi...
248,989
<p>I have some code that raises <code>PropertyChanged</code> events and I would like to be able to unit test that the events are being raised correctly.</p> <p>The code that is raising the events is like</p> <pre><code>public class MyClass : INotifyPropertyChanged { public event PropertyChangedEventHandler Propert...
[ { "answer_id": 249042, "author": "Andrew Stapleton", "author_id": 28506, "author_profile": "https://Stackoverflow.com/users/28506", "pm_score": 9, "selected": true, "text": "<p>Everything you've done is correct, providing you want your test to ask \"What is the last event that was raised...
2008/10/30
[ "https://Stackoverflow.com/questions/248989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2660/" ]
I have some code that raises `PropertyChanged` events and I would like to be able to unit test that the events are being raised correctly. The code that is raising the events is like ``` public class MyClass : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void N...
Everything you've done is correct, providing you want your test to ask "What is the last event that was raised?" Your code is firing these two events, in this order * Property Changed (... "My Property" ...) * Property Changed (... "MyOtherProperty" ...) Whether this is "correct" or not depends upon the purpose of ...
248,990
<p>I have a table like as follows:</p> <pre> SoftwareName Count Country Project 15 Canada Visio 12 Canada Project 10 USA Visio 5 USA </pre> <p>How do I query it to give me a summary like...</p> <pre> SoftwareName Canada USA Total Project ...
[ { "answer_id": 249020, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "<pre><code>SELECT SoftwareName, \n SUM( CASE Country WHEN 'Canada' THEN [Count] ELSE 0 END ) AS Canada,\n SUM( CASE C...
2008/10/30
[ "https://Stackoverflow.com/questions/248990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31026/" ]
I have a table like as follows: ``` SoftwareName Count Country Project 15 Canada Visio 12 Canada Project 10 USA Visio 5 USA ``` How do I query it to give me a summary like... ``` SoftwareName Canada USA Total Project 15 10 ...
``` SELECT SoftwareName, SUM( CASE Country WHEN 'Canada' THEN [Count] ELSE 0 END ) AS Canada, SUM( CASE Country WHEN 'USA' THEN [Count] ELSE 0 END ) AS USA, SUM( [Count] ) AS Total FROM [Table] GROUP BY SoftwareName; ```
248,998
<p>This is really weird... When I open the following simple HTML document in Internet Explorer 7.0.5730.11 (on Windows Server 2003 Web Edition SP2)</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;p&gt;+&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>it shows me a totally blank page. FWIW, this is just a ...
[ { "answer_id": 249040, "author": "mhawke", "author_id": 21945, "author_profile": "https://Stackoverflow.com/users/21945", "pm_score": 1, "selected": false, "text": "<p>Does it work if you use the numeric character reference notation?</p>\n\n<pre><code>&lt;html&gt;\n &lt;body&gt;\n &...
2008/10/30
[ "https://Stackoverflow.com/questions/248998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31415/" ]
This is really weird... When I open the following simple HTML document in Internet Explorer 7.0.5730.11 (on Windows Server 2003 Web Edition SP2) ``` <html> <body> <p>+</p> </body> </html> ``` it shows me a totally blank page. FWIW, this is just a trivial "repro" sample. In real HTML documents, I observed oth...
Does it work if you use the numeric character reference notation? ``` <html> <body> <p>&#43;</p> </body> </html> ```
249,009
<p>I mean other than using it when required for functions, classes, if, while, switch, try-catch.</p> <p>I didn't know that it could be done like <a href="https://stackoverflow.com/questions/241088/what-do-curly-braces-by-themselves-mean-in-java">this until I saw this SO question</a>.</p> <p>In the above link, Eli me...
[ { "answer_id": 249013, "author": "agartzke", "author_id": 18402, "author_profile": "https://Stackoverflow.com/users/18402", "pm_score": 5, "selected": false, "text": "<p>I would not use curly braces for that purpose for a couple reasons.</p>\n\n<ol>\n<li><p>If your particular function is...
2008/10/30
[ "https://Stackoverflow.com/questions/249009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20646/" ]
I mean other than using it when required for functions, classes, if, while, switch, try-catch. I didn't know that it could be done like [this until I saw this SO question](https://stackoverflow.com/questions/241088/what-do-curly-braces-by-themselves-mean-in-java). In the above link, Eli mentioned that "They use it to...
I do if I am using a resource which I want to free at a specific time eg: ``` void myfunction() { { // Open serial port SerialPort port("COM1", 9600); port.doTransfer(data); } // Serial port gets closed here. for(int i = 0; i < data.size(); i++) doProcessData(data[i]); etc... } ```
249,010
<p>cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;</p> <p>in this method</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; </code></pre> <p>but I can only see it when I select that cell otherwise it's not visible.and it work perfe...
[ { "answer_id": 249145, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 4, "selected": true, "text": "<p>It would appear that the disclosure indicator is a gray, high-alpha image, so overlaying that over a black background...
2008/10/30
[ "https://Stackoverflow.com/questions/249010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/451867/" ]
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; in this method ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; ``` but I can only see it when I select that cell otherwise it's not visible.and it work perfectly when background is white. I ...
It would appear that the disclosure indicator is a gray, high-alpha image, so overlaying that over a black background makes it invisible. If you want to do this, you'll need to add your own UIImageView to the cell's contentView.
249,022
<p>I have an method which save files to the internet, it works but just slow. Then I'd like to make the user interface more smooth, so I create an NSThread to handle the slow task. </p> <p>I am seeing a list of errors like:</p> <pre><code>_NSAutoreleaseNoPool(): Object 0x18a140 of class NSCFString autoreleased with n...
[ { "answer_id": 249061, "author": "Kendall Helmstetter Gelner", "author_id": 6330, "author_profile": "https://Stackoverflow.com/users/6330", "pm_score": 0, "selected": false, "text": "<p>Within the thread, you need to create a new autorelease pool before you do anything else, otherwise th...
2008/10/30
[ "https://Stackoverflow.com/questions/249022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32096/" ]
I have an method which save files to the internet, it works but just slow. Then I'd like to make the user interface more smooth, so I create an NSThread to handle the slow task. I am seeing a list of errors like: ``` _NSAutoreleaseNoPool(): Object 0x18a140 of class NSCFString autoreleased with no pool in place - jus...
Well first of all, you are both creating a new thread for your saving code and then using NSUrlConnection asynchronously. NSUrlConnection in its own implementation would also spin-off another thread and call you back on your newly created thread, which mostly is not something you are trying to do. I assume you are just...
249,027
<p>I would like to implement a command line interface for a Java application. This wouldn't be too difficult to do, except I would like the command line program to affect the state of another Java GUI program. So for example, I could type:</p> <pre><code>java CliMain arg1 arg2 </code></pre> <p>And another running GUI...
[ { "answer_id": 249036, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": true, "text": "<p>You could have the GUI application listen on a TCP port (on the <code>localhost</code> interface) and the CLI applicati...
2008/10/30
[ "https://Stackoverflow.com/questions/249027", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23845/" ]
I would like to implement a command line interface for a Java application. This wouldn't be too difficult to do, except I would like the command line program to affect the state of another Java GUI program. So for example, I could type: ``` java CliMain arg1 arg2 ``` And another running GUI instance would perform an...
You could have the GUI application listen on a TCP port (on the `localhost` interface) and the CLI application would connect to it. One way to do this would be to use REST over HTTP.
249,066
<p>I just want to know how to validate (or clean) user input in ASP.NET MVC so that an HttpRequestValidationException will not be thrown regardless of the values submitted. For example, with a text input, if the user inputs <code>&lt;BR/&gt;</code>, it will cause an exception and the Yellow Screen of Death will be sh...
[ { "answer_id": 253398, "author": "Hrvoje Hudo", "author_id": 1407, "author_profile": "https://Stackoverflow.com/users/1407", "pm_score": 0, "selected": false, "text": "<p>Put put ValidateRequest=\"false\" to your aspx view declaration, but sanitize users input text inside your code, to a...
2008/10/30
[ "https://Stackoverflow.com/questions/249066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32173/" ]
I just want to know how to validate (or clean) user input in ASP.NET MVC so that an HttpRequestValidationException will not be thrown regardless of the values submitted. For example, with a text input, if the user inputs `<BR/>`, it will cause an exception and the Yellow Screen of Death will be shown. I don't want that...
With the latest version of ASP.NET MVC (the RC, at the time of writing this) you can just put an attribute on either your controller class or your action method, e.g.: ``` [ValidateInput(false)] public ActionResult create() { // ...method body } ``` The ValidateInputAttribute is in System.Web.Mvc. But as others...
249,074
<p>I'm sure there are a million posts about this out there, but surprisingly I'm having trouble finding something. </p> <p>I have a simple script where I want to set the onClick handler for an <code>&lt;A&gt;</code> link on initialization of the page.</p> <p>When I run this I <strong>immediately</strong> get a 'foo' ...
[ { "answer_id": 249084, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 6, "selected": false, "text": "<p>Try:</p>\n\n<pre><code>document.getElementById(\"foo\").onclick = function (){alert('foo');};\n</code></pre>...
2008/10/30
[ "https://Stackoverflow.com/questions/249074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
I'm sure there are a million posts about this out there, but surprisingly I'm having trouble finding something. I have a simple script where I want to set the onClick handler for an `<A>` link on initialization of the page. When I run this I **immediately** get a 'foo' alert box where I expected to only get an alert...
jQuery: ``` $('#foo').click(function() { alert('foo'); }); ``` Or if you don't want it to follow the link href: ``` $('#foo').click(function() { alert('foo'); return false; }); ```
249,087
<p>I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert <code>é</code> to <code>e</code>, so <code>crème brûlée</code> would become <code>creme brulee</code>)</p> <p>What is the best ...
[ { "answer_id": 249126, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 10, "selected": true, "text": "<p>I've not used this method, but Michael Kaplan describes a method for doing so in his blog post (with a confusing tit...
2008/10/30
[ "https://Stackoverflow.com/questions/249087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/514/" ]
I'm trying to convert some strings that are in French Canadian and basically, I'd like to be able to take out the French accent marks in the letters while keeping the letter. (E.g. convert `é` to `e`, so `crème brûlée` would become `creme brulee`) What is the best method for achieving this?
I've not used this method, but Michael Kaplan describes a method for doing so in his blog post (with a confusing title) that talks about stripping diacritics: [Stripping is an interesting job (aka On the meaning of meaningless, aka All Mn characters are non-spacing, but some are more non-spacing than others)](http://ar...
249,103
<p>So I just love it when my application is working great in Firefox, but then I open it in IE and... Nope, please try again.</p> <p>The issue I'm having is that I'm setting a CSS display property to either <code>none</code> or <code>table-cell</code> with JavaScript.</p> <p>I was initially using <code>display: block...
[ { "answer_id": 249121, "author": "joelhardi", "author_id": 11438, "author_profile": "https://Stackoverflow.com/users/11438", "pm_score": 2, "selected": false, "text": "<p>Well, <a href=\"http://www.quirksmode.org/css/display.html\" rel=\"nofollow noreferrer\">IE7 does not have <code>disp...
2008/10/30
[ "https://Stackoverflow.com/questions/249103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10420/" ]
So I just love it when my application is working great in Firefox, but then I open it in IE and... Nope, please try again. The issue I'm having is that I'm setting a CSS display property to either `none` or `table-cell` with JavaScript. I was initially using `display: block`, but Firefox was rendering it weird withou...
A good way of solving this setting the `display` value to `''`: ``` <script type="text/javascript"> <!-- function toggle( elemntId ) { if (document.getElementById( elemntId ).style.display != 'none') { document.getElementById( elemntId ).style.display = 'none'; } else { document.getElementById(...
249,110
<p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p> <pre><code>/browse/&lt;name1&gt;/&lt;value1&gt;/&lt;name2&gt;/&lt;value2&gt;/ .... ...
[ { "answer_id": 249524, "author": "Adam", "author_id": 30084, "author_profile": "https://Stackoverflow.com/users/30084", "pm_score": 5, "selected": true, "text": "<p>A possibility that you might consider is matching the entire string of possible values within the url pattern portion and p...
2008/10/30
[ "https://Stackoverflow.com/questions/249110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32638/" ]
I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this: ``` /browse/<name1>/<value1>/<name2>/<value2>/ .... etc .... ``` where 'name' maps to a m...
A possibility that you might consider is matching the entire string of possible values within the url pattern portion and pull out the specific pieces within your view. As an example: ``` urlpatterns = patterns('', url(r'^browse/(?P<match>.+)/$', 'app.views.view', name='model_browse'), ) def view(request, match):...
249,158
<p>First, a couple operating parameters:</p> <ul> <li>.NET development using Visual Studio 2005/2008</li> <li>TortoiseSVN client</li> </ul> <p>I've only primarily worked with Visual Source Safe and SourceGear Vault source control systems. In each, I map the root of the repository to a local working directory. For e...
[ { "answer_id": 249164, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>The Subversion \"check out\" operation creates a <em>new</em> working copy. What you probably want to do is check out ...
2008/10/30
[ "https://Stackoverflow.com/questions/249158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5496/" ]
First, a couple operating parameters: * .NET development using Visual Studio 2005/2008 * TortoiseSVN client I've only primarily worked with Visual Source Safe and SourceGear Vault source control systems. In each, I map the root of the repository to a local working directory. For example: ``` $/ --> C:\source ``` ...
I seemed to have found a suitable solution to my problem. **Using TortoiseSVN, the "Update item to revision" action within the repo browser can be used to locally reconstruct the repository's folder structure for an arbitrary repo path.** Detailed steps are: 1. Create a local folder to be the working copy root of th...
249,171
<p>I am working on a business problem in C#.NET. I have two classes, named C and W that will be instantiated independently at different times.</p> <p>An object of class C needs to contain references to 0 ... n objects of class W, i.e. a C object can contain up to n W objects.</p> <p>Each W object needs to contain a ...
[ { "answer_id": 249180, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "<p>Hmmm, looks like you almost got it, with one minor glitch -- you gotta be able to control the addition to the list withi...
2008/10/30
[ "https://Stackoverflow.com/questions/249171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18542/" ]
I am working on a business problem in C#.NET. I have two classes, named C and W that will be instantiated independently at different times. An object of class C needs to contain references to 0 ... n objects of class W, i.e. a C object can contain up to n W objects. Each W object needs to contain a reference to exact...
If you have the Martin Fowler's Refactoring book, just follow the "Change Unidirectional Association to Bidirectional" refactoring. In case you don't have it, here's how your classes will look like after the refactoring: ``` class C { // Don't to expose this publicly so that // no one can get behind your back an...
249,188
<p>What's the most elegant way of implementing a DropDownList in <code>ASP.NET</code> that is editable without using 3rd party components.</p> <p>As a last resort I will probably try using a <code>TextBox</code> with an <code>AutoCompleteExtender</code> with an image to 'drop down' the list; or a <code>TextBox</code> ...
[ { "answer_id": 1592106, "author": "Ray", "author_id": 4872, "author_profile": "https://Stackoverflow.com/users/4872", "pm_score": 3, "selected": false, "text": "<h2>One Control on a Page</h2>\n\n<p>You can follow <a href=\"http://www.codeproject.com/KB/aspnet/EditableDropdown_aspx.aspx\"...
2008/10/30
[ "https://Stackoverflow.com/questions/249188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8280/" ]
What's the most elegant way of implementing a DropDownList in `ASP.NET` that is editable without using 3rd party components. As a last resort I will probably try using a `TextBox` with an `AutoCompleteExtender` with an image to 'drop down' the list; or a `TextBox` overlapping a HTML Select with some JavaScript to fill...
One Control on a Page --------------------- You can follow [this simple example for an Editable DropDownlist on Code Project](http://www.codeproject.com/KB/aspnet/EditableDropdown_aspx.aspx) that uses standard ASP.NET TextBox and DropDownList controls combined with some JavaScript. However, the code did not work for ...
249,222
<p>I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static class, such as <code>Console</code>.</p> <p>For example, if I want to add an extension to <code>Console</code>, called '<code>WriteBlueLine</code>', so that I can go:</p> <pre><code>Console.WriteBlueLine(&quot;Th...
[ { "answer_id": 249234, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 3, "selected": false, "text": "<p>You can't add <em>static</em> methods to a type. You can only add (pseudo-)instance methods to an instance of a type.</p...
2008/10/30
[ "https://Stackoverflow.com/questions/249222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49/" ]
I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static class, such as `Console`. For example, if I want to add an extension to `Console`, called '`WriteBlueLine`', so that I can go: ``` Console.WriteBlueLine("This text is blue"); ``` I tried this by adding a local, ...
No. Extension methods require an instance variable (value) for an object. You can however, write a static wrapper around the `ConfigurationManager` interface. If you implement the wrapper, you don't need an extension method since you can just add the method directly. ``` public static class ConfigurationManagerWrappe...
249,241
<p>I have an application that uses the accelerometer. Sometimes, the application will launch without the accelerometer data updating. Relaunching the app, sometimes the problem persist, sometimes it doesn't. And even weirder, sometimes I can try 10 times and everything works as expected. Is this a bug, or maybe somethi...
[ { "answer_id": 249492, "author": "MrDatabase", "author_id": 22471, "author_profile": "https://Stackoverflow.com/users/22471", "pm_score": 1, "selected": false, "text": "<p>I have this same problem. It happens perhaps 1/20 times with an app I made from the CrashLanding sample. After I n...
2008/10/30
[ "https://Stackoverflow.com/questions/249241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29642/" ]
I have an application that uses the accelerometer. Sometimes, the application will launch without the accelerometer data updating. Relaunching the app, sometimes the problem persist, sometimes it doesn't. And even weirder, sometimes I can try 10 times and everything works as expected. Is this a bug, or maybe something ...
I finally found a work around. This is a known bug. So the work around I found is to start a thread and have this thread check if the accelerometer delegate has been called, if it has, then quit the thread, if not, set the delegate again, and re-test, until the accelerometer delegate gets called. I tested this throughl...
249,247
<p>Is it possible to add an image overlay to a google map that scales as the user zooms?</p> <p>My current code works like this:</p> <pre><code>var map = new GMap2(document.getElementById("gMap")); var customIcon = new GIcon(); customIcon.iconSize = new GSize(100, 100); customIcon.image = "/images/image.png"; map.a...
[ { "answer_id": 249249, "author": "moogs", "author_id": 26374, "author_profile": "https://Stackoverflow.com/users/26374", "pm_score": 1, "selected": false, "text": "<p>There is a zoomend event, fired when the map reaches a new zoom level. The event handler receives the previous and the ne...
2008/10/30
[ "https://Stackoverflow.com/questions/249247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
Is it possible to add an image overlay to a google map that scales as the user zooms? My current code works like this: ``` var map = new GMap2(document.getElementById("gMap")); var customIcon = new GIcon(); customIcon.iconSize = new GSize(100, 100); customIcon.image = "/images/image.png"; map.addOverlay(new GMarker...
Well after messing around trying to scale it myself for a little bit I found a helper called [EInserts](http://econym.org.uk/gmap/einsert.htm) which I'm going to check out. Addition: Okay EInserts is about the coolest thing ever. It even has a method to allow you to drag the image and place it in development mode for...
249,253
<p>I have a script to extract certain data from a much bigger table, with one field in particular changing regularly, e.g.</p> <pre><code>SELECT CASE @Flag WHEN 1 THEN t.field1 WHEN 2 THEN t.field2 WHEN 3 THEN t.field3 END as field, ...[A bunch of other fields] FROM table t </code></pre> <p>However, th...
[ { "answer_id": 249313, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": false, "text": "<p>I think you need to pull <code>@Flag</code> out of the query altogether, and use it to decide which of three separa...
2008/10/30
[ "https://Stackoverflow.com/questions/249253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27290/" ]
I have a script to extract certain data from a much bigger table, with one field in particular changing regularly, e.g. ``` SELECT CASE @Flag WHEN 1 THEN t.field1 WHEN 2 THEN t.field2 WHEN 3 THEN t.field3 END as field, ...[A bunch of other fields] FROM table t ``` However, the issue is now I want to d...
A simpler solution, and one suggested by a workmate: ``` SELECT CASE @Flag WHEN 1 THEN t.field1 WHEN 2 THEN t.field2 WHEN 3 THEN t.field3 END as field, [A bunch of other fields], @Flag as flag FROM table t ``` Then base the decision making on the last field. A lot simpler, and probably should have occurred...
249,256
<p>I was browsing the <a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden Features of C#</a> question and thought I would try out one of the features I was unfamiliar with. Unfortunately I use Visual Studio 2005 and the feature in question was introduced later. Is there a good list for new...
[ { "answer_id": 249261, "author": "ojrac", "author_id": 20760, "author_profile": "https://Stackoverflow.com/users/20760", "pm_score": 1, "selected": false, "text": "<p>Here's a link to the MS page on .NET 3.0: <a href=\"http://msdn.microsoft.com/en-us/library/bb822048.aspx\" rel=\"nofollo...
2008/10/30
[ "https://Stackoverflow.com/questions/249256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6180/" ]
I was browsing the [Hidden Features of C#](https://stackoverflow.com/questions/9033/hidden-features-of-c) question and thought I would try out one of the features I was unfamiliar with. Unfortunately I use Visual Studio 2005 and the feature in question was introduced later. Is there a good list for new features in C# 3...
This is not a comprehensive list but these are some of my favorite new features of C# 3.0: New type initializers. Instead of saying this: ``` Person person = new Person(); person.Name = "John Smith"; ``` I can say this: ``` Person person = new Person() { Name = "John Smith" }; ``` Similarly, instead of adding i...
249,262
<pre><code>'''use Jython''' import shutil print dir(shutil) </code></pre> <p>There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?</p>
[ { "answer_id": 249279, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 3, "selected": true, "text": "<p><code>os.rename()</code> to move, and <code>os.unlink()</code> to delete -- just like Python pre-<code>shutil</cod...
2008/10/30
[ "https://Stackoverflow.com/questions/249262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
``` '''use Jython''' import shutil print dir(shutil) ``` There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython?
`os.rename()` to move, and `os.unlink()` to delete -- just like Python pre-`shutil`.
249,266
<p>I have a large xml document that needs to be processed 100 records at a time</p> <p>It is being done within a Windows Service written in c#. </p> <p>The structure is as follows :</p> <pre><code>&lt;docket xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="docket.xsd"&gt; &lt;...
[ { "answer_id": 249310, "author": "Jim Burger", "author_id": 20164, "author_profile": "https://Stackoverflow.com/users/20164", "pm_score": 1, "selected": false, "text": "<p>Naive, iterative, but works [EDIT: in .NET 3.5 only]</p>\n\n<pre><code> public List&lt;XDocument&gt; ChunkDocket(...
2008/10/30
[ "https://Stackoverflow.com/questions/249266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17194/" ]
I have a large xml document that needs to be processed 100 records at a time It is being done within a Windows Service written in c#. The structure is as follows : ``` <docket xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="docket.xsd"> <order> <Date>2008-10-13</Date...
Another naive solution; this time for .NET 2.0. It should give you an idea of how to go about what you want. Uses Xpath expressions instead of Linq to XML. Chunks a 100 order docket into 10 dockets in under a second on my devbox. ``` public List<XmlDocument> ChunkDocket(XmlDocument docket, int chunkSize) { ...
249,283
<p>I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the <strong>--no-site-packages</strong> option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a...
[ { "answer_id": 249342, "author": "monkut", "author_id": 24718, "author_profile": "https://Stackoverflow.com/users/24718", "pm_score": 3, "selected": false, "text": "<p>One way is to add the paths to your code using sys.path.</p>\n\n<pre><code>import sys\n\nsys.path.append(somepath)\n</co...
2008/10/30
[ "https://Stackoverflow.com/questions/249283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the **--no-site-packages** option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (wit...
``` $ virtualenv --no-site-packages --python=/usr/bin/python2.6 myvirtualenv $ cd myvirtualenv $ source bin/activate $ cd lib/python2.6/ $ ln -s /usr/lib/pymodules/python2.6/gtk-2.0/ $ ln -s /usr/lib/pymodules/python2.6/pygtk.pth $ ln -s /usr/lib/pymodules/python2.6/pygtk.py $ ln -s /usr/lib/pymodules/python2.6/cair...
249,301
<p>How do I take an efficient simple random sample in SQL? The database in question is running MySQL; my table is at least 200,000 rows, and I want a simple random sample of about 10,000.</p> <p>The &quot;obvious&quot; answer is to:</p> <pre><code>SELECT * FROM table ORDER BY RAND() LIMIT 10000 </code></pre> <p>For lar...
[ { "answer_id": 249351, "author": "staticsan", "author_id": 28832, "author_profile": "https://Stackoverflow.com/users/28832", "pm_score": -1, "selected": false, "text": "<p>Maybe you could do</p>\n\n<pre><code>SELECT * FROM table LIMIT 10000 OFFSET FLOOR(RAND() * 190000)\n</code></pre>\n"...
2008/10/30
[ "https://Stackoverflow.com/questions/249301", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20760/" ]
How do I take an efficient simple random sample in SQL? The database in question is running MySQL; my table is at least 200,000 rows, and I want a simple random sample of about 10,000. The "obvious" answer is to: ``` SELECT * FROM table ORDER BY RAND() LIMIT 10000 ``` For large tables, that's too slow: it calls `RA...
There's a very interesting discussion of this type of issue here: [<http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/>](http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/) I think with absolutely no assumptions about the table tha...
249,312
<p>What does the following code do? A link to something in the PHP manual would also be nice.</p> <pre><code>if ($_SERVER['SERVER_PORT'] &lt;&gt; 443) { doSomething(); } </code></pre>
[ { "answer_id": 249315, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 6, "selected": true, "text": "<p>Same as !=, \"Not equal\"</p>\n\n<pre><code>false &lt;&gt; true // operator will evaluate expression as true\...
2008/10/30
[ "https://Stackoverflow.com/questions/249312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18285/" ]
What does the following code do? A link to something in the PHP manual would also be nice. ``` if ($_SERVER['SERVER_PORT'] <> 443) { doSomething(); } ```
Same as !=, "Not equal" ``` false <> true // operator will evaluate expression as true false != true // operator will evaluate expression as true ``` Here is some reference: [PHP Comparison Operators](http://www.php.net/operators.comparison)
249,314
<p>I was just watching a video on MSDN Channel 9 which can be found <a href="http://channel9.msdn.com/posts/Dan/Lucian-Wischik-and-Lisa-Feigenbaum-Whats-new-in-Visual-Basic-10/" rel="noreferrer">here</a>, about some of the new features in Visual Basic 10. Now I like most of the new features, some of which have been lo...
[ { "answer_id": 249325, "author": "MichaelGG", "author_id": 27012, "author_profile": "https://Stackoverflow.com/users/27012", "pm_score": 0, "selected": false, "text": "<p>Full anonymous method support in VB means you can start taking a more functional style with things. If the Sub() End ...
2008/10/30
[ "https://Stackoverflow.com/questions/249314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
I was just watching a video on MSDN Channel 9 which can be found [here](http://channel9.msdn.com/posts/Dan/Lucian-Wischik-and-Lisa-Feigenbaum-Whats-new-in-Visual-Basic-10/), about some of the new features in Visual Basic 10. Now I like most of the new features, some of which have been long awaited(auto properties and C...
Personally, I think that VB's syntax for delegates and lambdas is completely bogus. I mean, come on, `AddressOf`! This was fine in VB6. It is definitely *not* fine in a language such as VB.NET where functions *should* be treated as first-class citizens (although they really aren't, of course) and where conversion from ...
249,330
<p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p> <p>I have a copy of the files on my local file system and I do an update t...
[ { "answer_id": 249444, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 0, "selected": false, "text": "<p>Hm... That would do it:</p>\n\n<pre><code>baselen = len(self.basePath)\nfor path in paths:\n path = path[baselen:].r...
2008/10/30
[ "https://Stackoverflow.com/questions/249330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1804/" ]
I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository. I have a copy of the files on my local file system and I do an update to check if ...
Stay with the slice operator, but do not change the loop variable inside the loop. for fun, try the generator expression (or keep the listcomp). ``` baselen = len(self.basePath) return (path[baselen:].replace("/", "\\") for path in paths) ``` Edit: `lstrip()' is not relevant here. From the [manual](http://docs.pytho...
249,346
<p>I am building a utility page for a web app that I am working on. I have an element that I want to use as a "console" of sorts.</p> <p>I get entries for the console via Ajax calls (using prototype's <code>Ajax.PeriodicalUpdater</code>).</p> <p>The problem I'm having is that when I insert new lines to the bottom o...
[ { "answer_id": 249349, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": true, "text": "<pre><code>new Ajax.PeriodicalUpdater(container, url, {\n onComplete: function() {\n (function() {\n ...
2008/10/30
[ "https://Stackoverflow.com/questions/249346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
I am building a utility page for a web app that I am working on. I have an element that I want to use as a "console" of sorts. I get entries for the console via Ajax calls (using prototype's `Ajax.PeriodicalUpdater`). The problem I'm having is that when I insert new lines to the bottom of the "console", the scrollbar...
``` new Ajax.PeriodicalUpdater(container, url, { onComplete: function() { (function() { container.scrollTop = container.scrollHeight; }).defer(); } }); ```
249,348
<p>I wrote this scheme code to compute one solution of the quadratic equation a<em>x2 + b</em>x + c = 0</p> <pre><code>(define (solve-quadratic-equation a b c) (define disc (sqrt (- (* b b) (* 4.0 a c)))) (/ (+ (- b) disc) (* 2.0 a))) </code></pre> <p>However, someone told me that this procedure is hard to understand...
[ { "answer_id": 249352, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 3, "selected": false, "text": "<p>Well, one reason is that it's all on one line. You can make it more readable using something called <strong>pretty-prin...
2008/10/30
[ "https://Stackoverflow.com/questions/249348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
I wrote this scheme code to compute one solution of the quadratic equation a*x2 + b*x + c = 0 ``` (define (solve-quadratic-equation a b c) (define disc (sqrt (- (* b b) (* 4.0 a c)))) (/ (+ (- b) disc) (* 2.0 a))) ``` However, someone told me that this procedure is hard to understand. Why? What would a cleaned up v...
Well, one reason is that it's all on one line. You can make it more readable using something called **pretty-printing**, where you break it up into multiple lines and use whitespace: ``` (define (solve-quadratic-equation a b c) (define disc (sqrt (- (* b b) (* 4.0 a c)))) (/ (+ (- b) disc) ...
249,350
<p>I have seen some declaration of a union inside a struct as follows. Example code given below.</p> <p>My questions is does it help in any memory savings(typical use for which a union is used for)? I do not see the benefit. </p> <pre><code>typedef struct { int x1; unsigned int x2; ourstruct1 ov1; our...
[ { "answer_id": 249355, "author": "bog", "author_id": 20909, "author_profile": "https://Stackoverflow.com/users/20909", "pm_score": 2, "selected": false, "text": "<p>Hmm. Well, the example above seems a little strange to me--the usual reason for a union is to have two different symbolic ...
2008/10/30
[ "https://Stackoverflow.com/questions/249350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
I have seen some declaration of a union inside a struct as follows. Example code given below. My questions is does it help in any memory savings(typical use for which a union is used for)? I do not see the benefit. ``` typedef struct { int x1; unsigned int x2; ourstruct1 ov1; ourstruct1 ov2; unio...
Hmm. Well, the example above seems a little strange to me--the usual reason for a union is to have two different symbolic paths into the same storage (by bytes, by words, etc). However, the example you've given has only one member of the union. The only thing I can think is that the code is written with an eye towards...
249,357
<p>I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following.</p> <p>I would appreciate any links or first-hand advise.</p>
[ { "answer_id": 249359, "author": "wprl", "author_id": 17847, "author_profile": "https://Stackoverflow.com/users/17847", "pm_score": 2, "selected": false, "text": "<p>Not exactly beginner material, but <a href=\"http://www.alistapart.com/\" rel=\"nofollow noreferrer\">A List Apart</a> is ...
2008/10/30
[ "https://Stackoverflow.com/questions/249357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2598/" ]
I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following. I would appreciate any links or first-hand advise.
An error that beginners make quite often: CSS is semantic as well. Try to express concepts, not formats. Contrived example: ### Wrong: ``` div.red { color: red; } ``` as opposed to: ### Good: ``` div.error { color: red; } ``` CSS should be the formatting companion for the concepts you use on your web s...
249,374
<p>Is anyone familiar with this?</p> <blockquote> <p>Write a procedure that takes as inputs a procedure that computes f and a positive integer n and returns the procedure that computes the nth repeated application of f. The procedure should be able to be used as follows:</p> <pre><code>((repeated square...
[ { "answer_id": 249490, "author": "Matthias Benkard", "author_id": 15517, "author_profile": "https://Stackoverflow.com/users/15517", "pm_score": 1, "selected": false, "text": "<p>Well, you probably want something like this, right?</p>\n\n<pre><code>((repeated square 3) 5)\n-&gt; (square (...
2008/10/30
[ "https://Stackoverflow.com/questions/249374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
Is anyone familiar with this? > > Write a procedure that takes as inputs > a procedure that computes f and a > positive integer n and returns the > procedure that computes the nth > repeated application of f. The > procedure should be able to be used as > follows: > > > > ``` > ((repeated square 2) 5) > 625 ...
Well, you probably want something like this, right? ``` ((repeated square 3) 5) -> (square ((repeated square 2) 5)) -> (square (square ((repeated square 1) 5))) -> (square (square (square ((repeated square 0) 5)))) -> (square (square (square (identity 5)))) ``` (I don't know whether `identity` is predefined in Schem...
249,375
<p>How do you programmatically set a DataContext that specifies the selected item of a list? </p> <p>More simply, how do you reproduce this type of binding in code?</p> <pre><code>&lt;StackPanel&gt; &lt;ListBox Name="listBox1" /&gt; &lt;TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=...
[ { "answer_id": 249378, "author": "Ty.", "author_id": 16948, "author_profile": "https://Stackoverflow.com/users/16948", "pm_score": 4, "selected": true, "text": "<p>You need to set a Name for the textbox so you can refer to it in code. Then you should just be able to assign an object to ...
2008/10/30
[ "https://Stackoverflow.com/questions/249375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25968/" ]
How do you programmatically set a DataContext that specifies the selected item of a list? More simply, how do you reproduce this type of binding in code? ``` <StackPanel> <ListBox Name="listBox1" /> <TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=SelectedItem}" /> </StackPanel> ```
You need to set a Name for the textbox so you can refer to it in code. Then you should just be able to assign an object to the DataContext property. You can create a data binding programatically like so: ``` Binding binding = new Binding(); binding.ElementName = "listBox1"; binding.Path = new PropertyPath("SelectedIte...
249,388
<p>I'm having trouble getting pictures supported with PIL - it throws me this:</p> <pre><code>IOError: decoder jpeg not available </code></pre> <p>I installed PIL from binary, not realizing I needed libjpeg.</p> <p>I installed libjpeg and freetype2 through fink. </p> <p>I tried to reinstall PIL using instructions f...
[ { "answer_id": 249406, "author": "Doug Miller", "author_id": 3431280, "author_profile": "https://Stackoverflow.com/users/3431280", "pm_score": 0, "selected": false, "text": "<p>Is the python path still looking at the old binary version of libjpeg?</p>\n\n<p>You will need to modify it to ...
2008/10/30
[ "https://Stackoverflow.com/questions/249388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20824/" ]
I'm having trouble getting pictures supported with PIL - it throws me this: ``` IOError: decoder jpeg not available ``` I installed PIL from binary, not realizing I needed libjpeg. I installed libjpeg and freetype2 through fink. I tried to reinstall PIL using instructions from <http://timhatch.com/> (bottom of th...
I had the similar 'jpeg decoder problem' recently when deploying a django project on a product RHEL box that required PIL. I downloaded PIL, and ran 'python setup.py install' instantly, and was happy that everything was working, until I bumped into the problem. Solution: libjpeg was already installed on the system, so ...
249,392
<p>How would I implement a binary search using just an array? </p>
[ { "answer_id": 249404, "author": "mmcdole", "author_id": 2635, "author_profile": "https://Stackoverflow.com/users/2635", "pm_score": 6, "selected": true, "text": "<p>Ensure that your array is sorted since this is the crux of a binary search. </p>\n\n<p>Any indexed/random-access data str...
2008/10/30
[ "https://Stackoverflow.com/questions/249392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
How would I implement a binary search using just an array?
Ensure that your array is sorted since this is the crux of a binary search. Any indexed/random-access data structure can be binary searched. So when you say using "just an array", I would say arrays are the most basic/common data structure that a binary search is employed on. You can do it recursively (easiest) or ...
249,423
<p>Can someone explain to me how XOR swapping of two variables with no temp variable works?</p> <pre><code>void xorSwap (int *x, int *y) { if (x != y) { *x ^= *y; *y ^= *x; *x ^= *y; } } </code></pre> <p>I understand WHAT it does, but can someone walk me through the logic of how it wor...
[ { "answer_id": 249427, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": false, "text": "<p>Most people would swap two variables x and y using a temporary variable, like this:</p>\n\n<pre><code>tmp = x\nx = y\ny = tm...
2008/10/30
[ "https://Stackoverflow.com/questions/249423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2635/" ]
Can someone explain to me how XOR swapping of two variables with no temp variable works? ``` void xorSwap (int *x, int *y) { if (x != y) { *x ^= *y; *y ^= *x; *x ^= *y; } } ``` I understand WHAT it does, but can someone walk me through the logic of how it works?
You can see how it works by doing the substitution: ``` x1 = x0 xor y0 y2 = x1 xor y0 x2 = x1 xor y2 ``` Substituting, ``` x1 = x0 xor y0 y2 = (x0 xor y0) xor y0 x2 = (x0 xor y0) xor ((x0 xor y0) xor y0) ``` Because xor is fully associative and commutative: ``` y2 = x0 xor (y0 xor y0) x2 = (x0 xor x0) xor (y0 xo...
249,432
<p>I'm reading through the <a href="http://framework.zend.com/manual/en/coding-standard.coding-style.html" rel="nofollow noreferrer">Zend Framework coding standards</a>, where they state that curly brace after a Class definitions should be on the next line, the "one true brace form".</p> <pre><code>class MyClass { ...
[ { "answer_id": 249434, "author": "Kyle Trauberman", "author_id": 21461, "author_profile": "https://Stackoverflow.com/users/21461", "pm_score": 1, "selected": false, "text": "<p>User preference. It really makes no difference. When I developed in PHP, I used the second option, but now us...
2008/10/30
[ "https://Stackoverflow.com/questions/249432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
I'm reading through the [Zend Framework coding standards](http://framework.zend.com/manual/en/coding-standard.coding-style.html), where they state that curly brace after a Class definitions should be on the next line, the "one true brace form". ``` class MyClass { function.... } ``` I usually have the braces on ...
Personal preference is really the only real "reason".
249,448
<p>I have a textbox with the <strong>Text</strong> property bound to a dataset column with the DataType set to System.DateTime.<br> The FormatString on the Binding is set to <strong>dd-MM-yyyy</strong>.</p> <p>When the user enters a date it attempts to convert it to a date but can come up with some strange values for ...
[ { "answer_id": 249517, "author": "dove", "author_id": 30913, "author_profile": "https://Stackoverflow.com/users/30913", "pm_score": 0, "selected": false, "text": "<p>Any reason not to use a date picker control instead of a textbox? Would solve validation problem and probably make it a be...
2008/10/30
[ "https://Stackoverflow.com/questions/249448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4490/" ]
I have a textbox with the **Text** property bound to a dataset column with the DataType set to System.DateTime. The FormatString on the Binding is set to **dd-MM-yyyy**. When the user enters a date it attempts to convert it to a date but can come up with some strange values for a seemingly invalid date. For exampl...
A .NET DateTime is in the range 01/01/0001 to 31/12/9999 23:59:59.9999999, so 01/01/200 is considered to be valid. You can validate the input and restrict the range: the Validating event would be the place to do your validation. You'll need to parse the string into a DateTime and validate its range. The allowed range...
249,452
<p>How to add new item in existing string array in C#.net?</p> <p>I need to preserve the existing data.</p>
[ { "answer_id": 249455, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 7, "selected": false, "text": "<p>I would use a List if you need a dynamically sized array:</p>\n\n<pre><code>List&lt;string&gt; ls = new List&lt;string&gt;(...
2008/10/30
[ "https://Stackoverflow.com/questions/249452", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How to add new item in existing string array in C#.net? I need to preserve the existing data.
I would use a List if you need a dynamically sized array: ``` List<string> ls = new List<string>(); ls.Add("Hello"); ```
249,460
<p>On Windows Mobile, I am displaying my output in HTML. This includes lots of user-generated strings. Occasionally there are situations where a really large string is part of the output that has no whitespaces or punctuation. </p> <p>Unfortunately the Windows Mobile's HTML view (htmlview.dll, based on Pocket Internet...
[ { "answer_id": 249455, "author": "Ed S.", "author_id": 1053, "author_profile": "https://Stackoverflow.com/users/1053", "pm_score": 7, "selected": false, "text": "<p>I would use a List if you need a dynamically sized array:</p>\n\n<pre><code>List&lt;string&gt; ls = new List&lt;string&gt;(...
2008/10/30
[ "https://Stackoverflow.com/questions/249460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27101/" ]
On Windows Mobile, I am displaying my output in HTML. This includes lots of user-generated strings. Occasionally there are situations where a really large string is part of the output that has no whitespaces or punctuation. Unfortunately the Windows Mobile's HTML view (htmlview.dll, based on Pocket Internet Explorer)...
I would use a List if you need a dynamically sized array: ``` List<string> ls = new List<string>(); ls.Add("Hello"); ```
249,467
<p>I've heard of "error" when using floating point variables. Now I'm trying to solve this puzzle and I think I'm getting some rounding/floating point error. So I'm finally going to figure out the basics of floating point error.</p> <p>What is a simple example of floating point/rounding error (preferably in C++) ?</...
[ { "answer_id": 249498, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 4, "selected": false, "text": "<p>Generally, floating point error refers to when a number that cannot be stored in the IEEE floating point represen...
2008/10/30
[ "https://Stackoverflow.com/questions/249467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22471/" ]
I've heard of "error" when using floating point variables. Now I'm trying to solve this puzzle and I think I'm getting some rounding/floating point error. So I'm finally going to figure out the basics of floating point error. What is a simple example of floating point/rounding error (preferably in C++) ? Edit: For ex...
Picture is worth a thousand words - try to draw equation `f(k)` : ![enter image description here](https://i.stack.imgur.com/bZcxI.gif) and you will get such XY graph (X and Y are in logarithmic scale). ![enter image description here](https://i.stack.imgur.com/UVWuE.png) If computer could represent 32-bit flo...
249,470
<p>What would be a simple implementation of a method to convert a String like "Hello there everyone" to "helloThereEveryone". In JavaME support for String and StringBuffer utility operations are quite limited.</p>
[ { "answer_id": 249510, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 0, "selected": false, "text": "<p>Suggestion:</p>\n\n<p>May be if you can <a href=\"https://stackoverflow.com/questions/121988/how-can-i-add-a-regex-match-to-...
2008/10/30
[ "https://Stackoverflow.com/questions/249470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22012/" ]
What would be a simple implementation of a method to convert a String like "Hello there everyone" to "helloThereEveryone". In JavaME support for String and StringBuffer utility operations are quite limited.
Quick primitive implementation. I have no idea of restrictions of J2ME, so I hope it fits or it gives some ideas... ``` String str = "Hello, there, everyone?"; StringBuffer result = new StringBuffer(str.length()); String strl = str.toLowerCase(); boolean bMustCapitalize = false; for (int i = 0; i < strl.length(); i++...
249,499
<p>Evaluate:</p> <pre><code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5) </code></pre> <p>This is what I did:</p> <ul> <li><p>evaluate <code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5)</code></p> <ul> <li>evaluate <code>5 -&gt; 5</code></li> </ul></li> <li><p>evaluate <code>(((lambda (x...
[ { "answer_id": 249520, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<p>I suggest you break this down into individual 'defined' procedures.</p>\n\n<pre><code>(define part1 (lambda (y) (lambda ...
2008/10/30
[ "https://Stackoverflow.com/questions/249499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
Evaluate: ``` ((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5) ``` This is what I did: * evaluate `((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5)` + evaluate `5 -> 5` * evaluate `(((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4)` + evaluate `4 -> 4` * evaluate `((lambda (x) (lambda (y...
I suggest you break this down into individual 'defined' procedures. ``` (define part1 (lambda (y) (lambda (x) (+ x y)))) ; basically an adder (define part2 (lambda (x) part1)) ; just return part1, x has no effect ``` Now call `(((part2 3) 4) 5) => 9`
249,500
<p>OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality.</p> <p>I'm using a library that provides a standard Shape interface, as well as some common shapes...
[ { "answer_id": 249515, "author": "andreas buykx", "author_id": 19863, "author_profile": "https://Stackoverflow.com/users/19863", "pm_score": 2, "selected": false, "text": "<p>I suppose the <a href=\"http://en.wikipedia.org/wiki/Facade_pattern\" rel=\"nofollow noreferrer\">facade</a> patt...
2008/10/30
[ "https://Stackoverflow.com/questions/249500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3175/" ]
OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality. I'm using a library that provides a standard Shape interface, as well as some common shapes. ``` cla...
We had a very similar problem in a project and we solved it by just NOT deriving ImprovedShape from Shape. If you need Shape functionality in ImprovedShape you can dynamic\_cast, knowing that your cast will always work. And the rest is just like in your example.
249,536
<p>FindBugs has found a potential bug in my code. But it is not a bug.</p> <p>Is it possible to mark this occurrence as 'not a bug' AND have it removed from the bug list?</p> <p>I have documented quite clearly why for each case it is not a bug.</p> <p>For example. A class implements the comparable interface. it has ...
[ { "answer_id": 249543, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": false, "text": "<p>Probably by adding a <a href=\"http://findbugs.sourceforge.net/manual/filter.html\" rel=\"noreferrer\">filter</a> as paramet...
2008/10/30
[ "https://Stackoverflow.com/questions/249536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/939/" ]
FindBugs has found a potential bug in my code. But it is not a bug. Is it possible to mark this occurrence as 'not a bug' AND have it removed from the bug list? I have documented quite clearly why for each case it is not a bug. For example. A class implements the comparable interface. it has the compareTo method. I ...
Instead of using filters, you can also use the [SuppressWarnings](http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/SuppressWarnings.html "SuppressWarnings") annotation. You must use the annotation out of the findbugs package, meaning you either need an import or use the fully qualified name of it. Th...
249,540
<p>How do I specify the username and password in order for my program to open a file for reading? The program that needs to access the file is running from an account that does not have read access to the folder the file is in. Program is written in C# and .NET 2, running under XP and file is on a Windows Server 2003 m...
[ { "answer_id": 249559, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 0, "selected": false, "text": "<p>You can impersonate a user who has the necessary rights. There is an <a href=\"http://msdn.microsoft.com/en-us/library/b80...
2008/10/30
[ "https://Stackoverflow.com/questions/249540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I specify the username and password in order for my program to open a file for reading? The program that needs to access the file is running from an account that does not have read access to the folder the file is in. Program is written in C# and .NET 2, running under XP and file is on a Windows Server 2003 mach...
You want to impersonate a user who does have the rights to access the file. I recommend using a class like this - <http://www.codeproject.com/KB/cs/zetaimpersonator.aspx>. It hides all the nasty implementation of doing impersonation. ``` using (new Impersonator("myUsername", "myDomainname", "myPassword")) { string ...
249,557
<blockquote> <p>If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f(...(f(x))...)). For example, if f is the function x + 1, then the nth repeated application of f is the function x + n. If f is the ope...
[ { "answer_id": 249564, "author": "Matthias Benkard", "author_id": 15517, "author_profile": "https://Stackoverflow.com/users/15517", "pm_score": 1, "selected": false, "text": "<p>Did you just delete and reask this question? I'm copying my former answer here (thankfully, my browser had ca...
2008/10/30
[ "https://Stackoverflow.com/questions/249557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
> > If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f(...(f(x))...)). For example, if f is the function x + 1, then the nth repeated application of f is the function x + n. If f is the operation of s...
``` (define (repeated f n) (if (= n 1) f (compose f (repeated f (- n 1))))) ```
249,570
<p>On a particular Debian server, iostat (and similar) report an unexpectedly high volume (in bytes) of disk writes going on. I am having trouble working out which process is doing these writes.</p> <p>Two interesting points:</p> <ol> <li><p>Tried turning off system services one at a time to no avail. Disk activity...
[ { "answer_id": 249574, "author": "Geo", "author_id": 31610, "author_profile": "https://Stackoverflow.com/users/31610", "pm_score": 0, "selected": false, "text": "<p>You could try to use <a href=\"http://sourceware.org/systemtap/\" rel=\"nofollow noreferrer\">SystemTap</a> , it has a lot ...
2008/10/30
[ "https://Stackoverflow.com/questions/249570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
On a particular Debian server, iostat (and similar) report an unexpectedly high volume (in bytes) of disk writes going on. I am having trouble working out which process is doing these writes. Two interesting points: 1. Tried turning off system services one at a time to no avail. Disk activity remains fairly constant ...
iotop is good (great, actually). If you have a kernel from before 2.6.20, you can't use most of these tools. Instead, you can try the following (which should work for almost any 2.6 kernel IIRC): ``` sudo -s dmesg -c /etc/init.d/klogd stop echo 1 > /proc/sys/vm/block_dump rm /tmp/disklog watch "dmesg -c >> /tmp/di...
249,573
<p>There is small system, where a database table as queue on MSSQL 2005. Several applications are writing to this table, and one application is reading and processing in a FIFO manner.</p> <p>I have to make it a little bit more advanced to be able to create a distributed system, where several processing application ca...
[ { "answer_id": 249611, "author": "philsquared", "author_id": 32136, "author_profile": "https://Stackoverflow.com/users/32136", "pm_score": 1, "selected": false, "text": "<p>This approach looks reasonable to me, and is similar to one I have used in the past - successfully.</p>\n\n<p>Also,...
2008/10/30
[ "https://Stackoverflow.com/questions/249573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/968/" ]
There is small system, where a database table as queue on MSSQL 2005. Several applications are writing to this table, and one application is reading and processing in a FIFO manner. I have to make it a little bit more advanced to be able to create a distributed system, where several processing application can run. The...
This will work, but you'll probably find you'll run into blocking or deadlocks where multiple processes try and read/update the same data. I wrote a procedure to do exactly this for one of our systems which uses some interesting locking semantics to ensure this type of thing runs with no blocking or deadlocks, [describ...
249,578
<p>I'm writing a bash script that needs to delete old files.</p> <p>It's currently implemented using :</p> <pre><code>find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete </code></pre> <p>This will delete of the files older than 1 day.</p> <p>However, what if I need a finer resolution that 1 day, say like...
[ { "answer_id": 249584, "author": "GavinCattell", "author_id": 21644, "author_profile": "https://Stackoverflow.com/users/21644", "pm_score": 2, "selected": false, "text": "<p>-mmin is for minutes.</p>\n\n<p>Try looking at the man page.</p>\n\n<pre><code>man find\n</code></pre>\n\n<p>for m...
2008/10/30
[ "https://Stackoverflow.com/questions/249578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13523/" ]
I'm writing a bash script that needs to delete old files. It's currently implemented using : ``` find $LOCATION -name $REQUIRED_FILES -type f -mtime +1 -delete ``` This will delete of the files older than 1 day. However, what if I need a finer resolution that 1 day, say like 6 hours old? Is there a nice clean way ...
Does your [`find`](http://man7.org/linux/man-pages/man1/find.1.html) have the `-mmin` option? That can let you test the number of mins since last modification: ``` find $LOCATION -name $REQUIRED_FILES -type f -mmin +360 -delete ``` Or maybe look at using [`tmpwatch`](http://linux.about.com/library/cmd/blcmdl8_tmpwat...
249,580
<p>What is the recommended practice? Should I add the my sub-folder under the fitnesse folder to version control? </p> <p><em>Context: working on a single developer rails pet project. I've my rails project under version-control (Subversion) however my fitnesse wiki pages lie under the fitnesse program folder.</em><...
[ { "answer_id": 249621, "author": "Aur Saraf", "author_id": 19993, "author_profile": "https://Stackoverflow.com/users/19993", "pm_score": 2, "selected": false, "text": "<p>FitNesse stores old revisions of every page in a zip file in the same directory as the page's files. The zip filename...
2008/10/30
[ "https://Stackoverflow.com/questions/249580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
What is the recommended practice? Should I add the my sub-folder under the fitnesse folder to version control? *Context: working on a single developer rails pet project. I've my rails project under version-control (Subversion) however my fitnesse wiki pages lie under the fitnesse program folder.* Fitnesse seems to h...
Use the `-d` switch (*which is surprisingly low profile on a google search*) ``` Fitnesse20081201>run -p 8080 -d c:/projects/MyProjectNeedsAcceptanceTests ``` This will create a subfolder in the specified folder called FitnesseRoot if it doesn't already exist, with all the stuff it needs to run. Fitnesse should be ...
249,581
<p>I have checked with the <a href="http://en.wikipedia.org/wiki/Facade_pattern" rel="noreferrer">wikipedia article</a>, and it seems like it is missing the c++ version of a code example. I am not able to fully appreciate the Facade pattern without this, can you please help explain it to me using C++?</p>
[ { "answer_id": 249656, "author": "Dave Hillier", "author_id": 1575281, "author_profile": "https://Stackoverflow.com/users/1575281", "pm_score": 3, "selected": false, "text": "<p>I've done a search and replace on the C# example. This might not help you, because if you understand C++ then ...
2008/10/30
[ "https://Stackoverflow.com/questions/249581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22076/" ]
I have checked with the [wikipedia article](http://en.wikipedia.org/wiki/Facade_pattern), and it seems like it is missing the c++ version of a code example. I am not able to fully appreciate the Facade pattern without this, can you please help explain it to me using C++?
**Facade pattern: provides a unified - simplified interface to a complex subsystem or set of interfaces. It provides a higher level interface simultaneously decoupling the client from the complex subsystem.** An example to help you understand .. a cab driver. You tell the cab driver 'Take me to PointX' (unified simpli...
249,587
<p>I want to scale an image in C# with quality level as good as Photoshop does. Is there any C# image processing library available to do this thing?</p>
[ { "answer_id": 249601, "author": "Hallgrim", "author_id": 15454, "author_profile": "https://Stackoverflow.com/users/15454", "pm_score": 4, "selected": false, "text": "<p>When you draw the image using GDI+ it scales quite well in my opinion. You can use this to create a scaled image.</p>\...
2008/10/30
[ "https://Stackoverflow.com/questions/249587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
I want to scale an image in C# with quality level as good as Photoshop does. Is there any C# image processing library available to do this thing?
Here's a nicely commented Image Manipulation helper class that you can look at and use. I wrote it as an example of how to perform certain image manipulation tasks in C#. You'll be interested in the **ResizeImage** function that takes a System.Drawing.Image, the width and the height as the arguments. ``` using System;...
249,607
<p>I am using Visual C++ 2005 Express Edition and get the following linker errors:</p> <pre><code>19&gt;mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in functio...
[ { "answer_id": 249685, "author": "MSalters", "author_id": 15416, "author_profile": "https://Stackoverflow.com/users/15416", "pm_score": 0, "selected": false, "text": "<p>The third error makes it clear that <code>#define the _HAS_EXCEPTIONS 0</code> does not affect . Now, might include ...
2008/10/30
[ "https://Stackoverflow.com/questions/249607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2666/" ]
I am using Visual C++ 2005 Express Edition and get the following linker errors: ``` 19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: sta...
Adding this line: ``` #define _STATIC_CPPLIB ``` before including the vector header seems to do the trick.
249,632
<p>What is the time complexity? Why?</p> <pre><code>(define (mult a b) (define (internal a accum) (if (= a 1) accum (internal (- a 1) (+ accum b)))) (internal a b)) (define (to-the-power-of m n) (define (internal x accum) (if (= x 0) accum (internal (- x 1) (mult accum m)...
[ { "answer_id": 249652, "author": "Pramod", "author_id": 1386292, "author_profile": "https://Stackoverflow.com/users/1386292", "pm_score": 0, "selected": false, "text": "<p>Assuming addition and multiplication are both counted as a single operation, this function performs O(m^n) operation...
2008/10/30
[ "https://Stackoverflow.com/questions/249632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the time complexity? Why? ``` (define (mult a b) (define (internal a accum) (if (= a 1) accum (internal (- a 1) (+ accum b)))) (internal a b)) (define (to-the-power-of m n) (define (internal x accum) (if (= x 0) accum (internal (- x 1) (mult accum m)))) (interna...
the time complexity for the mult part can be found like this: to calculate (mult a b), (internal a accum) is called until a = 1 so we have some kind of tail recursion (loop) that iterates over a. we thus know that the time complexity of (mult a b) is **O(a)** (= linear time complexity) (to-the-power-of m n) also has...
249,637
<p>Let's suppose I have an applet running within a page in a browser. What happens when the browser is closed by the user?</p> <p>Is the applet notified so that it can perform some kind of close action on its side (closing connections opened to a server, cleaning static variables, ...)?</p> <p>Also, I assume the same...
[ { "answer_id": 249643, "author": "keparo", "author_id": 19468, "author_profile": "https://Stackoverflow.com/users/19468", "pm_score": 3, "selected": true, "text": "<p>Yes, the <strong>destroy() method</strong> should be called before the <strong>browser unloads the object</strong>.</p>\n...
2008/10/30
[ "https://Stackoverflow.com/questions/249637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7218/" ]
Let's suppose I have an applet running within a page in a browser. What happens when the browser is closed by the user? Is the applet notified so that it can perform some kind of close action on its side (closing connections opened to a server, cleaning static variables, ...)? Also, I assume the same behavior would a...
Yes, the **destroy() method** should be called before the **browser unloads the object**. **destroy()** is the last of four "**life-cycle methods**" of the Java applet (the others are **init()**, **start()**, and **stop()** ). They're actually called at different times depending on your **browser** and **virtual machi...
249,655
<p>I work on a large project in Delphi 5. Today, after merging two branches of the app together, one of the hundreds of units, UnitMain (the main form's unit, would you guess) stopped recognizing the Application global.</p> <p>This is a rather bizarre problem - I could get the program to compile by defining Applicatio...
[ { "answer_id": 249669, "author": "Re0sless", "author_id": 2098, "author_profile": "https://Stackoverflow.com/users/2098", "pm_score": 2, "selected": false, "text": "<p>What units are in the uses clause at the top of the file? Application comes from the \"Forms\" unit.</p>\n\n<p>eg.</p>\...
2008/10/30
[ "https://Stackoverflow.com/questions/249655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15477/" ]
I work on a large project in Delphi 5. Today, after merging two branches of the app together, one of the hundreds of units, UnitMain (the main form's unit, would you guess) stopped recognizing the Application global. This is a rather bizarre problem - I could get the program to compile by defining Application: TApplic...
I think it is most likely that you have two symbols called "Application" in scope, and the one from the Forms unit isn't the active one. Make sure the Forms unit in the uses list comes after any prior unit that contains a symbol called Application. But, you need to provide more information. The exact error messages, e...
249,657
<p>could someone provide working example (full maven plugin configuration) how to copy built jar file to a specific server(s) at the time of deploy phase?</p> <p>I have tried to look at wagon plugin, but it is hugely undocumented and I was not able to set it up. The build produces standard jar that is being deployed t...
[ { "answer_id": 249911, "author": "Roland Schneider", "author_id": 16515, "author_profile": "https://Stackoverflow.com/users/16515", "pm_score": 1, "selected": false, "text": "<p>I don't have a working example but the <a href=\"http://maven.apache.org/plugins/maven-assembly-plugin/assembl...
2008/10/30
[ "https://Stackoverflow.com/questions/249657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15045/" ]
could someone provide working example (full maven plugin configuration) how to copy built jar file to a specific server(s) at the time of deploy phase? I have tried to look at wagon plugin, but it is hugely undocumented and I was not able to set it up. The build produces standard jar that is being deployed to Nexus, b...
Actually I have found a different way: Dependency plugin! ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-to-ebs</id> <phase>deploy</phase> <goals> <goal>copy</goal> </goals> <c...
249,664
<p>I found the discussion on <a href="https://stackoverflow.com/questions/105007/do-you-test-private-method">Do you test private method</a> informative.</p> <p>I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. Because most of the public m...
[ { "answer_id": 249776, "author": "troelskn", "author_id": 18180, "author_profile": "https://Stackoverflow.com/users/18180", "pm_score": 6, "selected": false, "text": "<p>You seem to be aware already, but I'll just restate it anyway; It's a bad sign, if you need to test protected methods....
2008/10/30
[ "https://Stackoverflow.com/questions/249664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32679/" ]
I found the discussion on [Do you test private method](https://stackoverflow.com/questions/105007/do-you-test-private-method) informative. I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. Because most of the public methods make use of th...
If you're using PHP5 (>= 5.3.2) with PHPUnit, you can test your private and protected methods by using reflection to set them to be public prior to running your tests: ``` protected static function getMethod($name) { $class = new ReflectionClass('MyClass'); $method = $class->getMethod($name); $method->setAccessi...
249,667
<p>Say you get a recordset like the following:</p> <pre><code>| ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. </code></pre> <p>And you want:</p> <pre><cod...
[ { "answer_id": 249717, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 1, "selected": false, "text": "<p>The query you had above works just fine for VARCHAR fields as it did for INT fields. The problem with your query...
2008/10/30
[ "https://Stackoverflow.com/questions/249667", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15031/" ]
Say you get a recordset like the following: ``` | ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. ``` And you want: ``` | ID | Foo | Bar | Red | |-----|--...
I don't have access to a SQL2K box at the minute but select max(column) will work on nvarchars in 2005. The only problem will be if you have multiple text values under each column for each id in your original table... ``` CREATE TABLE Flatten ( id int not null, foo Nvarchar(10) null, bar Nvarchar(10) null,...
249,671
<p>I have created the following style for a listbox that will have an image displayed next to some text:</p> <pre><code>&lt;Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}"&gt; &lt;Setter Property="SnapsToDevicePixels" Value="true"/&gt; &lt;Setter Property="BorderThickness" Value="1"/&gt; &lt;...
[ { "answer_id": 258612, "author": "Bijington", "author_id": 32348, "author_profile": "https://Stackoverflow.com/users/32348", "pm_score": 5, "selected": false, "text": "<p>It's all ok, I have managed to answer this question myself, I was trying to modify the foreground/fontweight of the c...
2008/10/30
[ "https://Stackoverflow.com/questions/249671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32348/" ]
I have created the following style for a listbox that will have an image displayed next to some text: ``` <Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="ScrollViewer.Horiz...
There is also another way. You can add in your `ContentPresenter` this attribute ``` TextBlock.Foreground="YourColour" ``` In this case you can also use animations over that property.
249,692
<p>I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax()</p> <p>To perform the AJAX I'm using:</p> <pre><code>$.ajax({ url: myUrl, cache: false, dataType: "json", success: function(data){ ... }, error: function(e, xhr){ ... } }); </code></pre> <p>And if I re...
[ { "answer_id": 249758, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 7, "selected": true, "text": "<p>Is your server sending data as Content-Type <code>\"*/json\"</code>? If not, modify the response headers accordingly. Se...
2008/10/30
[ "https://Stackoverflow.com/questions/249692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/366/" ]
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To perform the AJAX I'm using: ``` $.ajax({ url: myUrl, cache: false, dataType: "json", success: function(data){ ... }, error: function(e, xhr){ ... } }); ``` And if I return an array of items then it wo...
Is your server sending data as Content-Type `"*/json"`? If not, modify the response headers accordingly. Sending `"application/json"` would be fine, for example.
249,701
<p>I have a header file x.h which is included by more than one *.c source files. This header file has some structure variables defined.</p> <p>I have put multiple inclusion prevention guard at the beginning of the header file as:</p> <pre><code>#ifndef X_H #define X_H ... .. //header file declarations and definitons...
[ { "answer_id": 249707, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>Using a multiple inclusion guard prevents <em>compiler</em> errors, but you're getting a linker error. Do you have dat...
2008/10/30
[ "https://Stackoverflow.com/questions/249701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2759376/" ]
I have a header file x.h which is included by more than one \*.c source files. This header file has some structure variables defined. I have put multiple inclusion prevention guard at the beginning of the header file as: ``` #ifndef X_H #define X_H ... .. //header file declarations and definitons. #endif//X_H ``` ...
If the linker is complaining, it means you have definitions rather than just declarations in your header. Here's an example of things that would be wrong. ``` #ifndef X_H #define X_H int myFunc() { return 42; // Wrong! definition in header. } int myVar; // Wrong! definition in header. #endif ``` You should spli...
249,703
<p>I have some scripts that ought to have stopped running but hang around forever. Is there some way I can figure out what they're writing to STDOUT and STDERR in a readable way?</p> <p>I tried, for example, to do:</p> <pre><code>$ tail -f /proc/(pid)/fd/1 </code></pre> <p>but that doesn't really work. It was a lo...
[ { "answer_id": 249725, "author": "Jauco", "author_id": 6874, "author_profile": "https://Stackoverflow.com/users/6874", "pm_score": 4, "selected": true, "text": "<p>I'm not sure if it will work for you, but I read a page a while back describing a <a href=\"http://etbe.coker.com.au/2008/02...
2008/10/30
[ "https://Stackoverflow.com/questions/249703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2900/" ]
I have some scripts that ought to have stopped running but hang around forever. Is there some way I can figure out what they're writing to STDOUT and STDERR in a readable way? I tried, for example, to do: ``` $ tail -f /proc/(pid)/fd/1 ``` but that doesn't really work. It was a long shot anyway. Any other ideas? ...
I'm not sure if it will work for you, but I read a page a while back describing a [method that uses gdb](http://etbe.coker.com.au/2008/02/27/redirecting-output-from-a-running-process/)
249,704
<p>Has anyone tested sorting with Selenium? I'd like to verify that sorting a table in different ways work (a-z, z-a, state, date, etc.). Any help would be very much appreciated.</p> <p>/Göran</p>
[ { "answer_id": 296686, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 0, "selected": false, "text": "<p>You can get value of fields like this:</p>\n\n<pre><code> //div[@id='sortResult']/div[1]/div (this'd be row 1 of th...
2008/10/30
[ "https://Stackoverflow.com/questions/249704", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Has anyone tested sorting with Selenium? I'd like to verify that sorting a table in different ways work (a-z, z-a, state, date, etc.). Any help would be very much appreciated. /Göran
Before checking it with **selenium**, You have to do small thing. Store the table values(which comes after sorting) in a `string` or `array`. Now perform the sorting using selenium and capture the new list as ``` string new_list= selenium.gettable("xpath"); ``` Now compare both the values and check whether they ar...
249,709
<p>How can i, in a bash script, execute a command when the user stops the script (with ctrl - c)?</p> <p>Currently, i have this:</p> <pre><code>afplay file.mp3 while true: do osascript -e "set volume 10" end </code></pre> <p>But i would like it to execute <code>killall afplay</code> when the user is finished with i...
[ { "answer_id": 249733, "author": "Vebjorn Ljosa", "author_id": 17498, "author_profile": "https://Stackoverflow.com/users/17498", "pm_score": 4, "selected": true, "text": "<p><code>trap 'killall afplay' EXIT</code></p>\n" }, { "answer_id": 249736, "author": "CesarB", "auth...
2008/10/30
[ "https://Stackoverflow.com/questions/249709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
How can i, in a bash script, execute a command when the user stops the script (with ctrl - c)? Currently, i have this: ``` afplay file.mp3 while true: do osascript -e "set volume 10" end ``` But i would like it to execute `killall afplay` when the user is finished with it, regardless if it is command-c or another ...
`trap 'killall afplay' EXIT`
249,721
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/249760/how-to-convert-unix-timestamp-to-datetime-and-vice-versa">How to convert UNIX timestamp to DateTime and vice versa?</a> </p> </blockquote> <p>I've got the following class:</p> <pre><code>[DataContractAt...
[ { "answer_id": 251804, "author": "Dan Esparza", "author_id": 19020, "author_profile": "https://Stackoverflow.com/users/19020", "pm_score": 2, "selected": false, "text": "<p>Here's what I've come up with. In C#, it looks like you need to create a new DateTime and add the epoch value as '...
2008/10/30
[ "https://Stackoverflow.com/questions/249721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
> > **Possible Duplicate:** > > [How to convert UNIX timestamp to DateTime and vice versa?](https://stackoverflow.com/questions/249760/how-to-convert-unix-timestamp-to-datetime-and-vice-versa) > > > I've got the following class: ``` [DataContractAttribute] public class TestClass { [DataMemberAttribute] pu...
Finishing what you posted, AND making it private seemed to work fine for me. ``` [DataContract] public class TestClass { private static readonly DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); [IgnoreDataMember] public DateTime MyDateTime { get; set; } [DataMember(Name =...
249,729
<p>I am writing a Jython script to sort a list of URLs.</p> <p>I have a list that looks like this:</p> <p><a href="http://www.domain.com/folder1/folder2/|,1" rel="nofollow noreferrer">http://www.domain.com/folder1/folder2/|,1</a><br /> <a href="http://www.domain.com/folder1/|,1" rel="nofollow noreferrer">http://www.d...
[ { "answer_id": 249742, "author": "Michael McCarty", "author_id": 25007, "author_profile": "https://Stackoverflow.com/users/25007", "pm_score": 0, "selected": false, "text": "<p>Wouldn't sorting them take care of this?</p>\n" }, { "answer_id": 249754, "author": "bobince", ...
2008/10/30
[ "https://Stackoverflow.com/questions/249729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30786/" ]
I am writing a Jython script to sort a list of URLs. I have a list that looks like this: <http://www.domain.com/folder1/folder2/|,1> <http://www.domain.com/folder1/|,1> <http://www.domain.com/folder1/folder2/folder3/|,1> <http://www.domain.com/folder1/|,1> <http://www.domain.com/folder1/folder2/|,1> <h...
Sort-by-length, using a sort function: ``` urls.sort(lambda a, b: cmp(len(a), len(b))) ``` For performance, some might prefer the decorate-sort-undecorate pattern: ``` urllengths= [(len(url), url) for url in urls] urllengths.sort() urls= [url for (l, url) in urllengths] ``` Or as a one-liner: ``` urls= zip(*sort...
249,747
<p>Im currently working on a PPC application that I would like to test in the PPC emulator "USA Windows mobile 5.0 PC R2 Emulator" without using Active Sync. Somewhere in my back head I think I have been able to just do that: But when I start a debug session with Visual Studio, it can not deploy the application to the ...
[ { "answer_id": 249811, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 0, "selected": false, "text": "<p>From your build log, you are targetting the <strong>ARMv4</strong> processor. You need to target <strong>Win32 (WCE emul...
2008/10/30
[ "https://Stackoverflow.com/questions/249747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28553/" ]
Im currently working on a PPC application that I would like to test in the PPC emulator "USA Windows mobile 5.0 PC R2 Emulator" without using Active Sync. Somewhere in my back head I think I have been able to just do that: But when I start a debug session with Visual Studio, it can not deploy the application to the emu...
The actual problem was that I had different target devices when I built the project and tried to deploy it. At the end VS would deploy one file to an ActiveSync device, one to the emulator and so forth. It was not suprisngly that it didnt work. If I changed the target device for the current project, it would not change...
249,760
<p>There is this example code, but then it starts talking about millisecond / nanosecond problems.</p> <p>The same question is on MSDN, <em><a href="https://learn.microsoft.com/archive/blogs/brada/seconds-since-the-unix-epoch-in-c" rel="noreferrer">Seconds since the Unix epoch in C#</a></em>.</p> <p>This is what I've...
[ { "answer_id": 249793, "author": "Luk", "author_id": 5789, "author_profile": "https://Stackoverflow.com/users/5789", "pm_score": 2, "selected": false, "text": "<p>A Unix tick is 1 second (if I remember well), and a .NET tick is 100&nbsp;nanoseconds. </p>\n\n<p>If you've been encountering...
2008/10/30
[ "https://Stackoverflow.com/questions/249760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
There is this example code, but then it starts talking about millisecond / nanosecond problems. The same question is on MSDN, *[Seconds since the Unix epoch in C#](https://learn.microsoft.com/archive/blogs/brada/seconds-since-the-unix-epoch-in-c)*. This is what I've got so far: ``` public Double CreatedEpoch { get...
Here's what you need: ``` public static DateTime UnixTimeStampToDateTime( double unixTimeStamp ) { // Unix timestamp is seconds past epoch DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dateTime = dateTime.AddSeconds( unixTimeStamp ).ToLocalTime(); return dateTime; } ``` ...