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 |
|---|---|---|---|---|---|---|
32,145 | <p>I'm going to try something with the format of this question and I'm very open to suggestions about a better way to handle it.</p>
<p>I didn't want to just dump a bunch of code in the question so I've posted the code for the class on <code>refactormycode</code>.</p>
<p><strong><a href="http://www.refactormycode.com... | [
{
"answer_id": 32191,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 3,
"selected": false,
"text": "<p>The way I do it is the following:</p>\n\n<pre><code>class test {\n protected $x='';\n protected $y='';\n\n function set... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | I'm going to try something with the format of this question and I'm very open to suggestions about a better way to handle it.
I didn't want to just dump a bunch of code in the question so I've posted the code for the class on `refactormycode`.
**[base class for easy class property handling](http://www.refactormycode.... | The way I do it is the following:
```
class test {
protected $x='';
protected $y='';
function set_y ($y) {
print "specific function set_y\n";
$this->y = $y;
}
function __call($function , $args) {
print "generic function $function\n";
list ($name , $var ) = split ('... |
32,149 | <p>Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as <code>"GEORGE BURDELL"</code> or <code>"george burdell"</code> and turns it into <code>"George Burdell"</code>.</p>
<p>I have a simple one that handles the simple cases. Th... | [
{
"answer_id": 32189,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "<p>What programming language do you use? Many languages allow callback functions for regular expression matches. These... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3203/"
] | Does anyone have a trusted Proper Case or PCase algorithm (similar to a UCase or Upper)? I'm looking for something that takes a value such as `"GEORGE BURDELL"` or `"george burdell"` and turns it into `"George Burdell"`.
I have a simple one that handles the simple cases. The ideal would be to have something that can h... | Unless I've misunderstood your question I don't think you need to roll your own, the TextInfo class can do it for you.
```
using System.Globalization;
CultureInfo.InvariantCulture.TextInfo.ToTitleCase("GeOrGE bUrdEll")
```
Will return "George Burdell. And you can use your own culture if there's some special rules i... |
32,168 | <p>A question related to <a href="https://stackoverflow.com/questions/28002">Regular cast vs. static_cast vs. dynamic_cast</a>:</p>
<p>What cast syntax style do you prefer in C++?</p>
<ul>
<li>C-style cast syntax: <code>(int)foo</code></li>
<li>C++-style cast syntax: <code>static_cast<int>(foo)</code></li>
<li>... | [
{
"answer_id": 32180,
"author": "CiNN",
"author_id": 2566,
"author_profile": "https://Stackoverflow.com/users/2566",
"pm_score": 1,
"selected": false,
"text": "<p>C-style cast syntax, do not error check.\nC++-style cast syntax, does some checking.\nWhen using static_cast, even if it does... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2686/"
] | A question related to [Regular cast vs. static\_cast vs. dynamic\_cast](https://stackoverflow.com/questions/28002):
What cast syntax style do you prefer in C++?
* C-style cast syntax: `(int)foo`
* C++-style cast syntax: `static_cast<int>(foo)`
* constructor syntax: `int(foo)`
They may not translate to exactly the sa... | It's best practice *never* to use C-style casts for three main reasons:
* as already mentioned, no checking is performed here. The programmer simply cannot know which of the various casts is used which weakens strong typing
* the new casts are intentionally visually striking. Since casts often reveal a weakness in the... |
32,173 | <p>I'm trying to disable a bunch of controls with JavaScript (so that they post back values). All the controls work fine except for my radio buttons as they lose their value. In the below code which is called via a recursive function to disable all child controls the Second else (else if (control is <code>RadioButton</... | [
{
"answer_id": 32203,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Off the top of my head, I think you have to check the \"type\" attribute of the checkbox to determine if it's a radio button... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2808/"
] | I'm trying to disable a bunch of controls with JavaScript (so that they post back values). All the controls work fine except for my radio buttons as they lose their value. In the below code which is called via a recursive function to disable all child controls the Second else (else if (control is `RadioButton`)) is nev... | I found 2 ways to get this to work, the below code correctly distinguishes between the RadioButton and Checkbox controls.
```
private static void DisableControl(WebControl control)
{
Type controlType = control.GetType();
if (controlType == typeof(CheckBox))
{
((CheckBox)con... |
32,231 | <p>Are there any rapid Database protoyping tools that don't require me to declare a database schema, but rather create it based on the way I'm using my entities.</p>
<p>For example, assuming an empty database (pseudo code):</p>
<pre><code>user1 = new User() // Creates the user table with a single id column
user1.fir... | [
{
"answer_id": 32297,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://code.google.com/appengine/\" rel=\"nofollow noreferrer\">Google's Application Engine</a> works like t... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Are there any rapid Database protoyping tools that don't require me to declare a database schema, but rather create it based on the way I'm using my entities.
For example, assuming an empty database (pseudo code):
```
user1 = new User() // Creates the user table with a single id column
user1.firstName = "Allain" // ... | [Google's Application Engine](http://code.google.com/appengine/) works like this. When you download the toolkit you get a local copy of the database engine for testing. |
32,241 | <p><a href="https://stackoverflow.com/questions/32149/does-anyone-have-a-good-proper-case-algorithm">Using this question</a> as the base is there an alogrithm or coding example to change some text to Pascal or Camel casing.</p>
<p>For example:</p>
<pre><code>mynameisfred
</code></pre>
<p>becomes</p>
<pre><code>Came... | [
{
"answer_id": 32277,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 0,
"selected": false,
"text": "<p>The only way to do that would be to run each section of the word through a dictionary.</p>\n\n<p>\"mynameisfred\" is jus... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075/"
] | [Using this question](https://stackoverflow.com/questions/32149/does-anyone-have-a-good-proper-case-algorithm) as the base is there an alogrithm or coding example to change some text to Pascal or Camel casing.
For example:
```
mynameisfred
```
becomes
```
Camel: myNameIsFred
Pascal: MyNameIsFred
``` | I found a thread with a bunch of Perl guys arguing the toss on this question over at <http://www.perlmonks.org/?node_id=336331>.
I hope this isn't too much of a non-answer to the question, but I would say you have a bit of a problem in that it would be a very open-ended algorithm which could have a lot of 'misses' as ... |
32,243 | <p>The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. </p>
<p>Even though <code>imagesavealpha</code> is set, something isn't quite right.</p>
<p>What's the... | [
{
"answer_id": 32270,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 4,
"selected": false,
"text": "<p>I believe this should do the trick:</p>\n\n<pre><code>$srcImage = imagecreatefrompng($uploadTempFile);\nimagealphab... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1820/"
] | The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case.
Even though `imagesavealpha` is set, something isn't quite right.
What's the best way to preserve the tr... | ```
imagealphablending( $targetImage, false );
imagesavealpha( $targetImage, true );
```
did it for me. Thanks ceejayoz.
note, the target image needs the alpha settings, not the source image.
Edit:
full replacement code. See also answers below and their comments. This is not guaranteed to be be perfect in any way, ... |
32,260 | <p>Instead of relying on my host to send an email, I was thinking of sending the email messages using my <strong>Gmail</strong> account. The emails are personalized emails to the bands I play on my show. </p>
<p>Is it possible to do it?</p>
| [
{
"answer_id": 32336,
"author": "Domenic",
"author_id": 3191,
"author_profile": "https://Stackoverflow.com/users/3191",
"pm_score": 11,
"selected": true,
"text": "<p>Be sure to use <code>System.Net.Mail</code>, not the deprecated <code>System.Web.Mail</code>. Doing SSL with <code>System.... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535/"
] | Instead of relying on my host to send an email, I was thinking of sending the email messages using my **Gmail** account. The emails are personalized emails to the bands I play on my show.
Is it possible to do it? | Be sure to use `System.Net.Mail`, not the deprecated `System.Web.Mail`. Doing SSL with `System.Web.Mail` is a gross mess of hacky extensions.
```
using System.Net;
using System.Net.Mail;
var fromAddress = new MailAddress("from@gmail.com", "From Name");
var toAddress = new MailAddress("to@example.com", "To Name");
con... |
32,280 | <p>I am in the middle of reading the excellent <a href="https://rads.stackoverflow.com/amzn/click/com/0132350882" rel="noreferrer" rel="nofollow noreferrer">Clean Code</a></p>
<p>One discussion is regarding passing nulls into a method.</p>
<pre><code>public class MetricsCalculator {
public double xProjection(Poin... | [
{
"answer_id": 32295,
"author": "wvdschel",
"author_id": 2018,
"author_profile": "https://Stackoverflow.com/users/2018",
"pm_score": 1,
"selected": false,
"text": "<p>I generally prefer not doing either, since it's just slowing things down. NullPointerExceptions are thrown later on anywa... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3295/"
] | I am in the middle of reading the excellent [Clean Code](https://rads.stackoverflow.com/amzn/click/com/0132350882)
One discussion is regarding passing nulls into a method.
```
public class MetricsCalculator {
public double xProjection(Point p1, Point p2) {
return (p2.x - p1.x) * 1.5;
}
}
...
calculato... | Both the use of assertions and the throwing of exceptions are valid approaches here. Either mechanism can be used to indicate a programming error, not a runtime error, as is the case here.
* Assertions have the advantage of performance as they are typically disabled on production systems.
* Exceptions have the advanta... |
32,332 | <p>This isn't a design question, really, though it may seem like it. (Well, okay, it's kind of a design question). What I'm wondering is why the C++ <code>std::fstream</code> classes don't take a <code>std::string</code> in their constructor or open methods. Everyone loves code examples so:</p>
<pre><code>#include <... | [
{
"answer_id": 32353,
"author": "Magnus Westin",
"author_id": 2957,
"author_profile": "https://Stackoverflow.com/users/2957",
"pm_score": 0,
"selected": false,
"text": "<p>Is there any class in STL that takes a string... I dont think so (couldnt find any in my quick search). So it's prob... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | This isn't a design question, really, though it may seem like it. (Well, okay, it's kind of a design question). What I'm wondering is why the C++ `std::fstream` classes don't take a `std::string` in their constructor or open methods. Everyone loves code examples so:
```
#include <iostream>
#include <fstream>
#include ... | By taking a C string the C++03 [`std::fstream`](http://en.cppreference.com/w/cpp/io/basic_fstream) class reduced dependency on the `std::string` class. In C++11, however, the `std::fstream` class does allow passing a `std::string` for its constructor parameter.
Now, you may wonder why isn't there a transparent convers... |
32,333 | <p>Here's a perfect example of the problem: <a href="http://blog.teksol.info/2009/03/27/argumenterror-on-number-sum-when-using-classifier-bayes.html" rel="nofollow noreferrer">Classifier gem breaks Rails</a>.</p>
<p>** Original question: **</p>
<p>One thing that concerns me as a security professional is that Ruby doe... | [
{
"answer_id": 32471,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 1,
"selected": false,
"text": "<p>I guess Ruby has that a feature - valued more over it being a security issue. Ducktyping too.<br>\nE.g. I can add my own me... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | Here's a perfect example of the problem: [Classifier gem breaks Rails](http://blog.teksol.info/2009/03/27/argumenterror-on-number-sum-when-using-classifier-bayes.html).
\*\* Original question: \*\*
One thing that concerns me as a security professional is that Ruby doesn't have a parallel of Java's package-privacy. Th... | Check out [Immutable](http://scie.nti.st/2008/9/17/making-methods-immutable-in-ruby) by Garry Dolley.
You can prevent redefinition of individual methods. |
32,360 | <p>How do you specify that a foreign key constraint should be a 1:1 relationship in transact sql? Is declaring the column UNIQUE enough? Below is my existing code.!</p>
<pre><code>CREATE TABLE [dbo].MyTable(
[MyTablekey] INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[OtherTableKey] INT NOT NULL UNIQUE
... | [
{
"answer_id": 32372,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 2,
"selected": false,
"text": "<p>You could declare the column to be both the primary key and a foreign key. This is a good strategy for \"extension\"... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3400/"
] | How do you specify that a foreign key constraint should be a 1:1 relationship in transact sql? Is declaring the column UNIQUE enough? Below is my existing code.!
```
CREATE TABLE [dbo].MyTable(
[MyTablekey] INT IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[OtherTableKey] INT NOT NULL UNIQUE
CONSTRAINT [... | A foreign key column with the UNIQUE and NOT NULL constraints that references a UNIQUE, NOT NULL column in another table creates a 1:(0|1) relationship, which is probably what you want.
If there was a true 1:1 relationship, every record in the first table would have a corresponding record in the second table and vice-... |
32,369 | <p>One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes ... | [
{
"answer_id": 32378,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 3,
"selected": false,
"text": "<p>Not really - the only thing you could realistically do is offer advice on the site; maybe, before their first time s... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3262/"
] | One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes peo... | I'm not sure if it'll work in all browsers but you should try setting autocomplete="off" on the form.
```
<form id="loginForm" action="login.cgi" method="post" autocomplete="off">
```
>
> The easiest and simplest way to disable Form **and Password storage prompts** and prevent form data from being cached in session... |
32,397 | <p>On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine. </p>
| [
{
"answer_id": 32399,
"author": "Tall Jeff",
"author_id": 1553,
"author_profile": "https://Stackoverflow.com/users/1553",
"pm_score": 5,
"selected": true,
"text": "<p>My understanding is that it is approximately the following from another <a href=\"https://stackoverflow.com/questions/240... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1942/"
] | On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine. | My understanding is that it is approximately the following from another [Jeff Atwood](https://stackoverflow.com/questions/24066/what-formula-should-be-used-to-determine-hot-questions) post
```
t = (time of entry post) - (Dec 8, 2005)
x = upvotes - downvotes
y = {1 if x > 0, 0 if x = 0, -1 if x < 0)
z = {1 if x < 1, o... |
32,404 | <p>I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which provides a higher level interface for operations on these objects, and the other programs to access the objects through that service.</p>
<p>I am c... | [
{
"answer_id": 32440,
"author": "Ricardo Reyes",
"author_id": 3399,
"author_profile": "https://Stackoverflow.com/users/3399",
"pm_score": 9,
"selected": true,
"text": "<p>Yes you can. I do it using the pythoncom libraries that come included with <a href=\"http://www.activestate.com/Produ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | I am sketching the architecture for a set of programs that share various interrelated objects stored in a database. I want one of the programs to act as a service which provides a higher level interface for operations on these objects, and the other programs to access the objects through that service.
I am currently a... | Yes you can. I do it using the pythoncom libraries that come included with [ActivePython](http://www.activestate.com/Products/activepython/index.mhtml) or can be installed with [pywin32](https://sourceforge.net/projects/pywin32/) (Python for Windows extensions).
This is a basic skeleton for a simple service:
```
impo... |
32,414 | <p>We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. That being said, one issue we are running into is that after we push out an update with new JavaScript files, the clien... | [
{
"answer_id": 32427,
"author": "Huppie",
"author_id": 1830,
"author_profile": "https://Stackoverflow.com/users/1830",
"pm_score": 10,
"selected": true,
"text": "<p>As far as I know a common solution is to add a <code>?<version></code> to the script's src link.</p>\n\n<p>For instan... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2176/"
] | We are currently working in a private beta and so are still in the process of making fairly rapid changes, although obviously as usage is starting to ramp up, we will be slowing down this process. That being said, one issue we are running into is that after we push out an update with new JavaScript files, the client br... | As far as I know a common solution is to add a `?<version>` to the script's src link.
For instance:
```
<script type="text/javascript" src="myfile.js?1500"></script>
```
---
>
> I assume at this point that there isn't a better way than find-replace to increment these "version numbers" in all of the script tags?
>... |
32,428 | <p>I've created an assembly and referenced it in my Reporting Services report. I've tested the report locally (works), and I then uploaded the report to a report server (doesn't work).</p>
<p>Here is the error that is thrown by the custom code I've written.</p>
<blockquote>
<p>System.Security.SecurityException:
R... | [
{
"answer_id": 37379,
"author": "Ian Robinson",
"author_id": 326,
"author_profile": "https://Stackoverflow.com/users/326",
"pm_score": 4,
"selected": true,
"text": "<p>This is how I was able to solve the issue:</p>\n\n<ul>\n<li>strongly sign the custom assembly in question</li>\n<li><p>m... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326/"
] | I've created an assembly and referenced it in my Reporting Services report. I've tested the report locally (works), and I then uploaded the report to a report server (doesn't work).
Here is the error that is thrown by the custom code I've written.
>
> System.Security.SecurityException:
> Request for the permission ... | This is how I was able to solve the issue:
* strongly sign the custom assembly in question
* modify the rssrvpolicy.config file to add permissions for the assembly
```
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSe... |
32,433 | <p>This query works great:</p>
<pre><code>var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select op)
.SingleOrDefault();
</code></pre>
<p>I get a ... | [
{
"answer_id": 32445,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>You must create a new anonymous type:</p>\n\n<pre><code> select new { op, pg }\n</code></pre>\n\n<p>Refer to the of... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | This query works great:
```
var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select op)
.SingleOrDefault();
```
I get a new type with my 'op' fiel... | You can use anonymous types for this, i.e.:
```
var pageObject = (from op in db.ObjectPermissions
join pg in db.Pages on op.ObjectPermissionName equals page.PageName
where pg.PageID == page.PageID
select new { pg, op }).SingleOrDefault();
```
This will make pageO... |
32,460 | <p>Here's the situation: I need to bind a WPF <code>FixedPage</code> against a <code>DataRow</code>. Bindings don't work against <code>DataRows</code>; they work against <code>DataRowViews</code>. I need to do this in the most generic way possible, as I know nothing about and have no control over what is in the <cod... | [
{
"answer_id": 32483,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<pre><code>row.Table.DefaultView[row.Table.Rows.IndexOf(row)]\n</code></pre>\n\n<p>This is an okay answer. But if you find you... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's the situation: I need to bind a WPF `FixedPage` against a `DataRow`. Bindings don't work against `DataRows`; they work against `DataRowViews`. I need to do this in the most generic way possible, as I know nothing about and have no control over what is in the `DataRow`.
What I need is to be able to get a `DataR... | Not Exactly a sexy piece of code but their doesn't seem to be an automated way to find the row without just looping the table.
```
DataRowView newRowView = null;
foreach (DataRowView tempRowView in myDataTable.DefaultView)
{
if (tempRowView.Row == rowToMatch)
newRowV... |
32,462 | <p>So I've got a hobby site I'm working on. I've got items that are tagged and I want to associate those items with photos from Flickr. Even with restrictive searches, I might get results numbering in the thousands.</p>
<p>Requirements:</p>
<ol>
<li>I want to display between 10-20 pictures but I want to randomize t... | [
{
"answer_id": 32483,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<pre><code>row.Table.DefaultView[row.Table.Rows.IndexOf(row)]\n</code></pre>\n\n<p>This is an okay answer. But if you find you... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2863/"
] | So I've got a hobby site I'm working on. I've got items that are tagged and I want to associate those items with photos from Flickr. Even with restrictive searches, I might get results numbering in the thousands.
Requirements:
1. I want to display between 10-20 pictures but I want to randomize the photos each time.
2... | Not Exactly a sexy piece of code but their doesn't seem to be an automated way to find the row without just looping the table.
```
DataRowView newRowView = null;
foreach (DataRowView tempRowView in myDataTable.DefaultView)
{
if (tempRowView.Row == rowToMatch)
newRowV... |
32,537 | <p>For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?</p>
<p>Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown a... | [
{
"answer_id": 32557,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 1,
"selected": false,
"text": "<p>I think it depends on the console. The usefulness of a CMD console on windows pails in comparison to a Powershell console.... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2001/"
] | For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?
Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown apps, but a... | >
> I am thinking more along the lines of Ruby, ...
>
>
>
Well for Ruby the `irb` interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:
* *Automation*. You are allowed a `.irbrc` file that will be automatically ex... |
32,540 | <p>How is your javaScript code organized? Does it follow patterns like MVC, or something else? </p>
<p>I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com" rel="noreferrer"... | [
{
"answer_id": 32594,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 4,
"selected": true,
"text": "<p>..but Javascript has many facets that <strong>are</strong> OO.</p>\n\n<p>Consider this:</p>\n\n<pre><code>var Vehicle... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3436/"
] | How is your javaScript code organized? Does it follow patterns like MVC, or something else?
I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with [jQuery](http://jquery.com), however, the logic on the... | ..but Javascript has many facets that **are** OO.
Consider this:
```
var Vehicle = jQuery.Class.create({
init: function(name) { this.name = name; }
});
var Car = Vehicle.extend({
fillGas: function(){
this.gas = 100;
}
});
```
I've used this technique to create page-level javascript classes tha... |
32,541 | <p>Anybody have a good example how to deep clone a WPF object, preserving databindings?</p>
<hr>
<p>The marked answer is the first part.</p>
<p>The second part is that you have to create an ExpressionConverter and inject it into the serialization process. Details for this are here:<br>
<a href="http://www.codeproje... | [
{
"answer_id": 32575,
"author": "Arcturus",
"author_id": 900,
"author_profile": "https://Stackoverflow.com/users/900",
"pm_score": 0,
"selected": false,
"text": "<p>How about:</p>\n\n<pre><code> public static T DeepClone<T>(T from)\n {\n using (MemoryStream s = new Mem... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Anybody have a good example how to deep clone a WPF object, preserving databindings?
---
The marked answer is the first part.
The second part is that you have to create an ExpressionConverter and inject it into the serialization process. Details for this are here:
<http://www.codeproject.com/KB/WPF/xamlwriterandb... | The simplest way that I've done it is to use a XamlWriter to save the WPF object as a string. The Save method will serialize the object and all of its children in the logical tree. Now you can create a new object and load it with a XamlReader.
ex:
Write the object to xaml (let's say the object was a Grid control):
``... |
32,550 | <p>When writing a SQL statement in SQL Server 2005, does the READUNCOMMITTED query hint imply NOLOCK or do I have to specify it manually too?</p>
<p>So is:</p>
<pre><code>With (NoLock, ReadUnCommitted)
</code></pre>
<p>the same as:</p>
<pre><code>With (ReadUnCommitted)
</code></pre>
| [
{
"answer_id": 32556,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": -1,
"selected": false,
"text": "<p>I think you can say that</p>\n\n<p>ReadUnCommitted has the abilities of NoLock</p>\n\n<p>However you cannot say that</p>... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | When writing a SQL statement in SQL Server 2005, does the READUNCOMMITTED query hint imply NOLOCK or do I have to specify it manually too?
So is:
```
With (NoLock, ReadUnCommitted)
```
the same as:
```
With (ReadUnCommitted)
``` | Yes they are one and the same |
32,586 | <p>Is there an easy way to discover a File's creation time with Java? The File class only has a method to get the "last modified" time. According to some resources I found on Google, the File class doesn't provide a getCreationTime() method because not all file systems support the idea of a creation time.</p>
<p>The... | [
{
"answer_id": 32712,
"author": "Joseph Gordon",
"author_id": 1741,
"author_profile": "https://Stackoverflow.com/users/1741",
"pm_score": 1,
"selected": false,
"text": "<p>I like the answer on <a href=\"http://www.jguru.com/faq/view.jsp?EID=1297118\" rel=\"nofollow noreferrer\">jGuru</a>... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1471/"
] | Is there an easy way to discover a File's creation time with Java? The File class only has a method to get the "last modified" time. According to some resources I found on Google, the File class doesn't provide a getCreationTime() method because not all file systems support the idea of a creation time.
The only workin... | With the release of Java 7 there is a built-in way to do this:
```
Path path = Paths.get("path/to/file");
BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class);
FileTime creationTime = attributes.creationTime();
```
It is important to note that not all operating systems provide this ... |
32,621 | <p>I'm trying to find the latitude and longitude of the corners of my map while in birdseye view. I want to be able to plot pins on the map, but I have hundreds of thousands of addresses that I want to be able to limit to the ones that need to show on the map.</p>
<p>In normal view, VEMap.GetMapView().TopLeftLatLong ... | [
{
"answer_id": 33238,
"author": "MartinHN",
"author_id": 2972,
"author_profile": "https://Stackoverflow.com/users/2972",
"pm_score": 0,
"selected": false,
"text": "<p>According to <a href=\"http://dev.live.com/virtualearth/sdk/\" rel=\"nofollow noreferrer\">http://dev.live.com/virtualear... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3420/"
] | I'm trying to find the latitude and longitude of the corners of my map while in birdseye view. I want to be able to plot pins on the map, but I have hundreds of thousands of addresses that I want to be able to limit to the ones that need to show on the map.
In normal view, VEMap.GetMapView().TopLeftLatLong and .Bottom... | Here's the code for getting the Center Lat/Long point of the map. This method works in both Road/Aerial and Birdseye/Oblique map styles.
```
function GetCenterLatLong()
{
//Check if in Birdseye or Oblique Map Style
if (map.GetMapStyle() == VEMapStyle.Birdseye || map.GetMapStyle() == VEM... |
32,637 | <p>I am consuming the Twitter API and want to convert all URLs to hyperlinks. </p>
<p>What is the most effective way you've come up with to do this?</p>
<p>from</p>
<pre><code>string myString = "This is my tweet check it out http://tinyurl.com/blah";
</code></pre>
<p>to</p>
<pre><code>This is my tweet check it out... | [
{
"answer_id": 32648,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 6,
"selected": true,
"text": "<p>Regular expressions are probably your friend for this kind of task:</p>\n\n<pre><code>Regex r = new Regex(@\"(https?://[^... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2347826/"
] | I am consuming the Twitter API and want to convert all URLs to hyperlinks.
What is the most effective way you've come up with to do this?
from
```
string myString = "This is my tweet check it out http://tinyurl.com/blah";
```
to
```
This is my tweet check it out <a href="http://tinyurl.com/blah">http://tinyurl.c... | Regular expressions are probably your friend for this kind of task:
```
Regex r = new Regex(@"(https?://[^\s]+)");
myString = r.Replace(myString, "<a href=\"$1\">$1</a>");
```
The regular expression for matching URLs might need a bit of work. |
32,640 | <p>So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return "GET".</p>
<p>I've seen some examples/helpers out on the nets, but some ar... | [
{
"answer_id": 32672,
"author": "Haacked",
"author_id": 598,
"author_profile": "https://Stackoverflow.com/users/598",
"pm_score": 7,
"selected": true,
"text": "<p>Using MoQ it looks something like this:</p>\n\n<pre><code>var request = new Mock<HttpRequestBase>();\nrequest.Expect(r ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] | So the controller context depends on some asp.net internals. What are some ways to cleanly mock these up for unit tests? Seems like its very easy to clog up tests with tons of setup when I only need, for example, Request.HttpMethod to return "GET".
I've seen some examples/helpers out on the nets, but some are dated. F... | Using MoQ it looks something like this:
```
var request = new Mock<HttpRequestBase>();
request.Expect(r => r.HttpMethod).Returns("GET");
var mockHttpContext = new Mock<HttpContextBase>();
mockHttpContext.Expect(c => c.Request).Returns(request.Object);
var controllerContext = new ControllerContext(mockHttpContext.Objec... |
32,649 | <p>When making changes using <code>SubmitChanges()</code>, LINQ sometimes dies with a <code>ChangeConflictException</code> exception with the error message <code>Row not found or changed</code>, without any indication of either the row that has the conflict or the fields with changes that are in conflict, when another ... | [
{
"answer_id": 32703,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 2,
"selected": false,
"text": "<p>I've gotten this error in a circumstance completely unrelated to what the error message describes.</p>\n\n<p>What I did w... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] | When making changes using `SubmitChanges()`, LINQ sometimes dies with a `ChangeConflictException` exception with the error message `Row not found or changed`, without any indication of either the row that has the conflict or the fields with changes that are in conflict, when another user has changed some data in that r... | Here's a way to see where the conflicts are (this is an MSDN example, so you'll need to heavily customize):
```
try
{
db.SubmitChanges(ConflictMode.ContinueOnConflict);
}
catch (ChangeConflictException e)
{
Console.WriteLine("Optimistic concurrency error.");
Console.WriteLine(e.Message);
Console.ReadLi... |
32,664 | <p>Can anyone tell me if there is a way with generics to limit a generic type argument <code>T</code> to only:</p>
<ul>
<li><code>Int16</code></li>
<li><code>Int32</code></li>
<li><code>Int64</code></li>
<li><code>UInt16</code></li>
<li><code>UInt32</code></li>
<li><code>UInt64</code></li>
</ul>
<p>I'm aware of the <... | [
{
"answer_id": 32687,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 7,
"selected": false,
"text": "<p>There's no constraint for this. It's a real issue for anyone wanting to use generics for numeric calculations.</p>\n\n<p>I'd g... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736/"
] | Can anyone tell me if there is a way with generics to limit a generic type argument `T` to only:
* `Int16`
* `Int32`
* `Int64`
* `UInt16`
* `UInt32`
* `UInt64`
I'm aware of the `where` keyword, but can't find an interface for **only** these types,
Something like:
```
static bool IntegerFunction<T>(T value) where T ... | This constraint exists in .Net 7.
Check out this [.NET Blog post](https://devblogs.microsoft.com/dotnet/dotnet-7-generic-math/) and the [actual documentation](https://learn.microsoft.com/en-us/dotnet/standard/generics/math).
Starting in .NET 7, you can make use of interfaces such as `INumber` and `IFloatingPoint` to ... |
32,694 | <p>I'm trying to use <strong>NIS</strong> for authentication on a st of machines. I had to change one of the user ID numbers for a user account on the NIS server (I changed the userid for <code>username</code> from 500 to 509 to avoid a conflict with a local user account with id 500 on the clients). The problem is that... | [
{
"answer_id": 32770,
"author": "Lorin Hochstein",
"author_id": 742,
"author_profile": "https://Stackoverflow.com/users/742",
"pm_score": 1,
"selected": false,
"text": "<p>OK, I found the problem, I also had to restart the NIS service on the server to get it to refresh everything (<code>... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | I'm trying to use **NIS** for authentication on a st of machines. I had to change one of the user ID numbers for a user account on the NIS server (I changed the userid for `username` from 500 to 509 to avoid a conflict with a local user account with id 500 on the clients). The problem is that it has not updated properl... | John O pointed me in the right direction.
He is right. If you set "files: 0" in /etc/ypserv.conf, you can get ypserv to not cache files. If you have to restart ypserv after each make, this is the problem.
The real solution is to look in /var/log/messages for this error:
```
ypserv[]: refused connect from 127.0.0.1... |
32,717 | <p>I just finished setting up an out-of-place build system for our existing C++ code using inherited property sheets, a feature that seems to be specific to the Visual C++ product. Building out-of-place requires that many of the project settings be changed, and the inherited property sheets allowed me to change all the... | [
{
"answer_id": 32879,
"author": "John Smithers",
"author_id": 1069,
"author_profile": "https://Stackoverflow.com/users/1069",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Is there a way I can define a macro for a directory and use it in the output path </p>\n</blockquot... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] | I just finished setting up an out-of-place build system for our existing C++ code using inherited property sheets, a feature that seems to be specific to the Visual C++ product. Building out-of-place requires that many of the project settings be changed, and the inherited property sheets allowed me to change all the ne... | I'm not quite sure what an "out-of-place" build system is, but if you just need the ability to copy the compiled files (or other resources) to other directories you can do so by tying into the MSBuild build targets.
In our projects we move the compiled dlls into lib folders and put the files into the proper locations ... |
32,744 | <p>For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...</p>
<p>The w... | [
{
"answer_id": 32754,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 3,
"selected": false,
"text": "<p>You're looking for the Mail Transfer Agent, Wikipedia has <a href=\"http://en.wikipedia.org/wiki/Mail_transfer_agent\" rel=\"... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] | For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...
The way I understa... | The SMTP server at Gmail (which accepted the message from Thunderbird) will route the message to the final recipient.
It does this by using DNS to find the MX (mail exchanger) record for the domain name part of the destination email address (hotmail.com in this example). The DNS server will return an IP address which ... |
32,747 | <p>How do I get today's date in C# in mm/dd/yyyy format?</p>
<p>I need to set a string variable to today's date (preferably without the year), but there's got to be a better way than building it month-/-day one piece at a time.</p>
<p>BTW: I'm in the US so M/dd would be correct, e.g. September 11th is 9/11.</p>
<p><... | [
{
"answer_id": 32749,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 9,
"selected": true,
"text": "<pre><code>DateTime.Now.ToString(\"M/d/yyyy\");\n</code></pre>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/8... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/730/"
] | How do I get today's date in C# in mm/dd/yyyy format?
I need to set a string variable to today's date (preferably without the year), but there's got to be a better way than building it month-/-day one piece at a time.
BTW: I'm in the US so M/dd would be correct, e.g. September 11th is 9/11.
*Note: an answer from kro... | ```
DateTime.Now.ToString("M/d/yyyy");
```
<http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx> |
32,750 | <p>I have a <code>byte[]</code> array, the contents of which represent a TIFF file (as in, if I write out these bytes directly to a file using the <code>BinaryWriter</code> object, it forms a perfectly valid TIFF file) and I'm trying to turn it into a System.Drawing.Image object so that I can use it for later manipulat... | [
{
"answer_id": 32841,
"author": "Tim",
"author_id": 1970,
"author_profile": "https://Stackoverflow.com/users/1970",
"pm_score": 3,
"selected": true,
"text": "<p><strong>Edit:</strong> The assumption below is not correct, I had a chance to fire up my IDE later and tested with and without ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2577/"
] | I have a `byte[]` array, the contents of which represent a TIFF file (as in, if I write out these bytes directly to a file using the `BinaryWriter` object, it forms a perfectly valid TIFF file) and I'm trying to turn it into a System.Drawing.Image object so that I can use it for later manipulation (feeding into a multi... | **Edit:** The assumption below is not correct, I had a chance to fire up my IDE later and tested with and without Write and both populated the MemoryStream correctly.
I think you need to write to your MemeoryStream first.
As if my memory (no pun intended) serves me correctly this:
```
MemoryStream ms = new MemoryStr... |
32,824 | <p>While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object.</p>
<p>My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the S... | [
{
"answer_id": 33555,
"author": "Duncan Smart",
"author_id": 1278,
"author_profile": "https://Stackoverflow.com/users/1278",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately if you look at <code>System.Web.HttpCachePolicy.UpdateCachedHeaders()</code> in .NET Reflector you see ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] | While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object.
My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCacheabi... | I think you need to use HttpCacheability.ServerAndPrivate
That should give you cache-control: private in the headers and let you set an ETag.
The documentation on that needs to be a bit better.
**Edit:** Markus found that you also have call cache.SetOmitVaryStar(true) otherwise the cache will add the Vary: \* header... |
32,845 | <p>Is it "taboo" to programatically create system restore points? I would be doing this before I perform a software update. If there is a better method to create a restore point with just my software's files and data, please let me know.</p>
<p>I would like a means by which I can get the user back to a known working... | [
{
"answer_id": 32854,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": -1,
"selected": false,
"text": "<p>I don't think a complete system restore would be a good plan. Two reasons that quickly come to mind:</p>\n\n<ul>\n<li>Was... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] | Is it "taboo" to programatically create system restore points? I would be doing this before I perform a software update. If there is a better method to create a restore point with just my software's files and data, please let me know.
I would like a means by which I can get the user back to a known working state if ev... | >
> Is it "taboo" to programatically create system restore points?
>
>
>
No. That's why the API is there; so that you can have pseudo-atomic updates of the system. |
32,877 | <p>I've got a problem where incoming SOAP messages from one particular client are being marked as invalid and rejected by our XML firewall device. It appears extra payload data is being inserted by Visual Studio; we're thinking the extra data may be causing a problem b/c we're seeing "VsDebuggerCausalityData" in these ... | [
{
"answer_id": 33312,
"author": "Darryl Braaten",
"author_id": 1834,
"author_profile": "https://Stackoverflow.com/users/1834",
"pm_score": 5,
"selected": true,
"text": "<p>A quick google reveals that this should get rid of it, get them to add it to the web.config or app.config for their ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1683/"
] | I've got a problem where incoming SOAP messages from one particular client are being marked as invalid and rejected by our XML firewall device. It appears extra payload data is being inserted by Visual Studio; we're thinking the extra data may be causing a problem b/c we're seeing "VsDebuggerCausalityData" in these mes... | A quick google reveals that this should get rid of it, get them to add it to the web.config or app.config for their application.
```
<configuration>
<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1" />
</switches>
</system.diagnostics>
</configuration>
```
The information is d... |
32,897 | <p>This question would probably apply equally as well to other languages with C-like multi-line comments. Here's the problem I'm encountering. I'm working with Java code in Eclipse, and I wanted to comment out a block of code. However, there is a string that contains the character sequence "*/", and Eclipse thinks that... | [
{
"answer_id": 32916,
"author": "Damien B",
"author_id": 3069,
"author_profile": "https://Stackoverflow.com/users/3069",
"pm_score": 4,
"selected": true,
"text": "<p>Eclipse is correct. There is no interpretation context inside a comment (no escaping, etc). See <a href=\"http://java.sun.... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This question would probably apply equally as well to other languages with C-like multi-line comments. Here's the problem I'm encountering. I'm working with Java code in Eclipse, and I wanted to comment out a block of code. However, there is a string that contains the character sequence "\*/", and Eclipse thinks that t... | Eclipse is correct. There is no interpretation context inside a comment (no escaping, etc). See [JLS §3.7](http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48125). |
32,899 | <p>I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this:</p>
<pre><code>import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
class TestSequenc... | [
{
"answer_id": 32939,
"author": "Dmitry Mukhin",
"author_id": 3448,
"author_profile": "https://Stackoverflow.com/users/3448",
"pm_score": 9,
"selected": true,
"text": "<p>This is called "parametrization".</p>\n<p>There are several tools that support this approach. E.g.:</p>\n<u... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/720/"
] | I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this:
```
import unittest
l = [["foo", "a", "a",], ["bar", "a", "b"], ["lee", "b", "b"]]
class TestSequence(unittest.TestCase):
def testsample(self):
for name, a,b in l:
print "test", n... | This is called "parametrization".
There are several tools that support this approach. E.g.:
* [pytest's decorator](https://docs.pytest.org/en/latest/parametrize.html)
* [parameterized](https://github.com/wolever/parameterized)
The resulting code looks like this:
```
from parameterized import parameterized
class Te... |
32,937 | <p>In C# is there a shorthand way to write this:</p>
<pre><code>public static bool IsAllowed(int userID)
{
return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...);
}
</code></pre>
<p>Like:</p>
<pre><code>public static bool IsAllowed(int userID)
{
return (userID in Personnel.JohnDoe, Personnel... | [
{
"answer_id": 32942,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<p>I would encapsulate the list of allowed IDs as <em>data</em> not <em>code</em>. Then it's source can be changed easily... | 2008/08/28 | [
"https://Stackoverflow.com/questions/32937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1302/"
] | In C# is there a shorthand way to write this:
```
public static bool IsAllowed(int userID)
{
return (userID == Personnel.JohnDoe || userID == Personnel.JaneDoe ...);
}
```
Like:
```
public static bool IsAllowed(int userID)
{
return (userID in Personnel.JohnDoe, Personnel.JaneDoe ...);
}
```
I know I could... | How about this?
```
public static class Extensions
{
public static bool In<T>(this T testValue, params T[] values)
{
return values.Contains(testValue);
}
}
```
Usage:
```
Personnel userId = Personnel.JohnDoe;
if (userId.In(Personnel.JohnDoe, Personnel.JaneDoe))
{
// Do something
}
```
I c... |
33,048 | <p>Suppose you have an ActiveRecord::Observer in one of your Ruby on Rails applications - how do you test this observer with rSpec?</p>
| [
{
"answer_id": 33869,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": false,
"text": "<p>Disclaimer: I've never actually done this on a production site, but it looks like a reasonable way would be to use moc... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2569/"
] | Suppose you have an ActiveRecord::Observer in one of your Ruby on Rails applications - how do you test this observer with rSpec? | You are on the right track, but I have run into a number of frustrating unexpected message errors when using rSpec, observers, and mock objects. When I am spec testing my model, I don't want to have to handle observer behavior in my message expectations.
In your example, there isn't a really good way to spec "set\_st... |
33,055 | <p>I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment?</p>
| [
{
"answer_id": 33062,
"author": "Misha M",
"author_id": 3467,
"author_profile": "https://Stackoverflow.com/users/3467",
"pm_score": 2,
"selected": false,
"text": "<p>I like to just copy the entire repo directory to my backup location. That way, if something happens, you can just copy th... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3396/"
] | I'm new to SVN and I'd like to know what methods are available for backing up repositories in a Windows environment? | You could use something like (Linux):
```
svnadmin dump repositorypath | gzip > backupname.svn.gz
```
Since Windows does not support GZip it is just:
```
svnadmin dump repositorypath > backupname.svn
``` |
33,063 | <p>I have a big string (let's call it a CSV file, though it isn't actually one, it'll just be easier for now) that I have to parse in C# code.<br>
The first step of the parsing process splits the file into individual lines by just using a <code>StreamReader</code> object and calling <code>ReadLine</code> until it's thr... | [
{
"answer_id": 33074,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "<p><strong>EDIT:</strong> Sorry, I've misinterpreted your post. If you're looking for a regex, then here is one:</p>\n\n<pre>... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2187/"
] | I have a big string (let's call it a CSV file, though it isn't actually one, it'll just be easier for now) that I have to parse in C# code.
The first step of the parsing process splits the file into individual lines by just using a `StreamReader` object and calling `ReadLine` until it's through the file. However, an... | Since this isn't a true CSV file, does it have any sort of schema?
From your example, it looks like you have:
int, int, int, int, string , bool, bool, int
With that making up your record / object.
Assuming that your data is well formed (I don't know enough about your source to know how valid this assumption is); you... |
33,073 | <p>How do I make <code>diff</code> ignore temporary files like <code>foo.c~</code>? Is there a configuration file that will make ignoring temporaries the default?</p>
<p>More generally: what's the best way to generate a "clean" patch off a tarball? I do this rarely enough (submitting a bug fix to an OSS project by ema... | [
{
"answer_id": 33085,
"author": "Cheekysoft",
"author_id": 1820,
"author_profile": "https://Stackoverflow.com/users/1820",
"pm_score": 3,
"selected": true,
"text": "<p>This doesn't strictly answer your question, but you can avoid the problem by configuring Emacs to use a specific directo... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | How do I make `diff` ignore temporary files like `foo.c~`? Is there a configuration file that will make ignoring temporaries the default?
More generally: what's the best way to generate a "clean" patch off a tarball? I do this rarely enough (submitting a bug fix to an OSS project by email) that I always struggle with ... | This doesn't strictly answer your question, but you can avoid the problem by configuring Emacs to use a specific directory to keep the backup files in. There are different implementations for Emacs or XEmacs.
In GNU Emacs
```
(defvar user-temporary-file-directory
(concat temporary-file-directory user-login... |
33,080 | <p>In a web application, I have a page that contains a DIV that has an auto-width depending on the width of the browser window.</p>
<p>I need an auto-height for the object. The DIV starts about 300px from the top screen, and its height should make it stretch to the bottom of the browser screen. I have a max height f... | [
{
"answer_id": 33096,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": false,
"text": "<p>What should happen in the case of overflow? If you want it to just get to the bottom of the window, use absolute ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1226/"
] | In a web application, I have a page that contains a DIV that has an auto-width depending on the width of the browser window.
I need an auto-height for the object. The DIV starts about 300px from the top screen, and its height should make it stretch to the bottom of the browser screen. I have a max height for the conta... | Try this simple, specific function:
```
function resizeElementHeight(element) {
var height = 0;
var body = window.document.body;
if (window.innerHeight) {
height = window.innerHeight;
} else if (body.parentElement.clientHeight) {
height = body.parentElement.clientHeight;
} else if (body && body.c... |
33,089 | <p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application. It keep... | [
{
"answer_id": 33092,
"author": "Zack Peterson",
"author_id": 83,
"author_profile": "https://Stackoverflow.com/users/83",
"pm_score": 1,
"selected": false,
"text": "<p>I found the answer at <a href=\"http://www.codersource.net/asp_net_forms_authentication.aspx\" rel=\"nofollow noreferrer... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I'm using the [ASP.NET Login Controls](http://msdn.microsoft.com/en-us/library/ms178329.aspx) and [Forms Authentication](http://msdn.microsoft.com/en-us/library/aa480476.aspx) for membership/credentials for an ASP.NET web application. It keeps redirecting to a Login.aspx page at the root of my application that does not... | Use the LoginUrl property for the forms item?
```
<authentication mode="Forms">
<forms defaultUrl="~/Default.aspx" loginUrl="~/login.aspx" timeout="1440" ></forms>
</authentication>
``` |
33,103 | <p>I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item?</p>
| [
{
"answer_id": 33130,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 4,
"selected": true,
"text": "<p>Probably using the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.onpaste\" rel=\"nofollow noreferre... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] | I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item? | Probably using the [`onpaste`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.onpaste) event, and either `return false` from it or use `e.preventDefault()` on the Event object.
Note that `onpaste` is *non standard*, don't rely on it for production sites, because it will not be there forever.
```js
$(doc... |
33,115 | <p>Does C# have the notion of private / protected inheritance, and if not, why?</p>
<p><strong>C++</strong></p>
<pre>
<code>
class Foo : private Bar {
public:
...
};
</code>
</pre>
<p><strong>C#</strong></p>
<pre>
<code>
public abstract NServlet class : private System.Web.UI.Page
{
// error "type expected... | [
{
"answer_id": 33128,
"author": "Chris Karcher",
"author_id": 2773,
"author_profile": "https://Stackoverflow.com/users/2773",
"pm_score": 1,
"selected": false,
"text": "<p>No, public inheritance only.</p>\n"
},
{
"answer_id": 33142,
"author": "Daren Thomas",
"author_id": ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | Does C# have the notion of private / protected inheritance, and if not, why?
**C++**
```
class Foo : private Bar {
public:
...
};
```
**C#**
```
public abstract NServlet class : private System.Web.UI.Page
{
// error "type expected"
}
```
I am implementing a "servlet like" concept in an .aspx page and... | C# allows public inheritance only. C++ allowed all three kinds. Public inheritance implied an "IS-A" type of relationship, and private inheritance implied a "Is-Implemented-In-Terms-Of" kind of relationship. Since layering (or composition) accomplished this in an arguably simpler fashion, private inheritance was only u... |
33,150 | <p>I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.</p>
<p>in vb.net: <code>Parent.FindControl(TargetControlName)</code></p>
<p>I would like to pass a method to the control in the ASPX markup. </p>
<p>for example: <code><c:... | [
{
"answer_id": 33163,
"author": "Joel Martinez",
"author_id": 3433,
"author_profile": "https://Stackoverflow.com/users/3433",
"pm_score": 0,
"selected": false,
"text": "<p>Your workaround is actually the better answer. If you have code that you must run at a certain part of your control... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] | I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.
in vb.net: `Parent.FindControl(TargetControlName)`
I would like to pass a method to the control in the ASPX markup.
for example: `<c:MyCustomerControl runat=server InitializeStuf... | If you want to be able to pass a method in the ASPX markup, you need to use the `Browsable` attribute in your code on the event.
VB.NET
```vb
<Browsable(True)> Public Event InitializeStuffCallback
```
C#
```
[Browsable(true)]
public event EventHandler InitializeStuffCallback;
```
Reference:
[Design-Time Attribut... |
33,199 | <p>Would it be possible to print <code>Hello</code> twice using single <code>condition</code>?</p>
<pre><code>if "condition"
printf ("Hello");
else
printf("World");
</code></pre>
| [
{
"answer_id": 33202,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>The <code>if</code> statement executes one or the other of the controlled statements (both <code>printf</code> in your ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2454/"
] | Would it be possible to print `Hello` twice using single `condition`?
```
if "condition"
printf ("Hello");
else
printf("World");
``` | ```
if ( printf("Hello") == 0 )
printf ("Hello");
else
printf ("World");
```
:-) |
33,226 | <p>Assuming such a query exists, I would greatly appreciate the help.</p>
<p>I'm trying to develop a permissions script that will grant "select" and "references" permissions on the user tables and views in a database. My hope is that executing the "grant" commands on each element in such a set will make it easier to ... | [
{
"answer_id": 33266,
"author": "Jas",
"author_id": 777,
"author_profile": "https://Stackoverflow.com/users/777",
"pm_score": 0,
"selected": false,
"text": "<pre><code>select * from information_schema.tables\nwhere table_type = 'view'\n</code></pre>\n"
},
{
"answer_id": 33285,
... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3475/"
] | Assuming such a query exists, I would greatly appreciate the help.
I'm trying to develop a permissions script that will grant "select" and "references" permissions on the user tables and views in a database. My hope is that executing the "grant" commands on each element in such a set will make it easier to keep permis... | ```
select * from information_schema.tables
WHERE OBJECTPROPERTY(OBJECT_ID(table_name),'IsMSShipped') =0
```
Will exclude dt\_properties and system tables
add
```
where table_type = 'view'
```
if you just want the view |
33,233 | <p>Imagine you homebrew a custom gui framework that <em>doesn't</em> use windows handles (compact framework, so please don't argue with "whys"). One of the main disadvantages of developing such a framework is that you lose compatability with the winform designer.</p>
<p>So my question is to all of you who know a lot a... | [
{
"answer_id": 33266,
"author": "Jas",
"author_id": 777,
"author_profile": "https://Stackoverflow.com/users/777",
"pm_score": 0,
"selected": false,
"text": "<pre><code>select * from information_schema.tables\nwhere table_type = 'view'\n</code></pre>\n"
},
{
"answer_id": 33285,
... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143/"
] | Imagine you homebrew a custom gui framework that *doesn't* use windows handles (compact framework, so please don't argue with "whys"). One of the main disadvantages of developing such a framework is that you lose compatability with the winform designer.
So my question is to all of you who know a lot about VS customisa... | ```
select * from information_schema.tables
WHERE OBJECTPROPERTY(OBJECT_ID(table_name),'IsMSShipped') =0
```
Will exclude dt\_properties and system tables
add
```
where table_type = 'view'
```
if you just want the view |
33,250 | <p>In one of my applications, I am querying active directory to get a list of all users below a given user (using the "Direct Reports" thing). So basically, given the name of the person, it is looked up in AD, then the Direct Reports are read. But then for every direct report, the tool needs to check the direct reports... | [
{
"answer_id": 33299,
"author": "kemiller2002",
"author_id": 1942,
"author_profile": "https://Stackoverflow.com/users/1942",
"pm_score": 2,
"selected": false,
"text": "<p>Active Directory is pretty efficient at storing information and the retrieval shouldn't be that much of a performance... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | In one of my applications, I am querying active directory to get a list of all users below a given user (using the "Direct Reports" thing). So basically, given the name of the person, it is looked up in AD, then the Direct Reports are read. But then for every direct report, the tool needs to check the direct reports of... | In order to take control over the properties that you want to be cached you can call 'RefreshCache()' passing the properties that you want to hang around:
```c#
System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry();
// Push the property values from AD back to cac... |
33,252 | <p>As a temporary stopgap until all the designers are in place we are currently hand-cranking a whole bunch of xml configuration files at work. One of the issues with this is file-versioning because people forget to update version numbers when updating the files (which is to be expected as humans generally suck at perf... | [
{
"answer_id": 33299,
"author": "kemiller2002",
"author_id": 1942,
"author_profile": "https://Stackoverflow.com/users/1942",
"pm_score": 2,
"selected": false,
"text": "<p>Active Directory is pretty efficient at storing information and the retrieval shouldn't be that much of a performance... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143/"
] | As a temporary stopgap until all the designers are in place we are currently hand-cranking a whole bunch of xml configuration files at work. One of the issues with this is file-versioning because people forget to update version numbers when updating the files (which is to be expected as humans generally suck at perfect... | In order to take control over the properties that you want to be cached you can call 'RefreshCache()' passing the properties that you want to hang around:
```c#
System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry();
// Push the property values from AD back to cac... |
33,262 | <p>I have a complete XML document in a string and would like a <code>Document</code> object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5)</p>
<p><strong>Solution</strong> Thanks to <a href="https://stackoverflow.com/users/1322/matt-mcminn">Matt McMinn</a>, I have settled on this i... | [
{
"answer_id": 33283,
"author": "Matt McMinn",
"author_id": 1322,
"author_profile": "https://Stackoverflow.com/users/1322",
"pm_score": 7,
"selected": true,
"text": "<p>This works for me in Java 1.5 - I stripped out specific exceptions for readability.</p>\n\n<pre><code>import javax.xml.... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I have a complete XML document in a string and would like a `Document` object. Google turns up all sorts of garbage. What is the simplest solution? (In Java 1.5)
**Solution** Thanks to [Matt McMinn](https://stackoverflow.com/users/1322/matt-mcminn), I have settled on this implementation. It has the right level of inpu... | This works for me in Java 1.5 - I stripped out specific exceptions for readability.
```
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.ByteArrayInputStream;
public Document loadXMLFromString(String xml) throws Exception
{
Docu... |
33,263 | <p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application.</p>
<p>... | [
{
"answer_id": 33283,
"author": "Matt McMinn",
"author_id": 1322,
"author_profile": "https://Stackoverflow.com/users/1322",
"pm_score": 7,
"selected": true,
"text": "<p>This works for me in Java 1.5 - I stripped out specific exceptions for readability.</p>\n\n<pre><code>import javax.xml.... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I'm using the [ASP.NET Login Controls](http://msdn.microsoft.com/en-us/library/ms178329.aspx) and [Forms Authentication](http://msdn.microsoft.com/en-us/library/aa480476.aspx) for membership/credentials for an ASP.NET web application.
I've got two roles:
* Users
* Administrators
I want pages to be viewable by four d... | This works for me in Java 1.5 - I stripped out specific exceptions for readability.
```
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import java.io.ByteArrayInputStream;
public Document loadXMLFromString(String xml) throws Exception
{
Docu... |
33,265 | <p>There are two weird operators in C#:</p>
<ul>
<li>the <a href="http://msdn.microsoft.com/en-us/library/6x6y6z4d.aspx" rel="noreferrer">true operator</a></li>
<li>the <a href="http://msdn.microsoft.com/en-us/library/6292hy1k.aspx" rel="noreferrer">false operator</a></li>
</ul>
<p>If I understand this right these op... | [
{
"answer_id": 33315,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 4,
"selected": false,
"text": "<p>The page you link to <a href=\"http://msdn.microsoft.com/en-us/library/6x6y6z4d.aspx\" rel=\"noreferrer\">http://msdn.mic... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361/"
] | There are two weird operators in C#:
* the [true operator](http://msdn.microsoft.com/en-us/library/6x6y6z4d.aspx)
* the [false operator](http://msdn.microsoft.com/en-us/library/6292hy1k.aspx)
If I understand this right these operators can be used in types which I want to use instead of a boolean expression and where ... | You can use it to override the `&&` and `||` operators.
The `&&` and `||` operators can't be overridden, but if you override `|`, `&`, `true` and `false` in exactly the right way the compiler will call `|` and `&` when you write `||` and `&&`.
For example, look at this code (from <http://ayende.com/blog/1574/nhiberna... |
33,301 | <p>I have a JavaScript method that I need to run on one of my pages, in particular, the <code>onresize</code> event. </p>
<p>However, I don't see how I can set that event from my content page. I wish I could just put it on my master page, but I don't have the need for the method to be called on all pages that use th... | [
{
"answer_id": 33440,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 3,
"selected": true,
"text": "<p>Place the following in your content page:</p>\n\n<pre><code><script type=\"text/javascript\">\n\n// here is a c... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1226/"
] | I have a JavaScript method that I need to run on one of my pages, in particular, the `onresize` event.
However, I don't see how I can set that event from my content page. I wish I could just put it on my master page, but I don't have the need for the method to be called on all pages that use that master page.
Any he... | Place the following in your content page:
```
<script type="text/javascript">
// here is a cross-browser compatible way of connecting
// handlers to events, in case you don't have one
function attachEventHandler(element, eventToHandle, eventHandler) {
if(element.attachEvent) {
element.attachEvent(eventToH... |
33,334 | <p>In this <a href="https://stackoverflow.com/questions/32877/how-to-remove-vsdebuggercausalitydata-data-from-soap-message">question</a> the answer was to flip on a switch that is picked up by the debugger disabling the extraneous header that was causing the problem. The Microsoft help implies these switched are user ... | [
{
"answer_id": 33677,
"author": "Kevin Dente",
"author_id": 9,
"author_profile": "https://Stackoverflow.com/users/9",
"pm_score": 1,
"selected": false,
"text": "<p>You can use Reflector to search for uses of the Switch class and its subclasss (BooleanSwitch, TraceSwitch, etc). The variou... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1834/"
] | In this [question](https://stackoverflow.com/questions/32877/how-to-remove-vsdebuggercausalitydata-data-from-soap-message) the answer was to flip on a switch that is picked up by the debugger disabling the extraneous header that was causing the problem. The Microsoft help implies these switched are user generated and d... | As you suspected, Remote.Disable stops the app from attaching debug info to remote requests. It's defined inside the .NET framework methods that make the SOAP request.
The basic situation is that these switches can be defined anywhere in code, you just need to create a new System.Diagnostics.BooleanSwitch with the nam... |
33,341 | <p>Is there a way to hide radio buttons inside a RadioButtonList control programmatically?</p>
| [
{
"answer_id": 33353,
"author": "Zack Peterson",
"author_id": 83,
"author_profile": "https://Stackoverflow.com/users/83",
"pm_score": 0,
"selected": false,
"text": "<p>If you mean with JavaScript, and if I remember correctly, you've got to dig out the ClientID properties of each <inpu... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/877/"
] | Is there a way to hide radio buttons inside a RadioButtonList control programmatically? | Under the hood, you can access the attributes of the item and assign it a CSS style.
So you should be able to then programmatically assign it by specifying:
```
RadioButtonList.Items(1).CssClass.Add("visibility", "hidden")
```
and get the job done. |
33,395 | <p>I'm using the <a href="http://msdn.microsoft.com/en-us/library/ms178329.aspx" rel="nofollow noreferrer">ASP.NET Login Controls</a> and <a href="http://msdn.microsoft.com/en-us/library/aa480476.aspx" rel="nofollow noreferrer">Forms Authentication</a> for membership/credentials for an ASP.NET web application. And I'm... | [
{
"answer_id": 33402,
"author": "Vin",
"author_id": 1747,
"author_profile": "https://Stackoverflow.com/users/1747",
"pm_score": 0,
"selected": false,
"text": "<p>I think Jeff Atwood talked about this in the <a href=\"http://herdingcode.com/?p=36\" rel=\"nofollow noreferrer\">Herding Code... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I'm using the [ASP.NET Login Controls](http://msdn.microsoft.com/en-us/library/ms178329.aspx) and [Forms Authentication](http://msdn.microsoft.com/en-us/library/aa480476.aspx) for membership/credentials for an ASP.NET web application. And I'm using a [site map](http://msdn.microsoft.com/en-us/library/yy2ykkab.aspx) for... | You pretty much need to keep the same data context available throughout the lifetime of the operations you want to perform if you're ever going to be storing changes which are to be `.SubmitChanges()`'d later, as otherwise you will lose those changes.
If you're just querying stuff then it's fine to create them as need... |
33,409 | <p>I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response:</p>
<blockquote>
<p>The data types text and varchar are incompatible in the not equal to operator.</p>
<... | [
{
"answer_id": 33415,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 0,
"selected": false,
"text": "<p>I would test against <a href=\"http://msdn.microsoft.com/en-us/library/ms187748.aspx\" rel=\"nofollow noreferrer\">SUBSTRIN... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1214/"
] | I am using SQL Server 2005. I have a table with a text column and I have many rows in the table where the value of this column is not null, but it is empty. Trying to compare against '' yields this response:
>
> The data types text and varchar are incompatible in the not equal to operator.
>
>
>
Is there a specia... | ```
where datalength(mytextfield)=0
``` |
33,412 | <p>After reading Jeff's blog post on <a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">Protecting Your Cookies: HttpOnly</a>. I'd like to implement HttpOnly cookies in my web application.</p>
<p>How do you tell tomcat to use http only cookies for sessions?</p>
| [
{
"answer_id": 33456,
"author": "Shabaz",
"author_id": 1827,
"author_profile": "https://Stackoverflow.com/users/1827",
"pm_score": 3,
"selected": false,
"text": "<p>For session cookies it doesn't seem to be supported in Tomcat yet. See the bug report <a href=\"https://issues.apache.org/b... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1310/"
] | After reading Jeff's blog post on [Protecting Your Cookies: HttpOnly](http://www.codinghorror.com/blog/archives/001167.html). I'd like to implement HttpOnly cookies in my web application.
How do you tell tomcat to use http only cookies for sessions? | httpOnly is supported as of Tomcat 6.0.19 and Tomcat 5.5.28.
See the [changelog](http://tomcat.apache.org/tomcat-6.0-doc/changelog.html) entry for bug 44382.
The last comment for bug [44382](https://issues.apache.org/bugzilla/show_bug.cgi?id=44382) states, "this has been applied to 5.5.x and will be included in 5.5.... |
33,449 | <p>Is there a way to call out from a TSQL stored procedure or function to a webservice?</p>
| [
{
"answer_id": 33455,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 3,
"selected": false,
"text": "<p>Not in T-SQL code itself, but with SQL Server 2005 and above, they've enabled the ability to write CLR stored procedures, whi... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1874/"
] | Is there a way to call out from a TSQL stored procedure or function to a webservice? | Yes , you can create like this
```
CREATE PROCEDURE CALLWEBSERVICE(@Para1 ,@Para2)
AS
BEGIN
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get', 'http://www.webservicex.com/stockquote.asmx/GetQuot... |
33,459 | <p>Is it possible to use a flash document embedded in HTML as a link?</p>
<p>I tried just wrapping the <code>object</code> element with an <code>a</code> like this:</p>
<pre><code><a href="http://whatever.com">
<object ...>
<embed ... />
</object>
</a>
</code></pre>
<p>I... | [
{
"answer_id": 33519,
"author": "dlamblin",
"author_id": 459,
"author_profile": "https://Stackoverflow.com/users/459",
"pm_score": 2,
"selected": true,
"text": "<p>Though the object really should respond to being wrapped in an a href tag, you could open the swf in vim and just throw in a... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2214/"
] | Is it possible to use a flash document embedded in HTML as a link?
I tried just wrapping the `object` element with an `a` like this:
```
<a href="http://whatever.com">
<object ...>
<embed ... />
</object>
</a>
```
In Internet Explorer, that made it show the location in the status bar like a link, bu... | Though the object really should respond to being wrapped in an a href tag, you could open the swf in vim and just throw in an `_root.onPress=function(){getURL("http://yes.no/");};` or if it's AS3, something like `_root.addEventHandler(MouseEvent.PRESS, function (e:event) {getURL("http://yes.no/");});` But if editing th... |
33,465 | <p>Working on a little side project web app...</p>
<p>I'd like to have it set up so that, when users send email to a certain account, I can kick off a PHP script that reads the email, pulls out some key info, and writes it to a database.</p>
<p>What's the best way to do this? A cron job that checks for new email?</p>... | [
{
"answer_id": 33472,
"author": "crono",
"author_id": 1462,
"author_profile": "https://Stackoverflow.com/users/1462",
"pm_score": 0,
"selected": false,
"text": "<p>The Cronjob is the common solution to such a task. <a href=\"http://php.net/manual/en/function.imap-getmailboxes.php\" rel=\... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Working on a little side project web app...
I'd like to have it set up so that, when users send email to a certain account, I can kick off a PHP script that reads the email, pulls out some key info, and writes it to a database.
What's the best way to do this? A cron job that checks for new email?
The app is running ... | Procmail is how I do it. Here's an example where I actually process the text inside the email to archive it back to a MySQL database.
```
:0:
* ^(From).*test@example.com
{
:0 c
| php /var/www/app/process_email.php
}
``` |
33,469 | <p>So I just fixed a bug in a framework I'm developing. The pseudo-pseudocode looks like this:</p>
<pre><code>myoldObject = new MyObject { someValue = "old value" };
cache.Insert("myObjectKey", myoldObject);
myNewObject = cache.Get("myObjectKey");
myNewObject.someValue = "new value";
if(myObject.someValue != cache.Get... | [
{
"answer_id": 33507,
"author": "Craig Walker",
"author_id": 3488,
"author_profile": "https://Stackoverflow.com/users/3488",
"pm_score": 1,
"selected": false,
"text": "<p>I've done similar things, but I got around it by cloning too. The difference is that I had the cache do the cloning. ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212/"
] | So I just fixed a bug in a framework I'm developing. The pseudo-pseudocode looks like this:
```
myoldObject = new MyObject { someValue = "old value" };
cache.Insert("myObjectKey", myoldObject);
myNewObject = cache.Get("myObjectKey");
myNewObject.someValue = "new value";
if(myObject.someValue != cache.Get("myObjectKey"... | Dirty tracking is the normal way to handle this, I think. Something like:
```
class MyObject {
public string SomeValue {
get { return _someValue; }
set {
if (value != SomeValue) {
IsDirty = true;
_someValue = value;
}
}
public bool IsDirty {
get;
private s... |
33,471 | <p>Is there a way to tell subversion "update/merge unless it would cause a conflict"?</p>
<p>I know you can use <code>--dry-run</code> / <code>status -u</code> to check before running the update, but I often have others running updates and getting broken webpages because they don't notice the "C index.php" line.</p>... | [
{
"answer_id": 33483,
"author": "jsight",
"author_id": 1432,
"author_profile": "https://Stackoverflow.com/users/1432",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps a better way is to use a graphical tool? Or write a script to do the update that redirects the output to a file an... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1806/"
] | Is there a way to tell subversion "update/merge unless it would cause a conflict"?
I know you can use `--dry-run` / `status -u` to check before running the update, but I often have others running updates and getting broken webpages because they don't notice the "C index.php" line.
I've also noticed that svn doesn't s... | You can use the --accept parameter to indicate what should happen when a conflict occurs:
```
--accept ARG : specify automatic conflict resolution action
('postpone', 'base', 'mine-full', 'theirs-full',
'edit', 'launch')
```
See also the [interactive co... |
33,475 | <p>I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr.</p>
<p>I want to automate the process of logging on to the remote machine, launching the process, and ret... | [
{
"answer_id": 33486,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n<pre><code>s = p.stderr.readline()\n</code></pre>\n</blockquote>\n\n<p>I suspect it's the above line. When ... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/742/"
] | I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr.
I want to automate the process of logging on to the remote machine, launching the process, and retrieving the... | >
>
> ```
> s = p.stderr.readline()
>
> ```
>
>
I suspect it's the above line. When you invoke a command directly through ssh, you don't get your full pty (assuming Linux), and thus no stderr to read from.
When you log in interactively, stdin, stdout, and stderr are set up for you, and so your script works. |
33,529 | <p>Inspired by this CodingHorror article, "<a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">Protecting Your Cookies: HttpOnly</a>"</p>
<p>How do you set this property? Somewhere in the web config?</p>
| [
{
"answer_id": 33532,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 4,
"selected": false,
"text": "<p>With props to Rick (second comment down in the blog post mentioned), here's the <a href=\"http://msdn.microsoft.com/en-us/lib... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1842/"
] | Inspired by this CodingHorror article, "[Protecting Your Cookies: HttpOnly](http://www.codinghorror.com/blog/archives/001167.html)"
How do you set this property? Somewhere in the web config? | If you're using ASP.NET 2.0 or greater, you can turn it on in the Web.config file. In the <system.web> section, add the following line:
```
<httpCookies httpOnlyCookies="true"/>
``` |
33,534 | <p>I'm trying to extend some "base" classes in Python:</p>
<pre><code>class xlist (list):
def len(self):
return len(self)
def add(self, *args):
self.extend(args)
return None
class xint (int):
def add(self, value):
self += value
return self
x = xlist([1,2,3])
pri... | [
{
"answer_id": 33556,
"author": "dwestbrook",
"author_id": 3119,
"author_profile": "https://Stackoverflow.com/users/3119",
"pm_score": 0,
"selected": false,
"text": "<p>Ints are immutable and you can't modify them in place, so you should go with option #2 (because option #1 is impossible... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/394/"
] | I'm trying to extend some "base" classes in Python:
```
class xlist (list):
def len(self):
return len(self)
def add(self, *args):
self.extend(args)
return None
class xint (int):
def add(self, value):
self += value
return self
x = xlist([1,2,3])
print x.len() ## ... | `int` is a value type, so each time you do an assignment, (e.g. both instances of `+=` above), it doesn't modify the object you have on the heap, but replaces the reference with one of the result of the right hand side of the assignment (i.e. an `int`)
`list` isn't a value type, so it isn't bound by the same rules.
t... |
33,577 | <p>I want to check out all files in all subdirectories of a specified folder.</p>
<p>(And it is painful to do this using the GUI, because there is no recursive checkout option).</p>
| [
{
"answer_id": 33605,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<pre><code>cleartool find somedir -exec \"cleartool checkout -nc \\\"%CLEARCASE_PN%\\\"\"\n</code></pre>\n\n<p>Also an article \"... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | I want to check out all files in all subdirectories of a specified folder.
(And it is painful to do this using the GUI, because there is no recursive checkout option). | Beware: ClearCase is File-centric, not repository centric (like SVN or CVS).
That means it is rarely a good solution to checkout all files (and it can be fairly long with ClearCase ;) )
That being said, the question is perfectly legitimate and I would like to point out another way:
open a `cleartool` session in the ... |
33,590 | <p>Has anyone looked at <a href="http://developer.yahoo.com/flash/" rel="nofollow noreferrer">Yahoo's ASTRA</a>? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's series's label renderer. My solution was to override the <c... | [
{
"answer_id": 35019,
"author": "dlamblin",
"author_id": 459,
"author_profile": "https://Stackoverflow.com/users/459",
"pm_score": 3,
"selected": true,
"text": "<p>Okay... so no-one's tried Astra, or people just avoid Flash questions.</p>\n\n<p>After a lot of guess work it turns out I ne... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459/"
] | Has anyone looked at [Yahoo's ASTRA](http://developer.yahoo.com/flash/)? It's fairly nifty, but I had some issues creating a custom label for a pie chart. They have an example for a line chart, which overrides an axis's series's label renderer. My solution was to override the `myPieChart.dataTipFunction`. For data that... | Okay... so no-one's tried Astra, or people just avoid Flash questions.
After a lot of guess work it turns out I needed to cast the series to a PieSeries and then work with those member functions, as the ISeries was useless on it's own.
```
myPieChart.dataTipFunction =
function (item:Object, index:int, series:ISeri... |
33,594 | <p>I need to <code>ShellExecute</code> something as another user, currently I start a helper process with <code>CreateProcessAsUser</code> that calls <code>ShellExecute</code>, but that seems like too much of a hack (Wrong parent process etc.) Is there a better way to do this?</p>
<p>@PabloG: ImpersonateLoggedOnUser d... | [
{
"answer_id": 33661,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 0,
"selected": false,
"text": "<p>You can wrap the ShellExecute between ImpersonateLoggedOnUser / RevertToSelf</p>\n\n<p>links: \nImpersonateLoggedOnUser: <a h... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3501/"
] | I need to `ShellExecute` something as another user, currently I start a helper process with `CreateProcessAsUser` that calls `ShellExecute`, but that seems like too much of a hack (Wrong parent process etc.) Is there a better way to do this?
@PabloG: ImpersonateLoggedOnUser does not work:
```
HANDLE hTok;
VERIFY(Log... | The solution really depends on what your needs are, and can be pretty complex (Thanks fully to Windows Vista). This is probably going to be beyond your need, but this will help others that find this page via search.
1. If you do not need the process to run with a GUI and you do not require elevation
2. If the user you... |
33,685 | <p>This is a sql 2000 database that I am working with.</p>
<p>I have what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). </p>
<p>I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.)</p>
<p>The way I was going to do... | [
{
"answer_id": 33717,
"author": "jason saldo",
"author_id": 1293,
"author_profile": "https://Stackoverflow.com/users/1293",
"pm_score": 2,
"selected": false,
"text": "<p>What are you using to import the file? DTS has scripting abilities that can be used for data validation. If your not... | 2008/08/28 | [
"https://Stackoverflow.com/questions/33685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1950/"
] | This is a sql 2000 database that I am working with.
I have what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255).
I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.)
The way I was going to do this was to iterate thr... | Generally I don't like "loop through the record" solutions as they tend to be slow and you end up writing a lot of custom code.
So...
Depending on how many records are in your staging table, you could post process the data with a series of SQL statements that test the columns for correctness and mark any records that... |
33,708 | <p>So I've got a <code>JPanel</code> implementing <code>MouseListener</code> and <code>MouseMotionListener</code>:</p>
<pre><code>import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayArea extends JPanel implements MouseListener, MouseMotionListener {
public DisplayArea(Rectangle ... | [
{
"answer_id": 33715,
"author": "Shabaz",
"author_id": 1827,
"author_profile": "https://Stackoverflow.com/users/1827",
"pm_score": 5,
"selected": true,
"text": "<p>The <em>implements mouselistener, mousemotionlistener</em> just allows the displayArea class to listen to some, to be define... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61/"
] | So I've got a `JPanel` implementing `MouseListener` and `MouseMotionListener`:
```
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayArea extends JPanel implements MouseListener, MouseMotionListener {
public DisplayArea(Rectangle bounds, Display display) {
setLayout(nu... | The *implements mouselistener, mousemotionlistener* just allows the displayArea class to listen to some, to be defined, Swing component's mouse events. You have to explicitly define what it should be listening at. So I suppose you could add something like this to the constructor:
```
this.addMouseListener(this);
this.... |
33,746 | <p>At work we are being asked to create XML files to pass data to another offline application that will then create a second XML file to pass back in order to update some of our data. During the process we have been discussing with the team of the other application about the structure of the XML file. </p>
<p>The samp... | [
{
"answer_id": 33749,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "<p>Both methods for storing object's properties are perfectly valid. You should depart from pragmatic considerations. Try answeri... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3340/"
] | At work we are being asked to create XML files to pass data to another offline application that will then create a second XML file to pass back in order to update some of our data. During the process we have been discussing with the team of the other application about the structure of the XML file.
The sample I came ... | I use this rule of thumb:
1. An Attribute is something that is self-contained, i.e., a color, an ID, a name.
2. An Element is something that does or could have attributes of its own or contain other elements.
So yours is close. I would have done something like:
**EDIT**: Updated the original example based on feedbac... |
33,751 | <p>I would like to add the following MIME type to a site run by <code>Apache</code>:</p>
<pre><code><mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
</code></pre>
<p><strong>That is the Tomcat format.</strong></p>
<... | [
{
"answer_id": 33762,
"author": "Ryan Guest",
"author_id": 1811,
"author_profile": "https://Stackoverflow.com/users/1811",
"pm_score": 2,
"selected": false,
"text": "<p>You should be able to just add this line:</p>\n\n<pre><code>AddType application/x-java-jnlp-file .jnlp\n</code></pr... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I would like to add the following MIME type to a site run by `Apache`:
```
<mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
```
**That is the Tomcat format.**
I'm on a shared host, so I can only create an `.htaccess` file. Would someone please specif... | ```
AddType application/x-java-jnlp-file .jnlp
```
Note that you might not actually be allowed to do that.
See also the [documentation of the AddType directive](http://HTTPd.Apache.Org/docs/trunk/mod/mod_mime.html#addtype "mod_mime - AddType") and the [.htaccess howto](http://HTTPd.Apache.Org/docs/trunk/howto/htacce... |
33,779 | <p>Does anyone know of a powershell cmdlet out there for automating task scheduler in XP/2003? If you've ever tried to work w/ schtasks you know it's pretty painful.</p>
| [
{
"answer_id": 33805,
"author": "PabloG",
"author_id": 394,
"author_profile": "https://Stackoverflow.com/users/394",
"pm_score": 1,
"selected": false,
"text": "<p>You don't need PowerShell to automate the Task Scheduler, you can use the SCHTASKS command in XP.</p>\n\n<p>According to <a h... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635/"
] | Does anyone know of a powershell cmdlet out there for automating task scheduler in XP/2003? If you've ever tried to work w/ schtasks you know it's pretty painful. | Ok, Pablo has sparked my interest in saying that the scheduler is accessible via COM.
In PowerShell you can do this:
```
$svc = new-object -com Schedule.Service
```
... and that gives you a handle to the task scheduler. You can see what members it has using:
```
$svc | get-member
```
One of its methods is NewTas... |
33,790 | <p>I am currently using the following command to upload my site content:</p>
<pre><code>scp -r web/* user@site.com:site.com/
</code></pre>
<p>This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden.</p>
<p>I have tried adding a second line to send the file explicitely:</p... | [
{
"answer_id": 33791,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 4,
"selected": true,
"text": "<p>Just combine the two commands:</p>\n\n<pre><code>scp -r web/* web/.htaccess user@site.com:site.com/\n</code></pre>\n\n<p>If you... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I am currently using the following command to upload my site content:
```
scp -r web/* user@site.com:site.com/
```
This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden.
I have tried adding a second line to send the file explicitely:
```
scp -r web/.htaccess user@site... | Just combine the two commands:
```
scp -r web/* web/.htaccess user@site.com:site.com/
```
If you want 0 entries of your password you can set up [public key authentication](http://sial.org/howto/openssh/publickey-auth/) for ssh/scp. |
33,813 | <p>I noticed that many people here use <a href="http://macromates.com/" rel="nofollow noreferrer">TextMate</a> for coding on OS X. I've recently started using it, and although I like its minimalistic interface, it makes it harder to stumble upon cool features if you don't know what you're looking for.</p>
<p>So, what ... | [
{
"answer_id": 33819,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "<p>The ease of snippet creation.</p>\n\n<p>It's trivial to create new snippets that can accomplish a lot using replacemen... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3002/"
] | I noticed that many people here use [TextMate](http://macromates.com/) for coding on OS X. I've recently started using it, and although I like its minimalistic interface, it makes it harder to stumble upon cool features if you don't know what you're looking for.
So, what feature have you found most helpful for coding ... | Don't neglect the 'mate' command line tool. You can use it to pipe output into TextMate, so if you do the following...
```
diff file1.py file2.py | mate
```
...it will not only open in TextMate, but it is smart enough to know that you're looking at a diff and highlight lines on screen.
TextMate's SVN integration is... |
33,814 | <p>I'm writing a PHP script that involves scraping web pages. Currently, the script analyzes the page line by line, but it breaks if there is a tag that spans multiple lines, like </p>
<pre><code><img src="example.jpg"
alt="example">
</code></pre>
<p>If worse comes to worst, I could possibly preprocess the page... | [
{
"answer_id": 33835,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 1,
"selected": false,
"text": "<p>Well, this doesn't answer the question and is more of an opinion, but...</p>\n\n<p>I think that the best scraping strateg... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1569/"
] | I'm writing a PHP script that involves scraping web pages. Currently, the script analyzes the page line by line, but it breaks if there is a tag that spans multiple lines, like
```
<img src="example.jpg"
alt="example">
```
If worse comes to worst, I could possibly preprocess the page by removing all line breaks, th... | Perhaps for future projects I'll use a parsing library, but that's kind of aside from the question at hand. This is my current solution. `rstrpos` is strpos, but from the reverse direction. Example use:
```
for($i=0; $i<count($lines); $i++)
{
$line = handle_mulitline_tags(&$i, $line, $lines);
}
```
And here's th... |
33,822 | <p>Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on my machine for security and compliance. What I'd like to... | [
{
"answer_id": 33826,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 2,
"selected": false,
"text": "<p>Download <a href=\"http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx\" rel=\"nofollow noreferrer\">PSKill</a>. Wri... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3030/"
] | Every time I turn on my company-owned development machine, I have to kill 10+ processes using the Task Manager or any other process management app just to get decent performance out of my IDE. Yes, these are processes from programs that my company installs on my machine for security and compliance. What I'd like to do ... | You can do this with '**taskkill**'.
With the /IM parameter, you can specify image names.
Example:
```
taskkill /im somecorporateprocess.exe
```
You can also do this to '**force**' kill:
Example:
```
taskkill /f /im somecorporateprocess.exe
```
Just add one line per process you want to kill, save it as a .bat ... |
33,836 | <p>This is a follow on question to "<a href="https://stackoverflow.com/questions/33778/how-do-i-delete-1-file-from-a-revision-in-svn">How do I delete 1 file from a revision in SVN?</a>" but because it probably has a very different answer and I believe that others would benefit from knowing the answer. (I don't know the... | [
{
"answer_id": 33846,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 1,
"selected": false,
"text": "<p>I would have said you can't - you have created a new file and thus revision tree in the eyes of SVN.</p>\n\n<p>It may ... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | This is a follow on question to "[How do I delete 1 file from a revision in SVN?](https://stackoverflow.com/questions/33778/how-do-i-delete-1-file-from-a-revision-in-svn)" but because it probably has a very different answer and I believe that others would benefit from knowing the answer. (I don't know the answer yet.)
... | With a simple
```
svn log -v [folder]
```
you can browse quickly the adding and deletion.
```
------------------------------------------------------------------------
r14 | kame | 2008-08-29 04:23:43 +0200 (ven., 29 aoû2008) | 1 line
Chemins modifié :
A /a.txt
Readded a
----------------------------------------... |
33,837 | <p>I have a page where there is a column and a content div, somewhat like this:</p>
<pre><code><div id="container">
<div id="content">blahblahblah</div>
<div id="column"> </div>
</div>
</code></pre>
<p>With some styling I have an image that is split between the column and t... | [
{
"answer_id": 33854,
"author": "Ricky",
"author_id": 653,
"author_profile": "https://Stackoverflow.com/users/653",
"pm_score": 3,
"selected": true,
"text": "<p>Its a bug in the rendering engine. I run into it all the time. One potential way to solve it is to hide and show the div whenev... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | I have a page where there is a column and a content div, somewhat like this:
```
<div id="container">
<div id="content">blahblahblah</div>
<div id="column"> </div>
</div>
```
With some styling I have an image that is split between the column and the content but needs to maintain the same vertical positioning... | Its a bug in the rendering engine. I run into it all the time. One potential way to solve it is to hide and show the div whenever you change the content (that in turn changes the height):
```
var divCol = document.getElementById('column');
divCol.style.display = 'none';
divCol.style.display = 'block';
```
Hopefully ... |
33,852 | <p>Most of time we represent concepts which can never be less than 0. For example to declare length, we write:</p>
<pre><code>int length;
</code></pre>
<p>The name expresses its purpose well but you can assign negative values to it. It seems that for some situations, you can represent your intent more clearly by writ... | [
{
"answer_id": 33857,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 3,
"selected": false,
"text": "<p>If you decrement a signed number with a value of 0, it becomes negative and you can easily test for this. If you decrement an ... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/718/"
] | Most of time we represent concepts which can never be less than 0. For example to declare length, we write:
```
int length;
```
The name expresses its purpose well but you can assign negative values to it. It seems that for some situations, you can represent your intent more clearly by writing it this way instead:
... | “When in Rome, do as the Romans do.”
While there is theoretically an advantage in using unsigned values where applicable because it makes the code more expressive, this is simply not done in C#. I'm not sure why the developers initially didn't design the interfaces to handle `uints` and make the type CLS compliant but... |
33,860 | <p>In Ruby on Rails, I'm attempting to update the <code>innerHTML</code> of a div tag using the <code>form_remote_tag</code> helper. This update happens whenever an associated select tag receives an onchange event. The problem is, <code><select onchange="this.form.submit();"></code>; doesn't work. Nor does <co... | [
{
"answer_id": 33879,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": false,
"text": "<p>give your form an <code>id</code>.</p>\n\n<p>then</p>\n\n<pre><code>document.getElementById('formid').submit();\n</code></... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3499/"
] | In Ruby on Rails, I'm attempting to update the `innerHTML` of a div tag using the `form_remote_tag` helper. This update happens whenever an associated select tag receives an onchange event. The problem is, `<select onchange="this.form.submit();">`; doesn't work. Nor does `document.forms[0].submit()`. The only way to ge... | If you didn't actually want to submit the form, but just invoke whatever code happened to be in the onsubmit, you could possibly do this: (untested)
```
var code = document.getElementById('formId').getAttribute('onsubmit');
eval(code);
``` |
33,881 | <p>I always run into the same problem when creating web pages. When I add a font that is larger then about 16-18px it looks terrible. Its jagged, and pixelated. I have tried using different fonts and weights, however I haven't had much luck there. </p>
<p>Note: Its only in windows that it is like this. Mainly in Opera... | [
{
"answer_id": 33885,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 0,
"selected": false,
"text": "<p>Enabling anti-aliasing should solve the display problem. </p>\n"
},
{
"answer_id": 33886,
"author": "tra... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1925/"
] | I always run into the same problem when creating web pages. When I add a font that is larger then about 16-18px it looks terrible. Its jagged, and pixelated. I have tried using different fonts and weights, however I haven't had much luck there.
Note: Its only in windows that it is like this. Mainly in Opera and FF al... | There is nothing you can do to force the user to change the way that their operating system renders fonts. If it is that big a deal to you then you can replace the large headings with images, this allows you to control exactly how the font is rendered (and ensures that the heading looks exactly as you wish, even if the... |
33,893 | <p>In my (PHP) web app, I have a part of my site that keeps a history of recent searches. The most recent queries get shown in a side box. If the query text is too long, I truncate it and show ellipses. Eg: "My very long query is..."</p>
<p>Currently, I truncate after a certain number of characters. Since the font is ... | [
{
"answer_id": 33899,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Does CSS have a way?</p>\n</blockquote>\n\n<p>No</p>\n\n<blockquote>\n <p>Does PHP?</p>\n</blockquote... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/356/"
] | In my (PHP) web app, I have a part of my site that keeps a history of recent searches. The most recent queries get shown in a side box. If the query text is too long, I truncate it and show ellipses. Eg: "My very long query is..."
Currently, I truncate after a certain number of characters. Since the font is not monoty... | Here's another take on it and you don't have to live without the ellipsis!
```
<html>
<head>
<style>
div.sidebox {
width: 25%;
}
div.sidebox div.qrytxt {
height: 1em;
line-height: 1em;
overflow: hidden;
}
div.sidebox div.qrytxt span.ellipsis {
float: right;
}
</style>
</head>
<body>
<div clas... |
33,923 | <p>Whilst starting to learn lisp, I've come across the term <em>tail-recursive</em>. What does it mean exactly?</p>
| [
{
"answer_id": 33924,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not a Lisp programmer, but I think <a href=\"http://en.wikipedia.org/wiki/Tail_recursion\" rel=\"noreferrer\">this... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2045/"
] | Whilst starting to learn lisp, I've come across the term *tail-recursive*. What does it mean exactly? | Consider a simple function that adds the first N natural numbers. (e.g. `sum(5) = 0 + 1 + 2 + 3 + 4 + 5 = 15`).
Here is a simple JavaScript implementation that uses recursion:
```js
function recsum(x) {
if (x === 0) {
return 0;
} else {
return x + recsum(x - 1);
}
}
```
If you called `re... |
33,933 | <p>I have the following <code>textarea</code> in a <code>table</code>:</p>
<pre><code><table width="300"><tr><td>
<textarea style="width:100%">
longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring
</textarea>
... | [
{
"answer_id": 33936,
"author": "Jiaaro",
"author_id": 2908,
"author_profile": "https://Stackoverflow.com/users/2908",
"pm_score": 0,
"selected": false,
"text": "<p>did you try...</p>\n\n<p><code>overflow: hidden;</code></p>\n\n<p>??</p>\n\n<p>I'm not sure if it should be in the table of... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2749/"
] | I have the following `textarea` in a `table`:
```
<table width="300"><tr><td>
<textarea style="width:100%">
longstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstringlongstring
</textarea>
</td></tr></table>
```
With a long string in the textarea, the t... | Apply the width to the `td`, not the `table`.
EDIT: @Emmett - the width could just as easily be applied via CSS.
```css
td {
width: 300px;
}
```
produces the desired result. Or, if you're using jQuery, you could add the width through script:
```
$('textarea[width=100%]').parent('td').css('width', '300px');
``... |
33,956 | <p>Assume that I have a field called <em>price</em> for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it?</p>
<p>I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges... | [
{
"answer_id": 34027,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 2,
"selected": false,
"text": "<p>There may well be a better Solr-specific answer, but I work with straight Lucene, and since you're not getting much tract... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] | Assume that I have a field called *price* for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it?
I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges (say for 5 value... | To answer your first question, you can get facet ranges by using the the generic facet query support. [Here](http://wiki.apache.org/solr/SimpleFacetParameters#head-1da3ab3995bc4abcdce8e0f04be7355ba19e9b2c)'s an example:
```
http://localhost:8983/solr/select?q=video&rows=0&facet=true&facet.query=price:[*+TO+500]&facet.... |
33,969 | <p>We're experimenting with various ways to throttle user actions in a <strong>given time period</strong>:</p>
<ul>
<li>Limit question/answer posts</li>
<li>Limit edits</li>
<li>Limit feed retrievals</li>
</ul>
<p>For the time being, we're using the Cache to simply insert a record of user activity - if that record ex... | [
{
"answer_id": 291390,
"author": "Rob Kraft",
"author_id": 37749,
"author_profile": "https://Stackoverflow.com/users/37749",
"pm_score": 4,
"selected": false,
"text": "<p>We use the technique borrowed from this URL <a href=\"http://www.codeproject.com/KB/aspnet/10ASPNetPerformance.aspx\"... | 2008/08/29 | [
"https://Stackoverflow.com/questions/33969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3/"
] | We're experimenting with various ways to throttle user actions in a **given time period**:
* Limit question/answer posts
* Limit edits
* Limit feed retrievals
For the time being, we're using the Cache to simply insert a record of user activity - if that record exists if/when the user does the same activity, we thrott... | Here's a generic version of what we've been using on Stack Overflow for the past year:
```
/// <summary>
/// Decorates any MVC route that needs to have client requests limited by time.
/// </summary>
/// <remarks>
/// Uses the current System.Web.Caching.Cache to store each client request to the decorated route.
/// </... |
34,065 | <p>Given the key for some registry value (e.g. HKEY_LOCAL_MACHINE\blah\blah\blah\foo) how can I:</p>
<ol>
<li>Safely determine that such a key exists.</li>
<li>Programmatically (i.e. with code) get its value.</li>
</ol>
<p>I have absolutely no intention of writing anything back to the registry (for the duration of my... | [
{
"answer_id": 34067,
"author": "Tyler",
"author_id": 3561,
"author_profile": "https://Stackoverflow.com/users/3561",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms724911%28VS.85%29.aspx\" rel=\"nofollow noreferrer\">RegQueryValueEx</a>... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3551/"
] | Given the key for some registry value (e.g. HKEY\_LOCAL\_MACHINE\blah\blah\blah\foo) how can I:
1. Safely determine that such a key exists.
2. Programmatically (i.e. with code) get its value.
I have absolutely no intention of writing anything back to the registry (for the duration of my career if I can help it). So w... | **Here is some pseudo-code to retrieve the following:**
1. If a registry key exists
2. What the default value is for that registry key
3. What a string value is
4. What a DWORD value is
**Example code:**
Include the library dependency: Advapi32.lib
```
HKEY hKey;
LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFT... |
34,079 | <p>What's the best way to specify a proxy with username and password for an http connection in python?</p>
| [
{
"answer_id": 34116,
"author": "bernhardrusch",
"author_id": 3056,
"author_profile": "https://Stackoverflow.com/users/3056",
"pm_score": 6,
"selected": false,
"text": "<p>This works for me: </p>\n\n<pre><code>import urllib2\n\nproxy = urllib2.ProxyHandler({'http': 'http://\nusername:pa... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3573/"
] | What's the best way to specify a proxy with username and password for an http connection in python? | Use this:
```
import requests
proxies = {"http":"http://username:password@proxy_ip:proxy_port"}
r = requests.get("http://www.example.com/", proxies=proxies)
print(r.content)
```
I think it's much simpler than using `urllib`. I don't understand why people love using `urllib` so much. |
34,087 | <pre><code><xsl:for-each select="./node [position() &lt;= (count(*) div 2)]">
<li>foo</li>
</xsl:for-each>
<xsl:for-each select="./node [count(*) div 2 &lt; position()]">
<li>bar</li>
</xsl:for-each>
</code></pre>
<p>My list has 12 nodes, but the second l... | [
{
"answer_id": 34111,
"author": "A. Rex",
"author_id": 3508,
"author_profile": "https://Stackoverflow.com/users/3508",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not at all sure, but it seems to me that <code>count(*)</code> is not doing what you think it is. That counts the numb... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] | ```
<xsl:for-each select="./node [position() <= (count(*) div 2)]">
<li>foo</li>
</xsl:for-each>
<xsl:for-each select="./node [count(*) div 2 < position()]">
<li>bar</li>
</xsl:for-each>
```
My list has 12 nodes, but the second list is always 8 and the first is always 4. What's wrong with my selects? | When you do `count(*)`, the current node is the `node` element being processed. You want either `count(current()/node)` or `last()` (preferable), or just calculate the midpoint to a variable for better performance and clearer code:
```
<xsl:variable name="nodes" select="node"/>
<xsl:variable name="mid" select="count($... |
34,093 | <p>I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File.</p>
| [
{
"answer_id": 34095,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 9,
"selected": true,
"text": "<p>I found a possible answer here: <a href=\"http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Artic... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | I want to apply an XSLT Stylesheet to an XML Document using C# and write the output to a File. | I found a possible answer here: <http://web.archive.org/web/20130329123237/http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63>
From the article:
```
XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ;
XslTransform myXslTrans = new XslTransform() ;
myXslTrans.Load(myStyleSheet);
XmlTextWriter myW... |
34,125 | <p>It seems to me that it would work perfectly well to do tail-recursion optimization in both C and C++, yet while debugging I never seem to see a frame stack that indicates this optimization. That is kind of good, because the stack tells me how deep the recursion is. However, the optimization would be kind of nice as ... | [
{
"answer_id": 34129,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 8,
"selected": true,
"text": "<p><strong>All current mainstream compilers perform tail call optimisation</strong> fairly well (and have done for more... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2971/"
] | It seems to me that it would work perfectly well to do tail-recursion optimization in both C and C++, yet while debugging I never seem to see a frame stack that indicates this optimization. That is kind of good, because the stack tells me how deep the recursion is. However, the optimization would be kind of nice as wel... | **All current mainstream compilers perform tail call optimisation** fairly well (and have done for more than a decade), [even for mutually recursive calls](https://godbolt.org/g/TjqTHV) such as:
```
int bar(int, int);
int foo(int n, int acc) {
return (n == 0) ? acc : bar(n - 1, acc + 2);
}
int bar(int n, int acc... |
34,126 | <p>I see 2 main ways to set events in JavaScript:</p>
<ol>
<li><p>Add an event directly inside the tag like this:</p>
<p><code><a href="" onclick="doFoo()">do foo</a></code></p></li>
<li><p>Set them by JavaScript like this:</p>
<p><code><a id="bar" href="">do bar</a></code></p></li>
</ol>
<p... | [
{
"answer_id": 34130,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 0,
"selected": false,
"text": "<p>Libraries like YUI and jQuery provide methods to add events only once the DOM is ready, which can be before window.onload. ... | 2008/08/29 | [
"https://Stackoverflow.com/questions/34126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3122/"
] | I see 2 main ways to set events in JavaScript:
1. Add an event directly inside the tag like this:
`<a href="" onclick="doFoo()">do foo</a>`
2. Set them by JavaScript like this:
`<a id="bar" href="">do bar</a>`
and add an event in a `<script>` section inside the `<head>` section or in an external JavaScript file, li... | In my experience, there are two major points to this:
1) The most important thing is to be consistent. I don't think either of the two methods is necessarily easier to read, as long as you stick to it. I only get confused when both methods are used in a project (or even worse on the same page) because then I have to s... |