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 |
|---|---|---|---|---|---|---|
68,283 | <p>What's a quick and easy way to view and edit ID3 tags (artist, album, etc.) using C#?</p>
| [
{
"answer_id": 68306,
"author": "tslocum",
"author_id": 1662,
"author_profile": "https://Stackoverflow.com/users/1662",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html\" rel=\"noreferrer\">TagLib Sharp</a... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10606/"
] | What's a quick and easy way to view and edit ID3 tags (artist, album, etc.) using C#? | Thirding [TagLib Sharp](https://github.com/mono/taglib-sharp).
```
TagLib.File f = TagLib.File.Create(path);
f.Tag.Album = "New Album Title";
f.Save();
``` |
68,291 | <p>If you were running a news site that created a list of 10 top news stories, and you wanted to make tweaks to your algorithm and see if people liked the new top story mix better, how would you approach this? </p>
<p>Simple Click logging in the DB associated with the post entry? </p>
<p>A/B testing where you would s... | [
{
"answer_id": 68306,
"author": "tslocum",
"author_id": 1662,
"author_profile": "https://Stackoverflow.com/users/1662",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html\" rel=\"noreferrer\">TagLib Sharp</a... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/281/"
] | If you were running a news site that created a list of 10 top news stories, and you wanted to make tweaks to your algorithm and see if people liked the new top story mix better, how would you approach this?
Simple Click logging in the DB associated with the post entry?
A/B testing where you would show one version o... | Thirding [TagLib Sharp](https://github.com/mono/taglib-sharp).
```
TagLib.File f = TagLib.File.Create(path);
f.Tag.Album = "New Album Title";
f.Save();
``` |
68,327 | <p>I create a new Button object but did not specify the <code>command</code> option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created?</p>
| [
{
"answer_id": 68455,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 2,
"selected": false,
"text": "<p>Sure; just use the <code>bind</code> method to specify the callback after the button has been created. I've just ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | I create a new Button object but did not specify the `command` option upon creation. Is there a way in Tkinter to change the command (onclick) function after the object has been created? | Though [Eli Courtwright's](https://stackoverflow.com/questions/68327/change-command-method-for-tkinter-button-in-python#68455) program will work fine¹, what you really seem to want though is just a way to reconfigure after instantiation any attribute which you could have set when you instantiated². How you do so is by ... |
68,335 | <p>I have a text file on my local machine that is generated by a daily Python script run in cron. </p>
<p>I would like to add a bit of code to have that file sent securely to my server over SSH.</p>
| [
{
"answer_id": 68365,
"author": "pdq",
"author_id": 8598,
"author_profile": "https://Stackoverflow.com/users/8598",
"pm_score": 7,
"selected": true,
"text": "<p>You can call the <a href=\"https://en.wikipedia.org/wiki/Secure_copy\" rel=\"noreferrer\"><code>scp</code></a> bash command (it... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10668/"
] | I have a text file on my local machine that is generated by a daily Python script run in cron.
I would like to add a bit of code to have that file sent securely to my server over SSH. | You can call the [`scp`](https://en.wikipedia.org/wiki/Secure_copy) bash command (it copies files over [SSH](https://en.wikipedia.org/wiki/Secure_Shell)) with [`subprocess.run`](https://docs.python.org/library/subprocess.html#subprocess.run):
```
import subprocess
subprocess.run(["scp", FILE, "USER@SERVER:PATH"])
#e.g... |
68,352 | <p>I use this question in interviews and I wonder what the best solution is.</p>
<p>Write a Perl sub that takes <em>n</em> lists, and then returns 2^<em>n</em>-1 lists telling you which items are in which lists; that is, which items are only in the first list, the second, list, both the first and second list, and all ... | [
{
"answer_id": 68417,
"author": "nohat",
"author_id": 3101,
"author_profile": "https://Stackoverflow.com/users/3101",
"pm_score": 0,
"selected": false,
"text": "<p>Here is my solution:</p>\n\n<p>Construct a hash whose keys are the union of all the elements in the input lists, and the val... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3101/"
] | I use this question in interviews and I wonder what the best solution is.
Write a Perl sub that takes *n* lists, and then returns 2^*n*-1 lists telling you which items are in which lists; that is, which items are only in the first list, the second, list, both the first and second list, and all other combinations of li... | Your given solution can be simplified quite a bit still.
In the first loop, you can use plain addition since you are only ever ORing with single bits, and you can narrow the scope of `$bit` by iterating over indices. In the second loop, you can subtract 1 from the index instead of producing an unnecessary 0th output l... |
68,372 | <p>We all know how to use <code><ctrl>-R</code> to reverse search through history, but did you know you can use <code><ctrl>-S</code> to forward search if you set <code>stty stop ""</code>? Also, have you ever tried running bind -p to see all of your keyboard shortcuts listed? There are over 455 on Mac OS... | [
{
"answer_id": 68386,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "<p>Well, this may be a bit off topic, but if you are an Emacs user, I would say \"emacs\" is the most powerful trick... bef... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3499/"
] | We all know how to use `<ctrl>-R` to reverse search through history, but did you know you can use `<ctrl>-S` to forward search if you set `stty stop ""`? Also, have you ever tried running bind -p to see all of your keyboard shortcuts listed? There are over 455 on Mac OS X by default.
What is your single most favorite... | When running commands, sometimes I'll want to run a command with the previous ones arguments. To do that, you can use this shortcut:
```
$ mkdir /tmp/new
$ cd !!:*
```
Occasionally, in lieu of using find, I'll break-out a one-line loop if I need to run a bunch of commands on a list of files.
```
for file in *.wav;... |
68,391 | <p>In an effort to reduce code duplication in my little Rails app, I've been working on getting common code between my models into it's own separate module, so far so good.</p>
<p>The model stuff is fairly easy, I just have to include the module at the beginning, e.g.:</p>
<pre><code>class Iso < Sale
include Sha... | [
{
"answer_id": 68934,
"author": "hoyhoy",
"author_id": 3499,
"author_profile": "https://Stackoverflow.com/users/3499",
"pm_score": 3,
"selected": false,
"text": "<p>If that code needs to get added to all models and all controllers, you could always do the following:</p>\n\n<pre><code># m... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/841/"
] | In an effort to reduce code duplication in my little Rails app, I've been working on getting common code between my models into it's own separate module, so far so good.
The model stuff is fairly easy, I just have to include the module at the beginning, e.g.:
```
class Iso < Sale
include Shared::TracksSerialNumberE... | You could pluginize it (use script/generate plugin).
Then in your init.rb just do something like:
```
ActiveRecord::Base.send(:include, PluginName::Sendable)
ActionController::Base.send(:include, PluginName::SendableController)
```
And along with your self.included that should work just fine.
Check out some of the... |
68,408 | <p>Is there any <strong>simple algorithm</strong> to determine the likeliness of 2 names representing the same person? </p>
<p>I'm not asking for something of the level that Custom department might be using. Just a simple algorithm that would tell me if 'James T. Clark' is most likely the same name as 'J. Thomas Clark... | [
{
"answer_id": 68422,
"author": "Antti",
"author_id": 6037,
"author_profile": "https://Stackoverflow.com/users/6037",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://en.wikipedia.org/wiki/Levenshtein_distance\" rel=\"nofollow noreferrer\">Levenshtein</a> is close, although... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3610/"
] | Is there any **simple algorithm** to determine the likeliness of 2 names representing the same person?
I'm not asking for something of the level that Custom department might be using. Just a simple algorithm that would tell me if 'James T. Clark' is most likely the same name as 'J. Thomas Clark' or 'James Clerk'.
If... | I've faced similar problem and tried to use Levenstein distance first, but it did not work well for me. I came up with an algorithm that gives you "similarity" value between two strings (higher value means more similar strings, "1" for identical strings). This value is not very meaningful by itself (if not "1", always ... |
68,444 | <p>We have a program that produces several SWF files, some CSS and XML files, all of which need to be deployed for the thing to work.</p>
<p>Is there a program or technique out there for wrapping all these files together into a single SWF file?</p>
| [
{
"answer_id": 68474,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 0,
"selected": false,
"text": "<p>I think you can just drag them into the library of your main swf and make references to them. At least the other SWFs you ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6277/"
] | We have a program that produces several SWF files, some CSS and XML files, all of which need to be deployed for the thing to work.
Is there a program or technique out there for wrapping all these files together into a single SWF file? | If you use the Flex compiler (`mxmlc` or FlexBuilder) you can embed SWF files and create them at runtime, more or less like you would create any display object:
```
package {
public class Assets {
[Embed(source="another.swf")]
public var another : Class;
}
}
```
The code above embeds the file `anothe... |
68,477 | <p>Is there a way to send a file using POST from a Python script?</p>
| [
{
"answer_id": 68502,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 5,
"selected": false,
"text": "<p>Yes. You'd use the <code>urllib2</code> module, and encode using the <code>multipart/form-data</code> content type. ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | Is there a way to send a file using POST from a Python script? | From: <https://requests.readthedocs.io/en/latest/user/quickstart/#post-a-multipart-encoded-file>
Requests makes it very simple to upload Multipart-encoded files:
```
with open('report.xls', 'rb') as f:
r = requests.post('http://httpbin.org/post', files={'report.xls': f})
```
That's it. I'm not joking - this is ... |
68,485 | <p>In <b>Prototype</b> I can show a "loading..." image with this code:</p>
<pre><code>var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,
onLoading: showLoad, onComplete: showResponse} );
function showLoad () {
...
}
</code></pre>
<p>In <b>jQuery</b>, I can load a server page into an element w... | [
{
"answer_id": 68503,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 11,
"selected": true,
"text": "<p>There are a couple of ways. My preferred way is to attach a function to the ajaxStart/Stop events on the element itself.</p>... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | In **Prototype** I can show a "loading..." image with this code:
```
var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars,
onLoading: showLoad, onComplete: showResponse} );
function showLoad () {
...
}
```
In **jQuery**, I can load a server page into an element with this:
```
$('#message').loa... | There are a couple of ways. My preferred way is to attach a function to the ajaxStart/Stop events on the element itself.
```
$('#loadingDiv')
.hide() // Hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
})
;
```
The ajaxStart/Stop... |
68,509 | <p>If I use the following code I lose the ability to right click on variables in the code behind and refactor (rename in this case) them</p>
<pre><code><a href='<%# "/Admin/Content/EditResource.aspx?ResourceId=" + Eval("Id").ToString() %>'>Edit</a>
</code></pre>
<p>I see this practice everywhere but... | [
{
"answer_id": 68530,
"author": "Kilhoffer",
"author_id": 5469,
"author_profile": "https://Stackoverflow.com/users/5469",
"pm_score": 3,
"selected": true,
"text": "<p>I wouldnt call it bad practice (some would disagree, but why did they give us that option in the first place?), but I wou... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6084/"
] | If I use the following code I lose the ability to right click on variables in the code behind and refactor (rename in this case) them
```
<a href='<%# "/Admin/Content/EditResource.aspx?ResourceId=" + Eval("Id").ToString() %>'>Edit</a>
```
I see this practice everywhere but it seems weird to me as I no longer am able... | I wouldnt call it bad practice (some would disagree, but why did they give us that option in the first place?), but I would say that you'll improve overall readability and maintainability if you do not submit to this practice. You already conveyed out a good point, and that is IDE feature limitation (i.e., design time ... |
68,537 | <p>A basic problem I run into quite often, but ever found a clean solution to, is one where you want to code behaviour for interaction between different objects of a common base class or interface. To make it a bit concrete, I'll throw in an example;</p>
<p><em>Bob has been coding on a strategy game which supports "co... | [
{
"answer_id": 68560,
"author": "Jiaaro",
"author_id": 2908,
"author_profile": "https://Stackoverflow.com/users/2908",
"pm_score": 0,
"selected": false,
"text": "<p>Old idea:</p>\n\n<blockquote>\n <p>Make a class iTerrain and another\n class iUnit which accepts an argument\n which is ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2166173/"
] | A basic problem I run into quite often, but ever found a clean solution to, is one where you want to code behaviour for interaction between different objects of a common base class or interface. To make it a bit concrete, I'll throw in an example;
*Bob has been coding on a strategy game which supports "cool geographic... | Terrain has-a Terrain Attribute
Terrain Attributes are multidimensional.
Units has-a Propulsion.
Propulsion is compatible able with Terrain Attributes.
Units move by a Terrain visit with Propulsion as an argument.
That gets delegated to the Propulsion.
Units *may* get affected by terrain as part of the visit.
U... |
68,541 | <p>When trying to use <code>libxml2</code> as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.</p>
<p>I have installed <code>python25</code> and all <code>libxml2</code> and <code>libxml2-py25</code> related libraries via fink and own the entire path includi... | [
{
"answer_id": 69513,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 2,
"selected": false,
"text": "<p>Check your path by running:</p>\n\n<pre><code>'echo $PATH'\n</code></pre>\n"
},
{
"answer_id": 70895,
"autho... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When trying to use `libxml2` as myself I get an error saying the package cannot be found. If I run as as super user I am able to import fine.
I have installed `python25` and all `libxml2` and `libxml2-py25` related libraries via fink and own the entire path including the library. Any ideas why I'd still need to sudo? | Check your path by running:
```
'echo $PATH'
``` |
68,565 | <p>I like the XMLReader class for it's simplicity and speed. But I like the xml_parse associated functions as it better allows for error recovery. It would be nice if the XMLReader class would throw exceptions for things like invalid entity refs instead of just issuinng a warning.</p>
| [
{
"answer_id": 68580,
"author": "ctcherry",
"author_id": 10322,
"author_profile": "https://Stackoverflow.com/users/10322",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://us2.php.net/simplexml\" rel=\"nofollow noreferrer\">SimpleXML</a> seems to do a good job for me.</p>\n... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I like the XMLReader class for it's simplicity and speed. But I like the xml\_parse associated functions as it better allows for error recovery. It would be nice if the XMLReader class would throw exceptions for things like invalid entity refs instead of just issuinng a warning. | I'd avoid SimpleXML if you can. Though it looks very tempting by getting to avoid a lot of "ugly" code, it's just what the name suggests: simple. For example, it can't handle this:
```
<p>
Here is <strong>a very simple</strong> XML document.
</p>
```
Bite the bullet and go to the DOM Functions. The power of it f... |
68,569 | <p>I am a C++/C# developer and never spent time working on web pages. I would like to put text (randomly and diagonally perhaps) in large letters across the background of some pages. I want to be able to read the foreground text and also be able to read the "watermark". I understand that is probably more of a functi... | [
{
"answer_id": 68591,
"author": "dawnerd",
"author_id": 69503,
"author_profile": "https://Stackoverflow.com/users/69503",
"pm_score": 2,
"selected": false,
"text": "<p>You could make an image with the watermark and then set the image as the background via css.</p>\n\n<p>For example:</p>\... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10755/"
] | I am a C++/C# developer and never spent time working on web pages. I would like to put text (randomly and diagonally perhaps) in large letters across the background of some pages. I want to be able to read the foreground text and also be able to read the "watermark". I understand that is probably more of a function of ... | ```
<style type="text/css">
#watermark {
color: #d0d0d0;
font-size: 200pt;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
height: 100%;
margin: 0;
z-index: -1;
left:-100px;
top:-200px;
}
</style>
```
This lets you use just text as the watermar... |
68,572 | <p>I have a question that I may be over thinking at this point but here goes...</p>
<p>I have 2 classes Users and Groups. Users and groups have a many to many relationship and I was thinking that the join table group_users I wanted to have an IsAuthorized property (because some groups are private -- users will need au... | [
{
"answer_id": 68591,
"author": "dawnerd",
"author_id": 69503,
"author_profile": "https://Stackoverflow.com/users/69503",
"pm_score": 2,
"selected": false,
"text": "<p>You could make an image with the watermark and then set the image as the background via css.</p>\n\n<p>For example:</p>\... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1385358/"
] | I have a question that I may be over thinking at this point but here goes...
I have 2 classes Users and Groups. Users and groups have a many to many relationship and I was thinking that the join table group\_users I wanted to have an IsAuthorized property (because some groups are private -- users will need authorizati... | ```
<style type="text/css">
#watermark {
color: #d0d0d0;
font-size: 200pt;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
height: 100%;
margin: 0;
z-index: -1;
left:-100px;
top:-200px;
}
</style>
```
This lets you use just text as the watermar... |
68,578 | <p>Is there a way to fall through multiple case statements without stating <code>case value:</code> repeatedly?</p>
<p>I know this works:</p>
<pre><code>switch (value)
{
case 1:
case 2:
case 3:
// Do some stuff
break;
case 4:
case 5:
case 6:
// Do some different stuff
break;
... | [
{
"answer_id": 68611,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 10,
"selected": true,
"text": "<p>There is no syntax in C++ nor C# for the second method you mentioned. </p>\n\n<p>There's nothing wrong with your fi... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7870/"
] | Is there a way to fall through multiple case statements without stating `case value:` repeatedly?
I know this works:
```
switch (value)
{
case 1:
case 2:
case 3:
// Do some stuff
break;
case 4:
case 5:
case 6:
// Do some different stuff
break;
default:
// Default st... | There is no syntax in C++ nor C# for the second method you mentioned.
There's nothing wrong with your first method. If however you have very big ranges, just use a series of if statements. |
68,583 | <p>I have the following code snippet.</p>
<pre><code>$items['A'] = "Test";
$items['B'] = "Test";
$items['C'] = "Test";
$items['D'] = "Test";
$index = 0;
foreach($items as $key => $value)
{
echo "$index is a $key containing $value\n";
$index++;
}
</code></pre>
<p>Expected output:</p>
<pre><code>0 is a A c... | [
{
"answer_id": 68612,
"author": "Brent",
"author_id": 10680,
"author_profile": "https://Stackoverflow.com/users/10680",
"pm_score": 5,
"selected": true,
"text": "<p>Your $index variable there kind of misleading. That number isn't the index, your \"A\", \"B\", \"C\", \"D\" keys are. You c... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | I have the following code snippet.
```
$items['A'] = "Test";
$items['B'] = "Test";
$items['C'] = "Test";
$items['D'] = "Test";
$index = 0;
foreach($items as $key => $value)
{
echo "$index is a $key containing $value\n";
$index++;
}
```
Expected output:
```
0 is a A containing Test
1 is a B containing Test
... | Your $index variable there kind of misleading. That number isn't the index, your "A", "B", "C", "D" keys are. You can still access the data through the numbered index $index[1], but that's really not the point. If you really want to keep the numbered index, I'd almost restructure the data:
```
$items[] = array("A", "... |
68,598 | <p>I've seen this done in Borland's <a href="https://en.wikipedia.org/wiki/Turbo_C++" rel="noreferrer">Turbo C++</a> environment, but I'm not sure how to go about it for a C# application I'm working on. Are there best practices or gotchas to look out for?</p>
| [
{
"answer_id": 68722,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 6,
"selected": false,
"text": "<p>In Windows Forms, set the control's AllowDrop property, then listen for DragEnter event and DragDrop event.</p... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've seen this done in Borland's [Turbo C++](https://en.wikipedia.org/wiki/Turbo_C++) environment, but I'm not sure how to go about it for a C# application I'm working on. Are there best practices or gotchas to look out for? | Some sample code:
```
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}
void Form1_DragEnter(object sender, DragEvent... |
68,610 | <p>I am having problems getting text within a table to appear centered in IE. </p>
<p>In Firefox 2, 3 and Safari everything work fine, but for some reason, the text doesn't appear centered in IE 6 or 7. </p>
<p>I'm using:</p>
<pre class="lang-css prettyprint-override"><code>h2 {
font: 300 12px "Helvetica", serif; ... | [
{
"answer_id": 68621,
"author": "Mike Becatti",
"author_id": 6617,
"author_profile": "https://Stackoverflow.com/users/6617",
"pm_score": 3,
"selected": true,
"text": "<p>The table cell needs the text-align: center.</p>\n"
},
{
"answer_id": 68637,
"author": "nickf",
"autho... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10761/"
] | I am having problems getting text within a table to appear centered in IE.
In Firefox 2, 3 and Safari everything work fine, but for some reason, the text doesn't appear centered in IE 6 or 7.
I'm using:
```css
h2 {
font: 300 12px "Helvetica", serif;
text-align: center;
text-transform: uppercase;
}
```
I'... | The table cell needs the text-align: center. |
68,624 | <p>I would like to parse a string such as <code>p1=6&p2=7&p3=8</code> into a <code>NameValueCollection</code>.</p>
<p>What is the most elegant way of doing this when you don't have access to the <code>Page.Request</code> object?</p>
| [
{
"answer_id": 68639,
"author": "Mark Glorie",
"author_id": 952,
"author_profile": "https://Stackoverflow.com/users/952",
"pm_score": 0,
"selected": false,
"text": "<p>Hit up Request.QueryString.Keys for a NameValueCollection of all query string parameters.</p>\n"
},
{
"answer_id... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4998/"
] | I would like to parse a string such as `p1=6&p2=7&p3=8` into a `NameValueCollection`.
What is the most elegant way of doing this when you don't have access to the `Page.Request` object? | There's a built-in .NET utility for this: [HttpUtility.ParseQueryString](http://msdn.microsoft.com/en-us/library/ms150046.aspx)
```cs
// C#
NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);
```
```vb
' VB.NET
Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(querystring)
```
Yo... |
68,630 | <p>Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? </p>
| [
{
"answer_id": 68638,
"author": "ctcherry",
"author_id": 10322,
"author_profile": "https://Stackoverflow.com/users/10322",
"pm_score": 2,
"selected": false,
"text": "<p>Tuples should be slightly more efficient and because of that, faster, than lists because they are immutable.</p>\n"
}... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | Is there any performance difference between tuples and lists when it comes to instantiation and retrieval of elements? | The [`dis`](https://docs.python.org/3/library/dis.html) module disassembles the byte code for a function and is useful to see the difference between tuples and lists.
In this case, you can see that accessing an element generates identical code, but that assigning a tuple is much faster than assigning a list.
```
>>> ... |
68,633 | <p>I need a Regex that will match a java method declaration. I have come up with one that will match a method declaration, but it requires the opening bracket of the method to be on the same line as the declaration. If you have any suggestions to improve my regex or simply have a better one then please submit an answer... | [
{
"answer_id": 68669,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 3,
"selected": true,
"text": "<p>Have you considered matching the actual possible keywords? such as:</p>\n\n<pre><code>(?:(?:public)|(?:private)|(?:static... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/340/"
] | I need a Regex that will match a java method declaration. I have come up with one that will match a method declaration, but it requires the opening bracket of the method to be on the same line as the declaration. If you have any suggestions to improve my regex or simply have a better one then please submit an answer.
... | Have you considered matching the actual possible keywords? such as:
```
(?:(?:public)|(?:private)|(?:static)|(?:protected)\s+)*
```
It might be a bit more likely to match correctly, though it might also make the regex harder to read... |
68,640 | <p>Is it possible in C# to have a Struct with a member variable which is a Class type? If so, where does the information get stored, on the Stack, the Heap, or both?</p>
| [
{
"answer_id": 68681,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, you can. The pointer to the class member variable is stored <strike>on the stack</strike> with the rest of the s... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10722/"
] | Is it possible in C# to have a Struct with a member variable which is a Class type? If so, where does the information get stored, on the Stack, the Heap, or both? | Yes, you can. The pointer to the class member variable is stored on the stack with the rest of the struct's values, and the class instance's data is stored on the heap.
Structs can also contain class definitions as members (inner classes).
Here's some really useless code that at least compiles and runs to show that i... |
68,645 | <p>How do I create class (i.e. <a href="https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods" rel="nofollow noreferrer">static</a>) variables or methods in Python?</p>
| [
{
"answer_id": 68672,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 12,
"selected": true,
"text": "<p>Variables declared inside the class definition, but not inside a method are class or static variables:</p>\n<pre><cod... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2246/"
] | How do I create class (i.e. [static](https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods)) variables or methods in Python? | Variables declared inside the class definition, but not inside a method are class or static variables:
```
>>> class MyClass:
... i = 3
...
>>> MyClass.i
3
```
As @[millerdev](https://stackoverflow.com/questions/68645/static-class-variables-in-python#answer-69067) points out, this creates a class-level `i` vari... |
68,651 | <p>If I pass PHP variables with <code>.</code> in their names via $_GET PHP auto-replaces them with <code>_</code> characters. For example:</p>
<pre><code><?php
echo "url is ".$_SERVER['REQUEST_URI']."<p>";
echo "x.y is ".$_GET['x.y'].".<p>";
echo "x_y is ".$_GET['x_y'].".<p>";
</code></pre>
<p>.... | [
{
"answer_id": 68710,
"author": "Jeremy Privett",
"author_id": 560,
"author_profile": "https://Stackoverflow.com/users/560",
"pm_score": 2,
"selected": false,
"text": "<p>The reason this happens is because of PHP's old register_globals functionality. The . character is not a valid charac... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I pass PHP variables with `.` in their names via $\_GET PHP auto-replaces them with `_` characters. For example:
```
<?php
echo "url is ".$_SERVER['REQUEST_URI']."<p>";
echo "x.y is ".$_GET['x.y'].".<p>";
echo "x_y is ".$_GET['x_y'].".<p>";
```
... outputs the following:
```
url is /SpShipTool/php/testGetUrl.php... | Here's PHP.net's explanation of why it does it:
>
> ### Dots in incoming variable names
>
>
> Typically, PHP does not alter the
> names of variables when they are
> passed into a script. However, it
> should be noted that the dot (period,
> full stop) is not a valid character in
> a PHP variable name. For the reaso... |
68,666 | <p>Why does the following code sometimes causes an Exception with the contents "CLIPBRD_E_CANT_OPEN":</p>
<pre><code>Clipboard.SetText(str);
</code></pre>
<p>This usually occurs the first time the Clipboard is used in the application and not after that.</p>
| [
{
"answer_id": 68857,
"author": "Tadmas",
"author_id": 3750,
"author_profile": "https://Stackoverflow.com/users/3750",
"pm_score": 6,
"selected": true,
"text": "<p>Actually, I think this is the <a href=\"https://cloudblogs.microsoft.com/enterprisemobility/2006/11/20/why-does-my-shared-cl... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10784/"
] | Why does the following code sometimes causes an Exception with the contents "CLIPBRD\_E\_CANT\_OPEN":
```
Clipboard.SetText(str);
```
This usually occurs the first time the Clipboard is used in the application and not after that. | Actually, I think this is the [fault of the Win32 API](https://cloudblogs.microsoft.com/enterprisemobility/2006/11/20/why-does-my-shared-clipboard-not-work-part-2/).
To set data in the clipboard, you have to [open it](http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx) first. Only one process can have the cl... |
68,677 | <p>I'm using SQL Server 2000 to print out some values from a table using <code>PRINT</code>. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:</p>
<pre><code>DECLARE @binvalue binary(4)
SET @binvalue... | [
{
"answer_id": 68858,
"author": "Ricardo C",
"author_id": 232589,
"author_profile": "https://Stackoverflow.com/users/232589",
"pm_score": 2,
"selected": false,
"text": "<pre><code>DECLARE @binvalue binary(4)\nSET @binvalue = 0x61000000\nPRINT @binvalue \nPRINT cast('a' AS binary(4))\nPRI... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3750/"
] | I'm using SQL Server 2000 to print out some values from a table using `PRINT`. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:
```
DECLARE @binvalue binary(4)
SET @binvalue = 0x12345678
PRINT CAST(@b... | If you were on Sql Server 2005 you could use this:
```
print master.sys.fn_varbintohexstr(@binvalue)
```
I don't think that exists on 2000, though, so you might have to roll your own. |
68,688 | <p>What is the best solution of defaultButton and "Enter key pressed" for ASP.NET 2.0-3.5 forms?</p>
| [
{
"answer_id": 68700,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<p>Just add the \"defaultbutton\" attribute to the form and set it to the ID of the button you want to be the default. </p>\n\n... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10778/"
] | What is the best solution of defaultButton and "Enter key pressed" for ASP.NET 2.0-3.5 forms? | Just add the "defaultbutton" attribute to the form and set it to the ID of the button you want to be the default.
```
<form defaultbutton="button1" runat="server">
<asp:textbox id="textbox1" runat="server"/>
<asp:button id="button1" text="Button1" runat="server"/>
</form>
```
NOTE: This only works in ASP.NE... |
68,711 | <p>any idea how if the following is possible in PHP as a single line ?:</p>
<pre><code><?php
$firstElement = functionThatReturnsAnArray()[0];
</code></pre>
<p>... It doesn't seem to 'take'. I need to do this as a 2-stepper:</p>
<pre><code><?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allE... | [
{
"answer_id": 68716,
"author": "owenmarshall",
"author_id": 9806,
"author_profile": "https://Stackoverflow.com/users/9806",
"pm_score": 3,
"selected": false,
"text": "<p>Unfortunately, that is not possible with PHP. You have to use two lines to do it.</p>\n"
},
{
"answer_id": 68... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | any idea how if the following is possible in PHP as a single line ?:
```
<?php
$firstElement = functionThatReturnsAnArray()[0];
```
... It doesn't seem to 'take'. I need to do this as a 2-stepper:
```
<?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
```
... just curious - other ... | Try:
```
<?php
$firstElement = reset(functionThatReturnsAnArray());
```
If you're just looking for the first element of the array. |
68,750 | <p>This should hopefully be a simple one.</p>
<p>I would like to add an extension method to the System.Web.Mvc.ViewPage< T > class.</p>
<p>How should this extension method look?</p>
<p>My first intuitive thought is something like this:</p>
<pre><code>namespace System.Web.Mvc
{
public static class ViewPageExt... | [
{
"answer_id": 68772,
"author": "David Thibault",
"author_id": 5903,
"author_profile": "https://Stackoverflow.com/users/5903",
"pm_score": 5,
"selected": true,
"text": "<p>I don't have VS installed on my current machine, but I think the syntax would be:</p>\n\n<pre><code>namespace System... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | This should hopefully be a simple one.
I would like to add an extension method to the System.Web.Mvc.ViewPage< T > class.
How should this extension method look?
My first intuitive thought is something like this:
```
namespace System.Web.Mvc
{
public static class ViewPageExtensions
{
public static st... | I don't have VS installed on my current machine, but I think the syntax would be:
```
namespace System.Web.Mvc
{
public static class ViewPageExtensions
{
public static string GetDefaultPageTitle<T>(this ViewPage<T> v)
{
return "";
}
}
}
``` |
68,774 | <p>I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?</p>
| [
{
"answer_id": 68796,
"author": "The.Anti.9",
"author_id": 2128,
"author_profile": "https://Stackoverflow.com/users/2128",
"pm_score": 7,
"selected": true,
"text": "<p>Opening sockets in python is pretty simple. You really just need something like this:</p>\n\n<pre><code>import socket\ns... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] | I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way? | Opening sockets in python is pretty simple. You really just need something like this:
```
import socket
sock = socket.socket()
sock.connect((address, port))
```
and then you can `send()` and `recv()` like any other socket |
68,843 | <p>How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place?</p>
<p>Moreover, if I specify <code>sleep(1,1,"xyz")</code> or any arbitrary number of arguments, the compiler still compiles it.
But the strange thing is that gcc is able t... | [
{
"answer_id": 68861,
"author": "Jason Dagit",
"author_id": 5113,
"author_profile": "https://Stackoverflow.com/users/5113",
"pm_score": 2,
"selected": false,
"text": "<p>C will guess int for unknown types. So, it probably thinks sleep has this prototype:</p>\n\n<pre><code>int sleep(int)... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How does the compiler know the prototype of sleep function or even printf function, when I did not include any header file in the first place?
Moreover, if I specify `sleep(1,1,"xyz")` or any arbitrary number of arguments, the compiler still compiles it.
But the strange thing is that gcc is able to find the definition... | Lacking a more specific prototype, the compiler will assume that the function returns int and takes whatever number of arguments you provide.
Depending on the CPU architecture arguments can be passed in registers (for example, a0 through a3 on MIPS) or by pushing them onto the stack as in the original x86 calling conv... |
68,993 | <p>Say I have a line in an emacs buffer that looks like this:</p>
<pre><code>foo -option1 value1 -option2 value2 -option3 value3 \
-option4 value4 ...
</code></pre>
<p>I want it to look like this:</p>
<pre><code>foo -option1 value1 \
-option2 value2 \
-option3 value3 \
-option4 value4 \
...
</cod... | [
{
"answer_id": 69032,
"author": "Jason Dagit",
"author_id": 5113,
"author_profile": "https://Stackoverflow.com/users/5113",
"pm_score": 1,
"selected": false,
"text": "<p>In this case I would use a macro. You can start recording a macro with C-x (, and stop recording it with C-x ). When... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7432/"
] | Say I have a line in an emacs buffer that looks like this:
```
foo -option1 value1 -option2 value2 -option3 value3 \
-option4 value4 ...
```
I want it to look like this:
```
foo -option1 value1 \
-option2 value2 \
-option3 value3 \
-option4 value4 \
...
```
I want each option/value pair on a s... | Nobody had what I was looking for so I decided to dust off my elisp manual and do it myself. This seems to work well enough, though the output isn't precisely what I asked for. In this version the first option goes on a line by itself instead of staying on the first line like in my original question.
```lisp
(defun tc... |
68,999 | <p>I'm using a Java socket, connected to a server.
If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is there an easier way?</p>
<p>I'm looking for a short answer, I don't want to use other protocols etc. Obviously do I neither want to have a so... | [
{
"answer_id": 69105,
"author": "hoyhoy",
"author_id": 3499,
"author_profile": "https://Stackoverflow.com/users/3499",
"pm_score": 4,
"selected": false,
"text": "<p>You can use time and curl and time on the command-line. The -I argument for curl instructs it to only request the header.<... | 2008/09/16 | [
"https://Stackoverflow.com/questions/68999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10889/"
] | I'm using a Java socket, connected to a server.
If I send a HEADER http request, how can I measure the response time from the server? Must I use a provided java timer, or is there an easier way?
I'm looking for a short answer, I don't want to use other protocols etc. Obviously do I neither want to have a solution tha... | I would say it depends on what exact interval you are trying measure, the amount of time from the last byte of the request that you send until the first byte of the response that you receive? Or until the entire response is received? Or are you trying to measure the server-side time only?
If you're trying to measure t... |
69,000 | <p>I have a WPF application in VS 2008 with some web service references. For varying reasons (max message size, authentication methods) I need to manually define a number of settings in the WPF client's app.config for the service bindings.</p>
<p>Unfortunately, this means that when I update the service references in t... | [
{
"answer_id": 69154,
"author": "cruizer",
"author_id": 6441,
"author_profile": "https://Stackoverflow.com/users/6441",
"pm_score": 0,
"selected": false,
"text": "<p>Somehow I prefer using svcutil.exe directly than to use the \"Add Service Reference\" feature of Visual Studio :P This is ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10890/"
] | I have a WPF application in VS 2008 with some web service references. For varying reasons (max message size, authentication methods) I need to manually define a number of settings in the WPF client's app.config for the service bindings.
Unfortunately, this means that when I update the service references in the project... | Create a .Bat file which uses svcutil, for proxygeneration, that has the settings that is right for your project. It's fairly easy. Clicking on the batfile, to generate new proxyfiles whenever the interface have been changed is easy.
The batch can then later be used in automated builds. Then you only need to set up th... |
69,030 | <p>I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help m... | [
{
"answer_id": 69404,
"author": "tjw",
"author_id": 11029,
"author_profile": "https://Stackoverflow.com/users/11029",
"pm_score": 3,
"selected": true,
"text": "<p>Using /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app you can use the built-in accessibilit... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10906/"
] | I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu.
... | Using /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app you can use the built-in accessibility system to look at properties of the UI element under the mouse. Take special note of the cmd-F7 action to lock focus on an element and the Refresh button. Sadly the element and property names d... |
69,068 | <p>How can I split long commands over multiple lines in a batch file?</p>
| [
{
"answer_id": 69079,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 11,
"selected": true,
"text": "<p>You can break up long lines with the caret <code>^</code> as long as you remember that the caret and the newline following i... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I split long commands over multiple lines in a batch file? | You can break up long lines with the caret `^` as long as you remember that the caret and the newline following it are completely removed. So, if there should be a space where you're breaking the line, include a space. *([More on that below.](https://stackoverflow.com/a/21000752/157247))*
Example:
```
copy file1.txt ... |
69,089 | <p>We have a web application that uses SQL Server 2008 as the database. Our users are able to do full-text searches on particular columns in the database. SQL Server's full-text functionality does not seem to provide support for hit highlighting. Do we need to build this ourselves or is there perhaps some library or kn... | [
{
"answer_id": 74932,
"author": "WIDBA",
"author_id": 10868,
"author_profile": "https://Stackoverflow.com/users/10868",
"pm_score": 1,
"selected": false,
"text": "<p>You might be missing the point of the database in this instance. Its job is to return the data to you that satisfies the ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1899/"
] | We have a web application that uses SQL Server 2008 as the database. Our users are able to do full-text searches on particular columns in the database. SQL Server's full-text functionality does not seem to provide support for hit highlighting. Do we need to build this ourselves or is there perhaps some library or knowl... | Expanding on Ishmael's idea, it's not the final solution, but I think it's a good way to start.
Firstly we need to get the list of words that have been retrieved with the full-text engine:
```
declare @SearchPattern nvarchar(1000) = 'FORMSOF (INFLECTIONAL, " ' + @SearchString + ' ")'
declare @SearchWords table (Wo... |
69,104 | <p>A J2ME client is sending HTTP POST requests with chunked transfer encoding.</p>
<p>When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.</p>
<p>However, when I read the Reques... | [
{
"answer_id": 80576,
"author": "Andrew",
"author_id": 15127,
"author_profile": "https://Stackoverflow.com/users/15127",
"pm_score": 1,
"selected": false,
"text": "<p>That url does not work any more, so it's hard to test this directly. I wondered if this would work, and google turned up... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209/"
] | A J2ME client is sending HTTP POST requests with chunked transfer encoding.
When ASP.NET (in both IIS6 and WebDev.exe.server) tries to read the request it sets the Content-Length to 0. I guess this is ok because the Content-length is unknown when the request is loaded.
However, when I read the Request.InputStream to ... | Seems to be official: [Cassini does not support `Transfer-Encoding: chunked` requests.](http://msdn.microsoft.com/en-us/library/ee960144.aspx)
>
> By default, the client sends large
> binary streams by using a chunked HTTP
> Transfer-Encoding. **Because the ASP.NET
> Development Server does not support
> this kin... |
69,107 | <p>What is the best way to refactor the attached code to accommodate multiple email addresses?</p>
<p>The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email... | [
{
"answer_id": 69148,
"author": "Pandincus",
"author_id": 2273,
"author_profile": "https://Stackoverflow.com/users/2273",
"pm_score": 3,
"selected": true,
"text": "<p>Instead of using IDs for your email fields, you can give them each a class:</p>\n\n<pre><code><div>\n <label ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] | What is the best way to refactor the attached code to accommodate multiple email addresses?
The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email address f... | Instead of using IDs for your email fields, you can give them each a class:
```
<div>
<label for="Email_Address_1">Friend #1</label></div>
<input type="text" class="email">
<span></span>
</div>
<div>
<label for="Email_Address_2">Friend #2</label></div>
<input type="text" class="email">
<span></... |
69,115 | <p>Below is my current char* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is there any trick or other way that I am missing?</p>
<p>How can I make this faster?</p>
<p>Compiled with -O3 in g++</p>
<pre><code>static con... | [
{
"answer_id": 69126,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 2,
"selected": false,
"text": "<p>For one, instead of multiplying by <code>16</code> do a <code>bitshift << 4</code></p>\n\n<p>Also don't use t... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/716/"
] | Below is my current char\* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is there any trick or other way that I am missing?
How can I make this faster?
Compiled with -O3 in g++
```
static const char _hex2asciiU_value[2... | At the cost of more memory you can create a full 256-entry table of the hex codes:
```
static const char _hex2asciiU_value[256][2] =
{ {'0','0'}, {'0','1'}, /* ..., */ {'F','E'},{'F','F'} };
```
Then direct index into the table, no bit fiddling required.
```
const char *pHexVal = pHex[*pChar];
pszHex[0] = pHexV... |
69,159 | <p>I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out: </p>
<pre><code>"Too Many Connections"
</code></pre>
<p>I can't log in anywhere to close the connections manually. </p>... | [
{
"answer_id": 69171,
"author": "owenmarshall",
"author_id": 9806,
"author_profile": "https://Stackoverflow.com/users/9806",
"pm_score": 1,
"selected": false,
"text": "<p>If you can't log into MySQL at all, you will probably have to contact your hosting provider to kill the connections.<... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9803/"
] | I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out:
```
"Too Many Connections"
```
I can't log in anywhere to close the connections manually.
**Is that any way to close o... | If you can't log into MySQL at all, you will probably have to contact your hosting provider to kill the connections.
If you can use the MySQL shell, you can use the [show processlist](http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html) command to view connections, then use the [kill](http://dev.mysql.com/doc... |
69,188 | <p><a href="http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx" rel="nofollow noreferrer">http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx</a></p>
<p>This post shows how to test setting a cookie and then seeing ... | [
{
"answer_id": 69535,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": -1,
"selected": false,
"text": "<pre><code>function ReadCookie(cookieName) {\n var theCookie=\"\"+document.cookie;\n var ind=theCookie.indexOf(cookie... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/438/"
] | <http://stephenwalther.com/blog/archive/2008/07/01/asp-net-mvc-tip-12-faking-the-controller-context.aspx>
This post shows how to test setting a cookie and then seeing it in ViewData. What I what to do is see if the correct cookies were written (values and name). Any reply, blog post or article will be greatly apprecia... | Are you looking for something more like this? (untested, just typed it up in the reply box)
```
var cookies = new HttpCookieCollection();
controller.ControllerContext = new FakeControllerContext(controller, cookies);
var result = controller.TestCookie() as ViewResult;
Assert.AreEqual("somevaluethatshouldbethere", cook... |
69,192 | <p>Suppose we have two stacks and no other temporary variable.</p>
<p>Is to possible to "construct" a queue data structure using only the two stacks?</p>
| [
{
"answer_id": 69206,
"author": "Tyler",
"author_id": 3561,
"author_profile": "https://Stackoverflow.com/users/3561",
"pm_score": 4,
"selected": false,
"text": "<p>The time complexities would be worse, though. A good queue implementation does everything in constant time.</p>\n\n<p><stro... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7086/"
] | Suppose we have two stacks and no other temporary variable.
Is to possible to "construct" a queue data structure using only the two stacks? | Keep 2 stacks, let's call them `inbox` and `outbox`.
**Enqueue**:
* Push the new element onto `inbox`
**Dequeue**:
* If `outbox` is empty, refill it by popping each element from `inbox` and pushing it onto `outbox`
* Pop and return the top element from `outbox`
Using this method, each element will be in each stack... |
69,209 | <p>Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node?After deletion the previous node should point to the node next to deleted node. </p>
| [
{
"answer_id": 69214,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<p>yes, but you can't delink it. If you don't care about corrupting memory, go ahead ;-)</p>\n"
},
{
"answer_i... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7086/"
] | Is it possible to delete a middle node in the single linked list when the only information available we have is the pointer to the node to be deleted and not the pointer to the previous node?After deletion the previous node should point to the node next to deleted node. | It's definitely more a quiz rather than a real problem. However, if we are allowed to make some assumption, it can be solved in O(1) time. To do it, the strictures the list points to must be copyable. The algorithm is as the following:
We have a list looking like: ... -> Node(i-1) -> Node(i) -> Node(i+1) -> ... and we... |
69,250 | <p>In most C or C++ environments, there is a "debug" mode and a "release" mode compilation.<br>
Looking at the difference between the two, you find that the debug mode adds the debug symbols (often the -g option on lots of compilers) but it also disables most optimizations.<br>
In "release" mode, you usually have all s... | [
{
"answer_id": 69252,
"author": "Benoit",
"author_id": 10703,
"author_profile": "https://Stackoverflow.com/users/10703",
"pm_score": 6,
"selected": true,
"text": "<p>Without any optimization on, the flow through your code is linear. If you are on line 5 and single step, you step to line... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10703/"
] | In most C or C++ environments, there is a "debug" mode and a "release" mode compilation.
Looking at the difference between the two, you find that the debug mode adds the debug symbols (often the -g option on lots of compilers) but it also disables most optimizations.
In "release" mode, you usually have all sorts ... | Without any optimization on, the flow through your code is linear. If you are on line 5 and single step, you step to line 6. With optimization on, you can get instruction re-ordering, loop unrolling and all sorts of optimizations.
For example:
```
void foo() {
1: int i;
2: for(i = 0; i < 2; )
3: i++;
4: retu... |
69,262 | <p>I am wondering if there is a method or format string I'm missing in .NET to convert the following:</p>
<pre><code> 1 to 1st
2 to 2nd
3 to 3rd
4 to 4th
11 to 11th
101 to 101st
111 to 111th
</code></pre>
<p><a href="http://www.dotnet-friends.com/fastcode/csharp/fastcodeincsc3bd4149-03d0-40fe-90fd-63bc... | [
{
"answer_id": 69279,
"author": "Scott Hanselman",
"author_id": 6380,
"author_profile": "https://Stackoverflow.com/users/6380",
"pm_score": 7,
"selected": true,
"text": "<p>No, there is no inbuilt capability in the .NET Base Class Library.</p>\n"
},
{
"answer_id": 69284,
"aut... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I am wondering if there is a method or format string I'm missing in .NET to convert the following:
```
1 to 1st
2 to 2nd
3 to 3rd
4 to 4th
11 to 11th
101 to 101st
111 to 111th
```
[This link](http://www.dotnet-friends.com/fastcode/csharp/fastcodeincsc3bd4149-03d0-40fe-90fd-63bcee77b43e.aspx) has a ba... | No, there is no inbuilt capability in the .NET Base Class Library. |
69,275 | <p>I'm trying to draw a graph on an ASP webpage. I'm hoping an API can be helpful, but so far I have not been able to find one. </p>
<p>The graph contains labeled nodes and unlabeled directional edges.
The ideal output would be something like <a href="http://en.wikipedia.org/wiki/Image:6n-graf.svg" rel="noreferrer">th... | [
{
"answer_id": 69285,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure about ASP interface, but you may want to check out <a href=\"http://www.graphviz.org/\" rel=\"nofollow no... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/165305/"
] | I'm trying to draw a graph on an ASP webpage. I'm hoping an API can be helpful, but so far I have not been able to find one.
The graph contains labeled nodes and unlabeled directional edges.
The ideal output would be something like [this](http://en.wikipedia.org/wiki/Image:6n-graf.svg).
Anybody know of anything pre... | Definitely [graphviz](http://graphviz.org). The image on the wikipedia link you are pointing at was made in graphviz. From its description page the graph description file looked like this:
```
graph untitled {
graph[bgcolor="transparent"];
node [fontname="Bitstream Vera Sans", fontsize="22.00", shape=circle, s... |
69,277 | <p>I have an Enumerable array</p>
<pre><code>int meas[] = new double[] {3, 6, 9, 12, 15, 18};
</code></pre>
<p>On each successive call to the mock's method that I'm testing I want to return a value from that array.</p>
<pre><code>using(_mocks.Record()) {
Expect.Call(mocked_class.GetValue()).Return(meas);
}
using(... | [
{
"answer_id": 69382,
"author": "vrdhn",
"author_id": 414441,
"author_profile": "https://Stackoverflow.com/users/414441",
"pm_score": 0,
"selected": false,
"text": "<p>IMHO, yield will handle this.\n<a href=\"http://msdn.microsoft.com/en-us/library/9k7k7cf0%28VS.80%29.aspx\" rel=\"nofoll... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have an Enumerable array
```
int meas[] = new double[] {3, 6, 9, 12, 15, 18};
```
On each successive call to the mock's method that I'm testing I want to return a value from that array.
```
using(_mocks.Record()) {
Expect.Call(mocked_class.GetValue()).Return(meas);
}
using(_mocks.Playback()) {
foreach(var i ... | There is alway static fake object, but this question is about rhino-mocks, so I present you with the way I'll do it.
The trick is that you create a local variable as the counter, and use it in your anonymous delegate/lambda to keep track of where you are on the array. Notice that I didn't handle the case that GetValue(... |
69,296 | <p>I have a a property defined as:</p>
<pre><code>[XmlArray("delete", IsNullable = true)]
[XmlArrayItem("contact", typeof(ContactEvent)),
XmlArrayItem("sms", typeof(SmsEvent))]
public List<Event> Delete { get; set; }
</code></pre>
<p>If the List<> Delete has no items</p>
<pre><code><delete />
</code>... | [
{
"answer_id": 69315,
"author": "Craig Eddy",
"author_id": 5557,
"author_profile": "https://Stackoverflow.com/users/5557",
"pm_score": 0,
"selected": false,
"text": "<p>You could always implement IXmlSerializer and perform the serialization manually.</p>\n\n<p>See <a href=\"http://www.co... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2281/"
] | I have a a property defined as:
```
[XmlArray("delete", IsNullable = true)]
[XmlArrayItem("contact", typeof(ContactEvent)),
XmlArrayItem("sms", typeof(SmsEvent))]
public List<Event> Delete { get; set; }
```
If the List<> Delete has no items
```
<delete />
```
is emitted. If the List<> Delete is set to null
```
... | If you set IsNullable=false or just remove it (it is false by default), then the "delete" element will not be emitted. This will work only if the collection equals to null.
My guess is that there is a confusion between "nullability" in terms of .NET, and the one related to nullable elements in XML -- those that are ma... |
69,352 | <p>What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu item, but I can't seem to find an event to trigger to minimize the fo... | [
{
"answer_id": 69359,
"author": "JP Richardson",
"author_id": 10333,
"author_profile": "https://Stackoverflow.com/users/10333",
"pm_score": 5,
"selected": false,
"text": "<pre><code>FormName.WindowState = FormWindowState.Minimized;\n</code></pre>\n"
},
{
"answer_id": 69362,
"... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7516/"
] | What I'm doing is I have a full-screen form, with no title bar, and consequently lacks the minimize/maximize/close buttons found in the upper-right hand corner. I'm wanting to replace that functionality with a keyboard short-cut and a context menu item, but I can't seem to find an event to trigger to minimize the form. | ```
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == 'm')
this.WindowState = FormWindowState.Minimized;
}
``` |
69,391 | <p>In OS X, in order to quickly get at menu items from the keyboard, I want to be able to type a key combination, have it run a script, and have the script focus the Search field in the Help menu. It should work just like the key combination for Spotlight, so if I run it again, it should dismiss the menu. I can run t... | [
{
"answer_id": 69393,
"author": "easeout",
"author_id": 10906,
"author_profile": "https://Stackoverflow.com/users/10906",
"pm_score": 2,
"selected": true,
"text": "<p>Here is the script I came up with.</p>\n\n<pre><code>tell application \"System Events\"\n tell (first process whose fr... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10906/"
] | In OS X, in order to quickly get at menu items from the keyboard, I want to be able to type a key combination, have it run a script, and have the script focus the Search field in the Help menu. It should work just like the key combination for Spotlight, so if I run it again, it should dismiss the menu. I can run the sc... | Here is the script I came up with.
```
tell application "System Events"
tell (first process whose frontmost is true)
click menu "Help" of menu bar 1
end tell
end tell
``` |
69,398 | <p>i have scenario where i have to provide my own control template for a few WPF controls - i.e. GridViewHeader. when you take a look at control template for GridViewHEader in blend, it is agregated from several other controls, which in some cases are styled for that control only - i.e. this splitter between columns.
... | [
{
"answer_id": 69427,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 2,
"selected": false,
"text": "<p>Referencing internal resources that are 100% subject to change isn't serviceable - better to just copy it. </p>\n"
},
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11013/"
] | i have scenario where i have to provide my own control template for a few WPF controls - i.e. GridViewHeader. when you take a look at control template for GridViewHEader in blend, it is agregated from several other controls, which in some cases are styled for that control only - i.e. this splitter between columns.
tho... | Referencing internal resources that are 100% subject to change isn't serviceable - better to just copy it. |
69,411 | <p>What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both. </p>
| [
{
"answer_id": 69418,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 3,
"selected": false,
"text": "<p>rsync -avlzp /path/to/folder [email protected]:/path/to/remote/folder</p>\n"
},
{
"answer_id": 69419,
"auth... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both. | There are two ways I usually do this, both use ssh:
```
scp -r sourcedir/ [email protected]:/dest/dir/
```
or, the more robust and faster (in terms of transfer speed) method:
```
rsync -auv -e ssh --progress sourcedir/ [email protected]:/dest/dir/
```
Read the man pages for each command if you want more details about how... |
69,430 | <p>I'm building an HTML UI with some text elements, such as tab names, which look bad when selected. Unfortunately, it's very easy for a user to double-click a tab name, which selects it by default in many browsers.</p>
<p>I might be able to solve this with a JavaScript trick (I'd like to see those answers, too) -- bu... | [
{
"answer_id": 69474,
"author": "Dave Rutledge",
"author_id": 2486915,
"author_profile": "https://Stackoverflow.com/users/2486915",
"pm_score": 3,
"selected": false,
"text": "<p>Absolutely position divs over the text area with a z-index higher and give these divs a transparent <a href=\"... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3561/"
] | I'm building an HTML UI with some text elements, such as tab names, which look bad when selected. Unfortunately, it's very easy for a user to double-click a tab name, which selects it by default in many browsers.
I might be able to solve this with a JavaScript trick (I'd like to see those answers, too) -- but I'm real... | In most browsers, this can be achieved using CSS:
```css
*.unselectable {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
/*
Introduced in IE 10.
See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
*/
-ms-user-select: none;
user-select: none;
}
`... |
69,440 | <p>I'm wondering if there's any way to write CSS specifically for Safari using only CSS. I know there has to be something out there, but I haven't found it yet.</p>
| [
{
"answer_id": 69446,
"author": "dawnerd",
"author_id": 69503,
"author_profile": "https://Stackoverflow.com/users/69503",
"pm_score": 2,
"selected": false,
"text": "<p>So wait, you want to write CSS for Safari using only CSS? I think you answered your own question. Webkit has really good... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8970/"
] | I'm wondering if there's any way to write CSS specifically for Safari using only CSS. I know there has to be something out there, but I haven't found it yet. | I think the question is valid. I agree with the other responses, but it doesn't mean it's a terrible question. I've only ever had to use a Safari CSS hack once as a temporary solution and later got rid of it. I agree that you shouldn't have to target just Safari, but no harm in knowing how to do it.
FYI, this hack onl... |
69,445 | <p>I'm using the After Effects CS3 Javascript API to dynamically create and change text layers in a composition.</p>
<p>Or at least I'm trying to because I can't seem to find the right property to change to alter the actual text of the TextLayer object.</p>
| [
{
"answer_id": 69462,
"author": "dawnerd",
"author_id": 69503,
"author_profile": "https://Stackoverflow.com/users/69503",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not an expert with After Effects, but I have messed around with it. I think <a href=\"http://library.creativecow.net... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/147/"
] | I'm using the After Effects CS3 Javascript API to dynamically create and change text layers in a composition.
Or at least I'm trying to because I can't seem to find the right property to change to alter the actual text of the TextLayer object. | Hmm, must read docs harder next time.
```
var theComposition = app.project.item(1);
var theTextLayer = theComposition.layers[1];
theTextLayer.property("Source Text").setValue("This text is from code");
``` |
69,470 | <p>Is there a way to get the current xml data when we make our own custom XPath function (see here).</p>
<p>I know you have access to an <code>XPathContext</code> but is this enough?</p>
<p><strong>Example:</strong></p>
<p>Our XML:</p>
<pre><code><foo>
<bar>smang</bar>
<fizz>buzz</fiz... | [
{
"answer_id": 69478,
"author": "Yann Ramin",
"author_id": 9167,
"author_profile": "https://Stackoverflow.com/users/9167",
"pm_score": 2,
"selected": false,
"text": "<p>There is the classic 'ab' (apachebench) program. More power comes from <a href=\"http://jakarta.apache.org/jmeter/\" re... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] | Is there a way to get the current xml data when we make our own custom XPath function (see here).
I know you have access to an `XPathContext` but is this enough?
**Example:**
Our XML:
```
<foo>
<bar>smang</bar>
<fizz>buzz</fizz>
</foo>
```
Our XSL:
```
<xsl:template match="/">
<xsl:value-of select="ourFunc... | There is the classic 'ab' (apachebench) program. More power comes from [JMmeter](http://jakarta.apache.org/jmeter/). For server health, I recommend Munin, which can painlessly capture data from several systems and aggregate it on one page. |
69,480 | <p>I have a script that renders graphs in gnuplot. The graphs all end up with an ugly white background. How do I change this? (Ideally, with a command that goes into a gnuplot script, as opposed to a command-line option or something in a settings file)</p>
| [
{
"answer_id": 69510,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 2,
"selected": false,
"text": "<p>It is a setting for some terminal (windows use background). Check out colorbox including its bdefault.</p>\n\n<p>/Alla... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | I have a script that renders graphs in gnuplot. The graphs all end up with an ugly white background. How do I change this? (Ideally, with a command that goes into a gnuplot script, as opposed to a command-line option or something in a settings file) | Ooh, found it. It's along the lines of:
```
set terminal png x222222 xffffff
``` |
69,546 | <p>I have a multi-frame layout. One of the frames contains a form, which I am submitting through XMLHttpRequest. Now when I use document.write() to rewrite the frame with the form, and the new page I am adding contains any javascript then the javascript is not exectuted in IE6?</p>
<p>For example:</p>
<pre><code>docu... | [
{
"answer_id": 69655,
"author": "dimarzionist",
"author_id": 10778,
"author_profile": "https://Stackoverflow.com/users/10778",
"pm_score": 1,
"selected": false,
"text": "<p>Workaround is to programmatically add <code><script></code> blocks to head DOM element in JavaScript at Callb... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a multi-frame layout. One of the frames contains a form, which I am submitting through XMLHttpRequest. Now when I use document.write() to rewrite the frame with the form, and the new page I am adding contains any javascript then the javascript is not exectuted in IE6?
For example:
```
document.write("<html><he... | Workaround is to programmatically add `<script>` blocks to head DOM element in JavaScript at Callback function or call eval() method. It's only way you can make this work in IE 6. |
69,561 | <p>gnuplot is giving the error: "sh: kpsexpand: not found." </p>
<p>I feel like the guy in Office Space when he saw "PC LOAD LETTER". What the heck is kpsexpand?</p>
<p>I searched Google, and there were a lot of pages that make reference to kpsexpand, and say not to worry about it, but I can't find anything, anywhere... | [
{
"answer_id": 69575,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 1,
"selected": false,
"text": "<p>This is on the first page of google search results for \"kpexpand gnuplot\":</p>\n\n<p><a href=\"http://dschneller.blogspot.c... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | gnuplot is giving the error: "sh: kpsexpand: not found."
I feel like the guy in Office Space when he saw "PC LOAD LETTER". What the heck is kpsexpand?
I searched Google, and there were a lot of pages that make reference to kpsexpand, and say not to worry about it, but I can't find anything, anywhere that actually ex... | kpsexpand, kpsetool and kpsepath are all wrappers for kpsewhich that deals with finding tex-related files
kpsexpand is used to expand environment varibles.
Say $VAR1 is "Hello World" and $VAR2 is "/home/where/I/belong" then
```
$ kpsexpand $VAR1
```
will return
```
Hello World
```
and
```
$ kpsexpand $VAR2
```
wi... |
69,591 | <p>I want to create a regexp in Emacs that matches exactly 3 digits. For example, I want to match the following:</p>
<pre><code>123
345
789
</code></pre>
<p>But not</p>
<pre><code>1234
12
12 23
</code></pre>
<p>If I use <code>[0-9]+</code> I match any single string of digits. I thought <code>[0-9]{3}</code> wou... | [
{
"answer_id": 69593,
"author": "mike511",
"author_id": 9593,
"author_profile": "https://Stackoverflow.com/users/9593",
"pm_score": -1,
"selected": false,
"text": "<p>It's pretty simple:</p>\n\n<pre><code>[0-9][0-9][0-9]\n</code></pre>\n"
},
{
"answer_id": 69615,
"author": "J... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180/"
] | I want to create a regexp in Emacs that matches exactly 3 digits. For example, I want to match the following:
```
123
345
789
```
But not
```
1234
12
12 23
```
If I use `[0-9]+` I match any single string of digits. I thought `[0-9]{3}` would work, but when tested in re-builder it doesn't match anything. | If you're entering the regex interactively, and want to use `{3}`, you need to use backslashes to escape the curly braces. If you don't want to match any part of the longer strings of numbers, use `\b` to match word boundaries around the numbers. This leaves:
```
\b[0-9]\{3\}\b
```
For those wanting more information... |
69,645 | <p>I want to take a screenshot via a python script and unobtrusively save it.</p>
<p>I'm only interested in the Linux solution, and should support any X based environment.</p>
| [
{
"answer_id": 70237,
"author": "Slava V",
"author_id": 37141,
"author_profile": "https://Stackoverflow.com/users/37141",
"pm_score": 3,
"selected": false,
"text": "<pre><code>import ImageGrab\nimg = ImageGrab.grab()\nimg.save('test.jpg','JPEG')\n</code></pre>\n\n<p>this requires Python ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1724701/"
] | I want to take a screenshot via a python script and unobtrusively save it.
I'm only interested in the Linux solution, and should support any X based environment. | This works without having to use scrot or ImageMagick.
```
import gtk.gdk
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
print "The size of the window is %d x %d" % sz
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
if (pb != N... |
69,676 | <p>How do I get Asterisk to forward incoming calls based on matching the incoming call number with a number to forward to? Both numbers are stored in a MySQL database.</p>
| [
{
"answer_id": 69689,
"author": "willurd",
"author_id": 1943957,
"author_profile": "https://Stackoverflow.com/users/1943957",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://scottstuff.net/blog/articles/2004/08/09/database-driven-call-forwarding-with-asterisk\" rel=\"nofol... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11176/"
] | How do I get Asterisk to forward incoming calls based on matching the incoming call number with a number to forward to? Both numbers are stored in a MySQL database. | The solution I was looking for ended up looking like this:
```
[default]
exten => _X.,1,Set(ARRAY(${EXTEN}_phone)=${DTC_ICF(phone_number,${EXTEN})})
exten => _X.,n(callphone),Dial(SIP/metaswitch/${${EXTEN}_phone},26)
exten => _X.,n(end),Hangup()
``` |
69,695 | <p>I am trying to use a stringstream object in VC++ (VStudio 2003) butI am getting an error when I use the overloaded << operator to try and set some manipulators. </p>
<p>I am trying the following: </p>
<pre><code>int SomeInt = 1;
stringstream StrStream;
StrStream << std::setw(2) << SomeInt; ... | [
{
"answer_id": 69721,
"author": "Jesse Beder",
"author_id": 112,
"author_profile": "https://Stackoverflow.com/users/112",
"pm_score": 2,
"selected": true,
"text": "<p>Are you sure you included all of the right headers? The following compiles for me in VS2003:</p>\n\n<pre><code>#include &... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1682/"
] | I am trying to use a stringstream object in VC++ (VStudio 2003) butI am getting an error when I use the overloaded << operator to try and set some manipulators.
I am trying the following:
```
int SomeInt = 1;
stringstream StrStream;
StrStream << std::setw(2) << SomeInt;
```
This will not compile (error C259... | Are you sure you included all of the right headers? The following compiles for me in VS2003:
```
#include <iostream>
#include <sstream>
#include <iomanip>
int main()
{
int SomeInt = 1;
std::stringstream StrStream;
StrStream << std::setw(2) << SomeInt;
return 0;
}
``` |
69,702 | <pre><code>public static void main(String[] args) {
List<? extends Object> mylist = new ArrayList<Object>();
mylist.add("Java"); // compile error
}
</code></pre>
<p>The above code does not allow you to add elements to the list and wild cards can only be used as a signature in methods, again not ... | [
{
"answer_id": 69797,
"author": "Ren",
"author_id": 11188,
"author_profile": "https://Stackoverflow.com/users/11188",
"pm_score": 1,
"selected": false,
"text": "<p>With java generics using wildcards, you are allowed the above declaration assuming you are only going to read from it. </p>\... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] | ```
public static void main(String[] args) {
List<? extends Object> mylist = new ArrayList<Object>();
mylist.add("Java"); // compile error
}
```
The above code does not allow you to add elements to the list and wild cards can only be used as a signature in methods, again not for adding but only for accessi... | Let's say you have an interface and two classes:
```
interface IResult {}
class AResult implements IResult {}
class BResult implements IResult {}
```
Then you have classes that return a list as a result:
```
interface ITest<T extends IResult> {
List<T> getResult();
}
class ATest implements ITest<AResult> {
// ... |
69,722 | <p>I have a dl containing some input boxes that I "clone" with a bit of JavaScript like: </p>
<pre><code>var newBox = document.createElement('dl');
var sourceBox = document.getElementById(oldkey);
newBox.innerHTML = sourceBox.innerHTML;
newBox.id = newkey;
document.getElementById('boxes').appendChild(col... | [
{
"answer_id": 69795,
"author": "rpetrich",
"author_id": 4007,
"author_profile": "https://Stackoverflow.com/users/4007",
"pm_score": 1,
"selected": false,
"text": "<p>You could try the <code>cloneNode</code> method. It might do a better job of copying the contents. It should also be fast... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6997/"
] | I have a dl containing some input boxes that I "clone" with a bit of JavaScript like:
```
var newBox = document.createElement('dl');
var sourceBox = document.getElementById(oldkey);
newBox.innerHTML = sourceBox.innerHTML;
newBox.id = newkey;
document.getElementById('boxes').appendChild(columnBox);
``... | [Firefox vs. IE: innerHTML handling](https://stackoverflow.com/questions/36778/firefox-vs-ie-innerhtml-handling#36793) ? |
69,738 | <p>I am working with an open-source UNIX tool that is implemented in C++, and I need to change some code to get it to do what I want. I would like to make the smallest possible change in hopes of getting my patch accepted upstream. Solutions that are implementable in standard C++ and do not create more external depende... | [
{
"answer_id": 69762,
"author": "Assaf Lavie",
"author_id": 11208,
"author_profile": "https://Stackoverflow.com/users/11208",
"pm_score": 0,
"selected": false,
"text": "<p>Is this about serialization? Or printing proper?\nIf the former, consider boost::serialization as well. It's all abo... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8146/"
] | I am working with an open-source UNIX tool that is implemented in C++, and I need to change some code to get it to do what I want. I would like to make the smallest possible change in hopes of getting my patch accepted upstream. Solutions that are implementable in standard C++ and do not create more external dependenci... | I am using #3: the boost string format library - but I have to admit that I've never had any problem with the differences in format specifications.
Works like a charm for me - and the external dependencies could be worse (a very stable library)
Edited: adding an example how to use boost::format instead of printf:
``... |
69,743 | <p>I am trying to populate a string with a double value using a <code>sprintf</code> like this:</p>
<pre><code>sprintf(S, "%f", val);
</code></pre>
<p>But the precision is being cut off to six decimal places. I need about 10 decimal places for the precision.</p>
<p>How can that be achieved?</p>
| [
{
"answer_id": 69747,
"author": "Yann Ramin",
"author_id": 9167,
"author_profile": "https://Stackoverflow.com/users/9167",
"pm_score": 3,
"selected": false,
"text": "<p>What you want is a modifier:</p>\n\n<pre><code>sprintf(S, \"%.10f\", val);\n</code></pre>\n\n<p>man sprintf will have m... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11212/"
] | I am trying to populate a string with a double value using a `sprintf` like this:
```
sprintf(S, "%f", val);
```
But the precision is being cut off to six decimal places. I need about 10 decimal places for the precision.
How can that be achieved? | %[width].[precision]
Width should include the decimal point.
%8.2 means 8 characters wide; 5 digits before the point and 2 after. One character is reserved for the point.
5 + 1 + 2 = 8 |
69,748 | <p>Another easy one hopefully.</p>
<p>Let's say I have a collection like this:</p>
<pre><code>List<DateTime> allDates;
</code></pre>
<p>I want to turn that into </p>
<pre><code>List<List<DateTime>> dividedDates;
</code></pre>
<p>where each List in 'dividedDates' contains all of the dates in 'allD... | [
{
"answer_id": 69769,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": true,
"text": "<pre><code>var q = from date in allDates \n group date by date.Year into datesByYear\n select datesByYear... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | Another easy one hopefully.
Let's say I have a collection like this:
```
List<DateTime> allDates;
```
I want to turn that into
```
List<List<DateTime>> dividedDates;
```
where each List in 'dividedDates' contains all of the dates in 'allDates' that belong to a distinct year.
Is there a bit of LINQ trickery tha... | ```
var q = from date in allDates
group date by date.Year into datesByYear
select datesByYear.ToList();
q.ToList(); //returns List<List<DateTime>>
``` |
69,761 | <p>I'd like to to associate a file extension to the current executable in C#.
This way when the user clicks on the file afterwards in explorer, it'll run my executable with the given file as the first argument.
Ideally it'd also set the icon for the given file extensions to the icon for my executable.
Thanks all.</p>
| [
{
"answer_id": 69805,
"author": "Steve Morgan",
"author_id": 5806,
"author_profile": "https://Stackoverflow.com/users/5806",
"pm_score": 2,
"selected": false,
"text": "<p>The file associations are defined in the registry under HKEY_CLASSES_ROOT.</p>\n\n<p>There's a VB.NET example <a href... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to to associate a file extension to the current executable in C#.
This way when the user clicks on the file afterwards in explorer, it'll run my executable with the given file as the first argument.
Ideally it'd also set the icon for the given file extensions to the icon for my executable.
Thanks all. | There doesn't appear to be a .Net API for directly managing file associations but you can use the Registry classes for reading and writing the keys you need to.
You'll need to create a key under HKEY\_CLASSES\_ROOT with the name set to your file extension (eg: ".txt"). Set the default value of this key to a unique nam... |
69,766 | <p>I'm working on VS 2005 and something has gone wrong on my machine. Suddenly, out of the blue, I can no longer build deployment files.
The build message is:</p>
<pre><code>ERROR: An error occurred generating a bootstrapper: Invalid syntax.
ERROR: General failure building bootstrapper
ERROR: Unrecoverable build erro... | [
{
"answer_id": 69809,
"author": "deemer",
"author_id": 11192,
"author_profile": "https://Stackoverflow.com/users/11192",
"pm_score": 1,
"selected": false,
"text": "<p>If it doesn't build only on the one machine, then either you've managed to make that machine different, or the VS2005 ins... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7850/"
] | I'm working on VS 2005 and something has gone wrong on my machine. Suddenly, out of the blue, I can no longer build deployment files.
The build message is:
```
ERROR: An error occurred generating a bootstrapper: Invalid syntax.
ERROR: General failure building bootstrapper
ERROR: Unrecoverable build error
```
A quick... | **SOLUTION!**
Thanks to Michael Bleifer of Microsoft support - I installed .NET 2.0 SP1, and the problem was solved! |
69,768 | <p>Mac OS X ships with apache pre-installed, but the files are in non-standard locations. This question is a place to collect information about where configuration files live, and how to tweak the apache installation to do things like serve php pages.</p>
| [
{
"answer_id": 69784,
"author": "ctcherry",
"author_id": 10322,
"author_profile": "https://Stackoverflow.com/users/10322",
"pm_score": 5,
"selected": true,
"text": "<p>Apache Config file is: /private/etc/apache2/httpd.conf</p>\n\n<p>Default DocumentRoot is: /Library/Webserver/Documents/<... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3575/"
] | Mac OS X ships with apache pre-installed, but the files are in non-standard locations. This question is a place to collect information about where configuration files live, and how to tweak the apache installation to do things like serve php pages. | Apache Config file is: /private/etc/apache2/httpd.conf
Default DocumentRoot is: /Library/Webserver/Documents/
To enable PHP, at around line 114 (maybe) in the /private/etc/apache2/httpd.conf file is the following line:
```
#LoadModule php5_module libexec/apache2/libphp5.so
```
Remove the pound sign to uncommen... |
69,843 | <p>Does anybody have useful example of <code>this</code> assignment inside a C# method? I have been asked for it once during job interview, and I am still interested in answer myself. </p>
| [
{
"answer_id": 69851,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": -1,
"selected": false,
"text": "<p>You cannot overwrite \"this\". It points to the current object instance.</p>\n"
},
{
"answer_id": 69878,
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | Does anybody have useful example of `this` assignment inside a C# method? I have been asked for it once during job interview, and I am still interested in answer myself. | The other answers are incorrect when they say you cannot assign to 'this'. True, you can't for a class type, but you *can* for a struct type:
```
public struct MyValueType
{
public int Id;
public void Swap(ref MyValueType other)
{
MyValueType temp = this;
this = other;
other = temp;... |
69,849 | <p>When is it a good idea to use factory methods within an object instead of a Factory class?</p>
| [
{
"answer_id": 69861,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 3,
"selected": false,
"text": "<p>It's really a matter of taste. Factory classes can be abstracted/interfaced away as necessary, whereas factory methods... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When is it a good idea to use factory methods within an object instead of a Factory class? | I like thinking about design pattens in terms of my classes being 'people,' and the patterns are the ways that the people talk to each other.
So, to me the factory pattern is like a hiring agency. You've got someone that will need a variable number of workers. This person may know some info they need in the people the... |
69,913 | <p>What is the reason browsers do not correctly recognize:</p>
<pre><code><script src="foobar.js" /> <!-- self-closing script element -->
</code></pre>
<p>Only this is recognized:</p>
<pre><code><script src="foobar.js"></script>
</code></pre>
<p>Does this break the concept of XHTML support?<... | [
{
"answer_id": 69984,
"author": "squadette",
"author_id": 7754,
"author_profile": "https://Stackoverflow.com/users/7754",
"pm_score": 10,
"selected": true,
"text": "<p>The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:</p>\n<p><a href=\"http://w... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10778/"
] | What is the reason browsers do not correctly recognize:
```
<script src="foobar.js" /> <!-- self-closing script element -->
```
Only this is recognized:
```
<script src="foobar.js"></script>
```
Does this break the concept of XHTML support?
Note: This statement is correct at least for all IE (6-8 beta 2). | The non-normative appendix ‘HTML Compatibility Guidelines’ of the XHTML 1 specification says:
[С.3. Element Minimization and Empty Element Content](http://www.w3.org/TR/xhtml1/#C_3)
>
> Given an empty instance of an element whose content model is not `EMPTY` (for example, an empty title or paragraph) do not use the ... |
69,928 | <p>The company has the traditional complex organizational structure, defining the amount of levels using the letter 'n' rather than an actual number. I will try and express the structure I'm trying to achieve in mono-spaced font: </p>
<pre><code> Alice
,--------|-------,------,------,
Bob Fred Jack ... | [
{
"answer_id": 69952,
"author": "rudigrobler",
"author_id": 5147,
"author_profile": "https://Stackoverflow.com/users/5147",
"pm_score": 2,
"selected": false,
"text": "<p>Josh Smith has a excecllent CodeProject article about TreeView. Read it <a href=\"http://www.codeproject.com/KB/WPF/Ad... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/952/"
] | The company has the traditional complex organizational structure, defining the amount of levels using the letter 'n' rather than an actual number. I will try and express the structure I'm trying to achieve in mono-spaced font:
```
Alice
,--------|-------,------,------,
Bob Fred Jack Kim Lucy
|... | I did end up using tips from the linked article, which I'd already read through but didn't think would help me.
The meat of it happens here, in a converter:
```
<ValueConversion(GetType(ItemsPresenter), GetType(Orientation))> _
Public Class ItemsPanelOrientationConverter
Implements IValueConverter
Public Function ... |
69,934 | <p>I've been unsuccessful in getting Emacs to switch from 8 space tabs to 4 space tabs when pressing the <kbd>TAB</kbd> in buffers with the major mode <code>text-mode</code>. I've added the following to my <code>.emacs</code>:</p>
<pre><code>(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
;;; And I hav... | [
{
"answer_id": 69992,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried</p>\n\n<pre><code>(setq tab-width 4)\n</code></pre>\n"
},
{
"answer_id": 70027,
"author": "Bert... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | I've been unsuccessful in getting Emacs to switch from 8 space tabs to 4 space tabs when pressing the `TAB` in buffers with the major mode `text-mode`. I've added the following to my `.emacs`:
```
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
;;; And I have tried
(setq indent-tabs-mode nil)
(setq tab... | >
> Do not confuse variable `tab-width` with variable `tab-stop-list`.
> The former is used for the display of literal `TAB` characters.
> The latter controls what characters are inserted when you press the `TAB` character in certain modes.
>
>
>
-- [GNU Emacs Manual](https://www.gnu.org/software/emacs/manual/html... |
69,959 | <p>After successfully building dblink on solaris 10 using Sun C 5.9
SunOS_sparc 2007/05/03 and gmake.</p>
<p>I ran gmake installcheck and got the following output:</p>
<pre><code>========== running regression test queries ==========
test dblink ... FAILED
======================
1 of 1 tests f... | [
{
"answer_id": 73275,
"author": "Grant Johnson",
"author_id": 12518,
"author_profile": "https://Stackoverflow.com/users/12518",
"pm_score": 0,
"selected": false,
"text": "<p>Does the file it is looking for actually exist? Is it in that location?</p>\n\n<p>It may be one of a few things ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5385/"
] | After successfully building dblink on solaris 10 using Sun C 5.9
SunOS\_sparc 2007/05/03 and gmake.
I ran gmake installcheck and got the following output:
```
========== running regression test queries ==========
test dblink ... FAILED
======================
1 of 1 tests failed.
```
The dif... | To solve this issue I tried using the 8.2 dblink sources, instead of the latest version.
You also need to make sure you use gnu make not the sun make. |
69,998 | <p>How do I prevent vim from replacing spaces with tabs when autoindent is on?</p>
<p>An example: if I have two tabs and 7 spaces in the beginning of the line, and <code>tabstop=3</code>, and I press Enter, the next line has four tabs and 1 space in the beginning, but I don't want that...</p>
| [
{
"answer_id": 70034,
"author": "svrist",
"author_id": 86,
"author_profile": "https://Stackoverflow.com/users/86",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.jwz.org/doc/tabs-vs-spaces.html\" rel=\"nofollow noreferrer\">Maybe the bottom of this can help you?</a></... | 2008/09/16 | [
"https://Stackoverflow.com/questions/69998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I prevent vim from replacing spaces with tabs when autoindent is on?
An example: if I have two tabs and 7 spaces in the beginning of the line, and `tabstop=3`, and I press Enter, the next line has four tabs and 1 space in the beginning, but I don't want that... | It is perhaps a good idea not to use tabs at all.
```
:set expandtab
```
If you want to replace all the tabs in your file to 3 spaces (which will look pretty similar to `tabstop=3`):
```
:%s/^I/ /
```
(where `^I` is the `TAB` character)
From the VIM online help:
```
'tabstop' 'ts' number (default 8)
... |
70,013 | <p>Is there any way to know if I'm compiling under a specific Microsoft Visual Studio version?</p>
| [
{
"answer_id": 70021,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": -1,
"selected": false,
"text": "<p>In visual studio, go to help | about and look at the version of Visual Studio that you're using to compile your app.</p>\n"... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234/"
] | Is there any way to know if I'm compiling under a specific Microsoft Visual Studio version? | `_MSC_VER` and possibly `_MSC_FULL_VER` is what you need. You can also examine [visualc.hpp](https://www.boost.org/doc/libs/master/boost/config/compiler/visualc.hpp) in any recent boost install for some usage examples.
Some values for the more recent versions of the compiler are:
```
MSVC++ 14.24 _MSC_VER == 1924 (Vi... |
70,074 | <p>I'm new to Ruby, so I'm having some trouble understanding this weird exception problem I'm having. I'm using the ruby-aaws gem to access Amazon ECS: <a href="http://www.caliban.org/ruby/ruby-aws/" rel="nofollow noreferrer">http://www.caliban.org/ruby/ruby-aws/</a>. This defines a class Amazon::AWS:Error:</p>
<pre><... | [
{
"answer_id": 70127,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 1,
"selected": false,
"text": "<p>Well, from what I can tell:</p>\n\n<pre><code>Class.new( StandardError )\n</code></pre>\n\n<p>Is creating a new class wit... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11284/"
] | I'm new to Ruby, so I'm having some trouble understanding this weird exception problem I'm having. I'm using the ruby-aaws gem to access Amazon ECS: <http://www.caliban.org/ruby/ruby-aws/>. This defines a class Amazon::AWS:Error:
```
module Amazon
module AWS
# All dynamically generated exceptions occur within th... | Ok, I'll try to help here :
First a module is not a class, it allows you to mix behaviour in a class. second see the following example :
```
module A
module B
module Error
def foobar
puts "foo"
end
end
end
end
class StandardError
include A::B::Error
end
StandardError.new.kind_of?... |
70,090 | <p>How can I visually customize autocomplete fields in Wicket (change colors, fonts, etc.)?</p>
| [
{
"answer_id": 77292,
"author": "Loren_",
"author_id": 13703,
"author_profile": "https://Stackoverflow.com/users/13703",
"pm_score": 4,
"selected": true,
"text": "<p>You can use CSS to modify the look of this component. For the Ajax auto-complete component in 1.3 the element you want to... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] | How can I visually customize autocomplete fields in Wicket (change colors, fonts, etc.)? | You can use CSS to modify the look of this component. For the Ajax auto-complete component in 1.3 the element you want to override is div.wicket-aa, so for example you might do:
```
div.wicket-aa {
background-color:white;
border:1px solid #CCCCCC;
color:black;
}
div.wicket-aa ul {
list-style-image:none;... |
70,096 | <p>I've been looking for a way to convert an mp3 to aac programmatically or via the command line with no luck. Ideally, I'd have a snippet of code that I could call from my rails app that converts an mp3 to an aac. I installed ffmpeg and libfaac and was able to create an aac file with the following command:</p>
<p><... | [
{
"answer_id": 70117,
"author": "Dark Shikari",
"author_id": 11206,
"author_profile": "https://Stackoverflow.com/users/11206",
"pm_score": 2,
"selected": false,
"text": "<p>There are only three free AAC encoders that I know of that are available through a commandline interface:</p>\n\n<o... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been looking for a way to convert an mp3 to aac programmatically or via the command line with no luck. Ideally, I'd have a snippet of code that I could call from my rails app that converts an mp3 to an aac. I installed ffmpeg and libfaac and was able to create an aac file with the following command:
`ffmpeg -i te... | [FFmpeg](http://en.wikipedia.org/wiki/Ffmpeg) provides AAC encoding facilities if you've compiled them in. If you are using Windows you can grab full binaries from [here](http://arrozcru.no-ip.org/ffmpeg_builds/)
```
ffmpeg -i source.mp3 -acodec libfaac -ab 128k dest.aac
```
I'm not sure how you would call this from... |
70,123 | <p>If I have a table structure that is: </p>
<pre><code>code, description, isdeleted
</code></pre>
<p>where <code>code</code> is the primary key.</p>
<p>The user creates a record, then later on deletes it. Because I am using soft deletes the <code>isdeleted</code> will be set to true. Then in my queries I would be d... | [
{
"answer_id": 70149,
"author": "Wayne",
"author_id": 8236,
"author_profile": "https://Stackoverflow.com/users/8236",
"pm_score": 2,
"selected": false,
"text": "<p>I know many people have argued that the data should be natural, but you should be using a primary key that is completely sep... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11355/"
] | If I have a table structure that is:
```
code, description, isdeleted
```
where `code` is the primary key.
The user creates a record, then later on deletes it. Because I am using soft deletes the `isdeleted` will be set to true. Then in my queries I would be doing a select with the where clause `and not isdeleted`... | I know many people have argued that the data should be natural, but you should be using a primary key that is completely separate from your data if you're going to be supporting soft deletes without the intention of always re-using the previous record when this situation arises.
Having a divorced primary key will allo... |
70,143 | <p>I have a xslt stylesheet with multiple <code>xsl:import</code>s and I want to merge them all into the one xslt file.</p>
<p>It is a limitation of the system we are using where it passes around the xsl stylesheet as a string object stored in memory. This is transmitted to remote machine where it performs the transfo... | [
{
"answer_id": 70180,
"author": "chrisb",
"author_id": 8262,
"author_profile": "https://Stackoverflow.com/users/8262",
"pm_score": 0,
"selected": false,
"text": "<p>Why would you want to? They're usually seperated for a reason afterall (often maintainability)</p>\n\n<p>You could always ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/716/"
] | I have a xslt stylesheet with multiple `xsl:import`s and I want to merge them all into the one xslt file.
It is a limitation of the system we are using where it passes around the xsl stylesheet as a string object stored in memory. This is transmitted to remote machine where it performs the transformation. Since it is ... | You can use an XSL stylesheet to merge your stylesheets. However, this is equivalent to using the xsl:include element, not xsl:import (as Azat Razetdinov has already pointed out). You can read up on the difference [here](http://www.w3.org/TR/xslt#section-Combining-Stylesheets).
Therefore you should first replace the x... |
70,150 | <p>I am looking for attributes I can use to ensure the best runtime performance for my .Net application by giving hints to the loader, JIT compiler or ngen.</p>
<p>For example we have <a href="http://msdn.microsoft.com/en-us/library/k2wxda47.aspx" rel="noreferrer">DebuggableAttribute</a> which should be set to not deb... | [
{
"answer_id": 70168,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 1,
"selected": false,
"text": "<p>I found another: <a href=\"http://msdn.microsoft.com/en-us/library/system.resources.neutralresourceslanguageattribut... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242/"
] | I am looking for attributes I can use to ensure the best runtime performance for my .Net application by giving hints to the loader, JIT compiler or ngen.
For example we have [DebuggableAttribute](http://msdn.microsoft.com/en-us/library/k2wxda47.aspx) which should be set to not debug and not disable optimization for op... | Ecma-335 specifies some more CompilationRelaxations for relaxed exception handling (so-called e-relaxed calls) in Annex F "Imprecise faults", but they have not been exposed by Microsoft.
Specifically CompilationRelaxations.RelaxedArrayExceptions and CompilationRelaxations.RelaxedNullReferenceException are mentioned th... |
70,161 | <p>As we all know numbers can be written either in numerics, or called by their names. While there are a lot of examples to be found that convert 123 into one hundred twenty three, I could not find good examples of how to convert it the other way around.</p>
<p>Some of the caveats:</p>
<ol>
<li>cardinal/nominal or or... | [
{
"answer_id": 70198,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "<p>I have some code I wrote a while ago: <a href=\"https://github.com/ghewgill/text2num\" rel=\"nofollow noreferrer\">text... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11414/"
] | As we all know numbers can be written either in numerics, or called by their names. While there are a lot of examples to be found that convert 123 into one hundred twenty three, I could not find good examples of how to convert it the other way around.
Some of the caveats:
1. cardinal/nominal or ordinal: "one" and "fi... | I was playing around with a PEG parser to do what you wanted (and may post that as a separate answer later) when I noticed that there's a very simple algorithm that does a remarkably good job with common forms of numbers in English, Spanish, and German, at the very least.
Working with English for example, you need a d... |
70,216 | <p>In Java, you often see a META-INF folder containing some meta files. What is the purpose of this folder and what can I put there?</p>
| [
{
"answer_id": 70221,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 8,
"selected": false,
"text": "<p>From <a href=\"http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html\" rel=\"noreferrer\">the official JAR File S... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11429/"
] | In Java, you often see a META-INF folder containing some meta files. What is the purpose of this folder and what can I put there? | Generally speaking, you should not put anything into META-INF yourself. Instead, you should rely upon whatever you use to package up your JAR. This is one of the areas where I think Ant really excels: specifying JAR file manifest attributes. It's very easy to say something like:
```
<jar ...>
<manifest>
<a... |
70,272 | <p>I have an application with one form in it, and on the Load method I need to hide the form. </p>
<p>The form will display itself when it has a need to (think along the lines of a outlook 2003 style popup), but I can' figure out how to hide the form on load without something messy.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 70282,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": -1,
"selected": false,
"text": "<p>Here is a simple approach:<br>\nIt's in C# (I don't have VB compiler at the moment)</p>\n\n<pre><code>public Form1()\n{\n ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1500/"
] | I have an application with one form in it, and on the Load method I need to hide the form.
The form will display itself when it has a need to (think along the lines of a outlook 2003 style popup), but I can' figure out how to hide the form on load without something messy.
Any suggestions? | I'm coming at this from C#, but should be very similar in vb.net.
In your main program file, in the Main method, you will have something like:
```
Application.Run(new MainForm());
```
This creates a new main form and limits the lifetime of the application to the lifetime of the main form.
However, if you remove th... |
70,303 | <p>I have a structure in C#:</p>
<pre><code>public struct UserInfo
{
public string str1
{
get;
set;
}
public string str2
{
get;
set;
}
}
</code></pre>
<p>The only rule is that <code>UserInfo(str1="AA", str2="BB").Equals(UserInfo(str1="BB", str2="AA"))</code></p>
<p>How to o... | [
{
"answer_id": 70323,
"author": "VolkerK",
"author_id": 4833,
"author_profile": "https://Stackoverflow.com/users/4833",
"pm_score": 0,
"selected": false,
"text": "<p>Many possibilities. E.g.<br /></p>\n\n<p><code>\nreturn str1.GetHashCode() ^ str1.GetHashCode()\n</code></p>\n"
},
{
... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I have a structure in C#:
```
public struct UserInfo
{
public string str1
{
get;
set;
}
public string str2
{
get;
set;
}
}
```
The only rule is that `UserInfo(str1="AA", str2="BB").Equals(UserInfo(str1="BB", str2="AA"))`
How to override the GetHashCode function for this str... | [MSDN](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx):
A hash function must have the following properties:
>
> * If two objects compare as equal, the `GetHashCode` method for each object must return the same value. However, if two objects do not compare as equal, the `GetHashCode` methods fo... |
70,318 | <p>Experienced with Rails / ActiveRecord 2.1.1</p>
<ul>
<li>You create a first version with (for example) ruby script\generate scaffold product title:string description:text image_url:string</li>
<li>This create (for example) a migration file called 20080910122415_create_products.rb</li>
<li>You apply the migration wi... | [
{
"answer_id": 70771,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 2,
"selected": true,
"text": "<p>You should be able to use </p>\n\n<pre><code>rake db:migrate:up \n</code></pre>\n\n<p>to force it to go forward, but then you ... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11477/"
] | Experienced with Rails / ActiveRecord 2.1.1
* You create a first version with (for example) ruby script\generate scaffold product title:string description:text image\_url:string
* This create (for example) a migration file called 20080910122415\_create\_products.rb
* You apply the migration with rake db:migrate
* Now,... | You should be able to use
```
rake db:migrate:up
```
to force it to go forward, but then you risk missing interleaved migrations from other people on your team
if you run
```
rake db:migrate
```
twice, it will reapply all your migrations.
I encounter the same behavior on windows with SQLite, it might be a b... |
70,324 | <p>What is the main difference between an inner class and a static nested class in Java? Does design / implementation play a role in choosing one of these?</p>
| [
{
"answer_id": 70339,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 3,
"selected": false,
"text": "<p>Ummm… An inner class <em>is</em> a nested class… Do you mean anonymous class and inner class?</p>\n<p>Edit: If you actual... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11193/"
] | What is the main difference between an inner class and a static nested class in Java? Does design / implementation play a role in choosing one of these? | From the [Java Tutorial](http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html):
>
> Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.
>
>
>
Static n... |
70,366 | <p>When trying to commit to a cvs branch after adding a new file I get this error</p>
<pre><code>Assertion failed: key != NULL, file hash.c, line 317
</code></pre>
<p>Any idea how to fix it so I can check my code in?<br>
Both server and client are Linux and there are pre-commits involved.</p>
| [
{
"answer_id": 70441,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps there is some kind of pre-commit check on your repository, see <a href=\"http://ximbiot.com/cvs/manual/cvs... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7873/"
] | When trying to commit to a cvs branch after adding a new file I get this error
```
Assertion failed: key != NULL, file hash.c, line 317
```
Any idea how to fix it so I can check my code in?
Both server and client are Linux and there are pre-commits involved. | >
> sleep-er writes:
>
>
>
> >
> > Not sure what the issue was but I solved it by going onto the server and deleting the file Attic/newfile.v in the repository and adding it again.
> >
> >
> >
>
>
>
The "Attic" is the place where deleted files go in CVS. At some point in the past, someone checked in newfile... |
70,371 | <p>I'm trying out ASP.NET MVC routing and have of course stumbled across a problem. I have a section, /Admin/Pages/, and this is also accessible through /Pages/, which it shouldn't. What could I be missing?</p>
<p>The routing code in global.asax:</p>
<pre><code>public static void RegisterRoutes(RouteCollection routes... | [
{
"answer_id": 70396,
"author": "Steve Morgan",
"author_id": 5806,
"author_profile": "https://Stackoverflow.com/users/5806",
"pm_score": 4,
"selected": true,
"text": "<p>I'd suggest adding an explicit route for /Pages/ at the beginning.</p>\n\n<p>The problem is that it's being handled by... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11334/"
] | I'm trying out ASP.NET MVC routing and have of course stumbled across a problem. I have a section, /Admin/Pages/, and this is also accessible through /Pages/, which it shouldn't. What could I be missing?
The routing code in global.asax:
```
public static void RegisterRoutes(RouteCollection routes)
{
routes.Ig... | I'd suggest adding an explicit route for /Pages/ at the beginning.
The problem is that it's being handled by the Default route and deriving:
controller = "Pages"
action = "Index"
id = ""
which are exactly the same as the parameters for your Admin route. |
70,386 | <p>There are three places where menus show up in the new MFC functionality (Feature Pack):</p>
<ul>
<li>In menu bars (CMFCMenuBar)</li>
<li>In popup menus (CMFCPopupMenu)</li>
<li>In the 'dropdown menu' version of CMFCButton</li>
</ul>
<p>I want to put icons (high-color and with transparancy) in the menus in all of t... | [
{
"answer_id": 72654,
"author": "Nevermind",
"author_id": 12366,
"author_profile": "https://Stackoverflow.com/users/12366",
"pm_score": 2,
"selected": false,
"text": "<p>I believe (but I may be wrong) that these classes are the same as the BCGToolbar classes that were included in MFC whe... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11449/"
] | There are three places where menus show up in the new MFC functionality (Feature Pack):
* In menu bars (CMFCMenuBar)
* In popup menus (CMFCPopupMenu)
* In the 'dropdown menu' version of CMFCButton
I want to put icons (high-color and with transparancy) in the menus in all of them. I have found CFrameWndEx::OnDrawMenuI... | This is how I got it to work:
### First
, as the others said, create an invisible toolbar next to your main toolbar (I'm using the usual names based on AppWizard's names):
```
MainFrm.h:
class CMainFrame
{
//...
CMFCToolBar m_wndToolBar;
CMFCToolBar m_wndInvisibleToolBar;
//...
};
MainFrm.cpp:
i... |
70,389 | <p>I have apache 2.2 and tomcat 5.5 running on a Windows XP machine.</p>
<p>Which tomcat/apache connector is the easiest to set up and is well documented? </p>
| [
{
"answer_id": 70432,
"author": "Chris Broadfoot",
"author_id": 3947,
"author_profile": "https://Stackoverflow.com/users/3947",
"pm_score": 0,
"selected": false,
"text": "<p><code>mod_jk</code>, or simply just use <code>mod_proxy</code> even though it's not really a Tomcat connector.</p>... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8633/"
] | I have apache 2.2 and tomcat 5.5 running on a Windows XP machine.
Which tomcat/apache connector is the easiest to set up and is well documented? | `[mod\_proxy\_ajp](http://httpd.apache.org/docs/2.2/mod/mod_proxy.html)` would be the easiest to use if you are using Apache 2.2. It is part of the Apache distribution so you don't need to install any additional software.
In your `httpd.conf` you need to make sure that `mod_proxy` and `mod_proxy_ajp` are loaded:
```
... |
70,397 | <p>So I'm working on a Rails app to get the feeling for the whole thing. I've got a <code>Product</code> model that's a standard ActiveRecord model. However, I also want to get some additional product info from Amazon ECS. So my complete model gets some of its info from the database and some from the web service. My qu... | [
{
"answer_id": 70457,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <code>composed_of</code> relationship in ActiveRecord. You make a regular class with all the attributes that... | 2008/09/16 | [
"https://Stackoverflow.com/questions/70397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11284/"
] | So I'm working on a Rails app to get the feeling for the whole thing. I've got a `Product` model that's a standard ActiveRecord model. However, I also want to get some additional product info from Amazon ECS. So my complete model gets some of its info from the database and some from the web service. My question is, sho... | As with most things: it depends. Each of your ideas have merit. If it were me, I'd start out this way:
```
class Product < ActiveRecord::Base
has_one :aws_item
end
class AWSItem
belongs_to :product
end
```
The key questions you want to ask yourself are:
**Are you only going to be offering AWS ... |