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 |
|---|---|---|---|---|---|---|
47,309 | <p>I'm trying to install <a href="http://godi.camlcity.org/godi/index.html" rel="noreferrer">GODI</a> on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what ... | [
{
"answer_id": 47655,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 2,
"selected": false,
"text": "<p>What is the output of <code>which godi_confdir</code>?</p>\n\n<p>P.S. I remember having this exact same problem, but ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157/"
] | I'm trying to install [GODI](http://godi.camlcity.org/godi/index.html) on linux (Ubuntu). It's a library management tool for the ocaml language. I've actually installed this before --twice, but awhile ago-- with no issues --that I can remember-- but this time I just can't figure out what I'm missing.
```
$ ./bootstrap... | Hey Chris, I just figured it out. Silly mistake.
It was just a permission issue, running everything from `/tmp/` worked fine --well after enabling `GODI_BASEPKG_PCRE` in `godi.conf`. I had been running it from my home directory, you forget simple things like that at 3:00am.
--
Actually I'm having another problem. In... |
47,329 | <p>I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"):</p>
<pre><code>"Default.aspx?page=1"
"Default.aspx?... | [
{
"answer_id": 47344,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 2,
"selected": true,
"text": "<p>I'm afraid I don't know of any built-in method for this, we use this method that takes the querystring and sets parame... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3263/"
] | I'm implementing a custom control and in this control I need to write a bunch of links to the current page, each one with a different query parameter. I need to keep existing query string intact, and add (or modify the value of ) an extra query item (eg. "page"):
```
"Default.aspx?page=1"
"Default.aspx?page=2"
"Defaul... | I'm afraid I don't know of any built-in method for this, we use this method that takes the querystring and sets parameters
```
/// <summary>
/// Set a parameter value in a query string. If the parameter is not found in the passed in query string,
/// it is added to the end of the query string
/// </sum... |
47,338 | <p>I have a problem with a sample routing with the preview 5 of asp.net mvc.</p>
<p>In the AccountController I have 2 actions: </p>
<pre><code>public ActionResult Delete()
public ActionResult Delete(string username)
</code></pre>
<p>While trying to look for Account/Delete or Account/Delete?username=davide the Con... | [
{
"answer_id": 47375,
"author": "berko",
"author_id": 4884,
"author_profile": "https://Stackoverflow.com/users/4884",
"pm_score": 0,
"selected": false,
"text": "<p>I can't say for sure why this is happening. But you might want to consider only having the Delete(string username) action an... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1812/"
] | I have a problem with a sample routing with the preview 5 of asp.net mvc.
In the AccountController I have 2 actions:
```
public ActionResult Delete()
public ActionResult Delete(string username)
```
While trying to look for Account/Delete or Account/Delete?username=davide the ControllerActionInvoker throws a exce... | Solution found!
With the introduction of the ActionNameAttribute, it's now necessary to filter manually which method to call depending on the request. This is done by the ActionSelectionAttribute.
Full explanation here: <http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx> |
47,363 | <p>What is the command to list all triggers in a MySQL database?</p>
| [
{
"answer_id": 47364,
"author": "Harry",
"author_id": 4704,
"author_profile": "https://Stackoverflow.com/users/4704",
"pm_score": 9,
"selected": true,
"text": "<p>The command for listing all triggers is:</p>\n\n<pre><code>show triggers;\n</code></pre>\n\n<p>or you can access the <code>IN... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4704/"
] | What is the command to list all triggers in a MySQL database? | The command for listing all triggers is:
```
show triggers;
```
or you can access the `INFORMATION_SCHEMA` table directly by:
```
select trigger_schema, trigger_name, action_statement
from information_schema.triggers
```
* You can do this from version 5.0.10 onwards.
* More information about the [`TRIGGERS` table... |
47,374 | <p>Part of the web application I'm working on is an area displaying messages from management to 1...n users. I have a DataAccess project that contains the LINQ to SQL classes, and a website project that is the UI. My database looks like this:</p>
<p>User -> MessageDetail <- Message <- MessageCategory</p>
<p>Mes... | [
{
"answer_id": 47383,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 1,
"selected": false,
"text": "<p>Regardless of LINQ, I think that mixing presentation code with database-relaed code is not a good idea. I would create a simpl... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4160/"
] | Part of the web application I'm working on is an area displaying messages from management to 1...n users. I have a DataAccess project that contains the LINQ to SQL classes, and a website project that is the UI. My database looks like this:
User -> MessageDetail <- Message <- MessageCategory
MessageDetail is a join ta... | All your LINQ querys should be in a **business logic class**, no change from older methodologies like ADO.
If you are a **purist** you should always return List(of T) from your methods in the business class, in fact, the datacontext should only be visible to the business classes.
Then you can manipulate the list in th... |
47,400 | <p>With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).</p>
<p>One of the main issues with testing forms is that only a few controls have a <code>hwnd</code> handle and other controls only ... | [
{
"answer_id": 47404,
"author": "Knox",
"author_id": 4873,
"author_profile": "https://Stackoverflow.com/users/4873",
"pm_score": 2,
"selected": false,
"text": "<p>I would design the application to have as much work as possible done in queries and in vba subroutines so that your testing c... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] | With the code, forms and data inside the same database I am wondering what are the best practices to design a suite of tests for a Microsoft Access application (say for Access 2007).
One of the main issues with testing forms is that only a few controls have a `hwnd` handle and other controls only get one they have foc... | 1. Write Testable Code
======================
First, stop writing business logic into your Form's code behind. That's not the place for it. It can't be properly tested there. In fact, you really shouldn't have to test your form itself at all. It should be a dead dumb simple view that responds to User Interaction and t... |
47,402 | <p>Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.</p>
<p>Example input and output:</p>
<pre><code>>>> reverse_words("this is a string")
'string a is this'
</code></pre>
<p>It should be O(N) time and O(1) spa... | [
{
"answer_id": 47416,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 1,
"selected": false,
"text": "<p>In pseudo code:</p>\n\n<pre><code>reverse input string\nreverse each word (you will need to find word boundaries)\n</code></pr... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4279/"
] | Given an array of characters which forms a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
Example input and output:
```
>>> reverse_words("this is a string")
'string a is this'
```
It should be O(N) time and O(1) space (`split()` and pushing on / popping off... | A solution in C/C++:
```cpp
void swap(char* str, int i, int j){
char t = str[i];
str[i] = str[j];
str[j] = t;
}
void reverse_string(char* str, int length){
for(int i=0; i<length/2; i++){
swap(str, i, length-i-1);
}
}
void reverse_words(char* str){
int l = strlen(str);
//Reverse str... |
47,413 | <p>It's common to have a table where for example the the fields are account, value, and time. What's the best design pattern for retrieving the last value for each account? Unfortunately the last keyword in a grouping gives you the last physical record in the database, not the last record by any sorting. Which means... | [
{
"answer_id": 47431,
"author": "Tom",
"author_id": 3715,
"author_profile": "https://Stackoverflow.com/users/3715",
"pm_score": 2,
"selected": true,
"text": "<p>The subquery option sounds best to me, something like the following psuedo-sql. It may be possible/necessary to optimize it vi... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4873/"
] | It's common to have a table where for example the the fields are account, value, and time. What's the best design pattern for retrieving the last value for each account? Unfortunately the last keyword in a grouping gives you the last physical record in the database, not the last record by any sorting. Which means IMHO ... | The subquery option sounds best to me, something like the following psuedo-sql. It may be possible/necessary to optimize it via a join, that will depend on the capabilities of the SQL engine.
```
select *
from table
where account+time in (select account+max(time)
from table
... |
47,433 | <p>Consider the following 2 queries:</p>
<pre><code>select tblA.a,tblA.b,tblA.c,tblA.d
from tblA
where tblA.a not in (select tblB.a from tblB)
select tblA.a,tblA.b,tblA.c,tblA.d
from tblA left outer join tblB
on tblA.a = tblB.a where tblB.a is null
</code></pre>
<p>Which will perform better? My assumption is that i... | [
{
"answer_id": 47439,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 0,
"selected": false,
"text": "<p>From my observations, MSSQL server produces same query plan for these queries.</p>\n"
},
{
"answer_id": 47448,
"au... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] | Consider the following 2 queries:
```
select tblA.a,tblA.b,tblA.c,tblA.d
from tblA
where tblA.a not in (select tblB.a from tblB)
select tblA.a,tblA.b,tblA.c,tblA.d
from tblA left outer join tblB
on tblA.a = tblB.a where tblB.a is null
```
Which will perform better? My assumption is that in general the join will be ... | RDBMSs "rewrite" queries to optimize them, so it depends on system you're using, and I would guess they end up giving the same performance on most "good" databases.
I suggest picking the one that is clearer and easier to maintain, for my money, that's the first one. It's much easier to debug the subquery as it can be ... |
47,447 | <p>I am trying to create a horizontal menu with the elements represented by <code><span></code>'s. The menu itself (parent <code><div></code>) has a fixed width, but the elements number is always different.</p>
<p>I would like to have child <code><span></code>'s of the same width, independently of ho... | [
{
"answer_id": 47465,
"author": "Xian",
"author_id": 4642,
"author_profile": "https://Stackoverflow.com/users/4642",
"pm_score": 2,
"selected": false,
"text": "<p>If you have a fixed width container, then you are losing some of the effectiveness of a percentage width child span.</p>\n\n<... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3894/"
] | I am trying to create a horizontal menu with the elements represented by `<span>`'s. The menu itself (parent `<div>`) has a fixed width, but the elements number is always different.
I would like to have child `<span>`'s of the same width, independently of how many of them are there.
What I've done so far: added a `fl... | You might try a table with a fixed table layout. It should calculate the column widths without concerning itself with the cell contents.
```css
table.ClassName {
table-layout: fixed
}
``` |
47,475 | <p>If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?</p>
<p>ie </p>
<pre><code>[Test]
public void ShouldValidateUserNameIsLessThan100Characters() {}
</code></pre>
<p>verse </p>
<pre><code>[Test]
publ... | [
{
"answer_id": 47477,
"author": "zappan",
"author_id": 4723,
"author_profile": "https://Stackoverflow.com/users/4723",
"pm_score": 1,
"selected": false,
"text": "<p>i wouldn't put conditions that test needs to meet in the name, because conditions may change in time. in your example, i'd ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4642/"
] | If unit-test names can become outdated over time and if you consider that the test itself is the most important thing, then is it important to choose wise test names?
ie
```
[Test]
public void ShouldValidateUserNameIsLessThan100Characters() {}
```
verse
```
[Test]
public void UserNameTestValidation1() {}
``` | The name of any method should make it clear what it does.
IMO, your first suggestion is a bit long and the second one isn't informative enough. Also it's probably a bad idea to put "100" in the name, as that's very likely to change. What about:
```
public void validateUserNameLength()
```
If the test changes, the n... |
47,487 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/30170/avoiding-repeated-constants-in-css">Avoiding repeated constants in CSS</a> </p>
</blockquote>
<p>We have some "theme colors" that are reused in our CSS sheet.</p>
<p>Is there a way to set a variable and ... | [
{
"answer_id": 47490,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>CSS doesn't offer any such thing. The only solution is to write a preprocessing script that is either run manually ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] | >
> **Possible Duplicate:**
>
> [Avoiding repeated constants in CSS](https://stackoverflow.com/questions/30170/avoiding-repeated-constants-in-css)
>
>
>
We have some "theme colors" that are reused in our CSS sheet.
Is there a way to set a variable and then reuse it?
E.g.
```
.css
OurColor: Blue
H1 {
colo... | There's no requirement that all styles for a selector reside in a single rule, and a single rule can apply to multiple selectors... so *flip it around*:
```
/* Theme color: text */
H1, P, TABLE, UL
{ color: blue; }
/* Theme color: emphasis */
B, I, STRONG, EM
{ color: #00006F; }
/* ... */
/* Theme font: header */
H... |
47,519 | <p>I have a fairly standards compliant XHTML+CSS site that looks great on all browsers on PC and Mac. The other day I saw it on FF3 on Linux and the letter spacing was slightly larger, throwing everything out of whack and causing unwanted wrapping and clipping of text. The CSS in question has</p>
<pre><code>font-size:... | [
{
"answer_id": 47523,
"author": "thekidder",
"author_id": 1631,
"author_profile": "https://Stackoverflow.com/users/1631",
"pm_score": 0,
"selected": false,
"text": "<p>I find the easiest way to solve font sizing problems between browsers is to simply leave room for error. Make divs sligh... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3206/"
] | I have a fairly standards compliant XHTML+CSS site that looks great on all browsers on PC and Mac. The other day I saw it on FF3 on Linux and the letter spacing was slightly larger, throwing everything out of whack and causing unwanted wrapping and clipping of text. The CSS in question has
```
font-size: 11px;
font-fa... | Sizing/spacing differences are usually difficult to catch. What you can do is create a Linux-specific CSS file that will contain these values adjusted for Linux, then do a simple JS-based detect to inject that CSS if the User agent is a Linux one.
This is probably not the cleanest approach, but it will work, and with ... |
47,521 | <p>Here is a sample code to retrieve data from a database using the yield keyword that I found in a few place while googling around :</p>
<pre><code>public IEnumerable<object> ExecuteSelect(string commandText)
{
using (IDbConnection connection = CreateConnection())
{
using (IDbCommand cmd = Creat... | [
{
"answer_id": 47529,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>Connection will be closed automatically since you're using it inside \"using\" block.</p>\n"
},
{
"answer_id": 47699,
... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4789/"
] | Here is a sample code to retrieve data from a database using the yield keyword that I found in a few place while googling around :
```
public IEnumerable<object> ExecuteSelect(string commandText)
{
using (IDbConnection connection = CreateConnection())
{
using (IDbCommand cmd = CreateCommand(commandText... | The Iterator that the compiler synthesises implements `IDisposable`, which `foreach` calls when the `foreach` loop is exited.
The Iterator's `Dispose()` method will clean up the `using` statements on early exit.
As long as you use the iterator in a `foreach` loop, `using()` block, or call the `Dispose()` method in so... |
47,535 | <p>Updating an old ASP/Access site for a client - I need SQL to add a column to an existing table and set a default value. Doesn't work - any ideas?</p>
<p>This works fine</p>
<pre><code>ALTER TABLE documents ADD COLUMN membersOnly NUMBER
</code></pre>
<p>I want this to work:</p>
<pre><code>ALTER TABLE documents AD... | [
{
"answer_id": 47552,
"author": "zappan",
"author_id": 4723,
"author_profile": "https://Stackoverflow.com/users/4723",
"pm_score": 4,
"selected": true,
"text": "<p>Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137/"
] | Updating an old ASP/Access site for a client - I need SQL to add a column to an existing table and set a default value. Doesn't work - any ideas?
This works fine
```
ALTER TABLE documents ADD COLUMN membersOnly NUMBER
```
I want this to work:
```
ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0
```
... | Tools -> Options -> Tables/Queries -> (At the bottom right:) Sql Server Compatible Syntax - turn option on for this database.
then you can execute your query:
```
ALTER TABLE documents ADD COLUMN membersOnly NUMBER DEFAULT 0
``` |
47,589 | <p>I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning.</p>
<p>I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropr... | [
{
"answer_id": 47597,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 2,
"selected": false,
"text": "<p>First, you should <a href=\"http://us.php.net/error_reporting\" rel=\"nofollow noreferrer\">turn warnings off</a> so tha... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2056/"
] | I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If somebody tries to save a new Job to the database using a JobName that is already in the database, MySQL throws a warning.
I would like to be able to detect this warning, just like an error, in my PHP script and deal with it appropriately. Ide... | For warnings to be "flagged" to PHP natively would require changes to the mysql/mysqli driver, which is obviously beyond the scope of this question. Instead you're going to have to basically check every query you make on the database for warnings:
```
$warningCountResult = mysql_query("SELECT @@warning_count");
if ($w... |
47,591 | <p>Specifically, I am looking to use CA on properties of types other than </p>
<ul>
<li>integers and doubles</li>
<li>CGRect, CGPoint, CGSize, and CGAffineTransform structures</li>
<li>CATransform3D data structures</li>
<li>CGColor and CGImage references</li>
</ul>
<p>and in objects other than CALayers or NSViews</p>... | [
{
"answer_id": 48564,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Well, it seems I cannot do that. What I should be doing is [subclassing NSAnimation](<a href=\"https://developer.apple.com/l... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Specifically, I am looking to use CA on properties of types other than
* integers and doubles
* CGRect, CGPoint, CGSize, and CGAffineTransform structures
* CATransform3D data structures
* CGColor and CGImage references
and in objects other than CALayers or NSViews | If you can do the changes yourself and the class you use is custom, you might want to add a setProgress:(float) f method to your class and use CA to animate it, then modify the desired properties as needed as a function of f.
Just do a
```
[[someObject animator] setValue:[NSNumber numberWithFloat:1.0] forKeyPath:@"so... |
47,605 | <p>Assuming String a and b:</p>
<pre><code>a += b
a = a.concat(b)
</code></pre>
<p>Under the hood, are they the same thing?</p>
<p>Here is concat decompiled as reference. I'd like to be able to decompile the <code>+</code> operator as well to see what that does.</p>
<pre><code>public String concat(String s) {
... | [
{
"answer_id": 47615,
"author": "Niyaz",
"author_id": 184,
"author_profile": "https://Stackoverflow.com/users/184",
"pm_score": 2,
"selected": false,
"text": "<p>The <strong>+ operator</strong> can work between a string and a string, char, integer, double or float data type value. It jus... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292/"
] | Assuming String a and b:
```
a += b
a = a.concat(b)
```
Under the hood, are they the same thing?
Here is concat decompiled as reference. I'd like to be able to decompile the `+` operator as well to see what that does.
```
public String concat(String s) {
int i = s.length();
if (i == 0) {
return th... | No, not quite.
Firstly, there's a slight difference in semantics. If `a` is `null`, then `a.concat(b)` throws a `NullPointerException` but `a+=b` will treat the original value of `a` as if it were `null`. Furthermore, the `concat()` method only accepts `String` values while the `+` operator will silently convert the a... |
47,612 | <p>I've got a C# class with a <code>Dispose</code> function via <code>IDisposable</code>. It's intended to be used inside a <code>using</code> block so the expensive resource it handles can be released right away.</p>
<p>The problem is that a bug occurred when an exception was thrown before <code>Dispose</code> was ca... | [
{
"answer_id": 47617,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 2,
"selected": false,
"text": "<pre><code>~ClassName()\n{\n}\n</code></pre>\n\n<p>EDIT (bold):</p>\n\n<p>If will get called when the object is moved out... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3568/"
] | I've got a C# class with a `Dispose` function via `IDisposable`. It's intended to be used inside a `using` block so the expensive resource it handles can be released right away.
The problem is that a bug occurred when an exception was thrown before `Dispose` was called, and the programmer neglected to use `using` or `... | Unfortunately there isn't any way to do this directly in the code. If this is an issue in house, there are various code analysis solutions that could catch these sort of problems. Have you looked into FxCop? I think that this will catch these situations and in all cases where IDisposable objects might be left hanging. ... |
47,658 | <p>I am writing a coding standards document for a team of about 15 developers with a project load of between 10 and 15 projects a year. Amongst other sections (which I may post here as I get to them) I am writing a section on code formatting. So to start with, I think it is wise that, for whatever reason, we establish ... | [
{
"answer_id": 47664,
"author": "stimms",
"author_id": 361,
"author_profile": "https://Stackoverflow.com/users/361",
"pm_score": 1,
"selected": false,
"text": "<p>It obviously varies depending on languages and technologies. By the look of your example name space I am going to guess java... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4910/"
] | I am writing a coding standards document for a team of about 15 developers with a project load of between 10 and 15 projects a year. Amongst other sections (which I may post here as I get to them) I am writing a section on code formatting. So to start with, I think it is wise that, for whatever reason, we establish som... | First find a automated code-formatter that works with your language. Reason: Whatever the document says, people will inevitably break the rules. It's much easier to run code through a formatter than to nit-pick in a code review.
If you're using a language with an existing standard (e.g. Java, C#), it's easiest to use ... |
47,683 | <p>We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBo... | [
{
"answer_id": 47963,
"author": "Todd",
"author_id": 3803,
"author_profile": "https://Stackoverflow.com/users/3803",
"pm_score": 4,
"selected": true,
"text": "<p>You should implement in your client code javax.jms.ExceptionListener. You will need a method called onException. When the cl... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3098/"
] | We have a Java listener that reads text messages off of a queue in JBossMQ. If we have to reboot JBoss, the listener will not reconnect and start reading messages again. We just get messages in the listener's log file every 2 minutes saying it can't connect. Is there something we're not setting in our code or in JBossM... | You should implement in your client code javax.jms.ExceptionListener. You will need a method called onException. When the client's connection is lost, you should get a JMSException, and this method will be called automatically. The only thing you have to look out for is if you are intentionally disconnecting from JBoss... |
47,701 | <p>I'm trying to debug a deadlock in a multi-threaded Python application after it has locked up. Is there a way to attach a debugger to inspect the state of the process? </p>
<p>Edit: I'm attempting this on Linux, but it would be great if there were a cross-platform solution. It's Python after all :)</p>
| [
{
"answer_id": 47744,
"author": "Henk",
"author_id": 4613,
"author_profile": "https://Stackoverflow.com/users/4613",
"pm_score": 0,
"selected": false,
"text": "<p>What platform are you attempting this on? Most debuggers allow you to attach to a running process by using the process id.\nY... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | I'm trying to debug a deadlock in a multi-threaded Python application after it has locked up. Is there a way to attach a debugger to inspect the state of the process?
Edit: I'm attempting this on Linux, but it would be great if there were a cross-platform solution. It's Python after all :) | Yeah, gdb is good for lower level debugging.
You can change threads with the *thread* command.
e.g
```
(gdb) thr 2
[Switching to thread 2 (process 6159 thread 0x3f1b)]
(gdb) backtrace
....
```
You could also check out Python specific debuggers like [Winpdb](http://winpdb.org/about/), or [pydb](http://bashdb.source... |
47,752 | <p>Anyone have a quick method for de-duplicating a generic List in C#?</p>
| [
{
"answer_id": 47755,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": false,
"text": "<p>Sort it, then check two and two next to each others, as the duplicates will clump together.</p>\n\n<p>Something lik... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4541/"
] | Anyone have a quick method for de-duplicating a generic List in C#? | Perhaps you should consider using a [HashSet](http://msdn.microsoft.com/en-us/library/bb359438.aspx).
From the MSDN link:
```
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
HashSet<int> evenNumbers = new HashSet<int>();
HashSet<int> oddNumbers = new HashS... |
47,762 | <p>I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.</p>
<p>problem statement: </p>
<ul>
<li>a user enters several keywords/tokens</li>
<li>the application searches for matches to the tokens</li>
<li>ne... | [
{
"answer_id": 47796,
"author": "Robin Barnes",
"author_id": 1349865,
"author_profile": "https://Stackoverflow.com/users/1349865",
"pm_score": 4,
"selected": true,
"text": "<p>you could achive this in one query using 'UNION ALL' in MySQL.</p>\n\n<p>Just loop through the tokens in PHP cre... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4418/"
] | I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.
problem statement:
* a user enters several keywords/tokens
* the application searches for matches to the tokens
* need one result for each token
+ ie,... | you could achive this in one query using 'UNION ALL' in MySQL.
Just loop through the tokens in PHP creating a UNION ALL for each token:
e.g if the tokens are 'x', 'y' and 'z' your query may look something like this
```
SELECT * FROM `entries`
WHERE token like "%x%" union all
SELECT * FROM `entries`
WHERE ... |
47,780 | <p>I have an inherited project that uses a build script (not make) to build and link the project with various libraries.</p>
<p>When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming fr... | [
{
"answer_id": 47805,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 0,
"selected": false,
"text": "<p>Static libraries, that makes life more difficult in this regard. In case of dynamic libraries you could just have ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | I have an inherited project that uses a build script (not make) to build and link the project with various libraries.
When it performs a build I would like to parse the build output to determine what and where the actual static libraries being linked into the final executable are and where are they coming from.
The s... | You might try using the `nm` tool. Given the right options, it will look at a binary (archive or linked image) and tell you what objects were linked into it.
Actually, here's a one-liner I use at work:
```
#!/bin/sh
nm -Ag $* | sed 's/^.*\/\(.*\.a\):/\1/' | sort -k 3 | grep -v ' U '
```
to find the culprits for un... |
47,786 | <p>Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do:</p>
<pre><code>SELECT blah FROM blah WHERE blah LIKE '%text%'
</code></pre>
<p>The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem?</p>
| [
{
"answer_id": 47811,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 7,
"selected": true,
"text": "<p>BigTable, which is the database back end for App Engine, will scale to millions of records. Due to this, App Engine will... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366/"
] | Simple one really. In SQL, if I want to search a text field for a couple of characters, I can do:
```
SELECT blah FROM blah WHERE blah LIKE '%text%'
```
The documentation for App Engine makes no mention of how to achieve this, but surely it's a common enough problem? | BigTable, which is the database back end for App Engine, will scale to millions of records. Due to this, App Engine will not allow you to do any query that will result in a table scan, as performance would be dreadful for a well populated table.
In other words, every query must use an index. This is why you can only d... |
47,789 | <p>When should you use generator expressions and when should you use list comprehensions in Python?</p>
<pre><code># Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
</code></pre>
| [
{
"answer_id": 47792,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 7,
"selected": false,
"text": "<p>Use list comprehensions when the result needs to be iterated over multiple times, or where speed is paramount. Use g... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | When should you use generator expressions and when should you use list comprehensions in Python?
```
# Generator expression
(x*2 for x in range(256))
# List comprehension
[x*2 for x in range(256)]
``` | [John's answer](https://stackoverflow.com/a/47792/4518341) is good (that list comprehensions are better when you want to iterate over something multiple times). However, it's also worth noting that you should use a list if you want to use any of the list methods. For example, the following code won't work:
```
def gen... |
47,801 | <p>I am trying to create a web application using Pylons and the resources on the web point to the <a href="http://pylonsbook.com/alpha1/authentication_and_authorization" rel="noreferrer">PylonsBook</a> page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work ea... | [
{
"answer_id": 52136,
"author": "elarson",
"author_id": 5434,
"author_profile": "https://Stackoverflow.com/users/5434",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think AuthKit is actively maintained anymore. It does use the Paste (<a href=\"http://pythonpaste.org\" rel=\"nofo... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] | I am trying to create a web application using Pylons and the resources on the web point to the [PylonsBook](http://pylonsbook.com/alpha1/authentication_and_authorization) page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work easily with Pylons?
I tried down... | Ok, another update on the subject. It seems that the cheeseshop template is broken. I've followed the chapter you linked in the post and it seems that authkit is working fine. There are some caveats:
1. sqlalchemy has to be in 0.5 version
2. authkit has to be the dev version from svn (easy\_install authkit==dev)
I ma... |
47,824 | <p>Using core jQuery, how do you remove all the options of a select box, then add one option and select it?</p>
<p>My select box is the following.</p>
<pre><code><Select id="mySelect" size="9"> </Select>
</code></pre>
<p>EDIT: The following code was helpful with chaining. However, (in Internet Explo... | [
{
"answer_id": 47829,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 12,
"selected": true,
"text": "<pre><code>$('#mySelect')\n .find('option')\n .remove()\n .end()\n .append('<option value=\"whatever\">text<... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] | Using core jQuery, how do you remove all the options of a select box, then add one option and select it?
My select box is the following.
```
<Select id="mySelect" size="9"> </Select>
```
EDIT: The following code was helpful with chaining. However, (in Internet Explorer) `.val('whatever')` did not select the option ... | ```
$('#mySelect')
.find('option')
.remove()
.end()
.append('<option value="whatever">text</option>')
.val('whatever')
;
``` |
47,833 | <p>I know you can look at the row.count or tables.count, but are there other ways to tell if a dataset is empty?</p>
| [
{
"answer_id": 47839,
"author": "Joe Ratzer",
"author_id": 4092,
"author_profile": "https://Stackoverflow.com/users/4092",
"pm_score": 3,
"selected": false,
"text": "<p>What's wrong with</p>\n\n<p>(aDataSet.Tables.Count == 0)</p>\n\n<p>?</p>\n"
},
{
"answer_id": 47840,
"autho... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445815/"
] | I know you can look at the row.count or tables.count, but are there other ways to tell if a dataset is empty? | I would suggest something like:-
```
bool nonEmptyDataSet = dataSet != null &&
(from DataTable t in dataSet.Tables where t.Rows.Count > 0 select t).Any();
```
**Edits:** I have significantly cleaned up the code after due consideration, I think this is much cleaner. Many thanks to Keith for the inspiration reg... |
47,837 | <p>I'm struggling to find the right terminology here, but if you have jQuery object...</p>
<pre><code>$('#MyObject')
</code></pre>
<p>...is it possible to extract the base element? Meaning, the equivalent of this:</p>
<pre><code>document.getElementById('MyObject')
</code></pre>
| [
{
"answer_id": 47844,
"author": "VolkerK",
"author_id": 4833,
"author_profile": "https://Stackoverflow.com/users/4833",
"pm_score": 7,
"selected": true,
"text": "<p>Yes, use <code>.get(index)</code>. According to the <a href=\"https://api.jquery.com/get/#get1\" rel=\"nofollow noreferrer... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1923/"
] | I'm struggling to find the right terminology here, but if you have jQuery object...
```
$('#MyObject')
```
...is it possible to extract the base element? Meaning, the equivalent of this:
```
document.getElementById('MyObject')
``` | Yes, use `.get(index)`. According to the [documentation](https://api.jquery.com/get/#get1):
>
> The `.get()` method grants access to the DOM nodes underlying each jQuery object.
>
>
> |
47,849 | <p>I'm trying to refer to a drive whose letter may change. I'd like to refer to it by its label (e.g., MyLabel (v:) within a Batch File. It can be referred to by V:\ . I'd like to refer to it by MyLabel.</p>
<p>(This was posted on Experts Echange for a month with no answer. Let's see how fast SO answers it )</p>
| [
{
"answer_id": 47856,
"author": "VolkerK",
"author_id": 4833,
"author_profile": "https://Stackoverflow.com/users/4833",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the WMI query language for that.\nTake a look at <a href=\"http://msdn.microsoft.com/en-us/library/aa394592(VS... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] | I'm trying to refer to a drive whose letter may change. I'd like to refer to it by its label (e.g., MyLabel (v:) within a Batch File. It can be referred to by V:\ . I'd like to refer to it by MyLabel.
(This was posted on Experts Echange for a month with no answer. Let's see how fast SO answers it ) | This bat file will give you the drive letter from a drive label:
```
Option Explicit
Dim num, args, objWMIService, objItem, colItems
set args = WScript.Arguments
num = args.Count
if num <> 1 then
WScript.Echo "Usage: CScript DriveFromLabel.vbs <label>"
WScript.Quit 1
end if
Set objWMIService = GetObject("winm... |
47,862 | <p>I'm loading a <strong><em>SQL Server 2000</em></strong> database into my new <strong><em>SQL Server 2005</em></strong> <strong><em>instance</em></strong>. <strong><em>As expected, the full-text catalogs don't come with it.</strong> <strong>How can I rebuild them?</em></strong></p>
<p>Right-clicking my full text cat... | [
{
"answer_id": 47900,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": true,
"text": "<p>Try it using SQL.</p>\n\n<ul>\n<li><a href=\"http://msdn.microsoft.com/en-us/library/ms189520%28SQL.90%29.aspx\" rel=... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2590/"
] | I'm loading a ***SQL Server 2000*** database into my new ***SQL Server 2005*** ***instance***. ***As expected, the full-text catalogs don't come with it.*** **How can I rebuild them?**
Right-clicking my full text catalogs and hitting "***rebuild indexes***" just hangs for hours and hours without doing anything, so it ... | Try it using SQL.
* [CREATE FULLTEXT CATALOG](http://msdn.microsoft.com/en-us/library/ms189520%28SQL.90%29.aspx)
* [ALTER FULLTEXT CATALOG](http://msdn.microsoft.com/en-us/library/ms176095%28SQL.90%29.aspx)
Here's an example from Microsoft.
```
--Change to accent insensitive
USE AdventureWorks;
GO
ALTER FULLTEXT CAT... |
47,864 | <p>ValidateEvents is a great ASP.net function, but the Yellow Screen of Death is not so nice. I found a way how to handle the HttpRequestValidationException gracefully <a href="http://www.romsteady.net/blog/2007/06/how-to-catch-httprequestvalidationexcep.html" rel="nofollow noreferrer">here</a>, but that does not work... | [
{
"answer_id": 48831,
"author": "Sara Chipps",
"author_id": 4140,
"author_profile": "https://Stackoverflow.com/users/4140",
"pm_score": 0,
"selected": false,
"text": "<p>hmmmm, it seems you would need to find some sort of JavaScript to check for html input or a client side validator. </p... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | ValidateEvents is a great ASP.net function, but the Yellow Screen of Death is not so nice. I found a way how to handle the HttpRequestValidationException gracefully [here](http://www.romsteady.net/blog/2007/06/how-to-catch-httprequestvalidationexcep.html), but that does not work with ASP.net AJAX properly.
Basically, ... | Found it and [blogged about it](http://www.stum.de/2008/09/08/gracefully-handling-httprequestvalidationexception-with-aspnet-ajax/). Basically, the EndRequestHandler and the args.set\_errorHandled are our friends here.
```
<script type="text/javascript" language="javascript">
var prm = Sys.WebForms.PageRequestManager.... |
47,882 | <p>What is a magic number?</p>
<p>Why should it be avoided?</p>
<p>Are there cases where it's appropriate?</p>
| [
{
"answer_id": 47885,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 4,
"selected": false,
"text": "<p>A magic number is a sequence of characters at the start of a file format, or protocol exchange. This number serves... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] | What is a magic number?
Why should it be avoided?
Are there cases where it's appropriate? | A magic number is a direct usage of a number in the code.
For example, if you have (in Java):
```java
public class Foo {
public void setPassword(String password) {
// don't do this
if (password.length() > 7) {
throw new InvalidArgumentException("password");
}
}
}
```
... |
47,883 | <p>I'm trying to install 'quadrupel', a library that relies on ffmpeg on Solaris x86.</p>
<p>I managed to build ffmpeg and its libraries live in /opt/gnu/lib and the includes are in /opt/gnu/include but when I try to build quadrupel, it can't find the ffmpeg headers.</p>
<p>What flags/configuration is required to inc... | [
{
"answer_id": 47913,
"author": "stimms",
"author_id": 361,
"author_profile": "https://Stackoverflow.com/users/361",
"pm_score": 2,
"selected": true,
"text": "<p>You can override the path by setting the environmental variable LD_LIBRARY_PATH. However I would suggest changing the system ... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/555/"
] | I'm trying to install 'quadrupel', a library that relies on ffmpeg on Solaris x86.
I managed to build ffmpeg and its libraries live in /opt/gnu/lib and the includes are in /opt/gnu/include but when I try to build quadrupel, it can't find the ffmpeg headers.
What flags/configuration is required to include those two di... | You can override the path by setting the environmental variable LD\_LIBRARY\_PATH. However I would suggest changing the system paths as well so you don't have to change the library path for all users. This can be done using crel.
```
crle -l -c /var/ld/ld.config -l /usr/lib:/usr/local/lib:/opt/gnu/lib
```
For the i... |
47,919 | <p>I'm used to doing all my coding in one C file. However, I'm working on a project large enough that it becomes impractical to do so. I've been #including them together but I've run into cases where I'm #including some files multiple times, etc. I've heard of .h files, but I'm not sure what their function is (or why h... | [
{
"answer_id": 47928,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 3,
"selected": false,
"text": "<p>Try to make each .c focus on a particular area of functionality. Use the corresponding .h file to declare those functions.</p... | 2008/09/06 | [
"https://Stackoverflow.com/questions/47919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I'm used to doing all my coding in one C file. However, I'm working on a project large enough that it becomes impractical to do so. I've been #including them together but I've run into cases where I'm #including some files multiple times, etc. I've heard of .h files, but I'm not sure what their function is (or why havi... | You should regard .h files as **interface files** of your .c file. Every .c file represents a module with a certain amount of functionality. If functions in a .c file are used by other modules (i.e. other .c files) put the function prototype in the .h interface file. By including the interface file in your original mod... |
47,975 | <p>More out of interest than anything else, but can you compile a DirectX app under linux?</p>
<p>Obviously there's no official SDK, but I was thinking it might be possible with wine.</p>
<p>Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edi... | [
{
"answer_id": 47978,
"author": "Nicholas",
"author_id": 2658,
"author_profile": "https://Stackoverflow.com/users/2658",
"pm_score": 0,
"selected": false,
"text": "<p>There is currently no way to compile DirectX code to directly target Linux. You would build your application like you nor... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4949/"
] | More out of interest than anything else, but can you compile a DirectX app under linux?
Obviously there's no official SDK, but I was thinking it might be possible with wine.
Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edit: This is called... | I've had some luck with this. I've managed to compile [this simple Direct3D example](http://www.directxtutorial.com/Tutorial9/B-Direct3DBasics/dx9B5.aspx).
I used winelib for this (wine-dev package on Ubuntu). Thanks to [alastair](https://stackoverflow.com/users/9554/alastair) for pointing me to winelib.
I modified t... |
47,981 | <p>How do I set, clear, and toggle a bit?</p>
| [
{
"answer_id": 47990,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 13,
"selected": true,
"text": "<h1>Setting a bit</h1>\n<p>Use the bitwise OR operator (<code>|</code>) to set a bit.</p>\n<pre><code>number |= 1UL <<... | 2008/09/07 | [
"https://Stackoverflow.com/questions/47981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | How do I set, clear, and toggle a bit? | Setting a bit
=============
Use the bitwise OR operator (`|`) to set a bit.
```
number |= 1UL << n;
```
That will set the `n`th bit of `number`. `n` should be zero, if you want to set the `1`st bit and so on upto `n-1`, if you want to set the `n`th bit.
Use `1ULL` if `number` is wider than `unsigned long`; promoti... |
48,009 | <p>What are the performance, security, or "other" implications of using the following form to declare a new class instance in PHP</p>
<pre><code><?php
$class_name = 'SomeClassName';
$object = new $class_name;
?>
</code></pre>
<p>This is a contrived example, but I've seen this form used in Factories (OOP) to... | [
{
"answer_id": 48035,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<p>It looks you can still pass arguments to the constructor, here's my test code:</p>\n\n<pre><code><?php\n\nclass Test ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4668/"
] | What are the performance, security, or "other" implications of using the following form to declare a new class instance in PHP
```
<?php
$class_name = 'SomeClassName';
$object = new $class_name;
?>
```
This is a contrived example, but I've seen this form used in Factories (OOP) to avoid having a big if/switch st... | One of the issues with the resolving at run time is that you make it really hard for the opcode caches (like APC). Still, for now, doing something like you describe in your question is a valid way if you need a certain amount of indirection when instanciating stuff.
As long as you don't do something like
```
$classna... |
48,053 | <p>I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.</p>
<p>Is there another way ... | [
{
"answer_id": 48058,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 1,
"selected": false,
"text": "<p>In the embedded world, the \"modulus\" operations you need to do are often the ones that break down nicely into bit o... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | I read somewhere once that the modulus operator is inefficient on small embedded devices like 8 bit micro-controllers that do not have integer division instruction. Perhaps someone can confirm this but I thought the difference is 5-10 time slower than with an integer division operation.
Is there another way to do this... | Ah, the joys of bitwise arithmetic. A side effect of many division routines is the modulus - so in few cases should division actually be faster than modulus. I'm interested to see the source you got this information from. Processors with multipliers have interesting division routines using the multiplier, but you can g... |
48,070 | <p>We are trying to lighten our page load as much as possible. Since ViewState can sometimes swell up to 100k of the page, I'd love to completely eliminate it.</p>
<p>I'd love to hear some techniques other people have used to move ViewState to a custom provider.</p>
<p>That said, a few caveats:</p>
<ul>
<li>We serve... | [
{
"answer_id": 48082,
"author": "Erick Sgarbi",
"author_id": 4171,
"author_profile": "https://Stackoverflow.com/users/4171",
"pm_score": 2,
"selected": false,
"text": "<p>I have tested many ways to remove the load of view state from the page and between all hacks and some software out th... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | We are trying to lighten our page load as much as possible. Since ViewState can sometimes swell up to 100k of the page, I'd love to completely eliminate it.
I'd love to hear some techniques other people have used to move ViewState to a custom provider.
That said, a few caveats:
* We serve on average 2 Million unique... | How do you handle Session State? There is a built-in "store the viewstate in the session state" provider. If you are storing the session state in some fast, out of proc system, that might be the best option for the viewstate.
edit: to do this add the following code to the your Page classes / global page base class
``... |
48,094 | <p>So I have a pointer to an array of pointers. If I delete it like this:</p>
<pre><code>delete [] PointerToPointers;
</code></pre>
<p>Will that delete all the pointed to pointers as well? If not, do I have to loop over all of the pointers and delete them as well, or is there an easier way to do it? My google-fu d... | [
{
"answer_id": 48095,
"author": "Matt Sheppard",
"author_id": 797,
"author_profile": "https://Stackoverflow.com/users/797",
"pm_score": 1,
"selected": false,
"text": "<p>I think you're going to have to loop over I'm afraid.</p>\n"
},
{
"answer_id": 48098,
"author": "Jeffrey",... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | So I have a pointer to an array of pointers. If I delete it like this:
```
delete [] PointerToPointers;
```
Will that delete all the pointed to pointers as well? If not, do I have to loop over all of the pointers and delete them as well, or is there an easier way to do it? My google-fu doesn't seem to give me any go... | Yes you have to loop over the pointers, deleting individually.
Reason: What if other code had pointers to the objects in your array? The C++ compiler doesn't know if that's true or not, so you have to be explicit.
For an "easier way," two suggestions: (1) Make a subroutine for this purpose so at least you won't have ... |
48,124 | <p>How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?</p>
| [
{
"answer_id": 48125,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 8,
"selected": true,
"text": "<p>First make a string with all your possible characters:</p>\n\n<pre><code> $characters = 'abcdefghijklmnopqrstuvwxyz012345... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP? | First make a string with all your possible characters:
```
$characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
```
You could also use [range()](http://php.net/range) to do this more quickly.
Then, in a loop, choose a random number and use it as the index to the `$characters` string to get a random character, and... |
48,126 | <p>Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter?</p>
| [
{
"answer_id": 48161,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 5,
"selected": true,
"text": "<p>it looks like it's answered in this post:</p>\n\n<p><a href=\"http://forums.mysql.com/read.php?52,198596,198717#msg-1987... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | Documentation is severely lacking on anything to do with stored procedures in mysql with PHP. I currently have a stored procedure that I call via PHP, how can I get the value of an out parameter? | it looks like it's answered in this post:
<http://forums.mysql.com/read.php?52,198596,198717#msg-198717>
With mysqli PHP API:
Assume sproc myproc( IN i int, OUT j int ):
```
$mysqli = new mysqli( "HOST", "USR", "PWD", "DBNAME" );
$ivalue=1;
$res = $mysqli->multi_query( "CALL myproc($ivalue,@x);SELECT @x" );
if( ... |
48,198 | <p>How do I find out which process is listening on a TCP or UDP port on Windows?</p>
| [
{
"answer_id": 48199,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 13,
"selected": true,
"text": "<h1><a href=\"https://en.wikipedia.org/wiki/PowerShell\" rel=\"noreferrer\">PowerShell</a></h1>\n<h2>TCP</h2>\n<pre><code... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | How do I find out which process is listening on a TCP or UDP port on Windows? | [PowerShell](https://en.wikipedia.org/wiki/PowerShell)
======================================================
TCP
---
```
Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess
```
UDP
---
```
Get-Process -Id (Get-NetUDPEndpoint -LocalPort YourPortNumberHere).OwningProcess
```
[cmd](h... |
48,235 | <p>I really enjoy Chrome, and the sheer exercise of helping a port would boost my knowledge-base.</p>
<p>Where do I start?</p>
<p>What are the fundamental similarities and differences between the code which will operated under Windows and Linux?</p>
<p>What skills and software do I need?</p>
<hr />
<h3>Note:</h3>
<p>Th... | [
{
"answer_id": 48236,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "<p>Read this article on Chrome and Open Source on Linux:</p>\n\n<p><a href=\"http://arstechnica.com/journals/linux.ars/2008/09/0... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | I really enjoy Chrome, and the sheer exercise of helping a port would boost my knowledge-base.
Where do I start?
What are the fundamental similarities and differences between the code which will operated under Windows and Linux?
What skills and software do I need?
---
### Note:
The official website is Visual Stud... | EDIT: (2/6/10)
A Beta version of Chrome has been released for Linux. Although it is labeled beta, it works great on my Ubuntu box. You can download it from Google:
<http://www.google.com/chrome?platform=linux>
EDIT: (5/31/09)
Since I answered this question, there have been more new developments in Chrome (actually ... |
48,239 | <p>Is there any way to get the ID of the element that fires an event?</p>
<p>I'm thinking something like:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready... | [
{
"answer_id": 48242,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 6,
"selected": false,
"text": "<p>You can use <code>(this)</code> to reference the object that fired the function.</p>\n\n<p><code>'this'</code> is a <strong>D... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1090/"
] | Is there any way to get the ID of the element that fires an event?
I'm thinking something like:
```js
$(document).ready(function() {
$("a").click(function() {
var test = caller.id;
alert(test.val());
});
});
```
```html
<script type="text/javascript" src="starterkit/jquery.js"></script>
<form clas... | In jQuery `event.target` always refers to the element that triggered the event, where `event` is the parameter passed to the function. <http://api.jquery.com/category/events/event-object/>
```
$(document).ready(function() {
$("a").click(function(event) {
alert(event.target.id);
});
});
```
Note also ... |
48,240 | <p>I am working with an API that provides bus arrival data. For every request, I get back (among other things) a list of which routes serve the stop in question. For example, if the list includes result for bus route #1, 2, and 5, then I know that those serve this stop.</p>
<p>I have a many-to-many relationship set up... | [
{
"answer_id": 48529,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 1,
"selected": false,
"text": "<p>If I get it right, you (should) have 2 models. A Route model, and a Stop model.</p>\n\n<p>Here's how I would define... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/124/"
] | I am working with an API that provides bus arrival data. For every request, I get back (among other things) a list of which routes serve the stop in question. For example, if the list includes result for bus route #1, 2, and 5, then I know that those serve this stop.
I have a many-to-many relationship set up between R... | If I get it right, you (should) have 2 models. A Route model, and a Stop model.
Here's how I would define these models:
```
class Route < ActiveRecord::Base
has_and_belongs_to_many :stops
belongs_to :stop, :foreign_key => 'destination_id'
end
class Stop < ActiveRecorde::Base
has_and_belongs_to_many :routes
end... |
48,278 | <p>I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts.</p>
<p>Is there a way to make the webbrowser print the background of the displayed document too?</p>
<p>Edit:
Since I wanted to do this programatically, I opted for this... | [
{
"answer_id": 48292,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "<p>By default, the browser does not print background images at all. </p>\n\n<p>In Firefox</p>\n\n<pre><code>* File > Page Set... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4582/"
] | I am using the webbrowser control in winforms and discovered now that background images which I apply with css are not included in the printouts.
Is there a way to make the webbrowser print the background of the displayed document too?
Edit:
Since I wanted to do this programatically, I opted for this solution:
```
u... | If you're going to go and change an important system setting, make sure to first read the current setting and restore it when you are done.
I consider this *very bad* practice in the first place, but if you must do it then be kind.
```
Registry.LocalMachine
```
Also, try changing `LocalUser` instead of `LocalMachin... |
48,288 | <p>I've been trying to understand <a href="http://msdn.microsoft.com/en-gb/library/system.diagnostics.process.mainwindowhandle.aspx" rel="nofollow noreferrer">Process.MainWindowHandle</a>.</p>
<p>According to MSDN; "The main window is the window that is created when the process is started. After initialization, other ... | [
{
"answer_id": 48301,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<p>Actually Process.MainWindowHandle is a handle of top-most window, it's not really the \"Main Window Handle\"</p>\n"
},
{
... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4200/"
] | I've been trying to understand [Process.MainWindowHandle](http://msdn.microsoft.com/en-gb/library/system.diagnostics.process.mainwindowhandle.aspx).
According to MSDN; "The main window is the window that is created when the process is started. After initialization, other windows may be opened, including the Modal and ... | @edg,
I guess it's an error in MSDN. You can clearly see in Relfector, that "Main window" check in .NET looks like:
```
private bool IsMainWindow(IntPtr handle)
{
return (!(NativeMethods.GetWindow(new HandleRef(this, handle), 4) != IntPtr.Zero)
&& NativeMethods.IsWindowVisible(new HandleRef(this, h... |
48,340 | <p>i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract. </p>
<p>here is the code below;</p>
<pre><code>public void Foo()
{
try
{
DoSomething(); // throws FaultException<FooFault>
... | [
{
"answer_id": 48345,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 0,
"selected": false,
"text": "<p>Take a closer look at catched exception. Was it FaultException< FooFault> or FaultException ? There are 2 version of FaultE... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4215/"
] | i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract.
here is the code below;
```
public void Foo()
{
try
{
DoSomething(); // throws FaultException<FooFault>
}
catch (Fau... | Are you consuming the WCF service from Silverlight? If so, a special configuration is needed to make the service return a HTTP 200 code instead of 500 in case of error. The details are here: <http://msdn.microsoft.com/en-us/library/dd470096%28VS.96%29.aspx> |
48,356 | <p>Greetings, I'm trying to find a way to 'unbind' a socket from a particular IP/Port combination. My pseudocode looks like this:</p>
<pre><code>ClassA a = new ClassA(); //(class A instantiates socket and binds it to 127.0.0.1:4567)
//do something
//...much later, a has been garbage-collected away.
ClassA aa = ne... | [
{
"answer_id": 48361,
"author": "zappan",
"author_id": 4723,
"author_profile": "https://Stackoverflow.com/users/4723",
"pm_score": 0,
"selected": false,
"text": "<p>you can't rely on object being garbage collected in C# (i assume you're using c#, based on tagging) if it holds resources l... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5021/"
] | Greetings, I'm trying to find a way to 'unbind' a socket from a particular IP/Port combination. My pseudocode looks like this:
```
ClassA a = new ClassA(); //(class A instantiates socket and binds it to 127.0.0.1:4567)
//do something
//...much later, a has been garbage-collected away.
ClassA aa = new ClassA(); //cr... | (this is what finally got everything to work for me)
Make sure EVERY socket that the socket in A connects to has
```
socket.SetSocketOption(SocketOptionLevel.Socket,SocketOptionName.ReuseAddress, true);
```
set upon being initiated. |
48,426 | <p>My gcc build toolchain produces a .map file. How do I display the memory map graphically?</p>
| [
{
"answer_id": 112078,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 6,
"selected": true,
"text": "<p>Here's the beginnings of a script in Python. It loads the map file into a list of Sections and Symbols (first half). I... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | My gcc build toolchain produces a .map file. How do I display the memory map graphically? | Here's the beginnings of a script in Python. It loads the map file into a list of Sections and Symbols (first half). It then renders the map using HTML (or do whatever you want with the `sections` and `symbols` lists).
You can control the script by modifying these lines:
```
with open('t.map') as f:
colors = ['9C9F84... |
48,432 | <p>Being relatively new to the .net game, I was wondering, has anyone had any experience of the pros / cons between the use of LINQ and what could be considered more traditional methods working with lists / collections? </p>
<p>For a specific example of a project I'm working on : a list of unique id / name pairs are ... | [
{
"answer_id": 48476,
"author": "Rob Stevenson-Leggett",
"author_id": 4950,
"author_profile": "https://Stackoverflow.com/users/4950",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure a singleton class is absolutely necessary, do you absolutely need global access at all times? I... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4396/"
] | Being relatively new to the .net game, I was wondering, has anyone had any experience of the pros / cons between the use of LINQ and what could be considered more traditional methods working with lists / collections?
For a specific example of a project I'm working on : a list of unique id / name pairs are being retri... | i dont think the linq you wrote would compile, it'd have to be
```
public string branchName (string branchId)
{
//branchList populated in the constructor
branch_summary bs = (from b in branchList where b.id == branchId select b).FirstOrDefault();
return branch_summary == null ? null : branch_summary.name;... |
48,458 | <p>I started an application in Google App Engine right when it came out, to play with the technology and work on a pet project that I had been thinking about for a long time but never gotten around to starting. The result is <a href="http://www.bowlsk.com" rel="noreferrer">BowlSK</a>. However, as it has grown, and fe... | [
{
"answer_id": 48467,
"author": "Dominic Eidson",
"author_id": 5042,
"author_profile": "https://Stackoverflow.com/users/5042",
"pm_score": 1,
"selected": false,
"text": "<p>I am not entirely up to date on the latest best practices, et cetera when it comes to code layout, but when I did m... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] | I started an application in Google App Engine right when it came out, to play with the technology and work on a pet project that I had been thinking about for a long time but never gotten around to starting. The result is [BowlSK](http://www.bowlsk.com). However, as it has grown, and features have been added, it has go... | First, I would suggest you have a look at "[Rapid Development with Python, Django, and Google App Engine](http://sites.google.com/site/io/rapid-development-with-python-django-and-google-app-engine)"
GvR describes a general/standard project layout on page 10 of his [slide presentation](http://sites.google.com/site/io/r... |
48,470 | <p>Whenever I use a macro in Visual Studio I get an annoying tip balloon in the system tray and an accompanying "pop" sound. It says:</p>
<blockquote>
<p>Visual Studio .NET macros</p>
<p>To stop the macro from running, double-click the spinning cassette.<br>
Click here to not show this balloon again.</p>
</bl... | [
{
"answer_id": 48478,
"author": "Owen",
"author_id": 4790,
"author_profile": "https://Stackoverflow.com/users/4790",
"pm_score": 2,
"selected": false,
"text": "<p>Okay, I found a way to make the balloon clickable, and clicking it does indeed stop it from popping up again. (On the other s... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4790/"
] | Whenever I use a macro in Visual Studio I get an annoying tip balloon in the system tray and an accompanying "pop" sound. It says:
>
> Visual Studio .NET macros
>
>
> To stop the macro from running, double-click the spinning cassette.
>
> Click here to not show this balloon again.
>
>
>
I have trouble click... | This will disable the pop up:
For Visual Studio 2008:
```
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0
DWORD DontShowMacrosBalloon=6
```
For Visual Studio 2010 (the DWORD won't be there by default, use `New | DWORD value` to create it):
```
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0
DWORD... |
48,474 | <p>I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and ... | [
{
"answer_id": 48482,
"author": "Chris Bartow",
"author_id": 497,
"author_profile": "https://Stackoverflow.com/users/497",
"pm_score": 3,
"selected": false,
"text": "<p>The easy way to do it is to use background-image then just put an <img> in that element.</p>\n\n<p>The other way ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5038/"
] | I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and simila... | Ok, after some time, here's what I landed on:
```css
.parent {
position: relative;
top: 0;
left: 0;
}
.image1 {
position: relative;
top: 0;
left: 0;
border: 1px red solid;
}
.image2 {
position: absolute;
top: 30px;
left: 30px;
border: 1px green solid;
}
```
```html
<div class="parent">
<img cl... |
48,491 | <p>I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:</p>
<pre><code>$ rsync --remove-source-files spe... | [
{
"answer_id": 48500,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": false,
"text": "<p>How much control do you have over the download process? If you roll your own, you can have the file being downloaded... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4300/"
] | I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:
```
$ rsync --remove-source-files speed:/var/crawld... | How much control do you have over the download process? If you roll your own, you can have the file being downloaded go to a temp directory or have a temporary name until it's finished downloading, and then mv it to the correct name when it's done. If you're using third party software, then you don't have as much contr... |
48,497 | <p>The following XHTML code is not working:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
... | [
{
"answer_id": 48552,
"author": "John Smithers",
"author_id": 1069,
"author_profile": "https://Stackoverflow.com/users/1069",
"pm_score": 0,
"selected": false,
"text": "<p>Well, what is dojo.js doing at line 319?</p>\n"
},
{
"answer_id": 48554,
"author": "Brian Gianforcaro",
... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4875/"
] | The following XHTML code is not working:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/... | The problem seams to be the ending of the file...
* If I name the file [test2.html](http://www.tasix.ch/Greter/test2.html) everything works.
* If I name the file [test2.xhtml](http://www.tasix.ch/Greter/test2.xhtml) I get the error message.
The diverence between the two seams to be the Content-Type in the response he... |
48,521 | <p>I would like to use a component that exposes the datasource property, but instead of supplying the datasource with whole list of objects, I would like to use only simple object. Is there any way to do this ?</p>
<p>The mentioned component is DevExpress.XtraDataLayout.DataLayoutControl - this is fairly irrelevant to... | [
{
"answer_id": 48522,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "<p>Databinding expects an IEnumerable object, because it enumorates over it just like a foreach loop does.</p>\n\n<p>So to do ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4694/"
] | I would like to use a component that exposes the datasource property, but instead of supplying the datasource with whole list of objects, I would like to use only simple object. Is there any way to do this ?
The mentioned component is DevExpress.XtraDataLayout.DataLayoutControl - this is fairly irrelevant to the quest... | Databinding expects an IEnumerable object, because it enumorates over it just like a foreach loop does.
So to do this, just wrap your single object in an IEnumerable.
Even this would work:
```
DataBindObject.DataSource = new List<YourObject>().Add(YourObjectInstance);
``` |
48,526 | <p>I've been looking into different web statistics programs for my site, and one promising one is <a href="http://www.hping.org/visitors/" rel="nofollow noreferrer">Visitors</a>. Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's <a href="http://us.php.net/manual... | [
{
"answer_id": 48528,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>Visitors looks like a log analyzer and report generator. Its probably best setup as a chron job to create static HTML page... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I've been looking into different web statistics programs for my site, and one promising one is [Visitors](http://www.hping.org/visitors/). Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's [shell\_exec](http://us.php.net/manual/en/function.shell-exec.php), but m... | I managed to solve this problem on my own. I put the following lines in a file named visitors.cgi:
```
#!/bin/sh
printf "Content-type: text/html\n\n"
exec visitors -A /home/logs/access_log
``` |
48,550 | <p>I am trying to publish an Asp.net MVC web application locally using the NAnt and MSBuild. This is what I am using for my NAnt target;</p>
<pre><code><target name="publish-artifacts-to-build">
<msbuild project="my-solution.sln" target="Publish">
<property name="Configuration" value="debug" /... | [
{
"answer_id": 48553,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 5,
"selected": true,
"text": "<p>The \"Publish\" target you are trying to invoke is for \"OneClick\" deployment, not for publishing a website... This is why y... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4642/"
] | I am trying to publish an Asp.net MVC web application locally using the NAnt and MSBuild. This is what I am using for my NAnt target;
```
<target name="publish-artifacts-to-build">
<msbuild project="my-solution.sln" target="Publish">
<property name="Configuration" value="debug" />
<property name="OutDi... | The "Publish" target you are trying to invoke is for "OneClick" deployment, not for publishing a website... This is why you are getting the seemingly bizarre message.
You would want to use the AspNetCompiler task, rather than the MSBuild task. See <http://msdn2.microsoft.com/en-us/library/ms164291.aspx> for more info ... |
48,555 | <p>I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod_deflate and mod_gzip, so these options are out. I do have PHP 5 at my disposal, though, so I could use the gzip component of that.</p>
<p>I ... | [
{
"answer_id": 48583,
"author": "macbirdie",
"author_id": 5049,
"author_profile": "https://Stackoverflow.com/users/5049",
"pm_score": 1,
"selected": false,
"text": "<p>You can try your luck with <a href=\"http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html\" rel=\"nofollow noreferrer\"... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1944/"
] | I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod\_deflate and mod\_gzip, so these options are out. I do have PHP 5 at my disposal, though, so I could use the gzip component of that.
I am curre... | Sorry about the delay - it's a busy week for me.
Assumptions:
* `.htaccess` is in the same file as `compress.php`
* static files to be compressed are in `static` subdirectory
I started my solution from setting the following directives in .htaccess:
```
RewriteEngine on
RewriteRule ^static/.+\.(js|ico|gif|jpg|jpeg|p... |
48,567 | <p>I wrote a simple Windows Forms program in C#. I want to be able to input a windows user name and password and when I click a login button to run code run as the user I've entered as input.</p>
| [
{
"answer_id": 48571,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": true,
"text": "<p>You can use the WindowsIdentity.Impersonate method to \nachieve this. This method allows code to impersonate a different Windo... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] | I wrote a simple Windows Forms program in C#. I want to be able to input a windows user name and password and when I click a login button to run code run as the user I've entered as input. | You can use the WindowsIdentity.Impersonate method to
achieve this. This method allows code to impersonate a different Windows
user. Here is a link for more information on this method with a good sample:
<http://msdn.microsoft.com/en-us/library/system.security.principal.windowsidentity.impersonate.aspx>
Complete ex... |
48,570 | <p>I would like to implement something similar to a c# delegate method in PHP. A quick word to explain what I'm trying to do overall: I am trying to implement some asynchronous functionality. Basically, some resource-intensive calls that get queued, cached and dispatched when the underlying system gets around to it. ... | [
{
"answer_id": 48585,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": 2,
"selected": false,
"text": "<p>How do you feel about using the <a href=\"http://en.wikipedia.org/wiki/Observer_Pattern\" rel=\"nofollow noreferre... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I would like to implement something similar to a c# delegate method in PHP. A quick word to explain what I'm trying to do overall: I am trying to implement some asynchronous functionality. Basically, some resource-intensive calls that get queued, cached and dispatched when the underlying system gets around to it. When ... | (Apart from the observer pattern) you can also use [`call_user_func()`](http://php.net/manual/function.call-user-func.php) or [`call_user_func_array()`](http://php.net/manual/function.call-user-func-array.php).
If you pass an `array(obj, methodname)` as first parameter it will invoked as `$obj->methodname()`.
```
<?p... |
48,578 | <p>Not entirely sure what's going on here; any help would be appreciated.</p>
<p>I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:</p>
<pre><code>The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly
'C:\MyProject\bin... | [
{
"answer_id": 48581,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 1,
"selected": false,
"text": "<p>This error usually indicates a class naming conflict. You are referencing two namespaces or you created a class with t... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1540/"
] | Not entirely sure what's going on here; any help would be appreciated.
I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:
```
The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly
'C:\MyProject\bin\System.Web.Mvc.DLL' ... | Are you using a CodeBehind file, I don't see CodeBehind="" attribute where you are specifying the Inherits from? Then you have to point inherits to the class name of the codebehind.
Example:
```
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inheri... |
48,616 | <p>How do I set a property of a user control in <code>ListView</code>'s <code>LayoutTemplate</code> from the code-behind?</p>
<pre><code><asp:ListView ...>
<LayoutTemplate>
<myprefix:MyControl id="myControl" ... />
</LayoutTemplate>
...
</asp:ListView>
</code></pre>
<p>I want to do this:... | [
{
"answer_id": 48636,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <a href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.control.findcontrol.aspx\" rel=\"nofollow noreferr... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | How do I set a property of a user control in `ListView`'s `LayoutTemplate` from the code-behind?
```
<asp:ListView ...>
<LayoutTemplate>
<myprefix:MyControl id="myControl" ... />
</LayoutTemplate>
...
</asp:ListView>
```
I want to do this:
```
myControl.SomeProperty = somevalue;
```
Please notice that my control ... | To set a property of a control that is inside the LayoutTemplate, simply use the FindControl method on the ListView control.
```
var control = (MyControl)myListView.FindControl("myControlId");
``` |
48,642 | <p>I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type: </p>
<pre><code>:s/\(abc\)/\1\1/
</code></pre>
<p>But then I'd like to be able to... | [
{
"answer_id": 48657,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 7,
"selected": true,
"text": "<p><code><cword></code> is the word under the cursor (:help <code><cword></code>).</p>\n\n<p>Sorry, I should have b... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084/"
] | I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type:
```
:s/\(abc\)/\1\1/
```
But then I'd like to be able to move the cursor to "def" and... | `<cword>` is the word under the cursor (:help `<cword>`).
Sorry, I should have been more complete in this answer.
You can nmap a command to it, or this series of keystrokes for the lazy will work:
```
b #go to beginning of current word
yw #yank to register
```
Then, when you are typing in your pattern you can hit ... |
48,668 | <p>I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program?</p>
| [
{
"answer_id": 48672,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "<p>When you create types for 'Use and throw' purposes. \nThis seems to have come due to LINQ. Seems to be a way to create struc... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program? | Anonymous types have nothing to do with the design of systems or even at the class level. They're a tool for developers to use when coding.
I don't even treat anonymous types as types per-se. I use them mainly as method-level anonymous tuples. If I query the database and then manipulate the results, I would rather cre... |
48,669 | <p>I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of <code><div></code>s between my page and the master pages.</p>
<p>Does anyone know of a... | [
{
"answer_id": 48674,
"author": "DrFloyd5",
"author_id": 1736623,
"author_profile": "https://Stackoverflow.com/users/1736623",
"pm_score": 2,
"selected": false,
"text": "<p>If out output XML compliant HTML. Or at least translate your HTML product into XML compliancy, you at least could t... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2757/"
] | I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of `<div>`s between my page and the master pages.
Does anyone know of a tool that will help in this... | You can use [HTMLTidy](http://tidy.sourceforge.net/) to convert the HTML to well-formed XML so you can use [XML Diff](http://msdn.microsoft.com/en-us/library/aa302294.aspx), as Gulzar suggested.
```
tidy -asxml index.html
``` |
48,680 | <p>Say I have a <code>Textbox</code> nested within a <code>TabControl</code>. </p>
<p>When the form loads, I would like to focus on that <code>Textbox</code> (by default the focus is set to the <code>TabControl</code>).</p>
<p>Simply calling <code>textbox1.focus()</code> in the <code>Load</code> event of the form do... | [
{
"answer_id": 48719,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 7,
"selected": true,
"text": "<p>The following is the solution:</p>\n\n<pre><code>private void frmMainLoad(object sender, EventArgs e)\n{\n ActiveContr... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736/"
] | Say I have a `Textbox` nested within a `TabControl`.
When the form loads, I would like to focus on that `Textbox` (by default the focus is set to the `TabControl`).
Simply calling `textbox1.focus()` in the `Load` event of the form does not appear to work.
I have been able to focus it by doing the following:
```
... | The following is the solution:
```
private void frmMainLoad(object sender, EventArgs e)
{
ActiveControl = textBox1;
}
```
The better question would however be why... I'm not entirely sure what the answer to that one is.
Edit: I suspect it is something to do with the fact that both the form, and the TabControl a... |
48,744 | <h2>How do you find the phone numbers in 50,000 HTML pages?<br><br></h2>
<blockquote>
<h3>Jeff Attwood posted 5 Questions for programmers applying for jobs:</h3>
<p>In an effort to make life simpler for phone screeners, I've put together
this list of Five Essential Questions
that you need to ask during an S... | [
{
"answer_id": 48767,
"author": "Ande Turner",
"author_id": 4857,
"author_profile": "https://Stackoverflow.com/users/4857",
"pm_score": 1,
"selected": false,
"text": "<h2>Perl Solution</h2>\n<p>By: "MH" via codinghorror,com on September 5, 2008 07:29 AM</p>\n<pre><code>#!/usr/b... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | How do you find the phone numbers in 50,000 HTML pages?
-------------------------------------------------------
>
> ### Jeff Attwood posted 5 Questions for programmers applying for jobs:
>
>
> In an effort to make life simpler for phone screeners, I've put together
> this list of Five Essential Questions
> that y... | ```
egrep "(([0-9]{1,2}.)?[0-9]{3}.[0-9]{3}.[0-9]{4})" . -R --include='*.html'
``` |
48,772 | <p>I have never "hand-coded" object creation code for SQL Server and foreign key decleration is seemingly different between SQL Server and Postgres. Here is my sql so far:</p>
<pre><code>drop table exams;
drop table question_bank;
drop table anwser_bank;
create table exams
(
exam_id uniqueidentifier primary key,
... | [
{
"answer_id": 48778,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 9,
"selected": true,
"text": "<pre><code>create table question_bank\n(\n question_id uniqueidentifier primary key,\n question_exam_id uniqueidentif... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have never "hand-coded" object creation code for SQL Server and foreign key decleration is seemingly different between SQL Server and Postgres. Here is my sql so far:
```
drop table exams;
drop table question_bank;
drop table anwser_bank;
create table exams
(
exam_id uniqueidentifier primary key,
exam_name ... | ```
create table question_bank
(
question_id uniqueidentifier primary key,
question_exam_id uniqueidentifier not null,
question_text varchar(1024) not null,
question_point_value decimal,
constraint fk_questionbank_exams foreign key (question_exam_id) references exams (exam_id)
);
``` |
48,774 | <p>What's the "right" way to do the following as a boolean expression?</p>
<pre><code>for i in `ls $1/resources`; do
if [ $i != "database.db" ]
then
if [ $i != "tiles" ]
then
if [ $i != "map.pdf" ]
then
if [ $i != "map.png" ]
then
... | [
{
"answer_id": 48787,
"author": "frizz",
"author_id": 1003,
"author_profile": "https://Stackoverflow.com/users/1003",
"pm_score": 1,
"selected": false,
"text": "<pre><code>for i in `ls $1/resources`; do\n if [ $i != \"database.db\" ] && [ $i != \"tiles\" ] && [ $i != \... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/79/"
] | What's the "right" way to do the following as a boolean expression?
```
for i in `ls $1/resources`; do
if [ $i != "database.db" ]
then
if [ $i != "tiles" ]
then
if [ $i != "map.pdf" ]
then
if [ $i != "map.png" ]
then
sv... | The other solutions have a couple of common mistakes:
<http://www.pixelbeat.org/programming/shell_script_mistakes.html>
1. `for i in $(ls ...)` is redundant/problematic
just do: `for i in $1/resources*; do ...`
2. `[ $i != file1 -a $1 != file2 ]` This actually has 2 problems.
a. The `$i` is not quoted, hence names wi... |
48,794 | <p>Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page. I cannot set Model on my masterpage (... | [
{
"answer_id": 48821,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 0,
"selected": false,
"text": "<p>The ViewData Model property should only be used for the content that you're viewing/editing on the main section of t... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/481/"
] | Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page. I cannot set Model on my masterpage (am ... | How about creating an HtmlHelper extension method that allows you to call a partial view result on the an action on the controller.
Something like
```
public static void RenderPartialAction<TController>(this HtmlHelper helper, Func<TController, PartialViewResult> actionToRender)
where TController : Controller, n... |
48,872 | <p>In <a href="https://web.archive.org/web/20141127115939/https://blogs.msmvps.com/kathleen/2008/09/05/in-praise-of-nested-classes/" rel="noreferrer">Kathleen Dollard's 2008 blog post</a>, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes... | [
{
"answer_id": 48879,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 8,
"selected": true,
"text": "<p>Use a nested class when the class you are nesting is only useful to the enclosing class. For instance, nested classes allow ... | 2008/09/07 | [
"https://Stackoverflow.com/questions/48872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/100/"
] | In [Kathleen Dollard's 2008 blog post](https://web.archive.org/web/20141127115939/https://blogs.msmvps.com/kathleen/2008/09/05/in-praise-of-nested-classes/), she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes. I'm assuming that the people ... | Use a nested class when the class you are nesting is only useful to the enclosing class. For instance, nested classes allow you to write something like (simplified):
```
public class SortedMap {
private class TreeNode {
TreeNode left;
TreeNode right;
}
}
```
You can make a complete definition... |
48,908 | <p>I am a bit confused about socket programming in C.</p>
<p>You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article <s><a href="http://users.actcom.co.il/~choo/lupg/tutorials/internetworki... | [
{
"answer_id": 48910,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 2,
"selected": false,
"text": "<p>When you do a read on the socket, you tell it how many maximum bytes to read, but if it doesn't have that many, it gi... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277/"
] | I am a bit confused about socket programming in C.
You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article ~~[Network programming under Unix systems](http://users.actcom.co.il/~choo/lupg/tu... | Short answer is that you have to do all the heavy lifting yourself. You can be notified that there is data available to be read, but you won't know how many bytes are available. In most IP protocols that use variable length packets, there will be a header with a known fixed length prepended to the packet. This header w... |
48,916 | <p>I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this form loads, which takes a bit of time since it's accessing a web service API to populate some drop-downs. I also want to do some basic testing for depen... | [
{
"answer_id": 48944,
"author": "McKenzieG1",
"author_id": 3776,
"author_profile": "https://Stackoverflow.com/users/3776",
"pm_score": 3,
"selected": false,
"text": "<p>One simple way is the use something like this as main():</p>\n\n<pre><code><STAThread()> Public Shared Sub Main()... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4246/"
] | I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this form loads, which takes a bit of time since it's accessing a web service API to populate some drop-downs. I also want to do some basic testing for dependen... | Well, for a ClickOnce app that I deployed in the past, we used the `Microsoft.VisualBasic` namespace to handle the splash screen threading. You can reference and use the `Microsoft.VisualBasic` assembly from C# in .NET 2.0 and it provides a lot of nice services.
1. Have the main form inherit from `Microsoft.VisualBasi... |
48,919 | <p>What is the JavaScript to scroll to the top when a button/link/etc. is clicked?</p>
| [
{
"answer_id": 48925,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 4,
"selected": true,
"text": "<pre><code><a href=\"javascript:scroll(0, 0)\">Top</a>\n</code></pre>\n"
},
{
"answer_id": 48939,
"... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2469/"
] | What is the JavaScript to scroll to the top when a button/link/etc. is clicked? | ```
<a href="javascript:scroll(0, 0)">Top</a>
``` |
48,931 | <p>I used jQuery to set hover callbacks for elements on my page. I'm now writing a module which needs to temporarily set new hover behaviour for some elements. The new module has no access to the original code for the hover functions.</p>
<p>I want to store the old hover functions before I set new ones so I can restor... | [
{
"answer_id": 49042,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if this is what you mean, but you can bind custom events and then trigger them.</p>\n\n<p><a href=\"http://docs... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5114/"
] | I used jQuery to set hover callbacks for elements on my page. I'm now writing a module which needs to temporarily set new hover behaviour for some elements. The new module has no access to the original code for the hover functions.
I want to store the old hover functions before I set new ones so I can restore them whe... | Calling an event `bind` method (such as `hover`) does not delete old event handlers, only adds your new events, so your idea of 'restoring' the old event functions wouldn't work, as it wouldn't delete your events.
You can add your own events, and then remove them without affecting any other events then use Event names... |
48,933 | <p>Does anybody know of a way to list up the "loaded plugins" in <strong>Vim</strong>?
I know I should be keeping track of this kind of stuff myself but
it would always be nice to be able to check the current status.</p>
| [
{
"answer_id": 48952,
"author": "Rob Rolnick",
"author_id": 4798,
"author_profile": "https://Stackoverflow.com/users/4798",
"pm_score": 10,
"selected": true,
"text": "<p>Not a VIM user myself, so forgive me if this is totally offbase. But according to what I gather from the following <a ... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4037/"
] | Does anybody know of a way to list up the "loaded plugins" in **Vim**?
I know I should be keeping track of this kind of stuff myself but
it would always be nice to be able to check the current status. | Not a VIM user myself, so forgive me if this is totally offbase. But according to what I gather from the following [VIM Tips](http://rayninfo.co.uk/vimtips.html) site:
```
" where was an option set
:scriptnames : list all plugins, _vimrcs loaded (super)
:verbose set history? : reveals value of histor... |
48,934 | <p>I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:</p>
<pre><code>procedure TForm1.CalculateGP(..)
const
Price : money = 0;
begin
...
Price := 1.0;
...
end;
</code></pre>
<p>So in... | [
{
"answer_id": 48938,
"author": "Ray",
"author_id": 233,
"author_profile": "https://Stackoverflow.com/users/233",
"pm_score": 6,
"selected": true,
"text": "<p>You need to turn assignable typed constants on.\n\nProject -> Options -> Compiler -> Assignable typed Constants</p>\n\n<p>Also yo... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:
```
procedure TForm1.CalculateGP(..)
const
Price : money = 0;
begin
...
Price := 1.0;
...
end;
```
So in the new project, Delphi c... | You need to turn assignable typed constants on.
Project -> Options -> Compiler -> Assignable typed Constants
Also you can add `{$J+}` or `{$WRITEABLECONST ON}` to the pas file, which is probably better, since it'll work even if you move the file to another project. |
48,935 | <p>I'm building an application in C# using WPF. How can I bind to some keys?</p>
<p>Also, how can I bind to the <a href="http://en.wikipedia.org/wiki/Windows_key" rel="noreferrer">Windows key</a>?</p>
| [
{
"answer_id": 48942,
"author": "John Virgolino",
"author_id": 4246,
"author_profile": "https://Stackoverflow.com/users/4246",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure about WPF, but this may help. I used the solution described in <em><a href=\"http://www.pinvoke.net/de... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/146637/"
] | I'm building an application in C# using WPF. How can I bind to some keys?
Also, how can I bind to the [Windows key](http://en.wikipedia.org/wiki/Windows_key)? | I'm not sure of what you mean by "global" here, but here it goes (I'm assuming you mean a command at the application level, for example, *Save All* that can be triggered from anywhere by `Ctrl` + `Shift` + `S`.)
You find the global `UIElement` of your choice, for example, the top level window which is the parent of al... |
48,947 | <p>How are callbacks written in PHP?</p>
| [
{
"answer_id": 48948,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": 5,
"selected": false,
"text": "<p>Implementation of a callback is done like so</p>\n\n<pre><code>// This function uses a callback function. \nfuncti... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] | How are callbacks written in PHP? | The manual uses the terms "callback" and "callable" interchangeably, however, "callback" traditionally refers to a string or array value that acts like a [function pointer](http://en.wikipedia.org/wiki/Function_pointer), referencing a function or class method for future invocation. This has allowed some elements of fun... |
48,984 | <p>We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely?</p>
| [
{
"answer_id": 49136,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 5,
"selected": true,
"text": "<p>Here's the code we found to work:</p>\n\n<pre><code>IE browser = new IE(....);\nbrowser.Button(\"SlowPageLoadingButton... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] | We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely? | Here's the code we found to work:
```
IE browser = new IE(....);
browser.Button("SlowPageLoadingButton").ClickNoWait();
Link continueLink = browser.Link(Find.ByText("linktext"));
continueLink.WaitUntilExists();
continueLink.Click();
``` |
48,993 | <p>I am wondering if anyone has any experience using a JQuery plugin that converts a html </p>
<pre><code><select>
<option> Blah </option>
</select>
</code></pre>
<p>combo box into something (probably a div) where selecting an item acts the same as clicking a link.</p>
<p>I guess you coul... | [
{
"answer_id": 49027,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 0,
"selected": false,
"text": "<p>This bit of javascript in the 'select':</p>\n\n<pre><code>onchange=\"if(this.options[this.selectedIndex].value!=''){th... | 2008/09/08 | [
"https://Stackoverflow.com/questions/48993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I am wondering if anyone has any experience using a JQuery plugin that converts a html
```
<select>
<option> Blah </option>
</select>
```
combo box into something (probably a div) where selecting an item acts the same as clicking a link.
I guess you could probably use javascript to handle a selection event (my... | The simple solution is to use
```
$("#mySelect").change(function() {
document.location = this.value;
});
```
This creates an onchange event on the select box that redirects you to the url stored in the value field of the selected option. |
49,035 | <p>Given a declaration like this:</p>
<pre><code>class A {
public:
void Foo() const;
};
</code></pre>
<p>What does it mean?</p>
<p>Google turns up this:</p>
<blockquote>
<p>Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is no... | [
{
"answer_id": 49036,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 1,
"selected": false,
"text": "<p>that will cause the method to not be able to alter any member variables of the object</p>\n"
},
{
"answer_id": ... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | Given a declaration like this:
```
class A {
public:
void Foo() const;
};
```
What does it mean?
Google turns up this:
>
> Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is not declared const, in can not be applied to a const... | Consider a variation of your class `A`.
```
class A {
public:
void Foo() const;
void Moo();
private:
int m_nState; // Could add mutable keyword if desired
int GetState() const { return m_nState; }
void SetState(int val) { m_nState = val; }
};
const A *A1 = new A();
A *A2 = new A();
A1->Foo(); ... |
49,046 | <p>Why does <code>n</code> not equal to <code>8</code> in the following function?</p>
<pre><code>void foo(char cvalue[8])
{
int n = sizeof (cvalue);
}
</code></pre>
<p>But <code>n</code> <em>does</em> equal to <code>8</code> in this version of the function:</p>
<pre><code>void bar()
{
char cvalue[8];
int n = s... | [
{
"answer_id": 49055,
"author": "Nick Retallack",
"author_id": 2653,
"author_profile": "https://Stackoverflow.com/users/2653",
"pm_score": 7,
"selected": true,
"text": "<p>Because you can't pass entire arrays as function parameters in C. You're actually passing a pointer to it; the brac... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5065/"
] | Why does `n` not equal to `8` in the following function?
```
void foo(char cvalue[8])
{
int n = sizeof (cvalue);
}
```
But `n` *does* equal to `8` in this version of the function:
```
void bar()
{
char cvalue[8];
int n = sizeof (cvalue);
}
``` | Because you can't pass entire arrays as function parameters in C. You're actually passing a pointer to it; the brackets are syntactic sugar. There are no guarantees the array you're pointing to has size 8, since you could pass this function any character pointer you want.
```
// These all do the same thing
void foo(ch... |
49,098 | <p>So I have a function that looks something like this:</p>
<pre><code>float function(){
float x = SomeValue;
return x / SomeOtherValue;
}
</code></pre>
<p>At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout ... | [
{
"answer_id": 49120,
"author": "David Dibben",
"author_id": 5022,
"author_profile": "https://Stackoverflow.com/users/5022",
"pm_score": 2,
"selected": false,
"text": "<p>Printing a value to cout should not change the value of the paramter in any way at all.</p>\n\n<p>However, I have see... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | So I have a function that looks something like this:
```
float function(){
float x = SomeValue;
return x / SomeOtherValue;
}
```
At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout statement so that the funct... | Welcome to the wonderful world of floating point. The answer you get will likely depend on the floating point model you compiled the code with.
This happens because of the difference between the IEEE spec and the hardware the code is running on. Your CPU likely has 80 bit floating point registers that get use to hold... |
49,107 | <p>Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky. What's the normal pattern to work around this? </p>
<p>For example, is there a clean way to implement <em>swap( intA, ... | [
{
"answer_id": 49109,
"author": "Nick Retallack",
"author_id": 2653,
"author_profile": "https://Stackoverflow.com/users/2653",
"pm_score": -1,
"selected": false,
"text": "<p>If ActionScript works like Javascript,</p>\n\n<pre><code>[a,b] = [b,a]\n</code></pre>\n"
},
{
"answer_id":... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4969/"
] | Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky. What's the normal pattern to work around this?
For example, is there a clean way to implement *swap( intA, intB )* in Acti... | I Believe the best you can do is pass a container object as an argument to a function and change the values of some properties in that object:
```
function swapAB(aValuesContainer:Object):void
{
if (!(aValuesContainer.hasOwnProperty("a") && aValuesContainer.hasOwnProperty("b")))
throw new ArgumentError("aV... |
49,110 | <p>I'm looking for the basic loop like:</p>
<pre><code>for(int i = 0; i < MAX; i++) {
doSomething(i);
}
</code></pre>
<p>but for Bash.</p>
| [
{
"answer_id": 49111,
"author": "Rob Rolnick",
"author_id": 4798,
"author_profile": "https://Stackoverflow.com/users/4798",
"pm_score": 8,
"selected": true,
"text": "<p>From <a href=\"http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html\" rel=\"noreferrer\">this site</a>:</p>\n\n<pre><code... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535/"
] | I'm looking for the basic loop like:
```
for(int i = 0; i < MAX; i++) {
doSomething(i);
}
```
but for Bash. | From [this site](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html):
```
for i in $(seq 1 10);
do
echo $i
done
``` |
49,147 | <p>I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition.</p>
<p>I started in the Form Designer and made a button named "Click Me!" proceeded to double-click it and typed in</p>
<pre><code>MessageBox... | [
{
"answer_id": 49151,
"author": "moobaa",
"author_id": 3569,
"author_profile": "https://Stackoverflow.com/users/3569",
"pm_score": 5,
"selected": false,
"text": "<p>Code summary:</p>\n\n<pre><code>using System.Windows.Forms;\n\n...\n\nMessageBox.Show( \"hello world\" );\n</code></pre>\n\... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] | I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition.
I started in the Form Designer and made a button named "Click Me!" proceeded to double-click it and typed in
```
MessageBox("Hello, World!");
`... | MessageBox.Show also returns a DialogResult, which if you put some buttons on there, means you can have it returned what the user clicked. Most of the time I write something like
```
if (MessageBox.Show("Do you want to continue?", "Question", MessageBoxButtons.YesNo) == MessageBoxResult.Yes) {
//some interesting ... |
49,158 | <p>I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. </p>
<p>Is there a way I can use GreaseMonkey ... | [
{
"answer_id": 49188,
"author": "Garo Yeriazarian",
"author_id": 2655,
"author_profile": "https://Stackoverflow.com/users/2655",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you use Firefox (I assume you're using Firefox) to remember your credentials using the Password Manager... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3847/"
] | I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication.
Is there a way I can use GreaseMonkey to log me in... | It is possible to log in using HTTP authentication by setting the "Authorization" HTTP header, with the value of this header set to the string "basic username:password", but with the "username:password" portion of the string Base 64 encoded.
<http://frontier.userland.com/stories/storyReader$2159>
A bit of researchin... |
49,166 | <p>I've inherited a hoary old piece of code (by hoary, I mean warty with lots of undocumented bug fixes than WTF-y) and there's one part that's giving me a bit of trouble. Here's how it connects to the remote registry to get the add/remove programs key:</p>
<pre><code>try
{
remoteKey = RegistryKey.OpenRemoteBaseKe... | [
{
"answer_id": 49176,
"author": "Garo Yeriazarian",
"author_id": 2655,
"author_profile": "https://Stackoverflow.com/users/2655",
"pm_score": 1,
"selected": false,
"text": "<p>You probably have to use impersonation to change the credentials of the thread that calls the remote registry met... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133/"
] | I've inherited a hoary old piece of code (by hoary, I mean warty with lots of undocumented bug fixes than WTF-y) and there's one part that's giving me a bit of trouble. Here's how it connects to the remote registry to get the add/remove programs key:
```
try
{
remoteKey = RegistryKey.OpenRemoteBaseKey(
Reg... | John's pointer to MSDN answered what UnauthorizedAccessException is for - it only appears when you try to access a key remotely, using OpenRemoteBaseKey.
We're a little wary about changing the security context on the computer - I've found a reference [here](http://vbcity.com/forums/topic.asp?tid=43510) about using WMI... |
49,194 | <p>I have an action like this:</p>
<pre><code>public class News : System.Web.Mvc.Controller
{
public ActionResult Archive(int year)
{
/ *** /
}
}
</code></pre>
<p>With a route like this:</p>
<pre><code>routes.MapRoute(
"News-Archive",
... | [
{
"answer_id": 49197,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 3,
"selected": true,
"text": "<p>You have a couple problems, I think.</p>\n\n<p>First, your route doesn't have a default value for \"year\", so the URL ... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I have an action like this:
```
public class News : System.Web.Mvc.Controller
{
public ActionResult Archive(int year)
{
/ *** /
}
}
```
With a route like this:
```
routes.MapRoute(
"News-Archive",
"News.mvc/Archive/{year}", ... | You have a couple problems, I think.
First, your route doesn't have a default value for "year", so the URL "/News.mvc/Archive" is actually not valid for routing purposes.
Second, you're expect form values to show up as route parameters, but that's not how HTML works. If you use a plain form with a select and a submit... |
49,211 | <p>I have an existing application that is written in C++ for Windows. This application uses the Win32 CryptoAPI to generate a TripleDES session key for encrypting/decrypting data. We're using the <a href="http://www.phdcc.com/cryptorc4.htm" rel="nofollow noreferrer">exponent of one trick</a> to export the session key o... | [
{
"answer_id": 49232,
"author": "Nic Strong",
"author_id": 2281,
"author_profile": "https://Stackoverflow.com/users/2281",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, forget the last answer I can't read :) You are working with 3Des keys not RSA keys.</p>\n\n<p>I worked on a bunch o... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4916/"
] | I have an existing application that is written in C++ for Windows. This application uses the Win32 CryptoAPI to generate a TripleDES session key for encrypting/decrypting data. We're using the [exponent of one trick](http://www.phdcc.com/cryptorc4.htm) to export the session key out as a blob, which allows the blob to b... | Intro
-----
I'm Finally getting around to posting the solution. I hope it provides some help to others out there that might be doing similar type things. There really isn't much reference to doing this elsewhere.
Prerequisites
-------------
In order for a lot of this to make sense it's necessary to read the [*expone... |
49,214 | <p>I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously:</p>
<pre><code>List<int> iList = new List<int>();
for (int i = 1; i <= x; i++)
{
iList.Add(i);
}
</code></pre>
<p>This seems dumb, surely there's a more... | [
{
"answer_id": 49216,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 6,
"selected": false,
"text": "<p>LINQ to the rescue:</p>\n\n<pre><code>// Adding value to existing list\nvar list = new List<int>();\nlist.AddRange(Enume... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] | I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously:
```
List<int> iList = new List<int>();
for (int i = 1; i <= x; i++)
{
iList.Add(i);
}
```
This seems dumb, surely there's a more elegant way to do this, something like th... | If you're using .Net 3.5, [Enumerable.Range](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.range.aspx) is what you need.
>
> Generates a sequence of integral
> numbers within a specified range.
>
>
> |
49,252 | <p>For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:</p>
<p><code>Object.variable_name= 'new value'</code> </p>
<p>However, after implementing this I found out that many of ... | [
{
"answer_id": 49255,
"author": "Nick Retallack",
"author_id": 2653,
"author_profile": "https://Stackoverflow.com/users/2653",
"pm_score": 4,
"selected": true,
"text": "<p>Don't do it!</p>\n\n<p>Trying to create identifiers that are not valid in your language is not a good idea. If you r... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | For a project I am working on in ruby I am overriding the method\_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:
`Object.variable_name= 'new value'`
However, after implementing this I found out that many of the variable names have per... | Don't do it!
Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:
```
attr_writer :bar
attr_reader :baz
attr_accessor :foo
```
Okay, now that you have been warned, here's how to do it. Just return another instance o... |
49,258 | <p>I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I <em>don't</em> want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Do... | [
{
"answer_id": 49255,
"author": "Nick Retallack",
"author_id": 2653,
"author_profile": "https://Stackoverflow.com/users/2653",
"pm_score": 4,
"selected": true,
"text": "<p>Don't do it!</p>\n\n<p>Trying to create identifiers that are not valid in your language is not a good idea. If you r... | 2008/09/08 | [
"https://Stackoverflow.com/questions/49258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3955/"
] | I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I *don't* want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Does anyone ... | Don't do it!
Trying to create identifiers that are not valid in your language is not a good idea. If you really want to set variables like that, use attribute macros:
```
attr_writer :bar
attr_reader :baz
attr_accessor :foo
```
Okay, now that you have been warned, here's how to do it. Just return another instance o... |