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 |
|---|---|---|---|---|---|---|
26,098 | <p>I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this</p>
<pre><code>LIBRARY "MyLib"
EXPORTS
Foo
Bar
</code></pre>
<p>with the code defined as this, for example:</p>
<pre><code>int Foo(int a);
void Bar(int foo);
</code></pre>
<p>However, what if I wan... | [
{
"answer_id": 26121,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 4,
"selected": true,
"text": "<p>In the code itself, mark the functions you want to export using __declspec(dllexport). For example:</p>\n\n<pre><code... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I'm writing a C/C++ DLL and want to export certain functions which I've done before using a .def file like this
```
LIBRARY "MyLib"
EXPORTS
Foo
Bar
```
with the code defined as this, for example:
```
int Foo(int a);
void Bar(int foo);
```
However, what if I want to declare an overloaded method of Foo() like:
... | In the code itself, mark the functions you want to export using \_\_declspec(dllexport). For example:
```
#define DllExport __declspec(dllexport)
int DllExport Foo( int a ) {
// implementation
}
int DllExport Foo( int a, int b ) {
// implementation
}
```
If you do this, you do not need to list the functions in... |
26,123 | <p>I want to use Powershell to write some utilities, leveraging our own .NET components to handle the actual work. This is in place of writing a small console app to tie the calls together. My question is where I would find a good source of documentation or tutorial material to help me fast track this?</p>
| [
{
"answer_id": 26135,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 5,
"selected": true,
"text": "<p>If you want to load an assembly into your PowerShell session, you can use reflection and load the assembly.</p>\n\n... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1535/"
] | I want to use Powershell to write some utilities, leveraging our own .NET components to handle the actual work. This is in place of writing a small console app to tie the calls together. My question is where I would find a good source of documentation or tutorial material to help me fast track this? | If you want to load an assembly into your PowerShell session, you can use reflection and load the assembly.
```
[void][System.Reflection.Assembly]::LoadFrom(PathToYourAssembly)
```
After you load your assembly, you can call static methods and create new instances of a class.
A good tutorial can be found [here](htt... |
26,137 | <p>I have a couple of questions regarding VBScript and ASP Classic:</p>
<ol>
<li><p>What is the preferred way to access an MS SQL Server database in VBScript/ASP?</p></li>
<li><p>What are best practices in regards to separating model from view from controller?</p></li>
<li><p>Any other things I should know about eithe... | [
{
"answer_id": 26181,
"author": "Michael Pryor",
"author_id": 245,
"author_profile": "https://Stackoverflow.com/users/245",
"pm_score": 5,
"selected": true,
"text": "<p>ADO is an excellent way to access a database in VBScript/Classic ASP.</p>\n\n<pre><code>Dim db: Set db = Server.CreateO... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | I have a couple of questions regarding VBScript and ASP Classic:
1. What is the preferred way to access an MS SQL Server database in VBScript/ASP?
2. What are best practices in regards to separating model from view from controller?
3. Any other things I should know about either VBScript or ASP?
If you haven't noticed... | ADO is an excellent way to access a database in VBScript/Classic ASP.
```
Dim db: Set db = Server.CreateObject("ADODB.Connection")
db.Open "yourconnectionstring -> see connectionstrings.com"
Dim rs: Set rs = db.Execute("SELECT firstName from Employees")
While Not rs.EOF
Response.Write rs("firstName")
rs.MoveNe... |
26,145 | <p>I'm making a simple extra java app launcher for Eclipse 3.2 (JBuilder 2007-8) for internal use.</p>
<p>So I looked up all the documentations related, including this one <a href="http://www.eclipse.org/articles/Article-Launch-Framework/launch.html" rel="nofollow noreferrer" title="The Launching Framework">The Launch... | [
{
"answer_id": 26341,
"author": "zvikico",
"author_id": 2823,
"author_profile": "https://Stackoverflow.com/users/2823",
"pm_score": 0,
"selected": false,
"text": "<p>You class should implement ILaunchShortcut.\nCheck out the <a href=\"http://help.eclipse.org/help32/nftopic/org.eclipse.pl... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2710/"
] | I'm making a simple extra java app launcher for Eclipse 3.2 (JBuilder 2007-8) for internal use.
So I looked up all the documentations related, including this one [The Launching Framework from eclipse.org](http://www.eclipse.org/articles/Article-Launch-Framework/launch.html "The Launching Framework") and have managed t... | I had to add `contextualLaunch` under `org.eclipse.debug.ui.launchShortcuts`.
The old way seems like it's deprecated a long ago.
For other people who are working on the same subject,
you might want to extend `org.eclipse.ui.commands` and bindings, too.
I cannot choose this answer but this is the answer that I (the q... |
26,151 | <p>C++ 0x has template aliases (sometimes referred to as template typedefs). See <a href="http://en.wikipedia.org/wiki/C%2B%2B0x#Alias_templates" rel="noreferrer">here</a>. Current spec of C++ does not. </p>
<p>What do you like to use as work around ? Container objects or Macros ?
Do you feel its worth it ?</p>
| [
{
"answer_id": 26162,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 8,
"selected": true,
"text": "<blockquote>\n <p>What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?</p... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759/"
] | C++ 0x has template aliases (sometimes referred to as template typedefs). See [here](http://en.wikipedia.org/wiki/C%2B%2B0x#Alias_templates). Current spec of C++ does not.
What do you like to use as work around ? Container objects or Macros ?
Do you feel its worth it ? | >
> What do you like to use as work around ? Container objects or Macros ? Do you feel its worth it ?
>
>
>
The canonical way is to use a metafunction like thus:
```
template <typename T>
struct my_string_map {
typedef std::map<std::string, T> type;
};
// Invoke:
my_string_map<int>::type my_str_int_map;
``... |
26,196 | <p>I am looking for a very fast way to filter down a collection in C#. I am currently using generic <code>List<object></code> collections, but am open to using other structures if they perform better.</p>
<p>Currently, I am just creating a new <code>List<object></code> and looping thru the original list. ... | [
{
"answer_id": 26203,
"author": "Jorge Córdoba",
"author_id": 2695,
"author_profile": "https://Stackoverflow.com/users/2695",
"pm_score": 9,
"selected": true,
"text": "<p>If you're using C# 3.0 you can use linq, which is way better and way more elegant:</p>\n<pre class=\"lang-c# prettypr... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2470/"
] | I am looking for a very fast way to filter down a collection in C#. I am currently using generic `List<object>` collections, but am open to using other structures if they perform better.
Currently, I am just creating a new `List<object>` and looping thru the original list. If the filtering criteria matches, I put a co... | If you're using C# 3.0 you can use linq, which is way better and way more elegant:
```c#
List<int> myList = GetListOfIntsFromSomewhere();
// This will filter ints that are not > 7 out of the list; Where returns an
// IEnumerable<T>, so call ToList to convert back to a List<T>.
List<int> filteredList = myList.Where(x ... |
26,233 | <p>Given a URL, what would be the most efficient code to download the contents of that web page? I am only considering the HTML, not associated images, JS and CSS.</p>
| [
{
"answer_id": 26237,
"author": "Chris",
"author_id": 2134,
"author_profile": "https://Stackoverflow.com/users/2134",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.net.webclient%28VS.80%29.aspx\" rel=\"noreferrer\">System.Net.WebCl... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2141/"
] | Given a URL, what would be the most efficient code to download the contents of that web page? I am only considering the HTML, not associated images, JS and CSS. | ```
public static void DownloadFile(string remoteFilename, string localFilename)
{
WebClient client = new WebClient();
client.DownloadFile(remoteFilename, localFilename);
}
``` |
26,305 | <p>I want to be able to play sound files in my program. Where should I look?</p>
| [
{
"answer_id": 26311,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 4,
"selected": false,
"text": "<p>A bad example:</p>\n\n<pre><code>import sun.audio.*; //import the sun.audio package\nimport java.io.*;\n\n//** add t... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] | I want to be able to play sound files in my program. Where should I look? | I wrote the following code that works fine. But I think it only works with `.wav` format.
```
public static synchronized void playSound(final String url) {
new Thread(new Runnable() {
// The wrapper thread is unnecessary, unless it blocks on the
// Clip finishing; see comments.
public void run() {
try ... |
26,323 | <p>C#: What is a good Regex to parse hyperlinks and their description?</p>
<p>Please consider case insensitivity, white-space and use of single quotes (instead of double quotes) around the HREF tag.</p>
<p>Please also consider obtaining hyperlinks which have other tags within the <code><a></code> tags such as <... | [
{
"answer_id": 26328,
"author": "Teifion",
"author_id": 1384652,
"author_profile": "https://Stackoverflow.com/users/1384652",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://regexlib.com/RETester.aspx?regexp_id=968\" rel=\"nofollow noreferrer\">I found this</a> but apparen... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2141/"
] | C#: What is a good Regex to parse hyperlinks and their description?
Please consider case insensitivity, white-space and use of single quotes (instead of double quotes) around the HREF tag.
Please also consider obtaining hyperlinks which have other tags within the `<a>` tags such as `<b>` and `<i>`.
... | As long as there are no nested tags (and no line breaks), the following variant works well:
```
<a\s+href=(?:"([^"]+)"|'([^']+)').*?>(.*?)</a>
```
As soon as nested tags come into play, regular expressions are unfit for parsing. However, you can still use them by applying more advanced features of modern interpreter... |
26,354 | <p>Does anyone know how to print a barcode to the Intermec PB20 bluetooth printer from a Windows Compact Framework application? We are currently using the Intermec LinePrinter API but have been unable to find a way to print a barcode.
</p>
| [
{
"answer_id": 26356,
"author": "Martin Marconcini",
"author_id": 2684,
"author_profile": "https://Stackoverflow.com/users/2684",
"pm_score": 0,
"selected": false,
"text": "<p>Last time I had to print Barcode (despite the printer or framework) I resorted to use a True Type font with the ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/620435/"
] | Does anyone know how to print a barcode to the Intermec PB20 bluetooth printer from a Windows Compact Framework application? We are currently using the Intermec LinePrinter API but have been unable to find a way to print a barcode.
| Thank you all for your thoughts. Printing directly to the serial port is likely the most flexible method. In this case we didn't want to replicate all of the work that was already built into the Intermec dll for handling the port, printer errors, etc. We were able to get this working by sending the printer the appropri... |
26,362 | <p>Has anyone managed to use <code>ItemizedOverlays</code> in Android Beta 0.9? I can't get it to work, but I'm not sure if I've done something wrong or if this functionality isn't yet available. </p>
<p>I've been trying to use the <code>ItemizedOverlay</code> and <code>OverlayItem</code> classes. Their intended purpo... | [
{
"answer_id": 46766,
"author": "eon",
"author_id": 2000,
"author_profile": "https://Stackoverflow.com/users/2000",
"pm_score": 7,
"selected": true,
"text": "<p>For the sake of completeness I'll repeat the discussion on Reto's post over at the <a href=\"http://groups.google.com/group/and... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/822/"
] | Has anyone managed to use `ItemizedOverlays` in Android Beta 0.9? I can't get it to work, but I'm not sure if I've done something wrong or if this functionality isn't yet available.
I've been trying to use the `ItemizedOverlay` and `OverlayItem` classes. Their intended purpose is to simulate map markers (as seen in G... | For the sake of completeness I'll repeat the discussion on Reto's post over at the [Android Groups here](http://groups.google.com/group/android-developers/browse_thread/thread/36fe0648dabfe745#).
It seems that if you set the bounds on your drawable it does the trick:
```
Drawable defaultMarker = r.getDrawable(R.drawa... |
26,366 | <p>For the past 10 years or so there have been a smattering of articles and papers referencing Christopher Alexander's newer work "The Nature of Order" and how it can be applied to software.</p>
<p>Unfortunately, the only works I can find are from James Coplien and Richard Gabriel; there is nothing beyond that, at lea... | [
{
"answer_id": 46766,
"author": "eon",
"author_id": 2000,
"author_profile": "https://Stackoverflow.com/users/2000",
"pm_score": 7,
"selected": true,
"text": "<p>For the sake of completeness I'll repeat the discussion on Reto's post over at the <a href=\"http://groups.google.com/group/and... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1799/"
] | For the past 10 years or so there have been a smattering of articles and papers referencing Christopher Alexander's newer work "The Nature of Order" and how it can be applied to software.
Unfortunately, the only works I can find are from James Coplien and Richard Gabriel; there is nothing beyond that, at least from my... | For the sake of completeness I'll repeat the discussion on Reto's post over at the [Android Groups here](http://groups.google.com/group/android-developers/browse_thread/thread/36fe0648dabfe745#).
It seems that if you set the bounds on your drawable it does the trick:
```
Drawable defaultMarker = r.getDrawable(R.drawa... |
26,369 | <p>I have a .NET 2.0 Windows Forms application. Where is the best place the store user settings (considering Windows guidelines)?</p>
<p>Some people pointed to <code>Application.LocalUserAppDataPath</code>. However, that creates a folder structure like:</p>
<blockquote>
<p>C:\Documents and Settings\user_name\Local ... | [
{
"answer_id": 26377,
"author": "LeoD",
"author_id": 2868,
"author_profile": "https://Stackoverflow.com/users/2868",
"pm_score": 0,
"selected": false,
"text": "<p>Settings are standard key-value pairs (string-string). I could wrap them in an XML file, if that helps.</p>\n\n<p>I'd rather ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2868/"
] | I have a .NET 2.0 Windows Forms application. Where is the best place the store user settings (considering Windows guidelines)?
Some people pointed to `Application.LocalUserAppDataPath`. However, that creates a folder structure like:
>
> C:\Documents and Settings\user\_name\Local Settings\Application
> Data\company\... | I love using the built-in [Application Settings](http://msdn.microsoft.com/en-us/library/a65txexh.aspx). Then you have built in support for using the settings designer if you want at design-time, or at runtime to use:
```
// read setting
string setting1 = (string)Settings.Default["MySetting1"];
// save setting
Settin... |
26,383 | <p>I know two approaches to Exception handling, lets have a look at them.</p>
<ol>
<li><p>Contract approach.</p>
<p>When a method does not do what it says it will do in the method header, it will throw an exception. Thus the method "promises" that it will do the operation, and if it fails for some reason, it ... | [
{
"answer_id": 26395,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that if you are building a class which will be used by an external program (or will be reused by other programs) t... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know two approaches to Exception handling, lets have a look at them.
1. Contract approach.
When a method does not do what it says it will do in the method header, it will throw an exception. Thus the method "promises" that it will do the operation, and if it fails for some reason, it will throw an exception.
2. Exc... | I favor what you call the "contract" approach. Returning nulls or other special values to indicate errors isn't necessary in a language that supports exceptions. I find it much easier to understand code when it doesn't have a bunch of "if (result == NULL)" or "if (result == -1)" clauses mixed in with what could be very... |
26,393 | <p>I've seen news of <a href="http://github.com/jeresig/sizzle/tree/master" rel="noreferrer">John Resig's fast new selector engine named Sizzle</a> pop up in quite a few places, but I don't know what a selector engine is, nor have any of the articles given an explanation of what it is. I know Resig is the creator of j... | [
{
"answer_id": 26411,
"author": "Dave Ward",
"author_id": 60,
"author_profile": "https://Stackoverflow.com/users/60",
"pm_score": 7,
"selected": true,
"text": "<p>A selector engine is used to query a page's DOM for particular elements, based on some sort of query (usually CSS syntax or s... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1266/"
] | I've seen news of [John Resig's fast new selector engine named Sizzle](http://github.com/jeresig/sizzle/tree/master) pop up in quite a few places, but I don't know what a selector engine is, nor have any of the articles given an explanation of what it is. I know Resig is the creator of jQuery, and that Sizzle is someth... | A selector engine is used to query a page's DOM for particular elements, based on some sort of query (usually CSS syntax or similar).
For example, this jQuery:
```
$('div')
```
Would search for and return all of the <div> elements on the page. It uses jQuery's selector engine to do that.
Optimizing the selector e... |
26,433 | <p>Say I have three files (template_*.txt):</p>
<ul>
<li>template_x.txt</li>
<li>template_y.txt</li>
<li>template_z.txt</li>
</ul>
<p>I want to copy them to three new files (foo_*.txt). </p>
<ul>
<li>foo_x.txt </li>
<li>foo_y.txt </li>
<li>foo_z.txt</li>
</ul>
<p>Is there some simple way to do that with one command... | [
{
"answer_id": 26439,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know of anything in bash or on cp, but there are simple ways to do this sort of thing using (for example) a p... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/437/"
] | Say I have three files (template\_\*.txt):
* template\_x.txt
* template\_y.txt
* template\_z.txt
I want to copy them to three new files (foo\_\*.txt).
* foo\_x.txt
* foo\_y.txt
* foo\_z.txt
Is there some simple way to do that with one command, e.g.
`cp --enableAwesomeness template_*.txt foo_*.txt` | ```
for f in template_*.txt; do cp $f foo_${f#template_}; done
``` |
26,450 | <p>Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?</p>
<ul>
<li>Doing <code>session.contains(obj)</code> seems to only return true if the session contains that exact object, not another object with the same ID.</li>
<li>Using <code>merge(o... | [
{
"answer_id": 26468,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried calling .SaveOrUpdateCopy()? \nIt should work in all instances, if there is an entity by the same id in... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2875/"
] | Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?
* Doing `session.contains(obj)` seems to only return true if the session contains that exact object, not another object with the same ID.
* Using `merge(obj)` throws an exception if the objec... | Have you tried calling .SaveOrUpdateCopy()?
It should work in all instances, if there is an entity by the same id in the session or if there is no entity at all. This is basically the catch-all method, as it converts a transient object into a persistent one (Save), updates the object if it is existing (Update) or even... |
26,455 | <p>Do you use Design by Contract professionally? Is it something you have to do from the beginning of a project, or can you change gears and start to incorporate it into your software development lifecycle? What have you found to be the pros/cons of the design approach?</p>
<p>I came across the <a href="http://en.wiki... | [
{
"answer_id": 26484,
"author": "James A. Rosen",
"author_id": 1190,
"author_profile": "https://Stackoverflow.com/users/1190",
"pm_score": 5,
"selected": true,
"text": "<p>I can't recommend it highly enough. It's particularly nice if you have a suite that takes inline documentation cont... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Do you use Design by Contract professionally? Is it something you have to do from the beginning of a project, or can you change gears and start to incorporate it into your software development lifecycle? What have you found to be the pros/cons of the design approach?
I came across the [Design by Contract](http://en.wi... | I can't recommend it highly enough. It's particularly nice if you have a suite that takes inline documentation contract specifications, like so:
```
// @returns null iff x = 0
public foo(int x) {
...
}
```
and turns them into generated unit tests, like so:
```
public test_foo_returns_null_iff_x_equals_0() {
ass... |
26,478 | <p>I'm having trouble getting the following to work in SQL Server 2k, but it works in 2k5:</p>
<pre><code>--works in 2k5, not in 2k
create view foo as
SELECT usertable.legacyCSVVarcharCol as testvar
FROM usertable
WHERE rsrcID in
( select val
from
dbo.fnSplitStringToInt(usertable... | [
{
"answer_id": 26577,
"author": "wcm",
"author_id": 2173,
"author_profile": "https://Stackoverflow.com/users/2173",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think functions can have default values in functions in SS2K.</p>\n\n<p>What happens when you run this SQL in SS2K?</p... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2327/"
] | I'm having trouble getting the following to work in SQL Server 2k, but it works in 2k5:
```
--works in 2k5, not in 2k
create view foo as
SELECT usertable.legacyCSVVarcharCol as testvar
FROM usertable
WHERE rsrcID in
( select val
from
dbo.fnSplitStringToInt(usertable.legacyCSVVarc... | Passing column-values to a table-valued user-defined function is not supported in SQL Server 2000, you can only use constants, so the following (simpler version) would also fail:
```
SELECT *, (SELECT TOP 1 val FROM dbo.fnSplitStringToInt(usertable.legacyCSVVarcharCol, ','))
FROM usertable
```
It will work on SQL Se... |
26,512 | <p>I have a ComboBox that I bind to a standard HTTPService, I would like to add an event listener so that I can run some code after the ComboBox is populated from the data provider.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 26553,
"author": "Theo",
"author_id": 1109,
"author_profile": "https://Stackoverflow.com/users/1109",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>BindingUtils</code> to get notified when the <code>dataProvider</code> property of the combo box changes:</... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a ComboBox that I bind to a standard HTTPService, I would like to add an event listener so that I can run some code after the ComboBox is populated from the data provider.
How can I do this? | Flex doesn't have a specific data-binding events in the way that say ASP .Net does. You have to watch for the dataProvider property like John says in the first answer, but not simply to the combobox or its dataProvider property. Let's say you have a setup like this:
```
<!-- Assume you have extracted an XMLList out of... |
26,515 | <p>I have a habit of keeping my variable usage to a bare minimum. So I'm wondering if there is any advantage to be gained by the following:</p>
<pre><code>$query = $mysqli->query('SELECT * FROM `people` ORDER BY `name` ASC LIMIT 0,30');
// Example 1
$query = $query->fetch_assoc();
// Example 2
$query_r = $que... | [
{
"answer_id": 26537,
"author": "Brian Warshaw",
"author_id": 1344,
"author_profile": "https://Stackoverflow.com/users/1344",
"pm_score": 4,
"selected": true,
"text": "<p>The <a href=\"http://us2.php.net/manual/en/mysqli-result.free.php\" rel=\"noreferrer\">manual</a> seems to suggest th... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | I have a habit of keeping my variable usage to a bare minimum. So I'm wondering if there is any advantage to be gained by the following:
```
$query = $mysqli->query('SELECT * FROM `people` ORDER BY `name` ASC LIMIT 0,30');
// Example 1
$query = $query->fetch_assoc();
// Example 2
$query_r = $query->fetch_assoc();
$q... | The [manual](http://us2.php.net/manual/en/mysqli-result.free.php) seems to suggest that you should still be using `free()` to release the memory. I believe the reasoning is that `free()` is freeing the memory in *MySQL*, not in PHP. Since PHP can't garbage-collect for MySQL, you need to call `free()`. |
26,522 | <p>Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:</p>
<pre><code>[0, 0, 0] = 2
[0, 0, 1] = 32
</code></pre>
<p>And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a bui... | [
{
"answer_id": 26546,
"author": "Gabriël",
"author_id": 2104,
"author_profile": "https://Stackoverflow.com/users/2104",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://forums.msdn.microsoft.com/en-US/csharplanguage/thread/2ca85aa4-0672-40ad-b780-e181b28fcd80/\" rel=\"nofol... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/632/"
] | Let's say I have a .NET Array of n number of dimensions. I would like to foreach through the elements and print out something like:
```
[0, 0, 0] = 2
[0, 0, 1] = 32
```
And so on. I could write a loop using some the Rank and dimension functions to come up with the indices. Is there a built in function instead? | Thanks for the answer, here is what I wrote while I waited:
```
public static string Format(Array array)
{
var builder = new StringBuilder();
builder.AppendLine("Count: " + array.Length);
var counter = 0;
var dimensions = new List<int>();
for (int i = 0; i < array.Rank; i++)
{
dimensio... |
26,547 | <p>Let's say that you want to create a dead simple BlogEditor and, one of your ideas, is to do what Live Writer does and ask only the URL of the persons Blog. How can you detect what type of blog is it?</p>
<p>Basic detection can be done with the URL itself, such as “<a href="http://myblog.blogger.com" rel="nofollow n... | [
{
"answer_id": 26579,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 1,
"selected": false,
"text": "<p>Some blogs provide a Generator meta tag - e.g. Wordpress - you could find out if there's any exceptions to this.</p>\n\n<p>Yo... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] | Let's say that you want to create a dead simple BlogEditor and, one of your ideas, is to do what Live Writer does and ask only the URL of the persons Blog. How can you detect what type of blog is it?
Basic detection can be done with the URL itself, such as “<http://myblog.blogger.com>” etc. But what if it's self hoste... | Many (most?) blogs will have a meta tag for "generator" which will list the blog engine. For example a blogger blog will contain the following meta tag:
```
<meta name="generator" content="Blogger" />
```
My Subtext blog shows the following generator meta tag:
```
<meta name="Generator" content="Subtext Version... |
26,551 | <p>I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file.</p>
<p>Here's what the command line looks like:</p>
<pre><code>test.cmd admin P@55w0rd > test-log.txt
</code></pre>
| [
{
"answer_id": 26556,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 6,
"selected": false,
"text": "<p>Yep, and just don't forget to use variables like <code>%%1</code> when using <code>if</code> and <code>for</code> and ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file.
Here's what the command line looks like:
```
test.cmd admin P@55w0rd > test-log.txt
``` | Here's how I did it:
```
@fake-command /u %1 /p %2
```
Here's what the command looks like:
```
test.cmd admin P@55w0rd > test-log.txt
```
The `%1` applies to the first parameter the `%2` (and here's the tricky part) applies to the second. You can have up to 9 parameters passed in this way. |
26,567 | <p>I have a report with many fields that I'm trying to get down to 1 page horizontally (I don't care whether it's 2 or 200 pages vertically... just don't want to have to deal with 2 pages wide by x pages long train-wreck). That said, it deals with contact information.</p>
<p>My idea was to do:</p>
<pre><code>Name: ... | [
{
"answer_id": 26953,
"author": "Sean Carpenter",
"author_id": 729,
"author_profile": "https://Stackoverflow.com/users/729",
"pm_score": 2,
"selected": false,
"text": "<p>I believe you need to set the CanGrow property to <strong>true</strong> on the Textbox. See <a href=\"http://msdn.mi... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2156/"
] | I have a report with many fields that I'm trying to get down to 1 page horizontally (I don't care whether it's 2 or 200 pages vertically... just don't want to have to deal with 2 pages wide by x pages long train-wreck). That said, it deals with contact information.
My idea was to do:
```
Name: Address: City: ... | Alter the report's text box to:
```
= Fields!Addr1.Value + VbCrLf +
Fields!Addr2.Value + VbCrLf +
Fields!Addr3.Value
``` |
26,595 | <p>Is there any difference between:</p>
<pre><code>if foo is None: pass
</code></pre>
<p>and</p>
<pre><code>if foo == None: pass
</code></pre>
<p>The convention that I've seen in most Python code (and the code I myself write) is the former, but I recently came across code which uses the latter. None is an instance... | [
{
"answer_id": 26611,
"author": "Brendan",
"author_id": 199,
"author_profile": "https://Stackoverflow.com/users/199",
"pm_score": 9,
"selected": true,
"text": "<p><code>is</code> always returns <code>True</code> if it compares the same object instance</p>\n\n<p>Whereas <code>==</code> is... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/156/"
] | Is there any difference between:
```
if foo is None: pass
```
and
```
if foo == None: pass
```
The convention that I've seen in most Python code (and the code I myself write) is the former, but I recently came across code which uses the latter. None is an instance (and the only instance, IIRC) of NoneType, so it ... | `is` always returns `True` if it compares the same object instance
Whereas `==` is ultimately determined by the `__eq__()` method
i.e.
```
>>> class Foo(object):
def __eq__(self, other):
return True
>>> f = Foo()
>>> f == None
True
>>> f is None
False
``` |
26,620 | <p>In my web app, I submit some form fields with jQuery's <code>$.getJSON()</code> method. I am having some problems with the encoding. The character-set of my app is <code>charset=ISO-8859-1</code>, but I think these fields are submitted with <code>UTF-8</code>. </p>
<p>How I can set encoding used in <code>$.getJSON<... | [
{
"answer_id": 26681,
"author": "travis",
"author_id": 1414,
"author_profile": "https://Stackoverflow.com/users/1414",
"pm_score": 6,
"selected": true,
"text": "<p>I think that you'll probably have to use <a href=\"http://docs.jquery.com/Ajax/jQuery.ajax#options\" rel=\"noreferrer\"><cod... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | In my web app, I submit some form fields with jQuery's `$.getJSON()` method. I am having some problems with the encoding. The character-set of my app is `charset=ISO-8859-1`, but I think these fields are submitted with `UTF-8`.
How I can set encoding used in `$.getJSON` calls? | I think that you'll probably have to use [`$.ajax()`](http://docs.jquery.com/Ajax/jQuery.ajax#options) if you want to change the encoding, see the `contentType` param below (the `success` and `error` callbacks assume you have `<div id="success"></div>` and `<div id="error"></div>` in the html):
```
$.ajax({
type: ... |
26,652 | <p>Is there a way to make a TSQL variable constant?</p>
| [
{
"answer_id": 26655,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 0,
"selected": false,
"text": "<p>There are no such thing as \"creating a constant\" in database literature. Constants exist as they are and often called v... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1874/"
] | Is there a way to make a TSQL variable constant? | No, but you can create a function and hardcode it in there and use that.
Here is an example:
```
CREATE FUNCTION fnConstant()
RETURNS INT
AS
BEGIN
RETURN 2
END
GO
SELECT dbo.fnConstant()
``` |
26,670 | <p>I'm creating PDFs on-demand with ColdFusion's <a href="http://cfquickdocs.com/cf8/?getDoc=cfdocument" rel="nofollow noreferrer">CFDocument</a> tag, like so:</p>
<pre><code><cfdocument format="PDF" filename="#attributes.fileName#" overwrite="true">
<cfdocumentitem type="footer">
<table bor... | [
{
"answer_id": 30688,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 3,
"selected": true,
"text": "<p>A PDF is what I'm after, so I'm not sure how outputting another format would help.</p>\n\n<p>As it turns out, the footer ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751/"
] | I'm creating PDFs on-demand with ColdFusion's [CFDocument](http://cfquickdocs.com/cf8/?getDoc=cfdocument) tag, like so:
```
<cfdocument format="PDF" filename="#attributes.fileName#" overwrite="true">
<cfdocumentitem type="footer">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
... | A PDF is what I'm after, so I'm not sure how outputting another format would help.
As it turns out, the footer space just wasn't enough to fit all of this text; verified by the fact that changing the font size to 4pt would fit it all in without a problem.
I spent some time attempting to rewrite the footer code using ... |
26,715 | <p>How does the new Microsoft asp.net mvc implementation handle partitioning your application - for example:</p>
<pre><code>--index.aspx
--about.aspx
--contact.aspx
--/feature1
--/feature1/subfeature/action
--/feature2/subfeature/action
</code></pre>
<p>I guess what I am trying to say is that it seems everything has ... | [
{
"answer_id": 26741,
"author": "Dale Ragan",
"author_id": 1117,
"author_profile": "https://Stackoverflow.com/users/1117",
"pm_score": 5,
"selected": true,
"text": "<p>There isn't any issues with organizing your controllers. You just need to setup the routes to take the organization int... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2041/"
] | How does the new Microsoft asp.net mvc implementation handle partitioning your application - for example:
```
--index.aspx
--about.aspx
--contact.aspx
--/feature1
--/feature1/subfeature/action
--/feature2/subfeature/action
```
I guess what I am trying to say is that it seems everything has to go into the root of the... | There isn't any issues with organizing your controllers. You just need to setup the routes to take the organization into consideration. The problem you will run into is finding the view for the controller, since you changed the convention. There isn't any built in functionality for it yet, but it is easy to create a wo... |
26,721 | <p>When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations where, for example, a vertical scrollbar pops up, overlapping the control's content, causing a horizontal scrollbar to also be needed. Ideally the content would shrink just a bit to make room for the vertical scro... | [
{
"answer_id": 26782,
"author": "Bryan Roth",
"author_id": 299,
"author_profile": "https://Stackoverflow.com/users/299",
"pm_score": 0,
"selected": false,
"text": "<p>If your controls are inside a panel, try setting the AutoScroll property of the Panel to False. This will hide the scrol... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2729/"
] | When creating scrollable user controls with .NET and WinForms I have repeatedly encountered situations where, for example, a vertical scrollbar pops up, overlapping the control's content, causing a horizontal scrollbar to also be needed. Ideally the content would shrink just a bit to make room for the vertical scrollba... | You will need your controls to resize slightly to accommodate the width of the vertical scroll bar. One way to achieve this achieved through docking. Rather than just dropping controls on the form, you'll have to play a bit with panels, padding, min/max sizing and docking.
Here is example code you can place behind a b... |
26,732 | <pre><code><servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>workflow.WDispatcher</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern&... | [
{
"answer_id": 26744,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 8,
"selected": true,
"text": "<pre><code><url-pattern>*NEXTEVENT*</url-pattern>\n</code></pre>\n\n<p>The URL pattern is not valid. It can either ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>workflow.WDispatcher</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>*NEXTEVENT*</url-pattern>
</servlet-mapping>
```
Above is the snippet from... | ```
<url-pattern>*NEXTEVENT*</url-pattern>
```
The URL pattern is not valid. It can either end in an asterisk or start with one (to denote a file extension mapping).
The url-pattern specification:
>
> * A string beginning with a ‘/’ character and ending with a ‘/\*’
> suffix is used for path mapping.
> * A string... |
26,733 | <p>Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations?</p>
<p>This is what I want to re-write:</p>
<pre><code>foreach (Type t in this.GetType().Assembly.GetTypes())
if (t is IMyInterface)
; //do stuff
</code></pre>
| [
{
"answer_id": 26745,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": false,
"text": "<p>loop through all loaded assemblies, loop through all their types, and check if they implement the interface.</p>\n\... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] | Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations?
This is what I want to re-write:
```
foreach (Type t in this.GetType().Assembly.GetTypes())
if (t is IMyInterface)
; //do stuff
``` | Mine would be this in c# 3.0 :)
```
var type = typeof(IMyInterface);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
```
Basically, the least amount of iterations will always be:
```
loop assemblies
loop types
see if implemente... |
26,743 | <p>I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the... | [
{
"answer_id": 6421794,
"author": "Simon Mourier",
"author_id": 403671,
"author_profile": "https://Stackoverflow.com/users/403671",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure this is what you're looking for, but you can use this kind of code when you start writing to the ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2892/"
] | I use .NET XML technologies quite extensively on my work. One of the things the I like very much is the XSLT engine, more precisely the extensibility of it. However there one little piece which keeps being a source of annoyance. Nothing major or something we can't live with but it is preventing us from producing the be... | Use this code:
```cs
using (var writer = XmlWriter.Create("file.xml"))
{
const string Ns = "http://bladibla";
const string Prefix = "abx";
writer.WriteStartDocument();
writer.WriteStartElement("root");
// set root namespace
writer.WriteAttributeString("xmlns", Prefix, null, Ns);
writer.... |
26,760 | <p>I have some strings of xxh:yym format where xx is hours and yy is minutes like "05h:30m". What is an elegant way to convert a string of this type to TimeSpan?</p>
| [
{
"answer_id": 26769,
"author": "Lars Mæhlum",
"author_id": 960,
"author_profile": "https://Stackoverflow.com/users/960",
"pm_score": 6,
"selected": true,
"text": "<p>This seems to work, though it is a bit hackish:</p>\n\n<pre><code>TimeSpan span;\n\n\nif (TimeSpan.TryParse(\"05h:30m\".R... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | I have some strings of xxh:yym format where xx is hours and yy is minutes like "05h:30m". What is an elegant way to convert a string of this type to TimeSpan? | This seems to work, though it is a bit hackish:
```
TimeSpan span;
if (TimeSpan.TryParse("05h:30m".Replace("m","").Replace("h",""), out span))
MessageBox.Show(span.ToString());
``` |
26,795 | <p>I have an extender (IExtenderProvider) which extends certain types of
controls with additional properties. For one of these properties, I have
written a UITypeEditor. So far, all works just fine.</p>
<p>The extender also has a couple of properties itself, which I am trying to
use as a sort of default for the UIT... | [
{
"answer_id": 30275,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 0,
"selected": false,
"text": "<p>Have you considered adding the DefaultValue as a static property of the ExtenderProvider, then you can access it without... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2899/"
] | I have an extender (IExtenderProvider) which extends certain types of
controls with additional properties. For one of these properties, I have
written a UITypeEditor. So far, all works just fine.
The extender also has a couple of properties itself, which I am trying to
use as a sort of default for the UITypeEditor.... | Could you read the attribute yourself?
```
DefaultValueAttribute att = context.
PropertyDescriptor.Attributes.
OfType<DefaultValueAttribute>().
FirstOrDefault();
object myDefault = null;
if ( att != null )
myDefault = att.Value;
```
I've used Linq to simplify the code, but you could do something simi... |
26,796 | <p>What is the best way to use ResolveUrl() in a Shared/static function in Asp.Net? My current solution for VB.Net is:</p>
<pre><code>Dim x As New System.Web.UI.Control
x.ResolveUrl("~/someUrl")
</code></pre>
<p>Or C#:</p>
<pre><code>System.Web.UI.Control x = new System.Web.UI.Control();
x.ResolveUrl("~/someUrl");
<... | [
{
"answer_id": 26807,
"author": "Dave Ward",
"author_id": 60,
"author_profile": "https://Stackoverflow.com/users/60",
"pm_score": 7,
"selected": true,
"text": "<p>I use <a href=\"http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx\" rel=\"noreferrer\">System.Web.Vi... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] | What is the best way to use ResolveUrl() in a Shared/static function in Asp.Net? My current solution for VB.Net is:
```
Dim x As New System.Web.UI.Control
x.ResolveUrl("~/someUrl")
```
Or C#:
```
System.Web.UI.Control x = new System.Web.UI.Control();
x.ResolveUrl("~/someUrl");
```
But I realize that isn't the bes... | I use [System.Web.VirtualPathUtility.ToAbsolute](http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx). |
26,800 | <p>I'm using XPath in .NET to parse an XML document, along the lines of:</p>
<pre class="lang-cs prettyprint-override"><code>XmlNodeList lotsOStuff = doc.SelectNodes("//stuff");
foreach (XmlNode stuff in lotsOStuff) {
XmlNode stuffChild = stuff.SelectSingleNode("//stuffChild");
// ... etc
}
</code></pre>
<p>Th... | [
{
"answer_id": 26805,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 4,
"selected": true,
"text": "<p><code>//</code> at the beginning of an XPath expression starts from the document root. Try \".//stuffChild\". . i... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm using XPath in .NET to parse an XML document, along the lines of:
```cs
XmlNodeList lotsOStuff = doc.SelectNodes("//stuff");
foreach (XmlNode stuff in lotsOStuff) {
XmlNode stuffChild = stuff.SelectSingleNode("//stuffChild");
// ... etc
}
```
The issue is that the XPath Query for `stuffChild` is always re... | `//` at the beginning of an XPath expression starts from the document root. Try ".//stuffChild". . is shorthand for self::node(), which will set the context for the search, and // is shorthand for the descendant axis.
So you have:
```
XmlNode stuffChild = stuff.SelectSingleNode(".//stuffChild");
```
which translate... |
26,809 | <p>I frequently have problems dealing with <code>DataRows</code> returned from <code>SqlDataAdapters</code>. When I try to fill in an object using code like this:</p>
<pre><code>DataRow row = ds.Tables[0].Rows[0];
string value = (string)row;
</code></pre>
<p>What is the best way to deal with <code>DBNull's</code> in ... | [
{
"answer_id": 26832,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 6,
"selected": true,
"text": "<p>Nullable types are good, but only for types that are not nullable to begin with.</p>\n\n<p>To make a type \"nullable\" ap... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2191/"
] | I frequently have problems dealing with `DataRows` returned from `SqlDataAdapters`. When I try to fill in an object using code like this:
```
DataRow row = ds.Tables[0].Rows[0];
string value = (string)row;
```
What is the best way to deal with `DBNull's` in this type of situation. | Nullable types are good, but only for types that are not nullable to begin with.
To make a type "nullable" append a question mark to the type, for example:
```
int? value = 5;
```
I would also recommend using the "`as`" keyword instead of casting. You can only use the "as" keyword on nullable types, so make sure y... |
26,825 | <p>I have a CollapsiblePanelExtender that will not collapse. I have "collapsed" set to true and all the ControlID set correctly. I try to collapse and it goes through the animation but then expands almost instantly. This is in an User Control with the following structure.</p>
<pre><code><asp:UpdatePanel ID="Upda... | [
{
"answer_id": 26912,
"author": "Ian Patrick Hughes",
"author_id": 2213,
"author_profile": "https://Stackoverflow.com/users/2213",
"pm_score": 3,
"selected": true,
"text": "<p>I am sorry I do not have time to trouble-shoot your code, so this is from the hip.</p>\n\n<p>There is a good cha... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2894/"
] | I have a CollapsiblePanelExtender that will not collapse. I have "collapsed" set to true and all the ControlID set correctly. I try to collapse and it goes through the animation but then expands almost instantly. This is in an User Control with the following structure.
```
<asp:UpdatePanel ID="UpdatePanel1" runat="ser... | I am sorry I do not have time to trouble-shoot your code, so this is from the hip.
There is a good chance that this a client-side action that is failing. Make certain that your page has the correct doctype tag if you took it out of your page or masterPage. Furthermore, attempt to set the ClientState as well:
DDE.Clie... |
26,842 | <p>I'm attempting to use an existing CAS server to authenticate login for a Perl CGI web script and am using the <a href="http://search.cpan.org/dist/AuthCAS" rel="nofollow noreferrer">AuthCAS</a> Perl module (v 1.3.1). I can connect to the CAS server to get the service ticket but when I try to connect to validate the... | [
{
"answer_id": 27602,
"author": "Cebjyre",
"author_id": 1612,
"author_profile": "https://Stackoverflow.com/users/1612",
"pm_score": -1,
"selected": false,
"text": "<p>Well, from the <a href=\"http://search.cpan.org/src/OSALAUN/AuthCAS-1.3.1/lib/AuthCAS.pm\" rel=\"nofollow noreferrer\">mo... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/171/"
] | I'm attempting to use an existing CAS server to authenticate login for a Perl CGI web script and am using the [AuthCAS](http://search.cpan.org/dist/AuthCAS) Perl module (v 1.3.1). I can connect to the CAS server to get the service ticket but when I try to connect to validate the ticket my script returns with the follow... | As usually happens when I post questions like this, I found the problem. It turns out the [Crypt::SSLeay](http://search.cpan.org/dist/Crypt-SSLeay) module was not installed or at least not up to date. Of course the error messages didn't give me any clues. Updating it and all the problems go away and things are working ... |
26,855 | <p>I'm currently using the module <code>URI::URL</code> to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster?</p>
| [
{
"answer_id": 26894,
"author": "Brendan",
"author_id": 199,
"author_profile": "https://Stackoverflow.com/users/199",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps I got the wrong end of the stick but wouldn't,</p>\n\n<pre><code>$full_url = $base_url . $relative_url</code></pre>\... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2901/"
] | I'm currently using the module `URI::URL` to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster? | The following code should work.
```
$uri = URI->new_abs( $str, $base_uri )
```
You should also take a look at [the URI page on search.cpan.org](http://search.cpan.org/dist/URI/URI.pm). |
26,857 | <p>Using C# and ASP.NET I want to programmatically fill in some values (4 text boxes) on a web page (form) and then 'POST' those values. How do I do this?</p>
<p>Edit: Clarification: There is a service (www.stopforumspam.com) where you can submit ip, username and email address on their 'add' page. I want to be able to... | [
{
"answer_id": 26881,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 7,
"selected": true,
"text": "<p>The code will look something like this: </p>\n\n<pre><code>WebRequest req = WebRequest.Create(\"http://mysite/myform.a... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | Using C# and ASP.NET I want to programmatically fill in some values (4 text boxes) on a web page (form) and then 'POST' those values. How do I do this?
Edit: Clarification: There is a service (www.stopforumspam.com) where you can submit ip, username and email address on their 'add' page. I want to be able to create a ... | The code will look something like this:
```
WebRequest req = WebRequest.Create("http://mysite/myform.aspx");
string postData = "item1=11111&item2=22222&Item3=33333";
byte[] send = Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send... |
26,877 | <p>In C#, what is the difference (if any) between these two lines of code?</p>
<pre><code>tmrMain.Elapsed += new ElapsedEventHandler(tmrMain_Tick);
</code></pre>
<p>and</p>
<pre><code>tmrMain.Elapsed += tmrMain_Tick;
</code></pre>
<p>Both appear to work exactly the same. Does C# just assume you mean the former when... | [
{
"answer_id": 26884,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 6,
"selected": true,
"text": "<p>I did this</p>\n\n<pre><code>static void Hook1()\n{\n someEvent += new EventHandler( Program_someEvent );\n}\n\nstat... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/369/"
] | In C#, what is the difference (if any) between these two lines of code?
```
tmrMain.Elapsed += new ElapsedEventHandler(tmrMain_Tick);
```
and
```
tmrMain.Elapsed += tmrMain_Tick;
```
Both appear to work exactly the same. Does C# just assume you mean the former when you type the latter? | I did this
```
static void Hook1()
{
someEvent += new EventHandler( Program_someEvent );
}
static void Hook2()
{
someEvent += Program_someEvent;
}
```
And then ran ildasm over the code.
The generated MSIL was exactly the same.
So to answer your question, yes they are the same thing.
The compiler is j... |
26,879 | <p>I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother.</p>
<p>However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content n... | [
{
"answer_id": 26891,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "<p>Are you aligning with percentage widths or fixed widths? I'm also guessing you're applying a background to the body - I've ha... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother.
However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content not on the ... | I use
```
html { overflow-y: scroll; }
```
To standardize the scrollbar behavior in IE and FF |
26,882 | <p>My asp.net page will render different controls based on which report a user has selected e.g. some reports require 5 drop downs, some two checkboxes and 6 dropdowns).</p>
<p>They can select a report using two methods. With <code>SelectedReport=MyReport</code> in the query string, or by selecting it from a dropdown.... | [
{
"answer_id": 26902,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>If it's an automatic post when the data changes then you should be able to redirect to the new query string with a server si... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/233/"
] | My asp.net page will render different controls based on which report a user has selected e.g. some reports require 5 drop downs, some two checkboxes and 6 dropdowns).
They can select a report using two methods. With `SelectedReport=MyReport` in the query string, or by selecting it from a dropdown. And it's a common ca... | You need to turn off autopostback on the dropdown - then, you need to hook up some javascript code that will take over that role - in the event handler code for the onchange event for the dropdown, you would create a URL based on the currently-selected value from the dropdown and use javascript to then request that pag... |
26,903 | <p>Is there a way?</p>
<p>I need all types that implement a specific interface to have a parameterless constructor, can it be done?</p>
<p>I am developing the base code for other developers in my company to use in a specific project.</p>
<p>There's a proccess which will create instances of types (in different thread... | [
{
"answer_id": 26909,
"author": "Vaibhav",
"author_id": 380,
"author_profile": "https://Stackoverflow.com/users/380",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think so. </p>\n\n<p>You also can't use an abstract class for this.</p>\n"
},
{
"answer_id": 26928,
"aut... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] | Is there a way?
I need all types that implement a specific interface to have a parameterless constructor, can it be done?
I am developing the base code for other developers in my company to use in a specific project.
There's a proccess which will create instances of types (in different threads) that perform certain ... | [Juan Manuel said:](https://stackoverflow.com/questions/26903/how-can-you-require-a-constructor-with-no-parameters-for-types-implementing-an#27386)
>
> that's one of the reasons I don't understand why it cannot be a part of the contract in the interface
>
>
>
It's an indirect mechanism. The generic allows you to ... |
26,947 | <p>What built-in PHP functions are useful for web scraping? What are some good resources (web or print) for getting up to speed on web scraping with PHP?</p>
| [
{
"answer_id": 26951,
"author": "Peter Stuifzand",
"author_id": 1633,
"author_profile": "https://Stackoverflow.com/users/1633",
"pm_score": -1,
"selected": false,
"text": "<p>The curl library allows you to download web pages. You should look into regular expressions for doing the scrapin... | 2008/08/25 | [
"https://Stackoverflow.com/questions/26947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2052/"
] | What built-in PHP functions are useful for web scraping? What are some good resources (web or print) for getting up to speed on web scraping with PHP? | Scraping generally encompasses 3 steps:
* first you GET or POST your request
to a specified URL
* next you receive
the html that is returned as the
response
* finally you parse out of
that html the text you'd like to
scrape.
To accomplish steps 1 and 2, below is a simple php class which uses Curl to fetch webpag... |
27,020 | <p>I have an Excel Spreadsheet like this</p>
<pre>
id | data for id
| more data for id
id | data for id
id | data for id
| more data for id
| even more data for id
id | data for id
| more data for id
id | data for id
id | data for id
| more data for id
</pre>
<p>Now I want to group the data of one id b... | [
{
"answer_id": 27043,
"author": "Daniel Pollard",
"author_id": 2758,
"author_profile": "https://Stackoverflow.com/users/2758",
"pm_score": 0,
"selected": false,
"text": "<p>If you select the Conditional Formatting menu option under the Format menu item, you will be given a dialog that le... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2798/"
] | I have an Excel Spreadsheet like this
```
id | data for id
| more data for id
id | data for id
id | data for id
| more data for id
| even more data for id
id | data for id
| more data for id
id | data for id
id | data for id
| more data for id
```
Now I want to group the data of one id by alternating... | I think this does what you are looking for. Flips color when the cell in column A changes value. Runs until there is no value in column B.
```
Public Sub HighLightRows()
Dim i As Integer
i = 1
Dim c As Integer
c = 3 'red
Do While (Cells(i, 2) <> "")
If (Cells(i, 1) <> "") Then 'ch... |
27,030 | <p>I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is t... | [
{
"answer_id": 27212,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 7,
"selected": true,
"text": "<p>EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.</p>\... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2176/"
] | I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is the e... | EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.
To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply [serialize the two arrays to JSON](https://github.com/douglascrockford/JSON-js/blob/master/json2.js)... |
27,034 | <p>My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled:</p>
<pre><code>var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
shareProxiesPref.disabled = proxyTypePref.value != 1;
</code></pre>
<p>Isn't it better to do an if on <code>proxyTypePref.val... | [
{
"answer_id": 27039,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>(Incidentally, I also found this form very hard to read in comparison to the normal usage.</p>\n</b... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled:
```
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
shareProxiesPref.disabled = proxyTypePref.value != 1;
```
Isn't it better to do an if on `proxyTypePref.value`, and then declare the var i... | It depends on the context of this code. If it's running on page load, then it would be better to put this code in an if block.
But, if this is part of a validation function, and the field switches between enabled and disabled throughout the life of the page, then this code sort of makes sense.
It's important to remem... |
27,044 | <p>I'm accessing an Ubuntu machine using PuTTY, and using gcc.</p>
<p>The default <code>LANG</code> environment variable on this machine is set to <code>en_NZ.UTF-8</code>, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be.
Maybe it's my font, I don't know - it does this... | [
{
"answer_id": 27051,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": true,
"text": "<p><code>LANG=en_NZ</code> is correct. However, you must make locale files for <code>en_NZ</code>.</p>\n\n<p>For Ubuntu, edit ... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234/"
] | I'm accessing an Ubuntu machine using PuTTY, and using gcc.
The default `LANG` environment variable on this machine is set to `en_NZ.UTF-8`, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be.
Maybe it's my font, I don't know - it does this:
```
foo.c:1: error: expected ... | `LANG=en_NZ` is correct. However, you must make locale files for `en_NZ`.
For Ubuntu, edit `/var/lib/locales/supported.d/local` and add `en_NZ ISO-8859-1` to the file. If your system is another distribution (including Debian), the location will be different. Look at `/usr/sbin/locale-gen` and see where it stores this ... |
27,065 | <p>Do any of you know of a tool that will search for .class files and then display their compiled versions?</p>
<p>I know you can look at them individually in a hex editor but I have a lot of class files to look over (something in my giant application is compiling to Java6 for some reason).</p>
| [
{
"answer_id": 27123,
"author": "McDowell",
"author_id": 304,
"author_profile": "https://Stackoverflow.com/users/304",
"pm_score": 6,
"selected": false,
"text": "<p>It is easy enough to read the <a href=\"http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.1\" rel=\"nore... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] | Do any of you know of a tool that will search for .class files and then display their compiled versions?
I know you can look at them individually in a hex editor but I have a lot of class files to look over (something in my giant application is compiling to Java6 for some reason). | Use the [javap](http://java.sun.com/javase/6/docs/technotes/tools/solaris/javap.html) tool that comes with the JDK. The `-verbose` option will print the version number of the class file.
```
> javap -verbose MyClass
Compiled from "MyClass.java"
public class MyClass
SourceFile: "MyClass.java"
minor version: 0
maj... |
27,071 | <p>I have an old C library with a function that takes a void**:</p>
<pre><code>oldFunction(void** pStuff);
</code></pre>
<p>I'm trying to call this function from managed C++ (m_pStuff is a member of the parent ref class of type void*):</p>
<pre><code>oldFunction( static_cast<sqlite3**>( &m_pStuff ) );
</c... | [
{
"answer_id": 27326,
"author": "Ben Childs",
"author_id": 2925,
"author_profile": "https://Stackoverflow.com/users/2925",
"pm_score": 2,
"selected": true,
"text": "<p>EDIT: Fixed answer, see below.</p>\n\n<p>Really you need to know what oldFunction is going to be doing with pStuff. If p... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39040/"
] | I have an old C library with a function that takes a void\*\*:
```
oldFunction(void** pStuff);
```
I'm trying to call this function from managed C++ (m\_pStuff is a member of the parent ref class of type void\*):
```
oldFunction( static_cast<sqlite3**>( &m_pStuff ) );
```
This gives me the following error from V... | EDIT: Fixed answer, see below.
Really you need to know what oldFunction is going to be doing with pStuff. If pStuff is a pointer to some unmanaged data you can try wrapping the definition of m\_pStuff with:
```
#pragma unmanaged
void* m_pStuff
#pragma managed
```
This will make the pointer unmanaged which can the... |
27,077 | <p>When I do:</p>
<pre><code>$ find /
</code></pre>
<p>It searches the entire system.<br>
How do I prevent that?</p>
<p>(This question comes from an "<a href="https://stackoverflow.com/questions/18836/why-doesnt-find-find-anything#26182">answer</a>" to another question.)</p>
| [
{
"answer_id": 27080,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <strong>-prune</strong> option.</p>\n"
},
{
"answer_id": 27084,
"author": "Jon Ericson",
"auth... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] | When I do:
```
$ find /
```
It searches the entire system.
How do I prevent that?
(This question comes from an "[answer](https://stackoverflow.com/questions/18836/why-doesnt-find-find-anything#26182)" to another question.) | G'day,
Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like:
```
find . \( -type d ! -name . -prune \) -o \( <the bit you want to look for> \)
```
this will stop find from descendi... |
27,078 | <p>I am debugging my ASP.NET application on my Windows XP box with a virtual directory set up in IIS (5.1).</p>
<p>I am also running <strong>VirtualPC</strong> with XP and IE6 for testing purposes. When I connect to my real machine from the virtual machine, I enter the URL: <a href="http://machinename/projectname" rel... | [
{
"answer_id": 27080,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <strong>-prune</strong> option.</p>\n"
},
{
"answer_id": 27084,
"author": "Jon Ericson",
"auth... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417/"
] | I am debugging my ASP.NET application on my Windows XP box with a virtual directory set up in IIS (5.1).
I am also running **VirtualPC** with XP and IE6 for testing purposes. When I connect to my real machine from the virtual machine, I enter the URL: <http://machinename/projectname>.
I get a security popup to connec... | G'day,
Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like:
```
find . \( -type d ! -name . -prune \) -o \( <the bit you want to look for> \)
```
this will stop find from descendi... |
27,095 | <p>I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound <a href="http://www.google.com/search?hl=en&q=1999999999999999-1999999999999995&btnG=Search" rel="nofollow noreferrer">inability</a> to do <a href="http://www.google.com/searc... | [
{
"answer_id": 27105,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<p>For more of this kind of silliness see this nice article pertaining to Windows calculator.</p>\n\n<p><a href=\"http://... | 2008/08/25 | [
"https://Stackoverflow.com/questions/27095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547/"
] | I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound [inability](http://www.google.com/search?hl=en&q=1999999999999999-1999999999999995&btnG=Search) to do [math](http://www.google.com/search?hl=en&q=400000000000002-400000000000001&btnG=Sea... | in C#, try (double.maxvalue == (double.maxvalue - 100)) , you'll get true ...
but thats what it is supposed to be:
<http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems>
thinking about it, you have 64 bit representing a number greater than 2^64 (double.maxvalue), so inaccuracy is expected. |
27,219 | <p>Given a select with multiple option's in jQuery. </p>
<pre><code>$select = $("<select></select>");
$select.append("<option>Jason</option>") //Key = 1
.append("<option>John</option>") //Key = 32
.append("<option>Paul</option>") //Key = 423
</code></pre>
... | [
{
"answer_id": 27231,
"author": "Lucas Wilson-Richter",
"author_id": 1157,
"author_profile": "https://Stackoverflow.com/users/1157",
"pm_score": 3,
"selected": false,
"text": "<p>The HTML <code><option></code> tag has an attribute called \"value\", where you can store your key.</p>... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1293/"
] | Given a select with multiple option's in jQuery.
```
$select = $("<select></select>");
$select.append("<option>Jason</option>") //Key = 1
.append("<option>John</option>") //Key = 32
.append("<option>Paul</option>") //Key = 423
```
How should the key be stored and retrieved?
The ID may be an OK place ... | Like lucas said the value attribute is what you need. Using your code it would look something like this ( I added an id attribute to the select to make it fit ):
```
$select = $('<select id="mySelect"></select>');
$select.append('<option value="1">Jason</option>') //Key = 1
.append('<option value="32">John</option>... |
27,220 | <p>I'm looking for a method, or a code snippet for converting std::string to LPCWSTR</p>
| [
{
"answer_id": 27291,
"author": "17 of 26",
"author_id": 2284,
"author_profile": "https://Stackoverflow.com/users/2284",
"pm_score": 4,
"selected": false,
"text": "<p>If you are in an ATL/MFC environment, You can use the ATL conversion macro:</p>\n\n<pre><code>#include <atlbase.h>\... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I'm looking for a method, or a code snippet for converting std::string to LPCWSTR | The solution is actually a lot easier than any of the other suggestions:
```
std::wstring stemp = std::wstring(s.begin(), s.end());
LPCWSTR sw = stemp.c_str();
```
Best of all, it's platform independent. |
27,222 | <p>I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML.</p>
<p>I am getting input that looks something like this:</p>
<pre><code><div>This is some <b>text
</code></pre>
<p>As you noticed, the HTML is missing closing tags. I c... | [
{
"answer_id": 27236,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 5,
"selected": true,
"text": "<p>PHP has <a href=\"http://php.net/tidy\" rel=\"noreferrer\">a PECL extension that gives you access to the features of... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/889/"
] | I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML.
I am getting input that looks something like this:
```
<div>This is some <b>text
```
As you noticed, the HTML is missing closing tags. I could use regex or an XML Parser to solve this... | PHP has [a PECL extension that gives you access to the features of HTML Tidy](http://php.net/tidy). Tidy is a pretty powerful library that should be able to take code like that and close tags in an intelligent manner.
I use it to clean up malformed XML and HTML sent to me by a classified ad system prior to import. |
27,240 | <p>In Java 5 and above you have the foreach loop, which works magically on anything that implements <code>Iterable</code>:</p>
<pre><code>for (Object o : list) {
doStuff(o);
}
</code></pre>
<p>However, <code>Enumerable</code> still does not implement <code>Iterable</code>, meaning that to iterate over an <code>Enum... | [
{
"answer_id": 27389,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 6,
"selected": true,
"text": "<p>Enumeration hasn't been modified to support Iterable because it's an interface not a concrete class (like Vector, which wa... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] | In Java 5 and above you have the foreach loop, which works magically on anything that implements `Iterable`:
```
for (Object o : list) {
doStuff(o);
}
```
However, `Enumerable` still does not implement `Iterable`, meaning that to iterate over an `Enumeration` you must do the following:
```
for(; e.hasMoreElements... | Enumeration hasn't been modified to support Iterable because it's an interface not a concrete class (like Vector, which was modifed to support the Collections interface).
If Enumeration was changed to support Iterable it would break a bunch of people's code. |
27,258 | <p>I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. </p>
<ul>
<li>I don't need to do any DOM updates before, after, or during the callbacks. </li>
<li>I don't need any information from the page, just fr... | [
{
"answer_id": 27264,
"author": "abigblackman",
"author_id": 2279,
"author_profile": "https://Stackoverflow.com/users/2279",
"pm_score": 2,
"selected": false,
"text": "<p>You are not just restricted to ASP.NET AJAX but can use any 3rd party library like jQuery, YUI etc to do the same thi... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page.
* I don't need to do any DOM updates before, after, or during the callbacks.
* I don't need any information from the page, just from a site cookie which... | If you don't want to create a blank page, you could call a IHttpHandler (ashx) file:
```
public class RSSHandler : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/xml";
string sXml = BuildXMLString(); //not showing t... |
27,294 | <p>I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later.</p>
<p>Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task wi... | [
{
"answer_id": 27310,
"author": "DevelopingChris",
"author_id": 1220,
"author_profile": "https://Stackoverflow.com/users/1220",
"pm_score": 5,
"selected": true,
"text": "<p>I use reflection to do this.\nYou can make a factory that basically expands without you having to add any extra cod... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later.
Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task with a seper... | I use reflection to do this.
You can make a factory that basically expands without you having to add any extra code.
make sure you have "using System.Reflection", place the following code in your instantiation method.
```
public Task CreateTask(XmlElement elem)
{
if (elem != null)
{
try
{
... |
27,303 | <p>Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code?</p>
<pre><code><Image Height="60" Hor... | [
{
"answer_id": 27309,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 1,
"selected": false,
"text": "<p>Is it a runtime error or compile-time, Jonas? Looking at the <a href=\"http://msdn.microsoft.com/en-us/library/system.... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199387/"
] | Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code?
```
<Image Height="60" HorizontalAlignment=... | ScaleTransform doesn't have a data context so most likely the binding is looking for SelectedDive.Visibility off it's self and not finding it. There is much in Silverlight xaml and databinding that is different from WPF...
Anyway to solve this you will want to set up the binding in code\*\*, or manually listen for th... |
27,359 | <p>I want to setup a cron job to rsync a remote system to a backup partition, something like:</p>
<pre><code>bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/'
</code></pre>
<p>I would like to be able to "set it and forget it" but what if <code>/mnt/remote1</code> becomes unmounte... | [
{
"answer_id": 27370,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 2,
"selected": false,
"text": "<p>A quick google led me to this bash script that can check if a filesystem is mounted. It seems that grepping the o... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/163/"
] | I want to setup a cron job to rsync a remote system to a backup partition, something like:
```
bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/'
```
I would like to be able to "set it and forget it" but what if `/mnt/remote1` becomes unmounted? (After a reboot or something) I'd ... | ```
if cut -d' ' -f2 /proc/mounts | grep '^/mnt/remote1$' >/dev/null; then
rsync -avz ...
fi
```
Get the list of mounted partitions from `/proc/mounts`, only match `/mnt/remote1` (and if it is mounted, send grep's output to `/dev/null`), then run your `rsync` job.
Recent `grep`s have a `-q` option that you can u... |
27,405 | <p>On an 8-bit micro controller I would like to do the following:</p>
<pre><code>16bit_integer = another_16bit_integer * 0.997;</code></pre>
<p>with the least possible number of instructions.</p>
| [
{
"answer_id": 27415,
"author": "T Percival",
"author_id": 954,
"author_profile": "https://Stackoverflow.com/users/954",
"pm_score": 2,
"selected": false,
"text": "<p>How about integer arithmetic in 32 bits?</p>\n\n<pre><code>16bit_integer = (int16_t) (another_16bit_integer * (int32_t) 9... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609/"
] | On an 8-bit micro controller I would like to do the following:
```
16bit_integer = another_16bit_integer * 0.997;
```
with the least possible number of instructions. | How about integer arithmetic in 32 bits?
```
16bit_integer = (int16_t) (another_16bit_integer * (int32_t) 997 / 1000);
```
32 bits will be enough to store (INT16\_MAX × 997), do the sum on values 1000 times larger then divide back to your 16 bit scale. |
27,442 | <p>Is there a rake task for backing up the data in your database? </p>
<p>I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. </p>
| [
{
"answer_id": 27448,
"author": "thelsdj",
"author_id": 163,
"author_profile": "https://Stackoverflow.com/users/163",
"pm_score": 4,
"selected": true,
"text": "<p>The below script is a simplified version taken from <a href=\"http://github.com/engineyard/eycap/tree/master\" rel=\"nofollow... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | Is there a rake task for backing up the data in your database?
I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. | The below script is a simplified version taken from [eycap](http://github.com/engineyard/eycap/tree/master), specifically from [this file](http://github.com/engineyard/eycap/tree/master/lib/eycap/recipes/database.rb).
```
set :dbuser "user"
set :dbhost "host"
set :database "db"
namespace :db do
desc "Get the databa... |
27,455 | <p>I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:</p>
<p><strong>EDIT:</strong> No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or ... | [
{
"answer_id": 27459,
"author": "jfs",
"author_id": 718,
"author_profile": "https://Stackoverflow.com/users/718",
"pm_score": 4,
"selected": true,
"text": "<p>From the <a href=\"http://www.mono-project.com/FAQ:_General\" rel=\"noreferrer\">Mono docs</a>, I think yes:</p>\n\n<blockquote>\... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/327/"
] | I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below:
**EDIT:** No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something.
```
private vo... | From the [Mono docs](http://www.mono-project.com/FAQ:_General), I think yes:
>
> Managed.Windows.Forms (aka
> System.Windows.Forms): A complete and
> cross platform, System.Drawing based
> Winforms implementation.
>
>
>
It also useful if you run the [Mono Migration Analyzer](http://www.mono-project.com/Moma) f... |
27,509 | <p>How do I check if an object property in JavaScript is undefined?</p>
| [
{
"answer_id": 27510,
"author": "tslocum",
"author_id": 1662,
"author_profile": "https://Stackoverflow.com/users/1662",
"pm_score": -1,
"selected": false,
"text": "<pre><code>if (somevariable == undefined) {\n alert('the variable is not defined!');\n}\n</code></pre>\n\n<p>You can also m... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] | How do I check if an object property in JavaScript is undefined? | The usual way to check if the value of a property is the special value `undefined`, is:
```js
if(o.myProperty === undefined) {
alert("myProperty value is the special value `undefined`");
}
```
To check if an object does not actually have such a property, and will therefore return `undefined` by default when you tr... |
27,532 | <p>Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is <a href="http://jtauber.com/blog/2008/05/18/creating_gradients_programmatically_in_python/" rel="noreferrer">this blog entry</a>, but the e... | [
{
"answer_id": 27536,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 6,
"selected": true,
"text": "<p>you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is [this blog entry](http://jtauber.com/blog/2008/05/18/creating_gradients_programmatically_in_python/), but the example code seems to be missing... | you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage *p* of the first colour and percentage 1 - *p*... |
27,559 | <p>The ones that stick out and make life usefull.</p>
| [
{
"answer_id": 27563,
"author": "chrissie1",
"author_id": 2936,
"author_profile": "https://Stackoverflow.com/users/2936",
"pm_score": 1,
"selected": false,
"text": "<p>Here is one for a testClass with Nunit support.</p>\n\n<pre><code>\n Imports Nunit.FrameWork\n\n Namespace $NAMESP... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2936/"
] | The ones that stick out and make life usefull. | Here is one for a testClass with Nunit support.
```
Imports Nunit.FrameWork
Namespace $NAMESPACE$
'''
''' A TestClass
'''
'''
_
Public Class $CLASSNAME$
#Region " Setup and TearDown "
'''
''' Sets up the Tests
'''
'''
_
Public S... |
27,570 | <p>Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:</p>
<pre><code>int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll");
</code></pre>
<p>I know that I can ma... | [
{
"answer_id": 27574,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>Someone has to do the iterating part.</p>\n\n<p>AFAIK, there is no such method present in .NET already, so I guess ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2257/"
] | Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:
```
int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll");
```
I know that I can make a recursive function to... | You should use the [Directory.GetFiles(path, searchPattern, SearchOption)](http://msdn.microsoft.com/en-us/library/ms143316.aspx) overload of Directory.GetFiles().
Path specifies the path, searchPattern specifies your wildcards (e.g., \*, \*.format) and SearchOption provides the option to include subdirectories.
The ... |
27,581 | <p>What issues / pitfalls must be considered when overriding <code>equals</code> and <code>hashCode</code>?</p>
| [
{
"answer_id": 27609,
"author": "Antti Kissaniemi",
"author_id": 2948,
"author_profile": "https://Stackoverflow.com/users/2948",
"pm_score": 12,
"selected": true,
"text": "<h3>The theory (for the language lawyers and the mathematically inclined):</h3>\n\n<p><code>equals()</code> (<a href... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] | What issues / pitfalls must be considered when overriding `equals` and `hashCode`? | ### The theory (for the language lawyers and the mathematically inclined):
`equals()` ([javadoc](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object))) must define an equivalence relation (it must be *reflexive*, *symmetric*, and *transitive*). In addition, it must be *consistent* (i... |
27,599 | <p>(<strong>Updated a little</strong>)</p>
<p>I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.</p>
<p>I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS messag... | [
{
"answer_id": 27603,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "<p>PHP6 will have better unicode support but there are a few functions you can use.</p>\n\n<p>My first thought was <a href=\"htt... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951/"
] | (**Updated a little**)
I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.
I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily... | To deal with it conceptually before getting into mechanisms, and apologies if any of this is obvious, a string can be defined as a sequence of Unicode characters, Unicode being a database that gives an id number known as a code point to every character you might need to work with. GSM-338 contains a subset of the Unico... |
27,607 | <p>Let's say I have a list of server names stored in a vector, and I would like to contact them one at a time until one has successfully responded. I was thinking about using STL's find_if algorithm in the following way:</p>
<pre><code>find_if(serverNames.begin(), serverNames.end(), ContactServer());
</code></pre>
<p... | [
{
"answer_id": 27614,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 2,
"selected": false,
"text": "<p>I think I would go for it.</p>\n\n<p>The only thing I would worry about is the readability (and therefore maintainabil... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2150/"
] | Let's say I have a list of server names stored in a vector, and I would like to contact them one at a time until one has successfully responded. I was thinking about using STL's find\_if algorithm in the following way:
```
find_if(serverNames.begin(), serverNames.end(), ContactServer());
```
Where ContactServer is a... | I think I would go for it.
The only thing I would worry about is the readability (and therefore maintainability) of it. To me, it reads something like "Find the first server I can contact", which makes perfect sense.
You might want to rename `ContactServer` to indicate that it is a predicate; `CanContactServer`? (But... |
27,610 | <p>I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then. It should include:</p>
<ul>
<li>App.config / Web.config stuff to add for registering TraceListeners</li>
<li>how to ... | [
{
"answer_id": 27659,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 2,
"selected": false,
"text": "<p>DotNetCoders has a starter article on it: <a href=\"http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?article... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then. It should include:
* App.config / Web.config stuff to add for registering TraceListeners
* how to set it up in the cal... | I followed around five different answers as well as all the blog posts in the previous answers and still had problems. I was trying to add a listener to some existing code that was tracing using the `TraceSource.TraceEvent(TraceEventType, Int32, String)` method where the `TraceSource` object was initialised with a stri... |
27,621 | <p>On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)?</p>
<p>Obviously there is the problem of having duplicates in the source hierar... | [
{
"answer_id": 27625,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 7,
"selected": true,
"text": "<p>In bash:</p>\n\n<pre><code>find /foo -iname '*.txt' -exec cp \\{\\} /dest/ \\;\n</code></pre>\n\n<p><code>find</code> w... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2954/"
] | On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)?
Obviously there is the problem of having duplicates in the source hierarchy. I wou... | In bash:
```
find /foo -iname '*.txt' -exec cp \{\} /dest/ \;
```
`find` will find all the files under the path `/foo` matching the wildcard `*.txt`, case insensitively (That's what `-iname` means). For each file, `find` will execute `cp {} /dest/`, with the found file in place of `{}`. |
27,622 | <p>The <strong><a href="http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx" rel="noreferrer">TRACE macro</a></strong> can be used to output diagnostic messages to the debugger when the code is compiled in <strong>Debug</strong> mode. I need the same messages while in <strong>Release</strong> mode. Is there a ... | [
{
"answer_id": 27628,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 1,
"selected": false,
"text": "<p>In MFC, TRACE is defined as ATLTRACE. And in release mode that is defined as:</p>\n\n<pre><code>#define ATLTRACE ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1630/"
] | The **[TRACE macro](http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx)** can be used to output diagnostic messages to the debugger when the code is compiled in **Debug** mode. I need the same messages while in **Release** mode. Is there a way to achieve this?
(Please do **not** waste your time discussing wh... | Actually, the TRACE macro is a lot more flexible than OutputDebugString. It takes a printf() style format string and parameter list whereas OutputDebugString just takes a single string. In order to implement the full TRACE functionality in release mode you need to do something like this:
```
void trace(const char* for... |
27,670 | <p>On my Vista machine I cannot install the .Net framework 3.5 SP1. Setup ends few moments after ending the download of the required files, stating in the log that: </p>
<pre><code>[08/26/08,09:46:11] Microsoft .NET Framework 2.0SP1 (CBS): [2] Error: Installation failed for component Microsoft .NET Framework 2.0SP1 (C... | [
{
"answer_id": 27677,
"author": "Magnus Westin",
"author_id": 2957,
"author_profile": "https://Stackoverflow.com/users/2957",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://blogs.msdn.com/astebner/archive/2007/08/24/4548657.aspx\" rel=\"nofollow noreferrer\">Here is an art... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1178/"
] | On my Vista machine I cannot install the .Net framework 3.5 SP1. Setup ends few moments after ending the download of the required files, stating in the log that:
```
[08/26/08,09:46:11] Microsoft .NET Framework 2.0SP1 (CBS): [2] Error: Installation failed for component Microsoft .NET Framework 2.0SP1 (CBS). MSI retur... | [Here is an article describing what might be your problem.](http://blogs.msdn.com/astebner/archive/2007/08/24/4548657.aspx) |
27,711 | <p>I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data.</p>
<p>I've tried several approaches:</p>
<pre><code>protected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e)
{
totalLabel.Text = ... | [
{
"answer_id": 27739,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 2,
"selected": false,
"text": "<p>The LinqDataSourceEventArgs returned in those events return -1 on these occasions:</p>\n\n<blockquote>\n <p>-1 if the... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2841/"
] | I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data.
I've tried several approaches:
```
protected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e)
{
totalLabel.Text = e.TotalRowCount.ToStr... | The LinqDataSourceEventArgs returned in those events return -1 on these occasions:
>
> -1 if the LinqDataSourceStatusEventArgs object was created during a data modification operation; -1 if you enabled customized paging by setting AutoPage to true and by setting RetrieveTotalRowCount to false.
>
>
>
[Check here ... |
27,743 | <p>My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time.</p>
<p>However, ... | [
{
"answer_id": 27787,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 0,
"selected": false,
"text": "<p>Try using:</p>\n\n<pre><code>mongrel_cluster_ctl stop\n</code></pre>\n\n<p>You can also use:</p>\n\n<pre><code>mongrel... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2994/"
] | My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time.
However, for reason... | I've done a little more investigation into the Mongrel source and it turns out that Mongrel installs a signal handler to catch an standard process kill (TERM) and do a graceful shutdown, so I don't need a special procedure after all.
You can see this working from the log output you get when killing a Mongrel while it'... |
27,745 | <p>Given the URL (single line):<br>
<a href="http://test.example.com/dir/subdir/file.html" rel="noreferrer">http://test.example.com/dir/subdir/file.html</a></p>
<p>How can I extract the following parts using regular expressions:</p>
<ol>
<li>The Subdomain (test)</li>
<li>The Domain (example.com)</li>
<li>The path wit... | [
{
"answer_id": 27755,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 8,
"selected": true,
"text": "<blockquote>\n <p>A single regex to parse and breakup a\n full URL including query parameters\n and anchors e.g.</p>\n \... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] | Given the URL (single line):
<http://test.example.com/dir/subdir/file.html>
How can I extract the following parts using regular expressions:
1. The Subdomain (test)
2. The Domain (example.com)
3. The path without the file (/dir/subdir/)
4. The file (file.html)
5. The path with the file (/dir/subdir/file.html)
6. T... | >
> A single regex to parse and breakup a
> full URL including query parameters
> and anchors e.g.
>
>
> <https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash>
>
>
> `^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$`
>
>
> RexEx positions:
>
>
> url: Reg... |
27,757 | <p>I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this:</p>
<pre><code>Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png");
</code></pre>
<p>The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marke... | [
{
"answer_id": 27769,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "<p>I'm guessing that your class is in a different namespace. The canonical way to solve this would be to use the resou... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1006/"
] | I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this:
```
Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png");
```
The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource.
... | This will get you a string array of all the resources:
```
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
``` |
27,758 | <p>OK, I know what you're thinking, "why write a method you do not want people to use?" Right?</p>
<p>Well, in short, I have a class that needs to be serialized to XML. In order for the <a href="https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx" rel="noreferrer... | [
{
"answer_id": 27763,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 2,
"selected": false,
"text": "<p>I read the heading and immediately thought \"obsolete atribute\". How about</p>\n\n<pre><code> /// <summary>\n... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] | OK, I know what you're thinking, "why write a method you do not want people to use?" Right?
Well, in short, I have a class that needs to be serialized to XML. In order for the [`XmlSerializer`](https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx) to do its magic, the clas... | If a class is [`[Serialisable]`](https://msdn.microsoft.com/en-us/library/system.serializableattribute%28v=vs.110%29.aspx) (i.e. it can be copied around the place as needed) the param-less constructor is needed to deserialise.
I'm guessing that you want to force your code's access to pass defaults for your properties ... |
27,774 | <p>Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the <code>LOOKUP</code> function into an array formula works:</p>
<pre><code>{=SUM(LOOKUP(grades, scoringarray))}
</code></pre>
<p>With the <code>VLOOKUP</code> function this does not work (only gets the score for the fi... | [
{
"answer_id": 28132,
"author": "paulmorriss",
"author_id": 2983,
"author_profile": "https://Stackoverflow.com/users/2983",
"pm_score": 2,
"selected": false,
"text": "<p>I'm afraid I think the answer is no. From the help text on\n<a href=\"http://docs.google.com/support/spreadsheets/bin/... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2492/"
] | Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the `LOOKUP` function into an array formula works:
```
{=SUM(LOOKUP(grades, scoringarray))}
```
With the `VLOOKUP` function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear ... | I still can't see the formulae in your example (just values), but that is exactly what I'm trying to do in terms of the result; obviously I can already do it "by the side" and sum separately - the key for me is doing it in one cell.
I have looked at it again this morning - using the `MATCH` function for the lookup wor... |
27,818 | <p>We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very co... | [
{
"answer_id": 45671,
"author": "jamesh",
"author_id": 4737,
"author_profile": "https://Stackoverflow.com/users/4737",
"pm_score": 1,
"selected": false,
"text": "<p>We use <a href=\"http://www.eclipse.org/buckminster/\" rel=\"nofollow noreferrer\">Buckminster</a>. It's a build and assemb... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287/"
] | We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very condu... | Closing out some old questions...
Our setup was not conducive to maven due to lack of network connectivity and timing. I know there are offline maven setups, but it was all too much given the time. Hopefully we'll get to use a proper setup when we've got time to reorganize the build process.
The solution involved Ant... |
27,832 | <p>I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. </p>
<p>Obviously there is some setup step that I'm not performing on some filter in the graph that Graph... | [
{
"answer_id": 27858,
"author": "Timbo",
"author_id": 1810,
"author_profile": "https://Stackoverflow.com/users/1810",
"pm_score": 5,
"selected": true,
"text": "<p>You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to re... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2587612/"
] | I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine.
Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is... | You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to remote Graph...
In order to find your graph in the list, you have to register it in the running object table:
```
void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister )
{
IMoniker* pMonike... |
27,846 | <p>What is the configuration setting for modifying the default homepage in a Grails application to no longer be appName/index.gsp? Of course you can set that page to be a redirect but there must be a better way.</p>
| [
{
"answer_id": 62067,
"author": "dahernan",
"author_id": 6435,
"author_profile": "https://Stackoverflow.com/users/6435",
"pm_score": 4,
"selected": false,
"text": "<p>Edit UrlMappings.groovy</p>\n\n<p>Add for example add this rule, to handle the root with a HomeController.</p>\n\n<p>\"/\... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3014/"
] | What is the configuration setting for modifying the default homepage in a Grails application to no longer be appName/index.gsp? Of course you can set that page to be a redirect but there must be a better way. | Add this in UrlMappings.groovy
```
"/" {
controller = "yourController"
action = "yourAction"
}
```
By configuring the URLMappings this way, the home-page of the app will be yourWebApp/yourController/yourAction.
(cut/pasted from [IntelliGrape Blog](http://blog.intelligrape.com/?p=18)) |
27,894 | <p>In SQL Server 2005, we can create temp tables one of two ways:</p>
<pre><code>declare @tmp table (Col1 int, Col2 int);
</code></pre>
<p>or</p>
<pre><code>create table #tmp (Col1 int, Col2 int);
</code></pre>
<p>What are the differences between these two? I have read conflicting opinions on whether @tmp still us... | [
{
"answer_id": 27905,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 4,
"selected": false,
"text": "<p>@wcm - actually to nit pick the Table Variable isn't Ram only - it can be partially stored on disk.</p>\n\n<p>A temp t... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | In SQL Server 2005, we can create temp tables one of two ways:
```
declare @tmp table (Col1 int, Col2 int);
```
or
```
create table #tmp (Col1 int, Col2 int);
```
What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory.
I... | There are a few differences between Temporary Tables (#tmp) and Table Variables (@tmp), although using tempdb isn't one of them, as spelt out in the MSDN link below.
As a rule of thumb, for small to medium volumes of data and simple usage scenarios you should use table variables. (This is an overly broad guideline wit... |
27,899 | <p>Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing:</p>
<pre><code>/index.html
/favicon.ico
/images/logo.gif
</code></pre>
<p>A call to <strong>www.example.com/<em>index.html</em></strong> works great! But if one were to call <strong>www.example.com/</strong> we'd either get ... | [
{
"answer_id": 27922,
"author": "yoavf",
"author_id": 1011,
"author_profile": "https://Stackoverflow.com/users/1011",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest reading <a href=\"http://developer.amazonwebservices.com/connect/thread.jspa?threadID=10849&start=0&... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2961/"
] | Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing:
```
/index.html
/favicon.ico
/images/logo.gif
```
A call to **www.example.com/*index.html*** works great! But if one were to call **www.example.com/** we'd either get a 403 or a REST object listing XML document depending on how ... | Amazon S3 now supports [Index Documents](http://docs.amazonwebservices.com/AmazonS3/latest/dev/IndexDocumentSupport.html)
The *index document* for a bucket can be set to something like `index.html`. When accessing the root of the site or a sub-directory containing a document of that name that document is returned.
It... |
27,910 | <p>The <a href="http://doi.org/" rel="noreferrer">DOI</a> system places basically no useful limitations on what constitutes <a href="http://doi.org/handbook_2000/enumeration.html#2.2" rel="noreferrer">a reasonable identifier</a>. However, being able to pull DOIs out of PDFs, web pages, etc. is quite useful for citation... | [
{
"answer_id": 29639,
"author": "Silas Snider",
"author_id": 2933,
"author_profile": "https://Stackoverflow.com/users/2933",
"pm_score": 1,
"selected": false,
"text": "<p>The following regex should do the job (Perl regex syntax):</p>\n\n<pre><code>/(10\\.\\d+\\/\\d+)/\n</code></pre>\n\n<... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2963/"
] | The [DOI](http://doi.org/) system places basically no useful limitations on what constitutes [a reasonable identifier](http://doi.org/handbook_2000/enumeration.html#2.2). However, being able to pull DOIs out of PDFs, web pages, etc. is quite useful for citation information, etc.
Is there a reliable way to identify a D... | Ok, I'm currently extracting thousands of DOIs from free form text (XML) and I realized that [my previous approach](https://stackoverflow.com/a/10300246/89771) had a few problems, namely regarding encoded entities and trailing punctuation, so I went on reading [the specification](http://www.doi.org/doi_handbook/2_Numbe... |
27,921 | <p>Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive.</p>
<p>"Best" here is defined as </p>
<ul>
<li>Relatively easy to implement, un... | [
{
"answer_id": 27938,
"author": "Huppie",
"author_id": 1830,
"author_profile": "https://Stackoverflow.com/users/1830",
"pm_score": 5,
"selected": true,
"text": "<p>I suppose your best solution would be using the <a href=\"http://msdn.microsoft.com/en-us/library/system.drawing.image.getth... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/308/"
] | Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive.
"Best" here is defined as
* Relatively easy to implement, understand, and maintain
... | I suppose your best solution would be using the [GetThumbnailImage](http://msdn.microsoft.com/en-us/library/system.drawing.image.getthumbnailimage.aspx) from the .NET [Image](http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx) class.
```
// Example in C#, should be quite alike in ASP.NET
// Assuming fi... |
27,928 | <p>How do I calculate the distance between two points specified by latitude and longitude?</p>
<p>For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available.</p>
| [
{
"answer_id": 27943,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 11,
"selected": true,
"text": "<p>This <a href=\"http://www.movable-type.co.uk/scripts/latlong.html\" rel=\"noreferrer\">link</a> might be helpful to you, as ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456/"
] | How do I calculate the distance between two points specified by latitude and longitude?
For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available. | This [link](http://www.movable-type.co.uk/scripts/latlong.html) might be helpful to you, as it details the use of the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to calculate the distance.
Excerpt:
>
> This script [in Javascript] calculates great-circle distances between the two points –
> t... |
27,972 | <p>JavaScript needs access to cookies if AJAX is used on a site with access restrictions based on cookies. Will HttpOnly cookies work on an AJAX site? </p>
<p><em>Edit:</em> Microsoft created a way to prevent XSS attacks by disallowing JavaScript access to cookies if HttpOnly is specified. FireFox later adopted this. ... | [
{
"answer_id": 28000,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 2,
"selected": false,
"text": "<p>Not necessarily, it depends what you want to do. Could you elaborate a bit? AJAX doesn't need access to cookies to w... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | JavaScript needs access to cookies if AJAX is used on a site with access restrictions based on cookies. Will HttpOnly cookies work on an AJAX site?
*Edit:* Microsoft created a way to prevent XSS attacks by disallowing JavaScript access to cookies if HttpOnly is specified. FireFox later adopted this. So my question is... | Yes, HTTP-Only cookies would be fine for this functionality. They will still be provided with the XmlHttpRequest's request to the server.
In the case of Stack Overflow, the cookies are automatically provided as part of the XmlHttpRequest request. I don't know the implementation details of the Stack Overflow authentica... |
27,983 | <p>I have a table of tags and want to get the highest count tags from the list.</p>
<p>Sample data looks like this</p>
<pre><code>id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')
</code></pre>
<p>using</p>
<pre><code>SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`
</code></pre>
<p>gets me ... | [
{
"answer_id": 27992,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": false,
"text": "<p>MySQL prior to version 5 did not allow aggregate functions in ORDER BY clauses.</p>\n\n<p>You can get around this l... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477/"
] | I have a table of tags and want to get the highest count tags from the list.
Sample data looks like this
```
id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')
```
using
```
SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`
```
gets me back the data I'm looking for perfectly. However, I woul... | In all versions of MySQL, simply alias the aggregate in the SELECT list, and order by the alias:
```
SELECT COUNT(id) AS theCount, `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY theCount DESC
LIMIT 20
``` |
28,002 | <p>I've been writing C and C++ code for almost twenty years, but there's one aspect of these languages that I've never really understood. I've obviously used regular casts i.e.</p>
<pre><code>MyClass *m = (MyClass *)ptr;
</code></pre>
<p>all over the place, but there seem to be two other types of casts, and I don't k... | [
{
"answer_id": 28020,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 4,
"selected": false,
"text": "<p><code>dynamic_cast</code> has runtime type checking and only works with references and pointers, whereas <code>static_cas... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821/"
] | I've been writing C and C++ code for almost twenty years, but there's one aspect of these languages that I've never really understood. I've obviously used regular casts i.e.
```
MyClass *m = (MyClass *)ptr;
```
all over the place, but there seem to be two other types of casts, and I don't know the difference. What's... | static\_cast
------------
`static_cast` is used for cases where you basically want to reverse an implicit conversion, with a few restrictions and additions. `static_cast` performs no runtime checks. This should be used if you know that you refer to an object of a specific type, and thus a check would be unnecessary. E... |
28,003 | <p>I have a large database and would like to select table names that have a certain column name. I have done something like this in MySQL, but can't find any info on SQL Server.</p>
<p>I want to do something like:</p>
<pre><code>select [table]
from [db]
where table [has column 'classtypeid']
</code></pre>
<p>How c... | [
{
"answer_id": 28008,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 4,
"selected": true,
"text": "<p>Use the ANSI information_schema views, this will also work in MySQL</p>\n\n<pre><code>select table_name \nfrom information_... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a large database and would like to select table names that have a certain column name. I have done something like this in MySQL, but can't find any info on SQL Server.
I want to do something like:
```
select [table]
from [db]
where table [has column 'classtypeid']
```
How can I do something like this? | Use the ANSI information\_schema views, this will also work in MySQL
```
select table_name
from information_schema.columns
where column_name = 'classtypeid'
``` |
28,029 | <p>How can I have it so Visual Studio doesn't keep re-creating this folder that I never use. It's annoying ot keep looking and unnecessary.</p>
| [
{
"answer_id": 29442,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": -1,
"selected": true,
"text": "<pre><code>Tools->Options->Addin/Macro Security\n</code></pre>\n\n<p>Change Paths there.</p>\n"
},
{
"answer_id... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993/"
] | How can I have it so Visual Studio doesn't keep re-creating this folder that I never use. It's annoying ot keep looking and unnecessary. | ```
Tools->Options->Addin/Macro Security
```
Change Paths there. |
28,092 | <p>I have a ListBox that has a style defined for ListBoxItems. Inside this style, I have some labels and a button. One that button, I want to define a click event that can be handled on my page (or any page that uses that style). How do I create an event handler on my WPF page to handle the event from my ListBoxItem... | [
{
"answer_id": 28187,
"author": "Jas",
"author_id": 777,
"author_profile": "https://Stackoverflow.com/users/777",
"pm_score": 0,
"selected": false,
"text": "<p>You could create a user control (.ascx) to house the listbox. Then add a public event for the page.</p>\n\n<pre><code>Public Eve... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | I have a ListBox that has a style defined for ListBoxItems. Inside this style, I have some labels and a button. One that button, I want to define a click event that can be handled on my page (or any page that uses that style). How do I create an event handler on my WPF page to handle the event from my ListBoxItems styl... | Take a look at [RoutedCommand](http://msdn.microsoft.com/en-us/library/system.windows.input.routedcommand.aspx)s.
Define your command in myclass somewhere as follows:
```
public static readonly RoutedCommand Login = new RoutedCommand();
```
Now define your button with this command:
```
<Button Command="{x:... |
28,098 | <p>How do I convert the value of a PHP variable to string?</p>
<p>I was looking for something better than concatenating with an empty string:</p>
<pre><code>$myText = $myVar . '';
</code></pre>
<p>Like the <code>ToString()</code> method in Java or .NET.</p>
| [
{
"answer_id": 28101,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 4,
"selected": false,
"text": "<p>Putting it in double quotes should work:</p>\n\n<pre><code>$myText = \"$myVar\";\n</code></pre>\n"
},
{
"answer_id... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2680/"
] | How do I convert the value of a PHP variable to string?
I was looking for something better than concatenating with an empty string:
```
$myText = $myVar . '';
```
Like the `ToString()` method in Java or .NET. | You can use the [casting operators](http://us3.php.net/manual/en/language.types.type-juggling.php):
```
$myText = (string)$myVar;
```
There are more details for string casting and conversion in the [Strings section](http://us3.php.net/manual/en/language.types.string.php#language.types.string.casting) of the PHP manu... |