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 |
|---|---|---|---|---|---|---|
335,783 | <p>I'm writing an application that will need to open up browser windows (probably can stick to IE) to websites that use Forms Authentication. The trick is that they need to be authenticated already, in order to save time due to the sheer number of sites we need to get into. (Eventually I'll be screen scraping them an... | [
{
"answer_id": 335820,
"author": "Kevin Tighe",
"author_id": 39461,
"author_profile": "https://Stackoverflow.com/users/39461",
"pm_score": 0,
"selected": false,
"text": "<p>I think the browser may be ignoring the cookies in the response header because of the impending Response.Redirect. ... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17145/"
] | I'm writing an application that will need to open up browser windows (probably can stick to IE) to websites that use Forms Authentication. The trick is that they need to be authenticated already, in order to save time due to the sheer number of sites we need to get into. (Eventually I'll be screen scraping them and pro... | I don't think you're going to be able to do this. The browser is going to ignore any "Add-Cookie" headers from a web server that does not belong to the domain associated with the cookies. This is part of the built-in security for cookies - it would be catastrophic (from a security and privacy perspective) if other webs... |
335,805 | <p>I have a 'reference' SQL Server 2005 database that is used as our global standard. We're all set up for keeping general table schema and data properly synchronized, but don't yet have a good solution for other objects like views, stored procedures, and user-defined functions.</p>
<p>I'm aware of products like <a hr... | [
{
"answer_id": 335819,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>1) Keep all your views, triggers, functions, stored procedures, table schemas etc in Source Control and use that as... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1354/"
] | I have a 'reference' SQL Server 2005 database that is used as our global standard. We're all set up for keeping general table schema and data properly synchronized, but don't yet have a good solution for other objects like views, stored procedures, and user-defined functions.
I'm aware of products like [Redgate's SQL ... | You can use the system tables to do this.
For example,
```
select * from sys.syscomments
```
The "text" column will give you all of the code for the store procedures (plus other data).
It is well worth looking at all the system tables and procedures. In fact, I suspect this is what RedGate's software and other to... |
335,812 | <p>I'm having an issue with CruiseControl.net where the web dashboard just won't work in IIS. I have tried switching ASP.Net between 64 and 32 bit modes and reinstalling cruise control, but nothing seems to work. Has anyone else had issues with CruiseControl.Net on 64 bit platforms?</p>
<p>Cheers,
Jamie</p>
<p>[Edit]... | [
{
"answer_id": 335821,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "<p>Clarify a bit, does the web-dashboard function incorrectly? Does it not show up at all?</p>\n\n<p>The webdashboard uses N... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/68230/"
] | I'm having an issue with CruiseControl.net where the web dashboard just won't work in IIS. I have tried switching ASP.Net between 64 and 32 bit modes and reinstalling cruise control, but nothing seems to work. Has anyone else had issues with CruiseControl.Net on 64 bit platforms?
Cheers,
Jamie
[Edit]
Thought I shoul... | It seems I needed to enable Web Service Extensions for ASP.Net. I'm still not getting an ASP.Net tab in the cruise control website properties, but it is working.
---
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727> or C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727> for 64 bit
Type aspnet\_regiis.exe – i
ASP.NET will... |
335,817 | <p>Is there a way to access the DOM of the document in an iframe from parent doc if the doc in the iframe is on another domain? I can easily access it if both parent and child pages are on the same domain, but I need to be able to do that when they are on different domains.</p>
<p>If not, maybe there is some other way... | [
{
"answer_id": 335877,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 3,
"selected": true,
"text": "<p>Not really. This is essential for security – otherwise you could open my online banking site or webmail and mess with it.... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41877/"
] | Is there a way to access the DOM of the document in an iframe from parent doc if the doc in the iframe is on another domain? I can easily access it if both parent and child pages are on the same domain, but I need to be able to do that when they are on different domains.
If not, maybe there is some other way to READ t... | Not really. This is essential for security – otherwise you could open my online banking site or webmail and mess with it.
You can [loosen restriction](https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript) a bit by setting `document.domain`, but still top level domain must be the same.
You can work aroun... |
335,833 | <p>I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below.</p>
<p>I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). M... | [
{
"answer_id": 335904,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 2,
"selected": false,
"text": "<p>You can use NSString's <code>lowercaseString</code> to convert the XML key name to lowercase, if that helps.</... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38753/"
] | I'd appreciate some feedback on a particular approach I'm thinking of using. The scenario is below.
I have an object (lets call it MObject) that has a number of properties, say, x and y coordinates, height and width. The properties are named according to the KVC guidelines (MObject.x; MObject.height, etc). My next tas... | Don't override `-[NSObject valueForKey:]` and `-[NSObject setValue:forKey:]` if you can at all help it.
Your best bet would be to convert the keys you get from the XML file on the fly. Use a separate method to do the conversion and you can also maintain a cache of names to property keys, so you only need to do each co... |
335,839 | <p>Note that this function does not have a "{" and "}" body. Just a try/catch block:</p>
<pre><code>void func( void )
try
{
...
}
catch(...)
{
...
}
</code></pre>
<p>Is this intentionally part of C++, or is this a g++ extension?</p>
<p>Is there any purpose to this other than bypass 1 level of {}?</p>
<p>I'... | [
{
"answer_id": 335850,
"author": "James Hopkin",
"author_id": 11828,
"author_profile": "https://Stackoverflow.com/users/11828",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, it is standard. Function try blocks, as they're called, aren't that much use for regular functions, but for co... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13022/"
] | Note that this function does not have a "{" and "}" body. Just a try/catch block:
```
void func( void )
try
{
...
}
catch(...)
{
...
}
```
Is this intentionally part of C++, or is this a g++ extension?
Is there any purpose to this other than bypass 1 level of {}?
I'd never heard of this until I ran into <h... | Yes, it is standard. Function try blocks, as they're called, aren't that much use for regular functions, but for constructors, they allow you to catch exceptions thrown in the initialiser list.
Note that, in the constructor case, the exception will always be rethrown at the end of any catch blocks. |
335,841 | <p>I've tried this both with and without the 'ExceptionType' parameter. I have an Error.aspx page in both the Views/Shared folder and the Views/thisController folder. But everytime I run this I get a "Server Error in '/' Application." error page, rather than the nice one in Views/Shared.</p>
<p>Any idea what could be ... | [
{
"answer_id": 335982,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 1,
"selected": false,
"text": "<p>It doesn't work for me on my current project or a new one. It's probably a \"feature\".</p>\n\n<p><strong>EDIT:</str... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40814/"
] | I've tried this both with and without the 'ExceptionType' parameter. I have an Error.aspx page in both the Views/Shared folder and the Views/thisController folder. But everytime I run this I get a "Server Error in '/' Application." error page, rather than the nice one in Views/Shared.
Any idea what could be going wron... | I do indeed have this in my web.config
```
<customErrors mode="On"></customErrors>
```
Must be something else at play. |
335,849 | <p>I have run into an issue with WPF and Commands that are bound to a Button inside the DataTemplate of an ItemsControl. The scenario is quite straight forward. The ItemsControl is bound to a list of objects, and I want to be able to remove each object in the list by clicking a Button. The Button executes a Command, an... | [
{
"answer_id": 336258,
"author": "Ed Ball",
"author_id": 23818,
"author_profile": "https://Stackoverflow.com/users/23818",
"pm_score": 5,
"selected": false,
"text": "<p>I have found that the order in which I set Command and CommandParameter makes a difference. Setting the Command propert... | 2008/12/02 | [
"https://Stackoverflow.com/questions/335849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] | I have run into an issue with WPF and Commands that are bound to a Button inside the DataTemplate of an ItemsControl. The scenario is quite straight forward. The ItemsControl is bound to a list of objects, and I want to be able to remove each object in the list by clicking a Button. The Button executes a Command, and t... | I stumbled upon a similar problem and solved it using my trusty TriggerConverter.
```
public class TriggerConverter : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//... |
335,886 | <p>I want to do something like</p>
<pre><code>select * from tvfHello(@param) where @param in (Select ID from Users)
</code></pre>
| [
{
"answer_id": 335895,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 0,
"selected": false,
"text": "<p>That looks ok to me, except that you should always prefix your functions with their schema (usually dbo). So the quer... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30546/"
] | I want to do something like
```
select * from tvfHello(@param) where @param in (Select ID from Users)
``` | You need to use **CROSS APPLY** to achieve this
```
select
f.*
from
users u
cross apply dbo.tvfHello(u.ID) f
``` |
335,891 | <p>I have the following shell script registered in my "Login Items" preferences but it does not seem to have any effect. It is meant to launch the moinmoin wiki but only works when it is run by hand from a terminal window, after which it runs until the machine is next shut down.</p>
<pre><code>#!/bin/bash
cd /Users/st... | [
{
"answer_id": 335906,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know much about it, since I don't use login items. Just a suggestion, maybe try with applescript that calls those s... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27065/"
] | I have the following shell script registered in my "Login Items" preferences but it does not seem to have any effect. It is meant to launch the moinmoin wiki but only works when it is run by hand from a terminal window, after which it runs until the machine is next shut down.
```
#!/bin/bash
cd /Users/stuartcw/Documen... | launchd is one of the best parts of MacOS X, and it causes me great pain to not be able to find it on other systems.
Edit and place this in `/Library/LaunchDaemons` as `com.you.wiki.plist`
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DT... |
335,896 | <p>I am trying to write my first real python function that does something real. What i want to accomplish is searching a given folder, and then open all images and merging them together so they make a filmstrip image. Imagine 5 images stacked on top of eachother in one image.</p>
<p>I have this code now, which should ... | [
{
"answer_id": 335916,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 1,
"selected": false,
"text": "<p>I think if you change your <code>try</code> section to this:</p>\n\n<pre><code>filmstripimage.save(filmstrip_url,... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42546/"
] | I am trying to write my first real python function that does something real. What i want to accomplish is searching a given folder, and then open all images and merging them together so they make a filmstrip image. Imagine 5 images stacked on top of eachother in one image.
I have this code now, which should be pretty ... | It is not an answer to your question, but It might be helpful:
```
#!/usr/bin/env python
from PIL import Image
def makefilmstrip(images, mode='RGB', color='white'):
"""Return a combined (filmstripped, each on top of the other) image of the images.
"""
width = max(img.size[0] for img in images)
heigh... |
335,928 | <p>I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.</p>
<p>I am calling the linker with:</p>
<pre><code>g++ -w (..lots of .o file... | [
{
"answer_id": 335958,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 9,
"selected": true,
"text": "<p>The problem is the linker is looking for <code>libmagic.so</code> but you only have <code>libmagic.so.1</code></p>\n\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10733/"
] | I am attempting to link an application with g++ on this Debian lenny system. ld is complaining it cannot find specified libraries. The specific example here is ImageMagick, but I am having similar problems with a few other libraries too.
I am calling the linker with:
```
g++ -w (..lots of .o files/include directories... | The problem is the linker is looking for `libmagic.so` but you only have `libmagic.so.1`
A quick hack is to symlink `libmagic.so.1` to `libmagic.so` |
335,930 | <p>Suppose there´s a template function in C++ that does some useful work but also outputs a sequence of values via an output iterator. Now suppose that that sequence of values sometimes is interesting, but at others is not useful. Is there a ready-to-use iterator class in the STL that can be instantiated and passed to ... | [
{
"answer_id": 335948,
"author": "Alastair",
"author_id": 31038,
"author_profile": "https://Stackoverflow.com/users/31038",
"pm_score": 2,
"selected": false,
"text": "<p>Do you have Boost available? If so you could use a <a href=\"http://www.boost.org/doc/libs/1_37_0/libs/iterator/doc/fu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/78828/"
] | Suppose there´s a template function in C++ that does some useful work but also outputs a sequence of values via an output iterator. Now suppose that that sequence of values sometimes is interesting, but at others is not useful. Is there a ready-to-use iterator class in the STL that can be instantiated and passed to the... | The STL does not provide such an iterator. But you could code it yourself (tested that code):
```
struct null_output_iterator :
std::iterator< std::output_iterator_tag,
null_output_iterator > {
/* no-op assignment */
template<typename T>
void operator=(T const&) { }
null_output... |
335,933 | <p>I traditionally deploy a set of web pages which allow for manual validation of core application functionality. One example is LoggerTest.aspx which generates and logs a test exception. I've always chosen to raise a DivideByZeroException using an approach similar to the following code snippet: </p>
<pre><code>try
{
... | [
{
"answer_id": 335936,
"author": "Jesse Millikan",
"author_id": 7526,
"author_profile": "https://Stackoverflow.com/users/7526",
"pm_score": 5,
"selected": false,
"text": "<p>Short answer:</p>\n\n<pre><code>throw new Exception(\"Test Exception\");\n</code></pre>\n\n<p>You will need </p>\n... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115/"
] | I traditionally deploy a set of web pages which allow for manual validation of core application functionality. One example is LoggerTest.aspx which generates and logs a test exception. I've always chosen to raise a DivideByZeroException using an approach similar to the following code snippet:
```
try
{
int zero = ... | ```
try
{
throw new DivideByZeroException();
}
catch (DivideByZeroException ex)
{
LogHelper.Error("TEST EXCEPTION", ex);
}
``` |
335,934 | <p>I've installed passenger a little while back and when I restarted my mac tonight, Apache2 won't start.</p>
<p>Here is what I get. </p>
<p>Anyone have any ideas? Re-install Apache2?</p>
<pre><code>dyld: Library not loaded: /usr/lib/libaprutil-1.0.dylib
Referenced from: /usr/sbin/httpd
Reason: no suitable image... | [
{
"answer_id": 335941,
"author": "Dana the Sane",
"author_id": 2567,
"author_profile": "https://Stackoverflow.com/users/2567",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like that module isn't installed correctly. Try disabling it in your apache configuration (in /etc/apache2/)... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34819/"
] | I've installed passenger a little while back and when I restarted my mac tonight, Apache2 won't start.
Here is what I get.
Anyone have any ideas? Re-install Apache2?
```
dyld: Library not loaded: /usr/lib/libaprutil-1.0.dylib
Referenced from: /usr/sbin/httpd
Reason: no suitable image found. Did find:
/usr/... | Looks like the module was compiled for the wrong architecture. As trivial as it might seem, try uninstalling passenger to see whether this was the problem and then try to reinstall it. |
335,951 | <p>For a web application, when creating the user which will connect to the MySQL database, you have the choice of privileges. Assuming that the only actions intended to be done by that user are SELECT/INSERT/UPDATE/DELETE, it seems to make sense to only provide those privileges, however I've never seen that recommended... | [
{
"answer_id": 335964,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 4,
"selected": true,
"text": "<p>There are other privileges that a user might need during an ordinary application, for example:</p>\n\n<ul>\n<li>CREA... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | For a web application, when creating the user which will connect to the MySQL database, you have the choice of privileges. Assuming that the only actions intended to be done by that user are SELECT/INSERT/UPDATE/DELETE, it seems to make sense to only provide those privileges, however I've never seen that recommended an... | There are other privileges that a user might need during an ordinary application, for example:
* CREATE TEMPORARY TABLE
* EXECUTE (stored procedures)
* FILE (for SELECT INTO and LOAD DATA)
* LOCK TABLES
There's also the possibility that *minimal* privileges could mean only SELECT on certain tables, and only SELECT an... |
335,955 | <p>I've been slowly working my way through the list of Project Euler problems, and I've come to one that I know how to solve, but it seems like I can't (given the way my solution was written).</p>
<p>I am using Common Lisp to do this with and my script has been running for over 24 hours (well over their one minute goa... | [
{
"answer_id": 335975,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry, I don't understand LISP well enough to read your answer. But my first impression is that the time cost of t... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13293/"
] | I've been slowly working my way through the list of Project Euler problems, and I've come to one that I know how to solve, but it seems like I can't (given the way my solution was written).
I am using Common Lisp to do this with and my script has been running for over 24 hours (well over their one minute goal).
For t... | Here's a solution, keeping in mind the spirit of [Project] Euler. [Warning: **spoiler**. I've tried to keep the hints slow, so that you can read only part of the answer and think on your own if you want. :)]
When you are confronted with a problem having to do with numbers, one good strategy (as you probably already kn... |
335,963 | <p>I'm using VSTS Database Edition GDR Version 9.1.31024.02</p>
<p>I've got a project where we will be creating multiple databases with identical schema, on the fly, as customers are added to the system. It's one DB per customer. I thought I should be able to use the deploy script to do this. Unfortunately I always ge... | [
{
"answer_id": 351343,
"author": "baralong",
"author_id": 5130,
"author_profile": "https://Stackoverflow.com/users/5130",
"pm_score": 0,
"selected": false,
"text": "<p>Hmm, well it seems that the best answer so far (given the over whelming response) is to edit the file after the fact... ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5130/"
] | I'm using VSTS Database Edition GDR Version 9.1.31024.02
I've got a project where we will be creating multiple databases with identical schema, on the fly, as customers are added to the system. It's one DB per customer. I thought I should be able to use the deploy script to do this. Unfortunately I always get the full... | Better late than never, I know how to get the `$(DefaultDataPath)$(DatabaseName)` file names from your second example.
The SQL you're showing in your first code snippet suggests that you don't have scripts for creating the database files in your VSTS:DB project, perhaps by deliberately excluded them from any schema c... |
335,974 | <p>I noticed by looking at sample code from Apple, that they tend to design methods that receive structures instead of multiple parameters. Why is that? As far as ease of use, I personally prefer the latter, but as far as performance goes, is there one better choice than the other?</p>
<pre><code>[pencil drawPoint:Poi... | [
{
"answer_id": 335984,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 1,
"selected": false,
"text": "<p>If you are passing the same set of parameters around it is useful to pass them in a structure because they belong to... | 2008/12/03 | [
"https://Stackoverflow.com/questions/335974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] | I noticed by looking at sample code from Apple, that they tend to design methods that receive structures instead of multiple parameters. Why is that? As far as ease of use, I personally prefer the latter, but as far as performance goes, is there one better choice than the other?
```
[pencil drawPoint:Point3Make(20,40,... | Don't muddle this question with concerns of performance. Don't make premature optimizations (until you know you have a problem) and when thinking about performance hot spots in your code, its almost always in areas dealing with I/O (eg, database, files). So, separate your question on message passing style with performa... |
336,013 | <p>I'm working on a PyGTK/glade application that currently has 16 windows/dialogs and is about 130KB, and will eventually have around 25 windows/dialogs and be around 200KB. Currently, I'm storing all the windows in one monolithic glade file. When I run a window I call it like...</p>
<pre><code>self.wTree = gtk.glad... | [
{
"answer_id": 336735,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 2,
"selected": false,
"text": "<p>Did you take some timings to find out whether it makes a difference? </p>\n\n<p>The problem is that, as far as I un... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24208/"
] | I'm working on a PyGTK/glade application that currently has 16 windows/dialogs and is about 130KB, and will eventually have around 25 windows/dialogs and be around 200KB. Currently, I'm storing all the windows in one monolithic glade file. When I run a window I call it like...
```
self.wTree = gtk.glade.XML("interface... | In my projects, I always have one window per glade file. I'd recommend the same for your project.
The following are the two main reasons:
* It will be faster and use less memory, since each call to gtk.glade.XML() parses the whole thing. Sure you can pass in the root argument to avoid creating the widget tree for all... |
336,018 | <p>I have a class <code>Page</code> that creates an instance of <code>DB</code>, which is named <code>$db</code>.</p>
<p>In the <code>__construct()</code> of <code>Page</code>, I create the new <code>$db</code> object and I pull a bunch of config data from a file.</p>
<p>Now the DB class has a method <code>_connectTo... | [
{
"answer_id": 336026,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 1,
"selected": false,
"text": "<p>Why not pass the config parameters to the connectToDb function or pass the config data to the constructor of the DB ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | I have a class `Page` that creates an instance of `DB`, which is named `$db`.
In the `__construct()` of `Page`, I create the new `$db` object and I pull a bunch of config data from a file.
Now the DB class has a method `_connectToDB()` which (attempts) to connect to the database.
Is there a way in the DB class to ca... | I find that it's often easier to initialise all the "important" objects close to whatever variables they need to know. You could try it this way:
```
/* Code to get config variables here */
$DB = new DB($config);
/* You might want to delete the database password from $config here */
$Page = new Page($config, $DB);
``... |
336,035 | <p>I have a DataGridViewComboBoxColumn in a DataGridView that's based on a lookup table.</p>
<p>The ValueMember and DisplayMember fields are bound to string columns in the DataTable. All rows have a value for both fields - except for a special record where the value field is deliberately set to NULL.</p>
<p>However, ... | [
{
"answer_id": 336569,
"author": "Mitkins",
"author_id": 23401,
"author_profile": "https://Stackoverflow.com/users/23401",
"pm_score": 3,
"selected": true,
"text": "<p>Well, I did come up with <em>a</em> solution. Because the DataGridView is data bound, I implemented the ColumnChanging e... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23401/"
] | I have a DataGridViewComboBoxColumn in a DataGridView that's based on a lookup table.
The ValueMember and DisplayMember fields are bound to string columns in the DataTable. All rows have a value for both fields - except for a special record where the value field is deliberately set to NULL.
However, when I choose thi... | Well, I did come up with *a* solution. Because the DataGridView is data bound, I implemented the ColumnChanging event for the DataTable. Sample code:
```
void Schedule_ColumnChanging(object sender, DataColumnChangeEventArgs e)
{
if
(
e.Column.ColumnName == "Site" &&
e.ProposedValue is string ... |
336,038 | <p>I am trying to create a very simple ASP.NET application that presents information retrieved from a database based on the URL, in a similar way to a wiki, but in this case the site is read-only. An example of a URL I'd like would be:</p>
<pre><code>http://www.foo.com/bar
</code></pre>
<p>The application would then ... | [
{
"answer_id": 336056,
"author": "Yona",
"author_id": 40007,
"author_profile": "https://Stackoverflow.com/users/40007",
"pm_score": 2,
"selected": false,
"text": "<p>IIS6 only directs requests to the asp.net engine if that extension has been registered. By default the registered extensio... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5702/"
] | I am trying to create a very simple ASP.NET application that presents information retrieved from a database based on the URL, in a similar way to a wiki, but in this case the site is read-only. An example of a URL I'd like would be:
```
http://www.foo.com/bar
```
The application would then use "bar" as a SQL query p... | IIS6 only directs requests to the asp.net engine if that extension has been registered. By default the registered extensions are aspx ascx asmx etc...
If you cannot base you database query on a query string parameter (e.g. foo.com/default.aspx?query=bar) then the best you can do on IIS6 is a wildcard mapping. Basicall... |
336,067 | <p>Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint... | [
{
"answer_id": 336090,
"author": "user35978",
"author_id": 35978,
"author_profile": "https://Stackoverflow.com/users/35978",
"pm_score": -1,
"selected": false,
"text": "<p>You could use diff to see if they are REALLY different.. I guess it will remove lots of useless comparison. Then, fo... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8005/"
] | Sometimes two image files may be different on a file level, but a human would consider them perceptively identical. Given that, now suppose you have a huge database of images, and you wish to know if a human would think some image X is present in the database or not. If all images had a perceptive hash / fingerprint, t... | [findimagedupes](http://www.jhnc.org/findimagedupes/) is pretty good. You can run "findimagedupes -v fingerprint images" to let it print "perceptive hash", for example. |
336,073 | <p>I keep finding that if I have nested divs inside each other, and one of the inner ones is floated, the outer one won't expand around it.</p>
<p>Example:</p>
<pre><code><div style='background-color:red; '>
asdfasdf
<div style='float:left; background-color:blue; width:400px; height:400px;'>
... | [
{
"answer_id": 336177,
"author": "themis",
"author_id": 42706,
"author_profile": "https://Stackoverflow.com/users/42706",
"pm_score": 5,
"selected": true,
"text": "<p>You can do it strictly with CSS using <strong>overflow:hidden</strong></p>\n\n<pre><code><div style='background-color:... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I keep finding that if I have nested divs inside each other, and one of the inner ones is floated, the outer one won't expand around it.
Example:
```
<div style='background-color:red; '>
asdfasdf
<div style='float:left; background-color:blue; width:400px; height:400px;'>
asdfasdfasdfasdfasdfasdfasdf<b... | You can do it strictly with CSS using **overflow:hidden**
```
<div style='background-color:red;overflow:hidden;'>
...
</div>
``` |
336,078 | <p>I use <em>lazy connection</em> to connect to my DB within my DB object. This basically means that it doesn't call mysql_connect() until the first query is handed to it, and it subsequently skips reconnecting from then on after.</p>
<p>Now I have a method in my DB class called <code>disconnectFromDB()</code> which p... | [
{
"answer_id": 336087,
"author": "Rob Prouse",
"author_id": 30827,
"author_profile": "https://Stackoverflow.com/users/30827",
"pm_score": 6,
"selected": true,
"text": "<p>As far as I know, unless you are using persistent connections, your MySQL connection will be closed at the end of the... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | I use *lazy connection* to connect to my DB within my DB object. This basically means that it doesn't call mysql\_connect() until the first query is handed to it, and it subsequently skips reconnecting from then on after.
Now I have a method in my DB class called `disconnectFromDB()` which pretty much calls `mysql_clo... | As far as I know, unless you are using persistent connections, your MySQL connection will be closed at the end of the page execution.
Therefore, you calling disconnect will add nothing and because you do the lazy connection, may cause a second connection to be created if you or another developer makes a mistake and di... |
336,127 | <p>I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.</p>
<p>At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm ho... | [
{
"answer_id": 336155,
"author": "Tim",
"author_id": 33914,
"author_profile": "https://Stackoverflow.com/users/33914",
"pm_score": 4,
"selected": false,
"text": "<p>There are some args for the <a href=\"http://us.php.net/manual/en/function.date.php\" rel=\"noreferrer\">date()</a> functio... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1103/"
] | I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.
At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm hoping there... | Here's a function from the [user comments](http://www.php.net/manual/en/function.date.php#79911) on the date() function page in the PHP manual. It's an improvement of an earlier function in the comments that adds support for leap years.
Enter the starting and ending dates, along with an array of any holidays that migh... |
336,144 | <p>I have an application where I would like to have mixed Java and Scala source (actually its migrating a java app to scala - but a bit at a time). </p>
<p>I can make this work in IDEs just fine, very nice. But I am not sure how to do this with maven - scalac can compile java and scala intertwined, but how to I set up... | [
{
"answer_id": 336187,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 4,
"selected": false,
"text": "<p>Yeah, the scala part has to be in a separate module and in <code>src/main/scala</code> directory. Maven regards mixed sou... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/699/"
] | I have an application where I would like to have mixed Java and Scala source (actually its migrating a java app to scala - but a bit at a time).
I can make this work in IDEs just fine, very nice. But I am not sure how to do this with maven - scalac can compile java and scala intertwined, but how to I set up maven for... | Using the maven scala plugin, a config like the one below will work for a project that mixes java and scala source (scala source of course goes in the /scala directory, as mentioned by someone else).
You can run run mvn compile, test etc... and it will all work as normal. Very nice (it will run scalac first automatic... |
336,148 | <p>I've been told that the java class TreeMap uses an implementation of a RB tree. If this is the case, how does one do an inorder, preorder and postorder tree-walk on a TreeMap?</p>
<p>Or is this not possible?</p>
| [
{
"answer_id": 336153,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>AFAIK the TreeSet/TreeMap classes don't actually expose any of their internals and merely conform to the Set/Map interface.... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | I've been told that the java class TreeMap uses an implementation of a RB tree. If this is the case, how does one do an inorder, preorder and postorder tree-walk on a TreeMap?
Or is this not possible? | You wouldn't be able to do this with the TreeMap implemented in the Collections library. Here's an implementation of a [Red-Black Tree](https://www.java-tips.org/java-se-tips-100019/24-java-lang/1904-red-black-tree-implementation-in-java.html) in Java that you can look at though. Check out the `printTree()` methods to ... |
336,181 | <p>Some of you may recognize this as Project Euler's problem number 11. The one with the grid.</p>
<p>I'm trying to replicate the grid in a large multidimensional array, But it's giving me a syntax error and i'm not sure why</p>
<pre><code>grid = [
[ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50... | [
{
"answer_id": 336189,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 6,
"selected": true,
"text": "<p>I think when you start a literal number with a 0, it interprets it as an octal number and you can't have an '8' in an oc... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | Some of you may recognize this as Project Euler's problem number 11. The one with the grid.
I'm trying to replicate the grid in a large multidimensional array, But it's giving me a syntax error and i'm not sure why
```
grid = [
[ 08, 02, 22, 97, 38, 15, 00, 40, 00, 75, 04, 05, 07, 78, 52, 12, 50, 77, 91, 08 ],
[ 49,... | I think when you start a literal number with a 0, it interprets it as an octal number and you can't have an '8' in an octal number. |
336,210 | <p>Is there a regular expression which checks if a string contains only upper and lowercase letters, numbers, and underscores?</p>
| [
{
"answer_id": 336214,
"author": "Drew Hall",
"author_id": 23934,
"author_profile": "https://Stackoverflow.com/users/23934",
"pm_score": 4,
"selected": false,
"text": "<p>Use</p>\n<pre class=\"lang-none prettyprint-override\"><code>^([A-Za-z]|[0-9]|_)+$\n</code></pre>\n<p>...if you want ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a regular expression which checks if a string contains only upper and lowercase letters, numbers, and underscores? | To match a string that contains *only* those characters (or an empty string), try
```none
"^[a-zA-Z0-9_]*$"
```
This works for .NET regular expressions, and probably a lot of other languages as well.
Breaking it down:
```none
^ : start of string
[ : beginning of character group
a-z : any lowercase letter
A-Z : any... |
336,225 | <p>Well I'm new to OOP in PHP and am trying to write a site with it. The site is a basic flash games site and has categories to track the games. My first step was to create a basic MVC setup and list all the categories. The problem is I don't know how to create an array with all of the categories in it. Can I add t... | [
{
"answer_id": 336267,
"author": "staticsan",
"author_id": 28832,
"author_profile": "https://Stackoverflow.com/users/28832",
"pm_score": 2,
"selected": false,
"text": "<p>Very simply, you're just missing the glue to put it all together. This is often described as the \"business logic\". ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | Well I'm new to OOP in PHP and am trying to write a site with it. The site is a basic flash games site and has categories to track the games. My first step was to create a basic MVC setup and list all the categories. The problem is I don't know how to create an array with all of the categories in it. Can I add this to ... | Very simply, you're just missing the glue to put it all together. This is often described as the "business logic". What you currently have as your "model" is actually your data storage layer. Your model needs to use this to return to the controller what it needs to give to the view.
Down in the code, you have several... |
336,226 | <p>Stupid questions but cant get my head around it...
I have a string in this format 20081119</p>
<p>And I have a C# method that converts the string to a DateTime to be entered into a SQL Server DB </p>
<pre><code>public static DateTime MyDateConversion(string dateAsString)
{
return System.DateTime.Parse... | [
{
"answer_id": 336238,
"author": "johnc",
"author_id": 5302,
"author_profile": "https://Stackoverflow.com/users/5302",
"pm_score": 1,
"selected": false,
"text": "<p>Date Time is a class that, by default, formats it's ToString as 19/11/2008 12:00:00 AM</p>\n\n<p>This is from <a href=\"htt... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Stupid questions but cant get my head around it...
I have a string in this format 20081119
And I have a C# method that converts the string to a DateTime to be entered into a SQL Server DB
```
public static DateTime MyDateConversion(string dateAsString)
{
return System.DateTime.ParseExact(dateAsString, "... | There is no such thing as "a DateTime of type yyyyMMdd"; a DateTime is just a large integer, indicating the amount of time in an epoch - it doesn't have a format. But that is fine, since you should be using parametrized TSQL anyway - so just add the DateTime as the value of a DbParameter, and it will be handed to the d... |
336,250 | <p>EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C.</p>
<p>I am trying to speed up a PHP CLI script by hav... | [
{
"answer_id": 336304,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 0,
"selected": false,
"text": "<p>man 2 setrlimit</p>\n\n<p>That's going to be per-user which <em>may</em> be what you want anyway.</p>\n"
},
{
"a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C.
I am trying to speed up a PHP CLI script by having it execu... | There is no syscall to get a list of child pids, but `ps` can do it for you.
`--ppid` switch will list all children for you process so you just need to count number of lines outputted by `ps`.
Alternatively you can maintain your own counter that you will increment on `fork()` and decrement on `SIGCHLD` signal, assumi... |
336,268 | <p>I thought these were synonomous, but I wrote the following in Microsoft SQL:</p>
<pre><code>Select Unique col from
(select col from table1 union select col from table2) alias
</code></pre>
<p>And it failed. Changing it to </p>
<pre><code>Select Distinct col from
(select col from table1 union select c... | [
{
"answer_id": 336273,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 7,
"selected": false,
"text": "<p>Unique is a keyword used in the Create Table() directive to denote that a field will contain unique data, usually ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42712/"
] | I thought these were synonomous, but I wrote the following in Microsoft SQL:
```
Select Unique col from
(select col from table1 union select col from table2) alias
```
And it failed. Changing it to
```
Select Distinct col from
(select col from table1 union select col from table2) alias
```
fixed it. ... | Unique is a keyword used in the Create Table() directive to denote that a field will contain unique data, usually used for natural keys, foreign keys etc.
For example:
```
Create Table Employee(
Emp_PKey Int Identity(1, 1) Constraint PK_Employee_Emp_PKey Primary Key,
Emp_SSN Numeric Not Null Unique,
... |
336,288 | <p>Presently I'm starting to introduce the concept of Mock objects into my Unit Tests. In particular I'm using the Moq framework. However, one of the things I've noticed is that suddenly the classes I'm testing using this framework are showing code coverage of 0%.</p>
<p>Now I understand that since I'm just mocking th... | [
{
"answer_id": 336293,
"author": "Aleš Roubíček",
"author_id": 19892,
"author_profile": "https://Stackoverflow.com/users/19892",
"pm_score": 3,
"selected": false,
"text": "<p>Big mistake is mocking the <a href=\"https://en.wikipedia.org/wiki/System_under_test\" rel=\"noreferrer\" title=\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | Presently I'm starting to introduce the concept of Mock objects into my Unit Tests. In particular I'm using the Moq framework. However, one of the things I've noticed is that suddenly the classes I'm testing using this framework are showing code coverage of 0%.
Now I understand that since I'm just mocking the class, i... | You are not using your mock objects correctly. When you are using mock objects you meant to be testing how your code interacts with other objects without actually using the real objects. See the code below:
```
using Moq;
using NUnitFramework;
namespace MyNameSpace
{
[TestFixture]
public class MyC... |
336,289 | <p>In vc++ i am using MScomm for serial communication,
i received data in this format 02120812550006050.0,
i am not gettng how to read this ,in which format it is,
begning starting frame and at the end ending file, remaing i dont know.</p>
<p>EDIT 1:</p>
<p>it contains date time and data how i can seperate this one<... | [
{
"answer_id": 336292,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>It is unlikely that you will figure it out unless you know what you are communicating with and how it communicates with you... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In vc++ i am using MScomm for serial communication,
i received data in this format 02120812550006050.0,
i am not gettng how to read this ,in which format it is,
begning starting frame and at the end ending file, remaing i dont know.
EDIT 1:
it contains date time and data how i can seperate this one | The funny characters are markers indicating things like record start, record end, field separator and so on. Without knowing the actual protocol, it's a little hard to tell.
The data is a lot easier.
Between the 000f and 0002 markers you have a date/time field, 2nd of December 2008, 12:55:00.
Between 0002 and 0003 m... |
336,303 | <p>I'm writing a <a href="http://en.wikipedia.org/wiki/VoiceXML" rel="nofollow noreferrer">VoiceXML</a> application where we have a speech grammar and a <a href="http://en.wikipedia.org/wiki/DTMF" rel="nofollow noreferrer">DTMF</a> grammar. If the caller is calling from a particularly noisy environment, we need to dis... | [
{
"answer_id": 435869,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 3,
"selected": false,
"text": "<p>What you're looking for is probably the <code>inputmodes</code> property:</p>\n\n<pre><code><property name=\"inpu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm writing a [VoiceXML](http://en.wikipedia.org/wiki/VoiceXML) application where we have a speech grammar and a [DTMF](http://en.wikipedia.org/wiki/DTMF) grammar. If the caller is calling from a particularly noisy environment, we need to disable the speech grammar. Is there a way to do this which doesn't involve copyi... | What you're looking for is probably the `inputmodes` property:
```
<property name="inputmodes" value="dtmf"/>
```
This will enable the DTMF grammar while the voice grammar is disabled. |
336,327 | <p>I am trying to build a CAML query for SharePoint 2007 environment, to get items from a calendar list. Want to query items with a given 'From date' and 'To date', the calendar list contains 'EventDate' and 'EndDate' in Datetime format. I am only interested in the date part of the datetime field.</p>
<p>How can I tri... | [
{
"answer_id": 336406,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>Unfortunately you have to use CAML.</p>\n\n<p>You should be able to trim the time part...</p>\n\n<pre><code><Where>\n ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35366/"
] | I am trying to build a CAML query for SharePoint 2007 environment, to get items from a calendar list. Want to query items with a given 'From date' and 'To date', the calendar list contains 'EventDate' and 'EndDate' in Datetime format. I am only interested in the date part of the datetime field.
How can I trim the "Eve... | Unfortunately you have to use CAML.
You should be able to trim the time part...
```
<Where>
<Gt>
<FieldRef Name='EventDate' />
<Value IncludeTimeValue='FALSE' Type='DateTime'>2008-12-03T12:00:00Z</Value>
</Gt>
</Where>
``` |
336,333 | <p>Is there a way to use add-as-link when dragging and dropping source files or entire source trees into a C# project?</p>
<p>Currently, dragging a tree of source files onto a C# project will cause Visual Studio to copy all files to mirror tree below my solution file.</p>
<p>This can be avoided with the the add-as-li... | [
{
"answer_id": 533353,
"author": "Dan Byström",
"author_id": 64121,
"author_profile": "https://Stackoverflow.com/users/64121",
"pm_score": 1,
"selected": false,
"text": "<p>Probably not what you're asking for, but once I had two .NET applications which I wanted to share a lot of source f... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27234/"
] | Is there a way to use add-as-link when dragging and dropping source files or entire source trees into a C# project?
Currently, dragging a tree of source files onto a C# project will cause Visual Studio to copy all files to mirror tree below my solution file.
This can be avoided with the the add-as-link option as depi... | What you can also do if you don't find a solution is bind a directory to your project by hand once and let the project find all .cs files in that directory automatically when it loads.
This is easily done by changing your MSBuild file in the following way:
```
<ItemGroup>
<Compile Include="SomeDirectory\**\*.cs"/>
... |
336,345 | <p>I have a sql database that stores some documents.</p>
<p>A user can sign into the application, and view a list of their documents.</p>
<p>When clicking a linkbutton download in a gridview of their docs, I get the file from the database, write it to the file system, and then execute this code.</p>
<pre><code> S... | [
{
"answer_id": 336353,
"author": "user19371",
"author_id": 19371,
"author_profile": "https://Stackoverflow.com/users/19371",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried setting the content-disposition to \"attachment\" rather than \"inline\"? I believe that the browser w... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22451/"
] | I have a sql database that stores some documents.
A user can sign into the application, and view a list of their documents.
When clicking a linkbutton download in a gridview of their docs, I get the file from the database, write it to the file system, and then execute this code.
```
System.IO.FileInfo file = new... | How are you sending the actual content of the file??
I usually use [Response.TransmitFile](http://msdn.microsoft.com/en-us/library/12s31dhy(VS.80).aspx) method, it basically opens the file and sends its content to the Response.OutputStream |
336,348 | <p>I've got a web page that's using jquery to receive some product information as people are looking at things and then displays the last product images that were seen. This is in a jquery AJAX callback that looks pretty much like this:</p>
<pre><code>if(number_of_things_seen > 10) {
$('#shots li:last-child').re... | [
{
"answer_id": 336374,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 1,
"selected": false,
"text": "<p>Can you try changing the src of the last-child and see if that makes a difference?\nYou can then move that element to b... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39975/"
] | I've got a web page that's using jquery to receive some product information as people are looking at things and then displays the last product images that were seen. This is in a jquery AJAX callback that looks pretty much like this:
```
if(number_of_things_seen > 10) {
$('#shots li:last-child').remove();
}
$('<li>... | Browsers are notorious for memory leaks. It sounds like the problem occurs when the page is left running for a long time. How about refreshing the page before it runs out of memory?
```
window.setTimeout("location.reload()",1000*60*60);//refresh in an hour
``` |
336,387 | <p>i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream.</p>
<p>this is the... | [
{
"answer_id": 336396,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 9,
"selected": true,
"text": "<p>As it's a MemoryStream, you really don't <em>need</em> to close the stream - nothing bad will happen if you don't, alt... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | i've got some binary data which i want to save as an image. When i try to save the image, it throws an exception if the memory stream used to create the image, was closed before the save. The reason i do this is because i'm dynamically creating images and as such .. i need to use a memory stream.
this is the code:
``... | As it's a MemoryStream, you really don't *need* to close the stream - nothing bad will happen if you don't, although obviously it's good practice to dispose anything that's disposable anyway. (See [this question](https://stackoverflow.com/questions/234059) for more on this.)
However, you *should* be disposing the Bitm... |
336,414 | <p>Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like this:</p>
<pre><code>string s = new StreamReader("filename", Encoding.UTF8).ReadToEnd();
</code></pre>
<p>Any alternative elegant construction with the same semantics will be also accepted.</p>
| [
{
"answer_id": 336419,
"author": "Scott Saad",
"author_id": 4916,
"author_profile": "https://Stackoverflow.com/users/4916",
"pm_score": 2,
"selected": false,
"text": "<p>You could use a <em><a href=\"http://msdn.microsoft.com/en-us/library/yh598w02(VS.80).aspx\" rel=\"nofollow noreferrer... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like this:
```
string s = new StreamReader("filename", Encoding.UTF8).ReadToEnd();
```
Any alternative elegant construction with the same semantics will be also accepted. | I think the method you're really after is [File.ReadAllText](http://msdn.microsoft.com/en-us/library/system.io.file.readalltext.aspx), if you're just trying to read all the text from a file in the shortest possible code.
If you don't specify the encoding, it will use UTF-8 automatically. |
336,416 | <p>I have the following piece of code which replaces "template markers" such as %POST_TITLE% with the contents of a variable called $post_title.</p>
<pre><code>function replaceTags( $template, $newtext ) {
$template = preg_replace( '/%MYTAG%/', $newtext, $template );
return $template;
}
</code></pre>
<p>The i... | [
{
"answer_id": 336421,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": true,
"text": "<p>According to <a href=\"http://theserverpages.com/php/manual/en/function.preg-replace.php\" rel=\"nofollow noreferrer\">preg_r... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2136/"
] | I have the following piece of code which replaces "template markers" such as %POST\_TITLE% with the contents of a variable called $post\_title.
```
function replaceTags( $template, $newtext ) {
$template = preg_replace( '/%MYTAG%/', $newtext, $template );
return $template;
}
```
The issue is that when $post\... | According to [preg\_replace manual](http://theserverpages.com/php/manual/en/function.preg-replace.php), preg\_replace() treats this (`$1`) as **[backreference](http://www.regular-expressions.info/brackets.html)**.
(and not a "callback syntax" as mentionned in the comments of the preg\_replace manual page.
Thank y... |
336,451 | <p>Okay, my dilemma is this. I have an admin page that I use to get a summary of the day's submissions to one of my sites. This sumamry page pulls data from several tables, some of which store the actual media data, others store the website urls, ids and owners, and another table stores the day-to-day stats to calculat... | [
{
"answer_id": 336460,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 0,
"selected": false,
"text": "<p>There is no such thing as a ajax file upload. The components that you see either use flash swfupload or a hidden iframe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Okay, my dilemma is this. I have an admin page that I use to get a summary of the day's submissions to one of my sites. This sumamry page pulls data from several tables, some of which store the actual media data, others store the website urls, ids and owners, and another table stores the day-to-day stats to calculate i... | SWFUpload
<http://demo.swfupload.org/v220beta3/simpledemo/index.php>
<http://swfupload.org/>
Javascript and Flash, there's no post-back :) and there's .NET implementations available on the site. |
336,452 | <p>I'd like to write a functional test of a RESTful web service I'm working on in a Ruby on Rails app. </p>
<p>The test is of a POST request where the body of the request is a plain XML doc and not a form. Any pointers on how to do this? The problem I'm encountering is how to specify the body XML in the call to the po... | [
{
"answer_id": 337001,
"author": "Mike Breen",
"author_id": 22346,
"author_profile": "https://Stackoverflow.com/users/22346",
"pm_score": -1,
"selected": false,
"text": "<p>Check out <a href=\"http://github.com/thoughtbot/shoulda/tree/master\" rel=\"nofollow noreferrer\">shoulda</a>'s \"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'd like to write a functional test of a RESTful web service I'm working on in a Ruby on Rails app.
The test is of a POST request where the body of the request is a plain XML doc and not a form. Any pointers on how to do this? The problem I'm encountering is how to specify the body XML in the call to the post method. | The following worked for me:
```
@request.env['RAW_POST_DATA'] = MY_XML_STRING
post :create
``` |
336,453 | <p>I've written a Custom User Control which returns some user specific data.
To load the Custom User Control I use the following line of code:</p>
<pre><code>UserControl myUC = (UserControl).Load("~/customUserControl.ascx");
</code></pre>
<p>But how can I access <code>string user</code> inside the User Control <code... | [
{
"answer_id": 336480,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 0,
"selected": false,
"text": "<p>You will need to cast the loaded control to the actual type and use its public property:</p>\n\n<pre><code>MyUserControl... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37972/"
] | I've written a Custom User Control which returns some user specific data.
To load the Custom User Control I use the following line of code:
```
UserControl myUC = (UserControl).Load("~/customUserControl.ascx");
```
But how can I access `string user` inside the User Control `myUC`? | Let's call your usercontrol "Bob"
If you Inherit from UserControl in Bob, then I guess it's safe to do this:
```
Bob b = (Bob).Load("~/customUserControl.ascx");
```
For the user part, I can't really follow what you want to do, is the "user" in the class were you create the "Bob" usercontrol and you want to set a pr... |
336,475 | <p>I am writing some new code that will throw a custom exception - I want to include an error string and a status code. Which class should be exception derive from? <code>std::exception</code>? <code>std::runtime_error</code>? Any other 'gotchas' to worry about? I'm thinking of something like the following:</p>
<p... | [
{
"answer_id": 336492,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "<p>Consider whether the status code is really appropriate. It's usually superior to create a hierarchy of exception c... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | I am writing some new code that will throw a custom exception - I want to include an error string and a status code. Which class should be exception derive from? `std::exception`? `std::runtime_error`? Any other 'gotchas' to worry about? I'm thinking of something like the following:
```
class MyException : public std:... | Boost has a great document on [error and exception](http://www.boost.org/community/error_handling.html) handling which talks about common gotchas and how to properly inherit from std::exception(s). |
336,495 | <p>Working with Microsoft SQL Server I found extremely useful SQL Server Profiler and Estimated Execution Plan (available in Management Studio) to optimize queries during development and production system monitoring.</p>
<p>Are there similar tools (open source or commercial) or techniques available for MySQL?</p>
| [
{
"answer_id": 336520,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "<p>You can get information about how a query will execute using <a href=\"http://dev.mysql.com/doc/refman/5.0/en/explain.html\... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42512/"
] | Working with Microsoft SQL Server I found extremely useful SQL Server Profiler and Estimated Execution Plan (available in Management Studio) to optimize queries during development and production system monitoring.
Are there similar tools (open source or commercial) or techniques available for MySQL? | You can get information about how a query will execute using [`EXPLAIN`](http://dev.mysql.com/doc/refman/5.0/en/explain.html).
For example:
```
EXPLAIN SELECT * FROM foo INNER JOIN bar WHERE foo.index = 1 AND bar.foo_id = foo.id
```
It will then tell you which indexes will be used, what order the tables will be joi... |
336,553 | <p>Somewhere in the code, a waitHandle is used to perfom some actions. However the thing with waithandle is that the form freezes while waiting for some action to complete. So the following code would not work:</p>
<pre><code>frmProgressBar.show();
int successOrFail = PerformSynchronousActionUsingWaitHandle();
frmProg... | [
{
"answer_id": 336559,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": 1,
"selected": false,
"text": "<p>Can't you use the BackgroundWorker Class? <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Somewhere in the code, a waitHandle is used to perfom some actions. However the thing with waithandle is that the form freezes while waiting for some action to complete. So the following code would not work:
```
frmProgressBar.show();
int successOrFail = PerformSynchronousActionUsingWaitHandle();
frmProgressBar.close(... | Can't you use the BackgroundWorker Class? <http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx> |
336,572 | <p>How do we filter an xml document based on another xml document. I have to remove all the elements which are not there in the lookup xml. Both the input xml and lookup xml has the same root elements, we are using XSLT 1.0.</p>
<p>Ex Input</p>
<pre><code><Root>
<E1 a="1">V1</E1>
<E2>V... | [
{
"answer_id": 336606,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "<p>Hmmm, you're sort of talking about merging (assuming your filter doc is variable). There's a couple of possibilities w... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26036/"
] | How do we filter an xml document based on another xml document. I have to remove all the elements which are not there in the lookup xml. Both the input xml and lookup xml has the same root elements, we are using XSLT 1.0.
Ex Input
```
<Root>
<E1 a="1">V1</E1>
<E2>V2</E2>
<E3>V3</E3>
<E5>
<SE51>... | Here is the required transformation:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:z="inline:text.xml"
exclude-result-prefixes="z"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<z:filter>
<Root>
<... |
336,575 | <p>I would like to know whether it is possible to force LWP::UserAgent to accept an expired SSL certificate for a single, well-known server. The issue is slightly complicated by the Squid proxy in between.</p>
<p>I went as far as to set up a debugging environment like:</p>
<pre><code>use warnings;
use strict;
use Car... | [
{
"answer_id": 338550,
"author": "joshperry",
"author_id": 30587,
"author_profile": "https://Stackoverflow.com/users/30587",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Updated to address comment</strong></p>\n\n<p>To bypass <em>all</em> certificate checks you can set the <a hre... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36218/"
] | I would like to know whether it is possible to force LWP::UserAgent to accept an expired SSL certificate for a single, well-known server. The issue is slightly complicated by the Squid proxy in between.
I went as far as to set up a debugging environment like:
```
use warnings;
use strict;
use Carp;
use LWP::UserAgent... | **Updated to address comment**
To bypass *all* certificate checks you can set the [agent](http://search.cpan.org/~gaas/libwww-perl-6.05/lib/LWP/UserAgent.pm) up to not verify the certificate.
```
$agent->ssl_opts(verify_hostname => 0);
```
The agent will also pass settings down to the SSL socket implementation bein... |
336,578 | <p>We have a Hibernate/Spring application that have the following Spring beans:</p>
<pre><code><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" /&... | [
{
"answer_id": 336598,
"author": "BraveSirFoobar",
"author_id": 39263,
"author_profile": "https://Stackoverflow.com/users/39263",
"pm_score": 1,
"selected": false,
"text": "<p>Do you know about the property \"factory-method\" ? You can make spring call that method instead of the construc... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/382264/"
] | We have a Hibernate/Spring application that have the following Spring beans:
```
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" />
```
When wiring the ... | While I haven't used Spring, I have used Hibernate in a project which has classes which must either be instantiated by factory methods or through multiple argument constructors.
You can do this through an Interceptor, which is a class which listens in to several key hibernate events, such as when an object needs to be... |
336,585 | <p>I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I knew what was going on until a colleague told me that:</p>
<pre><code>const MyStructure** ppMyStruct;
</code></pre>
<p>means "ppMyStruct is <strong>a pointer to a const pointer to a (mutable) MyStructure</strong>" (in C++).</p>
<p... | [
{
"answer_id": 336621,
"author": "James Hopkin",
"author_id": 11828,
"author_profile": "https://Stackoverflow.com/users/11828",
"pm_score": 7,
"selected": true,
"text": "<p>Your colleague is wrong. That is a (non-const) pointer to a (non-const) pointer to a const MyStructure. In both C a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15323/"
] | I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I knew what was going on until a colleague told me that:
```
const MyStructure** ppMyStruct;
```
means "ppMyStruct is **a pointer to a const pointer to a (mutable) MyStructure**" (in C++).
I would have thought it meant "ppMyStruct is ... | Your colleague is wrong. That is a (non-const) pointer to a (non-const) pointer to a const MyStructure. In both C and C++. |
336,605 | <p>Is there a fast algorithm for finding the Largest Common Substring in two <code>strings</code> or is it an NPComplete problem?</p>
<p>In PHP I can find a needle in a haystack:</p>
<pre><code><?php
if (strstr("there is a needle in a haystack", "needle")) {
echo "found<br>\n";
}
?>
</code></pre>
<p... | [
{
"answer_id": 336617,
"author": "Tom",
"author_id": 42754,
"author_profile": "https://Stackoverflow.com/users/42754",
"pm_score": 3,
"selected": true,
"text": "<p>I have since found <a href=\"http://en.wikipedia.org/wiki/Longest_common_substring_problem\" rel=\"nofollow noreferrer\">a r... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42754/"
] | Is there a fast algorithm for finding the Largest Common Substring in two `strings` or is it an NPComplete problem?
In PHP I can find a needle in a haystack:
```
<?php
if (strstr("there is a needle in a haystack", "needle")) {
echo "found<br>\n";
}
?>
```
I guess I could do this in a loop over one of the `stri... | I have since found [a relevant wikipedia article](http://en.wikipedia.org/wiki/Longest_common_substring_problem). It is not a NP complete problem, it can be done in O(mn) time using a dynamic programming algorithm.
In PHP I found the [similar\_text](http://us3.php.net/manual/en/function.similar-text.php) function very... |
336,628 | <p>One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use "step over" (by pressing <kbd>F10</kbd>) to execute to the next line of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all th... | [
{
"answer_id": 336680,
"author": "Evgeny Lazin",
"author_id": 42371,
"author_profile": "https://Stackoverflow.com/users/42371",
"pm_score": 5,
"selected": false,
"text": "<p>You can freeze a different thread or switch to another thread using the Threads debug window (<kbd>Ctrl</kbd> + <k... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11758/"
] | One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use "step over" (by pressing `F10`) to execute to the next line of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all the context of... | I think there is only one answer to your question, which you have discounted as being 'way too much work.' However, I believe that is because you are going about it the wrong way. Let me present steps for adding a conditional breakpoint on Thread ID, which are extremely easy, but not obvious until you know them.
1. St... |
336,633 | <p>In a <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> 2.0 C# application I use the following code to detect the operating system platform:</p>
<pre><code>string os_platform = System.Environment.OSVersion.Platform.ToString();
</code></pre>
<p>This returns "Win32NT". The problem is tha... | [
{
"answer_id": 336645,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 4,
"selected": false,
"text": "<p>Quickest way:</p>\n\n<pre><code>if(IntPtr.Size == 8) {\n // 64 bit machine\n} else if(IntPtr.Size == 4) {\n ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34022/"
] | In a [.NET](http://en.wikipedia.org/wiki/.NET_Framework) 2.0 C# application I use the following code to detect the operating system platform:
```
string os_platform = System.Environment.OSVersion.Platform.ToString();
```
This returns "Win32NT". The problem is that it returns "Win32NT" even when running on Windows Vi... | **UPDATE:** As Joel Coehoorn and others suggest, starting at .NET Framework 4.0, you can just check `Environment.Is64BitOperatingSystem`.
---
IntPtr.Size won't return the correct value if running in 32-bit .NET Framework 2.0 on 64-bit Windows (it would return 32-bit).
As Microsoft's Raymond Chen describes, you have ... |
336,654 | <p>I've found the following code from here "<a href="http://www.boyet.com/Articles/CodeFromInternet.html" rel="nofollow noreferrer"><a href="http://www.boyet.com/Articles/CodeFromInternet.html" rel="nofollow noreferrer">http://www.boyet.com/Articles/CodeFromInternet.html</a></a>".<br/>
It returns the speed of the CPU i... | [
{
"answer_id": 359576,
"author": "Binoj Antony",
"author_id": 33015,
"author_profile": "https://Stackoverflow.com/users/33015",
"pm_score": 3,
"selected": false,
"text": "<p>Code below should do the trick</p>\n\n<pre><code> RegistryKey registrykeyHKLM = Registry.LocalMachine;\n string ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34022/"
] | I've found the following code from here "[<http://www.boyet.com/Articles/CodeFromInternet.html>](http://www.boyet.com/Articles/CodeFromInternet.html)".
It returns the speed of the CPU in GHz but works only on 32bit Windows.
```
using System;
using System.Management;
namespace CpuSpeed
{
class Program
{
... | I've used the following code based on the answer by Binoj Antony which returns the speed for each CPU/core, not only the first one:
```
Microsoft.Win32.RegistryKey registrykeyHKLM = Microsoft.Win32.Registry.LocalMachine;
string cpuPath = @"HARDWARE\DESCRIPTION\System\CentralProcessor";
Microsoft.Win32.RegistryKey regi... |
336,665 | <p>I have a VB6 class with a method which raises an error:</p>
<pre><code>Public Sub DoSomething
...
err.Raise 12345, description:="Error message"
...
End Sub
</code></pre>
<p>This method is called from a form:</p>
<pre><code>Public Sub ErrTest()
On Error Goto err1
obj.DoSomething
Exit Sub
err1:
MsgBox... | [
{
"answer_id": 336784,
"author": "onedaywhen",
"author_id": 15354,
"author_profile": "https://Stackoverflow.com/users/15354",
"pm_score": 4,
"selected": true,
"text": "<p>In the VB IDE, go to Tools, Option, General tab, Error trapping frame. I'm guessing you have it set to 'Break on All ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23368/"
] | I have a VB6 class with a method which raises an error:
```
Public Sub DoSomething
...
err.Raise 12345, description:="Error message"
...
End Sub
```
This method is called from a form:
```
Public Sub ErrTest()
On Error Goto err1
obj.DoSomething
Exit Sub
err1:
MsgBox err.Description
End Sub
```
This w... | In the VB IDE, go to Tools, Option, General tab, Error trapping frame. I'm guessing you have it set to 'Break on All Errors', whereas you probably want 'Break on Unhandled Errors'.
Your `Err.Raise` statement gives a compile error for me; try removing the braces.
Also, you may want to use
```
Err.Raise vbObjectError... |
336,670 | <p>I'm using xslt to transform xml to an aspx file. In the xslt, I have a script tag to include a jquery.js file. To get it to work with IE, the script tag must have an explicit closing tag. For some reason, this doesn't work with xslt below.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe... | [
{
"answer_id": 336693,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "<p>And this is against MS's XSLT engine of course? How strange. I can't say I've encountered this in .NET 1.1 or 2.0 and ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using xslt to transform xml to an aspx file. In the xslt, I have a script tag to include a jquery.js file. To get it to work with IE, the script tag must have an explicit closing tag. For some reason, this doesn't work with xslt below.
```
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xm... | If you're creating the XmlWriter yourself you need to pass the transform's OutputSettings to the XmlWriter, eg:
```
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book><author>Trudi Canavan</author><title>Voice of the Gods</title></book>");
XslCompiledTransform transform = new XslCompiledTransform();
transform.Lo... |
336,696 | <p>This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem.
As it turns out it is waiting on a call to a method which is declared as -</p>
<pre><code>synchronized void stopQuery()
</code></pre>
<p>But here is the crazy part, the lock for the 'synchronized' method is ... | [
{
"answer_id": 336700,
"author": "Carl Seleborg",
"author_id": 2095,
"author_profile": "https://Stackoverflow.com/users/2095",
"pm_score": 0,
"selected": false,
"text": "<p>Is the method recursive, somehow? Maybe you're using an object inside of it which requires that very same method?</... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14316/"
] | This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem.
As it turns out it is waiting on a call to a method which is declared as -
```
synchronized void stopQuery()
```
But here is the crazy part, the lock for the 'synchronized' method is already held by the thread... | This looks like a particularly nasty deadlock. It's hard to tell for sure without a little more information. Here's what I see without the code in front of me, though:
Possible deadlock on (or at least contention for) Object reference 0x00002aace2276720 between "Text Viewer Hover Presenter" and "Worker-3" while "Worke... |
336,714 | <p>I'm beginner in Java. I'm reading data from device through serial port. I'm getting data for every one minute, but first reading is coming half, after that data is coming correctly.</p>
<p>Output I'm getting is: </p>
<blockquote>
<p>6050.003120815340006050.003120815350006050.0</p>
</blockquote>
<p>Correct outpu... | [
{
"answer_id": 336736,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 2,
"selected": false,
"text": "<p>This looks as if you were reading the rest of some message which was sent before you started.</p>\n\n<p>Try to re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm beginner in Java. I'm reading data from device through serial port. I'm getting data for every one minute, but first reading is coming half, after that data is coming correctly.
Output I'm getting is:
>
> 6050.003120815340006050.003120815350006050.0
>
>
>
Correct output should be like this:
>
> 031208153... | This looks as if you were reading the rest of some message which was sent before you started.
Try to read as much data as possible as you start the program to clear any hardware buffers. After that, start your processing. |
336,716 | <p>How can I assert my <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> request and test the JSON output from Ruby on Rails functional tests?</p>
| [
{
"answer_id": 395912,
"author": "nicholaides",
"author_id": 48424,
"author_profile": "https://Stackoverflow.com/users/48424",
"pm_score": 8,
"selected": true,
"text": "<h2>In Rails >= 5</h2>\n<p>Use <a href=\"https://www.apidock.com/rails/v6.0.0/ActionDispatch/TestResponse/parsed_bod... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] | How can I assert my [Ajax](http://en.wikipedia.org/wiki/Ajax_%28programming%29) request and test the JSON output from Ruby on Rails functional tests? | In Rails >= 5
-------------
Use [`ActionDispatch::TestResponse#parsed_body`](https://www.apidock.com/rails/v6.0.0/ActionDispatch/TestResponse/parsed_body).
Example:
```
user = @response.parsed_body
assert_equal "Mike", user['name']
```
In Rails up to 4.x
------------------
Use `JSON.parse`, which takes a string a... |
336,721 | <p>I have an ASP.NET (2.0) site. I am on my dev box using V Studio 2008 and IIS. I have a separate User Control project that gets called from a javascript function in the default.aspx page. The User Control project is in another solution.</p>
<p>The application is running as expected. The user control is being called ... | [
{
"answer_id": 336767,
"author": "Chris James",
"author_id": 3193,
"author_profile": "https://Stackoverflow.com/users/3193",
"pm_score": 1,
"selected": false,
"text": "<ul>\n<li>Add the user control project to the solution you want to debug in.</li>\n<li>Remove the reference you have to ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an ASP.NET (2.0) site. I am on my dev box using V Studio 2008 and IIS. I have a separate User Control project that gets called from a javascript function in the default.aspx page. The User Control project is in another solution.
The application is running as expected. The user control is being called and all is... | * Add the user control project to the solution you want to debug in.
* Remove the reference you have to the user control project
* Then set the reference of the calling project, to be the local user control project
Edit: You might also have to do a clean after you remove the reference on the second step - then check t... |
336,731 | <p>How do I create a view dynamically in SQL Server using C#?</p>
| [
{
"answer_id": 336740,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the following code to write the query for a view:</p>\n\n<pre><code>query = \" Create View [Viewname] Sele... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18709/"
] | How do I create a view dynamically in SQL Server using C#? | Something like this, obviously your connection code will be different (better):
```
SqlConnection conn = null;
conn = new SqlConnection("yourConnectionString");
conn.Open();
string strSQLCommand = "CREATE VIEW vw_YourView AS SELECT YOurColumn FROM YourTable";
SqlCommand command = new SqlCommand(strSQLCommand, conn);
... |
336,755 | <p>In C# is it guaranteed that expressions are evaluated left to right? </p>
<p>For example:</p>
<pre><code>myClass = GetClass();
if (myClass == null || myClass.Property > 0)
continue;
</code></pre>
<p>Are there any languages that do not comply?</p>
| [
{
"answer_id": 336770,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 0,
"selected": false,
"text": "<p>The evaluation order depends on the operator, in this case the boolean or (<code><a href=\"http://msdn.microsoft.com/en-... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In C# is it guaranteed that expressions are evaluated left to right?
For example:
```
myClass = GetClass();
if (myClass == null || myClass.Property > 0)
continue;
```
Are there any languages that do not comply? | You actually refer to a language feature called "short-circuiting logical expressions":
What this means is this: When the outcome of a logical expression cannot change anymore, e.g. when it is clear that the expression will evaluate to "true" or "false" no matter what, remaining parts of the expression will not be ev... |
336,756 | <p>This code is not working on IE8 at all. FF3 is executing but the page is blank and seems loading not ending.</p>
<p>My code is:</p>
<pre><code>$("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>... | [
{
"answer_id": 336807,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 0,
"selected": false,
"text": "<p>try wrapping your code in</p>\n\n<pre><code>$(document).ready(function() {\n // your code here\n});\n</code></pre>\n"
},... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This code is not working on IE8 at all. FF3 is executing but the page is blank and seems loading not ending.
My code is:
```
$("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>".replace(/script2/gi, "script"));
```
I wa... | This works for me in FF3 and IE7:
```
$("#leaderBoard").html('<sc'+'ript language="javascript1.1">alert(1);</sc'+'ript>');
```
When you use document.write after the page has loaded, it replaces the entire document (<http://javascript.about.com/library/blwrite.htm>). You essentially replaced your page content with a ... |
336,775 | <p>Continuing <a href="https://stackoverflow.com/questions/308481/writing-the-f-recursive-folder-visitor-in-c-seq-vs-ienumerable">my investigation</a> of expressing F# ideas in C#, I wanted a pipe forward operator. For anything wrapped in a IEnumerable, we already have it, as you can .NextFunc() to your heart's content... | [
{
"answer_id": 336805,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>While it's not quite the same thing, you might be interested in my <a href=\"http://msmvps.com/blogs/jon_skeet/archiv... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | Continuing [my investigation](https://stackoverflow.com/questions/308481/writing-the-f-recursive-folder-visitor-in-c-seq-vs-ienumerable) of expressing F# ideas in C#, I wanted a pipe forward operator. For anything wrapped in a IEnumerable, we already have it, as you can .NextFunc() to your heart's content. But for exam... | I haven't bothered with a raw pipe, but I have tried making all references into the Maybe monad:
```
public static class ReferenceExtensions
{
public static TOut IfNotNull<TIn, TOut>(this TIn v, Func<TIn, TOut> f)
where TIn : class
where TOut... |
336,781 | <p>How can I read a Chinese text file using C#, my current code can't display the correct characters:</p>
<pre><code>try
{
using (StreamReader sr = new StreamReader(path,System.Text.Encoding.UTF8))
{
// This is an arbitrary size for this example.
string c = null;
while (sr.Peek() &... | [
{
"answer_id": 336786,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 1,
"selected": false,
"text": "<p><strike>Use <code>Encoding.Unicode</code> instead.</strike></p>\n\n<p>I think you need to change the OutputEncoding of t... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I read a Chinese text file using C#, my current code can't display the correct characters:
```
try
{
using (StreamReader sr = new StreamReader(path,System.Text.Encoding.UTF8))
{
// This is an arbitrary size for this example.
string c = null;
while (sr.Peek() >= 0)
{... | You need to use the right encoding for the file. Do you know what that encoding is? It might be UTF-16, aka Encoding.Unicode, or possibly something like Big5. Really you should try to find out for sure instead of guessing though.
As leppie's answer mentioned, the problem might also be the capabilities of the console. ... |
336,801 | <p>I have pretty much finished my first working Symbian application, but in my hastened learning have paid little attention to memory management and pushing to and cleaning up the stack?</p>
<p>Could somebody please point me in the direction of some of the best practises to use here, and maybe some of the best leak de... | [
{
"answer_id": 336833,
"author": "Dynite",
"author_id": 16177,
"author_profile": "https://Stackoverflow.com/users/16177",
"pm_score": 2,
"selected": false,
"text": "<p>Things stored on the stack do not need to be stored on the cleanup stack (unless they need special handling (R Classes e... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33604/"
] | I have pretty much finished my first working Symbian application, but in my hastened learning have paid little attention to memory management and pushing to and cleaning up the stack?
Could somebody please point me in the direction of some of the best practises to use here, and maybe some of the best leak detection/me... | I have in the past used [HookLogger from Symbian](http://www.newlc.com/Hooklogger-Tracking-leaked-heap.html) to trace and investigate memory leaks. It is not the best, but it sure does help. Also, the heap markers raise ALLOC panics in case of memory leaks whenever your exit your application. The information those pani... |
336,813 | <p>I understand they both don't change the URL that the client sees. Is there anything in them that makes one of them preferable over the other?<br>
I'm planning to use it in the Application_BeginRequest in Global.asax, but also in regular aspx page.</p>
| [
{
"answer_id": 336829,
"author": "netadictos",
"author_id": 31791,
"author_profile": "https://Stackoverflow.com/users/31791",
"pm_score": 4,
"selected": true,
"text": "<p>I think <code>Context.RewritePath()</code> is the better option. \nReason:</p>\n\n<p><code>Server.Transfer()</code> t... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278/"
] | I understand they both don't change the URL that the client sees. Is there anything in them that makes one of them preferable over the other?
I'm planning to use it in the Application\_BeginRequest in Global.asax, but also in regular aspx page. | I think `Context.RewritePath()` is the better option.
Reason:
`Server.Transfer()` throws a `ThreadAbortException` every time. The result of calling `Response.End()`.
For more details read the following MS articles:
* [ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer](http:/... |
336,814 | <p>Session transcript:</p>
<pre><code>> type lookma.c
int main() {
printf("%s", "no stdio.h");
}
> cl lookma.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
lookma.c
Microsoft (R) Incremental Link... | [
{
"answer_id": 336825,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 5,
"selected": false,
"text": "<p>You had originally tagged this C++, but it would appear to be a C program. C will automatically provide an implicit d... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20310/"
] | Session transcript:
```
> type lookma.c
int main() {
printf("%s", "no stdio.h");
}
> cl lookma.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
lookma.c
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C)... | In strict compliance mode (that means "in theory"), you invoke undefined behaviour (which is bad) when you call a function that takes a variable number of arguments without a prototype declaration of the function in scope. That means that the compiler is allowed to do anything it likes with a program that uses `printf(... |
336,817 | <p>I have a user control that I'm building. It's purpose is to display the status of a class to the user. Obviously, this does not matter, and will slow things down when the control runs in the IDE, as it does as soon as you add it to a form.</p>
<p>One way to work around this would be to have the control created an... | [
{
"answer_id": 336830,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 5,
"selected": true,
"text": "<pre><code>public static bool IsInRuntimeMode( IComponent component ) {\n bool ret = IsInDesignMode( component );\n retu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6389/"
] | I have a user control that I'm building. It's purpose is to display the status of a class to the user. Obviously, this does not matter, and will slow things down when the control runs in the IDE, as it does as soon as you add it to a form.
One way to work around this would be to have the control created and added to t... | ```
public static bool IsInRuntimeMode( IComponent component ) {
bool ret = IsInDesignMode( component );
return !ret;
}
public static bool IsInDesignMode( IComponent component ) {
bool ret = false;
if ( null != component ) {
ISite site = component.Site;
if ( null != site ) {
... |
336,826 | <p>SQL Server Full Text Search uses language specific Word Breakers. </p>
<p>For the German language this is used to break/split words including compound words. However, it appears not all known compound words are included in the Word Breaker. I would like to know if a list is available of the words the Word Breaker d... | [
{
"answer_id": 336830,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 5,
"selected": true,
"text": "<pre><code>public static bool IsInRuntimeMode( IComponent component ) {\n bool ret = IsInDesignMode( component );\n retu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42434/"
] | SQL Server Full Text Search uses language specific Word Breakers.
For the German language this is used to break/split words including compound words. However, it appears not all known compound words are included in the Word Breaker. I would like to know if a list is available of the words the Word Breaker does know a... | ```
public static bool IsInRuntimeMode( IComponent component ) {
bool ret = IsInDesignMode( component );
return !ret;
}
public static bool IsInDesignMode( IComponent component ) {
bool ret = false;
if ( null != component ) {
ISite site = component.Site;
if ( null != site ) {
... |
336,831 | <p>I really need your help in my issue very quickly and it's too close to the previous issue.
I want to call a function using thread from the main thread.</p>
<p>for more explanaition, here is a sample from my code:
// please look to the code begining from ( //------- ) </p>
<pre><code> // this function is being c... | [
{
"answer_id": 336838,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>You can't do operations on the UI from a different thread - but you could make GetFromServer and GetFromPC <em>fetch</... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] | I really need your help in my issue very quickly and it's too close to the previous issue.
I want to call a function using thread from the main thread.
for more explanaition, here is a sample from my code:
// please look to the code begining from ( //------- )
```
// this function is being called from the Form1 ... | You can't do operations on the UI from a different thread - but you could make GetFromServer and GetFromPC *fetch* the data on the other thread and then call Control.Invoke to get back to the UI thread to update the treeview.
See [my threading article](http://pobox.com/~skeet/csharp/threads/winforms.shtml) for example... |
336,845 | <p>Does anybody know why the following code only has effect in FF?</p>
<pre><code>$(document).ready(function() {
$('#powerSearchSubmitButton').click(function() {
startLoad();
});
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({ opacity: 0 }, 500);
... | [
{
"answer_id": 336838,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>You can't do operations on the UI from a different thread - but you could make GetFromServer and GetFromPC <em>fetch</... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | Does anybody know why the following code only has effect in FF?
```
$(document).ready(function() {
$('#powerSearchSubmitButton').click(function() {
startLoad();
});
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({ opacity: 0 }, 500);
});
};
``` | You can't do operations on the UI from a different thread - but you could make GetFromServer and GetFromPC *fetch* the data on the other thread and then call Control.Invoke to get back to the UI thread to update the treeview.
See [my threading article](http://pobox.com/~skeet/csharp/threads/winforms.shtml) for example... |
336,849 | <p>i have a problem with windows system cache.
Sample code:</p>
<pre><code>int main(int argc, char* argv[])
{
HANDLE file_ = INVALID_HANDLE_VALUE;
file_ = CreateFile(
"test_file.txt",
GENERIC_WRITE,
FILE_SHARE_READ,
... | [
{
"answer_id": 336941,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 2,
"selected": false,
"text": "<p>The Windows file cache will try to keep as much of a file in RAM as possible. In Windows NT, loading a very big f... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42371/"
] | i have a problem with windows system cache.
Sample code:
```
int main(int argc, char* argv[])
{
HANDLE file_ = INVALID_HANDLE_VALUE;
file_ = CreateFile(
"test_file.txt",
GENERIC_WRITE,
FILE_SHARE_READ,
... | The Windows file cache will try to keep as much of a file in RAM as possible. In Windows NT, loading a very big file could trigger a bug. If the file didn't fit into the cache, it would never be released anymore forcing everything else out of RAM into the swapfile until your machine would constantly swap.
But your cas... |
336,859 | <p>I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.</p>
<p>The previous developer used two ways of declaring functions and I can't work out if there is a reason behind it or not.</p>
<p>The two ways are:</... | [
{
"answer_id": 336868,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 13,
"selected": true,
"text": "<p>The difference is that <code>functionOne</code> is a function expression and so only defined when that line is reached, wh... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31569/"
] | I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.
The previous developer used two ways of declaring functions and I can't work out if there is a reason behind it or not.
The two ways are:
```
var functio... | The difference is that `functionOne` is a function expression and so only defined when that line is reached, whereas `functionTwo` is a function declaration and is defined as soon as its surrounding function or script is executed (due to [hoisting](http://adripofjavascript.com/blog/drips/variable-and-function-hoisting.... |
336,866 | <p>I want to create a very simple HTML/AJAX based GUI for a Python program. So the frontend is a HTML page which communicates with the program via AJAX. Can you give me a minimal implementation for the server-side using the python <code>SimpleHTTPServer.SimpleHTTPRequestHandler</code>?</p>
<p>A simple example would be... | [
{
"answer_id": 336894,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": false,
"text": "<p>Use the <a href=\"https://docs.python.org/2/library/wsgiref.html#module-wsgiref.simple_server\" rel=\"nofollow noreferre... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11992/"
] | I want to create a very simple HTML/AJAX based GUI for a Python program. So the frontend is a HTML page which communicates with the program via AJAX. Can you give me a minimal implementation for the server-side using the python `SimpleHTTPServer.SimpleHTTPRequestHandler`?
A simple example would be a textfield and a bu... | O.K., I think I can now answer my own question. Here is an example implementation for calculating the square of a number on the server. Please let me know if there are any improvements or misconceptions.
the python server file:
```
import threading
import webbrowser
import BaseHTTPServer
import SimpleHTTPServer
FILE... |
336,884 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/390900/cant-operator-be-applied-to-generic-types-in-c">Can’t operator == be applied to generic types in C#?</a> </p>
</blockquote>
<p>I've got the following generic class and the compiler complains that "<code>... | [
{
"answer_id": 336890,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "<ul>\n<li>Equals() for value types</li>\n<li>ReferenceEquals() for reference types</li>\n</ul>\n"
},
{
"answer_id":... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] | >
> **Possible Duplicate:**
>
> [Can’t operator == be applied to generic types in C#?](https://stackoverflow.com/questions/390900/cant-operator-be-applied-to-generic-types-in-c)
>
>
>
I've got the following generic class and the compiler complains that "`Operator '!=' cannot be applied to operands of type 'TVa... | Did you try something like this?
```
public class Example<TValue>
{
private TValue _value;
public TValue Value
{
get { return _value; }
set
{
if (!object.Equals(_value, value))
{
_value = value;
OnPropertyChanged("Value");
... |
336,897 | <p>In a webservice I see this code:</p>
<pre><code><WebMethod()> _
Public Function dosomething() As Boolean
Try
If successful Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function
</code></pre>
<p>What's ... | [
{
"answer_id": 336902,
"author": "Jack Ryan",
"author_id": 28882,
"author_profile": "https://Stackoverflow.com/users/28882",
"pm_score": 5,
"selected": true,
"text": "<p>I can think of no reason to do this for functionality. However, it can arise when previously there was some error han... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19307/"
] | In a webservice I see this code:
```
<WebMethod()> _
Public Function dosomething() As Boolean
Try
If successful Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function
```
What's the point of catching the except... | I can think of no reason to do this for functionality. However, it can arise when previously there was some error handling (logging usually) that has been removed, and the developer removed the log handling but did not restructure the code to remove the redundant try/catch. |
336,903 | <p>Is there in Windows API or in MFC any analog to <code>atoh()</code> function?</p>
<p><code>atoh()</code> converts a string containing a hexadecimal number into an unsigned number like</p>
<pre><code>unsigned x = atoh("A");
</code></pre>
<p>and x = 10 after the operation.</p>
<p>In Windows I have a CString, conta... | [
{
"answer_id": 336908,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "<p><code>unsigned long ten = <a href=\"http://msdn.microsoft.com/en-us/library/5k9xb7x1(VS.80).aspx\" rel=\"nofollow norefe... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4378/"
] | Is there in Windows API or in MFC any analog to `atoh()` function?
`atoh()` converts a string containing a hexadecimal number into an unsigned number like
```
unsigned x = atoh("A");
```
and x = 10 after the operation.
In Windows I have a CString, containing "A". How can I convert it to int? | ```
long x = strtoul("A", (char **) NULL, 16);
// x will be 10 decimal
``` |
336,909 | <p>I'm looking for a method to grep for multiple atoms e.g. "foo" and "bar".
I'm aware i can use <br />
<code>grep 'foo' file | grep 'bar'</code><br />
to get both of them but i was wondering if there was a more efficient way. Any googleing seems to only throw results for an 'or' based search rather than 'and'. </p... | [
{
"answer_id": 336920,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 2,
"selected": false,
"text": "<pre><code>egrep '(foo.*bar|bar.*foo)'\n# or\ngrep -E '(foo.*bar|bar.*foo)'\n</code></pre>\n"
},
{
"answer_id"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42789/"
] | I'm looking for a method to grep for multiple atoms e.g. "foo" and "bar".
I'm aware i can use
`grep 'foo' file | grep 'bar'`
to get both of them but i was wondering if there was a more efficient way. Any googleing seems to only throw results for an 'or' based search rather than 'and'. | I doubt you'll get a more efficient way than the one you've selected. Given that the grep executable will already be mapped into memory when the second copy runs, and that you have no backtracking in your regex (unlike an `egrep 'foo.*bar|bar.*foo'` obvious solution), I think what you have is a fast as you're going to ... |
336,919 | <p>The code I have pasted below is meant to display images on the middle 2 links without text and go back to text on the reset and fourth link. I have set display:none for the span tag only, but it does nothing. Is there anyway to do what I am after simply, without using a framework?</p>
<p>edit: example</p>
<pre><co... | [
{
"answer_id": 336939,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>rel</code> attribute is supposed to describe the relationship of the link to the current document. It shou... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | The code I have pasted below is meant to display images on the middle 2 links without text and go back to text on the reset and fourth link. I have set display:none for the span tag only, but it does nothing. Is there anyway to do what I am after simply, without using a framework?
edit: example
```
<html>
<head>
... | The `rel` attribute is supposed to describe the relationship of the link to the current document. It should have one of the values described [here](http://www.w3.org/TR/html401/types.html#type-links). A DIV is a block-level grouping element, whereas a SPAN is an inline grouping element. SPANs allow you to group text an... |
336,922 | <p>Is this still the recommended library in use? ThickBox 3.1</p>
| [
{
"answer_id": 336939,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>The <code>rel</code> attribute is supposed to describe the relationship of the link to the current document. It shou... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41291/"
] | Is this still the recommended library in use? ThickBox 3.1 | The `rel` attribute is supposed to describe the relationship of the link to the current document. It should have one of the values described [here](http://www.w3.org/TR/html401/types.html#type-links). A DIV is a block-level grouping element, whereas a SPAN is an inline grouping element. SPANs allow you to group text an... |
336,925 | <p>I have a number of heroshot images, that have a modal popup when clicked.
I'm trying to get my cursor to turn into magnifying glass whenever it is moved over the image. The following CSS does not appear to work even though my <code>magnify.cur</code> is present in the right location.</p>
<pre><code>a.heroshot img... | [
{
"answer_id": 336931,
"author": "activout.se",
"author_id": 20444,
"author_profile": "https://Stackoverflow.com/users/20444",
"pm_score": 2,
"selected": false,
"text": "<p>What if you enclose the url string with apostrohes?</p>\n\n<pre><code>a.heroshot img {\ncursor:url('/img/magnify.cu... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | I have a number of heroshot images, that have a modal popup when clicked.
I'm trying to get my cursor to turn into magnifying glass whenever it is moved over the image. The following CSS does not appear to work even though my `magnify.cur` is present in the right location.
```
a.heroshot img {
cursor:url(/img/magni... | Your problem may be that cursor URLs don't work in Firefox for the Mac.
You can get the same effect on Firefox by using the `-moz-zoom-in` keyword.
```
cursor:url(/img/magnify.cur), -moz-zoom-in, auto;
```
This will show magnify.cur, the Mozilla-specific zoom cursor or a system default cursor. The first cursor on t... |
336,942 | <p>I hava an ajax application that will not display an image, or make a popup window from html stored in a file.</p>
<p>This is the code I am usiong for the popup:</p>
<pre><code>echo '<script>
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write(' . json_encode($row2["ARTICLE_DE... | [
{
"answer_id": 337020,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>You really need to get Firefox/Firebug to help debug this. It's possible that your script error is causing the page... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I hava an ajax application that will not display an image, or make a popup window from html stored in a file.
This is the code I am usiong for the popup:
```
echo '<script>
function makewindows(){
child1 = window.open ("about:blank");
child1.document.write(' . json_encode($row2["ARTICLE_DESC"]) . ');
child1.document... | Your HTML looks invalid - you have:
```
<style ty
<p><strong>Location</strong></p> float: right;
<p><strong>Conditions</strong></p> margin: 0px;
```
Firstly the `<style>` tag is not closed (1. the opening tag is not even complete and 2. you don't have a closing tag) - when I look at the HTML using Firefox/Fireb... |
336,946 | <p>Does the MySQL command :</p>
<pre><code>FLUSH TABLES;
</code></pre>
<p>flush every table in the current database, or every table on the server ?</p>
<p>I'm using MySQL 5.0 - the <a href="http://dev.mysql.com/doc/refman/5.0/en/flush.html" rel="noreferrer">documentation</a> is unclear, although it does mention tha... | [
{
"answer_id": 341414,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "<p>I tried to look this up but I couldn't find an authoritative answer either.</p>\n\n<ul>\n<li>I looked in the manual... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36214/"
] | Does the MySQL command :
```
FLUSH TABLES;
```
flush every table in the current database, or every table on the server ?
I'm using MySQL 5.0 - the [documentation](http://dev.mysql.com/doc/refman/5.0/en/flush.html) is unclear, although it does mention that :
```
FLUSH TABLES WITH READ LOCK;
```
will do so for ALL... | It's all databases. |
336,960 | <p>Can you tell me if there anybody has implemented a <strong>custom validator for checking that one of two (or N)</strong> input fields are filled?</p>
<pre><code> "Insert phone number or email address"
</code></pre>
<p>I'm using ASP.NET (Ajax) 3.5, the ajaxToolkit:ValidatorCalloutExtender (and jQuery if it's nece... | [
{
"answer_id": 336978,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 4,
"selected": true,
"text": "<p>Oh, sure, about 10 minutes later I found this Code Project article <strong><a href=\"http://www.codeproject.com/KB/valida... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6461/"
] | Can you tell me if there anybody has implemented a **custom validator for checking that one of two (or N)** input fields are filled?
```
"Insert phone number or email address"
```
I'm using ASP.NET (Ajax) 3.5, the ajaxToolkit:ValidatorCalloutExtender (and jQuery if it's necessary). | Oh, sure, about 10 minutes later I found this Code Project article **[Multiple Fields Validator - An ASP.NET Validation Control by Adam Tibi](http://www.codeproject.com/KB/validation/MultipleFieldsValidator.aspx)** by myself:
 var isoft = new Object();
</code></pre>
<p>is such kind of code is writted by a freshman and writes</p>
<pre><code>if(!isoft) var isoft = new Object();
</code></pre>
<p>I originally consider there must be some difference. But I can't ... | [
{
"answer_id": 336982,
"author": "stesch",
"author_id": 41860,
"author_profile": "https://Stackoverflow.com/users/41860",
"pm_score": 1,
"selected": false,
"text": "<p>If <code>isoft</code> should hold a reference to an object, both do the same. A <code>!isoft</code> is true for all fals... | 2008/12/03 | [
"https://Stackoverflow.com/questions/336965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Today one of my friends said:
```
if (typeof isoft == "undefined") var isoft = new Object();
```
is such kind of code is writted by a freshman and writes
```
if(!isoft) var isoft = new Object();
```
I originally consider there must be some difference. But I can't find the difference. Is
there any? Or are the tw... | See the question [Javascript, check to see if a variable is an object](https://stackoverflow.com/questions/95875/javascript-check-to-see-if-a-variable-is-an-object) but note that **the accepted answer by Tom Ritter appears to be incomplete**, check the comment on his answer. See also the [community answer by Rob](https... |
337,019 | <p>In the below program:</p>
<pre><code>class Main
{
static string staticVariable = "Static Variable";
string instanceVariable = "Instance Variable";
public Main(){}
}
</code></pre>
<p>The <code>instanceVariable</code> will be stored inside the memory allocated for object instance. Where will the <... | [
{
"answer_id": 337032,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 5,
"selected": true,
"text": "<p>Memory for static variables are normally held in some rooted (and hidden) <code>object[]</code>. This can be seen doing a... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26036/"
] | In the below program:
```
class Main
{
static string staticVariable = "Static Variable";
string instanceVariable = "Instance Variable";
public Main(){}
}
```
The `instanceVariable` will be stored inside the memory allocated for object instance. Where will the `staticVariable` be stored, is it stor... | Memory for static variables are normally held in some rooted (and hidden) `object[]`. This can be seen doing a !gcroot on the object in WinDbg (with SOS).
Just to add, these references can never be GC'ed (unless you null the field), as I discovered recently. |
337,023 | <p>While trying to answer a question in the vicinity '<a href="https://stackoverflow.com/questions/331215/unit-test-wpf-bindings">Unit Testing WPF Bindings</a>' I had the following niggling question..<br>
<strong>What's the best way to find if you have WPF Data Binding wiring setup incorrectly (or you just broke someth... | [
{
"answer_id": 337026,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 6,
"selected": true,
"text": "<p>Best I could find... </p>\n\n<h2><a href=\"https://web.archive.org/web/20151215181325/http://www.zagstudio.com/blog/486\" re... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | While trying to answer a question in the vicinity '[Unit Testing WPF Bindings](https://stackoverflow.com/questions/331215/unit-test-wpf-bindings)' I had the following niggling question..
**What's the best way to find if you have WPF Data Binding wiring setup incorrectly (or you just broke something that was wired up... | Best I could find...
[How can I debug WPF Bindings? by Beatriz Stollnitz](https://web.archive.org/web/20151215181325/http://www.zagstudio.com/blog/486)
----------------------------------------------------------------------------------------------------------------------------------
Since everyone can't always keep o... |
337,024 | <p>I am working with an SVN repository with many projects. I need to move a few of the projects out of that repository into individual repositories, one for each project, keeping the history.</p>
<p>I've been able to use <code>svnadmin dump</code> to dump the entire repository and <code>svnadmin load</code> it into an... | [
{
"answer_id": 337110,
"author": "Avi",
"author_id": 1605,
"author_profile": "https://Stackoverflow.com/users/1605",
"pm_score": 7,
"selected": true,
"text": "<p>You can use the <a href=\"http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svndumpfilter\"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1142/"
] | I am working with an SVN repository with many projects. I need to move a few of the projects out of that repository into individual repositories, one for each project, keeping the history.
I've been able to use `svnadmin dump` to dump the entire repository and `svnadmin load` it into another repository, but I can't fi... | You can use the [svndumpfilter](http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svndumpfilter) utility to do this. The SVN book has a [good explanation](http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.filtering) of how to do this.
For instance, one... |
337,029 | <p>How do I implement this equality comparison is a sane java way? </p>
<pre><code>boolean x = (a == b) || (a.equals(b))
</code></pre>
<p>I want to make sure the content of both objects is equal but null is also ok, i.e. both can be null and are thus equal.</p>
<p>Update: just to be clear, I have to implement thi... | [
{
"answer_id": 337039,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": false,
"text": "<p>What happens if a is null but b is not? I think you really want:</p>\n\n<pre><code>boolean x = (a == null &&... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6460/"
] | How do I implement this equality comparison is a sane java way?
```
boolean x = (a == b) || (a.equals(b))
```
I want to make sure the content of both objects is equal but null is also ok, i.e. both can be null and are thus equal.
Update: just to be clear, I have to implement this comparison several times and don't... | What happens if a is null but b is not? I think you really want:
```
boolean x = (a == null && b == null) || (a != null && a.equals(b))
```
**EDIT:** You could implement a static NullEquals method for the class that takes two objects of that class and does the comparison as above to avoid rewriting and make the code... |
337,034 | <p>I JOIN 2 tables </p>
<p>for example</p>
<pre>
table_A
+---------+-----------+-----------+
| user_id | ticket_id | user_name |
+---------+-----------+-----------+
table_B
+-----------+-------------+
| ticket_id | ticket_name |
+-----------+-------------+
</pre>
<p>If I run the following query:</p>
<pre>
SELECT
... | [
{
"answer_id": 337084,
"author": "kristof",
"author_id": 3241,
"author_profile": "https://Stackoverflow.com/users/3241",
"pm_score": 4,
"selected": true,
"text": "<p>There are a similar issues with MS SQLServer where version 2000 is accepting some ambiguous queries and the 2005 would thr... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22674/"
] | I JOIN 2 tables
for example
```
table_A
+---------+-----------+-----------+
| user_id | ticket_id | user_name |
+---------+-----------+-----------+
table_B
+-----------+-------------+
| ticket_id | ticket_name |
+-----------+-------------+
```
If I run the following query:
```
SELECT
table_A.user_id
, table_... | There are a similar issues with MS SQLServer where version 2000 is accepting some ambiguous queries and the 2005 would throw an error. Basically the newer versions seem to be more strict.
As a general rule you should use the same DB version both on Test server and on Production server to avoid this type of behaviour w... |
337,038 | <p>I have an interface called Dictionary which has a method <code>insert()</code>. This interface is implemented by class <code>BSTree</code>, but I also have a class <code>AVLTree</code> which is a child class of <code>BSTree</code>. <code>AVLTree</code> redefines the <code>insert()</code> so it suits it's needs. Now ... | [
{
"answer_id": 337053,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>When you say AVLTree \"redefines\" the insert, what exactly do you mean? It has to override the method, which means h... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42803/"
] | I have an interface called Dictionary which has a method `insert()`. This interface is implemented by class `BSTree`, but I also have a class `AVLTree` which is a child class of `BSTree`. `AVLTree` redefines the `insert()` so it suits it's needs. Now if I type the following code:
```
Dictionary data=new AVLTree();
dat... | In java, (I'm talking relatively to C++), polymorphism should "always" work. It's hard to see what's wrong without looking at the code.. maybe you could post interesting part? Such as the method's signature, class declaration, etc.. My guess is that you haven't used the same signature for both methods. |
337,066 | <p>I am developing a wrapper for a third party function library that is interfacing with some special hardware. So basically, I want to encapsulate the dll functions (<code>bool Connect()</code>, <code>void Disconnect()</code> etc) in a MyHardwareObject with connect- and disconnect methods.</p>
<p>The Connect function... | [
{
"answer_id": 337080,
"author": "Joris Timmermans",
"author_id": 33987,
"author_profile": "https://Stackoverflow.com/users/33987",
"pm_score": 3,
"selected": false,
"text": "<p>In my opinion the first case is certainly better than the second. You <em>want</em> your hardware library to ... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22114/"
] | I am developing a wrapper for a third party function library that is interfacing with some special hardware. So basically, I want to encapsulate the dll functions (`bool Connect()`, `void Disconnect()` etc) in a MyHardwareObject with connect- and disconnect methods.
The Connect function from the dll can throw some spe... | It's really difficult to choose wisely between exceptions and return codes. It depends on a lot of things, and how errors are handled in the rest of your codebase would be the most important one - stay consistent.
Lately, I'm leaning more towards the "don't throw an exception if it's not worth it". Our exceptions do a... |
337,087 | <p>Say I have some code like</p>
<pre><code>namespace Portal
{
public class Author
{
public Author() { }
private void SomeMethod(){
string myMethodName = "";
// myMethodName = "Portal.Author.SomeMethod()";
}
}
}
</code></pre>
<p>Can I find out the name of the me... | [
{
"answer_id": 337091,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 5,
"selected": true,
"text": "<pre><code>MethodInfo.GetCurrentMethod().Name\n</code></pre>\n"
},
{
"answer_id": 337096,
"author": "StingyJack"... | 2008/12/03 | [
"https://Stackoverflow.com/questions/337087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] | Say I have some code like
```
namespace Portal
{
public class Author
{
public Author() { }
private void SomeMethod(){
string myMethodName = "";
// myMethodName = "Portal.Author.SomeMethod()";
}
}
}
```
Can I find out the name of the method I am using? In my exa... | ```
MethodInfo.GetCurrentMethod().Name
``` |