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 |
|---|---|---|---|---|---|---|
507,992 | <p>If I have an array in Javascript that has been filled sporadically, how do I determine the number of non-nothing elements in the array?</p>
<p>for example:</p>
<pre><code>var zipCodes = [];
zipCodes[10006] = 'New York, NY';
zipCodes[90210] = 'Los Angeles, CA';
</code></pre>
<p>zipCodes.length returns 90,211 here ... | [
{
"answer_id": 508002,
"author": "I.devries",
"author_id": 6388,
"author_profile": "https://Stackoverflow.com/users/6388",
"pm_score": 5,
"selected": true,
"text": "<p>You would need an object with key-value pairs (kind of like an associative array / hashtable) instead of an array:</p>\n... | 2009/02/03 | [
"https://Stackoverflow.com/questions/507992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | If I have an array in Javascript that has been filled sporadically, how do I determine the number of non-nothing elements in the array?
for example:
```
var zipCodes = [];
zipCodes[10006] = 'New York, NY';
zipCodes[90210] = 'Los Angeles, CA';
```
zipCodes.length returns 90,211 here and I really don't want to loop t... | You would need an object with key-value pairs (kind of like an associative array / hashtable) instead of an array:
```
var zipCodes = {};
zipCodes[10006] = 'New York, NY';
zipCodes[90210] = 'Los Angeles, CA';
for(var zipCode in zipCodes) {
if(zipCodes.hasOwnProperty(zipCode)) {//makes sure prototypes aren't taken... |
508,014 | <p>How do you do a query of an LDAP store by sAMAccountName and Domain? What is the "domain" property named in Active Directory or LDAP terms?</p>
<p>This is what I have for the filter so far. I'd like to be able to add in the domain:</p>
<pre><code>(&(objectCategory=Person)(sAMAccountName=BTYNDALL))
</code></pr... | [
{
"answer_id": 508057,
"author": "lkurts",
"author_id": 36084,
"author_profile": "https://Stackoverflow.com/users/36084",
"pm_score": 2,
"selected": false,
"text": "<p>You have to perform your search in the domain: </p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms677934(VS.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | How do you do a query of an LDAP store by sAMAccountName and Domain? What is the "domain" property named in Active Directory or LDAP terms?
This is what I have for the filter so far. I'd like to be able to add in the domain:
```
(&(objectCategory=Person)(sAMAccountName=BTYNDALL))
``` | First, modify your search filter to only look for users and not contacts:
```
(&(objectCategory=person)(objectClass=user)(sAMAccountName=BTYNDALL))
```
You can enumerate all of the domains of a forest by connecting to the configuration partition and enumerating all the entries in the partitions container. Sorry I do... |
508,019 | <p>How can I configure JPA/Hibernate to store a date/time in the database as UTC (GMT) time zone? Consider this annotated JPA entity:</p>
<pre><code>public class Event {
@Id
public int id;
@Temporal(TemporalType.TIMESTAMP)
public java.util.Date date;
}
</code></pre>
<p>If the date is 2008-Feb-03 9:30... | [
{
"answer_id": 508377,
"author": "mitchnull",
"author_id": 18645,
"author_profile": "https://Stackoverflow.com/users/18645",
"pm_score": 6,
"selected": false,
"text": "<p>To the best of my knowledge, you need to put your entire Java app in UTC timezone (so that Hibernate will store dates... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | How can I configure JPA/Hibernate to store a date/time in the database as UTC (GMT) time zone? Consider this annotated JPA entity:
```
public class Event {
@Id
public int id;
@Temporal(TemporalType.TIMESTAMP)
public java.util.Date date;
}
```
If the date is 2008-Feb-03 9:30am Pacific Standard Time (... | Since Hibernate 5.2, you can now force the UTC time zone by adding the following configuration property into the `properties.xml` JPA configuration file:
```
<property name="hibernate.jdbc.time_zone" value="UTC"/>
```
If you're using Spring Boot, then add this property to your `application.properties` file:
```
spr... |
508,026 | <p>Is it possible on a web server to determine the users local time and timezone when they sent the request? </p>
<p>Could it be done using javascript to capture it and post it back to the server?</p>
<p>My company want to track how many users use our site outside of office hours (no I dont really know why either!).<... | [
{
"answer_id": 508038,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 4,
"selected": true,
"text": "<p>You need to put the client's JavaScript time into a hidden field, and assume their clock is set prope... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1127460/"
] | Is it possible on a web server to determine the users local time and timezone when they sent the request?
Could it be done using javascript to capture it and post it back to the server?
My company want to track how many users use our site outside of office hours (no I dont really know why either!).
Thanks. | You need to put the client's JavaScript time into a hidden field, and assume their clock is set properly.
```
myTime = new Date() >> Tue Feb 03 2009 12:24:28 GMT-0500 (Eastern Standard Time)
``` |
508,028 | <p>My team built a Windows Service in Java that connects to a SQL Server 2005 in a Windows 2003 Server, using pure JDBC (no connection pooling) with the JTDS driver.</p>
<p>After a while, the method that opens the connections to the database start raising exceptions with the following stack trace:</p>
<pre><code> ... | [
{
"answer_id": 508124,
"author": "Stephane Grenier",
"author_id": 39371,
"author_profile": "https://Stackoverflow.com/users/39371",
"pm_score": 1,
"selected": false,
"text": "<p>It really looks like you're connections aren't being closed. That or you're trying to re-use the connection in... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/407003/"
] | My team built a Windows Service in Java that connects to a SQL Server 2005 in a Windows 2003 Server, using pure JDBC (no connection pooling) with the JTDS driver.
After a while, the method that opens the connections to the database start raising exceptions with the following stack trace:
```
java.net.BindExceptio... | Are you opening / closing connections at a very rapid rate? When a TCP connection is closed, they hang around for a little while in the [TIME\_WAIT](http://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions) state. On Windows, the default time they exist is 240 seconds. It sounds like you might... |
508,033 | <p>I am building a text parser using regular expressions. I need to convert all tab characters in a string to space characters. I cannot assume how many spaces a tab should encompass otherwise I could replace a tab with, say, 4 space characters. Is there any good solution for this type of problem. I need to do this in ... | [
{
"answer_id": 508061,
"author": "Miyagi Coder",
"author_id": 46780,
"author_profile": "https://Stackoverflow.com/users/46780",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the replace function:</p>\n\n<pre><code>char tabs = '\\u0009';\nString newLine = withTabs.Replace(tabs... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21160/"
] | I am building a text parser using regular expressions. I need to convert all tab characters in a string to space characters. I cannot assume how many spaces a tab should encompass otherwise I could replace a tab with, say, 4 space characters. Is there any good solution for this type of problem. I need to do this in cod... | Unfortunately, you need to assume how many spaces a tab represents. You should set this to a fixed value (like the mentioned four) or make it a user option.
The quickest way to do this is .NET is (I'm using C#):
```
var NewString = "This is a string with a Tab";
var TabLength = 4;
var TabSpace = new String(' ', Ta... |
508,034 | <p>A native DotNet application will load all referenced assemblies (and their references) on first use. However, an ASP.NET will load all referenced assemblies (and their references) on first access.</p>
<ol>
<li><p>Is this understanding correct?</p></li>
<li><p>Is there a way to force ASP.NET to load assemblies on de... | [
{
"answer_id": 508058,
"author": "Oscar Cabrero",
"author_id": 14440,
"author_profile": "https://Stackoverflow.com/users/14440",
"pm_score": 2,
"selected": false,
"text": "<p>asp.net loads all the assemblies needed because the worker process creates an app domain with all of the required... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5993/"
] | A native DotNet application will load all referenced assemblies (and their references) on first use. However, an ASP.NET will load all referenced assemblies (and their references) on first access.
1. Is this understanding correct?
2. Is there a way to force ASP.NET to load assemblies on demand (like local applications... | To answer point 3, the setting that causes all the assemblies in the bin folder to be loaded on first access can be found in the file *C:\winnt\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config* (depending on your environment). Cut-down extract from that file:
```
<system.web>
<compilation>
<assemblies>... |
508,054 | <p>I am creating an object that has a constuctor like this...</p>
<pre><code>public class BusinessLogic()
{
public BusinessLogic()
{
BusinessLogicSubClass blsc = new BusinessLogicSubClass(and I want to pass in BusinessLogic here)
}
}
</code></pre>
<p>I am doing this because I want Busine... | [
{
"answer_id": 508069,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 4,
"selected": true,
"text": "<pre><code> public BusinessLogic()\n {\n BusinessLogicSubClass blsc = new BusinessLogicSubClass(this);\n }\n</... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62039/"
] | I am creating an object that has a constuctor like this...
```
public class BusinessLogic()
{
public BusinessLogic()
{
BusinessLogicSubClass blsc = new BusinessLogicSubClass(and I want to pass in BusinessLogic here)
}
}
```
I am doing this because I want BusinessLogicSubClass to call ba... | ```
public BusinessLogic()
{
BusinessLogicSubClass blsc = new BusinessLogicSubClass(this);
}
```
An alternative to this (to address Jon Skeet's comments) would be to have a constructor, and an initializer, which uses the "this" pointer:
```
public class BusinessLogic
{
private BusinessLogicSubClass ... |
508,065 | <p>To tailor your scripts toward mp2, avoiding the need for any compatibility wrappers and such, it's said that you're supposed to declare variables using "local our" rather than "my". What about in modules?</p>
<pre><code>sub new
{
local our $type = shift;
local our $self = {};
bless $self, $type;
}
</co... | [
{
"answer_id": 508098,
"author": "innaM",
"author_id": 7498,
"author_profile": "https://Stackoverflow.com/users/7498",
"pm_score": 2,
"selected": true,
"text": "<p>You definitely need <code>my</code>.</p>\n\n<p>The <code>local our</code> advice pertains to variables that are global in yo... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] | To tailor your scripts toward mp2, avoiding the need for any compatibility wrappers and such, it's said that you're supposed to declare variables using "local our" rather than "my". What about in modules?
```
sub new
{
local our $type = shift;
local our $self = {};
bless $self, $type;
}
```
Is that right... | You definitely need `my`.
The `local our` advice pertains to variables that are global in your module. |
508,075 | <p>Given the tables: </p>
<pre><code>Exam (ExamId, SubjectId)
Result (ExamId, StudentId, GradeId)
</code></pre>
<p>What's the best way of retrieving a list of Students who received GradeId='A' in SubjectId='Maths' AND GradeId = 'B' in SubjectId='English' for their most recent exams in each subject? We can either assu... | [
{
"answer_id": 508485,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "<p>If you get nothing else from this post then let it be this: do NOT assume that the IDs will always increase. That onl... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62041/"
] | Given the tables:
```
Exam (ExamId, SubjectId)
Result (ExamId, StudentId, GradeId)
```
What's the best way of retrieving a list of Students who received GradeId='A' in SubjectId='Maths' AND GradeId = 'B' in SubjectId='English' for their most recent exams in each subject? We can either assume ExamIds increase over t... | First thing you need to do is deal with the "most recent exam" condition.
The following gets the most recent exam for each student by subject...
```
SELECT
[Result].StudentID,
[Exam].SubjectID,
MAX([Exam].id) AS ExamID
FROM
Result
INNER JOIN
Exam
ON [Exam].id = [Result].ExamID
GROUP BY
[Result]... |
508,097 | <p>Maybe you can help me with a SQL Query: </p>
<p>I have a conversion value in a secondary table and the following structure:</p>
<pre><code>ID PRICE_BRL PRICE_USD
-- --------- ---------
1 10 5
2 12 NULL
3 NULL 3
4 14 NULL
5 NULL 4
6 NULL NULL
</code></pre>
<p>I need a Resu... | [
{
"answer_id": 508107,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 4,
"selected": true,
"text": "<p>Pseudo code as well:</p>\n\n<pre><code>select id, coalesce(price_brl, price_usd * tbl_2.value) \nfrom tbl_1\ninner ... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | Maybe you can help me with a SQL Query:
I have a conversion value in a secondary table and the following structure:
```
ID PRICE_BRL PRICE_USD
-- --------- ---------
1 10 5
2 12 NULL
3 NULL 3
4 14 NULL
5 NULL 4
6 NULL NULL
```
I need a Result Set Like that prioritizes the ... | Pseudo code as well:
```
select id, coalesce(price_brl, price_usd * tbl_2.value)
from tbl_1
inner join tbl2
``` |
508,100 | <p>I'm afraid that I already know the answer to my question, but I'll ask it anyway:</p>
<p>When there are two MySQL DB servers, can I access data that is stored on the other server? </p>
<p>In other words: Can I somehow do this:</p>
<pre><code>INSERT INTO table (x, y, z)
SELECT x, y, x+y
FROM [otherserver]... | [
{
"answer_id": 508231,
"author": "volatilsis",
"author_id": 45789,
"author_profile": "https://Stackoverflow.com/users/45789",
"pm_score": 5,
"selected": true,
"text": "<p>You can set up federated tables in MySQL to accomplish what you're trying to do. There are some limitations.</p>\n\n<... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | I'm afraid that I already know the answer to my question, but I'll ask it anyway:
When there are two MySQL DB servers, can I access data that is stored on the other server?
In other words: Can I somehow do this:
```
INSERT INTO table (x, y, z)
SELECT x, y, x+y
FROM [otherserver].[database].[table]
```
Is... | You can set up federated tables in MySQL to accomplish what you're trying to do. There are some limitations.
<http://dev.mysql.com/doc/refman/en/federated-storage-engine.html>
<http://dev.mysql.com/doc/refman/en/federated-usagenotes.html> |
508,108 | <p>I have written the regex below for a really simple email validation. I plan to send a confirmation link.</p>
<pre><code>/.*@[a-z0-9.-]*/i
</code></pre>
<p>I would, however, like to enhance it from the current state because a string like this does not yield the desired result:</p>
<p>test ,my.name+test@gmail-somet... | [
{
"answer_id": 508121,
"author": "alxp",
"author_id": 19513,
"author_profile": "https://Stackoverflow.com/users/19513",
"pm_score": 4,
"selected": false,
"text": "<p><strong>Don't use regular expressions to validate e-mail addresses</strong></p>\n\n<p>Instead, from <a href=\"https://web.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74552/"
] | I have written the regex below for a really simple email validation. I plan to send a confirmation link.
```
/.*@[a-z0-9.-]*/i
```
I would, however, like to enhance it from the current state because a string like this does not yield the desired result:
test ,my.name+test@gmail-something.co.uk, test
The "test ," po... | Instead of . try matching every character except \s (whitespace):
```
/[^\s]*@[a-z0-9.-]*/i
``` |
508,109 | <p>I am constructing a query that will naturally return a result that has values for several columns, as well as some integer-valued grouping columns (indicating whether a particular value column was subtotalled but that's not in itself relevant to my question). I want to put a constraint on this query's grouping colu... | [
{
"answer_id": 508171,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 3,
"selected": true,
"text": "<p>You say that the values are integers. Can they be negative? If not, you could just use a set of comparisons:</p>\n\n<pre><co... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45664/"
] | I am constructing a query that will naturally return a result that has values for several columns, as well as some integer-valued grouping columns (indicating whether a particular value column was subtotalled but that's not in itself relevant to my question). I want to put a constraint on this query's grouping columns,... | You say that the values are integers. Can they be negative? If not, you could just use a set of comparisons:
```
where (grp1 >= grp2 and grp2 >= grp3 ...)
```
Edit: actually, I'm also assuming here that non-zero values have to be 1... but the principle could still be applied if that's not the case, I'd imagine. |
508,110 | <p>When you have a class car that implements IVehicle and you want to wrap it in a decorator that forwards all calls to car and counts them, how would you do it?</p>
<p>In Ruby I could just build a decorator without any methods and use method_missing to forward all calls to the car object.</p>
<p>In Java I could buil... | [
{
"answer_id": 508140,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, there is no mixin support in C#. So you'd need to implement all methods, or use some heavy-duty ref... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45719/"
] | When you have a class car that implements IVehicle and you want to wrap it in a decorator that forwards all calls to car and counts them, how would you do it?
In Ruby I could just build a decorator without any methods and use method\_missing to forward all calls to the car object.
In Java I could build a Proxy object... | For proxying you could look into "RealProxy" if you want to use standard types, it's a little bit of a hassle to use though (and it requires your classes inherit from MarshalByRefObject).
```
public class TestProxy<T> : RealProxy where T : class
{
public T Instance { get { return (T)GetTransparentProxy(); } }
... |
508,126 | <p>Below is a sample implementation of overriding Object.Equals() for an entity base class from which all other entities in an application derive.</p>
<p>All entity classes have the property Id, which is a nullable int. (It's the primary key of whatever table the entity class corresponds to.)</p>
<pre><code>public o... | [
{
"answer_id": 508130,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 1,
"selected": false,
"text": "<p>You can only correctly implement <code>GetHashCode()</code> if the <code>Id</code> property is immutable for the lif... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549/"
] | Below is a sample implementation of overriding Object.Equals() for an entity base class from which all other entities in an application derive.
All entity classes have the property Id, which is a nullable int. (It's the primary key of whatever table the entity class corresponds to.)
```
public override bool Equals(ob... | If you're deriving from something that already overrides `GetHashCode` I'd implement it as:
```
public override int GetHashCode()
{
unchecked
{
int hash = 37;
hash = hash * 23 + base.GetHashCode();
hash = hash * 23 + Id.GetHashCode();
return hash;
}
}
```
A null value of I... |
508,135 | <p>This isn't, I don't think, a standard svn ignore question.</p>
<p>I have a repository with a huge directory in it that I don't want. Because others using the repository <em>do</em>, I can't just delete it from the tree. BUT, I don't want to redownload this directory every time I do a svn up. I can understand tha... | [
{
"answer_id": 508164,
"author": "Stephen",
"author_id": 38714,
"author_profile": "https://Stackoverflow.com/users/38714",
"pm_score": 2,
"selected": false,
"text": "<p>You could use a script to svn update --non-recursive the current directory, then individually update the remaining subd... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62046/"
] | This isn't, I don't think, a standard svn ignore question.
I have a repository with a huge directory in it that I don't want. Because others using the repository *do*, I can't just delete it from the tree. BUT, I don't want to redownload this directory every time I do a svn up. I can understand that ignore will preven... | So I just came up with what I think is about the fastest answer to the question. Since SVN doesn't have a way to autoignore directories that I don't want updated...
Here's my existing dir structure:
root
-> goodDir 1
-> goodDir 2
etc
I've deleted the bad directories from my checkout. I can't do an 'svn up' from t... |
508,141 | <p>I'm parsing a tab-delimited file using FasterCSV:</p>
<pre><code> csv_rows = FasterCSV.readlines(file_location, {:col_sep=>"\t"})
</code></pre>
<p>When I parse this I get an 'Illegal quoting on line 1.' error. The line contains this text:</p>
<pre><code>...around \"foo bar\" with...
</code></pre>
<p>Is there... | [
{
"answer_id": 508266,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Is there another way to escape quotes that might work?</p>\n</blockquote>\n\n<p>\"...around \"\"foo bar... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm parsing a tab-delimited file using FasterCSV:
```
csv_rows = FasterCSV.readlines(file_location, {:col_sep=>"\t"})
```
When I parse this I get an 'Illegal quoting on line 1.' error. The line contains this text:
```
...around \"foo bar\" with...
```
Is there another way to escape quotes that might work?
Than... | >
> Is there another way to escape quotes that might work?
>
>
>
"...around ""foo bar"" with..." |
508,149 | <p>I use the following to start one of my applications</p>
<pre><code> // Start the process
ProcessStartInfo startInfo = new ProcessStartInfo(this.exeName);
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
controlProcess = System.Diagnostics.Process.Start(startInfo);
</code></pre>
<p>The behavior that I see... | [
{
"answer_id": 508170,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 1,
"selected": false,
"text": "<p>The possibility of doing what you're asking for (pre-load an application) depends entirely on the functionality of... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I use the following to start one of my applications
```
// Start the process
ProcessStartInfo startInfo = new ProcessStartInfo(this.exeName);
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
controlProcess = System.Diagnostics.Process.Start(startInfo);
```
The behavior that I see is that if there are no i... | You need to set the ShowInTaskbar property to false on the main form of the application that you are launching. Additionally, you will need to hide the form until a user action requests it to be shown.
You can also add a notifyIcon to the system tray if you want to keep the application somewhat visible. |
508,165 | <p>I have a listview with 4 columns - Name, Extension, Size and Location. I have a method that takes the file size in bytes and converts to KB, MB, GB, etc as needed. An example output would be a 1024 byte file which is printed as "1KB". This value is then placed in the listview.</p>
<p>What I need to do is sort the s... | [
{
"answer_id": 508264,
"author": "NascarEd",
"author_id": 62070,
"author_profile": "https://Stackoverflow.com/users/62070",
"pm_score": 2,
"selected": true,
"text": "<p>Most every object in .NET has a Tag member. This is a place where you can stuff anything extra you need to. In your cas... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14333/"
] | I have a listview with 4 columns - Name, Extension, Size and Location. I have a method that takes the file size in bytes and converts to KB, MB, GB, etc as needed. An example output would be a 1024 byte file which is printed as "1KB". This value is then placed in the listview.
What I need to do is sort the size column... | Most every object in .NET has a Tag member. This is a place where you can stuff anything extra you need to. In your case, I would stuff the file size in bytes into the ListViewSubItem.Tag property. Then, your sort algorithm can use that to sort by instead of the column text. |
508,177 | <p>I'm attempting to refactor some moderately complex existing .NET code to be usable in Silverlight. The core issue is that all Silverlight web services calls must be asynch, and the existing code was implemented in a fairly typical synchronous manner.</p>
<p>Existing call stack for a typical operation might be some... | [
{
"answer_id": 508260,
"author": "mbeckish",
"author_id": 21727,
"author_profile": "https://Stackoverflow.com/users/21727",
"pm_score": 0,
"selected": false,
"text": "<p>To avoid refactoring, you might be able to implement CallWebService as a synchronous method that internally uses async... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52101/"
] | I'm attempting to refactor some moderately complex existing .NET code to be usable in Silverlight. The core issue is that all Silverlight web services calls must be asynch, and the existing code was implemented in a fairly typical synchronous manner.
Existing call stack for a typical operation might be something like ... | 1. You can't block the main Silverlight thread, or your UI will hang. This is the reason all the network operations in SL are forced async.
2. You can't touch the UI from any thread but the UI thread.
Those are the two constraints. The way I'd approach this is to create an "async wrapper" function to wrap it up for yo... |
508,183 | <p>I am new to Python and it seems to have a lot of nice functions that I don't know about. What function can I use to get the root site name? For example, how would I get <em>faqs.org</em> if I gave the function the URL "<a href="http://ttp://www.faqs.org/docs/diveintopython/kgp_commandline.html" rel="nofollow norefer... | [
{
"answer_id": 508196,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 4,
"selected": true,
"text": "<pre><code> >>> from urllib.parse import urlparse\n >>> urlparse('http://www.cwi.nl:80/%7Eguido/Pytho... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am new to Python and it seems to have a lot of nice functions that I don't know about. What function can I use to get the root site name? For example, how would I get *faqs.org* if I gave the function the URL "[http://www.faqs.org/docs/diveintopython/kgp\_commandline.html](http://ttp://www.faqs.org/docs/diveintopytho... | ```
>>> from urllib.parse import urlparse
>>> urlparse('http://www.cwi.nl:80/%7Eguido/Python.html').hostname
'www.cwi.nl'
``` |
508,191 | <p>I am trying to copy the value in bar into the integer foo.</p>
<p>This is what I have so far. When I run it I get a different hex value. Any help would be great.</p>
<pre><code>int main()
{
string bar = "0x00EB0C62";
int foo = (int)bar;
cout << hex << foo;
ChangeMemVal("pinball.exe",... | [
{
"answer_id": 508200,
"author": "z -",
"author_id": 38264,
"author_profile": "https://Stackoverflow.com/users/38264",
"pm_score": 1,
"selected": false,
"text": "<p>when you cast a string as an int, you get the ascii value of that string, not the converted string value, to properly conv... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to copy the value in bar into the integer foo.
This is what I have so far. When I run it I get a different hex value. Any help would be great.
```
int main()
{
string bar = "0x00EB0C62";
int foo = (int)bar;
cout << hex << foo;
ChangeMemVal("pinball.exe", (void*) foo, "100000", 4);
... | [atoi](http://www.cplusplus.com/reference/clibrary/cstdlib/atoi.html) should work:
```
string bar = "0x00EB0C62";
int foo = atoi(bar.c_str());
``` |
508,208 | <p>In a windows form application what is the impact of calling <code>Thread.Sleep(1)</code> as illustrated in the following code:</p>
<pre><code>public Constructor()
{
Thread thread = new Thread(Task);
thread.IsBackground = true;
thread.Start();
}
private void Task()
{
while (true)
{
// do... | [
{
"answer_id": 508215,
"author": "Frederick The Fool",
"author_id": 32688,
"author_profile": "https://Stackoverflow.com/users/32688",
"pm_score": 5,
"selected": false,
"text": "<p>No it won't hog the CPU, it will just pause your thread for <em>at least</em> that long. While your thread i... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609/"
] | In a windows form application what is the impact of calling `Thread.Sleep(1)` as illustrated in the following code:
```
public Constructor()
{
Thread thread = new Thread(Task);
thread.IsBackground = true;
thread.Start();
}
private void Task()
{
while (true)
{
// do something
Thread... | As stated, your loop will not hog the CPU.
*But beware*: Windows is **not** a real-time OS, so you will **not** get 1000 wakes per second from Thread.Sleep(1). If you haven't used [timeBeginPeriod](http://msdn.microsoft.com/en-us/library/ms713413.aspx) to set your minimum resolution you'll wake about every 15 ms. Eve... |
508,213 | <p>Is there a way to dynamically execute code contained in a string using .net 2.0, in a similar way to eval() in javascript or using sp_executeSQL in tsql?</p>
<p>I have a string value in a variable that I want to manipulate at some point in my application - so the code would essentially be string manipulation. I don... | [
{
"answer_id": 508247,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>I think it's possible using reflection.emit and codedom to do this, but it's not at all trivial and I advise agains... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8479/"
] | Is there a way to dynamically execute code contained in a string using .net 2.0, in a similar way to eval() in javascript or using sp\_executeSQL in tsql?
I have a string value in a variable that I want to manipulate at some point in my application - so the code would essentially be string manipulation. I don't know w... | like the others already mentioned its not really possible to compile c# in an eval() function. that functionality is planed for a latter release of the clr which anders demoed at the PDC.
as a diffrent solutionm, if your application is able to run on mono you can just use its eval function which can dynamicly compile ... |
508,227 | <p>Given this C API declaration how would it be imported to C#?</p>
<pre><code>const char* _stdcall z4LLkGetKeySTD(void);
</code></pre>
<p>I've been able to get this far:</p>
<pre><code> [DllImport("zip4_w32.dll",
CallingConvention = CallingConvention.StdCall,
EntryPoint = "z4LLkGetKeySTD",
Ex... | [
{
"answer_id": 508239,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 2,
"selected": false,
"text": "<p>Just use 'string' instead of 'const char *'.</p>\n\n<p>Edit: This is dangerous for the reason JaredPar explaine... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27887/"
] | Given this C API declaration how would it be imported to C#?
```
const char* _stdcall z4LLkGetKeySTD(void);
```
I've been able to get this far:
```
[DllImport("zip4_w32.dll",
CallingConvention = CallingConvention.StdCall,
EntryPoint = "z4LLkGetKeySTD",
ExactSpelling = false)]
private exte... | Try this
```
[DllImport("zip4_w32.dll",
CallingConvention = CallingConvention.StdCall,
EntryPoint = "z4LLkGetKeySTD",
ExactSpelling = false)]
private extern static IntPtr z4LLkGetKeySTD();
```
You can then convert the result to a String by using Marshal.PtrToStringAnsi(). You will still ne... |
508,228 | <p>Full disclosure: I'm very new to Ruby.</p>
<p>The following code seems like it should update the para's text with the app's current dimensions as you resize it. </p>
<pre><code>Shoes.app do
stack do
@para = para
end
animate 1 do
@para.text = "%d x %d" % [ app.width, app.height... | [
{
"answer_id": 509259,
"author": "Rudd Zwolinski",
"author_id": 219,
"author_profile": "https://Stackoverflow.com/users/219",
"pm_score": 3,
"selected": true,
"text": "<p>I don't know Shoes well, but it looks like it's a problem with changing the app's dimensions. Your animation does up... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62052/"
] | Full disclosure: I'm very new to Ruby.
The following code seems like it should update the para's text with the app's current dimensions as you resize it.
```
Shoes.app do
stack do
@para = para
end
animate 1 do
@para.text = "%d x %d" % [ app.width, app.height]
end
end
... | I don't know Shoes well, but it looks like it's a problem with changing the app's dimensions. Your animation does update, but the width and height of the app don't update. The following code shows that it does animate (the frame number will change):
```
Shoes.app do
stack do
@para = para
end
animat... |
508,229 | <p>I'm trying to work out a way to display the contents of the version column from SharePoint (i.e. the value that changes every time a file is checked in) as a field (or something similar) inside of a Word document.</p>
<p>Ideally, I'd like to know how to configure SharePoint so I could click something like "Insert >... | [
{
"answer_id": 508626,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 0,
"selected": false,
"text": "<p>Try creating a calculated field in a custom content type. The field can be equal to the Version. That will give you the abi... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62055/"
] | I'm trying to work out a way to display the contents of the version column from SharePoint (i.e. the value that changes every time a file is checked in) as a field (or something similar) inside of a Word document.
Ideally, I'd like to know how to configure SharePoint so I could click something like "Insert > Quick Par... | This is one way to get the version in your document, it's a bit painful to get it working...
* Enable versioning and content types on your document library.
* Go into document library settings and select the content types you want the version to appear in.
* Select Information management policies settings from the co... |
508,233 | <p>How do I match complete words in a hibernate HQL query?
For example, imagine in our database we have an entry "Sam Adams".
Now, given this HQL fragment:</p>
<pre><code>book.character like 'Sam'
</code></pre>
<p>I do not match on "Sam Adams".</p>
<p>However, if I change my query to: </p>
<pre><code>book.character... | [
{
"answer_id": 508637,
"author": "Matt Sidesinger",
"author_id": 1481472,
"author_profile": "https://Stackoverflow.com/users/1481472",
"pm_score": 3,
"selected": false,
"text": "<p>Since the HQL maps directly to the SQL LIKE functionality and the LIKE functionality does not support regul... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I match complete words in a hibernate HQL query?
For example, imagine in our database we have an entry "Sam Adams".
Now, given this HQL fragment:
```
book.character like 'Sam'
```
I do not match on "Sam Adams".
However, if I change my query to:
```
book.character = 'Sam%'
```
then I also match on "Samant... | Since the HQL maps directly to the SQL LIKE functionality and the LIKE functionality does not support regular expressions, you will have to be creative and do something like:
book.character like 'Sam %' OR book.character like '% Sam' OR book.character like '% Sam %' OR book.character = 'Sam'
This might not be the exa... |
508,234 | <p>I have a <strong>PHP/MySQL</strong> web site where I want to output the # of entries in a DB/table on the main page, but I don't want to make this query every time a user hits the home page. I want it to automatically run once a day and output the query results to a flat file which I can then just include. I figur... | [
{
"answer_id": 508244,
"author": "niczak",
"author_id": 59975,
"author_profile": "https://Stackoverflow.com/users/59975",
"pm_score": 0,
"selected": false,
"text": "<p>Well first off its called \"cron\" and its pretty easy to implement.. check out a little info about it: <a href=\"http:/... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a **PHP/MySQL** web site where I want to output the # of entries in a DB/table on the main page, but I don't want to make this query every time a user hits the home page. I want it to automatically run once a day and output the query results to a flat file which I can then just include. I figure that should redu... | You should write a standalone PHP script to do all the work, and just add it to your crontab like this:
```
0 2 * * * cd /path/to/script; /usr/bin/php daily.php 1> output.txt 2> errors.log
```
At every 2AM your `daily.php` script will run, the output is in `output.txt` and any errors generated (leave display\_errors... |
508,252 | <p>I'm adding the odp configuration in the application web.config file. For this I have a configuration section named "oracle.dataaccess.client". Therefore I'm adding an entry in the <code><configSections></code> section.
Something like this:</p>
<pre><code><section name="oracle.dataaccess.client" type="Syst... | [
{
"answer_id": 508325,
"author": "Igor Zelaya",
"author_id": 22769,
"author_profile": "https://Stackoverflow.com/users/22769",
"pm_score": 1,
"selected": false,
"text": "<p>check also the <a href=\"http://download.oracle.com/docs/cd/B28359_01/win.111/e10927/featConfig.htm\" rel=\"nofollo... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43655/"
] | I'm adding the odp configuration in the application web.config file. For this I have a configuration section named "oracle.dataaccess.client". Therefore I'm adding an entry in the `<configSections>` section.
Something like this:
```
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigura... | ODP 9.2 was released before .Net 2, and does not implement the new interfaces and factories this framework added (in the System.Data.Common namespace)
In other words, you cannot configure this version of ODP via the System.Data.Common configuration entries. ADO.net 2.0 compatibility started with version 10.2.0.2 of OD... |
508,267 | <p>I would like a method/closure which works like this</p>
<pre><code> println TimeDifference.format( System.currentMilliSeconds()-1000*60*60*24*7*6 )
</code></pre>
<p>and prints</p>
<pre><code> 1 month, 3 weeks, 2 days, 45 hours and 3 minutes ago.
</code></pre>
<p>Is there an off the shelf solution for this?</p>
| [
{
"answer_id": 508933,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know about Groovy, but it is very straightforward to port <a href=\"http://api.rubyonrails.org/classes/ActionVi... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] | I would like a method/closure which works like this
```
println TimeDifference.format( System.currentMilliSeconds()-1000*60*60*24*7*6 )
```
and prints
```
1 month, 3 weeks, 2 days, 45 hours and 3 minutes ago.
```
Is there an off the shelf solution for this? | check out [this library](http://johannburkard.de/blog/programming/java/date-formatting-parsing-humans-humantime.html) , its called human time, and it allows parsing and rendering of time that is more digestable by humans. |
508,269 | <p>Is there a character in JavaScript to break up a line of code so that it is read as continuous despite being on a new line?</p>
<p>Something like....</p>
<pre>
1. alert ( "Please Select file
2. \ to delete" );
</pre>
| [
{
"answer_id": 508279,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 9,
"selected": true,
"text": "<p>In your example, you can break the string into two pieces:</p>\n\n<pre><code>alert ( \"Please Select file\"\n + \" to de... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | Is there a character in JavaScript to break up a line of code so that it is read as continuous despite being on a new line?
Something like....
```
1. alert ( "Please Select file
2. \ to delete" );
``` | In your example, you can break the string into two pieces:
```
alert ( "Please Select file"
+ " to delete");
```
Or, when it's a string, as in your case, you can use a [backslash](http://www.nczonline.net/blog/2006/12/26/interesting-javascript-string-capability/) as @Gumbo suggested:
```
alert ( "Please Select fil... |
508,271 | <p>My office is cursed with a very unreliable network. From time to time things just seem to stop working - the servers are all fine. We think the fault lies in the wires and routers between our computers. </p>
<p>My team looks after a large number of Windows servers and workstations. Each PC runs a number of distribu... | [
{
"answer_id": 508279,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 9,
"selected": true,
"text": "<p>In your example, you can break the string into two pieces:</p>\n\n<pre><code>alert ( \"Please Select file\"\n + \" to de... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] | My office is cursed with a very unreliable network. From time to time things just seem to stop working - the servers are all fine. We think the fault lies in the wires and routers between our computers.
My team looks after a large number of Windows servers and workstations. Each PC runs a number of distributed applic... | In your example, you can break the string into two pieces:
```
alert ( "Please Select file"
+ " to delete");
```
Or, when it's a string, as in your case, you can use a [backslash](http://www.nczonline.net/blog/2006/12/26/interesting-javascript-string-capability/) as @Gumbo suggested:
```
alert ( "Please Select fil... |
508,274 | <p>I have a query where i want to get a distinct description by the latest date entered and the descriptions ID. I can get the disctinct part but i run into trouble with trying to get the ID since im using MAX on the date. Here is the query:</p>
<pre><code>SELECT DISTINCT Resource.Description, MAX(arq.DateReferred) AS... | [
{
"answer_id": 508434,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "<p>I doni't see a reason for the join to the [Case] table, so I've left that out. You can add it back if you need it for... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62065/"
] | I have a query where i want to get a distinct description by the latest date entered and the descriptions ID. I can get the disctinct part but i run into trouble with trying to get the ID since im using MAX on the date. Here is the query:
```
SELECT DISTINCT Resource.Description, MAX(arq.DateReferred) AS DateReferred,... | ```
SELECT
Resource.Description,
arq.DateReferred AS DateReferred,
arq.AssessmentResourceID
FROM
Resource
INNER JOIN
AssessmentXResource AS arq
ON arq.ResourceID = Resource.ResourceID
AND arq.DateReferred = (
SELECT
... |
508,276 | <p>I have my editor setup to be textmate but when I do a git diff it uses vi to show me the diff output, is there any way to set it to show the diff in textmate?</p>
| [
{
"answer_id": 508329,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>The <a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" rel=\"nofollow noreferrer\"><code>GIT_PAGER</code> en... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3041/"
] | I have my editor setup to be textmate but when I do a git diff it uses vi to show me the diff output, is there any way to set it to show the diff in textmate? | I normally pipe the contents to mate like this:
```
git diff | mate -
``` |
508,280 | <p>I have a large result set assembled in a parent/child relationship. I need to walk the tree and display the results to the user. </p>
<p>I've done this before using recursion, but because my result set may be large, I want to avoid the possibility of receiving a StackOverflowException.</p>
<p>I found the followi... | [
{
"answer_id": 508287,
"author": "Niyaz",
"author_id": 184,
"author_profile": "https://Stackoverflow.com/users/184",
"pm_score": 2,
"selected": false,
"text": "<p>In the current algorithm you are going for the right child first.</p>\n\n<p>Make it left child first. Thats all.</p>\n\n<p>Fo... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62064/"
] | I have a large result set assembled in a parent/child relationship. I need to walk the tree and display the results to the user.
I've done this before using recursion, but because my result set may be large, I want to avoid the possibility of receiving a StackOverflowException.
I found the following [example](http:/... | Push your items onto the stack in the reverse order, i.e. 2 before 1.
Example:
```
// suppose I want to push children[] onto the stack
for (int i = children.Length - 1; i >= 0; i--)
{
stack.Push(children[i]);
}
```
To do this in your code, try the following `for-each` statement:
```
foreach (DataRowView drvCh... |
508,289 | <p>I have perl, v5.6.1 built for MSWin32-x86-multi-thread Binary build 638 provided by ActiveState. </p>
<p>I am working on a Perl script where I have declared constants that are used later for comparison purposes. For some reason, I am getting an error that states something along the line of Constant name has invalid... | [
{
"answer_id": 508305,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 0,
"selected": false,
"text": "<p>Works for me. Are you sure you don't have any control characters in that code somewhere?</p>\n"
},
{
"answer_id":... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59968/"
] | I have perl, v5.6.1 built for MSWin32-x86-multi-thread Binary build 638 provided by ActiveState.
I am working on a Perl script where I have declared constants that are used later for comparison purposes. For some reason, I am getting an error that states something along the line of Constant name has invalid character... | The problem is that you are using a hash reference. The version of `constant` provided by perl 5.6.1 does not support that. You'll either have to remove the braces or upgrade your `constant`. |
508,292 | <p>Just like <a href="https://stackoverflow.com/questions/235250/what-are-the-benefits-of-maintaining-a-clean-list-of-using-directives-in-c">Carl's question over here</a> I would like to ask you (because I couldn't find it out on my own :( ) if there is any benefit by removing an assembly reference that is not statical... | [
{
"answer_id": 508384,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>Removing unused assembly references wouldn't change anything apart from cleaning your projects. When you add asse... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1796/"
] | Just like [Carl's question over here](https://stackoverflow.com/questions/235250/what-are-the-benefits-of-maintaining-a-clean-list-of-using-directives-in-c) I would like to ask you (because I couldn't find it out on my own :( ) if there is any benefit by removing an assembly reference that is not statically nor dynamic... | Removing unused assembly references wouldn't change anything apart from cleaning your projects. When you add assembly references the compiler will ignore any assembly which you have not actually made use of in your code. Thus, if you were to set a reference to System.Data.dll and System.Windows.Forms.dll but only autho... |
508,293 | <p>Originaly posted a while back on a different forum, hope I can find a bit more help here :)</p>
<p>Hi Guys,</p>
<p>I'm sure this is a pretty basic question, but I'm new to much programming and C#. I find I need to clear databindings on several controls and currently have:</p>
<pre><code> lblTableValue1... | [
{
"answer_id": 508303,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 4,
"selected": true,
"text": "<pre><code>foreach(Control c in this.Controls)\n{\n if(c.Name.StartsWith(\"lblTableValue\"))\n {\n c.DataBin... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61999/"
] | Originaly posted a while back on a different forum, hope I can find a bit more help here :)
Hi Guys,
I'm sure this is a pretty basic question, but I'm new to much programming and C#. I find I need to clear databindings on several controls and currently have:
```
lblTableValue1.DataBindings.Clear();
... | ```
foreach(Control c in this.Controls)
{
if(c.Name.StartsWith("lblTableValue"))
{
c.DataBindings.Clear();
}
}
```
That might do the job. Or if you're more of a purist:
```
foreach(Control c in new Control[]
{
lblTableValue1,
lblTableValue2,
etc
})
{
c.DataBind... |
508,316 | <p>So, my application is being odd in the fact that when you login you will stay logged in for a page or two then get lost. My settings are this:</p>
<pre><code> <authentication mode="Forms">
<forms name=".ASPXFORMSAUTH" timeout="20"/>
</authentication>
<authorization>
<allow u... | [
{
"answer_id": 508547,
"author": "Scott Ivey",
"author_id": 36297,
"author_profile": "https://Stackoverflow.com/users/36297",
"pm_score": 2,
"selected": false,
"text": "<p>2 things stand out for me here. First is that you're allowing * users instead of ? users. * means anonymous, ? mea... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] | So, my application is being odd in the fact that when you login you will stay logged in for a page or two then get lost. My settings are this:
```
<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH" timeout="20"/>
</authentication>
<authorization>
<allow users="*" />
</authorization>
<membership... | 2 things stand out for me here. First is that you're allowing \* users instead of ? users. \* means anonymous, ? means authenticated. I'd change it to the following & see if that helps...
```
<authorization>
<allow users="?" />
<deny users="*" />
</authorization>
```
2nd thought would be that you'd want to add... |
508,321 | <p>I want to know whether the below is an acceptable use of the visitor pattern. I feel a little uncomfortable returning from an Accept() or Visit() call - is this an appropriate usage of this pattern and if not, why not?</p>
<p><strong>Note:</strong> Apologies for the long code sample, seems necessary to get across w... | [
{
"answer_id": 508411,
"author": "Pete Kirkham",
"author_id": 1527,
"author_profile": "https://Stackoverflow.com/users/1527",
"pm_score": 1,
"selected": false,
"text": "<p>It's fairly common. I don't know if you can do it in C#, but in Java it's normal to leave the Accept method generic,... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3394/"
] | I want to know whether the below is an acceptable use of the visitor pattern. I feel a little uncomfortable returning from an Accept() or Visit() call - is this an appropriate usage of this pattern and if not, why not?
**Note:** Apologies for the long code sample, seems necessary to get across what I'm doing as visito... | Well to me this feels like the implementation is a little bit on the fence.
Either have your Visit and Accept methods return void and track all the state in the Visitor object. Interrogate it at the end.
or ...
Have Visit and Accept return an in-progress state and accept an incoming in-progress state in a function... |
508,331 | <p>Is it possible to get rid of the <strong>eval</strong> statement below? The code below filters out all classes which are derived from type BaseClass. Afterwards those classes are instantiated and method 'hello' is called.</p>
<pre><code>module MySpace
class BaseClass
def hello; print "\nhello world"; end
e... | [
{
"answer_id": 508361,
"author": "Chuck",
"author_id": 50742,
"author_profile": "https://Stackoverflow.com/users/50742",
"pm_score": 3,
"selected": true,
"text": "<pre><code>c = MySpace.const_get(e)\n</code></pre>\n"
},
{
"answer_id": 508362,
"author": "Keltia",
"author_i... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/76172/"
] | Is it possible to get rid of the **eval** statement below? The code below filters out all classes which are derived from type BaseClass. Afterwards those classes are instantiated and method 'hello' is called.
```
module MySpace
class BaseClass
def hello; print "\nhello world"; end
end
class A<BaseClass
... | ```
c = MySpace.const_get(e)
``` |
508,345 | <p>I have a problem connecting to my MS Access DB 2007. Code:</p>
<pre><code>private void btnSave_Click(object sender, EventArgs e)
{
OleDbConnection Conn = new OleDbConnection();
try
{
string conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ Directory.GetCurrentDirector... | [
{
"answer_id": 508359,
"author": "Khadaji",
"author_id": 55520,
"author_profile": "https://Stackoverflow.com/users/55520",
"pm_score": 1,
"selected": false,
"text": "<p>ExecuteNonQuery will return an int indicating the number of rows affected. The first thing I would do is check the retu... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem connecting to my MS Access DB 2007. Code:
```
private void btnSave_Click(object sender, EventArgs e)
{
OleDbConnection Conn = new OleDbConnection();
try
{
string conn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="+ Directory.GetCurrentDirectory() +"\\dvd_ma... | ExecuteNonQuery will return an int indicating the number of rows affected. The first thing I would do is check the return. ExecuteNonQuery can execute and not affect any rows, that won't trigger the catch. |
508,356 | <p>Can anyone suggest a suitable way of figuring out a pieces allowable moves on a grid similar to the one in the image below.</p>
<p><img src="https://farm4.static.flickr.com/3534/3250436085_c91b07c7fd.jpg" alt="grid layout"></p>
<p>Assuming piece1 is at position a1 and piece2 is at position c3, how can I figure out... | [
{
"answer_id": 508401,
"author": "Dan Lew",
"author_id": 60261,
"author_profile": "https://Stackoverflow.com/users/60261",
"pm_score": 3,
"selected": true,
"text": "<p>Suppose piece p is at position x, y and can move n squares away to position x2, y2. This means that the sum of the abso... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60598/"
] | Can anyone suggest a suitable way of figuring out a pieces allowable moves on a grid similar to the one in the image below.

Assuming piece1 is at position a1 and piece2 is at position c3, how can I figure out which grid squares are allowab... | Suppose piece p is at position x, y and can move n squares away to position x2, y2. This means that the sum of the absolute differences between (x - x2) and (y - y2) can be no greater than n.
If you're going to show which squares can be moved to (rather than taking inputs x2 and y2), I think it'd be best to loop over ... |
508,386 | <p>i have a long running function¹:</p>
<pre><code>public string FindPasswordFromHash(String hash)
{
...
}
</code></pre>
<p>which is called like:</p>
<pre><code>private void Button1_Click(object sender, EventArgs e)
{
PasswordTextBox.Text = FindPasswordFromHash(HashTextBox.Text);
}
</code></pre>
<p>Now i wa... | [
{
"answer_id": 508419,
"author": "JFV",
"author_id": 1391,
"author_profile": "https://Stackoverflow.com/users/1391",
"pm_score": 2,
"selected": false,
"text": "<p>Your best bet for something like this is to use the <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.b... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] | i have a long running function¹:
```
public string FindPasswordFromHash(String hash)
{
...
}
```
which is called like:
```
private void Button1_Click(object sender, EventArgs e)
{
PasswordTextBox.Text = FindPasswordFromHash(HashTextBox.Text);
}
```
Now i want to convert it into the asynchronous BeginInvok... | You are handling the BeginInvoke() and EndInvoke() calls correctly. You just need to handle the fact that manipulating the GUI needs to be done on the GUI-thread.
Luckily the framework provides the [Control.Invoke()](http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx) method, which allows you to have code executed ... |
508,390 | <p>Does anyone know of an existing means of creating an XML hierarchy programatically from an XPath expression? </p>
<p>For example if I have an XML fragment such as:</p>
<pre><code><feed>
<entry>
<data></data>
<content></content>
</entry>
</feed>... | [
{
"answer_id": 509340,
"author": "xcud",
"author_id": 61396,
"author_profile": "https://Stackoverflow.com/users/61396",
"pm_score": 6,
"selected": false,
"text": "<p>In the example you present the only thing being created is the attribute ... </p>\n\n<pre><code>XmlElement element = (XmlE... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60835/"
] | Does anyone know of an existing means of creating an XML hierarchy programatically from an XPath expression?
For example if I have an XML fragment such as:
```
<feed>
<entry>
<data></data>
<content></content>
</entry>
</feed>
```
Given the XPath expression /feed/entry/content/@source I woul... | In the example you present the only thing being created is the attribute ...
```
XmlElement element = (XmlElement)doc.SelectSingleNode("/feed/entry/content");
if (element != null)
element.SetAttribute("source", "");
```
If what you really want is to be able to create the hierarchy where it doesn't exist then yo... |
508,428 | <p>I have an xml document object that I need to convert into a string.</p>
<p>Is there as simple way to do this?</p>
| [
{
"answer_id": 508445,
"author": "Todd R",
"author_id": 61592,
"author_profile": "https://Stackoverflow.com/users/61592",
"pm_score": 1,
"selected": false,
"text": "<p>You can use Dom4J:</p>\n\n<pre><code>OutputFormat format = OutputFormat.createPrettyPrint();\nXMLWriter writer = new XML... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59947/"
] | I have an xml document object that I need to convert into a string.
Is there as simple way to do this? | Here's some quick code I pulled out of a library I had nearby. Might wanna dress it up, but it works:
```
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
public String TransformDocumentToString(Document doc)
{
DOMSource dom = new DOMSource(doc... |
508,441 | <p>I've been trying to move a project over from Xcode to Linux (Ubuntu x86 for now, but hopefully the statically-linked executable will run on an x86 CentOS machine? I hope I hope?). I have the whole project compiling but it fails at the linking stage-- it's giving me undefined references for all functions defined by ... | [
{
"answer_id": 508445,
"author": "Todd R",
"author_id": 61592,
"author_profile": "https://Stackoverflow.com/users/61592",
"pm_score": 1,
"selected": false,
"text": "<p>You can use Dom4J:</p>\n\n<pre><code>OutputFormat format = OutputFormat.createPrettyPrint();\nXMLWriter writer = new XML... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62080/"
] | I've been trying to move a project over from Xcode to Linux (Ubuntu x86 for now, but hopefully the statically-linked executable will run on an x86 CentOS machine? I hope I hope?). I have the whole project compiling but it fails at the linking stage-- it's giving me undefined references for all functions defined by IPP.... | Here's some quick code I pulled out of a library I had nearby. Might wanna dress it up, but it works:
```
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
public String TransformDocumentToString(Document doc)
{
DOMSource dom = new DOMSource(doc... |
508,444 | <p>I have a database table with hundreds of thousands of forum posts, and I would like to find out what hour-long period contains the most number of posts.</p>
<p>I could crawl forward one minute at a time, keeping an array of timestamps and keeping track of what hour had the most in it, but I feel like there is a muc... | [
{
"answer_id": 508456,
"author": "Shane Delmore",
"author_id": 50031,
"author_profile": "https://Stackoverflow.com/users/50031",
"pm_score": 0,
"selected": false,
"text": "<pre>\nSELECT DATEPART(hour, PostDateTime) AS HourOfDay,\n COUNT(*) AS ForumPosts\nFROM Posts\nGROUP BY D... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62084/"
] | I have a database table with hundreds of thousands of forum posts, and I would like to find out what hour-long period contains the most number of posts.
I could crawl forward one minute at a time, keeping an array of timestamps and keeping track of what hour had the most in it, but I feel like there is a much better w... | Given a table filled with every minute in the year you are interested in `Minutes` and a table `Posts` with a `Time` column:
```
select top 1 minutes.time, count (posts.time)
from Minutes
left join posts on posts.time >= minutes.time AND posts.time < dateadd(hour, 1, Minutes.Time)
group by minutes.time
order by cou... |
508,448 | <p>I have some scientific image data that's coming out of a detector device in a 16 bit range which then gets rendered in an image. In order to display this data, I'm using OpenGL, because it should support ushorts as part of the library. I've managed to get this data into textures rendering on an OpenGL 1.4 platform... | [
{
"answer_id": 509243,
"author": "geofftnz",
"author_id": 20122,
"author_profile": "https://Stackoverflow.com/users/20122",
"pm_score": 0,
"selected": false,
"text": "<p>I've never worked in depths higher (deeper) than 8bit per channel, but here's what I'd try first:</p>\n\n<p>Turn off f... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21981/"
] | I have some scientific image data that's coming out of a detector device in a 16 bit range which then gets rendered in an image. In order to display this data, I'm using OpenGL, because it should support ushorts as part of the library. I've managed to get this data into textures rendering on an OpenGL 1.4 platform, a l... | If you create a texture the 'type' parameter of glTexImage is only the data type your texture data is in before it is converted by OpenGL into its own format. To create a texture with 16 bit per channel you need something like GL\_LUMINANCE16 as format (internal format remains GL\_LUMINANCE). If there's no GL\_LUMINANC... |
508,506 | <p>Even a 3rd party one will do.</p>
<p>Thanks</p>
| [
{
"answer_id": 508792,
"author": "Adrian",
"author_id": 55160,
"author_profile": "https://Stackoverflow.com/users/55160",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure how a <code>ComboBox</code> would display data in this fashion, as it is designed as a single-selection Con... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60477/"
] | Even a 3rd party one will do.
Thanks | There is no native multiselect combobox in WPF. Please check my blog for a simple hack using expression blend to achieve a multi selection on combobox.
<http://jobijoy.blogspot.com/2009/02/simple-multiselect-combobox-using.html>
The idea is to utilize the Multi-Selection feature of ListBox in to ComboBox by editing th... |
508,509 | <p>I'm trying write a query to find records which don't have a matching record in another table.</p>
<p>For example, I have a two tables whose structures looks something like this: </p>
<pre>
Table1
State | Product | Distributor | other fields
CA | P1 | A | xxxx
OR | P1 | A ... | [
{
"answer_id": 508521,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 6,
"selected": true,
"text": "<pre><code>SELECT\n *\nFROM\n Table2 T2\nWHERE\n NOT EXISTS (SELECT *\n FROM\n Table1 T1\n WHE... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1676/"
] | I'm trying write a query to find records which don't have a matching record in another table.
For example, I have a two tables whose structures looks something like this:
```
Table1
State | Product | Distributor | other fields
CA | P1 | A | xxxx
OR | P1 | A | xxxx
... | ```
SELECT
*
FROM
Table2 T2
WHERE
NOT EXISTS (SELECT *
FROM
Table1 T1
WHERE
T1.State = T2.State AND
T1.Product = T2.Product AND
T1.Distributor = 'X')
```
This should be ANSI compliant. |
508,511 | <p>I have 2 requirements:
1) All hidden input elements should be affected without removing standard decorators.
2) This should happen WITHOUT having to specify it on a per-element basis.</p>
<p>All I need is for a CSS class to be attached to the DT & DD tags IF the element type is Zend_Form_Element_Hidden.</p>
<p... | [
{
"answer_id": 508769,
"author": "waney",
"author_id": 58123,
"author_profile": "https://Stackoverflow.com/users/58123",
"pm_score": 0,
"selected": false,
"text": "<p>This will help you : \nYou may also specify any other attributes.</p>\n\n<pre><code>$el = $form->getElement('whatever'... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3407/"
] | I have 2 requirements:
1) All hidden input elements should be affected without removing standard decorators.
2) This should happen WITHOUT having to specify it on a per-element basis.
All I need is for a CSS class to be attached to the DT & DD tags IF the element type is Zend\_Form\_Element\_Hidden.
I've tried creati... | Based on your desired sample output I'm unclear why you would want to include the `<dt>` on hidden elements, especially since you're not applying any label, they end up becoming needless markup. Following the assumption that the label *is unnecessary*, you can achieve the desired effect with the following:
```
class T... |
508,529 | <pre><code> 'display the left product image
if intImagePos = 2 then
response.write("<td class=""ProductImage"">" & vbcrlf)
'show image
if Len(objProduct.Image2) > 0 then
response.write("<a class=""thumbnail"" href=""javascri... | [
{
"answer_id": 508743,
"author": "Andrew",
"author_id": 51534,
"author_profile": "https://Stackoverflow.com/users/51534",
"pm_score": 1,
"selected": false,
"text": "<p>This is just a guess, but I recall having a problem with window.open in ie where the winName variable had a space in it.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62090/"
] | ```
'display the left product image
if intImagePos = 2 then
response.write("<td class=""ProductImage"">" & vbcrlf)
'show image
if Len(objProduct.Image2) > 0 then
response.write("<a class=""thumbnail"" href=""javascript: void(0)"" onclick="... | Your call to MM\_openBrWindow() only has two parameters, but it takes three. Try changing it to this:
```
MM_openBrWindow('images/festool/KAPEXKS120-571287/KAPEXKS120-571287-Gallery/','putsomenamehere','scrollbars=no,resizable=no,width=840,height=580');
``` |
508,533 | <p>Im new to programming and I dont know very much about but I'm making a calculator, and i want to use a textbox that only acepts numbers and decimals, and when the user paste text from the clipboard the textbox deletes any literal characters, like the MS calc.</p>
<p>Please take the time to explain each part so I ca... | [
{
"answer_id": 508568,
"author": "Fredou",
"author_id": 40868,
"author_profile": "https://Stackoverflow.com/users/40868",
"pm_score": 0,
"selected": false,
"text": "<p>here how to do this in vb.net</p>\n\n<pre><code>Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e ... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62096/"
] | Im new to programming and I dont know very much about but I'm making a calculator, and i want to use a textbox that only acepts numbers and decimals, and when the user paste text from the clipboard the textbox deletes any literal characters, like the MS calc.
Please take the time to explain each part so I can learn or... | The easiest way :)
on Keypress event on your textbox
---
```
if ((e.KeyChar <= 57 && e.KeyChar >= 48) || e.KeyChar == 13 || e.KeyChar == 8)
{
}
else
{
e.Handled = true;
}
```
--- |
508,538 | <p>I have this code:</p>
<pre><code> $fp = fopen($unenc_path, "w");
fwrite($fp, $msg);
fclose($fp);
$easy_access_emails = 'person@##.com';
$headers = "From: support@##.com <support@##.com>\n" .
"Reply-to: support@##.com\n" .
"Subject: " . $subject . "\n";
$key = implode("",... | [
{
"answer_id": 508713,
"author": "Manuel",
"author_id": 1139600,
"author_profile": "https://Stackoverflow.com/users/1139600",
"pm_score": 1,
"selected": false,
"text": "<p>Are you loading the key in <code>$key</code> somewhere in your code? I can't see it on the snippet</p>\n"
},
{
... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1742702/"
] | I have this code:
```
$fp = fopen($unenc_path, "w");
fwrite($fp, $msg);
fclose($fp);
$easy_access_emails = 'person@##.com';
$headers = "From: support@##.com <support@##.com>\n" .
"Reply-to: support@##.com\n" .
"Subject: " . $subject . "\n";
$key = implode("", file("../newcert.pe... | Turned out Windows / `openssl_pkcs7_encrypt` didn't like that relative path, giving a full path after messing with forward and backslashes (`/. \\`) for a bit fixed it. |
508,565 | <p>In C#, I might do something like this:</p>
<pre><code>System.Net.WebClient w = new System.Net.WebClient();
w.Credentials = new System.Net.NetworkCredential(username, auth, domain);
string webpage = w.DownloadString(url);
</code></pre>
<p>Is there a Powershell version of this, or should I just call through to the <... | [
{
"answer_id": 509394,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 7,
"selected": true,
"text": "<p>The PowerShell is almost exactly the same.</p>\n\n<pre><code>$webclient = new-object System.Net.WebClient\n$webcli... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5453/"
] | In C#, I might do something like this:
```
System.Net.WebClient w = new System.Net.WebClient();
w.Credentials = new System.Net.NetworkCredential(username, auth, domain);
string webpage = w.DownloadString(url);
```
Is there a Powershell version of this, or should I just call through to the [CLR](https://stackoverflow... | The PowerShell is almost exactly the same.
```
$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($username, $password, $domain)
$webpage = $webclient.DownloadString($url)
``` |
508,571 | <p>We have an issue that occurs from time to time. We have a web server and an application server. Our application server houses our Business Logic code which is installed as COM+ Server and Library applications. We then put a proxy on the web server to force all calls from the web server to the COM+ Server. Almost... | [
{
"answer_id": 508597,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 0,
"selected": false,
"text": "<p>From what I can discern, the second message indicates that the remote procedure call failed meaning that the call to... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17822/"
] | We have an issue that occurs from time to time. We have a web server and an application server. Our application server houses our Business Logic code which is installed as COM+ Server and Library applications. We then put a proxy on the web server to force all calls from the web server to the COM+ Server. Almost 100% o... | There were timeouts happening with the hardware Web Server & Application Server & Firewall between them. The timeout for the firewall was less than that of the default timeout for the Application Server. All we had to do to solve the problem was to place the following registry key (it wasn't there to begin with) in the... |
508,614 | <p>I'm trying to create a new registry key in the windows registry using C++. Here is the code I have so far:</p>
<pre><code>HKEY hKey;
LPCTSTR sk = TEXT("SOFTWARE\\OtherTestSoftware");
LONG openRes = RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
sk,
0,
NULL,
... | [
{
"answer_id": 508654,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>The first clue is your use of <code>REG_OPTION_BACKUP_RESTORE</code>. You probably don't want to use that flag, as I b... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2170994/"
] | I'm trying to create a new registry key in the windows registry using C++. Here is the code I have so far:
```
HKEY hKey;
LPCTSTR sk = TEXT("SOFTWARE\\OtherTestSoftware");
LONG openRes = RegCreateKeyEx(
HKEY_LOCAL_MACHINE,
sk,
0,
NULL,
REG_OPTION_BAC... | I've been compiling my own personal Function Library for years. One part of this deals entirely with registry access, see the CreateRegistryKey function the [Registry.Cpp](https://github.com/NTDLS/NSWFL/blob/master/NSWFL_Registry.Cpp) file.
If you are interested, you can grab the [entire library here](https://github.c... |
508,627 | <p>I am using sqlite with python 2.5. I get a sqlite error with the syntax below. I looked around and saw AUTOINCREMENT on this page <a href="http://www.sqlite.org/syntaxdiagrams.html#column-constraint" rel="noreferrer">http://www.sqlite.org/syntaxdiagrams.html#column-constraint</a> but that did not work either. Withou... | [
{
"answer_id": 508664,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 6,
"selected": true,
"text": "<p>This is addressed in the <a href=\"http://www.sqlite.org/faq.html\" rel=\"noreferrer\">SQLite FAQ</a>. <a href=\"ht... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using sqlite with python 2.5. I get a sqlite error with the syntax below. I looked around and saw AUTOINCREMENT on this page <http://www.sqlite.org/syntaxdiagrams.html#column-constraint> but that did not work either. Without AUTO\_INCREMENT my table can be created.
```
An error occurred: near "AUTO_INCREMENT": sy... | This is addressed in the [SQLite FAQ](http://www.sqlite.org/faq.html). [Question #1](http://www.sqlite.org/faq.html#q1).
Which states:
>
> How do I create an AUTOINCREMENT
> field?
>
>
> Short answer: A column declared
> INTEGER PRIMARY KEY will
> autoincrement.
>
>
> Here is the long answer: If you
> declar... |
508,635 | <p>Trying to learn a bit of CSS and I want a horizontal navbar and I am using ul and li to build it. I would like all the 'buttons' to have the same width, is that possible with just CSS?</p>
<p>Thanks</p>
| [
{
"answer_id": 508656,
"author": "Ikke",
"author_id": 20261,
"author_profile": "https://Stackoverflow.com/users/20261",
"pm_score": 1,
"selected": false,
"text": "<p>Yup,</p>\n\n<pre><code>ul li\n{\n display: block;\n float: left;\n width: 100px;\n}\nul\n{\n padding: 0px;\n ... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51382/"
] | Trying to learn a bit of CSS and I want a horizontal navbar and I am using ul and li to build it. I would like all the 'buttons' to have the same width, is that possible with just CSS?
Thanks | Not exactly sure what you mean by same width. You just set it with pixels on the link? What are your constraints? do you know the list width? or the link width?
```
<style type="text/css">
.menu { margin:0px auto; padding:0px; list-style-type:none; }
.menu li { margin:0px auto; padding:0px; float:left; }
.... |
508,639 | <p>In a constructor in Java, if you want to call another constructor (or a super constructor), it has to be the first line in the constructor. I assume this is because you shouldn't be allowed to modify any instance variables before the other constructor runs. But why can't you have statements before the constructor ... | [
{
"answer_id": 508668,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>My <em>guess</em> is that, until a constructor has been called for every level of the heierarchy, the object is in an inval... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | In a constructor in Java, if you want to call another constructor (or a super constructor), it has to be the first line in the constructor. I assume this is because you shouldn't be allowed to modify any instance variables before the other constructor runs. But why can't you have statements before the constructor deleg... | >
> I find this pretty ugly, but it helps
> me avoid duplicating code. The
> following is what I'd like to do, but
> it is illegal in Java ...
>
>
>
You could also work around this limitation by using a static factory method that returns a new object:
```
public static BigFraction valueOf(BigDecimal d)
{
/... |
508,657 | <p>I have a little Java problem I want to translate to Python. Therefor I need a multidimensional array. In Java it looks like:</p>
<pre><code>double dArray[][][] = new double[x.length()+1][y.length()+1][x.length()+y.length()+3];
dArray[0][0][0] = 0;
dArray[0][0][1] = POSITIVE_INFINITY;
</code></pre>
<p>Further value... | [
{
"answer_id": 261008,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "<p>For numeric data, <a href=\"http://numpy.scipy.org/\" rel=\"nofollow noreferrer\">Numpy Arrays</a>:</p>\n\n<pre><code>>&... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56376/"
] | I have a little Java problem I want to translate to Python. Therefor I need a multidimensional array. In Java it looks like:
```
double dArray[][][] = new double[x.length()+1][y.length()+1][x.length()+y.length()+3];
dArray[0][0][0] = 0;
dArray[0][0][1] = POSITIVE_INFINITY;
```
Further values will be created bei loop... | You can create it using nested lists:
```
matrix = [[a,b],[c,d],[e,f]]
```
If it has to be dynamic it's more complicated, why not write a small class yourself?
```
class Matrix(object):
def __init__(self, rows, columns, default=0):
self.m = []
for i in range(rows):
self.m.append([def... |
508,661 | <p>I'm a bit new to WCF and I don't think I completely understand what the deal is with DataContracts. I have this 'RequestArray' class:</p>
<pre><code>[DataContract]
public class RequestArray
{
private int m_TotalRecords;
private RequestRecord[] m_Record;
[System.Xml.Serialization.XmlElement]
[DataMember]
... | [
{
"answer_id": 508722,
"author": "Mike_G",
"author_id": 52051,
"author_profile": "https://Stackoverflow.com/users/52051",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like you may be confusing server side and client side functionality. If you generated the client side classes vi... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23569/"
] | I'm a bit new to WCF and I don't think I completely understand what the deal is with DataContracts. I have this 'RequestArray' class:
```
[DataContract]
public class RequestArray
{
private int m_TotalRecords;
private RequestRecord[] m_Record;
[System.Xml.Serialization.XmlElement]
[DataMember]
public Request... | The premise that the client proxy will execute the same code on the client and on the server is flawed because WCF is based on interfaces. I explain this point in bullet #2 below.
Rules of Sharing WCF Interfaces & Implementation
------------------------------------------------
If you want to share the implementation... |
508,665 | <p>How is <code>parseInt()</code> different from <code>valueOf()</code> ? </p>
<p>They appear to do exactly the same thing to me (also goes for <code>parseFloat()</code>, <code>parseDouble()</code>, <code>parseLong()</code> etc, how are they different from <code>Long.valueOf(string)</code> ?</p>
<p>Also, which one of... | [
{
"answer_id": 508686,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 6,
"selected": false,
"text": "<p>From <a href=\"http://www.coderanch.com/t/378048/Java-General-intermediate/java/What-differece-bw-Parseint-ValueOf#1650... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | How is `parseInt()` different from `valueOf()` ?
They appear to do exactly the same thing to me (also goes for `parseFloat()`, `parseDouble()`, `parseLong()` etc, how are they different from `Long.valueOf(string)` ?
Also, which one of these is preferable and used more often by convention? | Well, the API for [`Integer.valueOf(String)`](http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#valueOf(java.lang.String)) does indeed say that the `String` is interpreted exactly as if it were given to [`Integer.parseInt(String)`](http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt(java.la... |
508,666 | <p>I have large data sets (10 Hz data, so 864k points per 24 Hours) which I need to plot in real time. The idea is the user can zoom and pan into highly detailed scatter plots.</p>
<p>The data is not very continuous and there are spikes. Since the data set is so large, I can't plot every point each time the plot ref... | [
{
"answer_id": 508694,
"author": "MatlabDoug",
"author_id": 46439,
"author_profile": "https://Stackoverflow.com/users/46439",
"pm_score": 4,
"selected": true,
"text": "<p>You should try the file from MATLAB Central:</p>\n\n<p><a href=\"https://mathworks.com/matlabcentral/fileexchange/158... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] | I have large data sets (10 Hz data, so 864k points per 24 Hours) which I need to plot in real time. The idea is the user can zoom and pan into highly detailed scatter plots.
The data is not very continuous and there are spikes. Since the data set is so large, I can't plot every point each time the plot refreshes.
But... | You should try the file from MATLAB Central:
<https://mathworks.com/matlabcentral/fileexchange/15850-dsplot-downsampled-plot>

**From the author:**
This version of "plot" will allow you to visualize data that... |
508,692 | <p>I have a legacy MySQL table called <code>lnk_lists_addresses</code> with columns <code>list_id</code> and <code>address_id</code>. I'd like to write a query that reports all the cases where the same <code>list_id</code>-<code>address_id</code> combination appears more than once in the table with a count.</p>
<p>I t... | [
{
"answer_id": 508705,
"author": "brendan",
"author_id": 225,
"author_profile": "https://Stackoverflow.com/users/225",
"pm_score": 4,
"selected": true,
"text": "<pre><code>SELECT count(*), list_id, address_id\nFROM lnk_lists_addresses\nGROUP BY list_id, address_id\nHAVING count(*)>1\n... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I have a legacy MySQL table called `lnk_lists_addresses` with columns `list_id` and `address_id`. I'd like to write a query that reports all the cases where the same `list_id`-`address_id` combination appears more than once in the table with a count.
I tried this...
```
SELECT count(*), list_id, address_id
FROM lnk_l... | ```
SELECT count(*), list_id, address_id
FROM lnk_lists_addresses
GROUP BY list_id, address_id
HAVING count(*)>1
ORDER BY count(*) DESC
```
To combine mine and Todd.Run's answers for a more "complete" answer. You want to use the HAVING clause:
<http://dev.mysql.com/doc/refman/5.1/en/select.html> |
508,696 | <p>I want to use a validator to ensure 2 password fields match in Flex. I want the validator to highlight form fields like a normal flex validation control. Thanks.</p>
| [
{
"answer_id": 508731,
"author": "Chetan S",
"author_id": 31284,
"author_profile": "https://Stackoverflow.com/users/31284",
"pm_score": 0,
"selected": false,
"text": "<p>Unless you <em>have</em> to use a validator, you can simply attach a change event handler and set <code>errorString</c... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | I want to use a validator to ensure 2 password fields match in Flex. I want the validator to highlight form fields like a normal flex validation control. Thanks. | `enter code here`I created my own custom validator (mostly copied from date validator):
```
package validators
{
import mx.validators.ValidationResult;
import mx.validators.Validator;
public class PasswordValidator extends Validator
{
// Define Array for the return value of doValidation().
... |
508,699 | <p>I want to both backup my Xampp directory and also transfer it to another computer.</p>
<p>Is there an easy way to do this?</p>
<p>When I try to copy it, it gives me a restriction, even though I am not running xampp at the time.</p>
<p>Thank you!</p>
| [
{
"answer_id": 508731,
"author": "Chetan S",
"author_id": 31284,
"author_profile": "https://Stackoverflow.com/users/31284",
"pm_score": 0,
"selected": false,
"text": "<p>Unless you <em>have</em> to use a validator, you can simply attach a change event handler and set <code>errorString</c... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40091/"
] | I want to both backup my Xampp directory and also transfer it to another computer.
Is there an easy way to do this?
When I try to copy it, it gives me a restriction, even though I am not running xampp at the time.
Thank you! | `enter code here`I created my own custom validator (mostly copied from date validator):
```
package validators
{
import mx.validators.ValidationResult;
import mx.validators.Validator;
public class PasswordValidator extends Validator
{
// Define Array for the return value of doValidation().
... |
508,707 | <p>WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find another way to say it. </p>
<p>I have a table of people and a table of links to photos and videos.
I join the people to the media, and of course a person can have more than one piece of media. </p>
<p>I am attempting to grab the first ... | [
{
"answer_id": 508732,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 3,
"selected": true,
"text": "<p>Can you use subqueries in your version of MySQL?</p>\n\n<blockquote>\n<pre><code>select *\nfrom media m\ninner join\n ... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48067/"
] | WOW! That's a weird title, but I'm happy you're looking, cause I couldn't find another way to say it.
I have a table of people and a table of links to photos and videos.
I join the people to the media, and of course a person can have more than one piece of media.
I am attempting to grab the first 30 people and all... | Can you use subqueries in your version of MySQL?
>
>
> ```
> select *
> from media m
> inner join
> ( select uid
> from users_tbl
> limit 0,30) map
> on map.uid = m.uid
> inner join users_tbl u
> on u.uid = m.uid
>
> ```
>
> |
508,723 | <p>I'm creating a Java application that will do some processing then needs to display a message to give the user feedback.</p>
<p>However, it appears to be incredibly slow - taking over two seconds to return.</p>
<p>I stripped the source down to the apparent culprit, and here is the code used:</p>
<pre><code>package... | [
{
"answer_id": 508729,
"author": "Stephane Grenier",
"author_id": 39371,
"author_profile": "https://Stackoverflow.com/users/39371",
"pm_score": 0,
"selected": false,
"text": "<p>What you're probably looking for is the <a href=\"http://java.sun.com/developer/technicalArticles/J2SE/Desktop... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9360/"
] | I'm creating a Java application that will do some processing then needs to display a message to give the user feedback.
However, it appears to be incredibly slow - taking over two seconds to return.
I stripped the source down to the apparent culprit, and here is the code used:
```
package SwingPlay;
import javax.sw... | The reason for the delay it because Java is an interpreted language and it takes time to start a new JVM ( the interpreter )
Actually creating the frame takes less than a few ms ( about 70 ms in my machine ).
If this is going to be used within a Java app, you don't need to worry about it. It will be almost instantane... |
508,727 | <p>I'm trying to convert a date string into an age.</p>
<p>The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.</p>
<p>I have sucessfully converted the date using:</p>
<pre><code>>>> time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200... | [
{
"answer_id": 508742,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 5,
"selected": true,
"text": "<p>You need to use the module <code>datetime</code> and the object <a href=\"http://docs.python.org/library/datetime.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32933/"
] | I'm trying to convert a date string into an age.
The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.
I have sucessfully converted the date using:
```
>>> time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200")
(2008, 11, 17, 1, 45, 32, 0, 322, ... | You need to use the module `datetime` and the object [`datetime.timedelta`](http://docs.python.org/library/datetime.html#datetime.timedelta)
```
from datetime import datetime
t1 = datetime.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200")
t2 = datetime.now()
tdelta = t2 - t1 # actually a date... |
508,735 | <p>C# has syntax for declaring and using properties. For example, one can declare a simple property, like this:</p>
<pre><code>public int Size { get; set; }
</code></pre>
<p>One can also put a bit of logic into the property, like this:</p>
<pre><code>public string SizeHex
{
get
{
return String.Format... | [
{
"answer_id": 508758,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 1,
"selected": false,
"text": "<p>Might be useful to add to Java, but it's probably not as high on the list as closures.</p>\n\n<p>Personally, I find tha... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58099/"
] | C# has syntax for declaring and using properties. For example, one can declare a simple property, like this:
```
public int Size { get; set; }
```
One can also put a bit of logic into the property, like this:
```
public string SizeHex
{
get
{
return String.Format("{0:X}", Size);
}
set
{
... | I think it's just Java's general philosophy towards things. Properties are somewhat "magical", and Java's philosophy is to keep the core language as simple as possible and avoid magic like the plague. This enables Java to be a *lingua franca* that can be understood by just about any programmer. It also makes it very ea... |
508,739 | <p>for example...</p>
<pre><code>ALTER PROCEDURE [dbo].[Reports_Dashboard_Get_Sav]
-- Add the parameters for the stored procedure here
@startDate datetime,
@endDate datetime,
@companyID int=null
set @days=datediff(m,@startdate,@enddate)
if (@days)=0
set @days=1
</code></pre>
<p>This is not my... | [
{
"answer_id": 508746,
"author": "Shawn",
"author_id": 26,
"author_profile": "https://Stackoverflow.com/users/26",
"pm_score": 1,
"selected": false,
"text": "<p>No. Not T-SQL at least...</p>\n"
},
{
"answer_id": 508754,
"author": "Soviut",
"author_id": 46914,
"author_... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18309/"
] | for example...
```
ALTER PROCEDURE [dbo].[Reports_Dashboard_Get_Sav]
-- Add the parameters for the stored procedure here
@startDate datetime,
@endDate datetime,
@companyID int=null
set @days=datediff(m,@startdate,@enddate)
if (@days)=0
set @days=1
```
This is not my code but if this is case ... | They can be, depending on your database's collation. When you install SQL Server and choose your default collation, you'll notice that there's a "case sensitivity" checkbox. Certain collations are case sensitive and will affect your queries (and stored procedures).
Worse still, many vendors don't test their products o... |
508,752 | <p>I've been playing with jquery and I've run myself into a time problem. I've got 3 time input select boxes, one for hours, one for minutes, and one for the Meridian. I need to convert this time into a 24 hour string format and then stick it into a hidden input.</p>
<pre><code>var time = "";
time += $("#EventCloseTim... | [
{
"answer_id": 508760,
"author": "TJ L",
"author_id": 12605,
"author_profile": "https://Stackoverflow.com/users/12605",
"pm_score": 1,
"selected": false,
"text": "<p>You should look into the native <a href=\"http://www.w3schools.com/jsref/jsref_obj_date.asp\" rel=\"nofollow noreferrer\">... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339/"
] | I've been playing with jquery and I've run myself into a time problem. I've got 3 time input select boxes, one for hours, one for minutes, and one for the Meridian. I need to convert this time into a 24 hour string format and then stick it into a hidden input.
```
var time = "";
time += $("#EventCloseTimeHour option:s... | Example of [tj111](https://stackoverflow.com/users/12605/) suggestion:
```
$("#ConditionValue").val(
(
new Date(
"01/01/2000 " +
$("#EventCloseTimeHour option:selected").text() +
$("#EventCloseTimeMin option:selected").text() + ":00" +
" " +
$("#... |
508,763 | <p>After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet Horizo... | [
{
"answer_id": 509222,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 2,
"selected": false,
"text": "<p>You mention that the Font properties support this so I did a little digging in reflector and found this interesting:</p>... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | After much searching on MSDN and other sources I have basically found that "some" Dependancy Properties do indeed support property value inheritance similar to WPF. However, as far as I can tell, there is no definitive list of which properties do, and which do not. I know Font properties, for example, do; yet Horizonta... | You mention that the Font properties support this so I did a little digging in reflector and found this interesting:
TextBlock
```
public static readonly DependencyProperty FontSizeProperty = DependencyProperty.RegisterCoreProperty(0x40003714, typeof(double));
```
Control
```
public static readonly DependencyPrope... |
508,779 | <p>I'm missing something (obvious?) about escaping my strings or spaces in the following Windows Server 2k3 batch command.</p>
<pre><code>FORFILES -m *.wsp -c "CMD /C C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^ -o^ addsolution^ -filename^ @FILE"
</code></pre>
<p>Result... | [
{
"answer_id": 508937,
"author": "Noel",
"author_id": 2637,
"author_profile": "https://Stackoverflow.com/users/2637",
"pm_score": 4,
"selected": true,
"text": "<p>The path needs to be quoted, and the quote must be escaped.</p>\n\n<pre><code>FORFILES -m *.wsp -c \"CMD /C ^0x22C:\\Program^... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2637/"
] | I'm missing something (obvious?) about escaping my strings or spaces in the following Windows Server 2k3 batch command.
```
FORFILES -m *.wsp -c "CMD /C C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^ -o^ addsolution^ -filename^ @FILE"
```
Results in the following error
... | The path needs to be quoted, and the quote must be escaped.
```
FORFILES -m *.wsp -c "CMD /C ^0x22C:\Program^ Files\Common^ Files\Microsoft^ Shared\web^ server^ extensions\12\bin\stsadm.exe^0x22 -o^ addsolution^ -filename^ @FILE"
```
A co-worker suggested using the hex for ", and I eventually figured out that the he... |
508,790 | <p>Is there some SSML tags etc, to remove a particular line of text from speaking. Yes, I know I can remove this using string functions, before sending it to the speech synthesizer. But my question is, is there any way to mark or tag some text, so that it won't play. I am looking for some XML based solution for this is... | [
{
"answer_id": 523151,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 1,
"selected": false,
"text": "<p>I'm wondering if XML commenting is a valid solution for what you're trying to accomplish:</p>\n\n<pre><code><!-... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61821/"
] | Is there some SSML tags etc, to remove a particular line of text from speaking. Yes, I know I can remove this using string functions, before sending it to the speech synthesizer. But my question is, is there any way to mark or tag some text, so that it won't play. I am looking for some XML based solution for this issue... | There are so many ways, you should clarify what you want to accomplish.
Maybe one of these will help you:
```
1. standard XML comment <!-- -->
2. <sub alias=" "> your text </sub>
3. <audio src='short_silence.wav'> your text </audio>
4. <prosody volume='silent'> your text </prosody>
``` |
508,791 | <p>Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a <code>TIMESTAMP</code> field, like: </p>
<pre><code>SELECT COUNT(id)
FROM stats
WHERE record_date.YEAR = 2009
GROUP BY record_date.YEAR
</code></pre>
<p>Or even:</p>
<pre><cod... | [
{
"answer_id": 508806,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 11,
"selected": true,
"text": "<pre><code>GROUP BY YEAR(record_date), MONTH(record_date)\n</code></pre>\n\n<p>Check out the <a href=\"http://dev.mysql.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a `TIMESTAMP` field, like:
```
SELECT COUNT(id)
FROM stats
WHERE record_date.YEAR = 2009
GROUP BY record_date.YEAR
```
Or even:
```
SELECT COUNT(id)
FROM stats
GROUP BY record_da... | ```
GROUP BY YEAR(record_date), MONTH(record_date)
```
Check out the [date and time functions](http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_month) in MySQL. |
508,802 | <p>We're considering switching our site from Prototype to jQuery. Being all-too-familiar with Prototype, I'm well aware of the things about Prototype that I find limiting or annoying. </p>
<p>My question for jQuery users is: After working with jQuery for a while, what do you find frustrating? Are there things about jQ... | [
{
"answer_id": 508813,
"author": "Svante Svenson",
"author_id": 19707,
"author_profile": "https://Stackoverflow.com/users/19707",
"pm_score": 2,
"selected": false,
"text": "<p>(The only thing I can think of is that this is the element instead of a jQuery object in <code>$(\"...\").each(f... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53166/"
] | We're considering switching our site from Prototype to jQuery. Being all-too-familiar with Prototype, I'm well aware of the things about Prototype that I find limiting or annoying.
My question for jQuery users is: After working with jQuery for a while, what do you find frustrating? Are there things about jQuery that ... | Probably the only real issue I've ever ran into is $(this) scope problems. For example, if you're doing a nested for loop over elements and sub elements using the built in JQuery .each() function, what does $(this) refer to? In that case it refers to the inner-most scope, as it should be, but its not always expected.
... |
508,817 | <p>I have a python client which pushes a great deal of data through the standard library's httlib. Users are complainging that the application is slow. I suspect that this may be partly due to the HTTP client I am using.</p>
<p>Could I improve performance by replacing httplib with something else? </p>
<p>I've seen th... | [
{
"answer_id": 508839,
"author": "Richard Levasseur",
"author_id": 36805,
"author_profile": "https://Stackoverflow.com/users/36805",
"pm_score": 1,
"selected": false,
"text": "<p>You seem to assume its the library. Its open source, so it would be worth checking the code to see if it is.... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] | I have a python client which pushes a great deal of data through the standard library's httlib. Users are complainging that the application is slow. I suspect that this may be partly due to the HTTP client I am using.
Could I improve performance by replacing httplib with something else?
I've seen that twisted offers... | Often when I've had performance problems with httplib, the problem hasn't been with the httplib itself, but with how I'm using it. Here are a few common pitfalls:
(1) Don't make a new TCP connection for every web request. If you are making lots of request to the same server, instead of this pattern:
```
conn = ... |
508,826 | <p>I'm dynamically adding a custom user control to the page as per <a href="https://stackoverflow.com/questions/213429/programmatically-adding-user-controls-inside-an-updatepanel">this post</a>. </p>
<p>However, i need to set a property on the user control as i add it to the page. How do I do that? </p>
<p>Code snipp... | [
{
"answer_id": 508868,
"author": "Jim Petkus",
"author_id": 38053,
"author_profile": "https://Stackoverflow.com/users/38053",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, you just cast the control to the proper type. EX:</p>\n\n<pre><code>((MyControl)control).MyProperty = \"blah\";... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3661/"
] | I'm dynamically adding a custom user control to the page as per [this post](https://stackoverflow.com/questions/213429/programmatically-adding-user-controls-inside-an-updatepanel).
However, i need to set a property on the user control as i add it to the page. How do I do that?
Code snippet would be nice :)
Details... | Ah, I answered before you added the additional clarification. The short answer is, yes, just cast it as your custom type.
I'll leave the rest of my answer here for reference, though it doesn't appear you'll need it.
---
Borrowing from the code in the other question, and assuming that all your User Controls can be ma... |
508,853 | <p>I am wondering what it would take to make something like this work:</p>
<pre><code>using System;
class Program
{
static void Main()
{
var f = new IFoo {
Foo = "foo",
Print = () => Console.WriteLine(Foo)
};
}
}
interface IFoo
{
String ... | [
{
"answer_id": 508884,
"author": "David Morton",
"author_id": 45916,
"author_profile": "https://Stackoverflow.com/users/45916",
"pm_score": -1,
"selected": false,
"text": "<p>This wouldn't be possible currently. </p>\n\n<p>What would be the difference between this and simply making IFoo... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34211/"
] | I am wondering what it would take to make something like this work:
```
using System;
class Program
{
static void Main()
{
var f = new IFoo {
Foo = "foo",
Print = () => Console.WriteLine(Foo)
};
}
}
interface IFoo
{
String Foo { get; set; }... | There would be a few issues with overloaded members, indexers, and explicit interface implementations.
However, you could probably define the syntax in a way that allows you to resolve those problems.
Interestingly, you can get pretty close to what you want with C# 3.0 by writing a library. Basically, you could do th... |
508,878 | <p>Followup question to <a href="https://stackoverflow.com/questions/504689/big-xml-file/504795">Big XML File</a>:</p>
<p>First thanks a lot for yours answers.
After… what I do wrong?
This is my class which uses SAX: </p>
<pre><code>public class SAXParserXML extends DefaultHandler {
public static void ParcourXML() ... | [
{
"answer_id": 508953,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 3,
"selected": false,
"text": "<p>There's a <a href=\"http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6536111\" rel=\"nofollow noreferrer\">bug</a... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61652/"
] | Followup question to [Big XML File](https://stackoverflow.com/questions/504689/big-xml-file/504795):
First thanks a lot for yours answers.
After… what I do wrong?
This is my class which uses SAX:
```
public class SAXParserXML extends DefaultHandler {
public static void ParcourXML() {
DefaultHandler handler ... | There's a [bug](http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6536111) for Java 1.6 which shows the exact same stack trace, and it's unfixed as of now. Newer Xerces versions seem to be fine.
For documents this large, which still contain a fair amount of structure, you could think about using pull-parsing, i.e. p... |
508,892 | <p>I have an environment where multiple sites hosted on the same server will use a single service to make its calls. For example:</p>
<p><a href="http://domain1.com/Api/Service.svc" rel="noreferrer">http://domain1.com/Api/Service.svc</a></p>
<p><a href="http://domain2.com/Api/Service.svc" rel="noreferrer">http://dom... | [
{
"answer_id": 508900,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>IIRC, you <em>can</em> have different prefixes - but only one per protocol - so you could have a tcp prefix, and p... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43250/"
] | I have an environment where multiple sites hosted on the same server will use a single service to make its calls. For example:
<http://domain1.com/Api/Service.svc>
<http://domain2.com/Api/Service.svc>
The Api application has been setup as a virtual directory in each site mapped to the same physical directory, so tha... | Ok, putting the whole URL in the endpoint address was something I hadn't thought of, so that's getting me somewhere. After using the custom ServiceHostFactory, that worked for domain1, but not for domain2. I got a new error message I haven't seen before:
"No protocol binding matches the given address '<http://domain2.... |
508,901 | <p>I have an assignment in a language-independent class, and part of it is using templated functions like
<pre><code>
T functionName(T &param1[], T &param2[]){
// do stuff
}
</code></pre></p>
<p>I would like to write this program in C#, but I've ran into a problem.</p>
<p>How can I mak... | [
{
"answer_id": 508906,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 3,
"selected": true,
"text": "<p>If you intended param2 to be <code>List<U></code></p>\n\n<pre><code>T functionName<T,U>(ref List<T>... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an assignment in a language-independent class, and part of it is using templated functions like
```
T functionName(T ¶m1[], T ¶m2[]){
// do stuff
}
```
I would like to write this program in C#, but I've ran into a problem.
How can I make this work in C#:
```
<pre><code>
T functionNa... | If you intended param2 to be `List<U>`
```
T functionName<T,U>(ref List<T> param1, ref List<U> param2)
```
Otherwise:
```
T functionName<T>(ref List<T> param1, ref List<T> param2)
``` |
508,911 | <p>There gotta be an easy way to do this, I can't believe there's none. I have scanned through net and found, like, 20 different methods to find in which domain current user is, but none to get domain (or workgroup) of current machine.</p>
<p>In unmanaged c++ this is retrieved by:</p>
<pre><code>WKSTA_INFO_100 *buf;
... | [
{
"answer_id": 508929,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 3,
"selected": false,
"text": "<p>System.Environment.UserDomainName</p>\n"
},
{
"answer_id": 508967,
"author": "tvanfosson",
"author_id"... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14395/"
] | There gotta be an easy way to do this, I can't believe there's none. I have scanned through net and found, like, 20 different methods to find in which domain current user is, but none to get domain (or workgroup) of current machine.
In unmanaged c++ this is retrieved by:
```
WKSTA_INFO_100 *buf;
NetWkstaGetInfo(NULL,... | To get the current domain of the system on which your progam is running you can use
[System.DirectoryServices.ActiveDirectory.Domain](http://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectory.domain.aspx).
```
Domain domain = Domain.GetComputerDomain();
Console.WriteLine( domain.Name );
``` |
508,938 | <p>Is there anyway to verify if a Session has been disposed of by NHibernate?</p>
<p>I have a wrapper class on Session that has it's own Finalizer and IDispoable implementation however if the Session gets disposed before I handle it myself in my class I end up receiving an ObjectDisposedException.</p>
<p>I really don... | [
{
"answer_id": 509166,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 0,
"selected": false,
"text": "<p>I always thought best practice with NHibernate was \"session per request\" meaning that it should only live inside th... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37055/"
] | Is there anyway to verify if a Session has been disposed of by NHibernate?
I have a wrapper class on Session that has it's own Finalizer and IDispoable implementation however if the Session gets disposed before I handle it myself in my class I end up receiving an ObjectDisposedException.
I really don't wish to wrap m... | Ok, just taked a peek at your code.
I don't know if this is exactly the issue, but you are calling End() from the conversation dispose method,
which in turn tries to reconnect and disposes the session..
if you have eplicitly called End() before this you will get what you get, avoid that call.
I think you shouldn't worr... |
508,950 | <p>We have an existing publicly accessible web application with user controls, data access libraries, graphics, etc. We want to create a new secure section of the site that accesses some of the already existing resources.</p>
<p>Initially we created the new section of the site as a virtual directory which (we hoped) w... | [
{
"answer_id": 508979,
"author": "JoshBerke",
"author_id": 26160,
"author_profile": "https://Stackoverflow.com/users/26160",
"pm_score": 4,
"selected": true,
"text": "<p>In your web.config file in the root of your site, if you add:</p>\n\n<pre><code><location path=\"relativePathToDir\... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29453/"
] | We have an existing publicly accessible web application with user controls, data access libraries, graphics, etc. We want to create a new secure section of the site that accesses some of the already existing resources.
Initially we created the new section of the site as a virtual directory which (we hoped) would allow... | In your web.config file in the root of your site, if you add:
```
<location path="relativePathToDir">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
```
This is working for me using FormsAuthentication, the user ge... |
508,959 | <p>I have heard mixed responses on this topic, so what is a sure fire way to destroy a PHP session? </p>
<pre><code>session_start();
if(isset($_SESSION['foo'])) {
unset($_SESSION['foo'];
...
}
session_destroy();
</code></pre>
<p>In the most simple of cases, would this sufficient to truly terminate the session ... | [
{
"answer_id": 508966,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 0,
"selected": false,
"text": "<p>In the one site I've made where I did use PHP sessions, I never actually destroy the session.</p>\n\n<p>The problem is th... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59975/"
] | I have heard mixed responses on this topic, so what is a sure fire way to destroy a PHP session?
```
session_start();
if(isset($_SESSION['foo'])) {
unset($_SESSION['foo'];
...
}
session_destroy();
```
In the most simple of cases, would this sufficient to truly terminate the session between the user and the se... | To destroy a session you should take the following steps:
* delete the session data
* invalidate the session ID
To do this, I’d use this:
```
session_start();
// resets the session data for the rest of the runtime
$_SESSION = array();
// sends as Set-Cookie to invalidate the session cookie
if (isset($_COOKIE[session... |
508,960 | <p>The Google App Engine Datastore querying language (gql) does not offer inexact operators like "LIKE" or even case insensitivity. One can get around the case sensitive issue by storing a lower-case version of a field. But what if I want to search for a person but I'm not sure of the spelling of the name? Is there ... | [
{
"answer_id": 509636,
"author": "Sam",
"author_id": 37575,
"author_profile": "https://Stackoverflow.com/users/37575",
"pm_score": 4,
"selected": true,
"text": "<p>Quoting from the documentation:</p>\n\n<p>Tip: Query filters do not have an explicit way to match just part of a string valu... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55944/"
] | The Google App Engine Datastore querying language (gql) does not offer inexact operators like "LIKE" or even case insensitivity. One can get around the case sensitive issue by storing a lower-case version of a field. But what if I want to search for a person but I'm not sure of the spelling of the name? Is there an acc... | Quoting from the documentation:
Tip: Query filters do not have an explicit way to match just part of a string value, but you can fake a prefix match using inequality filters:
```
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2", "abc", u"abc" + u"\ufffd")
```
This matches every MyModel entity with... |
508,965 | <p>This is a little out there but I have a customer object coming back to my controller. I want to just reconnect this object back to the database, is it even possible? I know there is a datacontext.customers.insertonsubmit(customer), but is there the equivalent datacontext.customers.updateonsubmit(customer)???</p>
| [
{
"answer_id": 508999,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": true,
"text": "<p>You want to use the attach method on the customers table on the data context.</p>\n\n<pre><code>datacontext.customers... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61962/"
] | This is a little out there but I have a customer object coming back to my controller. I want to just reconnect this object back to the database, is it even possible? I know there is a datacontext.customers.insertonsubmit(customer), but is there the equivalent datacontext.customers.updateonsubmit(customer)??? | You want to use the attach method on the customers table on the data context.
```
datacontext.customers.Attach(customer);
```
to reconnect it to the data context. Then you can use `SubmitChanges()` to update the values in the database.
**EDIT**: This only works with entities that have been detached from the origina... |
508,983 | <p>I'd like to be able to overwrite some bytes at a given offset in a file using Python.</p>
<p>My attempts have failed miserably and resulted in:</p>
<ul>
<li>overwriting the bytes at the offset but also truncating the file just after (file mode = "w" or "w+") </li>
<li>appending the bytes at the end of the file (f... | [
{
"answer_id": 509010,
"author": "tomjen",
"author_id": 21133,
"author_profile": "https://Stackoverflow.com/users/21133",
"pm_score": 3,
"selected": false,
"text": "<p>According to <a href=\"http://www.sthurlow.com/python/lesson10/\" rel=\"noreferrer\">this python page</a> you can type f... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62142/"
] | I'd like to be able to overwrite some bytes at a given offset in a file using Python.
My attempts have failed miserably and resulted in:
* overwriting the bytes at the offset but also truncating the file just after (file mode = "w" or "w+")
* appending the bytes at the end of the file (file mode = "a" or "a+")
Is it... | Try this:
```
fh = open("filename.ext", "r+b")
fh.seek(offset)
fh.write(bytes)
fh.close()
``` |
508,994 | <p>I've a simple asp.net page (framework 3.5) and an UpdatePanel with a series of dropdownlist I want to populate asyncronously. All works fine in all major browsers (Opera, Safari, IE6, IE7, FF3), but not in Chrome.</p>
<p>Chrome seems to ignore the SelectedIndexChanged event who had to make the asynch request.</p>
... | [
{
"answer_id": 509553,
"author": "Adam Lassek",
"author_id": 1249,
"author_profile": "https://Stackoverflow.com/users/1249",
"pm_score": 2,
"selected": false,
"text": "<p>This happens because MicrosoftAjax.js does browser detection, and it's incorrectly detecting Chrome as Safari. In ord... | 2009/02/03 | [
"https://Stackoverflow.com/questions/508994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51295/"
] | I've a simple asp.net page (framework 3.5) and an UpdatePanel with a series of dropdownlist I want to populate asyncronously. All works fine in all major browsers (Opera, Safari, IE6, IE7, FF3), but not in Chrome.
Chrome seems to ignore the SelectedIndexChanged event who had to make the asynch request.
Anyone knows a... | There is a known incompatibility with **Ajax.NET** and **Chrome** & **Safari 3**.
Small, quick tests can be deceptive because it will appear to work fine with the existing Ajax.NET library as is. This is because it manages to perform the **first** Ajax request and fails when that ends, so only when you try to perform ... |
509,007 | <p>I've set up an AJAX page refresh with <strong>setInterval</strong>.
From time to time, the server is so slow that a new request is initiated before the previous one has completed.</p>
<p>How can I prevent that?</p>
| [
{
"answer_id": 509035,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<p>Use a timeout value that is shorter than your refresh interval. When the request times out, it will call the error h... | 2009/02/03 | [
"https://Stackoverflow.com/questions/509007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1011/"
] | I've set up an AJAX page refresh with **setInterval**.
From time to time, the server is so slow that a new request is initiated before the previous one has completed.
How can I prevent that? | Use a timeout value that is shorter than your refresh interval. When the request times out, it will call the error handler so you'll need to differentiate between time out errors and other types of errors in the handler.
```
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
timeou... |
509,022 | <p>Is there a way to turn off multithreading or limit the number of cores used by an F# app? I'm aware this wouldn't be done in a production environment but I'm curious if I have to actually install the application on a single cored system in order to see how it would perform.</p>
| [
{
"answer_id": 509065,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 0,
"selected": false,
"text": "<p>You can set the process affinity through <a href=\"http://support.microsoft.com/default.aspx/kb/296930\" rel=\"nof... | 2009/02/03 | [
"https://Stackoverflow.com/questions/509022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52551/"
] | Is there a way to turn off multithreading or limit the number of cores used by an F# app? I'm aware this wouldn't be done in a production environment but I'm curious if I have to actually install the application on a single cored system in order to see how it would perform. | You can simply set this at the beginning of your application by setting the value for the current process's ProcessorAffinity:
```
System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity <- nativeint 1
```
This would effectively limit the cores used for the process to the first CPU on the system. |
509,033 | <p>I have a image in the shape of a Circle.</p>
<p>The circle is broken into 3 equal parts.</p>
<p>I have an image with the entire circle.</p>
<p>I have 3 other images, each only a piece of the circle but in the color green.</p>
<p>I have to do the following:</p>
<ol>
<li><p>Display the original circle image.</p><... | [
{
"answer_id": 509041,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 1,
"selected": false,
"text": "<p>The 3 images with partial circles should be transparent for the parts that are not green. Then all 4 images can be overl... | 2009/02/03 | [
"https://Stackoverflow.com/questions/509033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | I have a image in the shape of a Circle.
The circle is broken into 3 equal parts.
I have an image with the entire circle.
I have 3 other images, each only a piece of the circle but in the color green.
I have to do the following:
1. Display the original circle image.
2. Have a 3 buttons on the screen, each button i... | Here's a solution shown in straight JavaScript and also jQuery.
The straight JavaScript uses the DOM0 onclick handlers of the buttons which is OK because they're only triggering one event. The onload handler for the window is more of a problem: you can only have one per document.
The [jQuery](http://jquery.com/) ... |
509,042 | <pre><code>public class ExampleClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
Horse hr1 = new Horse();
Horse hr2 = new Horse();
Horse hr3 = new Horse();
Horse hr4 = new Horse();
Set hrSet = new HashSet();
hrSet.add(hr1);
... | [
{
"answer_id": 509070,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 1,
"selected": false,
"text": "<p>You might want to take a look at generics.</p>\n\n<pre><code>public static void callHorse(Set<Horse> xSet) {\n I... | 2009/02/03 | [
"https://Stackoverflow.com/questions/509042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62144/"
] | ```
public class ExampleClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
Horse hr1 = new Horse();
Horse hr2 = new Horse();
Horse hr3 = new Horse();
Horse hr4 = new Horse();
Set hrSet = new HashSet();
hrSet.add(hr1);
h... | Note: Code with sequences of "`if (x instanceof MyClass)` usually indicates that you are not using polymorphism enough. Code can usually be refactored to get rid of the need to test this. But I'll ignore this for the sake of answering the question asked.
You can do what you are trying to do, but not without some code ... |
509,045 | <p>I have the following code:</p>
<pre><code> Guid id = imageMetaData.ID;
Data.LinqToSQL.Image dbImage = DBContext.Images.Where(x => x.ID == id).SingleOrDefault();
dbImage.width = imageMetaData.Width;
dbImage.height = imageMetaData.Height;
DBContext.SubmitChanges();
</code>... | [
{
"answer_id": 509127,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 6,
"selected": true,
"text": "<p>Check to make sure your model matches the DB. I've run across this if they are out of sync, in most cases the null... | 2009/02/03 | [
"https://Stackoverflow.com/questions/509045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] | I have the following code:
```
Guid id = imageMetaData.ID;
Data.LinqToSQL.Image dbImage = DBContext.Images.Where(x => x.ID == id).SingleOrDefault();
dbImage.width = imageMetaData.Width;
dbImage.height = imageMetaData.Height;
DBContext.SubmitChanges();
```
Looking at SQL Pro... | Check to make sure your model matches the DB. I've run across this if they are out of sync, in most cases the nullable flag. Check out this [article](http://weblogs.asp.net/okloeten/archive/2008/04/28/6139181.aspx) for a possible cause.
I assume you are using the release version of .net 3.5 (Visual Studio 2008). |