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 |
|---|---|---|---|---|---|---|
234,515 | <p>I reloaded an old project, and tried to run it only to run into the Binding Failure MDA Assistant:</p>
<pre>
BindingFailure was detected
Message: The assembly with display name 'SoapTest.XmlSerializers' failed to load in the
'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was:
Sys... | [
{
"answer_id": 236732,
"author": "Geoff Cox",
"author_id": 30505,
"author_profile": "https://Stackoverflow.com/users/30505",
"pm_score": 1,
"selected": false,
"text": "<p>In VS.NET you can go to the project settings and try different settings for XmlSerialization - I believe there is a s... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] | I reloaded an old project, and tried to run it only to run into the Binding Failure MDA Assistant:
```
BindingFailure was detected
Message: The assembly with display name 'SoapTest.XmlSerializers' failed to load in the
'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was:
System.IO.F... | actually yes , i went to the propensities window and set the option of "Generate serialization assembly" to "on" , by this you insure every time you build the project ,
i guess that error happens when you edit the assmbly info of the class library you are referencing without re building it |
234,526 | <p>Can I setup a custom MIME type through ASP.NET or some .NET code? I need to register the Silverlight XAML and XAP MIME types in IIS 6.</p>
| [
{
"answer_id": 234613,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 4,
"selected": true,
"text": "<p>To add to the master mime type list:</p>\n\n<pre><code>using (DirectoryEntry mimeMap = new DirectoryEntry(\"IIS://Localhost/Mime... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5618/"
] | Can I setup a custom MIME type through ASP.NET or some .NET code? I need to register the Silverlight XAML and XAP MIME types in IIS 6. | To add to the master mime type list:
```
using (DirectoryEntry mimeMap = new DirectoryEntry("IIS://Localhost/MimeMap"))
{
PropertyValueCollection propValues = mimeMap.Properties["MimeMap"];
IISOle.MimeMapClass newMimeType = new IISOle.MimeMapClass();
newMimeType.Extension = extension; // string - .xap
... |
234,532 | <p>I have data that looks like</p>
<blockquote>
<pre><code>CUSTOMER, CUSTOMER_ID, PRODUCT
ABC INC 1 XYX
ABC INC 1 ZZZ
DEF CO 2 XYX
DEF CO 2 ZZZ
DEF CO 2 WWW
GHI LLC 3 ZYX
</code></pre>
</blockquote>
<p>I'd like to write a query th... | [
{
"answer_id": 234573,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php\" rel=\"nofollow nor... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1580/"
] | I have data that looks like
>
>
> ```
> CUSTOMER, CUSTOMER_ID, PRODUCT
> ABC INC 1 XYX
> ABC INC 1 ZZZ
> DEF CO 2 XYX
> DEF CO 2 ZZZ
> DEF CO 2 WWW
> GHI LLC 3 ZYX
>
> ```
>
>
I'd like to write a query that'd make the data lo... | [This link](http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php) refers to a number of examples of different ways to do this on Oracle. See if there's something there that you have permissions on your database to do. |
234,558 | <p>I can't seem to be able to disable ViewState for controls that I add to a page dynamically.</p>
<p><strong>ASPX</strong></p>
<pre><code><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Page1.aspx.cs" Inherits="Page1" EnableViewState="false" %>
...
<asp:PlaceHolder ID="DropDownPlaceHolder" runat="se... | [
{
"answer_id": 234763,
"author": "thismat",
"author_id": 14045,
"author_profile": "https://Stackoverflow.com/users/14045",
"pm_score": 0,
"selected": false,
"text": "<p>I tested this a bit and found it a little odd. It seems the post(back) will send the selected value, even if a control ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8797/"
] | I can't seem to be able to disable ViewState for controls that I add to a page dynamically.
**ASPX**
```
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Page1.aspx.cs" Inherits="Page1" EnableViewState="false" %>
...
<asp:PlaceHolder ID="DropDownPlaceHolder" runat="server" EnableViewState="false" />
<asp:Butto... | It's a "feature" -- <http://support.microsoft.com/?id=316813>
Thanks, Microsoft!! |
234,564 | <p>How do I make <a href="http://en.wikipedia.org/wiki/Vi" rel="noreferrer">vi</a>-<a href="http://en.wikipedia.org/wiki/Vim_%28text_editor%29" rel="noreferrer">Vim</a> never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like <a href="h... | [
{
"answer_id": 234578,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 12,
"selected": true,
"text": "<p>As has been pointed out in a couple of other answers, the preferred method now is NOT to use smartindent, but instead use t... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | How do I make [vi](http://en.wikipedia.org/wiki/Vi)-[Vim](http://en.wikipedia.org/wiki/Vim_%28text_editor%29) never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like [Emacs](http://en.wikipedia.org/wiki/Emacs) does?
Also, how do I sav... | As has been pointed out in a couple of other answers, the preferred method now is NOT to use smartindent, but instead use the following (in your [`.vimrc`](https://stackoverflow.com/questions/10921441/where-is-my-vimrc-file)):
```
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when i... |
234,589 | <p>One problem that I come across regularly and yet don't have a solution to is to restrict or permit access to specific entities in a system. Some companies (banks, for example) have very strict policies regarding which employees may access certain information. For example, an employee at a specific branch may access ... | [
{
"answer_id": 234649,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 1,
"selected": false,
"text": "<p>Have you looked into the <a href=\"http://msdn.microsoft.com/en-us/library/930b76w0(VS.80).aspx\" rel=\"nofollow noreferrer\... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15157/"
] | One problem that I come across regularly and yet don't have a solution to is to restrict or permit access to specific entities in a system. Some companies (banks, for example) have very strict policies regarding which employees may access certain information. For example, an employee at a specific branch may access acc... | I've beat my head against this wall on several occasions.
The best solution I've come to was to model everything in a tree hierarchy, where every domain class is an branch in the tree, and instances are leaves of that branch. Leaves can have veins if you need to secure parts of instances. Each branch has its own assig... |
234,594 | <p>In Eclipse, under <kbd>Windows</kbd> -> <kbd>Preference</kbd> -> <kbd>Java</kbd> -> <kbd>Code Style</kbd>, you can define code templates for comments and code, and you can setup a code formatter. </p>
<p>I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. B... | [
{
"answer_id": 234625,
"author": "Neal Swearer",
"author_id": 29962,
"author_profile": "https://Stackoverflow.com/users/29962",
"pm_score": 9,
"selected": true,
"text": "<p>Under <kbd>Preferences</kbd>, choose <kbd>Java</kbd> --> <kbd>Editor</kbd> --> <kbd>Save Actions</kbd>. Check the ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16524/"
] | In Eclipse, under `Windows` -> `Preference` -> `Java` -> `Code Style`, you can define code templates for comments and code, and you can setup a code formatter.
I'm wondering if it is possible in Eclipse to have these setting take affect every time I save a source file. Basically, instead of me highlighting everything... | Under `Preferences`, choose `Java` --> `Editor` --> `Save Actions`. Check the `Perform the selected actions on save`, and check the `Format source code` box.
This may or may not be available in previous versions of Eclipse. I know it works in:
```
Version: 3.3.3.r33x_r20080129-_19UEl7Ezk_gXF1kouft<br>
Build id: M2008... |
234,600 | <p>I would like to use <code>Class.newInstance()</code> but the class I am instantiating does not have a nullary constructor. Therefore I need to be able to pass in constructor arguments. Is there a way to do this?</p>
| [
{
"answer_id": 234610,
"author": "iny",
"author_id": 27067,
"author_profile": "https://Stackoverflow.com/users/27067",
"pm_score": 3,
"selected": false,
"text": "<p>You can get other constructors with <a href=\"http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getConstructor(jav... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to use `Class.newInstance()` but the class I am instantiating does not have a nullary constructor. Therefore I need to be able to pass in constructor arguments. Is there a way to do this? | ```
MyClass.class.getDeclaredConstructor(String.class).newInstance("HERESMYARG");
```
or
```
obj.getClass().getDeclaredConstructor(String.class).newInstance("HERESMYARG");
``` |
234,657 | <p>We have a Procedure in Oracle with a SYS_REFCURSOR output parameter that returns the data we want to bind to an ASP.NET GridView control. I've seen this done before but I can't find the original reference I used to solve the problem.</p>
<p>Here is what the procedure looks like:</p>
<pre><code>create or replace PR... | [
{
"answer_id": 234798,
"author": "balexandre",
"author_id": 28004,
"author_profile": "https://Stackoverflow.com/users/28004",
"pm_score": 1,
"selected": false,
"text": "<p>just GooglingIt trying to find out an answer for you, <a href=\"http://www.enterprisedb.com/documentation/dotnetprov... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31267/"
] | We have a Procedure in Oracle with a SYS\_REFCURSOR output parameter that returns the data we want to bind to an ASP.NET GridView control. I've seen this done before but I can't find the original reference I used to solve the problem.
Here is what the procedure looks like:
```
create or replace PROCEDURE GETSOMEDATA
... | Try something like: (didn't specify which language)
```
Public Function GetSomeData() as DataTable
Dim OrclConn as New OracleConnection("Connectionstring")
Dim OrclCmd as New Oraclecommand("GETSOMEDATA", OrclConn)
OrclCmd.CommandType = CommandType.StoredProcedure
OrclCmd.Parameters.... |
234,683 | <p>Which algorithm does the JavaScript <code>Array#sort()</code> function use? I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses.</p>
| [
{
"answer_id": 234706,
"author": "Huibert Gill",
"author_id": 1254442,
"author_profile": "https://Stackoverflow.com/users/1254442",
"pm_score": 3,
"selected": false,
"text": "<p>I think that would depend on what browser implementation you are refering to.</p>\n\n<p>Every browser type has... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11042/"
] | Which algorithm does the JavaScript `Array#sort()` function use? I understand that it can take all manner of arguments and functions to perform different kinds of sorts, I'm simply interested in which algorithm the vanilla sort uses. | I've just had a look at the WebKit (Chrome, Safari …) [source](http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp?rev=138530#L647). Depending on the type of array, different sort methods are used:
[Numeric arrays](http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/runtime/JSA... |
234,695 | <p>Is there a way to have a default parameter passed to a action in the case where the regex didnt match anything using django?</p>
<pre><code>
urlpatterns = patterns('',(r'^test/(?P<name>.*)?$','myview.displayName'))
#myview.py
def displayName(request,name):
# write name to response or something
</code><... | [
{
"answer_id": 234741,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 0,
"selected": false,
"text": "<p>I <em>thought</em> you could <code>def displayName(request, name=defaultObj)</code>; that's what I've done in the past, ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24730/"
] | Is there a way to have a default parameter passed to a action in the case where the regex didnt match anything using django?
```
urlpatterns = patterns('',(r'^test/(?P<name>.*)?$','myview.displayName'))
#myview.py
def displayName(request,name):
# write name to response or something
```
I have tried setting t... | The problem is that when the pattern is matched against 'test/' the groupdict captured by the regex contains the mapping 'name' => None:
```
>>> url.match("test/").groupdict()
{'name': None}
```
This means that when the view is invoked, using something I expect that is similar to below:
```
view(request, *groups, *... |
234,723 | <p>I would like to redirect <code>www.example.com</code> to <code>example.com</code>. The following htaccess code makes this happen:</p>
<pre><code>RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
</code></pre>
<p>But, is there a way to do this in a generic fashion w... | [
{
"answer_id": 234745,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>RewriteCond %{HTTP_HOST} ^www\\. [NC]\nRewriteRule ^(.*)$ %{HTTP_HOST}$1 [C]\nRewriteRule ^www... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21473/"
] | I would like to redirect `www.example.com` to `example.com`. The following htaccess code makes this happen:
```
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
```
But, is there a way to do this in a generic fashion without hardcoding the domain name? | ```
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
```
Same as [Michael's](https://stackoverflow.com/a/235064/662581) except this one works :P |
234,742 | <p>In <code>tcsh</code>, I have the following script working:</p>
<pre><code>#!/bin/tcsh
setenv X_ROOT /some/specified/path
setenv XDB ${X_ROOT}/db
setenv PATH ${X_ROOT}/bin:${PATH}
xrun -d xdb1 -i $1 > $2
</code></pre>
<p>What is the equivalent to the <code>tcsh setenv</code> function in Bash? </p>
<p>Is ... | [
{
"answer_id": 234753,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 3,
"selected": false,
"text": "<p>I think you're looking for <code>export</code> - though I could be wrong.. I've never played with tcsh before. Use the foll... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1266/"
] | In `tcsh`, I have the following script working:
```
#!/bin/tcsh
setenv X_ROOT /some/specified/path
setenv XDB ${X_ROOT}/db
setenv PATH ${X_ROOT}/bin:${PATH}
xrun -d xdb1 -i $1 > $2
```
What is the equivalent to the `tcsh setenv` function in Bash?
Is there a direct analog? The environment variables are for l... | `export VAR=value` will set VAR to value. Enclose it in single quotes if you want spaces, like `export VAR='my val'`. If you want the variable to be interpolated, use double quotes, like `export VAR="$MY_OTHER_VAR"`. |
234,776 | <p>I was reading some 3rd party code and I found this:</p>
<pre><code>x.Flags = x.Flags ^ Flags.Hidden;
</code></pre>
<p>What does it do?</p>
<p>I've used '&' and '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol...</p>
| [
{
"answer_id": 234788,
"author": "Romain Verdier",
"author_id": 4687,
"author_profile": "https://Stackoverflow.com/users/4687",
"pm_score": 6,
"selected": true,
"text": "<p>^ is the bitwise XOR operator in C#. </p>\n\n<p>EDIT: a ^ b returns true if a is true and b is false or if a is fal... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] | I was reading some 3rd party code and I found this:
```
x.Flags = x.Flags ^ Flags.Hidden;
```
What does it do?
I've used '&' and '|' for bitwise 'and' and 'or' with enums, but it's the first time I see the that symbol... | ^ is the bitwise XOR operator in C#.
EDIT: a ^ b returns true if a is true and b is false or if a is false and b is true, but not both. |
234,785 | <p>The situation is as follows: I've got 2 models: 'Action' and 'User'. These models refer to the tables 'actions' and 'users', respectively.</p>
<p>My action table contains a column <code>user_id</code>. At this moment, I need an overview of all actions, and the users to which they are assigned to. When i use <code>$... | [
{
"answer_id": 235267,
"author": "Peter Bailey",
"author_id": 8815,
"author_profile": "https://Stackoverflow.com/users/8815",
"pm_score": 2,
"selected": false,
"text": "<p>You could always make a view in your database that does the join for you.</p>\n\n<pre><code>CREATE OR REPLACE VIEW V... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11568/"
] | The situation is as follows: I've got 2 models: 'Action' and 'User'. These models refer to the tables 'actions' and 'users', respectively.
My action table contains a column `user_id`. At this moment, I need an overview of all actions, and the users to which they are assigned to. When i use `$action->fetchAll()`, I onl... | I designed and implemented the table-relationships feature in Zend Framework.
My first comment is that you wouldn't use `findDependentRowset()` anyway -- you'd use `findParentRow()` if the Action has a foreign key reference to User.
```
$actionTable = new Action();
$actionRowset = $actionTable->fetchAll();
foreach ($... |
234,797 | <p>I need to use sed to convert all occurences of <code>##XXX##</code> to <code>${XXX}</code>. X could be any alphabetic character or '_'. I know that I need to use something like:</p>
<pre><code>'s/##/\${/g'
</code></pre>
<p>But of course that won't work properly, as it will convert <code>##FOO##</code> to <code>${FOO... | [
{
"answer_id": 234806,
"author": "ADEpt",
"author_id": 10105,
"author_profile": "https://Stackoverflow.com/users/10105",
"pm_score": 1,
"selected": false,
"text": "<p>Use this:</p>\n\n<pre><code>s/##\\([^#]*\\)##/${\\1}/\n</code></pre>\n\n<p>BTW, there is no need to escape $ in the right... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I need to use sed to convert all occurences of `##XXX##` to `${XXX}`. X could be any alphabetic character or '\_'. I know that I need to use something like:
```
's/##/\${/g'
```
But of course that won't work properly, as it will convert `##FOO##` to `${FOO${` | Here's a shot at a better replacement regex:
```
's/##\([a-zA-Z_]\+\)##/${\1}/g'
```
Or if you assume exactly three characters :
```
's/##\([a-zA-Z_]\{3\}\)##/${\1}/g'
``` |
234,845 | <p>I am looking for a way to change the password of a local user account (local Administrator) on a Windows (XP in this case) machine. I have read the <a href="http://www.codeproject.com/KB/threads/Reset-Administrator-Pass.aspx" rel="noreferrer">CodeProject article</a> about one way to do this, but this just doesn't se... | [
{
"answer_id": 235085,
"author": "Ely",
"author_id": 30488,
"author_profile": "https://Stackoverflow.com/users/30488",
"pm_score": 3,
"selected": true,
"text": "<p>Try the <code>DirectoryEntry</code> class instead of <code>ManagementObject</code> class.</p>\n"
},
{
"answer_id": 2... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12367/"
] | I am looking for a way to change the password of a local user account (local Administrator) on a Windows (XP in this case) machine. I have read the [CodeProject article](http://www.codeproject.com/KB/threads/Reset-Administrator-Pass.aspx) about one way to do this, but this just doesn't seem 'clean'.
I can see that th... | Try the `DirectoryEntry` class instead of `ManagementObject` class. |
234,848 | <p>I found in MYSQL and apparently other database engines that there is a "greatest" function that can be used like: greatest(1, 2, 3, 4), and it would return 4. I need this, but I am using IBM's DB2. Does anybody know of such an equivalent function, even if it only accepts 2 parameters?</p>
<p>I found somewhere tha... | [
{
"answer_id": 234875,
"author": "Mike Wills",
"author_id": 2535,
"author_profile": "https://Stackoverflow.com/users/2535",
"pm_score": 1,
"selected": false,
"text": "<p>Two options:</p>\n\n<ol>\n<li><p>What about sorting the column in descending and grabbing the top 1 row?</p></li>\n<li... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | I found in MYSQL and apparently other database engines that there is a "greatest" function that can be used like: greatest(1, 2, 3, 4), and it would return 4. I need this, but I am using IBM's DB2. Does anybody know of such an equivalent function, even if it only accepts 2 parameters?
I found somewhere that MAX should... | Why does MAX not work for you?
select max(1,2,8,3,1,7) from sysibm.sysdummy1
gives me
```
1
---------------
8
1 record(s) selected.
``` |
234,849 | <p>I am using activemq to pass requests between different processes. In some cases, I have multiple, duplicate message (which are requests) in the queue. I would like to have only one. Is there a way to send a message in a way that it will replace an older message with similar attributes? If there isn't, is there a way... | [
{
"answer_id": 234884,
"author": "Dave",
"author_id": 3095,
"author_profile": "https://Stackoverflow.com/users/3095",
"pm_score": 1,
"selected": false,
"text": "<p>You could browse the queue and use selectors to identify the message. However, unless you have a small amount of messages t... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31289/"
] | I am using activemq to pass requests between different processes. In some cases, I have multiple, duplicate message (which are requests) in the queue. I would like to have only one. Is there a way to send a message in a way that it will replace an older message with similar attributes? If there isn't, is there a way to... | This sounds like an ideal use case for the [Idempotent Consumer](http://activemq.apache.org/camel/idempotent-consumer.html) which removes duplicates from a queue or topic.
The following example shows how to do this with [Apache Camel](http://activemq.apache.org/camel/) which is the easiest way to implement any of the... |
234,866 | <p>I come from a .NET world and I'm new to writting C++. I'm just wondering what are the preferred naming conventions when it comes to naming local variables and struct members.</p>
<p>For example, the legacy code that I've inheritted has alot of these:</p>
<pre><code>struct MyStruct
{
TCHAR szMyChar[STR... | [
{
"answer_id": 234877,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 1,
"selected": false,
"text": "<p>Hungarian notation was common among users of the Win32 and MFC APIs. If your predecessors were using that, you ca... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18170/"
] | I come from a .NET world and I'm new to writting C++. I'm just wondering what are the preferred naming conventions when it comes to naming local variables and struct members.
For example, the legacy code that I've inheritted has alot of these:
```
struct MyStruct
{
TCHAR szMyChar[STRING_SIZE];
bool ... | That kind of Hungarian Notation is fairly useless, and possibly worse than useless if you have to change the type of something. ([The *proper* kind of Hungarian Notation](http://www.joelonsoftware.com/articles/Wrong.html) is a different story.)
I suggest you use whatever your group does. If you're the only person work... |
234,930 | <p>Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application?</p>
<pre><code>-(void) doSomethingWithAnimation:(BOOL)animated
</code></pre>
<p>or:</p>
<pre><code>-(void) doSomething:(BOOL)animated
</code></pre>
<p>or even:</p>
<pre><code>-(void) doSomethingAnimated:(BOOL)... | [
{
"answer_id": 234954,
"author": "Noah Witherspoon",
"author_id": 30618,
"author_profile": "https://Stackoverflow.com/users/30618",
"pm_score": 2,
"selected": false,
"text": "<p>-(void)doSomethingAnimated:(BOOL)animated seems most consistent with Apple's naming style. For reference, chec... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17188/"
] | Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application?
```
-(void) doSomethingWithAnimation:(BOOL)animated
```
or:
```
-(void) doSomething:(BOOL)animated
```
or even:
```
-(void) doSomethingAnimated:(BOOL)animated
``` | I think the Cocoa convention would give your examples the following semmantics (ignoring the BOOL type for the argument, obviously):
```
-(void) doSomethingWithAnimation:(BOOL)animated
```
would actually expect an Animation as the parameter (i.e. something that represents the animation.
```
-(void) doSomething:(BOO... |
234,935 | <p>I'm having a problem dynamically adding columns to a GridView. I need to change the layout -- i.e. the included columns -- based on the value in a DropDownList. When the user changes the selection in this list, I need to remove all but the first column and dynamically add additional columns based on the selection.... | [
{
"answer_id": 235268,
"author": "Ken Pespisa",
"author_id": 30812,
"author_profile": "https://Stackoverflow.com/users/30812",
"pm_score": 0,
"selected": false,
"text": "<p>I found this little nugget in the documentation, under the DataControlFieldCollection Class. </p>\n\n<p><em>If you... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7961/"
] | I'm having a problem dynamically adding columns to a GridView. I need to change the layout -- i.e. the included columns -- based on the value in a DropDownList. When the user changes the selection in this list, I need to remove all but the first column and dynamically add additional columns based on the selection.
I h... | I recently conquered silmilar issues with dynamic columns in gridviews, perhaps this will help.
First turn the viewstate off
Second add the columns programatically in a function fired in the oninit event
Lastly I used the following helper class to cause the checkboxes to instantiate when the RowDataBound event ... |
234,945 | <p>I've inherited a WSDL file for a web service on a system that I don't have access to for development and testing.</p>
<p>I need to generate a web service that adheres to that WSDL. The wrapper is .NET, but if there's an easy way to do this with another platform, we might be able to look at that. The production web ... | [
{
"answer_id": 235005,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": false,
"text": "<p>You may find useful the <a href=\"http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx\" rel=\"noreferrer\">command... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7301/"
] | I've inherited a WSDL file for a web service on a system that I don't have access to for development and testing.
I need to generate a web service that adheres to that WSDL. The wrapper is .NET, but if there's an easy way to do this with another platform, we might be able to look at that. The production web service is... | We are using [WSCF - Web Services Contract First](http://www.thinktecture.com/resourcearchive/tools-and-software/wscf) tool from Thinktecture to do web service development creating XSD schema first and then generating service interfaces using this tool. It may be useful to generate service interfaces from WSDL but I ha... |
234,949 | <p>I'm new to CakePHP but I've been though their FAQs and guides to no avail. This is so simple that I just must not be thinking straight:</p>
<p>How can I access a parameter sent through the URL within my view files? </p>
<p>Example: <a href="http://example.com/view/6" rel="nofollow noreferrer">http://example.com/v... | [
{
"answer_id": 235017,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 3,
"selected": true,
"text": "<p>The URL, as you have it, will call the 6() method of your ViewController, which is not a valid method name. You may hav... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24565/"
] | I'm new to CakePHP but I've been though their FAQs and guides to no avail. This is so simple that I just must not be thinking straight:
How can I access a parameter sent through the URL within my view files?
Example: <http://example.com/view/6>
How would I take that parameter ("6") and cycle it through the controll... | The URL, as you have it, will call the 6() method of your ViewController, which is not a valid method name. You may have to play with your routes to make that work.
If you don't want to configure your routes, you'll need the controller in the URL, like so:
```
http://example.com/thinger/view/6
```
which will call `... |
234,973 | <p>What is the best way to check for the existence of a session variable in ASP.NET C#? </p>
<p>I like to use <code>String.IsNullOrEmpty()</code> works for strings and wondered if there was a similar method for <code>Session</code>. Currently the only way I know of is:</p>
<pre><code> var session;
if (Session["var... | [
{
"answer_id": 234991,
"author": "Ely",
"author_id": 30488,
"author_profile": "https://Stackoverflow.com/users/30488",
"pm_score": 4,
"selected": false,
"text": "<p>That is pretty much how you do it. However, there is a shorter syntax you can use.</p>\n\n<pre><code>sSession = (string)Se... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12252/"
] | What is the best way to check for the existence of a session variable in ASP.NET C#?
I like to use `String.IsNullOrEmpty()` works for strings and wondered if there was a similar method for `Session`. Currently the only way I know of is:
```
var session;
if (Session["variable"] != null)
{
session = Session["v... | To follow on from what others have said. I tend to have two layers:
**The core layer. This is within a DLL that is added to nearly all web app projects**. In this I have a SessionVars class which does the grunt work for Session state getters/setters. It contains code like the following:
```
public class SessionVar
{
... |
234,976 | <p>Scenario - I need to access an HTML template to generate a e-mail from my Business Logic Layer. It is a class library contains a sub folder that contains the file. When I tried the following code in a unit test:</p>
<pre><code>string FilePath = string.Format(@"{0}\templates\MyFile.htm", Environment.CurrentDirecto... | [
{
"answer_id": 234984,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 3,
"selected": false,
"text": "<p>You're running this from an ASP.Net app right? Use <code>Server.MapPath()</code> instead.</p>\n\n<p>Also take a look at <... | 2008/10/24 | [
"https://Stackoverflow.com/questions/234976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | Scenario - I need to access an HTML template to generate a e-mail from my Business Logic Layer. It is a class library contains a sub folder that contains the file. When I tried the following code in a unit test:
```
string FilePath = string.Format(@"{0}\templates\MyFile.htm", Environment.CurrentDirectory);
string File... | You're running this from an ASP.Net app right? Use `Server.MapPath()` instead.
Also take a look at `System.IO.Path.Combine()` for concatenating paths.
[Edit]
Since you can't use `System.Web`, try this:
```
System.Reflection.Assembly.GetExecutingAssembly().Location
```
Or `GetEntryAssembly()`. |
235,033 | <p>In Delphi, why does the Assigned() function still return True after I call the destructor?</p>
<p>The below example code will write "sl is still assigned" to the console.</p>
<p>However, I can call FreeAndNil(sl); and it won't be assigned.</p>
<p>I've been programming in Delphi for a while, but this never made se... | [
{
"answer_id": 235041,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 6,
"selected": true,
"text": "<p>If you use sl.Free, the object is freed but the variable sl still points to the now invalid memory.</p>\n\n<p>Use F... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | In Delphi, why does the Assigned() function still return True after I call the destructor?
The below example code will write "sl is still assigned" to the console.
However, I can call FreeAndNil(sl); and it won't be assigned.
I've been programming in Delphi for a while, but this never made sense to me.
Can someone ... | If you use sl.Free, the object is freed but the variable sl still points to the now invalid memory.
Use FreeAndNil(sl) to both free the object and clear the pointer.
By the way, if you do:
```
var
sl1, sl2: TStringList;
begin
sl1 := TStringList.Create;
sl2 := sl1;
FreeAndNil(sl1);
// sl2 is still assigned ... |
235,047 | <p>I am trying to insert about 50,000 objects (and therefore 50,000 keys) into a <code>java.util.HashMap<java.awt.Point, Segment></code>. However, I keep getting an OutOfMemory exception. (<code>Segment</code> is my own class - very light weight - one <code>String</code> field, and 3 <code>int</code> fields).</p>... | [
{
"answer_id": 235053,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 6,
"selected": true,
"text": "<p>You can increase the maximum heap size by passing -Xmx128m (where 128 is the number of megabytes) to java. I can't... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I am trying to insert about 50,000 objects (and therefore 50,000 keys) into a `java.util.HashMap<java.awt.Point, Segment>`. However, I keep getting an OutOfMemory exception. (`Segment` is my own class - very light weight - one `String` field, and 3 `int` fields).
```
Exception in thread "main" java.lang.OutOfMemoryErr... | You can increase the maximum heap size by passing -Xmx128m (where 128 is the number of megabytes) to java. I can't remember the default size, but it strikes me that it was something rather small.
You can programmatically check how much memory is available by using the [Runtime](http://java.sun.com/javase/6/docs/api/ja... |
235,072 | <p>Does the C++ compiler optimize the multiply by two operation <code>x*2</code> to a bitshift operation <code>x<<1</code>?</p>
<p>I would love to believe that yes.</p>
| [
{
"answer_id": 235077,
"author": "David Arno",
"author_id": 7122,
"author_profile": "https://Stackoverflow.com/users/7122",
"pm_score": 4,
"selected": false,
"text": "<p>Not if x is a float it won't.</p>\n"
},
{
"answer_id": 235082,
"author": "Andy Lester",
"author_id": 8... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24975/"
] | Does the C++ compiler optimize the multiply by two operation `x*2` to a bitshift operation `x<<1`?
I would love to believe that yes. | Actually VS2008 optimizes this to x+x:
```
01391000 push ecx
int x = 0;
scanf("%d", &x);
01391001 lea eax,[esp]
01391004 push eax
01391005 push offset string "%d" (13920F4h)
0139100A mov dword ptr [esp+8],0
01391012 call dword ptr [__imp__scanf (13920A4... |
235,081 | <p>We primarily use an ASP.NET environment at work. Right now I'm building an application which uses "Modules", which is just a UserControl, with its' Javascript right in the control, and a link element to the stylesheet for that control. I want to keep it modular, and would like the style of this control to be indepen... | [
{
"answer_id": 235099,
"author": "John Dunagan",
"author_id": 28939,
"author_profile": "https://Stackoverflow.com/users/28939",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on how big your app is, and whether or not it's dependent on Themes elsewhere, IMHO.</p>\n\n<p>If you'r... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31307/"
] | We primarily use an ASP.NET environment at work. Right now I'm building an application which uses "Modules", which is just a UserControl, with its' Javascript right in the control, and a link element to the stylesheet for that control. I want to keep it modular, and would like the style of this control to be independen... | It sounds like you're rolling your own theme engine... why not use ASP.NET Themes?
If you're determined to do it yourself, here's some code from the [CssFriendly project](http://www.codeplex.com/cssfriendly) that may be of interest to you. (I think it should be ok to post the code as long as I cite where it's from.) T... |
235,090 | <p>How do you configure cruiseControl to send out emails that contains the error log whenever a build fails? I've gotten it to send out emails to users when the build fails, but it does not include the actual error that caused the build to fail. I know that if I only configure it to send out emails to the users that ... | [
{
"answer_id": 235124,
"author": "Alex",
"author_id": 26564,
"author_profile": "https://Stackoverflow.com/users/26564",
"pm_score": 1,
"selected": false,
"text": "<p>Your email publisher will take the buildlog.xml and transorm it against whatever XSL's are configured either in your conso... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you configure cruiseControl to send out emails that contains the error log whenever a build fails? I've gotten it to send out emails to users when the build fails, but it does not include the actual error that caused the build to fail. I know that if I only configure it to send out emails to the users that have ... | You can check if \cruisecontrol.net\server\xsl\compile.xsl is the same as \cruisecontrol.net\webdashboard\xsl\compile.xsl.
Compile.xsl is the default file used to print the error messages from your error log. The one in \webdashboard\ is used for the web dashboard (as the name implies) and the one under \server\ is us... |
235,118 | <p>I am trying to create a route with a Username...</p>
<p>So the URL would be mydomain.com/abrudtkhul (abrudtkhul being the username)</p>
<p>My application will have public profiles based on usernames (Ex: <a href="http://delicious.com/abrudtkuhl" rel="noreferrer">http://delicious.com/abrudtkuhl</a>). I want to repl... | [
{
"answer_id": 235128,
"author": "Jason Whitehorn",
"author_id": 27860,
"author_profile": "https://Stackoverflow.com/users/27860",
"pm_score": 1,
"selected": false,
"text": "<p>You could have a route that looks like:</p>\n\n<pre><code>{username}\n</code></pre>\n\n<p>with the defaults of<... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442/"
] | I am trying to create a route with a Username...
So the URL would be mydomain.com/abrudtkhul (abrudtkhul being the username)
My application will have public profiles based on usernames (Ex: <http://delicious.com/abrudtkuhl>). I want to replicate this URL scheme.
How can I structure this in ASP.Net MVC? I am using Me... | Here's what you want to do, first define your route map:
```
routes.MapRoute(
"Users",
"{username}",
new { controller = "User", action="index", username=""});
```
What this allows you to do is to setup the following convention:
* Controller: User (the UserController type)
*... |
235,146 | <p>I need to replace the standard Overflow function in a ToolStrip to a "More..." button which would then pop up a menu with the overflowed items. Does anyone have any ideas about how to accomplish this?</p>
| [
{
"answer_id": 235277,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 0,
"selected": false,
"text": "<p>You can trap the paint event on the button by calling</p>\n\n<pre><code>toolStrip1.OverflowButton.Paint += new PaintEventHan... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4770/"
] | I need to replace the standard Overflow function in a ToolStrip to a "More..." button which would then pop up a menu with the overflowed items. Does anyone have any ideas about how to accomplish this? | I wrote something very similar to this awhile ago. The code I used is pasted below, and you are free to modify it to suit your needs.
The ToolStripCustomiseMenuItem is basically your "More" button that populates a DropDown Context Menu when clicked. Hope this helps you, at the very least this should be a good startin... |
235,148 | <p>I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around <a href="http://book.realworldhaskell.org/read/functional-programming.html#x_E9" rel="noreferrer">implementing foldl in terms of foldr</a>.</p>
<p>(Here's their code:)</p>
<pre><code>myFoldl :: (a -> b -> a) -> a ->... | [
{
"answer_id": 235207,
"author": "mattiast",
"author_id": 8272,
"author_profile": "https://Stackoverflow.com/users/8272",
"pm_score": 3,
"selected": false,
"text": "<p>I found a way using quite similar method to yours:</p>\n\n<pre><code>myzip = foldr step (const []) :: [a] -> [b] ->... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581/"
] | I'm currently on chapter 4 of Real World Haskell, and I'm trying to wrap my head around [implementing foldl in terms of foldr](http://book.realworldhaskell.org/read/functional-programming.html#x_E9).
(Here's their code:)
```
myFoldl :: (a -> b -> a) -> a -> [b] -> a
myFoldl f z xs = foldr step id xs z
where step... | ```
zip2 xs ys = foldr step done xs ys
where done ys = []
step x zipsfn [] = []
step x zipsfn (y:ys) = (x, y) : (zipsfn ys)
```
How this works: (foldr step done xs) returns a function that consumes
ys; so we go down the xs list building up a nested composition of
functions that will each be appl... |
235,156 | <p>I'd like to know if it is possible to redirect StreamWriter output to a variable</p>
<p>Something like</p>
<pre><code>String^ myString;
StreamWriter sw = gcnew StreamWriter([somehow specify myString])
sw->WriteLine("Foo");
</code></pre>
<p>then myString will contain Foo.
The reason I would like to do this is t... | [
{
"answer_id": 235183,
"author": "Matt Ellis",
"author_id": 29306,
"author_profile": "https://Stackoverflow.com/users/29306",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx\" rel=\"noreferrer\">StreamWriter</a> a... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | I'd like to know if it is possible to redirect StreamWriter output to a variable
Something like
```
String^ myString;
StreamWriter sw = gcnew StreamWriter([somehow specify myString])
sw->WriteLine("Foo");
```
then myString will contain Foo.
The reason I would like to do this is to reuse a complex function. I should... | [StreamWriter](http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx) and [StringWriter](http://msdn.microsoft.com/en-us/library/system.io.stringwriter.aspx) both extend TextWriter, perhaps you could refactor your method that uses StreamWriter to use TextWriter instead so it could write to either a stream... |
235,166 | <p>I'm trying to add parameters to an objectDataSource at runtime like this:</p>
<pre><code> Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID);
Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase);
//set up object data sou... | [
{
"answer_id": 235217,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 2,
"selected": false,
"text": "<p>Add as early as possible; at the <code>PreInit</code> event. This is part of initialization so should be done there.</p>\... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1874/"
] | I'm trying to add parameters to an objectDataSource at runtime like this:
```
Parameter objCustomerParameter = new Parameter("CustomerID", DbType.String, customerID);
Parameter objGPDatabaseParameter = new Parameter("Database", DbType.String, gpDatabase);
//set up object data source parameters... | Add them to the event for the operation you are trying to use. For example, if these parameters are part of the SELECT command then add them to the Selecting event, if they need to go with the UPDATE command then add them on the Updating event.
The ObjectDataSource raises an event before it performs each operation, th... |
235,191 | <p>What is the best way to make trailing slashes not matter in the latest version of Routes (1.10)? I currently am using the clearly non-DRY:</p>
<pre><code>map.connect('/logs/', controller='logs', action='logs')
map.connect('/logs', controller='logs', action='logs')
</code></pre>
<p>I think that turning minimization... | [
{
"answer_id": 235238,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 4,
"selected": true,
"text": "<p>There are two possible ways to solve this:</p>\n\n<ol>\n<li><a href=\"http://wiki.pylonshq.com/display/pylonscookbook/Addin... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12981/"
] | What is the best way to make trailing slashes not matter in the latest version of Routes (1.10)? I currently am using the clearly non-DRY:
```
map.connect('/logs/', controller='logs', action='logs')
map.connect('/logs', controller='logs', action='logs')
```
I think that turning minimization on would do the trick, bu... | There are two possible ways to solve this:
1. [Do it entirely in pylons](http://wiki.pylonshq.com/display/pylonscookbook/Adding+trailing+slash+to+pages+automatically).
2. [Add an htaccess rule to rewrite the trailing slash](http://enarion.net/web/apache/htaccess/trailing-slash/).
Personally I don't like the trailing ... |
235,233 | <p>Derik Whitaker posted an <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/10/22/how-is-interacting-with-your-data-repository-in-your-controller-different-or-better-than-doing-it-in-your-code-behind.aspx" rel="noreferrer">article</a> a couple of days ago that hit a point that I've been curious about for... | [
{
"answer_id": 235243,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 7,
"selected": true,
"text": "<p>Business logic should really be in the model. You should be aiming for fat models, skinny controllers.</p>\n\n<p>For examp... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | Derik Whitaker posted an [article](http://devlicio.us/blogs/derik_whittaker/archive/2008/10/22/how-is-interacting-with-your-data-repository-in-your-controller-different-or-better-than-doing-it-in-your-code-behind.aspx) a couple of days ago that hit a point that I've been curious about for some time: **should business l... | Business logic should really be in the model. You should be aiming for fat models, skinny controllers.
For example, instead of having:
```
public interface IOrderService{
int CalculateTotal(Order order);
}
```
I would rather have:
```
public class Order{
int CalculateTotal(ITaxService service){...} ... |
235,240 | <p>Recently, <a href="https://stackoverflow.com/questions/204814/is-there-any-valid-reason-to-ever-ignore-a-caught-exception">I made a post about the developers I'm working with not using try catch blocks properly</a>, and unfortuantely using try... catch blocks in critical situations and ignoring the exception error a... | [
{
"answer_id": 235301,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": true,
"text": "<p>Have you considered using an ORM like NHibernate? There's no point in re-inventing the wheel.</p>\n\n<p>To me this is a co... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] | Recently, [I made a post about the developers I'm working with not using try catch blocks properly](https://stackoverflow.com/questions/204814/is-there-any-valid-reason-to-ever-ignore-a-caught-exception), and unfortuantely using try... catch blocks in critical situations and ignoring the exception error all together. c... | Have you considered using an ORM like NHibernate? There's no point in re-inventing the wheel.
To me this is a code smell:
```
BLLCustomer cust = ((BLLCustomer)new BLLCustomer()).FillByID(34);
```
Too many brackets!
I've found that using the active record pattern in a language like C# always ends in tears because i... |
235,248 | <p>In Silverlight how can I launch / navigate to another page?</p>
| [
{
"answer_id": 235253,
"author": "Eric",
"author_id": 4540,
"author_profile": "https://Stackoverflow.com/users/4540",
"pm_score": 4,
"selected": true,
"text": "<pre><code>System.Windows.Browser.HtmlPage.Window.Navigate(\n new Uri( \"http://www.google.com\" ),\n \"_blank\"\n );\n</c... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] | In Silverlight how can I launch / navigate to another page? | ```
System.Windows.Browser.HtmlPage.Window.Navigate(
new Uri( "http://www.google.com" ),
"_blank"
);
```
You can leave out the target ("\_blank") if you just want to navigate within your current browser window. |
235,254 | <p>I am running GNU Emacs on Windows so entering:</p>
<pre><code>M-x shell
</code></pre>
<p>launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done?</p>
| [
{
"answer_id": 235344,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 3,
"selected": false,
"text": "<p>I use XEmacs with Cygwin, and can run bash from XEmacs relatively easily.</p>\n\n<p>Here's the relevant section from <... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | I am running GNU Emacs on Windows so entering:
```
M-x shell
```
launches the Windows command-line DOS shell. However, I would like to instead be able to run the Cygwin Bash Shell (or any other non-Windows shell) from within Emacs. How can this be easily done? | `shell-file-name` is the variable that controls which shell Emacs uses when it wants to run a shell command.
`explicit-shell-file-name` is the variable that controls which shell `M-x shell` starts up.
[Ken's answer](https://stackoverflow.com/questions/235254/how-can-i-run-cygwin-bash-shell-from-within-emacs#235344) c... |
235,272 | <p>I'm probably doing this all wrong. I have a text file full of data and I want to match and replace patterns of "item" and "catalog number" that are in the file. But the order of each element in the file is very important, so I want to match/replace starting from the top of the file and then work my way down.</p>
<p... | [
{
"answer_id": 235300,
"author": "Alexandr Ciornii",
"author_id": 13467,
"author_profile": "https://Stackoverflow.com/users/13467",
"pm_score": 4,
"selected": false,
"text": "<p>.+ at start of your regex is \"greedy\". This means that it will match maximum chars.</p>\n\n<p>You regex is b... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27687/"
] | I'm probably doing this all wrong. I have a text file full of data and I want to match and replace patterns of "item" and "catalog number" that are in the file. But the order of each element in the file is very important, so I want to match/replace starting from the top of the file and then work my way down.
The code ... | The best solution appears to be to grab each ELEMENT ... END\_ELEMENT section from the data and regex only one section at a time rather than feeding the whole complete data set to a regular expression at once. Not exactly what I was trying to accomplish, but I rewrote my program to do this piecemeal processing and it w... |
235,295 | <p>Im trying to use to define a one-to-many relationship in a single table. For example lets say I have a Groups table with these entries:</p>
<pre>
Group:
Group_1:
name: Atlantic Records
Group_2:
name: Capital Records
Group_3:
name: Gnarls Barkley
Group_4:
name: Death Cab For Cutie
Group_5:
... | [
{
"answer_id": 235314,
"author": "BradC",
"author_id": 21398,
"author_profile": "https://Stackoverflow.com/users/21398",
"pm_score": 2,
"selected": false,
"text": "<p>A couple of options:</p>\n\n<p>Easiest: If each group can only have one parent, then you just need a \"ParentID\" field i... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31327/"
] | Im trying to use to define a one-to-many relationship in a single table. For example lets say I have a Groups table with these entries:
```
Group:
Group_1:
name: Atlantic Records
Group_2:
name: Capital Records
Group_3:
name: Gnarls Barkley
Group_4:
name: Death Cab For Cutie
Group_5:
name... | There are a number of possible issues with this approach, but with a minimal understanding of the requirements, here goes:
There appear to be really three 'entities' here: Artist/Band, Label/Recording Co. and Management Co.
Artists/Bands can have a Label/Recording CO
Artists/Bands can have a Management Co.
Label/Rec... |
235,360 | <p>Today I had a discussion with a colleague about nested functions in Javascript:</p>
<pre><code>function a() {
function b() {
alert('boo')
}
var c = 'Bound to local call object.'
d = 'Bound to global object.'
}
</code></pre>
<p>In this example, trials point out that b is not reachable outside the ... | [
{
"answer_id": 235377,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 2,
"selected": false,
"text": "<p>As I understand it, these are equivalent as far as scoping is concerned:</p>\n\n<pre><code>function a() { ... }\... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31330/"
] | Today I had a discussion with a colleague about nested functions in Javascript:
```
function a() {
function b() {
alert('boo')
}
var c = 'Bound to local call object.'
d = 'Bound to global object.'
}
```
In this example, trials point out that b is not reachable outside the body of a, much like c is.... | This is static scoping. Statements within a function are scoped within that function.
Javascript has a quirky behavior, however, which is that without the **var** keyword, you've implied a **global variable**. That's what you're seeing in your test. Your "d" variable is available because it is an implied global, despi... |
235,376 | <p>Is there any way to add a field to a class at runtime ( a field that didn't exist before ) ? Something like this snippet :</p>
<pre><code>Myobject *ob; // create an object
ob->addField("newField",44); // we add the field to the class and we assign an initial value to it
printf("%d",ob->newField); // now we ca... | [
{
"answer_id": 235404,
"author": "Mark Ransom",
"author_id": 5987,
"author_profile": "https://Stackoverflow.com/users/5987",
"pm_score": 2,
"selected": false,
"text": "<p>There's no way to do it in the way you've described, since the compiler needs to resolve the reference at compile tim... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11234/"
] | Is there any way to add a field to a class at runtime ( a field that didn't exist before ) ? Something like this snippet :
```
Myobject *ob; // create an object
ob->addField("newField",44); // we add the field to the class and we assign an initial value to it
printf("%d",ob->newField); // now we can access that field
... | Use a map and a variant.
------------------------
For example, using boost::variant. See <http://www.boost.org/doc/libs/1_36_0/doc/html/variant.html>
(But of course, you can create your own, to suit the types of your XML attributes.)
```
#include <map>
#include <boost/variant.hpp>
typedef boost::variant< int, std::... |
235,386 | <p>What's the best way to use NaNs in C++?</p>
<p>I found <code>std::numeric_limits<double>::quiet_NaN()</code> and <code>std::numeric_limits<double>::signaling_NaN()</code>. I'd like to use <code>signaling_NaN</code> to represent an uninitialized variable as follows:</p>
<pre><code>double diameter = std... | [
{
"answer_id": 235490,
"author": "Menkboy",
"author_id": 29539,
"author_profile": "https://Stackoverflow.com/users/29539",
"pm_score": 2,
"selected": false,
"text": "<p>You can write a signalling NaN into a variable without triggering an exception with something like this (nb: untested)<... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25507/"
] | What's the best way to use NaNs in C++?
I found `std::numeric_limits<double>::quiet_NaN()` and `std::numeric_limits<double>::signaling_NaN()`. I'd like to use `signaling_NaN` to represent an uninitialized variable as follows:
```
double diameter = std::numeric_limits<double>::signaling_NaN();
```
This, however, sig... | After looking into this some more, it looks like `signaling_NaN` is useless as provided. If floating point exceptions are enabled, then calling it counts as processing a signaling NaN, so it immediately raises an exception. If floating point exceptions are disabled, then processing a signaling NaN automatically demotes... |
235,391 | <p>I am trying to find out how to upload a file from a web user to a server using an ASP page. The displayed page has an Input tag of type "File" like this:</p>
<pre><code><input type="file" name="uploadfile">
</code></pre>
<p>And a submit button that passes the Form info to another .ASP page. This page must ... | [
{
"answer_id": 235395,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 2,
"selected": true,
"text": "<p>This <a href=\"http://www.webconcerns.co.uk/asp/uploadasp/default.asp\" rel=\"nofollow noreferrer\">script</a> will ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16964/"
] | I am trying to find out how to upload a file from a web user to a server using an ASP page. The displayed page has an Input tag of type "File" like this:
```
<input type="file" name="uploadfile">
```
And a submit button that passes the Form info to another .ASP page. This page must take the path it gets from the Inp... | This [script](http://www.webconcerns.co.uk/asp/uploadasp/default.asp) will help you.
Also, you may google for "[asp upload file](http://www.google.com/search?q=asp+upload+file)" - there are tons of results. |
235,409 | <p>I have trouble comparing 2 double in Excel VBA</p>
<p>suppose that I have the following code</p>
<pre><code>Dim a as double
Dim b as double
a = 0.15
b = 0.01
</code></pre>
<p>After a few manipulations on b, b is now equal to 0.6</p>
<p>however the imprecision related to the double data type gives me headache bec... | [
{
"answer_id": 235424,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 3,
"selected": false,
"text": "<p>It is never wise to compare doubles on equality.</p>\n\n<p>Some decimal values map to several floating point repre... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | I have trouble comparing 2 double in Excel VBA
suppose that I have the following code
```
Dim a as double
Dim b as double
a = 0.15
b = 0.01
```
After a few manipulations on b, b is now equal to 0.6
however the imprecision related to the double data type gives me headache because
```
if a = b then
//this will nev... | You can't compare floating point values for equality. See this article on "[Comparing floating point numbers](http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/)" for a discussion of how to handle the intrinsic error.
It isn't as simple as comparing to a constant error margin un... |
235,411 | <p>Finding out what's selected in real browsers is as simple as:</p>
<pre><code>var range = {
start: textbox.selectionStart,
end: textbox.selectionEnd
}
</code></pre>
<p>But IE, as usual, doesn't understand. What's the best cross-browser way to do this?</p>
| [
{
"answer_id": 235419,
"author": "TALlama",
"author_id": 5657,
"author_profile": "https://Stackoverflow.com/users/5657",
"pm_score": 3,
"selected": false,
"text": "<p>My current solution is verbose and based on <a href=\"http://www.webdeveloper.com/forum/showthread.php?t=111407\" rel=\"n... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5657/"
] | Finding out what's selected in real browsers is as simple as:
```
var range = {
start: textbox.selectionStart,
end: textbox.selectionEnd
}
```
But IE, as usual, doesn't understand. What's the best cross-browser way to do this? | I'll post this function for another time, seeing as this question got linked to from another one.
The following will do the job in all browsers and deals with all new line problems without seriously compromising performance. I've arrived at this after [some toing and froing](https://stackoverflow.com/questions/3622818... |
235,418 | <p>I have (simplified for the example) a table with the following data</p>
<pre><code>Row Start Finish ID Amount
--- --------- ---------- -- ------
1 2008-10-01 2008-10-02 01 10
2 2008-10-02 2008-10-03 02 20
3 2008-10-03 2008-10-04 01 38
4 2008-10-04 2008-10-05 01 ... | [
{
"answer_id": 235429,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>Probably need to create a cursor and loop through the results, keeping track of which id you are working with and ac... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31326/"
] | I have (simplified for the example) a table with the following data
```
Row Start Finish ID Amount
--- --------- ---------- -- ------
1 2008-10-01 2008-10-02 01 10
2 2008-10-02 2008-10-03 02 20
3 2008-10-03 2008-10-04 01 38
4 2008-10-04 2008-10-05 01 23
5 200... | If you read the book "Developing Time-Oriented Database Applications in SQL" by [R T Snodgrass](http://www.cs.arizona.edu/~rts/) (the pdf of which is available from his web site under publications), and get as far as Figure 6.25 on p165-166, you will find the non-trivial SQL which can be used in the current example to ... |
235,435 | <p>Python's access to environment variables does not accurately reflect the operating system's view of the processes environment.</p>
<p>os.getenv and os.environ do not function as expected in particular cases.</p>
<p>Is there a way to properly get the running process' environment?</p>
<hr>
<p>To demonstrate what I... | [
{
"answer_id": 235448,
"author": "Thomas Vander Stichele",
"author_id": 2900,
"author_profile": "https://Stackoverflow.com/users/2900",
"pm_score": 1,
"selected": false,
"text": "<p>Looking at the Python source code (2.4.5):</p>\n\n<ul>\n<li><p>Modules/posixmodule.c gets the environ in c... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9241/"
] | Python's access to environment variables does not accurately reflect the operating system's view of the processes environment.
os.getenv and os.environ do not function as expected in particular cases.
Is there a way to properly get the running process' environment?
---
To demonstrate what I mean, take the two rough... | That's a very good question.
It turns out that the `os` module initializes `os.environ` to the value of [`posix`](http://docs.python.org/library/posix.html)`.environ`, which is set on interpreter start up. In other words, the standard library does not appear to provide access to the [getenv](http://www.opengroup.org/o... |
235,437 | <p>Given the following file:</p>
<pre><code>department=value1
location=valueA
location=valueB
department=value2
</code></pre>
<p>I use the following to load the file into a Perl hash:</p>
<pre><code>use File::Slurp;
use Data::Dumper;
my %hash = map {
s/#.*//;
s/^\s+//;
s/\s+$//;
m/(.*?)\s*=\s*(.*)/;
} re... | [
{
"answer_id": 235489,
"author": "Nikhil",
"author_id": 5734,
"author_profile": "https://Stackoverflow.com/users/5734",
"pm_score": 6,
"selected": true,
"text": "<p>Here you go:</p>\n\n<pre><code>my %hash;\nwhile (<FILE>)\n{\n chomp;\n my ($key, $val) = split /=/;\n $hash{$ke... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Given the following file:
```
department=value1
location=valueA
location=valueB
department=value2
```
I use the following to load the file into a Perl hash:
```
use File::Slurp;
use Data::Dumper;
my %hash = map {
s/#.*//;
s/^\s+//;
s/\s+$//;
m/(.*?)\s*=\s*(.*)/;
} read_file($file);
print Dumper(\%hash);... | Here you go:
```
my %hash;
while (<FILE>)
{
chomp;
my ($key, $val) = split /=/;
$hash{$key} .= exists $hash{$key} ? ",$val" : $val;
}
```
This walks through every line splitting on the '=' sign and either adds an entry or appends to an existing entry in the hash table. |
235,439 | <p>The way I do 80-column indication in Vim seems incorrect:<code>set columns=80</code>.
At times I also <code>set textwidth</code>, but I want to be able to see and anticipate line overflow with the <code>set columns</code> alternative.</p>
<p>This has some <strong>unfortunate</strong> side effects:</p>
<ol>
<li>I ... | [
{
"answer_id": 235501,
"author": "Lucas Oman",
"author_id": 6726,
"author_profile": "https://Stackoverflow.com/users/6726",
"pm_score": 3,
"selected": false,
"text": "<p>I'm afraid that you've put constraints on the set of solutions that, well, leave you with the null set.</p>\n\n<p>Usin... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | The way I do 80-column indication in Vim seems incorrect:`set columns=80`.
At times I also `set textwidth`, but I want to be able to see and anticipate line overflow with the `set columns` alternative.
This has some **unfortunate** side effects:
1. I can't `set number` for fear of splitting between files that have d... | I have this set up in my .vimrc:
```
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
```
This highlights the background in a subtle red for text that goes over the 80 column limit (subtle in GUI mode, anyway - in terminal mode it's less so). |
235,446 | <p>Anybody have a slicker way to do this? Seems like it should be easier than this, but I'm having a mental block. Basically I need to remove items from an dictionary and recurse into the values of the items that are also dictionaries.</p>
<pre><code>private void RemoveNotPermittedItems(ActionDictionary menu)
{
... | [
{
"answer_id": 235469,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>To start with, your <code>foreach</code> loop is way more complicated than it needs to be. Just do:</p>\n\n<pre><code... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29493/"
] | Anybody have a slicker way to do this? Seems like it should be easier than this, but I'm having a mental block. Basically I need to remove items from an dictionary and recurse into the values of the items that are also dictionaries.
```
private void RemoveNotPermittedItems(ActionDictionary menu)
{
var keysToRemove... | You don't really need to collect the keys and iterate them again if you iterate the dictionary in reverse (from 'menu.Count - 1' to zero). Iterating in forward order will, of course, yield mutated collection exceptions if you start removing things.
I don't know what an ActionDictionary is, so I couldn't test your exac... |
235,455 | <pre><code>string [] files = new string[2];
files[0] = "ThinkFarAhead.Example.Settings.Configuration_Local.xml";
files[1] = "ThinkFarAhead.Example.Settings.Configuration_Global.xml";
//Resharper complains this is an "access to modified closure"
for (int i = 0; i < files.Length; i++ )
{
// Resharper disable Acce... | [
{
"answer_id": 235459,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 9,
"selected": true,
"text": "<p>In this case, it's okay, since you are actually executing the delegate <em>within</em> the loop.</p>\n\n<p>If you were... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] | ```
string [] files = new string[2];
files[0] = "ThinkFarAhead.Example.Settings.Configuration_Local.xml";
files[1] = "ThinkFarAhead.Example.Settings.Configuration_Global.xml";
//Resharper complains this is an "access to modified closure"
for (int i = 0; i < files.Length; i++ )
{
// Resharper disable AccessToModifi... | In this case, it's okay, since you are actually executing the delegate *within* the loop.
If you were saving the delegate and using it later, however, you'd find that all of the delegates would throw exceptions when trying to access files[i] - they're capturing the *variable* `i` rather than its value at the time of t... |
235,515 | <p>Way back when I was working in an Oracle shop I took the CONNECT_BY for granted. Now I'm stuck working with SQL Server 2005 and have some nasty object hierarchies. Specifically, we have a self referencing table where all child records have a column with their parent's id. Currently we have a view that maps childr... | [
{
"answer_id": 235531,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 1,
"selected": false,
"text": "<p>in SQL Server 2005 you can use Common Table Expressions (CTE) for this.</p>\n"
},
{
"answer_id": 235534,... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31336/"
] | Way back when I was working in an Oracle shop I took the CONNECT\_BY for granted. Now I'm stuck working with SQL Server 2005 and have some nasty object hierarchies. Specifically, we have a self referencing table where all child records have a column with their parent's id. Currently we have a view that maps children to... | This creates your typical hierarchical table and uses a CTE to select the hierarchy structure and create a path for each item.
```
CREATE TABLE tblHierarchy (ID int, ParentID int NULL, Name varchar(128));
INSERT INTO tblHierarchy VALUES (1, NULL, '1');
INSERT INTO tblHierarchy VALUES (2, NULL, '2');
INSERT INTO tblHi... |
235,556 | <p>Using jQuery, how would you <code>show()</code> every <code>div.foo</code> on a page in a random order, with a new one appearing every X milliseconds?</p>
<p><strong>Clarification</strong>: I want to start with all these elements hidden and end with all of them showing, so it wouldn't make sense to <code>show()</co... | [
{
"answer_id": 235705,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 1,
"selected": false,
"text": "<p>I don't use jQuery myself, but what about this:</p>\n\n<pre><code>var intervalMilliseconds = X; // set to your valu... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4376/"
] | Using jQuery, how would you `show()` every `div.foo` on a page in a random order, with a new one appearing every X milliseconds?
**Clarification**: I want to start with all these elements hidden and end with all of them showing, so it wouldn't make sense to `show()` the same element twice.
I originally thought I'd ma... | An interesting way to do this would be the extend Javascript's Array base object with a shuffle function. In Prototype (should be the same in JQuery, except jQuery.extend). This is quick and dirty shuffle, there are plenty of other ways to do it.
```
Object.extend(Array.prototype, {
shuffle : function() {
this.s... |
235,564 | <p>I am using a mock object in RhinoMocks to represent a class that makes calls to MessageQueue.GetPublicQueues. I want to simulate the exception thrown when message queueing is operating in workgroup mode, which is a MessageQueueException, to ensure that I am catching the exception correctly</p>
<p>The MessageQueueEx... | [
{
"answer_id": 235703,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 4,
"selected": true,
"text": "<p>Reflection can break the accessibility rulez. You <em>will</em> void the warranty, a .NET update can easily break ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21862/"
] | I am using a mock object in RhinoMocks to represent a class that makes calls to MessageQueue.GetPublicQueues. I want to simulate the exception thrown when message queueing is operating in workgroup mode, which is a MessageQueueException, to ensure that I am catching the exception correctly
The MessageQueueException ha... | Reflection can break the accessibility rulez. You *will* void the warranty, a .NET update can easily break your code. Try this:
```
using System.Reflection;
using System.Messaging;
...
Type t = typeof(MessageQueueException);
ConstructorInfo ci = t.GetConstructor(BindingFlags.NonPublic | BindingFlags.In... |
235,608 | <p>I have the following situation:</p>
<p>A user will define a certain filter on a page, and on postback I will query the database using that filter and return a bunch of matching records to the user, each with a checkbox next to it, so he can choose whether to act on each of those records.</p>
<p>In Classic ASP / PH... | [
{
"answer_id": 235624,
"author": "Ramesh",
"author_id": 30594,
"author_profile": "https://Stackoverflow.com/users/30594",
"pm_score": 0,
"selected": false,
"text": "<p>Disable the ViewState. In case it cannot be done try using <a href=\"http://msdn.microsoft.com/en-us/library/system.web.... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3314/"
] | I have the following situation:
A user will define a certain filter on a page, and on postback I will query the database using that filter and return a bunch of matching records to the user, each with a checkbox next to it, so he can choose whether to act on each of those records.
In Classic ASP / PHP I can generate ... | Do it the same way you did it in classic ASP. Use <input type="checkbox"> instead of <asp:checkbox>. You can access the raw post paramaters using Request.Form |
235,616 | <p>Suppose a header file defines a function template. Now suppose two implementation files <code>#include</code> this header, and each of them has a call to the function template. In both implementation files the function template is instantiated with the same type.</p>
<pre><code>// header.hh
template <typename ... | [
{
"answer_id": 235623,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 4,
"selected": true,
"text": "<p>In order to support C++, the linker is smart enough to recognize that they are all the same function and throws out all ... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456/"
] | Suppose a header file defines a function template. Now suppose two implementation files `#include` this header, and each of them has a call to the function template. In both implementation files the function template is instantiated with the same type.
```
// header.hh
template <typename T>
void f(const T& o)
{
//... | In order to support C++, the linker is smart enough to recognize that they are all the same function and throws out all but one.
EDIT: clarification:
The linker doesn't compare function contents and determine that they are the same.
Templated functions are marked as such and the linker recognizes that they have the sa... |
235,618 | <p>I received an error when an referenced .NET Framework 2.0 assembly tried to execute the following line of code in an IIS hosted WCF service:</p>
<p>Error Message:</p>
<blockquote>
<p>exePath must be specified when not
running inside a stand alone exe.</p>
</blockquote>
<p>Source Code:</p>
<pre><code>Configur... | [
{
"answer_id": 235791,
"author": "tomasr",
"author_id": 10292,
"author_profile": "https://Stackoverflow.com/users/10292",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on what you're trying to accomplish. On ASP.NET, you'd normally wouldn't use ConfigurationManager for stuff l... | 2008/10/24 | [
"https://Stackoverflow.com/questions/235618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | I received an error when an referenced .NET Framework 2.0 assembly tried to execute the following line of code in an IIS hosted WCF service:
Error Message:
>
> exePath must be specified when not
> running inside a stand alone exe.
>
>
>
Source Code:
```
ConfigurationManager.OpenExeConfiguration(ConfigurationUs... | I was able to resolve the configuration issue by removing the existing code from my provious answer and replacing it with the following ConfigurationManager implementation:
```
string MySetting = ConfigurationManager.AppSettings.Get("MyAppSetting");
```
If works for ASP.NET applications, WinForms applications and WC... |
235,651 | <p>I have the following string expression in a PowerShell script:</p>
<pre><code>"select count(*) cnt from ${schema}.${table} where ${col.column_name} is null"
</code></pre>
<p>The schema and table resolve to the values of $schema and $table, respectively. However, an empty string is supplied for ${col.column_name}. ... | [
{
"answer_id": 235669,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": true,
"text": "<p>How about:</p>\n\n<pre><code>\"select count(*) cnt from $schema.$table where $($col.column_name) is null\"\n</code... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20625/"
] | I have the following string expression in a PowerShell script:
```
"select count(*) cnt from ${schema}.${table} where ${col.column_name} is null"
```
The schema and table resolve to the values of $schema and $table, respectively. However, an empty string is supplied for ${col.column\_name}. How can I dot into the me... | How about:
```
"select count(*) cnt from $schema.$table where $($col.column_name) is null"
``` |
235,664 | <p>After looking at another question on SO (<a href="https://stackoverflow.com/questions/235386/using-nan-in-c">Using NaN in C++</a>) I became curious about <code>std::numeric_limits<double>::signaling_NaN()</code>.</p>
<p>I could not get signaling_NaN to throw an exception. I thought perhaps by signaling it rea... | [
{
"answer_id": 235677,
"author": "Menkboy",
"author_id": 29539,
"author_profile": "https://Stackoverflow.com/users/29539",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"http://msdn.microsoft.com/en-us/library/hf16y784.aspx\" rel=\"nofollow noreferrer\">TFM</a>:</p>\n\n<pre... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29703/"
] | After looking at another question on SO ([Using NaN in C++](https://stackoverflow.com/questions/235386/using-nan-in-c)) I became curious about `std::numeric_limits<double>::signaling_NaN()`.
I could not get signaling\_NaN to throw an exception. I thought perhaps by signaling it really meant a signal so I tried catchin... | You can use the [`_control87()`](http://msdn.microsoft.com/en-us/library/e9b52ceh.aspx) function to enable floating-point exceptions. From the MSDN documentation on `_control87()`:
>
> Note:
>
>
> The run-time libraries mask all floating-point exceptions by default.
>
>
>
When floating point exceptions are en... |
235,671 | <p>I wanted to add a UTF-8 font in Gvim but I could not find out how to do this.
I tried to follow the step on this manual but it still did not work.
<a href="http://www.inter-locale.com/whitepaper/learn/learn_to_type.html" rel="noreferrer">http://www.inter-locale.com/whitepaper/learn/learn_to_type.html</a> (vim sectio... | [
{
"answer_id": 237002,
"author": "HS.",
"author_id": 1398,
"author_profile": "https://Stackoverflow.com/users/1398",
"pm_score": 3,
"selected": false,
"text": "<p>Quote from the <a href=\"http://vimdoc.sourceforge.net/htmldoc/usr_45.html#45.1\" rel=\"noreferrer\">vim documentation</a>:</... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18383/"
] | I wanted to add a UTF-8 font in Gvim but I could not find out how to do this.
I tried to follow the step on this manual but it still did not work.
<http://www.inter-locale.com/whitepaper/learn/learn_to_type.html> (vim section halfway the page)
Can anyone tell me how to add a font in Vim so I can have Japanese characte... | As others note, you must use a fixed-width font. Vim is a text editor, not a WYSIWYG editor.
If you have a fixed-width font with the characters you need then:
```
:set guifont=*
```
Select the font you want to use, the size, etc. Once you're happy with it, do:
```
:set guifont?
```
And it will output the current... |
235,694 | <p>In the filesystem I have</p>
<pre>
/file.aspx
/directory/default.aspx
</pre>
<p>I want to configure IIS so that it returns the appropriate file (add the aspx extension) or directory (default content page) as follows:</p>
<pre>
/file -> /file.aspx
/directory -> /directory/default.aspx
/directo... | [
{
"answer_id": 235697,
"author": "Mark S. Rasmussen",
"author_id": 12469,
"author_profile": "https://Stackoverflow.com/users/12469",
"pm_score": 0,
"selected": false,
"text": "<p>You'll have to add an ASP.NET global.asax or HttpModule that maps the / request to default.aspx.</p>\n"
},
... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6944/"
] | In the filesystem I have
```
/file.aspx
/directory/default.aspx
```
I want to configure IIS so that it returns the appropriate file (add the aspx extension) or directory (default content page) as follows:
```
/file -> /file.aspx
/directory -> /directory/default.aspx
/directory/ -> /directory/... | I looked at url rewriting, but ultimately decided on a simpler solution. I just moved the file.aspx into a directory and renamed it to default.aspx. |
235,695 | <p>I have a script that slides a div down from behind the menu, when people click on the tab. However its in jquery and I want to use mootools (lots of reasons I wont go into here). However im stuck with mootools 1.1 at present. But for some reason my attempt is not working :(</p>
<p>The html</p>
<pre><code>print("co... | [
{
"answer_id": 235697,
"author": "Mark S. Rasmussen",
"author_id": 12469,
"author_profile": "https://Stackoverflow.com/users/12469",
"pm_score": 0,
"selected": false,
"text": "<p>You'll have to add an ASP.NET global.asax or HttpModule that maps the / request to default.aspx.</p>\n"
},
... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28241/"
] | I have a script that slides a div down from behind the menu, when people click on the tab. However its in jquery and I want to use mootools (lots of reasons I wont go into here). However im stuck with mootools 1.1 at present. But for some reason my attempt is not working :(
The html
```
print("code sample");
<div ... | I looked at url rewriting, but ultimately decided on a simpler solution. I just moved the file.aspx into a directory and renamed it to default.aspx. |
235,759 | <p>I <em>think</em> I know how to create custom encrypted RSA keys, but how can I read one encrypted like ssh-keygen does?</p>
<p>I know I can do this:</p>
<pre><code>OpenSSL::PKey::RSA.new(File.read('private_key'))
</code></pre>
<p>But then OpenSSL asks me for the passphrase... How can I pass it to OpenSSL as a par... | [
{
"answer_id": 235847,
"author": "Ivan",
"author_id": 16957,
"author_profile": "https://Stackoverflow.com/users/16957",
"pm_score": -1,
"selected": true,
"text": "<p>I've made some progress on this. If I use the Net::SSH library, I can do this:</p>\n\n<pre><code>Net::SSH::KeyFactory.load... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16957/"
] | I *think* I know how to create custom encrypted RSA keys, but how can I read one encrypted like ssh-keygen does?
I know I can do this:
```
OpenSSL::PKey::RSA.new(File.read('private_key'))
```
But then OpenSSL asks me for the passphrase... How can I pass it to OpenSSL as a parameter?
And, how can I create one compa... | I've made some progress on this. If I use the Net::SSH library, I can do this:
```
Net::SSH::KeyFactory.load_private_key 'keyfile', 'passphrase'
```
By reading the source code I have yet to figure out what the library does to OpenSSL's PKey::RSA.new to accomplish this... And then I go and test again, and sure enough... |
235,822 | <p>How can my vbscript detect whether or not it is running in a UAC elevated context?</p>
<p>I have no problem detecting the user, and seeing if the user is within the Administrators group. But this still doesn't answer the question of whether the process has elevated privs or not, when running under Vista or Windows ... | [
{
"answer_id": 258070,
"author": "quux",
"author_id": 2383,
"author_profile": "https://Stackoverflow.com/users/2383",
"pm_score": 4,
"selected": true,
"text": "<p>The method I finally settled on depends on the fact that Vista and Windows 2008 have the whoami.exe utility, and it detects t... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2383/"
] | How can my vbscript detect whether or not it is running in a UAC elevated context?
I have no problem detecting the user, and seeing if the user is within the Administrators group. But this still doesn't answer the question of whether the process has elevated privs or not, when running under Vista or Windows 2008. Plea... | The method I finally settled on depends on the fact that Vista and Windows 2008 have the whoami.exe utility, and it detects the integrity level of the user who owns the process. A couple of screenshots help here:
[WHOAMI, normal and elevated, on Vista http://lh3.ggpht.com/\_Svunm47buj0/SQ6ql4iNjPI/AAAAAAAAAeA/iwbcSrAZ... |
235,855 | <p>I'm trying to get a background image of a HTML element (body, div, etc.) to stretch its entire width and height.</p>
<p>Not having much luck. Is it even possible or do I have to do it some other way besides it being a background image?</p>
<p>My current css is:</p>
<pre><code>body {
background-position: left ... | [
{
"answer_id": 235866,
"author": "Travis Collins",
"author_id": 30460,
"author_profile": "https://Stackoverflow.com/users/30460",
"pm_score": 3,
"selected": false,
"text": "<p>Not sure that stretching a background image is possible. If you find that it's not possible, or not reliable in... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8280/"
] | I'm trying to get a background image of a HTML element (body, div, etc.) to stretch its entire width and height.
Not having much luck. Is it even possible or do I have to do it some other way besides it being a background image?
My current css is:
```
body {
background-position: left top;
background-image: u... | ```
<style>
{ margin: 0; padding: 0; }
html {
background: url('images/yourimage.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
``` |
235,868 | <p>Given this algorithm, I would like to know if there exists an iterative version. Also, I want to know if the iterative version can be faster.</p>
<p>This some kind of pseudo-python...</p>
<p>the algorithm returns a reference to root of the tree</p>
<pre><code>make_tree(array a)
if len(a) == 0
return Non... | [
{
"answer_id": 235873,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>Making an iterative version is simply a matter of using your own stack instead of the normal language call stack. I doubt t... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18300/"
] | Given this algorithm, I would like to know if there exists an iterative version. Also, I want to know if the iterative version can be faster.
This some kind of pseudo-python...
the algorithm returns a reference to root of the tree
```
make_tree(array a)
if len(a) == 0
return None;
node = pick a random p... | A recursive function with only one recursive call can usually be turned into a tail-recursive function without too much effort, and then it's trivial to convert it into an iterative function. The canonical example here is factorial:
```
# naïve recursion
def fac(n):
if n <= 1:
return 1
else:
re... |
235,880 | <p>How can I convert an <code>Int64</code> to an <code>Int32</code> type in F# without using the <code>Microsoft.FSharp.Compatibility.Int32.of_int64</code>?</p>
<p>I'm doing this because interactive doesn't seem to work when I try:</p>
<pre><code>open Microsoft.FSharp.Compatibility
</code></pre>
<p>With <code>FSharp... | [
{
"answer_id": 235893,
"author": "Thedric Walker",
"author_id": 26166,
"author_profile": "https://Stackoverflow.com/users/26166",
"pm_score": 5,
"selected": false,
"text": "<p>F# 1.9.6 has a type conversion function so you can do this: </p>\n\n<pre><code>let num = 1000\nlet num64 = int64... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I convert an `Int64` to an `Int32` type in F# without using the `Microsoft.FSharp.Compatibility.Int32.of_int64`?
I'm doing this because interactive doesn't seem to work when I try:
```
open Microsoft.FSharp.Compatibility
```
With `FSharp.PowerPack` added as a reference it says:
>
> error FS0039: The name... | F# 1.9.6 has a type conversion function so you can do this:
```
let num = 1000
let num64 = int64(num)
``` |
235,955 | <p>I just downloaded MVC and I am going through a tutorial. Everything goes fine until I try to declare a DataContext object.</p>
<p>My dbml is named <strong>db.dbml</strong> (tried another on named test.dbml) and when I try this:</p>
<pre><code>public dbDataContext db = new dbDataContext();
</code></pre>
<p>I get:... | [
{
"answer_id": 238847,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 1,
"selected": false,
"text": "<p>A few quick questiosn: Is the name of your data context \"dbDataContext\"?... also, is it in a namespace? (do yo... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | I just downloaded MVC and I am going through a tutorial. Everything goes fine until I try to declare a DataContext object.
My dbml is named **db.dbml** (tried another on named test.dbml) and when I try this:
```
public dbDataContext db = new dbDataContext();
```
I get:
>
> The type or namespace name
> 'dbDataCon... | This is a sp1 bug if you are using partial classes, see the following and work-arounds:
<https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361577> |
235,959 | <p>I have a (derived) Menu control, that displays a rather large list of items from a custom data source. I need to disable ViewState on the menu to avoid the very annoying "Can't select a disabled or unselectable menu item" when some other control causes the current selection to change on a postback.</p>
<p>Unfortuna... | [
{
"answer_id": 237490,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 1,
"selected": true,
"text": "<p>I've figured out the essence of the problem. Using Reflector we can see the important part(s) of the low level ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31385/"
] | I have a (derived) Menu control, that displays a rather large list of items from a custom data source. I need to disable ViewState on the menu to avoid the very annoying "Can't select a disabled or unselectable menu item" when some other control causes the current selection to change on a postback.
Unfortunately, when... | I've figured out the essence of the problem. Using Reflector we can see the important part(s) of the low level method that handles the actual postback and then raises the event:
```
string str = HttpUtility.HtmlDecode(eventArgument);
...
MenuItem item = this.Items.FindItem(str.Split(new char[] { '\\' }), 0);
if (item ... |
235,967 | <p>I am working on a web page that is using jQuery. I have an Ajax call that gets data from the server and updates a div. Inside that data there is a jQuery function, but the function is not being called after the data is loaded into the page. I have the proper js files included in the page already.</p>
<p>This is wha... | [
{
"answer_id": 235990,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 6,
"selected": true,
"text": "<p>If you want JavaScript tag evaluation, with html content, you should set the dataType option of the ajax call... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | I am working on a web page that is using jQuery. I have an Ajax call that gets data from the server and updates a div. Inside that data there is a jQuery function, but the function is not being called after the data is loaded into the page. I have the proper js files included in the page already.
This is what is retur... | If you want JavaScript tag evaluation, with html content, you should set the dataType option of the ajax call to "html":
```
$.ajax({
type: "GET",
url: "yourPage.htm",
dataType: "html"
});
```
Or dataType "script", if you want to load and execute a .js file:
```
$.ajax({
type: "GET",
url: "test.js",
dat... |
235,972 | <p>I have a windows application running at the backend. I have functions in this applications mapped to hot keys. Like if I put a message box into this function and give hot key as <kbd>Alt</kbd>+<kbd>Ctrl</kbd>+<kbd>D</kbd>. then on pressing <kbd>Alt</kbd>, <kbd>Ctrl</kbd> and <kbd>D</kbd> together the message box com... | [
{
"answer_id": 236175,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <a href=\"http://msdn.microsoft.com/library/system.windows.forms.clipboard.aspx\" rel=\"nofollow norefer... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20951/"
] | I have a windows application running at the backend. I have functions in this applications mapped to hot keys. Like if I put a message box into this function and give hot key as `Alt`+`Ctrl`+`D`. then on pressing `Alt`, `Ctrl` and `D` together the message box comes up. My application is working fine till this point.
... | Your question has two answers
How can my app set a global hotkey
----------------------------------
You have to call an API funcion called RegisterHotKey
```
BOOL RegisterHotKey(
HWND hWnd, // window to receive hot-key notification
int id, // identifier of hot key
UINT fsModifiers, //... |
235,982 | <p>The most favorite feature of StackOverflow for me is that it can automatically detect code in post and set appropriate color to the code.</p>
<p>I'm wondering how the color is set. When I do a <kbd>Ctrl</kbd>+<kbd>F5</kbd> on a page, the code seems first be black text, then change to be colorful. Is it done by jQue... | [
{
"answer_id": 235987,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": false,
"text": "<p>From <a href=\"https://stackoverflow.fogbugz.com/default.asp?W12621\" rel=\"noreferrer\">Stack Overflow Podcast #11</a>... | 2008/10/25 | [
"https://Stackoverflow.com/questions/235982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] | The most favorite feature of StackOverflow for me is that it can automatically detect code in post and set appropriate color to the code.
I'm wondering how the color is set. When I do a `Ctrl`+`F5` on a page, the code seems first be black text, then change to be colorful. Is it done by jQuery? | In reply to..
>
> Spolsky: How do they know, how do they even know what language you're writing in?
>
>
>
It doesn't. The highlighter is very dumb, but manages to gets away with it because most programming languages are so similar. Nearly everything uses syntax close-enough to..
```
AFunction("a string")
1 + 4 #... |
236,031 | <p>How can I implement a <code>diff</code> function, such as Stack Overflow's question revision history?</p>
| [
{
"answer_id": 236034,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "<p>You have here a <a href=\"http://ejohn.org/projects/javascript-diff-algorithm/\" rel=\"nofollow noreferrer\">javascript examp... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20191/"
] | How can I implement a `diff` function, such as Stack Overflow's question revision history? | You have here a [javascript example](http://ejohn.org/projects/javascript-diff-algorithm/) of the implementation of a diff algorithm.
Based on:
[P. Heckel, A technique for isolating differences between files](http://www.scribd.com/doc/1461552/A-technique-for-isolating-differences-between-files)
Comm. ACM, 21, (4), 26... |
236,035 | <p>I've been reading many a tutorial/article on unmanaged DLLs in C++. For the life of me, however, I cannot seem to grasp the concept. I'm easily confused by the seeming disagreement about whether it needs a header file, how to export it, whether I need a .lib file and what have you.</p>
<p>So, let's assume I have ju... | [
{
"answer_id": 236052,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": 5,
"selected": true,
"text": "<p>I cannot stress this enough, the C++ compiler does not see header files, after the preprocessor is done, there's just one ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31389/"
] | I've been reading many a tutorial/article on unmanaged DLLs in C++. For the life of me, however, I cannot seem to grasp the concept. I'm easily confused by the seeming disagreement about whether it needs a header file, how to export it, whether I need a .lib file and what have you.
So, let's assume I have just a funct... | I cannot stress this enough, the C++ compiler does not see header files, after the preprocessor is done, there's just one big source file ( also called the compilation unit ). So strictly you don't need a header to export this function from a dll.
What you do need is some form of conditional compilation to export the f... |
236,038 | <p>I am facing this peculiar problem. My webapp, works fine on my localhost. Its a JSP/Struts-Tomcat-MySQL app. However, when I host it on hostjava.net (shared tomcat), it is unable to connect to the database.</p>
<p>After some debugging, I have identified the problem, to be with JNDI lookup for datasource. If you wan... | [
{
"answer_id": 236049,
"author": "anjanb",
"author_id": 11142,
"author_profile": "https://Stackoverflow.com/users/11142",
"pm_score": 0,
"selected": false,
"text": "<p>\"java.lang.NullPointerException \n at com.DAO.UserDAO.userLogin(UserDAO.java:109) \n at com.Actions.UserA... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8056/"
] | I am facing this peculiar problem. My webapp, works fine on my localhost. Its a JSP/Struts-Tomcat-MySQL app. However, when I host it on hostjava.net (shared tomcat), it is unable to connect to the database.
After some debugging, I have identified the problem, to be with JNDI lookup for datasource. If you want, you can... | Shouldn't this:
```
url="jdbc:mysql://localhost/[db name]?autoReconnect=true"
```
really point at the name of the server on which the database is hosted? On th remote host the database server may not be the same machine as the tomcat instance. I would think that you have to say
url="jdbc:mysql://[Server\_Name]/[db... |
236,070 | <p>How can I check the version of my script against an online file to see if it's the latest version?</p>
<p><em>For clarification, I'm talking about a script I wrote, not the version of PHP. I'd like to incorporate a way for the end user to tell when I've updated the script.</em></p>
| [
{
"answer_id": 236098,
"author": "Paweł Hajdan",
"author_id": 9403,
"author_profile": "https://Stackoverflow.com/users/9403",
"pm_score": 0,
"selected": false,
"text": "<p>Have an RSS or Atom <strong>feed</strong> with update info. Wordpress does something similar. Then you can locally s... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27025/"
] | How can I check the version of my script against an online file to see if it's the latest version?
*For clarification, I'm talking about a script I wrote, not the version of PHP. I'd like to incorporate a way for the end user to tell when I've updated the script.* | To specify the second (more simple) solution [phjr](https://stackoverflow.com/questions/236070/php-version-checking#236098) proposed:
Have a file `version.txt` on your own public server and include the following function into your deployed project/script:
```
define('REMOTE_VERSION', 'http://your.public.server/versio... |
236,073 | <p>Why do some sites (or advertisers that give clients javascript code) employ a technique of splitting the <code><script></code> and/or <code></script></code> tags up within <code>document.write()</code> calls?</p>
<p>I noticed that Amazon does this as well, for example:</p>
<pre><code><script type='t... | [
{
"answer_id": 236083,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": false,
"text": "<p>I think is for prevent the browser's HTML parser from interpreting the <script>, and mainly the </... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2929/"
] | Why do some sites (or advertisers that give clients javascript code) employ a technique of splitting the `<script>` and/or `</script>` tags up within `document.write()` calls?
I noticed that Amazon does this as well, for example:
```
<script type='text/javascript'>
if (typeof window['jQuery'] == 'undefined') docume... | `</script>` has to be broken up because otherwise it would end the enclosing `<script></script>` block too early. Really it should be split between the `<` and the `/`, because a script block is supposed (according to SGML) to be [terminated by any end-tag open (ETAGO) sequence (i.e. `</`)](http://www.w3.org/TR/html4/t... |
236,097 | <p>In XEmacs this is done by the calling the function char-to-ucs on a character. GNU Emacs does not seem to have this function. In GNU Emacs, characters seem to be ordinary integers. Running C-x = on a latin character reveals that the Emacs codepoint is different from the Unicode codepoint for the corresponding cha... | [
{
"answer_id": 236160,
"author": "Dwight Holman",
"author_id": 2667,
"author_profile": "https://Stackoverflow.com/users/2667",
"pm_score": 6,
"selected": false,
"text": "<p>In a modern Emacs, M-x describe-char will tell you about the character at point.<br>\nAn example:</p>\n\n<pre><code... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In XEmacs this is done by the calling the function char-to-ucs on a character. GNU Emacs does not seem to have this function. In GNU Emacs, characters seem to be ordinary integers. Running C-x = on a latin character reveals that the Emacs codepoint is different from the Unicode codepoint for the corresponding character... | In a modern Emacs, M-x describe-char will tell you about the character at point.
An example:
```
character: ¢ (2210, #o4242, #x8a2, U+00A2)
charset: latin-iso8859-1
(Right-Hand Part of Latin Alphabet 1 (ISO/IEC 8859-1): ISO-IR-100.)
code point: #x22
syntax: w which means: word
category: l:L... |
236,125 | <p>Suppose I have this Windows wchar_t string:</p>
<pre><code>L"\x4f60\x597d"
</code></pre>
<p>and</p>
<pre><code>L"\x00e4\x00a0\x597d"
</code></pre>
<p>and would like to convert it (not necessarily programmatically; it will be a one-time thing) to GCC/Linux wchar_t format, which is UTF-32 AFAIK. How do I do it? (a... | [
{
"answer_id": 236574,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "<p>Would converting from UTF-16 (the Visual C++ <code>wchar_t</code> form) to UTF-8, then possibly from UTF-8 to UCS-4 (... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] | Suppose I have this Windows wchar\_t string:
```
L"\x4f60\x597d"
```
and
```
L"\x00e4\x00a0\x597d"
```
and would like to convert it (not necessarily programmatically; it will be a one-time thing) to GCC/Linux wchar\_t format, which is UTF-32 AFAIK. How do I do it? (a general explanation would be nice, but example... | One of the most used libraries to do character conversion is the ICU library <http://icu-project.org/> It is e.g. used by some boost <http://www.boost.org/> libraries. |
236,129 | <p>How do I iterate over the words of a string composed of words separated by whitespace?</p>
<p>Note that I'm not interested in C string functions or that kind of character manipulation/access. I prefer elegance over efficiency. My current solution:</p>
<pre><code>#include <iostream>
#include <sstream>
#in... | [
{
"answer_id": 236137,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "<p>The STL does not have such a method available already.</p>\n\n<p>However, you can either use C's <a href=\"http://en.cppref... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1630/"
] | How do I iterate over the words of a string composed of words separated by whitespace?
Note that I'm not interested in C string functions or that kind of character manipulation/access. I prefer elegance over efficiency. My current solution:
```
#include <iostream>
#include <sstream>
#include <string>
using namespace... | For what it's worth, here's another way to extract tokens from an input string, relying only on standard library facilities. It's an example of the power and elegance behind the design of the STL.
```
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
int main() {
us... |
236,133 | <p>I'm trying to get a simple search form working in my RoR site. I've got the following code:</p>
<p>(in note_controller.rb)</p>
<pre><code> def search
@results = Note.find_with_ferret(params[:term]).sort_by(&:ferret_rank)
respond_to do |format|
format.html
format.xml { render :xml => @n... | [
{
"answer_id": 236612,
"author": "Gene T",
"author_id": 413049,
"author_profile": "https://Stackoverflow.com/users/413049",
"pm_score": 2,
"selected": true,
"text": "<p>I can't recall ever seeing that ferret error. There's two basic diagnostics: go into script/console, and do </p>\n\n<p... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] | I'm trying to get a simple search form working in my RoR site. I've got the following code:
(in note\_controller.rb)
```
def search
@results = Note.find_with_ferret(params[:term]).sort_by(&:ferret_rank)
respond_to do |format|
format.html
format.xml { render :xml => @nootes }
end
end
```
... | I can't recall ever seeing that ferret error. There's two basic diagnostics: go into script/console, and do
```
Notes.find_with_ferret("some term that should be in index")
```
And then see what happens when you remove the indexes' directory (/appname/index/development), do another find\_with\_ferret to force reinde... |
236,151 | <p>I recently started using Git as my version control system for some Cocoa projects I'm working on and wondered if there are best practices for working with version control systems on Cocoa projects.</p>
<p>There is the obvious "build" directory which I exclude from versioning as it's not important and can change qui... | [
{
"answer_id": 236170,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I never commit the ${LOGNAME}.* files as they're basically preferences information for the current user; the project source... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29618/"
] | I recently started using Git as my version control system for some Cocoa projects I'm working on and wondered if there are best practices for working with version control systems on Cocoa projects.
There is the obvious "build" directory which I exclude from versioning as it's not important and can change quite a bit w... | Here's my Mercurial `.hgignore` file, which is based on [Peter Hosey's](http://boredzo.org/blog/archives/2008-03-20/hgignore-for-mac-os-x-applications).
```
syntax: glob
.DS_Store
*.swp
*~.nib
build
*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.pyc
``` |
236,166 | <p>I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the current directory in a web service?</p>
<p>Thanks
Stuart </p>
| [
{
"answer_id": 236169,
"author": "driis",
"author_id": 13627,
"author_profile": "https://Stackoverflow.com/users/13627",
"pm_score": 6,
"selected": false,
"text": "<p>In a webservice, you are running in a http context. So,</p>\n\n<pre><code>HttpContext.Current.Server.MapPath(\"~/\") \n</... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23149/"
] | I am using System.IO.Directory.GetCurrentDirectory() to get the current directory in my web service, but that does not give me the current directory. How do I get the current directory in a web service?
Thanks
Stuart | In a webservice, you are running in a http context. So,
```
HttpContext.Current.Server.MapPath("~/")
```
will give you the answer. |
236,172 | <p>I have several <code>std::vector</code>, all of the same length. I want to sort one of these vectors, and apply the same transformation to all of the other vectors. Is there a neat way of doing this? (preferably using the STL or Boost)? Some of the vectors hold <code>int</code>s and some of them <code>std::string<... | [
{
"answer_id": 236193,
"author": "friol",
"author_id": 23034,
"author_profile": "https://Stackoverflow.com/users/23034",
"pm_score": 2,
"selected": false,
"text": "<p>Only one rough solution comes to my mind: create a vector that is the sum of all other vectors (a vector of structures, l... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8331/"
] | I have several `std::vector`, all of the same length. I want to sort one of these vectors, and apply the same transformation to all of the other vectors. Is there a neat way of doing this? (preferably using the STL or Boost)? Some of the vectors hold `int`s and some of them `std::string`s.
Pseudo code:
```
std::vecto... | friol's approach is good when coupled with yours. First, build a vector consisting of the numbers 1…*n*, along with the elements from the vector dictating the sorting order:
```
typedef vector<int>::const_iterator myiter;
vector<pair<size_t, myiter> > order(Index.size());
size_t n = 0;
for (myiter it = Index.begin()... |
236,183 | <p>I want to be able to put preformatted text (i.e. containing line breaks) into a single cell of a FitNesse fixture table. Is there a way to manipulate the FitNesse wiki markup to do this?</p>
| [
{
"answer_id": 236207,
"author": "Matthew Murdoch",
"author_id": 4023,
"author_profile": "https://Stackoverflow.com/users/4023",
"pm_score": 2,
"selected": false,
"text": "<p>One way to do this is to define a variable with the multi-line text and then refer to this from the table cell:</... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023/"
] | I want to be able to put preformatted text (i.e. containing line breaks) into a single cell of a FitNesse fixture table. Is there a way to manipulate the FitNesse wiki markup to do this? | Use !- -! to get multiline table cells and {{{ }}} to get preformatted text. The {{{ has to be outside the !-
For example:
```
|sql|
|{{{!- SELECT *
FROM bar
WHERE gaz = 14
-!}}}|
``` |
236,203 | <p>I have a div with a <code><h1></code> tag in a div, with no margins. If I define any doctype, a white space appears above the div.</p>
<p>If I remove the <code><h1></code> tags, or remove the doctype definition, there is no space (as there should be. Why?</p>
<p>Example HTML:</p>
<pre><code><!DOCTY... | [
{
"answer_id": 236213,
"author": "Shadow2531",
"author_id": 1697,
"author_profile": "https://Stackoverflow.com/users/1697",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"http://www.opera.com/docs/specs/doctype/\" rel=\"nofollow noreferrer\">http://www.opera.com/docs/specs/d... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | I have a div with a `<h1>` tag in a div, with no margins. If I define any doctype, a white space appears above the div.
If I remove the `<h1>` tags, or remove the doctype definition, there is no space (as there should be. Why?
Example HTML:
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org... | The space above the green div is the correct behaviour according to the [CSS spec](http://www.w3.org/TR/CSS21/box.html#collapsing-margins). This is because the top margin of the h1 adjoins the top margin of the div.
One way to keep the margin of the h1 inside the div is to add a border to the div:
```
#thediv{ backgr... |
236,211 | <p>Is it good practice to let abstract classes define instance variables?</p>
<pre><code>public abstract class ExternalScript extends Script {
String source;
public abstract void setSource(String file);
public abstract String getSource();
}
</code></pre>
<p>The sub class, ExternalJavaScript.class, woul... | [
{
"answer_id": 236215,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 4,
"selected": false,
"text": "<p>Sure.. Why not?<br>\nAbstract base classes are just a convenience to house behavior and data common to 2 or more classes in... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31518/"
] | Is it good practice to let abstract classes define instance variables?
```
public abstract class ExternalScript extends Script {
String source;
public abstract void setSource(String file);
public abstract String getSource();
}
```
The sub class, ExternalJavaScript.class, would then automatically get t... | I would have thought that something like this would be much better, since you're adding a variable, so why not restrict access and make it cleaner? Your getter/setters should do what they say on the tin.
```
public abstract class ExternalScript extends Script {
private String source;
public void setSource(St... |
236,235 | <p><em>(This question specifically in C#, but applies generally to .NET)</em> </p>
<p>I have a largish application that has a fairly good design, and is broken into major sections over interfaces (this was done to assist parallel development).</p>
<p>We now have a primary set of concrete classes that implement the re... | [
{
"answer_id": 236237,
"author": "Daniel Kreiseder",
"author_id": 31406,
"author_profile": "https://Stackoverflow.com/users/31406",
"pm_score": 1,
"selected": false,
"text": "<p>Try the factory pattern</p>\n\n<p><a href=\"http://en.wikipedia.org/wiki/Abstract_factory_pattern\" rel=\"nofo... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6408/"
] | *(This question specifically in C#, but applies generally to .NET)*
I have a largish application that has a fairly good design, and is broken into major sections over interfaces (this was done to assist parallel development).
We now have a primary set of concrete classes that implement the required interfaces, but w... | You want to look at IoC containers. (Spring.NET, StructureMap, Windsor, etc.) |
236,236 | <p>I have a select query that currently produces the following results:
<BR></p>
<pre><code>Description Code Price
Product 1 A 5
Product 1 B 4
Product 1 C 2
</code></pre>
<p>Using the following query: </p>
<pre><code>SELECT DISTINCT np.Description, p.promotionalCode, p.Price... | [
{
"answer_id": 236252,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SELECT \n np.Id, \n np.Description, \n MIN(Case promotionalCode WHEN 'A' THEN Price ELSE NULL END) AS... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a select query that currently produces the following results:
```
Description Code Price
Product 1 A 5
Product 1 B 4
Product 1 C 2
```
Using the following query:
```
SELECT DISTINCT np.Description, p.promotionalCode, p.Price
FROM Price AS p INNER JOIN
... | ```
SELECT
np.Id,
np.Description,
MIN(Case promotionalCode WHEN 'A' THEN Price ELSE NULL END) AS 'A',
MIN(Case promotionalCode WHEN 'B' THEN Price ELSE NULL END) AS 'B',
MIN(Case promotionalCode WHEN 'C' THEN Price ELSE NULL END) AS 'C'
FROM
Price AS p
INNER JOIN nProduct AS np ON p.nProduc... |
236,239 | <p>I have an <em>SQLite</em> table that contains prices for various products. It's a snapshot table, so it contains the prices on 5 minute intervals. I would like to write a query that would return the difference in price from one row to the next on each item.</p>
<p>The columns are id (auto inc), record_id (id of the... | [
{
"answer_id": 236286,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": false,
"text": "<p>I do not know if there are some limitations in SQLite, but you can try the following statements that are working in Sql Ser... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an *SQLite* table that contains prices for various products. It's a snapshot table, so it contains the prices on 5 minute intervals. I would like to write a query that would return the difference in price from one row to the next on each item.
The columns are id (auto inc), record\_id (id of the product), price... | Yes, it is **a bit late**, but for completeness. *SQLite Release 3.25.0 in 2018 added support for window functions*. And the above task can now be completed by using the [LAG() and LEAD()](https://www.sqlite.org/windowfunctions.html) functions.
Taken from: <https://www.sqlitetutorial.net/sqlite-window-functions/>
**L... |
236,279 | <pre><code><?php
function toconv(string)
{
$gogo = array("a" => "b","cd" => "e");
$string = str_replace(
array_keys( $gogo ),
array_values( $gogo ),
$string
);
return $string;
}
?>
</code></pre>
<p>How can I implement that in JavaScript?</p>
| [
{
"answer_id": 236287,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>String.replace() in Javascript receives regexes instead of strings and here's a translation. You need to append t... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21559/"
] | ```
<?php
function toconv(string)
{
$gogo = array("a" => "b","cd" => "e");
$string = str_replace(
array_keys( $gogo ),
array_values( $gogo ),
$string
);
return $string;
}
?>
```
How can I implement that in JavaScript? | And to make it in a way, where you can do it directly from an array:
```
<script type="text/javascript">
function toconv(string){
var gogo = {"a":"b", "cd":"e"}, reg;
for(x in gogo) {
reg = new RegExp(x, "g");
string.replace(x, gogo[x]);
}
return string;
}
</script>
``` |
236,283 | <p>I am using the following function to load a PlayList of Songs from 'PlayListJSON.aspx' but somethings seems wrong,evrytime OnFailure is getting called, I am unable to debug it further. any help would be really gr8.</p>
<pre><code>Player.prototype.loadPlaylist = function(playlistId, play) {
req = new Ajax.Request(... | [
{
"answer_id": 236299,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 1,
"selected": false,
"text": "<p>Generally, OnFailure gets called when the page you are calling out to can't be reached for some reason.</p>\n\n<p>Are you... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using the following function to load a PlayList of Songs from 'PlayListJSON.aspx' but somethings seems wrong,evrytime OnFailure is getting called, I am unable to debug it further. any help would be really gr8.
```
Player.prototype.loadPlaylist = function(playlistId, play) {
req = new Ajax.Request('/PlaylistJSON... | Generally, OnFailure gets called when the page you are calling out to can't be reached for some reason.
Are you positive that the URL **/PlaylistJSON.aspx** is valid?
---
Have you tried passing the parameters argument instead of specifying them as part of the url?
```
req = new Ajax.Request('/PlaylistJSON.aspx',
... |
236,290 | <p>For example, say one was to include a 'delete' keyword in C# 4. Would it be possible to guarantee that you'd never have wild pointers, but still be able to rely on the garbage collecter, due to the reference-based system?</p>
<p>The only way I could see it possibly happening is if instead of references to memory lo... | [
{
"answer_id": 236304,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>With garbage collection, as long as you have a referenced reference to the object, it stays alive. With manual del... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18658/"
] | For example, say one was to include a 'delete' keyword in C# 4. Would it be possible to guarantee that you'd never have wild pointers, but still be able to rely on the garbage collecter, due to the reference-based system?
The only way I could see it possibly happening is if instead of references to memory locations, a... | With garbage collection, as long as you have a referenced reference to the object, it stays alive. With manual delete you can't guarantee that.
Example (pseudocode):
```
obj1 = new instance;
obj2 = obj1;
//
delete obj2;
// obj1 now references the twilightzone.
```
Just to be short, combining manual memory manage... |
236,323 | <p>I need to compare the integer part of two doubles for inequality and I'm currently doing this:</p>
<pre><code>int iA = (int)dA;
int iB = (int)dB;
if( iA != iB )
{
...
}
</code></pre>
<p>but I wonder if there's a better approach than this.</p>
<p>Thanks.</p>
<p>If I used Math.Truncate() instead of a cast to ... | [
{
"answer_id": 236331,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, that is best approach.</p>\n\n<p>Assuming from your wording in you question you arent worried about rounding... jus... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7839/"
] | I need to compare the integer part of two doubles for inequality and I'm currently doing this:
```
int iA = (int)dA;
int iB = (int)dB;
if( iA != iB )
{
...
}
```
but I wonder if there's a better approach than this.
Thanks.
If I used Math.Truncate() instead of a cast to int, would it still be accurate to compa... | Use Math.Truncate() i.e.
```
if (Math.Truncate(x) == Math.Truncate(y))
```
[Edit] Realized that if you are comparing integer parts of doubles, casting to int values first runs the risk of overflows should your doubles be outside the range that could be represented as int.
Truncate returns either a Decimal or a dou... |
236,335 | <p>So, simple procedure, calculate a factorial number. Code is as follows.</p>
<pre><code>int calcFactorial(int num)
{
int total = 1;
if (num == 0)
{
return 0;
}
for (num; num > 0; num--)
{
total *= num;
}
return total;
}
</code></pre>
<p>Now, this works fine and ... | [
{
"answer_id": 236338,
"author": "Stewart Johnson",
"author_id": 6408,
"author_profile": "https://Stackoverflow.com/users/6408",
"pm_score": 5,
"selected": true,
"text": "<p>2^32 doesn't give you the limit for signed integers. </p>\n\n<p>The signed integer limit is actually <a href=\"htt... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31389/"
] | So, simple procedure, calculate a factorial number. Code is as follows.
```
int calcFactorial(int num)
{
int total = 1;
if (num == 0)
{
return 0;
}
for (num; num > 0; num--)
{
total *= num;
}
return total;
}
```
Now, this works fine and dandy (There are certainly qu... | 2^32 doesn't give you the limit for signed integers.
The signed integer limit is actually [2147483647](http://msdn.microsoft.com/en-us/library/296az74e(VS.80).aspx) (if you're developing on Windows using the MS tools, other toolsuites/platforms would have their own limits that are probably similar).
You'll need a C+... |
236,349 | <p>What's the best way to handle a visitor constructing their own URL and replacing what we expect to be an ID with anything they like?</p>
<p>For example:</p>
<p><a href="https://stackoverflow.com/questions/236349">ASP.Net MVC - handling bad URL parameters</a></p>
<p>But the user could just as easily replace the UR... | [
{
"answer_id": 236353,
"author": "Ovid",
"author_id": 8003,
"author_profile": "https://Stackoverflow.com/users/8003",
"pm_score": 0,
"selected": false,
"text": "<p>The problem with that approach is that they still might pass an integer which doesn't map to a page. Just return a 404 if t... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] | What's the best way to handle a visitor constructing their own URL and replacing what we expect to be an ID with anything they like?
For example:
[ASP.Net MVC - handling bad URL parameters](https://stackoverflow.com/questions/236349)
But the user could just as easily replace the URL with:
<https://stackoverflow.com... | Here's an example of a route like yours, with a constraint on the number:
```
routes.MapRoute(
"Question",
"questions/{questionID}",
new { controller = "StackOverflow", action = "Question" },
new { questionID = @"\d+" } //Regex constraint specifying that it must be a number.
);
```
Here we set the qu... |