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
387,829
<p>The problem domain features a large population of named snarks. Some of the snarks are boojums. </p> <p>There are at least two ways to model this:</p> <pre> // as a property: class Snark { string name; bool is_boojum; }; // as a list: class Snark { typedef long Id; Id ...
[ { "answer_id": 387844, "author": "Oddthinking", "author_id": 8014, "author_profile": "https://Stackoverflow.com/users/8014", "pm_score": 3, "selected": false, "text": "<p>What problem are you trying to solve?</p>\n\n<p>If the purpose of recording the royalty of the snarks is to display a...
2008/12/23
[ "https://Stackoverflow.com/questions/387829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29403/" ]
The problem domain features a large population of named snarks. Some of the snarks are boojums. There are at least two ways to model this: ``` // as a property: class Snark { string name; bool is_boojum; }; // as a list: class Snark { typedef long Id; Id id; string ...
I believe that the information entropy associated with the classification can be a guide to which method to use. Low-entropy classifications (i.e. most of the objects have the same value) suggest a list implementation tracking the exceptional cases, while high-entropy classifications (you cannot make any very good pred...
387,850
<p>I'm building a site where users can track their collection of figures for Dungeons &amp; Dragons (www.ddmdb.com). The models/relationships involved in this funcitonality are the following:</p> <p><strong>User:</strong></p> <ul> <li>id</li> <li>login (username)</li> <li><em>a bunch of other fields</em></li> </ul> ...
[ { "answer_id": 387874, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 0, "selected": false, "text": "<p>Maybe I'm missing something, but the way you've specified the relationships seems sufficient for rails to figure ou...
2008/12/23
[ "https://Stackoverflow.com/questions/387850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8252/" ]
I'm building a site where users can track their collection of figures for Dungeons & Dragons (www.ddmdb.com). The models/relationships involved in this funcitonality are the following: **User:** * id * login (username) * *a bunch of other fields* **Miniature:** * id * name * number (# in the set, not count) * relea...
Using fd's suggestion and information found at <http://www.ruby-forum.com/topic/52385>, I created the following method: ``` def miniature_count(miniature_id) if @counts.nil? @counts = Hash.new ownerships.collect{|o| @counts[o.miniature_id] = o.have_count } end count = @counts[miniature_id] || 0 end ``` ...
387,858
<p>I'm building a database web application using Java and Hibernate's JPA implementation. The application tracks objects. It also has to batch import objects from a legacy source.</p> <p>For example, let's say we're tracking people. The database has tables called Person and Address. There are corresponding JPA entity ...
[ { "answer_id": 388114, "author": "Ruggs", "author_id": 44700, "author_profile": "https://Stackoverflow.com/users/44700", "pm_score": 1, "selected": false, "text": "<p>There two solutions that I have found that work. One is to process a chunk at a time. After each chunk closing an resta...
2008/12/23
[ "https://Stackoverflow.com/questions/387858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
I'm building a database web application using Java and Hibernate's JPA implementation. The application tracks objects. It also has to batch import objects from a legacy source. For example, let's say we're tracking people. The database has tables called Person and Address. There are corresponding JPA entity and DAO cl...
There two solutions that I have found that work. One is to process a chunk at a time. After each chunk closing an restarting the session. I have tried to use the flush clear methods on the session but sometimes it just function like you'd expect. Starting and stopping the transaction between batches seems to work the b...
387,895
<p>Consider following example :</p> <pre><code>public class SomeBusinessLayerService : DataService&lt;MyEntityContainer&gt; { [WebInvoke] void DoSomething(string someParam) { } } </code></pre> <p>I can not find example or any help on how can I pass parameter to the function! Using WebClient (or goofinfg around wi...
[ { "answer_id": 429834, "author": "Michael Feinstein", "author_id": 44838, "author_profile": "https://Stackoverflow.com/users/44838", "pm_score": 1, "selected": true, "text": "<p>I have never received a response from Microsoft team to that question, so I found following workaround: </p>\n...
2008/12/23
[ "https://Stackoverflow.com/questions/387895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44838/" ]
Consider following example : ``` public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam) { } } ``` I can not find example or any help on how can I pass parameter to the function! Using WebClient (or goofinfg around with fiddler) I can trigger the fu...
I have never received a response from Microsoft team to that question, so I found following workaround: Create a table called FunctionRequest with RequestID, Result and Paramerter string To perform request I simply create object. If I need to send complex object - I use DataContext serialization to send it to t...
387,912
<p>I'm working with a CMS, Joomla, and there's a core class which renders a set of parameters to a form, JParameter. Basically it has a <code>render()</code> function which outputs some table-laden HTML which is not consistent with the rest of my site.</p> <p>For issues of maintainability, and because I have no idea w...
[ { "answer_id": 387967, "author": "Sean McSomething", "author_id": 39413, "author_profile": "https://Stackoverflow.com/users/39413", "pm_score": 3, "selected": true, "text": "<p>There's always <a href=\"http://pecl.php.net/package/classkit\" rel=\"nofollow noreferrer\">PECL's Classkit</a>...
2008/12/23
[ "https://Stackoverflow.com/questions/387912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I'm working with a CMS, Joomla, and there's a core class which renders a set of parameters to a form, JParameter. Basically it has a `render()` function which outputs some table-laden HTML which is not consistent with the rest of my site. For issues of maintainability, and because I have no idea where else this is bei...
There's always [PECL's Classkit](http://pecl.php.net/package/classkit) but I get a feeling that you'd really rather not do this. Assuming you're directly calling `$this->params->render()`, you might just want to make a function/object that does an alternate rendering ( `MyParamRenderer::render($this->params)`) and avoi...
387,944
<p>I was reading the <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js" rel="noreferrer">jQuery source</a> and I was wondering why the entire source file was wrapped in an anonomous function.</p> <pre><code>(function(){ ... })(); </code></pre> <p>Is this something which helps not to pollute the g...
[ { "answer_id": 387958, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 5, "selected": true, "text": "<p>It uses the function body to provide its own scope rather than introducing a large number of globals that could be accidental...
2008/12/23
[ "https://Stackoverflow.com/questions/387944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42413/" ]
I was reading the [jQuery source](http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js) and I was wondering why the entire source file was wrapped in an anonomous function. ``` (function(){ ... })(); ``` Is this something which helps not to pollute the global namespace? Why is it there and how does it work?
It uses the function body to provide its own scope rather than introducing a large number of globals that could be accidentally changed by external code. Eg. ``` (function (){ var someConstantValue = ...; myCoolFunction = function(){ return someConstantValue * 5; } })(); myCoolFunction(); ``` If the functi...
387,959
<p>Let's say I have a class called <code>SomeClass</code> with a <code>string</code> property name:</p> <pre><code>@interface SomeClass : NSObject { NSString* name; } @property (nonatomic, retain) NSString* name; @end </code></pre> <p>I understand that name may be assigned a <code>NSMutableString</code> in whic...
[ { "answer_id": 387984, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 7, "selected": false, "text": "<p><strong>Copy</strong> should be used for NSString. If it's Mutable, then it gets copied. If it's not, then it just ge...
2008/12/23
[ "https://Stackoverflow.com/questions/387959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2288585/" ]
Let's say I have a class called `SomeClass` with a `string` property name: ``` @interface SomeClass : NSObject { NSString* name; } @property (nonatomic, retain) NSString* name; @end ``` I understand that name may be assigned a `NSMutableString` in which case this may lead to errant behavior. * For strings in...
For attributes whose type is an immutable value class that conforms to the `NSCopying` protocol, you almost always should specify `copy` in your `@property` declaration. Specifying `retain` is something you almost never want in such a situation. Here's why you want to do that: ``` NSMutableString *someName = [NSMutab...
388,024
<p>How does one copy resource files (config/data/image) files to an applictions home directory on the iPhone.</p> <p>A related question <a href="https://stackoverflow.com/questions/317959/loading-data-files-on-iphone">Loading Data Files on iPhone?</a>, received an answer "just add them to your project; Xcode will copy...
[ { "answer_id": 388054, "author": "frankodwyer", "author_id": 42404, "author_profile": "https://Stackoverflow.com/users/42404", "pm_score": 4, "selected": true, "text": "<p>In my app, I have a sql lite DB which I just dropped in the root of my project folder and added to the resources fol...
2008/12/23
[ "https://Stackoverflow.com/questions/388024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
How does one copy resource files (config/data/image) files to an applictions home directory on the iPhone. A related question [Loading Data Files on iPhone?](https://stackoverflow.com/questions/317959/loading-data-files-on-iphone), received an answer "just add them to your project; Xcode will copy them to the .app bun...
In my app, I have a sql lite DB which I just dropped in the root of my project folder and added to the resources folder of my project, and it winds up in the bundle, accessible by the app. <http://img68.imageshack.us/img68/3047/xcoderesourceslw5.png> I assume this will work for any file. I didn't have to write any s...
388,034
<p>Hannuka, Chanukah, Hanukkah...Due to transliteration from another language and character set, there are many ways to spell the name of this holiday. How many legitimate spellings can you come up with?</p> <p>Now, write a regular expression that will recognise all of them.</p>
[ { "answer_id": 388045, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 1, "selected": false, "text": "<p>Try this:</p>\n<pre><code> /^[ck]?hann?ukk?ah?$/i\n</code></pre>\n" }, { "answer_id": 388048, "author": "Cha...
2008/12/23
[ "https://Stackoverflow.com/questions/388034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19512/" ]
Hannuka, Chanukah, Hanukkah...Due to transliteration from another language and character set, there are many ways to spell the name of this holiday. How many legitimate spellings can you come up with? Now, write a regular expression that will recognise all of them.
According to <http://www.holidays.net/chanukah/spelling.htm>, it can be spelled any of the following ways: ``` Chanuka Chanukah Chanukkah Channukah Hanukah Hannukah Hanukkah Hanuka Hanukka Hanaka Haneka Hanika Khanukkah ``` Here is my regex that matches all of them: ``` /(Ch|H|Kh)ann?[aeiu]kk?ah?/ ``` **Edit:** O...
388,053
<p>If I have a point, and a road network, how do I find the nearest point ON the road? i.e. this is like snapping the point to a line/road.</p> <p>I am using ArcGis server 9.3 with Java 5 and Oracle 10g. I am using the ST functions and NetworkAnalyst via the java api.</p> <p>Thanks.</p>
[ { "answer_id": 388045, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 1, "selected": false, "text": "<p>Try this:</p>\n<pre><code> /^[ck]?hann?ukk?ah?$/i\n</code></pre>\n" }, { "answer_id": 388048, "author": "Cha...
2008/12/23
[ "https://Stackoverflow.com/questions/388053", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20242/" ]
If I have a point, and a road network, how do I find the nearest point ON the road? i.e. this is like snapping the point to a line/road. I am using ArcGis server 9.3 with Java 5 and Oracle 10g. I am using the ST functions and NetworkAnalyst via the java api. Thanks.
According to <http://www.holidays.net/chanukah/spelling.htm>, it can be spelled any of the following ways: ``` Chanuka Chanukah Chanukkah Channukah Hanukah Hannukah Hanukkah Hanuka Hanukka Hanaka Haneka Hanika Khanukkah ``` Here is my regex that matches all of them: ``` /(Ch|H|Kh)ann?[aeiu]kk?ah?/ ``` **Edit:** O...
388,057
<p>While dabbling in Clojure I've written a very basic program to echo whatever the user types into it. However, it doesn't run in a way that I'm perceiving to be natural. Here's the code:</p> <pre><code>(defn goo [] (print "echo&gt; ") (def resp (read-line)) (print resp) ) </code></pre> <p>I would expect the c...
[ { "answer_id": 388065, "author": "jmucchiello", "author_id": 44065, "author_profile": "https://Stackoverflow.com/users/44065", "pm_score": 5, "selected": true, "text": "<p>I know nothing of clojure but this sounds like a case of buffers not getting flushed. Figure out how to flush standa...
2008/12/23
[ "https://Stackoverflow.com/questions/388057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
While dabbling in Clojure I've written a very basic program to echo whatever the user types into it. However, it doesn't run in a way that I'm perceiving to be natural. Here's the code: ``` (defn goo [] (print "echo> ") (def resp (read-line)) (print resp) ) ``` I would expect the code to run like this (for me ...
I know nothing of clojure but this sounds like a case of buffers not getting flushed. Figure out how to flush standard out after the print. The println function probably flushes at the end of each line. Try: ``` (defn goo [] (print "echo> ") (flush ) (def resp (read-line)) (print resp) ) ```
388,069
<p>How do you gracefully handle failed future feature imports? If a user is running using Python 2.5 and the first statement in my module is:</p> <pre><code>from __future__ import print_function </code></pre> <p>Compiling this module for Python 2.5 will fail with a:</p> <pre><code> File "__init__.py", line 1 fr...
[ { "answer_id": 388083, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 7, "selected": true, "text": "<p>\"I'd like to inform the user that they need to rerun the program with Python >= 2.6 and maybe provide some instructions ...
2008/12/23
[ "https://Stackoverflow.com/questions/388069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3594/" ]
How do you gracefully handle failed future feature imports? If a user is running using Python 2.5 and the first statement in my module is: ``` from __future__ import print_function ``` Compiling this module for Python 2.5 will fail with a: ``` File "__init__.py", line 1 from __future__ import print_function S...
"I'd like to inform the user that they need to rerun the program with Python >= 2.6 and maybe provide some instructions on how to do so." Isn't that what a README file is for? Here's your alternative. A "wrapper": a little blob of Python that checks the environment before running your target aop. File: appwrapper.py...
388,099
<p>I have a ListBox with a StackPanel that contains an image and label.</p> <pre><code>&lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBox.ItemTemplate&gt; ...
[ { "answer_id": 388122, "author": "Matt Hamilton", "author_id": 615, "author_profile": "https://Stackoverflow.com/users/615", "pm_score": 3, "selected": true, "text": "<p>You certainly can have one image behind another. Instead of directly adding the image to your StackPanel, add a Grid a...
2008/12/23
[ "https://Stackoverflow.com/questions/388099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22451/" ]
I have a ListBox with a StackPanel that contains an image and label. ``` <ListBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation...
You certainly can have one image behind another. Instead of directly adding the image to your StackPanel, add a Grid and then add both images, like this: ``` <StackPanel Orientation="Vertical"> <Grid> <Image Source="..." /> <Image Source="{Binding Image}" ... /> </Grid> <Label Content="{Bin...
388,123
<p>I have a flash movie that loads images dynamically from an xml file. I want to re-use this .swf file on different pages, however the images on page1 are all 400 x 200 and the images on page2 are all 745 x 422. When i try to reuse this on another page, the loaded images are shrunken (resized) - i would like them to...
[ { "answer_id": 388139, "author": "jerebear", "author_id": 42979, "author_profile": "https://Stackoverflow.com/users/42979", "pm_score": 0, "selected": false, "text": "<p>I apologize I don't have the code at hand, but I know you have the option to set a no-resize on the canvas at startup....
2008/12/23
[ "https://Stackoverflow.com/questions/388123", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26685/" ]
I have a flash movie that loads images dynamically from an xml file. I want to re-use this .swf file on different pages, however the images on page1 are all 400 x 200 and the images on page2 are all 745 x 422. When i try to reuse this on another page, the loaded images are shrunken (resized) - i would like them to matc...
Couple of things... firstly you'll need to specify your app not to scale. (AS3 code) ``` stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; ``` Then once your image is loaded (add a listener to the slideLoader object), execute a javascript function using flash's ExternalInterface class. `...
388,173
<p>Is there a way to tidy-up the following code, rather than a series of nested try/except statements?</p> <pre><code>try: import simplejson as json except ImportError: try: import json except ImportError: try: from django.utils import simplejson as json except: ...
[ { "answer_id": 388360, "author": "Soviut", "author_id": 46914, "author_profile": "https://Stackoverflow.com/users/46914", "pm_score": 4, "selected": true, "text": "<p>I found the following function at <a href=\"http://mail.python.org/pipermail/python-list/2007-May/441896.html\" rel=\"nor...
2008/12/23
[ "https://Stackoverflow.com/questions/388173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
Is there a way to tidy-up the following code, rather than a series of nested try/except statements? ``` try: import simplejson as json except ImportError: try: import json except ImportError: try: from django.utils import simplejson as json except: raise "Req...
I found the following function at <http://mail.python.org/pipermail/python-list/2007-May/441896.html>. It seems to work quite well, and I'm pretty sure the way its importing won't stomp on any existing imports you might already have. ``` def module_exists(module_name): try: mod = __import__(module_name) ...
388,180
<p>I have a div 200 x 200 px. I want to place a 50 x 50 px image right in the middle of the div. </p> <p>How can it be done?</p> <p>I am able to get it centered horizontally by using <code>text-align: center</code> for the div. But vertical alignment is the issue..</p>
[ { "answer_id": 388186, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 3, "selected": false, "text": "<p>Typically, I'll set the <code>line-height</code> to be 200px. Usually does the trick.</p>\n" }, { "answer_...
2008/12/23
[ "https://Stackoverflow.com/questions/388180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48557/" ]
I have a div 200 x 200 px. I want to place a 50 x 50 px image right in the middle of the div. How can it be done? I am able to get it centered horizontally by using `text-align: center` for the div. But vertical alignment is the issue..
Personally, I'd place it as the background image within the div, the CSS for that being: ``` #demo { background: url(bg_apple_little.gif) no-repeat center center; height: 200px; width: 200px; } ``` (Assumes a div with `id="demo"` as you are already specifying `height` and `width` adding a `background` sh...
388,192
<p>I've been looking for a while how to play sound on the iphone, and I think it's something along the lines of:</p> <pre><code>[[NSSound soundNamed:@"cat.mp3"] play]; </code></pre> <p>But the NSSound is on the AppKit ... any suggestions ? I know there is a really simple answer to this, but today my searches are not ...
[ { "answer_id": 388198, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": false, "text": "<p>Audio Toolbox system sounds are great for short async playback.</p>\n\n<pre><code>// Initialize\nCFBundleRef mainBund...
2008/12/23
[ "https://Stackoverflow.com/questions/388192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23238/" ]
I've been looking for a while how to play sound on the iphone, and I think it's something along the lines of: ``` [[NSSound soundNamed:@"cat.mp3"] play]; ``` But the NSSound is on the AppKit ... any suggestions ? I know there is a really simple answer to this, but today my searches are not rendering any result ...
the new AVFoundation class is the easiest way to play sound on the iPhone, though it is for firmware 2.2 only: ``` AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; [audioPlayer play]; ``` you just need this import in the class that uses it: ``` #...
388,200
<p>I've done quite a bit of programming on Windows but now I have to write my first Linux app. </p> <p>I need to talk to a hardware device using UDP. I have to send 60 packets a second with a size of 40 bytes. If I send less than 60 packets within 1 second, bad things will happen. The data for the packets may take a w...
[ { "answer_id": 388215, "author": "Cogsy", "author_id": 48234, "author_profile": "https://Stackoverflow.com/users/48234", "pm_score": 1, "selected": false, "text": "<p>Two threads as you've suggested would work. If you have a pipe() between them, then your calculating thread can provide ...
2008/12/23
[ "https://Stackoverflow.com/questions/388200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48556/" ]
I've done quite a bit of programming on Windows but now I have to write my first Linux app. I need to talk to a hardware device using UDP. I have to send 60 packets a second with a size of 40 bytes. If I send less than 60 packets within 1 second, bad things will happen. The data for the packets may take a while to ge...
I posted this answer to illustrate a quite different approach to the "obvious" one, in the hope that someone discovers it to be exactly what they need. I didn't expect it to be selected as the best answer! Treat this solution with caution, because there are potential dangers and concurrency issues... You can use the [...
388,201
<p>I'm not sure if memory is the culprit here. I am trying to instantiate a GD image from data in memory (it previously came from a database). I try a call like this:</p> <pre><code>my $image = GD::Image-&gt;new($image_data); </code></pre> <p><code>$image</code> comes back as <code>undef</code>. The POD for GD say...
[ { "answer_id": 388250, "author": "jerebear", "author_id": 42979, "author_profile": "https://Stackoverflow.com/users/42979", "pm_score": 0, "selected": false, "text": "<p>I've run into the same problem a few times.</p>\n\n<p>One of my solutions was simply to increase the amount of memory ...
2008/12/23
[ "https://Stackoverflow.com/questions/388201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4257/" ]
I'm not sure if memory is the culprit here. I am trying to instantiate a GD image from data in memory (it previously came from a database). I try a call like this: ``` my $image = GD::Image->new($image_data); ``` `$image` comes back as `undef`. The POD for GD says that the constructor will return `undef` for cases o...
GD library eats many bytes per byte of image size. It's a well over a 10:1 ratio! When a user uploads an image to our system, we start by checking the file size before loading it into a GD image. If it's over a threshold (1 Megabyte) we don't use it but instead report an error to the user. If we really cared we could...
388,208
<p>Is there a way to set the default buffer size for JSPs in Tomcat? I know I can set them on every page, but am hoping there's a global option somewhere.</p>
[ { "answer_id": 388402, "author": "Olaf Kock", "author_id": 13447, "author_profile": "https://Stackoverflow.com/users/13447", "pm_score": 2, "selected": false, "text": "<p>EDIT: To lift the comments discussion to this answer - this might be what you're after</p>\n\n<p>When you're stuck wi...
2008/12/23
[ "https://Stackoverflow.com/questions/388208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48560/" ]
Is there a way to set the default buffer size for JSPs in Tomcat? I know I can set them on every page, but am hoping there's a global option somewhere.
Short answer: No. Long answer: Perhaps, with some hacking... * You'd have to build Tomcat yourself after editing this class: [Jasper constants](http://tomcat.apache.org/tomcat-6.0-doc/api/constant-values.html#org.apache.jasper.Constants.DEFAULT_BUFFER_SIZE) * ...or you can do a Perl pie, and edit all your JSPs all at...
388,223
<p>I have a page with this HTML:</p> <pre><code>&lt;p&gt; &lt;img src="images/ih01.jpg" width="80" height="110" align="left" /&gt; This course overs basic human anatomy and physiology, including the major body systems and their functions. When you have completed this course you will be able to identify...
[ { "answer_id": 388226, "author": "recursive", "author_id": 44743, "author_profile": "https://Stackoverflow.com/users/44743", "pm_score": 4, "selected": true, "text": "<p>Use: </p>\n\n<pre><code>&lt;img src=\"images/ih01.jpg\" style=\"float: left; height: 110px; width: 80px; \" &gt;\n</co...
2008/12/23
[ "https://Stackoverflow.com/questions/388223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
I have a page with this HTML: ``` <p> <img src="images/ih01.jpg" width="80" height="110" align="left" /> This course overs basic human anatomy and physiology, including the major body systems and their functions. When you have completed this course you will be able to identify major body components and...
Use: ``` <img src="images/ih01.jpg" style="float: left; height: 110px; width: 80px; " > ``` instead of align. The align attribute is [deprecated](http://www.w3schools.com/tags/tag_IMG.asp).
388,233
<p>I have a Question model &amp; Form, one of the fields in this model is <strong>userid=ForeignKey(User)</strong>, this Works perfectly well on the Question Model, am able to pick the user from a drop down. </p> <p>But kind a tricky when i want to list the question from the model, which is the best way to <strong>loo...
[ { "answer_id": 388296, "author": "ayaz", "author_id": 23191, "author_profile": "https://Stackoverflow.com/users/23191", "pm_score": 0, "selected": false, "text": "<p>I find your question vague. If you want to fetch all <code>Question</code> instances that are related to a particular <cod...
2008/12/23
[ "https://Stackoverflow.com/questions/388233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20894/" ]
I have a Question model & Form, one of the fields in this model is **userid=ForeignKey(User)**, this Works perfectly well on the Question Model, am able to pick the user from a drop down. But kind a tricky when i want to list the question from the model, which is the best way to **lookup** the user name from the User...
The name of your field (`userid` instead of `user`) makes me think that you may be confused about the behavior of Django's `ForeignKey`. If you define a model like this: ``` from django.contrib.auth.models import User from django.db import models class Question(models.Model): user = models.ForeignKey(User) t...
388,237
<p>Let's say I have the following code:</p> <pre><code>IBOutlet UITextField* nameTextField; IBOutlet UILabel* greetingLabel; </code></pre> <p>I'd like the <code>greetingLabel</code> to read "Hello [nameTextField]" as soon as the user presses any key.</p> <p>What I need basically is the iPhone equivalent of the Cocoa...
[ { "answer_id": 388395, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": false, "text": "<p>you could register an action for the event UIControlEventEditingChanges on the text field:</p>\n\n<pre><code>[nameTextField...
2008/12/23
[ "https://Stackoverflow.com/questions/388237", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2288585/" ]
Let's say I have the following code: ``` IBOutlet UITextField* nameTextField; IBOutlet UILabel* greetingLabel; ``` I'd like the `greetingLabel` to read "Hello [nameTextField]" as soon as the user presses any key. What I need basically is the iPhone equivalent of the Cocoa delegate method `controlTextDidChange`. Th...
It turns out, the easiest way to do this is using Interface Builder: * Add a IBAction (to the ViewController, say, as in this case) * Ctrl-Click (or right click) on the UITextField in Interface Builder * Connect the "Editing Changed" event to the File's Owner's IBAction added in the first step. Works like a charm :) ...
388,238
<p>this seems so silly - i must be missing something obvious. I have the following code (just as a test):</p> <pre><code>&lt;%@ Page Language="C#" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;script runat="server"&gt; vo...
[ { "answer_id": 388251, "author": "Dave Markle", "author_id": 24995, "author_profile": "https://Stackoverflow.com/users/24995", "pm_score": 2, "selected": false, "text": "<p>Try this in Page_Load:</p>\n\n<pre><code>Response.BufferOutput = false;\n</code></pre>\n\n<p>Also get a copy of <a ...
2008/12/23
[ "https://Stackoverflow.com/questions/388238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31902/" ]
this seems so silly - i must be missing something obvious. I have the following code (just as a test): ``` <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void page_load(object o, EventArgs...
I put my 2 cents on that when you access the public site, you are running through a web proxy, and that is where the content is being cached.
388,258
<p>In my Dev C++, I am trying to create a 2D Array class that acts like a Grid. But one of the problem is I am unsure what do for the constructor.</p> <p>When I try to compile, I get the following errors: In constructor 'Grid::Grid(int,int)': 'sqaures' is not a type 'yPos' cannot appear in a constant-expression [Build...
[ { "answer_id": 388265, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 1, "selected": false, "text": "<p>Are you sure you got the code right? Your squares is defined as an int, not as an int**?\nI'm not sure how you're getting t...
2008/12/23
[ "https://Stackoverflow.com/questions/388258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In my Dev C++, I am trying to create a 2D Array class that acts like a Grid. But one of the problem is I am unsure what do for the constructor. When I try to compile, I get the following errors: In constructor 'Grid::Grid(int,int)': 'sqaures' is not a type 'yPos' cannot appear in a constant-expression [Build Error] [g...
Not directly related to your question, but you should not have using declarations in your header (.h/.hpp) files. e.g.: ``` using namespace std; ``` These belong in cpp files. See [Herb Sutters GOTW (Guru of the Week) #53](http://www.gotw.ca/gotw/053.htm) for reasons.
388,295
<p>Python, C++, Scheme, and others all let you define functions that take a variable number of arguments at the end of the argument list...</p> <pre><code>def function(a, b, *args): #etc... </code></pre> <p>...that can be called as followed:</p> <pre><code>function(1, 2) function(1, 2, 5, 6, 7, 8) </code></pre> ...
[ { "answer_id": 388306, "author": "Yuval F", "author_id": 1702, "author_profile": "https://Stackoverflow.com/users/1702", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.psg.com/~dlamkins/sl/chapter21.html\" rel=\"nofollow noreferrer\">Lisp's keyword parameters</a> may ...
2008/12/23
[ "https://Stackoverflow.com/questions/388295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
Python, C++, Scheme, and others all let you define functions that take a variable number of arguments at the end of the argument list... ``` def function(a, b, *args): #etc... ``` ...that can be called as followed: ``` function(1, 2) function(1, 2, 5, 6, 7, 8) ``` etc... Are there any languages that allow you...
Future versions of Ruby (1.9 and up, Ruby 1.9 is scheduled to released at the end of January, 2009) can do this. It is however not always obvious which value gets bound to which parameter. This is what Ruby 1.9 accepts: 0 or more mandatory arguments followed by 0 or more optional arguments followed by 0 or more mand...
388,302
<p>It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy of the matrix?</p>
[ { "answer_id": 390451, "author": "Gavin Miller", "author_id": 33226, "author_profile": "https://Stackoverflow.com/users/33226", "pm_score": 3, "selected": false, "text": "<p><strong>PREAMBLE</strong>:<br/></p>\n\n<p>Given the right sequestration of data, one could achieve parallel comput...
2008/12/23
[ "https://Stackoverflow.com/questions/388302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy of the matrix?
**PREAMBLE**: Given the right sequestration of data, one could achieve parallel computing results without a complete dataset on every machine. Take for example the following loop: ``` for (int i = 0; i < m[].length; i++) { for (int j = 0; j < m[i].length; j++) { m[i][j]++; } } ``` And given ...
388,328
<p>Ok, let me explain more... the goal is to make the checkbox checked if there's a change on select. The actual code was:</p> <pre><code>function checkit(date) { document.forms[0].date.checked = true; } &lt;input type="checkbox" name="date[]" value="2008-08-14"&gt;Aug 14, 2008&lt;br&gt; &lt;select name="slot[]"...
[ { "answer_id": 388339, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 1, "selected": false, "text": "<p>What exactly are you trying to do with this code ?</p>\n\n<p>According to your piece of code (which has some synt...
2008/12/23
[ "https://Stackoverflow.com/questions/388328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47301/" ]
Ok, let me explain more... the goal is to make the checkbox checked if there's a change on select. The actual code was: ``` function checkit(date) { document.forms[0].date.checked = true; } <input type="checkbox" name="date[]" value="2008-08-14">Aug 14, 2008<br> <select name="slot[]" size="1" onchange="checkit(da...
It doesn't work because (as [dreas](https://stackoverflow.com/users/44084/) [said](https://stackoverflow.com/questions/388328/#388339)) your HTML-code has errors and you are naming your variables in a way that conflicts with javascript syntax. The name of your input is **date[1]** and the **[** and **]** have special ...
388,344
<p>I am modifying a Nant build script to run some unit tests. I have different targets for locally run tests and tests to be run on team city.</p> <pre><code>&lt;target name=&quot;run-unit-tests&quot;&gt; &lt;property name=&quot;test.executable&quot; value=&quot;tools\nunit\nunit-console.exe&quot;/&gt; &lt;call...
[ { "answer_id": 388425, "author": "Stobor", "author_id": 43452, "author_profile": "https://Stackoverflow.com/users/43452", "pm_score": 3, "selected": true, "text": "<p>You can define properties in one target, and use their values in the other... For example, you can define</p>\n\n<pre><co...
2008/12/23
[ "https://Stackoverflow.com/questions/388344", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39532/" ]
I am modifying a Nant build script to run some unit tests. I have different targets for locally run tests and tests to be run on team city. ``` <target name="run-unit-tests"> <property name="test.executable" value="tools\nunit\nunit-console.exe"/> <call target="do-unit-tests"/> </target> <target name="run-uni...
You can define properties in one target, and use their values in the other... For example, you can define ``` <target name="run-unit-tests"> <property name="test.executable" value="tools\nunit\nunit-console.exe"/> <property name="test.extratestargs" value="foo,bar,baz"/> <call target="do-unit-tests"/> </targe...
388,356
<p>What is the recommended way of including a Javascript file from another Javascript file?</p>
[ { "answer_id": 388363, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 0, "selected": false, "text": "<p>How about this:</p>\n\n<p>(<a href=\"http://www.cryer.co.uk/resources/javascript/script17_include_js_from_js.htm\" rel=\"no...
2008/12/23
[ "https://Stackoverflow.com/questions/388356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48557/" ]
What is the recommended way of including a Javascript file from another Javascript file?
Most people add the JavaScript file to the head of the document: ``` <script type="text/javascript"> var newfile=document.createElement('script'); newfile.setAttribute("type","text/javascript"); newfile.setAttribute("src", '/myscript.js'); document.getElementsByTagName("head")[0].appendChild(newfile); </script...
388,357
<p>I have a JfreeReport Application which run under Tomcat inside a jar. In the report template (which exists outside the jar) I have the following: file:///var/lib/tomcat5.5/webapps/Reports/images/logo.gif But then I get exception: org.jfree.report.modules.ModuleInitializeException: Unable to create the sp...
[ { "answer_id": 388363, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 0, "selected": false, "text": "<p>How about this:</p>\n\n<p>(<a href=\"http://www.cryer.co.uk/resources/javascript/script17_include_js_from_js.htm\" rel=\"no...
2008/12/23
[ "https://Stackoverflow.com/questions/388357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a JfreeReport Application which run under Tomcat inside a jar. In the report template (which exists outside the jar) I have the following: file:///var/lib/tomcat5.5/webapps/Reports/images/logo.gif But then I get exception: org.jfree.report.modules.ModuleInitializeException: Unable to create the specified dire...
Most people add the JavaScript file to the head of the document: ``` <script type="text/javascript"> var newfile=document.createElement('script'); newfile.setAttribute("type","text/javascript"); newfile.setAttribute("src", '/myscript.js'); document.getElementsByTagName("head")[0].appendChild(newfile); </script...
388,358
<p>I've been using HInclude (<a href="http://www.mnot.net/javascript/hinclude/" rel="nofollow noreferrer">http://www.mnot.net/javascript/hinclude/</a>) for sometime now and its working great, but there is one problem though. The part of my site which is fetched using HInclude doesn't get refreshed everytime I hit the b...
[ { "answer_id": 388363, "author": "Ben", "author_id": 11522, "author_profile": "https://Stackoverflow.com/users/11522", "pm_score": 0, "selected": false, "text": "<p>How about this:</p>\n\n<p>(<a href=\"http://www.cryer.co.uk/resources/javascript/script17_include_js_from_js.htm\" rel=\"no...
2008/12/23
[ "https://Stackoverflow.com/questions/388358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44916/" ]
I've been using HInclude (<http://www.mnot.net/javascript/hinclude/>) for sometime now and its working great, but there is one problem though. The part of my site which is fetched using HInclude doesn't get refreshed everytime I hit the back button in Internet Exploer (6.x + and 7.0 also). It works fine on other browse...
Most people add the JavaScript file to the head of the document: ``` <script type="text/javascript"> var newfile=document.createElement('script'); newfile.setAttribute("type","text/javascript"); newfile.setAttribute("src", '/myscript.js'); document.getElementsByTagName("head")[0].appendChild(newfile); </script...
388,365
<p>I'm trying to POST to the HTTP gateway of an SMS provider (Sybase 365) using CURL from a Linux shell script.</p> <p>I need to pass the following data (note the [ ] and LF characters)</p> <pre><code>[MSISDN] List=+12345678 [MESSAGE] Text=Hello [END] </code></pre> <p>If I submit a file using the -F parameter, CURL ...
[ { "answer_id": 388371, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Probably a silly thought, but I don't suppose it actually requires CRLF instead of just LF?</p>\n\n<p>Alternatively, ...
2008/12/23
[ "https://Stackoverflow.com/questions/388365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1456/" ]
I'm trying to POST to the HTTP gateway of an SMS provider (Sybase 365) using CURL from a Linux shell script. I need to pass the following data (note the [ ] and LF characters) ``` [MSISDN] List=+12345678 [MESSAGE] Text=Hello [END] ``` If I submit a file using the -F parameter, CURL removes the LF e.g. ``` curl -F ...
I've got this working using -d ``` request=`printf "[MSISDN]\nList=$number\n[MESSAGE]\nText=$message\n[END]\n"` response=`curl -s -u $username:$password -d "$request" http://www.sybase.com/...` ``` Curiously, if I use -d @myfile (where myfile contains LF separated text), it doesn't work. I also tried --data-binary ...
388,431
<p>I have a function (called "powersearch", the irony!) that searches for a set of strings across a bunch(~ 5) of fields. The words come in as one string and are separated by spaces.<br> Some fields can have exact matches, others should have "contains". </p> <p>(Snipped for brevety)</p> <pre><code>//Start with all c...
[ { "answer_id": 388893, "author": "Brendan Cashman", "author_id": 5814, "author_profile": "https://Stackoverflow.com/users/5814", "pm_score": 0, "selected": false, "text": "<p>I've never used jfreechart tooltips before, but that maybe what you're looking for.</p>\n\n<p>There a series of c...
2008/12/23
[ "https://Stackoverflow.com/questions/388431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I have a function (called "powersearch", the irony!) that searches for a set of strings across a bunch(~ 5) of fields. The words come in as one string and are separated by spaces. Some fields can have exact matches, others should have "contains". (Snipped for brevety) ``` //Start with all colors IQueryable<Color>...
Use the ToolTipManager. If you can register the graph as a component, you can assign a specific tooltip to it which will be displayed automatically. If you cant use the default version it's also possible to write a custom ToolTipManager, which displays the tooltip when the cursor is over certain areas on the screen.
388,434
<p>How do i unset a already set flag using fcntl?</p> <p>For e.g. I can set the socket to nonblocking mode using </p> <pre><code>fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) </code></pre> <p>Now, i want to unset the O_NONBLOCK flag.</p> <p>I tried fcntl(sockfd, F_SETFL, flags | ~O_NONBLOCK). It gave me error EINVAL</...
[ { "answer_id": 388441, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 4, "selected": true, "text": "<pre><code>int oldfl;\noldfl = fcntl(sockfd, F_GETFL);\nif (oldfl == -1) {\n /* handle error */\n}\nfcntl(sockfd, F_SETFL,...
2008/12/23
[ "https://Stackoverflow.com/questions/388434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39615/" ]
How do i unset a already set flag using fcntl? For e.g. I can set the socket to nonblocking mode using ``` fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) ``` Now, i want to unset the O\_NONBLOCK flag. I tried fcntl(sockfd, F\_SETFL, flags | ~O\_NONBLOCK). It gave me error EINVAL
``` int oldfl; oldfl = fcntl(sockfd, F_GETFL); if (oldfl == -1) { /* handle error */ } fcntl(sockfd, F_SETFL, oldfl & ~O_NONBLOCK); ``` Untested, but hope this helps. :-)
388,436
<p>I have some jQuery code. I have called an Ajax function file, file.php, that has some fields, like:</p> <pre><code>&lt;input type="radio" value="plz"&gt;Milk&lt;/input&gt;. </code></pre> <p>Will I assign into again jQuery function? If so, how do I do it? I attached a sample file:</p> <pre><code>&lt;html&gt; &...
[ { "answer_id": 388450, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 5, "selected": true, "text": "<p>The <code>success</code> function takes a parameter, which contains the fetched data. So in your example:</p>\n\n<pre><co...
2008/12/23
[ "https://Stackoverflow.com/questions/388436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
I have some jQuery code. I have called an Ajax function file, file.php, that has some fields, like: ``` <input type="radio" value="plz">Milk</input>. ``` Will I assign into again jQuery function? If so, how do I do it? I attached a sample file: ``` <html> <head> <LINK REL=StyleSheet HREF="examples.css" ...
The `success` function takes a parameter, which contains the fetched data. So in your example: ``` $(document).ready( function(){ $.ajax({ type:"GET", url:"file.php", data:id, success:function(txt){ $.prompt( txt,{ opacity: 0.2 }); }, // ... more ... } }); `...
388,439
<p>Java 5 introduced generics, and they were added to many interfaces in the <code>java.lang</code> package. However, <code>Cloneable</code> did not get generics. I wonder why?</p> <hr> <p><strong>Edit:</strong> In reply to the answers of @Jon and @litb, and the comment of @Earwicker, I was thinking <code>Cloneable</...
[ { "answer_id": 388448, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>The Cloneable interface doesn't contain any members. What would be the point of making it generic?</p>\n\n<p>(If Clone...
2008/12/23
[ "https://Stackoverflow.com/questions/388439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
Java 5 introduced generics, and they were added to many interfaces in the `java.lang` package. However, `Cloneable` did not get generics. I wonder why? --- **Edit:** In reply to the answers of @Jon and @litb, and the comment of @Earwicker, I was thinking `Cloneable` might be: ``` public interface Cloneable<T> { ...
The Cloneable interface doesn't contain any members. What would be the point of making it generic? (If Cloneable contained the clone() method, it would make sense - but that's declared in java.lang.Object.) EDIT: clone() is in java.lang.Object as it has an implementation (which does a field-by-field copy). A better d...
388,464
<p>I'm creating a function where I need to pass an object so that it can be modified by the function. What is the difference between:</p> <pre><code>public void myFunction(ref MyClass someClass) </code></pre> <p>and</p> <pre><code>public void myFunction(out MyClass someClass) </code></pre> <p>Which should I use and...
[ { "answer_id": 388465, "author": "Ruben Bartelink", "author_id": 11635, "author_profile": "https://Stackoverflow.com/users/11635", "pm_score": 5, "selected": false, "text": "<p><a href=\"http://luisabreu.wordpress.com/2010/09/02/parameters-by-reference/\" rel=\"noreferrer\">ref is in <st...
2008/12/23
[ "https://Stackoverflow.com/questions/388464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1816/" ]
I'm creating a function where I need to pass an object so that it can be modified by the function. What is the difference between: ``` public void myFunction(ref MyClass someClass) ``` and ``` public void myFunction(out MyClass someClass) ``` Which should I use and why?
`ref` tells the compiler that the object is initialized before entering the function, while `out` tells the compiler that the object will be initialized inside the function. So while `ref` is two-ways, `out` is out-only.
388,468
<p>I am using the ListView Control with the following datasource <code>List&lt;MyObject&gt;</code></p> <p>On my listview control i have an OnItemDataBound</p> <p></p> <p>My question is how do get the current value of MyObject. Ie myObj[5].FirstName</p> <p>protected void ItemsListViewDataBound(object sender, ListVie...
[ { "answer_id": 388509, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 5, "selected": true, "text": "<pre><code>protected void MyListView_DataBind(object sender, ListViewItemEventArgs e){\n if(e.Item.ItemType == ListVi...
2008/12/23
[ "https://Stackoverflow.com/questions/388468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/461880/" ]
I am using the ListView Control with the following datasource `List<MyObject>` On my listview control i have an OnItemDataBound My question is how do get the current value of MyObject. Ie myObj[5].FirstName protected void ItemsListViewDataBound(object sender, ListViewItemEventArgs e) { // I want to do some kind of a...
``` protected void MyListView_DataBind(object sender, ListViewItemEventArgs e){ if(e.Item.ItemType == ListViewItemType.DataItem){ MyObject p = (MyObject)((ListViewDataItem)e.Item).DataItem; } } ``` You'll want to do the type check so that you don't try and do a cast when you're working on say, the header item...
388,470
<p>I am using C#.net for application development.</p> <p>To log and debug exceptions, I use the stacktrace.</p> <p>I executed my application on another machine, but when errors occur it refers to the path of my development machine.</p> <pre><code>Ex: D:\Projects\xyz.CS line no :12 _Error_message_here. </code></pre...
[ { "answer_id": 388486, "author": "TheSoftwareJedi", "author_id": 18941, "author_profile": "https://Stackoverflow.com/users/18941", "pm_score": 5, "selected": false, "text": "<p>The original compiled path is stored in the debug information within the PDB files.</p>\n" }, { "answer...
2008/12/23
[ "https://Stackoverflow.com/questions/388470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using C#.net for application development. To log and debug exceptions, I use the stacktrace. I executed my application on another machine, but when errors occur it refers to the path of my development machine. ``` Ex: D:\Projects\xyz.CS line no :12 _Error_message_here. ``` Why does it trace to the path on m...
The original compiled path is stored in the debug information within the PDB files.
388,483
<p>I'm trying to use the <code>Html.DropDownList</code> extension method but can't figure out how to use it with an enumeration.</p> <p>Let's say I have an enumeration like this:</p> <pre><code>public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } </code></pre> <p>How do I go about creating a dropdown ...
[ { "answer_id": 388590, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 3, "selected": false, "text": "<p>You want to look at using something like <a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.enum.getvalu...
2008/12/23
[ "https://Stackoverflow.com/questions/388483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I'm trying to use the `Html.DropDownList` extension method but can't figure out how to use it with an enumeration. Let's say I have an enumeration like this: ``` public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } ``` How do I go about creating a dropdown with these values using the `Html.DropDownLi...
For MVC v5.1 use Html.EnumDropDownListFor ----------------------------------------- ``` @Html.EnumDropDownListFor( x => x.YourEnumField, "Select My Type", new { @class = "form-control" }) ``` --- For MVC v5 use EnumHelper ------------------------- ``` @Html.DropDownList("MyType", EnumHelper.GetSel...
388,492
<p>When I visually scale an image, Firefox 3 blurs it. Firefox 2 and other browsers don't, which is the behavior I expect. This is especially lame for creating a web based game using png or gif sprites.</p> <p>For example, when showing a 100x100 image in Firefox 3 like this:</p> <pre><code>&lt;img src="sprite.gif" wi...
[ { "answer_id": 388499, "author": "olliej", "author_id": 784, "author_profile": "https://Stackoverflow.com/users/784", "pm_score": 2, "selected": false, "text": "<p>You're scaling the image up from its original size -- the desired effect is <em>normally</em> to have smooth scaling, and it...
2008/12/23
[ "https://Stackoverflow.com/questions/388492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48595/" ]
When I visually scale an image, Firefox 3 blurs it. Firefox 2 and other browsers don't, which is the behavior I expect. This is especially lame for creating a web based game using png or gif sprites. For example, when showing a 100x100 image in Firefox 3 like this: ``` <img src="sprite.gif" width="200" /> ``` or `...
I discovered this new feature of FireFox: <http://developer.mozilla.org/En/CSS/Image-rendering> So putting this in your CSS will fix it: ``` image-rendering: -moz-crisp-edges; ``` Thought I'd share this info. Sorry for answering my own question ;)
388,493
<p>How can we avoid Master Page from posting back the whole page?</p>
[ { "answer_id": 388523, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>The Master Page isn't responsible for the PostBack, that's what the HTML form is for.</p>\n\n<p>The only way you <...
2008/12/23
[ "https://Stackoverflow.com/questions/388493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48581/" ]
How can we avoid Master Page from posting back the whole page?
Just to clarify - the update panel doesn't prevent a whole page postback or a full page lifecycle. It just causes that process to be completed in the background "unseen" to the user. The only difference is that upon completion of the postback only the section wrapped by the update panel declaration is refreshed, thus c...
388,497
<pre><code>select (Case Remark01 When 'l1' then type1 when 'l2' then type2 end) AS [?] --Remark .....want to switch name in here from mytable </code></pre> <p>Example ....</p> <pre><code>select (Case level When 'l1' then type1 ('l1' mean check constant string) when 'l2' then type2(('l2' mean check constant string))...
[ { "answer_id": 388523, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>The Master Page isn't responsible for the PostBack, that's what the HTML form is for.</p>\n\n<p>The only way you <...
2008/12/23
[ "https://Stackoverflow.com/questions/388497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` select (Case Remark01 When 'l1' then type1 when 'l2' then type2 end) AS [?] --Remark .....want to switch name in here from mytable ``` Example .... ``` select (Case level When 'l1' then type1 ('l1' mean check constant string) when 'l2' then type2(('l2' mean check constant string)) end) AS **(Case when 'l1' the...
Just to clarify - the update panel doesn't prevent a whole page postback or a full page lifecycle. It just causes that process to be completed in the background "unseen" to the user. The only difference is that upon completion of the postback only the section wrapped by the update panel declaration is refreshed, thus c...
388,554
<p>Is there any possibility how to enumerate AppDomains within Process?</p>
[ { "answer_id": 388582, "author": "Brann", "author_id": 47341, "author_profile": "https://Stackoverflow.com/users/47341", "pm_score": 7, "selected": true, "text": "<p>You may want to look at <a href=\"https://learn.microsoft.com/en-us/archive/blogs/jackg/enumerating-appdomains\" rel=\"nof...
2008/12/23
[ "https://Stackoverflow.com/questions/388554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43178/" ]
Is there any possibility how to enumerate AppDomains within Process?
You may want to look at [this post](https://learn.microsoft.com/en-us/archive/blogs/jackg/enumerating-appdomains) ``` using System.Runtime.InteropServices; // Add the following as a COM reference - C:\WINDOWS\Microsoft.NET\Framework\vXXXXXX\mscoree.tlb using mscoree; public stati...
388,556
<p>I have an action method that that returns a PagedList&lt;> after a form's POST request.<br> I would like to add paging to this page, but all paging scenarios only seem to work with GET requests.</p> <p>Currently the only way of adding paging controls is adding a bunch of forms with one button for navigating the pag...
[ { "answer_id": 388968, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 0, "selected": false, "text": "<p>The way to add many optional parameters to a GET request is to use query string parameters. Make the arguments to yo...
2008/12/23
[ "https://Stackoverflow.com/questions/388556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
I have an action method that that returns a PagedList<> after a form's POST request. I would like to add paging to this page, but all paging scenarios only seem to work with GET requests. Currently the only way of adding paging controls is adding a bunch of forms with one button for navigating the page. This will l...
Each paging button has one unique value you need to submit along with the rest of your form values. So you really only need something such as: ``` function GoToPage(pageNumber) { // submit form along with pageNumber return false; } <a href="javascript:GoToPage(1);">1</a> <a href="javascript:GoToPage(2);">2</...
388,557
<p>I like .NET webcontrols and you manipulate things, that's common consensus, but XML and XSL is so great, because you have UI logic that is platform &amp; language-independent, so one day I change the app to php, java or whatever and i can reuse all the presentation logic. Moreover, XSL has the possibility to call ....
[ { "answer_id": 388605, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Not so much in the ASP.NET stuff, but before that (with VB6) I used to use it almost exclusively (at the server) t...
2008/12/23
[ "https://Stackoverflow.com/questions/388557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31791/" ]
I like .NET webcontrols and you manipulate things, that's common consensus, but XML and XSL is so great, because you have UI logic that is platform & language-independent, so one day I change the app to php, java or whatever and i can reuse all the presentation logic. Moreover, XSL has the possibility to call .NET (or...
Instead of HTML? I use it constantly in place of asp.net controls since it affords the separation of concerns for the V and the C in 2.0 that you don't get in .NET 2.0 out of the box. Obviously there's a million other uses unrelated to asp.net controls. --- Edit: a sketch of an implementation ``` public class xsl...
388,561
<p>thank you. here is the correct question:</p> <pre><code>{ "VID":"60", "name":"\u4f1a\u9634", "requireLevel":"20", "levelMax":"5", "venationRequirement":"0", "description":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8[Affect1]\u70b9", "cost":{"1":"240","2":"360","3":"400","4":"600","5":"720"}, ...
[ { "answer_id": 388564, "author": "Ruben Bartelink", "author_id": 11635, "author_profile": "https://Stackoverflow.com/users/11635", "pm_score": 0, "selected": false, "text": "<p>The [] syntax is explicitly for creating arrays whereas {} has a completely different meaning (it thinks you're...
2008/12/23
[ "https://Stackoverflow.com/questions/388561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
thank you. here is the correct question: ``` { "VID":"60", "name":"\u4f1a\u9634", "requireLevel":"20", "levelMax":"5", "venationRequirement":"0", "description":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8[Affect1]\u70b9", "cost":{"1":"240","2":"360","3":"400","4":"600","5":"720"}, "difficult":...
Your second one is wrong because you're evaluating a hash, for it to work you'd need to rewrite it to be something like: ``` var s = '{"first": {"a":1}, "second": {"b":2}}'; ```
388,565
<p>We have some web pages which have two frames, with one frame in the IE 6 search bar (created using the <code>open("path.htm", "_search");</code> call). The page shown in the frame on the search bar contains buttons, on click of which we update the right frame. On migration to IE 7, both frames open in their own wind...
[ { "answer_id": 388564, "author": "Ruben Bartelink", "author_id": 11635, "author_profile": "https://Stackoverflow.com/users/11635", "pm_score": 0, "selected": false, "text": "<p>The [] syntax is explicitly for creating arrays whereas {} has a completely different meaning (it thinks you're...
2008/12/23
[ "https://Stackoverflow.com/questions/388565", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9195/" ]
We have some web pages which have two frames, with one frame in the IE 6 search bar (created using the `open("path.htm", "_search");` call). The page shown in the frame on the search bar contains buttons, on click of which we update the right frame. On migration to IE 7, both frames open in their own windows, i.e, I no...
Your second one is wrong because you're evaluating a hash, for it to work you'd need to rewrite it to be something like: ``` var s = '{"first": {"a":1}, "second": {"b":2}}'; ```
388,570
<p>Why doesnt TestDriven.Net work with my gallio/mbunit tests?</p> <p>I've used TDD.Net with MbUnit v2 and not had any problems, but with the new gallio release on my new pc, it does nothing.</p> <p>From the tdd right click menu in solution explorer, if i do "test with debugger" i get "0 passed, 0 failed, 0 skipped" ...
[ { "answer_id": 397353, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 1, "selected": false, "text": "<p>Lots of uninstalling, rebooting and reinstalling seems to have solved it :s</p>\n" }, { "answer_id": 418...
2008/12/23
[ "https://Stackoverflow.com/questions/388570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28543/" ]
Why doesnt TestDriven.Net work with my gallio/mbunit tests? I've used TDD.Net with MbUnit v2 and not had any problems, but with the new gallio release on my new pc, it does nothing. From the tdd right click menu in solution explorer, if i do "test with debugger" i get "0 passed, 0 failed, 0 skipped" in the VS status ...
You just need to make sure you install TestDriven.Net before Gallio. Otherwise the Gallio installer will not install its extensions for TestDriven.Net.
388,585
<p>I have quite a few RewriteRules in my .htaccess that looks like this</p> <pre><code>RewriteRule ^something/(\d+)/start /index.php?ix=$1 RewriteRule ^embed/something/(\d+)/start /index.php?ix=$1&amp;fEmbed=1 </code></pre> <p>The only difference between these two is the leading "embed/", so I was thinking it w...
[ { "answer_id": 388603, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 2, "selected": true, "text": "<p>I think it should be two rules, but they shouldn't do the same thing. The following is untested, but hopefully the intention...
2008/12/23
[ "https://Stackoverflow.com/questions/388585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1606/" ]
I have quite a few RewriteRules in my .htaccess that looks like this ``` RewriteRule ^something/(\d+)/start /index.php?ix=$1 RewriteRule ^embed/something/(\d+)/start /index.php?ix=$1&fEmbed=1 ``` The only difference between these two is the leading "embed/", so I was thinking it would be beneficial to combine ...
I think it should be two rules, but they shouldn't do the same thing. The following is untested, but hopefully the intention is clear, if it doesn't work "out-of-the-box": ``` RewriteRule ^(embed/)?something/(\d+)/start$ /index.php?ix=$2 RewriteRule ^embed/(.*) $1&fEmbed=1 ``` I'm assuming "/start" is always a...
388,595
<p>What advantages do either method offer for html, css and javascript files served by a LAMP server. Are there better alternatives?</p> <p>The server provides information to a map application using Json, so a high volume of small files.</p> <p><strong>See also <a href="https://stackoverflow.com/questions/211284/is-t...
[ { "answer_id": 388623, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 2, "selected": false, "text": "<p>The main reason is that deflate is faster to encode than gzip and on a busy server that might make a difference. ...
2008/12/23
[ "https://Stackoverflow.com/questions/388595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20074/" ]
What advantages do either method offer for html, css and javascript files served by a LAMP server. Are there better alternatives? The server provides information to a map application using Json, so a high volume of small files. **See also [Is there any performance hit involved in choosing gzip over deflate for http c...
> > Why use deflate instead of gzip for text files served by Apache? > > > The simple answer is **don't**. --- [RFC 2616](http://www.ietf.org/rfc/rfc2616.txt) defines deflate as: > > deflate The "zlib" format defined in RFC 1950 in combination with the "deflate" compression mechanism described in RFC 1951 > ...
388,599
<p>When transmitting data, the Hamming code apparently allows you to recreate data that has been corrupted over the wire (an error correcting code).</p> <p>How does this work and what are its limitations, if any?</p> <p>Are there any better solutions for error correction (as opposed to retransmission)? Are there circ...
[ { "answer_id": 388607, "author": "Brann", "author_id": 47341, "author_profile": "https://Stackoverflow.com/users/47341", "pm_score": 3, "selected": false, "text": "<p>You will find details on the way it works <a href=\"http://en.wikipedia.org/wiki/Hamming_code\" rel=\"nofollow noreferrer...
2008/12/23
[ "https://Stackoverflow.com/questions/388599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14860/" ]
When transmitting data, the Hamming code apparently allows you to recreate data that has been corrupted over the wire (an error correcting code). How does this work and what are its limitations, if any? Are there any better solutions for error correction (as opposed to retransmission)? Are there circumstances where r...
Let's try to explain it a bit: We have a 3 bit number. The possibilities can be presented as a cube where each bit represent an axis. The eight possibilities are on the corners. ``` 000 --------001 | \ | \ | 100---------101 | | | | | | | | 010-|-------011 | \| \| 110------...
388,624
<p>I am trying to implement a ListView data control for displaying and editing lookup table/ application level variables. There are multiple entity classes which can be bound to the ListView, so the ItemTemplate needs to be dynamically bound to the selected entity object.</p> <p>For example i have: </p> <pre><code>Ad...
[ { "answer_id": 388635, "author": "Moran Helman", "author_id": 1409636, "author_profile": "https://Stackoverflow.com/users/1409636", "pm_score": 0, "selected": false, "text": "<p>maybe your answer is to bind a repeater inside the itemTemplate </p>\n\n<p>and the repeater will get the datas...
2008/12/23
[ "https://Stackoverflow.com/questions/388624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35286/" ]
I am trying to implement a ListView data control for displaying and editing lookup table/ application level variables. There are multiple entity classes which can be bound to the ListView, so the ItemTemplate needs to be dynamically bound to the selected entity object. For example i have: ``` AddressType { AddressTy...
Ok in answer to your questions: * You can iterate over the ListViewItems by using the OnItemDataBound event in the parent ListView. You can then use this to databind nested child ListViews (or insert Html or manipulate the contents of the list in any way you need). Make sure you use ListViewItemEventArgs in your code ...
388,642
<p>I have a repeater that should show a bound field value only if it exists. Having read <a href="https://stackoverflow.com/questions/368169/conditional-logic-in-aspnet-page">this post</a> I decided to do it by using a literal within my repeater and using the OnItemDatabound trigger to populate my literal but my litera...
[ { "answer_id": 388635, "author": "Moran Helman", "author_id": 1409636, "author_profile": "https://Stackoverflow.com/users/1409636", "pm_score": 0, "selected": false, "text": "<p>maybe your answer is to bind a repeater inside the itemTemplate </p>\n\n<p>and the repeater will get the datas...
2008/12/23
[ "https://Stackoverflow.com/questions/388642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40623/" ]
I have a repeater that should show a bound field value only if it exists. Having read [this post](https://stackoverflow.com/questions/368169/conditional-logic-in-aspnet-page) I decided to do it by using a literal within my repeater and using the OnItemDatabound trigger to populate my literal but my literal doesn't seem...
Ok in answer to your questions: * You can iterate over the ListViewItems by using the OnItemDataBound event in the parent ListView. You can then use this to databind nested child ListViews (or insert Html or manipulate the contents of the list in any way you need). Make sure you use ListViewItemEventArgs in your code ...
388,650
<p>I want to check the following with regular expression</p> <pre><code>{Today,Format} </code></pre> <p>Today - will be remains as it is. In the place of Format, we can allow the digits from 0 to 12.</p> <p>for example: we have to allow</p> <pre><code>{Today,0} {Today,1} {Today,2} ... {Today,12} </code></pre> <p>a...
[ { "answer_id": 388654, "author": "flesh", "author_id": 27805, "author_profile": "https://Stackoverflow.com/users/27805", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://txt2re.com/\" rel=\"nofollow noreferrer\">txt2re.com</a> is a brilliant web-based regex generator...</p>...
2008/12/23
[ "https://Stackoverflow.com/questions/388650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38172/" ]
I want to check the following with regular expression ``` {Today,Format} ``` Today - will be remains as it is. In the place of Format, we can allow the digits from 0 to 12. for example: we have to allow ``` {Today,0} {Today,1} {Today,2} ... {Today,12} ``` and also have to allow ``` {Today,} {Today,Format} ```...
``` \{Today,(\d|1[012]|Format)?\} ``` Meaning: * Open curly brace; * 'Today,'; * Optionally one of the following: a digit (0-9), 1 followed by 0, 1 or 2 (10,11,12), 'Format'; and then * Close curly brace. As for resources I can recommend [this site on regular expressions](http://www.regular-expressions.info/) and t...
388,673
<p>What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format.</p> <p>I tried the following function:</p> <pre><code>function get_date_offset($start_date, $end_date) { $start_time = strtotime($start_date); $end_time = strtotime($end_date); return ...
[ { "answer_id": 388679, "author": "csl", "author_id": 21028, "author_profile": "https://Stackoverflow.com/users/21028", "pm_score": 1, "selected": false, "text": "<p>I'm not sure what is considered <em>best</em>, since there is no built-in function in PHP for doing this, but some people h...
2008/12/23
[ "https://Stackoverflow.com/questions/388673", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31141/" ]
What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format. I tried the following function: ``` function get_date_offset($start_date, $end_date) { $start_time = strtotime($start_date); $end_time = strtotime($end_date); return round(($end_time-$sta...
If you do not want or you cannot use Zend Framework or Pear package try this function i hope this would help: ``` function dateDifference($date1, $date2) { $d1 = (is_string($date1) ? strtotime($date1) : $date1); $d2 = (is_string($date2) ? strtotime($date2) : $date2); $diff_secs = abs($d1 - $d2); $base...
388,677
<p>I have a multi-browser page that shows vertical text.</p> <p>As an ugly hack to get text to render vertically in all browsers I've created a custom page handler that returns a PNG with the text drawn vertically.</p> <p>Here's my basic code (C#3, but small changes to any other version down to 1):</p> <pre><code>Fo...
[ { "answer_id": 388680, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 3, "selected": false, "text": "<p>IIRC you need to specify the PixelFormat in the bitmap constructor.</p>\n" }, { "answer_id": 388693, "author...
2008/12/23
[ "https://Stackoverflow.com/questions/388677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/905/" ]
I have a multi-browser page that shows vertical text. As an ugly hack to get text to render vertically in all browsers I've created a custom page handler that returns a PNG with the text drawn vertically. Here's my basic code (C#3, but small changes to any other version down to 1): ``` Font f = GetSystemConfiguredFo...
To fix the text "blockiness", can't you just do... ``` g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; ``` after this line... ``` Graphics g = Graphics.FromImage( (Image) image ); ```
388,686
<p>private int DBUpdate() {</p> <pre><code>DAL dal = new DAL(); string upd = "UPDATE [RPform] SET [ProjectName] = '@pname', [ProjectCode] = '@pcode', [Country] = @cnt, "; upd += "[StartDate] = '@startdate', [FinishDate] = '@finishdate', [TotalParticipants] = @totpart, [ArrivalDate] = '@arrivedate', "; upd += "[Air...
[ { "answer_id": 388705, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 2, "selected": false, "text": "<p>If you set the parameter type in each new OleDbParameter you will not need to place single quotes on your sql making th...
2008/12/23
[ "https://Stackoverflow.com/questions/388686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
private int DBUpdate() { ``` DAL dal = new DAL(); string upd = "UPDATE [RPform] SET [ProjectName] = '@pname', [ProjectCode] = '@pcode', [Country] = @cnt, "; upd += "[StartDate] = '@startdate', [FinishDate] = '@finishdate', [TotalParticipants] = @totpart, [ArrivalDate] = '@arrivedate', "; upd += "[AirportTransfer] = @...
Check if the value of **user.ID** is being correctly set. In your **upd** command string you are surrounding the parameters with quotes, like this: ``` [StartDate] = '@startdate' ``` Remove those quotes in all your parameters.
388,687
<p>I have a database for an E-commerce storefront. MSSQL 2008.</p> <p>I have a table called Products and a table called Tags. This is a many to many relationship that is bound together by a table called ProductTags.</p> <p>Products:<br> id, name, price</p> <p>Tags:<br> id, name, sortorder, parentid(allow nulls)</p> ...
[ { "answer_id": 388695, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 1, "selected": false, "text": "<pre><code>Select T.id, T.Name, T.sortorder, T.parentid, \n(select count(*) from productstags where tagid=T.TagId) as ...
2008/12/23
[ "https://Stackoverflow.com/questions/388687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2972/" ]
I have a database for an E-commerce storefront. MSSQL 2008. I have a table called Products and a table called Tags. This is a many to many relationship that is bound together by a table called ProductTags. Products: id, name, price Tags: id, name, sortorder, parentid(allow nulls) ProductTags: productid, ta...
``` SELECT Tags.ID, Tags.Name, Tags.SortOrder, Tags.ParentID, COUNT(DISTINCT ProductTags.ProductID) AS ProductCount, COUNT(DISTINCT ChildTags.ID) AS ChildTagCount FROM Tags LEFT OUTER JOIN ProductTags ON Tags.ID = ProductTags.TagID LEFT OUTER JOIN Tags ChildTags ON Tags.ID = ChildTags.ParentID GROUP BY T...
388,708
<p>I have a method which is given the parameter "bool sortAscending". Now I want to use LINQ to create sorted list depending on this parameter. I got then this:</p> <pre><code>var ascendingQuery = from data in dataList orderby data.Property ascending select data; var descen...
[ { "answer_id": 388716, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": false, "text": "<p>In terms of how this is implemented, this changes the <em>method</em> - from OrderBy/ThenBy to OrderByDescending/T...
2008/12/23
[ "https://Stackoverflow.com/questions/388708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48621/" ]
I have a method which is given the parameter "bool sortAscending". Now I want to use LINQ to create sorted list depending on this parameter. I got then this: ``` var ascendingQuery = from data in dataList orderby data.Property ascending select data; var descendingQuery = fr...
You can easily create your own extension method on IEnumerable or IQueryable: ``` public static IOrderedEnumerable<TSource> OrderByWithDirection<TSource,TKey> (this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, bool descending) { return descending ? source.OrderByDescending(keySelecto...
388,715
<p>How do you transfer a worksheet from one excel app(1) to another(2) if you have two excel apps open using VBA?</p> <p>The problem is, the programmer uses JavaScript, and when you click on the button that transfers the web data to a xl workbook, it opens a new Excel app.</p> <p>I know part of the code would be:</p>...
[ { "answer_id": 388750, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": 3, "selected": false, "text": "<p>Not tested, but something like:</p>\n\n<pre><code>Dim sourceSheet As Worksheet\nDim destSheet As Worksheet\n\n'' ...
2008/12/23
[ "https://Stackoverflow.com/questions/388715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you transfer a worksheet from one excel app(1) to another(2) if you have two excel apps open using VBA? The problem is, the programmer uses JavaScript, and when you click on the button that transfers the web data to a xl workbook, it opens a new Excel app. I know part of the code would be: ``` Workbooks.Add A...
Not tested, but something like: ``` Dim sourceSheet As Worksheet Dim destSheet As Worksheet '' copy from the source Workbooks.Open Filename:="c:\source.xls" Set sourceSheet = Worksheets("source") sourceSheet.Activate sourceSheet.Cells.Select Selection.Copy '' paste to the destination Workbooks.Open Filename:="c:\des...
388,718
<p>I have two implementations of a method, one for value types and another for reference types:</p> <pre><code>public static Result&lt;T&gt; ImplRef(T arg) where T : class {...} public static Result&lt;T&gt; ImplVal(T arg) where T : struct {...} </code></pre> <p>I want to write a method which calls the correct implem...
[ { "answer_id": 388723, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": 0, "selected": false, "text": "<p>Is there a reason you can't go with the two separate implementations (that possibly both use a third common imple...
2008/12/23
[ "https://Stackoverflow.com/questions/388718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9204/" ]
I have two implementations of a method, one for value types and another for reference types: ``` public static Result<T> ImplRef(T arg) where T : class {...} public static Result<T> ImplVal(T arg) where T : struct {...} ``` I want to write a method which calls the correct implementation like this ``` public static ...
The idea with generics is usually to do the same logic with whichever inputs you are given, although obviously you need to be practical. Personally, I'd probably use two different methods, rather than brute-force them into the same method, but that would make it hard to call from a generic method just knowing about `T`...
388,748
<p>I'm using SSRS 2005 to produce a report, and one of the columns in my report is a simple mean calculation. I don't want to divide by zero, so for the textbox value I have put: </p> <p><code>=Switch(Fields!Count.Value=0,0,Fields!Count.Value&gt;0,Fields!Sum.Value/Fields!Count.Value)</code></p> <p>This still evaluat...
[ { "answer_id": 388938, "author": "HectorMac", "author_id": 1400, "author_profile": "https://Stackoverflow.com/users/1400", "pm_score": 2, "selected": false, "text": "<p>Unfortunately because IIF is actually just a function, all arguments get evaluated before the function gets called (res...
2008/12/23
[ "https://Stackoverflow.com/questions/388748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1116/" ]
I'm using SSRS 2005 to produce a report, and one of the columns in my report is a simple mean calculation. I don't want to divide by zero, so for the textbox value I have put: `=Switch(Fields!Count.Value=0,0,Fields!Count.Value>0,Fields!Sum.Value/Fields!Count.Value)` This still evaluates the second expression. And s...
Unfortunately because IIF is actually just a function, all arguments get evaluated before the function gets called (resulting in your divide by zero). One way of embedding complex logic in an expression is to embed a function in the report. You can write a VB function to return whatever you like in the Code Tab of the...
388,763
<p>I have a relationship between two tables, authors and styles. Every author is associated with a style, with the special case where an author doesn't have a style (IS NULL).</p> <p>There's no problem in setting the reference to NULL, but there's a problem doing a query to select the authors and styles.</p> <p>For e...
[ { "answer_id": 388770, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 3, "selected": true, "text": "<p>The most obvious solution is a LEFT OUTER JOIN.</p>\n\n<p>See: <a href=\"http://www.postgresql.org/docs/8.1/static/...
2008/12/23
[ "https://Stackoverflow.com/questions/388763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18403/" ]
I have a relationship between two tables, authors and styles. Every author is associated with a style, with the special case where an author doesn't have a style (IS NULL). There's no problem in setting the reference to NULL, but there's a problem doing a query to select the authors and styles. For example, the query...
The most obvious solution is a LEFT OUTER JOIN. See: <http://www.postgresql.org/docs/8.1/static/tutorial-join.html> If you don't want to use explicit joins you should be able to use a UNION ``` SELECT "authors"."id", "authors"."name", "styles"."name", "authors"."comments" FROM "authors" , "styles" WHERE "authors"."...
388,775
<p>I know I could have an attribute but that's more work than I want to go to... and not general enough.</p> <p>I want to do something like </p> <pre><code>class Whotsit { private string testProp = "thingy"; public string TestProp { get { return testProp; } set { testProp = value; } ...
[ { "answer_id": 388791, "author": "Stewart Johnson", "author_id": 6408, "author_profile": "https://Stackoverflow.com/users/6408", "pm_score": -1, "selected": false, "text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/kyaxdd3x.aspx\" rel=\"nofollow noreferrer\">GetProperties ...
2008/12/23
[ "https://Stackoverflow.com/questions/388775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41557/" ]
I know I could have an attribute but that's more work than I want to go to... and not general enough. I want to do something like ``` class Whotsit { private string testProp = "thingy"; public string TestProp { get { return testProp; } set { testProp = value; } } } ... Whotsit wh...
No, there's nothing to do this. The expression `whotsit.TestProp` will evaluate the property. What you want is the mythical "infoof" operator: ``` // I wish... MemberInfo member = infoof(whotsit.TestProp); ``` As it is, you can only use reflection to get the property by name - not from code. (Or get all the properti...
388,778
<p>i have a field in sql named as address which is of 80 char. i want to put this field into 2 fields addr1 and addr2 of 40 char each. how do i do it.</p>
[ { "answer_id": 388786, "author": "Mladen Prajdic", "author_id": 31345, "author_profile": "https://Stackoverflow.com/users/31345", "pm_score": 2, "selected": false, "text": "<p>this is for T-SQL, but it can't be much different for PL/SQL</p>\n\n<pre><code>declare @yourVar varchar(80)\nsel...
2008/12/23
[ "https://Stackoverflow.com/questions/388778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
i have a field in sql named as address which is of 80 char. i want to put this field into 2 fields addr1 and addr2 of 40 char each. how do i do it.
this is for T-SQL, but it can't be much different for PL/SQL ``` declare @yourVar varchar(80) select substring(@yourVar, 1, 40), substring(@yourVar, 40, 40) ```
388,799
<p>I have a Master Detail relationship configured. The hbm file is below. When I run some code like this</p> <pre><code>Favourite favourite = favourites.Find(f =&gt; f.Id== id); user.Favourites.Remove(favourite); m_UserRepository.Save(ref user); </code></pre> <p>I get the error message</p> <p><strong>NHibernate.Exce...
[ { "answer_id": 388824, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 1, "selected": false, "text": "<p>try changing your cascade rule to:</p>\n\n<pre><code>&lt;bag name=\"Favourites\" cascade=\"all,delete-orphan\" lazy=\"true...
2008/12/23
[ "https://Stackoverflow.com/questions/388799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I have a Master Detail relationship configured. The hbm file is below. When I run some code like this ``` Favourite favourite = favourites.Find(f => f.Id== id); user.Favourites.Remove(favourite); m_UserRepository.Save(ref user); ``` I get the error message **NHibernate.Exceptions.GenericADOException: could not dele...
Have you tried setting `inverse="true"` on your bag?
388,800
<p>For example I can point the <code>url '^/accounts/password/reset/$'</code> to <code>django.contrib.auth.views.password_reset</code> with my template filename in the context but I think need to send more context details.</p> <p>I need to know exactly what context to add for each of the password reset and change vie...
[ { "answer_id": 388811, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.django.contrib.auth.views.password_c...
2008/12/23
[ "https://Stackoverflow.com/questions/388800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15890/" ]
For example I can point the `url '^/accounts/password/reset/$'` to `django.contrib.auth.views.password_reset` with my template filename in the context but I think need to send more context details. I need to know exactly what context to add for each of the password reset and change views.
If you take a look at the sources for [django.contrib.auth.views.password\_reset](http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/views.py) you'll see that it uses [`RequestContext`](http://code.djangoproject.com/browser/django/trunk/django/template/__init__.py). The upshot is, you can use Contex...
388,814
<p>What is best way to show Date Picker for iPhone based Web Application. Can we show something like iPhone native date picker like shown below in web application:</p> <p><img src="https://i.stack.imgur.com/ms5tX.png" alt="iOS Date Picker"></p>
[ { "answer_id": 393413, "author": "August", "author_id": 30966, "author_profile": "https://Stackoverflow.com/users/30966", "pm_score": 1, "selected": false, "text": "<p>You can't. The date picker is a native control and is not available in Mobile Safari.</p>\n" }, { "answer_id": 4...
2008/12/23
[ "https://Stackoverflow.com/questions/388814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191/" ]
What is best way to show Date Picker for iPhone based Web Application. Can we show something like iPhone native date picker like shown below in web application: ![iOS Date Picker](https://i.stack.imgur.com/ms5tX.png)
The easiest way (and arguably the best way) is to use safari's built in datepicker for your input box using HTML5 type="date" ``` <input type="date" /> ```
388,816
<p>I have installed PEAR, <code>Spreadsheet_Excel_Writer</code> and OLE. The sample program is executed successfully but when I try to read the file it shows garbage values. I also tried <code>$workbook-&gt;setVersion(8);</code> and <code>$worksheet-&gt;setInputEncoding('UTF-8');</code></p> <p>I am using this tutoria...
[ { "answer_id": 389418, "author": "Jack", "author_id": 24998, "author_profile": "https://Stackoverflow.com/users/24998", "pm_score": 2, "selected": false, "text": "<p>I try to use PEAR only when I really need to...you can easily generate an excel spreadsheet( assuming it's just data) with...
2008/12/23
[ "https://Stackoverflow.com/questions/388816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have installed PEAR, `Spreadsheet_Excel_Writer` and OLE. The sample program is executed successfully but when I try to read the file it shows garbage values. I also tried `$workbook->setVersion(8);` and `$worksheet->setInputEncoding('UTF-8');` I am using this tutorial and Google lot for this problem. <http://www....
I try to use PEAR only when I really need to...you can easily generate an excel spreadsheet( assuming it's just data) with something like this: ``` $header = "Last Name\tFirst Name\tAge\tJob\n"; // new line is start of new row, tab is next column //ideally you would get this from a DB and just loop through it and app...
388,859
<p>I have a 'loader app' that loads a menu and when user clicks the menu image button a list view opens based on the text </p> <pre><code>(if text = employee) (Go to class A) (Go to class B) ... ... (Show List View Window) </code></pre> <p>if he clicks again on the same button it opens again, I would...
[ { "answer_id": 388872, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": false, "text": "<p>If you want a list of the open forms, that is <code>Application.OpenForms</code>. You could iterate over this, usi...
2008/12/23
[ "https://Stackoverflow.com/questions/388859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39278/" ]
I have a 'loader app' that loads a menu and when user clicks the menu image button a list view opens based on the text ``` (if text = employee) (Go to class A) (Go to class B) ... ... (Show List View Window) ``` if he clicks again on the same button it opens again, I would like to prevent this. i.e...
If you want a list of the open forms, that is `Application.OpenForms`. You could iterate over this, using GetType() and checking the `.Assembly` to find those from a different assembly. Beyond that, I'm not entire clear on the question... ``` Assembly currentAssembly = Assembly.GetExecutingAssembly(); ...
388,868
<p>Im currently using the following function to load an image, however i could not figure out a way to find the width of the loaded image, which i intend to use before placing the next image using the same function. </p> <p>Note that q is a a variable (a number) which is used to load differant images.</p> <p>=X i nee...
[ { "answer_id": 389256, "author": "Brian Hodge", "author_id": 20628, "author_profile": "https://Stackoverflow.com/users/20628", "pm_score": 1, "selected": false, "text": "<p>To access the width you must do it within the function assigned to handle Event.COMPLETE.</p>\n\n<p>\"You will want...
2008/12/23
[ "https://Stackoverflow.com/questions/388868", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Im currently using the following function to load an image, however i could not figure out a way to find the width of the loaded image, which i intend to use before placing the next image using the same function. Note that q is a a variable (a number) which is used to load differant images. =X i need help obtainning...
You can't know the width of the bitmap until it's actually loaded: ``` function LoadImage(q) { var imageLoader:Loader = new Loader(); var image:URLRequest = new URLRequest("GalleryImages/Album1/"+q+".jpg"); imageLoader.contentLoader.addEventListener(Event.COMPLETE, ImageLoaded); imageLoader.load(image)...
388,878
<p>EDIT: minor fixes (virtual Print; return mpInstance) following remarks in the answers.</p> <p>I am trying to create a system in which I can derive a Child class from any Base class, and its implementation should replace the implementation of the base class.</p> <p>All the objects that create and use the base class...
[ { "answer_id": 388888, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "https://Stackoverflow.com/users/1084", "pm_score": 0, "selected": false, "text": "<p>Without having read all of the code or gone into the details, it seems like you should've done the following:</p>\...
2008/12/23
[ "https://Stackoverflow.com/questions/388878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44673/" ]
EDIT: minor fixes (virtual Print; return mpInstance) following remarks in the answers. I am trying to create a system in which I can derive a Child class from any Base class, and its implementation should replace the implementation of the base class. All the objects that create and use the base class objects shouldn'...
This sort of pattern is fairly common. I'm not a C++ expert but in Java you see this everywhere. The dynamic cast appears to be necessary because the compiler can't tell what kind of factory you've stored in the map. To my knowledge there isn't much you can do about that with the current design. It would help to know h...
388,883
<p>I recently resolved an issue my VB6 application had when saving large binary objects to sql server using ADO 2.8 and the AppendChunck method for Recordset.Field. If the data was too big I would get either 'Invalid Handle' in a for loop or 'Not enough system storage to perform this operation'. I fixed the issue by ...
[ { "answer_id": 388902, "author": "DCNYAM", "author_id": 30419, "author_profile": "https://Stackoverflow.com/users/30419", "pm_score": 2, "selected": false, "text": "<p>If you are using SQL Server 2005, you could use the varbinary(MAX) datatype or varchar(MAX) datatype, depending on the t...
2008/12/23
[ "https://Stackoverflow.com/questions/388883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8219/" ]
I recently resolved an issue my VB6 application had when saving large binary objects to sql server using ADO 2.8 and the AppendChunck method for Recordset.Field. If the data was too big I would get either 'Invalid Handle' in a for loop or 'Not enough system storage to perform this operation'. I fixed the issue by sendi...
For sql server 2000, declare the parameter as text. Note that it has to be a parameter and not a local var, only parameters can be text, not locals.
388,908
<p>I am trying to measure the throughput of a webservice.</p> <p>In order to do that, I have written a small tool that continuously sends requests and reads responses from a number of threads.</p> <p>The contents of the inner loop of each thread looks like this:</p> <pre><code>public void PerformRequest() { WebReq...
[ { "answer_id": 388932, "author": "shaunf", "author_id": 21180, "author_profile": "https://Stackoverflow.com/users/21180", "pm_score": 2, "selected": false, "text": "<p>it could be the connection limit that has been imposed recently.</p>\n\n<p><a href=\"http://www.speedguide.net/read_arti...
2008/12/23
[ "https://Stackoverflow.com/questions/388908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5542/" ]
I am trying to measure the throughput of a webservice. In order to do that, I have written a small tool that continuously sends requests and reads responses from a number of threads. The contents of the inner loop of each thread looks like this: ``` public void PerformRequest() { WebRequest webRequest = WebRequest...
You must set the maxconnection parameter at the app.config or web.config file: ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.net> <connectionManagement> <add address="*" maxconnection="80"/> </connectionManagement> </system.net> </configuration> ``` Values up to 100 work very ...
388,914
<p>NHibernatians!</p> <p>I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended].</p> <p>[Wibble] is the main table and [WibbleExtended] is an optional table where some other fields are stored. There are far fewer entries in the [WibbleExtended] table than the main [Wibble] table. I think this was do...
[ { "answer_id": 388974, "author": "James Gregory", "author_id": 27206, "author_profile": "https://Stackoverflow.com/users/27206", "pm_score": 4, "selected": true, "text": "<p>Have you considered using the <a href=\"http://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-decla...
2008/12/23
[ "https://Stackoverflow.com/questions/388914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1122/" ]
NHibernatians! I have a table [dbo].[Wibble] and another table [dbo].[WibbleExtended]. [Wibble] is the main table and [WibbleExtended] is an optional table where some other fields are stored. There are far fewer entries in the [WibbleExtended] table than the main [Wibble] table. I think this was done back in the day ...
Have you considered using the [Join element](http://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-declaration-join) that was introduced in NHibernate 2.0? This element allows you to join multiple tables to form one entity; that relationship can also be optional.
388,928
<p>I've written a script to backup my server's HD every night. At the end of the script, I sync, wait a couple of minutes, sync and then I issue <code>sg_start --stop</code> to stop the device. The idea is to extend the lifetime of the device by switching the HD off after ten minutes of incremental backup (desktop disk...
[ { "answer_id": 389023, "author": "FredV", "author_id": 30829, "author_profile": "https://Stackoverflow.com/users/30829", "pm_score": 0, "selected": false, "text": "<p>I often find the drive still spinning the next morning.</p>\n\n<p>Couldn't this just be because it was spun up again when...
2008/12/23
[ "https://Stackoverflow.com/questions/388928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34088/" ]
I've written a script to backup my server's HD every night. At the end of the script, I sync, wait a couple of minutes, sync and then I issue `sg_start --stop` to stop the device. The idea is to extend the lifetime of the device by switching the HD off after ten minutes of incremental backup (desktop disks will survive...
When you say you've tried hdparm, you haven't said **what** you have tried. I have some usb hard drives in an enclosure, and some of the commands work for it and others don't, but I guess it all depends on all facets of the transport mechanism. ``` hdparm -S 120 /dev/sda ``` Should tell the drive to sleep its...
388,934
<p>I want to align my member variables based on a class template type but I'm not sure if it is actually possible.</p> <p>The following is a (very) simple example of what I'd like to do</p> <pre><code>template&lt;int Align&gt; class MyClass { private: struct MyStruct { // Some stuff } __declspec(align(Align...
[ { "answer_id": 389053, "author": "pmdj", "author_id": 48660, "author_profile": "https://Stackoverflow.com/users/48660", "pm_score": 4, "selected": true, "text": "<p>Custom alignment isn't in the standard, so how the compilers deal with it is up to them - looks like VC++ doesn't like comb...
2008/12/23
[ "https://Stackoverflow.com/questions/388934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48651/" ]
I want to align my member variables based on a class template type but I'm not sure if it is actually possible. The following is a (very) simple example of what I'd like to do ``` template<int Align> class MyClass { private: struct MyStruct { // Some stuff } __declspec(align(Align)); __declspec(align(Ali...
Custom alignment isn't in the standard, so how the compilers deal with it is up to them - looks like VC++ doesn't like combining templates with \_\_declspec. I suggest a work-around using specialisation, something like this: ``` template<int A> struct aligned; template<> struct aligned<1> { } __declspec(align(1)); te...
388,937
<p>I'd like to know if there's a better approach to this problem. I want to resize a label (vertically) to accomodate certain amount of text. My label has a fixed width (about 60 chars wide before it must wrap), about 495 pixels. The font is also a fixed size (12points afaik), but the text is not. </p> <p>What I want ...
[ { "answer_id": 388960, "author": "Quibblesome", "author_id": 1143, "author_profile": "https://Stackoverflow.com/users/1143", "pm_score": 3, "selected": false, "text": "<p>Graphics.MeasureString() will probably help you.</p>\n\n<p>This is also one of the only usecases for using the Contro...
2008/12/23
[ "https://Stackoverflow.com/questions/388937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2684/" ]
I'd like to know if there's a better approach to this problem. I want to resize a label (vertically) to accomodate certain amount of text. My label has a fixed width (about 60 chars wide before it must wrap), about 495 pixels. The font is also a fixed size (12points afaik), but the text is not. What I want to do is i...
How about `Graphics.MeasureString`, with the overload that accepts a string, the font, and the max width? This returns a `SizeF`, so you can round round-off the `Height`. ``` using(Graphics g = CreateGraphics()) { SizeF size = g.MeasureString(text, lbl.Font, 495); lbl.Height = (int) Mat...
388,944
<p>I have NUnit installed on my machine in "C:\Program Files\NUnit 2.4.8\" but on my integration server(running CruiseControl.Net) I have it installed in "D:\Program Files\NUnit 2.4.8\". The problem is that on my development machine my NAnt build file works correctly because in the task I'm using the path "C:\Program ...
[ { "answer_id": 388948, "author": "James Gregory", "author_id": 27206, "author_profile": "https://Stackoverflow.com/users/27206", "pm_score": 3, "selected": true, "text": "<p>Typically I distribute NUnit and any other dependencies with my project, in some common location (for me that's a ...
2008/12/23
[ "https://Stackoverflow.com/questions/388944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25125/" ]
I have NUnit installed on my machine in "C:\Program Files\NUnit 2.4.8\" but on my integration server(running CruiseControl.Net) I have it installed in "D:\Program Files\NUnit 2.4.8\". The problem is that on my development machine my NAnt build file works correctly because in the task I'm using the path "C:\Program File...
Typically I distribute NUnit and any other dependencies with my project, in some common location (for me that's a *libs* directory in the top level). ``` /MyApp /libs /NUnit /NAnt /etc... /src /etc... ``` I then just reference those libs from my application, and they're always in the same locatio...
388,956
<p>I am basically sending a URL to control the tilt and pan of an IP camera, so all I need to do is send the request, I am not worried about receiving anything. Currently I am using:</p> <pre><code>Dim Request As HttpWebRequest = WebRequest.Create("http://xxx.xxx.xxx.xxx/nphControlCamera?Direction=TiltDown&amp;Resolut...
[ { "answer_id": 388980, "author": "Jeff.Crossett", "author_id": 44746, "author_profile": "https://Stackoverflow.com/users/44746", "pm_score": 2, "selected": false, "text": "<p>Are you returning any response at all from the camera? It seems like your program is waiting for a response and ...
2008/12/23
[ "https://Stackoverflow.com/questions/388956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48654/" ]
I am basically sending a URL to control the tilt and pan of an IP camera, so all I need to do is send the request, I am not worried about receiving anything. Currently I am using: ``` Dim Request As HttpWebRequest = WebRequest.Create("http://xxx.xxx.xxx.xxx/nphControlCamera?Direction=TiltDown&Resolution=320x240&Qualit...
You might have better luck calling it asynchronously, and preventing the user from sending the request again until the camera gets itself situated? Basically you'd use BeginGetResponse instead of GetResponse. This might be of use: [How do you call an Asynchronous Web Request in VB.NET?](https://stackoverflow.com/ques...
388,971
<p>Normally I create web application projects and use code-behind, but I have a requirement to create an small throwaway demo app using code-inline.</p> <p>I added a global.asax file to the app, but for some odd reason, Visual Studio 2008 SP1 won't let me edit any of the code between the script tags i.e. add code to t...
[ { "answer_id": 388990, "author": "John Sonmez", "author_id": 45365, "author_profile": "https://Stackoverflow.com/users/45365", "pm_score": 0, "selected": false, "text": "<p>The only time I ever saw this kind of of thing is when I am in debug mode, and I didn't realize it. Seems pretty b...
2008/12/23
[ "https://Stackoverflow.com/questions/388971", "https://Stackoverflow.com", "https://Stackoverflow.com/users/419/" ]
Normally I create web application projects and use code-behind, but I have a requirement to create an small throwaway demo app using code-inline. I added a global.asax file to the app, but for some odd reason, Visual Studio 2008 SP1 won't let me edit any of the code between the script tags i.e. add code to the event h...
Ok, so here is the answer: You can see part of the explanation [here](http://support.microsoft.com/default.aspx/kb/937095) and [here](http://www.dotnetjunkies.com/WebLog/davetrux/archive/2008/02/06/433008.aspx). Basically the global.asax file doesn't actually get compiled, so VS2008 put in a fix to prevent you from m...
388,996
<p>I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both.</p>
[ { "answer_id": 389012, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": false, "text": "<pre><code>^\\s*([0-9a-zA-Z]*)\\s*$\n</code></pre>\n\n<p>or, if you want a minimum of one character:</p>\n\n<pre><code>^\\s...
2008/12/23
[ "https://Stackoverflow.com/questions/388996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48655/" ]
I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both.
``` /^[a-z0-9]+$/i ^ Start of string [a-z0-9] a or b or c or ... z or 0 or 1 or ... 9 + one or more times (change to * to allow empty string) $ end of string /i case-insensitive ``` **Update (supporting universal characters)** if you need to this regexp supports universal charact...
389,021
<p>I have an ASP.NET site that I'm developing. The layout is pretty basic. The master page has a header with a horizontal menu beneath the banner taking the entire width. On the left is a Navigation pane, 150 pixels wide with a picture and a few external links. The remainder of the width is the ContentPlaceholder. ...
[ { "answer_id": 389012, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": false, "text": "<pre><code>^\\s*([0-9a-zA-Z]*)\\s*$\n</code></pre>\n\n<p>or, if you want a minimum of one character:</p>\n\n<pre><code>^\\s...
2008/12/23
[ "https://Stackoverflow.com/questions/389021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15891/" ]
I have an ASP.NET site that I'm developing. The layout is pretty basic. The master page has a header with a horizontal menu beneath the banner taking the entire width. On the left is a Navigation pane, 150 pixels wide with a picture and a few external links. The remainder of the width is the ContentPlaceholder. Beneath...
``` /^[a-z0-9]+$/i ^ Start of string [a-z0-9] a or b or c or ... z or 0 or 1 or ... 9 + one or more times (change to * to allow empty string) $ end of string /i case-insensitive ``` **Update (supporting universal characters)** if you need to this regexp supports universal charact...
389,028
<p>Because of some non standard table creation options I am forced to use the sql dump instead of the standard schema.rb (i.e. I have uncommented this line in the environment.rb <code>config.active_record.schema_format = :sql</code>). I have noticed that when I use the sql dump that my fixtures do not seem to be loaded...
[ { "answer_id": 389247, "author": "csexton", "author_id": 19839, "author_profile": "https://Stackoverflow.com/users/19839", "pm_score": 0, "selected": false, "text": "<p>If you are loading the DB from the script you dumped, that should be all that is in there. If you see anything else I ...
2008/12/23
[ "https://Stackoverflow.com/questions/389028", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
Because of some non standard table creation options I am forced to use the sql dump instead of the standard schema.rb (i.e. I have uncommented this line in the environment.rb `config.active_record.schema_format = :sql`). I have noticed that when I use the sql dump that my fixtures do not seem to be loaded into the data...
This is a very old question but even almost 10 years later, the answer is still the same - it seems that fixtures ignore the schema format and are hard-coded to look for YAML files. Here's the Rake task as of Rails 5.2-stable: <https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/railties/data...
389,066
<p>How to find a specific element, or a list of elements by using their TagName using Watin?</p>
[ { "answer_id": 410927, "author": "Lars Thorup", "author_id": 51370, "author_profile": "https://Stackoverflow.com/users/51370", "pm_score": 1, "selected": false, "text": "<p>For example, to find the first &lt;h1&gt; on a page, use:</p>\n\n<pre><code>ie.Element(\"h1\", Find.ByIndex(0))\n</...
2008/12/23
[ "https://Stackoverflow.com/questions/389066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32582/" ]
How to find a specific element, or a list of elements by using their TagName using Watin?
As of WatiN 2.0 beta 1 this has changed to: ``` ie.ElementWithTag("h1", constraint); ``` Constraints are created when using the Find.XXX methods. Here is an example: ``` ie.ElementWithTag("h1", Find.ByClass("blue")); ```
389,069
<p>I want to write a program in C/C++ that will dynamically read a web page and extract information from it. As an example imagine if you wanted to write an application to follow and log an ebay auction. Is there an easy way to grab the web page? A library which provides this functionality? And is there an easy way to ...
[ { "answer_id": 389074, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 6, "selected": true, "text": "<p>Have a look at the <a href=\"http://curl.haxx.se/libcurl/c/example.html\" rel=\"noreferrer\">cURL library</a>: </p>\n\n<pre...
2008/12/23
[ "https://Stackoverflow.com/questions/389069", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23435/" ]
I want to write a program in C/C++ that will dynamically read a web page and extract information from it. As an example imagine if you wanted to write an application to follow and log an ebay auction. Is there an easy way to grab the web page? A library which provides this functionality? And is there an easy way to par...
Have a look at the [cURL library](http://curl.haxx.se/libcurl/c/example.html): ``` #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se"); res = curl_easy_perform(curl); ...
389,070
<p>I want to open a save file dialog, have the user enter a filename, and if they forget the .csv extension, have it tacked on.</p> <p>It would seem that the SaveFileDialog AddExtension property would work, but its doesn't. I've even set the DefaultExt property to .csv, and still nothing gets tacked on. My file gets s...
[ { "answer_id": 389078, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Try just using <code>\"csv\"</code> for the <code>DefaultExt</code> - also, you should be <code>using</code> this (...
2008/12/23
[ "https://Stackoverflow.com/questions/389070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18927/" ]
I want to open a save file dialog, have the user enter a filename, and if they forget the .csv extension, have it tacked on. It would seem that the SaveFileDialog AddExtension property would work, but its doesn't. I've even set the DefaultExt property to .csv, and still nothing gets tacked on. My file gets saved just ...
Try just using `"csv"` for the `DefaultExt` - also, you should be `using` this (it is `IDisposable`): ``` using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.AddExtension = true; sfd.DefaultExt = "csv"; sfd.Filter = "Comma Separated(*.csv)|*.*"; if (s...
389,082
<p>Our projects are using objects as the data source to reports.</p> <p>Our business layer is returning single objects or IEnumerable. Our reports (quite complex) need to display value-type properties of the object, and its related objects. Typical case would be, from a List, display a master report with category data...
[ { "answer_id": 389078, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Try just using <code>\"csv\"</code> for the <code>DefaultExt</code> - also, you should be <code>using</code> this (...
2008/12/23
[ "https://Stackoverflow.com/questions/389082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Our projects are using objects as the data source to reports. Our business layer is returning single objects or IEnumerable. Our reports (quite complex) need to display value-type properties of the object, and its related objects. Typical case would be, from a List, display a master report with category data, then a s...
Try just using `"csv"` for the `DefaultExt` - also, you should be `using` this (it is `IDisposable`): ``` using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.AddExtension = true; sfd.DefaultExt = "csv"; sfd.Filter = "Comma Separated(*.csv)|*.*"; if (s...
389,083
<p>I'm looking at writing a tool for generating code based on the contents of a stored procedure. Like the parameters and stuff.</p> <p>I was wondering if anybody knew of an open source library that has a all the regex's and stuff to parse all this easily.</p> <p>Thanks.</p>
[ { "answer_id": 389078, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 5, "selected": true, "text": "<p>Try just using <code>\"csv\"</code> for the <code>DefaultExt</code> - also, you should be <code>using</code> this (...
2008/12/23
[ "https://Stackoverflow.com/questions/389083", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45005/" ]
I'm looking at writing a tool for generating code based on the contents of a stored procedure. Like the parameters and stuff. I was wondering if anybody knew of an open source library that has a all the regex's and stuff to parse all this easily. Thanks.
Try just using `"csv"` for the `DefaultExt` - also, you should be `using` this (it is `IDisposable`): ``` using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.AddExtension = true; sfd.DefaultExt = "csv"; sfd.Filter = "Comma Separated(*.csv)|*.*"; if (s...
389,094
<p>There was a library of dynamic <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query" rel="noreferrer">LINQ</a> extensions methods released as a sample with <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2008" rel="noreferrer">Visual&nbsp;Studio&nbsp;2008</a>. I'd like to exten...
[ { "answer_id": 412868, "author": "Royd Brayshay", "author_id": 35043, "author_profile": "https://Stackoverflow.com/users/35043", "pm_score": 6, "selected": true, "text": "<p>I've fixed it myself now. It was a schoolboy error passing too many parameters to the CreateQuery(... ) call. Past...
2008/12/23
[ "https://Stackoverflow.com/questions/389094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35043/" ]
There was a library of dynamic [LINQ](http://en.wikipedia.org/wiki/Language_Integrated_Query) extensions methods released as a sample with [Visual Studio 2008](http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2008). I'd like to extend it with a join method. The code below fails with a parameter miss m...
I've fixed it myself now. It was a schoolboy error passing too many parameters to the CreateQuery(... ) call. Paste the following code into the Dynamic.cs file within the DynamicQueryable class for a dynamic Join extension method. You can find the source for the DynamicQuery sample project at <http://code.msdn.microsof...
389,124
<p>In C# if I want to create a "Custom Event" you do something like this:</p> <pre><code>private EventHandler _MyEvent; Public Event EventHandler MyEvent { add{ _MyEvent += value; } remove{ _MyEvent -= Value; } } protected void RaiseMyEvent() { if(_MyEvent != nul) _MyEvent(this, EventArgs.Empty); } </c...
[ { "answer_id": 389166, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 4, "selected": true, "text": "<p>Delegates are immutable, so method \"[Delegate].Combine\" returns new delegate, but not modify the parameters. So you need:...
2008/12/23
[ "https://Stackoverflow.com/questions/389124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
In C# if I want to create a "Custom Event" you do something like this: ``` private EventHandler _MyEvent; Public Event EventHandler MyEvent { add{ _MyEvent += value; } remove{ _MyEvent -= Value; } } protected void RaiseMyEvent() { if(_MyEvent != nul) _MyEvent(this, EventArgs.Empty); } ``` In VB this ...
Delegates are immutable, so method "[Delegate].Combine" returns new delegate, but not modify the parameters. So you need: ``` _MyEvent = [Delegate].Combine(_MyEvent, value) ```
389,140
<p>I have a ASP.Net TreeView control that I am binding to an XML data source. I'm wanting to be able to control which nodes are expanded and which ones are collapsed in the XML definition file. The Expanded='' doesn't work for me though. In the following simple example, I want Node 2 to be fully expanded.</p> <p>ASP P...
[ { "answer_id": 389623, "author": "JerKimball", "author_id": 48692, "author_profile": "https://Stackoverflow.com/users/48692", "pm_score": 0, "selected": false, "text": "<p>Hmm...well, using \"Expanded\" won't get you anywhere by default, since the DataBinding won't even look at that...I ...
2008/12/23
[ "https://Stackoverflow.com/questions/389140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7819/" ]
I have a ASP.Net TreeView control that I am binding to an XML data source. I'm wanting to be able to control which nodes are expanded and which ones are collapsed in the XML definition file. The Expanded='' doesn't work for me though. In the following simple example, I want Node 2 to be fully expanded. ASP Page... ``...
Unfortunately you can't do this in the XML. It is a short coming of the control. You will need to populate the TreeView with the XML and then traverse all of the nodes recursively and expand the branch that you need. Try the following: Add the OnPreRender attrobite to the TreeView control... ``` <asp:XmlDataSource ID...
389,149
<p>I have a basic HTML form that gets inserted into a server side <em>div</em> tag based on how many records exist in the database. This HTML form comes out just fine, and everything looks good. But on my action page I cannot seem to access the input elements from the code behind. I have tried using the <em>Request</em...
[ { "answer_id": 389163, "author": "Gant", "author_id": 12460, "author_profile": "https://Stackoverflow.com/users/12460", "pm_score": 3, "selected": false, "text": "<p>It should normally be done with <code>Request.Form[\"elementName\"]</code>.</p>\n\n<p>For example, if you have <code>&lt;i...
2008/12/23
[ "https://Stackoverflow.com/questions/389149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a basic HTML form that gets inserted into a server side *div* tag based on how many records exist in the database. This HTML form comes out just fine, and everything looks good. But on my action page I cannot seem to access the input elements from the code behind. I have tried using the *Request* scope, but I ha...
If you are accessing a plain HTML form, it has to be submitted to the server via a submit button (or via JavaScript post). This usually means that your form definition will look like this (I'm going off of memory - make sure you check the HTML elements are correct): ``` <form method="POST" action="page.aspx"> <in...
389,169
<p>Are there any known how-tos or best practices for web service REST API versioning?</p> <p>I have noticed that <a href="http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/APIUsage.html" rel="noreferrer">AWS does versioning by the URL of the endpoint</a>. Is this the only way or are there other ways to a...
[ { "answer_id": 398564, "author": "Shonzilla", "author_id": 31625, "author_profile": "https://Stackoverflow.com/users/31625", "pm_score": 10, "selected": true, "text": "<p>This is a good and a tricky question. The topic of <strong>URI design is</strong> at the same time <strong>the most p...
2008/12/23
[ "https://Stackoverflow.com/questions/389169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4869/" ]
Are there any known how-tos or best practices for web service REST API versioning? I have noticed that [AWS does versioning by the URL of the endpoint](http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/APIUsage.html). Is this the only way or are there other ways to accomplish the same goal? If there are ...
This is a good and a tricky question. The topic of **URI design is** at the same time **the most prominent part of a REST API and**, therefore, a potentially **long-term commitment towards the users of that API**. Since evolution of an application and, to a lesser extent, its API is a fact of life and that it's even s...
389,175
<p>Let's just assume that I don't know much about Kerberos - just the basics.</p> <p>I have...</p> <ul> <li>Debian Linux 2.6 Webserver <ul> <li>Apache 2.2 <ul> <li>mod_auth_kerb/5.3 </li> <li>PHP/5.2</li> </ul></li> </ul></li> <li>a (working) Kerberos Realm</li> <li>Windows Client <ul> <li>Firefox 3</li> <li>an lo...
[ { "answer_id": 390719, "author": "Cetra", "author_id": 15087, "author_profile": "https://Stackoverflow.com/users/15087", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if this will help, but it looks like Apache will send PHP the username information with the <a href=\"http:/...
2008/12/23
[ "https://Stackoverflow.com/questions/389175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999/" ]
Let's just assume that I don't know much about Kerberos - just the basics. I have... * Debian Linux 2.6 Webserver + Apache 2.2 - mod\_auth\_kerb/5.3 - PHP/5.2 * a (working) Kerberos Realm * Windows Client + Firefox 3 + an logged in identity "user@EXAMPLE.COM" in MIT Network Identity Manager How do I use this ...
I'm not sure if this will help, but it looks like Apache will send PHP the username information with the [modauthkerb](http://modauthkerb.sourceforge.net/configure.html#saving) package if you use the `KrbSaveCredentials` parameter. You should get two global variables in php: ``` $_SERVER['REMOTE_USER'] $_SERVER['KRB...
389,178
<p>Supposedly installing <a href="http://www.kuwata-lab.com/erubis/" rel="nofollow noreferrer">erubis</a> is as simple as:</p> <pre><code>gem install erubis # And in environment.rb: require 'erubis/helpers/rails_helper' </code></pre> <p>But I haven't found this to be so. Note that there are no evident errors in my ...
[ { "answer_id": 390719, "author": "Cetra", "author_id": 15087, "author_profile": "https://Stackoverflow.com/users/15087", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if this will help, but it looks like Apache will send PHP the username information with the <a href=\"http:/...
2008/12/23
[ "https://Stackoverflow.com/questions/389178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24950/" ]
Supposedly installing [erubis](http://www.kuwata-lab.com/erubis/) is as simple as: ``` gem install erubis # And in environment.rb: require 'erubis/helpers/rails_helper' ``` But I haven't found this to be so. Note that there are no evident errors in my code; it runs just fine and dandy with ERB. 1. Where do I put t...
I'm not sure if this will help, but it looks like Apache will send PHP the username information with the [modauthkerb](http://modauthkerb.sourceforge.net/configure.html#saving) package if you use the `KrbSaveCredentials` parameter. You should get two global variables in php: ``` $_SERVER['REMOTE_USER'] $_SERVER['KRB...
389,180
<p>After reading some threads on misuses of exceptions (basically saying you don't want to unwind the stack if a functions preconditions are incorrect - possibly signalling that all your memory is corrupt or something equally dangerous) I'm thinking about using assert() more often. Previously I have only used assert() ...
[ { "answer_id": 389193, "author": "David Poole", "author_id": 39766, "author_profile": "https://Stackoverflow.com/users/39766", "pm_score": 4, "selected": true, "text": "<p>You could build your own assert instead of using the stock C assert.h. Your assert won't be disabled.</p>\n\n<p>Loo...
2008/12/23
[ "https://Stackoverflow.com/questions/389180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38892/" ]
After reading some threads on misuses of exceptions (basically saying you don't want to unwind the stack if a functions preconditions are incorrect - possibly signalling that all your memory is corrupt or something equally dangerous) I'm thinking about using assert() more often. Previously I have only used assert() as ...
You could build your own assert instead of using the stock C assert.h. Your assert won't be disabled. Look at how assert() is implemented in /usr/include/assert.h (or wherever). It's simply some preprocessor magic eventually calling an "assert fail" function. In our embedded environments, we replace assert() all the ...
389,204
<p>I have seen:</p> <ul> <li><code>http://www...</code></li> <li><code>ftp://blah.blah...</code></li> <li><code>file://blah.blah...</code></li> <li><code>unreal://blah.blah...</code></li> <li><code>mailto://blah.blah...</code></li> </ul> <p>What is that first section where you see <code>http</code> and the like calle...
[ { "answer_id": 389213, "author": "Kibbee", "author_id": 1862, "author_profile": "https://Stackoverflow.com/users/1862", "pm_score": -1, "selected": false, "text": "<p>You don't really have to do any registering as such. I've seen many programs, like emule, create their own protocol spec...
2008/12/23
[ "https://Stackoverflow.com/questions/389204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37510/" ]
I have seen: * `http://www...` * `ftp://blah.blah...` * `file://blah.blah...` * `unreal://blah.blah...` * `mailto://blah.blah...` What is that first section where you see `http` and the like called? Can I register my own?
The portion with the `HTTP://`,`FTP://`, etc are called [URI Schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml) You can register your own through the registry. ``` HKEY_CLASSES_ROOT/ your-protocol-name/ (Default) "URL:your-protocol-name Protocol" URL Protocol "" shell/ op...