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 |
|---|---|---|---|---|---|---|
156,013 | <p>I can't quite figure out this syntax problem with a <code>case</code> expression in a <code>do</code> block.</p>
<p>What is the correct syntax? </p>
<p>If you could correct my example and explain it that would be the best.</p>
<pre><code>module Main where
main = do
putStrLn "This is a test"
s <-... | [
{
"answer_id": 156050,
"author": "wnoise",
"author_id": 15464,
"author_profile": "https://Stackoverflow.com/users/15464",
"pm_score": 6,
"selected": true,
"text": "<p>return is an (overloaded) function, and it's not expecting its first argument to be a keyword. You can either parenthesi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8965/"
] | I can't quite figure out this syntax problem with a `case` expression in a `do` block.
What is the correct syntax?
If you could correct my example and explain it that would be the best.
```
module Main where
main = do
putStrLn "This is a test"
s <- foo
putStrLn s
foo = do
args <- getArgs ... | return is an (overloaded) function, and it's not expecting its first argument to be a keyword. You can either parenthesize:
```
module Main where
import System(getArgs)
main = do
putStrLn "This is a test"
s <- foo
putStrLn s
foo = do
args <- getArgs
return (case args of
... |
156,046 | <p>I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?</p>
| [
{
"answer_id": 156067,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 3,
"selected": false,
"text": "<p>Doing this seems like a hack, but it seems to work:</p>\n\n<pre><code>this.TopMost = true; // as a result the... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus? | Hmmm, isn't simply overriding Form.ShowWithoutActivation enough?
```
protected override bool ShowWithoutActivation
{
get { return true; }
}
```
And if you don't want the user to click this notification window either, you can override CreateParams:
```
protected override CreateParams CreateParams
{
get
{
C... |
156,051 | <p>I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop:</p>
<pre><code>function populateDropDown(dropdownId, list, enable, showCount) {
var dropdown = $get(dropdownId);
dropdown.options... | [
{
"answer_id": 156059,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use Request.Form for this - you can't encrypt ViewState on the fly from the client - it would defeat the whole ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] | I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop:
```
function populateDropDown(dropdownId, list, enable, showCount) {
var dropdown = $get(dropdownId);
dropdown.options.length = 1; ... | Although I'm not really sure how it does it the CascadingDropDown in the AJAX Control Toolkit does support this.
This is the line that appears to do it:
```
AjaxControlToolkit.CascadingDropDownBehavior.callBaseMethod(this, 'set_ClientState', [ this._selectedValue+':::'+text ]);
```
But the simplest idea would be to... |
156,084 | <p>Using VBA i have a set of functions that return an <code>ADODB.Recordset</code> where all the columns as <code>adVarChar</code>. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7</p>
<p>Is there any methods that can sort numerics as text columns without resorting to changing the t... | [
{
"answer_id": 156104,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": true,
"text": "<p>Left pad with Zeros with at least as many as maximum number digits.\ne.g.</p>\n\n<p>0001\n0010\n0022\n1000</p>\n\n<p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4134/"
] | Using VBA i have a set of functions that return an `ADODB.Recordset` where all the columns as `adVarChar`. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7
Is there any methods that can sort numerics as text columns without resorting to changing the type of the column?
```
Sub Test... | Left pad with Zeros with at least as many as maximum number digits.
e.g.
0001
0010
0022
1000
You can use Right$() to accomplish this. |
156,113 | <p>I have some linq entities that inherit something like this:</p>
<pre><code>public abstract class EntityBase { public int Identifier { get; } }
public interface IDeviceEntity { int DeviceId { get; set; } }
public abstract class DeviceEntityBase : EntityBase, IDeviceEntity
{
public abstract int DeviceId { get; se... | [
{
"answer_id": 156124,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 1,
"selected": false,
"text": "<p>This kind of heirarchial mapping isnot possible with LinqToSql. The the mapping is setup it cannot map to properties in b... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2281/"
] | I have some linq entities that inherit something like this:
```
public abstract class EntityBase { public int Identifier { get; } }
public interface IDeviceEntity { int DeviceId { get; set; } }
public abstract class DeviceEntityBase : EntityBase, IDeviceEntity
{
public abstract int DeviceId { get; set; }
}
public... | LINQ-to-SQL has *some* support for inheritance via a discriminator ([here](http://www.davidhayden.com/blog/dave/archive/2007/10/28/LINQToSQLEnumSupportExampleDiscriminatorColumnInheritanceMapping.aspx), [here](http://weblogs.asp.net/zeeshanhirani/archive/2008/06/25/inheritance-in-linq-to-sql.aspx)), but you can only qu... |
156,114 | <p>When paging through data that comes from a DB, you need to know how many pages there will be to render the page jump controls.</p>
<p>Currently I do that by running the query twice, once wrapped in a <code>count()</code> to determine the total results, and a second time with a limit applied to get back just the res... | [
{
"answer_id": 156227,
"author": "Steve M",
"author_id": 1693,
"author_profile": "https://Stackoverflow.com/users/1693",
"pm_score": -1,
"selected": false,
"text": "<p>Seeing as you need to know for the purpose of paging, I'd suggest running the full query once, writing the data to disk ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20851/"
] | When paging through data that comes from a DB, you need to know how many pages there will be to render the page jump controls.
Currently I do that by running the query twice, once wrapped in a `count()` to determine the total results, and a second time with a limit applied to get back just the results I need for the c... | ### Pure SQL
Things have changed since 2008. You can use a [window function](https://www.postgresql.org/docs/current/functions-window.html) to get the full count *and* the limited result in one query. Introduced with [PostgreSQL 8.4 in 2009](https://www.postgresql.org/docs/8.4/release-8-4.html).
```sql
SELECT foo
... |
156,116 | <p>I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox.</p>
<p>Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross browser (Safari, WebKit, Firefox, etc.) would be preferre... | [
{
"answer_id": 156142,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 2,
"selected": false,
"text": "<p>There are no equivalents in other browsers. The closest you could get is using a graphics library like Canvas and m... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7831/"
] | I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox.
Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross browser (Safari, WebKit, Firefox, etc.) would be preferred.
```
<s... | Please check the [Nihilogic Javascript Image Effect Library](http://www.nihilogic.dk/labs/imagefx/):
* supports IE and Fx pretty well
* has a lot of effects
You can find many other effects in the [CVI Projects](http://www.netzgesta.de/cvi/):
* they are also JS based
* there's a [Lab to experiment](http://www.netzges... |
156,243 | <p>What is the difference between the following 2 ways to allocate and init an object?</p>
<pre><code>AController *tempAController = [[AController alloc] init];
self.aController = tempAController;
[tempAController release];
</code></pre>
<p>and</p>
<pre><code>self.aController= [[AController alloc] init];
</code></pr... | [
{
"answer_id": 156289,
"author": "benzado",
"author_id": 10947,
"author_profile": "https://Stackoverflow.com/users/10947",
"pm_score": 7,
"selected": true,
"text": "<p>Every object has a reference count. When it goes to 0, the object is deallocated.</p>\n\n<p>Assuming the property was d... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1987/"
] | What is the difference between the following 2 ways to allocate and init an object?
```
AController *tempAController = [[AController alloc] init];
self.aController = tempAController;
[tempAController release];
```
and
```
self.aController= [[AController alloc] init];
```
Most of the apple example use the first me... | Every object has a reference count. When it goes to 0, the object is deallocated.
Assuming the property was declared as `@property (retain)`:
Your first example, line by line:
1. The object is created by `alloc`, it has a reference count of 1.
2. The object is handed over to `self`'s `setAController:` method, which ... |
156,256 | <p>The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generates a NullReferenceException. Is this ... | [
{
"answer_id": 156277,
"author": "Jason Anderson",
"author_id": 5142,
"author_profile": "https://Stackoverflow.com/users/5142",
"pm_score": 2,
"selected": false,
"text": "<p>Could the Test property be null by the time the LostFocus event is fired?</p>\n\n<p>Try:</p>\n\n<pre><code> pri... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The sample below has two TextBoxes. The second TextBox has a handler for the LostFocus event which calls Clear() on itself. Changing focus between the two text boxes works fine; however, if the focus is on the second text box when the window is closed, TextBox.Clear() generates a NullReferenceException. Is this a bug i... | Could the Test property be null by the time the LostFocus event is fired?
Try:
```
private void Test_LostFocus(object sender, RoutedEventArgs e)
{
if (Test != null)
Test.Clear();
}
```
**EDIT:** I'm having trouble reproducing the NullReferenceException with the code you posted. Which... |
156,257 | <p>In an AI application I am writing in C++, </p>
<ol>
<li>there is not much numerical computation </li>
<li>there are lot of structures for which run-time polymorphism is needed </li>
<li>very often, several polymorphic structures interact during computation</li>
</ol>
<p>In such a situation, are there any optimiz... | [
{
"answer_id": 156263,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 1,
"selected": false,
"text": "<p>You rarely have to worry about cache in regards to such commonly used items, since they're fetched once and kept t... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19501/"
] | In an AI application I am writing in C++,
1. there is not much numerical computation
2. there are lot of structures for which run-time polymorphism is needed
3. very often, several polymorphic structures interact during computation
In such a situation, are there any optimization techniques? While I won't care to opt... | Virtual functions are very efficient. Assuming 32 bit pointers the memory layout is approximately:
```
classptr -> [vtable:4][classdata:x]
vtable -> [first:4][second:4][third:4][fourth:4][...]
first -> [code:x]
second -> [code:x]
...
```
The classptr points to memory that is typically on the heap, occasionally on th... |
156,278 | <p>Yet again, my teacher was unable to answer my question. I knew who may be able to...</p>
<p>So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put </p>
<pre><code>setbuf( stdout , NULL );
</code></pre>
<p>at... | [
{
"answer_id": 156321,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "<p>By default, iostreams and stdio are synchronised. <a href=\"http://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdio\"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/73/"
] | Yet again, my teacher was unable to answer my question. I knew who may be able to...
So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put
```
setbuf( stdout , NULL );
```
at the top of main() in order to ge... | By default, iostreams and stdio are synchronised. [Reference.](http://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdio)
This doesn't mean that manually adjusting the stdio buffering is a good idea, though! You may wish to utilise `std::endl` or `std::flush` (from `<ostream>`), which may help you. e.g.,
```
std::... |
156,279 | <p>The title is self explanatory. Is there a way of directly doing such kind of importing?</p>
| [
{
"answer_id": 156284,
"author": "Levi Rosol",
"author_id": 23458,
"author_profile": "https://Stackoverflow.com/users/23458",
"pm_score": 2,
"selected": false,
"text": "<p>Although my MySQL background is limited, I don't think you have much luck doing that. However, you should be able to... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] | The title is self explanatory. Is there a way of directly doing such kind of importing? | The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: <http://www.fpns.net/willy/msbackup.htm>
The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.
You will need to use SQL server to extract these. SQL Server Express is free and will do the job.
So, in... |
156,280 | <p>When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this?</p>
<p>I know I can do an "hg incoming -p" to see the patch sets of changes coming in, but it'd be nice to just directly see the actual changes for a part... | [
{
"answer_id": 156340,
"author": "Lars Westergren",
"author_id": 15627,
"author_profile": "https://Stackoverflow.com/users/15627",
"pm_score": 2,
"selected": false,
"text": "<p>You could try having two repositories locally - one for incoming stuff, and one for outgoing. Then you should b... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8912/"
] | When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this?
I know I can do an "hg incoming -p" to see the patch sets of changes coming in, but it'd be nice to just directly see the actual changes for a particular file... | After some digging, I came across the [Rdiff extension](https://www.mercurial-scm.org/wiki/RdiffExtension) that does most of what I want it to.
It doesn't come with mercurial, but it can be installed by cloning the repository:
```
hg clone http://hg.kublai.com/mercurial/extensions/rdiff
```
And then modifing your ... |
156,292 | <p>I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question.</p>
<p>Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object that it's editing, but I also want to in... | [
{
"answer_id": 156305,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<p>Matt, you shouldn't mix normal parameters with dependencies. Since your object will be created in the internals of IoC contai... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/615/"
] | I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question.
Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object that it's editing, but I also want to inject the P... | I disagree with @aku's answer.
I think what you're doing is fine and there are also other ways to do it that are no more or less right. For instance, one may question whether this object should be depending on services in the first place.
Regardless of DI, I feel it is helpful to clarify in your mind at least the k... |
156,329 | <p>I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle.</p>
<pre><code>select to_char(1011,'00000000') OPE_NO from dual;
select length(to_char(1011,'00000000')) OPE_NO from dual;
</code></pre>
<p>Instead of '00001011' I get ' 00001011'.
Why do I get an extra leading blank space? Wh... | [
{
"answer_id": 156361,
"author": "VVS",
"author_id": 21038,
"author_profile": "https://Stackoverflow.com/users/21038",
"pm_score": 3,
"selected": false,
"text": "<p>From that same <a href=\"http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#SQLRF00211\" re... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3751/"
] | I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle.
```
select to_char(1011,'00000000') OPE_NO from dual;
select length(to_char(1011,'00000000')) OPE_NO from dual;
```
Instead of '00001011' I get ' 00001011'.
Why do I get an extra leading blank space? What is the correct number f... | Use FM (Fill Mode), e.g.
`select to_char(1011,'FM00000000') OPE_NO from dual;` |
156,330 | <p>I'm just trying to time a piece of code. The pseudocode looks like:</p>
<pre><code>start = get_ticks()
do_long_code()
print "It took " + (get_ticks() - start) + " seconds."
</code></pre>
<p>How does this look in Python?</p>
<p>More specifically, how do I get the number of ticks since midnight (or however Python o... | [
{
"answer_id": 156335,
"author": "blackwing",
"author_id": 9107,
"author_profile": "https://Stackoverflow.com/users/9107",
"pm_score": 5,
"selected": false,
"text": "<p>What you need is <code>time()</code> function from <code>time</code> module:</p>\n\n<pre><code>import time\nstart = tim... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/432/"
] | I'm just trying to time a piece of code. The pseudocode looks like:
```
start = get_ticks()
do_long_code()
print "It took " + (get_ticks() - start) + " seconds."
```
How does this look in Python?
More specifically, how do I get the number of ticks since midnight (or however Python organizes that timing)? | In the `time` module, there are two timing functions: `time` and `clock`. `time` gives you "wall" time, if this is what you care about.
However, the python [docs](http://docs.python.org/lib/module-time.html) say that `clock` should be used for benchmarking. Note that `clock` behaves different in separate systems:
* o... |
156,331 | <p>I was inserting data into a MS Access database using JDBC-ODBC driver. The blank mdb file was 2KB. After populating this database, the size grew to 155MB. Then I was deleting the data. But I found the size of mdb remains the same as 155MB. I don't get any errors. But is it normal this way? I would expect the ... | [
{
"answer_id": 156341,
"author": "flamingLogos",
"author_id": 8161,
"author_profile": "https://Stackoverflow.com/users/8161",
"pm_score": 4,
"selected": false,
"text": "<p>MS Access doesn't free up space used by records even after they are deleted. You can free the space manually when yo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24020/"
] | I was inserting data into a MS Access database using JDBC-ODBC driver. The blank mdb file was 2KB. After populating this database, the size grew to 155MB. Then I was deleting the data. But I found the size of mdb remains the same as 155MB. I don't get any errors. But is it normal this way? I would expect the file size ... | MS Access doesn't reclaim the space for records until you have compacted the database.
This is something you should do to an access database as part of your regularly maintenance otherwise you will end up with some pretty painful problems.
You can compact a database either through the MS Access UI (Tools -> Database ... |
156,360 | <p>I have one thread that writes results into a Queue.</p>
<p>In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this:</p>
<pre><code>def queue_get_all(q):
items = []
while 1:
try:
items.append(q.get_nowait())
except Empty, e:
... | [
{
"answer_id": 156416,
"author": "fuentesjr",
"author_id": 10708,
"author_profile": "https://Stackoverflow.com/users/10708",
"pm_score": 1,
"selected": false,
"text": "<p>I see you are using get_nowait() which according to the documentation, \"return[s] an item if one is immediately avai... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | I have one thread that writes results into a Queue.
In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this:
```
def queue_get_all(q):
items = []
while 1:
try:
items.append(q.get_nowait())
except Empty, e:
break
... | I'd be very surprised if the `get_nowait()` call caused the pause by not returning if the list was empty.
Could it be that you're posting a large number of (maybe big?) items between checks which means the receiving thread has a large amount of data to pull out of the `Queue`? You could try limiting the number you ret... |
156,362 | <p>Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. </p>
<ul>
<li><strong>include</strong>: mixes in specified module methods as <strong>instance methods</strong> in the target class</li>
<li><strong>extend</strong>: mixes in specified module methods as <strong>class met... | [
{
"answer_id": 156659,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 4,
"selected": false,
"text": "<p>That's correct.</p>\n\n<p>Behind the scenes, include is actually an alias for <strong>append_features</strong>, which... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me.
* **include**: mixes in specified module methods as **instance methods** in the target class
* **extend**: mixes in specified module methods as **class methods** in the target class
*So is the major difference just this ... | What you have said is correct. However, there is more to it than that.
If you have a class `Klazz` and module `Mod`, including `Mod` in `Klazz` gives instances of `Klazz` access to `Mod`'s methods. Or you can extend `Klazz` with `Mod` giving the *class* `Klazz` access to `Mod`'s methods. But you can also extend an arb... |
156,369 | <p>It seems quite a few mainstream languages support <a href="http://en.wikipedia.org/wiki/First-class_function" rel="noreferrer">function literals</a> these days. They are also called <a href="http://en.wikipedia.org/wiki/Anonymous_function" rel="noreferrer">anonymous functions</a>, but I don't care if they have a nam... | [
{
"answer_id": 156371,
"author": "Torbjörn Gyllebring",
"author_id": 21182,
"author_profile": "https://Stackoverflow.com/users/21182",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://research.microsoft.com/fsharp/\" rel=\"nofollow noreferrer\">F#</a> has \"let rec\"</p>\n"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15069/"
] | It seems quite a few mainstream languages support [function literals](http://en.wikipedia.org/wiki/First-class_function) these days. They are also called [anonymous functions](http://en.wikipedia.org/wiki/Anonymous_function), but I don't care if they have a name. The important thing is that a function literal is an exp... | Most languages support it through use of the [Y combinator](http://en.wikipedia.org/wiki/Fixed_point_combinator#Y_combinator). Here's an example in Python (from the [cookbook](http://code.activestate.com/recipes/576366/)):
```
# Define Y combinator...come on Gudio, put it in functools!
Y = lambda g: (lambda f: g(lambd... |
156,373 | <p>I'm storing an object (<code>TTF_Font</code>) in a <code>shared_ptr</code> that is provided to me from a third-party API. I cannot use new or delete on the object, so the <code>shared_ptr</code> is also provided a "freeing" functor.</p>
<pre><code>// Functor
struct CloseFont
{
void operator()(TTF_Font* font) co... | [
{
"answer_id": 156382,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 5,
"selected": true,
"text": "<p>shared_ptr<>::reset() will drop the refcount by one. If that results in the count dropping to zero, the resourc... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18265/"
] | I'm storing an object (`TTF_Font`) in a `shared_ptr` that is provided to me from a third-party API. I cannot use new or delete on the object, so the `shared_ptr` is also provided a "freeing" functor.
```
// Functor
struct CloseFont
{
void operator()(TTF_Font* font) const
{
if(font != NULL) {
... | shared\_ptr<>::reset() will drop the refcount by one. If that results in the count dropping to zero, the resource pointed to by the shared\_ptr<> will be freed.
So I think the answer for you is, yes that will work. Or you can simply let the screenFont variable be destructed due to dropping out of scope or whatever, if... |
156,394 | <p>How is it that Ruby allows a class access methods outside of the class implicitly?</p>
<p>Example:</p>
<pre><code>class Candy
def land
homer
end
end
def homer
puts "Hello"
end
Candy.new.land #Outputs Hello
</code></pre>
| [
{
"answer_id": 156408,
"author": "janm",
"author_id": 7256,
"author_profile": "https://Stackoverflow.com/users/7256",
"pm_score": 6,
"selected": true,
"text": "<p>The definition of the \"homer\" method is adding the method to the Object class. It is not defining a free function.</p>\n\n... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How is it that Ruby allows a class access methods outside of the class implicitly?
Example:
```
class Candy
def land
homer
end
end
def homer
puts "Hello"
end
Candy.new.land #Outputs Hello
``` | The definition of the "homer" method is adding the method to the Object class. It is not defining a free function.
Class Candy implicitly inherits from Object, and so has access to the methods in Object. When you call "homer" in the "land" method, the method resolution can't find a definition in the current class, goe... |
156,395 | <p>As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what "<em>sending a message to nil</em>" means - let alone how it is actually useful. Taking an excerpt from the documentation:</p>
<blockquote>
<p>There are several patterns in Cocoa
that take advantage of this fact. The
valu... | [
{
"answer_id": 156415,
"author": "Rich",
"author_id": 22003,
"author_profile": "https://Stackoverflow.com/users/22003",
"pm_score": 4,
"selected": false,
"text": "<p>What it means is that the runtime doesn't produce an error when objc_msgSend is called on the nil pointer; instead it retu... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9931/"
] | As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what "*sending a message to nil*" means - let alone how it is actually useful. Taking an excerpt from the documentation:
>
> There are several patterns in Cocoa
> that take advantage of this fact. The
> value returned from a message ... | Well, I think it can be described using a very contrived example. Let's say you have a method in Java which prints out all of the elements in an ArrayList:
```
void foo(ArrayList list)
{
for(int i = 0; i < list.size(); ++i){
System.out.println(list.get(i).toString());
}
}
```
Now, if you call that me... |
156,412 | <p><code>GWT</code> gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie <code>en_US</code>) locale.</p>
<p>Why doesn't it get it from the browser settings?</p>
<p>It seems the only solution to this is to replace your static html launch page with... | [
{
"answer_id": 161313,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 2,
"selected": false,
"text": "<p>If you put a list of available languages into your *.gwt.xml file it will by default switch to the first language listed.</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | `GWT` gets locale from either the locale property or the locale query string. If neither is specified, it uses the "default" (ie `en_US`) locale.
Why doesn't it get it from the browser settings?
It seems the only solution to this is to replace your static html launch page with something like a JSP that reads the brow... | You can also put this switch in your \*.gwt.xml
```
<set-configuration-property name="locale.useragent" value="Y"/>
```
this will add language selecting based on language selected in browser. You can also control search order for locale by setting
```
<set-configuration-property name="locale.searchorder" value="q... |
156,436 | <p>It's quite a simple question - how do I sort a collection?</p>
<p>I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary?</p>
<p>I've clearly been spoilt with .NET and Linq, and now I f... | [
{
"answer_id": 156485,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 0,
"selected": false,
"text": "<p>It's been a long time for me too. IIRC you don't have an option out of the box.</p>\n\n<p>If I were you I'd put all the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5744/"
] | It's quite a simple question - how do I sort a collection?
I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary?
I've clearly been spoilt with .NET and Linq, and now I find myself back i... | In this case I would get help from big brother .net. It's possible to use **System.Collections.Sortedlist** within your ASP app and get your key value pairs sorted.
```
set list = server.createObject("System.Collections.Sortedlist")
with list
.add "something", "YY"
.add "something else", "XX"
end with
for i = 0 ... |
156,467 | <p>I've been looking at F# recently, and while I'm not likely to leap the fence any time soon, it definitely highlights some areas where C# (or library support) could make life easier.</p>
<p>In particular, I'm thinking about the pattern matching capability of F#, which allows a very rich syntax - much more expressive... | [
{
"answer_id": 156535,
"author": "Simon Buchan",
"author_id": 20135,
"author_profile": "https://Stackoverflow.com/users/20135",
"pm_score": 2,
"selected": false,
"text": "<p>Although it's not very 'C-sharpey' to switch on type, I know that construct would be pretty helpful in general use... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23354/"
] | I've been looking at F# recently, and while I'm not likely to leap the fence any time soon, it definitely highlights some areas where C# (or library support) could make life easier.
In particular, I'm thinking about the pattern matching capability of F#, which allows a very rich syntax - much more expressive than the ... | In C# 7, you can do:
```
switch(shape)
{
case Circle c:
WriteLine($"circle with radius {c.Radius}");
break;
case Rectangle s when (s.Length == s.Height):
WriteLine($"{s.Length} x {s.Height} square");
break;
case Rectangle r:
WriteLine($"{r.Length} x {r.Height} rectan... |
156,478 | <p>I'm implementing a cache in a class library that i'm using in an asp.net application. </p>
<p>I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variable/property with a collection of data i need cached (got some locking logic ofcourse). I... | [
{
"answer_id": 156481,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 1,
"selected": false,
"text": "<p>The data wouldn't get garbage collected as long as the cache still holds a reference to it.</p>\n\n<p>Also, don'... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] | I'm implementing a cache in a class library that i'm using in an asp.net application.
I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variable/property with a collection of data i need cached (got some locking logic ofcourse). I figured i... | In my opinion, the best solution would have the following characteristics:
* Uses the available caching services provided by the platform trying to avoid writing your own.
* Does not couple your class library to System.Web, in order to have the layers coherent.
* But if the class library is running inside an ASP.NET a... |
156,492 | <p>I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things:</p>
<ul>
<li><strong>share the... | [
{
"answer_id": 161777,
"author": "JG.",
"author_id": 7807,
"author_profile": "https://Stackoverflow.com/users/7807",
"pm_score": 2,
"selected": false,
"text": "<p>Okay - since I misunderstood your question initially I've deleted my previous answer as to not cause any further confusion.</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18771/"
] | I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things:
* **share the CFC between applica... | I understand your desire to avoid passing in the actual scope structure that you want to cache to, but your alternatives are limited. The first thing that comes to mind is just passing the name (a string) of the scope you want your cache stored in, and evaluating. By its nature, evaluation is inefficient and should be ... |
156,503 | <p>How can I use JUnit idiomatically to test that some code throws an exception?</p>
<p>While I can certainly do something like this:</p>
<pre><code>@Test
public void testFooThrowsIndexOutOfBoundsException() {
boolean thrown = false;
try {
foo.doStuff();
} catch (IndexOutOfBoundsException e) {
thrown = t... | [
{
"answer_id": 156515,
"author": "Johan",
"author_id": 11347,
"author_profile": "https://Stackoverflow.com/users/11347",
"pm_score": 5,
"selected": false,
"text": "<p>How about this: catch a very general exception, make sure it makes it out of the catch block, then assert that the class ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] | How can I use JUnit idiomatically to test that some code throws an exception?
While I can certainly do something like this:
```
@Test
public void testFooThrowsIndexOutOfBoundsException() {
boolean thrown = false;
try {
foo.doStuff();
} catch (IndexOutOfBoundsException e) {
thrown = true;
}
assertT... | It depends on the JUnit version and what assert libraries you use.
* For JUnit5 and 4.13 [see answer](https://stackoverflow.com/a/2935935/2986984)
* If you use AssertJ or google-truth, [see answer](https://stackoverflow.com/a/41019785/2986984)
The original answer for `JUnit <= 4.12` was:
```java
@Test(expected =... |
156,504 | <p>I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this:</p>
<pre><code>lines = open('filename.py').readlines()
</code></pre>
<p>How to find the line number, where the doc... | [
{
"answer_id": 156513,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": true,
"text": "<p>If you're using the standard docstring format, you can do something like this:</p>\n\n<pre><code>count = 0\nfor line... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/985/"
] | I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this:
```
lines = open('filename.py').readlines()
```
How to find the line number, where the docstring ends? | If you're using the standard docstring format, you can do something like this:
```
count = 0
for line in lines:
if line.startswith ('"""'):
count += 1
if count < 3:
# Before or during end of the docstring
continue
# Line is after docstring
```
Might need some adaptatio... |
156,508 | <p>Alright, I have been doing the following (variable names have been changed):</p>
<pre><code>
FileInputStream fis = null;
try
{
fis = new FileInputStream(file);
... process ...
}
catch (IOException e)
{
... handle error ...
}
finally
{
if (fis != null)
fis.close();
}
</code>
</pre>
<p>Rece... | [
{
"answer_id": 156520,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 5,
"selected": false,
"text": "<p>Something like the following should do it, up to you whether you throw or swallow the IOException on attempting to ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18049/"
] | Alright, I have been doing the following (variable names have been changed):
```
FileInputStream fis = null;
try
{
fis = new FileInputStream(file);
... process ...
}
catch (IOException e)
{
... handle error ...
}
finally
{
if (fis != null)
fis.close();
}
```
Recently, I started using FindB... | For Java 7 and above [try-with-resources](http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html) should be used:
```
try (InputStream in = new FileInputStream(file)) {
// TODO: work
} catch (IOException e) {
// TODO: handle error
}
```
If you're stuck on Java 6 or below...
This patte... |
156,514 | <p>I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the <code>HttpURLConnection</code> object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as:</p>
<pre><code>Set-Cookie: foo=foo; Path=/
Set-Cookie: bar=bar; Path=/
</code></pre>
<p>Th... | [
{
"answer_id": 156574,
"author": "Olaf Kock",
"author_id": 13447,
"author_profile": "https://Stackoverflow.com/users/13447",
"pm_score": 0,
"selected": false,
"text": "<p>Without actually having tried it (can't remember to have handled that topic myself), there's also getHeaderFields, in... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304/"
] | I am debugging some code in the Selenium-rc proxy server. It seems the culprit is the `HttpURLConnection` object, whose interface for getting at the HTTP headers does not cope with duplicate header names, such as:
```
Set-Cookie: foo=foo; Path=/
Set-Cookie: bar=bar; Path=/
```
The way of getting at the headers throu... | My recommended workaround is to not use HttpUtilConnection at all, which is crude and unintuitive, but use commons-httpclient instead.
<http://hc.apache.org/httpclient-3.x/> |
156,532 | <p>I need to import largish (24MB) text files into a MySQL table. Each line looks like this:</p>
<pre><code>1 1 0.008 0 0 0 0 0
</code></pre>
<p>There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline.</p>
<p>How do I ... | [
{
"answer_id": 156550,
"author": "Jauco",
"author_id": 6874,
"author_profile": "https://Stackoverflow.com/users/6874",
"pm_score": 4,
"selected": true,
"text": "<p>If you're on unix/linux then you can put it through sed.</p>\n\n<p>open a terminal and type:</p>\n\n<pre><code>sed 's/ \\+/ ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] | I need to import largish (24MB) text files into a MySQL table. Each line looks like this:
```
1 1 0.008 0 0 0 0 0
```
There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline.
How do I import such a file into MySQL? Fr... | If you're on unix/linux then you can put it through sed.
open a terminal and type:
```
sed 's/ \+/ /g' thefile > thefile.new
```
this replaces all sequences of multiple spaces with one space. |
156,563 | <p>How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it o... | [
{
"answer_id": 156583,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 0,
"selected": false,
"text": "<p>You'll have to have .NET 2.0 installed on the machine, all the VS tool is is a GUI wrapper for a command line tool... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17176/"
] | How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it on a... | I solved this problem by setting up a default super user at application start up.
By adding this to gobal.asax
```
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
// check that the minimal security settings are created
Security.SetupSecu... |
156,582 | <p>I started using <a href="http://www.codeplex.com/SHFB" rel="noreferrer">Sandcastle</a> some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely separate docum... | [
{
"answer_id": 156682,
"author": "Davy Landman",
"author_id": 11098,
"author_profile": "https://Stackoverflow.com/users/11098",
"pm_score": 4,
"selected": false,
"text": "<p>If you use <a href=\"http://www.codeplex.com/SHFB\" rel=\"noreferrer\">Sandcastle Help File Builder</a> there is a... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5005/"
] | I started using [Sandcastle](http://www.codeplex.com/SHFB) some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely separate documentation for the overall projec... | Sandcastle also supports the ndoc-style namespace documentation, which allows you to stick the documentation in the source files:
Simply create a non-public class called NamespaceDoc in the namespace you want to document, and the xml doc comment for that class will be used for the namespace.
Adorn it with a [Compile... |
156,584 | <p>I've seen a few examples on how to do build deployment, however I have something unique that I'd like to do:</p>
<ol>
<li>Deploy the build to a folder that has the build number (eg. Project\Builds\8423)</li>
<li>Alter the version number in the .NET AssmblyInfo.cs to match the build number</li>
</ol>
<p>Has anyone ... | [
{
"answer_id": 156612,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>i haven't done it with nant, but we have written a custom application in C# that reads the assembly and increments the rel... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17222/"
] | I've seen a few examples on how to do build deployment, however I have something unique that I'd like to do:
1. Deploy the build to a folder that has the build number (eg. Project\Builds\8423)
2. Alter the version number in the .NET AssmblyInfo.cs to match the build number
Has anyone done this before with .NET projec... | Deploying a build to a folder with the build number is pretty straightforward. [CruiseControl.NET's NAnt task](http://confluence.public.thoughtworks.org/display/CCNET/NAnt+Task) automatically passes a number of properties to your NAnt script. The *CCNetLabel* property is the one you'd use to create your deployment dire... |
156,585 | <p>I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty.</p>
<p>Currently I'm doing something like this:</p>
<pre><code>IPHostEntry hostEntry = Dns.GetHostEntry("some.hostname.tld");
if (hostEntry.AddressList.Count() < 1)
{
// c... | [
{
"answer_id": 156598,
"author": "user17222",
"author_id": 17222,
"author_profile": "https://Stackoverflow.com/users/17222",
"pm_score": 0,
"selected": false,
"text": "<p>You have three possible situations here:</p>\n\n<ol>\n<li><p>The hostname exists (DNS has an A Record) and resolves t... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21038/"
] | I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty.
Currently I'm doing something like this:
```
IPHostEntry hostEntry = Dns.GetHostEntry("some.hostname.tld");
if (hostEntry.AddressList.Count() < 1)
{
// can that ever happen?
t... | No, you'll not see an empty address list: even if you query a DNS label that does exist, but has no A or AAAA (IPv6) records, a SocketException ("No Such Host is Known") will be thrown.
You can verify this by looking at the function `InternalGetHostByName(string hostName, bool includeIPv6)` in DNS.cs from the .NET Ref... |
156,610 | <p>I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. </p>
<p>Does anyone know of a straightforward and practical way of bundling string resources in different ... | [
{
"answer_id": 156631,
"author": "Nadav",
"author_id": 23094,
"author_profile": "https://Stackoverflow.com/users/23094",
"pm_score": 0,
"selected": false,
"text": "<p>We use Flex for the client part of our application and support I18N via <a href=\"http://livedocs.adobe.com/flex/201/html... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24039/"
] | I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong.
Does anyone know of a straightforward and practical way of bundling string resources in different languages an... | I guess you know the basics of how to localize a Flex application, but if you would like to know more there's a good and thorough description here: [Runtime Localization](http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Runtime_Localization).
In Flex 3 you have three options on how to solve your prob... |
156,641 | <p>I have a table of users which has a username column consisting of a six digit number e.g 675381, I need to prepend a zero to each of these usernames e.g. 0675381 would be the final output of the previous example, is there a query that could handle this?</p>
| [
{
"answer_id": 156656,
"author": "daniels",
"author_id": 9789,
"author_profile": "https://Stackoverflow.com/users/9789",
"pm_score": 6,
"selected": true,
"text": "<pre><code>UPDATE Tablename SET Username = Concat('0', Username);\n</code></pre>\n"
},
{
"answer_id": 156657,
"au... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13658/"
] | I have a table of users which has a username column consisting of a six digit number e.g 675381, I need to prepend a zero to each of these usernames e.g. 0675381 would be the final output of the previous example, is there a query that could handle this? | ```
UPDATE Tablename SET Username = Concat('0', Username);
``` |
156,650 | <p>When reviewing, I sometimes encounter this kind of loop:</p>
<pre><code>i = begin
while ( i != end ) {
// ... do stuff
if ( i == end-1 (the one-but-last element) ) {
... do other stuff
}
increment i
}
</code></pre>
<p>Then I ask the question: would you write this?</p>
<pre><code>i = begin
mi... | [
{
"answer_id": 156660,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 2,
"selected": false,
"text": "<p>Of course, special-casing things in a loop which can be pulled out is silly. I wouldn't duplicate the do_stuff ei... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6610/"
] | When reviewing, I sometimes encounter this kind of loop:
```
i = begin
while ( i != end ) {
// ... do stuff
if ( i == end-1 (the one-but-last element) ) {
... do other stuff
}
increment i
}
```
Then I ask the question: would you write this?
```
i = begin
mid = ( end - begin ) / 2 // (the middl... | @xtofl,
I agree with your concern.
Million times I encountered similar problem.
Either developer adds special handling for first or for last element.
In most cases it is worth to just loop from **startIdx + 1** or to **endIdx - 1** element or even split one long loop into multiple shorter loops.
In a very rare ... |
156,683 | <p>I would like to know what of the many XSLT engines out there works well with Perl.</p>
<p>I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs.</p>
<p>I'm new to this kind of projects so any comment or suggestion will be welcome.</p>
<p>Thanks.</p>
<hr>
<p>Doing a simple search on Google I fou... | [
{
"answer_id": 156692,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>Can't really say which is the best solution because I didn't have a chance to try them all.<br>\nBut I can recommend you to t... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19689/"
] | I would like to know what of the many XSLT engines out there works well with Perl.
I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs.
I'm new to this kind of projects so any comment or suggestion will be welcome.
Thanks.
---
Doing a simple search on Google I found a lot and I suppose that ther... | First mistake - [search on CPAN](http://search.cpan.org/search?query=XSLT&mode=all), not Google :)
This throws up a bunch of results, but does rather highlight the problem of CPAN, that there's more than one solution, and it's not always clear which ones work, have been abandoned, are broken, slow or whatever.
And di... |
156,686 | <p>How do I initialize an automatic download of a file in Internet Explorer?</p>
<p>For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically .... etc". The download should begin shortly after the page loads.</p>
<p>In Firefox this is easy, you j... | [
{
"answer_id": 156703,
"author": "ullmark",
"author_id": 23044,
"author_profile": "https://Stackoverflow.com/users/23044",
"pm_score": 5,
"selected": false,
"text": "<p>I recently solved it by placing the following script on the page. </p>\n\n<pre><code>setTimeout(function () { window.lo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4685/"
] | How do I initialize an automatic download of a file in Internet Explorer?
For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically .... etc". The download should begin shortly after the page loads.
In Firefox this is easy, you just need to inclu... | [SourceForge](http://en.wikipedia.org/wiki/SourceForge) uses an `<iframe>` element with the `src=""` attribute pointing to the file to download.
```
<iframe width="1" height="1" frameborder="0" src="[File location]"></iframe>
```
(Side effect: no redirect, no JavaScript, original URL remains unchanged.) |
156,688 | <p>I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflect this.</p>
<p>Is there a way a can check the data integruity by performing a select stat... | [
{
"answer_id": 156703,
"author": "ullmark",
"author_id": 23044,
"author_profile": "https://Stackoverflow.com/users/23044",
"pm_score": 5,
"selected": false,
"text": "<p>I recently solved it by placing the following script on the page. </p>\n\n<pre><code>setTimeout(function () { window.lo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5055/"
] | I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflect this.
Is there a way a can check the data integruity by performing a select statement on t... | [SourceForge](http://en.wikipedia.org/wiki/SourceForge) uses an `<iframe>` element with the `src=""` attribute pointing to the file to download.
```
<iframe width="1" height="1" frameborder="0" src="[File location]"></iframe>
```
(Side effect: no redirect, no JavaScript, original URL remains unchanged.) |
156,689 | <p>Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks?</p>
<p>Example:</p>
<pre><code>@MappedSuperclass()
public class BaseEntity {
private Long id;
private Long version;
...
@Id @GeneratedValue(strate... | [
{
"answer_id": 156986,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 4,
"selected": true,
"text": "<p>This works fine for us. As well as the ID and creation date, we also have a modified date. We also have an intermedia... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18722/"
] | Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks?
Example:
```
@MappedSuperclass()
public class BaseEntity {
private Long id;
private Long version;
...
@Id @GeneratedValue(strategy = GenerationType.A... | This works fine for us. As well as the ID and creation date, we also have a modified date. We also have an intermediate *TaggedBaseEntity* that implements a *Taggable* interface, because some of our web application's entities have tags, like questions on Stack Overflow. |
156,697 | <p>In my environment here I use Java to serialize the result set to XML.
It happens basically like this:</p>
<pre><code>//foreach column of each row
xmlHandler.startElement(uri, lname, "column", attributes);
String chars = rs.getString(i);
xmlHandler.characters(chars.toCharArray(), 0, chars.length());
xmlHandler.endEl... | [
{
"answer_id": 156741,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.w3.org/TR/REC-xml/#syntax\" rel=\"nofollow noreferrer\">Extensible Markup Language (XML) 1.0</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21027/"
] | In my environment here I use Java to serialize the result set to XML.
It happens basically like this:
```
//foreach column of each row
xmlHandler.startElement(uri, lname, "column", attributes);
String chars = rs.getString(i);
xmlHandler.characters(chars.toCharArray(), 0, chars.length());
xmlHandler.endElement(uri, lna... | I found an interesting list in the [Xml Spec](http://www.w3.org/TR/2006/REC-xml11-20060816/#charsets):
According to that List its discouraged to use the Character #26 (Hex: *#x1A*).
>
> The characters defined in the
> following ranges are also discouraged.
> They are either control characters or
> permanently unde... |
156,724 | <p>I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in :) Here's an excerpt of the stack trace:</p>
<pre><code>Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.PresenceHome.customerId to java.la... | [
{
"answer_id": 157090,
"author": "Chobicus",
"author_id": 1514822,
"author_profile": "https://Stackoverflow.com/users/1514822",
"pm_score": 0,
"selected": false,
"text": "<p>try:\n...\n<code><f:param name=\"customerId\" value=\"#{customerId.toString()}\" /></code>\n...</p>\n"
},
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1900/"
] | I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in :) Here's an excerpt of the stack trace:
```
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.PresenceHome.customerId to java.lang.String
```
... | You want to add a converter to your pages.xml file. Like this:
```
<param name="customerId"
value="#{presenceHome.customerId}"
converterId="javax.faces.Long" />
```
See the seampay example provided with seam for more details. |
156,748 | <p>How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site?</p>
<p>Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at:</p>
<p><a href="http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/" rel="noreferrer">http://blog.codev... | [
{
"answer_id": 156952,
"author": "David Laing",
"author_id": 13238,
"author_profile": "https://Stackoverflow.com/users/13238",
"pm_score": 2,
"selected": false,
"text": "<p>Some ActionLink extensions: <a href=\"http://www.squaredroot.com/post/2008/06/11/MVC-and-SSL.aspx\" rel=\"nofollow ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13238/"
] | How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site?
Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at:
<http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/>
Is there a better / updated way with Preview 5?, | If you are using [ASP.NET MVC 2 Preview 2 or higher](http://blogs.teamb.com/craigstuntz/2009/10/05/38476/), you can now simply use:
```
[RequireHttps]
public ActionResult Login()
{
return View();
}
```
Though, the order parameter is worth noting, as [mentioned here](http://bartwullems.blogspot.com/2010/01/using-s... |
156,767 | <p>When verbally talking about methods, I'm never sure whether to use the word <em>argument</em> or <em>parameter</em> or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms?</p>
<p>I'm a C# programmer, but I also wonder whether people use different ter... | [
{
"answer_id": 156778,
"author": "Rinat Abdullin",
"author_id": 47366,
"author_profile": "https://Stackoverflow.com/users/47366",
"pm_score": 9,
"selected": false,
"text": "<p><strong>Parameter</strong> is the variable in the declaration of the function.</p>\n<p><strong>Argument</strong>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5351/"
] | When verbally talking about methods, I'm never sure whether to use the word *argument* or *parameter* or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms?
I'm a C# programmer, but I also wonder whether people use different terms in different language... | A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters.
```
public void MyMethod(string myParam) { }
...
string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);
``` |
156,777 | <p>This is a followup question of <a href="https://stackoverflow.com/questions/156697/how-to-encode-characters-from-oracle-to-xml">How to encode characters from Oracle to Xml?</a></p>
<p>In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xm... | [
{
"answer_id": 157635,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https://Stackoverflow.com/users/2204759",
"pm_score": 4,
"selected": true,
"text": "<p>It is getting escaped because the handler.characters function is designed to escape and the <code><![CDATA[</code> p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21027/"
] | This is a followup question of [How to encode characters from Oracle to Xml?](https://stackoverflow.com/questions/156697/how-to-encode-characters-from-oracle-to-xml)
In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler.... | It is getting escaped because the handler.characters function is designed to escape and the `<![CDATA[` part isn't considered part of the value.
You need to use the newly exposed methods in `DefaultHandler2` or use the `TransformerHandler` approach where you can set the output key `CDATA_SECTION_ELEMENTS`, which takes... |
156,779 | <p>I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method:</p>
<pre><code>public static T GetItem<T>(string key, Func<T> defaultValue)
{
if (HttpContext.Current.Session[key] == null)
{
Ht... | [
{
"answer_id": 156789,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>Why don't you pass the default value directly? What use is the functor?</p>\n\n<p>By the way, <code>defaultValue.I... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method:
```
public static T GetItem<T>(string key, Func<T> defaultValue)
{
if (HttpContext.Current.Session[key] == null)
{
HttpContext.Current.Session[k... | Since that is a func, a lambda would be the simplest way:
```
Foo foo = GetItem<Foo>("abc", () => new Foo("blah"));
```
Where [new Foo("blah")] is the func that is invoked as a default.
You could also simplify to:
```
return ((T)HttpContext.Current.Session[key]) ?? defaultValue();
```
Where ?? is the null-coale... |
156,800 | <p>I have created a nice silverlight control doing exactly what I want it to do, and it looks great :) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely.</p>
<p>I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The problem I'm havi... | [
{
"answer_id": 158377,
"author": "Adam Kinney",
"author_id": 1973,
"author_profile": "https://Stackoverflow.com/users/1973",
"pm_score": 0,
"selected": false,
"text": "<p>CSS issues can be difficult to debug sometimes. Is the behavior the same in different browsers? Is your CSS using \... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22621/"
] | I have created a nice silverlight control doing exactly what I want it to do, and it looks great :) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely.
I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The problem I'm having is that... | Found the cause myself...
It turns out Silverlight has a display problem when the control is placed in a html table. [Found information about this on the silverlight forum](http://silverlight.net/forums/p/20863/72280.aspx). It was about the beta 2, but I have upgraded to the release version, and it's still a problem.
... |
156,810 | <p>What is the best way to download files to local hard drive when logged in to another computer using ssh in bash. I'm aware of sftp, but it is not convienent, e.g. it lacks tab completion of directory names. I'm using Ubuntu 8.04.1 . I don't have a public IP and would not like to setup dynamic Dynamic DNS solution.</... | [
{
"answer_id": 156822,
"author": "Ronny Brendel",
"author_id": 14114,
"author_profile": "https://Stackoverflow.com/users/14114",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know.</p>\n\n<p>I'd $ scp host:file locallocation</p>\n"
},
{
"answer_id": 156850,
"author": ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11439/"
] | What is the best way to download files to local hard drive when logged in to another computer using ssh in bash. I'm aware of sftp, but it is not convienent, e.g. it lacks tab completion of directory names. I'm using Ubuntu 8.04.1 . I don't have a public IP and would not like to setup dynamic Dynamic DNS solution. | I'm also running Ubuntu 8.04.1, and if I type
```
$ scp me@myserver.mydomain.com:.bashr<TAB>
```
I do indeed get tab completion (i.e. bash is sshing to my server and getting completion results from the filesystem there). Then
```
$ scp me@myserver.mydomain.com:.bashrc .
```
copies my .bashrc from my server to the... |
156,815 | <p>In a <a href="https://stackoverflow.com/questions/9033#9099">question answer</a> I find the following coding tip:-</p>
<p>2) simple lambdas with one parameter:</p>
<pre><code>x => x.ToString() //simplify so many calls
</code></pre>
<p>As someone who has not yet used 3.0 I don't really understand this tip but i... | [
{
"answer_id": 156823,
"author": "Jacob",
"author_id": 22107,
"author_profile": "https://Stackoverflow.com/users/22107",
"pm_score": 2,
"selected": false,
"text": "<p>This basically expands to:</p>\n\n<pre><code>private string Lambda(object x) {\n return x.ToString();\n}\n</code></pre>\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22284/"
] | In a [question answer](https://stackoverflow.com/questions/9033#9099) I find the following coding tip:-
2) simple lambdas with one parameter:
```
x => x.ToString() //simplify so many calls
```
As someone who has not yet used 3.0 I don't really understand this tip but it looks interesting so I would appreciate an ex... | When you need to create an instance of a delegate which has a single parameter, lambda expressions allow you to create that delegate "inline" in a very concise manner. For instance, here's code to find a particular person in a list, by their name:
```
List<Person> list = new List<Person>();
// [..] Populate list here
... |
156,833 | <p>I need to consume a wcf service dynamically when all i know is its URL. I do not have the option of creating a service reference or web reference as my client side code picks up the URL from a config file. What classes and methods can i use from the System.ServiceModel namespace for doing so.</p>
| [
{
"answer_id": 156848,
"author": "Rinat Abdullin",
"author_id": 47366,
"author_profile": "https://Stackoverflow.com/users/47366",
"pm_score": 1,
"selected": false,
"text": "<p>If you know the contract then you can do something like:</p>\n\n<pre><code>using (WebChannelFactory<IService&... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16439/"
] | I need to consume a wcf service dynamically when all i know is its URL. I do not have the option of creating a service reference or web reference as my client side code picks up the URL from a config file. What classes and methods can i use from the System.ServiceModel namespace for doing so. | If you don't have the service interface, you must, at the very least, have an idea as to what the messages the server expects look like; otherwise it be pretty hard to do :)
But there is certainly a way to do that. You can start by creating the raw message the server expects as input, and create it in a Message object... |
156,835 | <p>I have inherited some code for a custom CMS that is a little out of my league and keep stumbling over the same errors, Notice: Undefined variable: media in /Applications/MAMP/htdocs/Chapman/Chapman_cms/admin/team-2.php on line 48. This is supposed to create new users and edit old users. However, it does not work whe... | [
{
"answer_id": 156841,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 1,
"selected": false,
"text": "<p>The notice is irrelevant, but this code doesn't create anything. That happens on the page it is submitted to.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have inherited some code for a custom CMS that is a little out of my league and keep stumbling over the same errors, Notice: Undefined variable: media in /Applications/MAMP/htdocs/Chapman/Chapman\_cms/admin/team-2.php on line 48. This is supposed to create new users and edit old users. However, it does not work when ... | To remove the notice in the right way is to do this with the code
```
<?php if(isset($media['copy'])){ echo $media['copy']; } ?>
``` |
156,852 | <p>Ok, here's one for the Java/JavaScript gurus:</p>
<p>In my app, one of the controllers passes a TreeMap to it's JSP. This map has car manufacturer's names as keys and Lists of Car objects as values. These Car objects are simple beans containing the car's name, id, year of production etc.
So, the map looks something... | [
{
"answer_id": 156865,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Are you using Struts?</p>\n\n<p>You will need some JavaScript trickery (or AJAX) to accomplish this.</p>\n\n<p>What you'd n... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19911/"
] | Ok, here's one for the Java/JavaScript gurus:
In my app, one of the controllers passes a TreeMap to it's JSP. This map has car manufacturer's names as keys and Lists of Car objects as values. These Car objects are simple beans containing the car's name, id, year of production etc.
So, the map looks something like this... | Well anyway, as i said, i finally managed to do it by myself, so here's my answer...
I receive the map from my controller like this (I'm using Spring, don't know how this works with other frameworks):
```
<c:set var="manufacturersAndModels" scope="page" value="${MANUFACTURERS_AND_MODELS_MAP}"/>
```
These are my co... |
156,873 | <p>I'm writing a shell for a project of mine, which by design parses commands that looks like this:</p>
<p>COMMAND_NAME ARG1="Long Value" ARG2=123 ARG3=me@me.com</p>
<p>My problem is that Python's command line parsing libraries (getopt and optparse) forces me to use '-' or '--' in front of the arguments. This behavio... | [
{
"answer_id": 156901,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 0,
"selected": false,
"text": "<p>Without fairly intensive surgery on optparse or getopt, I don't believe you can sensibly make them parse your fo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9941/"
] | I'm writing a shell for a project of mine, which by design parses commands that looks like this:
COMMAND\_NAME ARG1="Long Value" ARG2=123 ARG3=me@me.com
My problem is that Python's command line parsing libraries (getopt and optparse) forces me to use '-' or '--' in front of the arguments. This behavior doesn't match ... | You could split them up with shlex.split(), which can handle the quoted values you have, and pretty easily parse this with a very simple regular expression. Or, you can just use regular expressions for both splitting and parsing. Or simply use split().
```
args = {}
for arg in shlex.split(cmdln_args):
key, value =... |
156,913 | <p><strong>Concrete use case:</strong>
In the Eclipse IDE, new 'plugins' can be added by copying a plugin's file(s) into the <code>$ECLIPSE_HOME/plugins</code> directory. However, I want to keep my original Eclipse installation 'clean' without additional plugins because I want to run this basic installation on its own ... | [
{
"answer_id": 157180,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 1,
"selected": false,
"text": "<p>Have a look at <strong><a href=\"http://www.ibm.com/developerworks/library/os-ecl-manage/\" rel=\"nofollow noreferrer\">Mana... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **Concrete use case:**
In the Eclipse IDE, new 'plugins' can be added by copying a plugin's file(s) into the `$ECLIPSE_HOME/plugins` directory. However, I want to keep my original Eclipse installation 'clean' without additional plugins because I want to run this basic installation on its own at times.
What is a way o... | You could use an overlay filesystem for this. The three overlay filesystems that I know of in Linux are [unionfs](http://en.wikipedia.org/wiki/UnionFS), [aufs](http://aufs.sourceforge.net/), and [minifo](http://www.denx.de/wiki/Know.MiniFOHome).
Unionfs is included in recent Ubuntu kernels. |
156,916 | <p>I need to list all files whose names start with 'SomeLongString'. But the case of 'SomeLongString' can vary. How?</p>
<p>I am using zsh, but a bash solution is also welcome.</p>
| [
{
"answer_id": 156953,
"author": "Horst Gutmann",
"author_id": 22312,
"author_profile": "https://Stackoverflow.com/users/22312",
"pm_score": 4,
"selected": false,
"text": "<p>Depending on how deep you want to have this listing, <code>find</code> offers quite a lot\nin this regard:</p>\n\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45603/"
] | I need to list all files whose names start with 'SomeLongString'. But the case of 'SomeLongString' can vary. How?
I am using zsh, but a bash solution is also welcome. | ZSH:
```
$ unsetopt CASE_GLOB
```
Or, if you don't want to enable case-insensitive globbing in general, you can activate it for only the varying part:
```
$ print -l (#i)(somelongstring)*
```
This will match any file that starts with "somelongstring" (in any combination of lower/upper case). The case-insensitive ... |
156,930 | <p>We have an existing classic ASP intranet consisting of hundreds of pages. Its directory structure looks like this...</p>
<pre><code>/root
app_1
app_2
...
img
js
style
</code></pre>
<p>Obviously app_1 and so on have better names in the actual directory structure.</p>
<p>Even though the many... | [
{
"answer_id": 157244,
"author": "rohancragg",
"author_id": 5351,
"author_profile": "https://Stackoverflow.com/users/5351",
"pm_score": 2,
"selected": false,
"text": "<p>One solution would be to use IIS Manager to configure the website (created for your ASP.NET app by Visual Studio) and ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7508/"
] | We have an existing classic ASP intranet consisting of hundreds of pages. Its directory structure looks like this...
```
/root
app_1
app_2
...
img
js
style
```
Obviously app\_1 and so on have better names in the actual directory structure.
Even though the many applications have different beh... | One solution would be to use IIS Manager to configure the website (created for your ASP.NET app by Visual Studio) and add a virtual directory for each of the common folders so that (by the 'virtual' nature of the virtual directory) they will 'appear' to be in the same root folder as your ASP.NET app.
```
/root
app_1... |
156,936 | <p>I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance and I would be glad to accept your help.</p>
<p>I would like to expose an iterator for a class like this:</p>
<pre><code>template <class T&g... | [
{
"answer_id": 156995,
"author": "Sébastien RoccaSerra",
"author_id": 2797,
"author_profile": "https://Stackoverflow.com/users/2797",
"pm_score": 1,
"selected": false,
"text": "<p>This should do what you want:</p>\n\n<pre><code>typedef typename std::vector<T>::iterator MyIterator;\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166173/"
] | I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance and I would be glad to accept your help.
I would like to expose an iterator for a class like this:
```
template <class T>
class MyContainer
{
publ... | You may find the following article interesting as it addresses exactly the problem you have posted: [On the Tension Between Object-Oriented and Generic Programming in C++ and What Type Erasure Can Do About It](http://www.artima.com/cppsource/type_erasure.html) |
156,941 | <p>I have a scenario like this which I want to use capistrano to deploy my ruby on rails application:</p>
<ol>
<li>The web application is on a thin cluster with the config file stored under /etc/thin. also an init script is in /etc/init.d/thin, so it would start automatically whenever my server needs a reboot</li>
<li... | [
{
"answer_id": 156957,
"author": "Dre",
"author_id": 23033,
"author_profile": "https://Stackoverflow.com/users/23033",
"pm_score": 2,
"selected": false,
"text": "<p>This might not be what you want, but you can actually do something like this in your sudoers file:</p>\n\n<pre><code>someus... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] | I have a scenario like this which I want to use capistrano to deploy my ruby on rails application:
1. The web application is on a thin cluster with the config file stored under /etc/thin. also an init script is in /etc/init.d/thin, so it would start automatically whenever my server needs a reboot
2. Also nginx is exec... | This might not be what you want, but you can actually do something like this in your sudoers file:
```
someuser ALL=NOPASSWD: /etc/init.d/apache2
```
that lets someuser run /etc/init.d/apache2
If you try to do something else:
```
$ sudo ls
[sudo] password for someuser:
Sorry, user someuser is not allowed to execu... |
156,954 | <p>I need something in between a full text search and an index search:<br>
I want to search for text in one column of my table (probably there will be an index on the column, too, if that matters).</p>
<p>Problem is, I want to search for words in the column, but I don't want to match parts. </p>
<p>For example, my c... | [
{
"answer_id": 156978,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 2,
"selected": false,
"text": "<pre><code>where BusinessName like 'Break%' -- to find if it is beginning with the word\nor BusinessName like '% Break%' -- to fi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] | I need something in between a full text search and an index search:
I want to search for text in one column of my table (probably there will be an index on the column, too, if that matters).
Problem is, I want to search for words in the column, but I don't want to match parts.
For example, my column might contain... | SQL Server 2000 or above.
```
SELECT *
FROM dbo.TblBusinessNames
WHERE BusinessName like '%[^A-z^0-9]Break%' -- In the middle of a sentence
OR BusinessName like 'Break%' -- At the beginning of a sentence
```
Keyword Reference for **LIKE**: <http://msdn.microsoft.com/en-us/library/aa933232(SQL.80).a... |
156,975 | <p>I have a JLabel (actually, it is a JXLabel).</p>
<p>I have put an icon and text on it.</p>
<p><code><icon><text></code></p>
<p>Now I wand to add some spacing on the left side of the component, like this:</p>
<p><code><space><icon><text></code></p>
<p>I DON'T accept suggestion to mo... | [
{
"answer_id": 156993,
"author": "Jasper",
"author_id": 18702,
"author_profile": "https://Stackoverflow.com/users/18702",
"pm_score": 2,
"selected": false,
"text": "<p>The like this: is not very clear, but you can add spacing by adding a transparent border of a certain width to the label... | 2008/10/01 | [
"https://Stackoverflow.com/questions/156975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15173/"
] | I have a JLabel (actually, it is a JXLabel).
I have put an icon and text on it.
`<icon><text>`
Now I wand to add some spacing on the left side of the component, like this:
`<space><icon><text>`
I DON'T accept suggestion to move the JLabel or add spacing by modifying the image.
I just want to know how to do it wit... | I have found the solution!
```
setBorder(new EmptyBorder(0,10,0,0));
```
Thanks everyone! |
157,005 | <p>In HTML forms, buttons can be disabled by defining the "disabled" attribute on them, with any value:</p>
<pre><code><button name="btn1" disabled="disabled">Hello</button>
</code></pre>
<p>If a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attribu... | [
{
"answer_id": 157064,
"author": "Marcus Downing",
"author_id": 1000,
"author_profile": "https://Stackoverflow.com/users/1000",
"pm_score": -1,
"selected": false,
"text": "<p>I don't really use JSP (and I replied once, then deleted it when I understood the \"must by valid XML\" thing). T... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24068/"
] | In HTML forms, buttons can be disabled by defining the "disabled" attribute on them, with any value:
```
<button name="btn1" disabled="disabled">Hello</button>
```
If a button is to be enabled, the attribute should not exist as there is no defined value that the disabled attribute can be set to that would leave the ... | I use a custom JSP tag with dynamic attributes. You use it like this:
```
<util:element elementName="button" name="btn1" disabled="$(isDisabled ? 'disabled' : '')"/>
```
Basically, what this tag does is generate an XML element with elementName and puts all attributes present in the tag, but skips the empty ones.
Th... |
157,020 | <p>I have an script that falls over if any of the procedures it is trying to create already exists. How can I check/drop if this procedure is already created?</p>
| [
{
"answer_id": 157248,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 1,
"selected": false,
"text": "<p>I would guess something along the lines of:</p>\n\n<pre><code>IF EXISTS\n(\n SELECT *\n FROM SYSPROCS\n WHER... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an script that falls over if any of the procedures it is trying to create already exists. How can I check/drop if this procedure is already created? | I would guess something along the lines of:
```
IF EXISTS
(
SELECT *
FROM SYSPROCS
WHERE SPECIFIC_SCHEMA = ???
AND SPECIFIC_NAME = ???
AND ROUTINE_SCHEMA = ???
AND ROUTINE_NAME = ???
)
DROP PROCEDURE ???
```
I don't know if you actually need the SPECIFIC\_\* information or not and I... |
157,034 | <p>I have column that contains strings. The strings in that column look like this:</p>
<p>FirstString/SecondString/ThirdString</p>
<p>I need to parse this so I have two values:</p>
<p>Value 1: FirstString/SecondString
Value 2: ThirdString</p>
<p>I could have actually longer strings but I always nee it seperated lik... | [
{
"answer_id": 157049,
"author": "pappes",
"author_id": 19494,
"author_profile": "https://Stackoverflow.com/users/19494",
"pm_score": 0,
"selected": false,
"text": "<p>mid(col, 1, instr(col, \"/\", -1)) , mid(col, instr(col, \"/\", -1)+1, length(col)) </p>\n"
},
{
"answer_id": 15... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I have column that contains strings. The strings in that column look like this:
FirstString/SecondString/ThirdString
I need to parse this so I have two values:
Value 1: FirstString/SecondString
Value 2: ThirdString
I could have actually longer strings but I always nee it seperated like [string1/string2/string3/...]... | In a query, use the following two expressions as columns:
```
Left(col, InStrRev(col, "/") - 1), Mid(col, InStrRev(col, "/") + 1)
```
col is your column.
If in VBA, use the following:
```
last_index= InStrRev(your_string, "/")
first_part= Left$(your_string, last_index - 1)
last_part= Mid$(your_string, last_index... |
157,039 | <p>I have an iterable of entries on which I would like to gather some simple statistics, say the count of all numbers divisible by two and the count of all numbers divisible by three.</p>
<p>My first alternative, While only iterating through the list once and avoiding the list expansion (and keeping the <a href="http:... | [
{
"answer_id": 157080,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 2,
"selected": false,
"text": "<p>You could use the <a href=\"http://docs.python.org/lib/built-in-funcs.html\" rel=\"nofollow noreferrer\"><code>filter<... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2010/"
] | I have an iterable of entries on which I would like to gather some simple statistics, say the count of all numbers divisible by two and the count of all numbers divisible by three.
My first alternative, While only iterating through the list once and avoiding the list expansion (and keeping the [split loop](http://www.... | Having to iterate over the list multiple times isn't elegant IMHO.
I'd probably create a function that allows doing:
```
twos, threes = countmatching(xrange(1,10),
lambda a: a % 2 == 0,
lambda a: a % 3 == 0)
```
A starting point would be something like this:... |
157,044 | <p>I'm attempting to check for the existence of a node using the following .NET code:</p>
<pre><code>xmlDocument.SelectSingleNode(
String.Format("//ErrorTable/ProjectName/text()='{0}'", projectName));
</code></pre>
<p>This always raises:</p>
<blockquote>
<p>XPathException: Expression must evaluate to a nod... | [
{
"answer_id": 157085,
"author": "rjohnston",
"author_id": 246,
"author_profile": "https://Stackoverflow.com/users/246",
"pm_score": 1,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>Node node = xmlDocument.SelectSingleNode(String.Format(\"//ErrorTable/ProjectName = '{0}'\", proje... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] | I'm attempting to check for the existence of a node using the following .NET code:
```
xmlDocument.SelectSingleNode(
String.Format("//ErrorTable/ProjectName/text()='{0}'", projectName));
```
This always raises:
>
> XPathException: Expression must evaluate to a node-set.
>
>
>
Why am I getting this err... | The expression given evaluates to a boolean, not a node-set. I assume you want to check whether the ProjectName equals the parametrized text. In this case you need to write
```
//ErrorTable/ProjectName[text()='{0}']
```
This gives you a list of all nodes (a nodeset) matching the given condition. This list may be emp... |
157,058 | <p>I have a list of tuples eg. [{1,40},{2,45},{3,54}....{7,23}] where 1...7 are days of the week (calculated by finding calendar:day_of_the_week()). So now I want to change the list to [{Mon,40},{Tue,45},{Wed,54}...{Sun,23}]. Is there an easier way to do it than lists:keyreplace?</p>
| [
{
"answer_id": 157112,
"author": "Jon Gretar",
"author_id": 5601,
"author_profile": "https://Stackoverflow.com/users/5601",
"pm_score": 3,
"selected": true,
"text": "<p>Simple. Use map and a handy tool from the httpd module.</p>\n\n<pre><code>lists:map(fun({A,B}) -> {httpd_util:day(A)... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727/"
] | I have a list of tuples eg. [{1,40},{2,45},{3,54}....{7,23}] where 1...7 are days of the week (calculated by finding calendar:day\_of\_the\_week()). So now I want to change the list to [{Mon,40},{Tue,45},{Wed,54}...{Sun,23}]. Is there an easier way to do it than lists:keyreplace? | Simple. Use map and a handy tool from the httpd module.
```
lists:map(fun({A,B}) -> {httpd_util:day(A),B} end, [{1,40},{2,45},{3,54},{7,23}]).
``` |
157,070 | <p>When you're adding javaDoc comments to your code and you're outlining the structure of an XML document that you're passing back, what's the best way to represent attributes? Is there a best practice for this?</p>
<p>My general structure for my javaDoc comments is like this:</p>
<pre><code>/**
* ...
*
* @return... | [
{
"answer_id": 157109,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 2,
"selected": true,
"text": "<p>Not sure I clearly understand your question.</p>\n\n<p>My preferred solution would be to embed the schema XSD or D... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] | When you're adding javaDoc comments to your code and you're outlining the structure of an XML document that you're passing back, what's the best way to represent attributes? Is there a best practice for this?
My general structure for my javaDoc comments is like this:
```
/**
* ...
*
* @return XML document in the ... | Not sure I clearly understand your question.
My preferred solution would be to embed the schema XSD or DTC in the description of the return parameter. Your solution seems to lead to personal idioms on how to represent things like multiple elements or others. Using a standard like XSD or DTD allows you to have a well k... |
157,114 | <p>I made a view to abstract columns of different tables and pre-filter and pre-sort them. There is one column whose content I don't care about but I need to know whether the content is null or not. So my view should pass an alias as "<em>true</em>" in case the value of this specified column <strong>isn't null</strong>... | [
{
"answer_id": 157136,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 7,
"selected": true,
"text": "<p>You have to use a <strong>CASE</strong> statement for this:</p>\n\n<pre><code>SELECT CASE WHEN columnName IS NULL ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5703/"
] | I made a view to abstract columns of different tables and pre-filter and pre-sort them. There is one column whose content I don't care about but I need to know whether the content is null or not. So my view should pass an alias as "*true*" in case the value of this specified column **isn't null** and "*false*" in case ... | You have to use a **CASE** statement for this:
```
SELECT CASE WHEN columnName IS NULL THEN 'false' ELSE 'true' END FROM tableName;
``` |
157,119 | <p>As far as i know it is not possible to do the following in C# 2.0</p>
<pre><code>public class Father
{
public virtual Father SomePropertyName
{
get
{
return this;
}
}
}
public class Child : Father
{
public override Child SomePropertyName
{
get
... | [
{
"answer_id": 157128,
"author": "Anthony",
"author_id": 5599,
"author_profile": "https://Stackoverflow.com/users/5599",
"pm_score": 1,
"selected": false,
"text": "<p>No. C# does not support this idea (it's called \"return type covariance\"). \nYou can however do this:</p>\n\n<pre><code>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20335/"
] | As far as i know it is not possible to do the following in C# 2.0
```
public class Father
{
public virtual Father SomePropertyName
{
get
{
return this;
}
}
}
public class Child : Father
{
public override Child SomePropertyName
{
get
{
... | This is not possible in any .NET language because of type-safety concerns. In type-safe languages, you must provide covariance for return values, and contravariance for parameters. Take this code:
```
class B {
S Get();
Set(S);
}
class D : B {
T Get();
Set(T);
}
```
For the `Get` methods, covariance ... |
157,132 | <p>I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.</p>
<p>Is there a way to abort an upload process from the server side without waiting the HTTP request t... | [
{
"answer_id": 157188,
"author": "Nikhil Kashyap",
"author_id": 11299,
"author_profile": "https://Stackoverflow.com/users/11299",
"pm_score": 1,
"selected": false,
"text": "<p>You might try doing this in the doPost() method of your servlet </p>\n\n<pre><code>multi = new MultipartRequest(... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686/"
] | I'd like to limit the size of the file that can be uploaded to an application. To achieve this, I'd like to abort the upload process from the server side when the size of the file being uploaded exceeds a limit.
Is there a way to abort an upload process from the server side without waiting the HTTP request to finish? | You can do something like this (using the [Commons](http://commons.apache.org/fileupload/) library):
```
public class UploadFileServiceImpl extends HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
{
response.setContentT... |
157,149 | <p>Is it possible to split the information in a .csproj across more than one file? A bit like a project version of the <code>partial class</code> feature.</p>
| [
{
"answer_id": 157156,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": -1,
"selected": false,
"text": "<p>Well you can have multiple projects combined into one large solution, but I don't think that is quite what you had in... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24092/"
] | Is it possible to split the information in a .csproj across more than one file? A bit like a project version of the `partial class` feature. | You can not have more than one master csproj. But because the underneath wiring of the csproj is done using msbuild you can simply have multiple partial csproj that import each other. The solution file would see the most *derived* csproj.
**project1.csproj**
```
<Project DefaultTargets="Build" xmlns="http://schemas.m... |
157,163 | <p>I want to run a command as soon as a certain text appears in a log file. How do I do that in Bash?</p>
| [
{
"answer_id": 157171,
"author": "ketorin",
"author_id": 24094,
"author_profile": "https://Stackoverflow.com/users/24094",
"pm_score": 5,
"selected": true,
"text": "<p>Use command</p>\n\n<pre><code>tail -f file.log | grep --line-buffered \"my pattern\" | while read line\ndo\n echo $line... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24094/"
] | I want to run a command as soon as a certain text appears in a log file. How do I do that in Bash? | Use command
```
tail -f file.log | grep --line-buffered "my pattern" | while read line
do
echo $line
done
```
The `--line-buffered` is the key here, otherwise the read will fail. |
157,198 | <p>I was reading <a href="http://www.ibm.com/developerworks/java/library/j-dcl.html" rel="nofollow noreferrer">this article</a> about "Double-Checked locking" and out of the main topic of the article I was wondering why at some point of the article the author uses the next Idiom: </p>
<blockquote>
<p>Listing 7. Att... | [
{
"answer_id": 157213,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>The point of locking twice was to <em>attempt</em> to prevent out-of-order writes. The memory model specifies where re... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24097/"
] | I was reading [this article](http://www.ibm.com/developerworks/java/library/j-dcl.html) about "Double-Checked locking" and out of the main topic of the article I was wondering why at some point of the article the author uses the next Idiom:
>
> Listing 7. Attempting to solve the out-of-order write problem
>
>
>
... | The point of locking twice was to *attempt* to prevent out-of-order writes. The memory model specifies where reorderings can occur, partly in terms of locks. The lock ensures that no writes (including any within the singleton constructor) appear to happen after the "instance = inst;" line.
However, to go deeper into t... |
157,232 | <p>I have wrapped Log4net in a static wrapper and want to log </p>
<pre><code>loggingEvent.LocationInformation.MethodName
loggingEvent.LocationInformation.ClassName
</code></pre>
<p>However all I get is the name of my wrapper.</p>
<p>How can I log that info using a forwardingappender and a static wrapper class li... | [
{
"answer_id": 157261,
"author": "mattlant",
"author_id": 14642,
"author_profile": "https://Stackoverflow.com/users/14642",
"pm_score": 0,
"selected": false,
"text": "<p>The only thing I can think of doing (as I dont currently use log4net) is to request a stacktrace(new StackTrace), and ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15555/"
] | I have wrapped Log4net in a static wrapper and want to log
```
loggingEvent.LocationInformation.MethodName
loggingEvent.LocationInformation.ClassName
```
However all I get is the name of my wrapper.
How can I log that info using a forwardingappender and a static wrapper class like
```
Logger.Debug("Logging to De... | Well the error was somewhere in my appender but for completeness ill include the answer to the best of my knowledge:
the Facade you need should wrap ILogger and NOT ILog
```
public static class Logger
{
private readonly static Type ThisDeclaringType = typeof(Logger);
private static readonly ILogger defaultL... |
157,260 | <p>In the past and with most my current projects I tend to use a for loop like this:</p>
<pre><code>var elements = document.getElementsByTagName('div');
for (var i=0; i<elements.length; i++) {
doSomething(elements[i]);
}
</code></pre>
<p>I've heard that using a "reverse while" loop is quicker but I have no rea... | [
{
"answer_id": 157264,
"author": "Per Hornshøj-Schierbeck",
"author_id": 11619,
"author_profile": "https://Stackoverflow.com/users/11619",
"pm_score": 3,
"selected": false,
"text": "<p>At the risk of getting yelled at, i would get a javascript helper library like <a href=\"http://jquery.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21677/"
] | In the past and with most my current projects I tend to use a for loop like this:
```
var elements = document.getElementsByTagName('div');
for (var i=0; i<elements.length; i++) {
doSomething(elements[i]);
}
```
I've heard that using a "reverse while" loop is quicker but I have no real way to confirm this:
```
v... | Here's a nice form of a loop I often use. You create the iterated variable from the for statement and you don't need to check the length property, which can be expensive specially when iterating through a NodeList. However, **you must be careful**, you **can't use it if any of the values in array could be "falsy"**. In... |
157,318 | <p>We are using a PHP scripting for tunnelling file downloads, since we don't want to expose the absolute path of downloadable file:</p>
<pre><code>header("Content-Type: $ctype");
header("Content-Length: " . filesize($file));
header("Content-Disposition: attachment; filename=\"$fileName\"");
readfile($file);
</code></... | [
{
"answer_id": 157352,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": 4,
"selected": false,
"text": "<p>Yes. Support byteranges. See <a href=\"http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35\" rel=\"noreferrer\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We are using a PHP scripting for tunnelling file downloads, since we don't want to expose the absolute path of downloadable file:
```
header("Content-Type: $ctype");
header("Content-Length: " . filesize($file));
header("Content-Disposition: attachment; filename=\"$fileName\"");
readfile($file);
```
Unfortunately we ... | The first thing you need to do is to send the `Accept-Ranges: bytes` header in all responses, to tell the client that you support partial content. Then, if request with a `Range: bytes=x-y` header is received (with `x` and `y` being numbers) you parse the range the client is requesting, open the file as usual, seek `x`... |
157,342 | <p>Cron installation is vixie-cron</p>
<p><code>/etc/cron.daily/rmspam.cron</code></p>
<pre><code>#!/bin/bash
/usr/bin/rm /home/user/Maildir/.SPAM/cur/*;
</code></pre>
<p>I Have this simple bash script that I want to add to a cron job (also includes spam learning commands before) but this part always fails with "Fil... | [
{
"answer_id": 157350,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 0,
"selected": false,
"text": "<p>Are you specifying the full path to the script in the cronjob?</p>\n\n<pre><code>00 3 * * * /home/me/myscript.sh\n</code>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4275/"
] | Cron installation is vixie-cron
`/etc/cron.daily/rmspam.cron`
```
#!/bin/bash
/usr/bin/rm /home/user/Maildir/.SPAM/cur/*;
```
I Have this simple bash script that I want to add to a cron job (also includes spam learning commands before) but this part always fails with "File or directory not found" From what I figure... | If there are no files in the directory, then the wildcard will not be expanded and will be passed to the command directly. There is no file called "\*", and then the command fails with "File or directory not found." Try this instead:
```
if [ -f /home/user/Maildir/.SPAM/cur/* ]; then
rm /home/user/Maildir/.SPAM/cu... |
157,359 | <p>I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that).</p>
<p>I've been using datetime.now() as a first stab, ... | [
{
"answer_id": 157439,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 4,
"selected": false,
"text": "<p>time.clock() only measures wallclock time on Windows. On other systems, time.clock() actually measures CPU-time.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15369/"
] | I've been building an error logging app recently and was after a way of accurately timestamping the incoming data. When I say accurately I mean each timestamp should be accurate relative to each other (no need to sync to an atomic clock or anything like that).
I've been using datetime.now() as a first stab, but this i... | You're unlikely to get sufficiently fine-grained control that you can completely eliminate the possibility
of duplicate timestamps - you'd need resolution smaller than the time it takes to generate a datetime object. There are a couple of other approaches you might take to deal with it:
1. Deal with it. Leave your tim... |
157,392 | <p>I want to find out, with an SQL query, whether an index is UNIQUE or not. I'm using SQLite 3.</p>
<p>I have tried two approaches:</p>
<pre><code>SELECT * FROM sqlite_master WHERE name = 'sqlite_autoindex_user_1'
</code></pre>
<p>This returns information about the index ("type", "name", "tbl_name", "rootpage" and ... | [
{
"answer_id": 157636,
"author": "dland",
"author_id": 18625,
"author_profile": "https://Stackoverflow.com/users/18625",
"pm_score": 2,
"selected": false,
"text": "<p>you can programmatically build a select statement to see if any tuples point to more than one row. If you get back three ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12534/"
] | I want to find out, with an SQL query, whether an index is UNIQUE or not. I'm using SQLite 3.
I have tried two approaches:
```
SELECT * FROM sqlite_master WHERE name = 'sqlite_autoindex_user_1'
```
This returns information about the index ("type", "name", "tbl\_name", "rootpage" and "sql"). Note that the sql column... | ```
PRAGMA INDEX_LIST('table_name');
```
Returns a table with 3 columns:
1. `seq` Unique numeric ID of index
2. `name` Name of the index
3. `unique` Uniqueness flag (nonzero if `UNIQUE` index.)
**Edit**
Since SQLite 3.16.0 you can also use table-valued pragma functions which have the advantage that you can `JOIN` ... |
157,424 | <p>I have a dictionary of 200,000 items (the keys are strings and the values are integers).</p>
<p>What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)?</p>
<pre><code> a={ 'keyC':1, 'keyB':2, 'keyA':1 }
b = a.items()
b.sort( key=lambda a:a[0])
b.sort... | [
{
"answer_id": 157445,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 5,
"selected": true,
"text": "<p>You can't sort dictionaries. You have to sort the list of items.</p>\n\n<p>Previous versions were wrong. When you have ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a dictionary of 200,000 items (the keys are strings and the values are integers).
What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)?
```
a={ 'keyC':1, 'keyB':2, 'keyA':1 }
b = a.items()
b.sort( key=lambda a:a[0])
b.sort( key=lambda a:a[1], ... | You can't sort dictionaries. You have to sort the list of items.
Previous versions were wrong. When you have a numeric value, it's easy to sort in reverse order. These will do that. But this isn't general. This only works because the value is numeric.
```
a = { 'key':1, 'another':2, 'key2':1 }
b= a.items()
b.sort( k... |
157,431 | <p>I have created a Web Application in asp.net 2.0. which is working fine on my Local machine. However when trying to deploy it on sever that has windows 2003 sever, I get the error:</p>
<h1>Server Error in '/' Application.</h1>
<hr>
<h2><em>Parser Error</em></h2>
<p><strong>Description:</strong> An error occurred ... | [
{
"answer_id": 157440,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Is the folder on the web server (IIS presumably) marked as an ASP.NET application? If not, ~/ will point to the nex... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6621/"
] | I have created a Web Application in asp.net 2.0. which is working fine on my Local machine. However when trying to deploy it on sever that has windows 2003 sever, I get the error:
Server Error in '/' Application.
================================
---
*Parser Error*
--------------
**Description:** An error occurred d... | Is the folder on the web server (IIS presumably) marked as an ASP.NET application? If not, ~/ will point to the next application up, or the site root.
It should have a cog icon in the IIS/MMC snap-in. Also ensure that it is running the right version of ASP.NET (v2.blah usually).
In the IIS/MMC view, find the folder t... |
157,459 | <p>I have a products table...</p>
<p><a href="http://img357.imageshack.us/img357/6393/productscx5.gif" rel="nofollow noreferrer">alt text http://img357.imageshack.us/img357/6393/productscx5.gif</a></p>
<p>and a revisions table, which is supposed to track changes to product info</p>
<p><a href="http://img124.imagesha... | [
{
"answer_id": 157475,
"author": "ctrlShiftBryan",
"author_id": 6161,
"author_profile": "https://Stackoverflow.com/users/6161",
"pm_score": 1,
"selected": false,
"text": "<p>Begin and end dates on your history table would make this possible.(leaving the most recent end date null and stam... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18856/"
] | I have a products table...
[alt text http://img357.imageshack.us/img357/6393/productscx5.gif](http://img357.imageshack.us/img357/6393/productscx5.gif)
and a revisions table, which is supposed to track changes to product info
[alt text http://img124.imageshack.us/img124/1139/revisionslz5.gif](http://img124.imageshack... | Here's how I'd do it:
```
SELECT p.*, r.*
FROM products AS p
JOIN revisions AS r USING (product_id)
LEFT OUTER JOIN revisions AS r2
ON (r.product_id = r2.product_id AND r.modified < r2.modified)
WHERE r2.revision_id IS NULL;
```
In other words: find the revision for which no other revision exists with the s... |
157,480 | <p>How can this line in Java be translated to Ruby:<br>
String className = "java.util.Vector";<br>
...<br>
Object o = Class.forName(className).newInstance(); </p>
<p>Thanks!</p>
| [
{
"answer_id": 157499,
"author": "Ken",
"author_id": 20621,
"author_profile": "https://Stackoverflow.com/users/20621",
"pm_score": 7,
"selected": true,
"text": "<pre><code>Object::const_get('String').new()\n</code></pre>\n"
},
{
"answer_id": 158145,
"author": "Ian Terrell",
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can this line in Java be translated to Ruby:
String className = "java.util.Vector";
...
Object o = Class.forName(className).newInstance();
Thanks! | ```
Object::const_get('String').new()
``` |
157,504 | <p>I have object A which in turn has a property of type Object B</p>
<pre><code>Class A
property x as Object B
End Class
</code></pre>
<p>On my ASP.NET page when I select a gridview item which maps to an object of type A I serialize the object onto the QueryString and pass it to the next page. </p>
<p>However I ru... | [
{
"answer_id": 157527,
"author": "CodeRedick",
"author_id": 17145,
"author_profile": "https://Stackoverflow.com/users/17145",
"pm_score": 2,
"selected": false,
"text": "<p>I don't understand why you wouldn't use session state but...</p>\n\n<p>Option 1: Viewstate</p>\n\n<p>Option 2: Form ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | I have object A which in turn has a property of type Object B
```
Class A
property x as Object B
End Class
```
On my ASP.NET page when I select a gridview item which maps to an object of type A I serialize the object onto the QueryString and pass it to the next page.
However I run into problems if property x act... | If displaying the url of the next page in the browser does not matter, you could use the context.items collection.
```
context.items.add("keyA", objectA)
server.transfer("nextPage.aspx")
```
Then on the next page:
```
public sub page_load(...)
dim objectA as A = ctype(context.items("keyA"), objectA)
dim obj... |
157,511 | <p>I have a <code>Dictionary<string, someobject></code>.</p>
<p>EDIT: It was pointed out to me, that my example was bad. My whole intention was not to update the references in a loop but to update different values based on differnt threads need to update/get the data. I changed the loop to a method.</p>
<p>I ne... | [
{
"answer_id": 157536,
"author": "Sander",
"author_id": 2928,
"author_profile": "https://Stackoverflow.com/users/2928",
"pm_score": 3,
"selected": false,
"text": "<p>No, this would not work.</p>\n\n<p>The reason is <a href=\"http://en.wikipedia.org/wiki/String_intern_pool\" rel=\"norefer... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] | I have a `Dictionary<string, someobject>`.
EDIT: It was pointed out to me, that my example was bad. My whole intention was not to update the references in a loop but to update different values based on differnt threads need to update/get the data. I changed the loop to a method.
I need to update items in my dictionar... | Locking on an object that is accessible outside of the code locking it is a big risk. If any other code (anywhere) ever locks that object you could be in for some deadlocks that are hard to debug. Also note that you lock the *object*, not the reference, so if I gave you a dictionary, I may still hold references to the ... |
157,554 | <p>I've got a XmlNodeList which I need to have it in a format that I can then re-use within a XSLT stylesheet by calling it from a C# extension method.</p>
<p>Can anyone help? I have read that it might have something to do with using a XPathNavigator but I'm still a bit stuck.</p>
| [
{
"answer_id": 157624,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 4,
"selected": true,
"text": "<p>I had to solve this issue myself a couple of years ago. The only way I managed it was to create an XML fragment conta... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4455/"
] | I've got a XmlNodeList which I need to have it in a format that I can then re-use within a XSLT stylesheet by calling it from a C# extension method.
Can anyone help? I have read that it might have something to do with using a XPathNavigator but I'm still a bit stuck. | I had to solve this issue myself a couple of years ago. The only way I managed it was to create an XML fragment containing the nodes in the node list and then passing in the children of the fragment.
```
XsltArgumentList arguments = new XsltArgumentList();
XmlNodeList nodelist;
XmlDocument nodesFrament = new XmlDocume... |
157,557 | <p>In VB.Net, I can declare a variable in a function as Static, like this:</p>
<pre><code>Function EncodeForXml(ByVal data As String) As String
Static badAmpersand As Regex = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)")
data = badAmpersand.Replace(data, "&amp;")
''// more processing
return ... | [
{
"answer_id": 157571,
"author": "Max Schmeling",
"author_id": 3226,
"author_profile": "https://Stackoverflow.com/users/3226",
"pm_score": 2,
"selected": false,
"text": "<p>There is no equivalent in C# unfortunately.</p>\n\n<p>You will need to use a class level variable.</p>\n\n<p>This i... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] | In VB.Net, I can declare a variable in a function as Static, like this:
```
Function EncodeForXml(ByVal data As String) As String
Static badAmpersand As Regex = new Regex("&(?![a-zA-Z]{2,6};|#[0-9]{2,4};)")
data = badAmpersand.Replace(data, "&")
''// more processing
return data
End Function
```... | Ha! In posting the question, I found the answer! Rather than googling for C# I should have been looking for details on how VB.Net implements it, and typing up the question made that apparent to me. After applying that insight, I found this:
<http://weblogs.asp.net/psteele/articles/7717.aspx>
That article explains t... |
157,599 | <p>I am working on converting a CVS repository that has the following symbols (among others):</p>
<p><code>tcm-6.1.0-branch</code> -- a branch<br>
<code>tcm-6.1.0</code> -- a tag</p>
<p>Using the standard transformations cvs2svn identifies them properly. However, I'd like to do some clean up during the conversion... | [
{
"answer_id": 157626,
"author": "ctrlShiftBryan",
"author_id": 6161,
"author_profile": "https://Stackoverflow.com/users/6161",
"pm_score": 2,
"selected": false,
"text": "<p>What about emailing the report to the user. All the asp page should do is send the request to generate the report ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4356/"
] | I am working on converting a CVS repository that has the following symbols (among others):
`tcm-6.1.0-branch` -- a branch
`tcm-6.1.0` -- a tag
Using the standard transformations cvs2svn identifies them properly. However, I'd like to do some clean up during the conversion. Specifically I'd like to drop the redundan... | Using the filesystem here is probably a good bet. Have a request that immediately returns a url to the report pdf location. Your server can then either kick off an external process or send a request to itself to perform the reporting. The client can poll the server (using http HEAD) for the PDF at the supplied url. If ... |
157,628 | <p>I have a helper method has been created which allows a MovieClip-based class in code and have the constructor called. Unfortunately the solution is not complete because the MovieClip callback <b>onLoad()</b> is never called. </p>
<p>(Link to the <a href="http://www.flashdevelop.org/community/viewtopic.php?f=13&... | [
{
"answer_id": 164928,
"author": "Luke",
"author_id": 21406,
"author_profile": "https://Stackoverflow.com/users/21406",
"pm_score": 2,
"selected": false,
"text": "<p>Do I understand correctly that you want to create an instance of an empty movie clip with class behavior attached and with... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14747/"
] | I have a helper method has been created which allows a MovieClip-based class in code and have the constructor called. Unfortunately the solution is not complete because the MovieClip callback **onLoad()** is never called.
(Link to the [Flashdevelop thread](http://www.flashdevelop.org/community/viewtopic.php?f=13&t=45... | Do I understand correctly that you want to create an instance of an empty movie clip with class behavior attached and without having to define an empty clip symbol in the library?
If that's the case you need to use the packages trick. This is my base class (called View) that I've been using over the years and on hundr... |
157,629 | <p>Hi im new to MVC and I've fished around with no luck on how to build MVC User Controls that have ViewData returned to them. I was hoping someone would post a step by step solution on how to approach this problem. If you could make your solution very detailed that would help out greatly.</p>
<p>Sorry for being so di... | [
{
"answer_id": 157743,
"author": "stimms",
"author_id": 361,
"author_profile": "https://Stackoverflow.com/users/361",
"pm_score": 0,
"selected": false,
"text": "<p>I am pretty sure view data is accessible inside user controls so long as you extend System.Web.Mvc.ViewUserControl and pass ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24130/"
] | Hi im new to MVC and I've fished around with no luck on how to build MVC User Controls that have ViewData returned to them. I was hoping someone would post a step by step solution on how to approach this problem. If you could make your solution very detailed that would help out greatly.
Sorry for being so discrete wit... | If I understand your question, you are trying to pass ViewData into the user control. A user control is essentially a partial view, so you would do this:
```
<% Html.RenderPartial("someUserControl.ascx", viewData); %>
```
Now in your usercontrol, ViewData will be whatever you passed in... |
157,646 | <p>I was looking for a generic method in .Net to encode a string for use in an Xml element or attribute, and was surprised when I didn't immediately find one. So, before I go too much further, could I just be missing the built-in function? </p>
<p>Assuming for a moment that it really doesn't exist, I'm putting toget... | [
{
"answer_id": 157663,
"author": "Kilhoffer",
"author_id": 5469,
"author_profile": "https://Stackoverflow.com/users/5469",
"pm_score": 5,
"selected": false,
"text": "<p>In the past I have used HttpUtility.HtmlEncode to encode text for xml. It performs the same task, really. I haven't run... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] | I was looking for a generic method in .Net to encode a string for use in an Xml element or attribute, and was surprised when I didn't immediately find one. So, before I go too much further, could I just be missing the built-in function?
Assuming for a moment that it really doesn't exist, I'm putting together my own g... | System.XML handles the encoding for you, so you don't need a method like this. |
157,685 | <p>I'm trying to change the background color of a single subplot in a MATLAB figure.</p>
<p>It's clearly feasible since the UI allows it, but I cannot find the function to automate it.</p>
<p>I've looked into <code>whitebg</code>, but it changes the color scheme of the whole figure, not just the current subplot. </p>... | [
{
"answer_id": 157719,
"author": "Douglas F Shearer",
"author_id": 13831,
"author_profile": "https://Stackoverflow.com/users/13831",
"pm_score": 2,
"selected": false,
"text": "<p>I've not used Matlab in several years, but I think it might well be the whitebg method called after the subpl... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8027/"
] | I'm trying to change the background color of a single subplot in a MATLAB figure.
It's clearly feasible since the UI allows it, but I cannot find the function to automate it.
I've looked into `whitebg`, but it changes the color scheme of the whole figure, not just the current subplot.
(I'm using MATLAB Version 6.1 ... | You can use the set command.
```
set(subplot(2,2,1),'Color','Red')
```
That will give you a red background in the subplot location 2,2,1. |
157,689 | <p>How do I use the ofstream to write text to the end of a file without erasing its content inside?</p>
| [
{
"answer_id": 157698,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "<p>You can pass the flag <code>ios::app</code> when opening the file:</p>\n\n<pre><code>ofstream ofs(\"filename\", io... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I use the ofstream to write text to the end of a file without erasing its content inside? | You can pass the flag `ios::app` when opening the file:
```
ofstream ofs("filename", ios::app);
``` |
157,705 | <p>I've got some XML, for example purposes it looks like this:</p>
<pre><code><root>
<field1>test</field1>
<f2>t2</f2>
<f2>t3</f2>
</root>
</code></pre>
<p>I want to transform it with XSLT, but I want to suppress the second f2 element in the output - how do ... | [
{
"answer_id": 158125,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 4,
"selected": true,
"text": "<p>It depends how system wide you want to be.</p>\n\n<p>i.e. Are you only concerned with elements that are children of the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22073/"
] | I've got some XML, for example purposes it looks like this:
```
<root>
<field1>test</field1>
<f2>t2</f2>
<f2>t3</f2>
</root>
```
I want to transform it with XSLT, but I want to suppress the second f2 element in the output - how do I check inside my template to see if the f2 element already exists in the ... | It depends how system wide you want to be.
i.e. Are you only concerned with elements that are children of the same parent, or all elements at the same level ('cousins' if you like) or elements anywhere in the document...
In the first situation you could check the preceding-sibling axis to see if any other elements ex... |
157,747 | <p>I want to use VBScript to catch errors and log them (ie on error "log something") then resume the next line of the script.</p>
<p>For example,</p>
<pre>
On Error Resume Next
'Do Step 1
'Do Step 2
'Do Step 3
</pre>
<p>When an error occurs on step 1, I want it to log that error (or perform other custom functions wi... | [
{
"answer_id": 157785,
"author": "Dylan Beattie",
"author_id": 5017,
"author_profile": "https://Stackoverflow.com/users/5017",
"pm_score": 8,
"selected": true,
"text": "<p>VBScript has no notion of throwing or catching exceptions, but the runtime provides a global Err object that contain... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6128/"
] | I want to use VBScript to catch errors and log them (ie on error "log something") then resume the next line of the script.
For example,
```
On Error Resume Next
'Do Step 1
'Do Step 2
'Do Step 3
```
When an error occurs on step 1, I want it to log that error (or perform other custom functions with it) then resume a... | VBScript has no notion of throwing or catching exceptions, but the runtime provides a global Err object that contains the results of the last operation performed. You have to explicitly check whether the Err.Number property is non-zero after each operation.
```
On Error Resume Next
DoStep1
If Err.Number <> 0 Then
... |
157,770 | <p>I'm trying to format a column in a <code><table/></code> using a <code><col/></code> element. I can set <code>background-color</code>, <code>width</code>, etc., but can't set the <code>font-weight</code>. Why doesn't it work?</p>
<pre><code><table>
<col style="font-weight:bold; background-c... | [
{
"answer_id": 157798,
"author": "Philip Morton",
"author_id": 21709,
"author_profile": "https://Stackoverflow.com/users/21709",
"pm_score": -1,
"selected": false,
"text": "<p>A <code>col</code> tag must be inside of a <code>colgroup</code> tag, This may be something to do with the probl... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15788/"
] | I'm trying to format a column in a `<table/>` using a `<col/>` element. I can set `background-color`, `width`, etc., but can't set the `font-weight`. Why doesn't it work?
```
<table>
<col style="font-weight:bold; background-color:#CCC;">
<col>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
... | As far as I know, you can only format the following using CSS on the `<col>` element:
* background-color
* border
* width
* visibility
This [page](http://www.quirksmode.org/css/columns.html) has more info.
Herb is right - it's better to style the `<td>`'s directly. What I do is the following:
```
<style type="text... |