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 |
|---|---|---|---|---|---|---|
257,658 | <p>I've automated my Ubuntu installation - I've got Python code that runs automatically (after a clean install, but before the first user login - it's in a temporary /etc/init.d/ script) that sets up everything from Apache & its configuration to my personal Gnome preferences. It's the latter that's giving me troubl... | [
{
"answer_id": 257833,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 1,
"selected": false,
"text": "<p>Well, I think I understand the question. Looks like your script just needs to start the dbus daemon, or make sure it... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1452/"
] | I've automated my Ubuntu installation - I've got Python code that runs automatically (after a clean install, but before the first user login - it's in a temporary /etc/init.d/ script) that sets up everything from Apache & its configuration to my personal Gnome preferences. It's the latter that's giving me trouble.
Thi... | I can reproduce this by installing GConf 2.24 on my machine. GConf 2.22 works fine, but 2.24 breaks it.
GConf is failing to launch because D-Bus is not running. Manually spawning D-Bus and the GConf daemon makes this work again.
I tried to spawn the D-Bus session bus by doing the following:
```
import dbus
dummy_bus... |
257,659 | <p>I am wondering how to get a process run at the command line to use less processing power. The problem I'm having is the the process is basically taking over the CPU and taking MySQL and the rest of the server with it. Everything is becoming very slow.</p>
<p>I have used <code>nice</code> before but haven't had much... | [
{
"answer_id": 257667,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "<p>Using CPU cycles alone shouldn't take over the rest of the system. You can show this by doing:</p>\n\n<pre><code>while... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257659",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I am wondering how to get a process run at the command line to use less processing power. The problem I'm having is the the process is basically taking over the CPU and taking MySQL and the rest of the server with it. Everything is becoming very slow.
I have used `nice` before but haven't had much luck with it. If it ... | You should use nice with 19 "niceness" this makes the process very unlikely to run if there are other processes waiting for the cpu.
```
nice -n 19 <command>
```
Be sure that the program does not have busy waits and also check the I/O wait time. |
257,685 | <p>I have a program that uses save files. It needs to load the newest save file, but fall back on the next newest if that one is unavailable or corrupted. Can I use the windows file creation timestamp to tell the order of when they were created, or is this unreliable? I am asking because the "changed" timestamps seem u... | [
{
"answer_id": 257704,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": "<p>If you have a directory full of arbitrary and randomly named files and 'time' is the only factor, it may be more p... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a program that uses save files. It needs to load the newest save file, but fall back on the next newest if that one is unavailable or corrupted. Can I use the windows file creation timestamp to tell the order of when they were created, or is this unreliable? I am asking because the "changed" timestamps seem unre... | If you have a directory full of arbitrary and randomly named files and 'time' is the only factor, it may be more pointful to establish a filename that matches the timestamp to eliminate need for using tools to view it.
```
2008_12_31_24_60_60_1000
```
Would be my recommendation for a flatfile system.
Sometimes ... |
257,735 | <p>I'm looking to create a Visual Studio 2008 template that will create a basic project and based on remove certain files/folders based on options the user enters.</p>
<p>Right now, I have followed some tutorials online which have let me create the form to query the user and pass the data into an IWizard class, but I ... | [
{
"answer_id": 257978,
"author": "Erik",
"author_id": 33315,
"author_profile": "https://Stackoverflow.com/users/33315",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand correctly, you want to be able to determine whether or not you should add project items to a project.</p>\... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33536/"
] | I'm looking to create a Visual Studio 2008 template that will create a basic project and based on remove certain files/folders based on options the user enters.
Right now, I have followed some tutorials online which have let me create the form to query the user and pass the data into an IWizard class, but I don't know... | In my experience, `ShouldAddProjectItem` only gets called for *folders* in the template project. As such, it's pretty much useless.
Instead, you would need to put code in your `ProjectFinishedGenerating` implementation that uses the VS API to remove ProjectItems.
In there, you can remove items like this:
```
Projec... |
257,740 | <p>Basically I'm trying to change the <code>Canvas.Left</code> property of an Ellipse Silverlight control in C#. Here is how I'm accessing the control:</p>
<pre><code>Ellipse c1 = this.FindName("Circle1") as Ellipse;
</code></pre>
<p>How would I then set the <code>Canvas.Left</code> property?</p>
<p>Thanks,</p>
<p... | [
{
"answer_id": 257747,
"author": "JSmyth",
"author_id": 54794,
"author_profile": "https://Stackoverflow.com/users/54794",
"pm_score": 3,
"selected": true,
"text": "<p>The answer lies in Silverlights use of Dependancy Properties</p>\n\n<p>c1.SetValue(Canvas.LeftProperty, value);</p>\n"
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] | Basically I'm trying to change the `Canvas.Left` property of an Ellipse Silverlight control in C#. Here is how I'm accessing the control:
```
Ellipse c1 = this.FindName("Circle1") as Ellipse;
```
How would I then set the `Canvas.Left` property?
Thanks,
Jeff | The answer lies in Silverlights use of Dependancy Properties
c1.SetValue(Canvas.LeftProperty, value); |
257,767 | <p>I have a largish Mercurial repository that I've decided would be better as several smaller repositories. Is there a way that I can split the repository and have each piece retain its revision history?</p>
| [
{
"answer_id": 257788,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>Just clone it and delete the unwanted stuff out of each copy.</p>\n"
},
{
"answer_id": 257927,
"author": "Ry4a... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/207/"
] | I have a largish Mercurial repository that I've decided would be better as several smaller repositories. Is there a way that I can split the repository and have each piece retain its revision history? | The best way to do this is using the ['convert' extension](https://www.mercurial-scm.org/wiki/ConvertExtension). You'll use mercurial and both source and destination type and then use a `--filemap` with entries like:
```
exclude path/you/do/not/want
rename path/you/do/want .
```
The rename is only necessary if you w... |
257,772 | <p>I am using Structure map like the MVC storefront by Rob Conery does and I have an AdminController and so to get to it I just type:</p>
<pre><code>website/Admin/action
</code></pre>
<p>however if I miss spell the controller name I get the error below:</p>
<p>Exception Details: System.ArgumentNullException: Value c... | [
{
"answer_id": 257846,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "<p>You have a couple different options (or if you want, two things you can combine for a solution). To remove some of the p... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29376/"
] | I am using Structure map like the MVC storefront by Rob Conery does and I have an AdminController and so to get to it I just type:
```
website/Admin/action
```
however if I miss spell the controller name I get the error below:
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: ke... | The problem is that if there is no controller with the expected type name (i.e. if the user types "**Amdin**" the ControllerFactory base class will look for "**Amdin**Controller" and won't find it, but will still call your overriden method). In that case, the controllerType variable will be null. So you can just check ... |
257,793 | <p>I recently switched my hosting provider and due to the time zone that the server is now in, my code has stopped working. </p>
<p>The hosting server reports in Pacific time, However, my code needs to work with GMT as my site is for the UK market. So, all my displays and searches need to be in the format dd/MM/yyyy</... | [
{
"answer_id": 257807,
"author": "Ray",
"author_id": 233,
"author_profile": "https://Stackoverflow.com/users/233",
"pm_score": 2,
"selected": false,
"text": "<p>Try </p>\n\n<pre><code>DateTime.Parse(\"28/11/2008\", new CultureInfo(\"en-GB\"))\n</code></pre>\n\n<p>Have a look at <a href=\... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26300/"
] | I recently switched my hosting provider and due to the time zone that the server is now in, my code has stopped working.
The hosting server reports in Pacific time, However, my code needs to work with GMT as my site is for the UK market. So, all my displays and searches need to be in the format dd/MM/yyyy
How can I ... | In your web.config file add `<globalization>` element under `<system.web>` node:
```
<system.web>
<globalization culture="en-gb"/>
<!-- ... -->
</system.web>
``` |
257,795 | <p>I'm trying to add an header file to dev-C++ but when I compile it it doesn't work.
Here are my exact steps (for my example, I'm trying to get mysql.h to work):</p>
<ol>
<li>copy "mysql.h" into c:\dev-c++\includes</li>
<li>check that in dev-C++ tools > compiler options > directories > c includes and c++ includes hav... | [
{
"answer_id": 257800,
"author": "jpoh",
"author_id": 4368,
"author_profile": "https://Stackoverflow.com/users/4368",
"pm_score": 2,
"selected": false,
"text": "<p>You didn't say how you included it at the top of your file. This should work if you did</p>\n\n<pre><code>#include \"mysql.h... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28462/"
] | I'm trying to add an header file to dev-C++ but when I compile it it doesn't work.
Here are my exact steps (for my example, I'm trying to get mysql.h to work):
1. copy "mysql.h" into c:\dev-c++\includes
2. check that in dev-C++ tools > compiler options > directories > c includes and c++ includes have the path to "c:\d... | Dev-C++ is a port of GCC, so try this page: [http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html](http://gcc.gnu.org/onlinedocs/cpp/Search-Path.html#Search-Path).
Note that you probably have to tinkle with the Makefile. |
257,797 | <p>I wrote a C++ project in VS2005, and used lots of STL container with its plus-in STL. However, I found STL in VS2005 does not have a hash_map in it, I want to use SGI hash_map. How can I change my project to use SGI STL?</p>
<p>Thanks for Brian's method, it works! And it's simple.</p>
| [
{
"answer_id": 257799,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 3,
"selected": true,
"text": "<p>VS2005 does have a hash_map:</p>\n\n<pre><code>#include <hash_map>\nstdext::hash_map\n</code></pre>\n\n<p>If ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] | I wrote a C++ project in VS2005, and used lots of STL container with its plus-in STL. However, I found STL in VS2005 does not have a hash\_map in it, I want to use SGI hash\_map. How can I change my project to use SGI STL?
Thanks for Brian's method, it works! And it's simple. | VS2005 does have a hash\_map:
```
#include <hash_map>
stdext::hash_map
```
If you still want to though you can [download the sgi stl here](http://www.sgi.com/tech/stl/download.html). You should be able to just set the include directory to the sgi location. It will take precedence over the VC++ global include directo... |
257,801 | <p>Here's the scenario:</p>
<p>I have a textbox and a button on a web page. When the button is clicked, I want a popup window to open (using Thickbox) that will show all items that match the value entered in the textbox. I am currently using the IFrame implementation of Thickbox. The problem is that the URL to show... | [
{
"answer_id": 257852,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 0,
"selected": false,
"text": "<p>Here is an idea. I don't think it is very pretty but should work:</p>\n\n<pre><code>$('input#tb').blur(function(){ \n var ur... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | Here's the scenario:
I have a textbox and a button on a web page. When the button is clicked, I want a popup window to open (using Thickbox) that will show all items that match the value entered in the textbox. I am currently using the IFrame implementation of Thickbox. The problem is that the URL to show is hardcoded... | Just handle the onclick of your button to run a function that calls `tb_show()`, passing the value of the text box. Something like
```
... onclick = "doSearch()" ...
function doSearch()
{
tb_show(caption, 'Search.aspx?KeepThis=true&q=\"' +
$('input#tb').val() +
'\"&TB_iframe=true&height=50... |
257,805 | <p>I'm having a hard time understanding some git/DCVS concepts. Here's what happened:</p>
<ol>
<li>I created a git project, and imported it from an SVN repo</li>
<li>I made some commits</li>
<li>I wanted to experiment something, so I created a branch called <strong>constants-update</strong></li>
<li>I switched to <str... | [
{
"answer_id": 257829,
"author": "Grant Limberg",
"author_id": 27314,
"author_profile": "https://Stackoverflow.com/users/27314",
"pm_score": 2,
"selected": false,
"text": "<p>Lookup git-stash for changing branches while there are unsaved changes in the current branch.</p>\n"
},
{
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22992/"
] | I'm having a hard time understanding some git/DCVS concepts. Here's what happened:
1. I created a git project, and imported it from an SVN repo
2. I made some commits
3. I wanted to experiment something, so I created a branch called **constants-update**
4. I switched to **constants-update**branch, moved some files, de... | I solved the problem [hacking my pre-commit hook](http://www.dont-panic.cc/capi/2007/07/13/git-on-windows-you-have-some-suspicious-patch-lines/) (commenting these lines in `.git/hooks/pre-commit` with a `#`):
```
# if (/\s$/) {
# bad_line("trailing whitespace", $_);
# }
``` |
257,809 | <p>I want to search a table to find all rows where one particular field is one of two values. I know exactly what the values would be, but I'm wondering which is the most efficient way to search for them:</p>
<p>for the sake of example, the two values are "xpoints" and "ypoints". I know for certain that there will be ... | [
{
"answer_id": 257813,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 5,
"selected": true,
"text": "<p>As always with SQL queries, run it through the profiler to find out. However, my gut instinct would have to say that the I... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I want to search a table to find all rows where one particular field is one of two values. I know exactly what the values would be, but I'm wondering which is the most efficient way to search for them:
for the sake of example, the two values are "xpoints" and "ypoints". I know for certain that there will be no other v... | As always with SQL queries, run it through the profiler to find out. However, my gut instinct would have to say that the IN search would be quicker. Espcially in the example you gave, if the field was indexed, it would only have to do 2 lookups. If you did a like search, it may have to do a scan, because you are lookin... |
257,844 | <p>How can I <strong>quickly</strong> create a large file on a Linux (<a href="http://en.wikipedia.org/wiki/Red_Hat_Linux" rel="noreferrer">Red Hat Linux</a>) system?</p>
<p><a href="http://en.wikipedia.org/wiki/Dd_%28Unix%29" rel="noreferrer">dd</a> will do the job, but reading from <code>/dev/zero</code> and writing... | [
{
"answer_id": 257849,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 8,
"selected": false,
"text": "<h1>Linux & all filesystems</h1>\n\n<p><code>xfs_mkfile 10240m 10Gigfile</code></p>\n\n<h1>Linux & and ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17007/"
] | How can I **quickly** create a large file on a Linux ([Red Hat Linux](http://en.wikipedia.org/wiki/Red_Hat_Linux)) system?
[dd](http://en.wikipedia.org/wiki/Dd_%28Unix%29) will do the job, but reading from `/dev/zero` and writing to the drive can take a long time when you need a file several hundreds of GBs in size fo... | `dd` from the other answers is a good solution, but it is slow for this purpose. In Linux (and other POSIX systems), we have `fallocate`, which uses the desired space without having to actually writing to it, works with most modern disk based file systems, very fast:
For example:
```
fallocate -l 10G gentoo_root.img
... |
257,855 | <p>In my fieldset I have labels next (side) to my textboxes, but for some reason, they are towards the top and not middle. Here is my CSS for the fieldset:</p>
<pre><code>fieldset {
clear: both;
font-size: 100%;
border-color: #000000;
border-width: 1px 0 0 0;
border-style: solid none none none;
padding: 10... | [
{
"answer_id": 257860,
"author": "Zack The Human",
"author_id": 18265,
"author_profile": "https://Stackoverflow.com/users/18265",
"pm_score": 3,
"selected": true,
"text": "<p>Try adjusting the <strong>line-height</strong> property for the label element. You may need to increase or decrea... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | In my fieldset I have labels next (side) to my textboxes, but for some reason, they are towards the top and not middle. Here is my CSS for the fieldset:
```
fieldset {
clear: both;
font-size: 100%;
border-color: #000000;
border-width: 1px 0 0 0;
border-style: solid none none none;
padding: 10px;
margin: ... | Try adjusting the **line-height** property for the label element. You may need to increase or decrease it. |
257,872 | <p>I want to force Apache to use HTTPS for a particular URL in the following form:</p>
<pre><code>https://www.example.com/signup/*
</code></pre>
<p>so</p>
<p>if someone goes to any of the following example URLs directly, Apache will forward the URL over to the HTTPS equivalent site.</p>
<p>e.g.</p>
<pre><code>http... | [
{
"answer_id": 257875,
"author": "hayalci",
"author_id": 16084,
"author_profile": "https://Stackoverflow.com/users/16084",
"pm_score": 1,
"selected": false,
"text": "<p>You should take a look at <a href=\"http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html\" rel=\"nofollow noreferrer\"... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33554/"
] | I want to force Apache to use HTTPS for a particular URL in the following form:
```
https://www.example.com/signup/*
```
so
if someone goes to any of the following example URLs directly, Apache will forward the URL over to the HTTPS equivalent site.
e.g.
```
http://www.example.com/signup --> https://www.example... | Thank Murat,
Yours almost worked but figured out how to get it to exactly work.
The following is what works:
```
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/somefolder/?
RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]
```
Notice that I didn't include somefolder in the www.domain.com rewriterule |
257,877 | <p>I want to trim trailing whitespace at the end of all XHTML paragraphs. I am using Ruby with the REXML library.</p>
<p>Say I have the following in a valid XHTML file:</p>
<pre><code><p>hello <span>world</span> a </p>
<p>Hi there </p>
<p>The End </p>
</code></pre>
<p>... | [
{
"answer_id": 257917,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 4,
"selected": true,
"text": "<p>Your example worked for me</p>\n\n<pre>//p/child::text()[last()]</pre>\n"
},
{
"answer_id": 258030,
"author": "A... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5758/"
] | I want to trim trailing whitespace at the end of all XHTML paragraphs. I am using Ruby with the REXML library.
Say I have the following in a valid XHTML file:
```
<p>hello <span>world</span> a </p>
<p>Hi there </p>
<p>The End </p>
```
I want to end up with this:
```
<p>hello <span>world</span> a</p>
<p>Hi there</p... | Your example worked for me
```
//p/child::text()[last()]
``` |
257,901 | <p>I'm using this script to display all the images in a folder, but I can't figure out how to get each image's file name to display underneath it. Any suggestions?</p>
<pre><code><?php
$dirname = "images";
$images = scandir($dirname);
$ignore = Array(".", "..", "otherfiletoignore");
foreach($images as $curimg){
... | [
{
"answer_id": 257904,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 4,
"selected": true,
"text": "<pre><code>echo \"<img src='images/$curimg' /><br />$curimg<br />\\n\";\n</code></pre>\n"
},
{
"answe... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32972/"
] | I'm using this script to display all the images in a folder, but I can't figure out how to get each image's file name to display underneath it. Any suggestions?
```
<?php
$dirname = "images";
$images = scandir($dirname);
$ignore = Array(".", "..", "otherfiletoignore");
foreach($images as $curimg){
if (!in_array(... | ```
echo "<img src='images/$curimg' /><br />$curimg<br />\n";
``` |
257,902 | <p>I have seen lots of chat examples in Erlang but what about lists, like a work queue? If I want to build a work queue system, like a project management system, is it possible to re-order messages in a process mailbox or do I have to use message priorities? Are there examples of workflow systems built in Erlang?</p>... | [
{
"answer_id": 258348,
"author": "Adam Lindberg",
"author_id": 2457,
"author_profile": "https://Stackoverflow.com/users/2457",
"pm_score": 4,
"selected": true,
"text": "<p>You cannot reorder messages in process message queues in Erlang.</p>\n\n<p>You can, however do selective receives in... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32829/"
] | I have seen lots of chat examples in Erlang but what about lists, like a work queue? If I want to build a work queue system, like a project management system, is it possible to re-order messages in a process mailbox or do I have to use message priorities? Are there examples of workflow systems built in Erlang? | You cannot reorder messages in process message queues in Erlang.
You can, however do selective receives in which you can receive the message you deem most important first. It's not entirely the same but works for most purposes.
Here's an example:
```
receive
{important, Msg} ->
handle(Msg)
after 0 ->
... |
257,906 | <p>The activity monitor in sql2k8 allows us to see the most expensive queries. Ok, that's cool, but is there a way I can log this info or get this info via query analyser? I don't really want to have the Sql Management console open and me looking at the activity monitor dashboard.</p>
<p>I want to figure out which que... | [
{
"answer_id": 257924,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 2,
"selected": false,
"text": "<p>Would the SQL Server Profiler do what you need? I haven't used 2008 yet so I don't know if the tool is still in there bu... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | The activity monitor in sql2k8 allows us to see the most expensive queries. Ok, that's cool, but is there a way I can log this info or get this info via query analyser? I don't really want to have the Sql Management console open and me looking at the activity monitor dashboard.
I want to figure out which queries are p... | 1. Use SQL Server Profiler (on the tools menu in SSMS) to create a trace that logs these events:
```
RPC:Completed
SP:Completed
SP:StmtCompleted
SQL:BatchCompleted
SQL:StmtCompleted
```
2. You can start with the standard trace template and prune it. You didn't specify whether this was for a specific database or ... |
257,993 | <p>I am a trying to learn C# .Net.</p>
<p>I had written small (hobby) Analog Clock application in VB sometime ago(edit: VB6, to be precise), and I thought I will rewrite in C#.NET, as part of my <em>learning</em> process.</p>
<p>In the VB application, I drew the hands of the clock in XOR Drawmode, so that I have to <... | [
{
"answer_id": 258010,
"author": "nullDev",
"author_id": 6621,
"author_profile": "https://Stackoverflow.com/users/6621",
"pm_score": 3,
"selected": true,
"text": "<p>IMHO, until and unless you are targeting some really slow computers, you don't need to optimize performance by using XOR t... | 2008/11/03 | [
"https://Stackoverflow.com/questions/257993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25949/"
] | I am a trying to learn C# .Net.
I had written small (hobby) Analog Clock application in VB sometime ago(edit: VB6, to be precise), and I thought I will rewrite in C#.NET, as part of my *learning* process.
In the VB application, I drew the hands of the clock in XOR Drawmode, so that I have to *move* the second hand, I... | IMHO, until and unless you are targeting some really slow computers, you don't need to optimize performance by using XOR technique.
Since you'd be drawing the second hand only once in a second, a complete redraw of the clock would be much better. Also, the second hand will "look" good if drawn directly, and use smooth... |
258,006 | <p>I'm trying to play a sound file from an iPhone program.</p>
<p>Here's the code:</p>
<pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"play" ofType:@"caf"];
NSFileHandle *bodyf = [NSFileHandle fileHandleForReadingAtPath:path];
NSData *body = [bodyf availableData];
NSLog( @"length of play.caf %d",... | [
{
"answer_id": 258046,
"author": "zoul",
"author_id": 17279,
"author_profile": "https://Stackoverflow.com/users/17279",
"pm_score": 0,
"selected": false,
"text": "<p>I tried the same with my application that plays sounds just fine. The sounds don’t play in the Simulator and when I try to... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19391/"
] | I'm trying to play a sound file from an iPhone program.
Here's the code:
```
NSString *path = [[NSBundle mainBundle] pathForResource:@"play" ofType:@"caf"];
NSFileHandle *bodyf = [NSFileHandle fileHandleForReadingAtPath:path];
NSData *body = [bodyf availableData];
NSLog( @"length of play.caf %d",[body length] );
NSUR... | An update on this.
I got my keys to allow me to run my app on the device.
I found that my .caf file successfully played when the app ran on the device.
I then tried various alternatives.
A .wav file that is 60 seconds long failed to work on the simulator and the device.
A .wav file that is 5 seconds long would wor... |
258,007 | <p>How can I make the command button in my VC++ 6.0 dialog visible or invisible on load?</p>
| [
{
"answer_id": 258031,
"author": "arul",
"author_id": 15409,
"author_profile": "https://Stackoverflow.com/users/15409",
"pm_score": 1,
"selected": false,
"text": "<p>What do you mean by 'commnad button' exactly ? </p>\n\n<p>Anyway, you need to obtain the handle of the button then call Sh... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I make the command button in my VC++ 6.0 dialog visible or invisible on load? | From the resource editor once you select the button, you can see its properties in the properties window. Here you can set the visible property to true / false. (assuming this functionality is present in 6.0 - i use 2003 now and cannot remember if this used to be present in 6.0)
**Add CButton variable**
If you want ... |
258,011 | <p>I am using windsor DI framework in one of my MVC project. The project works fine when I tried to run from Visual Studio 2008.</p>
<p>But when i tried to run the project creating an application in IIS7 then I recieved the following error message:</p>
<blockquote>
<p>Looks like you forgot to register the http modu... | [
{
"answer_id": 258063,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 6,
"selected": true,
"text": "<p>Try adding it to the <code>system.webServer</code> section as well?</p>\n\n<pre><code><configuration>\n <s... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using windsor DI framework in one of my MVC project. The project works fine when I tried to run from Visual Studio 2008.
But when i tried to run the project creating an application in IIS7 then I recieved the following error message:
>
> Looks like you forgot to register the http module
> Castle.MicroKernel.Li... | Try adding it to the `system.webServer` section as well?
```
<configuration>
<system.web>
<httpModules>
<add name="PerRequestLifestyle" type="..." />
</httpModules>
</system.web>
<system.webServer>
<modules>
<add name="PerRequestLifestyle" type="..." />
... |
258,023 | <p>I need to create a panel which should be invisible but the components inside it (for example, JTextArea, JButton, etc.) should be visible. When I click on the invisible panel, it should become visible.</p>
<p>I can only use JRE 1.4 and nothing more than that. :(</p>
<p>Any idea how to create such a transparent pan... | [
{
"answer_id": 258040,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": 3,
"selected": false,
"text": "<p><code>JComponent.setOpaque(false)</code> is the way to go.</p>\n"
},
{
"answer_id": 258041,
"author": "Peter",
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22550/"
] | I need to create a panel which should be invisible but the components inside it (for example, JTextArea, JButton, etc.) should be visible. When I click on the invisible panel, it should become visible.
I can only use JRE 1.4 and nothing more than that. :(
Any idea how to create such a transparent panel??? | Transparancy is controlled with
```
setOpaque(false)
``` |
258,050 | <p><code>CString</code> is quite handy, while <code>std::string</code> is more compatible with STL container. I am using <code>hash_map</code>. However, <code>hash_map</code> does not support <code>CString</code>s as keys, so I want to convert the <code>CString</code> into a <code>std::string</code>.</p>
<p>Writing a <... | [
{
"answer_id": 258052,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 8,
"selected": true,
"text": "<p>According to <a href=\"http://www.codeguru.com/forum/archive/index.php/t-231155.html\" rel=\"noreferrer\">CodeGuru</a>:</p>\n... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] | `CString` is quite handy, while `std::string` is more compatible with STL container. I am using `hash_map`. However, `hash_map` does not support `CString`s as keys, so I want to convert the `CString` into a `std::string`.
Writing a `CString` hash function seems to take a lot of time.
```
CString -----> std::string
`... | According to [CodeGuru](http://www.codeguru.com/forum/archive/index.php/t-231155.html):
`CString` to `std::string`:
```
CString cs("Hello");
std::string s((LPCTSTR)cs);
```
**BUT:** `std::string` cannot always construct from a `LPCTSTR`. i.e. the code will fail for UNICODE builds.
As `std::string` can construct on... |
258,053 | <p>In excel 2007, I have a formula in a cell like the following:</p>
<pre><code>=COUNTIFS('2008-10-31'!$C:$C;">="&'$A7)
</code></pre>
<p>Now I want to make the name of the sheet ('2008-10-31') be dependent on the value of some cell (say A1). Something like: </p>
<pre><code>=COUNTIFS(A1!$C:$C;">="&'$A7)... | [
{
"answer_id": 258090,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "<p>You are looking for the INDIRECT worksheet function:</p>\n\n<pre><code>=INDIRECT(\"SHEET2!A1\")\n=COUNTIFS(INDIRECT(A1 ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26070/"
] | In excel 2007, I have a formula in a cell like the following:
```
=COUNTIFS('2008-10-31'!$C:$C;">="&'$A7)
```
Now I want to make the name of the sheet ('2008-10-31') be dependent on the value of some cell (say A1). Something like:
```
=COUNTIFS(A1!$C:$C;">="&'$A7) // error
```
Is there is way to do this? Or do I... | INDIRECT does what you want. Note that if the sheet name has any spaces, you need to put single quotes round it, ie
```
=COUNTIFS(INDIRECT("'" & A1 & "'!$C:$C"); ">=" & $A7)
``` |
258,056 | <p>I need to get the data of an particular <code><td></code>, but I don't have any <code>id</code> or <code>name</code> for that particular <code><td></code>. How do you get the contents of that <code><td></code>?</p>
<p>For example:</p>
<pre><code><table>
<tr><td>name</td>... | [
{
"answer_id": 258067,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 1,
"selected": false,
"text": "<p>Something along the line of:<br>\n(not tested, just quick code to give an idea)</p>\n\n<pre><code>var tables = document.getE... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to get the data of an particular `<td>`, but I don't have any `id` or `name` for that particular `<td>`. How do you get the contents of that `<td>`?
For example:
```
<table>
<tr><td>name</td><td>praveen</td></tr>
<tr><td>designation</td><td>software engineer</td></tr>
</table>
```
Is it possible to get t... | A quick solution:
```
function GetTdContent(label)
{
var TDs = document.getElementsByTagName("TD");
var foundFlag = false;
for (i = 0; i < TDs.length; i++)
{
if (foundFlag) return TDs[i].innerHTML;
foundFlag = TDs[i].innerHTML.toLower() == label.toLower();
}
}
```
elsewhere call:
```
var value =... |
258,062 | <p><em>This is javascript, but a virtually identical regex is failing in PHP too, so I don't think it's language specific</em></p>
<pre><code>var r = new RegExp(
"^(:19|20)?[0-9][0-9]" // optional 19/20 start followed by 2 numbers
+ "-" // a hyphen
+ "(:0?[1-9]|1[0-2]... | [
{
"answer_id": 258066,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 5,
"selected": true,
"text": "<p>I think your non-capturing blocks should be e.g. <code>(?:19|20)</code> rather than <code>(:19|20)</code></p>\n"
},
{... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | *This is javascript, but a virtually identical regex is failing in PHP too, so I don't think it's language specific*
```
var r = new RegExp(
"^(:19|20)?[0-9][0-9]" // optional 19/20 start followed by 2 numbers
+ "-" // a hyphen
+ "(:0?[1-9]|1[0-2])" // opt... | I think your non-capturing blocks should be e.g. `(?:19|20)` rather than `(:19|20)` |
258,119 | <p>I am instantiating a class A (which I am importing from somebody
else, so I can't modify it) into my class X.</p>
<p>Is there a way I can intercept or wrap calls to methods in A?
I.e., in the code below can I call</p>
<pre><code>x.a.p1()
</code></pre>
<p>and get the output</p>
<pre><code>X.pre
A.p1
X.post
</code... | [
{
"answer_id": 258125,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<p>The no-whistles-or-bells solution would be to write a wrapper class for class A that does just that.</p>\n"
},
{
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | I am instantiating a class A (which I am importing from somebody
else, so I can't modify it) into my class X.
Is there a way I can intercept or wrap calls to methods in A?
I.e., in the code below can I call
```
x.a.p1()
```
and get the output
```
X.pre
A.p1
X.post
```
Many TIA!
```
class A:
# in my real app... | Here is the solution I and my colleagues came up with:
```
from types import MethodType
class PrePostCaller:
def __init__(self, other):
self.other = other
def pre(self): print 'pre'
def post(self): print 'post'
def __getattr__(self, name):
if hasattr(self.other, name):
fu... |
258,120 | <p>Is the memory space consumed by one object with 100 attributes the same as that of 100 objects, with one attribute each?</p>
<p>How much memory is allocated for an object?<br>
How much additional space is used when adding an attribute?</p>
| [
{
"answer_id": 258124,
"author": "Mendelt",
"author_id": 3320,
"author_profile": "https://Stackoverflow.com/users/3320",
"pm_score": 3,
"selected": false,
"text": "<p>No, registering an object takes a bit of memory too. 100 objects with 1 attribute will take up more memory.</p>\n"
},
... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is the memory space consumed by one object with 100 attributes the same as that of 100 objects, with one attribute each?
How much memory is allocated for an object?
How much additional space is used when adding an attribute? | [Mindprod](http://mindprod.com/jgloss/sizeof.html) points out that this is not a straightforward question to answer:
>
> A JVM is free to store data any way it pleases internally, big or little endian, with any amount of padding or overhead, though primitives must behave as if they had the official sizes.
>
> For... |
258,134 | <p>I'm doing some FK analysis of our tables by making a directed
graph representing FK dependencies and then traversing the
graph. In my code, I name everything using directed graph
terminology, but I'd like to have something a bit more
"user friendly" in the report.</p>
<p>In this scenario:</p>
<pre><code>create ta... | [
{
"answer_id": 258152,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": true,
"text": "<p>I'd say (things between brackets are optional, but I'd use them)</p>\n\n<pre>\n[Column a of] table t1 references [... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | I'm doing some FK analysis of our tables by making a directed
graph representing FK dependencies and then traversing the
graph. In my code, I name everything using directed graph
terminology, but I'd like to have something a bit more
"user friendly" in the report.
In this scenario:
```
create table t1(a varchar2(20))... | I'd say (things between brackets are optional, but I'd use them)
```
[Column a of] table t1 references [column b of] table t2
```
and
```
[Column b of] table t2 is referenced by [column a of] table t1
```
?
I'd also specify the action that happens on delete/update if any.
```
Column b of table t2 is referenc... |
258,136 | <p>I am investigating a production system where there are several Windows services communicating with each other through TCP/IP sockets. I'm trying to figure out which executable is listening to which IP address and which port on a given machine.</p>
<p>Other than rummaging through each windows service's obscure confi... | [
{
"answer_id": 258139,
"author": "begray",
"author_id": 12123,
"author_profile": "https://Stackoverflow.com/users/12123",
"pm_score": 0,
"selected": false,
"text": "<p>Command line netstat tool might help you. To learn available parameters run it with /?: netstat /?</p>\n\n<p>Or there is... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33404/"
] | I am investigating a production system where there are several Windows services communicating with each other through TCP/IP sockets. I'm trying to figure out which executable is listening to which IP address and which port on a given machine.
Other than rummaging through each windows service's obscure configuration f... | As already mentioned [TCPView](http://technet.microsoft.com/en-us/sysinternals/bb897437.aspx) by SysInternals (i.e. Microsoft) is a great tool.
But on production systems you may not be allowed to install additional software, so I think you may want to try out netstat.exe, which is typically located at C:\WINNT\system32... |
258,172 | <p>I'm operating a neighbourhood <a href="http://maps.google.de/maps/ms?ie=UTF8&hl=de&msa=0&msid=101021148567197540440.00043fcffa4cdf06fb4bc&ll=51.791948,8.173571&spn=0.033976,0.058365&t=h&z=14" rel="nofollow noreferrer">WIFI network in a rural environment</a>.</p>
<p>Now I'm looking fo a m... | [
{
"answer_id": 258200,
"author": "paan",
"author_id": 2976,
"author_profile": "https://Stackoverflow.com/users/2976",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if this fits your usage but a lot of web hosting provider uses <a href=\"http://www.nagios.org/\" rel=\"nofollow no... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33433/"
] | I'm operating a neighbourhood [WIFI network in a rural environment](http://maps.google.de/maps/ms?ie=UTF8&hl=de&msa=0&msid=101021148567197540440.00043fcffa4cdf06fb4bc&ll=51.791948,8.173571&spn=0.033976,0.058365&t=h&z=14).
Now I'm looking fo a monitoring tool to run on a server (Windows or Linux) which would track band... | [MRTG](http://oss.oetiker.ch/mrtg/) is probably the easiest to setup. If your router has SNMP (as you mention), to setup it's a single command:
```
cfgmaker --output=mrtg_myrouter.cfg public@1.2.3.4
```
MRTG is good for high-bandwidth routers and the likes. It's not great for other data (it can be coerced into graph... |
258,173 | <p>I'm doing .NET 3.5 programming in VB for a class. I have a .mdb database with 3 related tables, and a table adapter with some queries on it that look like this:</p>
<pre><code>SELECT PropertyID, Street, Unit, City, Zip, Type, Bedrooms, Bathrooms, Area, MonthlyRent
FROM tblProperties
</code></pre>
<p>Th... | [
{
"answer_id": 258200,
"author": "paan",
"author_id": 2976,
"author_profile": "https://Stackoverflow.com/users/2976",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure if this fits your usage but a lot of web hosting provider uses <a href=\"http://www.nagios.org/\" rel=\"nofollow no... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33583/"
] | I'm doing .NET 3.5 programming in VB for a class. I have a .mdb database with 3 related tables, and a table adapter with some queries on it that look like this:
```
SELECT PropertyID, Street, Unit, City, Zip, Type, Bedrooms, Bathrooms, Area, MonthlyRent
FROM tblProperties
```
Then in a form i have a Data... | [MRTG](http://oss.oetiker.ch/mrtg/) is probably the easiest to setup. If your router has SNMP (as you mention), to setup it's a single command:
```
cfgmaker --output=mrtg_myrouter.cfg public@1.2.3.4
```
MRTG is good for high-bandwidth routers and the likes. It's not great for other data (it can be coerced into graph... |
258,198 | <p>inside my C# app I runs a 7z process to extract an archive into it's directory</p>
<p>the archive is located in a random-named directory on the %TEMP% directory for example</p>
<blockquote>
<p>C:\Documents and Settings\User\Local
Settings\Temp\vtugoyrc.fd2</p>
</blockquote>
<p>(fullPathFilename = "C:\Document... | [
{
"answer_id": 258206,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 3,
"selected": false,
"text": "<p>You're using 7 Zip as an external process here. Its the equivalent of calling the commands directly from the comm... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30324/"
] | inside my C# app I runs a 7z process to extract an archive into it's directory
the archive is located in a random-named directory on the %TEMP% directory for example
>
> C:\Documents and Settings\User\Local
> Settings\Temp\vtugoyrc.fd2
>
>
>
(fullPathFilename = "C:\Documents and Settings\User\Local Settings\Tem... | You're using 7 Zip as an external process here. Its the equivalent of calling the commands directly from the command line.
Have you considered using an actual Library for zipping/unzipping your files. Something you can reference in your C# project.
[Sharp Zip Lib](http://www.icsharpcode.net/OpenSource/SharpZipLib/) i... |
258,211 | <pre><code>#!/bin/bash
hello()
{
SRC=$1
DEST=$2
for IP in `cat /opt/ankit/configs/machine.configs` ; do
echo $SRC | grep '*' > /dev/null
if test `echo $?` -eq 0 ; then
for STAR in $SRC ; do
echo -en "$IP"
echo -en "\n\t ARG1=$STAR ARG2=$2\n\n"... | [
{
"answer_id": 258232,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 2,
"selected": false,
"text": "<p>The shell will expand wildcards unless you escape them, so for example if you have </p>\n\n<pre><code>$ ls\none.pdf two.pdf... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24813/"
] | ```
#!/bin/bash
hello()
{
SRC=$1
DEST=$2
for IP in `cat /opt/ankit/configs/machine.configs` ; do
echo $SRC | grep '*' > /dev/null
if test `echo $?` -eq 0 ; then
for STAR in $SRC ; do
echo -en "$IP"
echo -en "\n\t ARG1=$STAR ARG2=$2\n\n"
... | The shell will expand wildcards unless you escape them, so for example if you have
```
$ ls
one.pdf two.pdf three.pdf
```
and run your script as
```
./test.sh *.pdf /ankit__test/as
```
it will be the same as
```
./test.sh one.pdf two.pdf three.pdf /ankit__test/as
```
which is not what you expect. Doing
```
... |
258,212 | <p>I have a web server which saves cache files and keeps them for 7 days. The file names are md5 hashes, i.e. exactly 32 hex characters long, and are being kept in a tree structure that looks like this:</p>
<pre><code>00/
00/
00000ae9355e59a3d8a314a5470753d8
.
.
00/
01/
</code></pre>
<p>You get the id... | [
{
"answer_id": 258215,
"author": "David Arno",
"author_id": 7122,
"author_profile": "https://Stackoverflow.com/users/7122",
"pm_score": 0,
"selected": false,
"text": "<p>How about having a table in your database that uses the hash as the key. The other field would then be the name of the... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581/"
] | I have a web server which saves cache files and keeps them for 7 days. The file names are md5 hashes, i.e. exactly 32 hex characters long, and are being kept in a tree structure that looks like this:
```
00/
00/
00000ae9355e59a3d8a314a5470753d8
.
.
00/
01/
```
You get the idea.
My problem is that de... | When you store a file, make a symbolic link to a second directory structure that is organized by date, not by name.
Retrieve your files using the "name" structure, delete them using the "date" structure. |
258,218 | <p>In MSBuild, I would like to call a task that extracts all the files in all the project in a specific solution and hold these files in a property that can be passed around to other tasks (for processing etc.)</p>
<p>I was thinking something along the lines of:</p>
<pre><code><ParseSolutionFile SolutionFile="$(Th... | [
{
"answer_id": 261037,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know about tasks, but there are already properties that hold all items. Just look in your typical proj... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9222/"
] | In MSBuild, I would like to call a task that extracts all the files in all the project in a specific solution and hold these files in a property that can be passed around to other tasks (for processing etc.)
I was thinking something along the lines of:
```
<ParseSolutionFile SolutionFile="$(TheSolutionFile)">
<Outp... | I don't know about tasks, but there are already properties that hold all items. Just look in your typical project file and you'll see which collection they're being added to.
Note the properties **Content**, **Compile**, **Folder**... any time you add a file to a project, it gets put in one of the main collections lik... |
258,228 | <p>I have been bitten by something unexpected recently. I wanted to make something like that:</p>
<pre><code>try :
thing.merge(iterable) # this is an iterable so I add it to the list
except TypeError :
thing.append(iterable) # this is not iterable, so I add it
</code></pre>
<p>Well, It was working fine unti... | [
{
"answer_id": 258234,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": 2,
"selected": false,
"text": "<p>NOT VALID. Check Brian anwser.</p>\n\n<p>Ok, I just got it :</p>\n\n<pre><code>for x in Exception(\"test\") :\n print ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] | I have been bitten by something unexpected recently. I wanted to make something like that:
```
try :
thing.merge(iterable) # this is an iterable so I add it to the list
except TypeError :
thing.append(iterable) # this is not iterable, so I add it
```
Well, It was working fine until I passed an object inher... | Note that what is happening is not related to any kind of implicit string conversion etc, but because the `Exception` class implements `___getitem__` to return the values from the args tuple (`ex.args`). You can see this by the fact that you get the whole string as your first and only item in the iteration, rather than... |
258,231 | <p>I have a Table called <em>Product</em> and I have the Table <em>StorageHistory</em>.</p>
<p>Now, Product contains a reference to StorageHistory in it's mappings</p>
<pre><code><set name="StorageHistories" lazy="false">
<key column="ProductId" />
<one-to-many class="StorageHistory" />
</set... | [
{
"answer_id": 258255,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 4,
"selected": true,
"text": "<p>I always do the following in the ctor of the parent object:</p>\n\n<p>histories = new HashedSet();</p>\n\n<p>This cove... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21699/"
] | I have a Table called *Product* and I have the Table *StorageHistory*.
Now, Product contains a reference to StorageHistory in it's mappings
```
<set name="StorageHistories" lazy="false">
<key column="ProductId" />
<one-to-many class="StorageHistory" />
</set>
```
And it works, when I retrieve an object from the... | I always do the following in the ctor of the parent object:
histories = new HashedSet();
This covers the Save() use case. The Load()/Get() etc usecase is covered by NHibernate as you stated. |
258,251 | <p>How do I apply 'use base' in Perl to inherit subs from some base module?</p>
<p>I'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following:</p>
<pre><code>#! /usr/bin/perl
#The base class to inherit from
use strict;
use war... | [
{
"answer_id": 258308,
"author": "tsee",
"author_id": 13164,
"author_profile": "https://Stackoverflow.com/users/13164",
"pm_score": 2,
"selected": false,
"text": "<p>Perl's inheritance inherits <em>methods</em>, not functions. That means you will have to call </p>\n\n<pre><code>main->... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15161/"
] | How do I apply 'use base' in Perl to inherit subs from some base module?
I'm used to C++ inheritance mechanics, and all the sites I googled for this caused more confusion then help. I want to do something like the following:
```
#! /usr/bin/perl
#The base class to inherit from
use strict;
use warnings;
package 'Test... | The C++ mechnics aren't much different than the Perl mechanics: To use inheritance, you need two classes: the base class and the inheriting class. But you don't have any descendent class.
You are also lacking a constructor. Unlike C++, Perl will not provide a default constructor for you.
Your base class contains a b... |
258,264 | <p>Is there any way of using Memcached for fragment caching in Rails?</p>
| [
{
"answer_id": 259239,
"author": "TonyLa",
"author_id": 1295,
"author_profile": "https://Stackoverflow.com/users/1295",
"pm_score": 3,
"selected": true,
"text": "<p>You can set the fragment_cache_store in your environment.rb</p>\n\n<pre><code> ActionController::Base.cache_store = Active... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] | Is there any way of using Memcached for fragment caching in Rails? | You can set the fragment\_cache\_store in your environment.rb
```
ActionController::Base.cache_store = ActiveSupport::Cache::MemCacheStore.new()
```
<http://api.rubyonrails.org/classes/ActionController/Caching.html#M000628> |
258,273 | <p>Heres the link:</p>
<p><a href="http://tinyurl.com/596xva" rel="nofollow noreferrer">DAMNIE6TOHELL</a></p>
<p>As you can see if viewed in glorious 'IE6-o-color', the footer is shifting 1px over to the left.
I'm struggling to find a fix for this, I've whittled it down to a bare minimum of HTML.</p>
<p>Is it someth... | [
{
"answer_id": 258293,
"author": "yoavf",
"author_id": 1011,
"author_profile": "https://Stackoverflow.com/users/1011",
"pm_score": 2,
"selected": true,
"text": "<p>Add </p>\n\n<pre><code>background-position: 50% top;\n</code></pre>\n\n<p>to the css of container_bottom. </p>\n\n<p>It wo... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | Heres the link:
[DAMNIE6TOHELL](http://tinyurl.com/596xva)
As you can see if viewed in glorious 'IE6-o-color', the footer is shifting 1px over to the left.
I'm struggling to find a fix for this, I've whittled it down to a bare minimum of HTML.
Is it something to do with haslayout perhaps? Any help much appreciated. | Add
```
background-position: 50% top;
```
to the css of container\_bottom.
It works for me with IE Developer toolbar, but it's on a IE6 Virtual machine, so I'm not sure about real world results |
258,275 | <p>I'm trying to run a command-line process (which is extraction of a .7z archive) on a file that lies in a temporary folder on the windows user temp directory
(C:\Documents and Settings\User\Local Settings\Temp), using Process in my c# app.</p>
<p>I think the process return error that happens because of "access denie... | [
{
"answer_id": 258276,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming that you are using regular .NET (not CF/Silverlight, etc) Accessing files in the user's temp area is enti... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30324/"
] | I'm trying to run a command-line process (which is extraction of a .7z archive) on a file that lies in a temporary folder on the windows user temp directory
(C:\Documents and Settings\User\Local Settings\Temp), using Process in my c# app.
I think the process return error that happens because of "access denied" because... | Assuming that you are using regular .NET (not CF/Silverlight, etc) Accessing files in the user's temp area is entirely expected. I wonder if the problem isn't more that you've accidentally left the file open after creating it, perhaps by not using a "using" or similar?
I probably wouldn't suggest using environment var... |
258,280 | <p>I created an html helper </p>
<pre><code>Html.BreadCrumb(IDictionary<string, string> crumbs)
</code></pre>
<p>Where the first string is the label and the second string is the URL.
The helper creates the html required (an unordered list, some classes for first element, current element, last element, dead elem... | [
{
"answer_id": 258343,
"author": "Rene Saarsoo",
"author_id": 15982,
"author_profile": "https://Stackoverflow.com/users/15982",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think you will have any performance problems as long as the size of the HTML pages you produce is reasonab... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | I created an html helper
```
Html.BreadCrumb(IDictionary<string, string> crumbs)
```
Where the first string is the label and the second string is the URL.
The helper creates the html required (an unordered list, some classes for first element, current element, last element, dead element and separators etc)
All work... | It certainly is possible to use Response.Write instead of returning a string; see the source for System.Web.Mvc.Ajax.Form (in AjaxExtensions.cs) in the MVC source for an example.
You then call the helper with <% instead of <%=.
Will it be any faster? I doubt it, but it's easy to test. |
258,284 | <p>In either a Windows or Mac OS X terminal if you type...</p>
<pre><code>nslookup -type=SRV _xmpp-server._tcp.gmail.com
</code></pre>
<p>... (for example) you will receive a bunch of SRV records relating to different google chat servers..</p>
<p>Does anyone have any experience in this area and possibly know how to ... | [
{
"answer_id": 258413,
"author": "Alex Reynolds",
"author_id": 19410,
"author_profile": "https://Stackoverflow.com/users/19410",
"pm_score": 0,
"selected": false,
"text": "<p>Hmm, looks like I can't run <code>system()</code> on the Simulator or the device. I can run <code>NSTask</code> o... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33604/"
] | In either a Windows or Mac OS X terminal if you type...
```
nslookup -type=SRV _xmpp-server._tcp.gmail.com
```
... (for example) you will receive a bunch of SRV records relating to different google chat servers..
Does anyone have any experience in this area and possibly know how to service this information (hostnam... | I believe you need to use the DNSServiceDiscovery framework. I don't have the iPhone SDK, but a Google search suggests that it is available on the iPhone.
See the Apple Developer Site for [full API details](https://developer.apple.com/library/mac/documentation/networking/conceptual/dns_discovery_api/Introduction.html)... |
258,291 | <p>In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer. </p>
<p>In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building. </p>
<p>I have currently, created a ... | [
{
"answer_id": 258406,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 0,
"selected": false,
"text": "<p>Obvious question maybe, but still has to be asked, did you include the folder containing the XSLT's in the project itself? Is t... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | In a visual studio project I have three layers, Data Layer, Business Layer and Presentation Layer.
In the Data Layer I have a few XSLT's that transform some objects into an email, all works fine but I have discovered that the XSLTs do not get built/copied when building.
I have currently, created a folder in the dep... | If you are using Visual Studio 2005/2008, the easiest way to do this is by including your XSLT files as project resources.
1. Open the Properties for your project.
2. Select the Resources tab. You will probably see a link that says "This project does not contain a default resources file. Click here to create one." Go ... |
258,296 | <p>I have a models <code>A</code> and <code>B</code>, that are like this:</p>
<pre><code>class A(models.Model):
title = models.CharField(max_length=20)
(...)
class B(models.Model):
date = models.DateTimeField(auto_now_add=True)
(...)
a = models.ForeignKey(A)
</code></pre>
<p>Now I have some <code>A</code> ... | [
{
"answer_id": 258310,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 4,
"selected": true,
"text": "<p>Sounds like a job for <a href=\"http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] | I have a models `A` and `B`, that are like this:
```
class A(models.Model):
title = models.CharField(max_length=20)
(...)
class B(models.Model):
date = models.DateTimeField(auto_now_add=True)
(...)
a = models.ForeignKey(A)
```
Now I have some `A` and `B` objects, and I'd like to get a query that selects a... | Sounds like a job for [`extra`](http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none).
```
A.objects.extra(
select={
'b_count': 'SELECT COUNT(*) FROM yourapp_b WHERE yourapp_b.a_id = yourapp_a.id',
},
where=... |
258,317 | <p>I have the following snippet in one of my html pages :</p>
<pre><code><div class="inputboximage">
<div class="value2">
<input name='address1' value='Somewhere' type="text" size="26" maxlength="40" />
<br />
</div>
</div>
</code></pre>
<p>My problem is that I ne... | [
{
"answer_id": 258319,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "<p>I think using</p>\n\n<pre><code>$(this).parents('div.inputBoxImage').css(...)\n</code></pre>\n\n<p>instead of <code>$(this.p... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24079/"
] | I have the following snippet in one of my html pages :
```
<div class="inputboximage">
<div class="value2">
<input name='address1' value='Somewhere' type="text" size="26" maxlength="40" />
<br />
</div>
</div>
```
My problem is that I need the `inputboximage background` to change when I click in th... | I think using
```
$(this).parents('div.inputBoxImage').css(...)
```
instead of `$(this.parentNode)` should work.
See the jQuery [traversing documentation](http://docs.jquery.com/Traversing/parents#expr)
Edit: updated following Prody's answer (changed parent to parents) |
258,339 | <p>I have a GUI application that executes (in a new process) "console" applications and parse the output. To redirect the Output i set the pConsole.StartInfo.RedirectStandardOutput to true. I also subscribes to the event pConsole.Exited.</p>
<p>The problem I see is that I have to use Thread.Sleep() in the Exited event... | [
{
"answer_id": 258349,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I strongly suspect that it's just the operating system flushing any output buffers. It looks like your workaround is ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a GUI application that executes (in a new process) "console" applications and parse the output. To redirect the Output i set the pConsole.StartInfo.RedirectStandardOutput to true. I also subscribes to the event pConsole.Exited.
The problem I see is that I have to use Thread.Sleep() in the Exited event handler t... | I don't know if it is any better, but I've just been looking at something similar using threads to read both stderr/stdout, like below. It involves a few extra threads (to avoid deadlocks / complex async code), but seems to work pretty robustly.
The key here is that I `Join()` on the two threads handling IO, so I only... |
258,344 | <p>Is it possible to define a spring-managed EJB3 hibernate listener?</p>
<p>I have this definition in my <strong>persistence.xml</strong>:</p>
<pre><code><properties>
<property name="hibernate.ejb.interceptor"
value="my.class.HibernateAuditInterceptor" />
<property name="hibernate.ej... | [
{
"answer_id": 262992,
"author": "Chochos",
"author_id": 10165,
"author_profile": "https://Stackoverflow.com/users/10165",
"pm_score": 1,
"selected": true,
"text": "<p>The problem is that those properties are just strings. Even if you define your SessionFactory as a Spring bean, any prop... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22992/"
] | Is it possible to define a spring-managed EJB3 hibernate listener?
I have this definition in my **persistence.xml**:
```
<properties>
<property name="hibernate.ejb.interceptor"
value="my.class.HibernateAuditInterceptor" />
<property name="hibernate.ejb.event.post-update"
value="my.class.Hibe... | The problem is that those properties are just strings. Even if you define your SessionFactory as a Spring bean, any properties you pass to it through the hibernateProperties setter are just strings:
```
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="... |
258,355 | <p>I'm trying to find a way to automate some exception logging code to add to the stack information already available.</p>
<p>Is there any way to use reflection to retrieve the values of all variables on the stack (locals and parameters) - I sincerely doubt the names of the variables are available, but in many cases i... | [
{
"answer_id": 258373,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Not really. For this level of digging you'd probably need something like WinDbg.</p>\n\n<p>If a <em>specific</em> v... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] | I'm trying to find a way to automate some exception logging code to add to the stack information already available.
Is there any way to use reflection to retrieve the values of all variables on the stack (locals and parameters) - I sincerely doubt the names of the variables are available, but in many cases it would be... | Not really. For this level of digging you'd probably need something like WinDbg.
If a *specific* variable is of interest, you can add it to the exception yourself (although even this introduces issues with duplicate keys, re-entrancy, etc):
```
string dir = ...todo...
try
{
// some code
}
... |
258,365 | <p>Here is the directory structure</p>
<pre><code>/domain.com
/public_html
/functions
/image
/mobile
/www
</code></pre>
<p>the /domain.com/public_html/www folder has a file index.php
the default web directory is /user/public_html/www
in the index file is an include that includes the functions with
include"..... | [
{
"answer_id": 258370,
"author": "JamShady",
"author_id": 11905,
"author_profile": "https://Stackoverflow.com/users/11905",
"pm_score": 3,
"selected": false,
"text": "<p>You can't serve a page that's outside of the web directory because the path doesn't work, i.e. <a href=\"http://mydoma... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18383/"
] | Here is the directory structure
```
/domain.com
/public_html
/functions
/image
/mobile
/www
```
the /domain.com/public\_html/www folder has a file index.php
the default web directory is /user/public\_html/www
in the index file is an include that includes the functions with
include"../functions/function.inc"... | It is not possible to directly access files outside of the webroot; this is a builtin security restriction that is there for good reason.
It is however possible to use a PHP-script to serve these images for you. This way you can call an image like:
```
/image.php?file=myfile.jpg
```
and use [file\_get\_contents()](... |
258,367 | <p>looking for the standard bug-proofed way to convert "long names" such as "C:\Documents and settings" to their equivalent "short names" "C:\DOCUME~1"</p>
<p>I need this to run an external process from withing my C# app. It fails if I feed it with paths in the "long name".</p>
| [
{
"answer_id": 258382,
"author": "David Arno",
"author_id": 7122,
"author_profile": "https://Stackoverflow.com/users/7122",
"pm_score": 5,
"selected": false,
"text": "<p>If you are prepared to start calling out to Windows API functions, then GetShortPathName() and GetLongPathName() provi... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30324/"
] | looking for the standard bug-proofed way to convert "long names" such as "C:\Documents and settings" to their equivalent "short names" "C:\DOCUME~1"
I need this to run an external process from withing my C# app. It fails if I feed it with paths in the "long name". | Does the external process fail even if you enclose the long file paths in quotes? That may be a simpler method, if the external app supports it.
e.g.
```
myExternalApp "C:\Documents And Settings\myUser\SomeData.file"
``` |
258,372 | <p>I have a div container and have defined its style as follows:</p>
<pre><code>div#tbl-container
{
width: 600px;
overflow: auto;
scrollbar-base-color:#ffeaff
}
</code></pre>
<p>This gives me both horizontal and vertical scroll bars automatically once I populate my table which is contained by this... | [
{
"answer_id": 258379,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 1,
"selected": false,
"text": "<p><strong>CSS3</strong> has the <code>overflow-x</code> property, but I wouldn't expect great support for that. In <strong... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13370/"
] | I have a div container and have defined its style as follows:
```
div#tbl-container
{
width: 600px;
overflow: auto;
scrollbar-base-color:#ffeaff
}
```
This gives me both horizontal and vertical scroll bars automatically once I populate my table which is contained by this div.
I just want only hor... | You shouldn't get both horizontal and vertical scrollbars unless you make the content large enough to require them.
However you typically do in IE due to a bug. Check in other browsers (Firefox etc.) to find out whether it is in fact only IE that is doing it.
IE6-7 (amongst other browsers) supports the proposed CSS3 ... |
258,375 | <p>A lot of iPhone apps use a blue badge to indicate the number of items in the subviews, such as the Mail client:</p>
<p><a href="http://skitch.com/leonho/4xeu/iphoto" rel="noreferrer">iPhoto http://img.skitch.com/20081103-tjr9yupbhgr3sqfh7u56if4rsn.preview.jpg</a></p>
<p>Are there any standards way (or even an API)... | [
{
"answer_id": 258485,
"author": "Kristian",
"author_id": 23246,
"author_profile": "https://Stackoverflow.com/users/23246",
"pm_score": 0,
"selected": false,
"text": "<p>There are a few methods in the NSBezierPath class called \"appendBezierPathWithRoundedRect....\".</p>\n\n<p>I havent t... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30883/"
] | A lot of iPhone apps use a blue badge to indicate the number of items in the subviews, such as the Mail client:
[iPhoto http://img.skitch.com/20081103-tjr9yupbhgr3sqfh7u56if4rsn.preview.jpg](http://skitch.com/leonho/4xeu/iphoto)
Are there any standards way (or even an API) do this?
UPDATE: I have created a class cal... | To my knowledge there's no API for this. However, using CoreGraphics (NSBezierPath is not available on iPhone), you can do it pretty easily. It's just two arcs in a CGPath and some text:
```
CGContextRef context = UIGraphicsGetCurrentContext();
float radius = bounds.size.height / 2.0;
NSString ... |
258,390 | <p>I have a text file of URLs, about 14000. Below is a couple of examples:</p>
<p><a href="http://www.domainname.com/pagename?CONTENT_ITEM_ID=100&param2=123" rel="nofollow noreferrer">http://www.domainname.com/pagename?CONTENT_ITEM_ID=100&param2=123</a><br />
<a href="http://www.domainname.com/images?IMAGE_ID... | [
{
"answer_id": 258396,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile": "https://Stackoverflow.com/users/1821",
"pm_score": 3,
"selected": false,
"text": "<pre><code>list2 = filter( lambda x: x.find( 'CONTENT_ITEM_ID ') != -1, list1 )\n</code></pre>\n\n<p>The filter calls... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30786/"
] | I have a text file of URLs, about 14000. Below is a couple of examples:
<http://www.domainname.com/pagename?CONTENT_ITEM_ID=100¶m2=123>
<http://www.domainname.com/images?IMAGE_ID=10>
<http://www.domainname.com/pagename?CONTENT_ITEM_ID=101¶m2=123>
<http://www.domainname.com/images?IMAGE_ID=11>
<http... | Here's another alternative to Graeme's, using the newer list comprehension syntax:
```
list2= [line for line in file if 'CONTENT_ITEM_ID' in line]
```
Which you prefer is a matter of taste! |
258,397 | <p>I am desiging a new website for my company and I am trying to implement switch navigation which is what I have used on all my sites in the past.</p>
<pre><code><?php
switch($x) {
default:
include("inc/main.php");
break;
case "products":
include("inc/products.php");
break;
}
?>
</code></pre>
<p>For some re... | [
{
"answer_id": 258405,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, your PHP configuration has <strong>correctly</strong> got <code>register_globals</code> turned off, because that's in... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I am desiging a new website for my company and I am trying to implement switch navigation which is what I have used on all my sites in the past.
```
<?php
switch($x) {
default:
include("inc/main.php");
break;
case "products":
include("inc/products.php");
break;
}
?>
```
For some reason when I go to index.php?x=pr... | Yes, your PHP configuration has **correctly** got `register_globals` turned off, because that's incredibly insecure.
Just put:
```
$x = $_REQUEST['x']
```
at the top of your script.
You can also use `$_GET` if you specifically only want this to work for the `GET` HTTP method. I've seen some people claim that `$_RE... |
258,407 | <p>I need to convert a UNICODE_STRING structure to a simple NULL TERMINATED STRING.</p>
<pre><code>typedef
struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
}
UNICODE_STRING, *PUNICODE_STRING;
</code></pre>
<p>I can't find a clean sollution on MSDN about it.
Anyone bee... | [
{
"answer_id": 258693,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 2,
"selected": false,
"text": "<p>You should use WideCharToMultiByte. As an estimate for the output buffer size, you can use the Length field - b... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to convert a UNICODE\_STRING structure to a simple NULL TERMINATED STRING.
```
typedef
struct _UNICODE_STRING
{
USHORT Length;
USHORT MaximumLength;
PWSTR Buffer;
}
UNICODE_STRING, *PUNICODE_STRING;
```
I can't find a clean sollution on MSDN about it.
Anyone been there?
I am not using .... | You should use WideCharToMultiByte. As an estimate for the output buffer size, you can use the Length field - but do consider the case of true multi-byte strings, in which case it will fail with ERROR\_INSUFFICIENT\_BUFFER, and you need to start over with a larger buffer. Or, you call it with an output buffer size of 0... |
258,409 | <p>I have a 'generic' boiler plate static method for checking for InvokeRequired and invoking an associated action accordingly.</p>
<p>If an unhandled exception is raised by the action, the stack trace isn't much help because it starts from here. I can get information about the control, but that isn't always much help... | [
{
"answer_id": 258693,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 2,
"selected": false,
"text": "<p>You should use WideCharToMultiByte. As an estimate for the output buffer size, you can use the Length field - b... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | I have a 'generic' boiler plate static method for checking for InvokeRequired and invoking an associated action accordingly.
If an unhandled exception is raised by the action, the stack trace isn't much help because it starts from here. I can get information about the control, but that isn't always much help. I was wo... | You should use WideCharToMultiByte. As an estimate for the output buffer size, you can use the Length field - but do consider the case of true multi-byte strings, in which case it will fail with ERROR\_INSUFFICIENT\_BUFFER, and you need to start over with a larger buffer. Or, you call it with an output buffer size of 0... |
258,422 | <p>Using qsort in C we pass in a comparison function e.g.</p>
<pre><code>int cmp(const void*, const void*);
</code></pre>
<p>the protoype of qsort expects a <code>int (* )(const void* , const void*)</code> so we call:</p>
<pre><code>qsort(..., cmp);
</code></pre>
<p>but it is equally valid to call:</p>
<pre><code>... | [
{
"answer_id": 258435,
"author": "Jeff Hillman",
"author_id": 3950,
"author_profile": "https://Stackoverflow.com/users/3950",
"pm_score": 3,
"selected": false,
"text": "<p>Whether you feel uncomfortable or not doesn't change the fact that C is not considered a type-safe language. Case i... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26665/"
] | Using qsort in C we pass in a comparison function e.g.
```
int cmp(const void*, const void*);
```
the protoype of qsort expects a `int (* )(const void* , const void*)` so we call:
```
qsort(..., cmp);
```
but it is equally valid to call:
```
qsort(..., &cmp);
```
and this is what we would have to do if we pass... | Whether you feel uncomfortable or not doesn't change the fact that C is not considered a type-safe language. Case in point:
```
int main()
{
int integer = 0xFFFFFF;
void (*functionPointer)() = (void(*)())integer;
functionPointer();
return 0;
}
```
This is completely valid at compile time, but it is... |
258,425 | <p>I have a large project for which I am attempting to use TDD.
I am using <a href="http://tut-framework.sourceforge.net/" rel="nofollow noreferrer">Tut</a> as my test framework, which has its flaws but is sufficient for what I need. </p>
<p>I need to exploit link time test seams, <strong>each test must be in its own ... | [
{
"answer_id": 258453,
"author": "sergtk",
"author_id": 13441,
"author_profile": "https://Stackoverflow.com/users/13441",
"pm_score": 3,
"selected": true,
"text": "<p>\"Is it possible to hide projects from a build and yet still have them build?\"</p>\n\n<p>You can make separate solution ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1575281/"
] | I have a large project for which I am attempting to use TDD.
I am using [Tut](http://tut-framework.sourceforge.net/) as my test framework, which has its flaws but is sufficient for what I need.
I need to exploit link time test seams, **each test must be in its own executable**. The project for this executable then la... | "Is it possible to hide projects from a build and yet still have them build?"
You can make separate solution for test cases.
Then you can set up post build step of your main projects. This post-build should build tests-projects via separate solution and run them. Building test-projects should be done via command line ... |
258,481 | <p>In any (non-web) .net project, the compiler automatically declares the DEBUG and TRACE constants, so I can use conditional compiling to, for example, handle exceptions differently in debug vs release mode.</p>
<p>For example:</p>
<pre><code>#if DEBUG
/* re-throw the exception... */
#else
/* write something... | [
{
"answer_id": 258495,
"author": "Andrew Theken",
"author_id": 32238,
"author_profile": "https://Stackoverflow.com/users/32238",
"pm_score": 4,
"selected": true,
"text": "<p>Look at <a href=\"http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.getsection.asp... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23824/"
] | In any (non-web) .net project, the compiler automatically declares the DEBUG and TRACE constants, so I can use conditional compiling to, for example, handle exceptions differently in debug vs release mode.
For example:
```
#if DEBUG
/* re-throw the exception... */
#else
/* write something in the event log... ... | Look at [ConfigurationManager.GetSection()](http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.getsection.aspx) - this should get you most of the way there.. however, I think you're better off just changing between debug and release modes and letting the compiler determine to execute the ... |
258,483 | <h2>Question</h2>
<p>I'm sure many of you have been faced by the challenge of localizing a database backend to an application. If you've not then I'd be pretty confident in saying that the odds of you having to do so in the future is quite large. I'm talking anout storing multiple translations of texts (and the same c... | [
{
"answer_id": 258678,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 1,
"selected": false,
"text": "<p>I can't see why you need multiple text tables. A single text table, with a \"globally\" unique text ID, should ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25319/"
] | Question
--------
I'm sure many of you have been faced by the challenge of localizing a database backend to an application. If you've not then I'd be pretty confident in saying that the odds of you having to do so in the future is quite large. I'm talking anout storing multiple translations of texts (and the same can ... | I think you can stick with XML which allows for a cleaner design. I would go further and take advantage of the `xml:lang` attribute which [is designed for this usage](http://www.opentag.com/xfaq_lang.htm) :
```
<l10n>
<text xml:lang="sv-SE">Detta är ett namn</text>
<text xml:lang="en-EN">This is a name</text>
</l1... |
258,486 | <p>How to calculate the length (in pixels) of a string in Java?</p>
<p>Preferable without using Swing.</p>
<p>EDIT:
I would like to draw the string using the drawString() in Java2D
and use the length for word wrapping.</p>
| [
{
"answer_id": 258499,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "<p>If you just want to use AWT, then use <a href=\"http://docs.oracle.com/javase/6/docs/api/java/awt/Graphics.html#getFon... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26567/"
] | How to calculate the length (in pixels) of a string in Java?
Preferable without using Swing.
EDIT:
I would like to draw the string using the drawString() in Java2D
and use the length for word wrapping. | If you just want to use AWT, then use [`Graphics.getFontMetrics`](http://docs.oracle.com/javase/6/docs/api/java/awt/Graphics.html#getFontMetrics()) (optionally specifying the font, for a non-default one) to get a `FontMetrics` and then [`FontMetrics.stringWidth`](http://docs.oracle.com/javase/6/docs/api/java/awt/FontMe... |
258,529 | <p>Here's an interface:</p>
<pre><code>public interface Foo<T> extends Comparable<Foo<T>> {
...
}
</code></pre>
<p>And there are some classes implementing this interface:</p>
<pre><code>public class Bar extends Something implements Foo<Something> {
public Vector<Foo<Bar>> ... | [
{
"answer_id": 258623,
"author": "Marcus Downing",
"author_id": 1000,
"author_profile": "https://Stackoverflow.com/users/1000",
"pm_score": 4,
"selected": true,
"text": "<p>What all that code boils down to is:</p>\n\n<pre><code>Vector<A> vector = new Vector<B>();\n</code></pr... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's an interface:
```
public interface Foo<T> extends Comparable<Foo<T>> {
...
}
```
And there are some classes implementing this interface:
```
public class Bar extends Something implements Foo<Something> {
public Vector<Foo<Bar>> giveBar() {
...
}
}
public class Boo extends SomethingElse i... | What all that code boils down to is:
```
Vector<A> vector = new Vector<B>();
```
In this case B extends A, but that's not allowed because the types don't match. To make clear why this doesn't work, imagine the following code:
```
Vector<Vector<?>> vector = new Vector<Vector<String>>();
vector.add(new Vector<Integer... |
258,556 | <p>I am using the <code>OpenArgs</code> parameter to send a value when using <code>DoCmd.OpenForm</code>:</p>
<pre><code>DoCmd.OpenForm "frmSetOther", acNormal, , , acFormAdd, acDialog, "value"
</code></pre>
<p>I then use <code>Me.OpenArgs</code> inside the opened form to grab the <strong><em>value</em></strong>. It... | [
{
"answer_id": 258570,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": "<p>Is the value taken from a user completed control? Do you ensure that the focus is moved from the control before you run... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] | I am using the `OpenArgs` parameter to send a value when using `DoCmd.OpenForm`:
```
DoCmd.OpenForm "frmSetOther", acNormal, , , acFormAdd, acDialog, "value"
```
I then use `Me.OpenArgs` inside the opened form to grab the ***value***. It sometimes sends a **Null** value instead of the original string. What is wrong? | A very interesting alternative to this "openArgs" argument is to use the .properties collection of the currentProject.allforms("myFormName") object. When you need to pass a value to a form (such as a filter inherited from another control or another form, for example), just add the corresponding property for your form, ... |
258,590 | <p>I have an SVN repository structure like below. We are using multiple levels under branches for various release maintenance branches, plus a directory for feature branches.</p>
<p>git-svn init seems to work with a single --branches argument, i.e. it seems to expect all of the branches to be in a single location.</p>... | [
{
"answer_id": 258604,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 0,
"selected": false,
"text": "<p>Would it be feasible to create a <code>git</code> repo for each of the branch subdirectories?</p>\n"
},
{
"answe... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15203/"
] | I have an SVN repository structure like below. We are using multiple levels under branches for various release maintenance branches, plus a directory for feature branches.
git-svn init seems to work with a single --branches argument, i.e. it seems to expect all of the branches to be in a single location.
```
trunk
br... | In your config file, set the svn-remotes section to something like:
```
[svn-remote "svn"]
url = svn://svnserver/repo
fetch = trunk:refs/remotes/trunk
branches = branches/*/*:refs/remotes/*
tags = tags/*:refs/remotes/tags/*
```
This should let you grab the nested branches. |
258,655 | <p>Anyone know how to detect if a television is currently connected to a PC in c#?</p>
<p>Cheers</p>
| [
{
"answer_id": 258697,
"author": "Kristian",
"author_id": 23246,
"author_profile": "https://Stackoverflow.com/users/23246",
"pm_score": 3,
"selected": false,
"text": "<p>How is the device attached?</p>\n\n<p>Whenever a device arrival/removal happens, Windows sends a message called WM_DEV... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33647/"
] | Anyone know how to detect if a television is currently connected to a PC in c#?
Cheers | How is the device attached?
Whenever a device arrival/removal happens, Windows sends a message called WM\_DEVICECHANGE to all the applications running currently in the system. But to receive this message our application should handle the "Windows Process function". C# applications will not have default support for thi... |
258,661 | <p>I have a GridView defined like this:</p>
<pre><code><asp:GridView ID="myGridView" ruant="server">
<asp:BoundField DataField="myField" />
<asp:CommandField ShowDeleteButton="true" ShowEditButton="true" />
</asp:GridView>
</code></pre>
<p>After I put a row into edit mode with the Edit... | [
{
"answer_id": 258669,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "<p>Well, using the knowledge from the question you linked, it's simple:</p>\n\n<pre><code>string js = \"if (event.keyCode =... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I have a GridView defined like this:
```
<asp:GridView ID="myGridView" ruant="server">
<asp:BoundField DataField="myField" />
<asp:CommandField ShowDeleteButton="true" ShowEditButton="true" />
</asp:GridView>
```
After I put a row into edit mode with the Edit button, how do I capture the Enter key and trigge... | Well, using the knowledge from the question you linked, it's simple:
```
string js = "if (event.keyCode == 13) this.form.submit();"
myGridView.Attributes.Add("onkeydown", js);
```
As we found out in the comments, this introduces a small problem. The `GridView_RowUpdating` server event does not fire anymore, but the ... |
258,668 | <p>In GWT, what is the best way to convert a JavaScriptObject overlay type into a JSON string?</p>
<p>I currently have</p>
<pre><code>public final String toJSON() {
return new JSONObject(this).toString();
}
</code></pre>
<p>Which seems to work fine. I would like to know if there are any better approaches.<... | [
{
"answer_id": 332195,
"author": "Mark Renouf",
"author_id": 758,
"author_profile": "https://Stackoverflow.com/users/758",
"pm_score": 3,
"selected": true,
"text": "<p>I've never actually tried that (only consumed JSON so far, never needed to produce it). This seems to be native browser/... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32320/"
] | In GWT, what is the best way to convert a JavaScriptObject overlay type into a JSON string?
I currently have
```
public final String toJSON() {
return new JSONObject(this).toString();
}
```
Which seems to work fine. I would like to know if there are any better approaches. | I've never actually tried that (only consumed JSON so far, never needed to produce it). This seems to be native browser/javascript functionality.
You *could* write it as:
```
public native String toJSON() /*-{
return this.toString();
}-*/;
```
They essentially just do the exact same thing and likely result in ide... |
258,680 | <p>Is there a possible htaccess directive that can transparently forward request from index.php to index_internal.php if the request is coming from an internal ip range?</p>
| [
{
"answer_id": 258704,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 1,
"selected": false,
"text": "<p>Something like this should do it (obviously change the IP address to match your network):</p>\n\n<pre><code>RewriteCond %{... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300/"
] | Is there a possible htaccess directive that can transparently forward request from index.php to index\_internal.php if the request is coming from an internal ip range? | ```
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\. [OR]
RewriteCond %{REMOTE_ADDR} ^10\.15\.
RewriteRule ^index\.php$ index_internal.php [R,NC,QSA,L]
```
What this does:
start mod\_rewrite engine (you may have that already)
if (client IP address starts with "192.168.1." [or]
client IP address starts ... |
258,691 | <p>I am using an XmlDocument to parse and manipulate an XHTML string, converting some nodes to non-HTML nodes.</p>
<p>What is the best way to get a list of all nodes with a given class name? Can it be done with XPath?</p>
| [
{
"answer_id": 258698,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>With a given class? If it is just the one class, then you should be able to do something like .SelectNodes(\"//*[@c... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18107/"
] | I am using an XmlDocument to parse and manipulate an XHTML string, converting some nodes to non-HTML nodes.
What is the best way to get a list of all nodes with a given class name? Can it be done with XPath? | With a given class? If it is just the one class, then you should be able to do something like .SelectNodes("//\*[@class='foo']"). If it isn't xhtml, then the [HTML Agility Pack](http://www.codeplex.com/htmlagilitypack) is worth looking at.
At the client, jQuery would be a good option - and supports composite class nam... |
258,694 | <p>For a one-shot operation, i need to parse the contents of an XML string and change the numbers of the "ID" field. However, i can not risk changing anything else of the string, eg. whitespace, line feeds, etc. MUST remain as they are! </p>
<p>Since i have made the experience that XmlReader tends to mess whitespace u... | [
{
"answer_id": 258723,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "<p>The regex pattern you are looking for is:</p>\n\n<pre><code>ID=\"(\\d+)\"\n</code></pre>\n\n<p>Match group 1 would conta... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15328/"
] | For a one-shot operation, i need to parse the contents of an XML string and change the numbers of the "ID" field. However, i can not risk changing anything else of the string, eg. whitespace, line feeds, etc. MUST remain as they are!
Since i have made the experience that XmlReader tends to mess whitespace up and may ... | The regex pattern you are looking for is:
```
ID="(\d+)"
```
Match group 1 would contain the number. Use a [MatchEvaluator Delegate](http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchevaluator.aspx) to replace matches with dynamically calculated replacements.
```
Regex r = new Regex("ID=\"... |
258,725 | <p>When working with my .Net 2.0 code base ReSharper continually recommends applying the latest c# 3.0 language features, most notably; convert simple properties into auto-implement properties or declaring local variables as var. Amongst others.</p>
<p>When a new language feature arrives do you go back and religiousl... | [
{
"answer_id": 258739,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>If it ain't broke, don't fix it. Of course, if you have confidence in your unit tests, you can give it a whirl, but... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26409/"
] | When working with my .Net 2.0 code base ReSharper continually recommends applying the latest c# 3.0 language features, most notably; convert simple properties into auto-implement properties or declaring local variables as var. Amongst others.
When a new language feature arrives do you go back and religiously apply it ... | If it ain't broke, don't fix it. Of course, if you have confidence in your unit tests, you can give it a whirl, but you shouldn't really go randomly changing code "just because".
Of course - in some cases, simplifying code is a valid reason to make a change - but even something as innocent as switching to an auto-impl... |
258,726 | <p>I am using a bat file on a Windows 2000 SP4 server to copy database files while the database is shut down. Once the bat file hits the xcopy command, it does the copy, but never returns to the bat file to continue with the other commands (start up the database, etc). I should mention that the xcopy takes several ho... | [
{
"answer_id": 258758,
"author": "Brian Knoblauch",
"author_id": 15689,
"author_profile": "https://Stackoverflow.com/users/15689",
"pm_score": 0,
"selected": false,
"text": "<p>There's no timeout that I'm aware of on .bat or .cmd files. However, there may be on the process that's launch... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using a bat file on a Windows 2000 SP4 server to copy database files while the database is shut down. Once the bat file hits the xcopy command, it does the copy, but never returns to the bat file to continue with the other commands (start up the database, etc). I should mention that the xcopy takes several hours. ... | Batch files don't timeout. It sounds like you might be running into a prompt from XCOPY, like an "Are you sure" prompt.
Make sure you've added the necessary command-line switches to XCOPY to make it silent.
The ones I'm aware of are:
```
-Y to suppress prompts about overwriting files
-C continue even if errors occu... |
258,727 | <p>I'd like to display a stack trace in an error dialog in Delphi 2007 (Win32).</p>
<p>Ideally, I'd like something like this:</p>
<pre><code>try
//do something
except on e : exception do
begin
//rollback a transaction or whatever i need to do here
MessageDlg('An error has occurred!' + #13#10 +
... | [
{
"answer_id": 258759,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"http://www.madshi.net/madExceptDescription.htm\" rel=\"noreferrer\">madExcept</a> has a method StackTrace (in unit ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/672/"
] | I'd like to display a stack trace in an error dialog in Delphi 2007 (Win32).
Ideally, I'd like something like this:
```
try
//do something
except on e : exception do
begin
//rollback a transaction or whatever i need to do here
MessageDlg('An error has occurred!' + #13#10 +
e.Message... | [madExcept](http://www.madshi.net/madExceptDescription.htm) has a method StackTrace (in unit madStackTrace) that does that.
[JEDI Code Library](http://sourceforge.net/projects/jcl/) offers similar functionality in unit JclDebug. |
258,729 | <p>I have a simple linux script:</p>
<pre><code>#!/bin/sh
for i in `ls $1`
do
echo $i
done
</code></pre>
<p>In my temp folder are 4 file: a.a, a.aa, a.ab and a.ac</p>
<p>When i call ./script temp/*.?? i get:</p>
<pre><code>temp/a.aa
</code></pre>
<p>When i call ./script "temp/*.??" i get:</p>
<pre><code>te... | [
{
"answer_id": 258778,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 1,
"selected": false,
"text": "<p>Because without the quotes the shell is expanding your call to:</p>\n\n<pre><code>./script temp/a.aa temp/a.ab temp/a.ac... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12860/"
] | I have a simple linux script:
```
#!/bin/sh
for i in `ls $1`
do
echo $i
done
```
In my temp folder are 4 file: a.a, a.aa, a.ab and a.ac
When i call ./script temp/\*.?? i get:
```
temp/a.aa
```
When i call ./script "temp/\*.??" i get:
```
temp/a.aa
temp/a.ab
temp/a.ac
```
Why do the double quote change ... | In the first case the shell expands `temp/*.??` to:
```
temp/a.aa temp/a.ab temp/a.ac
```
Since you are only looking at the first parameter in your script only `temp/a.aa` is passed to ls.
In the second case, the shell does not perform any expansion because of the quotes and the script receives the single argument ... |
258,738 | <p>I have a Java maven project which includes XSLT transformations. I load the stylesheet as follows:</p>
<pre><code>TransformerFactory tFactory = TransformerFactory.newInstance();
DocumentBuilderFactory dFactory = DocumentBuilderFactory
.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuil... | [
{
"answer_id": 258753,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 0,
"selected": false,
"text": "<p>I had a problem similar to this once with relative paths in the XSLT. </p>\n\n<p>If you can, try to put absolute paths in ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8633/"
] | I have a Java maven project which includes XSLT transformations. I load the stylesheet as follows:
```
TransformerFactory tFactory = TransformerFactory.newInstance();
DocumentBuilderFactory dFactory = DocumentBuilderFactory
.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder dBuilder =... | Solved my problem using a URIResolver.
```
class MyURIResolver implements URIResolver {
@Override
public Source resolve(String href, String base) throws TransformerException {
try {
ClassLoader cl = this.getClass().getClassLoader();
java.io.InputStream in = cl.getResourceAsStream("xsl/" + href);
InputSou... |
258,746 | <p>I am working with a huge list of URL's. Just a quick question I have trying to slice a part of the URL out, see below:</p>
<pre><code>http://www.domainname.com/page?CONTENT_ITEM_ID=1234&param2&param3
</code></pre>
<p>How could I slice out:</p>
<pre><code>http://www.domainname.com/page?CONTENT_ITEM_ID=1234... | [
{
"answer_id": 258797,
"author": "RailsSon",
"author_id": 30786,
"author_profile": "https://Stackoverflow.com/users/30786",
"pm_score": 1,
"selected": false,
"text": "<p>I figured it out below is what I needed to do:</p>\n\n<pre><code>url = \"http://www.domainname.com/page?CONTENT_ITEM_I... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30786/"
] | I am working with a huge list of URL's. Just a quick question I have trying to slice a part of the URL out, see below:
```
http://www.domainname.com/page?CONTENT_ITEM_ID=1234¶m2¶m3
```
How could I slice out:
```
http://www.domainname.com/page?CONTENT_ITEM_ID=1234
```
Sometimes there is more than two param... | Use the [urlparse](http://docs.python.org/2/library/urlparse.html#urlparse.urlsplit) module. Check this function:
```
import urlparse
def process_url(url, keep_params=('CONTENT_ITEM_ID=',)):
parsed= urlparse.urlsplit(url)
filtered_query= '&'.join(
qry_item
for qry_item in parsed.query.split('&... |
258,757 | <p>How do I escape a string in SQL Server's stored procedure so that it is safe to use in <code>LIKE</code> expression.</p>
<p>Suppose I have an <code>NVARCHAR</code> variable like so:</p>
<pre><code>declare @myString NVARCHAR(100);
</code></pre>
<p>And I want to use it in a <code>LIKE</code> expression:</p>
<pre><... | [
{
"answer_id": 258766,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 2,
"selected": false,
"text": "<p>You specify the escape character. Documentation here:<br>\n<a href=\"http://msdn.microsoft.com/en-us/library/ms179... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I escape a string in SQL Server's stored procedure so that it is safe to use in `LIKE` expression.
Suppose I have an `NVARCHAR` variable like so:
```
declare @myString NVARCHAR(100);
```
And I want to use it in a `LIKE` expression:
```
... WHERE ... LIKE '%' + @myString + '%';
```
How do I escape the stri... | To escape special characters in a LIKE expression you prefix them with an escape character. You get to choose which escape char to use with the ESCAPE keyword. ([MSDN Ref](http://msdn.microsoft.com/en-us/library/ms179859.aspx))
For example this escapes the % symbol, using \ as the escape char:
```
select * from table... |
258,762 | <p>Is there a way in .NET 2.0 (C#) to serialize object like you do using XmlSerializer in a simple / customizable human readable format thats for instance looks like <a href="http://community.moertel.com/pxsl/" rel="noreferrer">PXLS</a> or JSON?
Also I know that XML is human readable, I'm looking for something with les... | [
{
"answer_id": 258813,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>The built-in serialization options for .Net are Xml, Xml-Soap, and binary. Since you've ruled out xml and binary i... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25782/"
] | Is there a way in .NET 2.0 (C#) to serialize object like you do using XmlSerializer in a simple / customizable human readable format thats for instance looks like [PXLS](http://community.moertel.com/pxsl/) or JSON?
Also I know that XML is human readable, I'm looking for something with less annoying redundancy, somethin... | To Serialize into JSON in .NET you do as follows:
```
public static string ToJson(IEnumerable collection)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(collection.GetType());
string json;
using (MemoryStream m = new MemoryStream())
{
... |
258,767 | <p>I am using <strong>0.97-pre-SVN-unknown</strong> release of Django.</p>
<p>I have a model for which I have not given any primary_key. Django, consequently, automatically provides an AutoField that is called "id". Everything's fine with that. But now, I have to change the "verbose_name" of that Au... | [
{
"answer_id": 259027,
"author": "Justin Voss",
"author_id": 5616,
"author_profile": "https://Stackoverflow.com/users/5616",
"pm_score": 2,
"selected": false,
"text": "<p>Look into the command-line options for <code>manage.py</code>; there's a command to dump all of the model data to JSO... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23191/"
] | I am using **0.97-pre-SVN-unknown** release of Django.
I have a model for which I have not given any primary\_key. Django, consequently, automatically provides an AutoField that is called "id". Everything's fine with that. But now, I have to change the "verbose\_name" of that AutoField to something other than "id". I ... | Hmm... and what about explicitly write *id* field in the model definition? Like this for example:
```
class Entry(models.Model):
id = models.AutoField(verbose_name="custom name")
# and other fields...
```
It doesn't require any underlying database changes. |
258,769 | <p>My link is here:</p>
<p><a href="http://tinyurl.com/5kr4ra" rel="nofollow noreferrer">Example Page</a></p>
<p>I'm using list-style-image: to give my horizontal lists ( very top and bottom ) seperators. I have a class of .first to remove the image from the first li in each list.</p>
<p>Lo and behold in IE6, it doe... | [
{
"answer_id": 258844,
"author": "yoavf",
"author_id": 1011,
"author_profile": "https://Stackoverflow.com/users/1011",
"pm_score": 3,
"selected": true,
"text": "<p>I know this isn't really a solution, but I would recommend using <strong>background-image</strong> instead of <strong>list-s... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] | My link is here:
[Example Page](http://tinyurl.com/5kr4ra)
I'm using list-style-image: to give my horizontal lists ( very top and bottom ) seperators. I have a class of .first to remove the image from the first li in each list.
Lo and behold in IE6, it doesn't work. What happens is that the bullet images are not bei... | I know this isn't really a solution, but I would recommend using **background-image** instead of **list-style image**.
You'll achive the same effect, and it will work in all browsers. |
258,793 | <p>I need to be able to compare some month names I have in an array.</p>
<p>It would be nice if there were some direct way like:</p>
<pre><code>Month.toInt("January") > Month.toInt("May")
</code></pre>
<p>My Google searching seems to suggest the only way is to write your own method, but this seems like a common e... | [
{
"answer_id": 258814,
"author": "Adam Naylor",
"author_id": 17540,
"author_profile": "https://Stackoverflow.com/users/17540",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using c# 3.0 (or above) you can use extenders<br/><br/></p>\n"
},
{
"answer_id": 258828,
"au... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21367/"
] | I need to be able to compare some month names I have in an array.
It would be nice if there were some direct way like:
```
Month.toInt("January") > Month.toInt("May")
```
My Google searching seems to suggest the only way is to write your own method, but this seems like a common enough problem that I would think it ... | `DateTime.ParseExact(monthName, "MMMM", CultureInfo.CurrentCulture ).Month`
Although, for your purposes, you'll probably be better off just creating a `Dictionary<string, int>` mapping the month's name to its value. |
258,807 | <p>I've got 2 remote databases as part of a query </p>
<pre><code>select p.ID,p.ProjectCode_VC,p.Name_VC,v.*
FROM [serverB].Projects.dbo.Projects_T p
LEFT JOIN [serverA].SOCON.dbo.vw_PROJECT v on
p.ProjectCode_VC = v.PROJ_CODE
</code></pre>
<p>The problem is that serverA uses collation <code>Latin1_General_BIN</code>... | [
{
"answer_id": 258855,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 4,
"selected": true,
"text": "<p>Just add the collation to your select, like:</p>\n\n<pre><code>select \n p.ID,\n p.ProjectCode_VC,\n p.Name_VC,\n v.* \nFRO... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2995/"
] | I've got 2 remote databases as part of a query
```
select p.ID,p.ProjectCode_VC,p.Name_VC,v.*
FROM [serverB].Projects.dbo.Projects_T p
LEFT JOIN [serverA].SOCON.dbo.vw_PROJECT v on
p.ProjectCode_VC = v.PROJ_CODE
```
The problem is that serverA uses collation `Latin1_General_BIN` and serverB uses `Latin1_General_CP1... | Just add the collation to your select, like:
```
select
p.ID,
p.ProjectCode_VC,
p.Name_VC,
v.*
FROM
[serverB].Projects.dbo.Projects_T p
LEFT JOIN [serverA].SOCON.dbo.vw_PROJECT v on p.ProjectCode_VC
collate Latin1_General_Bin = v.PROJ_CODE
```
or the other way around. So "convert" one of the coll... |
258,812 | <p>I've created a Silverlight project that produces [something].xap file to package a few silverlight UserControls. I would like to manipulate that .xap file through the use of javascript in the browser to show and hide user controls based upon java script events.</p>
<p>Is it possible to do this?</p>
<p>If so any s... | [
{
"answer_id": 258940,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 0,
"selected": false,
"text": "<p>Here is a my collections of my links for this subject.</p>\n\n<ul>\n<li><a href=\"http://weblogs.asp.net/albertpasc... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2723/"
] | I've created a Silverlight project that produces [something].xap file to package a few silverlight UserControls. I would like to manipulate that .xap file through the use of javascript in the browser to show and hide user controls based upon java script events.
Is it possible to do this?
If so any sample could or lin... | Here's my solution...not sure if it's the "best-practices" way...comments????
In the App class within my Silverlight application I have the following code:
```
private Page _page = null;
private void Application_Startup(object sender, StartupEventArgs e)
{
_page = new Page();
this.RootVisu... |
258,824 | <p>I have a window which overrides a <code>RadioButton</code>'s <code>ControlTemplate</code> to show a custom control inside of it. Inside the custom control, I have a button's visibility tied to <code>IsMouseOver</code>, which works correctly in showing the button only when the mouse is hovering over the control. Howe... | [
{
"answer_id": 258935,
"author": "DavidN",
"author_id": 33662,
"author_profile": "https://Stackoverflow.com/users/33662",
"pm_score": 2,
"selected": true,
"text": "<p>I seemed to have fixed the problem by setting a trigger in the control template, which binds to the RadioButton's IsMouse... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33662/"
] | I have a window which overrides a `RadioButton`'s `ControlTemplate` to show a custom control inside of it. Inside the custom control, I have a button's visibility tied to `IsMouseOver`, which works correctly in showing the button only when the mouse is hovering over the control. However, when I click on the `RadioButto... | I seemed to have fixed the problem by setting a trigger in the control template, which binds to the RadioButton's IsMouseOver, and sets a custom DependencyProperty on the UserControl.
Something like:
```
<ControlTemplate TargetType="{x:Type RadioButton}">
<WPFTest:TestUC x:Name="UC" />
<ControlTemplate.Trig... |
258,857 | <p>In C#, how do I set the Identity of a Thread?</p>
<p>For example, if I have Thread MyThread, which is already started, can I change MyThread's Identity?</p>
<p>Or is this not possible?</p>
| [
{
"answer_id": 258884,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, using <a href=\"http://msdn.microsoft.com/en-us/library/system.security.principal.windowsimpersonationcontext.aspx\" ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | In C#, how do I set the Identity of a Thread?
For example, if I have Thread MyThread, which is already started, can I change MyThread's Identity?
Or is this not possible? | You can set the Identity of a thread by creating a new Principal. You can use any Identity that inherits from [System.Security.Principal.IIdentity](https://msdn.microsoft.com/en-us/library/system.security.principal.iidentity(v=vs.110).aspx), but you need a class that inherits from [System.Security.Principal.IPrincipal]... |
258,858 | <p>I'm dynamically generating an asp form, and I would like to add the <strong>label</strong> and <strong>input</strong> elements inside a list.</p>
<p>For example, I would like to end up with something like:</p>
<pre><code><ul>
<li><label for="input"/><input id=input"/></li>
</ul>... | [
{
"answer_id": 259043,
"author": "Michael DeLorenzo",
"author_id": 1383003,
"author_profile": "https://Stackoverflow.com/users/1383003",
"pm_score": 0,
"selected": false,
"text": "<p>You could probably do something like this using a Repeater. </p>\n\n<pre><code><asp:Repeater ID=\"rpt... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920/"
] | I'm dynamically generating an asp form, and I would like to add the **label** and **input** elements inside a list.
For example, I would like to end up with something like:
```
<ul>
<li><label for="input"/><input id=input"/></li>
</ul>
```
To do this, I create a Label object and a TextBox object, then assign the As... | The System.Web.UI.HtmlControls namespace has some useful controls.
In your aspx:
```
<asp:PlaceHolder ID="PlaceHolder1" runat="server" />
```
In your code behind:
```
HtmlGenericControl list = new HtmlGenericControl("ul");
for (int i = 0; i < 10; i++)
{
HtmlGenericControl listItem = new HtmlGenericControl("li"... |
258,864 | <p>When an <code>Expression<T></code> is compiled, is the resultant code implicitly cached by the framework? I'm thinking along the lines of the static <code>Regex</code> methods where the framework implicitly compiles and caches the last few regexes.</p>
<p>If compiled <code>Expression<T></code> objects a... | [
{
"answer_id": 258907,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>No; I do not believe that it is; if you want it cached, you must hold onto the <code>Delegate</code> reference (typ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30321/"
] | When an `Expression<T>` is compiled, is the resultant code implicitly cached by the framework? I'm thinking along the lines of the static `Regex` methods where the framework implicitly compiles and caches the last few regexes.
If compiled `Expression<T>` objects are **not** cached, can you recommend some best practice... | No; I do not believe that it is; if you want it cached, you must hold onto the `Delegate` reference (typically `Func<...>` or `Action<...>`). Likewise, if you want to get the best performance, you would compile it as a parameterised expression, so you can send in different values when you invoke it.
In this case, re-p... |
258,871 | <p>I want to find in a vector of Object pointers for a matching object. Here's a sample code to illustrate my problem:</p>
<pre><code>class A {
public:
A(string a):_a(a) {}
bool operator==(const A& p) {
return p._a == _a;
}
private:
string _a;
};
vector<A*> va;
va.push_back(new A... | [
{
"answer_id": 258898,
"author": "Laserallan",
"author_id": 11758,
"author_profile": "https://Stackoverflow.com/users/11758",
"pm_score": 1,
"selected": false,
"text": "<p>Try using find_if instead. It has a parameter for a predicate where you can decide exactly how to check wheter you f... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28161/"
] | I want to find in a vector of Object pointers for a matching object. Here's a sample code to illustrate my problem:
```
class A {
public:
A(string a):_a(a) {}
bool operator==(const A& p) {
return p._a == _a;
}
private:
string _a;
};
vector<A*> va;
va.push_back(new A("one"));
va.push_back(n... | Use find\_if with a functor:
```
template <typename T>
struct pointer_values_equal
{
const T* to_find;
bool operator()(const T* other) const
{
return *to_find == *other;
}
};
// usage:
void test(const vector<A*>& va)
{
A* to_find = new A("two");
pointer_values_equal<A> eq = { to_find ... |
258,875 | <p>I was looking into using some .NET code from within a Delphi program, I will need to make my program extensible using .net assemblies and predefined functions (I already support regular DLLs).</p>
<p>After a lot of searching online, I found <a href="http://www.managed-vcl.com/" rel="noreferrer">Managed-VCL</a>, bu... | [
{
"answer_id": 258904,
"author": "zendar",
"author_id": 25732,
"author_profile": "https://Stackoverflow.com/users/25732",
"pm_score": 2,
"selected": false,
"text": "<p>You can use .Net classes as COM objects in Delphi:</p>\n\n<ul>\n<li>create assembly in C# </li>\n<li>create type library... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25544/"
] | I was looking into using some .NET code from within a Delphi program, I will need to make my program extensible using .net assemblies and predefined functions (I already support regular DLLs).
After a lot of searching online, I found [Managed-VCL](http://www.managed-vcl.com/), but I'm not ready to pay $250 for what I ... | In the Jedi Code Library (JCL) - free - there is a JclDotNet.pas, containing a class TJclClrHost, probably doing what you want:
```
TJclClrHost = class(TJclClrBase, ICorRuntimeHost)
private
FDefaultInterface: ICorRuntimeHost;
FAppDomains: TObjectList;
procedure EnumAppDomains;
function GetAppDomain... |
258,877 | <p>I am trying to render a user control into a string. The application is set up to enable user to use tokens and user controls are rendered where the tokens are found.</p>
<pre><code>StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter writer = new HtmlTextWriter(sw);
Contr... | [
{
"answer_id": 258888,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 2,
"selected": false,
"text": "<p>You would need to attach the control to a Page by adding it to a Controls collection of the Page or a Control on the page... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12252/"
] | I am trying to render a user control into a string. The application is set up to enable user to use tokens and user controls are rendered where the tokens are found.
```
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter writer = new HtmlTextWriter(sw);
Control uc = LoadCon... | I've been using the following code provided by Scott Guthrie in his blog for quite some time:
```
public class ViewManager
{
public static string RenderView(string path, object data)
{
Page pageHolder = new Page();
UserControl viewControl = (UserControl) pageHolder.LoadControl(path);
i... |
258,908 | <p>I'm trying to find a way to determine how many parameters a constructor has.</p>
<p>Now I've built one constructor with no parameters and 1 constructor with 4 parameters.</p>
<p>Is there, in C#, a way to find out how many parameters a used or given constructor has?</p>
<p>Thing is, I'm using a third constructor t... | [
{
"answer_id": 258915,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<p>i'm not sure exactly what context you need this information, but if you need it dynamically at run-time try the Sy... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I'm trying to find a way to determine how many parameters a constructor has.
Now I've built one constructor with no parameters and 1 constructor with 4 parameters.
Is there, in C#, a way to find out how many parameters a used or given constructor has?
Thing is, I'm using a third constructor to read log files. These ... | You should look at the System.Reflection Namespace. More specifically, you can get a list of the constructors of a class with:
```
System.Type.GetType("MYClassName").GetConstructors()
``` |
258,917 | <p>I have a problem applying the <code>DebuggerDisplay</code> attribute on a generic class:</p>
<pre><code>[DebuggerDisplay("--foo--")]
class Foo
{
}
[DebuggerDisplay("Bar: {t}")]
class Bar<T>
{
public T t;
}
</code></pre>
<p>When inspecting an object of type <code>Bar<Foo></code> I would expect it t... | [
{
"answer_id": 258961,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 5,
"selected": true,
"text": "<p>The DebuggerDisplay attribute is not recursive. The {} inside the string essentially say evaluate this expression and ... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31890/"
] | I have a problem applying the `DebuggerDisplay` attribute on a generic class:
```
[DebuggerDisplay("--foo--")]
class Foo
{
}
[DebuggerDisplay("Bar: {t}")]
class Bar<T>
{
public T t;
}
```
When inspecting an object of type `Bar<Foo>` I would expect it to show as `Bar: --foo--`, but I get `Bar: {Foo}`
What am I ... | The DebuggerDisplay attribute is not recursive. The {} inside the string essentially say evaluate this expression and display the result inline. The string for the inner result is calculated as if there was no DebuggerDisplay attribute in play for type or member. That is why you see {Foo} instead of --foo--.
The reas... |
258,954 | <p>Java is nearing version 7. It occurs to me that there must be plenty of textbooks and training manuals kicking around that teach methods based on older versions of Java, where the methods taught, would have far better solutions now.</p>
<p>What are some boilerplate code situations, especially ones that you see peop... | [
{
"answer_id": 258956,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 5,
"selected": false,
"text": "<p>Generics and no longer needing to create an iterator to go through all elements in a collection. The new version is much b... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] | Java is nearing version 7. It occurs to me that there must be plenty of textbooks and training manuals kicking around that teach methods based on older versions of Java, where the methods taught, would have far better solutions now.
What are some boilerplate code situations, especially ones that you see people impleme... | Enums. Replacing
```
public static final int CLUBS = 0;
public static final int DIAMONDS = 1;
public static final int HEARTS = 2;
public static final int SPADES = 3;
```
with
```
public enum Suit {
CLUBS,
DIAMONDS,
HEARTS,
SPADES
}
``` |
258,960 | <p>Is there a way for me to serialize an object in .NET without the XML Namespaces automatically serializing also? It seems that by default .NET believes the XSI and XSD namespaces should be included, but I don't want them there.</p>
| [
{
"answer_id": 258974,
"author": "Wes P",
"author_id": 13611,
"author_profile": "https://Stackoverflow.com/users/13611",
"pm_score": 8,
"selected": true,
"text": "<p>Ahh... nevermind. It's always the search after the question is posed that yields the answer. My object that is being ser... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13611/"
] | Is there a way for me to serialize an object in .NET without the XML Namespaces automatically serializing also? It seems that by default .NET believes the XSI and XSD namespaces should be included, but I don't want them there. | Ahh... nevermind. It's always the search after the question is posed that yields the answer. My object that is being serialized is `obj` and has already been defined. Adding an XMLSerializerNamespace with a single empty namespace to the collection does the trick.
In VB like this:
```
Dim xs As New XmlSerializer(GetTy... |
258,968 | <p>Just wondering what the difference between MFC control messages prefixed with the following is:</p>
<pre><code>LVN (e.g. LVN_ITEMCHANGED)
HDN (e.g. HDN_TRACK)
NM (e.g. NM_HOVER)
</code></pre>
<p>Also, I am using a ListControl and trapping when the user clicks on an item using the NM_CLICK message. I also want to t... | [
{
"answer_id": 258979,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "<ul>\n<li>LVN = ListView Notification</li>\n<li>HDN = HeaDer control Notification</li>\n<li>NM = er..um.. \"Notificat... | 2008/11/03 | [
"https://Stackoverflow.com/questions/258968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | Just wondering what the difference between MFC control messages prefixed with the following is:
```
LVN (e.g. LVN_ITEMCHANGED)
HDN (e.g. HDN_TRACK)
NM (e.g. NM_HOVER)
```
Also, I am using a ListControl and trapping when the user clicks on an item using the NM\_CLICK message. I also want to trap when a user selects a... | For change in selection, you need to handle the LVN\_ITEMCHANGED notification:
```
NMLISTVIEW & nm = *(NMLISTVIEW *) pnmh;
if ( (nm.uNewState ^ nm.uOldState) & LVIS_SELECTED)
{
// nm.iItem was selected or deselected
if (!m_internalUIChange)
{
// see below
}
}
```
The first "if" checks if the... |