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 |
|---|---|---|---|---|---|---|
41,699 | <p>So creating a Windows service using Visual Studio is fairly trivial. My question goes a bit deeper as to what actually makes an executable installable as a service & how to write a service as a straight C application. I couldn't find a lot of references on this, but I'm presuming there has to be some interface... | [
{
"answer_id": 41706,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 1,
"selected": false,
"text": "<p>Hope this helps:</p>\n<p><a href=\"http://support.microsoft.com/kb/251192\" rel=\"nofollow noreferrer\">http://support.mi... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/634/"
] | So creating a Windows service using Visual Studio is fairly trivial. My question goes a bit deeper as to what actually makes an executable installable as a service & how to write a service as a straight C application. I couldn't find a lot of references on this, but I'm presuming there has to be some interface I can im... | Setting up your executable as a service is part of it, but realistically it's usually handled by whatever installation software you're using. You can use the command line SC tool while testing (or if you don't need an installer).
The important thing is that your program has to call StartServiceCtrlDispatcher() upon st... |
41,701 | <p>I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username)</p>
<p>For ease of passing it around between functions, I've been passing the entire tuple as a variable called 'job'. Eventually, however, I want to get at the bits, so I've been... | [
{
"answer_id": 41707,
"author": "Chris Upchurch",
"author_id": 2600,
"author_profile": "https://Stackoverflow.com/users/2600",
"pm_score": 5,
"selected": true,
"text": "<p>I'd say that a dictionary is definitely the best way to do it. It's easily extensible, allows you to give each valu... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4397/"
] | I have a method in my Python code that returns a tuple - a row from a SQL query. Let's say it has three fields: (jobId, label, username)
For ease of passing it around between functions, I've been passing the entire tuple as a variable called 'job'. Eventually, however, I want to get at the bits, so I've been using cod... | I'd say that a dictionary is definitely the best way to do it. It's easily extensible, allows you to give each value a sensible name, and Python has a lot of built-in language features for using and manipulating dictionaries. If you need to add more fields later, all you need to change is the code that converts the tup... |
41,717 | <p>Like many others on this site I am considering a move to ASP.NET MVC for future projects. Currently my sites are running the traditional ASP.NET 2.0 Web Forms, and it works OK for us, so my other option is just to stick with what I know and make the move to ASP.NET 3.5 with the integrated AJAX stuff.</p>
<p>I'm wo... | [
{
"answer_id": 41722,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 4,
"selected": true,
"text": "<p>To implement a user control you do the following call:</p>\n\n<pre><code><% Html.RenderPartial(\"~/Views/Shared/MyContr... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | Like many others on this site I am considering a move to ASP.NET MVC for future projects. Currently my sites are running the traditional ASP.NET 2.0 Web Forms, and it works OK for us, so my other option is just to stick with what I know and make the move to ASP.NET 3.5 with the integrated AJAX stuff.
I'm wondering abo... | To implement a user control you do the following call:
```
<% Html.RenderPartial("~/Views/Shared/MyControl.ascx", {data model object}) %>
```
You may also see the older syntax which as of PR5 is not valid anymore
```
<%= Html.RenderUserControl("~/Views/Shared/MyControl.ascx", {data model object}) %>
```
You will ... |
41,724 | <p>I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen <a href="http://ayende.com/blog/tags/domain-specific-languages" rel="noreferrer">Ayende's blog posts</a> and things, but I've never really gotten exactly why I would take m... | [
{
"answer_id": 41735,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 4,
"selected": false,
"text": "<p><strong>DSL</strong> stands for <em>Domain Specific Language</em> i.e. language designed specifically for solving problems in ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen [Ayende's blog posts](http://ayende.com/blog/tags/domain-specific-languages) and things, but I've never really gotten exactly why I would take my business logic away from the ... | DSL's are good in situations where you need to give some aspect of the system's control over to someone else. I've used them in Rules Engines, where you create a simple language that is easier for less-technical folks to use to express themselves- particularly in workflows.
In other words, instead of making them learn... |
41,733 | <p>Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?</p>
<pre><code>TExample = record
SortOrder : integer;
SomethingElse : string;
end;
var SomeVar : array of TExample;
</code></pre>
| [
{
"answer_id": 41809,
"author": "Ralph M. Rickenbach",
"author_id": 4549416,
"author_profile": "https://Stackoverflow.com/users/4549416",
"pm_score": 0,
"selected": false,
"text": "<p>Use one of the sort alorithms propose by <a href=\"http://en.wikipedia.org/wiki/Sorting_algorithm\" rel=... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1008/"
] | Say I have an array of records which I want to sort based on one of the fields in the record. What's the best way to achieve this?
```
TExample = record
SortOrder : integer;
SomethingElse : string;
end;
var SomeVar : array of TExample;
``` | You can add pointers to the elements of the array to a `TList`, then call `TList.Sort` with a comparison function, and finally create a new array and copy the values out of the TList in the desired order.
However, if you're using the next version, D2009, there is a new collections library which can sort arrays. It tak... |
41,763 | <p>What is the best way to calculate Age using Flex?</p>
| [
{
"answer_id": 41845,
"author": "Richard Braxton",
"author_id": 4393,
"author_profile": "https://Stackoverflow.com/users/4393",
"pm_score": 4,
"selected": false,
"text": "<p>I found an answer at <a href=\"http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?conte... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4393/"
] | What is the best way to calculate Age using Flex? | I found an answer at [the bottom of this page in comments section (which is now offline)](http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=08_Dates_and_times_164_2.html).
>
> **jpwrunyan said on Apr 30, 2007 at 10:10 PM :**
>
>
>
> >
> > By the way, h... |
41,792 | <p>I am re-factoring some code and am wondering about the use of a <code>lock</code> in the instance constructor.</p>
<pre><code>public class MyClass {
private static Int32 counter = 0;
private Int32 myCount;
public MyClass() {
lock(this) {
counter++;
myCount = counter;
... | [
{
"answer_id": 41801,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 2,
"selected": false,
"text": "<p>I'm guessing this is for a singleton pattern or something like it. What you want to do is not lock your object, but lock ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | I am re-factoring some code and am wondering about the use of a `lock` in the instance constructor.
```
public class MyClass {
private static Int32 counter = 0;
private Int32 myCount;
public MyClass() {
lock(this) {
counter++;
myCount = counter;
}
}
}
```
Pl... | @ajmastrean
I am not saying you should use the singleton pattern itself, but adopt its method of encapsulating the instantiation process.
i.e.
* Make the constructor private.
* Create a static instance method that returns the type.
* In the static instance method, use the lock keyword before instantiating.
* Instant... |
41,824 | <p>I'm using Microsoft AjaxControlToolkit for modal popup window.</p>
<p>And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup?</p>
| [
{
"answer_id": 41910,
"author": "Ricky Supit",
"author_id": 4191,
"author_profile": "https://Stackoverflow.com/users/4191",
"pm_score": 3,
"selected": false,
"text": "<p>You can call <code>Show()</code> method during postback to prevent the modal popup window from closing</p>\n\n<pre><co... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4215/"
] | I'm using Microsoft AjaxControlToolkit for modal popup window.
And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup? | Put you controls inside the update panel. Please see my sample code, pnlControls is control that holds controls that will be displayed on popup:
```
<asp:Panel ID="pnlControls" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="TestButton" r... |
41,836 | <p>I have tried both of :</p>
<pre><code>ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes');
</code></pre>
<p>and also :</p>
<pre><code>php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes"
</code></pre>
<p>in the .htaccess file.</p>
<p>Both methods actually... | [
{
"answer_id": 41877,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Looks like you duplicated the current directory in your include path. Try removing one of the '.:' from your string.</p>\n"
... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/319/"
] | I have tried both of :
```
ini_set('include_path', '.:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes');
```
and also :
```
php_value include_path ".:/usr/share/php5:/usr/share/php5/PEAR:lib:app/classes"
```
in the .htaccess file.
Both methods actually **do work** but only intermittently. That is, they will... | It turned out the issue was related to a PHP bug in 5.2.5
Setting an "admin\_flag" for include\_path caused the include path to be empty in some requests, and Plesk sets an admin\_flag in the default config for something or other. An update of PHP solved the issue.
<http://bugs.php.net/bug.php?id=43677> |
41,839 | <p>I'm writing a tool to run a series of integration tests on my product. It will install it and then run a bunch of commands against it to make sure its doing what it is supposed to. I'm exploring different options for how to markup the commands for each test case and wondering if folks had insight to share on this. I... | [
{
"answer_id": 41848,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 1,
"selected": false,
"text": "<p>You might want to check out <a href=\"http://www.cpan.org/\" rel=\"nofollow noreferrer\">CPAN</a>. It does for Perl scrip... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/511/"
] | I'm writing a tool to run a series of integration tests on my product. It will install it and then run a bunch of commands against it to make sure its doing what it is supposed to. I'm exploring different options for how to markup the commands for each test case and wondering if folks had insight to share on this. I'm ... | Go and have a look at the XUnit suite of test tools. This framework was originally designed for Smalltalk by Kent Beck and, I think, Erich Gamma, and it has now been ported to a whole stack of other languages, e.g. [CUnit](http://cunit.sourceforge.net/) |
41,869 | <p>If I run the following query in SQL Server 2000 Query Analyzer:</p>
<pre><code>BULK INSERT OurTable
FROM 'c:\OurTable.txt'
WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK)
</code></pre>
<p>On a text file that conforms to OurTable's schema for 40 lines, but ... | [
{
"answer_id": 41942,
"author": "kaiz.net",
"author_id": 3714,
"author_profile": "https://Stackoverflow.com/users/3714",
"pm_score": 0,
"selected": false,
"text": "<p>Try to put it inside user-defined transaction and see what happens. Actually it should roll-back as you described it.</p>... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41869",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2831/"
] | If I run the following query in SQL Server 2000 Query Analyzer:
```
BULK INSERT OurTable
FROM 'c:\OurTable.txt'
WITH (CODEPAGE = 'RAW', DATAFILETYPE = 'char', FIELDTERMINATOR = '\t', ROWS_PER_BATCH = 10000, TABLOCK)
```
On a text file that conforms to OurTable's schema for 40 lines, but then changes format for th... | `BULK INSERT` acts as a series of individual `INSERT` statements and thus, if the job fails, it doesn't roll back all of the committed inserts.
It can, however, be placed within a transaction so you could do something like this:
```
BEGIN TRANSACTION
BEGIN TRY
BULK INSERT OurTable
FROM 'c:\OurTable.txt'
WITH (CODE... |
41,894 | <p>Is there a way to find the name of the program that is running in Java? The class of the main method would be good enough.</p>
| [
{
"answer_id": 41904,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 7,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code> StackTraceElement[] stack = Thread.currentThread ().getStackTrace ();\n StackTraceElem... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/823/"
] | Is there a way to find the name of the program that is running in Java? The class of the main method would be good enough. | Try this:
```
StackTraceElement[] stack = Thread.currentThread ().getStackTrace ();
StackTraceElement main = stack[stack.length - 1];
String mainClass = main.getClassName ();
```
Of course, this only works if you're running from the main thread. Unfortunately I don't think there's a system property you c... |
41,925 | <p>What is a good data structure for storing phone numbers in database fields? I'm looking for something that is flexible enough to handle international numbers, and also something that allows the various parts of the number to be queried efficiently.</p>
<p><strong>Edit:</strong> Just to clarify the use case here: I... | [
{
"answer_id": 41929,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps storing the phone number sections in different columns, allowing for blank or null entries?</p>\n"
},
{
... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | What is a good data structure for storing phone numbers in database fields? I'm looking for something that is flexible enough to handle international numbers, and also something that allows the various parts of the number to be queried efficiently.
**Edit:** Just to clarify the use case here: I currently store numbers... | First, beyond the country code, there is no real standard. About the best you can do is recognize, by the country code, which nation a particular phone number belongs to and deal with the rest of the number according to that nation's format.
Generally, however, phone equipment and such is standardized so you can almos... |
41,928 | <p>I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of <code>lightwindow.js</code>, claiming that the <code>object does not support this property or method</code>. Despite finding various postings on various forums, no Google result I cou... | [
{
"answer_id": 47224,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of the try..catch maybe you could try using </p>\n\n<pre><code>if( this && this._getGalleryInfo )\n{\n ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of `lightwindow.js`, claiming that the `object does not support this property or method`. Despite finding various postings on various forums, no Google result I could find had a solution, s... | I fixed this by changing line 444 to:
```
var gallery = this._getGalleryInfo(link.rel)
```
Then changing the subsequent comparison statement to:
```
if(gallery.length > 0)
{
// Rest of code here...
```
...which seems to have sorted it in IE6+ and kept it working in Firefox etc.
I didn't change line 1157 at ... |
41,948 | <p>I'm creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date. I can't quite figure out, however, how to get the difference between the two times, and then how to create a new end Date using that difference.<... | [
{
"answer_id": 41960,
"author": "Vincent Robert",
"author_id": 268,
"author_profile": "https://Stackoverflow.com/users/268",
"pm_score": 7,
"selected": true,
"text": "<p>In JavaScript, dates can be transformed to the number of milliseconds since the epoc by calling the <code>getTime()</c... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2688/"
] | I'm creating an application which lets you define events with a time frame. I want to automatically fill in the end date when the user selects or changes the start date. I can't quite figure out, however, how to get the difference between the two times, and then how to create a new end Date using that difference. | In JavaScript, dates can be transformed to the number of milliseconds since the epoc by calling the `getTime()` method **or** just using the date in a numeric expression.
So to get the difference, just subtract the two dates.
To create a new date based on the difference, just pass the number of milliseconds in the co... |
41,969 | <p>I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.</p>
<p>On OSX, I can open a window in the finder with</p>
<pre><code>os.system('open "%s"' % foldername)
</code></pre>
<p>and on Windows with</p>
<pre><code>os.startfile(foldernam... | [
{
"answer_id": 41999,
"author": "Tanj",
"author_id": 4275,
"author_profile": "https://Stackoverflow.com/users/4275",
"pm_score": 0,
"selected": false,
"text": "<p>this would probably have to be done manually, or have as a config item since there are many file managers that users may want... | 2008/09/03 | [
"https://Stackoverflow.com/questions/41969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3002/"
] | I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.
On OSX, I can open a window in the finder with
```
os.system('open "%s"' % foldername)
```
and on Windows with
```
os.startfile(foldername)
```
What about unix/linux? Is there a s... | ```
os.system('xdg-open "%s"' % foldername)
```
`xdg-open` can be used for files/urls also |
42,017 | <p>I am looking for simple straightforward solution for accessing EXIF information of jpeg images in .Net. Does anybody has experience with this?</p>
| [
{
"answer_id": 42058,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>I like <a href=\"http://www.atalasoft.com/products/dotimage/photo/default.aspx\" rel=\"nofollow noreferrer\">Atalasoft's Dot... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361/"
] | I am looking for simple straightforward solution for accessing EXIF information of jpeg images in .Net. Does anybody has experience with this? | If you're willing to use an open-source library, may I humbly suggest one of my own creation?
The *metadata-extractor* project has been alive and well since 2002 for Java, and is now available for .NET.
* Open source (Apache 2.0)
* Heavily tested and widely used
* Supports many image types (JPEG, TIFF, PNG, WebP, GIF... |
42,068 | <p>I've generated some JSON and I'm trying to pull it into an object in JavaScript. I keep getting errors. Here's what I have:</p>
<pre><code>var data = '{"count" : 1, "stack" : "sometext\n\n"}';
var dataObj = eval('('+data+')');
</code></pre>
<p>This gives me an error: </p>
<pre><code>unterminated string literal
</... | [
{
"answer_id": 42073,
"author": "BlaM",
"author_id": 999,
"author_profile": "https://Stackoverflow.com/users/999",
"pm_score": 10,
"selected": true,
"text": "<p>This is what you want:</p>\n<pre><code>var data = '{"count" : 1, "stack" : "sometext\\\\n\\\\n"}'... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3636/"
] | I've generated some JSON and I'm trying to pull it into an object in JavaScript. I keep getting errors. Here's what I have:
```
var data = '{"count" : 1, "stack" : "sometext\n\n"}';
var dataObj = eval('('+data+')');
```
This gives me an error:
```
unterminated string literal
```
With `JSON.parse(data)`, I see si... | This is what you want:
```
var data = '{"count" : 1, "stack" : "sometext\\n\\n"}';
```
You need to escape the `\` in your string (turning it into a double-`\`), otherwise it will become a newline in the JSON source, not the JSON data. |
42,070 | <p>What's going on here?</p>
<p>printf.sh:</p>
<pre><code>#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" $NAME
</code></pre>
<p>Command line session:</p>
<pre><code>$ ./printf.sh
Hello, George
Hello, W.
Hello, Bush
</code></pre>
<p>UPDATE: <code>printf "Hello, %s\n" "$NAME"</code> works. For why I'm not usi... | [
{
"answer_id": 42087,
"author": "Redbaron",
"author_id": 41,
"author_profile": "https://Stackoverflow.com/users/41",
"pm_score": 0,
"selected": false,
"text": "<p>If you want all of those words to be printed out on their own, use <strong>print</strong> instead of <strong>printf</strong> ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | What's going on here?
printf.sh:
```
#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" $NAME
```
Command line session:
```
$ ./printf.sh
Hello, George
Hello, W.
Hello, Bush
```
UPDATE: `printf "Hello, %s\n" "$NAME"` works. For why I'm not using `echo`, consider
echo.sh:
```
#! /bin/sh
FILE="C:\tmp"
echo "F... | Your NAME variable is being substituted like this:
```
printf "Hello, %s\n" George W. Bush
```
Use this:
```
#! /bin/sh
NAME="George W. Bush"
printf "Hello, %s\n" "$NAME"
``` |
42,102 | <p>I have a Singleton/Factory object that I'd like to write a JUnit test for. The Factory method decides which implementing class to instantiate based upon a classname in a properties file on the classpath. If no properties file is found, or the properties file does not contain the classname key, then the class will in... | [
{
"answer_id": 42108,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 2,
"selected": false,
"text": "<p>When I run into these sort of situations I prefer to use what is a bit of a hack. I might instead expose a protected met... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4249/"
] | I have a Singleton/Factory object that I'd like to write a JUnit test for. The Factory method decides which implementing class to instantiate based upon a classname in a properties file on the classpath. If no properties file is found, or the properties file does not contain the classname key, then the class will insta... | This question might be old but since this was the nearest answer I found when I had this problem I though I'd describe my solution.
**Using JUnit 4**
Split your tests up so that there is one test method per class (this solution only changes classloaders between classes, not between methods as the parent runner gather... |
42,115 | <p>I am running into an issue I had before; can't find my reference on how to solve it.</p>
<p>Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below:</p>
<pre><code> config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.No... | [
{
"answer_id": 42206,
"author": "Booji Boy",
"author_id": 1433,
"author_profile": "https://Stackoverflow.com/users/1433",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like a permissions issue. The (new) user in question has write permissions to the app.config file? Was the previo... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1889/"
] | I am running into an issue I had before; can't find my reference on how to solve it.
Here is the issue. We encrypt the connection strings section in the app.config for our client application using code below:
```
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
If config... | I found a more elegant solution that in my original answer to myself. I found if I just logged in as th euser who orignally installed the application and caused the config file connectionstrings to be encrypted and go to the .net framework directory in a commadn prompt and run
```
aspnet_regiis -pa "NetFrameworkConfi... |
42,125 | <p>I have a library I created,</p>
<h3>File <em>mylib.c:</em></h3>
<pre><code>#include <mylib.h>
int
testlib() {
printf("Hello, World!\n");
return (0);
}
</code></pre>
<h3>File <em>mylib.h:</em></h3>
<pre><code>#include <stdio.h>
extern int testlib();
</code></pre>
<p>In my program, I've ... | [
{
"answer_id": 42133,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>extern int testlib(void);\n</code></pre>\n"
},
{
"answer_id": 47693,
"author": "... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3807/"
] | I have a library I created,
### File *mylib.c:*
```
#include <mylib.h>
int
testlib() {
printf("Hello, World!\n");
return (0);
}
```
### File *mylib.h:*
```
#include <stdio.h>
extern int testlib();
```
In my program, I've attempted to call this library function:
### File *myprogram.c*:
```
#include <my... | In C `int foo()` and `int foo(void)` are different functions. `int foo()` accepts an arbitrary number of arguments, while `int foo(void)` accepts 0 arguments. In C++ they mean the same thing. I suggest that you use `void` consistently when you mean no arguments.
If you have a variable `a`, `extern int a;` is a way to ... |
42,153 | <p>I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead.</p>
<p>How do you embed a <code>JApplet</code> in HTML on a webpage?</p>
| [
{
"answer_id": 42162,
"author": "pkaeding",
"author_id": 4257,
"author_profile": "https://Stackoverflow.com/users/4257",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <applet> tag. For more info: <a href=\"http://java.sun.com/docs/books/tutorial/deployment/applet/html.html... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] | I searched for this subject on Google and got some website about an experts exchange...so I figured I should just ask here instead.
How do you embed a `JApplet` in HTML on a webpage? | Here is an example from [sun's website](http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html):
```
<applet code="TumbleItem.class"
codebase="examples/"
archive="tumbleClasses.jar, tumbleImages.jar"
width="600" height="95">
<param name="maxwidth" value="120">
<param na... |
42,182 | <p>I'm trying to write a blog post which includes a code segment inside a <code><pre></code> tag. The code segment includes a generic type and uses <code><></code> to define that type. This is what the segment looks like:</p>
<pre><code><pre>
PrimeCalc calc = new PrimeCalc();
Func<int, int... | [
{
"answer_id": 42189,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": -1,
"selected": false,
"text": "<p>It's probably something specific to your blog software, but you might want to give the following strings a try (remove the ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/373/"
] | I'm trying to write a blog post which includes a code segment inside a `<pre>` tag. The code segment includes a generic type and uses `<>` to define that type. This is what the segment looks like:
```
<pre>
PrimeCalc calc = new PrimeCalc();
Func<int, int> del = calc.GetNextPrime;
</pre>
```
The resulting HTM... | ```
<pre>
PrimeCalc calc = new PrimeCalc();
Func<int, int> del = calc.GetNextPrime;
</pre>
``` |
42,187 | <p>I have read about partial methods in the latest <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx" rel="noreferrer">C# language specification</a>, so I understand the principles, but I'm wondering how people are actually using them. Is there a particular design pattern that benefits from partial method... | [
{
"answer_id": 42190,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "<p><strong><a href=\"http://msdn.microsoft.com/en-us/library/bb531348.aspx\" rel=\"nofollow noreferrer\">Code generatio... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | I have read about partial methods in the latest [C# language specification](http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx), so I understand the principles, but I'm wondering how people are actually using them. Is there a particular design pattern that benefits from partial methods? | Partial methods have been introduced for similar reasons to why partial classes were in .Net 2.
A partial class is one that can be split across multiple files - the compiler builds them all into one file as it runs.
The advantage for this is that Visual Studio can provide a graphical designer for part of the class wh... |
42,215 | <p>We get the following error;</p>
<pre><code>The request was aborted: Could not create SSL/TLS secure channel
</code></pre>
<p>while using a <code>WebRequest</code> object to make an <code>HTTPS</code> request. The funny thing is that this only happens after a while, and is temporarily fixed when the application is ... | [
{
"answer_id": 42228,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like it may be a Conenction: Keep-alive thing: <a href=\"http://blogs.x2line.com/al/archive/2005/01/04/759.as... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1659/"
] | We get the following error;
```
The request was aborted: Could not create SSL/TLS secure channel
```
while using a `WebRequest` object to make an `HTTPS` request. The funny thing is that this only happens after a while, and is temporarily fixed when the application is restarted, which suggests that something is bein... | I seem to recall having this problem last year. I suspect that you aren't closing your WebRequest objects properly, which is why after a certain amount of use it won't allow you to create any new connections. |
42,246 | <p>I have somewhat interesting development situation. The client and deployment server are inside a firewall without access to the Subversion server. But the developers are outside the firewall and are able to use the Subversion server. Right now the solution I have worked out is to update my local copy of the code and... | [
{
"answer_id": 42295,
"author": "Brian Lyttle",
"author_id": 636,
"author_profile": "https://Stackoverflow.com/users/636",
"pm_score": -1,
"selected": false,
"text": "<p>You don't provide information on what is allowed through the firewall. I'm not familiar with UnleashIT.</p>\n\n<p>I gu... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3442/"
] | I have somewhat interesting development situation. The client and deployment server are inside a firewall without access to the Subversion server. But the developers are outside the firewall and are able to use the Subversion server. Right now the solution I have worked out is to update my local copy of the code and th... | I've found [rsync](http://samba.anu.edu.au/rsync/) extremely useful for synchronizing directory trees across multiple systems. If you have shell access to your server from a development workstation, you can regularly check out code locally and run rsync, which will transfer only the files that have changed to the serve... |
42,247 | <p>The following code illustrates an object literal being assigned, but with no semicolon afterwards:</p>
<pre><code>var literal = {
say: function(msg) { alert(msg); }
}
literal.say("hello world!");
</code></pre>
<p>This appears to be legal, and doesn't issue a warning (at least in Firefox 3). Is this comple... | [
{
"answer_id": 42252,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 6,
"selected": true,
"text": "<p>Not technically, JavaScript has semicolons as optional in many situations. </p>\n\n<p>But, as a general rule, use the... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/122/"
] | The following code illustrates an object literal being assigned, but with no semicolon afterwards:
```
var literal = {
say: function(msg) { alert(msg); }
}
literal.say("hello world!");
```
This appears to be legal, and doesn't issue a warning (at least in Firefox 3). Is this completely legal, or is there a stric... | Not technically, JavaScript has semicolons as optional in many situations.
But, as a general rule, use them at the end of any statement. Why? Because if you ever want to compress the script, it will save you from countless hours of frustration.
Automatic semicolon insertion is performed by the interpreter, so you *c... |
42,254 | <p>I would like to flash a success message on my page.</p>
<p>I am using the jQuery <code>fadeOut</code> method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange.</p>
<p>What I would like to happen is have the element be displayed for five seconds, the... | [
{
"answer_id": 42255,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 4,
"selected": false,
"text": "<p>use <code>setTimeout(function(){$elem.hide();}, 5000);</code></p>\n\n<p>Where <code>$elem</code> is the element you ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3645/"
] | I would like to flash a success message on my page.
I am using the jQuery `fadeOut` method to fade and then remove the element. I can increase the duration to make it last longer, however this looks strange.
What I would like to happen is have the element be displayed for five seconds, then fade quickly, and finally ... | The new `delay()` function in jQuery 1.4 should do the trick.
```
$('#foo').fadeIn(200).delay(5000).fadeOut(200).remove();
``` |
42,282 | <p>Which way do you prefer to create your forms in MVC?</p>
<pre><code><% Html.Form() { %>
<% } %>
</code></pre>
<p>Or</p>
<pre><code><form action="<%= Url.Action("ManageImage", "UserAccount") %>" method="post">
</form>
</code></pre>
<p>I understand that Html.Form() as of PR5 now just ... | [
{
"answer_id": 42289,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>On the whole, I think I'm kinda old-school as I prefer to roll my own HTML elements.</p>\n\n<p>I also prefer a view en... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17/"
] | Which way do you prefer to create your forms in MVC?
```
<% Html.Form() { %>
<% } %>
```
Or
```
<form action="<%= Url.Action("ManageImage", "UserAccount") %>" method="post">
</form>
```
I understand that Html.Form() as of PR5 now just uses the URL provided by the request. However something about that doesn't sit ... | The second way, definitely. The first way is programmer-centric, which is not what the V part of MVC is about. The second way is more designer centric, only binding to the model where it is necessary, leaving the HTML as natural as possible. |
42,286 | <p>It seems like there should be something shorter than this:</p>
<pre><code>private string LoadFromFile(string path)
{
try
{
string fileContents;
using(StreamReader rdr = File.OpenText(path))
{
fileContents = rdr.ReadToEnd();
}
return fileContents;
}
catch
... | [
{
"answer_id": 42290,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>File.ReadAllText() maybe?</p>\n\n<p>ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_mscorlib/html/4803f846-3d8a-de8a-18e... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3475/"
] | It seems like there should be something shorter than this:
```
private string LoadFromFile(string path)
{
try
{
string fileContents;
using(StreamReader rdr = File.OpenText(path))
{
fileContents = rdr.ReadToEnd();
}
return fileContents;
}
catch
{
thr... | First of all, the title asks for "how to write the contents of strnig to a text file"
but your code example is for "how to read the contents of a text file to a string.
Answer to both questions:
```
using System.IO;
...
string filename = "C:/example.txt";
string content = File.ReadAllText(filename);
File.WriteAllText... |
42,294 | <p>I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in all browsers. It works if the content pushes the footer down, but that's not always the case. </p>
| [
{
"answer_id": 42301,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 9,
"selected": true,
"text": "<p>To get a sticky footer:</p>\n\n<ol>\n<li><p>Have a <code><div></code> with <code>class=\"wrapper\"</code> for your con... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in all browsers. It works if the content pushes the footer down, but that's not always the case. | To get a sticky footer:
1. Have a `<div>` with `class="wrapper"` for your content.
2. Right **before** the closing `</div>` of the `wrapper` place the
`<div class="push"></div>`.
3. Right **after** the closing `</div>` of the `wrapper` place the
`<div class="footer"></div>`.
```css
* {
margin: 0;
}
html, body {
... |
42,323 | <p>I have the next function:</p>
<pre><code>function setImagesWidth(id,width) {
var images = document.getElementById(id).getElementsByTagName("img");
for(var i = 0; i < images.length;i++) {
// If the real width is bigger than width parameter
images[i].style.width=width;
//} ... | [
{
"answer_id": 42331,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "<p>Here is, hopefully, enough sample code to give you what you want:</p>\n\n<pre><code>var myImage = document.getElemen... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I have the next function:
```
function setImagesWidth(id,width) {
var images = document.getElementById(id).getElementsByTagName("img");
for(var i = 0; i < images.length;i++) {
// If the real width is bigger than width parameter
images[i].style.width=width;
//}
} ... | @Sergio del Amo: Indeed, if you check out my link you'll see that you want `clientWidth` instead.
@Sergio del Amo: You cannot, unfortunately, accept your own answer. But you do have an extraneous period in the "px" suffix, so let's go with this, including the `clientWidth` change:
```
// width in pixels
function setI... |
42,342 | <p>Sometimes IE6 will render the text of a <code><ul></code> list the same color as the background color. If you select it, they show back up, or if you scroll the page up and back down.</p>
<p>It is obviously a rendering bug, but I was wondering if anyone knows of a workaround to make it reliable?</p>
| [
{
"answer_id": 42346,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried explicitly setting a line-height? For some reason this seems to be the solution to a great many IE6 renderi... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Sometimes IE6 will render the text of a `<ul>` list the same color as the background color. If you select it, they show back up, or if you scroll the page up and back down.
It is obviously a rendering bug, but I was wondering if anyone knows of a workaround to make it reliable? | try giving it hasLayout with
```css
zoom: 1
``` |
42,345 | <p>How can I determine if a string is an IP address? Either <em>IPv4</em> or <em>IPv6</em>?</p>
<p>What is the least and most number of characters?</p>
<p>I assume this would be a <strong>regex</strong> answer.</p>
| [
{
"answer_id": 42359,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "<p>For IPv4 you can use this regular expression.</p>\n\n<pre><code>\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] | How can I determine if a string is an IP address? Either *IPv4* or *IPv6*?
What is the least and most number of characters?
I assume this would be a **regex** answer. | In .NET there's an IPAddress type which has a handy method [TryParse](http://msdn.microsoft.com/en-us/library/system.net.ipaddress.tryparse.aspx).
Example:
```
if(System.Net.IPAddress.TryParse(PossibleIPAddress, validatedIPAddress)){
//validatedIPAddress is good
}
// or more simply:
bool IsValidIPAddress(string... |
42,386 | <p>Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression?</p>
<pre><code>//pseudo-codeish
string s = Coalesce(string1, string2, string3);
</code></pre>
<p>or, more generally,</p>
<pre><code>object obj = Coale... | [
{
"answer_id": 42387,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 2,
"selected": false,
"text": "<p>the <strong>??</strong> operator.</p>\n\n<pre><code>string a = nullstring ?? \"empty!\";\n</code></pre>\n"
},
{
"a... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4438/"
] | Is there a one statement or one line way to accomplish something like this, where the string s is declared AND assigned the first non-null value in the expression?
```
//pseudo-codeish
string s = Coalesce(string1, string2, string3);
```
or, more generally,
```
object obj = Coalesce(obj1, obj2, obj3, ...objx);
``` | As Darren Kopp said.
Your statement
```
object obj = Coalesce(obj1, obj2, obj3, ...objx);
```
Can be written like this:
```
object obj = obj1 ?? obj2 ?? obj3 ?? ... objx;
```
to put it in other words:
```
var a = b ?? c;
```
is equivalent to
```
var a = b != null ? b : c;
``` |
42,395 | <p>How do you write the syntax for a While loop?</p>
<h2>C<code>#</code></h2>
<pre><code>int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
</code></pre>
<h2>VB.Net</h2>
<pre><code>Dim i As Integer = 0
While i <> 10
Console.WriteLine(i)
i += 1
End While
</code></pre>
<h2>PHP</h2>
... | [
{
"answer_id": 42409,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 4,
"selected": true,
"text": "<p>In PHP a while loop will look like this:</p>\n\n<pre><code><?php\nwhile(CONDITION)\n{\n//Do something here.\n}\n?>\n<... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] | How do you write the syntax for a While loop?
C`#`
----
```
int i = 0;
while (i != 10)
{
Console.WriteLine(i);
i++;
}
```
VB.Net
------
```
Dim i As Integer = 0
While i <> 10
Console.WriteLine(i)
i += 1
End While
```
PHP
---
```
<?php
while(CONDITION)
{
//Do something here.
}
?>
<?php
//MyS... | In PHP a while loop will look like this:
```
<?php
while(CONDITION)
{
//Do something here.
}
?>
```
A real world example of this might look something like this
```
<?php
//MySQL query stuff here
$result = mysql_query($sql, $link) or die("Opps");
while($row = mysql_fetch_assoc($result))
{
$_SESSION['fName'] = $row['... |
42,396 | <p>Here's the code from the ascx that has the repeater:</p>
<pre><code><asp:Repeater ID="ListOfEmails" runat="server" >
<HeaderTemplate><h3>A sub-header:</h3></HeaderTemplate>
<ItemTemplate>
[Some other stuff is here]
<asp:Button ID="removeEmail" runat="se... | [
{
"answer_id": 42404,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 0,
"selected": false,
"text": "<p>Here's an experiment for you to try:</p>\n\n<p>Set a breakpoint on ListOfEmails_ItemDataBound and see if it's being ca... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] | Here's the code from the ascx that has the repeater:
```
<asp:Repeater ID="ListOfEmails" runat="server" >
<HeaderTemplate><h3>A sub-header:</h3></HeaderTemplate>
<ItemTemplate>
[Some other stuff is here]
<asp:Button ID="removeEmail" runat="server" Text="X" ToolTip="remove" />
</ItemTemplate... | Controls nested inside of Repeaters do not intercept events. Instead you need to bind to the `Repeater.ItemCommand` Event.
[`ItemCommand`](https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeater.itemcommand) contains [`RepeaterCommandEventArgs`](https://learn.microsoft.com/en-us/dotnet/api/syst... |
42,416 | <p>I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may... | [
{
"answer_id": 42431,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 0,
"selected": false,
"text": "<p>here's a link to it on the ubuntu site:</p>\n\n<p><a href=\"http://packages.ubuntu.com/intrepid/libgluezilla\" rel=\"no... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] | I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may hav... | ```
apt-cache search libgluezilla
libmono-mozilla0.1-cil - Mono Mozilla library
```
From the package description:
```
Description: Mono Mozilla library
Mono is a platform for running and developing applications based on the
ECMA/ISO Standards. Mono is an open source effort led by Novell.
Mono provides a complete... |
42,422 | <p>Essentially I want to know if in VB.NET 2005 if using a sqlcommand and then reusing it by using the NEW is wrong. Will it cause a memory leak.</p>
<p>EG:</p>
<pre><code>try
dim mySQL as new sqlcommand(sSQL, cnInput)
// do a sql execute and read the data
mySQL = new sqlcommand(sSQLdifferent, cnInput)
// do sq... | [
{
"answer_id": 42434,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 2,
"selected": false,
"text": "<p>Garbage collection will gather up the first new when it is run.</p>\n\n<p>Only the second one you purposely dispose ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2357/"
] | Essentially I want to know if in VB.NET 2005 if using a sqlcommand and then reusing it by using the NEW is wrong. Will it cause a memory leak.
EG:
```
try
dim mySQL as new sqlcommand(sSQL, cnInput)
// do a sql execute and read the data
mySQL = new sqlcommand(sSQLdifferent, cnInput)
// do sql execute and read the... | Just to extend what Longhorn213 said, here's the code for it:
```
Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)
' do stuff'
End Using
Using mysql as SqlCommand = new SqlCommand(otherSql, cnInput)
' do other stuff'
End Using
```
(edit) Just as an FYI, using automatically wraps the block of code aroun... |
42,428 | <p>X Windows has special processes called Window Managers that manage the layout of windows and decorations like their title bar, control buttons etc. Such processes use an X Windows API to detect events related to windows sizes and positions.</p>
<p>Are there any consistent ways for writing such processes for Microso... | [
{
"answer_id": 42434,
"author": "David Basarab",
"author_id": 2469,
"author_profile": "https://Stackoverflow.com/users/2469",
"pm_score": 2,
"selected": false,
"text": "<p>Garbage collection will gather up the first new when it is run.</p>\n\n<p>Only the second one you purposely dispose ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1476/"
] | X Windows has special processes called Window Managers that manage the layout of windows and decorations like their title bar, control buttons etc. Such processes use an X Windows API to detect events related to windows sizes and positions.
Are there any consistent ways for writing such processes for Microsoft Windows... | Just to extend what Longhorn213 said, here's the code for it:
```
Using mysql as SqlCommand = new SqlCommand(sSql, cnInput)
' do stuff'
End Using
Using mysql as SqlCommand = new SqlCommand(otherSql, cnInput)
' do other stuff'
End Using
```
(edit) Just as an FYI, using automatically wraps the block of code aroun... |
42,446 | <pre><code>class Foo
{
static bool Bar(Stream^ stream);
};
class FooWrapper
{
bool Bar(LPCWSTR szUnicodeString)
{
return Foo::Bar(??);
}
};
</code></pre>
<p><code>MemoryStream</code> will take a <code>byte[]</code> but I'd <em>like</em> to do this without copying the data if possible.</p>
| [
{
"answer_id": 42605,
"author": "Adam Tegen",
"author_id": 4066,
"author_profile": "https://Stackoverflow.com/users/4066",
"pm_score": 0,
"selected": false,
"text": "<p>If I had to copy the memory, I think the following would work:</p>\n\n<pre><code>\nstatic Stream^ UnicodeStringToStream... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | ```
class Foo
{
static bool Bar(Stream^ stream);
};
class FooWrapper
{
bool Bar(LPCWSTR szUnicodeString)
{
return Foo::Bar(??);
}
};
```
`MemoryStream` will take a `byte[]` but I'd *like* to do this without copying the data if possible. | You can avoid the copy if you use an [`UnmanagedMemoryStream()`](http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx) instead (class exists in .NET FCL 2.0 and later). Like `MemoryStream`, it is a subclass of `IO.Stream`, and has all the usual stream operations.
Microsoft's description of the ... |
42,482 | <p>Is there a reasonable way to extract plain text from a Word file that doesn't depend on COM automation? (This is a a feature for a web app deployed on a non-Windows platform - that's non-negotiable in this case.)</p>
<p>Antiword seems like it might be a reasonable option, but it seems like it might be abandoned.</... | [
{
"answer_id": 42485,
"author": "Unsliced",
"author_id": 2902,
"author_profile": "https://Stackoverflow.com/users/2902",
"pm_score": 1,
"selected": false,
"text": "<p>Open Office has an <a href=\"http://api.openoffice.org/\" rel=\"nofollow noreferrer\">API</a></p>\n"
},
{
"answer... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2678/"
] | Is there a reasonable way to extract plain text from a Word file that doesn't depend on COM automation? (This is a a feature for a web app deployed on a non-Windows platform - that's non-negotiable in this case.)
Antiword seems like it might be a reasonable option, but it seems like it might be abandoned.
A Python so... | I use catdoc or antiword for this, whatever gives the result that is the easiest to parse. I have embedded this in python functions, so it is easy to use from the parsing system (which is written in python).
```
import os
def doc_to_text_catdoc(filename):
(fi, fo, fe) = os.popen3('catdoc -w "%s"' % filename)
... |
42,490 | <p><em>Disclaimer: I'm stuck on TFS and I hate it.</em></p>
<p>My source control structure looks like this:</p>
<ul>
<li>/dev</li>
<li>/releases</li>
<li>/branches</li>
<li>/experimental-upgrade</li>
</ul>
<p>I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merge... | [
{
"answer_id": 42534,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 0,
"selected": false,
"text": "<p>@Nick: No changes have been made to this just yet. I may have to delete it and re-branch (however you really can't... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3381/"
] | *Disclaimer: I'm stuck on TFS and I hate it.*
My source control structure looks like this:
* /dev
* /releases
* /branches
* /experimental-upgrade
I branched from dev to experimental-upgrade and didn't touch it. I then did some more work in dev and merged to experimental-upgrade. Somehow TFS complained that I had cha... | @Ben
You can actually do a full delete in TFS, but it is highly not recommended unless you know what you are doing. You have to do it from the command line with the command tf destroy
```
tf destroy [/keephistory] itemspec1 [;versionspec]
[itemspec2...itemspecN] [/stopat:versionspec] [/preview]
... |
42,505 | <p>I have a C# singleton class that multiple classes use. Is access through <code>Instance</code> to the <code>Toggle()</code> method thread-safe? If yes, by what assumptions, rules, etc. If no, why <em>and</em> how can I fix it?</p>
<pre><code>public class MyClass
{
private static readonly MyClass instance = new ... | [
{
"answer_id": 42511,
"author": "juan",
"author_id": 1782,
"author_profile": "https://Stackoverflow.com/users/1782",
"pm_score": 0,
"selected": false,
"text": "<p>Quote:</p>\n\n<pre><code>if(value == 0) { value = 1; }\nif(value == 1) { value = 0; }\nreturn value;\n</code></pre>\n\n<p><co... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | I have a C# singleton class that multiple classes use. Is access through `Instance` to the `Toggle()` method thread-safe? If yes, by what assumptions, rules, etc. If no, why *and* how can I fix it?
```
public class MyClass
{
private static readonly MyClass instance = new MyClass();
public static MyClass Insta... | >
> Is access through 'Instance' to the 'Toggle()' class threadsafe? If yes, by what assumptions, rules, etc. If no, why and how can I fix it?
>
>
>
No, it's not threadsafe.
Basically, both threads can run the `Toggle` function at the same time, so this could happen
```
// thread 1 is running this code
i... |
42,519 | <p>Inspired by <a href="https://devblogs.microsoft.com/oldnewthing/20080902-00/?p=21003" rel="noreferrer">Raymond Chen's post</a>, say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real world stuff.</p>
<pre><code... | [
{
"answer_id": 42535,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 8,
"selected": true,
"text": "<p>Here it is in C#</p>\n\n<pre class=\"lang-csharp prettyprint-override\"><code>int[,] array = new int[4,4] {\n { 1,2,3,4... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/736/"
] | Inspired by [Raymond Chen's post](https://devblogs.microsoft.com/oldnewthing/20080902-00/?p=21003), say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real world stuff.
```
[1][2][3][4]
[5][6][7][8]
[9][0][1][2]
[3... | Here it is in C#
```csharp
int[,] array = new int[4,4] {
{ 1,2,3,4 },
{ 5,6,7,8 },
{ 9,0,1,2 },
{ 3,4,5,6 }
};
int[,] rotated = RotateMatrix(array, 4);
static int[,] RotateMatrix(int[,] matrix, int n) {
int[,] ret = new int[n, n];
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ... |
42,531 | <p>Looking for an example that:</p>
<ol>
<li>Launches an EXE</li>
<li>Waits for the EXE to finish.</li>
<li>Properly closes all the handles when the executable finishes.</li>
</ol>
| [
{
"answer_id": 42543,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 5,
"selected": false,
"text": "<p>There is an example at <a href=\"http://msdn.microsoft.com/en-us/library/ms682512(VS.85).aspx\" rel=\"noreferrer\"><a hr... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | Looking for an example that:
1. Launches an EXE
2. Waits for the EXE to finish.
3. Properly closes all the handles when the executable finishes. | Something like this:
```
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
if (CreateProcess(path, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
``` |
42,566 | <p>I'm in the process of maintaining a Ruby on Rails app and am looking for an easy way to find the hostname or IP address of the box I'm on (since it's a VM and new instances may have different hostnames or IP addresses). Is there a quick and easy way to do this in Ruby on Rails?</p>
<p>Edit: The answer below is corr... | [
{
"answer_id": 42595,
"author": "Craig",
"author_id": 1611,
"author_profile": "https://Stackoverflow.com/users/1611",
"pm_score": 0,
"selected": false,
"text": "<p>try: <a href=\"http://apidock.com/rails/v2.3.8/ActionController/Request/remote_ip\" rel=\"nofollow noreferrer\">Request.remo... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] | I'm in the process of maintaining a Ruby on Rails app and am looking for an easy way to find the hostname or IP address of the box I'm on (since it's a VM and new instances may have different hostnames or IP addresses). Is there a quick and easy way to do this in Ruby on Rails?
Edit: The answer below is correct but th... | From [coderrr.wordpress.com](http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/):
```
require 'socket'
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.a... |
42,575 | <p>We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:</p>
<pre><code>// Add market_local to index
contactDocument.add(
new Field(
"mark... | [
{
"answer_id": 42734,
"author": "Darren Hague",
"author_id": 4450,
"author_profile": "https://Stackoverflow.com/users/4450",
"pm_score": 4,
"selected": true,
"text": "<p>For debugging Lucene, the best tool to use is <a href=\"http://www.getopt.org/luke/\" rel=\"noreferrer\">Luke</a>, whi... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/302/"
] | We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:
```
// Add market_local to index
contactDocument.add(
new Field(
"market_local"
... | For debugging Lucene, the best tool to use is [Luke](http://www.getopt.org/luke/), which lets you poke around in the index itself to see what got indexed, carry out searches, etc. I recommend downloading it, pointing it at your index, and seeing what's in there. |
42,581 | <p>The Python docs say:</p>
<blockquote>
<p>re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...</p>
</blockquote>
<p>So what's going on ... | [
{
"answer_id": 42597,
"author": "Moe",
"author_id": 3051,
"author_profile": "https://Stackoverflow.com/users/3051",
"pm_score": 8,
"selected": true,
"text": "<p>Look at the definition of <a href=\"http://docs.python.org/library/re.html#re.sub\" rel=\"noreferrer\"><code>re.sub</code></a>:... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | The Python docs say:
>
> re.MULTILINE: When specified, the pattern character '^' matches at the beginning of the string and at the beginning of each line (immediately following each newline)... By default, '^' matches only at the beginning of the string...
>
>
>
So what's going on when I get the following unexpec... | Look at the definition of [`re.sub`](http://docs.python.org/library/re.html#re.sub):
```
re.sub(pattern, repl, string[, count, flags])
```
The 4th argument is the count, you are using `re.MULTILINE` (which is 8) as the count, not as a flag.
Either use a named argument:
```
re.sub('^//', '', s, flags=re.MULTILINE)
... |
42,587 | <p>I have heard/read the term but don't quite understand what it means.</p>
<p>When should I use this technique and how would I use it? Can anyone provide a good code sample?</p>
| [
{
"answer_id": 42656,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 7,
"selected": true,
"text": "<p>The visitor pattern is a way of doing double-dispatch in an object-oriented way.</p>\n\n<p>It's useful for when you wan... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] | I have heard/read the term but don't quite understand what it means.
When should I use this technique and how would I use it? Can anyone provide a good code sample? | The visitor pattern is a way of doing double-dispatch in an object-oriented way.
It's useful for when you want to choose which method to use for a given argument based on its type at runtime rather than compile time.
Double dispatch is a special case of **multiple dispatch**.
When you call a virtual method on an ob... |
42,703 | <p>I am using sp_send_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8.</p>
<p>Here is the SQL</p>
<pre><code>EXEC msdb.dbo.sp_send_dbmail
@recipients = '[email protected]'
, @query = 'DECLARE @string_to_trim va... | [
{
"answer_id": 42728,
"author": "Craig",
"author_id": 2894,
"author_profile": "https://Stackoverflow.com/users/2894",
"pm_score": 1,
"selected": true,
"text": "<p>I think the only way to get around what you are seeing is to use BCP to dump the data to a flat file and then attach that fil... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using sp\_send\_dbmail in SQL2005 to send an email with the results in an attachment. When the attachment is sent it is UCS-2 Encoded, I want it to be ANSI or UTF-8.
Here is the SQL
```
EXEC msdb.dbo.sp_send_dbmail
@recipients = '[email protected]'
, @query = 'DECLARE @string_to_trim varchar(60);SET @stri... | I think the only way to get around what you are seeing is to use BCP to dump the data to a flat file and then attach that file. Sorry I couldn't be more help. :( |
42,710 | <p>I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I want vcs to successfully optimizing the code and also... | [
{
"answer_id": 43143,
"author": "DMC",
"author_id": 3148,
"author_profile": "https://Stackoverflow.com/users/3148",
"pm_score": 2,
"selected": false,
"text": "<p>My preference - if it makes sense for your problem - is for a case statement that makes use of enums or `defines. Anything to ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4454/"
] | I need to implement a 4-to-1 function in Veriog. The input is 4 bits, a number from 0-15. The output is a single bit, 0 or 1. Each input gives a different output and the mapping from inputs to outputs is known, but the inputs and outputs themselves are not. I want vcs to successfully optimizing the code and also have i... | What you have is fine. A case statement would also work equally well. It's just a matter of how expressive you wish to be.
Your solution, indexing, works fine if the select encodings don't have any special meaning (a memory address selector for example). If the select encodings do have some special semantic meaning t... |
42,762 | <p>Here is some code I could not get to format properly in markdown, this is straight C code, pasted into the text box with the '4 spaces' format to denote code:</p>
<pre><code>#define PRINT(x, format, ...) \
if ( x ) { \
if ( debug_fd != NULL ) { \
fprintf(debug_fd, format, ##__VA_ARGS__); \
} \
e... | [
{
"answer_id": 42764,
"author": "Julio César",
"author_id": 2148,
"author_profile": "https://Stackoverflow.com/users/2148",
"pm_score": 2,
"selected": false,
"text": "<p>Add at least four spaces or a hard tab before each line of the code. Like this:</p>\n\n<pre><code>#define PRINT(x, for... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3663/"
] | Here is some code I could not get to format properly in markdown, this is straight C code, pasted into the text box with the '4 spaces' format to denote code:
```
#define PRINT(x, format, ...) \
if ( x ) { \
if ( debug_fd != NULL ) { \
fprintf(debug_fd, format, ##__VA_ARGS__); \
} \
else { \
... | You can also use the HTML tags <pre><code> in succession. I find this easier for pasting code into the window.
```
#define PRINT(x, format, ...)
if ( x )
{
if ( debug_fd != NULL )
{
fprintf(debug_fd, format, ##VA_ARGS);
}
else
{
fprintf(stdout, format, ##VA_ARGS);
}
}
`... |
42,774 | <p>I'm using <kbd>Ctrl</kbd>+<kbd>Left</kbd> / <kbd>Ctrl</kbd>+<kbd>Right</kbd> in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if i... | [
{
"answer_id": 42807,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 3,
"selected": true,
"text": "<p>document.activeElement works for me in FF3 but the following also works</p>\n\n<pre><code>(function() {\n\nvar myActiveElemen... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394/"
] | I'm using `Ctrl`+`Left` / `Ctrl`+`Right` in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always ret... | document.activeElement works for me in FF3 but the following also works
```
(function() {
var myActiveElement;
document.onkeypress = function(event) {
if ((myActiveElement || document.activeElement || {}).tagName != 'INPUT')
// do your magic
};
if (!document.activeElement) {
var elements = document.ge... |
42,793 | <p>What techniques do you know\use to create user-friendly GUI ? </p>
<p>I can name following techniques that I find especially useful: </p>
<ul>
<li>Non-blocking notifications (floating dialogs like in Firefox3 or Vista's pop-up messages in tray area)</li>
<li>Absence of "Save" button<br>
MS OneNote as an example.<... | [
{
"answer_id": 42843,
"author": "Ryan P",
"author_id": 1539,
"author_profile": "https://Stackoverflow.com/users/1539",
"pm_score": 0,
"selected": false,
"text": "<p>The best technique I found is to put your self in the users shoes. What would you like to see from the GUI and put that in ... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1196/"
] | What techniques do you know\use to create user-friendly GUI ?
I can name following techniques that I find especially useful:
* Non-blocking notifications (floating dialogs like in Firefox3 or Vista's pop-up messages in tray area)
* Absence of "Save" button
MS OneNote as an example.
IM clients can save convers... | If you do give the user a question, don't make it a yes/no question. Take the time to make a new form and put the verbs as choices like in mac.
For example:
```
Would you like to save?
Yes No
```
Should Be:
```
Would you like to save?
Save Don't Save
```
There is a more detailed e... |
42,797 | <p>I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.</p>
<p>A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.</p... | [
{
"answer_id": 42811,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>We used <a href=\"http://www.eworldui.net/unleashit/\" rel=\"nofollow noreferrer\">UnleashIt</a> (unfortunate name I know) wh... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/729/"
] | I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.
A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.
UPDATE: A free/... | **@Sean Carpenter** can you tell us a little more about your environment? Should the solution be free? simple?
I find robocopy to be pretty slick for this sort of thing. Wrap in up in a batch file and you are good to go. It's a glorified xcopy, but deploying my website isn't really hard. Just copy out the files.
As f... |
42,814 | <p>How can I get the MAC Address using only the compact framework?</p>
| [
{
"answer_id": 42824,
"author": "Greg Roberts",
"author_id": 4269,
"author_profile": "https://Stackoverflow.com/users/4269",
"pm_score": -1,
"selected": false,
"text": "<p>Add a reference to System.Management.dll and use something like:</p>\n\n<pre><code>Dim mc As System.Management.Manag... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4463/"
] | How can I get the MAC Address using only the compact framework? | 1.4 of the OpenNETCF code gets the information from the following P/Invoke call:
```
[DllImport ("iphlpapi.dll", SetLastError=true)]
public static extern int GetAdaptersInfo( byte[] ip, ref int size );
```
The physical address (returned as MAC address) I think is around about index 400 - 408 of the byte arra... |
42,830 | <p>I'm using the <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx" rel="nofollow noreferrer">AutoComplete</a> control from the ASP.NET AJAX Control Toolkit and I'm experiencing an issue where the AutoComplete does not populate when I set the focus to the assigned textbox. </p>... | [
{
"answer_id": 42858,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 3,
"selected": true,
"text": "<p>We had exactly the same problem. What we had to do is write a script at the bottom of the page that quickly blurs the... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2034/"
] | I'm using the [AutoComplete](http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx) control from the ASP.NET AJAX Control Toolkit and I'm experiencing an issue where the AutoComplete does not populate when I set the focus to the assigned textbox.
I've tried setting the focus in the Page\_L... | We had exactly the same problem. What we had to do is write a script at the bottom of the page that quickly blurs then refocuses to the textbox. You can have a look at the (terribly hacky) solution here: <http://www.drive.com.au>
The textbox id is `MainSearchBox_SearchTextBox`. Have a look at about line 586 & you can... |
42,833 | <p>In the web-application I'm developing I currently use a naive solution when connecting to the database:</p>
<pre><code>Connection c = DriverManager.getConnection("url", "username", "password");
</code></pre>
<p>This is pretty unsafe. If an attacker gains access to the sourcecode he also gains access to the databas... | [
{
"answer_id": 42838,
"author": "Julio César",
"author_id": 2148,
"author_profile": "https://Stackoverflow.com/users/2148",
"pm_score": 5,
"selected": true,
"text": "<p>You can store the connection string in Web.config or App.config file and encrypt the section that holds it. Here's a ve... | 2008/09/03 | [
"https://Stackoverflow.com/questions/42833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4464/"
] | In the web-application I'm developing I currently use a naive solution when connecting to the database:
```
Connection c = DriverManager.getConnection("url", "username", "password");
```
This is pretty unsafe. If an attacker gains access to the sourcecode he also gains access to the database itself. How can my web-a... | You can store the connection string in Web.config or App.config file and encrypt the section that holds it. Here's a very good article I used in a previous project to encrypt the connection string:
<http://www.ondotnet.com/pub/a/dotnet/2005/02/15/encryptingconnstring.html> |
42,876 | <p>Why does the following code not work as I was expecting?</p>
<pre><code><?php
$data = array(
array('Area1', null, null),
array(null, 'Section1', null),
array(null, null, 'Location1'),
array('Area2', null, null),
array(null, 'Section2', null),
array(null, null, 'Location2')
);
$root = arra... | [
{
"answer_id": 42885,
"author": "pix0r",
"author_id": 72,
"author_profile": "https://Stackoverflow.com/users/72",
"pm_score": 3,
"selected": true,
"text": "<p>If you modify your code on two lines as follows:</p>\n\n<pre><code>$area = array();\n\n$section = array();\n</code></pre>\n\n<p>t... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/486/"
] | Why does the following code not work as I was expecting?
```
<?php
$data = array(
array('Area1', null, null),
array(null, 'Section1', null),
array(null, null, 'Location1'),
array('Area2', null, null),
array(null, 'Section2', null),
array(null, null, 'Location2')
);
$root = array();
foreach ($da... | If you modify your code on two lines as follows:
```
$area = array();
$section = array();
```
to this:
```
unset($area);
$area = array();
unset($section);
$section = array();
```
it will work as expected.
In the first version, `$area` and `$section` are acting as "pointers" to the value inside the `$root` arra... |
42,934 | <p>It seems that everybody is jumping on the dynamic, non-compiled bandwagon lately. I've mostly only worked in compiled, static typed languages (C, Java, .Net). The experience I have with dynamic languages is stuff like ASP (Vb Script), JavaScript, and PHP. Using these technologies has left a bad taste in my mouth ... | [
{
"answer_id": 42945,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 2,
"selected": false,
"text": "<p>The argument is more complex than this (read <a href=\"http://steve.yegge.googlepages.com/is-weak-typing-strong-enough... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1862/"
] | It seems that everybody is jumping on the dynamic, non-compiled bandwagon lately. I've mostly only worked in compiled, static typed languages (C, Java, .Net). The experience I have with dynamic languages is stuff like ASP (Vb Script), JavaScript, and PHP. Using these technologies has left a bad taste in my mouth when t... | I think the reason is that people are used to statically typed languages that have very limited and inexpressive type systems. These are languages like Java, C++, Pascal, etc. Instead of going in the direction of more expressive type systems and better type inference, (as in Haskell, for example, and even SQL to some e... |
42,950 | <p>Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?</p>
<p>If the standard library doesn't support that, does the dateutil package support this?</p>
| [
{
"answer_id": 42997,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 7,
"selected": false,
"text": "<p>EDIT: See @Blair Conrad's answer for a cleaner solution</p>\n\n<hr>\n\n<pre><code>>>> import datetime\n>... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/680/"
] | Is there a way using Python's standard library to easily determine (i.e. one function call) the last day of a given month?
If the standard library doesn't support that, does the dateutil package support this? | [`calendar.monthrange`](https://docs.python.org/library/calendar.html#calendar.monthrange) provides this information:
>
> calendar.**monthrange**(year, month)
>
> Returns weekday of first day of the month and number of days in month, for the specified *year* and *month*.
>
>
>
```
>>> import calendar
>>> c... |
42,966 | <p>What would be the best way to develop a text box that remembers the last x number of entries that were put into it. This is a standalone app written with C#.</p>
| [
{
"answer_id": 43003,
"author": "Adam Haile",
"author_id": 194,
"author_profile": "https://Stackoverflow.com/users/194",
"pm_score": 3,
"selected": false,
"text": "<p>This is actually fairly easy, especially in terms of showing the \"AutoComplete\" part of it. In terms of remembering th... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2066/"
] | What would be the best way to develop a text box that remembers the last x number of entries that were put into it. This is a standalone app written with C#. | [@Ethan](https://stackoverflow.com/questions/42966/google-suggestish-text-box#45014)
I forgot about the fact that you would want to save that so it wasn't a per session only thing :P But yes, you are completely correct.
This is easily done, especially since it's just basic strings, just write out the contents of Auto... |
42,980 | <p>Does anyone know how to setup <a href="http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial" rel="noreferrer">Mercurial</a> to use <a href="http://www.perforce.com/perforce/products/merge.html" rel="noreferrer">p4merge</a> as the merge/diff tool on OS X 10.5?</p>
| [
{
"answer_id": 43241,
"author": "Matthew Schinckel",
"author_id": 188,
"author_profile": "https://Stackoverflow.com/users/188",
"pm_score": 0,
"selected": false,
"text": "<p>I'm guessing there's a CLI tool for p4merge (which I know nothing about).</p>\n\n<p>I wrote a blog post about usin... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3547/"
] | Does anyone know how to setup [Mercurial](http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial) to use [p4merge](http://www.perforce.com/perforce/products/merge.html) as the merge/diff tool on OS X 10.5? | **This will work for merging:**
Place this into your `~/.hgrc` (or, optionally, your `Mercurial.ini` on Windows):
```
[merge-tools]
p4.priority = 100
p4.premerge = True # change this to False if you're don't trust hg's internal merge
p4.executable = /Applications/p4merge.app/Contents/MacOS/p4merge
p4.gui = True
p4.a... |
42,990 | <p>I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.</p>
<p>Example:</p>
<pre><code>// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
</code></pre>
<p>Should match anything that starts with "foo" and doesn't end with "bar". I kno... | [
{
"answer_id": 43010,
"author": "Sam Hasler",
"author_id": 2541,
"author_profile": "https://Stackoverflow.com/users/2541",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not familiar with Java regex but documentation for the <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/util/... | 2008/09/04 | [
"https://Stackoverflow.com/questions/42990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535/"
] | I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.
Example:
```
// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
```
Should match anything that starts with "foo" and doesn't end with "bar". I know about the [^...] syntax, but I can'... | I think in this case you want **negative lookbehind**, like so:
```
foo.*(?<!bar)
``` |
43,021 | <p>Is there some rare language construct I haven't encountered (like the few I've learned recently, some on Stack Overflow) in C# to get a value representing the current iteration of a foreach loop?</p>
<p>For instance, I currently do something like this depending on the circumstances:</p>
<pre><code>int i = 0;
forea... | [
{
"answer_id": 43026,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 2,
"selected": false,
"text": "<p>Unless your collection can return the index of the object via some method, the only way is to use a counter like in yo... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | Is there some rare language construct I haven't encountered (like the few I've learned recently, some on Stack Overflow) in C# to get a value representing the current iteration of a foreach loop?
For instance, I currently do something like this depending on the circumstances:
```
int i = 0;
foreach (Object o in colle... | The `foreach` is for iterating over collections that implement [`IEnumerable`](http://msdn.microsoft.com/en-us/library/9eekhta0%28v=vs.110%29.aspx). It does this by calling [`GetEnumerator`](http://msdn.microsoft.com/en-us/library/s793z9y2(v=vs.110).aspx) on the collection, which will return an [`Enumerator`](http://ms... |
43,044 | <p>I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc. </p>
<p>I've found solutions to this problem but they rely on alternative color palettes than RGB.
I would rather just use straight RGB than mapping back... | [
{
"answer_id": 43081,
"author": "helloandre",
"author_id": 50,
"author_profile": "https://Stackoverflow.com/users/50",
"pm_score": 0,
"selected": false,
"text": "<p>you could have them be within a certain brightness. that would control the ammount of \"neon\" colors a bit. for instance, ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3415/"
] | I'm looking for a simple algorithm to generate a large number of random, aesthetically pleasing colors. So no crazy neon colors, colors reminiscent of feces, etc.
I've found solutions to this problem but they rely on alternative color palettes than RGB.
I would rather just use straight RGB than mapping back and forth... | You could average the RGB values of random colors with those of a constant color:
*(example in Java)*
```
public Color generateRandomColor(Color mix) {
Random random = new Random();
int red = random.nextInt(256);
int green = random.nextInt(256);
int blue = random.nextInt(256);
// mix the color
... |
43,051 | <p>I have the following C# code:</p>
<pre><code>byte rule = 0;
...
rule = rule | 0x80;
</code></pre>
<p>which produces the error: </p>
<blockquote>
<p><em>Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)</em></p>
</blockquote>
<p>[Update: first version of the... | [
{
"answer_id": 43057,
"author": "John Rutherford",
"author_id": 3880,
"author_profile": "https://Stackoverflow.com/users/3880",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like you may just have to do it the ugly way: <a href=\"http://msdn.microsoft.com/en-us/library/5bdb6693.asp... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3631/"
] | I have the following C# code:
```
byte rule = 0;
...
rule = rule | 0x80;
```
which produces the error:
>
> *Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?)*
>
>
>
[Update: first version of the question was wrong ... I misread the compiler output]
Adding... | ```
int rule = 0;
rule |= 0x80;
```
<http://msdn.microsoft.com/en-us/library/kxszd0kx.aspx> The | operator is defined for all value types. I think this will produced the intended result. The "|=" operator is an or then assign operator, which is simply shorthand for rule = rule | 0x80.
One of the niftier things about... |
43,126 | <pre><code>public static IList<T> LoadObjectListAll<T>()
{
ISession session = CheckForExistingSession();
var cfg = new NHibernate.Cfg.Configuration().Configure();
var returnList = session.CreateCriteria(typeof(T));
var list = returnList.List();
var castList = list.Cast<typeof(T)>()... | [
{
"answer_id": 43128,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 3,
"selected": false,
"text": "<p>I think </p>\n\n<pre><code>var castList = list.Cast<typeof(T)>();\n</code></pre>\n\n<p>should be </p>\n\n<pre><code>var ca... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] | ```
public static IList<T> LoadObjectListAll<T>()
{
ISession session = CheckForExistingSession();
var cfg = new NHibernate.Cfg.Configuration().Configure();
var returnList = session.CreateCriteria(typeof(T));
var list = returnList.List();
var castList = list.Cast<typeof(T)>();
return castList;
}
... | `T` is not a type nor a `System.Type`. `T` is a type parameter. `typeof(T)` returns the type of `T`. The `typeof` operator does not act on an object, it returns the `Type` object of a type. <http://msdn.microsoft.com/en-us/library/58918ffs.aspx>
@John is correct in answering your direct question. But the NHibernate co... |
43,134 | <p>Simple question, but one that I've been curious about...is there a functional difference between the following two commands?</p>
<pre><code>String::class
String.class
</code></pre>
<p>They both do what I expect -- that is to say they return <code>Class</code> -- but what is the difference between using the <code>:... | [
{
"answer_id": 43146,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 6,
"selected": true,
"text": "<p>The <code>.</code> operator basically says \"send this message to the object\". In your example it is calling that part... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4142/"
] | Simple question, but one that I've been curious about...is there a functional difference between the following two commands?
```
String::class
String.class
```
They both do what I expect -- that is to say they return `Class` -- but what is the difference between using the `::` and the `.`?
I notice that on those cl... | The `.` operator basically says "send this message to the object". In your example it is calling that particular member. The `::` operator "drills down" to the scope defined to the left of the operator, and then calls the member defined on the right side of operator.
When you use `::` you have to be referencing member... |
43,157 | <p>I was surprised to find today that I couldn't track down any simple way to write the contents of an <code>InputStream</code> to an <code>OutputStream</code> in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code cleare... | [
{
"answer_id": 43163,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 7,
"selected": false,
"text": "<p>I think this will work, but make sure to test it... minor \"improvement\", but it might be a bit of a cost at readability... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] | I was surprised to find today that I couldn't track down any simple way to write the contents of an `InputStream` to an `OutputStream` in Java. Obviously, the byte buffer code isn't difficult to write, but I suspect I'm just missing something which would make my life easier (and the code clearer).
So, given an `InputS... | Java 9
======
Since Java 9, `InputStream` provides a method called `transferTo` with the following signature:
```
public long transferTo(OutputStream out) throws IOException
```
As the [documentation](https://docs.oracle.com/javase/9/docs/api/java/io/InputStream.html#transferTo-java.io.OutputStream-) states, `trans... |
43,199 | <p>The login page in my Tapestry application has a property in which the password the user types in is stored, which is then compared against the value from the database. If the user enters a password with multi-byte characters, such as:</p>
<pre><code>áéíóú
</code></pre>
<p>...an inspection of the return value of ge... | [
{
"answer_id": 43238,
"author": "Palgar",
"author_id": 3479,
"author_profile": "https://Stackoverflow.com/users/3479",
"pm_score": 2,
"selected": false,
"text": "<p>If you have built them as Hyper-V machines, I don't think you can go back. There are serious differences in the HAL for Vi... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] | The login page in my Tapestry application has a property in which the password the user types in is stored, which is then compared against the value from the database. If the user enters a password with multi-byte characters, such as:
```
áéíóú
```
...an inspection of the return value of getPassword() (the abstract ... | VPC to Hyper-V is one way. |
43,201 | <p>I'm looking for some examples or samples of routing for the following sort of scenario:</p>
<p>The general example of doing things is: {controller}/{action}/{id}</p>
<p>So in the scenario of doing a product search for a store you'd have:</p>
<pre><code>public class ProductsController: Controller
{
public Acti... | [
{
"answer_id": 43623,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 1,
"selected": false,
"text": "<p>The best way to do this without any compromises would be to implement your own ControllerFactory by inheriting off of I... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3717/"
] | I'm looking for some examples or samples of routing for the following sort of scenario:
The general example of doing things is: {controller}/{action}/{id}
So in the scenario of doing a product search for a store you'd have:
```
public class ProductsController: Controller
{
public ActionResult Search(string id) /... | I actually found it not even by searching, but by scanning through the ASP .NET forums in [this question](http://forums.asp.net/t/1296928.aspx?PageIndex=1).
Using this you can have the controllers of the same name under any part of the namespace, so long as you qualify which routes belong to which namespaces (you can ... |
43,218 | <p>I'm working on a C#/ASP.NET project that has all the javascript files in a /Javascript folder. If I refer to the JS file using this syntax: src="/Javascript/jsfile.js" then the file is correctly picked up if the project is deployed to the root of the URL.</p>
<p>However, if this "web site" is deployed to a sub-fold... | [
{
"answer_id": 43222,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 5,
"selected": true,
"text": "<p>If you reference the JS-file in a section that is \"runat=server\" you could write src=\"~/Javascript/jsfile.js\" and it will ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | I'm working on a C#/ASP.NET project that has all the javascript files in a /Javascript folder. If I refer to the JS file using this syntax: src="/Javascript/jsfile.js" then the file is correctly picked up if the project is deployed to the root of the URL.
However, if this "web site" is deployed to a sub-folder of the ... | If you reference the JS-file in a section that is "runat=server" you could write src="~/Javascript/jsfile.js" and it will always work.
You could also do this in your Page\_Load (In your masterpage):
```
Page.ClientScript.RegisterClientScriptInclude("myJsFile", Page.ResolveClientUrl("~/Javascript/jsfile.js"))
``` |
43,249 | <p>Is there a graceful way to handle passing a list of ids as a parameter to a stored procedure? </p>
<p>For instance, I want departments 1, 2, 5, 7, 20 returned by my stored procedure. In the past, I have passed in a comma delimited list of ids, like the below code, but feel really dirty doing it. </p>
<p>SQL Server... | [
{
"answer_id": 43260,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": false,
"text": "<p>Yeah, your current solution is prone to SQL injection attacks.</p>\n\n<p>The best solution that I've found is to use a... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1865/"
] | Is there a graceful way to handle passing a list of ids as a parameter to a stored procedure?
For instance, I want departments 1, 2, 5, 7, 20 returned by my stored procedure. In the past, I have passed in a comma delimited list of ids, like the below code, but feel really dirty doing it.
SQL Server 2005 is my only ... | Erland Sommarskog has maintained the authoritative answer to this question for the last 16 years: *[Arrays and Lists in SQL Server](http://www.sommarskog.se/arrays-in-sql.html)*.
There are at least a dozen ways to pass an array or list to a query; each has their own unique pros and cons.
* [Table-Valued Parameters](... |
43,289 | <p>How can I do this fast?</p>
<p>Sure I can do this:</p>
<pre><code>static bool ByteArrayCompare(byte[] a1, byte[] a2)
{
if (a1.Length != a2.Length)
return false;
for (int i=0; i<a1.Length; i++)
if (a1[i]!=a2[i])
return false;
return true;
}
</code></pre>
<p>But I'm look... | [
{
"answer_id": 43300,
"author": "gil",
"author_id": 195,
"author_profile": "https://Stackoverflow.com/users/195",
"pm_score": 3,
"selected": false,
"text": "<p>I would use unsafe code and run the <code>for</code> loop comparing Int32 pointers.</p>\n\n<p>Maybe you should also consider che... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4489/"
] | How can I do this fast?
Sure I can do this:
```
static bool ByteArrayCompare(byte[] a1, byte[] a2)
{
if (a1.Length != a2.Length)
return false;
for (int i=0; i<a1.Length; i++)
if (a1[i]!=a2[i])
return false;
return true;
}
```
But I'm looking for either a [BCL](https://en.wi... | Edit: modern fast way is to use `a1.SequenceEquals(a2)`
User *gil* suggested unsafe code which spawned this solution:
```
// Copyright (c) 2008-2013 Hafthor Stefansson
// Distributed under the MIT/X11 software license
// Ref: http://www.opensource.org/licenses/mit-license.php.
static unsafe bool UnsafeCompare(byte[] ... |
43,290 | <p>In Django's template language, you can use <code>{% url [viewname] [args] %}</code> to generate a URL to a specific view with parameters. How can you programatically do the same in Python code?</p>
<p>What I need is to create a list of menu items where each item has name, URL, and an active flag (whether it's the ... | [
{
"answer_id": 43312,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 7,
"selected": true,
"text": "<p>If you need to use something similar to the <code>{% url %}</code> template tag in your code, Django provides the <cod... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3355/"
] | In Django's template language, you can use `{% url [viewname] [args] %}` to generate a URL to a specific view with parameters. How can you programatically do the same in Python code?
What I need is to create a list of menu items where each item has name, URL, and an active flag (whether it's the current page or not). ... | If you need to use something similar to the `{% url %}` template tag in your code, Django provides the `django.core.urlresolvers.reverse()`. The `reverse` function has the following signature:
```
reverse(viewname, urlconf=None, args=None, kwargs=None)
```
<https://docs.djangoproject.com/en/dev/ref/urlresolvers/>
A... |
43,291 | <p>I know that I can do something like</p>
<pre><code>$int = (int)99; //(int) has a maximum or 99
</code></pre>
<p>To set the variable <code>$int</code> to an integer and give it a value of <code>99</code>. </p>
<p>Is there a way to set the type to something like <code>LongBlob</code> in MySQL for <code>LARGE</code>... | [
{
"answer_id": 43295,
"author": "erlando",
"author_id": 4192,
"author_profile": "https://Stackoverflow.com/users/4192",
"pm_score": 4,
"selected": true,
"text": "<p>No. PHP does what is called automatic type conversion.</p>\n\n<p>In your example</p>\n\n<pre><code>$int = (int)123;\n</code... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] | I know that I can do something like
```
$int = (int)99; //(int) has a maximum or 99
```
To set the variable `$int` to an integer and give it a value of `99`.
Is there a way to set the type to something like `LongBlob` in MySQL for `LARGE` Integers in PHP? | No. PHP does what is called automatic type conversion.
In your example
```
$int = (int)123;
```
the "(int)" just assures that at that exact moment 123 will be handled as an int.
I think your best bet would be to use a class to provide some sort of type safety. |
43,320 | <p>One of the things that get me thoroughly confused is the use of <code>session.Flush</code>,in conjunction with <code>session.Commit</code>, and <code>session.Close</code>.</p>
<p>Sometimes <code>session.Close</code> works, e.g., it commits all the changes that I need. I know I need to use commit when I have a trans... | [
{
"answer_id": 43567,
"author": "Matt Hinze",
"author_id": 2676,
"author_profile": "https://Stackoverflow.com/users/2676",
"pm_score": 9,
"selected": true,
"text": "<p>Briefly:</p>\n<ol>\n<li>Always use transactions</li>\n<li>Don't use <code>Close()</code>, instead wrap your calls on an ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/372/"
] | One of the things that get me thoroughly confused is the use of `session.Flush`,in conjunction with `session.Commit`, and `session.Close`.
Sometimes `session.Close` works, e.g., it commits all the changes that I need. I know I need to use commit when I have a transaction, or a unit of work with several creates/updates... | Briefly:
1. Always use transactions
2. Don't use `Close()`, instead wrap your calls on an `ISession` inside a `using` statement or **manage the lifecycle of your ISession somewhere else**.
From [the documentation](http://nhibernate.info/doc/nh/en/index.html#manipulatingdata-flushing):
>
> From time to time the `ISe... |
43,321 | <p>The default shell in Mac OS X is <code>bash</code>, which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed <em>more stuff</em>, though, and I've heard good things about <code>zsh</code> in this regard. But I don't really have the inclination to spend hours fid... | [
{
"answer_id": 43323,
"author": "Staale",
"author_id": 3355,
"author_profile": "https://Stackoverflow.com/users/3355",
"pm_score": 3,
"selected": false,
"text": "<p>zsh has a console gui configuration thing. You can set it up pretty quickly and easily without having to fiddle with config... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4161/"
] | The default shell in Mac OS X is `bash`, which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed *more stuff*, though, and I've heard good things about `zsh` in this regard. But I don't really have the inclination to spend hours fiddling with settings to improve m... | For casual use you are probably better off sticking with bash and just installing bash completion.
Installing it is pretty easy, grab the bash-completion-20060301.tar.gz from <http://www.caliban.org/bash/index.shtml#completion> and extract it with
```
tar -xzvf bash-completion-20060301.tar.gz
```
then copy the ba... |
43,324 | <p>I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's g... | [
{
"answer_id": 43353,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "<p>The ASP.Net Session ID is stored in <code>Session.SessionID</code> so you could set that in a hidden field and then post it t... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2527/"
] | I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's great... | [Here](http://swfupload.org/forum/generaldiscussion/98) is a post from the maintainer of [SWFUpload](http://swfupload.org) which explains how to load the session from an ID stored in Request.Form. I imagine the same thing would work for the Yahoo component.
Note the security disclaimers at the bottom of the post.
---... |
43,354 | <p>How do you reference a bitmap on the stage in flash using actionscript 3?</p>
<p>I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/... | [
{
"answer_id": 43477,
"author": "bitbonk",
"author_id": 4227,
"author_profile": "https://Stackoverflow.com/users/4227",
"pm_score": 1,
"selected": false,
"text": "<p>It should be something like this:</p>\n\n<pre><code>imageHolder.removeChild( imageIndex )\n</code></pre>\n\n<p>or</p>\n\n<... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098/"
] | How do you reference a bitmap on the stage in flash using actionscript 3?
I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. here... | To reference something on the stage, you need to give the stage instance a name - not give the symbol in the library a class name.
Click on the item on the stage and look at the properties panel. There should be a text entry box just above the entry boxes for the item's dimensions. Enter a name there.
Elsewhere in yo... |
43,368 | <p>I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain t... | [
{
"answer_id": 43386,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 2,
"selected": false,
"text": "<p>You should have a look at django and especially its <a href=\"http://www.djangoproject.com/documentation/forms/\" rel... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4462/"
] | I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of when generating user interfaces. E.g., if a VARCHAR column has a maximum with of 20 characters, there GUIs should automatically constrain the ... | web2py does most of what you ask:
Based on a field type and its validators it will render the field with the appropriate widget. You can override with
```
db.table.field.widget=...
```
and use a third party widget.
web2py has js to blocks the user from entering a non-integer in a integer field or a non-double in a... |
43,374 | <p>What I have so far is </p>
<pre><code>#!/bin/sh
php_syntax_check()
{
retval=0
for i in $(git-diff-index --name-only --cached HEAD -- | grep -e '\.php$'); do
if [ -f $i ]; then
output=$(php -l $i)
retval=$?
if [ $retval -gt 0 ]; then
echo "========... | [
{
"answer_id": 173878,
"author": "Anonymous",
"author_id": 15073,
"author_profile": "https://Stackoverflow.com/users/15073",
"pm_score": 2,
"selected": false,
"text": "<p>I'm sorry if it's offtopic, but aren't you supposed to run some kind of automated tests (which would imply that the c... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4342/"
] | What I have so far is
```
#!/bin/sh
php_syntax_check()
{
retval=0
for i in $(git-diff-index --name-only --cached HEAD -- | grep -e '\.php$'); do
if [ -f $i ]; then
output=$(php -l $i)
retval=$?
if [ $retval -gt 0 ]; then
echo "======================... | If the commit is a partial commit (not all the changes in the working tree are committed), then this make give incorrect results since it tests the working copy and not the staged copy.
One way to do this could be:
```
git diff --cached --name-only --diff-filter=ACMR | xargs git checkout-index --prefix=$TMPDIR/ --
fi... |
43,427 | <p>Say I have a site on <a href="http://example.com" rel="noreferrer">http://example.com</a>. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words</p>
<p><a href="http://example.com" rel="noreferrer">http://example.com</a> & <a href... | [
{
"answer_id": 43436,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 0,
"selected": false,
"text": "<p>Basic robots.txt:</p>\n\n<pre><code>Disallow: /subdir/\n</code></pre>\n\n<p>I don't think that you can create an expression say... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] | Say I have a site on <http://example.com>. I would really like allowing bots to see the home page, but any other page need to blocked as it is pointless to spider. In other words
<http://example.com> & <http://example.com/> should be allowed, but
<http://example.com/anything> and <http://example.com/someendpoint.aspx... | So after some research, here is what I found - a solution acceptable by the major search providers: [google](http://www.google.com/support/webmasters/bin/answer.py?answer=40367) , [yahoo](http://help.yahoo.com/l/us/yahoo/search/webcrawler/slurp-02.html) & msn (I could on find a validator here) :
```
User-Agent: *
Disa... |
43,490 | <p>When is this called? More specifically, I have a control I'm creating - how can I release handles when the window is closed. In normal win32 I'd do it during <code>wm_close</code> - is <code>DestroyHandle</code> the .net equivalent?</p>
<hr>
<p>I don't want to destroy the window handle myself - my control is liste... | [
{
"answer_id": 43499,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>Normally <code>DestroyHandle</code> is being called in <code>Dispose</code> method. So you need to make sure that all controls... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4495/"
] | When is this called? More specifically, I have a control I'm creating - how can I release handles when the window is closed. In normal win32 I'd do it during `wm_close` - is `DestroyHandle` the .net equivalent?
---
I don't want to destroy the window handle myself - my control is listening for events on another object... | Normally `DestroyHandle` is being called in `Dispose` method. So you need to make sure that all controls are disposed to avoid resource leaks. |
43,503 | <p>Is there a way to detect if a flash movie contains any sound or is playing any music?<br>
It would be nice if this could be done inside a webbrowser (actionscript <strong>from another flash object</strong>, javascript,..) and could be done <em>before</em> the flash movie starts playing.</p>
<p>However, I have my do... | [
{
"answer_id": 43519,
"author": "Stu Thompson",
"author_id": 2961,
"author_profile": "https://Stackoverflow.com/users/2961",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, on the server side for sure. Client side? I don't know. (I'm a serverside kind of guy.) </p>\n\n<p>On the serv... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46/"
] | Is there a way to detect if a flash movie contains any sound or is playing any music?
It would be nice if this could be done inside a webbrowser (actionscript **from another flash object**, javascript,..) and could be done *before* the flash movie starts playing.
However, I have my doubts this will be possible alto... | Yes, on the server side for sure. Client side? I don't know. (I'm a serverside kind of guy.)
On the server side, one would have to parse the file, read the header and/or look for audio frames. (I've ported a haskel FLV parser to Java for indexing purposes myself, and there are other parsing utilities out there. It is... |
43,507 | <p>I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?</p>
<p>Is there anything more to be added to the code that goes into a real world application?</p>
<p>What all steps are to be taken to make the ... | [
{
"answer_id": 43510,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 0,
"selected": false,
"text": "<p>I would use a framework like <a href=\"http://www.domassistant.com/\" rel=\"nofollow noreferrer\">DOMAssistant</a> which ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] | I have seen simple example Ajax source codes in many online tutorials. What I want to know is whether using the source code in the examples are perfectly alright or not?
Is there anything more to be added to the code that goes into a real world application?
What all steps are to be taken to make the application more ... | The code you posted is missing one important ingredient: the function stateChanged.
If you don't quite understand the code you posted yourself, then what happens is when the call to getchats.php is complete, a function "stateChanged" is called and that function will be responsible for handling the response. Since the ... |
43,511 | <p>I have some classes layed out like this</p>
<pre><code>class A
{
public virtual void Render()
{
}
}
class B : A
{
public override void Render()
{
// Prepare the object for rendering
SpecialRender();
// Do some cleanup
}
protected virtual void SpecialRender()
... | [
{
"answer_id": 43516,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 6,
"selected": true,
"text": "<p>You can seal individual methods to prevent them from being overridable:</p>\n\n<pre><code>public sealed override void R... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3602/"
] | I have some classes layed out like this
```
class A
{
public virtual void Render()
{
}
}
class B : A
{
public override void Render()
{
// Prepare the object for rendering
SpecialRender();
// Do some cleanup
}
protected virtual void SpecialRender()
{
}
}
clas... | You can seal individual methods to prevent them from being overridable:
```
public sealed override void Render()
{
// Prepare the object for rendering
SpecialRender();
// Do some cleanup
}
``` |
43,525 | <p>For some strange, bizarre reason, my images in my website just will not display on webkit based languages (such as safari and chrome).</p>
<p>This is the image tag</p>
<pre><code><img src="images/dukkah.jpg" class="imgleft"/>
</code></pre>
<p>Not only does it not display in the website, it wont display when... | [
{
"answer_id": 43537,
"author": "Niyaz",
"author_id": 184,
"author_profile": "https://Stackoverflow.com/users/184",
"pm_score": 2,
"selected": false,
"text": "<p>I have come across this problem a couple of times.</p>\n\n<p>I think it is because of some problem in the file format.</p>\n\n... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] | For some strange, bizarre reason, my images in my website just will not display on webkit based languages (such as safari and chrome).
This is the image tag
```
<img src="images/dukkah.jpg" class="imgleft"/>
```
Not only does it not display in the website, it wont display when accessed directly at `http://kilkin.ma... | Imagemagick reports that this particular image is saved in CMYK colorspace instead of the more standard RGB. Try converting it, it should be more compatible with the webkit rendering engine.
Imagemagick is available for download from [<http://www.imagemagick.org/script/index.php>](http://www.imagemagick.org/script/ind... |
43,569 | <p>How to restrict the maximum number of characters that can be entered into an HTML <code><textarea></code>? I'm looking for a cross-browser solution.</p>
| [
{
"answer_id": 43571,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 5,
"selected": true,
"text": "<p>The <code>TEXTAREA</code> tag does not have a <code>MAXLENGTH</code> attribute the way that an\n<code>INPUT</code> tag does, a... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3512/"
] | How to restrict the maximum number of characters that can be entered into an HTML `<textarea>`? I'm looking for a cross-browser solution. | The `TEXTAREA` tag does not have a `MAXLENGTH` attribute the way that an
`INPUT` tag does, at least not in most standard browsers. A very simple and effective way to limit the number of characters that can be *typed* into a `TEXTAREA` tag is:
```
<textarea onKeyPress="return ( this.value.length < 50 );"></textarea>
`... |
43,580 | <p>Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.</p>
<p>Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) h... | [
{
"answer_id": 43588,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 7,
"selected": false,
"text": "<p>The <a href=\"https://docs.python.org/library/mimetypes.html\" rel=\"noreferrer\">mimetypes module</a> in the standard ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.
Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in t... | The python-magic method suggested by [toivotuo](https://stackoverflow.com/a/2133843/5337834) is outdated. [Python-magic's](http://github.com/ahupp/python-magic) current trunk is at Github and based on the readme there, finding the MIME-type, is done like this.
```
# For MIME types
import magic
mime = magic.Magic(mime=... |
43,584 | <p>A very niche problem:</p>
<p>I sometimes (30% of the time) get an 'undefined handler' javascript error on line 3877 of the prototype.js library (version 1.6.0.2 from google: <a href="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js" rel="nofollow noreferrer">http://ajax.googleapis.com/ajax/libs/p... | [
{
"answer_id": 43646,
"author": "David McLaughlin",
"author_id": 3404,
"author_profile": "https://Stackoverflow.com/users/3404",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>I switched to a local version of prototypejs and added some debugging\n in the offending method ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4512/"
] | A very niche problem:
I sometimes (30% of the time) get an 'undefined handler' javascript error on line 3877 of the prototype.js library (version 1.6.0.2 from google: <http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js>).
Now on this page I have a Google Map and I use the Prototype Window library.
T... | I just found out this error also occurs if you accidentally leave on the parenthesis on your observer call:
```
Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp());
```
instead of
```
Event.observe(document, 'myapp:application_ready', myapp.MyClass.initApp);
``` |
43,589 | <p>I need to get the first and last day of a month in the format YYYY-MM-DD given only the month and year. Is there a good, easy way to do this?</p>
| [
{
"answer_id": 43607,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 3,
"selected": false,
"text": "<p>First day is always YYYY-MM-01, isn't it? Example: <code>date(\"Y-M-d\", mktime(0, 0, 0, 8, 1, 2008))</code></p>\n\n<p>Last day... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] | I need to get the first and last day of a month in the format YYYY-MM-DD given only the month and year. Is there a good, easy way to do this? | ```
$first = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
$last = date('Y-m-t', mktime(0, 0, 0, $month, 1, $year));
```
See [date()](http://ie2.php.net/date) in PHP documentation. |
43,632 | <p>I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive.</p>
<p>For example, let's say I have a string like this:</p>
<pre><code>fooFOOfOoFoOBARBARbarbarbAr
</code></pre>
<p>What if I want to match all ... | [
{
"answer_id": 43636,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 8,
"selected": true,
"text": "<p>Perl lets you make part of your regular expression case-insensitive by using the (?i:) pattern modifier.</p>\n\n<p>Modern rege... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive.
For example, let's say I have a string like this:
```
fooFOOfOoFoOBARBARbarbarbAr
```
What if I want to match all occurrences of "foo" regardless of... | Perl lets you make part of your regular expression case-insensitive by using the (?i:) pattern modifier.
Modern regex flavors allow you to apply modifiers to only part of the regular expression. If you insert the modifier (?ism) in the middle of the regex, the modifier only applies to the part of the regex to the righ... |
43,643 | <p>Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-c... | [
{
"answer_id": 43703,
"author": "pkaeding",
"author_id": 4257,
"author_profile": "https://Stackoverflow.com/users/4257",
"pm_score": 3,
"selected": false,
"text": "<p>This will get your buttons and labels next to each other, at least. I believe the second part can't be done in css alone... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4013/"
] | Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels?
```html
<link href="http://yui.yahooapis.com/2.5.2/build/reset-fonts-grids/reset-fonts-grids.css" rel="stylesheet">
<link href="http://yui.yahooapis.com/... | The first part of your question can be solved with just HTML & CSS; you'll need to use Javascript for the second part.
### Getting the Label Near the Radio Button
I'm not sure what you mean by "next to": on the same line and near, or on separate lines? If you want all of the radio buttons on the same line, just use m... |
43,711 | <p>I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a k... | [
{
"answer_id": 43716,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 4,
"selected": false,
"text": "<p>I think creating a separate clock class for something simple like getting the current date is a bit overkill. </p>\n\n<p>Y... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1404/"
] | I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a know... | My preference is to have classes that use time actually rely on an interface, such as
```
interface IClock
{
DateTime Now { get; }
}
```
With a concrete implementation
```
class SystemClock: IClock
{
DateTime Now { get { return DateTime.Now; } }
}
```
Then if you want, you can provide any other kind of ... |
43,738 | <p>I have a line color property in my custom grid control. I want it to default to <code>Drawing.SystemColors.InactiveBorder</code>. I tried:</p>
<pre><code>[DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")]
public Color LineColor { get; set; }
</code></pre>
<p>But it doesn't seem to work. How do I... | [
{
"answer_id": 43751,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 4,
"selected": false,
"text": "<p>You need to change first argument from <code>SystemColors</code> to <code>Color</code>.<br>\nIt seems that there is no type co... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/976/"
] | I have a line color property in my custom grid control. I want it to default to `Drawing.SystemColors.InactiveBorder`. I tried:
```
[DefaultValue(typeof(System.Drawing.SystemColors), "InactiveBorder")]
public Color LineColor { get; set; }
```
But it doesn't seem to work. How do I do that with the default value attri... | You need to change first argument from `SystemColors` to `Color`.
It seems that there is no type converter for the `SystemColors` type, only for the `Color` type.
```
[DefaultValue(typeof(Color),"InactiveBorder")]
``` |
43,765 | <p>For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code.</p>
<p>Normally, I have 2 windows in a split (C-x 3):
<a href="http://bitthicket.com/files/emacs-2split.JPG">alt text http://bitthicket.com/files/emacs-2split.JPG</a></p>
<p>And I use the r... | [
{
"answer_id": 44562,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 0,
"selected": false,
"text": "<p>Well, I decided to not be a reputation-whore and find the answer myself. I looked in cscope.el as shown on the Emacs ... | 2008/09/04 | [
"https://Stackoverflow.com/questions/43765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3279/"
] | For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code.
Normally, I have 2 windows in a split (C-x 3):
[alt text http://bitthicket.com/files/emacs-2split.JPG](http://bitthicket.com/files/emacs-2split.JPG)
And I use the right window for code buffers a... | Put this in your .emacs file:
```
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p w... |