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
142,845
<p>I'm working on an application that consists of an overall Quartz-based scheduler and "CycledJob" run using CronTriggers. The purpose of the application is to process inputs from different email inboxes based on the source country. </p> <p>Based on the country that it comes in from (i.e. US, UK, FR, etc.) the applic...
[ { "answer_id": 142920, "author": "Feet", "author_id": 18340, "author_profile": "https://Stackoverflow.com/users/18340", "pm_score": 2, "selected": false, "text": "<p>I wish I could be a bit more helpful than this, but you may want to investigate using some filters? Perhaps your logging c...
2008/09/27
[ "https://Stackoverflow.com/questions/142845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18402/" ]
I'm working on an application that consists of an overall Quartz-based scheduler and "CycledJob" run using CronTriggers. The purpose of the application is to process inputs from different email inboxes based on the source country. Based on the country that it comes in from (i.e. US, UK, FR, etc.) the application trig...
At the top of each country's processing thread, put the country code into Log4j's mapped diagnostic context (MDC). This uses a ThreadLocal variable so that you don't have to pass the country up and down the call stack explicitly. Then create a custom filter that looks at the MDC, and filters out any events that don't c...
142,863
<p><em>Comment on Duplicate Reference: Why would this be marked duplicate when it was asked years prior to the question referenced as a duplicate? I also believe the question, detail, and response is much better than the referenced question.</em></p> <p>I've been a C++ programmer for quite a while but I'm new to Java...
[ { "answer_id": 142880, "author": "Mike Deck", "author_id": 1247, "author_profile": "https://Stackoverflow.com/users/1247", "pm_score": 4, "selected": false, "text": "<p>This assumes Eclipse and an appropriate JDK are installed on your system</p>\n\n<ol>\n<li>Open Eclipse and create a new...
2008/09/27
[ "https://Stackoverflow.com/questions/142863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22917/" ]
*Comment on Duplicate Reference: Why would this be marked duplicate when it was asked years prior to the question referenced as a duplicate? I also believe the question, detail, and response is much better than the referenced question.* I've been a C++ programmer for quite a while but I'm new to Java and new to Eclips...
1. Create a new Java project in Eclipse. This will create a src folder (to contain your source files). 2. Also create a lib folder (the name isn't that important, but it follows standard conventions). 3. Copy the `./com/*` folders into the `/src` folder (you can just do this using the OS, no need to do any fancy import...
142,868
<p>How do I change Oracle from port 8080? My Eclipse is using 8080, so I can't use that.</p>
[ { "answer_id": 142889, "author": "Brad Bruce", "author_id": 5008, "author_profile": "https://Stackoverflow.com/users/5008", "pm_score": 3, "selected": false, "text": "<p>I assume you're talking about the Apache server that Oracle installs. Look for the file httpd.conf. </p>\n\n<p>Open ...
2008/09/27
[ "https://Stackoverflow.com/questions/142868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22916/" ]
How do I change Oracle from port 8080? My Eclipse is using 8080, so I can't use that.
From Start | Run open a command window. Assuming your environmental variables are set correctly start with the following: ``` C:\>sqlplus /nolog SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 26 10:40:44 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. SQL> connect Enter user-name: system Enter pass...
142,877
<p>I have a very large codebase (read: thousands of modules) that has code shared across numerous projects that all run on different operating systems with different C++ compilers. Needless to say, maintaining the build process can be quite a chore. </p> <p>There are several places in the codebase where it would clean...
[ { "answer_id": 142884, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "<p>You could have a pre-build step run that generates an include file that contains a list of #defines that represent the...
2008/09/27
[ "https://Stackoverflow.com/questions/142877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a very large codebase (read: thousands of modules) that has code shared across numerous projects that all run on different operating systems with different C++ compilers. Needless to say, maintaining the build process can be quite a chore. There are several places in the codebase where it would clean up the co...
Generally this is done by using a script that tries running the preprocessor on an attempt at including the file. Depending on if the preprocessor returns an error, the script updates a generated .h file with an appropriate #define (or #undef). In bash, the script might look vaguely like this: ``` cat > .test.h <<'EOM...
142,903
<p>I started playing around with Linq today and ran into a problem I couldn't find an answer to. I was querying a simple SQL Server database that had some employee records. One of the fields is the full name (cn). I thought it would be interesting to group by the first name by splitting the full name at the first space...
[ { "answer_id": 143078, "author": "Amy B", "author_id": 8155, "author_profile": "https://Stackoverflow.com/users/8155", "pm_score": 2, "selected": false, "text": "<p>Split has no translation into SQL.</p>\n\n<p>So, how to do this string manipulation without split? Cheat like hell (untest...
2008/09/27
[ "https://Stackoverflow.com/questions/142903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18321/" ]
I started playing around with Linq today and ran into a problem I couldn't find an answer to. I was querying a simple SQL Server database that had some employee records. One of the fields is the full name (cn). I thought it would be interesting to group by the first name by splitting the full name at the first space. I...
Split has no translation into SQL. So, how to do this string manipulation without split? Cheat like hell (untested): ``` string oneSpace = " "; string fiftySpace = " "; var query = from person in db.Persons let lastname = person.cn.Replace(oneSpace, fiftySpace).S...
142,944
<p>I remember seeing the code for a Highpass filter a few days back somewhere in the samples, however I can't find it anywhere now! Could someone remember me where the Highpass filter implementation code was?</p> <p>Or better yet post the algorithm?</p> <p>Thanks!</p>
[ { "answer_id": 142962, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 6, "selected": true, "text": "<p><a href=\"http://idevkit.com/forums/tutorials-code-samples-sdk/171-accelerometer-high-pass-filter-incorrect-apple-code....
2008/09/27
[ "https://Stackoverflow.com/questions/142944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
I remember seeing the code for a Highpass filter a few days back somewhere in the samples, however I can't find it anywhere now! Could someone remember me where the Highpass filter implementation code was? Or better yet post the algorithm? Thanks!
[From the idevkit.com forums:](http://idevkit.com/forums/tutorials-code-samples-sdk/171-accelerometer-high-pass-filter-incorrect-apple-code.html) ``` #define kFilteringFactor 0.1 static UIAccelerationValue rollingX=0, rollingY=0, rollingZ=0; - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcce...
142,965
<p>An existing Java site is designed to run under "/" on tomcat and there are many specific references to fixed absolute paths like "/dir/dir/page".</p> <p>Want to migrate this to Java EE packaging, where the site will need to run under a context-root e.g. "/dir/dir/page" becomes "/my-context-root/dir/dir/page"</p> <...
[ { "answer_id": 143115, "author": "anjanb", "author_id": 11142, "author_profile": "https://Stackoverflow.com/users/11142", "pm_score": 0, "selected": false, "text": "<p>the apache world used Redirects(mod_rewrite) to do the same.</p>\n\n<p>The Servlet world started using filters</p>\n\n<p...
2008/09/27
[ "https://Stackoverflow.com/questions/142965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6329/" ]
An existing Java site is designed to run under "/" on tomcat and there are many specific references to fixed absolute paths like "/dir/dir/page". Want to migrate this to Java EE packaging, where the site will need to run under a context-root e.g. "/dir/dir/page" becomes "/my-context-root/dir/dir/page" Now, the contex...
Check out a related [question](https://stackoverflow.com/questions/125359/any-clever-ways-of-handling-the-context-in-a-web-app) Also consider [URLRewriteFilter](http://tuckey.org/urlrewrite/) Another thing (I keep editing this darn post). If you're using JSP (versus static HTML or something else) you could also creat...
142,972
<p>I have a series of ASCII flat files coming in from a mainframe to be processed by a C# application. A new feed has been introduced with a Packed Decimal (COMP-3) field, which needs to be converted to a numerical value.</p> <p>The files are being transferred via FTP, using ASCII transfer mode. I am concerned that th...
[ { "answer_id": 143001, "author": "Jason Stevenson", "author_id": 13368, "author_profile": "https://Stackoverflow.com/users/13368", "pm_score": 2, "selected": false, "text": "<p>I apologize if I am way off base here, but perhaps this code sample I'll paste here could help you. This came f...
2008/09/27
[ "https://Stackoverflow.com/questions/142972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11112/" ]
I have a series of ASCII flat files coming in from a mainframe to be processed by a C# application. A new feed has been introduced with a Packed Decimal (COMP-3) field, which needs to be converted to a numerical value. The files are being transferred via FTP, using ASCII transfer mode. I am concerned that the binary f...
First of all you must eliminate the end of line (EOL) translation problems that will be caused by ASCII transfer mode. You are absolutely right to be concerned about data corruption when the BCD values happen to correspond to EOL characters. The worst aspect of this problem is that it will occur rarely and unexpectedly...
143,025
<pre><code>struct a { char *c; char b; }; </code></pre> <p>What is sizeof(a)? </p>
[ { "answer_id": 143026, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 0, "selected": false, "text": "<p>I assume you mean struct and not strict, but on a 32-bit system it'll be either 5 or 8 bytes, depending on if t...
2008/09/27
[ "https://Stackoverflow.com/questions/143025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` struct a { char *c; char b; }; ``` What is sizeof(a)?
``` #include <stdio.h> typedef struct { char* c; char b; } a; int main() { printf("sizeof(a) == %d", sizeof(a)); } ``` I get "sizeof(a) == 8", on a 32-bit machine. The total size of the structure will depend on the packing: In my case, the default packing is 4, so 'c' takes 4 bytes, 'b' takes one byte, leaving ...
143,058
<p>ToolStripItems show Active highlighting when you mouse over them, even if the form they are in is not in focus. They do not, however, show their tooltips, unless the form is focused. I have seen the <a href="http://blogs.msdn.com/rickbrew/archive/2006/01/09/511003.aspx" rel="noreferrer">ToolStrip 'click-though'...
[ { "answer_id": 145483, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 2, "selected": false, "text": "<p>Perhaps one of the two approaches in this code will kick you off in the right direction...</p>\n\n<pre><code>p...
2008/09/27
[ "https://Stackoverflow.com/questions/143058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22539/" ]
ToolStripItems show Active highlighting when you mouse over them, even if the form they are in is not in focus. They do not, however, show their tooltips, unless the form is focused. I have seen the [ToolStrip 'click-though' hack](http://blogs.msdn.com/rickbrew/archive/2006/01/09/511003.aspx). Anyone know how to make a...
The problem is that the ToolStrip "controls" like ToolStripButton or ToolStripDropDownButton don't inherit from Control. For now I addressed the problem by focusing the ToolStrip whenever a user hovers over a button. The button's MouseHover event is fired too late -- after the "show tooltip" code would have been run, s...
143,063
<p>I've recently seen the light of EventWaitHandle's powerful behavior in C# and decided to move some functionality in a sister application to do the same. The only problem is that the sister app is written in C.</p> <p>No big deal, I'm using pthreads, which have a pthread_cond_t datatype that allows for signalling. M...
[ { "answer_id": 143161, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 3, "selected": true, "text": "<p>If you're using condition variables correctly, this won't matter.</p>\n\n<p>The basic flow of your code should be (in pseu...
2008/09/27
[ "https://Stackoverflow.com/questions/143063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8945/" ]
I've recently seen the light of EventWaitHandle's powerful behavior in C# and decided to move some functionality in a sister application to do the same. The only problem is that the sister app is written in C. No big deal, I'm using pthreads, which have a pthread\_cond\_t datatype that allows for signalling. My only q...
If you're using condition variables correctly, this won't matter. The basic flow of your code should be (in pseudocode): ``` lock(lockobj); while (!signalled) { wait(condvar); } signalled = false; unlock(lockobj); ``` on the waiting side, and: ``` lock(lockobj); signalled = true; notify(condvar); unlock(lockob...
143,075
<p>I'm trying to print out the date in a certain format:</p> <pre><code>NSDate *today = [[NSDate alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyyMMddHHmmss"]; NSString *dateStr = [dateFormatter stringFromDate:today]; </code></pre> <p>If the iPhone is s...
[ { "answer_id": 143114, "author": "Mike McMaster", "author_id": 544, "author_profile": "https://Stackoverflow.com/users/544", "pm_score": 5, "selected": true, "text": "<p>Using the code you posted on both the simulator and a phone with the 2.1 firmware and 24-hour time set to off, I never...
2008/09/27
[ "https://Stackoverflow.com/questions/143075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6044/" ]
I'm trying to print out the date in a certain format: ``` NSDate *today = [[NSDate alloc] init]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyyMMddHHmmss"]; NSString *dateStr = [dateFormatter stringFromDate:today]; ``` If the iPhone is set to 24 hour time, this w...
Using the code you posted on both the simulator and a phone with the 2.1 firmware and 24-hour time set to off, I never had an AM/PM appended to dateStr when I do: ``` NSLog(@"%@", dateStr); ``` Are you doing anything else with dateStr that you didn't post here? How are you checking the value? **Follow up** > > T...
143,084
<p>Let's say I have one class <code>Foo</code> that has a bunch of logic in it and another class <code>Bar</code> which is essentially the same. However, as <code>Foo</code> and <code>Bar</code> are different (but related) entities I need the difference to be apparent from my code (i.e. I can tell whether an instance i...
[ { "answer_id": 143091, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": true, "text": "<p>In my opinion, it's best if <code>Foo</code> and <code>Bar</code> subclass off a common ancestor class (maybe <code>Abstra...
2008/09/27
[ "https://Stackoverflow.com/questions/143084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
Let's say I have one class `Foo` that has a bunch of logic in it and another class `Bar` which is essentially the same. However, as `Foo` and `Bar` are different (but related) entities I need the difference to be apparent from my code (i.e. I can tell whether an instance is a `Foo` or a `Bar`) As I was whacking this t...
In my opinion, it's best if `Foo` and `Bar` subclass off a common ancestor class (maybe `AbstractFoo`), which has all the functionality. What difference in behaviour should exist between `Foo` and `Bar`? Code that difference as an abstract method in `AbstractFoo`, not by using a `if` statement in your code. Example: R...
143,122
<p>Is it possible to use PHP's SimpleXML functions to create an XML object from scratch? Looking through the function list, there's ways to import an existing XML string into an object that you can then manipulate, but if I just want to generate an XML object programmatically from scratch, what's the best way to do th...
[ { "answer_id": 143192, "author": "DreamWerx", "author_id": 15487, "author_profile": "https://Stackoverflow.com/users/15487", "pm_score": 8, "selected": true, "text": "<p>Sure you can. Eg.</p>\n\n<pre><code>&lt;?php\n$newsXML = new SimpleXMLElement(\"&lt;news&gt;&lt;/news&gt;\");\n$newsX...
2008/09/27
[ "https://Stackoverflow.com/questions/143122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20903/" ]
Is it possible to use PHP's SimpleXML functions to create an XML object from scratch? Looking through the function list, there's ways to import an existing XML string into an object that you can then manipulate, but if I just want to generate an XML object programmatically from scratch, what's the best way to do that? ...
Sure you can. Eg. ``` <?php $newsXML = new SimpleXMLElement("<news></news>"); $newsXML->addAttribute('newsPagePrefix', 'value goes here'); $newsIntro = $newsXML->addChild('content'); $newsIntro->addAttribute('type', 'latest'); Header('Content-type: text/xml'); echo $newsXML->asXML(); ?> ``` Output ``` <?xml version...
143,123
<p>Using C / C++ socket programming, and the "read(socket, buffer, BUFSIZE)" method. What exactly is the "buffer" I know that char and byte are the same thing, but does it matter how many elements the byte array has in it? Does the buffer need to be able to hold the entire message until the null character?</p>
[ { "answer_id": 143127, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 5, "selected": true, "text": "<p>BUFSIZE should be equal to the size of your buffer in bytes. read() will stop reading when the buffer is full. Here is...
2008/09/27
[ "https://Stackoverflow.com/questions/143123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3484/" ]
Using C / C++ socket programming, and the "read(socket, buffer, BUFSIZE)" method. What exactly is the "buffer" I know that char and byte are the same thing, but does it matter how many elements the byte array has in it? Does the buffer need to be able to hold the entire message until the null character?
BUFSIZE should be equal to the size of your buffer in bytes. read() will stop reading when the buffer is full. Here is an example: ``` #define MY_BUFFER_SIZE 1024 char mybuffer[MY_BUFFER_SIZE]; int nBytes = read(sck, mybuffer, MY_BUFFER_SIZE); ```
143,171
<p>I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together <code>find</code> and <code>grep</code> with <code>xargs</code>, I get the following error:</p> <pre><code>find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar xa...
[ { "answer_id": 143172, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 7, "selected": false, "text": "<p><code>find . -print0 | grep --null 'FooBar' | xargs -0 ...</code></p>\n\n<p>I don't know about whether <code>grep</code> ...
2008/09/27
[ "https://Stackoverflow.com/questions/143171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17339/" ]
I'm trying to copy a bunch of files below a directory and a number of the files have spaces and single-quotes in their names. When I try to string together `find` and `grep` with `xargs`, I get the following error: ``` find .|grep "FooBar"|xargs -I{} cp "{}" ~/foo/bar xargs: unterminated quote ``` Any suggestions fo...
You can combine all of that into a single `find` command: ``` find . -iname "*foobar*" -exec cp -- "{}" ~/foo/bar \; ``` This will handle filenames and directories with spaces in them. You can use `-name` to get case-sensitive results. Note: The `--` flag passed to `cp` prevents it from processing files starting w...
143,174
<p>Is there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the current working directory. (Please don't suggest libraries unless they're standard ones like clib or STL.)</p> <p>(If there's no platform/file...
[ { "answer_id": 143177, "author": "Torbjörn Gyllebring", "author_id": 21182, "author_profile": "https://Stackoverflow.com/users/21182", "pm_score": 3, "selected": false, "text": "<p>For Win32 <a href=\"http://msdn.microsoft.com/en-us/library/aa364934(VS.85).aspx\" rel=\"noreferrer\">GetCu...
2008/09/27
[ "https://Stackoverflow.com/questions/143174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1630/" ]
Is there a platform-agnostic and filesystem-agnostic method to obtain the full path of the directory from where a program is running using C/C++? Not to be confused with the current working directory. (Please don't suggest libraries unless they're standard ones like clib or STL.) (If there's no platform/filesystem-agn...
Here's code to get the full path to the executing app: Variable declarations: ``` char pBuf[256]; size_t len = sizeof(pBuf); ``` Windows: ``` int bytes = GetModuleFileName(NULL, pBuf, len); return bytes ? bytes : -1; ``` Linux: ``` int bytes = MIN(readlink("/proc/self/exe", pBuf, len), len - 1); if(bytes >= 0)...
143,181
<p>If you have a project, that releases a library and an application, how you handle version-numbers between the two.</p> <p>Example: Your project delivers a library, that convert different file-formats into each other. The library is released for inclusion into other applications. But you also release a command-line-...
[ { "answer_id": 143185, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 2, "selected": false, "text": "<p>Completely independent version numbers, but the command line (or any other dependent) app should say which versio...
2008/09/27
[ "https://Stackoverflow.com/questions/143181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
If you have a project, that releases a library and an application, how you handle version-numbers between the two. Example: Your project delivers a library, that convert different file-formats into each other. The library is released for inclusion into other applications. But you also release a command-line-applicatio...
I'd say use separate version numbers, and of course document what minimum library version is required for each release of the app. If they always have the same version number, and you only ever test the app against the equal-numbered library version, then they aren't really separate components, so don't say they are. R...
143,194
<p>I have a pretty complicated Linq query that I can't seem to get into a LinqDataSsource for use in a GridView:</p> <pre><code>IEnumerable&lt;ticket&gt; tikPart = ( from p in db.comments where p.submitter == me.id &amp;&amp; p.ticket.closed == DateTime.Parse("1/1/2001") &amp;&amp; p.tic...
[ { "answer_id": 143195, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 2, "selected": false, "text": "<pre><code>gridview.DataSource = tikPart.ToList();\ngridview.DataBind();\n</code></pre>\n" }, { "answer_id": 143196...
2008/09/27
[ "https://Stackoverflow.com/questions/143194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14777/" ]
I have a pretty complicated Linq query that I can't seem to get into a LinqDataSsource for use in a GridView: ``` IEnumerable<ticket> tikPart = ( from p in db.comments where p.submitter == me.id && p.ticket.closed == DateTime.Parse("1/1/2001") && p.ticket.originating_group != me.sub_unit...
You can setup your Gridview with no Datasource. Setup the gridview columns, and in codebehind bind that result to the grid view.
143,206
<p>I want to obtain the current number of window handles and the system-wide window handle limit in C#. How do I go about this?</p>
[ { "answer_id": 143220, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 2, "selected": false, "text": "<p>As Raymond Chen put it some time ago, if you're thinking about window handle limits, you're probably doing somethin...
2008/09/27
[ "https://Stackoverflow.com/questions/143206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to obtain the current number of window handles and the system-wide window handle limit in C#. How do I go about this?
If you read Raymond Chen's post, you'll probably find it as annoying as I did. You're only "probably doing something wrong" because you're doing something Windows isn't capable of. In my application, the first time a user visits a tab page, I create and lay out all the controls on that page. This takes a noticeable a...
143,215
<p>I've been trying to display text using a Quartz context, but no matter what I've tried I simply haven't had luck getting the text to display (I'm able to display all sorts of other Quartz objects though). Anybody knows what I might be doing wrong?</p> <p>example:</p> <pre><code>-(void)drawRect:(CGRect)rect { ...
[ { "answer_id": 143352, "author": "Darron", "author_id": 22704, "author_profile": "https://Stackoverflow.com/users/22704", "pm_score": 4, "selected": true, "text": "<p>Here is a fragment of code that I'm using.</p>\n\n<pre><code>UIColor *mainTextColor = [UIColor whiteColor];\n[mainTextCol...
2008/09/27
[ "https://Stackoverflow.com/questions/143215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
I've been trying to display text using a Quartz context, but no matter what I've tried I simply haven't had luck getting the text to display (I'm able to display all sorts of other Quartz objects though). Anybody knows what I might be doing wrong? example: ``` -(void)drawRect:(CGRect)rect { // Drawing code CGC...
Here is a fragment of code that I'm using. ``` UIColor *mainTextColor = [UIColor whiteColor]; [mainTextColor set]; drawTextLjust(@"Sample Text", 8, 50, 185, 18, 16); ``` And: ``` static void drawTextLjust(NSString* text, CGFloat y, CGFloat left, CGFloat right, int maxFontSize, int minFontS...
143,226
<p>let's assume i have a self referencing hierarchical table build the classical way like this one:</p> <pre><code>CREATE TABLE test (name text,id serial primary key,parent_id integer references test); insert into test (name,id,parent_id) values ('root1',1,NULL),('root2',2,NULL),('root1sub1',3,1),('root1sub2',4,1),('...
[ { "answer_id": 143313, "author": "njr101", "author_id": 9625, "author_profile": "https://Stackoverflow.com/users/9625", "pm_score": 3, "selected": false, "text": "<p>Pulling this result in recursively is tricky (although possible). However, it's typically not very efficient and there is ...
2008/09/27
[ "https://Stackoverflow.com/questions/143226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
let's assume i have a self referencing hierarchical table build the classical way like this one: ``` CREATE TABLE test (name text,id serial primary key,parent_id integer references test); insert into test (name,id,parent_id) values ('root1',1,NULL),('root2',2,NULL),('root1sub1',3,1),('root1sub2',4,1),('root 2sub1',5,...
Pulling this result in recursively is tricky (although possible). However, it's typically not very efficient and there is a *much* better way to solve this problem. Basically, you augment the table with an extra column which traces the tree to the top - I'll call it the "Upchain". It's just a long string that looks so...
143,234
<p>In Lua, using the = operator without an l-value seems to be equivalent to a print(r-value), here are a few examples run in the Lua standalone interpreter:</p> <pre><code>&gt; = a nil &gt; a = 8 &gt; = a 8 &gt; = 'hello' hello &gt; = print function: 003657C8 </code></pre> <p>And so on...</p> <p>My question is : wh...
[ { "answer_id": 143252, "author": "Arle Nadja", "author_id": 17774, "author_profile": "https://Stackoverflow.com/users/17774", "pm_score": 2, "selected": false, "text": "<p>I think that must be a feature of the stand alone interpreter. I can't make that work on anything I have compiled lu...
2008/09/27
[ "https://Stackoverflow.com/questions/143234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12291/" ]
In Lua, using the = operator without an l-value seems to be equivalent to a print(r-value), here are a few examples run in the Lua standalone interpreter: ``` > = a nil > a = 8 > = a 8 > = 'hello' hello > = print function: 003657C8 ``` And so on... My question is : where can I find a detailed description of this us...
Quoting the [man page](http://www.lua.org/manual/5.1/lua.html): > > In interactive mode ... If a line starts with '=', then lua displays the values of all the expressions in the remainder of the line. The expressions must be separated by commas. > > >
143,285
<p>For example if I have an Enum with two cases, does it make take more memory than a boolean? Languages: Java, C++</p>
[ { "answer_id": 143291, "author": "Serafina Brocious", "author_id": 4977, "author_profile": "https://Stackoverflow.com/users/4977", "pm_score": 0, "selected": false, "text": "<p>No, an enum is generally the same size as an int, same as boolean.</p>\n" }, { "answer_id": 143298, ...
2008/09/27
[ "https://Stackoverflow.com/questions/143285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
For example if I have an Enum with two cases, does it make take more memory than a boolean? Languages: Java, C++
In Java, an [`enum` is a full-blown class](http://download.oracle.com/javase/tutorial/java/javaOO/enum.html): > > Java programming language enum types > are much more powerful than their > counterparts in other languages. The > enum declaration defines a class > (called an enum type). The enum class > body can i...
143,296
<p>I've got such a simple code:</p> <pre><code>&lt;div class="div1"&gt; &lt;div class="div2"&gt;Foo&lt;/div&gt; &lt;div class="div3"&gt; &lt;div class="div4"&gt; &lt;div class="div5"&gt; Bar &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and this CSS:</p...
[ { "answer_id": 143309, "author": "Ross", "author_id": 2025, "author_profile": "https://Stackoverflow.com/users/2025", "pm_score": 0, "selected": false, "text": "<p>I found that this solution worked better and was a bit cleaner:</p>\n\n<pre><code> &lt;style type=\"text/css\"&gt;\n ...
2008/09/27
[ "https://Stackoverflow.com/questions/143296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20403/" ]
I've got such a simple code: ``` <div class="div1"> <div class="div2">Foo</div> <div class="div3"> <div class="div4"> <div class="div5"> Bar </div> </div> </div> </div> ``` and this CSS: ```css .div1{ position: relative; } .div1 .div3 { position: absolute; top: 30px; ...
IE7 won't allow you to apply `:hover` pseudo-classes to non-anchor elements unless you explicitly specify a doctype. Just add a doctype declaration to your page and it should work perfectly. ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> ``` More on IE7/quirks mode...
143,365
<p>I have a flash application running Flash 9 (CS3). Application is able to control the Softkeys when this flash application is loaded in the supported mobile device. But, the application doesn't have control when the same is embedded in HTML page and browsed via supported mobile device. Any ideas how to make this w...
[ { "answer_id": 144130, "author": "fenomas", "author_id": 10651, "author_profile": "https://Stackoverflow.com/users/10651", "pm_score": 1, "selected": false, "text": "<p>There is no special way to receive soft key events when embedded in HTML - if the browser/OS gives the events to Flash,...
2008/09/27
[ "https://Stackoverflow.com/questions/143365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a flash application running Flash 9 (CS3). Application is able to control the Softkeys when this flash application is loaded in the supported mobile device. But, the application doesn't have control when the same is embedded in HTML page and browsed via supported mobile device. Any ideas how to make this work? ...
There is no special way to receive soft key events when embedded in HTML - if the browser/OS gives the events to Flash, then you can catch them like any other key event: ``` var myListener = new Object(); myListener.onKeyDown = function() { var code = Key.getCode(); if (code==ExtendedKey.SOFT1) { trace...
143,374
<p>A long time ago I had an apple ][ . </p> <p>I remember the command call – 151 But I can not remember what it did ? </p>
[ { "answer_id": 143383, "author": "Kev", "author_id": 419, "author_profile": "https://Stackoverflow.com/users/419", "pm_score": 6, "selected": true, "text": "<p>CALL -151</p>\n\n<p>Enter the machine code monitor -</p>\n\n<p><a href=\"http://www.skepticfiles.org/cowtext/apple/memorytx.htm\...
2008/09/27
[ "https://Stackoverflow.com/questions/143374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
A long time ago I had an apple ][ . I remember the command call – 151 But I can not remember what it did ?
CALL -151 Enter the machine code monitor - <http://www.skepticfiles.org/cowtext/apple/memorytx.htm> **Update:** That link appears to be dead, here's a Wayback Machine alternative: > > <http://web.archive.org/web/20090315100335/http://www.skepticfiles.org/cowtext/apple/memorytx.htm> > > > Here's the full artic...
143,405
<p>What are the differences in implementing interfaces <strong>implicitly</strong> and <strong>explicitly</strong> in C#?</p> <p>When should you use implicit and when should you use explicit?</p> <p>Are there any pros and/or cons to one or the other?</p> <hr> <p>Microsoft's official guidelines (from first edition <...
[ { "answer_id": 143423, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 10, "selected": true, "text": "<p><strong>Implicit</strong> is when you define your interface via a member on your class. <strong>Explicit</strong> is w...
2008/09/27
[ "https://Stackoverflow.com/questions/143405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
What are the differences in implementing interfaces **implicitly** and **explicitly** in C#? When should you use implicit and when should you use explicit? Are there any pros and/or cons to one or the other? --- Microsoft's official guidelines (from first edition [Framework Design Guidelines](https://rads.stackover...
**Implicit** is when you define your interface via a member on your class. **Explicit** is when you define methods within your class on the interface. I know that sounds confusing but here is what I mean: `IList.CopyTo` would be implicitly implemented as: ``` public void CopyTo(Array array, int index) { throw new ...
143,429
<p>We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so.</p> <p>However, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes or vented frustraton, I'm talki...
[ { "answer_id": 143439, "author": "Rich Bradshaw", "author_id": 16511, "author_profile": "https://Stackoverflow.com/users/16511", "pm_score": 8, "selected": true, "text": "<p>Just the typical Comp Sci 101 type comments:</p>\n\n<pre><code>$i = 0; //set i to 0\n\n$i++; //use sneaky trick to...
2008/09/27
[ "https://Stackoverflow.com/questions/143429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21632/" ]
We all know that commenting our code is an important part of coding style for making our code understandable to the next person who comes along, or even ourselves in 6 months or so. However, sometimes a comment just doesn't cut the mustard. I'm not talking about obvious jokes or vented frustraton, I'm talking about co...
Just the typical Comp Sci 101 type comments: ``` $i = 0; //set i to 0 $i++; //use sneaky trick to add 1 to i! if ($i==$j) { // I made sure to use == rather than = here to avoid a bug ``` That sort of thing.
143,484
<p>I want to change the title showing in a page based on information I pick up from within the page (eg to show the number of inbox messages)</p> <p><code>document.getElementsByTagName('title')[0].innerHTML="foo";</code> does change the title tag, but firefox does not update the displayed title (in window and tags) wh...
[ { "answer_id": 143494, "author": "Vhaerun", "author_id": 11234, "author_profile": "https://Stackoverflow.com/users/11234", "pm_score": 5, "selected": true, "text": "<p>Try using this instead: </p>\n\n<pre>\ndocument.title = \"MyTitle\";\n</pre>\n" }, { "answer_id": 143502, "a...
2008/09/27
[ "https://Stackoverflow.com/questions/143484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7473/" ]
I want to change the title showing in a page based on information I pick up from within the page (eg to show the number of inbox messages) `document.getElementsByTagName('title')[0].innerHTML="foo";` does change the title tag, but firefox does not update the displayed title (in window and tags) when this happens. Is...
Try using this instead: ``` document.title = "MyTitle"; ```
143,552
<p>In MySQL, If I have a list of date ranges (range-start and range-end). e.g.</p> <pre><code>10/06/1983 to 14/06/1983 15/07/1983 to 16/07/1983 18/07/1983 to 18/07/1983 </code></pre> <p>And I want to check if another date range contains ANY of the ranges already in the list, how would I do that?</p> <p>e.g.</p> <pr...
[ { "answer_id": 143568, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 10, "selected": true, "text": "\n\n<p>This is a classical problem, and it's actually easier if you reverse the logic.</p>\n\n<p>Let me give you an e...
2008/09/27
[ "https://Stackoverflow.com/questions/143552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5777/" ]
In MySQL, If I have a list of date ranges (range-start and range-end). e.g. ``` 10/06/1983 to 14/06/1983 15/07/1983 to 16/07/1983 18/07/1983 to 18/07/1983 ``` And I want to check if another date range contains ANY of the ranges already in the list, how would I do that? e.g. ``` 06/06/1983 to 18/06/1983 = IN LIST 1...
This is a classical problem, and it's actually easier if you reverse the logic. Let me give you an example. I'll post one period of time here, and all the different variations of other periods that overlap in some way. ```none |-------------------| compare to this one |---------| ...
143,554
<p>I have written a ruby script which opens up dlink admin page in firefox and does a ADSL connection or disconnection.</p> <p>I could run this script in the terminal without any problem. But if I put it as cron job, it doesn't fire up firefox.</p> <p>This is the entry I have in <em>crontab</em></p> <pre><code># con...
[ { "answer_id": 143596, "author": "mana", "author_id": 12016, "author_profile": "https://Stackoverflow.com/users/12016", "pm_score": 0, "selected": false, "text": "<p>the crontab entry is wrong</p>\n\n<p>it is like</p>\n\n<pre><code>#min hour day month dow user command...
2008/09/27
[ "https://Stackoverflow.com/questions/143554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15139/" ]
I have written a ruby script which opens up dlink admin page in firefox and does a ADSL connection or disconnection. I could run this script in the terminal without any problem. But if I put it as cron job, it doesn't fire up firefox. This is the entry I have in *crontab* ``` # connect to dataone 55 17 * * * ruby /h...
You need to have a DISPLAY environment pointing at a valid X-server. This could either involve setting it to the value ":0.0" (without quotes), such that it refers to your local standard DISPLAY. There's a few things to keep in mind though: You could run an X virtual frame buffer (xvfb), so that Firefox simply uses t...
143,571
<p>I'm building my first ASP.NET MVC application and I am having some troubles with Partial Views.</p> <p>If I, as an example, want to put a "Footer" as a Partial I create an "MVC View User Control" in "/Views/Shared/Footer.ascx". (I leave it empty for now)</p> <p>What is the correct way for adding it to my Layout? <...
[ { "answer_id": 143576, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 6, "selected": true, "text": "<p>In this case don't use the &lt;%= syntax. Just use the &lt;% %> syntax. Then the first form in your examples shoul...
2008/09/27
[ "https://Stackoverflow.com/questions/143571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm building my first ASP.NET MVC application and I am having some troubles with Partial Views. If I, as an example, want to put a "Footer" as a Partial I create an "MVC View User Control" in "/Views/Shared/Footer.ascx". (I leave it empty for now) What is the correct way for adding it to my Layout? I have tried: `...
In this case don't use the <%= syntax. Just use the <% %> syntax. Then the first form in your examples should work. For more info, check here: <http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html>
143,622
<p>This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below?</p> <pre><code>try { // Do something } catch(IOE...
[ { "answer_id": 143628, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 9, "selected": true, "text": "<p>No, since the new <code>throw</code> is not in the <code>try</code> block directly.</p>\n" }, { "answer_id": 14363...
2008/09/27
[ "https://Stackoverflow.com/questions/143622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270/" ]
This may seem like a programming 101 question and I had thought I knew the answer but now find myself needing to double check. In this piece of code below, will the exception thrown in the first catch block then be caught by the general Exception catch block below? ``` try { // Do something } catch(IOException e) { ...
No, since the new `throw` is not in the `try` block directly.
143,680
<p>It seems that most of the installers for Perl are centered around installing Perl modules, not applications. Things like ExtUtils::MakeMaker and Module::Build are very well suited for modules, but require some additional work for Web Apps.</p> <p>Ideally it would be nice to be able to do the following after checki...
[ { "answer_id": 143754, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 2, "selected": false, "text": "<p>I'd recommend seriously considering a package system such as RPM to do this. Even if you're running on Windows I'd co...
2008/09/27
[ "https://Stackoverflow.com/questions/143680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21632/" ]
It seems that most of the installers for Perl are centered around installing Perl modules, not applications. Things like ExtUtils::MakeMaker and Module::Build are very well suited for modules, but require some additional work for Web Apps. Ideally it would be nice to be able to do the following after checking out the ...
What are your limitations for installing web apps? Can you log into the machine? Are all of the machines running the same thing? Are the people installing the web apps co-workers or random people from the general public? Are the people installing this sysadmins, programmers, web managers, or something else? Do you inst...
143,712
<p>Is there a way of comparing two bitmasks in Transact-SQL to see if any of the bits match? I've got a User table with a bitmask for all the roles the user belongs to, and I'd like to select all the users that have <em>any</em> of the roles in the supplied bitmask. So using the data below, a roles bitmask of 6 (design...
[ { "answer_id": 143716, "author": "Diomidis Spinellis", "author_id": 20520, "author_profile": "https://Stackoverflow.com/users/20520", "pm_score": 3, "selected": false, "text": "<p>Use the Transact-SQL <a href=\"http://msdn.microsoft.com/en-us/library/ms174965.aspx\" rel=\"nofollow norefe...
2008/09/27
[ "https://Stackoverflow.com/questions/143712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14072/" ]
Is there a way of comparing two bitmasks in Transact-SQL to see if any of the bits match? I've got a User table with a bitmask for all the roles the user belongs to, and I'd like to select all the users that have *any* of the roles in the supplied bitmask. So using the data below, a roles bitmask of 6 (designer+program...
The answer to your question is to use the Bitwise `&` like this: ``` SELECT * FROM UserTable WHERE Roles & 6 != 0 ``` The `6` can be exchanged for any combination of your bitfield where you want to check that any user has one or more of those bits. When trying to validate this I usually find it helpful to write this...
143,736
<p>I have a simple message box in a WPF application that is launched as below:</p> <pre><code>private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Howdy", "Howdy"); } </code></pre> <p>I can get <a href="http://www.codeplex.com/white" rel="nofollow noreferrer" title="white">white</a> to cl...
[ { "answer_id": 143766, "author": "Brownie", "author_id": 6600, "author_profile": "https://Stackoverflow.com/users/6600", "pm_score": 3, "selected": true, "text": "<p>Found it! The window class has a MessageBox method that does the trick:</p>\n\n<pre><code> var app = Application.La...
2008/09/27
[ "https://Stackoverflow.com/questions/143736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6600/" ]
I have a simple message box in a WPF application that is launched as below: ``` private void Button_Click(object sender, RoutedEventArgs e) { MessageBox.Show("Howdy", "Howdy"); } ``` I can get [white](http://www.codeplex.com/white "white") to click my button and launch the message box. UISpy shows it as a child...
Found it! The window class has a MessageBox method that does the trick: ``` var app = Application.Launch(@"c:\ApplicationPath.exe"); var window = app.GetWindow("Window1"); var helloButton = window.Get<Button>("Hello"); Assert.IsNotNull(helloButton); helloButton.Click(); ...
143,739
<p>How do you do your own fonts? I don't want a heavyweight algorithm (freetype, truetype, adobe, etc) and would be fine with pre-rendered bitmap fonts.</p> <p>I do want anti-aliasing, and would like proportional fonts if possible.</p> <p>I've heard I can use Gimp to do the rendering (with some post processing?)</p>...
[ { "answer_id": 143810, "author": "SteinNorheim", "author_id": 19220, "author_profile": "https://Stackoverflow.com/users/19220", "pm_score": 3, "selected": true, "text": "<p>In my old demo-scene days I often drew all characters in the font in one big bitmap image. In the code, I stored th...
2008/09/27
[ "https://Stackoverflow.com/questions/143739", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2915/" ]
How do you do your own fonts? I don't want a heavyweight algorithm (freetype, truetype, adobe, etc) and would be fine with pre-rendered bitmap fonts. I do want anti-aliasing, and would like proportional fonts if possible. I've heard I can use Gimp to do the rendering (with some post processing?) I'm developing for a...
In my old demo-scene days I often drew all characters in the font in one big bitmap image. In the code, I stored the (X,Y) coordinates of each character in the font, as well as the width of each character. The height was usually constant throughout the font. If space isn't an issue, you can put all characters in a grid...
143,746
<p>I know most people think that as a <em>bad practice</em> but when you are trying to make your class public interface only work with references, keeping pointers inside and only when necessary, I think there is no way to return something telling that the value you are looking doesn't exist in the container.</p> <pre...
[ { "answer_id": 143758, "author": "MidnightGun", "author_id": 13220, "author_profile": "https://Stackoverflow.com/users/13220", "pm_score": -1, "selected": false, "text": "<p>Interesting question. It's a problem in C++ to exclusively use references I guess - in Java the references are mor...
2008/09/27
[ "https://Stackoverflow.com/questions/143746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18623/" ]
I know most people think that as a *bad practice* but when you are trying to make your class public interface only work with references, keeping pointers inside and only when necessary, I think there is no way to return something telling that the value you are looking doesn't exist in the container. ``` class list { ...
The STL deals with this situation by using iterators. For example, the std::map class has a similar function: ``` iterator find( const key_type& key ); ``` If the key isn't found, it returns 'end()'. You may want to use this iterator approach, or to use some sort of wrapper for your return value.
143,747
<p>I'm writing some JavaScript code that needs to fire the <code>click</code> event for a link. In Internet Explorer I can do this </p> <pre><code>var button = document.getElementById('myButton'); button.click(); </code></pre> <p>But this doesn't work in Firefox, and I assume any other browser. In Firefox, I've done...
[ { "answer_id": 143755, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 1, "selected": false, "text": "<p>It's not generally possible, afaik, mozilla has the <a href=\"http://developer.mozilla.org/En/DOM:element.click#1...
2008/09/27
[ "https://Stackoverflow.com/questions/143747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
I'm writing some JavaScript code that needs to fire the `click` event for a link. In Internet Explorer I can do this ``` var button = document.getElementById('myButton'); button.click(); ``` But this doesn't work in Firefox, and I assume any other browser. In Firefox, I've done this ``` var button = document.getE...
<http://jehiah.cz/archive/firing-javascript-events-properly> ``` function fireEvent(element,event) { if (document.createEvent) { // dispatch for firefox + others var evt = document.createEvent("HTMLEvents"); evt.initEvent(event, true, true ); // event type,bubbling,cancelable return !ele...
143,756
<p>I need to rename the database but when I do in <code>PGAdmin : ALTER DATABASE "databaseName" RENAME TO "databaseNameOld"</code> it told me that it cannot.</p> <p>How can I do it?</p> <p>(<strong>Version 8.3 on WindowsXP</strong>)</p> <p><strong>Update</strong></p> <ul> <li><p>The first error message : Cannot be...
[ { "answer_id": 143764, "author": "bmdhacks", "author_id": 14032, "author_profile": "https://Stackoverflow.com/users/14032", "pm_score": 8, "selected": false, "text": "<p>Try not quoting the database name:</p>\n\n<pre><code>ALTER DATABASE people RENAME TO customers;\n</code></pre>\n\n<p>A...
2008/09/27
[ "https://Stackoverflow.com/questions/143756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13913/" ]
I need to rename the database but when I do in `PGAdmin : ALTER DATABASE "databaseName" RENAME TO "databaseNameOld"` it told me that it cannot. How can I do it? (**Version 8.3 on WindowsXP**) **Update** * The first error message : Cannot because I was connect to it. So I selected an other database and did the quer...
Try not quoting the database name: ``` ALTER DATABASE people RENAME TO customers; ``` Also ensure that there are no other clients connected to the database at the time. Lastly, try posting the error message it returns so we can get a bit more information.
143,814
<p>In an ideal world, our development processes would be perfect, resulting in regular releases that were so thoroughly tested that it would never be necessary to "hotfix" a running application.</p> <p>But, unfortunately, we live in the real world, and sometimes bugs slip past us and don't rear their ugly heads until ...
[ { "answer_id": 143851, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 2, "selected": false, "text": "<p>[Even though we test a lot before we release, ] What we do is this:</p>\n<p>Our SVN looks like this:</p>\n<pre><code>/repo/t...
2008/09/27
[ "https://Stackoverflow.com/questions/143814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1219/" ]
In an ideal world, our development processes would be perfect, resulting in regular releases that were so thoroughly tested that it would never be necessary to "hotfix" a running application. But, unfortunately, we live in the real world, and sometimes bugs slip past us and don't rear their ugly heads until we're alre...
[Even though we test a lot before we release, ] What we do is this: Our SVN looks like this: ``` /repo/trunk/ /repo/tags/1.1 /repo/tags/1.2 /repo/tags/1.3 ``` Now whenever we release, we create a tag which we eventually check out in production. Before we do production, we do staging which is [less servers but] pret...
143,815
<p>Can I use JavaScript to check (irrespective of scrollbars) if an HTML element has overflowed its content? For example, a long div with small, fixed size, the overflow property set to visible, and no scrollbars on the element.</p>
[ { "answer_id": 143833, "author": "Chris MacDonald", "author_id": 18146, "author_profile": "https://Stackoverflow.com/users/18146", "pm_score": 4, "selected": false, "text": "<p>Try comparing <code>element.scrollHeight</code> / <code>element.scrollWidth</code> to <code>element.offsetHeigh...
2008/09/27
[ "https://Stackoverflow.com/questions/143815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can I use JavaScript to check (irrespective of scrollbars) if an HTML element has overflowed its content? For example, a long div with small, fixed size, the overflow property set to visible, and no scrollbars on the element.
Normally, you can compare the `client[Height|Width]` with `scroll[Height|Width]` in order to detect this... but the values will be the same when overflow is visible. So, a detection routine must account for this: ``` // Determines if the passed element is overflowing its bounds, // either vertically or horizontally. /...
143,822
<p>this wiki page gave a general idea of how to convert a single char to ascii <a href="http://en.wikibooks.org/wiki/Ruby_Programming/ASCII" rel="noreferrer">http://en.wikibooks.org/wiki/Ruby_Programming/ASCII</a></p> <p>But say if I have a string and I wanted to get each character's ascii from it, what do i need to d...
[ { "answer_id": 143834, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "<p>The <code>c</code> variable already contains the char code!</p>\n\n<pre><code>\"string\".each_byte do |c|\n puts...
2008/09/27
[ "https://Stackoverflow.com/questions/143822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2668/" ]
this wiki page gave a general idea of how to convert a single char to ascii <http://en.wikibooks.org/wiki/Ruby_Programming/ASCII> But say if I have a string and I wanted to get each character's ascii from it, what do i need to do? ``` "string".each_byte do |c| $char = c.chr $ascii = ?char puts $asci...
The `c` variable already contains the char code! ``` "string".each_byte do |c| puts c end ``` yields ``` 115 116 114 105 110 103 ```
143,847
<p>What is the best way to find if an object is in an array?</p> <p>This is the best way I know:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function include(arr, obj) ...
[ { "answer_id": 143863, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 11, "selected": true, "text": "<p>As of ECMAScript 2016 you can use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glo...
2008/09/27
[ "https://Stackoverflow.com/questions/143847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17533/" ]
What is the best way to find if an object is in an array? This is the best way I know: ```js function include(arr, obj) { for (var i = 0; i < arr.length; i++) { if (arr[i] == obj) return true; } } console.log(include([1, 2, 3, 4], 3)); // true console.log(include([1, 2, 3, 4], 6)); // undefined ```
As of ECMAScript 2016 you can use [`includes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) ``` arr.includes(obj); ``` If you want to support IE or other older browsers: ``` function include(arr,obj) { return (arr.indexOf(obj) != -1); } ``` EDIT: This will...
143,850
<p>let's say we have a c++ class like:</p> <pre><code>class MyClass { void processArray( &lt;an array of 255 integers&gt; ) { int i ; for (i=0;i&lt;255;i++) { // do something with values in the array } } } </code></pre> <p>and one instance of the class like: </p> <pre><code>MyCl...
[ { "answer_id": 143853, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 5, "selected": true, "text": "<p><code>i</code> is allocated on the stack. Since each thread has its own separate stack, each thread gets its own ...
2008/09/27
[ "https://Stackoverflow.com/questions/143850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23000/" ]
let's say we have a c++ class like: ``` class MyClass { void processArray( <an array of 255 integers> ) { int i ; for (i=0;i<255;i++) { // do something with values in the array } } } ``` and one instance of the class like: ``` MyClass myInstance ; ``` and 2 threads which call...
`i` is allocated on the stack. Since each thread has its own separate stack, each thread gets its own copy of `i`.
143,925
<p>I want to be able to run a single spec file's tests &mdash; for the one file I'm editing, for example. <code>rake spec</code> executes all the specs. My project is not a Rails project, so <code>rake spec:doc</code> doesn't work.</p> <p>Don't know if this matters, but here is my directory structure.</p> <pre> ./R...
[ { "answer_id": 143934, "author": "mislav", "author_id": 11687, "author_profile": "https://Stackoverflow.com/users/11687", "pm_score": 8, "selected": false, "text": "<p>The raw invocation:</p>\n\n<pre>\nrake spec SPEC=spec/controllers/sessions_controller_spec.rb \\\n SPEC_OPTS=\"...
2008/09/27
[ "https://Stackoverflow.com/questions/143925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12887/" ]
I want to be able to run a single spec file's tests — for the one file I'm editing, for example. `rake spec` executes all the specs. My project is not a Rails project, so `rake spec:doc` doesn't work. Don't know if this matters, but here is my directory structure. ``` ./Rakefile ./lib ./lib/cushion.rb ./lib/cushion ...
Or you can skip rake and use the 'rspec' command: ``` bundle exec rspec path/to/spec/file.rb ``` In your case I think as long as your ./spec/db\_spec.rb file includes the appropriate helpers, it should work fine. If you're using an older version of rspec it is: ``` bundle exec spec path/to/spec/file.rb ```
143,938
<p>I'm writing a Delphi expert. I need to be able to write a value to a property on a property which is an object. E.g. I have a GroupBox on the form and I want to edit the Margins.Left property. I'm using the following procedure to do it but if gives an AV on the marked line.</p> <p>The procedure takes a component fr...
[ { "answer_id": 143952, "author": "roryf", "author_id": 270, "author_profile": "https://Stackoverflow.com/users/270", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://www.phpmyadmin.net/home_page/index.php\" rel=\"nofollow noreferrer\">phpMyAdmin</a> is a good favourite if y...
2008/09/27
[ "https://Stackoverflow.com/questions/143938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23008/" ]
I'm writing a Delphi expert. I need to be able to write a value to a property on a property which is an object. E.g. I have a GroupBox on the form and I want to edit the Margins.Left property. I'm using the following procedure to do it but if gives an AV on the marked line. The procedure takes a component from the (pr...
If you want the database behind a firewall, and believe me, you do want your database behind a firewall, see if you can have a VPN for going directly into the box. Once you are on the VPN, you can use whichever management tool you currently use for managing the database. So if you use SQL Server, you can connect via th...
143,947
<p>More than about LINQ to [insert your favorite provider here], this question is about searching or filtering in-memory collections. </p> <p>I know LINQ (or searching/filtering extension methods) works in objects implementing <code>IEnumerable</code> or <code>IEnumerable&lt;T&gt;</code>. The question is: <em>because ...
[ { "answer_id": 144002, "author": "Sklivvz", "author_id": 7028, "author_profile": "https://Stackoverflow.com/users/7028", "pm_score": 2, "selected": false, "text": "<p>Yes, it has to be, because the only way of accessing any member of an <code>IEnumerable</code> is by using its methods, w...
2008/09/27
[ "https://Stackoverflow.com/questions/143947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18552/" ]
More than about LINQ to [insert your favorite provider here], this question is about searching or filtering in-memory collections. I know LINQ (or searching/filtering extension methods) works in objects implementing `IEnumerable` or `IEnumerable<T>`. The question is: *because of the nature of enumeration, is every qu...
Even with parallelisation, it's still O(n). The constant factor would be different (depending on your number of cores) but as n varied the total time would still vary linearly. Of course, you could write your own implementations of the various LINQ operators over your own data types, but they'd only be appropriate in ...
143,997
<p>In Jesse Liberty's Learning C# book, he says "Objects of one type can be converted into objects of another type. This is called casting."</p> <p>If you investigate the IL generated from the code below, you can clearly see that the casted assignment isn't doing the same thing as the converted assignment. In the form...
[ { "answer_id": 144003, "author": "Matt", "author_id": 13666, "author_profile": "https://Stackoverflow.com/users/13666", "pm_score": -1, "selected": false, "text": "<p>The difference there is whether the conversion is implicit or explicit. The first one up there is a cast, the second one...
2008/09/27
[ "https://Stackoverflow.com/questions/143997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536/" ]
In Jesse Liberty's Learning C# book, he says "Objects of one type can be converted into objects of another type. This is called casting." If you investigate the IL generated from the code below, you can clearly see that the casted assignment isn't doing the same thing as the converted assignment. In the former, you ca...
The simple answer is: it depends. For value types, casting will involve genuinely converting it to a different type. For instance: ``` float f = 1.5f; int i = (int) f; // Conversion ``` When the casting expression unboxes, the result (assuming it works) is *usually* just a copy of what was in the box, with the same...
144,046
<p>I am trying to find a better way to integrate IRB with my normal ruby devleopment. Currently I rarely use IRB with my code. I only use it to verify syntax or to try something small. </p> <p>I know I can load my own code into ruby as a</p> <pre><code>require 'mycode' </code></pre> <p>but this usually doesn't me...
[ { "answer_id": 144074, "author": "TonyLa", "author_id": 1295, "author_profile": "https://Stackoverflow.com/users/1295", "pm_score": 0, "selected": false, "text": "<p>I just use rdebug to debug any of my ruby or RoR code. </p>\n" }, { "answer_id": 144080, "author": "Cameron B...
2008/09/27
[ "https://Stackoverflow.com/questions/144046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22423/" ]
I am trying to find a better way to integrate IRB with my normal ruby devleopment. Currently I rarely use IRB with my code. I only use it to verify syntax or to try something small. I know I can load my own code into ruby as a ``` require 'mycode' ``` but this usually doesn't mesh with my programming style. Someti...
Install the ruby-debug gem. Of course, require it inside your app (only in development/test mode). Now you can write 'debugger' where you want to stop execution. Once your app stop at your breakpoint, you can type 'help' to know about all commands. One of them is 'irb'. It starts an IRB session in which you have acces...
144,058
<p>I just installed Ganymede and am exploring an old project in it. All of my JSPs are giving me weird validation errors. I'm seeing stuff like - </p> <pre><code>Syntax error on token "}", delete this token Syntax error on token "catch", Identifier expected Syntax error, insert "Finally" to complete TryStatement </cod...
[ { "answer_id": 144115, "author": "Jorn", "author_id": 8681, "author_profile": "https://Stackoverflow.com/users/8681", "pm_score": 2, "selected": false, "text": "<p>Under preferences -> editors -> file associations, you can see which editor(s) are associated with .jsp files. Perhaps it go...
2008/09/27
[ "https://Stackoverflow.com/questions/144058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
I just installed Ganymede and am exploring an old project in it. All of my JSPs are giving me weird validation errors. I'm seeing stuff like - ``` Syntax error on token "}", delete this token Syntax error on token "catch", Identifier expected Syntax error, insert "Finally" to complete TryStatement ``` I'm doing bes...
I have just downloaded Ganymede 3.4.2 and added WTP 3.0.4 to it and this error has gone for me.
144,088
<p>I'm playing with ASP.NET MVC for the last few days and was able to build a small site. Everything works great. </p> <p>Now, I need to pass the page's META tags (title, description, keywords, etc.) via the ViewData. (i'm using a master page).</p> <p>How you're dealing with this? Thank you in advance.</p>
[ { "answer_id": 144127, "author": "Ricky", "author_id": 653, "author_profile": "https://Stackoverflow.com/users/653", "pm_score": 5, "selected": true, "text": "<p>Here is how I am currently doing it...</p>\n\n<p>In the masterpage, I have a content place holder with a default title, descri...
2008/09/27
[ "https://Stackoverflow.com/questions/144088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19610/" ]
I'm playing with ASP.NET MVC for the last few days and was able to build a small site. Everything works great. Now, I need to pass the page's META tags (title, description, keywords, etc.) via the ViewData. (i'm using a master page). How you're dealing with this? Thank you in advance.
Here is how I am currently doing it... In the masterpage, I have a content place holder with a default title, description and keywords: ``` <head> <asp:ContentPlaceHolder ID="cphHead" runat="server"> <title>Default Title</title> <meta name="description" content="Default Description" /> <meta name="keyword...
144,109
<p>I'm just wondering what the optimal solution is here.</p> <p>Say I have a normalized database. The primary key of the whole system is a varchar. What I'm wondering is should I relate this varchar to an int for normalization or leave it? It's simpler to leave as a varchar, but it might be more optimal </p> <p>For i...
[ { "answer_id": 144148, "author": "Troels Arvin", "author_id": 4462, "author_profile": "https://Stackoverflow.com/users/4462", "pm_score": 4, "selected": true, "text": "<p>Can you really use names as primary keys? Isn't there a high risk of several people with the same name?</p>\n\n<p>If ...
2008/09/27
[ "https://Stackoverflow.com/questions/144109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7870/" ]
I'm just wondering what the optimal solution is here. Say I have a normalized database. The primary key of the whole system is a varchar. What I'm wondering is should I relate this varchar to an int for normalization or leave it? It's simpler to leave as a varchar, but it might be more optimal For instance I can hav...
Can you really use names as primary keys? Isn't there a high risk of several people with the same name? If you really are so lucky that your name attribute can be used as primary key, then - by all means - use that. Often, though, you will have to make something up, like a customer\_id, etc. And finally: "NAME" is a ...
144,118
<p>While trying to generate classes from a xsd, i got this error:</p> <pre><code>java.lang.IllegalArgumentException: Illegal class inheritance loop. Outer class OrderPropertyList may not subclass from inner class: OrderPropertyList </code></pre> <p>My xsd define a element to group a unbounded element like this:</p> ...
[ { "answer_id": 144155, "author": "David M. Karr", "author_id": 10508, "author_profile": "https://Stackoverflow.com/users/10508", "pm_score": 0, "selected": false, "text": "<p>I believe this is happening because it's likely that the generated Java class representing the sequence of \"orde...
2008/09/27
[ "https://Stackoverflow.com/questions/144118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21370/" ]
While trying to generate classes from a xsd, i got this error: ``` java.lang.IllegalArgumentException: Illegal class inheritance loop. Outer class OrderPropertyList may not subclass from inner class: OrderPropertyList ``` My xsd define a element to group a unbounded element like this: ``` <element minOccurs="0" ...
I believe what you need to to is set: ``` <jaxb:globalBindings localScoping="toplevel"/> ``` This will generate standalone classes instead of nested classes. Doing ``` <jaxb:bindings schemaLocation="../xsd/Schema.xsd" node="/xs:schema"> <jaxb:bindings node="//xs:element[@name='orderPropertyList']"> ...
144,147
<p>I have a sparse array in Jscript, with non-null elements occuring at both negative and positive indices. When I try to use a for in loop, it doesn't traverse the array from the lowest (negative) index to the highest positive index. Instead it returns the array in the order that I added the elements. Enumeration does...
[ { "answer_id": 144182, "author": "Ricky", "author_id": 653, "author_profile": "https://Stackoverflow.com/users/653", "pm_score": 4, "selected": true, "text": "<p>Technically, \"A\" isn't in the Array at all since you can't have a negative index. It is just a member of the arrName object....
2008/09/27
[ "https://Stackoverflow.com/questions/144147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a sparse array in Jscript, with non-null elements occuring at both negative and positive indices. When I try to use a for in loop, it doesn't traverse the array from the lowest (negative) index to the highest positive index. Instead it returns the array in the order that I added the elements. Enumeration doesn't...
Technically, "A" isn't in the Array at all since you can't have a negative index. It is just a member of the arrName object. If you check the arrName.length you will see that it is 21 (0,1,2,...,20) Why don't you use a plain object instead (as a hashtable). Something like this should work: ``` <script type="text/javas...
144,151
<p>My macro updates a large spreadsheet with numbers, but it runs very slowly as excel is rendering the result as it computes it. How do I stop excel from rendering the output until the macro is complete?</p>
[ { "answer_id": 144154, "author": "Rich Bradshaw", "author_id": 16511, "author_profile": "https://Stackoverflow.com/users/16511", "pm_score": 0, "selected": false, "text": "<p>You can turn off automatic calculation in the options dialog, it sets it so that it only calculates when you pres...
2008/09/27
[ "https://Stackoverflow.com/questions/144151", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5472/" ]
My macro updates a large spreadsheet with numbers, but it runs very slowly as excel is rendering the result as it computes it. How do I stop excel from rendering the output until the macro is complete?
I use both of the proposed solutions: ``` Application.ScreenUpdating = False Application.Calculation = xlCalculationManual ... ... ... Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True ```
144,167
<p>I am using Oracle SQL (in SQLDeveloper, so I don't have access to SQLPLUS commands such as COLUMN) to execute a query that looks something like this:</p> <pre><code>select assigner_staff_id as staff_id, active_flag, assign_date, complete_date, mod_date from work where assigner_staff_id = '2096'; </code></pre> <p...
[ { "answer_id": 144187, "author": "Thomas Jones-Low", "author_id": 23030, "author_profile": "https://Stackoverflow.com/users/23030", "pm_score": 3, "selected": true, "text": "<p>What are you using to get the results? The output you pasted looks like it's coming from SQL*PLUS. It may be th...
2008/09/27
[ "https://Stackoverflow.com/questions/144167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13140/" ]
I am using Oracle SQL (in SQLDeveloper, so I don't have access to SQLPLUS commands such as COLUMN) to execute a query that looks something like this: ``` select assigner_staff_id as staff_id, active_flag, assign_date, complete_date, mod_date from work where assigner_staff_id = '2096'; ``` The results it give me lo...
What are you using to get the results? The output you pasted looks like it's coming from SQL\*PLUS. It may be that whatever tool you are using to generate the results has some method of modifying the output. By default Oracle outputs columns based upon the width of the title or the width of the column data which ever...
144,176
<p>I need to convert a (possibly) null terminated array of ascii bytes to a string in C# and the fastest way I've found to do it is by using my UnsafeAsciiBytesToString method shown below. This method uses the String.String(sbyte*) constructor which contains a warning in it's remarks:</p> <p>"The value parameter is as...
[ { "answer_id": 144189, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>Any reason not to use the <code>String(sbyte*, int, int)</code> constructor? If you've worked out which portion of the...
2008/09/27
[ "https://Stackoverflow.com/questions/144176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16387/" ]
I need to convert a (possibly) null terminated array of ascii bytes to a string in C# and the fastest way I've found to do it is by using my UnsafeAsciiBytesToString method shown below. This method uses the String.String(sbyte\*) constructor which contains a warning in it's remarks: "The value parameter is assumed to ...
Any reason not to use the `String(sbyte*, int, int)` constructor? If you've worked out which portion of the buffer you need, the rest should be simple: ``` public static string UnsafeAsciiBytesToString(byte[] buffer, int offset, int length) { unsafe { fixed (byte* pAscii = buffer) { r...
144,218
<p>So I've decided to try to solve my physics homework by writing some python scripts to solve problems for me. One problem that I'm running into is that significant figures don't always seem to come out properly. For example this handles significant figures properly:</p> <pre><code>from decimal import Decimal &gt;&...
[ { "answer_id": 144225, "author": "Dre", "author_id": 23033, "author_profile": "https://Stackoverflow.com/users/23033", "pm_score": 0, "selected": false, "text": "<p>Decimal defaults to 28 places of precision.<br/>\nThe only way to limit the number of digits it returns is by altering the ...
2008/09/27
[ "https://Stackoverflow.com/questions/144218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
So I've decided to try to solve my physics homework by writing some python scripts to solve problems for me. One problem that I'm running into is that significant figures don't always seem to come out properly. For example this handles significant figures properly: ``` from decimal import Decimal >>> Decimal('1.0') + ...
Changing the decimal working precision to 2 digits is *not* a good idea, unless you absolutely only are going to perform a single operation. You should always perform calculations at higher precision than the level of significance, and only round the final result. If you perform a long sequence of calculations and rou...
144,226
<p>From what I know, the em keyword in CSS means the current size of a font.</p> <p>So if you put 1.2 em, it means 120% of the font height.</p> <p>It doesn't seem right though that em is used for setting the width of divs etc like YUI grids does:</p> <pre><code>margin-right:24.0769em;*margin-right:23.62em; </code></...
[ { "answer_id": 144233, "author": "Zach", "author_id": 9128, "author_profile": "https://Stackoverflow.com/users/9128", "pm_score": 2, "selected": false, "text": "<p>It does mean the size of the font, but using it for width/height is useful for creating designs that scale with the font-siz...
2008/09/27
[ "https://Stackoverflow.com/questions/144226", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
From what I know, the em keyword in CSS means the current size of a font. So if you put 1.2 em, it means 120% of the font height. It doesn't seem right though that em is used for setting the width of divs etc like YUI grids does: ``` margin-right:24.0769em;*margin-right:23.62em; ``` Everytime I read about em, I fo...
Historically it is the width of an "M" in the font. Hence the name! In CSS2.1 it is [defined](http://www.w3.org/TR/CSS21/syndata.html#em-width) to be the same as the font-size. In many cases it seems more natural to use em rather than points or pixels, because it is relative to the font size. For example you might def...
144,246
<p>I have an application that is causing a lot of headaches. It's a .NET app connecting to SQL Server 2005 via a web service. The program has grid that is filled by a long running stored procedure that is prone to timing out. In the case when it does time out and a SqlException is thrown, there is no execption handling...
[ { "answer_id": 144247, "author": "Alex Weinstein", "author_id": 16668, "author_profile": "https://Stackoverflow.com/users/16668", "pm_score": 2, "selected": false, "text": "<p>There is a connection limit; if your app crashes frequently and does not close the connections automatically, ne...
2008/09/27
[ "https://Stackoverflow.com/questions/144246", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22273/" ]
I have an application that is causing a lot of headaches. It's a .NET app connecting to SQL Server 2005 via a web service. The program has grid that is filled by a long running stored procedure that is prone to timing out. In the case when it does time out and a SqlException is thrown, there is no execption handling to...
Since a SqlConnection closes while disposing i usually use this syntax ``` using (SqlConnection conn = new SqlConnection()) { // SqlCode here } ```
144,250
<p>I am writing an iPhone application and need to essentially implement something equivalent to the 'eyedropper' tool in photoshop, where you can touch a point on the image and capture the RGB values for the pixel in question to determine and match its color. Getting the UIImage is the easy part, but is there a way to...
[ { "answer_id": 144928, "author": "lajos", "author_id": 3740, "author_profile": "https://Stackoverflow.com/users/3740", "pm_score": 4, "selected": false, "text": "<p>You can't access the bitmap data of a UIImage directly.</p>\n\n<p>You need to get the CGImage representation of the UIImage...
2008/09/27
[ "https://Stackoverflow.com/questions/144250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17123/" ]
I am writing an iPhone application and need to essentially implement something equivalent to the 'eyedropper' tool in photoshop, where you can touch a point on the image and capture the RGB values for the pixel in question to determine and match its color. Getting the UIImage is the easy part, but is there a way to con...
A little more detail... ----------------------- I posted earlier this evening with a consolidation and small addition to what had been said on this page - that can be found at the bottom of this post. I am editing the post at this point, however, to post what I propose is (at least for my requirements, which include m...
144,321
<p>I'm processing a huge file with (GNU) <code>awk</code>, (other available tools are: Linux shell tools, some old (>5.0) version of Perl, but can't install modules).</p> <p>My problem: if some field1, field2, field3 contain X, Y, Z I must search for a file in another directory which contains field4, and field5 on one...
[ { "answer_id": 144406, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>This seems to work for some test files I set up matching your examples. Involving perl in this manner (interpose...
2008/09/27
[ "https://Stackoverflow.com/questions/144321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11621/" ]
I'm processing a huge file with (GNU) `awk`, (other available tools are: Linux shell tools, some old (>5.0) version of Perl, but can't install modules). My problem: if some field1, field2, field3 contain X, Y, Z I must search for a file in another directory which contains field4, and field5 on one line, and insert som...
Let me start out by saying that your problem description isn't really that helpful. Next time, please just be more specific: You might be missing out on much better solutions. So from your description, I understand you have two files which contain whitespace-separated data. In the first file, you want to match the fir...
144,339
<p>A couple of days ago, I read a blog entry (<a href="http://ayende.com/Blog/archive/2008/09/08/Implementing-generic-natural-language-DSL.aspx" rel="noreferrer">http://ayende.com/Blog/archive/2008/09/08/Implementing-generic-natural-language-DSL.aspx</a>) where the author discuss the idea of a generic natural language ...
[ { "answer_id": 144374, "author": "Joe Skora", "author_id": 14057, "author_profile": "https://Stackoverflow.com/users/14057", "pm_score": 6, "selected": true, "text": "<p>Considering the complexity of lexing and parsing, I don't know if I'd want to code all that by hand. <strong><a href=...
2008/09/27
[ "https://Stackoverflow.com/questions/144339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540/" ]
A couple of days ago, I read a blog entry (<http://ayende.com/Blog/archive/2008/09/08/Implementing-generic-natural-language-DSL.aspx>) where the author discuss the idea of a generic natural language DSL parser using .NET. The brilliant part of his idea, in my opinion, is that the text is parsed and matched against cla...
Considering the complexity of lexing and parsing, I don't know if I'd want to code all that by hand. **[ANTLR](http://www.antlr.org/) isn't that hard to pickup and I think it is worthing looking into based on your problem.** If you use a parse grammar to build and abstract syntax tree from the input, its pretty easy to...
144,375
<p>I want a nice 2 column layout using CSS float's.</p> <p>Column#1 160 px Column#2 100% (i.e. the rest of the space).</p> <p>I want to place the Col#2's div first, so my layout looks like:</p> <pre><code>&lt;div id="header"&gt;&lt;/div&gt; &lt;div id="content"&gt; &lt;div id="col2"&gt;&lt;/div&gt; &lt;div...
[ { "answer_id": 144381, "author": "Vijesh VP", "author_id": 22016, "author_profile": "https://Stackoverflow.com/users/22016", "pm_score": 0, "selected": false, "text": "<p>You should use the \"float\" CSS property for doing this. Check out for a <a href=\"http://www.456bereastreet.com/lab...
2008/09/27
[ "https://Stackoverflow.com/questions/144375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1368/" ]
I want a nice 2 column layout using CSS float's. Column#1 160 px Column#2 100% (i.e. the rest of the space). I want to place the Col#2's div first, so my layout looks like: ``` <div id="header"></div> <div id="content"> <div id="col2"></div> <div id="col1"></div> </div> <div id="footer"></div> ``` What h...
Neither of the above will work. ```css div#col2 { width: 160px; float: left; position: relative; } div#col1 { width:100%; margin-left: 160px; } ``` That's assuming that Column 2 should appear as a left sidebar, with col 1 as the main content.
144,380
<p>I'm writing a game which is taking user input and rendering it on-screen. The engine I'm using for this is entirely unicode-friendly, so I'd like to keep that if at all possible. The problem is that the rendering loop looks like this:</p> <pre><code>"string".each_byte do |c| render_this_letter(c) end </code><...
[ { "answer_id": 144381, "author": "Vijesh VP", "author_id": 22016, "author_profile": "https://Stackoverflow.com/users/22016", "pm_score": 0, "selected": false, "text": "<p>You should use the \"float\" CSS property for doing this. Check out for a <a href=\"http://www.456bereastreet.com/lab...
2008/09/27
[ "https://Stackoverflow.com/questions/144380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2555346/" ]
I'm writing a game which is taking user input and rendering it on-screen. The engine I'm using for this is entirely unicode-friendly, so I'd like to keep that if at all possible. The problem is that the rendering loop looks like this: ``` "string".each_byte do |c| render_this_letter(c) end ``` I don't know a who...
Neither of the above will work. ```css div#col2 { width: 160px; float: left; position: relative; } div#col1 { width:100%; margin-left: 160px; } ``` That's assuming that Column 2 should appear as a left sidebar, with col 1 as the main content.
144,439
<p>If i have lots of directory names either as literal strings or contained in variables, what is the easiest way of combining these to make a complete path?</p> <p>I know of <pre>Path.Combine</pre> but this only takes 2 string parameters, i need a solution that can take any number number of directory parameters.</p> ...
[ { "answer_id": 144441, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 5, "selected": true, "text": "<blockquote>\n <p>Does C# support unlimited args in methods?</p>\n</blockquote>\n\n<p>Yes, have a look at the params k...
2008/09/27
[ "https://Stackoverflow.com/questions/144439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
If i have lots of directory names either as literal strings or contained in variables, what is the easiest way of combining these to make a complete path? I know of ``` Path.Combine ``` but this only takes 2 string parameters, i need a solution that can take any number number of directory parameters. e.g: ``` str...
> > Does C# support unlimited args in methods? > > > Yes, have a look at the params keyword. Will make it easy to write a function that just calls Path.Combine the appropriate number of times, like this (untested): ``` string CombinePaths(params string[] parts) { string result = String.Empty; foreach (str...
144,474
<p>I'm used to working with PHP but lately I've been working with Java and I'm having a headache trying to figure this out. I want to save this representation in Java:</p> <pre> Array ( ["col_name_1"] => Array ( 1 => ["col_value_1"], 2 => ["col_v...
[ { "answer_id": 144485, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 3, "selected": false, "text": "<p>You want a <a href=\"http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html\" rel=\"nofollow noreferrer\">Map</a>, wh...
2008/09/27
[ "https://Stackoverflow.com/questions/144474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6618/" ]
I'm used to working with PHP but lately I've been working with Java and I'm having a headache trying to figure this out. I want to save this representation in Java: ``` Array ( ["col_name_1"] => Array ( 1 => ["col_value_1"], 2 => ["col_value_2"]...
You can use a Map and a List (these both are interfaces implemented in more than one way for you to choose the most adequate in your case). For more information check the tutorials for [Map](http://java.sun.com/docs/books/tutorial/collections/interfaces/map.html) and [List](http://java.sun.com/docs/books/tutorial/col...
144,503
<p>I initially designed my system following the s# architecture example <a href="http://wwww.codeproject.com/KB/architecture/NHibernateBestPractices.aspx" rel="nofollow noreferrer">outlined in this codeproject article</a> (Unfortunately, I am not using NHibernate). The basic idea is that for each domain object that wo...
[ { "answer_id": 144538, "author": "Mladen Mihajlovic", "author_id": 11421, "author_profile": "https://Stackoverflow.com/users/11421", "pm_score": 1, "selected": false, "text": "<p>I'm also using the <a href=\"http://martinfowler.com/eaaCatalog/repository.html\" rel=\"nofollow noreferrer\"...
2008/09/27
[ "https://Stackoverflow.com/questions/144503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I initially designed my system following the s# architecture example [outlined in this codeproject article](http://wwww.codeproject.com/KB/architecture/NHibernateBestPractices.aspx) (Unfortunately, I am not using NHibernate). The basic idea is that for each domain object that would need to communicate with the persiste...
I recommend against the simple approach other than in simple systems, usually I think your better creating a custom repository for each aggregate and encapsulating as much suitable logic as you can within it. So my approach would to have a repository for each aggregate that needs it, such as CustomerRepository. This ...
144,516
<p>I'm currently writing an interface to allow applications to send exception data to a central repository for support purposes. I'm at a quandary about how to pass extra contextual data:</p> <pre><code>public interface IExceptionNotifier { void Notify(Exception ex, NameValueCollection context); //this v...
[ { "answer_id": 144518, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 2, "selected": true, "text": "<p>If the context is a throw-away value and (here comes the important part) will not be serialized, e.g. for sending th...
2008/09/27
[ "https://Stackoverflow.com/questions/144516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3642/" ]
I'm currently writing an interface to allow applications to send exception data to a central repository for support purposes. I'm at a quandary about how to pass extra contextual data: ``` public interface IExceptionNotifier { void Notify(Exception ex, NameValueCollection context); //this void Notify(Exc...
If the context is a throw-away value and (here comes the important part) will not be serialized, e.g. for sending the data to another system, I'd go with the IDictionary because it makes using your interface more flexible. If, on the other hand, the context is kept all the time or the context will be serialized, use N...
144,550
<p><strong>Problem:</strong></p> <p>Ajax suggest-search on [<em>n</em>] ingredients in recipes. That is: match recipes against multiple ingredients.</p> <p>For instance: <code>SELECT Recipes using "flower", "salt"</code> would produce: <code>"Pizza", "Bread", "Saltwater"</code> and so forth.</p> <p><strong>Tables:</...
[ { "answer_id": 144589, "author": "alexmac", "author_id": 23066, "author_profile": "https://Stackoverflow.com/users/23066", "pm_score": 2, "selected": false, "text": "<p>Depending on how you are processing the input ingredients I think this current method has some sql injection risks. </p...
2008/09/27
[ "https://Stackoverflow.com/questions/144550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20946/" ]
**Problem:** Ajax suggest-search on [*n*] ingredients in recipes. That is: match recipes against multiple ingredients. For instance: `SELECT Recipes using "flower", "salt"` would produce: `"Pizza", "Bread", "Saltwater"` and so forth. **Tables:** ``` Ingredients [ IngredientsID INT [PK], IngredientsName VARC...
You have two options. If you're using SQL Server 2008 (or Oracle) you can pass in a [table value parameter](http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters). If you're using SQL Server 2005, you can use [XML to simulate this capability](http://weblogs.asp.net/jgalloway/archive/2007/02/16/passin...
144,570
<p>I thought that there was some way in .net 3.0 to give an array list a type so that it didnt just return Object's but I'm having trouble doing so. Is it possible? If so, how?</p>
[ { "answer_id": 144574, "author": "OregonGhost", "author_id": 20363, "author_profile": "https://Stackoverflow.com/users/20363", "pm_score": 2, "selected": false, "text": "<p>You're probably looking for List<code>&lt;T&gt;</code>, available since .NET 2.0, or for any other of the generic t...
2008/09/27
[ "https://Stackoverflow.com/questions/144570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2128/" ]
I thought that there was some way in .net 3.0 to give an array list a type so that it didnt just return Object's but I'm having trouble doing so. Is it possible? If so, how?
`List<T>` was introduced with generics in .NET 2.0: ``` using System.Collections.Generic; var list = new List<int>(); list.Add(1); list.Add("string"); //compile-time error! int i = list[0]; ```
144,630
<p>I am working on an ASP.NET MVC web app that allows people to publish content, but other than publish the content to a remote server, I want to allow people to use their domain name directly. For example, the user "Tom" can have his domain name TomSite.com point to <a href="http://www.mywebapp.com/user/tom" rel="nof...
[ { "answer_id": 144695, "author": "SchizoDuckie", "author_id": 18077, "author_profile": "https://Stackoverflow.com/users/18077", "pm_score": 0, "selected": false, "text": "<p>Just make a new record in your webserver setting tomsite.com directly to your mywebapp.com/user/tom/ path ?</p>\n\...
2008/09/27
[ "https://Stackoverflow.com/questions/144630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20067/" ]
I am working on an ASP.NET MVC web app that allows people to publish content, but other than publish the content to a remote server, I want to allow people to use their domain name directly. For example, the user "Tom" can have his domain name TomSite.com point to <http://www.mywebapp.com/user/tom>, but the sub path wi...
This require multiple steps. First you have to find out how your users will configure their domain to have a CNAME record for you site. You can archieve this in a number of ways where the best is education. Making partnerships with hosting providers requires a great deal of volume. In IIS this will require you to eit...
144,639
<p>By default (using the <code>plain</code> style) BibTeX orders citations alphabetically. </p> <p>How to order the citations by order of appearance in the document?</p>
[ { "answer_id": 144640, "author": "Brendan", "author_id": 199, "author_profile": "https://Stackoverflow.com/users/199", "pm_score": 5, "selected": false, "text": "<p>The best I came up with is using the <code>unsrt</code> style, which seems to be a tweaked <code>plain</code> style. i.e.</...
2008/09/27
[ "https://Stackoverflow.com/questions/144639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/199/" ]
By default (using the `plain` style) BibTeX orders citations alphabetically. How to order the citations by order of appearance in the document?
There are three good answers to this question. * Use the `unsrt` bibliography style, if you're happy with its formatting otherwise * Use the `makebst` [(link)](http://www.ctan.org/tex-archive/macros/latex/contrib/custom-bib/) tool to design your own bibliography style And my personal recommendation: * Use the `bibla...
144,642
<p>I require a tree / directed acyclic graph implementation something like this:</p> <pre><code>public class TreeNode&lt;K, V&gt; { private K key; // 'key' for this node, always present private V value; // 'value' for this node, doesn't have to be set private TreeNode&lt;K, V&gt; parent; private Set&l...
[ { "answer_id": 144652, "author": "stimms", "author_id": 361, "author_profile": "https://Stackoverflow.com/users/361", "pm_score": 5, "selected": true, "text": "<p>There doesn't seem to be anything of the kind. I asked <a href=\"https://stackoverflow.com/questions/66893/tree-data-structur...
2008/09/27
[ "https://Stackoverflow.com/questions/144642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1666/" ]
I require a tree / directed acyclic graph implementation something like this: ``` public class TreeNode<K, V> { private K key; // 'key' for this node, always present private V value; // 'value' for this node, doesn't have to be set private TreeNode<K, V> parent; private Set<TreeNode<K, V>> children; ...
There doesn't seem to be anything of the kind. I asked [a similar question](https://stackoverflow.com/questions/66893/tree-data-structure-in-c) last week and ended up implementing my own tree. My implementation was very similar to what you're proposing: ``` public class TreeNode<T> { private LinkedList<TreeNode<T>...
144,651
<p>I've the following rewrite rule in .htaccess:</p> <pre><code>RewriteRule ^groups/([^/\.]+)/?$ groupdetail.php?gname=$1 [L,NC] </code></pre> <p>This takes something like www.example.com/groups/groupname and calls www.example/groupdetail.php?gname=groupname. And it works just fine.</p> <p>But all the relative lin...
[ { "answer_id": 144676, "author": "Kevin Hakanson", "author_id": 22514, "author_profile": "https://Stackoverflow.com/users/22514", "pm_score": 1, "selected": false, "text": "<p>If you change the rewite rule to do a <a href=\"http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterul...
2008/09/27
[ "https://Stackoverflow.com/questions/144651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've the following rewrite rule in .htaccess: ``` RewriteRule ^groups/([^/\.]+)/?$ groupdetail.php?gname=$1 [L,NC] ``` This takes something like www.example.com/groups/groupname and calls www.example/groupdetail.php?gname=groupname. And it works just fine. But all the relative links on groupdetail.php use groups/ ...
If like me you had hundreds of relative links in the page, insert a `<base href="">` in the `<head>` with an absolute path (could use relative too). You'll need to also make the path to .js files in the `<head>` absolute because IE and firefox deal with the base href differently. I agree it is an annoying issue.
144,657
<p>I have a Java program that uses Hibernate and MySQL to store a lot of tracing data about the use of the Eclipse IDE. This data contains a lot of strings such as method names, directories, perspective name, etc. </p> <p>For example, an event object (which is then reflected in a record) can specify the source file an...
[ { "answer_id": 144674, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 0, "selected": false, "text": "<p>I suspect you'll need a string holder object and then make sure all these objects refer to that. </p>\n\n<pre><code>class...
2008/09/27
[ "https://Stackoverflow.com/questions/144657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23072/" ]
I have a Java program that uses Hibernate and MySQL to store a lot of tracing data about the use of the Eclipse IDE. This data contains a lot of strings such as method names, directories, perspective name, etc. For example, an event object (which is then reflected in a record) can specify the source file and the curr...
Building on sblundy's answer, you could probably get away with something like: ``` class Foo { // client code uses this to get the value... ignored by Hibernate @Transient public String getString() { return getStringHolder().getString(); } public StringHolder getStringHolder() {...} } ```...
144,669
<p>I've removed a checked in file from the CVS branch, i.e.:</p> <pre><code>cvs remove -f file.txt cvs commit </code></pre> <p>How do I restore the file?</p>
[ { "answer_id": 144672, "author": "Jason Etheridge", "author_id": 2193, "author_profile": "https://Stackoverflow.com/users/2193", "pm_score": 6, "selected": true, "text": "<p>I believe that:</p>\n\n<pre><code>cvs add file.txt\ncvs commit file.txt\n</code></pre>\n\n<p>... will resurrect it...
2008/09/27
[ "https://Stackoverflow.com/questions/144669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4704/" ]
I've removed a checked in file from the CVS branch, i.e.: ``` cvs remove -f file.txt cvs commit ``` How do I restore the file?
I believe that: ``` cvs add file.txt cvs commit file.txt ``` ... will resurrect it from the attic.
144,701
<p>I frequently start with a simple console application to try out an idea, then create a new GUI based project and copy the code in. Is there a better way? Can I convert my existing console application easily?</p>
[ { "answer_id": 144720, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 7, "selected": true, "text": "<p>Just add a new Winform, add the following code to your <code>Main</code>:</p>\n\n<pre><code> Application.EnableVisu...
2008/09/27
[ "https://Stackoverflow.com/questions/144701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5/" ]
I frequently start with a simple console application to try out an idea, then create a new GUI based project and copy the code in. Is there a better way? Can I convert my existing console application easily?
Just add a new Winform, add the following code to your `Main`: ``` Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); ``` Also, be sure the `[STAThread]` attribute is declared above your `Main` function to indicate the COM threading model...
144,713
<p>I have an XML document with un-namespaced elements, and I want to use XSLT to add namespaces to them. Most elements will be in namespace A; a few will be in namespace B. How do I do this?</p>
[ { "answer_id": 144724, "author": "Craig Walker", "author_id": 3488, "author_profile": "https://Stackoverflow.com/users/3488", "pm_score": 1, "selected": false, "text": "<p>Here's what I have so far:</p>\n\n<pre><code>&lt;xsl:template match=\"*\"&gt;\n &lt;xsl:element name=\"{local-nam...
2008/09/27
[ "https://Stackoverflow.com/questions/144713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3488/" ]
I have an XML document with un-namespaced elements, and I want to use XSLT to add namespaces to them. Most elements will be in namespace A; a few will be in namespace B. How do I do this?
With foo.xml ``` <foo x="1"> <bar y="2"> <baz z="3"/> </bar> <a-special-element n="8"/> </foo> ``` and foo.xsl ``` <xsl:template match="*"> <xsl:element name="{local-name()}" namespace="A" > <xsl:copy-of select="attribute::*"/> <xsl:apply-templates /> ...
144,731
<p>Are there any commonly used patterns in Javascript for storing the URL's of endpoints that will be requested in an AJAX application?</p> <p>For example would you create a "Service" class to abstract the URL's away?</p>
[ { "answer_id": 144736, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 0, "selected": false, "text": "<p>Is your question similar to <a href=\"https://stackoverflow.com/questions/108853/relative-urls-for-javascript-files...
2008/09/27
[ "https://Stackoverflow.com/questions/144731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21875/" ]
Are there any commonly used patterns in Javascript for storing the URL's of endpoints that will be requested in an AJAX application? For example would you create a "Service" class to abstract the URL's away?
I've used something like this (used in Rails): ``` NAMESPACE.categories.baseUri = '/categories'; NAMESPACE.categories.getUri = function(options) { options = options || {}; var uri = [NAMESPACE.categories.baseUri]; if(options.id) { uri.push(options.id); } if(options.action) { uri.push(options.ac...
144,761
<p>I have a problem with a string in C++ which has several words in Spanish. This means that I have a lot of words with accents and tildes. I want to replace them for their not accented counterparts. Example: I want to replace this word: "había" for habia. I tried replace it directly but with replace method of string c...
[ { "answer_id": 144769, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": -1, "selected": false, "text": "<p>If you can (if you're running Unix), I suggest using the <a href=\"http://www.gnu.org/software/coreutils/manual/html_nod...
2008/09/27
[ "https://Stackoverflow.com/questions/144761", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23084/" ]
I have a problem with a string in C++ which has several words in Spanish. This means that I have a lot of words with accents and tildes. I want to replace them for their not accented counterparts. Example: I want to replace this word: "había" for habia. I tried replace it directly but with replace method of string clas...
First, this is a really bad idea: you’re mangling somebody’s language by removing letters. Although the extra dots in words like “naïve” seem superfluous to people who only speak English, there are literally thousands of writing systems in the world in which such distinctions are very important. Writing software to mut...
144,774
<p>I'm writing a program that uses <a href="http://msdn.microsoft.com/en-us/library/dd145102(VS.85).aspx" rel="nofollow noreferrer"><code>SetWindowRgn</code></a> to make transparent holes in a window that belongs to another process. (This is done only when the user explicitly requests it.)</p> <p>The program has to as...
[ { "answer_id": 144856, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 5, "selected": true, "text": "<p>Are you sure your window <em>has</em> a region? Most top-level windows in XP do, simply because the default theme uses them fo...
2008/09/27
[ "https://Stackoverflow.com/questions/144774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23091/" ]
I'm writing a program that uses [`SetWindowRgn`](http://msdn.microsoft.com/en-us/library/dd145102(VS.85).aspx) to make transparent holes in a window that belongs to another process. (This is done only when the user explicitly requests it.) The program has to assume that the target window may already have holes which n...
Are you sure your window *has* a region? Most top-level windows in XP do, simply because the default theme uses them for round corners... but this is still a bad assumption to be making, and may very well not hold once you get to Vista. If you haven't set a region yet, and the call fails, use a sensible default (the w...
144,810
<p>Recently I have started playing with jQuery, and have been following a couple of tutorials. Now I feel slightly competent with using it (it's pretty easy), and I thought it would be cool if I were able to make a 'console' on my webpage (as in, you press the ` key like you do in <a href="http://en.wiktionary.org/wiki...
[ { "answer_id": 144818, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 4, "selected": false, "text": "<p>Normally, it's the value property</p>\n\n<pre><code>testArea.value\n</code></pre>\n\n<p>Or is there something I'm missing...
2008/09/28
[ "https://Stackoverflow.com/questions/144810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20900/" ]
Recently I have started playing with jQuery, and have been following a couple of tutorials. Now I feel slightly competent with using it (it's pretty easy), and I thought it would be cool if I were able to make a 'console' on my webpage (as in, you press the ` key like you do in [FPS](http://en.wiktionary.org/wiki/first...
Why would you want to convert key strokes to text? Add a button that sends the text inside the textarea to the server when clicked. You can get the text using the value attribute as the poster before has pointed out, or using jQuery's API: ``` $('input#mybutton').click(function() { var text = $('textarea#mytextare...
144,824
<p>Can you use the bash "getopts" function twice in the same script?</p> <p>I have a set of options that would mean different things depending on the value of a specific option. Since I can't guarantee that getopts will evaluate that specific option first, I would like to run getopts one time, using only that specifi...
[ { "answer_id": 144838, "author": "andrewdotn", "author_id": 14558, "author_profile": "https://Stackoverflow.com/users/14558", "pm_score": 4, "selected": true, "text": "<p>Yes, just reset OPTIND afterwards.</p>\n\n<pre><code>#!/bin/bash\n\nset -- -1\nwhile getopts 1 opt; do\n case \"${...
2008/09/28
[ "https://Stackoverflow.com/questions/144824", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17925/" ]
Can you use the bash "getopts" function twice in the same script? I have a set of options that would mean different things depending on the value of a specific option. Since I can't guarantee that getopts will evaluate that specific option first, I would like to run getopts one time, using only that specific option, t...
Yes, just reset OPTIND afterwards. ``` #!/bin/bash set -- -1 while getopts 1 opt; do case "${opt}" in 1) echo "Worked!";; *) exit 1; esac done OPTIND=1 set -- -2 while getopts 2 opt; do case "${opt}" in 2) echo "Worked!";; *) exit 1; esac done ```
144,833
<p>I know that attributes are extremely useful. There are some predefined ones such as <code>[Browsable(false)]</code> which allows you to hide properties in the properties tab. Here is a good question explaining attributes: <a href="https://stackoverflow.com/questions/20346/c-what-are-attributes">What are attributes i...
[ { "answer_id": 144841, "author": "Gilligan", "author_id": 12356, "author_profile": "https://Stackoverflow.com/users/12356", "pm_score": 6, "selected": false, "text": "<p><code>[Serializable]</code> is used all the time for serializing and deserializing objects to and from external data s...
2008/09/28
[ "https://Stackoverflow.com/questions/144833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1632/" ]
I know that attributes are extremely useful. There are some predefined ones such as `[Browsable(false)]` which allows you to hide properties in the properties tab. Here is a good question explaining attributes: [What are attributes in .NET?](https://stackoverflow.com/questions/20346/c-what-are-attributes) **What are t...
`[DebuggerDisplay]` can be really helpful to quickly see customized output of a Type when you mouse over the instance of the Type during debugging. example: ``` [DebuggerDisplay("FirstName={FirstName}, LastName={LastName}")] class Customer { public string FirstName; public string LastName; } ``` This is how ...
144,902
<p>Recently I had to do some very processing heavy stuff with data stored in a DataSet. It was heavy enough that I ended up using a tool to help identify some bottlenecks in my code. When I was analyzing the bottlenecks, I noticed that although DataSet lookups were not terribly slow (they weren't the bottleneck), it wa...
[ { "answer_id": 144911, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": 0, "selected": false, "text": "<p>I imagine that any lookups would be O(n), as I don't think they would use any type of hashtable, but would actually use mo...
2008/09/28
[ "https://Stackoverflow.com/questions/144902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/392/" ]
Recently I had to do some very processing heavy stuff with data stored in a DataSet. It was heavy enough that I ended up using a tool to help identify some bottlenecks in my code. When I was analyzing the bottlenecks, I noticed that although DataSet lookups were not terribly slow (they weren't the bottleneck), it was s...
Via [Reflector](http://www.red-gate.com/products/reflector/) the steps for DataRow["ColumnName"] are: 1. Get the DataColumn from ColumnName. Uses the row's DataColumnCollection["ColumnName"]. Internally, DataColumnCollection stores its DataColumns in a Hastable. O(1) 2. Get the DataRow's row index. The index is stored...
144,980
<p>Greetings.</p> <p>I'm trying to implement some multithreaded code in an application. The purpose of this code is to validate items that the database gives it. Validation can take quite a while (a few hundred ms to a few seconds), so this process needs to be forked off into its own thread for each item.</p> <p>The ...
[ { "answer_id": 144991, "author": "Michael Haren", "author_id": 29, "author_profile": "https://Stackoverflow.com/users/29", "pm_score": 2, "selected": false, "text": "<p>The thread pool is a convenient choice if you have <em>light weight</em> sporadic processing that isn't time sensitive....
2008/09/28
[ "https://Stackoverflow.com/questions/144980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
Greetings. I'm trying to implement some multithreaded code in an application. The purpose of this code is to validate items that the database gives it. Validation can take quite a while (a few hundred ms to a few seconds), so this process needs to be forked off into its own thread for each item. The database may give...
The thread pool is a convenient choice if you have *light weight* sporadic processing that isn't time sensitive. However, I recall reading on MSDN that it's not appropriate for large scale processing of this nature. I used it for something quite similar to this and regret it. I took a worker-thread approach in subsequ...
144,983
<p>Every time I start Emacs I see a page of help text and a bunch of messages suggesting that I try the tutorial. How do I stop this from happening?</p>
[ { "answer_id": 144984, "author": "jfm3", "author_id": 11138, "author_profile": "https://Stackoverflow.com/users/11138", "pm_score": 4, "selected": true, "text": "<p>Put the following in your <code>.emacs</code>:</p>\n\n<pre>\n(setq inhibit-startup-message t)\n(setq inhibit-startup-echo-a...
2008/09/28
[ "https://Stackoverflow.com/questions/144983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11138/" ]
Every time I start Emacs I see a page of help text and a bunch of messages suggesting that I try the tutorial. How do I stop this from happening?
Put the following in your `.emacs`: ``` (setq inhibit-startup-message t) (setq inhibit-startup-echo-area-message t) ```
145,006
<p>Very simply put, I have the following code snippet:</p> <pre><code>FILE* test = fopen("C:\\core.u", "w"); printf("Filepointer at: %d\n", ftell(test)); fwrite(data, size, 1, test); printf("Written: %d bytes.\n", size); fseek(test, 0, SEEK_END); printf("Filepointer is now at %d.\n", ftell(test)); fclose(test); </code...
[ { "answer_id": 145013, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": true, "text": "<p>Since you're opening the file in text mode, it will convert end-of-line markers, such as LF, into CR/LF.</p>\n\n<p>Thi...
2008/09/28
[ "https://Stackoverflow.com/questions/145006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Very simply put, I have the following code snippet: ``` FILE* test = fopen("C:\\core.u", "w"); printf("Filepointer at: %d\n", ftell(test)); fwrite(data, size, 1, test); printf("Written: %d bytes.\n", size); fseek(test, 0, SEEK_END); printf("Filepointer is now at %d.\n", ftell(test)); fclose(test); ``` and it outputs...
Since you're opening the file in text mode, it will convert end-of-line markers, such as LF, into CR/LF. This is likely if you're running on Windows (and you probably are, given that your file name starts with `"c:\"`). If you open the file in `"wb"` mode, I suspect you'll find the numbers are identical: ``` FILE* t...
145,025
<p>I'm implementing a secure WCF service. Authentication is done using username / password or Windows credentials. The service is hosted in a Windows Service process. Now, I'm trying to find out the best way to implement <em>authorization</em> for each service operation.</p> <p>For example, consider the following meth...
[ { "answer_id": 145160, "author": "Paul Lalonde", "author_id": 5782, "author_profile": "https://Stackoverflow.com/users/5782", "pm_score": 3, "selected": false, "text": "<p>For question 1, it's best to perform authorization first. That way, you don't leak validation error messages back t...
2008/09/28
[ "https://Stackoverflow.com/questions/145025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6995/" ]
I'm implementing a secure WCF service. Authentication is done using username / password or Windows credentials. The service is hosted in a Windows Service process. Now, I'm trying to find out the best way to implement *authorization* for each service operation. For example, consider the following method: ``` public E...
For question 1, absolutely do authorization first. No code (within your control) should execute before authorization to maintain the tightest security. Paul's example above is excellent. For question 2, you could handle this by subclassing your concrete service implementation. Make the true business logic implementati...
145,052
<p>Is there any libraries that would allow me to use the same known notation as we use in BeanUtils for extracting POJO parameters, but for easily replacing placeholders in a string?</p> <p>I know it would be possible to roll my own, using BeanUtils itself or other libraries with similar features, but I didn't want to...
[ { "answer_id": 145156, "author": "Brian", "author_id": 700, "author_profile": "https://Stackoverflow.com/users/700", "pm_score": 1, "selected": false, "text": "<p>Spring Framework should have a feature that does this (see Spring JDBC example below). If you can use groovy (just add the g...
2008/09/28
[ "https://Stackoverflow.com/questions/145052", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14540/" ]
Is there any libraries that would allow me to use the same known notation as we use in BeanUtils for extracting POJO parameters, but for easily replacing placeholders in a string? I know it would be possible to roll my own, using BeanUtils itself or other libraries with similar features, but I didn't want to reinvent ...
Rolling your own using BeanUtils wouldn't take too much wheel reinvention (assuming you want it to be as basic as asked for). This implementation takes a Map for replacement context, where the map key should correspond to the first portion of the variable lookup paths given for replacement. ``` import java.lang.reflec...
145,056
<p>A friend came across a quadratic Bézier curve function in his codebase that used a gigantic rats nest of a switch table to perform the computation. He challenged me to find a single, short expression that would allow him to replace the gigantic block of code.</p> <p>In attempting to satisfy two different curiositie...
[ { "answer_id": 145142, "author": "nlucaroni", "author_id": 157, "author_profile": "https://Stackoverflow.com/users/157", "pm_score": 2, "selected": false, "text": "<p>I have two suggestions:</p>\n<p>You should call <code>List.rev</code> after <code>b2i</code> returns so ocaml can exploit...
2008/09/28
[ "https://Stackoverflow.com/questions/145056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18446/" ]
A friend came across a quadratic Bézier curve function in his codebase that used a gigantic rats nest of a switch table to perform the computation. He challenged me to find a single, short expression that would allow him to replace the gigantic block of code. In attempting to satisfy two different curiosities, I thoug...
b2 isn't recursive, so no need for [let rec b2 n =]. Since n never changes, no need to have it as argument to b2i, just use n from the enclosing scope. Your inner function should depend on p0, p1 and p2, but I see it depending on -10., n\*\*2 and 10. The function also has the form of a map from [ 0.0; 1.0; 2.0; ...; n....
145,096
<p>I am taking a class in C++ programming and the professor told us that there is no need to learn C because C++ contains everything in C plus object-oriented features. However, some others have told me that this is not necessarily true. Can anyone shed some light on this?</p>
[ { "answer_id": 145098, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 7, "selected": true, "text": "<p><strong>Overview:</strong></p>\n\n<p>It is almost true that C++ is a superset of C, and your professor is correct i...
2008/09/28
[ "https://Stackoverflow.com/questions/145096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23126/" ]
I am taking a class in C++ programming and the professor told us that there is no need to learn C because C++ contains everything in C plus object-oriented features. However, some others have told me that this is not necessarily true. Can anyone shed some light on this?
**Overview:** It is almost true that C++ is a superset of C, and your professor is correct in that there is no need to learn C separately. C++ adds the whole object oriented aspect, generic programming aspect, as well as having less strict rules (like variables needing to be declared at the top of each function). C+...
145,154
<p>My singleton accessor method is usually some variant of:</p> <pre><code>static MyClass *gInstance = NULL; + (MyClass *)instance { @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance); } </code></pre> <p>What could I be doing to impr...
[ { "answer_id": 145164, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 7, "selected": false, "text": "<pre><code>@interface MySingleton : NSObject\n{\n}\n\n+ (MySingleton *)sharedSingleton;\n@end\n\n@implementation MySin...
2008/09/28
[ "https://Stackoverflow.com/questions/145154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23113/" ]
My singleton accessor method is usually some variant of: ``` static MyClass *gInstance = NULL; + (MyClass *)instance { @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance); } ``` What could I be doing to improve this?
Another option is to use the `+(void)initialize` method. From the documentation: > > The runtime sends `initialize` to each class in a program exactly one time just before the class, or any class that inherits from it, is sent its first message from within the program. (Thus the method may never be invoked if the cla...
145,169
<p>I'm using the current version of restful_authentication that is found on github and I'm having a bunch of strange session issues. The server seems to be somehow assigning sessions to users it shouldn't be. This only happens when crossing the logged out/logged in barrier.</p> <p>Here's an example. With no sessions a...
[ { "answer_id": 147032, "author": "Nathan de Vries", "author_id": 11109, "author_profile": "https://Stackoverflow.com/users/11109", "pm_score": 2, "selected": false, "text": "<p>This can happen if you (or those who wrote restful_authentication) are caching the current user in a class vari...
2008/09/28
[ "https://Stackoverflow.com/questions/145169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23128/" ]
I'm using the current version of restful\_authentication that is found on github and I'm having a bunch of strange session issues. The server seems to be somehow assigning sessions to users it shouldn't be. This only happens when crossing the logged out/logged in barrier. Here's an example. With no sessions active on ...
I don't know if this is so much of an answer as it is a work around. All I did was switch over to cookie based sessions and everything is working smoothly.
145,175
<p>Right now I write expressions in the <code>*scratch*</code> buffer and test them by evaluating with <kbd>C-x</kbd> <kbd>C-e</kbd>. I would really appreciate having an interactive interpreter like SLIME or irb, in which I could test Emacs Lisp expressions.</p>
[ { "answer_id": 145205, "author": "cjm", "author_id": 8355, "author_profile": "https://Stackoverflow.com/users/8355", "pm_score": 1, "selected": false, "text": "<p>In the <code>*scratch*</code> buffer, just type C-j to evaluate the expression before point.</p>\n" }, { "answer_id":...
2008/09/28
[ "https://Stackoverflow.com/questions/145175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21998/" ]
Right now I write expressions in the `*scratch*` buffer and test them by evaluating with `C-x` `C-e`. I would really appreciate having an interactive interpreter like SLIME or irb, in which I could test Emacs Lisp expressions.
It's easy to evaluate Lisp expressions in Inferior Emacs-Lisp Mode: ``` M-x ielm ``` You can read more about this feature in the [Emacs manual section on "Lisp Interaction"](http://www.gnu.org/software/emacs/manual/html_mono/emacs.html#Lisp-Interaction)
145,209
<p>I want to mount some internal and external NTFS drives in CentOS 5.2, preferably automatically upon boot-up. Doesn't matter if it's read/write or read-only, but read/write would be preferred, if it's safe.</p> <p>Edit: Thanks for all answers, I summarized them below =)</p>
[ { "answer_id": 145213, "author": "Martin Beckett", "author_id": 10897, "author_profile": "https://Stackoverflow.com/users/10897", "pm_score": 2, "selected": false, "text": "<p>You should already have ntfs available, read-write support is now pretty reliable.<br>\nYou can test it with \"m...
2008/09/28
[ "https://Stackoverflow.com/questions/145209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18406/" ]
I want to mount some internal and external NTFS drives in CentOS 5.2, preferably automatically upon boot-up. Doesn't matter if it's read/write or read-only, but read/write would be preferred, if it's safe. Edit: Thanks for all answers, I summarized them below =)
To answer my own question: PostMan and mgb led me to the right path, but their answers did not contain complete solution. Note: A short manual/wiki on this question is here: <http://wiki.centos.org/TipsAndTricks/NTFSPartitions> So, I am using a fresh, bare install of CentOS 5.2 with latest updates. First of all, I ra...
145,241
<h2><strong>Edit: I have solved this by myself. See <a href="https://stackoverflow.com/questions/145241/change-the-value-of-a-text-box-to-its-current-order-in-a-sortable-tab/145388#145388">my answer below</a></strong></h2> <p>I have set up a nice sortable table with jQuery and it is quite nice. But now i want to extend...
[ { "answer_id": 145284, "author": "Sugendran", "author_id": 22466, "author_profile": "https://Stackoverflow.com/users/22466", "pm_score": 0, "selected": false, "text": "<p>Hmmm..\nI think you want to do something like this:</p>\n\n<pre><code>$(\"input:text\", \"#table-2\").each( function(...
2008/09/28
[ "https://Stackoverflow.com/questions/145241", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
**Edit: I have solved this by myself. See [my answer below](https://stackoverflow.com/questions/145241/change-the-value-of-a-text-box-to-its-current-order-in-a-sortable-tab/145388#145388)** ----------------------------------------------------------------------------------------------------------------------------------...
Hardnrg in #jquery ended up solving it for me. It involved adding an id="" to each input: ``` <form name="productform"> <table cellspacing="0" id="table-2" name="productform"> <thead> <tr><td>Product</td> <td>Order</td></tr> </thead> <tbody> <tr class="row1" i...