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 |
|---|---|---|---|---|---|---|
318,807 | <p>I'm pretty sure this is not the right way to do this so I'm looking for some suggestions.</p>
<p>I don't think my problem so much is that I'm trying to solve a spatial problem. I'm just not sure of a good way to take the latitude and longitude and return a geography data type in a select statement. I have success... | [
{
"answer_id": 318852,
"author": "David M. Karr",
"author_id": 10508,
"author_profile": "https://Stackoverflow.com/users/10508",
"pm_score": 2,
"selected": false,
"text": "<p>I know that one advantage of Ivy is that it can use different kinds of repositories. Maven is typically very rig... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32113/"
] | I'm pretty sure this is not the right way to do this so I'm looking for some suggestions.
I don't think my problem so much is that I'm trying to solve a spatial problem. I'm just not sure of a good way to take the latitude and longitude and return a geography data type in a select statement. I have successfully create... | Since what you're wanting to do is add dependency management to an existing Ant project, that's precisely what Ivy's designed to do. Dependency management is a big part of Maven, but far from all of it. Maven is more of a project-oriented tool that does several other things in addition to dependencies. It would be wort... |
318,816 | <p>How would I go about setting different authentication tags for different parts of my web app? Say I have:</p>
<pre><code>/
/folder1/
/folder2/
</code></pre>
<p>Would it be possible to specify different <code><authentication/></code> tags for each folder?</p>
<p>I want folder1 to use Windows authentication ... | [
{
"answer_id": 319035,
"author": "JasonS",
"author_id": 1865,
"author_profile": "https://Stackoverflow.com/users/1865",
"pm_score": 1,
"selected": false,
"text": "<p>I think you can set the forms authentication authorization on folder1 to </p>\n\n<pre><code><allow users=\"*\" />\n<... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/70/"
] | How would I go about setting different authentication tags for different parts of my web app? Say I have:
```
/
/folder1/
/folder2/
```
Would it be possible to specify different `<authentication/>` tags for each folder?
I want folder1 to use Windows authentication but folder2 use Forms authentication.
I tried doi... | You can only have `<authentication />` on the top level `web.config`. You may have to create multiple applications. ie you can create an application within an application and use different authentication modes in each one. |
318,835 | <p>When creating a new C++ header/source file, what information do you add to the top? For example, do you add the date, your name, a description of the file, etc.? Do you use a structured format for this information?</p>
<p>e.g.</p>
<pre><code>// Foo.cpp - Implementation of the Foo class
// Date: 2008-25-11
// Cre... | [
{
"answer_id": 318851,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 1,
"selected": false,
"text": "<p>I don't embed the date because it's redundant. If someone wants to know the date a file was created don't trust the a... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | When creating a new C++ header/source file, what information do you add to the top? For example, do you add the date, your name, a description of the file, etc.? Do you use a structured format for this information?
e.g.
```
// Foo.cpp - Implementation of the Foo class
// Date: 2008-25-11
// Created by: John Smith
``... | Information about who created a file and when and who edited it and when is all in source control. If your team has good practices around check-in comments, then you'll know the reasons for each change too. No need for comments for that stuff.
I think it's 100% legit - wise, even - to put a comment block, as long as i... |
318,850 | <p>I have a two part question</p>
<p><strong>Best-Practice</strong></p>
<ul>
<li>I have an algorithm that performs some operation on a data structure using the public interface</li>
<li>It is currently a module with numerous static methods, all private except for the one public interface method.</li>
<li>There is one... | [
{
"answer_id": 318893,
"author": "J Cooper",
"author_id": 38803,
"author_profile": "https://Stackoverflow.com/users/38803",
"pm_score": 4,
"selected": false,
"text": "<p>Unfortunately, <code>private</code> only applies to instance methods. The general way to get private \"static\" method... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13216/"
] | I have a two part question
**Best-Practice**
* I have an algorithm that performs some operation on a data structure using the public interface
* It is currently a module with numerous static methods, all private except for the one public interface method.
* There is one instance variable that needs to be shared among... | I think the best way (and mostly how existing libs are written) to do this is by creating a class within the module that deals with all the logic, and the module just provides a convenient method, e.g.
```
module GTranslate
class Translator
def perform(text)
translate(text)
end
private
def tr... |
318,871 | <p>Due to current limitations on getting DIV tags to work well across browser platforms for the particular liquid layout I desire, I have opted to use a combination of Tables and DIVs for layout. That being said, a couple of issues remain. </p>
<p>The FIRST issue is that in Firefox, my table row height for my footer... | [
{
"answer_id": 318920,
"author": "K4emic",
"author_id": 348430,
"author_profile": "https://Stackoverflow.com/users/348430",
"pm_score": 2,
"selected": false,
"text": "<p>I know this is quite unrelated, but I recommend that you use <a href=\"http://validator.w3.org/#validate_by_input\" re... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40810/"
] | Due to current limitations on getting DIV tags to work well across browser platforms for the particular liquid layout I desire, I have opted to use a combination of Tables and DIVs for layout. That being said, a couple of issues remain.
The FIRST issue is that in Firefox, my table row height for my footer is being re... | I know this is quite unrelated, but I recommend that you use [the w3c validator](http://validator.w3.org/#validate_by_input) to validate your HTML once in a while. |
318,875 | <p>Is this right for When 4 < 5 and 1 < 2 ?</p>
<pre><code><xsl:when test="4 &lt; 5 AND 1 &lt; 2" >
<!-- do something -->
</xsl:when>
</code></pre>
| [
{
"answer_id": 318904,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 3,
"selected": false,
"text": "<p>From <a href=\"http://www.xml.com/pub/a/2003/04/02/trxml.html\" rel=\"noreferrer\">XML.com</a>:</p>\n\n<blockquot... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5653/"
] | Is this right for When 4 < 5 and 1 < 2 ?
```
<xsl:when test="4 < 5 AND 1 < 2" >
<!-- do something -->
</xsl:when>
``` | Not quite, the AND has to be lower-case.
```
<xsl:when test="4 < 5 and 1 < 2">
<!-- do something -->
</xsl:when>
``` |
318,876 | <p>I have TFS installed on a single server and am running out of space on the disk. (We've been using the instance for about 2 years now.) </p>
<p>Looking at the tables in SQL Server what seems to be culprit is the tbl_content table, it is at 70 GB. If I do a get on the entire source tree for all projects it is only... | [
{
"answer_id": 319777,
"author": "JB Brown",
"author_id": 21360,
"author_profile": "https://Stackoverflow.com/users/21360",
"pm_score": 2,
"selected": false,
"text": "<p>I can't help with the ratio question at the moment, sorry. For a short-term fix you might check to see if there is any... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have TFS installed on a single server and am running out of space on the disk. (We've been using the instance for about 2 years now.)
Looking at the tables in SQL Server what seems to be culprit is the tbl\_content table, it is at 70 GB. If I do a get on the entire source tree for all projects it is only about 8 GB... | I can't help with the ratio question at the moment, sorry. For a short-term fix you might check to see if there is any space within the DB files that can be freed up. You may have already, but if not..
```
SELECT name ,size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS AvailableSpaceInMB
FROM sys.datab... |
318,886 | <p>I can't seem to figure this out. I'm experimenting with MVC Beta and am trying to implement a catchall route such that if the user enters mysite.com/blah instead of mysite.com/home/index it will hit the "Error" route. </p>
<p>Unfortunately it seems that the "Default" route always catches "blah" first. In fact the o... | [
{
"answer_id": 319074,
"author": "Min",
"author_id": 14461,
"author_profile": "https://Stackoverflow.com/users/14461",
"pm_score": 3,
"selected": true,
"text": "<p>MVC routes are checked in the order that they are entered. </p>\n\n<p>Mysite/blah will be found by the default route. The co... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40814/"
] | I can't seem to figure this out. I'm experimenting with MVC Beta and am trying to implement a catchall route such that if the user enters mysite.com/blah instead of mysite.com/home/index it will hit the "Error" route.
Unfortunately it seems that the "Default" route always catches "blah" first. In fact the only route ... | MVC routes are checked in the order that they are entered.
Mysite/blah will be found by the default route. The controller will be blah, and the action is index.
When you entered the mysite/blah/blah/blah/blah route you gave it a route it could not map the default route to and then your catchall route was called.
F... |
318,888 | <p>Edit: this puzzle is also known as "Einstein's Riddle"</p>
<p>The <a href="https://en.wikipedia.org/wiki/Zebra_Puzzle" rel="noreferrer">Who owns the Zebra</a> (you can <a href="https://www.brainzilla.com/logic/zebra/einsteins-riddle/" rel="noreferrer" title="Einstein's Riddle">try the online version here</a>) i... | [
{
"answer_id": 318922,
"author": "Larry OBrien",
"author_id": 10116,
"author_profile": "https://Stackoverflow.com/users/10116",
"pm_score": 3,
"selected": false,
"text": "<p>Here is an excerpt from the <a href=\"http://web.archive.org/web/20060602230950/http://www.knowing.net/einstein_cs... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20444/"
] | Edit: this puzzle is also known as "Einstein's Riddle"
The [Who owns the Zebra](https://en.wikipedia.org/wiki/Zebra_Puzzle) (you can [try the online version here](https://www.brainzilla.com/logic/zebra/einsteins-riddle/ "Einstein's Riddle")) is an example of a classic set of puzzles and I bet that most people on Stack... | Here's a solution in Python based on constraint-programming:
```py
from constraint import AllDifferentConstraint, InSetConstraint, Problem
# variables
colors = "blue red green white yellow".split()
nationalities = "Norwegian German Dane Swede English".split()
pets = "birds dog cats horse zebra".split(... |
318,906 | <p>I'm having some problems with a datagridview element I'm using in VS2008.
This DataGridView is actually a tab in a TabControl element.</p>
<p>I gave it 5 colums which need to be filled up with elements from a costum Object i made.</p>
<p>It's basically a small library application which contains a main class and se... | [
{
"answer_id": 318928,
"author": "dragonjujo",
"author_id": 37344,
"author_profile": "https://Stackoverflow.com/users/37344",
"pm_score": 0,
"selected": false,
"text": "<p>I can only give a partial answer but I think the reason that </p>\n\n<pre><code>public void tabControl1_SelectedInde... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I'm having some problems with a datagridview element I'm using in VS2008.
This DataGridView is actually a tab in a TabControl element.
I gave it 5 colums which need to be filled up with elements from a costum Object i made.
It's basically a small library application which contains a main class and several classed der... | I'm a little confused by the question, but here are some thoughts:
1. `DataGridView` has an [`AutoGenerateColumn`s](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns.aspx) property; if you don't want it to create its own columns, set this to false
2. To bind to existing colu... |
318,915 | <p>I'm using the following code</p>
<pre><code>System::Diagnostics::Process^ p = gcnew System::Diagnostics::Process();
p->StartInfo->FileName = "tnccmd.exe";
p->StartInfo->UseShellExecute = false;
p->StartInfo->RedirectStandardInput = true;
p->StartInfo->RedirectStandardOutput = true;
p->S... | [
{
"answer_id": 318928,
"author": "dragonjujo",
"author_id": 37344,
"author_profile": "https://Stackoverflow.com/users/37344",
"pm_score": 0,
"selected": false,
"text": "<p>I can only give a partial answer but I think the reason that </p>\n\n<pre><code>public void tabControl1_SelectedInde... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | I'm using the following code
```
System::Diagnostics::Process^ p = gcnew System::Diagnostics::Process();
p->StartInfo->FileName = "tnccmd.exe";
p->StartInfo->UseShellExecute = false;
p->StartInfo->RedirectStandardInput = true;
p->StartInfo->RedirectStandardOutput = true;
p->Start();
System::IO::StreamWriter^ tnc_std... | I'm a little confused by the question, but here are some thoughts:
1. `DataGridView` has an [`AutoGenerateColumn`s](http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecolumns.aspx) property; if you don't want it to create its own columns, set this to false
2. To bind to existing colu... |
318,926 | <p>i've populated a dropdownlist control with different text properties but each text properties had THE SAME value (text property was A, value properties is blah,text property was B, value properties is blahblah, etc... )</p>
<p>ASP.net only checks value properties on postback and because ALL values were the same (fo... | [
{
"answer_id": 318948,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 4,
"selected": true,
"text": "<p>Sounds like you are working on the wrong event. Try <a href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webco... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | i've populated a dropdownlist control with different text properties but each text properties had THE SAME value (text property was A, value properties is blah,text property was B, value properties is blahblah, etc... )
ASP.net only checks value properties on postback and because ALL values were the same (for
testing ... | Sounds like you are working on the wrong event. Try [SelectedIndexChanged](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listcontrol.onselectedindexchanged(VS.85).aspx).
Ensure you also have the `AutoPostBack` property set to `True`.
### Resolved
OK, so I got digging on this since I was curious :... |
318,938 | <p>Testing:</p>
<pre><code>return request.getCookies() == null;
</code></pre>
<p>is not an appropriate way test. Is there another way?</p>
| [
{
"answer_id": 319091,
"author": "digitalsanctum",
"author_id": 22436,
"author_profile": "https://Stackoverflow.com/users/22436",
"pm_score": 3,
"selected": true,
"text": "<p>You generally want to use JavaScript to determine if the client's browser has cookies enabled:</p>\n\n<pre><code>... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39371/"
] | Testing:
```
return request.getCookies() == null;
```
is not an appropriate way test. Is there another way? | You generally want to use JavaScript to determine if the client's browser has cookies enabled:
```
<script type="text/javascript">
var cookieEnabled=(navigator.cookieEnabled)? true : false
//if not IE4+ nor NS6+
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
document.cookie="testcookie"
cookieEn... |
318,952 | <p>How do I convert a string into the corresponding code in PLT Scheme (which does not contain the <code>string->input-port</code> method)? For example, I want to convert this string:</p>
<pre><code>"(1 (0) 1 (0) 0)"
</code></pre>
<p>into this list:</p>
<pre><code>'(1 (0) 1 (0) 0)
</code></pre>
<p>Is it possibl... | [
{
"answer_id": 318978,
"author": "Brian Gianforcaro",
"author_id": 3415,
"author_profile": "https://Stackoverflow.com/users/3415",
"pm_score": 2,
"selected": false,
"text": "<p>From this similar question on <a href=\"http://groups.google.com/group/comp.lang.scheme/browse_thread/thread/30... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] | How do I convert a string into the corresponding code in PLT Scheme (which does not contain the `string->input-port` method)? For example, I want to convert this string:
```
"(1 (0) 1 (0) 0)"
```
into this list:
```
'(1 (0) 1 (0) 0)
```
Is it possible to do this without opening a file? | Scheme has procedure `read` for reading s-expressions from input port and you can convert a string to input stream with `string->input-port`. So, you can read a Scheme object from a string with
```
(read (string->input-port "(1 (0) 1 (0) 0)"))
```
I don't have Scheme installed, so I only read it [from reference](htt... |
318,964 | <p>I'm building a new app that is using NHibernate to generate the database schema but i can see a possible problem in the future.</p>
<p>Obviously you use all the data from your database is cleared when you update the schema but what stratagies do people use to restore any data to the new database. I am aware that ma... | [
{
"answer_id": 319010,
"author": "Min",
"author_id": 14461,
"author_profile": "https://Stackoverflow.com/users/14461",
"pm_score": 0,
"selected": false,
"text": "<p>We don't update the schema from NHibernate. We use SQLCompare to move database schemas across environments. SQLCompare does... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1213936/"
] | I'm building a new app that is using NHibernate to generate the database schema but i can see a possible problem in the future.
Obviously you use all the data from your database is cleared when you update the schema but what stratagies do people use to restore any data to the new database. I am aware that massive chan... | When testing, we use NHibernate to create the database, then a series of [builders](http://en.wikipedia.org/wiki/Builder_pattern) to create the data for each test fixture. We also use Sqlite for these tests, so they are lightening fast.
Our builders look a something like this:
```
public class CustomerBuilder : Build... |
318,969 | <p>i have a basic ruby class:</p>
<pre><code>class LogEntry
end
</code></pre>
<p>and what i would like to do is be able to define a hash with a few values like so:</p>
<pre><code>EntryType = { :error => 0, :warning => 1, :info => 2 }
</code></pre>
<p>so that i can access the values like this (or something... | [
{
"answer_id": 318981,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this:</p>\n\n<pre><code>class LogEntry\n EntryType = { :error => 0, :warning => 1, :info => 2 }\ne... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | i have a basic ruby class:
```
class LogEntry
end
```
and what i would like to do is be able to define a hash with a few values like so:
```
EntryType = { :error => 0, :warning => 1, :info => 2 }
```
so that i can access the values like this (or something similar):
```
LogEntry.EntryType[:error]
```
is this e... | You can do this:
```
class LogEntry
EntryType = { :error => 0, :warning => 1, :info => 2 }
end
```
But you want to reference it as
```
LogEntry::EntryType[:error]
``` |
318,988 | <p>Let's say I have a table like this:</p>
<pre><code>name | score_a | score_b
-----+---------+--------
Joe | 100 | 24
Sam | 96 | 438
Bob | 76 | 101
... | ... | ...
</code></pre>
<p>I'd like to select the minimum of score_a and score_b. In other words, something like:</p>
<pre><code>SELECT... | [
{
"answer_id": 318993,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 10,
"selected": true,
"text": "<p><a href=\"https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-GREATEST-LEAST\" rel=\"norefer... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Let's say I have a table like this:
```
name | score_a | score_b
-----+---------+--------
Joe | 100 | 24
Sam | 96 | 438
Bob | 76 | 101
... | ... | ...
```
I'd like to select the minimum of score\_a and score\_b. In other words, something like:
```
SELECT name, MIN(score_a, score_b)
FROM t... | [LEAST](https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-GREATEST-LEAST)(a, b):
>
> The `GREATEST` and `LEAST` functions select the largest or smallest value from a list of any number of expressions. The expressions must all be convertible to a common data type, which will be the type of t... |
318,998 | <p>I am currently building a .Net userform using C# and I am populating it with custom user controls. The controls each have an accessor that gets and sets the object that contains the data that the control will be populated with.</p>
<p>At runtime, everything works great, but at design time I will get errors in the ... | [
{
"answer_id": 319019,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "<p>Here is an example of design-time-aware code in a user control:</p>\n\n<pre><code>protected override void OnPaintBa... | 2008/11/25 | [
"https://Stackoverflow.com/questions/318998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5239/"
] | I am currently building a .Net userform using C# and I am populating it with custom user controls. The controls each have an accessor that gets and sets the object that contains the data that the control will be populated with.
At runtime, everything works great, but at design time I will get errors in the form design... | It sounds like it could be the way that the object is being serialized.
The designer is doing a binary serialization of the object into the resx file, what you probably need is code to be produced in you .Designer.cs file.
Try putting the following attribute line on the property:
[DesignerSerializationVisibility(Desi... |
319,002 | <p>I use custom Attributes in a project and I would like to integrate them in my unit-tests.</p>
<p>Now I use Rhino Mocks to create my mocks but I don't see a way to add my attributes (and there parameters) to them.</p>
<p>Did I miss something, or is it not possible? Other mocking framework? Or do I have to create du... | [
{
"answer_id": 319219,
"author": "Joseph Anderson",
"author_id": 18102,
"author_profile": "https://Stackoverflow.com/users/18102",
"pm_score": 1,
"selected": false,
"text": "<p>Here's an example of how I've tested custom attributes. In this case I've got a custom attribute that's used on... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23805/"
] | I use custom Attributes in a project and I would like to integrate them in my unit-tests.
Now I use Rhino Mocks to create my mocks but I don't see a way to add my attributes (and there parameters) to them.
Did I miss something, or is it not possible? Other mocking framework? Or do I have to create dummy implementatio... | Here's an example of how I've tested custom attributes. In this case I've got a custom attribute that's used on a method. In my test class, I've created a placeholder method to which the custom attribute is applied. I've then used reflection to get the instance of the custom attribute.
```
[TestFixture] public class S... |
319,038 | <p>I've added a jpg file to the App_localResources folder and in the document properites specified the photo in the Background propery. In the designer it shows up as the background but when i run the page i still get the white page background.</p>
| [
{
"answer_id": 319050,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 0,
"selected": false,
"text": "<p>Guessing that perhaps you have a stylesheet which might be overriding the background?</p>\n"
},
{
"answer_id": 3... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've added a jpg file to the App\_localResources folder and in the document properites specified the photo in the Background propery. In the designer it shows up as the background but when i run the page i still get the white page background. | There's no distinctly ASP.Net way of doing this.
The canonical HTML way is to include this CSS:
```
body { background-image: url('background.jpg'); }
```
If you defined the body tag with `runat="server"` you could add the style inline using the Attributes property, but this wouldn't be a good idea. Layout details l... |
319,044 | <p>For the last couple hours I have been messing with all sorts of different variations of SQL Server full text search. However I am still unable to figure out how the ranking works. I have come across a couple examples that really confuse me as to how they rank higher then others. For example</p>
<p>I have a table wi... | [
{
"answer_id": 322180,
"author": "jerryhung",
"author_id": 37568,
"author_profile": "https://Stackoverflow.com/users/37568",
"pm_score": 1,
"selected": false,
"text": "<p>What happens if you remove the DoB criteria?</p>\n\n<p>MS Full-Text search is really really a black box that's hard t... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1925/"
] | For the last couple hours I have been messing with all sorts of different variations of SQL Server full text search. However I am still unable to figure out how the ranking works. I have come across a couple examples that really confuse me as to how they rank higher then others. For example
I have a table with 5 cols ... | I've found AND and OR clauses don't apply across columns. Create an indexed view that merges the columns and you'll get better results. Look at my past questions and you'll find information that suites your scenario.
I also have found I'm better off not appending a '\*'. I thought it'd turn up more matches, but it ten... |
319,057 | <p>trying to implement a dialog-box style behaviour using a separate div section with all the stuff inside it.</p>
<p>When the "dialog box" needs to be shown, it has to display at the center of the WINDOW, not in the center of the page, that is, REGARDLESS of the scroling position. Furthermore, the correct solution wi... | [
{
"answer_id": 319069,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": 2,
"selected": false,
"text": "<p>Try the method outlined <a href=\"http://www.cssplay.co.uk/layouts/fixed.html\" rel=\"nofollow norefe... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19584/"
] | trying to implement a dialog-box style behaviour using a separate div section with all the stuff inside it.
When the "dialog box" needs to be shown, it has to display at the center of the WINDOW, not in the center of the page, that is, REGARDLESS of the scroling position. Furthermore, the correct solution will not mov... | If I were you I would do it using jQuery and I would suggest you try it out too. This should fit perfectly for jQuery based solution [jQuery Version][1] or try out
```
body {
font: 80% verdana, arial, helvetica, sans-serif;
text-align: center; /* for IE */
}
#container {
margin: 0 ... |
319,065 | <p>Here's the problem:</p>
<p>1.) We have page here... www.blah.com/mypage.html</p>
<p>2.) That page requests a js file www.foo.com like this...</p>
<pre><code><script type="text/javascript" src="http://www.foo.com/jsfile.js" />
</code></pre>
<p>3.) "jsfile.js" uses Prototype to make an Ajax request back to w... | [
{
"answer_id": 319085,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 5,
"selected": true,
"text": "<p>It is XSS and it is forbidden. You should really not do things that way. </p>\n\n<p>If you really need to, make y... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40825/"
] | Here's the problem:
1.) We have page here... www.blah.com/mypage.html
2.) That page requests a js file www.foo.com like this...
```
<script type="text/javascript" src="http://www.foo.com/jsfile.js" />
```
3.) "jsfile.js" uses Prototype to make an Ajax request back to www.foo.com.
4.) The ajax request calls www.fo... | It is XSS and it is forbidden. You should really not do things that way.
If you really need to, make your AJAX code call the local code (PHP, ASP, whatever) on blah.com and make it behave like client and fetch whatever you need from foo.com and return that back to the client. If you use PHP, you can do this with fope... |
319,108 | <p>I have a list of items in a hierarchy, and I'm attempting to parse this list out into an actual hierarchy of objects. I'm using <a href="http://www.sitepoint.com/article/hierarchical-data-database/2/" rel="noreferrer">modified pre-order tree traversal</a> to store/iterate through this list, and so what I have is a s... | [
{
"answer_id": 319127,
"author": "Coincoin",
"author_id": 42,
"author_profile": "https://Stackoverflow.com/users/42",
"pm_score": 2,
"selected": false,
"text": "<p><em>I assume you already know the parent of all items</em>.</p>\n\n<p>All you need to do is to iterate through all item of t... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7913/"
] | I have a list of items in a hierarchy, and I'm attempting to parse this list out into an actual hierarchy of objects. I'm using [modified pre-order tree traversal](http://www.sitepoint.com/article/hierarchical-data-database/2/) to store/iterate through this list, and so what I have is a subset of the tree, including al... | Here's the function I ended up writing. I'm using MPTT to store objects, so the list is in order of the 'left' value, which basically means the parent always comes before any given item in the list. In other words, the item referenced by item.ParentID has always already been added (except in the case of top-level or ro... |
319,113 | <p>I have a JavaScript request going to a ASP.Net (2.0) HTTP handler which passes the request to a java web service. In this system special characters, such as those with an accent do not get passed on correctly.</p>
<p>E.G.</p>
<ul>
<li>Human input: <code>Düsseldorf</code></li>
<li>becomes a JavaScript asynch reques... | [
{
"answer_id": 319412,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 4,
"selected": true,
"text": "<p>I don't know what the default character encoding used by your server (IIS?) is, or if it can be changed, but I can tell y... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459/"
] | I have a JavaScript request going to a ASP.Net (2.0) HTTP handler which passes the request to a java web service. In this system special characters, such as those with an accent do not get passed on correctly.
E.G.
* Human input: `Düsseldorf`
* becomes a JavaScript asynch request to `http://site/serviceproxy.ashx?q=D... | I don't know what the default character encoding used by your server (IIS?) is, or if it can be changed, but I can tell you a few things that might help.
0xFC is the ISO-8859-1 encoding for ü. While the Unicode code point is U+00FC, when encoded with UTF-8, this requires two bytes, and becomes 0xC3 0xBC.
If a UTF-8 d... |
319,124 | <p>In my application I need to temporarily gray out the minimize button of the main form. Any ideas how this can be achieved? I don't mind doing p/invokes to Win32 dlls.</p>
<p>Edit: Graying out the minimize button would be the preferred solution, but is there any other way of preventing the form from becoming minimiz... | [
{
"answer_id": 319139,
"author": "Coincoin",
"author_id": 42,
"author_profile": "https://Stackoverflow.com/users/42",
"pm_score": 3,
"selected": false,
"text": "<pre><code>form.MinimizeBox = false;\n</code></pre>\n\n<p>or if in the form scope</p>\n\n<pre><code>MinimizeBox = false;\n</cod... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21704/"
] | In my application I need to temporarily gray out the minimize button of the main form. Any ideas how this can be achieved? I don't mind doing p/invokes to Win32 dlls.
Edit: Graying out the minimize button would be the preferred solution, but is there any other way of preventing the form from becoming minimized? | I read your comment in regards to my response and was able to drum up a more complete solution for you. I ran this quickly and it seemed to have the behavior that you wanted. Instead of deriving your winforms from Form, derive from this class:
```
using System;
using System.Windows.Forms;
using System.ComponentModel;... |
319,154 | <p>I want <code>boost::any_cast<T></code> to only throw an exception when the type of the <code>any</code> doesn't have an implicit conversion to <code>T</code>. The normal behaviour seems to be to throw an exception if the type of the <code>any</code> is not <code>T</code>, regardless of implicit conversions.</p... | [
{
"answer_id": 319196,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>Well you can't do it. The <code>any</code> mechanism works like this:</p>\n\n<pre><code>struct base {\n ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40834/"
] | I want `boost::any_cast<T>` to only throw an exception when the type of the `any` doesn't have an implicit conversion to `T`. The normal behaviour seems to be to throw an exception if the type of the `any` is not `T`, regardless of implicit conversions.
Example:
```
boost::any a = 1;
boost::any_cast<int>(a); // This ... | Well you can't do it. The `any` mechanism works like this:
```
struct base {
virtual ~base() { }
};
template<typename T>
struct concrete_base : base {
T t;
concrete_base(T t):t(t) { }
};
struct my_any {
base * b;
template<typename T>
my_any(T t):b(new concrete_base<T>(t)) { }
template<t... |
319,155 | <p>I'm working on a project where I am using a script.aculo.us Sortable object.</p>
<p>It works nice and fast in Firefox and Chrome, but in IE it is incredibly slow whenever I drop an element.</p>
<p>I've done a little checking, and it turns out that in IE, the "onUpdate" callback function gets called about 8 times e... | [
{
"answer_id": 319196,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>Well you can't do it. The <code>any</code> mechanism works like this:</p>\n\n<pre><code>struct base {\n ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12983/"
] | I'm working on a project where I am using a script.aculo.us Sortable object.
It works nice and fast in Firefox and Chrome, but in IE it is incredibly slow whenever I drop an element.
I've done a little checking, and it turns out that in IE, the "onUpdate" callback function gets called about 8 times every time I drop.... | Well you can't do it. The `any` mechanism works like this:
```
struct base {
virtual ~base() { }
};
template<typename T>
struct concrete_base : base {
T t;
concrete_base(T t):t(t) { }
};
struct my_any {
base * b;
template<typename T>
my_any(T t):b(new concrete_base<T>(t)) { }
template<t... |
319,159 | <p>I have an XML definition that contains an element with child elements. For example:</p>
<pre><code><a>
<b>
<c>C</c>
<d>D</d>
</b>
</a>
</code></pre>
<p>I have an XSLT with an output of text. For example:</p>
<pre><code><xsl...>
<xsl:output method="t... | [
{
"answer_id": 319175,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 1,
"selected": false,
"text": "<p>Your SQL statement scares me. XML is case-sensitive, and your comparison there is likely to fail if the input XML and XSLT (i... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26625/"
] | I have an XML definition that contains an element with child elements. For example:
```
<a>
<b>
<c>C</c>
<d>D</d>
</b>
</a>
```
I have an XSLT with an output of text. For example:
```
<xsl...>
<xsl:output method="text" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="/a/b" />
...
```
I... | Here is how it can be done:
```
<xsl:output method="xml" />
<xsl:template match="/"><xsl:apply-templates select="/a/b" mode="normalize-space" /></xsl:template>
<xsl:template match="text()" mode="normalize-space"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="@*|node()" mode="normali... |
319,168 | <p>I'm working on +1M LOC C/C++ project on Solaris (remote, via VNC or SSH). I have a daily updated copy of source code on my local machine too (Windows, just for browsing code).</p>
<p>I use VIM and ctags combo (on both Solaris and Windows) but I'm not happy with results / speed. What settings for ctags would you rec... | [
{
"answer_id": 319175,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 1,
"selected": false,
"text": "<p>Your SQL statement scares me. XML is case-sensitive, and your comparison there is likely to fail if the input XML and XSLT (i... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579/"
] | I'm working on +1M LOC C/C++ project on Solaris (remote, via VNC or SSH). I have a daily updated copy of source code on my local machine too (Windows, just for browsing code).
I use VIM and ctags combo (on both Solaris and Windows) but I'm not happy with results / speed. What settings for ctags would you recommend? Th... | Here is how it can be done:
```
<xsl:output method="xml" />
<xsl:template match="/"><xsl:apply-templates select="/a/b" mode="normalize-space" /></xsl:template>
<xsl:template match="text()" mode="normalize-space"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="@*|node()" mode="normali... |
319,171 | <p>I understand the first argument must be the result of GetFileVersionInfo().</p>
<p>The third and forth are target buffer and size</p>
<p>What is the second argument, lpSubBlock?</p>
<p>Thanks In Advance</p>
| [
{
"answer_id": 319233,
"author": "Renaud Bompuis",
"author_id": 3811,
"author_profile": "https://Stackoverflow.com/users/3811",
"pm_score": 2,
"selected": false,
"text": "<p>It must be a string whose format you can find here:<br>\n<a href=\"http://www.hep.wisc.edu/~pinghc/books/apirefeng... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2167252/"
] | I understand the first argument must be the result of GetFileVersionInfo().
The third and forth are target buffer and size
What is the second argument, lpSubBlock?
Thanks In Advance | When you view the version info through the resource editor you might notice that there is an initial section with FILEVERSION, PRODUCTVERISON etc. and then one or more blocks which contain language specific settings.
```
VS_VERSION_INFO VERSIONINFO
FILEVERSION 5,0,0,0
PRODUCTVERSION 5,0,0,0
FILEFLAGSMASK 0x3fL
#ifd... |
319,178 | <p>I'm not sure how to ask the question, for I don't know what I don't know, and therefore I don't know the proper terminology for what I'm trying to get the answer to. I will explain my scenario, in hopes that it will help:</p>
<p>I've got three tables, a Book table, a Tag table and a BookTag lookup table.</p>
<p>E... | [
{
"answer_id": 319236,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 3,
"selected": true,
"text": "<p>You don't need a BookTag class at all. You can map Book.Tags collection as many-to-many. To do this you will specify... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38375/"
] | I'm not sure how to ask the question, for I don't know what I don't know, and therefore I don't know the proper terminology for what I'm trying to get the answer to. I will explain my scenario, in hopes that it will help:
I've got three tables, a Book table, a Tag table and a BookTag lookup table.
Each book has an ID... | You don't need a BookTag class at all. You can map Book.Tags collection as many-to-many. To do this you will specify BookTag in the map to connect the association. Look [here](http://www.hibernate.org/hib_docs/nhibernate/html/collections.html#collections-ofvalues) in section 6.8 Bidirectional Associations. |
319,199 | <p>An integer's max value in Java is 2147483647, since Java integers are signed, right?</p>
<p>0xff000000 has a numeric value of 4278190080.</p>
<p>Yet I see Java code like this:</p>
<pre><code>int ALPHA_MASK = 0xff000000;
</code></pre>
<p>Can anyone enlighten me please?</p>
| [
{
"answer_id": 319201,
"author": "Jimmy",
"author_id": 4435,
"author_profile": "https://Stackoverflow.com/users/4435",
"pm_score": 1,
"selected": false,
"text": "<p>the extra bit is for the sign </p>\n\n<p>Java ints are <a href=\"http://en.wikipedia.org/wiki/Two's_complement\" rel=\"... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13466/"
] | An integer's max value in Java is 2147483647, since Java integers are signed, right?
0xff000000 has a numeric value of 4278190080.
Yet I see Java code like this:
```
int ALPHA_MASK = 0xff000000;
```
Can anyone enlighten me please? | The high bit is a sign bit. Setting it denotes a negative number: -16777216.
Java, like most languages, stores signed numbers in [2's complement](http://en.wikipedia.org/wiki/Two%27s_complement) form. In this case, subtracting 231, or 2147483648 from 0x7F000000, or 2130706432, yields -16777216. |
319,204 | <p>How would you take an arbitrary list of strings (of the form "%[text]%") and a database column, and turn them into a SQL query that does a LIKE comparison for each string in the list?</p>
<p>An example: I have three strings in my list, "%bc%", "%def%" and "%ab%". This builds the query:</p>
<pre><code>([ColumnName]... | [
{
"answer_id": 319240,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 0,
"selected": false,
"text": "<p>It's just a string join on a map:</p>\n\n<pre><code>>>> los=['ab', 'cd', 'ef']\n>>> ' and '.join((\"so... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133/"
] | How would you take an arbitrary list of strings (of the form "%[text]%") and a database column, and turn them into a SQL query that does a LIKE comparison for each string in the list?
An example: I have three strings in my list, "%bc%", "%def%" and "%ab%". This builds the query:
```
([ColumnName] LIKE "%bc" AND [Colu... | To answer your question directly,
```
string.join(" and ",
(new[] { "%bc%", "%def%", "%ab%" })
.Select(x => string.Format("[{0}] LIKE '{1}'",columnName, x))
.ToArray());
```
To solve your problem, you should use the Sql Server full-text search tools. the query would be:
```
select * from table
where FR... |
319,262 | <p>Let's say I have two existing tables, "dogs" and "cats":</p>
<pre><code> dog_name | owner
---------+------
Sparky | Bob
Rover | Bob
Snoopy | Chuck
Odie | Jon
cat_name | owner
---------+------
Garfield | Jon
Muffy | Sam
Stupid | Bob
</code></pre>
<p>How do I write a query with this output... | [
{
"answer_id": 319268,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 5,
"selected": true,
"text": "<pre><code>select owner, sum(num_dogs), sum(num_cats) from\n (select owner, 1 as num_dogs, 0 as num_cats from dogs\n ... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Let's say I have two existing tables, "dogs" and "cats":
```
dog_name | owner
---------+------
Sparky | Bob
Rover | Bob
Snoopy | Chuck
Odie | Jon
cat_name | owner
---------+------
Garfield | Jon
Muffy | Sam
Stupid | Bob
```
How do I write a query with this output?
```
owner | num_dogs |... | ```
select owner, sum(num_dogs), sum(num_cats) from
(select owner, 1 as num_dogs, 0 as num_cats from dogs
union
select owner, 0 as num_dogs, 1 as num_cats from cats)
group by owner
``` |
319,267 | <p>I can not figure out what all the parameters to the arc() function are (by experimentation) and I have not found any tutorial that seems to explain them. Where would a good explanation of the arc() function be?</p>
| [
{
"answer_id": 319286,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>According to <a href=\"https://developer.mozilla.org/En/Canvas_tutorial/Drawing_shapes\" rel=\"nofollow noreferrer\">MD... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10608/"
] | I can not figure out what all the parameters to the arc() function are (by experimentation) and I have not found any tutorial that seems to explain them. Where would a good explanation of the arc() function be? | ```
arc(x, y, radius, startAngle, endAngle, anticlockwise)
```
The first three parameters, x and y and radius, describe a circle, the arc drawn will be part of that circle.
startAngle and endAngle are where along the circle to start and stop drawing. 0 is east, Math.PI/2 is south, Math.PI is west, and Math.PI\*3/2 is... |
319,279 | <p>What's the best way to validate that an IP entered by the user is valid? It comes in as a string.</p>
| [
{
"answer_id": 319291,
"author": "chills42",
"author_id": 23855,
"author_profile": "https://Stackoverflow.com/users/23855",
"pm_score": 3,
"selected": false,
"text": "<p>I think this would do it...</p>\n\n<pre><code>def validIP(address):\n parts = address.split(\".\")\n if len(part... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27729/"
] | What's the best way to validate that an IP entered by the user is valid? It comes in as a string. | Don't parse it. Just ask.
```
import socket
try:
socket.inet_aton(addr)
# legal
except socket.error:
# Not legal
``` |
319,292 | <p>I have a vector with 1000 "nodes"</p>
<pre><code> if(count + 1 > m_listItems.capacity())
m_listItems.reserve(count + 100);
</code></pre>
<p>The problem is I also clear it out when I'm about to refill it. </p>
<pre><code>m_listItems.clear();
</code></pre>
<p>The capacity doesn't change.
I've used the res... | [
{
"answer_id": 319301,
"author": "Tim Stewart",
"author_id": 26002,
"author_profile": "https://Stackoverflow.com/users/26002",
"pm_score": 1,
"selected": false,
"text": "<p>You could try this technique from <a href=\"http://www.gamedev.net/community/forums/topic.asp?topic_id=397748\" rel... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31325/"
] | I have a vector with 1000 "nodes"
```
if(count + 1 > m_listItems.capacity())
m_listItems.reserve(count + 100);
```
The problem is I also clear it out when I'm about to refill it.
```
m_listItems.clear();
```
The capacity doesn't change.
I've used the resize(1); but that doesn't seem to alter the capacity.... | ```
vector<Item>(m_listItems).swap(m_listItems);
```
will shrink `m_listItems` again: <http://www.gotw.ca/gotw/054.htm> (Herb Sutter)
If you want to clear it anyway, swap with an empty vector:
```
vector<Item>().swap(m_listItems);
```
which of course is way more efficient. (Note that swapping vectors basicially m... |
319,304 | <p>So I added an EXE to my project's solution. The EXE does some stuff and outputs data via stdout. I want to capture the output, but more importantly how do I execute that EXE within my program?</p>
| [
{
"answer_id": 319311,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx\" rel=\"nofollow noreferre... | 2008/11/25 | [
"https://Stackoverflow.com/questions/319304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40856/"
] | So I added an EXE to my project's solution. The EXE does some stuff and outputs data via stdout. I want to capture the output, but more importantly how do I execute that EXE within my program? | ```
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "myExec.exe";
p.Start();
``` |
319,320 | <p>I'm a little lost (still working with Ron Jeffries's book). Here's a simple class:</p>
<pre><code>public class Model{
private String[] lines;
public void myMethod(){
String[] newLines = new String[lines.length + 2];
for (i = 0, i <= lines.length, i++) {
newLines[i] = lines[i]... | [
{
"answer_id": 319325,
"author": "Bill K",
"author_id": 12943,
"author_profile": "https://Stackoverflow.com/users/12943",
"pm_score": 1,
"selected": false,
"text": "<p>lines will be null, so lines.length will throw an exception.</p>\n\n<p>I believe your other class initializing \"Model\"... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16851/"
] | I'm a little lost (still working with Ron Jeffries's book). Here's a simple class:
```
public class Model{
private String[] lines;
public void myMethod(){
String[] newLines = new String[lines.length + 2];
for (i = 0, i <= lines.length, i++) {
newLines[i] = lines[i];
}
}... | I think your example is probably not the same as your actual code based on your description. I think the problem is that arrays are zero-based and thus an array initialized as:
string[] lines = new string[0];
has no elements.
You need to change your loop so that you check that the index is strictly less than the len... |
319,339 | <p>I can start with my own .NET dll. I have a dll I use in all my web projects (around 10) and I have util classes for FTP, zip, imageresizing, extensionmethods and a generic singleton class.</p>
<p>I think it is a common practice and I just thought it would be interesting to hear what people put in their 'Utils' dlls... | [
{
"answer_id": 319347,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 0,
"selected": false,
"text": "<p>I have only just really started mine but at the moment it mostly contains just common extension methods that I use all t... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29519/"
] | I can start with my own .NET dll. I have a dll I use in all my web projects (around 10) and I have util classes for FTP, zip, imageresizing, extensionmethods and a generic singleton class.
I think it is a common practice and I just thought it would be interesting to hear what people put in their 'Utils' dlls
EDIT:
Wh... | I think carrying utility assemblies beyond the current version of your language does more harm than good.
The main reason is that as the language grows new methods and better ways of doing things are built in. By carrying around a utilities assembly, you will quickly end up with a lot of dead weight which may expose s... |
319,354 | <p>I have a SQL Server database and I want to know what columns and types it has. I'd prefer to do this through a query rather than using a GUI like Enterprise Manager. Is there a way to do this?</p>
| [
{
"answer_id": 319366,
"author": "Brannon",
"author_id": 5745,
"author_profile": "https://Stackoverflow.com/users/5745",
"pm_score": 7,
"selected": false,
"text": "<p>There are a few methods to get metadata about a table:</p>\n\n<pre><code>EXEC sp_help tablename\n</code></pre>\n\n<p>Will... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a SQL Server database and I want to know what columns and types it has. I'd prefer to do this through a query rather than using a GUI like Enterprise Manager. Is there a way to do this? | You can use the [sp\_columns](http://msdn.microsoft.com/en-us/library/ms176077.aspx) stored procedure:
```
exec sp_columns MyTable
``` |
319,367 | <p>I have a problem with time<br>
My server is in the USA and I'm in Denmark (Europa) and I would like to have my site show the time in my local time. How can I do that?</p>
<p>I try this </p>
<pre><code>Datetime localtime = DateTimeOffset.Now.ToOffset(new TimeSpan(1,0,0)).DateTime;
</code></pre>
<p>and it works, ... | [
{
"answer_id": 319380,
"author": "HitLikeAHammer",
"author_id": 35165,
"author_profile": "https://Stackoverflow.com/users/35165",
"pm_score": 0,
"selected": false,
"text": "<p>You can get the time off the server and do this.</p>\n\n<pre><code>DateTime myTimeGMT = ServerTime.ToUniversalTi... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31296/"
] | I have a problem with time
My server is in the USA and I'm in Denmark (Europa) and I would like to have my site show the time in my local time. How can I do that?
I try this
```
Datetime localtime = DateTimeOffset.Now.ToOffset(new TimeSpan(1,0,0)).DateTime;
```
and it works, but it will only work when I'm in GM... | The only way you should do it is as follows:
```
string zoneId = "Central European Standard Time";
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(zoneId);
DateTime result = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow,tzi);
Console.WriteLine("Time is " + result + " in Denmark");
```
Using the TimeZoneInfo... |
319,384 | <p>I have a column in my database (a flag) with type varchar(1) that is populated either Y or NULL (this is how it is, not in my control).</p>
<p>In SQL Server, doing an ascending order by query, NULL is ordered at the top. Should this behaviour be consistent for Oracle and DB2? </p>
<p>If, instead I have a COALESCE ... | [
{
"answer_id": 319390,
"author": "FerranB",
"author_id": 40441,
"author_profile": "https://Stackoverflow.com/users/40441",
"pm_score": 0,
"selected": false,
"text": "<p>In oracle you can do this:</p>\n\n<pre><code>ORDER BY value NULLS FIRST \n</code></pre>\n\n<p>or </p>\n\n<pre><code>ORD... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5302/"
] | I have a column in my database (a flag) with type varchar(1) that is populated either Y or NULL (this is how it is, not in my control).
In SQL Server, doing an ascending order by query, NULL is ordered at the top. Should this behaviour be consistent for Oracle and DB2?
If, instead I have a COALESCE on the column to ... | I know for a fact that DB2 Express and DB2 (at least up to v8) does **not** support the `NULLS FIRST` clause.
If you want a portable solution, you may have to opt for something like:
```
select * from tbl where fld is null
union all select * from tbl where fld is not null
```
I think the result of the union (at... |
319,395 | <p>I have two questions:</p>
<p>1) How can I make an array which points to objects of integers?</p>
<pre><code>int* myName[5]; // is this correct?
</code></pre>
<p>2) If I want to return a pointer to an array, which points to objects (like (1)) how can I do this in a method? ie) I want to impliment the method:</p>
... | [
{
"answer_id": 319404,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>How can I make an array which points\n to objects?</p>\n</blockquote>\n\n<pre><code>int ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two questions:
1) How can I make an array which points to objects of integers?
```
int* myName[5]; // is this correct?
```
2) If I want to return a pointer to an array, which points to objects (like (1)) how can I do this in a method? ie) I want to impliment the method:
```
int **getStuff() {
// what goes ... | >
> How can I make an array which points
> to objects?
>
>
>
```
int * myName[5]; /* correct */
```
>
> If I want to return a pointer to an
> array, which points to objects (like
> (1)) how can I do this in a method?
>
>
>
Technically, you write this function:
```
int * (* getStuff() )[5] {
return &... |
319,407 | <p>I am saving some small images to Xml as a Byte[] via the following XElement construct..</p>
<pre><code>XElement xe = new XElement("Images",
from c in qry
select new XElement("Image", new XAttribute("Date", c.Date),
new XElement("Data", c.Bytes)));
</code></pre>
<p>the Bytes pr... | [
{
"answer_id": 319690,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": true,
"text": "<p>I would think about Base64 encoding the byte array. It should be fairly easy to encode/decode this from/to a byte ar... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10387/"
] | I am saving some small images to Xml as a Byte[] via the following XElement construct..
```
XElement xe = new XElement("Images",
from c in qry
select new XElement("Image", new XAttribute("Date", c.Date),
new XElement("Data", c.Bytes)));
```
the Bytes property is a Byte[], lookin... | I would think about Base64 encoding the byte array. It should be fairly easy to encode/decode this from/to a byte array. |
319,422 | <p>i'm generating controls dynamically on my asp.net page by xslt transformation from an xml file. i will need to reference these controls from code behind later. i would like to add these references to the list/hashtable/whatever during creation (in xslt file i suppose) so that i could reach them later and i have no i... | [
{
"answer_id": 319481,
"author": "david valentine",
"author_id": 36627,
"author_profile": "https://Stackoverflow.com/users/36627",
"pm_score": 0,
"selected": false,
"text": "<p>Can you give a better idea of what you are trying to do?</p>\n\n<p>XML > XSLT > produces aspx page</p>\n\n<p>So... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40872/"
] | i'm generating controls dynamically on my asp.net page by xslt transformation from an xml file. i will need to reference these controls from code behind later. i would like to add these references to the list/hashtable/whatever during creation (in xslt file i suppose) so that i could reach them later and i have no idea... | Once you have transformed your XML using XSLT, you could pass the output to the ASP.Net [ParseControl](http://msdn.microsoft.com/en-us/library/kz3ffe28.aspx) method and it will return your controls ready to use. For example this code will place two buttons on the page:
```
protected void Page_Load(object sender, Event... |
319,423 | <p>I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query. </p>
<p>Is this a decent practice or should I be checking for the error in between every query?</p>
<p>Thanks! </p>
<pre><code>$mysqli->autocomm... | [
{
"answer_id": 319436,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "<p>No -- it reports the error code of the last mysqli function call. Zero means no error occurred on the last functio... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] | I am new to mysqli, and trying to confirm that if I so something like the below, the errno will be set to the last error, if any, and not the error of the last query.
Is this a decent practice or should I be checking for the error in between every query?
Thanks!
```
$mysqli->autocommit(FALSE);
$mysqli->query("INS... | mysqli\_errno — Returns the error code for **the most recent function call**. |
319,426 | <p>How can I compare strings in a case insensitive way in Python?</p>
<p>I would like to encapsulate comparison of a regular strings to a repository string, using simple and Pythonic code. I also would like to have ability to look up values in a dict hashed by strings using regular python strings.</p>
| [
{
"answer_id": 319435,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 11,
"selected": true,
"text": "<p>Assuming ASCII strings:</p>\n<pre><code>string1 = 'Hello'\nstring2 = 'hello'\n\nif string1.lower() == string2.low... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52490/"
] | How can I compare strings in a case insensitive way in Python?
I would like to encapsulate comparison of a regular strings to a repository string, using simple and Pythonic code. I also would like to have ability to look up values in a dict hashed by strings using regular python strings. | Assuming ASCII strings:
```
string1 = 'Hello'
string2 = 'hello'
if string1.lower() == string2.lower():
print("The strings are the same (case insensitive)")
else:
print("The strings are NOT the same (case insensitive)")
```
As of Python 3.3, [casefold()](https://docs.python.org/3/library/stdtypes.html#str.ca... |
319,429 | <p>I have a C# .NET application with which I've created a custom image display control. Each image display represents its own display context and draws the image using glDrawPixels (Yes I know it would be better to use textures, I plan to in the futures but this app is already too far along and my time is limited).</p>... | [
{
"answer_id": 319561,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 1,
"selected": false,
"text": "<p>Its difficult telling what's wrong with what you do since you give so little detail. Here are some pointers which may help... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55638/"
] | I have a C# .NET application with which I've created a custom image display control. Each image display represents its own display context and draws the image using glDrawPixels (Yes I know it would be better to use textures, I plan to in the futures but this app is already too far along and my time is limited).
I am ... | Its difficult telling what's wrong with what you do since you give so little detail. Here are some pointers which may help.
- before doing something in a context, make sure you make it the current one. If you want to pan two contexts, make the first one current, pan it and then make the second one current and pan it... |
319,438 | <p>I'm able to get cells to format as Dates, but I've been unable to get cells to format as currency... Anyone have an example of how to create a style to get this to work? My code below show the styles I'm creating... the styleDateFormat works like a champ while styleCurrencyFormat has no affect on the cell.</p>
<pr... | [
{
"answer_id": 319917,
"author": "Dave K",
"author_id": 19864,
"author_profile": "https://Stackoverflow.com/users/19864",
"pm_score": 7,
"selected": true,
"text": "<p>After digging through the documentation a bit more, I found the answer:</p>\n\n<p><a href=\"http://poi.apache.org/apidocs... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19864/"
] | I'm able to get cells to format as Dates, but I've been unable to get cells to format as currency... Anyone have an example of how to create a style to get this to work? My code below show the styles I'm creating... the styleDateFormat works like a champ while styleCurrencyFormat has no affect on the cell.
```
private... | After digging through the documentation a bit more, I found the answer:
<http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFDataFormat.html>
Just need to find an appropriate pre-set format and supply the code.
```
styleCurrencyFormat.setDataFormat((short)8); //8 = "($#,##0.00_);[Red]($#,##0.00)"
``... |
319,463 | <p>Is there a way using the iPhone SDK to get the same results as an HTTP POST or GET methods? </p>
| [
{
"answer_id": 319719,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 3,
"selected": false,
"text": "<p>If you're using Objective C, you'll need to use the NSURL, NSURLRequest, and NURLConnection classes. <a href=\"http:... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way using the iPhone SDK to get the same results as an HTTP POST or GET methods? | Assume your class has a `responseData` instance variable, then:
```
responseData = [[NSMutableData data] retain];
NSURLRequest *request =
[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.domain.com/path"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
```
And then add the follo... |
319,479 | <p>Are there any libraries out there for Java that will accept two strings, and return a string with formatted output as per the *nix diff command?</p>
<p>e.g. feed in </p>
<pre><code>test 1,2,3,4
test 5,6,7,8
test 9,10,11,12
test 13,14,15,16
</code></pre>
<p>and </p>
<pre><code>test 1,2,3,4
test 5,6,7,8
test 9,10,... | [
{
"answer_id": 319499,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 0,
"selected": false,
"text": "<p>Busybox has a diff implementation that is very lean, should not be hard to convert to java, but you would have to add the... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14160/"
] | Are there any libraries out there for Java that will accept two strings, and return a string with formatted output as per the \*nix diff command?
e.g. feed in
```
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12
test 13,14,15,16
```
and
```
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12,13
test 13,14,15,16
```
as input, a... | I ended up rolling my own. Not sure if it's the best implementation, and it's ugly as hell, but it passes against test input.
It uses [java-diff](http://www.incava.org/projects/java/java-diff/) to do the heavy diff lifting (any apache commons StrBuilder and StringUtils instead of stock Java StringBuilder)
```
public... |
319,482 | <p>I have a simple app that uses an SQL Express 2005 database. When the user closes the app, I want to give the option to back up the database by making a copy in another directory. However, when I try to do it, I get "The process cannot access the file '...\Pricing.MDF' because it is being used by another process." ... | [
{
"answer_id": 319624,
"author": "Turnkey",
"author_id": 13144,
"author_profile": "https://Stackoverflow.com/users/13144",
"pm_score": 0,
"selected": false,
"text": "<p>There's an example in <a href=\"http://forums.microsoft.com/msdn/showpost.aspx?postid=487021&siteid=1\" rel=\"nofol... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12897/"
] | I have a simple app that uses an SQL Express 2005 database. When the user closes the app, I want to give the option to back up the database by making a copy in another directory. However, when I try to do it, I get "The process cannot access the file '...\Pricing.MDF' because it is being used by another process." I clo... | You don't want to copy the mdf directly because SQL keeps most of the changes in the transaction log, take a look at the modified time after running some queries, it doesn't write directly to the file. I noticed this while setting up an rsync job.
Having SQL generate the backup is much safer and more desirable, single... |
319,485 | <p>Here are two chunks of code that accomplish (what I think is) the same thing.</p>
<p>I basically am trying to learn how to use Java 1.5's concurrency to get away from Thread.sleep(long). The first example uses ReentrantLock, and the second example uses CountDownLatch. The jist of what I am trying to do is put one... | [
{
"answer_id": 319621,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 2,
"selected": false,
"text": "<p>The lock/condition variable approach is better for this task in my opinion. There is a similar example to yours here... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34410/"
] | Here are two chunks of code that accomplish (what I think is) the same thing.
I basically am trying to learn how to use Java 1.5's concurrency to get away from Thread.sleep(long). The first example uses ReentrantLock, and the second example uses CountDownLatch. The jist of what I am trying to do is put one thread to s... | Either approach is roughly equivalent, except that a [CountDownLatch](http://java.sun.com/javase/6/docs/api/java/util/concurrent/CountDownLatch.html) can only be released once. After that all [await()](http://java.sun.com/javase/6/docs/api/java/util/concurrent/CountDownLatch.html#await()) calls return instantly. So a [... |
319,508 | <p>I want to get the VB.NET or VB code to access the hard disk serial no when starting the program. It's to help me to protect my own software from people who try to pirate copies. </p>
| [
{
"answer_id": 319515,
"author": "pixelbeat",
"author_id": 4421,
"author_profile": "https://Stackoverflow.com/users/4421",
"pm_score": 2,
"selected": false,
"text": "<p>People often need to upgrade/replace their hard disk.\nBetter to use the serial number from the DMI.</p>\n"
},
{
... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40875/"
] | I want to get the VB.NET or VB code to access the hard disk serial no when starting the program. It's to help me to protect my own software from people who try to pirate copies. | In c#, but you get the idea. You'll want to use System.Management for this:
```
string driveLetter = Environment.SystemDirectory.Substring(0, 2);
string sn = new System.Management.ManagementObject("Win32_LogicalDisk.DeviceID=\"" + driveLetter + "\"").GetPropertyValue("VolumeSerialNumber").ToString();
```
As others h... |
319,516 | <p>I'm developing an FTP-like program to download a large number of small files onto an Xbox 360 devkit (which uses Winsock), and porting it to Playstation3 (also a devkit, and uses linux AFAIK). The program uses BSD-style sockets (TCP). Both of the programs communicate with the same server, downloading the same data... | [
{
"answer_id": 319550,
"author": "geocar",
"author_id": 37507,
"author_profile": "https://Stackoverflow.com/users/37507",
"pm_score": 2,
"selected": false,
"text": "<p>You want <code>TCP_CORK</code>. It'll prevent partial frames from being sent increasing throughput (at the expense of la... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40877/"
] | I'm developing an FTP-like program to download a large number of small files onto an Xbox 360 devkit (which uses Winsock), and porting it to Playstation3 (also a devkit, and uses linux AFAIK). The program uses BSD-style sockets (TCP). Both of the programs communicate with the same server, downloading the same data. The... | You want `TCP_CORK`. It'll prevent partial frames from being sent increasing throughput (at the expense of latency) - just like winsock.
```
int v,vlen;
v=1; vlen=sizeof(v);
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &v, &vlen);
```
Set `v=0` to flush the frames before receive:
```
int v,vlen;
v=0; vlen=sizeof(v);
setso... |
319,518 | <p>I've got the a SQL Server stored procedure with the following T-SQL code contained within:</p>
<pre><code>insert into #results ([ID], [Action], [Success], [StartTime], [EndTime], [Process])
select
'ID' = aa.[ActionID],
'Action' = cast(aa.[Action] as int),
'Success' = aa.[Success],
'StartTime' = aa.[... | [
{
"answer_id": 319558,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "<p>Just offhand, you can simplify these:</p>\n\n<pre><code> 2 = case\n when (@startDate is null) t... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2049/"
] | I've got the a SQL Server stored procedure with the following T-SQL code contained within:
```
insert into #results ([ID], [Action], [Success], [StartTime], [EndTime], [Process])
select
'ID' = aa.[ActionID],
'Action' = cast(aa.[Action] as int),
'Success' = aa.[Success],
'StartTime' = aa.[StartTime],
... | The following article explains how to find out if your stored procedure is recompiling:
<http://it.toolbox.com/blogs/programming-life/sql-performance-abnormal-stored-procedure-recompiles-8105>
Here's a quote from the appropriate section:
>
> start SQL Profiler and start a new
> trace, connect to our server and give... |
319,527 | <p>I have config.time_zone in environment.rb set to "UTC", and my mySQL server returns the current time in my local time zone when I issue "select now();" and in utc when I ask for "select utc_timestamp;"</p>
<p>I'm running rails 2.1.2, the mysql gem 2.7.3, activerecord gem 2.1.2, and mysql --version returns "Ver 14.1... | [
{
"answer_id": 319941,
"author": "allesklar",
"author_id": 19893,
"author_profile": "https://Stackoverflow.com/users/19893",
"pm_score": 0,
"selected": false,
"text": "<p>After editing the environment.rb file, did you restart your server before making a new record to your database?</p>\n... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] | I have config.time\_zone in environment.rb set to "UTC", and my mySQL server returns the current time in my local time zone when I issue "select now();" and in utc when I ask for "select utc\_timestamp;"
I'm running rails 2.1.2, the mysql gem 2.7.3, activerecord gem 2.1.2, and mysql --version returns "Ver 14.12 Distri... | We had the same issue regarding dates, time zones and MySQL. The latter assumes you provide it with date/time values in the timezone it's configured with.
But, since you configured Rails to handle time in UTC, ActiveRecord converts any date/time values in UTC (thus Tue Nov 25 17:40:48 -0800 2008 becomes Wed Nov 26 01... |
319,530 | <p>What does RESTful Authentication mean and how does it work? I can't find a good overview on Google. My only understanding is that you pass the session key (remeberal) in the URL, but this could be horribly wrong.</p>
| [
{
"answer_id": 319635,
"author": "Justin Sheehy",
"author_id": 11944,
"author_profile": "https://Stackoverflow.com/users/11944",
"pm_score": 5,
"selected": false,
"text": "<p>It's certainly not about \"session keys\" as it is generally used to refer to sessionless authentication which is... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35338/"
] | What does RESTful Authentication mean and how does it work? I can't find a good overview on Google. My only understanding is that you pass the session key (remeberal) in the URL, but this could be horribly wrong. | How to handle authentication in a RESTful Client-Server architecture is a matter of debate.
Commonly, it can be achieved, in the SOA over HTTP world via:
* HTTP basic auth over HTTPS;
* Cookies and session management;
* Token in HTTP headers (e.g. *OAuth* 2.0 + JWT);
* Query Authentication with additional signature p... |
319,531 | <p>For example, I hate typing things like:</p>
<pre><code>$x = mysql_escape_string(stripslashes($_GET['x']));
</code></pre>
<p>Is there a way to alias those two functions in init.php or something without writing a separate function that takes one argument and returns that argument with those functions applied to it?<... | [
{
"answer_id": 319536,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "<pre><code>function myget($string)\n{\n return mysql_real_escape_string(stripslashes($_GET[$string]));\n}\n</code></p... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29595/"
] | For example, I hate typing things like:
```
$x = mysql_escape_string(stripslashes($_GET['x']));
```
Is there a way to alias those two functions in init.php or something without writing a separate function that takes one argument and returns that argument with those functions applied to it?
My C/C++ is not very good... | This should do the trick :
```
// Macros
$mes = "mysql_escape_string";
$ss = "stripslashes";
// Using your macros
$x = $mes($ss($_GET['x']));
```
Though I don't recommend coding like this at all.
I'm just answering the question since you said you didn't want to create any new function and get a "#define"-like fun... |
319,552 | <p>I am working on setting up a Drupal based website and wanted to replace the site title in the header with an image file. I came across this article: <a href="http://www.mezzoblue.com/tests/revised-image-replacement/" rel="nofollow noreferrer">"Revised Image Replacement"</a> summarizing several techniques for doing ... | [
{
"answer_id": 319536,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "<pre><code>function myget($string)\n{\n return mysql_real_escape_string(stripslashes($_GET[$string]));\n}\n</code></p... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40332/"
] | I am working on setting up a Drupal based website and wanted to replace the site title in the header with an image file. I came across this article: ["Revised Image Replacement"](http://www.mezzoblue.com/tests/revised-image-replacement/) summarizing several techniques for doing just that.
I was wondering what the curr... | This should do the trick :
```
// Macros
$mes = "mysql_escape_string";
$ss = "stripslashes";
// Using your macros
$x = $mes($ss($_GET['x']));
```
Though I don't recommend coding like this at all.
I'm just answering the question since you said you didn't want to create any new function and get a "#define"-like fun... |
319,576 | <p>I'm trying to make a TCP Client program in C where the client will start up, connect to a server. Then it will send a little information and then just listen to what it receives and react accordingly.</p>
<p>The part that I'm having trouble with is the continuous listening. Here is what I have</p>
<pre><code>...
... | [
{
"answer_id": 319584,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": true,
"text": "<p>Print out the number of bytes received - it is likely to be zero, but confirm that.</p>\n\n<p>It would be worth... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm trying to make a TCP Client program in C where the client will start up, connect to a server. Then it will send a little information and then just listen to what it receives and react accordingly.
The part that I'm having trouble with is the continuous listening. Here is what I have
```
...
while (1) {
numbyt... | Print out the number of bytes received - it is likely to be zero, but confirm that.
It would be worth checking that you aren't getting an error - and therefore underflowing your buffer.
[*Note: from here onwards is the work of Pax - **thank you**, and I've converted it to Community Wiki so I don't get rep points unde... |
319,578 | <p>I have an app that I'm writing a little wizard for. It automated a small part of the app by moving the mouse to appropriate buttons, menus and clicking them so the user can watch.</p>
<p>So far it moves the mouse to a tree item and sends a right-click. That pops up a menu via TrackPopupMenu. Next I move the mous... | [
{
"answer_id": 319640,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 1,
"selected": false,
"text": "<p>I expect you could generate the necessary click messages by calling <a href=\"http://msdn.microsoft.com/en-us/libra... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7442/"
] | I have an app that I'm writing a little wizard for. It automated a small part of the app by moving the mouse to appropriate buttons, menus and clicking them so the user can watch.
So far it moves the mouse to a tree item and sends a right-click. That pops up a menu via TrackPopupMenu. Next I move the mouse to the appr... | I didn't find a prefect way to do it, but the following works pretty well:
```
//in my case, the menu is a popup from a tree control created with:
CMenu menu;
menu.CreatePopupMenu();
//add stuff to the menu...
pTreeCtrl->SetMenu(&menu);
m_hMenu = menu.GetSafeHmenu();
CPoint pt;
GetCursorPos(&pt);
menu.TrackPopupMenu(... |
319,591 | <p>With .net 3.5, there is a SyndicationFeed that will load in a RSS feed and allow you to run LINQ on it. </p>
<p>Here is an example of the RSS that I am loading:</p>
<pre><code><rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Title of RSS feed</title>
... | [
{
"answer_id": 321548,
"author": "jr.",
"author_id": 2415,
"author_profile": "https://Stackoverflow.com/users/2415",
"pm_score": 4,
"selected": true,
"text": "<p>Your missing the namespace. Using <a href=\"http://www.linqpad.net/\" rel=\"noreferrer\" title=\"LINQPad\">LINQPad</a> and you... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24841/"
] | With .net 3.5, there is a SyndicationFeed that will load in a RSS feed and allow you to run LINQ on it.
Here is an example of the RSS that I am loading:
```
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Title of RSS feed</title>
<link>http://www.google.com</link>
<d... | Your missing the namespace. Using [LINQPad](http://www.linqpad.net/ "LINQPad") and your example feed:
```
string xml = @"
<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/'>
<channel>
<title>Title of RSS feed</title>
<link>http://www.google.com</link>
<description>Detail... |
319,594 | <p>Given two colors and <em>n</em> steps, how can one calculate n colors including the two given colors that create a fade effect? </p>
<p>If possible pseudo-code is preferred but this will probably be implemented in Java.</p>
<p>Thanks!</p>
| [
{
"answer_id": 319604,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": true,
"text": "<p>Divide each colour into its RGB components and then calculate the individual steps required.</p>\n\n<pre><code>oldRed = 120;... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/868/"
] | Given two colors and *n* steps, how can one calculate n colors including the two given colors that create a fade effect?
If possible pseudo-code is preferred but this will probably be implemented in Java.
Thanks! | Divide each colour into its RGB components and then calculate the individual steps required.
```
oldRed = 120;
newRed = 200;
steps = 10;
redStepAmount = (newRed - oldRed) / steps;
currentRed = oldRed;
for (i = 0; i < steps; i++) {
currentRed += redStepAmount;
}
```
Obviously extend that for green and blue. |
319,595 | <p>Hi if I am creating something on the stack using new I declare it like:</p>
<pre><code>object *myObject = new object(contr, params);
</code></pre>
<p>Is there a way to declare this such as:</p>
<pre><code>object *myObject;
myObject = new object(constr, params);
</code></pre>
<p>Is this correct?</p>
| [
{
"answer_id": 319602,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, that is correct. But new does not create things on the stack, it creates them on the heap.</p>\n\n<p>To create ob... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Hi if I am creating something on the stack using new I declare it like:
```
object *myObject = new object(contr, params);
```
Is there a way to declare this such as:
```
object *myObject;
myObject = new object(constr, params);
```
Is this correct? | Yes, that is correct. But new does not create things on the stack, it creates them on the heap.
To create object on the stack you would do:
```
object myObject(constr, params);
```
There is no other way to create an object on the stack and once it is created on the stack you can't "recreate" it with the same name l... |
319,623 | <p>void (int a[]) {
a[5] = 3; // this is wrong?
}</p>
<p>Can I do this so that the array that is passed in is modified?</p>
<p>Sorry for deleting, a bit new here...</p>
<p>I have another question which might answer my question:</p>
<p>If I have</p>
<pre><code>void Test(int a) {
}
void Best(int &a) {
}... | [
{
"answer_id": 319627,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>If you get the variable not by reference and not by pointer, it means that the function is essentially isolated, getting an... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | void (int a[]) {
a[5] = 3; // this is wrong?
}
Can I do this so that the array that is passed in is modified?
Sorry for deleting, a bit new here...
I have another question which might answer my question:
If I have
```
void Test(int a) {
}
void Best(int &a) {
}
```
are these two statements equivalent?
```
Tes... | ```
void Test(int a[])
{
a[5] = 3;
}
```
just alternate syntax for:
```
void Test(int* a)
{
*(a+5) = 3;
}
```
No array is passed, just a pointer. The original array is modified.
As for your second revision, given:
```
void Test(int a)
{
}
void Best(int &a)
{
}
```
then
```
Test(aa); // Pass... |
319,626 | <p>I have a DataTable that queries out something like below</p>
<pre><code>usergroupid...userid......username
1.............1...........John
1.............2...........Lisa
2.............3...........Nathan
3.............4...........Tim
</code></pre>
<p>What I'm trying to do is write a LINQ statement that will return a... | [
{
"answer_id": 319656,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": -1,
"selected": false,
"text": "<p>There is - look at GroupBy and Select methods.</p>\n"
},
{
"answer_id": 319691,
"author": "Rohan West",
... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8280/"
] | I have a DataTable that queries out something like below
```
usergroupid...userid......username
1.............1...........John
1.............2...........Lisa
2.............3...........Nathan
3.............4...........Tim
```
What I'm trying to do is write a LINQ statement that will return an array of UserGroup insta... | Check this out, hope this helps
```
var users = new[]
{
new {UserGroupId = 1, UserId = 1, UserName = "John"},
new {UserGroupId = 1, UserId = 2, UserName = "Lisa"},
new {UserGroupId = 2, UserId = 3, UserName = "Nathan"},
new {UserGroupId = 3, UserId = 4, UserName = "Tim"}
};
var userGroups = from user... |
319,634 | <p>all files in ~/Cipher/nsdl/crypto can be found <a href="http://nsdeleon.wikispaces.com/file/detail/crypto.zip" rel="nofollow noreferrer">here</a>
java files compiled with gcj, see compile.sh</p>
<pre><code>nmint@nqmk-mint ~/Cipher/nsdl/crypto $ echo test | ./cryptTest encrypt deadbeefdeadbeefdeadbeefdeadbeef deadbe... | [
{
"answer_id": 319804,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps looking at <a href=\"http://fuseyism.com/classpath/doc/javax/crypto/Cipher-source.html\" rel=\"nofollow noreferrer\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40807/"
] | all files in ~/Cipher/nsdl/crypto can be found [here](http://nsdeleon.wikispaces.com/file/detail/crypto.zip)
java files compiled with gcj, see compile.sh
```
nmint@nqmk-mint ~/Cipher/nsdl/crypto $ echo test | ./cryptTest encrypt deadbeefdeadbeefdeadbeefdeadbeef deadbeef Blowfish CBC > test
null
Exception in thread "ma... | The Cipher, `ecipher`, is not initialized, and it throws an `IllegalStateException` when you try to use it as if it were initialized in `ENCRYPT_MODE`.
Note your `catch` block in the constructor of `BlockCrypt`. It is catching an exception with no message, and printing "null" to `System.err`. Rather than aborting exec... |
319,649 | <p>I have a database with one table, like so:</p>
<pre><code>UserID (int), MovieID (int), Rating (real)
</code></pre>
<p>The userIDs and movieIDs are large numbers, but my database only has a sample of the many possible values (4000 unique users, and 3000 unique movies)</p>
<p>I am going to do a matrix SVD (singular... | [
{
"answer_id": 319669,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SELECT m.UserID, m.MovieID, r.Rating\n FROM (SELECT a.userid, b.movieid\n FROM (SELECT ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2504/"
] | I have a database with one table, like so:
```
UserID (int), MovieID (int), Rating (real)
```
The userIDs and movieIDs are large numbers, but my database only has a sample of the many possible values (4000 unique users, and 3000 unique movies)
I am going to do a matrix SVD (singular value decomposition) on it, so I... | ```
SELECT m.UserID, m.MovieID, r.Rating
FROM (SELECT a.userid, b.movieid
FROM (SELECT DISTINCT UserID FROM Ratings) AS a,
(SELECT DISTINCT MovieID FROM Ratings) AS b
) AS m LEFT OUTER JOIN Ratings AS r
ON (m.MovieID = r.MovieID AND m.UserID = r.UserID)
ORDER B... |
319,651 | <p>I used standard exception handling methods in C++. Which is try{} and catch{} block. In my code, func1() would throw an exception, And func2 is like this:</p>
<pre><code>bool func2()
{
try{
func1();
}
catch(myException& e)
{
cerr << "error!" << endl;
return fals... | [
{
"answer_id": 319658,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<p>Open your app in WinDbg (or gdb), and enable first chance exceptions (in WinDbg via sxe eh). </p>\n"
},
{
"answ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26404/"
] | I used standard exception handling methods in C++. Which is try{} and catch{} block. In my code, func1() would throw an exception, And func2 is like this:
```
bool func2()
{
try{
func1();
}
catch(myException& e)
{
cerr << "error!" << endl;
return false;
}
return true;
}
`... | If you're using any optimize flags in your compiler (i.e. not debug mode), you can't trust the debugger to show you the proper lines of execution. You've made contradictory statements - the "return false" statement is executing, but the function is returning true. This is the only explanation I can think of. |
319,672 | <p>I was using GetWindowLong like this:</p>
<pre><code>[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
</code></pre>
<p>But according to the MSDN docs I am supposed to be using GetWindowLongPtr to be 64bit compatible.
<a href="http://msdn.microsoft.com/en-us/library/ms63... | [
{
"answer_id": 319693,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 3,
"selected": false,
"text": "<p>You should define GetWindowLongPtr using an IntPtr. In C/C++ a LONG_PTR is 32-bits on a 32-bit system and 64-bits on a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I was using GetWindowLong like this:
```
[DllImport("user32.dll")]
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
```
But according to the MSDN docs I am supposed to be using GetWindowLongPtr to be 64bit compatible.
<http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx>
The MSDN docs f... | Unfortunately it's not that easy, because GetWindowLongPtr doesn't exist in 32bit Windows. On 32bit systems GetWindowLongPtr is just a C macro that points to GetWindowLong. If you really need to use GetWindowLongPtr on both 32 and 64 bit systems you'll have to determine the correct one to call at run time. See the desc... |
319,679 | <p><B>This came out being incomprehensible. I will rephrase</B></p>
<p>Is there an algorithm or approach that will allow sorting an array in such a way that it minimizes the differences between successive elements? </p>
<pre><code>struct element
{
uint32 positions[8];
}
</code></pre>
<p>These records are order-ins... | [
{
"answer_id": 319721,
"author": "Sniggerfardimungus",
"author_id": 30997,
"author_profile": "https://Stackoverflow.com/users/30997",
"pm_score": 1,
"selected": false,
"text": "<p>You're looking at a pair of subproblems, defining the difference between structures, then the sort.</p>\n\n<... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **This came out being incomprehensible. I will rephrase**
Is there an algorithm or approach that will allow sorting an array in such a way that it minimizes the differences between successive elements?
```
struct element
{
uint32 positions[8];
}
```
These records are order-insensitive.
The output file format is... | Your problem
------------
I think this question should really be tagged with 'compression'.
As I understand it, you have unordered records which consist of eight 4-byte integers: 32 bytes in total. You want to store these records with a minimum file size, and have decided to use some form of [delta encoding](http://e... |
319,696 | <p>This is probably pretty basic... but I don't seem to get it:</p>
<p>How does </p>
<pre><code>(2 & 1) = 0
(3 & 1) = 1
(4 & 1) = 0
</code></pre>
<p>etc..</p>
<p>This pattern above seems to help find even numbers</p>
<p>or </p>
<pre><code>(0 | 1) = 1
(1 | 1) = 1
(2 | 1) = 3
(3 | 1) = 4
(4 | 1) = 5
(5 ... | [
{
"answer_id": 319698,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 3,
"selected": false,
"text": "<p>It works the same way in C# as it does in binary. </p>\n\n<p><code>2 | 1 = 3</code> and <code>4 | 1 = 5</code>. </p>\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is probably pretty basic... but I don't seem to get it:
How does
```
(2 & 1) = 0
(3 & 1) = 1
(4 & 1) = 0
```
etc..
This pattern above seems to help find even numbers
or
```
(0 | 1) = 1
(1 | 1) = 1
(2 | 1) = 3
(3 | 1) = 4
(4 | 1) = 5
(5 | 1) = 5
```
I know how boolean algebra works between bits. But I do... | It works the same way in C# as it does in binary.
`2 | 1 = 3` and `4 | 1 = 5`.
To understand this, you need to think about the binary representation of 1,2,3,4,and 5:
`010 | 001 = 011` and `100 | 001 = 101`.
Similarly:
`010 & 001 = 000` and `011 & 001 = 001` |
319,702 | <pre><code>public enum myEnum {
VAL1(10), VAL2(20), VAL3("hai") {
public Object getValue() {
return this.strVal;
}
public String showMsg() {
return "This is your msg!";
}
};
String strVal;
Integer intVal;
public Object getValue() {
retu... | [
{
"answer_id": 319722,
"author": "Craig P. Motlin",
"author_id": 23572,
"author_profile": "https://Stackoverflow.com/users/23572",
"pm_score": 4,
"selected": true,
"text": "<p>Your class myEnum inherits from java.lang.Enum. VAL3 is an anonymous inner class that inherits from myEnum call... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27784/"
] | ```
public enum myEnum {
VAL1(10), VAL2(20), VAL3("hai") {
public Object getValue() {
return this.strVal;
}
public String showMsg() {
return "This is your msg!";
}
};
String strVal;
Integer intVal;
public Object getValue() {
return this... | Your class myEnum inherits from java.lang.Enum. VAL3 is an anonymous inner class that inherits from myEnum called myEnum$1. Think of the enum keyword as syntatic sugar. It sets up classes with normal inheritance trees for you, but will not allow you to extend java.lang.Enum or myEnum directly. |
319,711 | <p>I posted a question earlier today when I'd not zeroed in quite so far on the problem. I'll be able to be more concise here.</p>
<p>I'm running RoR 2.1.2, on Windows, with MySQL. The SQL server's native time zone is UTC. My local timezone is Pacific (-0800)</p>
<p>I have a model with a :timestamp type column whi... | [
{
"answer_id": 321634,
"author": "allesklar",
"author_id": 19893,
"author_profile": "https://Stackoverflow.com/users/19893",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you did not comment on my last suggestion to restart your server or your console.</p>\n\n<p>I had a similar pro... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] | I posted a question earlier today when I'd not zeroed in quite so far on the problem. I'll be able to be more concise here.
I'm running RoR 2.1.2, on Windows, with MySQL. The SQL server's native time zone is UTC. My local timezone is Pacific (-0800)
I have a model with a :timestamp type column which I can do things l... | In the end, it was far easier to do this by storing times as an integer (Time.now().to\_i()) and converting them back to a time when I needed to display them (Time.at(the\_time\_the\_database\_returned\_to\_me).) This is hardly the best solution, but it was the only one that worked. |
319,716 | <p>I'm working on a .Net application which uses Asp.net 3.5 and Lucene.Net I am showing search results given by Lucene.Net in an asp.net datagrid. I need to implement Paging (10 records on each page) for this aspx page.</p>
<p>How do I get this done using Lucene.Net?</p>
| [
{
"answer_id": 319770,
"author": "David Thibault",
"author_id": 5903,
"author_profile": "https://Stackoverflow.com/users/5903",
"pm_score": 6,
"selected": true,
"text": "<p>Here is a way to build a simple list matching a specific page with Lucene.Net. This is not ASP.Net specific.</p>\n\... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40907/"
] | I'm working on a .Net application which uses Asp.net 3.5 and Lucene.Net I am showing search results given by Lucene.Net in an asp.net datagrid. I need to implement Paging (10 records on each page) for this aspx page.
How do I get this done using Lucene.Net? | Here is a way to build a simple list matching a specific page with Lucene.Net. This is not ASP.Net specific.
```
int first = 0, last = 9; // TODO: Set first and last to correct values according to page number and size
Searcher searcher = new IndexSearcher(YourIndexFolder);
Query query = BuildQuery(); // TODO: Implemen... |
319,730 | <p>How can I escape a bracket in a full-text SQL Server <code>contains()</code> query? I've tried all the following, <em>none</em> of which work:</p>
<pre><code>CONTAINS(crev.RawText, 'arg[0]')
CONTAINS(crev.RawText, 'arg[[0]]')
CONTAINS(crev.RawText, 'arg\[0\]')
</code></pre>
<p>Using double quotes does work, but it... | [
{
"answer_id": 319737,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "<p>Not in the spirit of fulltext indexing apparently.</p>\n\n<blockquote>\n <p>word</p>\n \n <p>Is a string of charac... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1/"
] | How can I escape a bracket in a full-text SQL Server `contains()` query? I've tried all the following, *none* of which work:
```
CONTAINS(crev.RawText, 'arg[0]')
CONTAINS(crev.RawText, 'arg[[0]]')
CONTAINS(crev.RawText, 'arg\[0\]')
```
Using double quotes does work, but it **forces the entire search to be a phrase**... | You don't have to escape the [ as it has no special meaning in Full Text Search. If you do need to search for an exact match though, you can use "" marks.
Further, you can use multiple "" inside the single quotes:
```
CONTAINS('"word1" or "word2" or "word3"')
```
This also works:
```
CONTAINS('"word1" and "word2"... |
319,736 | <p>I using GWT and have created a login form. I've tried all sorts of ways to get IE7 to prompt to remember the login info but with no success. I thought that maybe this would have worked (but it didn't):</p>
<pre><code> TextBox submit = new TextBox();
submit.getElement().setAttribute("type", "submit");
</cod... | [
{
"answer_id": 319738,
"author": "seanb",
"author_id": 3354,
"author_profile": "https://Stackoverflow.com/users/3354",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know GWT, but you might need to somehow set an attribute on the form tag -<br>\nautocomplete=\"on\", which has work... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I using GWT and have created a login form. I've tried all sorts of ways to get IE7 to prompt to remember the login info but with no success. I thought that maybe this would have worked (but it didn't):
```
TextBox submit = new TextBox();
submit.getElement().setAttribute("type", "submit");
```
Any ideas? | You can simply assign values:
```
private TextBox mName = new TextBox();
private PasswordTextBox mPassword = new PasswordTextBox();
mName.setText("username");
mPassword.setText("password");
```
In your case I would store the values in cookies, and read them out on startup.
```
public static String getLastLoginName... |
319,741 | <p>Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it becomes horribly stretched when leaving an aspect ratio of 1:1.</p>
<pre><code>xStep = (maxX - minX) / width;
yStep = (maxY - minY) / height;
for(i = 0; i < width; i++)
for(j = 0; j < height; j++)
{
constantReal = minRe... | [
{
"answer_id": 319750,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 0,
"selected": false,
"text": "<p>It probably has to do with how you are displaying the <code>image</code> array. You use the width variable i as... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/868/"
] | Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it becomes horribly stretched when leaving an aspect ratio of 1:1.
```
xStep = (maxX - minX) / width;
yStep = (maxY - minY) / height;
for(i = 0; i < width; i++)
for(j = 0; j < height; j++)
{
constantReal = minReal + xStep * i;
c... | >
> Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it
> becomes horribly stretched when leaving an aspect ratio of 1:1.
>
>
>
```
xStep = (maxX - minX) / width;
yStep = (maxY - minY) / height;
```
Aha! It's because you must keep the same aspect ratio *both* for the image you wi... |
319,748 | <p>I have tried to use ASP.NET MVC for a while, then I face a problem that I don't want to include all of my js and css in master page. But how can I register it in head of master page from my specific view?</p>
| [
{
"answer_id": 319760,
"author": "Kyle West",
"author_id": 34133,
"author_profile": "https://Stackoverflow.com/users/34133",
"pm_score": 0,
"selected": false,
"text": "<p>technically you should be putting all your js at the bottom of the page for the best performance. </p>\n\n<p>I think ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35700/"
] | I have tried to use ASP.NET MVC for a while, then I face a problem that I don't want to include all of my js and css in master page. But how can I register it in head of master page from my specific view? | The default master page template includes a Content PlaceHolder for the head. If it doesn't you can easily add one:
```
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server" />
</head>
```
Your views can then put anything they want in the head:
```
<asp:Content ID="Content1"... |
319,752 | <p>We have a C# windows application that needs to be able to connect to a server on a network, download and save a file to a specified location.
We can not use a web service as we can not assume that our clients will have IIS on their server. </p>
<p>The way that I am considering doing it is to FTP onto the server and... | [
{
"answer_id": 319760,
"author": "Kyle West",
"author_id": 34133,
"author_profile": "https://Stackoverflow.com/users/34133",
"pm_score": 0,
"selected": false,
"text": "<p>technically you should be putting all your js at the bottom of the page for the best performance. </p>\n\n<p>I think ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26300/"
] | We have a C# windows application that needs to be able to connect to a server on a network, download and save a file to a specified location.
We can not use a web service as we can not assume that our clients will have IIS on their server.
The way that I am considering doing it is to FTP onto the server and download ... | The default master page template includes a Content PlaceHolder for the head. If it doesn't you can easily add one:
```
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server" />
</head>
```
Your views can then put anything they want in the head:
```
<asp:Content ID="Content1"... |
319,762 | <p>I am trying to use this in my page class. I only just started using objects in PHP so I'm still a little clueless (but learning as much as I can). This is in my <code>page()</code> function (so called when there is a new instance of page)</p>
<pre><code>set_error_handler('$this->appendError');
</code></pre>
<p>... | [
{
"answer_id": 319782,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 6,
"selected": true,
"text": "<p>Few problems with that.</p>\n\n<p>First: <pre>'$this->appendError'</pre> is a nogo. It doesn't interpret $this to the curre... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31671/"
] | I am trying to use this in my page class. I only just started using objects in PHP so I'm still a little clueless (but learning as much as I can). This is in my `page()` function (so called when there is a new instance of page)
```
set_error_handler('$this->appendError');
```
This is causing an error
>
> Warning: ... | Few problems with that.
First:
```
'$this->appendError'
```
is a nogo. It doesn't interpret $this to the current class, php interprets it as the string '$this'.
Second: Try
```
set_error_handler(array($this, 'appendError'));
```
If that doesn't work, replace $this with the classname and use it statically. |
319,764 | <p>I'm using (GNU) Make in my project. I'm currently putting one makefile per directory and specify the subdirectories using SUBDIRS.
It's been suggested to me that this is not the ideal way of using make, that using a one toplevel make file (or several, split up using include). I've tried migrating/using this layout i... | [
{
"answer_id": 319858,
"author": "Dana the Sane",
"author_id": 2567,
"author_profile": "https://Stackoverflow.com/users/2567",
"pm_score": 0,
"selected": false,
"text": "<p>The benefit that I've gotten from this in the past is that it's easier to build files in a single subdirectory. You... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14337/"
] | I'm using (GNU) Make in my project. I'm currently putting one makefile per directory and specify the subdirectories using SUBDIRS.
It's been suggested to me that this is not the ideal way of using make, that using a one toplevel make file (or several, split up using include). I've tried migrating/using this layout in t... | The first thing you should keep in mind (just to eliminate any misunderstanding) is that we're not talking about a single vs. multiple makefiles. Splitting your makefile in one per subdirectory is probably a good idea in any case.
Recursive makefiles are bad primarily because you partition your dependency tree into se... |
319,765 | <p>Is there any way other than using reflection to access the members of a anonymous inner class?</p>
| [
{
"answer_id": 319884,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 0,
"selected": false,
"text": "<p>If it implements an interface or extends an existing class, you can access the members defined in the interface or base... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27784/"
] | Is there any way other than using reflection to access the members of a anonymous inner class? | Anonymous inner classes have a type but no name.
You can access fields not defined by the named supertype. However once assigned to a named type variable, the interface is lost.
Obviously, you can access the fields from within the inner class itself. One way of adding code is through an instance initialiser:
```
fin... |
319,788 | <p>I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started?
Here is a sample bit of code... | [
{
"answer_id": 319829,
"author": "Imran",
"author_id": 1897,
"author_profile": "https://Stackoverflow.com/users/1897",
"pm_score": 2,
"selected": false,
"text": "<p>Store the return value of beginTransaction() in Zend_Registry, and check it later.</p>\n"
},
{
"answer_id": 319844,... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35520/"
] | I am using Zend\_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started?
Here is a sample bit of code:
... | The framework has no way of knowing if you started a transaction. You can even use `$db->query('START TRANSACTION')` which the framework would not know about because it doesn't parse SQL statements you execute.
The point is that it's an application responsibility to track whether you've started a transaction or not. I... |
319,789 | <p>Sorry if this is basic but I was trying to pick up on .Net 3.5.</p>
<p>Question: Is there anything great about Func<> and it's 5 overloads? From the looks of it, I can still create a similar delgate on my own say, MyFunc<> with the exact 5 overloads and even more.</p>
<p>eg: <code>public delegate TResult MyF... | [
{
"answer_id": 319803,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": false,
"text": "<p>The <code>Func</code> family of delegates (and their return-type-less cousins, <code>Action</code>) are not any great... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Sorry if this is basic but I was trying to pick up on .Net 3.5.
Question: Is there anything great about Func<> and it's 5 overloads? From the looks of it, I can still create a similar delgate on my own say, MyFunc<> with the exact 5 overloads and even more.
eg: `public delegate TResult MyFunc<TResult>()` and a combo ... | The greatness lies in establishing **shared language for better communication**.
Instead of defining your own delegate types for the same thing (delegate explosion), use the ones provided by the framework. Anyone reading your code instantly grasps what you are trying to accomplish.. minimizes the time to 'what is this... |
319,790 | <p>Why does the SQLite C/C++ API return <code>unsigned char *</code>s for text values as opposed to the more de-facto <code>char *</code> type?</p>
<p>This is somewhat related to <a href="https://stackoverflow.com/questions/75191/unsigned-char">the unsigned char</a> question, except that the SQLite API's decision seem... | [
{
"answer_id": 319867,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 3,
"selected": false,
"text": "<p>At a wild guess I'd say that it has something to do with supporting UTF-8 encoding. Signed char values only make sense in... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | Why does the SQLite C/C++ API return `unsigned char *`s for text values as opposed to the more de-facto `char *` type?
This is somewhat related to [the unsigned char](https://stackoverflow.com/questions/75191/unsigned-char) question, except that the SQLite API's decision seems opposite of the conventional `char *` adv... | From the [SQLite documentation](http://www.sqlite.org/capi3ref.html#sqlite3_column_blob):
>
> (H13821) The sqlite3\_column\_text(S,N) interface converts the Nth column in the current row of the result set for the prepared statement S into a zero-terminated UTF-8 string and returns a pointer to that string.
>
>
>
... |
319,811 | <p>Does anyone have an example AUTORUN.INF which can launch an MSI installer automatically when the user inserts the CD.</p>
<p>I'm sure this can be done but I've been Googling around for ages and have not found any working solution.</p>
<p><strong>UPDATE:</strong> I have an AUTORUN.INF similar to this but it won't l... | [
{
"answer_id": 319812,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 4,
"selected": true,
"text": "<p>Try shellexecute= instead of open=</p>\n\n<pre>[autorun]\nshellexecute=MyInstaller-1.0.0.msi\nlabel=My CD Label\nicon=MyIcon... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] | Does anyone have an example AUTORUN.INF which can launch an MSI installer automatically when the user inserts the CD.
I'm sure this can be done but I've been Googling around for ages and have not found any working solution.
**UPDATE:** I have an AUTORUN.INF similar to this but it won't launch the installer:
```
[aut... | Try shellexecute= instead of open=
```
[autorun]
shellexecute=MyInstaller-1.0.0.msi
label=My CD Label
icon=MyIcon.ico
``` |
319,814 | <p>Could someone please point me toward a cleaner method to generate a random enum member. This works but seems ugly.</p>
<p>Thanks!</p>
<pre><code>public T RandomEnum<T>()
{
string[] items = Enum.GetNames(typeof( T ));
Random r = new Random();
string e = items[r.Next(0, items.Length - 1)];
return (T)En... | [
{
"answer_id": 319826,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 6,
"selected": true,
"text": "<pre><code>public T RandomEnum<T>()\n{ \n T[] values = (T[]) Enum.GetValues(typeof(T));\n return values[new Rando... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10178/"
] | Could someone please point me toward a cleaner method to generate a random enum member. This works but seems ugly.
Thanks!
```
public T RandomEnum<T>()
{
string[] items = Enum.GetNames(typeof( T ));
Random r = new Random();
string e = items[r.Next(0, items.Length - 1)];
return (T)Enum.Parse(typeof (T), e, tru... | ```
public T RandomEnum<T>()
{
T[] values = (T[]) Enum.GetValues(typeof(T));
return values[new Random().Next(0,values.Length)];
}
```
Thanks to @[Marc Gravell] for ponting out that the max in Random.Next(min,max) is exclusive. |
319,835 | <p>Scott Gu just posted about a new set of charting controls being distributed by the .NET team. They look incredible: <a href="http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2008/11/24/n... | [
{
"answer_id": 319843,
"author": "Chatu",
"author_id": 39203,
"author_profile": "https://Stackoverflow.com/users/39203",
"pm_score": 2,
"selected": false,
"text": "<p>You can already use them with MVC all you have to do is render them as images </p>\n"
},
{
"answer_id": 320891,
... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34133/"
] | Scott Gu just posted about a new set of charting controls being distributed by the .NET team. They look incredible: <http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx>
The million dollar question is ... will they work with MVC, and if so, when? | You can use the chart controls in two ways:
**Generating the Image from a Controller**
By generating the chart and returning it as an image from an action (as Chatuman is referring to I think):
```
Chart chart = new Chart();
chart.BackColor = Color.Transparent;
chart.Width = Unit.Pixel(250);
chart.Height = Unit.Pixe... |
319,847 | <p>In a program to find whether the given number is an <a href="http://en.wikipedia.org/wiki/Narcissistic_number" rel="nofollow noreferrer">Armstrong</a> number, I stored the input no (3 digit) as string as follows.</p>
<pre><code>char input[10];
scanf("%s",&input);
</code></pre>
<p>Now I have to calculate cube o... | [
{
"answer_id": 319854,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "<p>You do not need to get the address of the <code>input</code> array using <code>&input</code>. Simply passing <code>... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In a program to find whether the given number is an [Armstrong](http://en.wikipedia.org/wiki/Narcissistic_number) number, I stored the input no (3 digit) as string as follows.
```
char input[10];
scanf("%s",&input);
```
Now I have to calculate cube of each digit by using pow method of math.h as follows.
```
int a;
... | You are performing your calculation on the ASCII value of the digit. You'll need to convert it to a numeric value like so:
```
int digit = input[0] - '0';
int a; a = pow(digit, 3);
``` |
319,873 | <p>I have a table with some duplicate rows. I want to modify only the duplicate rows as follows.</p>
<p>Before:</p>
<pre><code>id col1
------------
1 vvvv
2 vvvv
3 vvvv
</code></pre>
<p>After:</p>
<pre><code>id col1
------------
1 vvvv
2 vvvv-2
3 vvvv-3
</code></pre>
<p>Col1 i... | [
{
"answer_id": 319877,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 0,
"selected": false,
"text": "<p>You might be able to do that with a sproc and cursors. I don't think it's possible in any reasonable select query.</p>\n"
}... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table with some duplicate rows. I want to modify only the duplicate rows as follows.
Before:
```
id col1
------------
1 vvvv
2 vvvv
3 vvvv
```
After:
```
id col1
------------
1 vvvv
2 vvvv-2
3 vvvv-3
```
Col1 is appended with a hyphen and the value of `id` column. | This SQL will only update duplicates, but not the one with the lowest id :
```
update tbl
set col1 = col1 + '-' + convert(varchar, id)
where exists(select * from tbl t where t.col1 = tbl.col1 and t.id < tbl.id)
``` |
319,879 | <p>I have two strings</p>
<pre><code><EM>is <i>love</i></EM>,<PARTITION />
</code></pre>
<p>and</p>
<pre><code><EM>is <i>love</i>,<PARTITION />
</code></pre>
<p>I want a regex to match the second string completely but should not match the first one. Please help... | [
{
"answer_id": 319890,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think you're asking the right question. This regex matches the second string completely and not the first:</p>\n\n... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40570/"
] | I have two strings
```
<EM>is <i>love</i></EM>,<PARTITION />
```
and
```
<EM>is <i>love</i>,<PARTITION />
```
I want a regex to match the second string completely but should not match the first one. Please help.
Note: Everything can change except the EM and PARTITION tags. | luckily going through all this and doing a lot of research on this i found the right regexx..........heres foor you all...thanks for everyone who helped
```
<EM>\w*\s*\W*\S*[^\(</EM>)]<PARTITION[ ]/>
```
captures the second string but leaves teh first one.... the only problem i was having was of negating the `</EM>`... |
319,894 | <p>Many of our customers have access to InstallShield, WISE or AdminStudio. These aren't a problem. I'm hoping there is some way I can provide our smaller customers <strong>without access to commercial repackaging tools</strong> a freely available set of tools and steps to do the file replacement themselves.</p>
<p>On... | [
{
"answer_id": 319981,
"author": "Martin v. Löwis",
"author_id": 33006,
"author_profile": "https://Stackoverflow.com/users/33006",
"pm_score": 1,
"selected": false,
"text": "<p>You need to add an entry to the <a href=\"http://msdn.microsoft.com/en-us/library/aa369801.aspx\" rel=\"nofollo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/592/"
] | Many of our customers have access to InstallShield, WISE or AdminStudio. These aren't a problem. I'm hoping there is some way I can provide our smaller customers **without access to commercial repackaging tools** a freely available set of tools and steps to do the file replacement themselves.
Only need to replace a si... | Okay, revisiting this question with my own answer providing nice little VB script that will do all heavy lifting. As mentioned in the original question, the aim was provide a simple solution for sysadmin users to make the updates/changes themselves.
Below is a simplified version of the code I'm currently providing to... |
319,896 | <p>using jython</p>
<p>I have a situation where emails come in with different attachments. Certain file types I process others I ignore and dont write to file.
I am caught in a rather nasty situation, because sometimes people send an email as an attachment, and that attached email has legal attachments. </p>
<p>What ... | [
{
"answer_id": 320093,
"author": "bortzmeyer",
"author_id": 15625,
"author_profile": "https://Stackoverflow.com/users/15625",
"pm_score": 0,
"selected": false,
"text": "<p>What about the example named \"<a href=\"http://docs.python.org/library/email-examples.html\" rel=\"nofollow norefer... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] | using jython
I have a situation where emails come in with different attachments. Certain file types I process others I ignore and dont write to file.
I am caught in a rather nasty situation, because sometimes people send an email as an attachment, and that attached email has legal attachments.
What I want to do is s... | The problem with existing suggestions is the walk method. This recursively, depth-first, walks the entire tree, including children.
Look at the source of the walk method, and adapt it to skip the recursive part. A cursory reading suggests:
```
if msg.is_multipart():
for part in msg.get_payload():
""" Pr... |
319,899 | <p>Suppose I have a text file with data separated by whitespace into columns. I want to write a shell script which takes as input a filename and a number N and prints out only that column. With awk I can do the following:</p>
<pre><code>awk < /tmp/in '{print $2}' > /tmp/out
</code></pre>
<p>This code prints out... | [
{
"answer_id": 319912,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 7,
"selected": true,
"text": "<pre>awk -v x=2 '{print $x}'</pre>\n\n<p>or in a shell script:</p>\n\n<pre>\n#!/bin/sh\nnum=$1\nawk < /tmp/in -v x=$num '{pr... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39584/"
] | Suppose I have a text file with data separated by whitespace into columns. I want to write a shell script which takes as input a filename and a number N and prints out only that column. With awk I can do the following:
```
awk < /tmp/in '{print $2}' > /tmp/out
```
This code prints out the second column.
But how wo... | ```
awk -v x=2 '{print $x}'
```
or in a shell script:
```
#!/bin/sh
num=$1
awk < /tmp/in -v x=$num '{print $x}' > /tmp/out
``` |
319,900 | <p>I am going to spend 30 minutes teaching Perl to an experienced programmer. The best way to learn Perl is by writing code. In addition to CPAN, what would you show a programmer so they would understand the expressiveness of Perl, the amount of functionality provided by CPAN, while keeping everything clean and tidy ... | [
{
"answer_id": 319913,
"author": "Alan",
"author_id": 37843,
"author_profile": "https://Stackoverflow.com/users/37843",
"pm_score": 3,
"selected": false,
"text": "<p>Definitely show them how easy it is to use regular expressions in Perl.</p>\n"
},
{
"answer_id": 319942,
"auth... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am going to spend 30 minutes teaching Perl to an experienced programmer. The best way to learn Perl is by writing code. In addition to CPAN, what would you show a programmer so they would understand the expressiveness of Perl, the amount of functionality provided by CPAN, while keeping everything clean and tidy so th... | We wrote a whole book on that called [Learning Perl](http://shop.oreilly.com/product/0636920018452.do). Check out the table of contents.
This book is a product of teaching people Perl since 1995. It's not geared to any particular application, and shows people the parts of Perl that they'll use for 80% of their Perl pr... |
319,915 | <p>In asp.net 3.5, I'm rewriting the url</p>
<p><a href="http://www.abc.com/archive/1108/harpersdecember" rel="nofollow noreferrer">http://www.abc.com/archive/1108/harpersdecember</a></p>
<p>to the following</p>
<p><a href="http://www.abc.com/article.aspx?docId=78" rel="nofollow noreferrer">http://www.abc.com/articl... | [
{
"answer_id": 320238,
"author": "Generic Error",
"author_id": 40944,
"author_profile": "https://Stackoverflow.com/users/40944",
"pm_score": 2,
"selected": false,
"text": "<p>You may need to create a wildcard mapping in IIS on the remote server so that all requests are processed by ASP.N... | 2008/11/26 | [
"https://Stackoverflow.com/questions/319915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40106/"
] | In asp.net 3.5, I'm rewriting the url
<http://www.abc.com/archive/1108/harpersdecember>
to the following
<http://www.abc.com/article.aspx?docId=78>
I'm using this code to do it:
```
Context.RewritePath("/article.aspx?docId=78");
```
It works fine locally but when I upload to the remote web server... | You may need to create a wildcard mapping in IIS on the remote server so that all requests are processed by ASP.Net. If you do not do this any URLs without .ASPX on the end will not run through your URL rewriting code.
There is a good explanation of this (and other reasons you might use it) on [Scott Guthrie's blog](h... |