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
128,305
<p>How to tag images in the image itself in a web page? </p> <p>I know <a href="http://www.taggify.net/" rel="nofollow noreferrer">Taggify</a>, but... is there other options?</p> <p><a href="http://en.blog.orkut.com/2008/06/tag-thats-me.html" rel="nofollow noreferrer">Orkut</a> also does it to tag people faces... How...
[ { "answer_id": 128518, "author": "Luke Foust", "author_id": 646, "author_profile": "https://Stackoverflow.com/users/646", "pm_score": 2, "selected": false, "text": "<p>I know this isn't javascript but C# 3.0 has an API for doing this. The <strong>System.Windows.Media.Imaging</strong> nam...
2008/09/24
[ "https://Stackoverflow.com/questions/128305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1100/" ]
How to tag images in the image itself in a web page? I know [Taggify](http://www.taggify.net/), but... is there other options? [Orkut](http://en.blog.orkut.com/2008/06/tag-thats-me.html) also does it to tag people faces... How is it done? Anyone knows any public framework that is able to do it? See a sample bellow...
I know this isn't javascript but C# 3.0 has an API for doing this. The **System.Windows.Media.Imaging** namespace has a class called **BitmapMetadata** which can be used to read and write image metadata (which is stored in the image itself). Here is a method for retrieving the metadata for an image given a file path: ...
128,342
<p>For a project of mine I would love to provide auto completion for a specific textarea. Similar to how intellisense/omnicomplete works. For that however I have to find out the absolute cursor position so that I know where the DIV should appear.</p> <p>Turns out: that's (nearly I hope) impossible to achieve. Does ...
[ { "answer_id": 128461, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p><a href=\"https://web.archive.org/web/20201022015103/http://geekswithblogs.net/svanvliet/archive/2005/03/24/texta...
2008/09/24
[ "https://Stackoverflow.com/questions/128342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19990/" ]
For a project of mine I would love to provide auto completion for a specific textarea. Similar to how intellisense/omnicomplete works. For that however I have to find out the absolute cursor position so that I know where the DIV should appear. Turns out: that's (nearly I hope) impossible to achieve. Does anyone has so...
**Version 2 of My Hacky Experiment** *This new version works with any font, which can be adjusted on demand, and any textarea size.* After noticing that some of you are still trying to get this to work, I decided to try a new approach. My results are FAR better this time around - at least on google chrome on linux. I...
128,343
<p>I am currently initializing a Hashtable in the following way:</p> <pre><code>Hashtable filter = new Hashtable(); filter.Add("building", "A-51"); filter.Add("apartment", "210"); </code></pre> <p>I am looking for a nicer way to do this.</p> <p>I tried something like </p> <pre><code>Hashtable filter2 = new Hashtabl...
[ { "answer_id": 128367, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 3, "selected": false, "text": "<p>In C# 3 it should compile fine like this:</p>\n\n<pre><code>Hashtable table = new Hashtable {{1, 1}, {2, 2}};\n</code>...
2008/09/24
[ "https://Stackoverflow.com/questions/128343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14755/" ]
I am currently initializing a Hashtable in the following way: ``` Hashtable filter = new Hashtable(); filter.Add("building", "A-51"); filter.Add("apartment", "210"); ``` I am looking for a nicer way to do this. I tried something like ``` Hashtable filter2 = new Hashtable() { {"building", "A-51"}, {"apartm...
The exact code you posted: ``` Hashtable filter2 = new Hashtable() { {"building", "A-51"}, {"apartment", "210"} }; ``` Compiles perfectly in C# 3. Given you reported compilation problems, I'm guessing you are using C# 2? In this case you can at least do this: ``` ...
128,349
<p>Date coming out of a database, need to format as "mm/dd/yy"</p> <pre><code>For Each dr as DataRow in ds.Tables(0).Rows Response.Write(dr("CreateDate")) Next </code></pre>
[ { "answer_id": 128356, "author": "Geoff", "author_id": 1097, "author_profile": "https://Stackoverflow.com/users/1097", "pm_score": 0, "selected": false, "text": "<pre><code>Response.Write(DateTime.Parse(dr(\"CreateDate\").ToString()).ToString(\"MM/dd/yyyy\"))\n</code></pre>\n" }, { ...
2008/09/24
[ "https://Stackoverflow.com/questions/128349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/70/" ]
Date coming out of a database, need to format as "mm/dd/yy" ``` For Each dr as DataRow in ds.Tables(0).Rows Response.Write(dr("CreateDate")) Next ```
``` string.Format( "{0:MM/dd/yy}", dr("CreateDate") ) ``` Edit: If dr("CreateDate") is DBNull, this returns "".
128,350
<p>I'm writing an <code>RSS</code> to <code>JSON parser</code> and as a part of that, I need to use <code>htmlentities()</code> on any tag found inside the description tag. Currently, I'm trying to use <code>preg_replace()</code>, but I'm struggling a little with it. My current (non-working) code looks like:</p> <pre>...
[ { "answer_id": 128373, "author": "Armin Ronacher", "author_id": 19990, "author_profile": "https://Stackoverflow.com/users/19990", "pm_score": 4, "selected": true, "text": "<p>Simple. Use <code>preg_replace_callback</code>:</p>\n\n<pre><code>function _handle_match($match)\n{\n return ...
2008/09/24
[ "https://Stackoverflow.com/questions/128350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13281/" ]
I'm writing an `RSS` to `JSON parser` and as a part of that, I need to use `htmlentities()` on any tag found inside the description tag. Currently, I'm trying to use `preg_replace()`, but I'm struggling a little with it. My current (non-working) code looks like: ``` $pattern[0] = "/\<description\>(.*?)\<\/description\...
Simple. Use `preg_replace_callback`: ``` function _handle_match($match) { return '<description>' . htmlentities($match[1]) . '</description>'; } $pattern = "/\<description\>(.*?)\<\/description\>/is"; $rawFeed = preg_replace_callback($pattern, '_handle_match', $rawFeed); ``` It accepts any callback type, so als...
128,365
<p>I have a server access log, with timestamps of each http request, I'd like to obtain a count of the number of requests at each second. Using <code>sed</code>, and <code>cut -c</code>, so far I've managed to cut the file down to just the timestamps, such as:</p> <blockquote> <p>22-Sep-2008 20:00:21 +0000<br> 22-...
[ { "answer_id": 128394, "author": "The Archetypal Paul", "author_id": 21755, "author_profile": "https://Stackoverflow.com/users/21755", "pm_score": 6, "selected": true, "text": "<p>I think you're looking for</p>\n\n<pre><code>uniq --count\n</code></pre>\n\n<blockquote>\n <p>-c, --count\n...
2008/09/24
[ "https://Stackoverflow.com/questions/128365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
I have a server access log, with timestamps of each http request, I'd like to obtain a count of the number of requests at each second. Using `sed`, and `cut -c`, so far I've managed to cut the file down to just the timestamps, such as: > > 22-Sep-2008 20:00:21 +0000 > > 22-Sep-2008 20:00:22 +0000 > > 22-Sep-2...
I think you're looking for ``` uniq --count ``` > > -c, --count > prefix lines by the number of occurrences > > >
128,412
<p>We are using SQL Server 2005, but this question can be for any <a href="http://en.wikipedia.org/wiki/Relational_database_management_system" rel="noreferrer">RDBMS</a>.</p> <p>Which of the following is more efficient, when selecting all columns from a view?</p> <pre><code>Select * from view </code></pre> <p>or </...
[ { "answer_id": 128422, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>If you're really selecting all columns, it shouldn't make any noticeable difference whether you ask for * or if y...
2008/09/24
[ "https://Stackoverflow.com/questions/128412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2539/" ]
We are using SQL Server 2005, but this question can be for any [RDBMS](http://en.wikipedia.org/wiki/Relational_database_management_system). Which of the following is more efficient, when selecting all columns from a view? ``` Select * from view ``` or ``` Select col1, col2, ..., colN from view ```
NEVER, EVER USE "SELECT \*"!!!! This is the cardinal rule of query design! There are multiple reasons for this. One of which is, that if your table only has three fields on it and you use all three fields in the code that calls the query, there's a great possibility that you will be adding more fields to that table a...
128,443
<p>Does anyone know how I can get a format string to use <a href="http://en.wikipedia.org/wiki/Rounding#Round-to-even_method" rel="nofollow noreferrer">bankers rounding</a>? I have been using "{0:c}" but that doesn't round the same way that bankers rounding does. The <a href="http://msdn.microsoft.com/en-us/library/sys...
[ { "answer_id": 128453, "author": "jop", "author_id": 11830, "author_profile": "https://Stackoverflow.com/users/11830", "pm_score": 2, "selected": false, "text": "<p><strike>Regexp is a pattern matching language. You can't do arithmetic operations in Regexp.</strike></p>\n\n<p>Do some exp...
2008/09/24
[ "https://Stackoverflow.com/questions/128443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21767/" ]
Does anyone know how I can get a format string to use [bankers rounding](http://en.wikipedia.org/wiki/Rounding#Round-to-even_method)? I have been using "{0:c}" but that doesn't round the same way that bankers rounding does. The [`Math.Round()`](http://msdn.microsoft.com/en-us/library/system.math.round.aspx) method does...
Can't you simply call Math.Round() on the string input to get the behavior you want? Instead of: ``` string s = string.Format("{0:c}", 12345.6789); ``` Do: ``` string s = string.Format("{0:c}", Math.Round(12345.6789)); ```
128,450
<p>I have some controller methods I'd like to share. What is the best practice for doing this in ruby on rails? Should I create an abstract class that my controllers extend, or should I create module and add it in to each controller? Below are the controller methods I want to share:</p> <pre><code>def driving_directio...
[ { "answer_id": 128771, "author": "danpickett", "author_id": 21788, "author_profile": "https://Stackoverflow.com/users/21788", "pm_score": 4, "selected": false, "text": "<p>I actually think a module is the best way to share code amongst controllers. Helpers are good if you want to share c...
2008/09/24
[ "https://Stackoverflow.com/questions/128450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1486/" ]
I have some controller methods I'd like to share. What is the best practice for doing this in ruby on rails? Should I create an abstract class that my controllers extend, or should I create module and add it in to each controller? Below are the controller methods I want to share: ``` def driving_directions @address_...
In my opinion, normal OO design principles apply: * If the code is really a set of utilities that doesn't need access to object state, I would consider putting it in a module to be called separately. For instance, if the code is all mapping utilities, create a module `Maps`, and access the methods like: `Maps::driving...
128,456
<p>I have a data warehouse containing typical star schemas, and a whole bunch of code which does stuff like this (obviously a lot bigger, but this is illustrative):</p> <pre><code>SELECT cdim.x ,SUM(fact.y) AS y ,dim.z FROM fact INNER JOIN conformed_dim AS cdim ON cdim.cdim_dim_id = fact.cdim_dim_id INNER ...
[ { "answer_id": 128486, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 1, "selected": false, "text": "<p>Make the view or views into into one or more summary fact tables and materialize it. These only need...
2008/09/24
[ "https://Stackoverflow.com/questions/128456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
I have a data warehouse containing typical star schemas, and a whole bunch of code which does stuff like this (obviously a lot bigger, but this is illustrative): ``` SELECT cdim.x ,SUM(fact.y) AS y ,dim.z FROM fact INNER JOIN conformed_dim AS cdim ON cdim.cdim_dim_id = fact.cdim_dim_id INNER JOIN nonconfor...
1. I’ve used this technique on several data warehouses I look after. I have not noticed any performance degradation when running reports based off of the views versus a table direct approach but have never performed a detailed analysis. 2. I created the views using the designer in SQL Server management studio and did n...
128,478
<p><a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer">PEP 8</a> states:</p> <blockquote> <p>Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.</p> </blockquote> <p>However if the class/method/function that I am importin...
[ { "answer_id": 128522, "author": "Curt Hagenlocher", "author_id": 533, "author_profile": "https://Stackoverflow.com/users/533", "pm_score": 4, "selected": false, "text": "<p>The first variant is indeed more efficient than the second when the function is called either zero or one times. ...
2008/09/24
[ "https://Stackoverflow.com/questions/128478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15676/" ]
[PEP 8](http://www.python.org/dev/peps/pep-0008/) states: > > Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants. > > > However if the class/method/function that I am importing is only used in rare cases, surely it is more efficien...
Module importing is quite fast, but not instant. This means that: * Putting the imports at the top of the module is fine, because it's a trivial cost that's only paid once. * Putting the imports within a function will cause calls to that function to take longer. So if you care about efficiency, put the imports at the...
128,502
<p>I've just updated my ruby installation on my gentoo server to ruby 1.8.6 patchlevel 287 and have started getting an error on one of my eRuby apps. The error given in the apache error_log file is:</p> <pre><code>[error] mod_ruby: /usr/lib/ruby/1.8/cgi.rb:774: superclass mismatch for class Cookie (TypeError) </code><...
[ { "answer_id": 129051, "author": "Ben Stiglitz", "author_id": 6298, "author_profile": "https://Stackoverflow.com/users/6298", "pm_score": 3, "selected": true, "text": "<p>That error shows up when you redeclare a class that’s already been declared, most likely because you’re loading two d...
2008/09/24
[ "https://Stackoverflow.com/questions/128502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1912/" ]
I've just updated my ruby installation on my gentoo server to ruby 1.8.6 patchlevel 287 and have started getting an error on one of my eRuby apps. The error given in the apache error\_log file is: ``` [error] mod_ruby: /usr/lib/ruby/1.8/cgi.rb:774: superclass mismatch for class Cookie (TypeError) ``` The strange thi...
That error shows up when you redeclare a class that’s already been declared, most likely because you’re loading two different copies of cgi.rb. See a [similar issue in Rails](http://209.85.173.104/search?q=cache:wbXLBotEIvUJ:railsforum.com/viewtopic.php%3Fid%3D10993+superclass+mismatch+for&hl=en&ct=clnk&cd=3&gl=us&clie...
128,527
<p>We have our JBoss and Oracle on separate servers. The connections seem to be dropped and is causing issues with JBoss. How can I have the JBoss reconnect to Oracle if the connection is bad while we figure out why the connections are being dropped in the first place?</p>
[ { "answer_id": 129333, "author": "Steve K", "author_id": 739, "author_profile": "https://Stackoverflow.com/users/739", "pm_score": 6, "selected": true, "text": "<p>There is usually a configuration option on the pool to enable a validation query to be executed on borrow. If the validatio...
2008/09/24
[ "https://Stackoverflow.com/questions/128527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6013/" ]
We have our JBoss and Oracle on separate servers. The connections seem to be dropped and is causing issues with JBoss. How can I have the JBoss reconnect to Oracle if the connection is bad while we figure out why the connections are being dropped in the first place?
There is usually a configuration option on the pool to enable a validation query to be executed on borrow. If the validation query executes successfully, the pool will return that connection. If the query does not execute successfully, the pool will create a new connection. The [JBoss Wiki](http://community.jboss.org...
128,561
<p>I have a new application written in WPF that needs to support an old API that allows it to receive a message that has been posted to a hidden window. Typically another application uses FindWindow to identify the hidden window using the name of its custom window class.</p> <p><strong>1) I assume to implement a cust...
[ { "answer_id": 128622, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "<p><strong>1)</strong> You can just subclass a normal Windows Forms class... no need for all those win32 calls, you just nee...
2008/09/24
[ "https://Stackoverflow.com/questions/128561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5427/" ]
I have a new application written in WPF that needs to support an old API that allows it to receive a message that has been posted to a hidden window. Typically another application uses FindWindow to identify the hidden window using the name of its custom window class. **1) I assume to implement a custom window class I...
For the record I finally got this to work. Turned out the difficulties I had were down to string marshalling problems. I had to be more precise in my importing of win32 functions. Below is the code that will create a custom window class in c# - useful for supporting old APIs you might have that rely on custom window c...
128,573
<p>I have a class with two class methods (using the <code>classmethod()</code> function) for getting and setting what is essentially a static variable. I tried to use the <code>property()</code> function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter:</...
[ { "answer_id": 128624, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": -1, "selected": false, "text": "<p>Here's my suggestion. Don't use class methods. </p>\n\n<p>Seriously. </p>\n\n<p>What's the reason for using class me...
2008/09/24
[ "https://Stackoverflow.com/questions/128573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
I have a class with two class methods (using the `classmethod()` function) for getting and setting what is essentially a static variable. I tried to use the `property()` function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter: ``` class Foo(object): ...
### 3.8 < Python < 3.11 Can use both decorators together. See [this answer](https://stackoverflow.com/a/64738850/674039). ### Python < 3.9 A property is created on a class but affects an instance. So if you want a `classmethod` property, create the property on the metaclass. ``` >>> class foo(object): ... _var ...
128,579
<p>When developing a module (device driver, middleware, etc...) that will run in the kernel space, we would like to have some way to capture the reason an operation might fail. </p> <p>In VxWorks, The errno mechanism seems to be a good way to do this.</p> <p>Is it possible to define my own errno values?</p>
[ { "answer_id": 128628, "author": "unexist", "author_id": 18179, "author_profile": "https://Stackoverflow.com/users/18179", "pm_score": 1, "selected": false, "text": "<p>Errno is just a number and functions like strerror() return a describing text. If you want to extend it just provide an...
2008/09/24
[ "https://Stackoverflow.com/questions/128579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10703/" ]
When developing a module (device driver, middleware, etc...) that will run in the kernel space, we would like to have some way to capture the reason an operation might fail. In VxWorks, The errno mechanism seems to be a good way to do this. Is it possible to define my own errno values?
In the context of VxWorks errno is defined as two 16-bit: * The upper 16-bit identifies the "module" where the error occured. * The lower 16-bit represent the particular error for that module. The official vxWorks module values (for errno) are located in the ../h/vwModNum.h file. They are currently using a few hundr...
128,580
<p>I'm trying to get the contents of a XML document element, but the element has a colon in it's name.</p> <p>This line works for every element but the ones with a colon in the name:</p> <pre><code>$(this).find("geo:lat").text(); </code></pre> <p>I assume that the colon needs escaping. How do I fix this?</p>
[ { "answer_id": 128598, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 6, "selected": true, "text": "<p>Use a backslash, which itself should be escaped so JavaScript doesn't eat it:</p>\n\n<pre><code>$(this).find(\"geo...
2008/09/24
[ "https://Stackoverflow.com/questions/128580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/399/" ]
I'm trying to get the contents of a XML document element, but the element has a colon in it's name. This line works for every element but the ones with a colon in the name: ``` $(this).find("geo:lat").text(); ``` I assume that the colon needs escaping. How do I fix this?
Use a backslash, which itself should be escaped so JavaScript doesn't eat it: ``` $(this).find("geo\\:lat").text(); ```
128,584
<p>The following simple "calculator expression" grammar (BNF) can be easily parsed with the a trivial recursive-descent parser, which is predictive LL(1):</p> <pre><code>&lt;expr&gt; := &lt;term&gt; + &lt;term&gt; | &lt;term&gt; - &lt;term&gt; | &lt;term&gt; &lt;term&gt; := &lt;...
[ { "answer_id": 128661, "author": "mmattax", "author_id": 1638, "author_profile": "https://Stackoverflow.com/users/1638", "pm_score": 2, "selected": false, "text": "<p>The problem is that the grammar:</p>\n\n<pre>\n<code>\n&lt;command> := &lt;expr>\n | &lt;id> = &lt;expr>\...
2008/09/24
[ "https://Stackoverflow.com/questions/128584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8206/" ]
The following simple "calculator expression" grammar (BNF) can be easily parsed with the a trivial recursive-descent parser, which is predictive LL(1): ``` <expr> := <term> + <term> | <term> - <term> | <term> <term> := <factor> * <factor> <factor> / <factor> ...
THe problem with ``` <command> := <expr> | <id> = <expr> ``` is that when you "see" `<id>` you can't tell if it's the beginning of an assignement (second rule) or it's a "`<factor>`". You will only know when you'll read the next token. AFAIK ANTLR is LL(\*) (and is also able to generate rat-pack p...
128,618
<p>Is there any easy way to create a class that uses <strong>IFormatProvider</strong> that writes out a user-friendly file-size?</p> <pre><code>public static string GetFileSizeString(string filePath) { FileInfo info = new FileInfo(@"c:\windows\notepad.exe"); long size = info.Length; string sizeString = siz...
[ { "answer_id": 128683, "author": "Eduardo Campañó", "author_id": 12091, "author_profile": "https://Stackoverflow.com/users/12091", "pm_score": 8, "selected": true, "text": "<p>I use this one, I get it from the web</p>\n\n<pre><code>public class FileSizeFormatProvider : IFormatProvider, I...
2008/09/24
[ "https://Stackoverflow.com/questions/128618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2429/" ]
Is there any easy way to create a class that uses **IFormatProvider** that writes out a user-friendly file-size? ``` public static string GetFileSizeString(string filePath) { FileInfo info = new FileInfo(@"c:\windows\notepad.exe"); long size = info.Length; string sizeString = size.ToString(FileSizeFormatPr...
I use this one, I get it from the web ``` public class FileSizeFormatProvider : IFormatProvider, ICustomFormatter { public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) return this; return null; } private const string fileSizeFormat = "fs"; private...
128,623
<p>How can I disable all table constrains in Oracle with a single command? This can be either for a single table, a list of tables, or for all tables.</p>
[ { "answer_id": 128663, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 0, "selected": false, "text": "<p>It doesn't look like you can do this with a single command, but <a href=\"http://oracle.ittoolbox.com/documents/p...
2008/09/24
[ "https://Stackoverflow.com/questions/128623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9435/" ]
How can I disable all table constrains in Oracle with a single command? This can be either for a single table, a list of tables, or for all tables.
It is better to avoid writing out temporary spool files. Use a PL/SQL block. You can run this from SQL\*Plus or put this thing into a package or procedure. The join to USER\_TABLES is there to avoid view constraints. It's unlikely that you really want to disable all constraints (including NOT NULL, primary keys, etc)....
128,783
<p>Is it possible to use AIX's mksysb and savevg to create a bootable tape with the rootvg and then append all the other VGs?</p>
[ { "answer_id": 129951, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>First, use savevg to backup any extra volume groups to a file system on the rootvg:</p>\n\n<pre><code>savevg -f /tmp/vgname...
2008/09/24
[ "https://Stackoverflow.com/questions/128783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to use AIX's mksysb and savevg to create a bootable tape with the rootvg and then append all the other VGs?
Answering my own question: To backup, use a script similar to this one: ``` tctl -f/dev/rmt0 rewind /usr/bin/mksysb -p -v /dev/rmt0.1 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg01 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg02 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg03 ...etc... tctl -f/dev/rmt0 rewind ``` Notes: - mks...
128,796
<p>I really enjoy having "pretty" URLs (e.g. <code>/Products/Edit/1</code> instead of <code>/products.aspx?productID=1</code>) but I'm at a loss on how to do this for pages that let you search by a large number of variables.</p> <p>For instance, let's say you have a page that lets a user search for all products of a p...
[ { "answer_id": 128846, "author": "Wolfwyrd", "author_id": 15570, "author_profile": "https://Stackoverflow.com/users/15570", "pm_score": 1, "selected": false, "text": "<p>The MVC (Model View Controller) framework is designed specifically to tackle this issue. It uses a form of url rewriti...
2008/09/24
[ "https://Stackoverflow.com/questions/128796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1574/" ]
I really enjoy having "pretty" URLs (e.g. `/Products/Edit/1` instead of `/products.aspx?productID=1`) but I'm at a loss on how to do this for pages that let you search by a large number of variables. For instance, let's say you have a page that lets a user search for all products of a particular type with a certain na...
You can get the "pretty" urls, but not through the prettiest of means.. You can set up your url to be something like: ``` /Products/Search/Type/{producttype}/Name_{name}/Address_{address} ``` Then a [mod\_rewrite](http://www.workingwith.me.uk/articles/scripting/mod_rewrite) rule something like: ``` RewriteRule ^Pr...
128,818
<p>I have seen people say that it is bad form to use catch with no arguments, especially if that catch doesn't do anything:</p> <pre><code>StreamReader reader=new StreamReader("myfile.txt"); try { int i = 5 / 0; } catch // No args, so it will catch any exception {} reader.Close(); </code></pre> <p>However, this ...
[ { "answer_id": 128827, "author": "Adam Wright", "author_id": 1200, "author_profile": "https://Stackoverflow.com/users/1200", "pm_score": 6, "selected": false, "text": "<p>\"Finally\" is a statement of \"Something you must always do to make sure program state is sane\". As such, it's alwa...
2008/09/24
[ "https://Stackoverflow.com/questions/128818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21727/" ]
I have seen people say that it is bad form to use catch with no arguments, especially if that catch doesn't do anything: ``` StreamReader reader=new StreamReader("myfile.txt"); try { int i = 5 / 0; } catch // No args, so it will catch any exception {} reader.Close(); ``` However, this is considered good form: ...
The big difference is that `try...catch` will swallow the exception, hiding the fact that an error occurred. `try..finally` will run your cleanup code and then the exception will keep going, to be handled by something that knows what to do with it.
128,853
<p>I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, that might be enough. </p> <p>The particular environment in question at the ...
[ { "answer_id": 128872, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 4, "selected": false, "text": "<p>There's a bunch of ways to do this, the first that came to mind was: </p>\n\n<pre><code>OUTPUT=\"\"; \nwhile [ `echo $OUTPU...
2008/09/24
[ "https://Stackoverflow.com/questions/128853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7671/" ]
I'm sure there's some trivial one-liner with perl, ruby, bash whatever that would let me run a command in a loop until I observe some string in stdout, then stop. Ideally, I'd like to capture stdout as well, but if it's going to console, that might be enough. The particular environment in question at the moment is Re...
In Perl: ``` #!/usr/local/bin/perl -w if (@ARGV != 2) { print "Usage: watchit.pl <cmd> <str>\n"; exit(1); } $cmd = $ARGV[0]; $str = $ARGV[1]; while (1) { my $output = `$cmd`; print $output; # or dump to file if desired if ($output =~ /$str/) { exit(0); } } ``` Example: ``` [ba...
128,857
<p>I have a user reporting that when they use the back button to return to a web page that they come back as a different person. It seems like they may be accessing a different users profile.</p> <p>Here are the important parts of the code:</p> <pre><code>//here's the code on the web page public static WebProfile p ...
[ { "answer_id": 128872, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 4, "selected": false, "text": "<p>There's a bunch of ways to do this, the first that came to mind was: </p>\n\n<pre><code>OUTPUT=\"\"; \nwhile [ `echo $OUTPU...
2008/09/24
[ "https://Stackoverflow.com/questions/128857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4888/" ]
I have a user reporting that when they use the back button to return to a web page that they come back as a different person. It seems like they may be accessing a different users profile. Here are the important parts of the code: ``` //here's the code on the web page public static WebProfile p = null; protected vo...
In Perl: ``` #!/usr/local/bin/perl -w if (@ARGV != 2) { print "Usage: watchit.pl <cmd> <str>\n"; exit(1); } $cmd = $ARGV[0]; $str = $ARGV[1]; while (1) { my $output = `$cmd`; print $output; # or dump to file if desired if ($output =~ /$str/) { exit(0); } } ``` Example: ``` [ba...
128,888
<p>In Java, I have a subclass <code>Vertex</code> of the Java3D class <code>Point3f</code>. Now <code>Point3f</code> computes <code>equals()</code> based on the values of its coordinates, but for my <code>Vertex</code> class I want to be stricter: two vertices are only equal if they are the same object. So far, so good...
[ { "answer_id": 128910, "author": "Christian P.", "author_id": 9479, "author_profile": "https://Stackoverflow.com/users/9479", "pm_score": -1, "selected": false, "text": "<p>The function hashCode() is inherited from Object and works exactly as you intend (on object level, not coordinate-l...
2008/09/24
[ "https://Stackoverflow.com/questions/128888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14637/" ]
In Java, I have a subclass `Vertex` of the Java3D class `Point3f`. Now `Point3f` computes `equals()` based on the values of its coordinates, but for my `Vertex` class I want to be stricter: two vertices are only equal if they are the same object. So far, so good: ``` class Vertex extends Point3f { // ... pub...
Either use System.identityHashCode() or use an IdentityHashMap.
128,914
<p>Several months ago my work deployed an in-house function that wraps the standard, php, mysql_query() function with additional options and abilities. A sample feature would be some handy debugging tools we can turn on/off. </p> <p>I was wondering how popular query handlers are and what features people like to build ...
[ { "answer_id": 128962, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 1, "selected": false, "text": "<p>I use a DBAL like <a href=\"http://pear.php.net/package/MDB2\" rel=\"nofollow noreferrer\">MDB2</a>, <a href=\"http://framew...
2008/09/24
[ "https://Stackoverflow.com/questions/128914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14959/" ]
Several months ago my work deployed an in-house function that wraps the standard, php, mysql\_query() function with additional options and abilities. A sample feature would be some handy debugging tools we can turn on/off. I was wondering how popular query handlers are and what features people like to build into them...
I use a DBAL like [MDB2](http://pear.php.net/package/MDB2), [Zend\_Db](http://framework.zend.com/manual/en/zend.db.html) or [Doctrine](http://www.doctrine-project.org/) for similar reason. Primarily to be able to utilize all the shortcuts it offers, not so much for the fact that it supports different databases. E.g., ...
128,923
<p>Many times I've seen links like these in HTML pages:</p> <pre><code>&lt;a href='#' onclick='someFunc(3.1415926); return false;'&gt;Click here !&lt;/a&gt; </code></pre> <p>What's the effect of the <code>return false</code> in there?</p> <p>Also, I don't usually see that in buttons.</p> <p>Is this specified anywhe...
[ { "answer_id": 128928, "author": "Guvante", "author_id": 16800, "author_profile": "https://Stackoverflow.com/users/16800", "pm_score": 4, "selected": false, "text": "<p>I believe it causes the standard event to not happen.</p>\n\n<p>In your example the browser will not attempt to go to #...
2008/09/24
[ "https://Stackoverflow.com/questions/128923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15649/" ]
Many times I've seen links like these in HTML pages: ``` <a href='#' onclick='someFunc(3.1415926); return false;'>Click here !</a> ``` What's the effect of the `return false` in there? Also, I don't usually see that in buttons. Is this specified anywhere? In some spec in w3.org?
The return value of an event handler determines whether or not the default browser behaviour should take place as well. In the case of clicking on links, this would be following the link, but the difference is most noticeable in form submit handlers, where you can cancel a form submission if the user has made a mistake...
128,933
<p>I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from an existing group with a command line script. It appears th...
[ { "answer_id": 129012, "author": "Dave Sherohman", "author_id": 18914, "author_profile": "https://Stackoverflow.com/users/18914", "pm_score": 1, "selected": false, "text": "<p>It looks like <em>deluser --group [groupname]</em> should do it.</p>\n\n<p>If not, the <em>groups</em> command l...
2008/09/24
[ "https://Stackoverflow.com/questions/128933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2346/" ]
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from an existing group with a command line script. It appears that the...
Web Link: <http://www.ibm.com/developerworks/linux/library/l-roadmap4/> To add members to the group, use the gpasswd command with the -a switch and the user id you wish to add: gpasswd -a userid mygroup Remove users from a group with the same command, but a -d switch rather than -a: gpasswd -d userid mygroup "man...
128,949
<p>Templates are a pretty healthy business in established programming languages, but are there any good ones that can be processed in JavaScript?</p> <p>By "template" I mean a document that accepts a data object as input, inserts the data into some kind of serialized markup language, and outputs the markup. Well-known...
[ { "answer_id": 128980, "author": "Mladen Mihajlovic", "author_id": 11421, "author_profile": "https://Stackoverflow.com/users/11421", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://ejohn.org/\" rel=\"noreferrer\">John Resig</a> has a mini javascript templating engine at <a...
2008/09/24
[ "https://Stackoverflow.com/questions/128949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8735/" ]
Templates are a pretty healthy business in established programming languages, but are there any good ones that can be processed in JavaScript? By "template" I mean a document that accepts a data object as input, inserts the data into some kind of serialized markup language, and outputs the markup. Well-known examples ...
You might want to check out [Mustache](https://mustache.github.io/) - it's really portable and simple template language with javascript support among other languages.
128,954
<p>I have code to create another "row" (div with inputs) on a button click. I am creating new input elements and everything works fine, however, I can't find a way to access these new elements.</p> <p>Example: I have input element (name_1 below). Then I create another input element (name_2 below), by using the javas...
[ { "answer_id": 128967, "author": "17 of 26", "author_id": 2284, "author_profile": "https://Stackoverflow.com/users/2284", "pm_score": 3, "selected": true, "text": "<p>You have to create the element AND add it to the DOM using functions such as appendChild. See <a href=\"http://www.w3sch...
2008/09/24
[ "https://Stackoverflow.com/questions/128954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16437/" ]
I have code to create another "row" (div with inputs) on a button click. I am creating new input elements and everything works fine, however, I can't find a way to access these new elements. Example: I have input element (name\_1 below). Then I create another input element (name\_2 below), by using the javascript's `c...
You have to create the element AND add it to the DOM using functions such as appendChild. See [here](http://www.w3schools.com/htmldom/dom_methods.asp) for details. My guess is that you called createElement() but never added it to your DOM hierarchy.
128,965
<p>When I started writing database queries I didn't know the JOIN keyword yet and naturally I just extended what I already knew and wrote queries like this:</p> <pre><code>SELECT a.someRow, b.someRow FROM tableA AS a, tableB AS b WHERE a.ID=b.ID AND b.ID= $someVar </code></pre> <p>Now that I know that this is the sam...
[ { "answer_id": 128995, "author": "Jared", "author_id": 7388, "author_profile": "https://Stackoverflow.com/users/7388", "pm_score": 2, "selected": false, "text": "<p>Nothing is wrong with the syntax in your example. The 'INNER JOIN' syntax is generally termed 'ANSI' syntax, and came afte...
2008/09/24
[ "https://Stackoverflow.com/questions/128965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11995/" ]
When I started writing database queries I didn't know the JOIN keyword yet and naturally I just extended what I already knew and wrote queries like this: ``` SELECT a.someRow, b.someRow FROM tableA AS a, tableB AS b WHERE a.ID=b.ID AND b.ID= $someVar ``` Now that I know that this is the same as an INNER JOIN I fin...
Filtering joins solely using `WHERE` can be extremely inefficient in some common scenarios. For example: ``` SELECT * FROM people p, companies c WHERE p.companyID = c.id AND p.firstName = 'Daniel' ``` Most databases will execute this query quite literally, first taking the [Cartesian product](http://en.wikipedi...
128,981
<p>I'm writing a program and am having trouble using the scanf and fopen working together.</p> <p>From what I can tell my erroneous lines seems to be:</p> <pre><code>FiLE * DataFile DataFile = fopen("StcWx.txt","r"); scanf(DataFile, "%i %i %i %.2f %i %i", &amp;Year, &amp;Month, &amp;Day, &amp;Precip, &amp;High, &amp;...
[ { "answer_id": 128991, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 4, "selected": false, "text": "<p>I think you want <a href=\"http://en.wikipedia.org/wiki/Scanf#fscanf\" rel=\"nofollow noreferrer\"><strong>fscanf</strong...
2008/09/24
[ "https://Stackoverflow.com/questions/128981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm writing a program and am having trouble using the scanf and fopen working together. From what I can tell my erroneous lines seems to be: ``` FiLE * DataFile DataFile = fopen("StcWx.txt","r"); scanf(DataFile, "%i %i %i %.2f %i %i", &Year, &Month, &Day, &Precip, &High, &Low); ``` The file it opens from has a list...
I think you want [**fscanf**](http://en.wikipedia.org/wiki/Scanf#fscanf) not [**scanf**](http://en.wikipedia.org/wiki/Scanf).
128,990
<p>I have a base URL :</p> <pre><code>http://my.server.com/folder/directory/sample </code></pre> <p>And a relative one :</p> <pre><code>../../other/path </code></pre> <p>How to get the absolute URL from this ? It's pretty straighforward using string manipulation, but I would like to do this in a secure way, using t...
[ { "answer_id": 129003, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 7, "selected": true, "text": "<pre><code>var baseUri = new Uri(\"http://my.server.com/folder/directory/sample\");\nvar absoluteUri = new Uri(baseUri,\"...
2008/09/24
[ "https://Stackoverflow.com/questions/128990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
I have a base URL : ``` http://my.server.com/folder/directory/sample ``` And a relative one : ``` ../../other/path ``` How to get the absolute URL from this ? It's pretty straighforward using string manipulation, but I would like to do this in a secure way, using the `Uri` class or something similar. It's for a ...
``` var baseUri = new Uri("http://my.server.com/folder/directory/sample"); var absoluteUri = new Uri(baseUri,"../../other/path"); ``` OR ``` Uri uri; if ( Uri.TryCreate("http://base/","../relative", out uri) ) doSomething(uri); ```
129,013
<p>This is only happening on the live server. On multiply development servers the image is being created as expected.</p> <p>LIVE: Red Hat</p> <pre><code>$ php --version PHP 5.2.6 (cli) (built: May 16 2008 21:56:34) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies <...
[ { "answer_id": 129030, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 2, "selected": false, "text": "<p>Maybe you are running out of memory or something similar? Did you double check all logfiles, etc.? </p>\n" }, { "ans...
2008/09/24
[ "https://Stackoverflow.com/questions/129013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1797/" ]
This is only happening on the live server. On multiply development servers the image is being created as expected. LIVE: Red Hat ``` $ php --version PHP 5.2.6 (cli) (built: May 16 2008 21:56:34) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies ``` GD Support => en...
Maybe you are running out of memory or something similar? Did you double check all logfiles, etc.?
129,019
<p>I would like something that I can use as follows</p> <pre><code>var msg = new NonStaticMessageBox(); if(msg.Show("MyMessage", "MyCaption", MessageBoxButtons.OkCancel) == DialogResult.Ok) {....} </code></pre> <p>But specifically non-static (I need to pass a reference to it around) does anyone know if/where such an...
[ { "answer_id": 129025, "author": "Yes - that Jake.", "author_id": 5287, "author_profile": "https://Stackoverflow.com/users/5287", "pm_score": 3, "selected": true, "text": "<p>Such an object does not exist in the .net framework. You'll need to roll your own.</p>\n" }, { "answer_id...
2008/09/24
[ "https://Stackoverflow.com/questions/129019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I would like something that I can use as follows ``` var msg = new NonStaticMessageBox(); if(msg.Show("MyMessage", "MyCaption", MessageBoxButtons.OkCancel) == DialogResult.Ok) {....} ``` But specifically non-static (I need to pass a reference to it around) does anyone know if/where such an object exists?
Such an object does not exist in the .net framework. You'll need to roll your own.
129,036
<p>I am writing a component that, given a ZIP file, needs to:</p> <ol> <li>Unzip the file.</li> <li>Find a specific dll among the unzipped files.</li> <li>Load that dll through reflection and invoke a method on it.</li> </ol> <p>I'd like to unit test this component.</p> <p>I'm tempted to write code that deals dire...
[ { "answer_id": 129061, "author": "nsayer", "author_id": 13757, "author_profile": "https://Stackoverflow.com/users/13757", "pm_score": 3, "selected": false, "text": "<p>One way would be to write the unzip method to take InputStreams. Then the unit test could construct such an InputStream ...
2008/09/24
[ "https://Stackoverflow.com/questions/129036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/536/" ]
I am writing a component that, given a ZIP file, needs to: 1. Unzip the file. 2. Find a specific dll among the unzipped files. 3. Load that dll through reflection and invoke a method on it. I'd like to unit test this component. I'm tempted to write code that deals directly with the file system: ```cs void DoIt() { ...
There's really nothing wrong with this, it's just a question of whether you call it a unit test or an integration test. You just have to make sure that if you do interact with the file system, there are no unintended side effects. Specifically, make sure that you clean up after youself -- delete any temporary files you...
129,043
<p>I have a bash script that creates a Subversion patch file for the current directory. I want to modify it to zip the produced file, if <code>-z</code> is given as an argument to the script.</p> <p>Here's the relevant part:</p> <pre><code>zipped='' zipcommand='&gt;' if [ "$1" = "-z" ] then zipped='zipped ' fi...
[ { "answer_id": 129132, "author": "Keeth", "author_id": 20588, "author_profile": "https://Stackoverflow.com/users/20588", "pm_score": 4, "selected": true, "text": "<p>I would do something like this (use bash -c or eval):</p>\n\n<pre><code>zipped=''\nzipcommand='&gt;'\n\nif [ \"$1\" = \"-z...
2008/09/24
[ "https://Stackoverflow.com/questions/129043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
I have a bash script that creates a Subversion patch file for the current directory. I want to modify it to zip the produced file, if `-z` is given as an argument to the script. Here's the relevant part: ``` zipped='' zipcommand='>' if [ "$1" = "-z" ] then zipped='zipped ' filename="${filename}.zip" zipcomm...
I would do something like this (use bash -c or eval): ``` zipped='' zipcommand='>' if [ "$1" = "-z" ] then zipped='zipped ' filename="${filename}.zip" zipcommand='| zip -@' fi echo "Creating ${zipped}patch file $filename..." eval "svn diff $zipcommand $filename" # this also works: # bash -c "svn diff $zip...
129,046
<p>How would I disable and later enable all indexes in a given schema/database in Oracle?</p> <p>Note: This is to make sqlldr run faster.</p>
[ { "answer_id": 129163, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 2, "selected": false, "text": "<p>From here: <a href=\"http://forums.oracle.com/forums/thread.jspa?messageID=2354075\" rel=\"nofollow noreferrer\...
2008/09/24
[ "https://Stackoverflow.com/questions/129046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9435/" ]
How would I disable and later enable all indexes in a given schema/database in Oracle? Note: This is to make sqlldr run faster.
Here's making the indexes unusable without the file: ``` DECLARE CURSOR usr_idxs IS select * from user_indexes; cur_idx usr_idxs% ROWTYPE; v_sql VARCHAR2(1024); BEGIN OPEN usr_idxs; LOOP FETCH usr_idxs INTO cur_idx; EXIT WHEN NOT usr_idxs%FOUND; v_sql:= 'ALTER INDEX ' || cur_idx.index_name |...
129,072
<p>Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat.</p> <p>Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do</p> <pre><code>c:\my_server&gt; java rails_a...
[ { "answer_id": 129109, "author": "jsight", "author_id": 1432, "author_profile": "https://Stackoverflow.com/users/1432", "pm_score": 4, "selected": true, "text": "<p>I'd recommend that you checkout Jetty. The process for <a href=\"http://docs.codehaus.org/display/JETTY/Embedding+Jetty\" ...
2008/09/24
[ "https://Stackoverflow.com/questions/129072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
Essentially the only thing I can deploy to my deployment machine is a JAR file. I can't install JRuby, nor can I install Glassfish or Tomcat. Is it possible to package up a Rails application (including Rails, vendored, of course) to a JAR file such that I can do ``` c:\my_server> java rails_app.jar ``` and have it ...
I'd recommend that you checkout Jetty. The process for [Embedding Jetty](http://docs.codehaus.org/display/JETTY/Embedding+Jetty) is surprisingly easy, and it should be possible to give it your servlets from your current jar file. I haven't used Ruby/Rails, though, so I'm not sure if there are any complications there. ...
129,077
<p>This issue came up when I got different records counts for what I thought were identical queries one using a <code>not in</code> <code>where</code> constraint and the other a <code>left join</code>. The table in the <code>not in</code> constraint had one null value (bad data) which caused that query to return a coun...
[ { "answer_id": 129089, "author": "Sunny Milenov", "author_id": 8220, "author_profile": "https://Stackoverflow.com/users/8220", "pm_score": 4, "selected": false, "text": "<p>Compare to null is undefined, unless you use IS NULL.</p>\n\n<p>So, when comparing 3 to NULL (query A), it returns ...
2008/09/24
[ "https://Stackoverflow.com/questions/129077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12752/" ]
This issue came up when I got different records counts for what I thought were identical queries one using a `not in` `where` constraint and the other a `left join`. The table in the `not in` constraint had one null value (bad data) which caused that query to return a count of 0 records. I sort of understand why but I ...
Query A is the same as: ``` select 'true' where 3 = 1 or 3 = 2 or 3 = 3 or 3 = null ``` Since `3 = 3` is true, you get a result. Query B is the same as: ``` select 'true' where 3 <> 1 and 3 <> 2 and 3 <> null ``` When `ansi_nulls` is on, `3 <> null` is UNKNOWN, so the predicate evaluates to UNKNOWN, and you don'...
129,120
<p>I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently.</p> <p>Our production code contains no asserts whatsoever and my question is this...</p> <p>Sh...
[ { "answer_id": 129136, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 7, "selected": false, "text": "<p>Put <code>Debug.Assert()</code> everywhere in the code where you want have sanity checks to ensure invariants. When y...
2008/09/24
[ "https://Stackoverflow.com/questions/129120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8945/" ]
I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains no asserts whatsoever and my question is this... Should I begin usin...
In [Debugging Microsoft .NET 2.0 Applications](https://rads.stackoverflow.com/amzn/click/com/0735622027) John Robbins has a big section on assertions. His main points are: 1. Assert liberally. You can never have too many assertions. 2. Assertions don't replace exceptions. Exceptions cover the things your code demands;...
129,133
<p>How do I view the SQL that is generated by nHibernate? version 1.2</p>
[ { "answer_id": 129138, "author": "Iain Holder", "author_id": 1122, "author_profile": "https://Stackoverflow.com/users/1122", "pm_score": 3, "selected": false, "text": "<p>Use sql server profiler.</p>\n\n<p>EDIT (1 year later): As @Toran Billups states below, the NHibernate profiler Ayend...
2008/09/24
[ "https://Stackoverflow.com/questions/129133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1642688/" ]
How do I view the SQL that is generated by nHibernate? version 1.2
You can put something like this in your app.config/web.config file : in the configSections node : ``` <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/> ``` in the configuration node : ``` <log4net> <appender name="NHibernateFileLog" type="log4net.Appender.FileAppender"> ...
129,144
<p>Sometimes I find myself in the situation where I want to execute several sequential commands like such:</p> <pre><code>try: foo(a, b) except Exception, e: baz(e) try: bar(c, d) except Exception, e: baz(e) ... </code></pre> <p>This same pattern occurs when exceptions simply need to be ignored.</p> ...
[ { "answer_id": 129172, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 2, "selected": false, "text": "<p>If they're simple one-line commands, you can wrap them in <code>lambda</code>s:</p>\n\n<pre><code>for cmd in [\n ...
2008/09/24
[ "https://Stackoverflow.com/questions/129144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9241/" ]
Sometimes I find myself in the situation where I want to execute several sequential commands like such: ``` try: foo(a, b) except Exception, e: baz(e) try: bar(c, d) except Exception, e: baz(e) ... ``` This same pattern occurs when exceptions simply need to be ignored. This feels redundant and the e...
You could use the [`with` statement](https://www.python.org/dev/peps/pep-0343/) if you have python 2.5 or above: ``` from __future__ import with_statement import contextlib @contextlib.contextmanager def handler(): try: yield except Exception, e: baz(e) ``` Your example now becomes: ``` wit...
129,157
<p>I've encountered a problem when retrieving a JSONP response from a server in a different domain using IE6.</p> <p>When I make the same AJAX call using JSONP to a server in the same domain as the web page, all goes well in all browsers (including IE6). However, when I make calls between domains (XSS) using JSONP, I...
[ { "answer_id": 132005, "author": "redsquare", "author_id": 6440, "author_profile": "https://Stackoverflow.com/users/6440", "pm_score": 0, "selected": false, "text": "<p>Does you json validate at <a href=\"http://www.jslint.com\" rel=\"nofollow noreferrer\">jslint</a>?\nIf you have a ur a...
2008/09/24
[ "https://Stackoverflow.com/questions/129157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21832/" ]
I've encountered a problem when retrieving a JSONP response from a server in a different domain using IE6. When I make the same AJAX call using JSONP to a server in the same domain as the web page, all goes well in all browsers (including IE6). However, when I make calls between domains (XSS) using JSONP, Internet Exp...
you're not going to like this response so much, but I'm convinced it's on your server side. Here's why: I've recreated your scenario and when I run with your JSONP responder I get IE6 hanging, as you've explained. However, when I change the JSONP responder to my own code (exactly the same output as you've give above...
129,160
<p>The resource definition in tomcat's <code>server.xml</code> looks something like this...</p> <pre class="lang-xml prettyprint-override"><code>&lt;Resource name="jdbc/tox" scope="Shareable" type="javax.sql.DataSource" url="jdbc:oracle:thin:@yourDBserver.yourCompany.com:1521:yourDBsid" driverClass...
[ { "answer_id": 129268, "author": "Brad8118", "author_id": 7617, "author_profile": "https://Stackoverflow.com/users/7617", "pm_score": -1, "selected": false, "text": "<p>We use C#'s SHA1CryptoServiceProvider </p>\n\n<pre><code>print(SHA1CryptoServiceProvider sHA1Hasher = new SHA1Crypto...
2008/09/24
[ "https://Stackoverflow.com/questions/129160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
The resource definition in tomcat's `server.xml` looks something like this... ```xml <Resource name="jdbc/tox" scope="Shareable" type="javax.sql.DataSource" url="jdbc:oracle:thin:@yourDBserver.yourCompany.com:1521:yourDBsid" driverClassName="oracle.jdbc.pool.OracleDataSource" username="tox" ...
As said before encrypting passwords is just moving the problem somewhere else. Anyway, it's quite simple. Just write a class with static fields for your secret key and so on, and static methods to encrypt, decrypt your passwords. Encrypt your password in Tomcat's configuration file (`server.xml` or `yourapp.xml`...) u...
129,248
<p>I have a many to many index table, and I want to do an include/exclude type query on it.</p> <p>fid is really a integer index, but here as letters for easier understanding. Here's a sample table :</p> <p>table t</p> <pre><code>eid | fid ----+---- 1 | A 1 | B 1 | C 2 | B 2 | C 3 | A 3 | C 4 | A 4 ...
[ { "answer_id": 129260, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 3, "selected": false, "text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/ms188055.aspx\" rel=\"nofollow noreferrer\">set subtraction</a><...
2008/09/24
[ "https://Stackoverflow.com/questions/129248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
I have a many to many index table, and I want to do an include/exclude type query on it. fid is really a integer index, but here as letters for easier understanding. Here's a sample table : table t ``` eid | fid ----+---- 1 | A 1 | B 1 | C 2 | B 2 | C 3 | A 3 | C 4 | A 4 | B 5 | B ``` Here are ...
Here's an example of a query for 1 (2 works much the same) ``` select t1.eid from t t1 where t1.fid = 'B' and not exists (select 1 from t t2 where t2.eid = t1.eid and t2.fid = 'A') ```
129,265
<p>I have a Postgresql database on which I want to do a few cascading deletes. However, the tables aren't set up with the ON DELETE CASCADE rule. Is there any way I can perform a delete and tell Postgresql to cascade it just this once? Something equivalent to</p> <pre><code>DELETE FROM some_table CASCADE; </code></...
[ { "answer_id": 129300, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 9, "selected": true, "text": "<p>No. To do it just once you would simply write the delete statement for the table you want to cascade.</p>\n\n<pre><code>D...
2008/09/24
[ "https://Stackoverflow.com/questions/129265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
I have a Postgresql database on which I want to do a few cascading deletes. However, the tables aren't set up with the ON DELETE CASCADE rule. Is there any way I can perform a delete and tell Postgresql to cascade it just this once? Something equivalent to ``` DELETE FROM some_table CASCADE; ``` The answers to [this...
No. To do it just once you would simply write the delete statement for the table you want to cascade. ``` DELETE FROM some_child_table WHERE some_fk_field IN (SELECT some_id FROM some_Table); DELETE FROM some_table; ```
129,297
<p>I have a laptop running Ubuntu to which I connect an external monitor when I'm at the office. Usually this requires me to run <code>xrandr --auto</code> in order for the laptop to re-size the display to match the external monitor. It would be nice if this could be done automatically, either triggered when the monito...
[ { "answer_id": 129493, "author": "André", "author_id": 9683, "author_profile": "https://Stackoverflow.com/users/9683", "pm_score": 0, "selected": false, "text": "<p>Have you tried to set the DISPLAY variable in the script correctly and granted access for other users to your DISPLAY with ...
2008/09/24
[ "https://Stackoverflow.com/questions/129297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13051/" ]
I have a laptop running Ubuntu to which I connect an external monitor when I'm at the office. Usually this requires me to run `xrandr --auto` in order for the laptop to re-size the display to match the external monitor. It would be nice if this could be done automatically, either triggered when the monitor is connected...
I guees that the problem is that the script is being run as root, with no access to your xauth data. Depending on your setup, something like this could work: ``` xauth merge /home/your_username/.Xauthority export DISPLAY=:0.0 xrandr --auto ``` You could use something more clever to find out which user you need to ex...
129,335
<p>When you call <code>RedirectToAction</code> within a controller, it automatically redirects using an HTTP GET. How do I explicitly tell it to use an HTTP POST?</p> <p>I have an action that accepts both GET and POST requests, and I want to be able to <code>RedirectToAction</code> using POST and send it some values...
[ { "answer_id": 129361, "author": "Eli Courtwright", "author_id": 1694, "author_profile": "https://Stackoverflow.com/users/1694", "pm_score": 8, "selected": true, "text": "<p>HTTP doesn't support redirection to a page using POST. When you redirect somewhere, the HTTP \"Location\" header ...
2008/09/24
[ "https://Stackoverflow.com/questions/129335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7831/" ]
When you call `RedirectToAction` within a controller, it automatically redirects using an HTTP GET. How do I explicitly tell it to use an HTTP POST? I have an action that accepts both GET and POST requests, and I want to be able to `RedirectToAction` using POST and send it some values. Like this: ``` this.RedirectTo...
HTTP doesn't support redirection to a page using POST. When you redirect somewhere, the HTTP "Location" header tells the browser where to go, and the browser makes a GET request for that page. You'll probably have to just write the code for your page to accept GET requests as well as POST requests.
129,345
<p>How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) )</p> <pre><code>object objectToLogFor = xxx; container.Resolve&lt;ILogging&gt;(objectToLogFor); public class MyLogging : ILogging { public MyLogging(object objectToLogFor){} } <...
[ { "answer_id": 129363, "author": "cynicalman", "author_id": 410, "author_profile": "https://Stackoverflow.com/users/410", "pm_score": 0, "selected": false, "text": "<p>Yes, other frameworks are more feature-rich - you need to use an ioc framework that allows for constructor injection. S...
2008/09/24
[ "https://Stackoverflow.com/questions/129345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21733/" ]
How can I pass arguments to a constructor in an IOC-framework? I want to do something like: (Trying to be IOC-framework agnostic ;) ) ``` object objectToLogFor = xxx; container.Resolve<ILogging>(objectToLogFor); public class MyLogging : ILogging { public MyLogging(object objectToLogFor){} } ``` It seems that t...
In structure map you could achieve this using the With method: ``` string objectToLogFor = "PolicyName"; ObjectFactory.With<string>(objectToLogFor).GetInstance<ILogging>(); ``` See: <http://codebetter.com/blogs/jeremy.miller/archive/2008/09/25/using-structuremap-2-5-to-inject-your-entity-objects-into-services.aspx>
129,360
<p>I'm working with jQuery for the first time and need some help. I have html that looks like the following:</p> <pre><code>&lt;div id='comment-8' class='comment'&gt; &lt;p&gt;Blah blah&lt;/p&gt; &lt;div class='tools'&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id='comment-9' class='comment'&gt; &lt;p&gt;Blah bl...
[ { "answer_id": 129420, "author": "andy", "author_id": 6152, "author_profile": "https://Stackoverflow.com/users/6152", "pm_score": 1, "selected": false, "text": "<p>To get from the span up to the surrounding divs, you can use <code>&lt;tt&gt;parent()&lt;/tt&gt;</code> (if you know the exa...
2008/09/24
[ "https://Stackoverflow.com/questions/129360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2656/" ]
I'm working with jQuery for the first time and need some help. I have html that looks like the following: ``` <div id='comment-8' class='comment'> <p>Blah blah</p> <div class='tools'></div> </div> <div id='comment-9' class='comment'> <p>Blah blah something else</p> <div class='tools'></div> </div> ``...
Event callbacks are called with an event object as the first argument, you can't pass something else in that way. This event object has a `target` property that references the element it was called for, and the `this` variable is a reference to the element the event handler was attached to. So you could do the followin...
129,388
<p>I am writing a webpage in C# .NET. In javascript there is a function called GetElementsByTagName... this is nice for javascript invoked from the .aspx page. My question is, is there any way I can have this kind of functionality from my C# code-behind?</p> <p>--</p> <p>The scenario for those curious: I used an a...
[ { "answer_id": 129400, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p>FindControl(), or iterate through the controls on the page...</p>\n\n<pre><code>For each ctl as Control in Me.Contro...
2008/09/24
[ "https://Stackoverflow.com/questions/129388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13732/" ]
I am writing a webpage in C# .NET. In javascript there is a function called GetElementsByTagName... this is nice for javascript invoked from the .aspx page. My question is, is there any way I can have this kind of functionality from my C# code-behind? -- The scenario for those curious: I used an asp:repeater to gener...
FindControl(), or iterate through the controls on the page... ``` For each ctl as Control in Me.Controls If ctl.Name = whatYouWant Then do stuff Next 'ctl ``` --If you are creating the controls, you should be setting their ID's ``` Dim ctl as New Control() ctl.ID = "blah1" ``` etc...
129,389
<p>I want a true deep copy. In Java, this was easy, but how do you do it in C#?</p>
[ { "answer_id": 129395, "author": "Kilhoffer", "author_id": 5469, "author_profile": "https://Stackoverflow.com/users/5469", "pm_score": 10, "selected": true, "text": "<h3>Important Note</h3>\n<p><a href=\"https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters...
2008/09/24
[ "https://Stackoverflow.com/questions/129389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18931/" ]
I want a true deep copy. In Java, this was easy, but how do you do it in C#?
### Important Note [BinaryFormatter](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters.binary.binaryformatter?view=net-5.0) has been deprecated, and will no longer be available in .NET after November 2023. See [BinaryFormatter Obsoletion Strategy](https://github.com/dotnet/designs/bl...
129,406
<p>When my browser renders the following test case, there's a gap below the image. From my understanding of CSS, the bottom of the blue box should touch the bottom of the red box. But that's not the case. Why?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div cla...
[ { "answer_id": 129412, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 3, "selected": false, "text": "<p>Because the image is inline it sits on the baseline. Try</p>\n\n<pre><code>vertical-align: bottom;\n</code></pre>\n\...
2008/09/24
[ "https://Stackoverflow.com/questions/129406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
When my browser renders the following test case, there's a gap below the image. From my understanding of CSS, the bottom of the blue box should touch the bottom of the red box. But that's not the case. Why? ```html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xh...
Inline elements are vertically aligned to the baseline, not the very bottom of the containing box. This is because text needs a small amount of space underneath for descenders - the tails on letters like lowercase 'p'. So there is an imaginary line a short distance above the bottom, called the baseline, and inline elem...
129,417
<p>Coming from a desktop background I'm not sure exactly how to pass the exceptions I have caught to an Error page in order to avoid the standard exception screen being seen by my users. </p> <p>My general question is how do I pass the exception from page X to my Error page in ASP.net?</p>
[ { "answer_id": 129421, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 0, "selected": false, "text": "<p>I think you can use the <strong>global.asax</strong> -- <strong>Application_Exception</strong> handler to catch the excep...
2008/09/24
[ "https://Stackoverflow.com/questions/129417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20748/" ]
Coming from a desktop background I'm not sure exactly how to pass the exceptions I have caught to an Error page in order to avoid the standard exception screen being seen by my users. My general question is how do I pass the exception from page X to my Error page in ASP.net?
I suggest using the customErrors section in the web.config: ``` <customErrors mode="RemoteOnly" defaultRedirect="/error.html"> <error statusCode="403" redirect="/accessdenied.html" /> <error statusCode="404" redirect="/pagenotfound.html" /> </customErrors> ``` And then using [ELMAH](https://code.go...
129,445
<p>I'm new to postgreSQL and I have a simple question:</p> <p>I'm trying to create a simple script that creates a DB so I can later call it like this:</p> <pre><code>psql -f createDB.sql </code></pre> <p>I want the script to call other scripts (separate ones for creating tables, adding constraints, functions etc), l...
[ { "answer_id": 129496, "author": "Steve K", "author_id": 739, "author_profile": "https://Stackoverflow.com/users/739", "pm_score": 8, "selected": true, "text": "<p>Postgres started on Linux/Unix. I suspect that reversing the slash with fix it.</p>\n\n<pre><code>\\i somedir/script2.sql \...
2008/09/24
[ "https://Stackoverflow.com/questions/129445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21853/" ]
I'm new to postgreSQL and I have a simple question: I'm trying to create a simple script that creates a DB so I can later call it like this: ``` psql -f createDB.sql ``` I want the script to call other scripts (separate ones for creating tables, adding constraints, functions etc), like this: ``` \i script1.sql \i ...
Postgres started on Linux/Unix. I suspect that reversing the slash with fix it. ``` \i somedir/script2.sql ``` If you need to fully qualify something ``` \i c:/somedir/script2.sql ``` If that doesn't fix it, my next guess would be you need to escape the backslash. ``` \i somedir\\script2.sql ```
129,451
<p>If you are using Java or JavaScript, is there a good way to do something like a String subtraction so that given two strings:</p> <pre><code>org.company.project.component org.company.project.component.sub_component </code></pre> <p>you just get:</p> <pre><code>sub_component </code></pre> <p>I know that I could j...
[ { "answer_id": 129461, "author": "Chris Marasti-Georg", "author_id": 96, "author_profile": "https://Stackoverflow.com/users/96", "pm_score": 3, "selected": false, "text": "<pre><code>String result = \"org.company.project.component.sub_component\".replace(\"org.company.project.component\"...
2008/09/24
[ "https://Stackoverflow.com/questions/129451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5412/" ]
If you are using Java or JavaScript, is there a good way to do something like a String subtraction so that given two strings: ``` org.company.project.component org.company.project.component.sub_component ``` you just get: ``` sub_component ``` I know that I could just write code to walk the string comparing chara...
Depends on *precisely* what you want. If you're looking for a way to compare strings in the general case -- meaning finding common sub-strings between arbitrary inputs -- then you're looking at something closer to the Levenshtein distance and similar algorithms. However, if all you need is prefix/suffix comparison, thi...
129,453
<p>Every time I start in deep in a C# project, I end up with lots of events that really just need to pass a single item. I stick with the <code>EventHandler</code>/<code>EventArgs</code> practice, but what I like to do is have something like:</p> <pre><code>public delegate void EventHandler&lt;T&gt;(object src, Event...
[ { "answer_id": 129466, "author": "swilliams", "author_id": 736, "author_profile": "https://Stackoverflow.com/users/736", "pm_score": 3, "selected": false, "text": "<p>No, I don't think this is the wrong approach. I think it's even recommended in the [fantastic] book <a href=\"https://rad...
2008/09/24
[ "https://Stackoverflow.com/questions/129453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/96/" ]
Every time I start in deep in a C# project, I end up with lots of events that really just need to pass a single item. I stick with the `EventHandler`/`EventArgs` practice, but what I like to do is have something like: ``` public delegate void EventHandler<T>(object src, EventArgs<T> args); public class EventArgs<T>: ...
Delegate of the following form has been added since .NET Framework 2.0 ``` public delegate void EventHandler<TArgs>(object sender, TArgs args) where TArgs : EventArgs ``` You approach goes a bit further, since you provide out-of-the-box implementation for EventArgs with single data item, but it lacks several proper...
129,498
<p>I am using the ADONetAppender to (try) to log data via a stored procedure (so that I may inject logic into the logging routine).</p> <p>My configuration settings are listed below. Can anybody tell what I'm doing wrong?</p> <pre class="lang-xml prettyprint-override"><code>&lt;appender name="ADONetAppender_SqlServer...
[ { "answer_id": 130028, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Thanks to a vigilant DBA, we have solved the problem.</p>\n\n<p>Note the size of the \"@Message\" parameter. log4net is ta...
2008/09/24
[ "https://Stackoverflow.com/questions/129498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using the ADONetAppender to (try) to log data via a stored procedure (so that I may inject logic into the logging routine). My configuration settings are listed below. Can anybody tell what I'm doing wrong? ```xml <appender name="ADONetAppender_SqlServer" type="log4net.Appender.ADONetAppender"> <bufferSize val...
Use "AnsiString" as dbType for varchar. "String" for nvarchar. <http://msdn.microsoft.com/en-us/library/system.data.dbtype%28v=VS.90%29.aspx>
129,502
<p>This is on iPhone 0S 2.0. Answers for 2.1 are fine too, though I am unaware of any differences regarding tables.</p> <p>It feels like it should be possible to get text to wrap without creating a custom cell, since a <code>UITableViewCell</code> contains a <code>UILabel</code> by default. I know I can make it work i...
[ { "answer_id": 129743, "author": "drewh", "author_id": 1967, "author_profile": "https://Stackoverflow.com/users/1967", "pm_score": -1, "selected": false, "text": "<p>I don't think you can manipulate a base <code>UITableViewCell's</code> private <code>UILabel</code> to do this. You could ...
2008/09/24
[ "https://Stackoverflow.com/questions/129502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18017/" ]
This is on iPhone 0S 2.0. Answers for 2.1 are fine too, though I am unaware of any differences regarding tables. It feels like it should be possible to get text to wrap without creating a custom cell, since a `UITableViewCell` contains a `UILabel` by default. I know I can make it work if I create a custom cell, but th...
Here is a simpler way, and it works for me: Inside your `cellForRowAtIndexPath:` function. The first time you create your cell: ``` UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault re...
129,507
<p>How does one write a unittest that fails only if a function doesn't throw an expected exception?</p>
[ { "answer_id": 129522, "author": "Moe", "author_id": 3051, "author_profile": "https://Stackoverflow.com/users/3051", "pm_score": 11, "selected": true, "text": "<p>Use <a href=\"http://docs.python.org/library/unittest.html#unittest.TestCase.assertRaises\" rel=\"noreferrer\"><code>TestCase...
2008/09/24
[ "https://Stackoverflow.com/questions/129507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
How does one write a unittest that fails only if a function doesn't throw an expected exception?
Use [`TestCase.assertRaises`](http://docs.python.org/library/unittest.html#unittest.TestCase.assertRaises) (or `TestCase.failUnlessRaises`) from the unittest module, for example: ``` import mymod class MyTestCase(unittest.TestCase): def test1(self): self.assertRaises(SomeCoolException, mymod.myfunc) ```
129,510
<p>I have an application I'm writing where I'm allowing the administrators to add aliases for pages, categories, etc, and I would like to use a different controller/action depending on the alias (without redirecting, and I've found that render doesn't actually call the method. I just renders the template). I have tried...
[ { "answer_id": 130750, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 0, "selected": false, "text": "<p>I'm not sure I fully understand the question, but you could use <code>method_missing</code> in your controllers and t...
2008/09/24
[ "https://Stackoverflow.com/questions/129510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6705/" ]
I have an application I'm writing where I'm allowing the administrators to add aliases for pages, categories, etc, and I would like to use a different controller/action depending on the alias (without redirecting, and I've found that render doesn't actually call the method. I just renders the template). I have tried a ...
Quick Solution -------------- Have a catch-all route at the bottom of routes.rb. Implement any alias lookup logic you want in the action that route routes you to. In my implementation, I have a table which maps defined URLs to a controller, action, and parameter hash. I just pluck them out of the database, then call...
129,544
<p>I'm using the following code to make sure all certificates pass, even invalid ones, but I would like to know if there is a better way, as this event gets called globally and I only want the certificate to pass for a certain HTTP call and not for any others that are happening asynchronously.</p> <pre><code>// This d...
[ { "answer_id": 141558, "author": "SecretDeveloper", "author_id": 2720, "author_profile": "https://Stackoverflow.com/users/2720", "pm_score": 1, "selected": false, "text": "<p>I have recently been looking into this issue but without the same requirements that you have. I haven't seen a s...
2008/09/24
[ "https://Stackoverflow.com/questions/129544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11421/" ]
I'm using the following code to make sure all certificates pass, even invalid ones, but I would like to know if there is a better way, as this event gets called globally and I only want the certificate to pass for a certain HTTP call and not for any others that are happening asynchronously. ``` // This delegate makes ...
[.NET Framework 1.1/2.0/3.5 Installer for InnoSetup](http://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx)
129,607
<p>I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me?</p>
[ { "answer_id": 129616, "author": "dlamblin", "author_id": 459, "author_profile": "https://Stackoverflow.com/users/459", "pm_score": 3, "selected": false, "text": "<p>Well Google really works for you on this one: <a href=\"http://www.perlmonks.org/?node_id=94007\" rel=\"noreferrer\">http:...
2008/09/24
[ "https://Stackoverflow.com/questions/129607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me?
Dynamic Scoping. It is a neat concept. Many people don't use it, or understand it. Basically think of `my` as creating and anchoring a variable to one block of {}, A.K.A. scope. ``` my $foo if (true); # $foo lives and dies within the if statement. ``` So a `my` variable is what you are used to. whereas with dynamic...
129,642
<p>With C#, How do I play (Pause, Forward...) a sound file (mp3, ogg)? The file could be on the hard disk, or on the internet.</p> <p>Is there any library or Class out there that can ease me the work ?</p>
[ { "answer_id": 129671, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 0, "selected": false, "text": "<p>use <a href=\"http://www.codeproject.com/KB/audio-video/PlaySounds1.aspx\" rel=\"nofollow noreferrer\">PlaySound A...
2008/09/24
[ "https://Stackoverflow.com/questions/129642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20709/" ]
With C#, How do I play (Pause, Forward...) a sound file (mp3, ogg)? The file could be on the hard disk, or on the internet. Is there any library or Class out there that can ease me the work ?
If you don't mind including **Microsoft.VisualBasic.dll** in your project, you can do it this way: ``` var audio = new Microsoft.VisualBasic.Devices.Audio(); audio.Play("some file path"); ``` If you want to do more complex stuff, the easiest way I know of is to use the **Windows Media Player API**. You add the DLL a...
129,650
<p>Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like <pre>FindAllPostByTags(IList&lt;Tag&gt; tags)</pre> that returns all Posts that have all (not just some of) the Ta...
[ { "answer_id": 130339, "author": "Sander Rijken", "author_id": 5555, "author_profile": "https://Stackoverflow.com/users/5555", "pm_score": 0, "selected": false, "text": "<p>I don't have a system at hand with a Castle install right now, so I didn't test or compile this, but the code below...
2008/09/24
[ "https://Stackoverflow.com/questions/129650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14064/" ]
Let's say I have many-to-many relationship (using the ActiveRecord attribute HasAndBelongsToMany) between Posts and Tags (domain object names changed to protect the innocent), and I wanted a method like ``` FindAllPostByTags(IList<Tag> tags) ``` that returns all Posts that have all (not just some of) the Tags in the ...
You could also just use an `IN` statement ``` DetachedCriteria query = DetachedCriteria.For<Post>(); query.CreateCriteria("Post").Add(Expression.In("TagName", string.Join(",",tags.ToArray()) ); ``` I haven't compiled that so it could have errors
129,651
<p>In the following HTML, I'd like the frame around the image to be snug -- not to stretch out and take up all the available width in the parent container. I know there are a couple of ways to do this (including horrible things like manually setting its width to a particular number of pixels), but what is the <em>right...
[ { "answer_id": 129672, "author": "neouser99", "author_id": 10669, "author_profile": "https://Stackoverflow.com/users/10669", "pm_score": 2, "selected": false, "text": "<p>The beige rectangle is so wide because you have display: block on the span, turning an inline element into a block el...
2008/09/24
[ "https://Stackoverflow.com/questions/129651", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7598/" ]
In the following HTML, I'd like the frame around the image to be snug -- not to stretch out and take up all the available width in the parent container. I know there are a couple of ways to do this (including horrible things like manually setting its width to a particular number of pixels), but what is the *right* way?...
The *right* way is to use: ``` .pictureframe { display: inline-block; } ``` **Edit:** Floating the element also produces the same effect, this is because floating elements use the same [shrink-to-fit](http://www.w3.org/TR/CSS21/visudet.html#shrink-to-fit-float) algorithm for determining the width.
129,693
<p>I ruined several unit tests some time ago when I went through and refactored them to make them more <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="noreferrer">DRY</a>--the intent of each test was no longer clear. It seems there is a trade-off between tests' readability and maintainability. If ...
[ { "answer_id": 129722, "author": "Kristopher Johnson", "author_id": 1175, "author_profile": "https://Stackoverflow.com/users/1175", "pm_score": 8, "selected": false, "text": "<p>Readability is more important for tests. If a test fails, you want the problem to be obvious. The developer ...
2008/09/24
[ "https://Stackoverflow.com/questions/129693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4766/" ]
I ruined several unit tests some time ago when I went through and refactored them to make them more [DRY](http://en.wikipedia.org/wiki/Don%27t_repeat_yourself)--the intent of each test was no longer clear. It seems there is a trade-off between tests' readability and maintainability. If I leave duplicated code in unit t...
Duplicated code is a smell in unit test code just as much as in other code. If you have duplicated code in tests, it makes it harder to refactor the implementation code because you have a disproportionate number of tests to update. Tests should help you refactor with confidence, rather than be a large burden that imped...
129,746
<p>I am trying to set up JBoss 4.2.2 and JConsole for remote monitoring. As per many of the how-to's I have found on the web to do this you need to enable jmxremote by setting the following options in run.conf. (I realize the other two opts disable authentication)</p> <pre><code>JAVA_OPTS="$JAVA_OPTS -Dcom.sun.manag...
[ { "answer_id": 129872, "author": "Chris Vest", "author_id": 13251, "author_profile": "https://Stackoverflow.com/users/13251", "pm_score": 2, "selected": false, "text": "<p>I have honestly never tried this remoting approach. But, if both your client machine and the server happen to both b...
2008/09/24
[ "https://Stackoverflow.com/questions/129746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4419/" ]
I am trying to set up JBoss 4.2.2 and JConsole for remote monitoring. As per many of the how-to's I have found on the web to do this you need to enable jmxremote by setting the following options in run.conf. (I realize the other two opts disable authentication) ``` JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote....
I have honestly never tried this remoting approach. But, if both your client machine and the server happen to both be linux boxes or similar \*nixes with SSH, then you can `ssh -XCA` to the server and start JConsole *on the server* and have the GUI display on your client machine with X port forwarding. A JConsole runni...
129,773
<p>When you create your mapping files, do you map your properties to fields or properties :</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Foo" namespace="Foo.Bar" &gt; &lt;class name="Foo" table="FOOS" batch-size="100"&gt; [...] &lt;property name="FooProperty1" access="fie...
[ { "answer_id": 129797, "author": "Sara Chipps", "author_id": 4140, "author_profile": "https://Stackoverflow.com/users/4140", "pm_score": 1, "selected": false, "text": "<p>I map to properties, I haven't come across the situation where I would map to a field... and when I have I augment my...
2008/09/24
[ "https://Stackoverflow.com/questions/129773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/971/" ]
When you create your mapping files, do you map your properties to fields or properties : ``` <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Foo" namespace="Foo.Bar" > <class name="Foo" table="FOOS" batch-size="100"> [...] <property name="FooProperty1" access="field.camelcase" column="FOO_1" ...
I map to properties. If I find it necessary, I map the SETTER to a field. (usually via something like "access=field.camelcase"). This lets me have nice looking Queries, e.g. "from People Where FirstName = 'John'" instead of something like "from People Where firstName/\_firstName" and also avoid setter logic when hydra...
129,815
<p>I am working on a geometry problem that requires finding the intersection of two parabolic arcs in any rotation. I was able to intesect a line and a parabolic arc by rotating the plane to align the arc with an axis, but two parabolas cannot both align with an axis. I am working on deriving the formulas, but I woul...
[ { "answer_id": 129889, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 4, "selected": true, "text": "<p>I'd first define the equation for the parabolic arc in 2D without rotations:</p>\n\n<pre><code> x(t) = ax² + b...
2008/09/24
[ "https://Stackoverflow.com/questions/129815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15032/" ]
I am working on a geometry problem that requires finding the intersection of two parabolic arcs in any rotation. I was able to intesect a line and a parabolic arc by rotating the plane to align the arc with an axis, but two parabolas cannot both align with an axis. I am working on deriving the formulas, but I would lik...
I'd first define the equation for the parabolic arc in 2D without rotations: ``` x(t) = ax² + bx + c y(t) = t; ``` You can now apply the rotation by building a rotation matrix: ``` s = sin(angle) c = cos(angle) matrix = | c -s | | s c | ``` Apply that matrix and you'll get the rotated param...
129,828
<p>My workplace filters our internet traffic by forcing us to go through a proxy, and unfortunately sites such as IT Conversations and Libsyn are blocked. However, mp3 files in general are not filtered, if they come from sites not on the proxy's blacklist.</p> <p>So is there a website somewhere that will let me give ...
[ { "answer_id": 129886, "author": "benPearce", "author_id": 4490, "author_profile": "https://Stackoverflow.com/users/4490", "pm_score": 1, "selected": false, "text": "<p>There are many other Development/Dotnet/Technology podcasts, try one of <a href=\"https://stackoverflow.com/questions/1...
2008/09/24
[ "https://Stackoverflow.com/questions/129828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1694/" ]
My workplace filters our internet traffic by forcing us to go through a proxy, and unfortunately sites such as IT Conversations and Libsyn are blocked. However, mp3 files in general are not filtered, if they come from sites not on the proxy's blacklist. So is there a website somewhere that will let me give it a URL an...
I ended up writing an extremely dumb-and-simple cgi-script and hosting it on my web server, with a script on my work computer to get at it. Here's the CGI script: ``` #!/usr/local/bin/python import cgitb; cgitb.enable() import cgi from urllib2 import urlopen def tohex(data): return "".join(hex(ord(char))[2:].rju...
129,861
<p>It is a bit of a "chicken or egg" kind of query, but can someone dreamup a query that can return the name of the current database instance in which the query executes? Believe me when I say I understand the paradox: why do you need to know the name of the database instance if you're already connected to execute the ...
[ { "answer_id": 129879, "author": "Dana", "author_id": 7856, "author_profile": "https://Stackoverflow.com/users/7856", "pm_score": 6, "selected": false, "text": "<pre><code>SELECT DB_NAME()\n</code></pre>\n\n<p>Returns the database name.</p>\n" }, { "answer_id": 129882, "autho...
2008/09/24
[ "https://Stackoverflow.com/questions/129861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
It is a bit of a "chicken or egg" kind of query, but can someone dreamup a query that can return the name of the current database instance in which the query executes? Believe me when I say I understand the paradox: why do you need to know the name of the database instance if you're already connected to execute the que...
``` SELECT @@servername AS 'Server Name' -- The database server's machine name ,@@servicename AS 'Instance Name' -- e.g.: MSSQLSERVER ,DB_NAME() AS 'Database Name' ,HOST_NAME() AS 'Host Name' -- The database client's machine name ```
129,877
<p>I'm writing a function to find <a href="http://projecteuler.net/index.php?section=problems&amp;id=12" rel="noreferrer">triangle numbers</a> and the natural way to write it is recursively:</p> <pre><code>function triangle (x) if x == 0 then return 0 end return x+triangle(x-1) end </code></pre> <p>But attempti...
[ { "answer_id": 129881, "author": "Jon Ericson", "author_id": 1438, "author_profile": "https://Stackoverflow.com/users/1438", "pm_score": 2, "selected": false, "text": "<pre><code>function memoize (f)\n local cache = {}\n return function (x)\n if cache[x] then\n ...
2008/09/24
[ "https://Stackoverflow.com/questions/129877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1438/" ]
I'm writing a function to find [triangle numbers](http://projecteuler.net/index.php?section=problems&id=12) and the natural way to write it is recursively: ``` function triangle (x) if x == 0 then return 0 end return x+triangle(x-1) end ``` But attempting to calculate the first 100,000 triangle numbers fails w...
I bet something like this should work with variable argument lists in Lua: ``` local function varg_tostring(...) local s = select(1, ...) for n = 2, select('#', ...) do s = s..","..select(n,...) end return s end local function memoize(f) local cache = {} return function (...) l...
129,890
<p>I'm getting lost in pointer land, I believe. I've got this (code syntax might be a little off, I am not looking at the machine with this code on it...but all the pertinent details are correct):</p> <pre><code>NSMutableArray *tmp = [[NSMutableArray alloc] init]; </code></pre> <p>I them pass that to a routine in an...
[ { "answer_id": 129906, "author": "user20456", "author_id": 20456, "author_profile": "https://Stackoverflow.com/users/20456", "pm_score": 1, "selected": false, "text": "<p>NSMutableArray retains objects added to it, but have you retained the array itself?</p>\n" }, { "answer_id": ...
2008/09/24
[ "https://Stackoverflow.com/questions/129890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/232/" ]
I'm getting lost in pointer land, I believe. I've got this (code syntax might be a little off, I am not looking at the machine with this code on it...but all the pertinent details are correct): ``` NSMutableArray *tmp = [[NSMutableArray alloc] init]; ``` I them pass that to a routine in another class ``` - (BOOL)my...
You don't need to call retain in this case. [[NSMutableArray alloc] init] creates the object with a retain count of 1, so it won't get released until you specifically release it. It would be good to see more of the code. I don't think the error is in the very small amount you've posted so far..
129,917
<p>It's common knowledge that using System.Diagnostics.Process.Start is the way to launch a url from a C# applicaiton:</p> <p>System.Diagnostics.Process.Start("<a href="http://www.mywebsite.com" rel="nofollow noreferrer">http://www.mywebsite.com</a>");</p> <p>However, if this url is invalid the application seems to h...
[ { "answer_id": 129926, "author": "Danimal", "author_id": 2757, "author_profile": "https://Stackoverflow.com/users/2757", "pm_score": 2, "selected": false, "text": "<p>If you need to verify that the URL exists, the only thing you can do is create a custom request in advance and verify tha...
2008/09/24
[ "https://Stackoverflow.com/questions/129917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9251/" ]
It's common knowledge that using System.Diagnostics.Process.Start is the way to launch a url from a C# applicaiton: System.Diagnostics.Process.Start("<http://www.mywebsite.com>"); However, if this url is invalid the application seems to have no way of knowing that the call failed or why. Is there a better way to laun...
Try an approach as below. ``` try { var url = new Uri("http://www.example.com/"); Process.Start(url.AbsoluteUri); } catch (UriFormatException) { // URL is not parsable } ``` This does not ensure that the resource exist, but it does ensure the URL is wellformed. You might also want to check if the scheme...
129,927
<p>I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server?</p> <p>Edit: to answer a question down below, this is going to be a download once and the...
[ { "answer_id": 129953, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Use a StringBuilder to create the text of the file, and then send it to the user using Content-Disposition.</p>\n\n<p>Examp...
2008/09/24
[ "https://Stackoverflow.com/questions/129927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download. What's the best / most efficient way to build such a text file on a .net web server? Edit: to answer a question down below, this is going to be a download once and then throw-awa...
The answer will depend on whether, as Forgotten Semicolon mentions, you need repeated downloads or once-and-done throwaways. Either way, the key will be to set the content-type of the output to ensure that a download window is displayed. The problem with straight text output is that the browser will attempt to display...
129,932
<p>I am running VS Team Studio 2008. I have created a web test that I want to use for monitoring a company web site. It interacts with the site and does some round trip processing. I want to create a standalone EXE file that can be run remotely. I have tried converting it to VB code and C# code and then creating comp...
[ { "answer_id": 130855, "author": "Jay Mooney", "author_id": 733, "author_profile": "https://Stackoverflow.com/users/733", "pm_score": 1, "selected": false, "text": "<p>Can you call MSTest.exe? If your test was created using VisualStudio, it uses MSTest to execute it.</p>\n\n<p>If you di...
2008/09/24
[ "https://Stackoverflow.com/questions/129932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am running VS Team Studio 2008. I have created a web test that I want to use for monitoring a company web site. It interacts with the site and does some round trip processing. I want to create a standalone EXE file that can be run remotely. I have tried converting it to VB code and C# code and then creating compiling...
Daniel, I created most of the classes in the Microsoft.VisualStudio.TestTools.WebTesting namespace and I can assure you it's NOT possible to run a coded web test without Visual Studio or MSTest.exe. Coded web tests basically hand WebTestRequests back to the web test engine, they don't start the web test engine themselv...
129,968
<p>Is it possible to convert a <code>com.vividsolutions.jts.geom.Geometry</code> (or a subclass of it) into a class that implements <code>java.awt.Shape</code>? Which library or method can I use to achieve that goal?</p>
[ { "answer_id": 129995, "author": "tim_yates", "author_id": 6509, "author_profile": "https://Stackoverflow.com/users/6509", "pm_score": 3, "selected": true, "text": "<p>According to:</p>\n\n<p><a href=\"http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html\" rel=\"nofollo...
2008/09/24
[ "https://Stackoverflow.com/questions/129968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21005/" ]
Is it possible to convert a `com.vividsolutions.jts.geom.Geometry` (or a subclass of it) into a class that implements `java.awt.Shape`? Which library or method can I use to achieve that goal?
According to: <http://lists.jump-project.org/pipermail/jts-devel/2007-May/001954.html> There's a class: ``` com.vividsolutions.jump.workbench.ui.renderer.java2D.Java2DConverter ``` which can do it?
130,020
<p>Can anyone recommend a dropdownlist control for asp.net (3.5) that can render option groups? Thanks</p>
[ { "answer_id": 130046, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 7, "selected": true, "text": "<p>I've used the standard control in the past, and just added a simple <a href=\"http://msdn.microsoft.com/en-us/librar...
2008/09/24
[ "https://Stackoverflow.com/questions/130020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14072/" ]
Can anyone recommend a dropdownlist control for asp.net (3.5) that can render option groups? Thanks
I've used the standard control in the past, and just added a simple [ControlAdapter](http://msdn.microsoft.com/en-us/library/system.web.ui.adapters.controladapter.aspx) for it that would override the default behavior so it could render <optgroup>s in certain places. This works great even if you have controls that don't...
130,032
<p>Is there a built-in editor for a multi-line string in a <code>PropertyGrid</code>.</p>
[ { "answer_id": 130079, "author": "Hector Sosa Jr", "author_id": 12829, "author_profile": "https://Stackoverflow.com/users/12829", "pm_score": 2, "selected": false, "text": "<p>No, you will need to create what's called a modal UI type editor. You'll need to create a class that inherits fr...
2008/09/24
[ "https://Stackoverflow.com/questions/130032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4592/" ]
Is there a built-in editor for a multi-line string in a `PropertyGrid`.
I found that `System.Design.dll` has `System.ComponentModel.Design.MultilineStringEditor` which can be used as follows: ``` public class Stuff { [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] public string MultiLineProperty { get; set; } } ```
130,074
<p>python's time module seems a little haphazard. For example, here is a list of methods in there, from the docstring:</p> <pre><code>time() -- return current time in seconds since the Epoch as a float clock() -- return CPU time since process start as a float sleep() -- delay for a number of seconds given as a float ...
[ { "answer_id": 130134, "author": "Mark Roddy", "author_id": 9940, "author_profile": "https://Stackoverflow.com/users/9940", "pm_score": 2, "selected": false, "text": "<p>I always thought the time and datetime modules were a little incoherent. Anyways, here's the inverse of mktime</p>\n\...
2008/09/24
[ "https://Stackoverflow.com/questions/130074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2900/" ]
python's time module seems a little haphazard. For example, here is a list of methods in there, from the docstring: ``` time() -- return current time in seconds since the Epoch as a float clock() -- return CPU time since process start as a float sleep() -- delay for a number of seconds given as a float gmtime() -- con...
There is actually an inverse function, but for some bizarre reason, it's in the [calendar](https://docs.python.org/2/library/calendar.html) module: calendar.timegm(). I listed the functions in this [answer](https://stackoverflow.com/questions/79797/how-do-i-convert-local-time-to-utc-in-python#79913).
130,092
<p>Rails uses the concept of migrations to deal with model changes using the ActiveRecord API.</p> <p>CouchDB uses JSON (nested maps and arrays) to represent its model objects.</p> <p>In working with CouchDB so far, I don't see good ways of recognizing when the document's structure has changed (other than being disci...
[ { "answer_id": 130608, "author": "Ian Terrell", "author_id": 9269, "author_profile": "https://Stackoverflow.com/users/9269", "pm_score": 2, "selected": false, "text": "<p>Check out <a href=\"https://github.com/arunthampi/activecouch/tree/master\" rel=\"nofollow noreferrer\">ActiveCouch</...
2008/09/24
[ "https://Stackoverflow.com/questions/130092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19784/" ]
Rails uses the concept of migrations to deal with model changes using the ActiveRecord API. CouchDB uses JSON (nested maps and arrays) to represent its model objects. In working with CouchDB so far, I don't see good ways of recognizing when the document's structure has changed (other than being disciplined as a devel...
Time for RDBMS de-brainwashing. :) One of the biggest points of couchdb's schema-less design is directly aimed at preventing the need for migrations. The JSON representation of objects makes it easy to just duck type your objects. For example, given that you have a blog type web app with posts and whatever fancy thin...
130,116
<p>How can I read the first line from a text file using a Windows batch file? Since the file is large I only want to deal with the first line.</p>
[ { "answer_id": 130154, "author": "Ross Fuhrman", "author_id": 9431, "author_profile": "https://Stackoverflow.com/users/9431", "pm_score": 4, "selected": false, "text": "<p>You might give this a try:</p>\n\n<pre><code>@echo off\n\nfor /f %%a in (sample.txt) do (\n echo %%a\n exit /b\n)\...
2008/09/24
[ "https://Stackoverflow.com/questions/130116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9822/" ]
How can I read the first line from a text file using a Windows batch file? Since the file is large I only want to deal with the first line.
Here's a general-purpose batch file to print the top `n` lines from a file like the GNU `head` utility, instead of just a single line. ``` @echo off if [%1] == [] goto usage if [%2] == [] goto usage call :print_head %1 %2 goto :eof REM REM print_head REM Prints the first non-blank %1 lines in the file %2. REM :prin...
130,117
<p>Most people say <em>never</em> throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes the point that <em>"the vector destructor explicitly invokes the destructor for every element. This implies that if an element destructor throws, the vector destruction fails... There is r...
[ { "answer_id": 130123, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 9, "selected": true, "text": "<p>Throwing an exception out of a destructor is dangerous.<br />\nIf another exception is already propagating the appli...
2008/09/24
[ "https://Stackoverflow.com/questions/130117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
Most people say *never* throw an exception out of a destructor - doing so results in undefined behavior. Stroustrup makes the point that *"the vector destructor explicitly invokes the destructor for every element. This implies that if an element destructor throws, the vector destruction fails... There is really no good...
Throwing an exception out of a destructor is dangerous. If another exception is already propagating the application will terminate. ``` #include <iostream> class Bad { public: // Added the noexcept(false) so the code keeps its original meaning. // Post C++11 destructors are by default `noexcept...
130,132
<p>My form receives asynchronous callbacks from another object on random worker threads. I have been passing the data to the main thread (where it can be used to update onscreen controls) using delegates as shown below. Performance is dreadful -- once I reach 500 updates per second, the program completely locks up. ...
[ { "answer_id": 130175, "author": "Ilya Ryzhenkov", "author_id": 18575, "author_profile": "https://Stackoverflow.com/users/18575", "pm_score": 2, "selected": true, "text": "<p>You probably don't need to update UI on every event, but rather \"not as often as X times per second\". You may u...
2008/09/24
[ "https://Stackoverflow.com/questions/130132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
My form receives asynchronous callbacks from another object on random worker threads. I have been passing the data to the main thread (where it can be used to update onscreen controls) using delegates as shown below. Performance is dreadful -- once I reach 500 updates per second, the program completely locks up. My GUI...
You probably don't need to update UI on every event, but rather "not as often as X times per second". You may utilize StopWatch or other timing system to collect events during a period of time, and then update UI when appropriate. If you need to capture all events, collect them in the Queue and fire event every so of...
130,166
<p>I am trying to write a macro that would "click" a command button that is in another workbook. Is that possible? Without changing any of the code within that other workbook?</p>
[ { "answer_id": 130325, "author": "Ozgur Ozcitak", "author_id": 976, "author_profile": "https://Stackoverflow.com/users/976", "pm_score": 1, "selected": false, "text": "<p>You can use <code>Application.Run</code> for that:</p>\n\n<pre><code>Run \"OtherWorkbook.xls!MyOtherMacro\"\n</code><...
2008/09/24
[ "https://Stackoverflow.com/questions/130166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to write a macro that would "click" a command button that is in another workbook. Is that possible? Without changing any of the code within that other workbook?
For an ActiveX button in another workbook: ``` Workbooks("OtherBook").Worksheets("Sheet1").CommandButton1.Value = True ``` For an MSForms button in another workbook: ``` Application.Run Workbooks("OtherBook").Worksheets("Sheet1").Shapes("Button 1").OnAction ```
130,186
<p>I'm having an unusual problem with an IE document with contentEditable set to true. Calling select() on a range that is positioned at the end of a text node that immediately precedes a block element causes the selection to be shifted to the right one character and appear where it shouldn't. I've submitted a bug to...
[ { "answer_id": 149310, "author": "Dave R", "author_id": 6969, "author_profile": "https://Stackoverflow.com/users/6969", "pm_score": 0, "selected": false, "text": "<p>I recently worked at a site which used Microsoft CMS with the \"MSIB+ pack\" of controls which included a WYSIWYG editor w...
2008/09/24
[ "https://Stackoverflow.com/questions/130186", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8458/" ]
I'm having an unusual problem with an IE document with contentEditable set to true. Calling select() on a range that is positioned at the end of a text node that immediately precedes a block element causes the selection to be shifted to the right one character and appear where it shouldn't. I've submitted a bug to Micr...
I've figured out a few methods for dealing with IE ranges like this. If all you want to do is save where the cursor is, and then restore it, you can use the pasteHTML method to insert an empty span at the current position of the cursor, and then use the moveToElementText method to put it back at that position again: ...
130,187
<p>I want to index this view but because it has subquery i cant index. Can anyone suggest how to change this view so that i can index it.</p> <pre><code>ALTER VIEW [dbo].[Recon2] WITH SCHEMABINDING AS SELECT dbo.Transactions.CustomerCode, dbo.Customer_Master.CustomerName, dbo.Transactions.TransDate, dbo.Transa...
[ { "answer_id": 130279, "author": "Corbin March", "author_id": 7625, "author_profile": "https://Stackoverflow.com/users/7625", "pm_score": 2, "selected": false, "text": "<p>I can't run it (obviously) but what about this?: </p>\n\n<pre><code>SELECT\ndbo.Transactions.CustomerCode, \ndbo.Cus...
2008/09/24
[ "https://Stackoverflow.com/questions/130187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14752/" ]
I want to index this view but because it has subquery i cant index. Can anyone suggest how to change this view so that i can index it. ``` ALTER VIEW [dbo].[Recon2] WITH SCHEMABINDING AS SELECT dbo.Transactions.CustomerCode, dbo.Customer_Master.CustomerName, dbo.Transactions.TransDate, dbo.Transactions.PubCode...
I can't run it (obviously) but what about this?: ``` SELECT dbo.Transactions.CustomerCode, dbo.Customer_Master.CustomerName, dbo.Transactions.TransDate, dbo.Transactions.PubCode, dbo.Transactions.TransType, dbo.Transactions.Copies, '0' AS ReceiptNo, '2008-01-01' AS PaymentDate, 0 AS Amount, dbo.Transactions....
130,192
<p>I was wondering if there is a clean way to represent an is-a relationship as illustrated by this example:</p> <p>This DB stores recording times for three types of programs: movies, game shows, drama. In an object oriented sense each of these is-a program. Each of these subclasses have different properties. Here are...
[ { "answer_id": 130211, "author": "Ron Savage", "author_id": 12476, "author_profile": "https://Stackoverflow.com/users/12476", "pm_score": 2, "selected": false, "text": "<p>Yes, that should be one table like</p>\n\n<pre><code>Programs:\n id,\n name,\n type_id,\n length,\n etc......
2008/09/24
[ "https://Stackoverflow.com/questions/130192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21906/" ]
I was wondering if there is a clean way to represent an is-a relationship as illustrated by this example: This DB stores recording times for three types of programs: movies, game shows, drama. In an object oriented sense each of these is-a program. Each of these subclasses have different properties. Here are the table...
Yes, that should be one table like ``` Programs: id, name, type_id, length, etc... ``` with a reference table for the type of program if there are other bits of data associated with the type: ``` ProgramType type_id, type_name, etc... ``` Like that.
130,193
<p>Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?</p>
[ { "answer_id": 130201, "author": "schaelle", "author_id": 21911, "author_profile": "https://Stackoverflow.com/users/21911", "pm_score": -1, "selected": false, "text": "<p>See <a href=\"http://www.chaminade.org/MIS/Articles/RegistryEdit.htm\" rel=\"nofollow noreferrer\">http://www.chamina...
2008/09/24
[ "https://Stackoverflow.com/questions/130193", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script?
You can use the REG command. From <http://www.ss64.com/nt/reg.html>: ``` Syntax: REG QUERY [ROOT\]RegKey /v ValueName [/s] REG QUERY [ROOT\]RegKey /ve --This returns the (default) value REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f] REG ADD [ROOT\]RegKey /ve [/d Data] [/f...
130,208
<p>Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? </p> <p>If it helps, I know that the class implements IMyCustomInterface and is fro...
[ { "answer_id": 130241, "author": "Jonathan Rupp", "author_id": 12502, "author_profile": "https://Stackoverflow.com/users/12502", "pm_score": 4, "selected": true, "text": "<p>Once you parse it up, use <a href=\"http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx\" rel=\"noreferrer\">Typ...
2008/09/24
[ "https://Stackoverflow.com/questions/130208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5287/" ]
Assuming I have only the class name of a generic as a string in the form of "MyCustomGenericCollection(of MyCustomObjectClass)" and don't know the assembly it comes from, what is the easiest way to create an instance of that object? If it helps, I know that the class implements IMyCustomInterface and is from an assem...
Once you parse it up, use [Type.GetType(string)](http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx) to get a reference to the types involved, then use [Type.MakeGenericType(Type[])](http://msdn.microsoft.com/en-us/library/system.type.makegenerictype.aspx) to construct the specific generic type you need. Then, use [...
130,240
<p>I have a bunch a values I would like to add together which are entered into a form. Right now, the form has 11 lines but it could get larger in the future. I can easily add all the values together with something like:</p> <pre><code>$total = $value1 + $value2 + ... + $value11; </code></pre> <p>All the values I wan...
[ { "answer_id": 130242, "author": "unexist", "author_id": 18179, "author_profile": "https://Stackoverflow.com/users/18179", "pm_score": 2, "selected": false, "text": "<p>Uhm why don't you use an array? If you give the forms a name like foobar[] it will be an array in PHP.</p>\n" }, { ...
2008/09/24
[ "https://Stackoverflow.com/questions/130240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16292/" ]
I have a bunch a values I would like to add together which are entered into a form. Right now, the form has 11 lines but it could get larger in the future. I can easily add all the values together with something like: ``` $total = $value1 + $value2 + ... + $value11; ``` All the values I want to add together are comi...
``` for ($i = 1 ; $i <= 3 ; $i++){ $varName = "pBalance".$i; $tempTotal += $$varName; } ``` This will do what you want. However you might indeed consider using an array for this kind of thing.
130,262
<p>The Python list comprehension syntax makes it easy to filter values within a comprehension. For example:</p> <pre><code>result = [x**2 for x in mylist if type(x) is int] </code></pre> <p>Will return a list of the squares of integers in mylist. However, what if the test involves some (costly) computation and you ...
[ { "answer_id": 130276, "author": "Nick", "author_id": 5222, "author_profile": "https://Stackoverflow.com/users/5222", "pm_score": 5, "selected": false, "text": "<p>Came up with my own answer after a minute of thought. It can be done with nested comprehensions:</p>\n\n<pre><code>result =...
2008/09/24
[ "https://Stackoverflow.com/questions/130262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5222/" ]
The Python list comprehension syntax makes it easy to filter values within a comprehension. For example: ``` result = [x**2 for x in mylist if type(x) is int] ``` Will return a list of the squares of integers in mylist. However, what if the test involves some (costly) computation and you want to filter on the result...
If the calculations are already nicely bundled into functions, how about using `filter` and `map`? ``` result = filter (None, map (expensive, mylist)) ``` You can use `itertools.imap` if the list is very large.
130,268
<h3>Background</h3> <p>Normal rails eager-loading of collections works like this:</p> <pre><code>Person.find(:all, :include=&gt;:companies) </code></pre> <p>This generates some sql which does</p> <pre><code>LEFT OUTER JOIN companies ON people.company_id = companies.id </code></pre> <h3>Question</h3> <p>However, I...
[ { "answer_id": 131247, "author": "Toby Hede", "author_id": 14971, "author_profile": "https://Stackoverflow.com/users/14971", "pm_score": 3, "selected": false, "text": "<p>Can you not add the join conditions using ActiveRecord?</p>\n\n<p>For example, I have a quite complex query using sev...
2008/09/24
[ "https://Stackoverflow.com/questions/130268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/234/" ]
### Background Normal rails eager-loading of collections works like this: ``` Person.find(:all, :include=>:companies) ``` This generates some sql which does ``` LEFT OUTER JOIN companies ON people.company_id = companies.id ``` ### Question However, I need a custom join (this could also arise if I was using `fin...
Can you not add the join conditions using ActiveRecord? For example, I have a quite complex query using several dependent records and it works fine by combining conditions and include directives ``` Contractors.find( :all, :include => {:council_areas => :suburbs}, :conditions => ["suburbs.postcode = ?", custom...
130,273
<p>I'm trying to automate a program I made with a test suite via a .cmd file.</p> <p>I can get the program that I ran's return code via %errorlevel%. </p> <p>My program has certain return codes for each type of error.</p> <p>For example: </p> <p>1 - means failed for such and such a reason</p> <p>2 - means failed f...
[ { "answer_id": 130290, "author": "Kris Kumler", "author_id": 4281, "author_profile": "https://Stackoverflow.com/users/4281", "pm_score": 1, "selected": false, "text": "<p>Not exactly like that, with a subroutine, but you can either populate the a variable with the text using a <a href=\"...
2008/09/24
[ "https://Stackoverflow.com/questions/130273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
I'm trying to automate a program I made with a test suite via a .cmd file. I can get the program that I ran's return code via %errorlevel%. My program has certain return codes for each type of error. For example: 1 - means failed for such and such a reason 2 - means failed for some other reason ... echo FAILED...
You can do this quite neatly with the `ENABLEDELAYEDEXPANSION` option. This allows you to use `!` as variable marker that is evaluated after `%`. ``` REM Turn on Delayed Expansion SETLOCAL ENABLEDELAYEDEXPANSION REM Define messages as variables with the ERRORLEVEL on the end of the name SET MESSAGE0=Everything is fin...
130,292
<p>What is the proper way to inject a data access dependency when I do lazy loading?</p> <p>For example I have the following class structure</p> <pre><code>class CustomerDao : ICustomerDao public Customer GetById(int id) {...} class Transaction { int customer_id; //Transaction always knows this value Customer ...
[ { "answer_id": 131059, "author": "Toran Billups", "author_id": 2701, "author_profile": "https://Stackoverflow.com/users/2701", "pm_score": 1, "selected": false, "text": "<p>I typically do the dependency injection in the constructor like you have above, but take the lazy loading a step fu...
2008/09/24
[ "https://Stackoverflow.com/questions/130292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
What is the proper way to inject a data access dependency when I do lazy loading? For example I have the following class structure ``` class CustomerDao : ICustomerDao public Customer GetById(int id) {...} class Transaction { int customer_id; //Transaction always knows this value Customer _customer = null; I...
I suggest something different... Use a lazy load class : ``` public class Lazy<T> { T value; Func<T> loader; public Lazy(T value) { this.value = value; } public Lazy(Func<T> loader { this.loader = loader; } T Value { get { if (loader != null) { value = loader(); ...
130,322
<p>I am trying to pass a member function within a class to a function that takes a member function class pointer. The problem I am having is that I am not sure how to properly do this within the class using the this pointer. Does anyone have suggestions?</p> <p>Here is a copy of the class that is passing the member ...
[ { "answer_id": 130402, "author": "Matt Cruikshank", "author_id": 8643, "author_profile": "https://Stackoverflow.com/users/8643", "pm_score": 4, "selected": false, "text": "<p>I'd strongly recommend <code>boost::bind</code> and <code>boost::function</code> for anything like this.</p>\n\n<...
2008/09/24
[ "https://Stackoverflow.com/questions/130322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20229/" ]
I am trying to pass a member function within a class to a function that takes a member function class pointer. The problem I am having is that I am not sure how to properly do this within the class using the this pointer. Does anyone have suggestions? Here is a copy of the class that is passing the member function: `...
To call a member function by pointer, you need two things: A pointer to the object and a pointer to the function. You need both in `MenuButton::SetButton()` ``` template <class object> void MenuButton::SetButton(int xPos, int yPos, LPCWSTR normalFilePath, LPCWSTR hoverFilePath, LPCWSTR pressedFilePath, ...
130,328
<p>How do I get the caller's IP address in a WebMethod?</p> <pre><code>[WebMethod] public void Foo() { // HttpRequest... ? - Not giving me any options through intellisense... } </code></pre> <p>using C# and ASP.NET</p>
[ { "answer_id": 130336, "author": "Darren Kopp", "author_id": 77, "author_profile": "https://Stackoverflow.com/users/77", "pm_score": 7, "selected": true, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx\" rel=\"noreferrer\">HttpCon...
2008/09/24
[ "https://Stackoverflow.com/questions/130328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
How do I get the caller's IP address in a WebMethod? ``` [WebMethod] public void Foo() { // HttpRequest... ? - Not giving me any options through intellisense... } ``` using C# and ASP.NET
[HttpContext.Current.Request.UserHostAddress](http://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress.aspx) is what you want.