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 |
|---|---|---|---|---|---|---|
305,491 | <p>I'm trying to convert some code that uses datasets to LINQ. Some of the code passes column names into other functions as strings.</p>
<p>Is there anyway I can easily rewrite this into LINQ?</p>
<pre><code>string s = getElement(tr, elementName);
private string getElement (tableRow re, string elementName){
if(tr[... | [
{
"answer_id": 305567,
"author": "GvS",
"author_id": 11492,
"author_profile": "https://Stackoverflow.com/users/11492",
"pm_score": -1,
"selected": false,
"text": "<p>Why would you convert working and clear code into something using LINQ?</p>\n\n<p>Edit: LINQ is nice, cool stuff. But don'... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37083/"
] | I'm trying to convert some code that uses datasets to LINQ. Some of the code passes column names into other functions as strings.
Is there anyway I can easily rewrite this into LINQ?
```
string s = getElement(tr, elementName);
private string getElement (tableRow re, string elementName){
if(tr[elementName] != nul... | The answer is to use reflection.
Getting a value
```
private string getElement (tableRow tr, string element){
string val = "";
try
{
val = tr.GetType().GetProperty(element).GetValue(tr, null).ToString();
}
catch //NULL value
{
val = "";
}
}
```
Or the copy scenario:
``... |
305,495 | <blockquote>
<p>This question exists because it has
historical significance, but it is not
considered a good, on-topic question
for this site, so please do not use it
as evidence that you can ask similar
questions here.</p>
<p>More info: <a href="https://stackoverflow.com/faq">https://stackoverflow.com... | [
{
"answer_id": 305502,
"author": "csl",
"author_id": 21028,
"author_profile": "https://Stackoverflow.com/users/21028",
"pm_score": 2,
"selected": false,
"text": "<p>It used to be possible with:</p>\n\n<pre><code>host -a -l domain.com\n</code></pre>\n"
},
{
"answer_id": 305517,
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36544/"
] | >
> This question exists because it has
> historical significance, but it is not
> considered a good, on-topic question
> for this site, so please do not use it
> as evidence that you can ask similar
> questions here.
>
>
> More info: <https://stackoverflow.com/faq>
>
>
>
Anyone knows if it's possible to fi... | Like others have said, what you want is a so called zone-transfer. If it is your own domain you can configure the DNS server to give it to you. If it is for some other domain you probably don't get it, since most DNS-admins consider it a security threat.
Even if an individual record isn't a problem (thats what the DNS... |
305,509 | <p>I wanted to pass <code>calendar1.Selecteddate</code> in a <code>query string</code> from <code>gridview</code> in one page to another <code>gridview</code> (I have written <code>sqlquery</code> in that <code>gridview</code>) in another page. As seen in the below code I tried passing it but this did not work. Can any... | [
{
"answer_id": 305622,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>In the example you've provided it would treat that calendar part of the string as a literal and pass the exact value you ha... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wanted to pass `calendar1.Selecteddate` in a `query string` from `gridview` in one page to another `gridview` (I have written `sqlquery` in that `gridview`) in another page. As seen in the below code I tried passing it but this did not work. Can anyone tell me how to pass the selected date from `calendar` in `query s... | One solution is to build your URL string in the code-behind, instead of building it in the markup.
Override the RowDataBound method on the GridView and build the hyperlink programmatically:
```
protected override gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
HyperLink hl = new Hyperlink();
hl.Navigate... |
305,519 | <p>In an impersonation scenario related to Sharepoint I need to execute some code in a separate process (the process will run in the context of a certain user). I do not want to launch a separate application, basically I want to do a "run as" on just a method.</p>
| [
{
"answer_id": 305532,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>\"Execute code in a separate process\" = \"launch a separate application\" though.</p>\n\n<p>I mean, you could launch... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] | In an impersonation scenario related to Sharepoint I need to execute some code in a separate process (the process will run in the context of a certain user). I do not want to launch a separate application, basically I want to do a "run as" on just a method. | The Process.Start method has an overload to start the process provided you have the appropriate user, password and domain.
What you want to do is create a ProcessStartInfo object and specify the proper UserName and Password when starting the process. So you can do something like this:
```
Dim psiNewProcess As New Pro... |
305,523 | <p>I am writing a QT application and I need to embed a terminal (we say,xterm) within a QDialog, like some KDE application (see kdevelop/kate/...).</p>
<p>I've been trying with:
- QX11EmbedContainer placed into the QLayout of my QDialog
- QProcess for the program I want to excecute</p>
<p>I expect the QProcess runn... | [
{
"answer_id": 307752,
"author": "David Dibben",
"author_id": 5022,
"author_profile": "https://Stackoverflow.com/users/5022",
"pm_score": 0,
"selected": false,
"text": "<p>You need to pass the window ID of the container to the xterm.</p>\n\n<p>If you look at the example in the Qt help fo... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] | I am writing a QT application and I need to embed a terminal (we say,xterm) within a QDialog, like some KDE application (see kdevelop/kate/...).
I've been trying with:
- QX11EmbedContainer placed into the QLayout of my QDialog
- QProcess for the program I want to excecute
I expect the QProcess running within the QX... | Sorry, I've tried your solution before posting oh this site and it does not work.
I've solved switching to kdelibs and using those imports and this code
```
#include <kparts/part.h>
#include <assert.h>
#include <kde_terminal_interface.h>
#include <kpluginfactory.h>
#include <klibloader.h>
```
---
```
KLibFactory* f... |
305,524 | <p>I'm using SQL Server 2005 and the the Dynamic Management View <code>sys.dm_db_missing_index_details</code>. It continues to tell me that Table1 really needs an index on ColumnX and ColumnY, but that index already exists! I've even dropped and re-created it a couple times to no avail.</p>
<p>More specifics: The view... | [
{
"answer_id": 316088,
"author": "jerryhung",
"author_id": 37568,
"author_profile": "https://Stackoverflow.com/users/37568",
"pm_score": -1,
"selected": false,
"text": "<p>If you have dropped & created the index, sp_update_stats shouldn't affect it (problem is not with statistics)</p... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24898/"
] | I'm using SQL Server 2005 and the the Dynamic Management View `sys.dm_db_missing_index_details`. It continues to tell me that Table1 really needs an index on ColumnX and ColumnY, but that index already exists! I've even dropped and re-created it a couple times to no avail.
More specifics: The view lists Column1 under ... | Random thought: What if one of the columns is better declared "DESC"?
This is useful for ORDER BY clauses and I've seen logical IO reduce by half. |
305,529 | <p>Greetings to all! This is my first question here on stackoverflow. I have a WPF application that I am writing for the fellow developers in my department, and there are a couple of settings that I need to check for at startup and update if they are not set (one is the location of an executable on the users computer... | [
{
"answer_id": 305547,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 6,
"selected": true,
"text": "<p>Have you looked into the ConfigurationManager class? It provides a more robust interface to the app.config file and you can d... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39337/"
] | Greetings to all! This is my first question here on stackoverflow. I have a WPF application that I am writing for the fellow developers in my department, and there are a couple of settings that I need to check for at startup and update if they are not set (one is the location of an executable on the users computer, we ... | Have you looked into the ConfigurationManager class? It provides a more robust interface to the app.config file and you can do something like this:
```
Configuration oConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
oConfig.AppSettings.Settings["PreferenceToRemember"].Value = "NewValue"... |
305,535 | <p>-Edit-
FYI.. I am converting b&w documents scanned in as greyscale or color. </p>
<p>1)The first solution worked, it just reversed black & white (black background, white text). It also took nearly 10 minutes.<br>
2)The JAI solution in the 2nd answer didn't work for me. I tried it before posting here.</p>
... | [
{
"answer_id": 305595,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackoverflow.com/users/20481",
"pm_score": 3,
"selected": true,
"text": "<p>Most likely, you want something like <a href=\"http://image4j.sourceforge.net/javadoc/net/sf/image4j/util/ConvertUtil.htm... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36641/"
] | -Edit-
FYI.. I am converting b&w documents scanned in as greyscale or color.
1)The first solution worked, it just reversed black & white (black background, white text). It also took nearly 10 minutes.
2)The JAI solution in the 2nd answer didn't work for me. I tried it before posting here.
Has anyone worked with o... | Most likely, you want something like [this](http://image4j.sourceforge.net/javadoc/net/sf/image4j/util/ConvertUtil.html) to convert to 1 bit before you save to TIFF with CCITT compression.
To expound a little bit - be aware that converting from other bit depths to 1 bit is non-trivial. You are doing a data reduction o... |
305,536 | <pre><code>// A Mutex allows threads mutually exclusive access to a resource.
//-----------------------------------------------------------------------
class Mutex
{
private:
CRITICAL_SECTION m_mutex;
public:
Mutex() { InitializeCriticalSection(&m_mutex); }
~Mutex() { DeleteCriticalSection(&m_mut... | [
{
"answer_id": 305563,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see anything wrong with your class <em>definition</em>. Where is it being used though? A particular instance... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7599/"
] | ```
// A Mutex allows threads mutually exclusive access to a resource.
//-----------------------------------------------------------------------
class Mutex
{
private:
CRITICAL_SECTION m_mutex;
public:
Mutex() { InitializeCriticalSection(&m_mutex); }
~Mutex() { DeleteCriticalSection(&m_mutex); }
... | I'll bet you can fake out the snitch with ::memset ( & m\_mutex, 0, sizeof ( m\_mutex ) ); before the call to init it. |
305,554 | <p>Assume I have a function like this:</p>
<pre><code>MyClass &MyFunction(void)
{
static MyClass *ptr = 0;
if (ptr == 0)
ptr = new MyClass;
return MyClass;
}
</code></pre>
<p>The question is at program exit time, will the ptr variable ever become invalid (i.e. the contents of that ptr are cleaned up by ... | [
{
"answer_id": 305569,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 2,
"selected": false,
"text": "<p>In modern operating systems, all of an application's memory is allocated on a \"heap\" specific to that application. Wh... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7587/"
] | Assume I have a function like this:
```
MyClass &MyFunction(void)
{
static MyClass *ptr = 0;
if (ptr == 0)
ptr = new MyClass;
return MyClass;
}
```
The question is at program exit time, will the ptr variable ever become invalid (i.e. the contents of that ptr are cleaned up by the exiting process)? I realiz... | To answer your question:
```
'imagine that the ptr points to some memory address which I want to check in the destructor of some other static class'
```
The answer is yes.
You can see the value of the pointer (the address).
You can look at the content if you have not called delete on the pointer.
Static fun... |
305,555 | <p>How to get the last selected item in a .Net Forms multiselect ListBox? Apparently if I select an item in the listbox and then select another 10 the selected item is the first one.</p>
<p>I would like to obtain the last element that I selected/deselected.</p>
| [
{
"answer_id": 305597,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 3,
"selected": false,
"text": "<p>Not sure I understand the question, but the last selected item will be the last in the SelectedItems array, so something ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] | How to get the last selected item in a .Net Forms multiselect ListBox? Apparently if I select an item in the listbox and then select another 10 the selected item is the first one.
I would like to obtain the last element that I selected/deselected. | I would take this general approach:
Listen for the `SelectedIndexChanged` event and scan through the `SelectedIndices` collection every time.
Keep a separate list of all selected indices, appending ones that have not been in the list, removing those that have been de-selected.
The separate list will contain the ind... |
305,568 | <p>Excuting the line of SQL:</p>
<pre><code>SELECT *
INTO assignment_20081120
FROM assignment ;
</code></pre>
<p>against a database in oracle to back up a table called assignment gives me the following ORACLE error:
ORA-00905: Missing keyword</p>
| [
{
"answer_id": 305584,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": false,
"text": "<p>Unless there is a single row in the <code>ASSIGNMENT</code> table and <code>ASSIGNMENT_20081120</code> is a local P... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Excuting the line of SQL:
```
SELECT *
INTO assignment_20081120
FROM assignment ;
```
against a database in oracle to back up a table called assignment gives me the following ORACLE error:
ORA-00905: Missing keyword | Unless there is a single row in the `ASSIGNMENT` table and `ASSIGNMENT_20081120` is a local PL/SQL variable of type `ASSIGNMENT%ROWTYPE`, this is not what you want.
Assuming you are trying to create a new table and copy the existing data to that new table
```
CREATE TABLE assignment_20081120
AS
SELECT *
FROM assign... |
305,574 | <p>This question follows on from <a href="https://stackoverflow.com/questions/299114/can-i-search-for-php-class-members-and-methods-with-vim-star-search">this vim search question</a></p>
<p>I have a setting in my .vimrc which excludes $ as a valid part of a word:</p>
<pre><code>set iskeyword-=$
</code></pre>
<p>This... | [
{
"answer_id": 305627,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "<p>I would probably just add <code>set isk-=$</code> to my syntax highlighting auto command in <code>$VIMRUNTIME\\filetype.... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] | This question follows on from [this vim search question](https://stackoverflow.com/questions/299114/can-i-search-for-php-class-members-and-methods-with-vim-star-search)
I have a setting in my .vimrc which excludes $ as a valid part of a word:
```
set iskeyword-=$
```
This works fine for most files but isn't working... | I would probably just add `set isk-=$` to my syntax highlighting auto command in `$VIMRUNTIME\filetype.vim`. Don't know if it is the nicest way to do it, though.
Thinking about it... I think it would be enough to have an appropriate autocommand in your `vimrc`.
```
au FileType php set isk-=$
```
This executes ... |
305,591 | <p>This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ?????</p>
<p>Here is my data type:</p>
<pre><code>[Serializable]
pub... | [
{
"answer_id": 305617,
"author": "MysticSlayer",
"author_id": 28139,
"author_profile": "https://Stackoverflow.com/users/28139",
"pm_score": 2,
"selected": false,
"text": "<p>foreach (GridViewRow di in GridView1.Rows)\n {\n HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5208/"
] | This seems like something simple, but I can't seem to figure it out! I'm trying to get 2-way data-binding to work on an ASP.net page with a check box as one of the columns. How do I get the updated values (from check boxes) back from the gridview ?????
Here is my data type:
```
[Serializable]
public class UserRequire... | foreach (GridViewRow di in GridView1.Rows)
{
HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("chkBox1");
```
if (chkBx != null && chkBx.Checked)
{
/// put your code here
}
}
``` |
305,605 | <p>I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.</p>
<p>Here's a simple case that demonstrates the error:</p>
<pre><code>@echo off
set MODE=FOOBAR
if "%~1"=="" (... | [
{
"answer_id": 305640,
"author": "user33675",
"author_id": 33675,
"author_profile": "https://Stackoverflow.com/users/33675",
"pm_score": 6,
"selected": true,
"text": "<p>You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409/"
] | I'm writing a simple .bat file and I've run into some weird behavior. There are a couple places where I have to do a simple if/else, but the code inside the blocks don't seem to be working correctly.
Here's a simple case that demonstrates the error:
```
@echo off
set MODE=FOOBAR
if "%~1"=="" (
set MODE=all
echo... | You are running into the problem of cmd's static variable expansion. The MODE variable is only evaluated once. You can see this if you omit the @echo off line.
From the set /? documentation:
>
> Finally, support for delayed environment variable expansion has
> been added. This support is always
> disabled by defau... |
305,615 | <p>When measuring network latency (time ack received - time msg sent) in any protocol over TCP, what timer would you recommend to use and why? What resolution does it have? What are other advantages/disadvantages?</p>
<p>Optional: how does it work?</p>
<p>Optional: what timer would you NOT use and why?</p>
<p>I'm lo... | [
{
"answer_id": 305623,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 2,
"selected": false,
"text": "<p>You mentioned that you use GetTickCount(), so I'm going to recommend that you take a look at QueryPerformanceCou... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22724/"
] | When measuring network latency (time ack received - time msg sent) in any protocol over TCP, what timer would you recommend to use and why? What resolution does it have? What are other advantages/disadvantages?
Optional: how does it work?
Optional: what timer would you NOT use and why?
I'm looking mostly for Windows... | This is a copy of my answer from: [C++ Timer function to provide time in nano seconds](https://stackoverflow.com/questions/275004/c-timer-function-to-provide-time-in-nano-seconds#275231)
For Linux (and BSD) you want to use [clock\_gettime()](http://opengroup.org/onlinepubs/007908799/xsh/clock_gettime.html).
```
#incl... |
305,635 | <p>I came across this snippet of code on MSDN:</p>
<pre><code>entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl|
res://*/AdventureWorksModel.ssdl|
res://*/AdventureWorksModel.msl";
</code></pre>
<p>What does the <code>res://*/</code> mean and how does ... | [
{
"answer_id": 305658,
"author": "Scott",
"author_id": 29640,
"author_profile": "https://Stackoverflow.com/users/29640",
"pm_score": 3,
"selected": true,
"text": "<p>You've got the right idea:</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/aa767740.aspx\" rel=\"nofollow nore... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17715/"
] | I came across this snippet of code on MSDN:
```
entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl|
res://*/AdventureWorksModel.ssdl|
res://*/AdventureWorksModel.msl";
```
What does the `res://*/` mean and how does it work? I think it has to do with re... | You've got the right idea:
[res protocol](http://msdn.microsoft.com/en-us/library/aa767740.aspx "res protocol")
EDIT: Incidentally, you should check [searchdotnet](http://searchdotnet.com/ "searchdotnet") for technical searches, it still uses google but filters on .net stuff. |
305,651 | <p>I've seen this syntax a couple times now, and it's beginning to worry me,</p>
<p>For example:</p>
<pre><code>iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
</code></pre>
| [
{
"answer_id": 305655,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>It's calling a generic method - so in your case, the method may be declared like this:</p>\n\n<pre><code>public T Cre... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] | I've seen this syntax a couple times now, and it's beginning to worry me,
For example:
```
iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
``` | It's a Generic Method, Create is declared with type parameters, and check this links for more information:
* [An Introduction to C# Generics](http://msdn.microsoft.com/en-us/library/ms379564(vs.80).aspx)
* [Generics (C# Programming Guide)](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/)
* ... |
305,673 | <p>Essentially, I have to get a flat file into a database. The flat files come in with the first two characters on each line indicating which type of record it is.</p>
<p>Do I create a class for each record type with properties matching the fields in the record? Should I just use arrays?</p>
<p>I want to load the d... | [
{
"answer_id": 305692,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": true,
"text": "<p>I'd recommend creating classes (or structs, or what-ever value type your language supports), as </p>\n\n<pre><code>re... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] | Essentially, I have to get a flat file into a database. The flat files come in with the first two characters on each line indicating which type of record it is.
Do I create a class for each record type with properties matching the fields in the record? Should I just use arrays?
I want to load the data into some sort ... | I'd recommend creating classes (or structs, or what-ever value type your language supports), as
```
record.ClientReference
```
is so much more descriptive than
```
record[0]
```
and, if you're using the (wonderful!) [FileHelpers Library](http://www.filehelpers.com/), then your terms are pretty much dictated for ... |
305,688 | <p>I'm pretty sure the answer to this is no. I know that I can write</p>
<blockquote>
<p>if lcase(strFoo) = lcase(request.querystring("x")) then...</p>
</blockquote>
<p>or use inStr, but I just want to check there isn't some undocumented setting buried in the registry or somewhere that makes the content of VBScript... | [
{
"answer_id": 305748,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 1,
"selected": false,
"text": "<p>I doubt the existence of such an option since if there were something like that and you use it, you'll lose the ability to ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21203/"
] | I'm pretty sure the answer to this is no. I know that I can write
>
> if lcase(strFoo) = lcase(request.querystring("x")) then...
>
>
>
or use inStr, but I just want to check there isn't some undocumented setting buried in the registry or somewhere that makes the content of VBScript strings behave consistently wit... | There is a [`StrComp`](http://msdn.microsoft.com/en-us/library/ya4w6fwy(VS.85).aspx) function which allows performing a case-insensitive comparison of two strings by passing `vbTextCompare` as the third argument. The main documentation doesn't make that obvious, but it is discussed in this [Hey, Scripting Guy](http://w... |
305,690 | <p>I am working on a tool where I need to convert string values to their proper object types. E.g. convert a string like <code>"2008-11-20T16:33:21Z"</code> to a <code>DateTime</code> value. Numeric values like <code>"42"</code> and <code>"42.42"</code> must be converted to an <code>Int32</code> value and a <code>Doubl... | [
{
"answer_id": 305703,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>In terms of efficiency, yes, TryParse is generally the preferred route.</p>\n\n<p>If you can know (for example, by ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27393/"
] | I am working on a tool where I need to convert string values to their proper object types. E.g. convert a string like `"2008-11-20T16:33:21Z"` to a `DateTime` value. Numeric values like `"42"` and `"42.42"` must be converted to an `Int32` value and a `Double` value respectively.
What is the best and most efficient ap... | In terms of efficiency, yes, TryParse is generally the preferred route.
If you can know (for example, by reflection) the target type in advance - but don't want to have to use a big `switch` block, you might be interested in using `TypeConverter` - for example:
```
DateTime foo = new DateTime(2008, 11, 20);
... |
305,755 | <p>Just trying to get my head around Generics by reading <a href="http://msdn.microsoft.com/en-us/library/ms379564.aspx" rel="noreferrer">this enlightening article by Juval Lowy</a> </p>
<p>Paraphrasing.. When you define a Generic class definition, it is compiled into IL.</p>
<ul>
<li>For value-types, as soon as you ... | [
{
"answer_id": 305764,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Upcasting to object doesn't require an execution time check - it will always work, and is just a no-op basically.</p>\... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | Just trying to get my head around Generics by reading [this enlightening article by Juval Lowy](http://msdn.microsoft.com/en-us/library/ms379564.aspx)
Paraphrasing.. When you define a Generic class definition, it is compiled into IL.
* For value-types, as soon as you request for a specific value-type, it substitutes... | Upcasting to object doesn't require an execution time check - it will always work, and is just a no-op basically.
Downcasting requires an execution time check to make sure you're not casting a Stream to a String for example. It's a pretty small penalty, and very unlikely to be a bottleneck - but avoiding it is just on... |
305,769 | <p>I'm trying to implement some hooks, both pre and post fail however. I get the same error message for both when I try to commit:</p>
<pre>
'*-commit' hook failed (did not exit cleanly: apr_exit_why_e was 2, exitcode was
-1073741515). with no output.
</pre>
<p>Exitcode -1073741515 looks to be an odd one, and a quic... | [
{
"answer_id": 305798,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "<p>Normally the problem with commit hooks is that there is ABSOLUTELY no environment (thus no path), so all references ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8607/"
] | I'm trying to implement some hooks, both pre and post fail however. I get the same error message for both when I try to commit:
```
'*-commit' hook failed (did not exit cleanly: apr_exit_why_e was 2, exitcode was
-1073741515). with no output.
```
Exitcode -1073741515 looks to be an odd one, and a quick bit of goo... | I'd thought I'd share the Solution here, as I got a great laugh out of it.
The SubversionNotify was written in .NET.
The Server did not have the .NET Framework installed.
The VM did.
I am wearing a dunce cap now. |
305,780 | <p>I am porting some queries from Access to T-SQL and those who wrote the queries used the Avg aggregate function on datetime columns. This is not supported in T-SQL and I can understand why - it doesn't make sense. What is getting averaged?</p>
<p>So I was about to start reverse engineering what Access does when it... | [
{
"answer_id": 305869,
"author": "Scott Ivey",
"author_id": 36297,
"author_profile": "https://Stackoverflow.com/users/36297",
"pm_score": 3,
"selected": true,
"text": "<p>I'd imagine that Access is averaging the numeric representation of the dates. You could do similar in T-SQL with the... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22355/"
] | I am porting some queries from Access to T-SQL and those who wrote the queries used the Avg aggregate function on datetime columns. This is not supported in T-SQL and I can understand why - it doesn't make sense. What is getting averaged?
So I was about to start reverse engineering what Access does when it aggregates ... | I'd imagine that Access is averaging the numeric representation of the dates. You could do similar in T-SQL with the following...
```
select AverageDate = cast(avg(cast(MyDateColumn as decimal(20, 10))) as datetime)
from MyTable
``` |
305,796 | <p>I'm working with some schema which defines an abstract complex type, eg.</p>
<pre><code><xs:complexType name="MyComplexType" abstract="true">
</code></pre>
<p>This type is then referenced by another complex type in the schema:</p>
<pre><code><xs:complexType name="AnotherType">
<xs:sequence>
... | [
{
"answer_id": 305825,
"author": "Brian Genisio",
"author_id": 36687,
"author_profile": "https://Stackoverflow.com/users/36687",
"pm_score": 2,
"selected": false,
"text": "<p>I have never run into this problem, but I quickly learned that xsd.exe has a lot of shortcomings. We started usi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36860/"
] | I'm working with some schema which defines an abstract complex type, eg.
```
<xs:complexType name="MyComplexType" abstract="true">
```
This type is then referenced by another complex type in the schema:
```
<xs:complexType name="AnotherType">
<xs:sequence>
<xs:element name="Data" type="MyComplexType" maxOccur... | After evaluating several different schema-to-code tools the only one we found that was able to deal with our schema (very large and extremely complicated) was Liquid XML (<http://www.liquid-technologies.com/>). |
305,797 | <p>The program that I am currently assigned to has a requirement that I copy the contents of a table to a backup table, prior to the real processing.</p>
<p>During code review, a coworker pointed out that</p>
<pre><code>INSERT INTO BACKUP_TABLE
SELECT *
FROM PRIMARY_TABLE
</code></pre>
<p>is unduly risky, as it is p... | [
{
"answer_id": 305812,
"author": "gx.",
"author_id": 21580,
"author_profile": "https://Stackoverflow.com/users/21580",
"pm_score": 0,
"selected": false,
"text": "<p>You could try something like:</p>\n\n<pre><code>CREATE TABLE secondary_table AS SELECT * FROM primary_table;\n</code></pre>... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] | The program that I am currently assigned to has a requirement that I copy the contents of a table to a backup table, prior to the real processing.
During code review, a coworker pointed out that
```
INSERT INTO BACKUP_TABLE
SELECT *
FROM PRIMARY_TABLE
```
is unduly risky, as it is possible for the tables to have di... | Does the backup table stay around? Does it keep the data permanently, or is it just a copy of the current values?
Too bad about not being able to create/delete/rename/copy. Otherwise, if it's short term, just used in case something goes wrong, then you could drop it at the start of processing and do something like
``... |
305,805 | <p>I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubunt... | [
{
"answer_id": 307742,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 4,
"selected": true,
"text": "<p>I'll assume your problem was that the machine on which you first created the repo crapped out when you tried to issue the <... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21512/"
] | I am developing some school grading software and decided to use Github to host the project. After building some code on my Ubuntu box I pushed it to Github and then cloned it down to my MacBook Pro. After editing the code on the MBP I pushed it back to Github. The next morning I tried to update my repo on the Ubuntu bo... | I'll assume your problem was that the machine on which you first created the repo crapped out when you tried to issue the `git pull` command.
When you clone an existing git repository (like you did on your 2nd machine, the MacBook Pro), you're automatically set up to so your `git pull` commands will automatically merg... |
305,817 | <p>I want to be able to read from an unsorted source text file (one record in each line), and insert the line/record into a destination text file by specifying the line number where it should be inserted.</p>
<p>Where to insert the line/record into the destination file will be determined by comparing the incoming line... | [
{
"answer_id": 305895,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 1,
"selected": false,
"text": "<p>If the file is just a plain text file, then I'm afraid the only way to find a particular numbered line is to walk the fil... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39360/"
] | I want to be able to read from an unsorted source text file (one record in each line), and insert the line/record into a destination text file by specifying the line number where it should be inserted.
Where to insert the line/record into the destination file will be determined by comparing the incoming line from the ... | The basic problem is that under common OSs, files are just streams of bytes. There is no concept of lines at the filesystem level. Those semantics have to be added as an additional layer on top of the OS provided facilities. Although I have never used it, I believe that VMS has a record oriented filesystem that would m... |
305,835 | <p>I'm trying to understand the differences between Assembly.Load and Assembly.ReflectionOnlyLoad.</p>
<p>In the code below I am attempting to find all of the objects in a given assembly that inherit from a given interface:</p>
<pre><code>var myTypes = new List<Type>();
var assembly = Assembly.Load("MyProject.... | [
{
"answer_id": 306096,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 6,
"selected": true,
"text": "<p>As per Jon's reply, it would be helpful to know what's in <code>LoaderExceptions</code>. In lieu of this information... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29662/"
] | I'm trying to understand the differences between Assembly.Load and Assembly.ReflectionOnlyLoad.
In the code below I am attempting to find all of the objects in a given assembly that inherit from a given interface:
```
var myTypes = new List<Type>();
var assembly = Assembly.Load("MyProject.Components");
foreach (var... | As per Jon's reply, it would be helpful to know what's in `LoaderExceptions`. In lieu of this information, I think I can hazard a guess. From [MSDN](http://msdn.microsoft.com/en-us/library/ms172331(VS.80).aspx):
>
> If the assembly has dependencies, the
> ReflectionOnlyLoad method does not
> load them. If you need ... |
305,837 | <p>Hey all. We're sending quite a few emails (around 23k) using IIS6 SMTP service and receive about 7-8 error messages each time. The stack trace is:</p>
<pre><code>System.Net.Mail.SmtpException: Exceeded storage allocation. The server response was: 4.3.1 Session size exceeds fixed maximum session size
at System.... | [
{
"answer_id": 422521,
"author": "LarryF",
"author_id": 18518,
"author_profile": "https://Stackoverflow.com/users/18518",
"pm_score": 4,
"selected": true,
"text": "<p>Jim, this seems like it's running out of disk space storing all the temp queue files to be sent out. Which is why you on... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3085/"
] | Hey all. We're sending quite a few emails (around 23k) using IIS6 SMTP service and receive about 7-8 error messages each time. The stack trace is:
```
System.Net.Mail.SmtpException: Exceeded storage allocation. The server response was: 4.3.1 Session size exceeds fixed maximum session size
at System.Net.Mail.DataSto... | Jim, this seems like it's running out of disk space storing all the temp queue files to be sent out. Which is why you only see the error a couple times. As it sends the messages, I'm sure it cleans up the temp files, making room for more. Keep in mind that you can send emails MANY, MANY times faster than the SMTP serve... |
305,849 | <p>I usually, almost without thinking anymore, use forward declarations so that I won't have to include headers. Something along this example:</p>
<pre><code>//-----------------------
// foo.h
//-----------------------
class foo
{
foo();
~foo();
};
//-----------------------
// bar.h
//-----------------------
... | [
{
"answer_id": 305862,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "<p>If you are able to use a reference, you can retain the same use syntax. However, your reference has to be initialised str... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] | I usually, almost without thinking anymore, use forward declarations so that I won't have to include headers. Something along this example:
```
//-----------------------
// foo.h
//-----------------------
class foo
{
foo();
~foo();
};
//-----------------------
// bar.h
//-----------------------
class foo; // f... | Just use a smart pointer - you can even use auto\_ptr in this case.
```
//-----------------------
// bar.h
//-----------------------
#include <memory>
class foo; // Not enough given the way we declare "foo_object"..
class bar
{
public:
bar();
~bar();
foo &foo_object() { return *foo_ptr; }
const fo... |
305,856 | <p>I have a project where multiple developers are using a copy of the same windows Virtual PC image (W2K3 SE SP2). Because our solution is tied to the machine-name (less than ideal, i know) all of the developers have the same machine name.</p>
<p>We use a VPN to connect to a remote system, upon connection we get the ... | [
{
"answer_id": 305862,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "<p>If you are able to use a reference, you can retain the same use syntax. However, your reference has to be initialised str... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30809/"
] | I have a project where multiple developers are using a copy of the same windows Virtual PC image (W2K3 SE SP2). Because our solution is tied to the machine-name (less than ideal, i know) all of the developers have the same machine name.
We use a VPN to connect to a remote system, upon connection we get the "Windows Er... | Just use a smart pointer - you can even use auto\_ptr in this case.
```
//-----------------------
// bar.h
//-----------------------
#include <memory>
class foo; // Not enough given the way we declare "foo_object"..
class bar
{
public:
bar();
~bar();
foo &foo_object() { return *foo_ptr; }
const fo... |
305,860 | <p>What do you think is the best way to implement an interactive grid similar to a Sudoku board for a native iPhone application? I did not see an object to fill this need in the SDK.</p>
<p>Should I make a custom control for an individual cell, then initialize as many of them as I need in a grid form?</p>
<p><a href... | [
{
"answer_id": 305999,
"author": "wisequark",
"author_id": 33159,
"author_profile": "https://Stackoverflow.com/users/33159",
"pm_score": 0,
"selected": false,
"text": "<p>The grid is a means of viewing contents, not of storing the representation. Ultimately, your grid is made of cells w... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39365/"
] | What do you think is the best way to implement an interactive grid similar to a Sudoku board for a native iPhone application? I did not see an object to fill this need in the SDK.
Should I make a custom control for an individual cell, then initialize as many of them as I need in a grid form?
[;
</code></pre>
... | [
{
"answer_id": 305877,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 3,
"selected": false,
"text": "<p>The service is probably running under a different account and is not getting the same environment variables.</p>\n"
},
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39373/"
] | I am attempting to write a Windows Service in C#. I need to find the path to a certain file, which is stored in an environment variable. In a regular C# console application, I can achieve that with the following line:
```
string t = System.Environment.GetEnvironmentVariable("TIP_HOME");
```
If I write that to the co... | I've no idea if this is useful, but I've found that for every service, there is an option to add environment variables directly to a service.
It is done via the registry.
Say the key to your service is ...
HKLM\SYSTEM\CurrentControlSet\Services\YourService
Create a REG\_MULTI\_SZ called Environment.
Now you can ad... |
305,880 | <p>I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example....</p>
<pre><code>@Entity
@Table(name="widget")
public class Widget {
private Integer id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)... | [
{
"answer_id": 305902,
"author": "Jonathan",
"author_id": 28209,
"author_profile": "https://Stackoverflow.com/users/28209",
"pm_score": 0,
"selected": false,
"text": "<p>Does it work if you do the following:</p>\n\n<pre><code>@Entity\n@Table(name=\"widget\")\npublic class Widget {\n @... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39374/"
] | I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example....
```
@Entity
@Table(name="widget")
public class Widget {
private Integer id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Integer ... | From a performance and design perspective, using annotations on getters is a better idea than member variables, because the getter setters are called using reflection if placed on the field, than a method. Also if you plan to use validation and other features of hibernate, you'll have all the annotations at one place, ... |
305,886 | <p>For a new project I have to import the pre-existing data from MySql.</p>
<p>In <a href="http://www.connectionstrings.com/?carrier=mysql" rel="noreferrer">this site</a> I have found many options, some including the installation of drivers. What is the fastest & easiest way to do it?</p>
<p>Update: this would be... | [
{
"answer_id": 305984,
"author": "Adam",
"author_id": 13320,
"author_profile": "https://Stackoverflow.com/users/13320",
"pm_score": 0,
"selected": false,
"text": "<p>If you have access to phpMyAdmin you could run an export of the entire database. It will generate a long list of SQL comma... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] | For a new project I have to import the pre-existing data from MySql.
In [this site](http://www.connectionstrings.com/?carrier=mysql) I have found many options, some including the installation of drivers. What is the fastest & easiest way to do it?
Update: this would be just a one time import | ```
-- Create Link Server
EXEC master.dbo.sp_addlinkedserver
@server = N'MYSQL',
@srvproduct=N'MySQL',
@provider=N'MSDASQL',
@provstr=N'DRIVER={MySQL ODBC 5.1 Driver}; SERVER=localhost; _
DATABASE=tigerdb; USER=root; PASSWORD=hejsan; OPTION=3'
-- Import Data
SELECT * INTO testMySQL.dbo.shoutbox
FROM openque... |
305,894 | <p>I am trying to update an old JavaScript function used to detect support for AJAX (i.e. the XmlHttpRequest object). I've looked online (including SO) and found various solutions but I'm not sure which is the most efficient for simply detecting support.</p>
<p>The current function is:</p>
<pre><code> function IsS... | [
{
"answer_id": 305916,
"author": "Phillip B Oldham",
"author_id": 30478,
"author_profile": "https://Stackoverflow.com/users/30478",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Don't!</strong></p>\n\n<p>Or rather, don't waste time doing what many other people have done better.</... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12124/"
] | I am trying to update an old JavaScript function used to detect support for AJAX (i.e. the XmlHttpRequest object). I've looked online (including SO) and found various solutions but I'm not sure which is the most efficient for simply detecting support.
The current function is:
```
function IsSyncAJAXSupported()
... | I've come up with this:
```
var xhr = null;
try { xhr = new XMLHttpRequest(); } catch (e) {}
try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
return (xhr!=null);
```
It seems to work so thought I'd share it. |
305,905 | <p>What's the best way to kill a process and all its child processes from a Perl script? It should run at least under Linux and Solaris, and not require installation of any additional packages.</p>
<p>My guess would be to get a list of all processes and their parents by parsing files in /proc or by parsing the output ... | [
{
"answer_id": 305919,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "<p>If you can live with killing a process group, you can use the following:</p>\n\n<pre><code>kill -$signum, $pgid;\n</code>... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2148773/"
] | What's the best way to kill a process and all its child processes from a Perl script? It should run at least under Linux and Solaris, and not require installation of any additional packages.
My guess would be to get a list of all processes and their parents by parsing files in /proc or by parsing the output of `ps` (n... | If you can live with killing a process group, you can use the following:
```
kill -$signum, $pgid;
```
where `$signum` is the signal number, and `$pgid` is the process group ID. However, signal numbers aren't very portable, in which case you can (on some platforms; read `perlfunc` for explanation) do the following (... |
305,911 | <p>Lets say you have a property like:</p>
<pre><code>Person person1;
public Person Captin{
get{
return person1;
}
set{
person1 = value;
}
}
public void SomeFunction(){
Captin.name = "Hook"
}
</code></pre>
<p>In this case if you set the name on the property we know that the new n... | [
{
"answer_id": 305942,
"author": "JSC",
"author_id": 37311,
"author_profile": "https://Stackoverflow.com/users/37311",
"pm_score": 2,
"selected": false,
"text": "<p>Each time you access your property Captin it will read from disk. But if you change the property 'name' it will not write t... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | Lets say you have a property like:
```
Person person1;
public Person Captin{
get{
return person1;
}
set{
person1 = value;
}
}
public void SomeFunction(){
Captin.name = "Hook"
}
```
In this case if you set the name on the property we know that the new name of Hook will get applie... | Each time you access your property Captin it will read from disk. But if you change the property 'name' it will not write to disk. It will only write to disk if you do something like
```
public void SomeFunction() {
Person p = Captin;
p.name = "Hook";
Captin = p;
}
``` |
305,924 | <p>I have a function that takes another function as a parameter. If the function is a member of a class, I need to find the name of that class. E.g.</p>
<pre><code>def analyser(testFunc):
print testFunc.__name__, 'belongs to the class, ...
</code></pre>
<p>I thought </p>
<pre><code>testFunc.__class__
</code></... | [
{
"answer_id": 305948,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "<p>I'm not a Python expert, but does this work?</p>\n\n<pre><code>testFunc.__self__.__class__\n</code></pre>\n\n<p>It seems ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] | I have a function that takes another function as a parameter. If the function is a member of a class, I need to find the name of that class. E.g.
```
def analyser(testFunc):
print testFunc.__name__, 'belongs to the class, ...
```
I thought
```
testFunc.__class__
```
would solve my problems, but that just te... | ```
testFunc.im_class
```
<https://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy>
>
> `im_class` is the class of `im_self` for
> bound methods or the class that asked
> for the method for unbound methods
>
>
> |
305,946 | <p>I'm working on a localized application which I develop in SharpDevelop. Based on a <a href="http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=211" rel="nofollow noreferrer">tutorial</a> I ran into an error:</p>
<blockquote>
<p>Could not find any resources appropriate for the specified culture (or... | [
{
"answer_id": 305995,
"author": "Glenn",
"author_id": 25191,
"author_profile": "https://Stackoverflow.com/users/25191",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure what version of .NET you are using but this MSDN article on <a href=\"http://msdn.microsoft.com/en-us/librar... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33429/"
] | I'm working on a localized application which I develop in SharpDevelop. Based on a [tutorial](http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=211) I ran into an error:
>
> Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName:
>
>
>
I cre... | CreateFileBasedResourceManager will only deal with binary .resources files (not .resx files).
If you insist on loading resources from external file rather than embed the resources into the assembly,
you will need to run the resgen command line utility to generate a .resources file.
So if you haven't done that, generat... |
305,989 | <p>We are using SSRS 2005 SP1 and the lastest Reportviewer controls.<br>
We are having situations where certain reporting infrastructure exceptions are not being exposed to any of the exception handling routines.</p>
<p>A specific example is when the SQL Server Reporting Services Windows service was unexpectantly stop... | [
{
"answer_id": 312157,
"author": "Bob Albright",
"author_id": 15050,
"author_profile": "https://Stackoverflow.com/users/15050",
"pm_score": 0,
"selected": false,
"text": "<p>I saw something similar to this in reporting services 2008 where I was trying to catch certain types of exceptions... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27714/"
] | We are using SSRS 2005 SP1 and the lastest Reportviewer controls.
We are having situations where certain reporting infrastructure exceptions are not being exposed to any of the exception handling routines.
A specific example is when the SQL Server Reporting Services Windows service was unexpectantly stopped due to ... | Thanks for your response Bob. It's surprising and a disappointment that SSRS is eating those exceptions. We will probably stay away from hacking the dll and try to figure out a way to monitor and alert from the SSRS internal logs. |
305,994 | <p>I searched all over this site and the web for a good and <strong>simple</strong> example of autocomplete using jQuery and ASP.NET. I wanted to expose the data used by autocomplete with a webservice (and will probably do that next). In the meantime, I got this working, but it seems a little hacky...</p>
<p>In my pag... | [
{
"answer_id": 306037,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 6,
"selected": true,
"text": "<p>I just recently implemented autocomplete, and it looks fairly similar. I'm using an ashx (Generic Handler) instead of the ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/305994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38787/"
] | I searched all over this site and the web for a good and **simple** example of autocomplete using jQuery and ASP.NET. I wanted to expose the data used by autocomplete with a webservice (and will probably do that next). In the meantime, I got this working, but it seems a little hacky...
In my page I have a text box:
`... | I just recently implemented autocomplete, and it looks fairly similar. I'm using an ashx (Generic Handler) instead of the aspx, but it's basically the same code in the code behind.
Using the ashx, it'll look something like this:
```
<script type="text/javascript">
$(document).ready(function(){
$("#txtSearch")... |
306,012 | <p>There is an actual running Java ServerPages (JSP) application within a *NIX box which I somewhat administer with kind of good permissions. The idea is to create a new but dead simple JSP page to control some Korn Shell scripts I've got running there. So the goal is to make some sort of HTML form that will be writing... | [
{
"answer_id": 306082,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 1,
"selected": false,
"text": "<p>Possibly <a href=\"http://commons.apache.org/io/api-release/org/apache/commons/io/FileUtils.html#touch(java.io.File)\" re... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] | There is an actual running Java ServerPages (JSP) application within a \*NIX box which I somewhat administer with kind of good permissions. The idea is to create a new but dead simple JSP page to control some Korn Shell scripts I've got running there. So the goal is to make some sort of HTML form that will be writing s... | You may have security issues here. Consider what risks you have and take appropriate steps to authenticate users and ensure they are authorized for this operation. The steps necessary for this depend to some extent on the servlet container you are using.
You don't need a library like Apache Commons IO for a such simpl... |
306,013 | <p>My form does not go to recipient when submitted! I changed the file mail.tpl.txt to direct to my own email address as a test and I got the email just fine.</p>
<p>Client has checked junk mail folder as well and he is just not getting information.</p>
<p>Below is the form code, followed by the code from mail.tpl.tx... | [
{
"answer_id": 306029,
"author": "Sebastian Hoitz",
"author_id": 9535,
"author_profile": "https://Stackoverflow.com/users/9535",
"pm_score": 3,
"selected": true,
"text": "<p>Your sending a plain text email right now - you should correct the header content type of that email.</p>\n\n<p>Ju... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30043/"
] | My form does not go to recipient when submitted! I changed the file mail.tpl.txt to direct to my own email address as a test and I got the email just fine.
Client has checked junk mail folder as well and he is just not getting information.
Below is the form code, followed by the code from mail.tpl.txt and then the fo... | Your sending a plain text email right now - you should correct the header content type of that email.
Just set it to text/html. There might be more information here:
* <http://www.ietf.org/rfc/rfc2387.txt>
* <http://www.faqs.org/rfcs/rfc2822>
Or google for it, there are plenty of sources out there! |
306,017 | <p>I realize that far is compiler specific, but my expectation is that the placement of the far specifier should make sense to those who really understand pointers.</p>
<p>So, I have two applications that share the processor's entire memory space.</p>
<p>App A needs to call function foo that exists in app B.</p>
<p>... | [
{
"answer_id": 306067,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 3,
"selected": false,
"text": "<p>The <code>__far</code> keyword, at least in the MS world, was used when creating binaries that used segmented memory. You n... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] | I realize that far is compiler specific, but my expectation is that the placement of the far specifier should make sense to those who really understand pointers.
So, I have two applications that share the processor's entire memory space.
App A needs to call function foo that exists in app B.
I know the memory locati... | *Is the \_\_far in the right spot in the typedef?*
[Edit, in response to ChrisN's comment -- thanks]
This is a compiler-dependent feature, since it is not part of ANSI C. According to the compiler manual <[<http://www.freescale.com/files/soft_dev_tools/doc/ref_manual/CW_Compiler_HC12_RM.pdf>](http://www.freescale.com... |
306,062 | <p>I need a CSS selector that can find the 2nd div of 2 that has the same class. I've looked at <code>nth-child()</code> but it's not what I want since I can't see a way to further clarify what class I want. These 2 divs will be siblings in the document if that helps.</p>
<p>My HTML looks something like this:</p>
<pr... | [
{
"answer_id": 306087,
"author": "geocar",
"author_id": 37507,
"author_profile": "https://Stackoverflow.com/users/37507",
"pm_score": 6,
"selected": false,
"text": "<p>Selectors can be combined:</p>\n\n<pre><code>.bar:nth-child(2)\n</code></pre>\n\n<p>means \"thing that has class <em>bar... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12094/"
] | I need a CSS selector that can find the 2nd div of 2 that has the same class. I've looked at `nth-child()` but it's not what I want since I can't see a way to further clarify what class I want. These 2 divs will be siblings in the document if that helps.
My HTML looks something like this:
```
<div class="foo">...</di... | **UPDATE**: This answer was originally written in 2008 when `nth-of-type` support was unreliable at best. Today I'd say you could safely use something like `.bar:nth-of-type(2)`, unless you have to support IE8 and older.
---
*Original answer from 2008 follows (Note that I would not recommend this anymore!)*:
If you... |
306,080 | <p>After following the advice in <a href="https://stackoverflow.com/questions/302560/wix-custom-actions-with-wixuiminimal">this question</a> successfully, I added a couple additional lines of code for another custom action. This one is intended to call regsvr32 on the copy of capicom which I've tried to put in the use... | [
{
"answer_id": 306219,
"author": "Rob Mensching",
"author_id": 23852,
"author_profile": "https://Stackoverflow.com/users/23852",
"pm_score": 1,
"selected": false,
"text": "<p>Uhh, are you really trying to install a Windows system file yourself? That's not allowed on a great many levels.... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192/"
] | After following the advice in [this question](https://stackoverflow.com/questions/302560/wix-custom-actions-with-wixuiminimal) successfully, I added a couple additional lines of code for another custom action. This one is intended to call regsvr32 on the copy of capicom which I've tried to put in the user's system fold... | The Right way:
* c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\Deployment\regcap.exe" /O capicom.reg capicom.dll
* Run program from Adam Tengen's [post here](https://stackoverflow.com/questions/269423/how-to-generate-wix-xml-from-a-reg-file).
Note that Heat (and Tallow, IIRC) do not, as of this pos... |
306,097 | <p>We determined in a <a href="https://stackoverflow.com/questions/303810/variable-dynamic-option-lists-in-html-select-using-ie">previous question</a> that many features of HTML SELECTs are not supported in IE. Is there an alternative widget that you would recommend from your experience that meets the following requir... | [
{
"answer_id": 306125,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "<p>At last check IE6+ does support #3 and #5, and you can (mis)use OPTGROUP to work around most of the other items.</p>... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26671/"
] | We determined in a [previous question](https://stackoverflow.com/questions/303810/variable-dynamic-option-lists-in-html-select-using-ie) that many features of HTML SELECTs are not supported in IE. Is there an alternative widget that you would recommend from your experience that meets the following requirements?
1. Res... | At last check IE6+ does support #3 and #5, and you can (mis)use OPTGROUP to work around most of the other items.
You can do this by having an optgroup with no options inside it, like this:
```
<optgroup label="--"></optgroup>
```
You can make the label anything you want, but the point is that you'll end up with an ... |
306,130 | <p>I am trying to write a decorator to do logging:</p>
<pre><code>def logger(myFunc):
def new(*args, **keyargs):
print 'Entering %s.%s' % (myFunc.im_class.__name__, myFunc.__name__)
return myFunc(*args, **keyargs)
return new
class C(object):
@logger
def f():
pass
C().f()
</co... | [
{
"answer_id": 306196,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 3,
"selected": false,
"text": "<p>It seems that while the class is being created, Python creates regular function objects. They only get turned into unbo... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11677/"
] | I am trying to write a decorator to do logging:
```
def logger(myFunc):
def new(*args, **keyargs):
print 'Entering %s.%s' % (myFunc.im_class.__name__, myFunc.__name__)
return myFunc(*args, **keyargs)
return new
class C(object):
@logger
def f():
pass
C().f()
```
I would like... | Claudiu's answer is correct, but you can also cheat by getting the class name off of the `self` argument. This will give misleading log statements in cases of inheritance, but will tell you the class of the object whose method is being called. For example:
```
from functools import wraps # use this to preserve functi... |
306,136 | <p>I know I could do this with closures (<code>var self = this</code>) if object was a function:</p>
<pre><code><a href="#" id="x">click here</a>
<script type="text/javascript">
var object = {
y : 1,
handle_click : function (e) {
alert('h... | [
{
"answer_id": 306151,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "<p>So, the event handler part wires up just fine (I tested it myself) but, as your comment indicates, you have no acce... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know I could do this with closures (`var self = this`) if object was a function:
```
<a href="#" id="x">click here</a>
<script type="text/javascript">
var object = {
y : 1,
handle_click : function (e) {
alert('handling click');
//want to access y here
retur... | So, the event handler part wires up just fine (I tested it myself) but, as your comment indicates, you have no access to the "y" property of the object you just defined.
This works:
```
var object = {
y : 1,
handle_click : function (e) {
alert('handling click');
//want to access y here
alert(this.... |
306,139 | <p>I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using <code>#!/usr/bin/env groovy</code> at the top of my script. </p>
| [
{
"answer_id": 306168,
"author": "Eric Wendelin",
"author_id": 25066,
"author_profile": "https://Stackoverflow.com/users/25066",
"pm_score": 6,
"selected": true,
"text": "<p>If you really have to you can also load a JAR at runtime with:</p>\n\n<pre><code>this.getClass().classLoader.rootL... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481/"
] | I have a groovy script that needs a library in a jar. How do I add that to the classpath? I want the script to be executable so I'm using `#!/usr/bin/env groovy` at the top of my script. | If you really have to you can also load a JAR at runtime with:
```
this.getClass().classLoader.rootLoader.addURL(new File("file.jar").toURL())
``` |
306,144 | <p>I am having trouble deleting orphan nodes using JPA with the following mapping</p>
<pre><code>@OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner")
private List<Bikes> bikes;
</code></pre>
<p>I am having the issue of the orphaned roles hanging around the database.</p>
<p>I can ... | [
{
"answer_id": 306161,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "<p>According to <a href=\"http://manning.com/bauer2/\" rel=\"nofollow noreferrer\">Java Persistence with Hibernate</a>, <em>... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3050/"
] | I am having trouble deleting orphan nodes using JPA with the following mapping
```
@OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner")
private List<Bikes> bikes;
```
I am having the issue of the orphaned roles hanging around the database.
I can use the annotation `org.hibernate.annot... | If you are using it with Hibernate, you'll have to explicitly define the annotation `CascadeType.DELETE_ORPHAN`, which can be used in conjunction with JPA `CascadeType.ALL`.
If you don't plan to use Hibernate, you'll have to explicitly first delete the child elements and then delete the main record to avoid any orpha... |
306,176 | <p>I am following a VB tutorial to do some <a href="http://blogs.msdn.com/bethmassi/archive/2008/04/25/querying-html-with-linq-to-xml.aspx" rel="nofollow noreferrer">HTML manipulation using LINQ</a> </p>
<p>It has the following construct</p>
<pre><code>Imports <xmlns="http://www.w3.org/1999/xhtml">
</code></pre... | [
{
"answer_id": 306216,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 3,
"selected": true,
"text": "<p>VB.Net has a feature called <code>XML Literals</code> that is not present in C#. This import statement adds a names... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5552/"
] | I am following a VB tutorial to do some [HTML manipulation using LINQ](http://blogs.msdn.com/bethmassi/archive/2008/04/25/querying-html-with-linq-to-xml.aspx)
It has the following construct
```
Imports <xmlns="http://www.w3.org/1999/xhtml">
```
How do I do the same in C#?
There appears to be something called an X... | VB.Net has a feature called `XML Literals` that is not present in C#. This import statement adds a namespace for use with those literals.
In researching this information, I found this link helpful:
<http://blogs.msdn.com/bethmassi/archive/2007/10/30/quickly-import-and-export-excel-data-with-linq-to-xml.aspx>
It'... |
306,191 | <p>I have a list of error codes I need to reference, kinda like this:</p>
<pre><code>Code / Error Message
A01 = whatever error
U01 = another error
U02 = yet another error type
</code></pre>
<p>I get the Code returned to me via a web service call and I need to display or get the readable error. So I need a func... | [
{
"answer_id": 306201,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "<p>Use a Dictionary, (in C#, but the concept and classes are the same):</p>\n\n<pre><code>// Initialize this once, and store ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] | I have a list of error codes I need to reference, kinda like this:
```
Code / Error Message
A01 = whatever error
U01 = another error
U02 = yet another error type
```
I get the Code returned to me via a web service call and I need to display or get the readable error. So I need a function when passed a Code tha... | Use a Dictionary, (in C#, but the concept and classes are the same):
```
// Initialize this once, and store it in the ASP.NET Cache.
Dictionary<String,String> errorCodes = new Dictionary<String,String>();
errorCodes.Add("A01", "Whatever Error");
errorCodes.Add("U01", "Another Error");
// And to get your error code:
... |
306,202 | <p>OK so I'm looking a some code which looks roughly like this:</p>
<pre><code>void DoSomething(object o)
{
if (o is Sometype1) {
//cast o to Sometype and do something to it
}
else if (o is Sometype2) {
//cast o to Sometype2 and do something to it
}
...
else if (o is SometypeN) {
/... | [
{
"answer_id": 306231,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you might be using C#. I believe that you can create \"extension methods\" that attach to already es... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2086/"
] | OK so I'm looking a some code which looks roughly like this:
```
void DoSomething(object o)
{
if (o is Sometype1) {
//cast o to Sometype and do something to it
}
else if (o is Sometype2) {
//cast o to Sometype2 and do something to it
}
...
else if (o is SometypeN) {
//cast o to Som... | any time you see a switch statement (or a series of if-statements) that are checking the type of an object, this is a Big Red Flag for a missing base class or interface. In other words, the code should be relying on polymorphism, not testing the object type
if you cannot change the base class or implement an interface... |
306,233 | <p>I have several deployment projects. In order to deploy an application, I need to do several tasks, one of them is to change each deployment project's product version and product code.</p>
<p>I can't find a way to programmatically change them.</p>
<p>Since it's a Deployment project (which finally produces an execut... | [
{
"answer_id": 306239,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 0,
"selected": false,
"text": "<p>You could use the msbuild task to update you product version. Check out <a href=\"http://blogs.msdn.com/msbuild/arc... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30339/"
] | I have several deployment projects. In order to deploy an application, I need to do several tasks, one of them is to change each deployment project's product version and product code.
I can't find a way to programmatically change them.
Since it's a Deployment project (which finally produces an executable installer), ... | I was searching for the exact same thing today. I found this using google:
```
static void Main(string[] args)
{
string setupFileName = @"<Replace the path to vdproj file>";
StreamReader reader = File.OpenText(setupFileName);
string file = string.Empty;
try
{
Regex expression = new R... |
306,252 | <p>This is one of the minor CSS problems that plague me constantly.</p>
<p>How do folks around Stack Overflow vertically align <em><strong><code>checkboxes</code></strong></em> and their <em><strong><code>labels</code></strong></em> consistently <strong>cross-browser</strong>?</p>
<p>Whenever I align them correctly in ... | [
{
"answer_id": 306266,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": 7,
"selected": false,
"text": "<p>try <code>vertical-align: middle</code></p>\n\n<p>also your code seems like it should be:\n<div class=\"snippet\... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38666/"
] | This is one of the minor CSS problems that plague me constantly.
How do folks around Stack Overflow vertically align ***`checkboxes`*** and their ***`labels`*** consistently **cross-browser**?
Whenever I align them correctly in Safari (usually using `vertical-align: baseline` on the `input`), they're completely off i... | Warning! This answer is ***too old*** and ***doesn't work*** on modern browsers.
================================================================================
I'm not the poster of this answer, but at the time of writing this, this is the most voted answer by far in both positive and negative votes (+1035 -17), and... |
306,272 | <p>Say I have a class with a private dispatch table. </p>
<pre><code>$this->dispatch = array(
1 => $this->someFunction,
2 => $this->anotherFunction
);
</code></pre>
<p>If I then call </p>
<pre><code>$this->dispatch[1]();
</code></pre>
<p>I get an error that the method is not a string. When... | [
{
"answer_id": 306302,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 4,
"selected": true,
"text": "<p>You can store the name of the method in dispatch like:</p>\n\n<pre><code>$this->dispatch = array('somemethod', '... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1797/"
] | Say I have a class with a private dispatch table.
```
$this->dispatch = array(
1 => $this->someFunction,
2 => $this->anotherFunction
);
```
If I then call
```
$this->dispatch[1]();
```
I get an error that the method is not a string. When I make it a string like this:
```
$this->dispatch = array(
1... | You can store the name of the method in dispatch like:
```
$this->dispatch = array('somemethod', 'anothermethod');
```
and then use:
```
$method = $this->dispatch[1];
$this->$method();
``` |
306,284 | <p>So, I have a pair of typeclasses that I'll be using a lot together, and I want to avoid specifying both each time. Basically, instead of putting</p>
<pre><code>:: (Ord a, Fractional a, Ord b, Fractional b, ... Ord z, Fractional z) =>
</code></pre>
<p>at the beginning of all my type specifications, I'd rather p... | [
{
"answer_id": 307017,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 4,
"selected": false,
"text": "<p>What you want is a class alias. There is a proposal to add it to Haskell at <a href=\"http://repetae.net/recent/out/clas... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9859/"
] | So, I have a pair of typeclasses that I'll be using a lot together, and I want to avoid specifying both each time. Basically, instead of putting
```
:: (Ord a, Fractional a, Ord b, Fractional b, ... Ord z, Fractional z) =>
```
at the beginning of all my type specifications, I'd rather put
```
:: (OrdFractional a, O... | With the ConstraintKinds extension introduced in GHC 7.4, constraints are now types of kind `Constraint`, so you can use ordinary type synonyms to get what you want:
```
{-# LANGUAGE ConstraintKinds #-}
type OrdFractional a = (Ord a, Fractional a)
``` |
306,288 | <p>I've been trying to create a custom control that works exactly like the Panel control except surrounded by a few divs and such to create a rounded box look. I haven't been able to find a decent example of how to do this. </p>
<p>I need to be able to place text and controls inside the control and access it directly ... | [
{
"answer_id": 306299,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 5,
"selected": true,
"text": "<p>There are two ways to do this. One is to implement <code>INamingContainer</code> on your control, and it takes a lot of ef... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] | I've been trying to create a custom control that works exactly like the Panel control except surrounded by a few divs and such to create a rounded box look. I haven't been able to find a decent example of how to do this.
I need to be able to place text and controls inside the control and access it directly without re... | There are two ways to do this. One is to implement `INamingContainer` on your control, and it takes a lot of effort.
The other way is to inherit from Panel, and override the RenderBeginTag and RenderEndTag methods to add your custom markup. This is easy.
```
public class RoundedCornersPanel : System.Web.UI.WebControl... |
306,305 | <p>I am trying to do positioning in JavaScript. I am using a cumulative position function based on the <a href="http://www.quirksmode.org/js/findpos.html" rel="noreferrer" title="Find position">classic quirksmode function</a> that sums <code>offsetTop</code> and <code>offsetLeft</code> for each <code>offsetParent</cod... | [
{
"answer_id": 306415,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 5,
"selected": true,
"text": "<p>If the document hasn't finished loading then offsetParent can be null</p>\n"
},
{
"answer_id": 2725814,
"author... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3078/"
] | I am trying to do positioning in JavaScript. I am using a cumulative position function based on the [classic quirksmode function](http://www.quirksmode.org/js/findpos.html "Find position") that sums `offsetTop` and `offsetLeft` for each `offsetParent` until the top node.
However, I am running into an issue where the e... | If the document hasn't finished loading then offsetParent can be null |
306,313 | <p>Why does the following behave unexpectedly in Python?</p>
<pre><code>>>> a = 256
>>> b = 256
>>> a is b
True # This is an expected result
>>> a = 257
>>> b = 257
>>> a is b
False # What happened here? Why is this False?
>>> 257 is 257... | [
{
"answer_id": 306347,
"author": "Amit",
"author_id": 29120,
"author_profile": "https://Stackoverflow.com/users/29120",
"pm_score": 4,
"selected": false,
"text": "<p>I think your hypotheses is correct. Experiment with <code>id</code> (identity of object):</p>\n\n<pre><code>In [1]: id(255... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] | Why does the following behave unexpectedly in Python?
```
>>> a = 256
>>> b = 256
>>> a is b
True # This is an expected result
>>> a = 257
>>> b = 257
>>> a is b
False # What happened here? Why is this False?
>>> 257 is 257
True # Yet the literal numbers compare properly
```
I am using P... | Take a look at this:
```
>>> a = 256
>>> b = 256
>>> id(a)
9987148
>>> id(b)
9987148
>>> a = 257
>>> b = 257
>>> id(a)
11662816
>>> id(b)
11662828
```
Here's what I found in the documentation for ["Plain Integer Objects"](https://docs.python.org/3/c-api/long.html#c.PyLong_FromLong):
>
> The current implementation ... |
306,316 | <p>I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges will have slopes of 0 or infinity.</p>
<p>I've tried to implement w... | [
{
"answer_id": 306332,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 11,
"selected": true,
"text": "<pre><code>if (RectA.Left < RectB.Right && RectA.Right > RectB.Left &&\n RectA.Top > ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/135/"
] | I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel to the x and the y axis, that is all of their edges will have slopes of 0 or infinity.
I've tried to implement what is men... | ```
if (RectA.Left < RectB.Right && RectA.Right > RectB.Left &&
RectA.Top > RectB.Bottom && RectA.Bottom < RectB.Top )
```
or, using Cartesian coordinates
(With X1 being left coord, X2 being right coord, **increasing from left to right** and Y1 being Top coord, and Y2 being Bottom coord, **increasing from bot... |
306,381 | <p>How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I'd prefer not to create a separate project for it or compile it as a DLL</p>
| [
{
"answer_id": 306388,
"author": "Bruno Shine",
"author_id": 28294,
"author_profile": "https://Stackoverflow.com/users/28294",
"pm_score": 1,
"selected": false,
"text": "<p>Create the class for the control and build the solution. If everything goes well the control should now be availabl... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18234/"
] | How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I'd prefer not to create a separate project for it or compile it as a DLL | Server controls should be compiled into a DLL. There should be no reason to be afraid of having an additional assembly in your project, and it helps create good project organization.
ASP.NET Server controls are actually custom classes in an assembly. They do not have an "ascx" markup file associated to them.
To use a... |
306,387 | <p>Delegates look like such a powerful language feature, but I've yet to find an opportunity to use them in anger (apart from in DALs I must say).</p>
<p>How often do you use them, and under what circumstances do you find them most useful? </p>
| [
{
"answer_id": 306391,
"author": "Michiel Overeem",
"author_id": 5043,
"author_profile": "https://Stackoverflow.com/users/5043",
"pm_score": 0,
"selected": false,
"text": "<p>I use them the most for callbacks. Instead of objects for callback methods (using interfaces), I can wrap a metho... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] | Delegates look like such a powerful language feature, but I've yet to find an opportunity to use them in anger (apart from in DALs I must say).
How often do you use them, and under what circumstances do you find them most useful? | Funcs and Actions are newish "types" of delegates and I use them a lot with Linq and really other odd situations. For Linq they are nice because personally I'd rather have a descriptive name than a lambda expression:
```
someList.Select(item => item.Name);
```
Where with a Func I can:
```
Func<Item, String> itemNam... |
306,400 | <p>How do I retrieve an item at random from the following list?</p>
<pre><code>foo = ['a', 'b', 'c', 'd', 'e']
</code></pre>
| [
{
"answer_id": 306417,
"author": "Pēteris Caune",
"author_id": 5821,
"author_profile": "https://Stackoverflow.com/users/5821",
"pm_score": 13,
"selected": true,
"text": "<p>Use <a href=\"https://docs.python.org/library/random.html#random.choice\" rel=\"noreferrer\"><code>random.choice()<... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | How do I retrieve an item at random from the following list?
```
foo = ['a', 'b', 'c', 'd', 'e']
``` | Use [`random.choice()`](https://docs.python.org/library/random.html#random.choice):
```
import random
foo = ['a', 'b', 'c', 'd', 'e']
print(random.choice(foo))
```
For [cryptographically secure](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) random choices (e.g., for generatin... |
306,410 | <p>I have a following object model:</p>
<pre>
- Book
-- Chapter 1
--- Page 1
---- Image 1
---- Image 2
---- Text 1
--- Page 2
...
</pre>
<p>Resources are way down at the page level. But, I need to know the full path to resources, from the resources' point of view. </p>
<p>One way, is to have resources be aware of... | [
{
"answer_id": 306437,
"author": "Jonathan DeMarks",
"author_id": 39421,
"author_profile": "https://Stackoverflow.com/users/39421",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like you want a <a href=\"http://en.wikipedia.org/wiki/Doubly_linked_list#Doubly-linked_list\" rel=\"no... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38753/"
] | I have a following object model:
```
- Book
-- Chapter 1
--- Page 1
---- Image 1
---- Image 2
---- Text 1
--- Page 2
...
```
Resources are way down at the page level. But, I need to know the full path to resources, from the resources' point of view.
One way, is to have resources be aware of their parents.
So... | Whether or not you use Zachary's tree structure or you do it in a more type-specific way, the question about coupling lives on.
If there is a lot about an image that doesn't have anything to do with how the image is "hosted" in a page, you might want to use an intermediate type which has the context-dependent aspect ... |
306,439 | <p>I have this Trigger in Postgresql that I can't just get to work (does nothing). For understanding, there's how I defined it:</p>
<pre><code>CREATE TABLE documents (
...
modification_time timestamp with time zone DEFAULT now()
);
CREATE FUNCTION documents_update_mod_time() RETURNS trigger
AS $$
begin
... | [
{
"answer_id": 306509,
"author": "Kev",
"author_id": 16777,
"author_profile": "https://Stackoverflow.com/users/16777",
"pm_score": 2,
"selected": false,
"text": "<p>You can use 'raise notice' statements inside your trigger function to debug it. To debug the trigger not being called at a... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35189/"
] | I have this Trigger in Postgresql that I can't just get to work (does nothing). For understanding, there's how I defined it:
```
CREATE TABLE documents (
...
modification_time timestamp with time zone DEFAULT now()
);
CREATE FUNCTION documents_update_mod_time() RETURNS trigger
AS $$
begin
new.modifica... | 1. Use the following code within a trigger function, then watch the 'messages' tab in pgAdmin3 or the output in psql:
```
RAISE NOTICE 'myplpgsqlval is currently %', myplpgsqlval; -- either this
RAISE EXCEPTION 'failed'; -- or that
```
2. To see which triggers actually get called, how many times etc, the follo... |
306,443 | <p>In designing a fluid layout, how do you use borders without ruining the layout.</p>
<p>More specifically, I have a HTML widget which consists of five divs. I would like the five divs to take up all the room in the containing element. I would also like to have a 1px border around each.</p>
<p>I tried:
.box { floa... | [
{
"answer_id": 306472,
"author": "One Crayon",
"author_id": 38666,
"author_profile": "https://Stackoverflow.com/users/38666",
"pm_score": 2,
"selected": false,
"text": "<p>Only put <code>width: 100%</code> on the outermost div, and don't put a border on it. If you do this, then the inne... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In designing a fluid layout, how do you use borders without ruining the layout.
More specifically, I have a HTML widget which consists of five divs. I would like the five divs to take up all the room in the containing element. I would also like to have a 1px border around each.
I tried:
.box { float: left; height: 10... | See [this article](http://www.quirksmode.org/css/box.html).
Basically, in the "traditional" CSS box model, the width of a box element only specifies the width of the *content* of the box, excluding its border (and padding).
In CSS3, you can switch to a different box model as follows:
```
box-sizing: border-box;
```... |
306,452 | <p>Let's say I need to implement domain model for StackOverflow. </p>
<p>If I am doing ORM, how can I define (and map) property for fetching "last comments" and other "last" things?
It looks to me like this should be reflected in the domain model.</p>
<p>Sometimes I might need "all comments" though...</p>
| [
{
"answer_id": 306472,
"author": "One Crayon",
"author_id": 38666,
"author_profile": "https://Stackoverflow.com/users/38666",
"pm_score": 2,
"selected": false,
"text": "<p>Only put <code>width: 100%</code> on the outermost div, and don't put a border on it. If you do this, then the inne... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] | Let's say I need to implement domain model for StackOverflow.
If I am doing ORM, how can I define (and map) property for fetching "last comments" and other "last" things?
It looks to me like this should be reflected in the domain model.
Sometimes I might need "all comments" though... | See [this article](http://www.quirksmode.org/css/box.html).
Basically, in the "traditional" CSS box model, the width of a box element only specifies the width of the *content* of the box, excluding its border (and padding).
In CSS3, you can switch to a different box model as follows:
```
box-sizing: border-box;
```... |
306,462 | <p>I'm using <a href="http://www.codeproject.com/KB/cs/lotusnoteintegrator.aspx" rel="nofollow noreferrer">Interop.Domino.dll</a> to retrieve E-mails from a Lotus "Database" (Term used loosely). I'm having some difficulty in retrieving certain fields and wonder how to do this properly. I've been using <code>NotesDocume... | [
{
"answer_id": 306624,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 3,
"selected": true,
"text": "<p>Hah, got it!</p>\n\n<pre><code>Object[] ni = (Object[])nDoc.Items;\nstring names_values = \"\";\nfor (int x = 0; x < ni... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11112/"
] | I'm using [Interop.Domino.dll](http://www.codeproject.com/KB/cs/lotusnoteintegrator.aspx) to retrieve E-mails from a Lotus "Database" (Term used loosely). I'm having some difficulty in retrieving certain fields and wonder how to do this properly. I've been using `NotesDocument.GetFirstItem` to retrieve Subject, From an... | Hah, got it!
```
Object[] ni = (Object[])nDoc.Items;
string names_values = "";
for (int x = 0; x < ni.Length; x++)
{
NotesItem item = (NotesItem)ni[x];
if (!string.IsNullOrEmpty(item.Name)) names_values += x.ToString() + ": " + item.Name + "\t\t" + item.Text + "\r\n";
}
```
This returned a list of indices, names, an... |
306,463 | <p>Is there any performance gain using a CTE over a derived table?</p>
| [
{
"answer_id": 306624,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 3,
"selected": true,
"text": "<p>Hah, got it!</p>\n\n<pre><code>Object[] ni = (Object[])nDoc.Items;\nstring names_values = \"\";\nfor (int x = 0; x < ni... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343291/"
] | Is there any performance gain using a CTE over a derived table? | Hah, got it!
```
Object[] ni = (Object[])nDoc.Items;
string names_values = "";
for (int x = 0; x < ni.Length; x++)
{
NotesItem item = (NotesItem)ni[x];
if (!string.IsNullOrEmpty(item.Name)) names_values += x.ToString() + ": " + item.Name + "\t\t" + item.Text + "\r\n";
}
```
This returned a list of indices, names, an... |
306,466 | <p>I'm writing a script to display the 10 most recently "active" WordPress blog posts (i.e. those with the most recent comments). Problem is, the list has a lot of duplicates. I'd like to weed out the duplicates. Is there an easy way to do this by changing the MySQL query (like IGNORE, WHERE) or some other means? Here... | [
{
"answer_id": 306492,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 2,
"selected": false,
"text": "<p>Look at the <a href=\"http://dev.mysql.com/doc/refman/5.0/en/select.html\" rel=\"nofollow noreferrer\">DISTINCT</... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34964/"
] | I'm writing a script to display the 10 most recently "active" WordPress blog posts (i.e. those with the most recent comments). Problem is, the list has a lot of duplicates. I'd like to weed out the duplicates. Is there an easy way to do this by changing the MySQL query (like IGNORE, WHERE) or some other means? Here's w... | Look at the [DISTINCT](http://dev.mysql.com/doc/refman/5.0/en/select.html) option for the SELECT statement. Or alternatively the GROUP BY syntax (look at the same link). Though they work in different ways, these would be the two methods most likely to help you get exactly what you want. |
306,475 | <p>In SharePoint MOSS 2007, I have created a custom content type that I will be applying to a document library. One of the required fields is "Incoming Date" and another is the "Due Date". </p>
<p>The Due Date is always 10 working days from the Incoming Date. The Incoming Date is when the mail room received the let... | [
{
"answer_id": 306643,
"author": "J c",
"author_id": 25837,
"author_profile": "https://Stackoverflow.com/users/25837",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps you can work around this limitation by using a workflow (possibly a custom one) to manage the due date? A due date... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24229/"
] | In SharePoint MOSS 2007, I have created a custom content type that I will be applying to a document library. One of the required fields is "Incoming Date" and another is the "Due Date".
The Due Date is always 10 working days from the Incoming Date. The Incoming Date is when the mail room received the letter, not nece... | Firstly I should point out that you are making hard work of that formula, this will do the same.
=[Incoming Date] + 10
From the comments you have figured out that 10 working days (M-F) will always have 2 weekends so you can use this
=[Incoming Date] + 14
But this still doesn't take account of holidays
You are not ... |
306,477 | <p>I am using the MFC class <code>CSocket</code>. Nothing complicated - open a connection to a server and send a short message. The code works fine when I link with MFC in a DLL. However, the call to <code>CSocket::Create()</code> crashes when I link to MFC in a static library.</p>
<p>I would like to use MFC in a s... | [
{
"answer_id": 306552,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 0,
"selected": false,
"text": "<p>Are you getting any linker warnings at all? Make sure you link the right CRT library depending on your \"Code Generat... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16582/"
] | I am using the MFC class `CSocket`. Nothing complicated - open a connection to a server and send a short message. The code works fine when I link with MFC in a DLL. However, the call to `CSocket::Create()` crashes when I link to MFC in a static library.
I would like to use MFC in a static library since it simplifies d... | According to <http://support.microsoft.com/kb/193101>
The handle maps used by the sockets need to be created for each thread. The following code shows a function to do this:
```
void SocketThreadInit()
{
#ifndef _AFXDLL
#define _AFX_SOCK_THREAD_STATE AFX_MODULE_THREAD_STATE
#define _afxSockThreadState ... |
306,482 | <p>I have the following command which will loop over all the subdirectories in a specific location and output the full path:</p>
<pre><code>for /d %i in ("E:\Test\*") do echo %i
</code></pre>
<p>Will give me:</p>
<pre><code>E:\Test\One
E:\Test\Two
</code></pre>
<p>But how do I get both the full path, and just the d... | [
{
"answer_id": 306507,
"author": "Craig Lebakken",
"author_id": 33130,
"author_profile": "https://Stackoverflow.com/users/33130",
"pm_score": 3,
"selected": true,
"text": "<p>The following command syntax can be used to return the full path or directory name only:</p>\n\n<pre><code>%~fI ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39428/"
] | I have the following command which will loop over all the subdirectories in a specific location and output the full path:
```
for /d %i in ("E:\Test\*") do echo %i
```
Will give me:
```
E:\Test\One
E:\Test\Two
```
But how do I get both the full path, and just the directory name, so the do command might be somethi... | The following command syntax can be used to return the full path or directory name only:
```
%~fI - expands %I to a fully qualified path name
%~nI - expands %I to a file name only
```
Using your example, the following command will list directories in the format that you specified:
```
for /d %i in ("E... |
306,527 | <p>I have a bit of code that looks like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff));
</code></pre>
<p>I need to pass in a 2nd parameter like this:</p>
<pre><code>text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff, otherData));
</code></pre>
<p>Is this possible, and what... | [
{
"answer_id": 306564,
"author": "Daniel Plaisted",
"author_id": 1509,
"author_profile": "https://Stackoverflow.com/users/1509",
"pm_score": 5,
"selected": false,
"text": "<p>MatchEvaluator is a delegate so you can't change its signature. You can create a delegate that calls a method wi... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I have a bit of code that looks like this:
```
text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff));
```
I need to pass in a 2nd parameter like this:
```
text = reg.Replace(text, new MatchEvaluator(MatchEvalStuff, otherData));
```
Is this possible, and what would be the best way to do this? | Sorry, I should have mentioned that I'm using 2.0, so I don't have access to lambdas. Here is what I ended up doing:
```
private string MyMethod(Match match, bool param1, int param2)
{
//Do stuff here
}
Regex reg = new Regex(@"{regex goes here}", RegexOptions.IgnoreCase);
Content = reg.Replace(Content, new MatchE... |
306,531 | <p>I have written a KornShell (ksh) script that sets an array the following way:</p>
<pre><code>set -A fruits Apple Orange Banana Strawberry
</code></pre>
<p>but when I am trying to run it from within cron, it raises the following error:</p>
<pre><code>Your "cron" job on myhost
/myScript.sh
produced the following o... | [
{
"answer_id": 306673,
"author": "Nano Taboada",
"author_id": 6992,
"author_profile": "https://Stackoverflow.com/users/6992",
"pm_score": 2,
"selected": true,
"text": "<p>Although I'm not sure it's the best way to do it, I've managed to solve it this way:</p>\n\n<p>Attempt 4:</p>\n\n<pre... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] | I have written a KornShell (ksh) script that sets an array the following way:
```
set -A fruits Apple Orange Banana Strawberry
```
but when I am trying to run it from within cron, it raises the following error:
```
Your "cron" job on myhost
/myScript.sh
produced the following output:
myScript.sh: -A: bad option(s... | Although I'm not sure it's the best way to do it, I've managed to solve it this way:
Attempt 4:
```
0,5,10,15,20,25,30,35,40,45,50,55 * * * * cd /path/to/script && ksh ./myScript.sh
``` |
306,541 | <p>I've had this problem many times before, and I've never had a solution I felt good about. </p>
<p>Let's say I have a Transaction base class and two derived classes AdjustmentTransaction and IssueTransaction.</p>
<p>I have a list of transactions in the UI, and each transaction is of the concrete type AdjustmentTran... | [
{
"answer_id": 306565,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": true,
"text": "<p>You need to map your \"EditorForm\" to a transaction at some point. You have a couple options:</p>\n\n<ul>\n<li>A switch s... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3285/"
] | I've had this problem many times before, and I've never had a solution I felt good about.
Let's say I have a Transaction base class and two derived classes AdjustmentTransaction and IssueTransaction.
I have a list of transactions in the UI, and each transaction is of the concrete type AdjustmentTransaction or IssueT... | You need to map your "EditorForm" to a transaction at some point. You have a couple options:
* A switch statement...like you, I think this stinks, and scales poorly.
* An abstract "EditorForm" property in base Transaction class, this scales better, but has poor seperation of concerns.
* A Type -> Form mapper in your f... |
306,559 | <p>I'm trying to figure out how to write this function:</p>
<pre><code>template <typename Bound>
Bound::result_type callFromAnyList(Bound b, list<any> p)
{
}
</code></pre>
<p>Then, if I had some function:</p>
<pre><code>double myFunc(string s, int i)
{
return -3.0;
}
</code></pre>
<p>I could call it... | [
{
"answer_id": 306691,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": true,
"text": "<p>As you updated your concerns in the comment sections, here the answer. Just getting the return type of a ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8643/"
] | I'm trying to figure out how to write this function:
```
template <typename Bound>
Bound::result_type callFromAnyList(Bound b, list<any> p)
{
}
```
Then, if I had some function:
```
double myFunc(string s, int i)
{
return -3.0;
}
```
I could call it by doing something like this:
```
list<any> p;
p.push_back(... | As you updated your concerns in the comment sections, here the answer. Just getting the return type of a function is possible:
```
template<typename>
struct return_of;
template<typename R>
struct return_of<R(*)()> {
typedef R type;
};
template<typename R, typename P1>
struct return_of<R(*)(P1)> {
typedef R t... |
306,572 | <p>I recently started building a console version of a web application. I copied my custom sections from my web.config. to my app.config. When I go to get config information i get this error:</p>
<p>An error occurred creating the configuration section handler for x/y: Could not load type 'x' from assembly 'System.Confi... | [
{
"answer_id": 306575,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 3,
"selected": true,
"text": "<p>it sounds like your config-section handler is not defined</p>\n\n<pre><code><configSection>\n <section\... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | I recently started building a console version of a web application. I copied my custom sections from my web.config. to my app.config. When I go to get config information i get this error:
An error occurred creating the configuration section handler for x/y: Could not load type 'x' from assembly 'System.Configuration
... | it sounds like your config-section handler is not defined
```
<configSection>
<section
name="YOUR_CLASS_NAME_HERE"
type="YOUR.NAMESPACE.CLASSNAME, YOUR.NAMESPACE, Version=1.1.0.0, Culture=neutral, PublicKeyToken=PUBLIC_TOKEN_ID_FROM_ASSEMBLY"
allowLocation="true"
all... |
306,573 | <p>Is it possible to have a file belong to multiple subpackages? For example:</p>
<pre><code>/**
* Name
*
* Desc
*
* @package Core
* @subpackage Sub1
* @subpackage Sub2
*/
</code></pre>
<p>Thanks!</p>
| [
{
"answer_id": 306998,
"author": "localshred",
"author_id": 29690,
"author_profile": "https://Stackoverflow.com/users/29690",
"pm_score": 3,
"selected": true,
"text": "<p>It appears that PHPDoc does not allow you to do it for namespacing reasons. From the <a href=\"http://manual.phpdoc.o... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/538/"
] | Is it possible to have a file belong to multiple subpackages? For example:
```
/**
* Name
*
* Desc
*
* @package Core
* @subpackage Sub1
* @subpackage Sub2
*/
```
Thanks! | It appears that PHPDoc does not allow you to do it for namespacing reasons. From the [PHPDoc Docs](http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.subpackage.pkg.html):
>
> NOTE: The @subpackage tag is intended to help categorize the elements that are in an actual @package value. Since ... |
306,579 | <p>I would like to be able to Serialize a DateTime with a specific Time Zone that is not the server, nor is it client time. Basically, any time zone.
Is it possible to override the DateTime serialization, in .Net2.0 webservices?</p>
<p>I compile an xmlschema using xsd.exe, so I made an attempt using XmlSchemaImporter... | [
{
"answer_id": 306587,
"author": "silverbugg",
"author_id": 29650,
"author_profile": "https://Stackoverflow.com/users/29650",
"pm_score": 0,
"selected": false,
"text": "<p>You may want to use DateTimeOffset instead of a pure DateTime object.</p>\n"
},
{
"answer_id": 306590,
"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36627/"
] | I would like to be able to Serialize a DateTime with a specific Time Zone that is not the server, nor is it client time. Basically, any time zone.
Is it possible to override the DateTime serialization, in .Net2.0 webservices?
I compile an xmlschema using xsd.exe, so I made an attempt using XmlSchemaImporter.
The OnSe... | Don't serialize the `DateTimeOffset` directly, but serialize a string instead:
```
// Don't serialize this one
[System.Xml.Serialization.XmlIgnore]
public System.DateTimeOffset metadataDateTime
{
get { ... }
set { ... }
}
// Serialize this one instead
[System.Xml.Serialization.XmlAttribute("metadataDateTime")... |
306,583 | <p>I have a layout similar to this:</p>
<pre><code><div id="..."><img src="..."></div>
</code></pre>
<p>and would like to use a jQuery selector to select the child <code>img</code> inside the <code>div</code> on click.</p>
<p>To get the <code>div</code>, I've got this selector:</p>
<pre><code>$(th... | [
{
"answer_id": 306608,
"author": "Maxam",
"author_id": 15310,
"author_profile": "https://Stackoverflow.com/users/15310",
"pm_score": 5,
"selected": false,
"text": "<p>Try this code:</p>\n\n<pre><code>$(this).children()[0]\n</code></pre>\n"
},
{
"answer_id": 306632,
"author": ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16974/"
] | I have a layout similar to this:
```
<div id="..."><img src="..."></div>
```
and would like to use a jQuery selector to select the child `img` inside the `div` on click.
To get the `div`, I've got this selector:
```
$(this)
```
How can I get the child `img` using a selector? | The jQuery constructor accepts a 2nd parameter called [`context`](http://api.jquery.com/jQuery/#jQuery-selector-context) which can be used to override the context of the selection.
```
jQuery("img", this);
```
Which is the same as using [`.find()`](http://api.jquery.com/find) like this:
```
jQuery(this).find("img"... |
306,591 | <p>I'm trying to get the contents from another file with <code>file_get_contents</code> (don't ask why).<br />
I have two files: <em>test1.php</em> and <em>test2.php</em>. <em>test1.php</em> returns a string, bases on the user that is logged in.</p>
<p><em>test2.php</em> tries to get the contents of <em>test1.php</em> ... | [
{
"answer_id": 306659,
"author": "Sebastian Hoitz",
"author_id": 9535,
"author_profile": "https://Stackoverflow.com/users/9535",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure that file1.php exists on the server. Try opening it in your own browser to make sure!</p>\n"
},
{
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20261/"
] | I'm trying to get the contents from another file with `file_get_contents` (don't ask why).
I have two files: *test1.php* and *test2.php*. *test1.php* returns a string, bases on the user that is logged in.
*test2.php* tries to get the contents of *test1.php* and is being executed by the browser, thus getting the coo... | First, this is probably just a typo in your question, but the third arguments to file\_get\_contents() needs to be your streaming context, NOT the array of options. I ran a quick test with something like this, and everything worked as expected
```
$opts = array('http' => array('header'=> 'Cookie: ' . $_SERVER['HTTP_CO... |
306,596 | <p>I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"?</p>
<p>Here is the code:</p>
<pre><code> //Some code here
BinaryFormatter b = new BinaryFormatter();
return (myObject)b.Deserialize(s);//s---> is a Stream object that ... | [
{
"answer_id": 306598,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 7,
"selected": true,
"text": "<p>Try to set the position to 0 of your stream and do not use your object but the object type.</p>\n\n<pre><code... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14441/"
] | I am trying to deserialize a stream but I always get this error "End of Stream encountered before parsing was completed"?
Here is the code:
```
//Some code here
BinaryFormatter b = new BinaryFormatter();
return (myObject)b.Deserialize(s);//s---> is a Stream object that has been fill up with da... | Try to set the position to 0 of your stream and do not use your object but the object type.
```
BinaryFormatter b = new BinaryFormatter();
s.Position = 0;
return (YourObjectType)b.Deserialize(s);
``` |
306,641 | <p>I am implementing a validation class in classic ASP. How should the validation class interface with my other classes? </p>
<p>My current setup:
The User class's set methods call the appropriate validation method in the validation class. Any errors that occur are stored in User.mError. For example, here's my set met... | [
{
"answer_id": 306823,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest looking at Validator related classes provided by .net framework.</p>\n\n<p>In your case, you can ha... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26180/"
] | I am implementing a validation class in classic ASP. How should the validation class interface with my other classes?
My current setup:
The User class's set methods call the appropriate validation method in the validation class. Any errors that occur are stored in User.mError. For example, here's my set method for th... | You should try the validation concept used in ajaxed (which is an AJAX library for classic ASP - [www.webdevbros.net/ajaxed/](http://www.webdevbros.net/ajaxed/)). Unfortunately the validator will be officialy released in version 2.0 but its already available in [SVN](http://code.google.com/p/asp-ajaxed/source/browse/#s... |
306,642 | <p>How can I retrieve raw time-series data from a Proficy Historian/iHistorian?</p>
<p>Ideally, I would ask for data for a particular tag between two dates.</p>
| [
{
"answer_id": 306646,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 2,
"selected": false,
"text": "<p>A coworker of mine put this together:</p>\n\n<p>In web.config:</p>\n\n<pre><code><add name=\"HistorianConnectionStri... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29/"
] | How can I retrieve raw time-series data from a Proficy Historian/iHistorian?
Ideally, I would ask for data for a particular tag between two dates. | There are several different sampling modes you can experiment with.
* Raw
* Interpolated
* Lab
* Trend
* Calculated
These modes are available using all of the following APIs.
* User API (ihuapi.dll)
* SDK (ihsdk.dll)
* OLEDB (iholedb.dll)
* Client Acess API (Proficy.Historian.ClientAccess.API)
Of these the trend sa... |
306,644 | <p>I always have this notion that writing SQL queries in the code behind is not good compared to writing it using a SqlDataSource</p>
<pre><code>SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "Categories");
myGridView.DataSource = ds;
myGri... | [
{
"answer_id": 306656,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 4,
"selected": false,
"text": "<p>I wouldn't write SQL queries in code behind full stop. How about a data access layer? </p>\n\n<p>What happens if you want... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16519/"
] | I always have this notion that writing SQL queries in the code behind is not good compared to writing it using a SqlDataSource
```
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Categories", myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "Categories");
myGridView.DataSource = ds;
myGridView.DataBind... | SQL queries in the code-behind and SQL queries in a SqlDataSource are pretty much equivalent.
they're both about the same security-wise; as for easier to maintain, SqlDataSource may be a bit easier in most cases.
A data-access layer is preferred, but SqlDataSource is sometimes a good-enough expediency. I wouldn't hit... |
306,668 | <p>I've been preaching both to my colleagues and here on SO about the goodness of using parameters in SQL queries, especially in .NET applications. I've even gone so far as to promise them as giving immunity against SQL injection attacks.</p>
<p>But I'm starting to wonder if this really is true. Are there any known SQ... | [
{
"answer_id": 306675,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 7,
"selected": true,
"text": "<p><strong>Placeholders</strong> are enough to prevent injections. You might still be open to buffer overflows, but ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30366/"
] | I've been preaching both to my colleagues and here on SO about the goodness of using parameters in SQL queries, especially in .NET applications. I've even gone so far as to promise them as giving immunity against SQL injection attacks.
But I'm starting to wonder if this really is true. Are there any known SQL injectio... | **Placeholders** are enough to prevent injections. You might still be open to buffer overflows, but that is a completely different flavor of attack from an SQL injection (the attack vector would not be SQL syntax but binary). Since the parameters passed will all be escaped properly, there isn't any way for an attacker ... |
306,679 | <p>If a line of text is wrapped to an additional line, how do I determine programmatically the point in the string where it was broken.</p>
<p>Example: Input string = "This is a test of a wrapped line of text".</p>
<pre><code> Based on the width of the richTextBox it could display:
This is a test o... | [
{
"answer_id": 313168,
"author": "Mike Two",
"author_id": 23659,
"author_profile": "https://Stackoverflow.com/users/23659",
"pm_score": 2,
"selected": false,
"text": "<p>The trick I found uses the TextPointer class and its GetCharacterRec method.</p>\n\n<p>RichTextBox holds a FlowDocumen... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37918/"
] | If a line of text is wrapped to an additional line, how do I determine programmatically the point in the string where it was broken.
Example: Input string = "This is a test of a wrapped line of text".
```
Based on the width of the richTextBox it could display:
This is a test of a wrapped line of
... | The trick I found uses the TextPointer class and its GetCharacterRec method.
RichTextBox holds a FlowDocument. Text in flow documents is contained in a Run object (bit of a simplification, but it works). The code finds the TextPointer at the start of the first Run. It then gets the bounding rectangle of that first cha... |
306,713 | <p>I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter:</p>
<pre><code>import java.util.Collections;
import java.util.List;
public class Person {
private String name;
private List<String> nicknames;
publ... | [
{
"answer_id": 306748,
"author": "carson",
"author_id": 25343,
"author_profile": "https://Stackoverflow.com/users/25343",
"pm_score": 7,
"selected": false,
"text": "<p>You want to use:</p>\n\n<pre><code>Collections.<String>emptyList();\n</code></pre>\n\n<p>If you look at the source... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | I'm having some trouble navigating Java's rule for inferring generic type parameters. Consider the following class, which has an optional list parameter:
```
import java.util.Collections;
import java.util.List;
public class Person {
private String name;
private List<String> nicknames;
public Person(String name... | The issue you're encountering is that even though the method `emptyList()` returns `List<T>`, you haven't provided it with the type, so it defaults to returning `List<Object>`. You can supply the type parameter, and have your code behave as expected, like this:
```
public Person(String name) {
this(name,Collections.... |
306,722 | <p>I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool to create a mapping for that table, it generates two classes, one for named after the table itself, and one with an "Id" suffix. It seems most of the us... | [
{
"answer_id": 306748,
"author": "carson",
"author_id": 25343,
"author_profile": "https://Stackoverflow.com/users/25343",
"pm_score": 7,
"selected": false,
"text": "<p>You want to use:</p>\n\n<pre><code>Collections.<String>emptyList();\n</code></pre>\n\n<p>If you look at the source... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table in my MYSQL database which does not have a primary key, but has a unique key on two columns. When using MyEclipse's Hibernate reverse engineer tool to create a mapping for that table, it generates two classes, one for named after the table itself, and one with an "Id" suffix. It seems most of the useful ... | The issue you're encountering is that even though the method `emptyList()` returns `List<T>`, you haven't provided it with the type, so it defaults to returning `List<Object>`. You can supply the type parameter, and have your code behave as expected, like this:
```
public Person(String name) {
this(name,Collections.... |
306,732 | <p>I have a Freemarker template which contains a bunch of placeholders for which values are supplied when the template is processed. I want to conditionally include part of the template if the userName variable is supplied, something like:</p>
<pre><code>[#if_exists userName]
Hi ${userName}, How are you?
[/#if_exist... | [
{
"answer_id": 306749,
"author": "Ulf Lindback",
"author_id": 30354,
"author_profile": "https://Stackoverflow.com/users/30354",
"pm_score": 9,
"selected": true,
"text": "<p>To check if the value exists:</p>\n\n<pre><code>[#if userName??]\n Hi ${userName}, How are you?\n[/#if]\n</code><... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have a Freemarker template which contains a bunch of placeholders for which values are supplied when the template is processed. I want to conditionally include part of the template if the userName variable is supplied, something like:
```
[#if_exists userName]
Hi ${userName}, How are you?
[/#if_exists]
```
Howev... | To check if the value exists:
```
[#if userName??]
Hi ${userName}, How are you?
[/#if]
```
Or with the standard freemarker syntax:
```
<#if userName??>
Hi ${userName}, How are you?
</#if>
```
To check if the value exists and is not empty:
```
<#if userName?has_content>
Hi ${userName}, How are you?
</#i... |
306,743 | <p>What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0</p>
| [
{
"answer_id": 306756,
"author": "Guge",
"author_id": 37771,
"author_profile": "https://Stackoverflow.com/users/37771",
"pm_score": 4,
"selected": false,
"text": "<p>You can use <code>group by</code> on all columns and then <code>count(*)>1</code></p>\n"
},
{
"answer_id": 3067... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39426/"
] | What is the most efficient way to detect duplicates in a 10 column / 50K row table? I'm using MSSQL 8.0 | To show an example of what others have been describing:
```
SELECT
Col1, -- All of the columns you want to dedupe on
Col2, -- which is not neccesarily all of the columns
Col3, -- in the table
Col4,
Col5,
Col6,
Col7,
Col8,
Col9,
Col10
FROM
MyTable
GROUP BY
Col1,
Col2,... |
306,757 | <p><strong>Given:</strong> Constructing an ADO Connection object from one thread and giving it to another thread is <strong><em>forbidden</em></strong>. The two threads are different apartments, and even though the first thread will <strong>never</strong> touch it again (not even maintain a reference to it!), it doesn... | [
{
"answer_id": 306791,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 0,
"selected": false,
"text": "<p>Why would you want to create a connection on one thread and use it from another? </p>\n\n<p>The time between connect... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | **Given:** Constructing an ADO Connection object from one thread and giving it to another thread is ***forbidden***. The two threads are different apartments, and even though the first thread will **never** touch it again (not even maintain a reference to it!), it doesn't matter.
That ADO Connection object was create... | SHOOTING for the bounty!
Okay, some classes/frameworks of classes in .NET have methods that are apartment bound, but BY DESIGN ONLY. That means you have to SPECIFICALLY CODE to do this. Its not set by default. Coding for this is kinda kludgy. You have to get the thread ID you want to stick with and check it all the ti... |
306,779 | <p>I have a PPPOE connection on a computer. That computer has two LAN cards and I activated ICS on it. The problem is, the connection kinda degrades over time (don't know why), and a redial would be nice, hourly maybe. I was thinking of writing an AutoIT script that would do this, if, for example I'm sending some data ... | [
{
"answer_id": 377502,
"author": "Imran",
"author_id": 1897,
"author_profile": "https://Stackoverflow.com/users/1897",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you can make something for yourself with <a href=\"http://webtools.live2support.com/windows/rasdial.php\" rel=\"nofol... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | I have a PPPOE connection on a computer. That computer has two LAN cards and I activated ICS on it. The problem is, the connection kinda degrades over time (don't know why), and a redial would be nice, hourly maybe. I was thinking of writing an AutoIT script that would do this, if, for example I'm sending some data to ... | you can use rasdial (which is build in into windows) and create a batch script (.bat extension) like so:
```
rasdial connectionname
```
-or-
if you want to do it in a programming language, you can just call the command internally
C# example:
```
public static int OpenConnection(string connectionName, int Timeout... |
306,788 | <p>How do I check if the timestamp date of a record is before midnight today?</p>
<p>datediff is driving me nuts...</p>
| [
{
"answer_id": 306794,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>WHERE dtColumn < DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))\n</code></pre>\n"
},
{
... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/750/"
] | How do I check if the timestamp date of a record is before midnight today?
datediff is driving me nuts... | Here is how to get 0 hour of today in SQL
```
SELECT (CAST(FLOOR(CAST(GETDATE() as FLOAT)) AS DateTime))
```
Just compare your time against that.
Don't use varchar casts since they are slow.
[Check this list](https://stackoverflow.com/questions/202243/custom-datetime-formatting-in-sql-server#202288) for more date ... |
306,806 | <p>I have the following entity class (in Groovy):</p>
<pre><code>import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
public class ServerNode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
String fi... | [
{
"answer_id": 306825,
"author": "billjamesdev",
"author_id": 13824,
"author_profile": "https://Stackoverflow.com/users/13824",
"pm_score": 6,
"selected": false,
"text": "<p>You might try changing this line in your persistence.xml from</p>\n\n<pre><code><property name=\"hbm2ddl.auto\"... | 2008/11/20 | [
"https://Stackoverflow.com/questions/306806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | I have the following entity class (in Groovy):
```
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
public class ServerNode {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
String firstName
Stri... | I don't know if leaving `hibernate` off the front makes a difference.
The [reference](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-misc-properties) suggests it should be `hibernate.hbm2ddl.auto`
A value of `create` will create your tables at sessionFactory creati... |