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 |
|---|---|---|---|---|---|---|
446,571 | <p>On my server I have installed a web application that comes with a bundle of Apache Services. Hence all the apache related dlls are located in the application folder's sub directory (e.g., C:\Program Files\MyWebApp\apache2). It seems that when the windows 2003 server is started all the request will be served by that ... | [
{
"answer_id": 453070,
"author": "Uresu",
"author_id": 11552,
"author_profile": "https://Stackoverflow.com/users/11552",
"pm_score": 4,
"selected": false,
"text": "<p>Does the original site still work ok? If it does, there is a chance that the second installation of apache is trying to... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | On my server I have installed a web application that comes with a bundle of Apache Services. Hence all the apache related dlls are located in the application folder's sub directory (e.g., C:\Program Files\MyWebApp\apache2). It seems that when the windows 2003 server is started all the request will be served by that apa... | Does the original site still work ok? If it does, there is a chance that the second installation of apache is trying to install itself as a service with the same name as the first instance and therefore, failing.
To install apache as a second service use:
```
httpd -k install -n "Apache Instance 2" -f "C:\Program Fil... |
446,594 | <p>Is it possible that using jQuery, I <strong>cancel/abort an Ajax request</strong> that I have not yet received the response from?</p>
| [
{
"answer_id": 446622,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 7,
"selected": false,
"text": "<p>You can't recall the request but you can set a timeout value after which the response will be ignored. See this <a ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47831/"
] | Is it possible that using jQuery, I **cancel/abort an Ajax request** that I have not yet received the response from? | Most of the jQuery Ajax methods return an XMLHttpRequest (or the equivalent) object, so you can just use `abort()`.
See the documentation:
* [abort Method](http://msdn.microsoft.com/en-us/library/ms535920%28VS.85%29.aspx) ([MSDN](http://en.wikipedia.org/wiki/Microsoft_Developer_Network)). Cancels the current HTTP req... |
446,608 | <p>I have an XML form with an element 0, which is well-formed but not valid.
When I try to validate it XMLSpy I get a following error:
Nothing is allowed inside empty element 'hidden'.
Below is my schema:</p>
<pre><code><xs:element name="hidden">
<xs:complexType>
<xs:attribute name="dataty... | [
{
"answer_id": 446641,
"author": "Welbog",
"author_id": 52443,
"author_profile": "https://Stackoverflow.com/users/52443",
"pm_score": 2,
"selected": false,
"text": "<p>Your \"hidden\" element is defined as being empty since you don't have anything in the schema explicitly allowing child ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425282/"
] | I have an XML form with an element 0, which is well-formed but not valid.
When I try to validate it XMLSpy I get a following error:
Nothing is allowed inside empty element 'hidden'.
Below is my schema:
```
<xs:element name="hidden">
<xs:complexType>
<xs:attribute name="datatype" type="xs:string" use="opt... | As welbog noted, you defined a complex empty element. Assuming you want only text within the hidden tag, you could write a schema along theses lines :
```
<xs:element name="hidden">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:integer">
<xs:attribute name="datatype" type="xs:string" u... |
446,624 | <p>I have a table containing cells with text of various lengths. It is essential that all of the table cells are of the same width. If this means truncating long words or forcing a break in long words then that's OK.</p>
<p>I cannot figure out any way of getting this to work.</p>
<p>This is for an internal client app... | [
{
"answer_id": 446647,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 5,
"selected": true,
"text": "<p>Stack Overflow has solved a similar problem with long lines of code by using a DIV and having <code>o... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39709/"
] | I have a table containing cells with text of various lengths. It is essential that all of the table cells are of the same width. If this means truncating long words or forcing a break in long words then that's OK.
I cannot figure out any way of getting this to work.
This is for an internal client application so needs... | Stack Overflow has solved a similar problem with long lines of code by using a DIV and having `overflow-x:auto`. CSS can't break up words for you. |
446,635 | <p>I'm trying to validate an XML file against the schemas it references. (Using Delphi and MSXML2_TLB.) The (relevant part of the) code looks something like this: </p>
<pre><code>procedure TfrmMain.ValidateXMLFile;
var
xml: IXMLDOMDocument2;
err: IXMLDOMParseError;
schemas: IXMLDOMSchemaCollection;
begin
... | [
{
"answer_id": 449817,
"author": "BennyBechDk",
"author_id": 34857,
"author_profile": "https://Stackoverflow.com/users/34857",
"pm_score": 0,
"selected": false,
"text": "<p>I have previously validated XML documents using the following code:</p>\n\n<pre><code>Uses\n Classes, \n XMLIntf,... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17336/"
] | I'm trying to validate an XML file against the schemas it references. (Using Delphi and MSXML2\_TLB.) The (relevant part of the) code looks something like this:
```
procedure TfrmMain.ValidateXMLFile;
var
xml: IXMLDOMDocument2;
err: IXMLDOMParseError;
schemas: IXMLDOMSchemaCollection;
begin
xml := Com... | I've come up with an approach that seems to work. I first load the schema's explicitly, then add themn to the schemacollection. Next I load the xml-file and assign the schemacollection to its schemas property. The solution now looks like this:
```
uses MSXML2_TLB
That is:
// Type Lib: C:\Windows\system32\msxml4.dl... |
446,646 | <p>I want to know how I can run a method in a separate thread? Class & Method references. Thanks.</p>
| [
{
"answer_id": 446779,
"author": "Mustafa",
"author_id": 49739,
"author_profile": "https://Stackoverflow.com/users/49739",
"pm_score": 3,
"selected": true,
"text": "<p>Found the answer (you can use either of these statements to achieve this):</p>\n\n<pre><code>[NSThread detachNewThreadSe... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49739/"
] | I want to know how I can run a method in a separate thread? Class & Method references. Thanks. | Found the answer (you can use either of these statements to achieve this):
```
[NSThread detachNewThreadSelector:@selector(myThreadMainMethod:) toTarget:self withObject:nil];
```
OR
```
NSThread *myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(myThreadMainMethod:)
... |
446,660 | <p>I'm building a webpage on which I display the <em>n</em> newest newsposts on the front page, and this is the method that gets the posts and returns them to the .aspx-file. I use a asp:substitution-control to insert the string into the webpage.</p>
<p>I think my way of doing this i kind of messy and ugly, and not ve... | [
{
"answer_id": 446779,
"author": "Mustafa",
"author_id": 49739,
"author_profile": "https://Stackoverflow.com/users/49739",
"pm_score": 3,
"selected": true,
"text": "<p>Found the answer (you can use either of these statements to achieve this):</p>\n\n<pre><code>[NSThread detachNewThreadSe... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39785/"
] | I'm building a webpage on which I display the *n* newest newsposts on the front page, and this is the method that gets the posts and returns them to the .aspx-file. I use a asp:substitution-control to insert the string into the webpage.
I think my way of doing this i kind of messy and ugly, and not very flexible if i ... | Found the answer (you can use either of these statements to achieve this):
```
[NSThread detachNewThreadSelector:@selector(myThreadMainMethod:) toTarget:self withObject:nil];
```
OR
```
NSThread *myThread = [[NSThread alloc] initWithTarget:self
selector:@selector(myThreadMainMethod:)
... |
446,663 | <p>I am writing a web service in Java, and I am <strong>trying to figure out the best way to define error codes and their associated error strings</strong>. I need to have a numerical error code and an error string grouped together. Both the error code and error string will be sent to the client accessing the web servi... | [
{
"answer_id": 446671,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 9,
"selected": true,
"text": "<p>Well there's certainly a better implementation of the enum solution (which is generally quite nice):</p>\n<pre><code>p... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2405/"
] | I am writing a web service in Java, and I am **trying to figure out the best way to define error codes and their associated error strings**. I need to have a numerical error code and an error string grouped together. Both the error code and error string will be sent to the client accessing the web service. For example,... | Well there's certainly a better implementation of the enum solution (which is generally quite nice):
```
public enum Error {
DATABASE(0, "A database error has occurred."),
DUPLICATE_USER(1, "This user already exists.");
private final int code;
private final String description;
private Error(int code, Strin... |
446,677 | <p>I am using <code>enum</code> keyword to define set of values which I read from database tables.</p>
<p>I am not confident that these values will remain constant in the database and in <code>switch</code> <code>case</code> statement we need to give constant values. How can I solve this problem?</p>
| [
{
"answer_id": 446671,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 9,
"selected": true,
"text": "<p>Well there's certainly a better implementation of the enum solution (which is generally quite nice):</p>\n<pre><code>p... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using `enum` keyword to define set of values which I read from database tables.
I am not confident that these values will remain constant in the database and in `switch` `case` statement we need to give constant values. How can I solve this problem? | Well there's certainly a better implementation of the enum solution (which is generally quite nice):
```
public enum Error {
DATABASE(0, "A database error has occurred."),
DUPLICATE_USER(1, "This user already exists.");
private final int code;
private final String description;
private Error(int code, Strin... |
446,691 | <p>I'm creating an ASP.NET application that will log some stuff to Windows EventLog. To do this an event source has to be created first. This requires administrative priviledges so I cannot do it in the ASP.NET app.</p>
<p>Is there an existing command-line application that is bundled with Windows that can create an ev... | [
{
"answer_id": 898816,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Or just use the command line command:</p>\n\n<p>Eventcreate</p>\n"
},
{
"answer_id": 1036133,
"author": "MSV Mu... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41360/"
] | I'm creating an ASP.NET application that will log some stuff to Windows EventLog. To do this an event source has to be created first. This requires administrative priviledges so I cannot do it in the ASP.NET app.
Is there an existing command-line application that is bundled with Windows that can create an event log so... | Try "eventcreate.exe"
=====================
An example:
```
eventcreate /ID 1 /L APPLICATION /T INFORMATION /SO MYEVENTSOURCE /D "My first log"
```
This will create a new event *source* named `MYEVENTSOURCE` under `APPLICATION` event *log* as `INFORMATION` event *type*.
I think this utility is included only from ... |
446,694 | <p>I'm working for the first time on a project that requires building a webapp which makes heavy use of JSF (and ICEfaces in particular). There's a mix of stuff to be coded including CSS, HTML, JSP/Java and, of course, JSF.</p>
<p>I'm doing all this within Eclipse btw and using a local tomcat server which eclipse is r... | [
{
"answer_id": 446719,
"author": "Romain Linsolas",
"author_id": 26457,
"author_profile": "https://Stackoverflow.com/users/26457",
"pm_score": 3,
"selected": false,
"text": "<p>I am developing my applications in JSF with almost the same configuration (Tomcat 5.5 run by my Eclipse 3.3 wit... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426/"
] | I'm working for the first time on a project that requires building a webapp which makes heavy use of JSF (and ICEfaces in particular). There's a mix of stuff to be coded including CSS, HTML, JSP/Java and, of course, JSF.
I'm doing all this within Eclipse btw and using a local tomcat server which eclipse is responsible... | I am developing my applications in JSF with almost the same configuration (Tomcat 5.5 run by my Eclipse 3.3 with JBoss Tools).
I am using also Facelets for JSF, and there is an important context parameter in web.xml I can to set in order to be able to modify my XHTML files with an automatic refresh (i.e. I don't need t... |
446,702 | <p>In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database.
I want to dynamically apply a sort filter to the datatable (could be a dataview), and then do a loop through the "rows" of the sorted data to use each row for some metrics.</p>
<p>I would greatly prefer not to hit the database each time to do... | [
{
"answer_id": 446718,
"author": "Welbog",
"author_id": 52443,
"author_profile": "https://Stackoverflow.com/users/52443",
"pm_score": 4,
"selected": true,
"text": "<p>The DataTable.Select() function does exactly what you seem to be wanting. Its second String parameter is a sorting string... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24126/"
] | In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database.
I want to dynamically apply a sort filter to the datatable (could be a dataview), and then do a loop through the "rows" of the sorted data to use each row for some metrics.
I would greatly prefer not to hit the database each time to do custom so... | The DataTable.Select() function does exactly what you seem to be wanting. Its second String parameter is a sorting string whose syntax is the same as SQL's: *[Column Name]* ASC, *[Other column name]* DESC, etc. |
446,706 | <p>I'm logging errors and sending myself the exception logs! Like the following code</p>
<pre><code> private void ExceptionForm_Load(object sender, EventArgs e)
{
Type exceptionType = _exception.GetType();
txtErrorMessage.Text = _exception.ToString();
if (exceptionType == typeof(Sybase... | [
{
"answer_id": 446722,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>The problem isn't the cast - it's that your _exception variable is (presumably) of type Exception. You need to declare... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50124/"
] | I'm logging errors and sending myself the exception logs! Like the following code
```
private void ExceptionForm_Load(object sender, EventArgs e)
{
Type exceptionType = _exception.GetType();
txtErrorMessage.Text = _exception.ToString();
if (exceptionType == typeof(Sybase.DataWindow.Db... | The problem isn't the cast - it's that your \_exception variable is (presumably) of type Exception. You need to declare a new variable of the right type. Also, do you have any reason for using GetType() instead of "as" or "is"? What about derived exceptions? Try this:
```
private void ExceptionForm_Load(object sender,... |
446,717 | <p>I am developing a 2D iPhone game by using cocos2d. I need a countdown timer. How can I create a count down timer in cocos2d?</p>
| [
{
"answer_id": 449628,
"author": "Joel Levin",
"author_id": 55743,
"author_profile": "https://Stackoverflow.com/users/55743",
"pm_score": -1,
"selected": false,
"text": "<p>Look at NSTimer, it can most likely provide any needed timer functionality.</p>\n\n<p><a href=\"http://developer.ap... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51108/"
] | I am developing a 2D iPhone game by using cocos2d. I need a countdown timer. How can I create a count down timer in cocos2d? | Not enough rep to upvote Tom, but he's absolutely right. Within the context of this question, NSTimer is the WRONG solution. The Cocos2d framework provides a scheduler that integrates with other game features like Pause/Resume (and most likely uses NSTimer under the hood).
Example from the above link:
```
-(id) init
... |
446,729 | <p>I'm helping troubleshoot some deadlocking in a .NET application that uses SQL Server 2005. I have the XML data from the trace below.</p>
<p>What really puzzles me is the RangeX-X lock on <code>PK_Exp_Experience_PriorFirm</code> when the transaction isolation level is read committed.</p>
<p>Everything I've read ind... | [
{
"answer_id": 447013,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": "<p>According to SQL Docs, somehow, your transaction (or some other one) was running at level serializable.</p>\n\n... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55421/"
] | I'm helping troubleshoot some deadlocking in a .NET application that uses SQL Server 2005. I have the XML data from the trace below.
What really puzzles me is the RangeX-X lock on `PK_Exp_Experience_PriorFirm` when the transaction isolation level is read committed.
Everything I've read indicates that you only get a k... | The RangeX-X lock on PK\_Exp\_Experience\_PriorFirm was being taken as part of a cascading delete.
SQL Server automatically upgrades the isolation level to serializable for certain operations, such as cascading deletes.
This is described in more detail here: [Conor vs. Isolation Level Upgrade on UPDATE/DELETE Cascadi... |
446,760 | <p>I am trying to submit a create and update request to rails using flex with multiple models. For example, imagine that we have a blog post and multiple comments.</p>
<p>The user comes and update the post and some comments, when he clicks on submit I want to send all updates.</p>
<p>If I send something like:</p>
<p... | [
{
"answer_id": 446768,
"author": "Stefano Driussi",
"author_id": 49209,
"author_profile": "https://Stackoverflow.com/users/49209",
"pm_score": 3,
"selected": true,
"text": "<p>You can use P/Invoke and you can call unmanaged methods.\nI'll post you some examples:\n<a href=\"http://msdn.mi... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/440867/"
] | I am trying to submit a create and update request to rails using flex with multiple models. For example, imagine that we have a blog post and multiple comments.
The user comes and update the post and some comments, when he clicks on submit I want to send all updates.
If I send something like:
```
var params:Object =... | You can use P/Invoke and you can call unmanaged methods.
I'll post you some examples:
[This](http://msdn.microsoft.com/en-us/library/aa288468.aspx) is a reference to MSDN official documentation.
[This](http://www.pinvoke.net/) is a community mantained website with most of the common Windows unmanaged libraries along wi... |
446,782 | <p>I want to get out of a function when an exception occurs or so.
I want to use other method than 'return'</p>
| [
{
"answer_id": 446805,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "<p>Can't think of another way to \"get out\" of a function other than a) return, b) throw an exception, or c) terminate execut... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46646/"
] | I want to get out of a function when an exception occurs or so.
I want to use other method than 'return' | If you catch an exception and then want to rethrow it, [this pattern](http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html) is pretty simple:
```
try:
do_something_dangerous()
except:
do_something_to_apologize()
raise
```
Of course if you want to *raise* the exception in the first pl... |
446,798 | <p>I need to get a list of the RSS subscriptions from iTunes. I'm using the COM interface that Apple provides for controlling iTunes, and have tried this both on Windows and Mac. </p>
<p>e.g.</p>
<pre><code>tell application "iTunes"
repeat with a_track in tracks of playlist "Podcasts"
get artist of a_tr... | [
{
"answer_id": 446803,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked at <a href=\"http://www.mygenerationsoftware.com/portal/default.aspx\" rel=\"nofollow noreferrer\">... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to get a list of the RSS subscriptions from iTunes. I'm using the COM interface that Apple provides for controlling iTunes, and have tried this both on Windows and Mac.
e.g.
```
tell application "iTunes"
repeat with a_track in tracks of playlist "Podcasts"
get artist of a_track
get album o... | Have you looked at [MyGeneration](http://www.mygenerationsoftware.com/portal/default.aspx)?
@Viks's suggestion of ASP.NET Dynamic Data is a good one, though you should check if it is ready for production releases:
<http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx>
<http://www.a... |
446,819 | <p>I have a PHP file and an image in the same directory. How could I get the PHP file to set it's headers as jpeg and "pull" the image into it. So if I went to file.php it would show the image. If I rewrite file.php to file_created.jpg and it needs to work.</p>
| [
{
"answer_id": 446846,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverflow.com/users/1638",
"pm_score": 1,
"selected": false,
"text": "<p>Should be easy as:</p>\n\n<pre><code><?php\n $filepath= '/home/foobar/bar.jpg';\n header('Content-Type: image/jp... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I have a PHP file and an image in the same directory. How could I get the PHP file to set it's headers as jpeg and "pull" the image into it. So if I went to file.php it would show the image. If I rewrite file.php to file\_created.jpg and it needs to work. | Rather than use [file\_get\_contents](http://php.net/file_get_contents) as suggested by another answer, use [readfile](http://php.net/readfile) and output out some more HTTP headers to play nicely:
```
<?php
$filepath= '/home/foobar/bar.gif'
header('Content-Type: image/gif');
header('Content-Length: ' .... |
446,835 | <p>Ran across this line of code:</p>
<pre><code>FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();
</code></pre>
<p>What do the two question marks mean, is it some kind of ternary operator?
It's hard to look up in Google.</p>
| [
{
"answer_id": 446839,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 12,
"selected": true,
"text": "<p>It's the null coalescing operator, and quite like the ternary (immediate-if) operator. See also <a href=\"https://learn.mic... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | Ran across this line of code:
```
FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();
```
What do the two question marks mean, is it some kind of ternary operator?
It's hard to look up in Google. | It's the null coalescing operator, and quite like the ternary (immediate-if) operator. See also [?? Operator - MSDN](https://learn.microsoft.com/en-in/dotnet/csharp/language-reference/operators/null-coalescing-operator).
```
FormsAuth = formsAuth ?? new FormsAuthenticationWrapper();
```
expands to:
```
FormsAuth = ... |
446,866 | <p>I am trying to compare the performance of boost::multi_array to native dynamically allocated arrays, with the following test program:</p>
<pre><code>#include <windows.h>
#define _SCL_SECURE_NO_WARNINGS
#define BOOST_DISABLE_ASSERTS
#include <boost/multi_array.hpp>
int main(int argc, char* argv[])
{
... | [
{
"answer_id": 446880,
"author": "Laserallan",
"author_id": 11758,
"author_profile": "https://Stackoverflow.com/users/11758",
"pm_score": 4,
"selected": true,
"text": "<p>Are you building release or debug?</p>\n\n<p>If running in debug mode, the boost array might be really slow because t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18882/"
] | I am trying to compare the performance of boost::multi\_array to native dynamically allocated arrays, with the following test program:
```
#include <windows.h>
#define _SCL_SECURE_NO_WARNINGS
#define BOOST_DISABLE_ASSERTS
#include <boost/multi_array.hpp>
int main(int argc, char* argv[])
{
const int X_SIZE = 200;... | Are you building release or debug?
If running in debug mode, the boost array might be really slow because their template magic isn't inlined properly giving lots of overhead in function calls. I'm not sure how multi array is implemented though so this might be totally off :)
Perhaps there is some difference in storag... |
446,869 | <p>I read somewhere that currently urllib2 doesn't support authenticated https connection. My proxy uses a basic authentication only, but how to open an https based webpage through it .
Please help me. </p>
<p>Thanks.</p>
| [
{
"answer_id": 447096,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://code.google.com/p/httplib2/\" rel=\"nofollow noreferrer\">httplib2</a>, which solves some of the... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55435/"
] | I read somewhere that currently urllib2 doesn't support authenticated https connection. My proxy uses a basic authentication only, but how to open an https based webpage through it .
Please help me.
Thanks. | "urllib2 doesn't support authenticated https connection" False.
```
# Build Handler to support HTTP Basic Authentication...
basic_handler = urllib2.HTTPBasicAuthHandler()
basic_handler.add_password(realm, self.urlBase, username, password)
# Get cookies, also, to handle login
self.cookies= cookielib... |
446,874 | <p>Is there any way in VB.NET to remove all of the whitespaces between tags in HTML? </p>
<p>Say, I've got this: </p>
<pre><code><tr>
<td>
</code></pre>
<p>The string I've built is an entire HTML document, and it counts everything before those tags as legitimate space, so I need to trim it out. Is t... | [
{
"answer_id": 446890,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 2,
"selected": true,
"text": "<p>Depending on the complexity of your document, you probably just need a replace regular expression across the document.... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13244/"
] | Is there any way in VB.NET to remove all of the whitespaces between tags in HTML?
Say, I've got this:
```
<tr>
<td>
```
The string I've built is an entire HTML document, and it counts everything before those tags as legitimate space, so I need to trim it out. Is there a reg ex or function out there I could us... | Depending on the complexity of your document, you probably just need a replace regular expression across the document... Something like:
RegexObj.Replace(">[\s\n]\*<","><")
You can read up about .NET and regular expressions [here](http://www.regular-expressions.info/dotnet.html) |
446,893 | <p>We have a mixture of .Net apps that connect through ODBC and DB2 Connect to an iSeries LPAR that's at V5R4. We also have some batch jobs running natively on the machine (COBOL, RPG, and straight CL mostly). During certain periods of the day, we experience high page faulting and are trying to determine which apps mig... | [
{
"answer_id": 446990,
"author": "Paul G",
"author_id": 162,
"author_profile": "https://Stackoverflow.com/users/162",
"pm_score": 0,
"selected": false,
"text": "<p>This seems to help a little:</p>\n\n<p>-- In iSeries Navigator, expand My Connections > connection > Work Management > Memor... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162/"
] | We have a mixture of .Net apps that connect through ODBC and DB2 Connect to an iSeries LPAR that's at V5R4. We also have some batch jobs running natively on the machine (COBOL, RPG, and straight CL mostly). During certain periods of the day, we experience high page faulting and are trying to determine which apps might ... | If you don't mind Java or its jvm or doing a little coding ...
Get the following (all available for Windows, Linux, AIX, Solaris, etc ... Mac?):
* [Groovy](http://groovy.codehaus.org) for I kinda hate Java's
wordiness
* [JTOpen](http://jt400.sourceforge.net/) which is IBM's open source version of [IBM Toolbox for Jav... |
446,894 | <p>Why should I use JSON with ASP.NET? Can you give a practical example? I have read articles but not so good.</p>
| [
{
"answer_id": 446916,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 0,
"selected": false,
"text": "<p>JSON is way easier to parse than XML, and there are a lot of options to do so.</p>\n"
},
{
"answer_id": 44... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55428/"
] | Why should I use JSON with ASP.NET? Can you give a practical example? I have read articles but not so good. | How about when **returning data from a Web Service** ?
Here are two methods that are suitable for .Net 2.0, that take a DataTable or a DataRow Parameter, and return a JSON formatted string to be sent over to the client, from the web service:
```
public string GetJson(DataRow r)
{
int index = 0;
Str... |
446,906 | <p>I'm using a web service and every time I change something on the dataset, it erases all my parameters. <br><br>
The weird thing is, I can execute the web service call from the data tab and it prompts for all my parameters, but if I click to edit the data the list is empty or if I try to preview the report it blows u... | [
{
"answer_id": 480994,
"author": "Pulsehead",
"author_id": 2156,
"author_profile": "https://Stackoverflow.com/users/2156",
"pm_score": 0,
"selected": false,
"text": "<p>I get this, and it's pretty annoying. If you are developing from VS, just click on the Refresh fields button, and it n... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54617/"
] | I'm using a web service and every time I change something on the dataset, it erases all my parameters.
The weird thing is, I can execute the web service call from the data tab and it prompts for all my parameters, but if I click to edit the data the list is empty or if I try to preview the report it blows up becaus... | The problem was coming from inside the web service. I pass a sessionID (its a GUID) as a string to the report, then from the report to the web service. Inside the web service I take that string and convert it back to a Guid and pass it to our SecurityTicket object.
That is where the issue was occurring. Apparently th... |
446,912 | <p>I'm interested in writing a python client for a web-service, and for testing purposes it would be very interesting also to have a simple stub server. I'm using python 2.3, and ZSI 2.0.</p>
<p>My problem is that I do not manage to return an exception from the server.</p>
<p>If I raise an exception of the type used ... | [
{
"answer_id": 447795,
"author": "GHZ",
"author_id": 18138,
"author_profile": "https://Stackoverflow.com/users/18138",
"pm_score": 0,
"selected": false,
"text": "<p>apologies for not being able to answer the question.</p>\n\n<p>I battled with ZSI for a while.</p>\n\n<p>I'm now using SUDS... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] | I'm interested in writing a python client for a web-service, and for testing purposes it would be very interesting also to have a simple stub server. I'm using python 2.3, and ZSI 2.0.
My problem is that I do not manage to return an exception from the server.
If I raise an exception of the type used for the soap faul... | I've found the answer in this [ZSI Cookbook](http://pywebsvcs.sourceforge.net/cookbook.pdf), by Chris Hoobs, linked at the bottom of the [ZSI home page](http://pywebsvcs.sourceforge.net/):
>
> 5.4 Exceptions
>
> A thorny question is how to generate the faults at the server. With the ZSI v2.0 code as
> it is pro... |
446,931 | <p>I'm working with a WPF dialog window that contains a <code>ListBox</code>. The list box can display both an 'icon' and 'list' view. To accomplish this, we used <code>ListBoxItem</code> styles that are dynamically applied to the <code>ListBox</code>, as well as a pair of corresponding <code>ItemsPanelTemplate</code>... | [
{
"answer_id": 446979,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 1,
"selected": false,
"text": "<p>If i understand correctly, you want to eliminate the \"save\" function of the pdf viewer and replace it with your own so... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working with a WPF dialog window that contains a `ListBox`. The list box can display both an 'icon' and 'list' view. To accomplish this, we used `ListBoxItem` styles that are dynamically applied to the `ListBox`, as well as a pair of corresponding `ItemsPanelTemplate`s. As is, it displays beautifully. However, when... | If i understand correctly, you want to eliminate the "save" function of the pdf viewer and replace it with your own so that the user cannot save locally but the files is sent back to the server....
If so, then you might need to build your own PDF viewer with the options you need; removing the "save" button or making i... |
446,981 | <p>I have a script that reads a form and puts some info into a cookie:</p>
<pre><code>Dim oCookie as HttpCookie
oCookie = New HttpCookie("authInfo")
Select Case oResult
Case "No ClientID", "No Password", "No PracType", "No Encrypt", "CRC Mismatch"
oCookie.Values.Add("LoggedIn", "False")
oCookie.Values.Add("OnS... | [
{
"answer_id": 447011,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 5,
"selected": true,
"text": "<p>Request.Cookies and Response.Cookies and use of the common cookie object makes of an intuative idiom but in fact a... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I have a script that reads a form and puts some info into a cookie:
```
Dim oCookie as HttpCookie
oCookie = New HttpCookie("authInfo")
Select Case oResult
Case "No ClientID", "No Password", "No PracType", "No Encrypt", "CRC Mismatch"
oCookie.Values.Add("LoggedIn", "False")
oCookie.Values.Add("OnSupport", "Fals... | Request.Cookies and Response.Cookies and use of the common cookie object makes of an intuative idiom but in fact a Request cookie and a Response cooke are quite different.
When you assign a Cookie in the response a Set-Cookie header gets added to the output and that will contain not only the value but also the path an... |
446,986 | <p>I'm writing a very simple flash app (AS 2) to sign users up to an email newsletter; the way it works is that it uses LoadVars to hit a (same-domain) PHP script via POST with the user's email address. The PHP script then passes the info through to another domain (the newsletter mailer URL) via curl to sign up the use... | [
{
"answer_id": 447011,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 5,
"selected": true,
"text": "<p>Request.Cookies and Response.Cookies and use of the common cookie object makes of an intuative idiom but in fact a... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42450/"
] | I'm writing a very simple flash app (AS 2) to sign users up to an email newsletter; the way it works is that it uses LoadVars to hit a (same-domain) PHP script via POST with the user's email address. The PHP script then passes the info through to another domain (the newsletter mailer URL) via curl to sign up the user.
... | Request.Cookies and Response.Cookies and use of the common cookie object makes of an intuative idiom but in fact a Request cookie and a Response cooke are quite different.
When you assign a Cookie in the response a Set-Cookie header gets added to the output and that will contain not only the value but also the path an... |
446,989 | <p>I'm building a questionnaire app in asp.net mvc, and I'm having trouble with the module binder for a list of complex types.</p>
<p>First: I can't get Questionnaire.IList<QuestionGroup>.IList<Question> object graph to work with the binder. So in the sample code below i use only one level IList. </p>
<... | [
{
"answer_id": 447265,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 1,
"selected": false,
"text": "<p>You can always write your own custom ModelBinder which would require you to write about two methods. See the UpdateC... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53293/"
] | I'm building a questionnaire app in asp.net mvc, and I'm having trouble with the module binder for a list of complex types.
First: I can't get Questionnaire.IList<QuestionGroup>.IList<Question> object graph to work with the binder. So in the sample code below i use only one level IList.
Second: I would love to pass ... | I have written how to do this with MvcContrib.FluentHtml:
* [Editing a Variable Length List Of Items With MvcContrib.FluentHtml](http://lunaverse.wordpress.com/2009/01/02/editing-a-variable-length-list-of-items-with-mvccontribfluenthtml/)
* [Editing a Variable Length List Of Items With MvcContrib.FluentHtml - Take 2](... |
447,014 | <p>How can I get static content on Apache to be {cached by browser} and not {checked for freshness {with every request}}?</p>
<p>I'm working on a website hosted on Apache webserver. Recently, I was testing something with headers (Content-Type for different types of content) and saw a lot of conditional requests for im... | [
{
"answer_id": 447039,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://httpd.apache.org/docs/current/mod/mod_expires.html\" rel=\"noreferrer\">Expires</a> m... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19746/"
] | How can I get static content on Apache to be {cached by browser} and not {checked for freshness {with every request}}?
I'm working on a website hosted on Apache webserver. Recently, I was testing something with headers (Content-Type for different types of content) and saw a lot of conditional requests for images. Exam... | [Expires](http://httpd.apache.org/docs/current/mod/mod_expires.html) module in Apache solves this
```
a2enmod expires
```
it needs to be loaded in server config, and set up in `.htaccess` (or in server config).
With an [Expires](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21) header, the resource i... |
447,034 | <p>I have a really odd issue with an ItemRenderer. I have a main.mxml container with a ViewStack. When a user logs in, the initial view contains an AdvancedDataGrid--containing some data and the ItemRenderer below--which simply displays a Delete button. When the user logs in, this AdvancedDataGrid is automatically refr... | [
{
"answer_id": 447496,
"author": "kenneth",
"author_id": 53363,
"author_profile": "https://Stackoverflow.com/users/53363",
"pm_score": 0,
"selected": false,
"text": "<p>what you should be doing is when your data is refreshed call lbDelete.enabled = checkDeleteSecurity(); This will make ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5592/"
] | I have a really odd issue with an ItemRenderer. I have a main.mxml container with a ViewStack. When a user logs in, the initial view contains an AdvancedDataGrid--containing some data and the ItemRenderer below--which simply displays a Delete button. When the user logs in, this AdvancedDataGrid is automatically refresh... | It sounds like you might have a couple of things going on here. First, it's worth noting that ItemRenderers are re-used; in a grid (or list, etc.) containing, say, a list of ten album tracks, one row for each track, each row gets rendered properly when the list is initially created -- but when the underlying album, to ... |
447,035 | <p>Or, to be more clear, how can I format a block of text (in my case, to be included within a tooltip) such that some portions of the text come from bound values.</p>
<p>In plain C# I would use:</p>
<pre><code>_toolTip.Text = string.Format("{1:#0}% up, {2:#0}% down",
Environment.NewLine, percentageOne, percentag... | [
{
"answer_id": 447080,
"author": "Michael Meadows",
"author_id": 7643,
"author_profile": "https://Stackoverflow.com/users/7643",
"pm_score": 2,
"selected": false,
"text": "<p>As far as I know, WPF doesn't do what you want. You do have a much more powerful (albeit more involved) solution... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24874/"
] | Or, to be more clear, how can I format a block of text (in my case, to be included within a tooltip) such that some portions of the text come from bound values.
In plain C# I would use:
```
_toolTip.Text = string.Format("{1:#0}% up, {2:#0}% down",
Environment.NewLine, percentageOne, percentage2);
```
However th... | You can use MultiBinding + StringFormat (requires WPF 3.5 SP1):
```
<TextBox.Text>
<MultiBinding StringFormat="{}{1:#0}% up, {2:#0}% down">
<Binding Path="PercentageOne" />
<Binding Path="PercentageTwo"/>
</MultiBinding>
</TextBox.Text>
```
Regarding Run.Text - you can't bind to it but there are ... |
447,038 | <p>Where I normally am verry proud of Opera for implementing everything CSS really correct it seems that implementing a custom cursor with the following line doesn't seem to work</p>
<pre><code>cursor:url("../pics/merge.gif");
</code></pre>
<p>The URL is correct since it works for regular background-image properties.... | [
{
"answer_id": 447050,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 2,
"selected": false,
"text": "<p>Opera <a href=\"http://www.quirksmode.org/css/cursor.html\" rel=\"nofollow noreferrer\">doesn't seem to</a> support the url ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | Where I normally am verry proud of Opera for implementing everything CSS really correct it seems that implementing a custom cursor with the following line doesn't seem to work
```
cursor:url("../pics/merge.gif");
```
The URL is correct since it works for regular background-image properties.
Works in other browser... | There is a workaround for opera using javascript:
<http://plugins.jquery.com/project/customcursor>
works ok, tested in opera 11, though I'd recommend usual css approach for other browsers, especially older ie, which are not too fast even without js. |
447,044 | <p>I need to change the title of a site collection in SharePoint (MOSS 2007). I found one post saying it can be done in SharePoint Designer, but I wasn't seeing the specified menus, and haven't been able to find it anywhere else. I'm assuming I can do it programmatically if necessary, but I'd like to think they made it... | [
{
"answer_id": 447198,
"author": "barneytron",
"author_id": 48988,
"author_profile": "https://Stackoverflow.com/users/48988",
"pm_score": 0,
"selected": false,
"text": "<p>When you said changing the \"title of a site collection\", do you mean the title of the site collection's top-level-... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55449/"
] | I need to change the title of a site collection in SharePoint (MOSS 2007). I found one post saying it can be done in SharePoint Designer, but I wasn't seeing the specified menus, and haven't been able to find it anywhere else. I'm assuming I can do it programmatically if necessary, but I'd like to think they made it ea... | OK, I think I know what you mean now. You want to change the title for the html page and not the title of a site. I did a little digging and here's what I found.
The text "Home" comes from this xml file (on my rig):
**C:\Inetpub\wwwroot\wss\VirtualDirectories\80\App\_GlobalResources\wss.en-US.resx**
```
<data name=... |
447,048 | <p>With this set of commands, what are the <code>{}</code> and <code>\;</code> characters for?</p>
<pre><code>find . -name '*.clj' -exec grep -r resources {} \;
</code></pre>
| [
{
"answer_id": 447054,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 6,
"selected": true,
"text": "<p>See <a href=\"http://unixhelp.ed.ac.uk/CGI/man-cgi?find\" rel=\"noreferrer\">man find</a>. (particular the part ab... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10522/"
] | With this set of commands, what are the `{}` and `\;` characters for?
```
find . -name '*.clj' -exec grep -r resources {} \;
``` | See [man find](http://unixhelp.ed.ac.uk/CGI/man-cgi?find). (particular the part about `-exec`)
When using `-exec` to run a command on each of the files found, the `{}` is replaced with the name of each file found, and the command is terminated by `\;`
In your example, all files found under the current directory (`.`)... |
447,052 | <p>I have the following command which deletes files that are one day old and that are of mp3 file type.</p>
<pre><code>find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1
-type f -name "*.mp3" |xargs rm -f
</code></pre>
<p>The problem with this is when I run it, it sometimes says,</p>
<blockquote>
<p... | [
{
"answer_id": 447087,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 0,
"selected": false,
"text": "<p>Check your man page for find, it might support -delete, making it as simple as </p>\n\n<pre><code>find /home/get/publi... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | I have the following command which deletes files that are one day old and that are of mp3 file type.
```
find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1
-type f -name "*.mp3" |xargs rm -f
```
The problem with this is when I run it, it sometimes says,
>
> "fork": resource xargs not available.
>
>... | what about trying:
```
find /home/get/public_html/audio -daystart -maxdepth 1 -mtime +1
-type f -name "*.mp3" -exec rm -f {} \;
``` |
447,063 | <p>I've a class that has a list of IDs with a function for adding new IDs from a list of objects.</p>
<p>I've got this resolved, but I'm sure this can be done with much less code.</p>
<pre><code>Public Class Page
Private _IdList As List(Of Integer)
Private _HasNewItems As Boolean = False
Public Sub AddItems(B... | [
{
"answer_id": 447077,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": true,
"text": "<p>Try the following</p>\n\n<pre><code>Public Sub AddItems(ByVal items as List(Of Item))\n Dim oldCount = _IdList.Count\n... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41385/"
] | I've a class that has a list of IDs with a function for adding new IDs from a list of objects.
I've got this resolved, but I'm sure this can be done with much less code.
```
Public Class Page
Private _IdList As List(Of Integer)
Private _HasNewItems As Boolean = False
Public Sub AddItems(ByVal Items As List(Of... | Try the following
```
Public Sub AddItems(ByVal items as List(Of Item))
Dim oldCount = _IdList.Count
_IdList.AddRange(items.Select(Function(x) x.ID).Except(_IdList))
_HasNewItems = oldCount < _IdList.Count
End Sub
```
The trick here is that Except will return all items Except when they are present in the enume... |
447,082 | <p>Given this definition:</p>
<pre><code>[UniqueId("Ident")]
public class MyClass : MyBase
{
public int Ident{ get; }
}
</code></pre>
<p>What is the best way from the "MyBase" class to get the "UniqueId" attribute, find the matching property name and get the underlying value?</p>
| [
{
"answer_id": 447094,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Wouldn't an abstract method / property in the base-class be more suitable?</p>\n\n<pre><code>public abstract int Un... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | Given this definition:
```
[UniqueId("Ident")]
public class MyClass : MyBase
{
public int Ident{ get; }
}
```
What is the best way from the "MyBase" class to get the "UniqueId" attribute, find the matching property name and get the underlying value? | Wouldn't an abstract method / property in the base-class be more suitable?
```
public abstract int UniqueId {get;}
```
Via attributes, like so:
```
object GetUniqueId() // or int
{
Type type = GetType();
UniqueIdAttribute attrib = null;
foreach(UniqueIdAttribute tmp in
type.GetCustomAttributes(... |
447,083 | <p>So I have this query that is relatively fast at ~0.5 seconds but when I add an ORDER BY clause it jumps up to nearly 30 seconds.</p>
<p>Original query: (returns in ~0.5 seconds)</p>
<pre><code>SELECT table1.*,table2.* FROM table1 LEFT OUTER JOIN table2 ON table1.column2=table2.column3 WHERE table1.column1='value' ... | [
{
"answer_id": 447093,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 3,
"selected": false,
"text": "<p>This takes longer because the query can't just pick the first 4 items it finds. It has to order the entire list and the... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | So I have this query that is relatively fast at ~0.5 seconds but when I add an ORDER BY clause it jumps up to nearly 30 seconds.
Original query: (returns in ~0.5 seconds)
```
SELECT table1.*,table2.* FROM table1 LEFT OUTER JOIN table2 ON table1.column2=table2.column3 WHERE table1.column1='value' LIMIT 4
```
Query w... | This takes longer because the query can't just pick the first 4 items it finds. It has to order the entire list and then choose the top 4 from that.
Fix this by adding an index which includes table1{column4, ...}. If you only need a few columns from table 1 (and they're narrow), I'd add them **all** to the index ([cov... |
447,086 | <p>One of the biggest annoyances I find in Python is the inability of the <code>re</code> module to save its state without explicitly doing it in a match object. Often, one needs to parse lines and if they comply a certain regex take out values from them by the same regex. I would like to write code like this:</p>
<pr... | [
{
"answer_id": 447140,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 3,
"selected": false,
"text": "<p>You might like <a href=\"http://code.activestate.com/recipes/456151/\" rel=\"nofollow noreferrer\">this module</... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8206/"
] | One of the biggest annoyances I find in Python is the inability of the `re` module to save its state without explicitly doing it in a match object. Often, one needs to parse lines and if they comply a certain regex take out values from them by the same regex. I would like to write code like this:
```
if re.match('foo ... | Trying out some ideas...
It looks like you would ideally want an expression with side effects. If this were allowed in Python:
```
if m = re.match('foo (\w+) bar (\d+)', line):
# do stuff with m.group(1) and m.group(2)
elif m = re.match('baz whoo_(\d+)', line):
# do stuff with m.group(1)
elif ...
```
... then y... |
447,097 | <p>It seems I don't understand javascript callbacks quite as well as I thought.</p>
<p>In the following example, I would think that each copy of function in setTimeout would refer to its own copy of the variable "index". Therefore, running the example should produce the following alerts: "zero" "one" "two".</p>
<pre>... | [
{
"answer_id": 447127,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 2,
"selected": true,
"text": "<p><code>index</code> changes with each iteration of the loop. What you want is to place <code>index</code> into a c... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44683/"
] | It seems I don't understand javascript callbacks quite as well as I thought.
In the following example, I would think that each copy of function in setTimeout would refer to its own copy of the variable "index". Therefore, running the example should produce the following alerts: "zero" "one" "two".
```
var array = ["z... | `index` changes with each iteration of the loop. What you want is to place `index` into a closure not affected by the loop:
```
var array = ["zero", "one", "two"];
var out = "";
for(var i = 0; i < 3; i++) {
(function(index) {
setTimeout( function(){alert(array[index])}, 1 );
})(i)
}
``` |
447,101 | <p>I have a simple script which is used to start another program. This other program may sometimes yield a <code>SIGSEGV</code>, which disrupts my output. I have therefore added a couple of lines which is supposed to temporarily redirect the <code>stderr</code> to <code>/dev/null</code> such that the <code>SIGSEGV</cod... | [
{
"answer_id": 447118,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 0,
"selected": false,
"text": "<p>Why not just redirect it for the progname run only?</p>\n\n<pre><code> progname > ./tmp/run.txt 2>/dev/null ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51634/"
] | I have a simple script which is used to start another program. This other program may sometimes yield a `SIGSEGV`, which disrupts my output. I have therefore added a couple of lines which is supposed to temporarily redirect the `stderr` to `/dev/null` such that the `SIGSEGV` is ignored. The following is a draft of my c... | Another option is:
```
exec 3> /dev/stderr 2> /dev/null
progname >& ./tmp/run.txt && run_status='OK'
exec 2>&3
```
Or even
```
exec 3>&2 2> /dev/null
progname >& ./tmp/run.txt && run_status='OK'
exec 2>&3
```
That way the script preserves the separation of stdout and stderr for the script (ie. the scripts stdout ... |
447,107 | <p>I've never been sure that I understand the difference between str/unicode decode and encode.</p>
<p>I know that <code>str().decode()</code> is for when you have a string of bytes that you know has a certain character encoding, given that encoding name it will return a unicode string.</p>
<p>I know that <code>unico... | [
{
"answer_id": 447138,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>There are a few encodings that can be used to de-/encode from str to str or from unicode to unicode. For example base64, he... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | I've never been sure that I understand the difference between str/unicode decode and encode.
I know that `str().decode()` is for when you have a string of bytes that you know has a certain character encoding, given that encoding name it will return a unicode string.
I know that `unicode().encode()` converts unicode c... | The `decode` method of unicode strings really doesn't have any applications at all (unless you have some non-text data in a unicode string for some reason -- see below). It is mainly there for historical reasons, i think. In Python 3 it is completely gone.
`unicode().decode()` will perform an implicit *encoding* of `s... |
447,117 | <p>I have the following code in my index view.</p>
<pre><code>latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10]
for entry in latest_entry_list:
entry.views = entry.views + 1
entry.save()
</code></pre>
<p>If there are ten (the limit) rows returned from the initial que... | [
{
"answer_id": 447133,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Revised</strong></p>\n\n<p>You're updating 10 separate, individual, distinct objects.</p>\n\n<p>The 10 separate,... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53390/"
] | I have the following code in my index view.
```
latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10]
for entry in latest_entry_list:
entry.views = entry.views + 1
entry.save()
```
If there are ten (the limit) rows returned from the initial query, will the save issue 10... | You can use `F()` objects for this.
Here is how you import `F`: `from django.db.models import F`
**[New in Django 1.1](http://docs.djangoproject.com/en/dev/topics/db/queries/#updating-multiple-objects-at-once).**
Calls to update can also use F() objects to update one field based on the value of another field in t... |
447,122 | <p>In SQL Server 2008 and given</p>
<pre><code>TableA(A_ID, A_Data)
TableB(B_ID, B_Data)
ViewC(A_or_B_ID, A_or_B_Data)
</code></pre>
<p>is it possible to define <code>TableZ(A_or_B_ID, Z_Data)</code> such that <code>Z.A_or_B_ID</code> column is constrained to the values found in <code>ViewC</code>? Can this be done ... | [
{
"answer_id": 447151,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 8,
"selected": true,
"text": "<p>You can't reference a view in a foreign key.</p>\n"
},
{
"answer_id": 447154,
"author": "Jarrett Meyer"... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12260/"
] | In SQL Server 2008 and given
```
TableA(A_ID, A_Data)
TableB(B_ID, B_Data)
ViewC(A_or_B_ID, A_or_B_Data)
```
is it possible to define `TableZ(A_or_B_ID, Z_Data)` such that `Z.A_or_B_ID` column is constrained to the values found in `ViewC`? Can this be done with a foreign key against the view? | You can't reference a view in a foreign key. |
447,134 | <p>I have encountered a problem that I have not come accross yet when setting up a log in page using php.</p>
<p>The page has a error message that relates to line 1 ( <code>require_once('../Connections/Login.php)</code></p>
<p>that states</p>
<blockquote>
<p>[function.require-once]: failed to open stream: No such file ... | [
{
"answer_id": 447165,
"author": "James Anderson",
"author_id": 38207,
"author_profile": "https://Stackoverflow.com/users/38207",
"pm_score": 0,
"selected": false,
"text": "<p>Where is your \"Connections/Login.php\" relative to the currrent php file.</p>\n\n<p>php will look for the file ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41378/"
] | I have encountered a problem that I have not come accross yet when setting up a log in page using php.
The page has a error message that relates to line 1 ( `require_once('../Connections/Login.php)`
that states
>
> [function.require-once]: failed to open stream: No such file or directory
> Fatal Error: require\_onc... | I think your require statement should be:
```
require_once 'Connections/connComparisonLogin.php';
``` |
447,188 | <p>I'm developing an Erlang system and having reoccurring problems with the fact that records are compile-time pre-processor macros (almost), and that they cant be manipulated at runtime...
basically, I'm working with a property pattern, where properties are added at run-time to objects on the front-end (AS3). Ideally... | [
{
"answer_id": 463338,
"author": "max",
"author_id": 49407,
"author_profile": "https://Stackoverflow.com/users/49407",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure I fully understand your Problem but I have moved from records to <a href=\"http://erlang.org/documentation/doc... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51923/"
] | I'm developing an Erlang system and having reoccurring problems with the fact that records are compile-time pre-processor macros (almost), and that they cant be manipulated at runtime...
basically, I'm working with a property pattern, where properties are added at run-time to objects on the front-end (AS3). Ideally, I... | It sounds like you want to be able to do something like `get_record_field(Field, SomeRecord)` where `Field` is determined at runtime by user interface code say.
You're right in that you can't do this in standard erlang as records and the `record_info` function are expanded and eliminated at compile time.
There are a ... |
447,189 | <p>I want to use the Split function on a string but keep the delimiting sequence as the first characters in each element of the string array. I am using this function to split HTML on every instance of a URL so I can run regex patterns on the URLs on a website. Is there any overloads of the split function to do this? o... | [
{
"answer_id": 447225,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": true,
"text": "<p>There is no built-in method for doing that. If you are splitting on a single pattern though, this can be coded out wit... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2501/"
] | I want to use the Split function on a string but keep the delimiting sequence as the first characters in each element of the string array. I am using this function to split HTML on every instance of a URL so I can run regex patterns on the URLs on a website. Is there any overloads of the split function to do this? or d... | There is no built-in method for doing that. If you are splitting on a single pattern though, this can be coded out with the following
```
public IEnumerable<string> SplitAndKeepPrefix(this string source, string delimeter) {
return SplitAndKeepPrefix(source, delimeter, StringSplitOptions.None);
}
public IEnumerable<... |
447,193 | <p>Take the following useless program:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
IUnityContainer unityContainer = new UnityContainer();
IWindsorContainer windsorContainer = new WindsorContainer();
Program unityProgram = unityContainer.Resolve<Program>();
... | [
{
"answer_id": 499675,
"author": "Krzysztof Kozmic",
"author_id": 13163,
"author_profile": "https://Stackoverflow.com/users/13163",
"pm_score": 4,
"selected": true,
"text": "<p>Windsor currently does not support that, and it's by design. The reasoning is that you should explicitly regist... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37725/"
] | Take the following useless program:
```
class Program
{
static void Main(string[] args)
{
IUnityContainer unityContainer = new UnityContainer();
IWindsorContainer windsorContainer = new WindsorContainer();
Program unityProgram = unityContainer.Resolve<Program>();
Program castle... | Windsor currently does not support that, and it's by design. The reasoning is that you should explicitly register types you need so that you dont get misconfigured object.
There is however a possibility that there will be added a hook to create non-registered type at some point in the near future, as this is needed by... |
447,196 | <p>Any free/paid <strong>API to get financial news</strong> either world-wide / country specific.</p>
| [
{
"answer_id": 447222,
"author": "Robin Rodricks",
"author_id": 41021,
"author_profile": "https://Stackoverflow.com/users/41021",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://mashable.com/2008/05/12/reuters-ap/\" rel=\"nofollow noreferrer\"><strong>Reuters</strong> News... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] | Any free/paid **API to get financial news** either world-wide / country specific. | Take it off **Yahoo** as an RSS feed:
```
http://finance.yahoo.com/rss/topstories
``` |
447,197 | <p>Is there any syntactical way in jQuery to define multiple CSS attributes without stringing everything out to the right like this:</p>
<pre><code>$("#message").css("width", "550px").css("height", "300px").css("font-size", "8pt");
</code></pre>
<p>If you have, say, 20 of these your code will become hard to read, any... | [
{
"answer_id": 447207,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 11,
"selected": true,
"text": "<p>Better to just use <a href=\"https://api.jquery.com/addClass/\" rel=\"noreferrer\"><code>.addClass()</code></a> and <a ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | Is there any syntactical way in jQuery to define multiple CSS attributes without stringing everything out to the right like this:
```
$("#message").css("width", "550px").css("height", "300px").css("font-size", "8pt");
```
If you have, say, 20 of these your code will become hard to read, any solutions?
From jQuery A... | Better to just use [`.addClass()`](https://api.jquery.com/addClass/) and [`.removeClass()`](https://api.jquery.com/removeclass/) even if you have 1 or more styles to change. It's more maintainable and readable.
If you really have the urge to do multiple CSS properties, then use the following:
```
.css({
'font-size... |
447,199 | <p>Am trying to implement a <strong>generic way for reading sections</strong> from a config file. The config file may contain 'standard' sections or 'custom' sections as below.</p>
<pre><code><configuration>
<configSections>
<section name="NoteSettings" type="System.Configuration.NameValueSectionHa... | [
{
"answer_id": 447418,
"author": "Dead account",
"author_id": 52458,
"author_profile": "https://Stackoverflow.com/users/52458",
"pm_score": 2,
"selected": false,
"text": "<p>Read your config into a XmlDocument then use XPath to find the elements your looking for?</p>\n\n<p>Something like... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40981/"
] | Am trying to implement a **generic way for reading sections** from a config file. The config file may contain 'standard' sections or 'custom' sections as below.
```
<configuration>
<configSections>
<section name="NoteSettings" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
<appSettings... | Since configuration file is XML file, you can use XPath queries for this task:
```
Configuration configFile = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
XmlDocument document = new XmlDocument();
document.Load(configFile.FilePath);
foreach (XmlNode node in docum... |
447,206 | <p>Does anybody know of a convenient means of determining if a string value "qualifies" as a floating-point number?</p>
<pre><code>bool IsFloat( string MyString )
{
... etc ...
return ... // true if float; false otherwise
}
</code></pre>
| [
{
"answer_id": 447277,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://www.cplusplus.com/reference/clibrary/cstdlib/atof.html\" rel=\"nofollow noreferrer\... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795/"
] | Does anybody know of a convenient means of determining if a string value "qualifies" as a floating-point number?
```
bool IsFloat( string MyString )
{
... etc ...
return ... // true if float; false otherwise
}
``` | If you can't use a Boost library function, you can write your own isFloat function like this.
```
#include <string>
#include <sstream>
bool isFloat( string myString ) {
std::istringstream iss(myString);
float f;
iss >> noskipws >> f; // noskipws considers leading whitespace invalid
// Check the entire... |
447,221 | <p>OK, it sounds easy, I know I can use Process.Start("<a href="http://mysite" rel="nofollow noreferrer">http://mysite</a>");</p>
<p>But I need to open 2 web sites at one go!! something like</p>
<p>Process.Start("<a href="http://mysite" rel="nofollow noreferrer">http://mysite</a>");
Process.Start("<a href="http://oth... | [
{
"answer_id": 447243,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 0,
"selected": false,
"text": "<pre><code> Process.Start(\"iexplore\",\"http://www.google.com\");\n Process.Start(\"iexplore\", \"http://www.yahoo.co... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | OK, it sounds easy, I know I can use Process.Start("<http://mysite>");
But I need to open 2 web sites at one go!! something like
Process.Start("<http://mysite>");
Process.Start("<http://othersite>");
I can't get this to work, since the process it opens only the second site.
Any help will be appreciated ,
Thanks, | You could try opening each in a new thread.
```
Thread thread1 = new Thread(new ThreadStart(Process.Start("http://mysite")));
thread1.Start();
Thread thread2 = new Thread(new ThreadStart(Process.Start("http://othersite")));
thread2.Start();
thread1.Join();
thread2.Join();
``` |
447,242 | <p>I want the "tr" that's currently hovered over to change color, and then change back when the mouse is no longer over it. Is this possible using pure CSS, or is javascript the only solution? (I currently have a javascript solution, so I don't need examples of that) </p>
<p>Thanks!</p>
| [
{
"answer_id": 447246,
"author": "Bryan A",
"author_id": 29707,
"author_profile": "https://Stackoverflow.com/users/29707",
"pm_score": 1,
"selected": false,
"text": "<p>I believe that javascript is the only solution that will provide cross-browser support.</p>\n"
},
{
"answer_id"... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47645/"
] | I want the "tr" that's currently hovered over to change color, and then change back when the mouse is no longer over it. Is this possible using pure CSS, or is javascript the only solution? (I currently have a javascript solution, so I don't need examples of that)
Thanks! | Yes, this is possible in CSS. The example below will have a red background normally, and a green background when the row is hovered over.
```
tr td { background: #f00; }
tr:hover td { background: #0f0; }
```
However, it should be noted that this will not work in IE6, as it does not understand the ":hover" pseudo cl... |
447,250 | <p>How can I test if a RegEx matches a string <em>exactly</em>?</p>
<pre><code>var r = /a/;
r.test("a"); // returns true
r.test("ba"); // returns true
testExact(r, "ba"); // should return false
testExact(r, "a"); // should return true
</code></pre>
| [
{
"answer_id": 447258,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 8,
"selected": true,
"text": "<p>Either modify the pattern <strong>beforehand</strong> so that it only matches the entire string:</p>\n\n<pre><code>var r = /... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | How can I test if a RegEx matches a string *exactly*?
```
var r = /a/;
r.test("a"); // returns true
r.test("ba"); // returns true
testExact(r, "ba"); // should return false
testExact(r, "a"); // should return true
``` | Either modify the pattern **beforehand** so that it only matches the entire string:
```
var r = /^a$/
```
or check **afterward** whether the pattern matched the whole string:
```
function matchExact(r, str) {
var match = str.match(r);
return match && str === match[0];
}
``` |
447,268 | <p>I am very familiar with <code>vlookup</code> and <code>hlookup</code> functions in Excel. However, I am looking for a method of doing both. Take this example:</p>
<pre><code> A B C
1 Resources
2 Task Mgr Sr. Mgr
3 -----------------------------
4 T... | [
{
"answer_id": 447406,
"author": "j_random_hacker",
"author_id": 47984,
"author_profile": "https://Stackoverflow.com/users/47984",
"pm_score": 1,
"selected": false,
"text": "<pre><code>=OFFSET(A3,MATCH(\"Task 3\", A4:A7, 0),MATCH(\"Mgr\",B2:C2,0))\n</code></pre>\n\n<p>Of course, you're p... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45109/"
] | I am very familiar with `vlookup` and `hlookup` functions in Excel. However, I am looking for a method of doing both. Take this example:
```
A B C
1 Resources
2 Task Mgr Sr. Mgr
3 -----------------------------
4 Task 1 30% 70%
5 Task ... | A combination of INDEX and MATCH will do the trick:
>
> =INDEX($B$4:$C$7,MATCH("Task 3",$A$4:$A$7,0),MATCH("Mgr",$B$2:$C$2,0))
>
>
> |
447,279 | <p>I have tried to use the MouseMove event to track the position of the mouse.</p>
<pre><code>protected override void OnMouseMove(MouseEventArgs e)
</code></pre>
<p>This works when the mouse is over the given UIElement (in this case, my application's window,) however I would like to access this data regardless of whe... | [
{
"answer_id": 447406,
"author": "j_random_hacker",
"author_id": 47984,
"author_profile": "https://Stackoverflow.com/users/47984",
"pm_score": 1,
"selected": false,
"text": "<pre><code>=OFFSET(A3,MATCH(\"Task 3\", A4:A7, 0),MATCH(\"Mgr\",B2:C2,0))\n</code></pre>\n\n<p>Of course, you're p... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54405/"
] | I have tried to use the MouseMove event to track the position of the mouse.
```
protected override void OnMouseMove(MouseEventArgs e)
```
This works when the mouse is over the given UIElement (in this case, my application's window,) however I would like to access this data regardless of where the mouse is, and prefe... | A combination of INDEX and MATCH will do the trick:
>
> =INDEX($B$4:$C$7,MATCH("Task 3",$A$4:$A$7,0),MATCH("Mgr",$B$2:$C$2,0))
>
>
> |
447,282 | <p>In my computer this code takes 17 seconds (1000 millions times):</p>
<pre><code>static void Main(string[] args) {
var sw = new Stopwatch(); sw.Start();
int r;
for (int i = 1; i <= 100000000; i++) {
for (int j = 1; j <= 10; j++) {
MyDivRem (i,j, out r);
}
}
Console.WriteLine... | [
{
"answer_id": 447330,
"author": "Sander",
"author_id": 2928,
"author_profile": "https://Stackoverflow.com/users/2928",
"pm_score": 2,
"selected": false,
"text": "<p>The answer is probably that nobody has thought this a priority - it's good enough. The fact that this has not been fixed w... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38561/"
] | In my computer this code takes 17 seconds (1000 millions times):
```
static void Main(string[] args) {
var sw = new Stopwatch(); sw.Start();
int r;
for (int i = 1; i <= 100000000; i++) {
for (int j = 1; j <= 10; j++) {
MyDivRem (i,j, out r);
}
}
Console.WriteLine(sw.ElapsedMilliseco... | Grrr. The only reason for this function to exist is to take advantage of the CPU instruction for this, and they didn't even do it! |
447,288 | <p>I want to process each source code file after it has been preprocessed:</p>
<pre><code>myprocess `gcc -E file1.c`
myprocess `gcc -E file2.c`
...
myprocess `gcc -E fileN.c`
</code></pre>
<p>This gets tedious so how do I make this a single command?<br>
That is, something along the line: </p>
<pre><code>myp... | [
{
"answer_id": 447305,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 4,
"selected": true,
"text": "<p>You mean like </p>\n\n<pre><code> for i in file*.c ; do\n myprocess `gcc -E $i`\n done\n</code></pre>\n"
... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53930/"
] | I want to process each source code file after it has been preprocessed:
```
myprocess `gcc -E file1.c`
myprocess `gcc -E file2.c`
...
myprocess `gcc -E fileN.c`
```
This gets tedious so how do I make this a single command?
That is, something along the line:
```
myprocess SOMETHINGMAGIC(gcc -E file*.c)
... | You mean like
```
for i in file*.c ; do
myprocess `gcc -E $i`
done
``` |
447,289 | <p>I'm having a problem running tomcat 6 with eclipse 3 in ubuntu.</p>
<p>I installed tomcat 6 on my machine and when I tested it using <code>http://localhost:8080</code>, it worked fine.</p>
<p>But whenever i want to create a server in eclipse, i select Tomcat 6 , i get the following message
<code>"Cannot create a s... | [
{
"answer_id": 447326,
"author": "Vinze",
"author_id": 26859,
"author_profile": "https://Stackoverflow.com/users/26859",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure, but maybe your version of Eclipse does not support the latest Tomcat version? Try to update Eclipse. I have Ecl... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm having a problem running tomcat 6 with eclipse 3 in ubuntu.
I installed tomcat 6 on my machine and when I tested it using `http://localhost:8080`, it worked fine.
But whenever i want to create a server in eclipse, i select Tomcat 6 , i get the following message
`"Cannot create a server using the selected type"`, ... | There’s a better workaround so you can keep Ubuntu’s Tomcat6 (taken from <http://ubuntuforums.org/showthread.php?p=8541057>, by DisDis)
In a terminal:
```
sudo apt-get install tomcat6
cd /usr/share/tomcat6
sudo ln -s /var/lib/tomcat6/conf conf
sudo ln -s /etc/tomcat6/policy.d/03catalina.policy conf/catalina.policy
su... |
447,292 | <p>Does anyone know a way to open a 2nd form in a .NET application with a certain tab selected in a tab control on that form?</p>
<p>This is what my current code looks like which just opens the form:</p>
<pre><code>SettingsForm TheSettingsForm = new SettingsForm(this);
TheSettingsForm.Show();
</code></pre>
<p>Settin... | [
{
"answer_id": 447316,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": true,
"text": "<p>You just need to expose a property on your form that allows the calling code to set the desired tab. You might do it... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/117494/"
] | Does anyone know a way to open a 2nd form in a .NET application with a certain tab selected in a tab control on that form?
This is what my current code looks like which just opens the form:
```
SettingsForm TheSettingsForm = new SettingsForm(this);
TheSettingsForm.Show();
```
SettingsForm.cs is the name of the 2nd ... | You just need to expose a property on your form that allows the calling code to set the desired tab. You might do it just by index like this:
```
var form = new SettingsForm(this);
form.SelectedTab = 2;
form.Show();
```
The property on the form would just set the appropriate property on the tab control:
```
public ... |
447,302 | <p>One of the problems I often run into, is that I will include '<strong>Windows</strong>' in my uses clause, and then I will later add '<strong>JwaWinBase</strong>' for some specific calls. </p>
<p>However, many of the functions in the 'Windows' unit are the same as in JwaWinBase, and I start getting errors in my mai... | [
{
"answer_id": 447341,
"author": "Uli Gerhardt",
"author_id": 1431618,
"author_profile": "https://Stackoverflow.com/users/1431618",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe it's enough to just switch the order of the two units in the uses clause.</p>\n"
},
{
"answer_id... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12458/"
] | One of the problems I often run into, is that I will include '**Windows**' in my uses clause, and then I will later add '**JwaWinBase**' for some specific calls.
However, many of the functions in the 'Windows' unit are the same as in JwaWinBase, and I start getting errors in my main unit, all over the place, until I ... | There isn't.
However, the function calls are handled in the reverse order they're in the uses clause, so that if you have this:
```
uses
Windows, JwaWinBase;
```
... it will call Jwa functions by default. However, if you reverse them:
```
uses
JwaWinBase, Windows;
```
... it should call the Windows functions... |
447,325 | <p>Given a DBIx::Class resultset, for example:</p>
<pre><code>my $rs = $c->model("DB::Card")->search({family_name => "Smith"});
</code></pre>
<p>the tutorials I've read use the stash to pass an arrayref of rows:</p>
<pre><code>$c->stash->{cards} = [$rs->all];
</code></pre>
<p>This results in the q... | [
{
"answer_id": 447410,
"author": "friedo",
"author_id": 20745,
"author_profile": "https://Stackoverflow.com/users/20745",
"pm_score": 5,
"selected": true,
"text": "<p>Sure. You can pass the result set directly to TT and iterate over it in the template.</p>\n\n<pre><code>$c->stash->... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12874/"
] | Given a DBIx::Class resultset, for example:
```
my $rs = $c->model("DB::Card")->search({family_name => "Smith"});
```
the tutorials I've read use the stash to pass an arrayref of rows:
```
$c->stash->{cards} = [$rs->all];
```
This results in the query getting executed at this point, and the resulting objects stuf... | Sure. You can pass the result set directly to TT and iterate over it in the template.
```
$c->stash->{cards} = $rs;
```
...and then:
```
[% WHILE (card = cards.next) %]
[% card.given_name %] [% card.family_name %]
[% END %]
``` |
447,329 | <p>Can somebody help me getting Wimpy player to work in Firefox? I followed the guide from <a href="http://wimpyplayer.com/docs/mp3/insert.html.html" rel="nofollow noreferrer">Wimpy documentation page</a> and am still getting nowhere.</p>
<p>For tests, I used the same HTML code to embed different swf file and it works... | [
{
"answer_id": 447410,
"author": "friedo",
"author_id": 20745,
"author_profile": "https://Stackoverflow.com/users/20745",
"pm_score": 5,
"selected": true,
"text": "<p>Sure. You can pass the result set directly to TT and iterate over it in the template.</p>\n\n<pre><code>$c->stash->... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2169/"
] | Can somebody help me getting Wimpy player to work in Firefox? I followed the guide from [Wimpy documentation page](http://wimpyplayer.com/docs/mp3/insert.html.html) and am still getting nowhere.
For tests, I used the same HTML code to embed different swf file and it works perfectly. Could it be the SWF file corrupted ... | Sure. You can pass the result set directly to TT and iterate over it in the template.
```
$c->stash->{cards} = $rs;
```
...and then:
```
[% WHILE (card = cards.next) %]
[% card.given_name %] [% card.family_name %]
[% END %]
``` |
447,339 | <p>I am trying to use some classes from the MFC Feature Pack to improve the look & feel of my MFC application.</p>
<p>In my application, I use one CReBar object to dock three different toolbars. I have updated the class of this object to use CMFCReBar, but it doesn´t look good when using some visual styles.</p>
<... | [
{
"answer_id": 447370,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 0,
"selected": false,
"text": "<p>I've noticed a few visual problems when using the Office 2007 style too - it seems to be a little bit buggy. Can ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14053/"
] | I am trying to use some classes from the MFC Feature Pack to improve the look & feel of my MFC application.
In my application, I use one CReBar object to dock three different toolbars. I have updated the class of this object to use CMFCReBar, but it doesn´t look good when using some visual styles.
It seems there's a ... | Paul DiLascia wrote a [class](http://msdn.microsoft.com/en-us/magazine/cc163931.aspx) to lock the CToolBar, I used it to create this class which will work on CMFCToolbar. And you can copy it to do exactly the same sort of thing for CMFCMenuBar - just change MFCToolBar to MFCMenuBar and you're done.
[;
DB.Open();
Reader = CodeStatus.ExecuteReader();
FormView1.DataSource = Reader;
FormView1.DataBind();
DB.Close();
</code></pre>
<p>It works with a gridview, which then displays the data, but with this formview it doesn'... | [
{
"answer_id": 447409,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 0,
"selected": false,
"text": "<p>I know this doesn't directly answer your question, but have you tried using a DataTable?</p>\n\n<pre><code>using(SqlDataA... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53409/"
] | I've got this code here:
```
SqlCommand CodeStatus = new SqlCommand(SQL, DB);
DB.Open();
Reader = CodeStatus.ExecuteReader();
FormView1.DataSource = Reader;
FormView1.DataBind();
DB.Close();
```
It works with a gridview, which then displays the data, but with this formview it doesn't display the data. Why no... | MSDN defines FormvView as **"A FormView displays the values of a single record from a data source using user-defined templates."**
So you will need to look at a few things-
1. 1.Test what your reader has. Does it even have rows. Trivial but a common
problem.
2. Provide the formview with a template in itemtemplate atl... |
447,369 | <p>I have an application that has been converted from VS2005 2.0 framework to VS2008 3.5 framework. I am attempting to add the ability to use the AjaxControlToolkit DLL <a href="http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488" rel="nofollow noreferrer">[AjaxControlToolkit-Framewo... | [
{
"answer_id": 447375,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": false,
"text": "<p>I'd like to say I always write a unit test before I write the corresponding code to pass it, but I'd be lying.</p>\... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53002/"
] | I have an application that has been converted from VS2005 2.0 framework to VS2008 3.5 framework. I am attempting to add the ability to use the AjaxControlToolkit DLL [[AjaxControlToolkit-Framework3.5SP1-DllOnly.zip]](http://www.codeplex.com/AjaxControlToolkit/Release/ProjectReleases.aspx?ReleaseId=16488) download only ... | I tend to code until I have something that should produce a well-defined observable behavior. Usually, this is a single public API function, sometimes a full class. This also encourages me to break down the problem into small functions with well-defined observable behavior. Most of my functions are smaller than a full ... |
447,379 | <p>Today, I have seen some legacy code. In the destructor there is a statement like "<code>delete this</code>". I think, this call will be recursive. Why it is working?</p>
<p>I made some quick search on Y!, I found that if there is a need to restrict the user to create the stack object, we can make destructor private... | [
{
"answer_id": 447404,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 6,
"selected": true,
"text": "<p>\"delete this\" is commonly used for ref counted objects. For a ref counted object the decision of when to delete is u... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28641/"
] | Today, I have seen some legacy code. In the destructor there is a statement like "`delete this`". I think, this call will be recursive. Why it is working?
I made some quick search on Y!, I found that if there is a need to restrict the user to create the stack object, we can make destructor private and provide an inter... | "delete this" is commonly used for ref counted objects. For a ref counted object the decision of when to delete is usually placed on the object itself. Here is an example of what a Release method would look like [1].
```
int MyRefCountedObject::Release() {
_refCount--;
if ( 0 == _refCount ) {
delete this;
... |
447,391 | <p>I've got a bunch of first names in a field that carry a middle initial with a '.' at the end..<br><br>I need a regex to convert this example:<br><br>Kenneth R.<br><br>into<br><br>Kenneth<br><br>I was trying to build my own and found this useful site btw..<br><br><a href="http://www.gskinner.com/RegExr/" rel="nofollo... | [
{
"answer_id": 447411,
"author": "siukurnin",
"author_id": 35273,
"author_profile": "https://Stackoverflow.com/users/35273",
"pm_score": 3,
"selected": true,
"text": "<p>To remove the last \"word\" if it ends with dot : </p>\n\n<pre><code>my $name =~ s/\\w+\\.$//i;\n</code></pre>\n\n<p>(... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42229/"
] | I've got a bunch of first names in a field that carry a middle initial with a '.' at the end..
I need a regex to convert this example:
Kenneth R.
into
Kenneth
I was trying to build my own and found this useful site btw..
<http://www.gskinner.com/RegExr/>
but I'm new to Perl & regular expressions an... | To remove the last "word" if it ends with dot :
```
my $name =~ s/\w+\.$//i;
```
(this supposes you don't have any space after that)
To remove any word ending with dot :
```
my $name =~ s/\w+\.//i;
```
look at the /g modifier if you want to remove them all ...
and BTW make yourself a test case list to check yo... |
447,408 | <p>This code compiles:</p>
<pre><code>private static void Main(string[] args)
{
bool? fred = true;
if (fred == true)
Console.WriteLine("fred is true");
else if (fred == false)
Console.WriteLine("fred is false");
else Console.WriteLine("fred is null");
}
</code></pre>
<p>This code doe... | [
{
"answer_id": 447421,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 3,
"selected": false,
"text": "<p>Because fred is not a boolean. it is a struct, which has a boolean property called IsNull, or HasValue, or wha... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143/"
] | This code compiles:
```
private static void Main(string[] args)
{
bool? fred = true;
if (fred == true)
Console.WriteLine("fred is true");
else if (fred == false)
Console.WriteLine("fred is false");
else Console.WriteLine("fred is null");
}
```
This code does *not* compile.
```
priv... | There's no implicit conversion from `Nullable<bool>` to `bool`. There *is* an implicit conversion from `bool` to `Nullable<bool>` and that's what happens (in language terms) to each of the bool constants in the first version. The `bool operator==(Nullable<bool>, Nullable<bool>` operator is then applied. (This isn't qui... |
447,417 | <p>I know nothing of CSS but am trying to figure out the meaning of this syntax:</p>
<pre><code>body {
margin: 0;
font-family: "Trebuchet MS", Helvetica;
background: #FFFFFF;
color: #FE6600;
overflow-x: hidden;
position: absolute;
margin: 0;
padding: 0;
left: 0;
top: 45px;
w... | [
{
"answer_id": 447438,
"author": "siukurnin",
"author_id": 35273,
"author_profile": "https://Stackoverflow.com/users/35273",
"pm_score": 1,
"selected": false,
"text": "<p>No quick answer can tell you what CSS are all about....</p>\n\n<p>That's quite a vast subject !!</p>\n\n<p>have a loo... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129162/"
] | I know nothing of CSS but am trying to figure out the meaning of this syntax:
```
body {
margin: 0;
font-family: "Trebuchet MS", Helvetica;
background: #FFFFFF;
color: #FE6600;
overflow-x: hidden;
position: absolute;
margin: 0;
padding: 0;
left: 0;
top: 45px;
width: 100%;
... | Are you talking about the :not pseudo-selector? It does what it sounds like it's going to select all elements from the current set which do not match this selector.
It's CSS3 though and not widely enough supported I should say.
Good article [here](http://kilianvalkhof.com/2008/css-xhtml/the-css3-not-selector/).
---
... |
447,447 | <p>I have a problem. I'd like to match all occurrences of \t in my text (and by \t i mean it literally it is not a tab character) but I would like to exclude a match if it is a part of \t string. How to do that?</p>
<p>Example</p>
<pre><code><HTML>Blah</HTML>\t
D:\\UserData\\tui
</code></pre>
<p>I'd like... | [
{
"answer_id": 447469,
"author": "Adrian Pronk",
"author_id": 41861,
"author_profile": "https://Stackoverflow.com/users/41861",
"pm_score": 1,
"selected": false,
"text": "<p>You have to define more precisely what you mean by \"part of a string\". For example, you might mean: Don't match... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4411/"
] | I have a problem. I'd like to match all occurrences of \t in my text (and by \t i mean it literally it is not a tab character) but I would like to exclude a match if it is a part of \t string. How to do that?
Example
```
<HTML>Blah</HTML>\t
D:\\UserData\\tui
```
I'd like to match \t in the first line but not in sec... | ```
/\\t\b/
```
`\b` matches a word boundary (transition from word-like character to non-word-like, or vice versa). |
447,460 | <p>I'm pulling a row from a database and there is a date field (y-m-d). I need to create an if statement so that I can do something IF that date is longer then 13 days ago. I've already found out how to display all results which are longer then 13 days ago if it is any help.</p>
<pre><code>SELECT * FROM links WHERE (T... | [
{
"answer_id": 447490,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 3,
"selected": true,
"text": "<p>In php you can use:</p>\n\n<pre><code>$date = '2008-11-05';\nif (strtotime(\"now\") > strtotime(\"+13 days\", st... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I'm pulling a row from a database and there is a date field (y-m-d). I need to create an if statement so that I can do something IF that date is longer then 13 days ago. I've already found out how to display all results which are longer then 13 days ago if it is any help.
```
SELECT * FROM links WHERE (TO_DAYS(NOW()) ... | In php you can use:
```
$date = '2008-11-05';
if (strtotime("now") > strtotime("+13 days", strtotime($date))) {
//Do something
}
``` |
447,462 | <p>My public template grabs data from Postgres to a drop down menu. The template displays the data in the drop down menu. When the selection is activated the following error occurs: </p>
<p>commodity() takes exactly 2 arguments (1 given)</p>
<p>The template code, views and URL are here:</p>
<p><a href="http://dpa... | [
{
"answer_id": 447490,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 3,
"selected": true,
"text": "<p>In php you can use:</p>\n\n<pre><code>$date = '2008-11-05';\nif (strtotime(\"now\") > strtotime(\"+13 days\", st... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My public template grabs data from Postgres to a drop down menu. The template displays the data in the drop down menu. When the selection is activated the following error occurs:
commodity() takes exactly 2 arguments (1 given)
The template code, views and URL are here:
<http://dpaste.com/109411/> | In php you can use:
```
$date = '2008-11-05';
if (strtotime("now") > strtotime("+13 days", strtotime($date))) {
//Do something
}
``` |
447,481 | <p>I am working on a project that transfers files over a network and I want to incorporate a <code>JProgressBar</code> to show the progress during file transfer but I need help on that. </p>
| [
{
"answer_id": 447511,
"author": "willcodejavaforfood",
"author_id": 51382,
"author_profile": "https://Stackoverflow.com/users/51382",
"pm_score": 0,
"selected": false,
"text": "<p>Well <a href=\"http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html\" rel=\"nofollow no... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a project that transfers files over a network and I want to incorporate a `JProgressBar` to show the progress during file transfer but I need help on that. | You probably would find a ProgressMonitorInputStream easiest, but if that doesn't do enough for you, look at its source code to get exactly what you want.
```
InputStream in = new BufferedInputStream(
new ProgressMonitorInputStream(
parentComponent,
... |
447,484 | <p>I have a user control in a master page and the same user control directly in the aspx. The user control in the master page works fine, but when I try the user control that is embedded directly in the aspx page, it doesn't work. The user control is 2 textboxes with a login button. What it looks like it is trying t... | [
{
"answer_id": 447593,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like your controls are sharing a ValidationGroup - can you post some code so we can see?</p>\n"
},
{
... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447484",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I have a user control in a master page and the same user control directly in the aspx. The user control in the master page works fine, but when I try the user control that is embedded directly in the aspx page, it doesn't work. The user control is 2 textboxes with a login button. What it looks like it is trying to do i... | It is hard to tell exactly what the problem is without more information.
From what you are saying, it could be client-side validation that kicks in. If this is the case, you could set ValidationGroup on the controls to the ID of the UserControl. Then the controls on the same instance of the UserControl will have the ... |
447,512 | <p>I'd like to override Django's administrative "Change Password" page (change_password.html). As such, I've placed Django's "/contrib/admin/templates/registration/password_change_form.html" in my project's "/templates/admin/registration/password_change_form.html" directory. Unfortunately, this doesn't seem to do the... | [
{
"answer_id": 447540,
"author": "Peter Rowell",
"author_id": 17017,
"author_profile": "https://Stackoverflow.com/users/17017",
"pm_score": 4,
"selected": true,
"text": "<p>A quick look at the source indicates you should place the template in:</p>\n\n<pre><code>/templates/registration/pa... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] | I'd like to override Django's administrative "Change Password" page (change\_password.html). As such, I've placed Django's "/contrib/admin/templates/registration/password\_change\_form.html" in my project's "/templates/admin/registration/password\_change\_form.html" directory. Unfortunately, this doesn't seem to do the... | A quick look at the source indicates you should place the template in:
```
/templates/registration/password_change_form.html
```
Note bene: there is no 'admin/' in there. |
447,516 | <p>My first programming job introduced me to unit testing and the concept of mock objects, but something always felt wrong about it.</p>
<p>Let's say we were writing a bank app, and needed to mock a BankAccount object:</p>
<pre><code>
// boilerplate code
public interface IBankAccount {
void Deposit(in... | [
{
"answer_id": 447532,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 4,
"selected": true,
"text": "<p>The better way is to have someone else write it. Some options here are:</p>\n\n<p>Moq - <a href=\"http://code.google.... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40516/"
] | My first programming job introduced me to unit testing and the concept of mock objects, but something always felt wrong about it.
Let's say we were writing a bank app, and needed to mock a BankAccount object:
```
// boilerplate code
public interface IBankAccount {
void Deposit(int amount);
vo... | The better way is to have someone else write it. Some options here are:
Moq - <http://code.google.com/p/moq/>
Rhino Mocks - <http://ayende.com/projects/rhino-mocks.aspx> |
447,537 | <p>A little bit of context:</p>
<p>I'm using the <em>jQuery Validation plugin</em> to validate a sign-up form. I now want to implement an <strong>ajax call to check whether the user name is available</strong> in the system, and I want to make this ajax call only if the userName value is a valid one as per the rules se... | [
{
"answer_id": 5779010,
"author": "Fatih Hayrioğlu",
"author_id": 296373,
"author_profile": "https://Stackoverflow.com/users/296373",
"pm_score": 6,
"selected": false,
"text": "<pre><code>$(\"#userName\").keyup(function () {\n if ($(\"#userName\").valid() == true ) {\n //make a... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21613/"
] | A little bit of context:
I'm using the *jQuery Validation plugin* to validate a sign-up form. I now want to implement an **ajax call to check whether the user name is available** in the system, and I want to make this ajax call only if the userName value is a valid one as per the rules set in `$(form).validate();`
I ... | ```
$("#userName").keyup(function () {
if ($("#userName").valid() == true ) {
//make ajax called
}
});
```
<http://docs.jquery.com/Plugins/Validation/valid>
*Note:* To those who do not click the link. You have to call `$("#myform").validate();` first. |
447,539 | <pre><code><td>
<img src="http://blog.garethjmsaunders.co.uk/wp-content/feed-icon-16x16.gif"/>
My feed
</td>
</code></pre>
<p>This is how it looks like:</p>
<p>
<a href="https://i.stack.imgur.com/tnWYq.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tnWYq.gif" alt=""></a><br>
<s... | [
{
"answer_id": 447557,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 0,
"selected": false,
"text": "<p>You could do <code>position: relative; top: 3px;</code> on the <code><img></code> tag. You could also tr... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24451/"
] | ```
<td>
<img src="http://blog.garethjmsaunders.co.uk/wp-content/feed-icon-16x16.gif"/>
My feed
</td>
```
This is how it looks like:
[](https://i.stack.imgur.com/tnWYq.gif)
(source: [garethjmsaunders.co.uk](http://blog.garethjmsaunders.co.uk/wp-content/feed-icon-16x16.gif... | Well, if you choose the background image method, then it is very simple:
```
background: url(feed.png) left center no-repeat
``` |
447,560 | <p>When I try to send a HTML encoded email from PHP, if the subject line contains special chars like <code>"Here's the information you requested"</code>, PHP encodes it to read <code>"Here&#039;s the information you requested."</code></p>
<p>How do I fix this?</p>
<hr>
<p>Here's what the code looks like using PH... | [
{
"answer_id": 447584,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": -1,
"selected": false,
"text": "<p>Try running the subject line through <a href=\"http://php.net/html_entity_decode\" rel=\"nofollow noreferrer\">html_e... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22475/"
] | When I try to send a HTML encoded email from PHP, if the subject line contains special chars like `"Here's the information you requested"`, PHP encodes it to read `"Here's the information you requested."`
How do I fix this?
---
Here's what the code looks like using PHP mail():
```
$headers = 'MIME-Version: 1.... | Try this:
```
$newsubject='=?UTF-8?B?'.base64_encode($subject).'?=';
```
This way you don't rely on PHP or the MTA's encoding, you do the job, and the mail client should understand it. No special characters will be present in your new subject, so no problems should arise while delivering the email. |
447,561 | <p>I'm trying to understand why this does not work. (Basic example with no validation yet)</p>
<p>When I test it, firebug states Product.addPage is not found.</p>
<pre><code>var Product = function ()
{
var Page = function ()
{
var IMAGE = '';
return {
image : function ()
... | [
{
"answer_id": 447581,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 2,
"selected": false,
"text": "<p>How about <code>Product.addPage</code><b><code>()</code></b><code>.setImage('http://site/images/small_logo.png');</code>?</... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to understand why this does not work. (Basic example with no validation yet)
When I test it, firebug states Product.addPage is not found.
```
var Product = function ()
{
var Page = function ()
{
var IMAGE = '';
return {
image : function ()
{
... | You're trying to reference the addPage property of the Product *function* (which in this case is a constructor), rather than on the returned object.
You probably want something like:
```
// Begin executing
$(document).ready(function ()
{
var product = new Product();
product.addPage().setImage('<http://site/im... |
447,566 | <p>In SQL one can write a query that searches for a name of a person like this:</p>
<pre><code>SELECT * FROM Person P WHERE P.Name LIKE N'%ike%'
</code></pre>
<p>This query would run with unicode characters (assuming that the Name column and database were setup to handle unicode support).</p>
<p>I have a similar que... | [
{
"answer_id": 447702,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried with parameters:</p>\n\n<pre><code>IList<Person> people = session\n .CreateQuery(\"from P... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13456/"
] | In SQL one can write a query that searches for a name of a person like this:
```
SELECT * FROM Person P WHERE P.Name LIKE N'%ike%'
```
This query would run with unicode characters (assuming that the Name column and database were setup to handle unicode support).
I have a similar query in HQL that is run by Hibernat... | Have you tried with parameters:
```
IList<Person> people = session
.CreateQuery("from Person p where p.Name like :name")
.SetParameter("name", "%カタカ%")
.List<Person>();
```
They also have the advantage to protect your query against SQL injection. |
447,586 | <p>I have an application written in Delphi that has several versions that contain binaries and database (MDB) with catalog data.</p>
<p>During the product life cycle fixes/enhancements are either in database file or in some binary files.</p>
<p>Version are preserved in Registry. </p>
<p>Users might have different ve... | [
{
"answer_id": 447683,
"author": "Re0sless",
"author_id": 2098,
"author_profile": "https://Stackoverflow.com/users/2098",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure if it is the correct way to do it, but you can use the [code] section and the BeforeInstall Flags</p>\n\n<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27016/"
] | I have an application written in Delphi that has several versions that contain binaries and database (MDB) with catalog data.
During the product life cycle fixes/enhancements are either in database file or in some binary files.
Version are preserved in Registry.
Users might have different versions of the program wh... | I am not sure if it is the correct way to do it, but you can use the [code] section and the BeforeInstall Flags
like so
```
[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall('{app}')
Source: "MYFILE.EXE"; DestDir: "{app}"; BeforeInstall: MyBeforeInstall('{app}')
Source: "MYDB.MDB"; DestDi... |
447,604 | <p>I'm puzzled on how to write a stored procedure to handle a conditional delete.</p>
<p>I have a table with 4 columns (<code>ID</code>, <code>A</code>, <code>B</code>, <code>C</code>) and the data in the table looks like this:</p>
<pre><code>ID | A | B | C
----------------------------------
1 | De... | [
{
"answer_id": 447611,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": false,
"text": "<p>You need another condition then. If you want to delete Debbie Jones, then you need to indicate that in your conditio... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | I'm puzzled on how to write a stored procedure to handle a conditional delete.
I have a table with 4 columns (`ID`, `A`, `B`, `C`) and the data in the table looks like this:
```
ID | A | B | C
----------------------------------
1 | Debbie Jones | |
2 | John Jones | |
3 | Jame... | You need another condition then. If you want to delete Debbie Jones, then you need to indicate that in your condition, either by specifying that column A = "Debbie Jones" or that the ID column is equal to 1.
This assumes, of course, that the values in the ID and A columns are unique and can uniquely identify the row. |
447,608 | <p>I have defined the global nls_date_format on Oracle 10.2 XE as follows:</p>
<pre><code>alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
</code></pre>
<p>When connecting on Windows, the clients override it with session specific format, so I need to run this line at the beginning of every sessi... | [
{
"answer_id": 447611,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 2,
"selected": false,
"text": "<p>You need another condition then. If you want to delete Debbie Jones, then you need to indicate that in your conditio... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36071/"
] | I have defined the global nls\_date\_format on Oracle 10.2 XE as follows:
```
alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
```
When connecting on Windows, the clients override it with session specific format, so I need to run this line at the beginning of every session:
```
alter session s... | You need another condition then. If you want to delete Debbie Jones, then you need to indicate that in your condition, either by specifying that column A = "Debbie Jones" or that the ID column is equal to 1.
This assumes, of course, that the values in the ID and A columns are unique and can uniquely identify the row. |
447,619 | <p>Greetings!</p>
<p>I am implementing a backup solution, and I need to access the X11 display for getting a password from the user and displaying status information. I have tried setting $DISPLAY in the script to :0.0 (hardcoded), but xhost and misc complain that they cannot open the display. What should I do?</p>
<... | [
{
"answer_id": 447660,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile": "https://Stackoverflow.com/users/13422",
"pm_score": 3,
"selected": false,
"text": "<p>You need the X Authentication information. I do not believe that <code>xhost</code> can \"break in\" to an X session ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54163/"
] | Greetings!
I am implementing a backup solution, and I need to access the X11 display for getting a password from the user and displaying status information. I have tried setting $DISPLAY in the script to :0.0 (hardcoded), but xhost and misc complain that they cannot open the display. What should I do?
PS: The script ... | As stated above, the user has to allow you to access their display. They need to perform the xhost + command. It's not really a good idea to just open your display up to anyone!
You'd be better off getting them to run
```
xhost +jeeger
```
or whatever your user is running as.
HTH
cheers,
Rob |
447,622 | <p>Is it considered 'bad practice' to create an function like so:</p>
<pre><code>// $arr_member_fields['first_name'] = $_POST['first_name'];
// $arr_member_fields['last_name'] = $_POST['first_name'];
// $arr_member_fields['email'] = $_POST['email'];
// $arr_member_fields['dob'] = $_POST['dob'];
// $arr_me... | [
{
"answer_id": 447640,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 1,
"selected": false,
"text": "<p>Depends on the function. There is no best practice here that will adequately capture most cases when writing a funct... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12564/"
] | Is it considered 'bad practice' to create an function like so:
```
// $arr_member_fields['first_name'] = $_POST['first_name'];
// $arr_member_fields['last_name'] = $_POST['first_name'];
// $arr_member_fields['email'] = $_POST['email'];
// $arr_member_fields['dob'] = $_POST['dob'];
// $arr_member_fields['g... | Depends on the function. There is no best practice here that will adequately capture most cases when writing a function. What if you don't need to loop through the arguments?
Seems like you're best off passing arrays in this case. |
447,623 | <p>I have been given the task of refactoring an existing stored procedure so that the results are paginated. The SQL server is SQL 2000 so I can't use the ROW_NUMBER method of pagination. The Stored proc is already fairly complex, building chunks of a large sql statement together before doing an sp_executesql and has... | [
{
"answer_id": 447637,
"author": "marc_s",
"author_id": 13302,
"author_profile": "https://Stackoverflow.com/users/13302",
"pm_score": 0,
"selected": false,
"text": "<p>No, I'm afraid not - SQL Server 2000 doesn't have any of the 2005 niceties like Common Table Expression (CTE) and such..... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13100/"
] | I have been given the task of refactoring an existing stored procedure so that the results are paginated. The SQL server is SQL 2000 so I can't use the ROW\_NUMBER method of pagination. The Stored proc is already fairly complex, building chunks of a large sql statement together before doing an sp\_executesql and has va... | After playing with this for a while there seems to be only one way of really doing this (using Start and Length parameters) and that's with the temp table.
My final solution was to **not** use the @start parameter and instead use a @page parameter and then use the
```
SET @sql = @sql + N'
SELECT * FROM
(... |
447,629 | <p>How can I know which machines are alive on the same LAN as my PC using ASP.NET?</p>
| [
{
"answer_id": 447651,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 3,
"selected": true,
"text": "<p>You can ping the computers on the network.</p>\n\n<pre><code>// addressToPing can be an IPaddress or host name.\n// return... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40521/"
] | How can I know which machines are alive on the same LAN as my PC using ASP.NET? | You can ping the computers on the network.
```
// addressToPing can be an IPaddress or host name.
// returns a boolean indicating successful ping
public static bool PingComputer (string[] addressToPing)
{
Ping pingSender = new Ping ();
PingOptions options = new PingOptions ();
// Use the default Ttl value... |
447,638 | <p>We're using the standard ASP.NET authentication provider (AspNetSqlMembershipProvider as it happens) and the defualt password strength requirement is a little excessive for our needs.</p>
<p>We require our users to enter a password that is alphanumeric at least (i.e, letters and at least one number mandatory, mixed... | [
{
"answer_id": 447677,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 5,
"selected": true,
"text": "<p>Here is a regex that allows all characters and requires at least one number and requiring at least 6 characters.</p>... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39709/"
] | We're using the standard ASP.NET authentication provider (AspNetSqlMembershipProvider as it happens) and the defualt password strength requirement is a little excessive for our needs.
We require our users to enter a password that is alphanumeric at least (i.e, letters and at least one number mandatory, mixed case and ... | Here is a regex that allows all characters and requires at least one number and requiring at least 6 characters.
```
^.*(?=.{6,})(?=.*\d).*$
```
If you want more or less characters defined simply change `(?=.{6,})` to reflect the number of characters you want as a minimum. |
447,639 | <p>I am trying to build a nested/threaded comment system in ASP.NET. I don't know how the PHP guys do it. Its much harder than first imagined.</p>
<p>I am trying my damnedest get Hierarchical data to output to the user, but its not working. </p>
<p>I have a table with text, a itemID and a parentID.</p>
<p>I want ... | [
{
"answer_id": 447727,
"author": "alex",
"author_id": 50564,
"author_profile": "https://Stackoverflow.com/users/50564",
"pm_score": 0,
"selected": false,
"text": "<p>As I understand it, if you have a database table with hierarchical data, you have two options: create your own custom data... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] | I am trying to build a nested/threaded comment system in ASP.NET. I don't know how the PHP guys do it. Its much harder than first imagined.
I am trying my damnedest get Hierarchical data to output to the user, but its not working.
I have a table with text, a itemID and a parentID.
I want to display the information ... | Quickly, by head (could not check in VS2k8 now), I would do it something like this using Linq to SQL
```
private void BuildTree()
{
List<Item> items = from item in dataContext.Items
select item;
List<Item> rootItems = items.FindAll(p => p.ParentID == null );
foreach ( Item item in root... |
447,657 | <p>I'm doing a <code>hlookup</code> against a value that spans multiple columns. My data is similar to this:</p>
<pre><code> A B C D
---------------------------
1| Col1 Col2
2| x y z w
3|
4|
</code></pre>
<p>In rows 3 and 4 (A3, B3, C3, D3, etc.), I'd like t... | [
{
"answer_id": 447726,
"author": "BradC",
"author_id": 21398,
"author_profile": "https://Stackoverflow.com/users/21398",
"pm_score": 0,
"selected": false,
"text": "<p>Cells B1 and D2 contain no values, only A1 and C1 have something inside them.</p>\n\n<p>So you'll just have to make sure ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45109/"
] | I'm doing a `hlookup` against a value that spans multiple columns. My data is similar to this:
```
A B C D
---------------------------
1| Col1 Col2
2| x y z w
3|
4|
```
In rows 3 and 4 (A3, B3, C3, D3, etc.), I'd like to put formulas that will do an hlookup... | To get access to the "Col1" and "Col2" labels, you can use the following:
>
> =INDEX($1:$1,1,COLUMN()-MOD(COLUMN()-1,2))
>
>
>
Note: This assumes that you are grouping together the same number of cells. If it were three cells, you would just change the last number in the formula to a 3, and so on.
**Edit:** Here... |
447,658 | <p>I'm using jQuery with the validators plugin. I would like to replace the "required" validator with one of my own. This is easy:</p>
<pre><code>jQuery.validator.addMethod("required", function(value, element, param) {
return myRequired(value, element, param);
}, jQuery.validator.messages.required);
</code></pre>
... | [
{
"answer_id": 447690,
"author": "roborourke",
"author_id": 42147,
"author_profile": "https://Stackoverflow.com/users/42147",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like there's no 'better way'. I guess you could try making a custom required function for your own eg:</p>\n\... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7714/"
] | I'm using jQuery with the validators plugin. I would like to replace the "required" validator with one of my own. This is easy:
```
jQuery.validator.addMethod("required", function(value, element, param) {
return myRequired(value, element, param);
}, jQuery.validator.messages.required);
```
So far, so good. This ... | >
> Storing a reference to the function
> externally before calling addMethod
> and calling the default validator via
> that reference makes no difference.
>
>
>
That's exactly what *should work*.
```
jQuery.validator.methods.oldRequired = jQuery.validator.methods.required;
jQuery.validator.addMethod("require... |
447,705 | <p>We have a website running .NET 2.0 and have started using the ASP.Net HttpRuntime.Cache to store the results of frequent data lookups to cut down our database access. </p>
<p>Snippet:</p>
<pre> <code>
lock (locker)
{
if (HttpRuntime.Cache[cacheKey] == null)
{
HttpRuntime.Cache.Insert(cacheKey, GetS... | [
{
"answer_id": 447730,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>As far as I know the Cache object is thread safe so you wouldn't need the lock.</p>\n"
},
{
"answer_id": ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34895/"
] | We have a website running .NET 2.0 and have started using the ASP.Net HttpRuntime.Cache to store the results of frequent data lookups to cut down our database access.
Snippet:
```
lock (locker)
{
if (HttpRuntime.Cache[cacheKey] == null)
{
HttpRuntime.Cache.Insert(cacheKey, GetSomeDataToCache(), null... | As far as I know the Cache object is thread safe so you wouldn't need the lock. |
447,739 | <p>I want to do some timing tests on a Java application. This is what I am currently doing:</p>
<pre><code>long startTime = System.currentTimeMillis();
doSomething();
long finishTime = System.currentTimeMillis();
System.out.println("That took: " + (finishTime - startTime) + " ms");
</code></pre>
<p>Is there anything ... | [
{
"answer_id": 447747,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "<p>I'd imagine you'd want to doSomething() before you start timing too, so that the code is JITted and \"warmed up\".<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33863/"
] | I want to do some timing tests on a Java application. This is what I am currently doing:
```
long startTime = System.currentTimeMillis();
doSomething();
long finishTime = System.currentTimeMillis();
System.out.println("That took: " + (finishTime - startTime) + " ms");
```
Is there anything "wrong" with performance t... | The one flaw in that approach is that the "real" time `doSomething()` takes to execute can vary wildly depending on what other programs are running on the system and what its load is. This makes the performance measurement somewhat imprecise.
One more accurate way of tracking the time it takes to execute code, assumin... |
447,744 | <p>I used the function:</p>
<pre><code>document.getElementsByTagName('strong')
</code></pre>
<p>to get all the text in a page with that type of formatting. The HTML looks like:</p>
<pre><code><td align="center" valign="bottom"><H1><font size="+4"><strong>TEXT_HERE</strong></font>... | [
{
"answer_id": 447782,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "<p>With a for loop?</p>\n\n<pre><code>var strongElems = document.getElementsByTagName('strong');\nvar wantToHide = true ||... | 2009/01/15 | [
"https://Stackoverflow.com/questions/447744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] | I used the function:
```
document.getElementsByTagName('strong')
```
to get all the text in a page with that type of formatting. The HTML looks like:
```
<td align="center" valign="bottom"><H1><font size="+4"><strong>TEXT_HERE</strong></font> <br>
```
I would like to change "TEXT\_HERE" to maybe something else or... | With a for loop?
```
var strongElems = document.getElementsByTagName('strong');
var wantToHide = true || false;
for (var i=0; i<strongElems.length; i++)
{
var thisElem = strongElems[i];
if (wantToHide)
{
thisElem.style.display = "none"; // hide it
}
else
{
thisElem.textContent = "something else";... |