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 |
|---|---|---|---|---|---|---|
251,155 | <p>I am developing an iPhone application that persists data to a SQLite3 database. </p>
<p>For each row I persist I wish to include a 'created date' and a 'last modified date'</p>
<p>My question is what is the recommend approach for storing this information in a table? </p>
<p>The properties are represented as NSDat... | [
{
"answer_id": 251194,
"author": "Stephen Darlington",
"author_id": 2998,
"author_profile": "https://Stackoverflow.com/users/2998",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.sqlite.org/datatype3.html\" rel=\"nofollow noreferrer\">According to the docs</a> there's... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3596/"
] | I am developing an iPhone application that persists data to a SQLite3 database.
For each row I persist I wish to include a 'created date' and a 'last modified date'
My question is what is the recommend approach for storing this information in a table?
The properties are represented as NSDate in my application but ... | I typically use a double, something like:
```
sqlite3_bind_double(statement, index, [dateObject timeIntervalSince1970]);
```
where dateObject is an NSDate\*. Then, when getting the data out of the DB, use
```
[NSDate dateWithTimeIntervalSince1970:doubleValueFromDatabase];
``` |
251,181 | <p>I have a DTS package that drops a table then creates it and populates it but sometimes something happens and the package fails after the drop table. If it's rerun it fails cuz the table hasn't been created yet. </p>
<p>Is there something like "if exists" for SQLServer 2000 like in MySQL?</p>
<p>thanks.</p>
| [
{
"answer_id": 251190,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 3,
"selected": false,
"text": "<pre><code>IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TableName]') AND type in (N'U'))... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I have a DTS package that drops a table then creates it and populates it but sometimes something happens and the package fails after the drop table. If it's rerun it fails cuz the table hasn't been created yet.
Is there something like "if exists" for SQLServer 2000 like in MySQL?
thanks. | Or quicker:
```
IF OBJECT_ID('temp_ARCHIVE_RECORD_COUNTS') IS NOT NULL
DROP TABLE temp_ARCHIVE_RECORD_COUNTS
```
* [OBJECT\_ID - MSDN Reference - SQL Server 2000](http://msdn.microsoft.com/en-us/library/aa276843%28v=sql.80%29.aspx)
* [OBJECT\_ID - MSDN Reference - SQL Server 2008](http://msdn.microsoft.com/en-... |
251,198 | <p>I am developing a C# program, and i have one function that consumes too much CPU. I would like to know a way to control this by code (not with any external application) and restrict the percentage of CPU usage.
For example, if it uses 90% of the CPU usage, to make my app consume only a 20%, even if it becomes slowe... | [
{
"answer_id": 251220,
"author": "dpurrington",
"author_id": 5573,
"author_profile": "https://Stackoverflow.com/users/5573",
"pm_score": 5,
"selected": true,
"text": "<p>I don't know if you can do that, but you can change the thread priority of the executing thread via the <a href=\"http... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31791/"
] | I am developing a C# program, and i have one function that consumes too much CPU. I would like to know a way to control this by code (not with any external application) and restrict the percentage of CPU usage.
For example, if it uses 90% of the CPU usage, to make my app consume only a 20%, even if it becomes slower. ... | I don't know if you can do that, but you can change the thread priority of the executing thread via the [Priority](http://msdn.microsoft.com/en-us/library/system.threading.thread.priority.aspx) property. You would set that by:
```
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
```
Also, I don't think you rea... |
251,204 | <p>I want to fade out an element and all its child elements after a delay of a few seconds. but I haven't found a way to specify that an effect should start after a specified time delay.</p>
| [
{
"answer_id": 251214,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 7,
"selected": true,
"text": "<pre><code>setTimeout(function() { $('#foo').fadeOut(); }, 5000);\n</code></pre>\n\n<p>The 5000 is five seconds in millisecon... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I want to fade out an element and all its child elements after a delay of a few seconds. but I haven't found a way to specify that an effect should start after a specified time delay. | ```
setTimeout(function() { $('#foo').fadeOut(); }, 5000);
```
The 5000 is five seconds in milliseconds. |
251,209 | <p>I want to do validation on my business code. I'm thinking of 2 ways to do this.</p>
<p>One, do the validation on my class property setters in the following fashion</p>
<pre><code>class Student{
public string Name{
get { return _name; }
set {
if (value.IsNullOrEmpty) throw exception ... | [
{
"answer_id": 251221,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 1,
"selected": false,
"text": "<p>Option two is something that doesn't actually enforce validation, at least not without you manually calling val... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32240/"
] | I want to do validation on my business code. I'm thinking of 2 ways to do this.
One, do the validation on my class property setters in the following fashion
```
class Student{
public string Name{
get { return _name; }
set {
if (value.IsNullOrEmpty) throw exception ...
}
}
... | I perform domain validation in the middle tier with a rules engine, very similar to the one [written about here](http://www.codethinked.com/post/2008/10/12/Thoughts-On-Domain-Validation-Part-1.aspx). A friend's project uses an approach similar to what you're proposing in your latter example and the end result is unmain... |
251,218 | <p>I'm using Wise Package Studio 7.0 SP2 on Windows XP.</p>
<p>I've got an MSI Wrapped EXE installation that goes about happily installing some files and then running one of the files from the installation which we can refer to as app.exe.</p>
<p>So on the "Execute Deferred" tab of the MSI Editor, I had to add the li... | [
{
"answer_id": 252627,
"author": "Froosh",
"author_id": 26000,
"author_profile": "https://Stackoverflow.com/users/26000",
"pm_score": 0,
"selected": false,
"text": "<p>You can insert VBscript elements into the MSI as custom actions. Something like this should do the job:</p>\n\n<pre><co... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26853/"
] | I'm using Wise Package Studio 7.0 SP2 on Windows XP.
I've got an MSI Wrapped EXE installation that goes about happily installing some files and then running one of the files from the installation which we can refer to as app.exe.
So on the "Execute Deferred" tab of the MSI Editor, I had to add the lines:
```
If Not ... | 6 months ago we were using VBScript actions to do the same thing, then right around the time that SP3 was released the objProcess.Terminate() function just refused to work on some machines. No matter what we did, it just froze. This happened on around 10% of our test machines so we were forced to find an alternative so... |
251,225 | <p>We have a large application in Ruby on Rails with many filters. Some of these filters can be complex. I am looking for a way to individually test these filters with a unit test. Right now I test them by testing them through an action that uses them with a functional test. This just doesn't feel like the right wa... | [
{
"answer_id": 251263,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on what your filters are doing.</p>\n\n<p>This: <a href=\"http://movesonrails.com/journal/2008/1/23/testing-you... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5935/"
] | We have a large application in Ruby on Rails with many filters. Some of these filters can be complex. I am looking for a way to individually test these filters with a unit test. Right now I test them by testing them through an action that uses them with a functional test. This just doesn't feel like the right way.
D... | Remember a filter is just a method.
Given this:
```
class SomeController
before_filter :ensure_awesomeness
...
end
```
There's no reason you can't just do this:
```
SomeController.new.ensure_awesomeness
```
and then check that it calls redirect\_to or whatever it's supposed to do |
251,246 | <p>Ok I have an <code>apache IBM HTTP Server WAS 6.1</code> setup </p>
<p>I have my <code>certs</code> correctly installed and can successfully load <code>http</code> and <code>https</code> pages.</p>
<p>After a successful <code>j_security_check</code> authentication via <code>https</code>, I want the now authorized ... | [
{
"answer_id": 251871,
"author": "Maglob",
"author_id": 27520,
"author_profile": "https://Stackoverflow.com/users/27520",
"pm_score": -1,
"selected": false,
"text": "<p>Wild guess: should the second logical OR be an AND (i.e. no [OR] and the RewriteCond defaults to AND)?</p>\n\n<pre><cod... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30807/"
] | Ok I have an `apache IBM HTTP Server WAS 6.1` setup
I have my `certs` correctly installed and can successfully load `http` and `https` pages.
After a successful `j_security_check` authentication via `https`, I want the now authorized page (and all subsequent pages) to load as `http`.
I want this all to work with `m... | This is the solution for http to https to http
You have to put the condition and the rewrite rule in the virtual host like the arcticle said but for some reason inheritance didn't want to work.
```
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /path/login\.jsp\ HTTP/1\.1
RewriteRu... |
251,248 | <p>I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route.</p>
<p>Apologies to everybody that answered in C# for not specifying it's C++. :-)</p>
| [
{
"answer_id": 251251,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.codeproject.com/KB/cs/processownersid.aspx\" rel=\"nofollow noreferrer\">CodeProject</a> has... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17028/"
] | I am looking for an easy way to get the SID for the current Windows user account. I know I can do it through WMI, but I don't want to go that route.
Apologies to everybody that answered in C# for not specifying it's C++. :-) | In Win32, call [GetTokenInformation](http://msdn.microsoft.com/en-us/library/aa446671.aspx), passing a token handle and the `TokenUser` constant. It will fill in a [TOKEN\_USER](http://msdn.microsoft.com/en-us/library/aa379634.aspx) structure for you. One of the elements in there is the user's SID. It's a BLOB (binary)... |
251,271 | <p>Sometimes you need to upgrade the database with many rows that you have in a datatable or you have an array full of data, instead of putting all this data together in a string and then splitting in SQL SERVER, or instead of iterating the datatable in the code row by row and updating database, is there any other way?... | [
{
"answer_id": 251285,
"author": "John",
"author_id": 30006,
"author_profile": "https://Stackoverflow.com/users/30006",
"pm_score": 3,
"selected": true,
"text": "<p>There's a few ways to do this.</p>\n\n<p>If you're simply inserting rows, then I would create a DataTable object with the i... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31791/"
] | Sometimes you need to upgrade the database with many rows that you have in a datatable or you have an array full of data, instead of putting all this data together in a string and then splitting in SQL SERVER, or instead of iterating the datatable in the code row by row and updating database, is there any other way? Is... | There's a few ways to do this.
If you're simply inserting rows, then I would create a DataTable object with the information in it, then use the SqlBulkCopy object:
```
SqlBulkCopy copier = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.Default);
copier.BatchSize = 500; //# of rows to insert at a time
copier.Des... |
251,275 | <p>I have a User object that has a Country object on it. I map this with a many-to-one tag in the User mapping file:</p>
<pre><code><many-to-one name="Country" column="CountryID" cascade="none"/>
</code></pre>
<p>How do I update a User's country?</p>
<p>At the moment my UI has a dropdown of countries and the I... | [
{
"answer_id": 251324,
"author": "loraderon",
"author_id": 22092,
"author_profile": "https://Stackoverflow.com/users/22092",
"pm_score": 0,
"selected": false,
"text": "<pre><code>var user = session.Get<User>(userID);\nuser.Country = session.Get<Country>(Convert.ToInt32(Reques... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32855/"
] | I have a User object that has a Country object on it. I map this with a many-to-one tag in the User mapping file:
```
<many-to-one name="Country" column="CountryID" cascade="none"/>
```
How do I update a User's country?
At the moment my UI has a dropdown of countries and the ID of the new country is passed to the c... | You should probably take this discussion to the NHibernate users group.
<http://groups.google.com/group/nhusers> |
251,276 | <p>I am writing a searching function, and have thought up of this query using parameters to prevent, or at least limit, SQL injection attacks. However, when I run it through my program it does not return anything:</p>
<p><code>SELECT * FROM compliance_corner WHERE (body LIKE '%@query%') OR (title LIKE '%@query%')</co... | [
{
"answer_id": 251280,
"author": "Will Wagner",
"author_id": 25468,
"author_profile": "https://Stackoverflow.com/users/25468",
"pm_score": 2,
"selected": false,
"text": "<p>You may have to concatenate the % signs with your parameter, e.g.:</p>\n\n<p>LIKE '%' || @query || '%'</p>\n\n<p>Ed... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I am writing a searching function, and have thought up of this query using parameters to prevent, or at least limit, SQL injection attacks. However, when I run it through my program it does not return anything:
`SELECT * FROM compliance_corner WHERE (body LIKE '%@query%') OR (title LIKE '%@query%')`
Can parameters be... | Your visual basic code would look something like this:
```
Dim cmd as New SqlCommand("SELECT * FROM compliance_corner WHERE (body LIKE '%' + @query + '%') OR (title LIKE '%' + @query + '%')")
cmd.Parameters.Add("@query", searchString)
``` |
251,277 | <p>Is there a simple way to sort an iterator in PHP (without just pulling it all into an array and sorting that).</p>
<p>The specific example I have is a <a href="http://www.php.net/directoryiterator" rel="noreferrer">DirectoryIterator</a> but it would be nice to have a solution general to any iterator.</p>
<pre><cod... | [
{
"answer_id": 251320,
"author": "andy.gurin",
"author_id": 22388,
"author_profile": "https://Stackoverflow.com/users/22388",
"pm_score": 4,
"selected": true,
"text": "<p>There is no way to do that. An iterator should \"iterate\" through the list. You have to sort the underlying list to ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24181/"
] | Is there a simple way to sort an iterator in PHP (without just pulling it all into an array and sorting that).
The specific example I have is a [DirectoryIterator](http://www.php.net/directoryiterator) but it would be nice to have a solution general to any iterator.
```
$dir = new DirectoryIterator('.');
foreach ($di... | There is no way to do that. An iterator should "iterate" through the list. You have to sort the underlying list to achieve the needed behavior.
By the way, the more complete reference to the SPL is here:
<http://www.php.net/~helly/php/ext/spl/> |
251,278 | <p>Added: Working with SQL Server 2000 and 2005, so has to work on both. Also, value_rk is not a number/integer (Error: Operand data type uniqueidentifier is invalid for min operator)</p>
<p>Is there a way to do a single column "DISTINCT" match when I don't care about the other columns returned? Example:</p>
<pre><c... | [
{
"answer_id": 251290,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 1,
"selected": false,
"text": "<pre><code>SELECT value, attribute_definition_id, value_rk\nFROM attribute_values\nWHERE value, value_rk IN (\n ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16631/"
] | Added: Working with SQL Server 2000 and 2005, so has to work on both. Also, value\_rk is not a number/integer (Error: Operand data type uniqueidentifier is invalid for min operator)
Is there a way to do a single column "DISTINCT" match when I don't care about the other columns returned? Example:
```
**Table**
Value A... | this might work:
```
SELECT DISTINCT a.value, a.attribute_definition_id,
(SELECT TOP 1 value_rk FROM attribute_values WHERE value = a.value) as value_rk
FROM attribute_values as a
ORDER BY attribute_definition_id
```
.. not tested. |
251,298 | <p>I noticed the specificaition for Collections.sort:</p>
<pre><code>public static <T> void sort(List<T> list, Comparator<? super T> c)
</code></pre>
<p>Why is the "<code>? super</code>" necessary here? If <code>ClassB</code> extends <code>ClassA</code>, then wouldn't we have a guarantee that a <co... | [
{
"answer_id": 251328,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "<p>Josh Bloch had a talk at Google I/O this year, called <a href=\"http://sites.google.com/site/io/effective-java-reloaded\" ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | I noticed the specificaition for Collections.sort:
```
public static <T> void sort(List<T> list, Comparator<? super T> c)
```
Why is the "`? super`" necessary here? If `ClassB` extends `ClassA`, then wouldn't we have a guarantee that a `Comparator<ClassA>` would be able to compare two `ClassB` objects anyway, withou... | Josh Bloch had a talk at Google I/O this year, called [Effective Java Reloaded](http://sites.google.com/site/io/effective-java-reloaded), which you may find interesting. It talks about a mnemonic called "Pecs" (producer `extends`, consumer `super`), which explains why you use `? extends T` and `? super T` in your input... |
251,307 | <p>I have a resource handler that is Response.WriteFile(fileName) based on a parameter passed through the querystring. I am handling the mimetype correctly, but the issue is in some browsers, the filename comes up as Res.ashx (The name of the handler) instead of MyPdf.pdf (the file I am outputting). Can someone inform ... | [
{
"answer_id": 251323,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>This Scott Hanselman post should be helpful:<br>\n<a href=\"http://www.hanselman.com/blog/CommentView.aspx?guid=360... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22521/"
] | I have a resource handler that is Response.WriteFile(fileName) based on a parameter passed through the querystring. I am handling the mimetype correctly, but the issue is in some browsers, the filename comes up as Res.ashx (The name of the handler) instead of MyPdf.pdf (the file I am outputting). Can someone inform me ... | Extending from Joel's comment, your actual code would look something like this:
```
context.Response.AddHeader("content-disposition", "attachment; filename=" + resource);
``` |
251,313 | <p>Suppose you want to make an async request in JavaScript, but you want to pass some state along to the callback method. Is the following an appropriate use of closures in JavaScript?</p>
<pre><code>function getSomethingAsync(someState, callback) {
var req = abc.createRequestObject(someParams);
req.invoke(mak... | [
{
"answer_id": 251347,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 0,
"selected": false,
"text": "<p>its better (nicer) to use anonymous functions:</p>\n\n<pre><code>function getSomethingAsync (someState, callback) {\n ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5309/"
] | Suppose you want to make an async request in JavaScript, but you want to pass some state along to the callback method. Is the following an appropriate use of closures in JavaScript?
```
function getSomethingAsync(someState, callback) {
var req = abc.createRequestObject(someParams);
req.invoke(makeCallback(some... | I don't see any immediate problems with this - closures are powerful for numerous reasons, one of which is removing the need to use global variables for state maintenance.
That said, the only thing you need to be wary of with regards to closures is memory leaks that typically occur in IE, but those are usually, IIRC, ... |
251,317 | <p>When I try to use <code>curl</code> or <code>file_get_contents</code> to read something like <a href="http://example.com/python/json/" rel="nofollow noreferrer">http://example.com/python/json/</a> from <a href="http://example.com/" rel="nofollow noreferrer">http://example.com/</a> I should be getting a JSON response... | [
{
"answer_id": 251327,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like example.com is not the default domain for the IP address and that file_get_contents uses HTTP/1.0 inst... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21716/"
] | When I try to use `curl` or `file_get_contents` to read something like <http://example.com/python/json/> from <http://example.com/> I should be getting a JSON response, but instead I get a 404 error. Using curl or any other method outside my own domain works perfectly well.
```
echo file_get_contents('http://example.c... | It looks like example.com is not the default domain for the IP address and that file\_get\_contents uses HTTP/1.0 instead of HTTP/1.1 and/or does not send a Host: header. Try the curl support in PHP instead:
```
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://example.com/');
curl_setopt($curl, CURLOPT_RET... |
251,325 | <p>So let's say I have two different functions. One is a part of the BST class, one is just a helper function that will call on that Class function. I will list them out here.</p>
<pre><code>sieve(BST<T>* t, int n);
</code></pre>
<p>this function is called like this: sieve(t,n) the object is called BST t; <... | [
{
"answer_id": 251335,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "<pre><code>sieve(BST<int>& t, int n)\n</code></pre>\n\n<p>The <code>&</code> specifies passing by <em>reference... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28392/"
] | So let's say I have two different functions. One is a part of the BST class, one is just a helper function that will call on that Class function. I will list them out here.
```
sieve(BST<T>* t, int n);
```
this function is called like this: sieve(t,n) the object is called BST t;
I'm going to be using the class rem... | ```
sieve(BST<int>& t, int n)
```
The `&` specifies passing by *reference* rather than value. :-) |
251,336 | <p>How do I discover classes at runtime in the classpath which implements a defined interface?</p>
<p>ServiceLoader suits well (I think, I haven't used it), but I need do it in Java 1.5.</p>
| [
{
"answer_id": 251670,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 0,
"selected": false,
"text": "<p>There is no reliable way to know what classes are in the classpath. According to its <a href=\"http://java.sun.co... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518/"
] | How do I discover classes at runtime in the classpath which implements a defined interface?
ServiceLoader suits well (I think, I haven't used it), but I need do it in Java 1.5. | There's nothing built into Java 1.5 for this. I implemented it myself; it's not too complicated. However, when we upgrade to Java 6, I will have to replace calls to my implementation with calls to `ServiceLoader`. I could have defined a little bridge between the app and the loader, but I only use it in a few places, an... |
251,338 | <p>I want to get the size of a drive (or UNC path pointing to a partition would be nice, but not required), as well as free space for said drive (or UNC path). This doesn't need to work cross platform; only in Windows.</p>
<p>I know it's easy to do in Java 6, but that's not an option; I'm stuck with Java 5.</p>
<p>I... | [
{
"answer_id": 251447,
"author": "DMKing",
"author_id": 10887,
"author_profile": "https://Stackoverflow.com/users/10887",
"pm_score": 3,
"selected": true,
"text": "<p>One way to do it would be to use fsutil on the command line. It returns something like this:</p>\n\n<pre><code>D:\\>f... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14007/"
] | I want to get the size of a drive (or UNC path pointing to a partition would be nice, but not required), as well as free space for said drive (or UNC path). This doesn't need to work cross platform; only in Windows.
I know it's easy to do in Java 6, but that's not an option; I'm stuck with Java 5.
I can get the free ... | One way to do it would be to use fsutil on the command line. It returns something like this:
```
D:\>fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number : 0xd49cf9cf9cf9ac5c
Version : 3.1
Number Sectors : 0x0000000004a813ff
Total Clusters : 0x000000000095... |
251,345 | <p>Really simple question - how do I do a search to find all records where the name starts with a certain string in ActiveRecord. I've seen all sorts of bits all over the internet where verbatim LIKE SQL clauses are used - but from what I've heard that isn't the 'correct' way of doing it.</p>
<p>Is there a 'proper' Ra... | [
{
"answer_id": 251518,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 7,
"selected": false,
"text": "<p>If you're looking to do the search in the database then you'll need to use SQL.</p>\n\n<p>And, of course, you'll need to... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] | Really simple question - how do I do a search to find all records where the name starts with a certain string in ActiveRecord. I've seen all sorts of bits all over the internet where verbatim LIKE SQL clauses are used - but from what I've heard that isn't the 'correct' way of doing it.
Is there a 'proper' Rails way? | I would highly recommend the [Searchlogic](http://rdoc.info/projects/binarylogic/searchlogic) plugin.
Then it's as easy as:
```
@search = Model.new_search(params[:search])
@search.condition.field_starts_with = "prefix"
@models = @search.all
```
Searchlogic is smart enough, like ActiveRecord, to pick up on the field... |
251,351 | <p>Is there a way of ordering a list of objects by a count of a property which is a collection? </p>
<p>For arguments sake let's say I have a question object with a question name property, a property that is a collection of answer objects and another property that is a collection of user objects. The users join the qu... | [
{
"answer_id": 251361,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 3,
"selected": false,
"text": "<p>There is no one single optimum hashing algorithm. If you have a known input domain you can use a per... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32835/"
] | Is there a way of ordering a list of objects by a count of a property which is a collection?
For arguments sake let's say I have a question object with a question name property, a property that is a collection of answer objects and another property that is a collection of user objects. The users join the question tab... | Forget about the term "best". No matter which hash algorithm anyone might come up with, unless you have a very limited set of data that needs to be hashed, every algorithm that performs very well on average can become completely useless if only being fed with the right (or from your perspective "wrong") data.
Instead ... |
251,379 | <p>I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this:</p>
<p>What is the benefit to use databinding from sql queries directly to a control over querying and manua... | [
{
"answer_id": 251452,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 4,
"selected": true,
"text": "<p>I personally find that using the </p>\n\n<pre><code>control.DataSource = YourSource;\ncontrol.DataBind();\n</cod... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8945/"
] | I've been a C# programmer for about 2 years total, and professionally for a little more than 1. I work at a company as a developer on an application that began before the days of .NET 2. My question is this:
What is the benefit to use databinding from sql queries directly to a control over querying and manually adding... | I personally find that using the
```
control.DataSource = YourSource;
control.DataBind();
```
process is much easier, you don't have to do the iteration, and overall reduces LOC.
If working with DropDownLists and other controls you will most likely set the DataValueField and DataTextField properties as well. |
251,389 | <p>How do you display a Silverlight 2.0 application in a Vista Sidebar gadget? Whenever I load a gadget with the standard Silverlight 2 object tag, I get the no-silverlight default content instead of the app. So, what's the trick to allowing it to run?</p>
<p>This is how I am currently trying to pull it off:</p>
<p... | [
{
"answer_id": 253910,
"author": "Gordon Mackie JoanMiro",
"author_id": 15778,
"author_profile": "https://Stackoverflow.com/users/15778",
"pm_score": 4,
"selected": true,
"text": "<p>It seems with the release version of Silverlight 2 the source parameter changed and has to be a URI - see... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/93/"
] | How do you display a Silverlight 2.0 application in a Vista Sidebar gadget? Whenever I load a gadget with the standard Silverlight 2 object tag, I get the no-silverlight default content instead of the app. So, what's the trick to allowing it to run?
This is how I am currently trying to pull it off:
```
<html>
<head... | It seems with the release version of Silverlight 2 the source parameter changed and has to be a URI - see this thread from the Silverlight forums: <http://silverlight.net/forums/p/30968/99824.aspx> |
251,391 | <p>The <a href="https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/c5kehkcz(v=vs.110)" rel="noreferrer">MSDN documentation</a> says that</p>
<pre><code>public class SomeObject
{
public void SomeOperation()
{
lock(this)
{
//Access instance variables
}
}
}
</code><... | [
{
"answer_id": 251399,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 6,
"selected": false,
"text": "<p>Because if people can get at your object instance (ie: your <code>this</code>) pointer, then they can also try to loc... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/341413/"
] | The [MSDN documentation](https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/c5kehkcz(v=vs.110)) says that
```
public class SomeObject
{
public void SomeOperation()
{
lock(this)
{
//Access instance variables
}
}
}
```
is "a problem if the instance can be access... | It is bad form to use `this` in lock statements because it is generally out of your control who else might be locking on that object.
In order to properly plan parallel operations, special care should be taken to consider possible deadlock situations, and having an unknown number of lock entry points hinders this. For... |
251,395 | <p>Is there a library out there which I can use in my current ASP.NET app, to validate queryStrings?</p>
<p>Edit ~ Using Regex to look for patterns, like string, only, numeric only, string with length x,...etc</p>
<p>Thanks</p>
| [
{
"answer_id": 251410,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 4,
"selected": true,
"text": "<p>Don't know about a library, but you can use to check if the querystring exists:</p>\n\n<pre><code>if (!String.IsNul... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | Is there a library out there which I can use in my current ASP.NET app, to validate queryStrings?
Edit ~ Using Regex to look for patterns, like string, only, numeric only, string with length x,...etc
Thanks | Don't know about a library, but you can use to check if the querystring exists:
```
if (!String.IsNullOrEmpty(Request.Querystring["foo"]))
{
// check further
}
else
{
// not there, do something else
}
```
If you want to use Reglar Expressions to further validate, you can create a class that accepts the string ... |
251,396 | <p>I am currently developing a Java app which handles a SOAP webservice. </p>
<p>The problem lies after I parse the WSDL [the <strong>Parser</strong> object from Apache Axis does it for me], and I create the call. </p>
<p>When I try to invoke it, I have to pass a Object[] to assign the parameters [taken from the Acti... | [
{
"answer_id": 251443,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 1,
"selected": false,
"text": "<p>Have you looked into using something like Spring's proxy functionality? You tell it a bit about the webservice i... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4749/"
] | I am currently developing a Java app which handles a SOAP webservice.
The problem lies after I parse the WSDL [the **Parser** object from Apache Axis does it for me], and I create the call.
When I try to invoke it, I have to pass a Object[] to assign the parameters [taken from the Action of the WSDL]. A normal acti... | Have you looked into using something like Spring's proxy functionality? You tell it a bit about the webservice in a spring config file, and all your client code has to deal with is an interface that you create - it doesn't even have to know that there is a web service on the other side!
Example Spring config:
```
<be... |
251,401 | <p>Does anyone know of any DLLs (preferably .net) that encapsulate the lua 5.1 compiler? I'm working on a .net project where part of it needs to compile lua scripts, and i would rather have a DLL that i could send script code to instead of sending the script to a temporary file and running luac.exe.</p>
<p>Edit: I'd ... | [
{
"answer_id": 251443,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 1,
"selected": false,
"text": "<p>Have you looked into using something like Spring's proxy functionality? You tell it a bit about the webservice i... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19252/"
] | Does anyone know of any DLLs (preferably .net) that encapsulate the lua 5.1 compiler? I'm working on a .net project where part of it needs to compile lua scripts, and i would rather have a DLL that i could send script code to instead of sending the script to a temporary file and running luac.exe.
Edit: I'd need a .NET... | Have you looked into using something like Spring's proxy functionality? You tell it a bit about the webservice in a spring config file, and all your client code has to deal with is an interface that you create - it doesn't even have to know that there is a web service on the other side!
Example Spring config:
```
<be... |
251,402 | <p>There are <strong>two different</strong> ways to create an empty object in JavaScript:</p>
<pre><code>var objectA = {}
var objectB = new Object()
</code></pre>
<p>Is there any difference in how the script engine handles them? Is there any reason to use one over the other?</p>
<p>Similarly it is also possible to c... | [
{
"answer_id": 251405,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "<p>This is essentially the same thing. Use whatever you find more convenient.</p>\n"
},
{
"answer_id": 251440,
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1918/"
] | There are **two different** ways to create an empty object in JavaScript:
```
var objectA = {}
var objectB = new Object()
```
Is there any difference in how the script engine handles them? Is there any reason to use one over the other?
Similarly it is also possible to create an empty array using different syntax:
... | Objects
-------
There is no benefit to using `new Object();` - whereas `{};` can make your code more compact, and more readable.
For defining empty objects they're technically the same. The `{}` syntax is shorter, neater (less Java-ish), and allows you to instantly populate the object inline - like so:
```
var myObj... |
251,403 | <p>I want to have a map that has a homogeneous key type but heterogeneous data types.</p>
<p>I want to be able to do something like (pseudo-code):</p>
<pre><code>boost::map<std::string, magic_goes_here> m;
m.add<int>("a", 2);
m.add<std::string>("b", "black sheep");
int i = m.get<int>("a");
in... | [
{
"answer_id": 251423,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.parashift.com/c++-faq/heterogeneous-list.html\" rel=\"noreferrer\">How can I build a <fav... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32794/"
] | I want to have a map that has a homogeneous key type but heterogeneous data types.
I want to be able to do something like (pseudo-code):
```
boost::map<std::string, magic_goes_here> m;
m.add<int>("a", 2);
m.add<std::string>("b", "black sheep");
int i = m.get<int>("a");
int j = m.get<int>("b"); // error!
```
I coul... | ```
#include <map>
#include <string>
#include <iostream>
#include <boost/any.hpp>
int main()
{
try
{
std::map<std::string, boost::any> m;
m["a"] = 2;
m["b"] = static_cast<char const *>("black sheep");
int i = boost::any_cast<int>(m["a"]);
std::cout << "I(" << i << ")\... |
251,409 | <p>In MS SQL 2005 or T-SQL, you can do something like:</p>
<pre><code>SELECT T.NAME, T.DATE
FROM (SELECT * FROM MyTable WHERE ....) AS T
</code></pre>
<p>I failed to try the similar SQL on Oracle 9i DB. In MS SQL, the nested SQL is treated as a temporary/dynamic view created on fly and destroyed afterward. How can... | [
{
"answer_id": 251414,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<p>I believe it chokes on the \"as\".</p>\n\n<pre><code>SELECT T.NAME, T.DATE \n FROM (SELECT * FROM MyTable WHERE .... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62776/"
] | In MS SQL 2005 or T-SQL, you can do something like:
```
SELECT T.NAME, T.DATE
FROM (SELECT * FROM MyTable WHERE ....) AS T
```
I failed to try the similar SQL on Oracle 9i DB. In MS SQL, the nested SQL is treated as a temporary/dynamic view created on fly and destroyed afterward. How can I do the similar thing in... | I believe it chokes on the "as".
```
SELECT T.NAME, T.DATE
FROM (SELECT * FROM MyTable WHERE ....) T
```
should work. |
251,420 | <p>Basically, I have an <code>iframe</code> embedded in a page and the <code>iframe</code> has some <a href="http://en.wikipedia.org/wiki/JavaScript" rel="noreferrer">JavaScript</a> routines I need to invoke from the parent page.</p>
<p>Now the opposite is quite simple as you only need to call <code>parent.functionNam... | [
{
"answer_id": 251437,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 3,
"selected": false,
"text": "<p>Quirksmode had a <a href=\"http://web.archive.org/web/20080225210716/http://www.quirksmode.org/js/iframe.html\" rel... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8954/"
] | Basically, I have an `iframe` embedded in a page and the `iframe` has some [JavaScript](http://en.wikipedia.org/wiki/JavaScript) routines I need to invoke from the parent page.
Now the opposite is quite simple as you only need to call `parent.functionName()`, but unfortunately, I need exactly the opposite of that.
Pl... | Assume your iFrame's id is "targetFrame" and the function you want to call is `targetFunction()`:
```
document.getElementById('targetFrame').contentWindow.targetFunction();
```
You can also access the frame using `window.frames` instead of `document.getElementById`.
```
// this option does not work in most of lates... |
251,432 | <p>Is it possible to <code>typedef</code> long types that use templates? For example:</p>
<pre><code>template <typename myfloat_t>
class LongClassName
{
// ...
};
template <typename myfloat_t>
typedef std::vector< boost::shared_ptr< LongClassName<myfloat_t> > > LongCollection;
Long... | [
{
"answer_id": 251446,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 5,
"selected": true,
"text": "<p>No, that isn't possible currently. It will be made possible in C++0X AFAIK.</p>\n\n<p>The best I can think of is <... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32515/"
] | Is it possible to `typedef` long types that use templates? For example:
```
template <typename myfloat_t>
class LongClassName
{
// ...
};
template <typename myfloat_t>
typedef std::vector< boost::shared_ptr< LongClassName<myfloat_t> > > LongCollection;
LongCollection<float> m_foo;
```
This doesn't work, but is... | No, that isn't possible currently. It will be made possible in C++0X AFAIK.
The best I can think of is
```
template<typename T> struct LongCollection {
typedef std::vector< boost::shared_ptr< LongClassName<T> > > type;
};
LongCollection<float>::type m_foo;
``` |
251,433 | <p>Looking up LINQ and Or in google is proving somewhat difficult so here I am.</p>
<p>I want to so the following:</p>
<pre><code>(from creditCard in AvailableCreditCards
where creditCard.BillToName.ToLowerInvariant().Contains(txtFilter.Text.ToLowerInvariant())
**or creditCard.CardNumber.().Contains(txtFilter.Text)*... | [
{
"answer_id": 251449,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the .Where() function to accomplish this.</p>\n\n<pre><code>var cards = AvailableCreditCards.Where(ca... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32772/"
] | Looking up LINQ and Or in google is proving somewhat difficult so here I am.
I want to so the following:
```
(from creditCard in AvailableCreditCards
where creditCard.BillToName.ToLowerInvariant().Contains(txtFilter.Text.ToLowerInvariant())
**or creditCard.CardNumber.().Contains(txtFilter.Text)**
orderby creditCard.... | C# keywords supporting LINQ are still C#. Consider `where` as a conditional like `if`; you perform logical operations in the same way. In this case, a logical-OR, you use `||`
```
(from creditCard in AvailableCreditCards
where creditCard.BillToName.ToLowerInvariant().Contains(
txtFilter.Text.ToLowerInva... |
251,439 | <p>I want to pass an int list (List) as a declarative property to a web user control like this:</p>
<pre><code><UC:MyControl runat="server" ModuleIds="1,2,3" />
</code></pre>
<p>I created a TypeConverter to do this:</p>
<pre><code>public class IntListConverter : System.ComponentModel.TypeConverter
{
public... | [
{
"answer_id": 251600,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 0,
"selected": false,
"text": "<p>pass the list from the code behind...</p>\n\n<p>aspx:</p>\n\n<pre><code><UC:MyControl id=\"uc\" runat=\"server\... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10475/"
] | I want to pass an int list (List) as a declarative property to a web user control like this:
```
<UC:MyControl runat="server" ModuleIds="1,2,3" />
```
I created a TypeConverter to do this:
```
public class IntListConverter : System.ComponentModel.TypeConverter
{
public override bool CanConvertFrom(
S... | After hooking a debugger into Cassini, I see that the null ref is actually coming from System.Web.Compilation.CodeDomUtility.GenerateExpressionForValue, which is basically trying to get an expression for the int[] array you pass into the List constructor. Since there's no type descriptor for the int[] array, it fails (... |
251,444 | <p>I have a command line Ruby app I'm developing and I want to allow a user of it to provide code that will run as a filter on part of the process. Basically, the application does this:</p>
<ol>
<li>read in some data</li>
<li>If a filter is specified, use it to filter data</li>
<li>process the data</li>
</ol>
<p>I w... | [
{
"answer_id": 251511,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<p>Looks like a job for a <a href=\"http://en.wikipedia.org/wiki/Strategy_pattern\" rel=\"nofollow noreferrer\">Strategy Patter... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3029/"
] | I have a command line Ruby app I'm developing and I want to allow a user of it to provide code that will run as a filter on part of the process. Basically, the application does this:
1. read in some data
2. If a filter is specified, use it to filter data
3. process the data
I want the filtering process (step 2) to be... | I'd just use a combination of the command line, and convention.
>
> If a filter is specified, use it to filter data
>
>
>
I'm assuming you'd specify a filter on the command line? So you'd invoke the application like this?
```
ruby dataprocessor.rb custom_filter
```
If so, you could define an "api" wherein a cl... |
251,464 | <p>How do I get a function's name as a string?</p>
<pre><code>def foo():
pass
>>> name_of(foo)
"foo"
</code></pre>
| [
{
"answer_id": 251469,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 6,
"selected": false,
"text": "<pre><code>my_function.func_name\n</code></pre>\n\n<p>There are also other fun properties of functions. Type <code... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11452/"
] | How do I get a function's name as a string?
```
def foo():
pass
>>> name_of(foo)
"foo"
``` | ```
my_function.__name__
```
Using `__name__` is the preferred method as it applies uniformly. Unlike `func_name`, it works on built-in functions as well:
```
>>> import time
>>> time.time.func_name
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'builtin_function_or_method' object ... |
251,466 | <p>An easy jQuery question.</p>
<p>I have several identical forms ( except their name ) on one page with a few hidden inputs in each. I want to refer to them by using the form name and then the input name. ( the input names are not unique in my page )</p>
<p>So for instance: </p>
<pre><code>var xAmt = $('#xForm'+nu... | [
{
"answer_id": 251520,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like you want <code>formSerialize()</code> (or even <code>ajaxSubmit()</code>) from the <a href=\"http://docs.jqu... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | An easy jQuery question.
I have several identical forms ( except their name ) on one page with a few hidden inputs in each. I want to refer to them by using the form name and then the input name. ( the input names are not unique in my page )
So for instance:
```
var xAmt = $('#xForm'+num).('#xAmt');
```
I really ... | ```
function queryX( args ) {
var queryString = [ "XID=", args.XID, "&xNumber=", args.xNumber, "&xAmt=", args.xAmt ].join("");
$.ajax({
url: "X.asp",
cache: false,
type: "POST",
data: queryString,
success : function( data ) {
return data;
}
});
}... |
251,467 | <p>I have a directory of bitmaps that are all of the same dimension. I would like to convert these bitmaps into a video file. I don't care if the video file (codec) is wmv or avi. My only requirement is that I specify the frame rate. This does not need to be cross platform, Windows (Vista and XP) only. I have read... | [
{
"answer_id": 251685,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the AVI* from avifil32 library, there is an example here (not tried):<br>\n<a href=\"http://www.adp-gmbh.ch/... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10333/"
] | I have a directory of bitmaps that are all of the same dimension. I would like to convert these bitmaps into a video file. I don't care if the video file (codec) is wmv or avi. My only requirement is that I specify the frame rate. This does not need to be cross platform, Windows (Vista and XP) only. I have read a few t... | At the risk of being voted down, I'll offer a possible alternative option-- a buffered Bitmap animation.
```
double framesPerSecond;
Bitmap[] imagesToDisplay; // add the desired bitmaps to this array
Timer playbackTimer;
int currentImageIndex;
PictureBox displayArea;
(...)
currentImageIndex = 0;
playbackTimer.I... |
251,479 | <p>I acquired a database from another developer. He didn't use auto_incrementers on any tables. They all have primary key ID's, but he did all the incrementing manually, in code.</p>
<p>Can I turn those into Auto_incrementers now?</p>
<hr>
<p>Wow, very nice, thanks a ton. It worked without a hitch on one of my tab... | [
{
"answer_id": 251526,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": -1,
"selected": false,
"text": "<p>As long as you have unique integers (or some unique value) in the current PK, you could create a new table, and insert in... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] | I acquired a database from another developer. He didn't use auto\_incrementers on any tables. They all have primary key ID's, but he did all the incrementing manually, in code.
Can I turn those into Auto\_incrementers now?
---
Wow, very nice, thanks a ton. It worked without a hitch on one of my tables. But a second ... | For example, here's a table that has a primary key but is not `AUTO_INCREMENT`:
```
mysql> CREATE TABLE foo (
id INT NOT NULL,
PRIMARY KEY (id)
);
mysql> INSERT INTO foo VALUES (1), (2), (5);
```
You can `MODIFY` the column to redefine it with the `AUTO_INCREMENT` option:
```
mysql> ALTER TABLE foo MODIFY COLUM... |
251,482 | <p>I would like to be able to cast a value dynamically where the type is known only at runtime. Something like this:</p>
<pre><code>myvalue = CType(value, "String, Integer or Boolean")
</code></pre>
<p>The string that contains the type value is passed as an argument and is also read from a database, and the value is ... | [
{
"answer_id": 251508,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "<p>Sure, but <code>myvalue</code> will have to be defined as of type <code>Object</code>, and you don't necessarily wan... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10968/"
] | I would like to be able to cast a value dynamically where the type is known only at runtime. Something like this:
```
myvalue = CType(value, "String, Integer or Boolean")
```
The string that contains the type value is passed as an argument and is also read from a database, and the value is stored as string in the da... | Sure, but `myvalue` will have to be defined as of type `Object`, and you don't necessarily want that. Perhaps this is a case better served by generics.
What determines what type will be used? |
251,485 | <p>Is there a way to dynamically invoke a method in the same class for PHP? I don't have the syntax right, but I'm looking to do something similar to this:</p>
<pre><code>$this->{$methodName}($arg1, $arg2, $arg3);
</code></pre>
| [
{
"answer_id": 251499,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "<p>Just omit the braces:</p>\n\n<pre><code>$this->$methodName($arg1, $arg2, $arg3);\n</code></pre>\n"
},
{
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] | Is there a way to dynamically invoke a method in the same class for PHP? I don't have the syntax right, but I'm looking to do something similar to this:
```
$this->{$methodName}($arg1, $arg2, $arg3);
``` | There is more than one way to do that:
```
$this->{$methodName}($arg1, $arg2, $arg3);
$this->$methodName($arg1, $arg2, $arg3);
call_user_func_array(array($this, $methodName), array($arg1, $arg2, $arg3));
```
You may even use the reflection api <http://php.net/manual/en/class.reflection.php> |
251,532 | <p>If I have a URL (eg. <a href="http://www.foo.com/alink.pl?page=2" rel="noreferrer">http://www.foo.com/alink.pl?page=2</a>), I want to determine if I am being redirected to another link. I'd also like to know the final URL (eg. <a href="http://www.foo.com/other_link.pl" rel="noreferrer">http://www.foo.com/other_link... | [
{
"answer_id": 251544,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<p>Well, I know nothing about either Perl or groovy, so I'll give you an another from an HTTP point of view, and you'... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I have a URL (eg. <http://www.foo.com/alink.pl?page=2>), I want to determine if I am being redirected to another link. I'd also like to know the final URL (eg. <http://www.foo.com/other_link.pl>). Finally, I want to be able to do this in Perl and Groovy. | In Perl:
```
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new( GET => 'http://google.com/' );
my $response = $ua->request($request);
if ( $response->is_success and $response->previous ) {
print $request->url, ' redirected to ', $response->request->uri, "\n";
}
``` |
251,535 | <p>One of our customers wants to be able to enter a date with only 2 digits for the year component. The date will be in the past, so we want it to work for the previous century if the 2 digit year is after the current year, but work for the current century if the 2 digit year is equal to or less than the current year.<... | [
{
"answer_id": 251570,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 3,
"selected": false,
"text": "<p>How about this:</p>\n\n<pre><code>public static String anEasierStupidDateWithNoStringParsing(String dateString) {\n Dat... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] | One of our customers wants to be able to enter a date with only 2 digits for the year component. The date will be in the past, so we want it to work for the previous century if the 2 digit year is after the current year, but work for the current century if the 2 digit year is equal to or less than the current year.
as... | Groovy script (easy enough to throw into java) demonstrating the point @bobince made about SimpleDateFormat.
```
import java.text.SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat('MM/dd/yy')
SimpleDateFormat fmt = new SimpleDateFormat('yyyy-MM-dd')
Calendar cal = Calendar.getInstance()
cal.add(Calendar.Y... |
251,541 | <pre><code>public void Getrecords(ref IList iList,T dataItem)
{
iList = Populate.GetList<dataItem>() // GetListis defined as GetList<T>
}
</code></pre>
<p>dataItem can be my order object or user object which will be decided at run time.The above does not work as it gives me this error
The type 'T' must... | [
{
"answer_id": 251550,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": -1,
"selected": false,
"text": "<p>You can use Generic with < T > that will accept the type in runtime like you want.</p>\n"
},
{
... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
public void Getrecords(ref IList iList,T dataItem)
{
iList = Populate.GetList<dataItem>() // GetListis defined as GetList<T>
}
```
dataItem can be my order object or user object which will be decided at run time.The above does not work as it gives me this error
The type 'T' must have a public parameterless co... | ```
public void GetRecords<T>(ref IList<T> iList, T dataitem)
{
}
```
What more are you looking for?
**To Revised question:**
```
iList = Populate.GetList<dataItem>()
```
"dataitem" is a variable. You want to specify a type there:
```
iList = Populate.GetList<T>()
```
>
> The type 'T' must have a public
>... |
251,554 | <p>Attempting to deploy a MOSS solution to a UAT server from dev server <em>for the first time</em>. On executing this command </p>
<pre><code>stsadm -o addsolution -filename xxx
</code></pre>
<p>I get a "Object reference not set to an instance of an object"
Based on these links: (and others):</p>
<p>[<a href="http:... | [
{
"answer_id": 251713,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": -1,
"selected": false,
"text": "<p>The issue seems to not be with your solution, but with the SSP. Try deleting the UAT SSP and re-creating it and associate ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10552/"
] | Attempting to deploy a MOSS solution to a UAT server from dev server *for the first time*. On executing this command
```
stsadm -o addsolution -filename xxx
```
I get a "Object reference not set to an instance of an object"
Based on these links: (and others):
[<http://social.msdn.microsoft.com/forums/en-US/sharepo... | I think the obvious thing you are missing is that the user account doesn't have the required permission to use the sharepoint database - just as it says in your post ;) |
251,557 | <p>I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:<br>
<code>echo some string < with angle > brackets >>myfile.txt</code></p>
<p>This doesn't work since the command interpreter gets confused with the angle bracket... | [
{
"answer_id": 251573,
"author": "Tim Robinson",
"author_id": 32133,
"author_profile": "https://Stackoverflow.com/users/32133",
"pm_score": 9,
"selected": true,
"text": "<p>The Windows escape character is ^, for some reason.</p>\n\n<pre><code>echo some string ^< with angle ^> brack... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26302/"
] | I need to echo a string containing angle brackets (< and >) to a file on a Windows machine. Basically what I want to do is the following:
`echo some string < with angle > brackets >>myfile.txt`
This doesn't work since the command interpreter gets confused with the angle brackets. I could quote the whole string like... | The Windows escape character is ^, for some reason.
```
echo some string ^< with angle ^> brackets >>myfile.txt
``` |
251,560 | <p>Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't.</p>
<p>Can someone provide a quick code sample, link, or nudge in the right direction... | [
{
"answer_id": 251581,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 0,
"selected": false,
"text": "<p>Query the table for the field you expect and handle the error if the field is not there.</p>\n\n<p>T... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27414/"
] | Our app (already deployed) is using an Access/Jet database. The upcoming version of our software requires some additional columns in one of the tables. I need to first check if these columns exist, and then add them if they don't.
Can someone provide a quick code sample, link, or nudge in the right direction?
(I'm us... | Off the top of my head, but something like:
```
Dim conn as New AdoConnection(someConnStr)
Dim cmd as New AdoCommand
cmd.Connection = conn
cmd.CommandText = "ALTER TABLE X ADD COLUMN y COLUMNTYPE"
cmd.ComandType = CommandType.Text
cmd.ExecuteNonQuery()
``` |
251,592 | <p>PHP (among others) will execute the deepest function first, working its way out. For example,</p>
<pre><code>$text = strtoupper(str_replace('_', ' ', file_get_contents('file.txt')));
</code></pre>
<p>I'm doing something very similar to the above example for a template parser. It looks for the tags</p>
<pre><code>... | [
{
"answer_id": 251606,
"author": "Henrik Paul",
"author_id": 2238,
"author_profile": "https://Stackoverflow.com/users/2238",
"pm_score": 1,
"selected": false,
"text": "<p>This is not a trivial task. You need to parse the string manually and do your own logical substitutions. There's no m... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32881/"
] | PHP (among others) will execute the deepest function first, working its way out. For example,
```
$text = strtoupper(str_replace('_', ' ', file_get_contents('file.txt')));
```
I'm doing something very similar to the above example for a template parser. It looks for the tags
```
{@tag_name}
```
and replaces it wit... | I'm not sure I understand the nesting in your example, as the example doesn't demonstrate a purpose behind nesting. Your example input could very easily be
```
'This is my test {@a} {@b} string.'
```
And using arrays in str\_replace would handle this very simply and quickly.
```
$aVars = array('{@a}' => 'hello', '{... |
251,636 | <p>ExtJS has Ext.each() function, but is there a map() also hidden somewhere?</p>
<p>I have tried hard, but haven't found anything that could fill this role. It seems to be something simple and trivial, that a JS library so large as Ext clearly must have.</p>
<p>Or when Ext really doesn't include it, what would be th... | [
{
"answer_id": 251689,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "<p>Since <code>map</code> is more of a utility than anything, I don't see why there would be any special way of pluggi... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15982/"
] | ExtJS has Ext.each() function, but is there a map() also hidden somewhere?
I have tried hard, but haven't found anything that could fill this role. It seems to be something simple and trivial, that a JS library so large as Ext clearly must have.
Or when Ext really doesn't include it, what would be the best way to add... | It appears, that my colleges here are using [ext-basex](http://code.google.com/p/ext-basex/), which extends Array.prototype with map() and other methods.
So I can just write:
```
[1, 2, 3].map( function(){ ... } );
```
Problem solved. |
251,651 | <p>I have a table of about a million rows and I need to update every row in the table with the result of a lengthy calculation (the calculation gets a potentially different result for each row). Because it is time consuming, the DBA must be able to control execution. This particular calculation needs to be run once a y... | [
{
"answer_id": 251725,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 4,
"selected": true,
"text": "<p>I would tend to be wary about using jobs like this to control execution. Either the delay between successive jobs w... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3275/"
] | I have a table of about a million rows and I need to update every row in the table with the result of a lengthy calculation (the calculation gets a potentially different result for each row). Because it is time consuming, the DBA must be able to control execution. This particular calculation needs to be run once a year... | I would tend to be wary about using jobs like this to control execution. Either the delay between successive jobs would tend to be too short for the DBA to figure out what job to kill/ pause/ etc. or the delay would be long enough that a significant fraction of the run time would be spent in delays between successive j... |
251,688 | <p>Does anybody knows how can I get the max and min value of the 2nd and 3rd columns in PHP?</p>
<pre><code>$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
</code></pre>
<p>Output should be like:</p>
<p>max(12.9)
min(10)</p>
| [
{
"answer_id": 251721,
"author": "belunch",
"author_id": 32867,
"author_profile": "https://Stackoverflow.com/users/32867",
"pm_score": 2,
"selected": true,
"text": "<pre><code><?php\n$ar = array(array(1, 10, 9.0, 'HELLO'),\n array(1, 11, 12.9, 'HELLO'),\n ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does anybody knows how can I get the max and min value of the 2nd and 3rd columns in PHP?
```
$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
```
Output should be like:
max(12.9)
min(10) | ```
<?php
$ar = array(array(1, 10, 9.0, 'HELLO'),
array(1, 11, 12.9, 'HELLO'),
array(3, 12, 10.9, 'HELLO'));
function col($tbl,$col){
$ret = array();
foreach ($tbl as $row){
$ret[count($ret)+1] = $row[$col];
}
return $ret;
}
print (max(col($ar,2))."\n");
prin... |
251,694 | <p>I have Perl code which relies on <code>Term::ReadKey</code> to get the terminal width. My installation is missing this module, so I want to provide a default if the module isn't present rather than throw an exception.</p>
<p>How can I conditionally use an optional module, without knowing ahead of time whether it is ... | [
{
"answer_id": 251736,
"author": "m0j0",
"author_id": 31319,
"author_profile": "https://Stackoverflow.com/users/31319",
"pm_score": 4,
"selected": false,
"text": "<p>Check out the CPAN module <a href=\"http://search.cpan.org/perldoc?Module::Load::Conditional\" rel=\"noreferrer\">Module::... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459/"
] | I have Perl code which relies on `Term::ReadKey` to get the terminal width. My installation is missing this module, so I want to provide a default if the module isn't present rather than throw an exception.
How can I conditionally use an optional module, without knowing ahead of time whether it is available.
```
# bu... | Here's a bare-bones solution that does not require another module:
```
my $rc = eval
{
require Term::ReadKey;
Term::ReadKey->import();
1;
};
if($rc)
{
# Term::ReadKey loaded and imported successfully
...
}
```
Note that all the answers below (I hope they're below this one! :-) that use `eval { use SomeMod... |
251,705 | <p>Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the <a href="http://search.cpan.org/dist/Parallel-ForkManager" rel="noreferrer">Parallel::ForkMana... | [
{
"answer_id": 251766,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 6,
"selected": true,
"text": "<p>From <a href=\"http://faq.perl.org/perlfaq8.html#How_do_I_keep_my_own\" rel=\"noreferrer\">perlfaq8: How do I k... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7743/"
] | Here is my situation: I know almost nothing about Perl but it is the only language available on a porting machine. I only have permissions to write in my local work area and not the Perl install location. I need to use the [Parallel::ForkManager](http://search.cpan.org/dist/Parallel-ForkManager) Perl module from CPAN
... | From [perlfaq8: How do I keep my own module/library directory?](http://faq.perl.org/perlfaq8.html#How_do_I_keep_my_own):
When you build modules, tell Perl where to install the modules.
For C-based distributions, use the INSTALL\_BASE option
when generating Makefiles:
```
perl Makefile.PL INSTALL_BASE=/mydir/perl
``... |
251,711 | <p>I have a SQL database (SQL Server 2008) which contains the following design</p>
<h2>ITEM</h2>
<ul>
<li>ID (Int, Identity)</li>
<li>Name (NVarChar(50))</li>
<li>Description (NVarChar(200))</li>
</ul>
<h2>META</h2>
<ul>
<li>ID (Int, Identity)</li>
<li>Name (NVarChar(50))</li>
</ul>
<p>There exists a N-N relations... | [
{
"answer_id": 252011,
"author": "Andrew Theken",
"author_id": 32238,
"author_profile": "https://Stackoverflow.com/users/32238",
"pm_score": 1,
"selected": false,
"text": "<p>this brings back anything that matchs any of the meta criteria, and then filters it down to only things that matc... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25319/"
] | I have a SQL database (SQL Server 2008) which contains the following design
ITEM
----
* ID (Int, Identity)
* Name (NVarChar(50))
* Description (NVarChar(200))
META
----
* ID (Int, Identity)
* Name (NVarChar(50))
There exists a N-N relationship between these two, i.e an Item can contain zero or more meta references... | This should work for you:
```
string[] criteria = new[] { "Car", "Ford", "Offroad" };
var items =
from i in db.Item
let wantedMetas = db.Meta.Where(m => criteria.Contains(m.Name))
let metas = i.ItemMeta.Select(im => im.Meta)
where wantedMetas.All(m => metas.Contains(m))
select i;
```
Basically ... |
251,727 | <p>I've set hibernate.generate_statistics=true and now need to register the mbeans so I can see the statistics in the jmx console. I can't seem to get anywhere and this doesn't seem like it should be such a difficult problem. Maybe I'm making things overcomplicated, but in any case so far I've tried:</p>
<ul>
<li>I co... | [
{
"answer_id": 251822,
"author": "Matt S.",
"author_id": 1458,
"author_profile": "https://Stackoverflow.com/users/1458",
"pm_score": 1,
"selected": true,
"text": "<p>Solved. Since I was not seeing all the caches for my entities I suspected I was not getting the right SessionFactory insta... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1458/"
] | I've set hibernate.generate\_statistics=true and now need to register the mbeans so I can see the statistics in the jmx console. I can't seem to get anywhere and this doesn't seem like it should be such a difficult problem. Maybe I'm making things overcomplicated, but in any case so far I've tried:
* I copied EhCacheP... | Solved. Since I was not seeing all the caches for my entities I suspected I was not getting the right SessionFactory instance. I started out with this line (see the example jmx registration code in the link I provided in the question):
```
SessionFactory sf = (new Configuration()).configure().buildSessionFactory();
`... |
251,730 | <p>We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation.</p>
<p>Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build.</p>
<... | [
{
"answer_id": 251760,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 5,
"selected": true,
"text": "<p>Normally you would add a profile to your maven configuration that runs a different set of tests:</p>\n\n<p>run this w... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32514/"
] | We've had an ongoing need here that I can't figure out how to address using the stock Maven 2 tools and documentation.
Some of our developers have some very long running JUnit tests (usually stress tests) that under no circumstances should be run as a regular part of the build process / nightly build.
Of course we ca... | Normally you would add a profile to your maven configuration that runs a different set of tests:
run this with mvn -Pintegrationtest install
```
<profile>
<id>integrationtest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>... |
251,740 | <p>This code was working properly before, basically I have a master page that has a single text box for searching, I named it <strong><code>searchBox</code></strong>. I have a method to pull the content of <strong><code>searchBox</code></strong> on form submit and set it to a variable <strong><code>userQuery</code></s... | [
{
"answer_id": 251761,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": true,
"text": "<p>Simply remove the permission to delete things from those unable to get it right. You can give very fine-grained permissi... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | This code was working properly before, basically I have a master page that has a single text box for searching, I named it **`searchBox`**. I have a method to pull the content of **`searchBox`** on form submit and set it to a variable **`userQuery`**. Here is the method:
```
Public Function searchString(ByVal oTextBox... | Simply remove the permission to delete things from those unable to get it right. You can give very fine-grained permissions in AD.
There is no "readonly" attribute. That's what the [ACLs](http://en.wikipedia.org/wiki/Access_control_list) are for. |
251,746 | <p>I want to create a class that takes string array as a constructor argument and has command line option values as members vals. Something like below, but I don't understand how the Bistate works.</p>
<pre><code>import scalax.data._
import scalax.io.CommandLineParser
class TestCLI(arguments: Array[String]) extends C... | [
{
"answer_id": 252007,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not personally familiar with Scalax or <code>Bistate</code> in particular, but just looking at the scaladocs, ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30958/"
] | I want to create a class that takes string array as a constructor argument and has command line option values as members vals. Something like below, but I don't understand how the Bistate works.
```
import scalax.data._
import scalax.io.CommandLineParser
class TestCLI(arguments: Array[String]) extends CommandLinePars... | Here are shorter alternatives to that pattern matching to get a boolean:
```
val opt1 = result(opt1Option).isInstanceOf[Positive[_]]
val opt2 = result(opt2Option).posValue.isDefined
```
The second one is probably better. The field **posValue** is an Option (there's **negValue** as well). The method **isDefined** fro... |
251,753 | <p>Using VB.net (.net 2.0)
I have a string in this format:</p>
<pre><code>record1_field1,record1_field2,record2_field3,record2_field1,record2_field2,
</code></pre>
<p>etc...</p>
<p>I wonder what the best (easiest) way is to get this into an xml?</p>
<p>I can think of 2 ways:</p>
<p>Method 1:
- use split to get the... | [
{
"answer_id": 251763,
"author": "JGW",
"author_id": 26288,
"author_profile": "https://Stackoverflow.com/users/26288",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of doing string concatenation, you could probably create an XmlDocument and stuff it with the appropriate XmlElemen... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32892/"
] | Using VB.net (.net 2.0)
I have a string in this format:
```
record1_field1,record1_field2,record2_field3,record2_field1,record2_field2,
```
etc...
I wonder what the best (easiest) way is to get this into an xml?
I can think of 2 ways:
Method 1:
- use split to get the items in an array
- loop through array and bui... | I would do something like this:
```
XmlDocument doc = new XmlDocuent();
string[] data = csv.split(',');
XmlNode = doc.CreateElement("root");
foreach(string str in data)
{
XmlNode node = doc.CreateElement("data");
node.innerText = str;
root.AppendChild(node);
}
Console.WriteLine(doc.InnerXML);
```
Shou... |
251,759 | <p>I'm writing an application that uses renaming rules to rename a list of files based on information given by the user. The files may be inconsistently named to begin with, or the filenames may be consistent. The user selects a list of files, and inputs information about the files (for MP3s, they would be Artist, Ti... | [
{
"answer_id": 251779,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 1,
"selected": false,
"text": "<p>Not the answer to the question you asked, but an <a href=\"http://en.wikipedia.org/wiki/ID3\" rel=\"nofollow noreferrer\">... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29249/"
] | I'm writing an application that uses renaming rules to rename a list of files based on information given by the user. The files may be inconsistently named to begin with, or the filenames may be consistent. The user selects a list of files, and inputs information about the files (for MP3s, they would be Artist, Title, ... | Easiest would be to replace each `%Label%` with `(?<Label>.*?)`, and escape any other characters.
```
%Artist%-%Album%-%Track%-%Title%.mp3
```
becomes
```
(?<Artist>.*?)-(?<Album>.*?)-(?<Track>.*?)-(?<Title>.*?)\.mp3
```
You would then get each component into named capture groups.
```
Dictinary<string,string> ma... |
251,781 | <p>I believe there's a way to find the kth largest element in an unsorted array of length n in O(n). Or perhaps it's "expected" O(n) or something. How can we do this?</p>
| [
{
"answer_id": 251793,
"author": "Kevin",
"author_id": 19038,
"author_profile": "https://Stackoverflow.com/users/19038",
"pm_score": 1,
"selected": false,
"text": "<p>iterate through the list. if the current value is larger than the stored largest value, store it as the largest value an... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I believe there's a way to find the kth largest element in an unsorted array of length n in O(n). Or perhaps it's "expected" O(n) or something. How can we do this? | This is called finding the **k-th order statistic**. There's a very simple randomized algorithm (called *quickselect*) taking `O(n)` average time, `O(n^2)` worst case time, and a pretty complicated non-randomized algorithm (called *introselect*) taking `O(n)` worst case time. There's some info on [Wikipedia](http://en.... |
251,791 | <p>I need to use JUnit 4.4 (or newer) in a set of eclipse plugin tests, but I've run into the following problem:</p>
<p>Tests are not detected when running with the junit 4.4 or 4.5 bundles from springsource
(<a href="http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.junit&... | [
{
"answer_id": 261242,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know which version of JUnit it was, but to succesfully find test the test methods name must start with the word \"<... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3446/"
] | I need to use JUnit 4.4 (or newer) in a set of eclipse plugin tests, but I've run into the following problem:
Tests are not detected when running with the junit 4.4 or 4.5 bundles from springsource
([junit44](http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.junit&version=4.4.0... | I cannot test this right now as I don't have an Eclipse 3.4 installation handy, but I've run across a similar problem a while ago in (I think) IntelliJ IDEA 7.0.x, and a workaround was to explicitly specify a test runner.
With JUnit 4.5:
```
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class Activ... |
251,806 | <p>I have a interface that defines some methods with attributes. These attributes need to be accessed from the calling method, but the method I have does not pull the attributes from the interface. What am I missing?</p>
<pre><code>public class SomeClass: ISomeInterface
{
MyAttribute GetAttribute()
{
... | [
{
"answer_id": 251827,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>The methodBase will be the method on the class, not the interface. You will need to look for the same method on the... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24500/"
] | I have a interface that defines some methods with attributes. These attributes need to be accessed from the calling method, but the method I have does not pull the attributes from the interface. What am I missing?
```
public class SomeClass: ISomeInterface
{
MyAttribute GetAttribute()
{
StackTrace stac... | The methodBase will be the method on the class, not the interface. You will need to look for the same method on the interface. In C# this is a little simpler (since it must be like-named), but you would need to consider things like explicit implementation. If you have VB code it will be trickier, since VB method "Foo" ... |
251,807 | <p>I use eclipse to work on an application which was originally created independently of eclipse. As such, the application's directory structure is decidedly not eclipse-friendly.</p>
<p>I want to programmatically generate a project for the application. The <code>.project</code> and <code>.classpath</code> files are... | [
{
"answer_id": 252168,
"author": "James Van Huis",
"author_id": 31828,
"author_profile": "https://Stackoverflow.com/users/31828",
"pm_score": 5,
"selected": true,
"text": "<p>You should be able to accomplish this by writing a small Eclipse plugin. You could even extend it out to being a... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16977/"
] | I use eclipse to work on an application which was originally created independently of eclipse. As such, the application's directory structure is decidedly not eclipse-friendly.
I want to programmatically generate a project for the application. The `.project` and `.classpath` files are easy enough to figure out, and I'... | You should be able to accomplish this by writing a small Eclipse plugin. You could even extend it out to being a "headless" RCP app, and pass in the command line arguments you need.
The barebones code to create a project is:
```
IProgressMonitor progressMonitor = new NullProgressMonitor();
IWorkspaceRoot root = Resou... |
251,814 | <p>I've been struggling lately with understanding the best way to organize jQuery code. I asked another question earlier and I don't think I was specific enough (<a href="https://stackoverflow.com/questions/247209/javascript-how-do-you-organize-this-mess">found in this question here</a>).</p>
<p>My problem is that the... | [
{
"answer_id": 251848,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https://Stackoverflow.com/users/2204759",
"pm_score": 2,
"selected": false,
"text": "<p>Stick some of the anon functions into global scope functions (or your own \"namespace\" object), especially the re-use... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] | I've been struggling lately with understanding the best way to organize jQuery code. I asked another question earlier and I don't think I was specific enough ([found in this question here](https://stackoverflow.com/questions/247209/javascript-how-do-you-organize-this-mess)).
My problem is that the richer you make an a... | Just want to add to what was mentioned previously that this:
```
$.each(container.children(), function(j,w) {
$(w).unbind().change(function() { ... });
});
```
can be optimized to:
```
container.children().unbind().change(function() { ... });
```
It's all about chaining, a great way to simplify your code. |
251,834 | <p>Given a Generic List of objects that contain a member variable that is a string, what is the best way to get the object that contains the string with the longest length?</p>
<p>ie.
assuming val1 is the string I'm comparing:</p>
<pre><code>0 : { val1 = "a" }
1 : { val1 = "aa" }
2 : { val1 = "aba" }
3 : { val1 = ... | [
{
"answer_id": 251858,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": true,
"text": "<p>Sorry, I'll try again. You can use the following aggregation:</p>\n\n<pre><code>Dim result = elements.Aggregate(Fun... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2847/"
] | Given a Generic List of objects that contain a member variable that is a string, what is the best way to get the object that contains the string with the longest length?
ie.
assuming val1 is the string I'm comparing:
```
0 : { val1 = "a" }
1 : { val1 = "aa" }
2 : { val1 = "aba" }
3 : { val1 = "c" }
```
what ne... | Sorry, I'll try again. You can use the following aggregation:
```
Dim result = elements.Aggregate(Function(a, b) If(a.val1.Length > b.val1.Length, a, b))
``` |
251,842 | <p>I'm using Asp.Net 2.0. I have a scenario where i need to check a user input against any of two ranges. For e.g. I need to check a textbox value against ranges 100-200 or 500-600. I know that i can hook up 2 Asp.Net RangeValidators to the TextBox, but that will try to validate the input against both the ranges, an A... | [
{
"answer_id": 251873,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the RegularExpressionValidator with the ValidationExpression property set to</p>\n\n<p>Edit: (whoops, 650 and... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28773/"
] | I'm using Asp.Net 2.0. I have a scenario where i need to check a user input against any of two ranges. For e.g. I need to check a textbox value against ranges 100-200 or 500-600. I know that i can hook up 2 Asp.Net RangeValidators to the TextBox, but that will try to validate the input against both the ranges, an AND c... | I extended the BaseValidator to achieve this. Its fairly simple once you understand how Validators work. I've included a crude version of code to demonstrate how it can be done. Mind you it's tailored to my problem(like int's should always be > 0) but you can easily extend it.
```
public class RangeValidatorEx : B... |
251,850 | <p>I'm using symfony and propel, and I'm trying to invoke a specific culture on an object and output some fields of that object to the screen in that specific culture. However, if the object's mapped database record doesn't have those fields in that specific culture, I would like it to default to the base culture (in t... | [
{
"answer_id": 263772,
"author": "Marek",
"author_id": 34452,
"author_profile": "https://Stackoverflow.com/users/34452",
"pm_score": 2,
"selected": true,
"text": "<p>You will have to overwrite symfony itself to make it default to another language.\nTheres a good working solution here <a ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53001/"
] | I'm using symfony and propel, and I'm trying to invoke a specific culture on an object and output some fields of that object to the screen in that specific culture. However, if the object's mapped database record doesn't have those fields in that specific culture, I would like it to default to the base culture (in this... | You will have to overwrite symfony itself to make it default to another language.
Theres a good working solution here <http://www.codemassacre.com/2008/03/10/symfony-default-language-fallback/> |
251,851 | <p>I have a directory of files that I'd like to append file extension to as long as they don't have an existing, specified extension. So add .txt to all file names that don't end in .xyz. PowerShell seems like a good candidate for this, but I don't know anything about it. How would I go about it?</p>
| [
{
"answer_id": 251855,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>Consider the DOS command FOR in a standard shell.</p>\n\n<pre><code>C:\\Documents and Settings\\Kenny>help for\nRuns a s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] | I have a directory of files that I'd like to append file extension to as long as they don't have an existing, specified extension. So add .txt to all file names that don't end in .xyz. PowerShell seems like a good candidate for this, but I don't know anything about it. How would I go about it? | +1 to EBGreen, except that (at least on XP) the "-exclude" parameter to get-childitem doesn't seem to work. The help text (gci -?) actually says "this parameter does not work properly in this cmdlet"!
So you can filter manually like this:
```
gci
| ?{ !$_.PSIsContainer -and !$_.Name.EndsWith(".xyz") }
| %{ ren ... |
251,861 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/174796/watermarked-textbox-for-compact-framework">Watermarked Textbox for Compact Framework</a> </p>
</blockquote>
<p>Using Visual Studio 2008 SP1, the latest Compact framework and Windows Mobile 5.</p>
<p>I n... | [
{
"answer_id": 251855,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>Consider the DOS command FOR in a standard shell.</p>\n\n<pre><code>C:\\Documents and Settings\\Kenny>help for\nRuns a s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16241/"
] | >
> **Possible Duplicate:**
>
> [Watermarked Textbox for Compact Framework](https://stackoverflow.com/questions/174796/watermarked-textbox-for-compact-framework)
>
>
>
Using Visual Studio 2008 SP1, the latest Compact framework and Windows Mobile 5.
I need to use DrawString to put a string over a TextBox. But ... | +1 to EBGreen, except that (at least on XP) the "-exclude" parameter to get-childitem doesn't seem to work. The help text (gci -?) actually says "this parameter does not work properly in this cmdlet"!
So you can filter manually like this:
```
gci
| ?{ !$_.PSIsContainer -and !$_.Name.EndsWith(".xyz") }
| %{ ren ... |
251,865 | <p>For a very simple ajax name lookup, I'm sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then displayed).</p>
<p>The javascript code that receives the value is pretty stand... | [
{
"answer_id": 251855,
"author": "kenny",
"author_id": 3225,
"author_profile": "https://Stackoverflow.com/users/3225",
"pm_score": 2,
"selected": false,
"text": "<p>Consider the DOS command FOR in a standard shell.</p>\n\n<pre><code>C:\\Documents and Settings\\Kenny>help for\nRuns a s... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For a very simple ajax name lookup, I'm sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then displayed).
The javascript code that receives the value is pretty standard:
```
... | +1 to EBGreen, except that (at least on XP) the "-exclude" parameter to get-childitem doesn't seem to work. The help text (gci -?) actually says "this parameter does not work properly in this cmdlet"!
So you can filter manually like this:
```
gci
| ?{ !$_.PSIsContainer -and !$_.Name.EndsWith(".xyz") }
| %{ ren ... |
251,868 | <p>I was watching <a href="http://channel9.msdn.com/pdc2008/TL16/" rel="noreferrer">Anders' talk about C# 4.0 and sneak preview of C# 5.0</a>, and it got me thinking about when optional parameters are available in C# what is going to be the recommended way to declare methods that do not need all parameters specified?</... | [
{
"answer_id": 251883,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 4,
"selected": false,
"text": "<p>When a method overload normally performs the same thing with a different number of arguments then defaults will be used.<... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13552/"
] | I was watching [Anders' talk about C# 4.0 and sneak preview of C# 5.0](http://channel9.msdn.com/pdc2008/TL16/), and it got me thinking about when optional parameters are available in C# what is going to be the recommended way to declare methods that do not need all parameters specified?
For example something like the ... | I'd consider the following:
* Do you need your code to be used from languages which don't support optional parameters? If so, consider including the overloads.
* Do you have any members on your team who violently oppose optional parameters? (Sometimes it's easier to live with a decision you don't like than to argue th... |
251,890 | <p>I am a rookie was using the Visual Studio 2008 built-in Unit Testing components, what would be the best way to record or display your results in a unit test?</p>
<p>I want to test my service method when it returns a System.GUID and an empty System.GUID</p>
<pre><code>[TestMethod]
public void GetGUID()
{
MyWcfSe... | [
{
"answer_id": 251895,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 0,
"selected": false,
"text": "<p>I used this for a few months last year, IIRC isn't there an <code>Assert</code> class? <code>Assert.IsTrue(...)</code>?<... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | I am a rookie was using the Visual Studio 2008 built-in Unit Testing components, what would be the best way to record or display your results in a unit test?
I want to test my service method when it returns a System.GUID and an empty System.GUID
```
[TestMethod]
public void GetGUID()
{
MyWcfServiceService.MyWcfSer... | For GetGUID()...
```
Assert.IsFalse(guid == Guid.Empty);
```
Similarly for GetEmptyGUID()...
```
Assert.IsTrue(guid == Guid.Empty);
``` |
251,902 | <p>I would like to search through all of my procedures packages and functions for a certain phrase.</p>
<p>Since it is possible to retrieve the code for compiled procedures using toad I assume that the full text is stored in some data dictionary table. Does anyone know where that would be?</p>
<p>Thanks a lot</p>
| [
{
"answer_id": 251907,
"author": "Mark",
"author_id": 26310,
"author_profile": "https://Stackoverflow.com/users/26310",
"pm_score": 1,
"selected": false,
"text": "<p>Do you mean using PL/SQL? Or just using TOAD? I know that you can use the \"Find Objects\" (or something like that) featur... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I would like to search through all of my procedures packages and functions for a certain phrase.
Since it is possible to retrieve the code for compiled procedures using toad I assume that the full text is stored in some data dictionary table. Does anyone know where that would be?
Thanks a lot | You can do something like
```
SELECT name, line, text
FROM dba_source
WHERE upper(text) like upper('%<<your_phrase>>%') escape '\'
``` |
251,908 | <p>What commands in Emacs can I use to insert into the text buffer of a file the current date and time?</p>
<p><em>(For example, the equivalent in Notepad is simply pressing F5 which is about the only useful feature for Notepad!)</em></p>
| [
{
"answer_id": 251922,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 6,
"selected": false,
"text": "<p>Put in your .emacs file:</p>\n\n<pre><code>;; ====================\n;; insert date and time\n\n(defvar curre... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | What commands in Emacs can I use to insert into the text buffer of a file the current date and time?
*(For example, the equivalent in Notepad is simply pressing F5 which is about the only useful feature for Notepad!)* | ```
C-u M-! date
``` |
251,909 | <p>I'm using <code>Microsoft's DSOFramer</code> control to allow me to embed an Excel file in my dialog so the user can choose his sheet, then select his range of cells; it's used with an import button on my dialog.</p>
<p>The problem is that when I call the <code>DSOFramer's OPEN</code> function, if I have Excel open... | [
{
"answer_id": 251922,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 6,
"selected": false,
"text": "<p>Put in your .emacs file:</p>\n\n<pre><code>;; ====================\n;; insert date and time\n\n(defvar curre... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965047/"
] | I'm using `Microsoft's DSOFramer` control to allow me to embed an Excel file in my dialog so the user can choose his sheet, then select his range of cells; it's used with an import button on my dialog.
The problem is that when I call the `DSOFramer's OPEN` function, if I have Excel open in another window, it closes th... | ```
C-u M-! date
``` |
251,924 | <p>Lists in C# have the <code>.ToArray()</code> method. I want the inverse, where an array is transformed into a list. I know how to create a list and loop through it but I would like a one liner to swap it back.</p>
<p>I am using the <code>String.Split</code> method in the .NET 2.0 environment, so LINQ, etc. is not a... | [
{
"answer_id": 251928,
"author": "Ty.",
"author_id": 16948,
"author_profile": "https://Stackoverflow.com/users/16948",
"pm_score": 3,
"selected": false,
"text": "<pre><code>return new List<string>(stringArray);\n</code></pre>\n"
},
{
"answer_id": 251929,
"author": "Ovid... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | Lists in C# have the `.ToArray()` method. I want the inverse, where an array is transformed into a list. I know how to create a list and loop through it but I would like a one liner to swap it back.
I am using the `String.Split` method in the .NET 2.0 environment, so LINQ, etc. is not available to me. | ```
string s = ...
new List<string>(s.Split(....));
``` |
251,941 | <p>I'm in javascript, running this in the console </p>
<pre><code>d = new Date();
d.setMonth(1);
d.setFullYear(2009);
d.setDate(15);
d.toString();
</code></pre>
<p>outputs this:</p>
<pre><code>"Sun Mar 15 2009 18:05:46 GMT-0400 (EDT)"
</code></pre>
<p>Why would this be... | [
{
"answer_id": 251962,
"author": "Issac Kelly",
"author_id": 144,
"author_profile": "https://Stackoverflow.com/users/144",
"pm_score": 1,
"selected": false,
"text": "<pre><code>d = new Date();\nd.setDate(15); \nd.setMonth(1);\nd.setFullYear(2009); ... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] | I'm in javascript, running this in the console
```
d = new Date();
d.setMonth(1);
d.setFullYear(2009);
d.setDate(15);
d.toString();
```
outputs this:
```
"Sun Mar 15 2009 18:05:46 GMT-0400 (EDT)"
```
Why would this be happening? It seems like a browser bug. | That's because when you initialize a new Date, it comes with today's date, so today is Oct 30 2008, then you set the month to February, so there is no February 30, so set first the day, then the month, and then the year:
```
d = new Date();
d.setDate(15);
d.setMonth(1);
d.setFullYear(2009);
```... |
251,945 | <p>I have a site that creates images for some bit of content after the content is created. I'm trying to figure out what to do in between the time the content is created and the image is created. My thought is that I might be able to set a custom image to display on a 404 error on the original image. However, I'm no... | [
{
"answer_id": 251977,
"author": "Jasper Bekkers",
"author_id": 31486,
"author_profile": "https://Stackoverflow.com/users/31486",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <code><object></code> tag in HTML with a fallback to the default image.</p>\n\n<pre><code><P>... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31240/"
] | I have a site that creates images for some bit of content after the content is created. I'm trying to figure out what to do in between the time the content is created and the image is created. My thought is that I might be able to set a custom image to display on a 404 error on the original image. However, I'm not sure... | Another alternative on the client side is to do:
```
<img src="/images/generated_image_xyz.png"
onerror="this.src='/images/default_image.png'; this.title='Loading...';" />
``` |
251,957 | <p>I have a simple table in SQL Server 2005, I wish to convert this to XML (using the "FOR XML" clause). I'm having trouble getting my XML to look like the required output.</p>
<p>I've tried looking through various tutorials on the web, but I am struggling. Can someone help?</p>
<p>The table I have looks like this</p... | [
{
"answer_id": 252021,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 1,
"selected": false,
"text": "<p>I prefer using for XML PATH, it provides a nicer way to control your elements etc.</p>\n\n<p><a href=\"http://theengineroom... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15144/"
] | I have a simple table in SQL Server 2005, I wish to convert this to XML (using the "FOR XML" clause). I'm having trouble getting my XML to look like the required output.
I've tried looking through various tutorials on the web, but I am struggling. Can someone help?
The table I have looks like this
```
TYPE,GROUP,VAL... | As close as I can get is this:
```
select "type" as '@name', "group" as 'row/column1', "value" as 'row/column2'
from tableName
for xml path('variable'), root('data')
```
Naming two items the same ("column" and "column") isn't something I know how to do in one pass, but on the other hand it is an odd XML schema choic... |
251,960 | <p>I have a long running insert transaction that inserts data into several related tables. </p>
<p>When this insert is running, I cannot perform a select * from MainTable. The select just spins its wheels until the insert is done. </p>
<p>I will be performing several of these inserts at the same/overlapping time. ... | [
{
"answer_id": 252005,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 0,
"selected": false,
"text": "<p>The only isolation level that allows one transaction to read changes executed by another transaction in progress (b... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] | I have a long running insert transaction that inserts data into several related tables.
When this insert is running, I cannot perform a select \* from MainTable. The select just spins its wheels until the insert is done.
I will be performing several of these inserts at the same/overlapping time. To check that the i... | You may want to rethink your process before you use READ UNCOMMITTED. There are many good reasons for isolated transactions. If you use READ UNCOMMITTED you may still get duplicates because there is a chance both of the inserts will check for updates at the same time and both not finding them creating duplicates. Try b... |
251,964 | <p>I often accidentally create a branch that contains more code than it needs to. When that happens, I delete the branch files, the branch tag, and then start over. The thing that stinks is having to sync the huge pile of data just so I can delete it.</p>
<p>Is there a way to delete server-side?</p>
| [
{
"answer_id": 252038,
"author": "pd.",
"author_id": 19066,
"author_profile": "https://Stackoverflow.com/users/19066",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, use sync -k.</p>\n\n<p>Add the path you want to delete to your client, e.g.</p>\n\n<pre><code>//depot/oops/... //your-... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11116/"
] | I often accidentally create a branch that contains more code than it needs to. When that happens, I delete the branch files, the branch tag, and then start over. The thing that stinks is having to sync the huge pile of data just so I can delete it.
Is there a way to delete server-side? | Yes, use sync -k.
Add the path you want to delete to your client, e.g.
```
//depot/oops/... //your-client/oops/...
```
Then sync that location using the -k option:
```
p4 sync -k oops/...
```
This will tell Perforce that your client has the files without actually transferring them. Then you can do:
```
p4 delet... |
251,985 | <p>I am binding the dropdown with db entity. </p>
<pre><code>ddlCustomer.DataSource = Customer.GetAll();
ddlCustomer.DataTextField = "CustomerName";
ddlCustomer.DataBind();
</code></pre>
<p>I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this?</p>
| [
{
"answer_id": 251997,
"author": "Mohamed Faramawi",
"author_id": 20006,
"author_profile": "https://Stackoverflow.com/users/20006",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know if there is a one line solution to this, but what i was doing before is, not using DataBind , and... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] | I am binding the dropdown with db entity.
```
ddlCustomer.DataSource = Customer.GetAll();
ddlCustomer.DataTextField = "CustomerName";
ddlCustomer.DataBind();
```
I want to add "SELECT" as the first itemlist in dropdown and bind then entity to the dropdown. How can i do this? | Add:
```
ddlCustomer.Items.Insert(0, "SELECT");
```
After ddlCustomer.DataBind();
The item must be inserted after the data bind because the data bind clears the items. |
251,987 | <p>Imagine I have a property defined in global.asax. </p>
<pre><code>public List<string> Roles
{
get
{
...
}
set
{
...
}
}
</code></pre>
<p>I want to use the value in another page. how to I refer to it?</p>
| [
{
"answer_id": 252004,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>It looks to me like that only depends on the session - so why not make it a pair of static methods which take the ses... | 2008/10/30 | [
"https://Stackoverflow.com/questions/251987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | Imagine I have a property defined in global.asax.
```
public List<string> Roles
{
get
{
...
}
set
{
...
}
}
```
I want to use the value in another page. how to I refer to it? | You can access the class like this:
```
((Global)this.Context.ApplicationInstance).Roles
``` |
252,028 | <p>I have a very strange bug cropping up right now in a fairly massive C++ application at work (massive in terms of CPU and RAM usage as well as code length - in excess of 100,000 lines). This is running on a dual-core Sun Solaris 10 machine. The program subscribes to stock price feeds and displays them on "pages" conf... | [
{
"answer_id": 252059,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "<p>That sounds like a stack overflow problem - something is writing beyond the bounds of an array and trampling o... | 2008/10/30 | [
"https://Stackoverflow.com/questions/252028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a very strange bug cropping up right now in a fairly massive C++ application at work (massive in terms of CPU and RAM usage as well as code length - in excess of 100,000 lines). This is running on a dual-core Sun Solaris 10 machine. The program subscribes to stock price feeds and displays them on "pages" configu... | Stack corruption, 99.9% definitely.
The smells you should be looking carefully for are:-
* Use of 'C' arrays
* Use of 'C' strcpy-style functions
* memcpy
* malloc and free
* thread-safety of anything using pointers
* Uninitialised POD variables.
* Pointer Arithmetic
* Functions trying to return local variables by ref... |
252,066 | <p>Using .Net how do I use the Sort method to sort an Array in reverse i.e. Z to A?</p>
| [
{
"answer_id": 252075,
"author": "Michał Piaskowski",
"author_id": 1534,
"author_profile": "https://Stackoverflow.com/users/1534",
"pm_score": 2,
"selected": false,
"text": "<p>You need to pass a <a href=\"http://msdn.microsoft.com/en-us/library/8ehhxeaf.aspx\" rel=\"nofollow noreferrer\... | 2008/10/30 | [
"https://Stackoverflow.com/questions/252066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Using .Net how do I use the Sort method to sort an Array in reverse i.e. Z to A? | Provide an appropriate element comparer. What C# version do you use? 3 lets you do this:
```
Array.Sort(myarray, (a, b) => b.CompareTo(a));
``` |
252,149 | <p>The following is code I've used to create a <code>memory mapped file</code>:</p>
<pre><code>fid = open(filename, O_CREAT | O_RDWR, 0660);
if ( 0 > fid )
{
throw error;
}
/* mapped offset pointer to data file */
offset_table_p = (ubyte_2 *) shmat(fid, 0, SHM_MAP);
/* Initialize table */
memset(offset_table... | [
{
"answer_id": 252261,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "<p>First things first:</p>\n\n<p>Examine the file both before and after the open() call. If on Linux, you can use the c... | 2008/10/30 | [
"https://Stackoverflow.com/questions/252149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The following is code I've used to create a `memory mapped file`:
```
fid = open(filename, O_CREAT | O_RDWR, 0660);
if ( 0 > fid )
{
throw error;
}
/* mapped offset pointer to data file */
offset_table_p = (ubyte_2 *) shmat(fid, 0, SHM_MAP);
/* Initialize table */
memset(offset_table_p, 0x00, (table_size + 1) *... | As far as I can tell from reading documentation, you are doing it completely wrong.
Either use open() and mmap() or use shmget() and shmat().
If you use open() you will need to make the file long enough first. Use ftruncate() for that. |
252,179 | <p>What is the best way to check if a given url points to a valid file (i.e. not return a 404/301/etc.)? I've got a script that will load certain .js files on a page, but I need a way to verify each URL it receives points to a valid file.</p>
<p>I'm still poking around the PHP manual to see which file functions (if an... | [
{
"answer_id": 252183,
"author": "Andrew Theken",
"author_id": 32238,
"author_profile": "https://Stackoverflow.com/users/32238",
"pm_score": 0,
"selected": false,
"text": "<p>one such way would be to request the url and get a response with a status code of 200 back, aside from that, ther... | 2008/10/30 | [
"https://Stackoverflow.com/questions/252179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | What is the best way to check if a given url points to a valid file (i.e. not return a 404/301/etc.)? I've got a script that will load certain .js files on a page, but I need a way to verify each URL it receives points to a valid file.
I'm still poking around the PHP manual to see which file functions (if any) will ac... | The file\_get\_contents is a bit overshooting the purpose as it is enough to have the HTTP header to make the decision, so you'll need to use curl to do so:
```
<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
cur... |
252,202 | <p>In my database I have tables that define types for example</p>
<p>Table: Publication Types</p>
<pre>
ID | Type
----------
1 | Article
2 | Abstract
3 | Book
....
</pre>
<p>Which is related through the ID key to a publication tables which has the field <em>TypeID</em>.</p>
<p>I then create a PublicationTable ... | [
{
"answer_id": 252212,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 4,
"selected": true,
"text": "<p>if publication types are essentially static, enums are fine</p>\n\n<p>there is arguably little difference between e... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] | In my database I have tables that define types for example
Table: Publication Types
```
ID | Type
----------
1 | Article
2 | Abstract
3 | Book
....
```
Which is related through the ID key to a publication tables which has the field *TypeID*.
I then create a PublicationTable data table my .NET application which... | if publication types are essentially static, enums are fine
there is arguably little difference between embedding
```
inner join lookuptable lt on lt.id = (int)myenum.sometype
```
in a query and adding
```
inner join lookuptable lt on lt.name = "somehardcodeddescription"
```
they're both embedded constants, t... |
252,203 | <p>I am using the following code to check if a variable is not nil and not zero</p>
<pre><code>if(discount != nil && discount != 0)
...
end
</code></pre>
<p>Is there a better way to do this?</p>
| [
{
"answer_id": 252214,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 0,
"selected": false,
"text": "<p>You could initialize discount to 0 as long as your code is guaranteed not to try and use it before it is initialized. That... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] | I am using the following code to check if a variable is not nil and not zero
```
if(discount != nil && discount != 0)
...
end
```
Is there a better way to do this? | ```
unless discount.nil? || discount == 0
# ...
end
``` |
252,221 | <p>My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.</p>
<p><a href="http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg" rel="nofollow noreferrer">t-shirt</a></p>
<p>So, I have a couple of guesses... | [
{
"answer_id": 252296,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>What if it doesn't mean anything, what if it is just a neat design they came up with?</p>\n"
},
{
"answer_id": 2523... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28486/"
] | My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.
[t-shirt](http://2.bp.blogspot.com/_iQVgmEEAit4/SPkKHA3e8fI/AAAAAAAAAB8/ugUerJjuBw8/s1600-h/GWO-tshirt.jpg)
So, I have a couple of guesses as to what it means, but I was just wondering if ther... | I emailed the Website Optimizer Team, and they said "There's no secret code, unless you find one. :)" |
252,222 | <p>What is the best way to access an ASP.NET HiddenField control that is embedded in an ASP.NET PlaceHolder control through JavaScript? The Visible attribute is set to false in the initial page load and can changed via an AJAX callback.</p>
<p>Here is my current source code:</p>
<pre><code><script language="javas... | [
{
"answer_id": 252228,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 2,
"selected": false,
"text": "<p>If the Visibility is set to false server-side, the placeholder won't be rendered and you won't be able to access any... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | What is the best way to access an ASP.NET HiddenField control that is embedded in an ASP.NET PlaceHolder control through JavaScript? The Visible attribute is set to false in the initial page load and can changed via an AJAX callback.
Here is my current source code:
```
<script language="javascript" type="text/javascr... | My understanding is if you set controls.Visible = false during initial page load, it doesn't get rendered in the client response.
My suggestion to solve your problem is
1. Don't use placeholder, judging from the scenario, you don't really need a placeholder, unless you need to dynamically add controls on the server si... |
252,230 | <p>First of all there is a <a href="https://stackoverflow.com/questions/59880/are-stored-procedures-more-efficient-in-general-than-inline-statements-on-moder">partial question</a> regarding this, but it is not exactly what I'm asking, so, bear with me and go for it.</p>
<p>My question is, after looking at what <a href... | [
{
"answer_id": 252232,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 3,
"selected": true,
"text": "<p>It doesn't need to be one or the other. If it's a simple query, use the SubSonic query tool. If it's more complex, us... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28004/"
] | First of all there is a [partial question](https://stackoverflow.com/questions/59880/are-stored-procedures-more-efficient-in-general-than-inline-statements-on-moder) regarding this, but it is not exactly what I'm asking, so, bear with me and go for it.
My question is, after looking at what [SubSonic](http://subsonicpr... | It doesn't need to be one or the other. If it's a simple query, use the SubSonic query tool. If it's more complex, use a stored procedure and load up a collection or create a dataset from the results.
See here: [What are the pros and cons to keeping SQL in Stored Procs versus Code](https://stackoverflow.com/questions/... |
252,242 | <p>Specifically, I have a model that has a field like this</p>
<pre><code>pub_date = models.DateField("date published")
</code></pre>
<p>I want to be able to easily grab the object with the most recent <code>pub_date</code>. What is the easiest/best way to do this?</p>
<p>Would something like the following do what I... | [
{
"answer_id": 252248,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 6,
"selected": true,
"text": "<pre><code>obj = Edition.objects.latest('pub_date')\n</code></pre>\n\n<p>You can also simplify things by putting <a h... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | Specifically, I have a model that has a field like this
```
pub_date = models.DateField("date published")
```
I want to be able to easily grab the object with the most recent `pub_date`. What is the easiest/best way to do this?
Would something like the following do what I want?
```
Edition.objects.order_by('pub_da... | ```
obj = Edition.objects.latest('pub_date')
```
You can also simplify things by putting [`get_latest_by`](http://docs.djangoproject.com/en/dev/ref/models/options/#get-latest-by) in the model's Meta, then you'll be able to do
```
obj = Edition.objects.latest()
```
See [the docs](http://docs.djangoproject.com/en/de... |
252,249 | <p>Lucene is an excellent search engine, but the .NET version is behind the official Java release (latest stable .NET release is 2.0, but the latest Java Lucene version is 2.4, which has more features).</p>
<p>How do you get around this?</p>
| [
{
"answer_id": 252254,
"author": "Kalid",
"author_id": 109,
"author_profile": "https://Stackoverflow.com/users/109",
"pm_score": 5,
"selected": true,
"text": "<p>One way I found, which was surprised could work: Create a .NET DLL from a Java .jar file! Using <a href=\"http://www.ikvm.net/... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/109/"
] | Lucene is an excellent search engine, but the .NET version is behind the official Java release (latest stable .NET release is 2.0, but the latest Java Lucene version is 2.4, which has more features).
How do you get around this? | One way I found, which was surprised could work: Create a .NET DLL from a Java .jar file! Using [IKVM](http://www.ikvm.net/) you can [download Lucene](http://www.apache.org/dyn/closer.cgi/lucene/java/), get the .jar file, and run:
```
ikvmc -target:library <path-to-lucene.jar>
```
which generates a .NET dll like thi... |
252,252 | <p>Given the following markup:</p>
<pre><code><ul>
<li>apple</li>
<li class="highlight">orange</li>
<li>pear</li>
</ul>
</code></pre>
<p>Both the <code>ul</code>s and the <code>li</code>s widths appear to be 100%. If I apply a <code>background-color</code> to t... | [
{
"answer_id": 252259,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 2,
"selected": false,
"text": "<p>Can you do it like this?</p>\n\n<pre><code><ul>\n <li>apple</li>\n <li><span class=\"hi... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26627/"
] | Given the following markup:
```
<ul>
<li>apple</li>
<li class="highlight">orange</li>
<li>pear</li>
</ul>
```
Both the `ul`s and the `li`s widths appear to be 100%. If I apply a `background-color` to the list item, the highlight stretches the full width of the page.
I only want the background highlight to ... | Adding `ul {float: left; }` style will force your list into preferred width, which is what you want.
Problem is, you should make sure next element goes below the list, as it did before. Clearing should take care of that. |
252,257 | <p>I was just wondering, since the <strong>sealed</strong> keyword's existence indicates that it's the class author's decision as to whether other classes are allowed to inherit from it, why aren't classes sealed by default, with some keyword to mark them explicitly as extensible?</p>
<p>I know it's somewhat different... | [
{
"answer_id": 252266,
"author": "Cory House",
"author_id": 26180,
"author_profile": "https://Stackoverflow.com/users/26180",
"pm_score": 4,
"selected": false,
"text": "<p>Inheritance is a foundational principle of OO, so arguably, disallowing it by default wouldn't be intuitive.</p>\n"
... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | I was just wondering, since the **sealed** keyword's existence indicates that it's the class author's decision as to whether other classes are allowed to inherit from it, why aren't classes sealed by default, with some keyword to mark them explicitly as extensible?
I know it's somewhat different, but access modifiers ... | **In my opinion** there should be no default syntax, that way you always write explicitly what you want. This forces the coder to understand/think more.
If you want a class to be inheritable then you write
```
public extensible class MyClass
```
otherwise
```
public sealed class MyClass
```
BTW I think the same ... |
252,258 | <p>I have a MySQL database behind a firewall which can only be accessed via an SSH connection. Does anyone know of an implementation of java.sql.Connection which would allow me to make an SSH connection to this database?</p>
| [
{
"answer_id": 252370,
"author": "Steve K",
"author_id": 739,
"author_profile": "https://Stackoverflow.com/users/739",
"pm_score": 5,
"selected": true,
"text": "<p>You can use SSH's port forwarding to do this. While not a pure java.sql.Connection, it will allow you to tunnel the connect... | 2008/10/31 | [
"https://Stackoverflow.com/questions/252258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I have a MySQL database behind a firewall which can only be accessed via an SSH connection. Does anyone know of an implementation of java.sql.Connection which would allow me to make an SSH connection to this database? | You can use SSH's port forwarding to do this. While not a pure java.sql.Connection, it will allow you to tunnel the connection through ssh.
```
ssh -L 3306:localhost:3306 remote.mysql.host.com
```
This will forward port 3306 on your local machine to port 3306 on remote.mysql.host.com. This will allow you to connect t... |