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 |
|---|---|---|---|---|---|---|
533,808 | <p>I'm trying to build up some skills in lexing/parsing grammars. I'm looking back on a simple parser I wrote for SQL, and I'm not altogether happy with it -- it seems like there should have been an easier way to write the parser.</p>
<p>SQL tripped me up because it has a lot of optional tokens and repetition. For exa... | [
{
"answer_id": 533840,
"author": "Bob Nadler",
"author_id": 2514,
"author_profile": "https://Stackoverflow.com/users/2514",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.StaticLogFileName.htm... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40516/"
] | I'm trying to build up some skills in lexing/parsing grammars. I'm looking back on a simple parser I wrote for SQL, and I'm not altogether happy with it -- it seems like there should have been an easier way to write the parser.
SQL tripped me up because it has a lot of optional tokens and repetition. For example:
```... | Add the following to your config file
```xml
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="c:\\ProjectX\\Log\\log.txt"/>
<param name="AppendToFile" value="true"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<param name="RollingS... |
533,817 | <p>Using JQuery 1.2.6, testing from Firefox 3 and IE7. I have a very basic bit of JavaScript to reload a captcha image. In my JS file, I have:</p>
<pre><code>var Captcha = {
count: 0,
Refresh: function(){
// Concatenate "count" to force a URL change, which forces the browser to reload the image
... | [
{
"answer_id": 533830,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 3,
"selected": false,
"text": "<p>Try sepperating the HTML and javascript:</p>\n\n<pre><code>$('#ChangeCaptcha').click(Captcha.Refresh);\n</code></pre>... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17803/"
] | Using JQuery 1.2.6, testing from Firefox 3 and IE7. I have a very basic bit of JavaScript to reload a captcha image. In my JS file, I have:
```
var Captcha = {
count: 0,
Refresh: function(){
// Concatenate "count" to force a URL change, which forces the browser to reload the image
$('#Captcha'... | The problem arises because you have an element with an id of `Captcha`, and a global variable with the same name. IE traditionally introduces a global variable for every id attribute. FF doesn't... but pretends it does in certain situations for compatibility with IE. In this case, the `click` handler sees Captcha as an... |
533,837 | <p>I want to use a for-each and a counter:</p>
<pre><code>i=0
for blah in blahs
puts i.to_s + " " + blah
i+=1
end
</code></pre>
<p>Is there a better way to do it?</p>
<p><strong>Note:</strong> I don't know if <code>blahs</code> is an array or a hash, but having to do <code>blahs[i]</code> wouldn't make it mu... | [
{
"answer_id": 533859,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, it's <code>collection.each</code> to do loops, and then <code>each_with_index</code> to get the index. </p>\n\n<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | I want to use a for-each and a counter:
```
i=0
for blah in blahs
puts i.to_s + " " + blah
i+=1
end
```
Is there a better way to do it?
**Note:** I don't know if `blahs` is an array or a hash, but having to do `blahs[i]` wouldn't make it much sexier. Also I'd like to know how to write `i++` in Ruby.
---
T... | As people have said, you can use
```
each_with_index
```
but if you want indices with an iterator different to "each" (for example, if you want to map with an index or something like that) you can concatenate enumerators with the each\_with\_index method, or simply use with\_index:
```
blahs.each_with_index.map { ... |
533,856 | <p>I have a table with a FooId and a CreatedTime column. During the day, multiple rows can be inserted for the same FooId. The CreatedTime column represent the time at the moment of the inserting. </p>
<p>I would like a query which will return me the latest row for a given day (e.g. 2000-01-01). Is there a way to writ... | [
{
"answer_id": 533869,
"author": "jdelator",
"author_id": 438,
"author_profile": "https://Stackoverflow.com/users/438",
"pm_score": 0,
"selected": false,
"text": "<p>You might want to have a computed column or another column that just stores the date. After this the query will be trivial... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42024/"
] | I have a table with a FooId and a CreatedTime column. During the day, multiple rows can be inserted for the same FooId. The CreatedTime column represent the time at the moment of the inserting.
I would like a query which will return me the latest row for a given day (e.g. 2000-01-01). Is there a way to write a query ... | of course it will work with MAX
since you didn't provide DDL and DML statements I used something I had laying around
run this
```
CREATE TABLE #MaxVal(id INT,VALUE varchar(10),SomeDate DATETIME)
INSERT #MaxVal VALUES(1,'a','2009-02-10 14:48:45.143')
INSERT #MaxVal VALUES(1,'b','2009-02-10 13:48:45.143')
... |
533,867 | <p>Suppose I have an ASP.NET application running across several web servers behind a load balancer:</p>
<p>Can I:</p>
<ul>
<li><p>Force OutputCache (Page and/or Control level) to expire globally?</p></li>
<li><p>Force Data Cache (i.e. Cache.Insert) to expire?</p></li>
<li><p>Monitor ASP.NET caching usage (keys, RAM, ... | [
{
"answer_id": 534296,
"author": "simplyharsh",
"author_id": 63841,
"author_profile": "https://Stackoverflow.com/users/63841",
"pm_score": 4,
"selected": true,
"text": "<p>There are many ways to make these caching expire, like page outputcache by</p>\n\n<pre><code>Page.Response.Cache.Set... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52529/"
] | Suppose I have an ASP.NET application running across several web servers behind a load balancer:
Can I:
* Force OutputCache (Page and/or Control level) to expire globally?
* Force Data Cache (i.e. Cache.Insert) to expire?
* Monitor ASP.NET caching usage (keys, RAM, etc) from a central location?
One possible solution... | There are many ways to make these caching expire, like page outputcache by
```
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)
```
Time-based dependency simply expires the item at a defined point in time.
```
Response.Cache.SetExpires(DateTime.Now.AddSeconds(360));
Response.Cache.SetCacheability(HttpC... |
533,881 | <p>I have a list of files, and i need to read them each in a specific order into byte[] of a given size. This in itself is not a problem for a single file, a simple <em>while ((got = fs.Read(piece, 0, pieceLength)) > 0)</em> gets the job done perfectly fine. The last piece of the file may be smaller than desired, which... | [
{
"answer_id": 533907,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>I don't believe there's anything in the framework, but I'd suggest making it a bit more flexible - take an <code>IEnum... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91/"
] | I have a list of files, and i need to read them each in a specific order into byte[] of a given size. This in itself is not a problem for a single file, a simple *while ((got = fs.Read(piece, 0, pieceLength)) > 0)* gets the job done perfectly fine. The last piece of the file may be smaller than desired, which is fine.
... | I don't believe there's anything in the framework, but I'd suggest making it a bit more flexible - take an `IEnumerable<Stream>` in your constructor, and derive from `Stream` yourself. Then to get file streams you can (assuming C# 3.0) just do:
```
Stream combined = new CombinationStream(files.Select(file => File.Open... |
533,901 | <p>I'm running into a performance problem in my SQL using Hibernate's DetachedCriteria. I have a few many-to-one relationships and when Hibernate generates the SQL it's including all of the fields from the tables that are joined in the FROM.
When this happens, it's taking MySQL a long time to run the query (which also ... | [
{
"answer_id": 534347,
"author": "Matt Sidesinger",
"author_id": 1481472,
"author_profile": "https://Stackoverflow.com/users/1481472",
"pm_score": 4,
"selected": true,
"text": "<p>You can set a Projection that contains a list of only the properties that you are interested in.</p>\n\n<p>H... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42226/"
] | I'm running into a performance problem in my SQL using Hibernate's DetachedCriteria. I have a few many-to-one relationships and when Hibernate generates the SQL it's including all of the fields from the tables that are joined in the FROM.
When this happens, it's taking MySQL a long time to run the query (which also has... | You can set a Projection that contains a list of only the properties that you are interested in.
Here is an example from a past project:
```
Criteria criteria = getSession().createCriteria(Something.class);
criteria.createCriteria("user", "u");
// only retrieve the following fields: id, state, viewCount, user.userna... |
533,902 | <p>We are currently in the process of migrating from Server 2003 to Server 2008. We have a few different environment changes for our ASP.NET application. Our Test Environment is working perfectly at this time, but the production machine with same code is injecting Invalid Characters into the SQL. </p>
<p>The follow... | [
{
"answer_id": 535156,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>CreatedB\\u0903\\u3408 [1] \\uffff</p>\n</blockquote>\n\n<p>That's not really Unicode... U+FFFF i... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64728/"
] | We are currently in the process of migrating from Server 2003 to Server 2008. We have a few different environment changes for our ASP.NET application. Our Test Environment is working perfectly at this time, but the production machine with same code is injecting Invalid Characters into the SQL.
The following is the SQ... | The issue ended up being a network card driver. The physical machine was the issue not configuration or code.
EDIT: The machine I was having issues with is a HP DL360 with Broadcom Network Cards. We will be contacting HP regarding the issue. The packets were being assembled wrong when sending the LINQ request across ... |
533,905 | <p>How can I get the Cartesian product (every possible combination of values) from a group of lists?</p>
<p>Input:</p>
<pre><code>somelists = [
[1, 2, 3],
['a', 'b'],
[4, 5]
]
</code></pre>
<p>Desired output:</p>
<pre><code>[(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2, 'a', 5), ...]
</c... | [
{
"answer_id": 533917,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 10,
"selected": true,
"text": "<p>Use <a href=\"https://docs.python.org/3/library/itertools.html#itertools.product\" rel=\"nofollow noreferrer\"><cod... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | How can I get the Cartesian product (every possible combination of values) from a group of lists?
Input:
```
somelists = [
[1, 2, 3],
['a', 'b'],
[4, 5]
]
```
Desired output:
```
[(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2, 'a', 5), ...]
```
---
One common application for this ... | Use [`itertools.product`](https://docs.python.org/3/library/itertools.html#itertools.product), which has been available since Python 2.6.
```
import itertools
somelists = [
[1, 2, 3],
['a', 'b'],
[4, 5]
]
for element in itertools.product(*somelists):
print(element)
```
This is the same as:
```
for ele... |
533,921 | <p>By putting functionality into a function, does that alone constitute an example of encapsulation or do you need to use objects to have encapsulation?</p>
<p>I'm trying to understand the concept of encapsulation. What I thought was if I go from something like this:</p>
<p>n = n + 1</p>
<p>which is executed out in ... | [
{
"answer_id": 533930,
"author": "juan",
"author_id": 1782,
"author_profile": "https://Stackoverflow.com/users/1782",
"pm_score": 1,
"selected": false,
"text": "<p>It's a component-level thing</p>\n\n<p>Check <a href=\"http://en.wikipedia.org/wiki/Encapsulation_(computer_science)\" rel=\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | By putting functionality into a function, does that alone constitute an example of encapsulation or do you need to use objects to have encapsulation?
I'm trying to understand the concept of encapsulation. What I thought was if I go from something like this:
n = n + 1
which is executed out in the wild as part of a bi... | Perhaps you are confusing abstraction with encapsulation, which is understood in the broader context of object orientation.
Encapsulation properly includes all three of the following:
* Abstraction
* Implementation Hiding
* Division of Responsibility
Abstraction is only one component of encapsulation. In your exampl... |
533,922 | <p>Is it OK to use <code>==</code> on enums in Java, or do I need to use <code>.equals()</code>? In my testing, <code>==</code> always works, but I'm not sure if I'm guaranteed of that. In particular, there is no <code>.clone()</code> method on an enum, so I don't know if it is possible to get an enum for which <code... | [
{
"answer_id": 533925,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": false,
"text": "<p>Yes, == is fine - there's guaranteed to be just a single reference for each value.</p>\n\n<p>However, there's a bette... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18511/"
] | Is it OK to use `==` on enums in Java, or do I need to use `.equals()`? In my testing, `==` always works, but I'm not sure if I'm guaranteed of that. In particular, there is no `.clone()` method on an enum, so I don't know if it is possible to get an enum for which `.equals()` would return a different value than `==`.
... | Just my 2 cents: Here is the code for Enum.java, as published by Sun, and part of the JDK:
```
public abstract class Enum<E extends Enum<E>>
implements Comparable<E>, Serializable {
// [...]
/**
* Returns true if the specified object is equal to this
* enum constant.
*
* @param other ... |
533,931 | <p>i have three double variable a ,b and c</p>
<pre><code>a = 0.000006
b = 6
c = a/b;
</code></pre>
<p>so C should be 0.000001</p>
<p>i want to show this value in text box so i wrote</p>
<pre><code>textbox.text = c.tostring();
</code></pre>
<p>but it's give result as "1E-06"..</p>
<p>Can anybody help me out ho... | [
{
"answer_id": 533969,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 7,
"selected": true,
"text": "<pre><code>a = 0.000006;\nb = 6;\nc = a/b;\n\ntextbox.Text = c.ToString(\"0.000000\");\n</code></pre>\n\n<p>As you request... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64739/"
] | i have three double variable a ,b and c
```
a = 0.000006
b = 6
c = a/b;
```
so C should be 0.000001
i want to show this value in text box so i wrote
```
textbox.text = c.tostring();
```
but it's give result as "1E-06"..
Can anybody help me out how can i put correct value in textbox ?
Thanks | ```
a = 0.000006;
b = 6;
c = a/b;
textbox.Text = c.ToString("0.000000");
```
As you requested:
```
textbox.Text = c.ToString("0.######");
```
This will only display out to the 6th decimal place if there are 6 decimals to display. |
533,942 | <p>There are hints of the answer to this question here and there on this site, but I'm asking a slightly different question.</p>
<p>Where does Crystal Reports document that this syntax does not work?</p>
<pre><code>Trim({PatientProfile.First}) + " "
+ Trim(Iif(
IsNull({PatientProfile.Middle})
, T... | [
{
"answer_id": 539135,
"author": "Arvo",
"author_id": 35777,
"author_profile": "https://Stackoverflow.com/users/35777",
"pm_score": 4,
"selected": true,
"text": "<p>I think CR evaluates both IIFs true and false parts. Because you have \"Trim({PatientProfile.Middle})\" part there, which w... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2531/"
] | There are hints of the answer to this question here and there on this site, but I'm asking a slightly different question.
Where does Crystal Reports document that this syntax does not work?
```
Trim({PatientProfile.First}) + " "
+ Trim(Iif(
IsNull({PatientProfile.Middle})
, Trim({PatientProfile.M... | I think CR evaluates both IIFs true and false parts. Because you have "Trim({PatientProfile.Middle})" part there, which will be evaluated aganst null value, CR formula evaluator seems just fail. |
533,951 | <p>What are your thoughts on this? I'm working on integrating some new data that's in a tab-delimited text format, and all of the decimal columns are kept as single integers; in order to determine the decimal amount you need to multiply the number by .01. It does this for things like percentages, weight and pricing i... | [
{
"answer_id": 533986,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "<p>Pedantically: they aren't kept as ints either. They are strings that require parsing.</p>\n\n<p>Philisophically: you have... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40667/"
] | What are your thoughts on this? I'm working on integrating some new data that's in a tab-delimited text format, and all of the decimal columns are kept as single integers; in order to determine the decimal amount you need to multiply the number by .01. It does this for things like percentages, weight and pricing inform... | "Do you think this is a good or bad idea?"
Bad.
"Should I be keeping my data structure identical to the one provided by the vendor?"
No.
"Should I make the database columns true decimals?"
Yes.
It's so much simpler to do what's right. Currently, the data is transmitted with no "." to separate the whole numbers fr... |
533,960 | <p>I have been reading a lot about <a href="http://en.wikipedia.org/wiki/Reinforcement_Learning" rel="nofollow noreferrer">Reinforcement Learning</a> lately, and I have found <a href="http://incompleteideas.net/sutton/book/ebook/the-book.html" rel="nofollow noreferrer">"Reinforcement Learning: An Introduction"</a> to b... | [
{
"answer_id": 534980,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 2,
"selected": false,
"text": "<p>My guess is that the code is CCL-dependent, so use <a href=\"http://www.cliki.net/CCL\" rel=\"nofollow noreferrer\">CCL<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277/"
] | I have been reading a lot about [Reinforcement Learning](http://en.wikipedia.org/wiki/Reinforcement_Learning) lately, and I have found ["Reinforcement Learning: An Introduction"](http://incompleteideas.net/sutton/book/ebook/the-book.html) to be an excellent guide. The author's helpfully provice [source code](http://inc... | That code is for Macintosh Common Lisp (MCL). It will only run there. Using Clozure CL (CCL) will not help. You would have to comment the graphics code. The random state stuff also is slightly special for MCL. You have to port it to portable Common Lisp ([make-random-state](http://www.lispworks.com/documentation/HyperS... |
533,968 | <p>Edit: I have looked at the answers code: <strong>NONE</strong> of them do what I want (I've checked). It would seem that there is no way to do what I want in native c#. I guess that's not a disaster just a shame given that .NET does support it (see accepted answer).</p>
<p>Thanks all.</p>
<hr />
<p>I have c# code (p... | [
{
"answer_id": 533976,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 0,
"selected": false,
"text": "<p>No, I think this is a common idiom the way you have it.</p>\n\n<p>EDIT\nTo be clear, the \"catch\" then \"rethrow\" strat... | 2009/02/10 | [
"https://Stackoverflow.com/questions/533968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | Edit: I have looked at the answers code: **NONE** of them do what I want (I've checked). It would seem that there is no way to do what I want in native c#. I guess that's not a disaster just a shame given that .NET does support it (see accepted answer).
Thanks all.
---
I have c# code (part of a test framework that w... | So, in .NET what you're asking for is theoretically possible, but it's not going to be easy.
CIL actually defines *five* types of exception handling block! The `try`, `catch` and `finally` ones you're used to in C#, and two others:
* `filter` - similar to a `catch` block but can run arbitrary code to determine wheth... |
534,007 | <p>I have following questions regarding strings in C++:</p>
<p>1>> which is a better option(considering performance) and why?</p>
<p>1.</p>
<pre><code>string a;
a = "hello!";
</code></pre>
<p>OR</p>
<p>2.</p>
<pre><code>string *a;
a = new string("hello!");
...
delete(a);
</code></pre>
<p>2>... | [
{
"answer_id": 534022,
"author": "Pierre",
"author_id": 58082,
"author_profile": "https://Stackoverflow.com/users/58082",
"pm_score": 2,
"selected": false,
"text": "<pre><code>string a;\na = \"hello!\";\n</code></pre>\n\n<p>2 operations: calls the default constructor std:string() and the... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2745562/"
] | I have following questions regarding strings in C++:
1>> which is a better option(considering performance) and why?
1.
```
string a;
a = "hello!";
```
OR
2.
```
string *a;
a = new string("hello!");
...
delete(a);
```
2>>
```
string a;
a = "less";
a = "moreeeeeee";
```
how exactly memory management is hand... | All the following is what a naive compiler would do. Of course as long as it doesn't change the behavior of the program, the compiler is free to make any optimization.
```
string a;
a = "hello!";
```
First you initialize a to contain the empty string. (set length to 0, and one or two other operations). Then you assi... |
534,030 | <p>How can I refresh Spring configuration file without restarting my servlet container?</p>
<p>I am looking for a solution other than JRebel.</p>
| [
{
"answer_id": 534490,
"author": "LiorH",
"author_id": 52954,
"author_profile": "https://Stackoverflow.com/users/52954",
"pm_score": 3,
"selected": false,
"text": "<p>I wouldn't recommend you to do that. \nWhat do you expect to happen to singleton beans which their configuration modified... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64752/"
] | How can I refresh Spring configuration file without restarting my servlet container?
I am looking for a solution other than JRebel. | Well, it can be useful to perform such a context reload while testing your app.
You can try the `refresh` method of one of the `AbstractRefreshableApplicationContext` class: it won't refresh your previously instanciated beans, but next call on the context will return refreshed beans.
```
import java.io.File;
import j... |
534,044 | <p>I have a Subject which offers <code>Subscribe(Observer*)</code> and <code>Unsubscribe(Observer*)</code> to clients. Subject runs in its own thread (from which it calls <code>Notify()</code> on subscribed Observers) and a mutex protects its internal list of Observers.</p>
<p>I would like client code - which I don't... | [
{
"answer_id": 534109,
"author": "Éric Malenfant",
"author_id": 59781,
"author_profile": "https://Stackoverflow.com/users/59781",
"pm_score": 2,
"selected": false,
"text": "<p>Can you change the signature of Subscribe() an Unsubscribe()? Replacing the Observer* with something like shared... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18167/"
] | I have a Subject which offers `Subscribe(Observer*)` and `Unsubscribe(Observer*)` to clients. Subject runs in its own thread (from which it calls `Notify()` on subscribed Observers) and a mutex protects its internal list of Observers.
I would like client code - which I don't control - to be able to safely delete an Ob... | The "ideal" solution would involve using `shared_ptr` and `weak_ptr`. However, in order to be generic, it also has to account for the issue of `Subject` being dropped before some of its `Observer` (yes, that can happen too).
```
class Subject {
public:
void Subscribe(std::weak_ptr<Observer> o);
void Unsubscrib... |
534,045 | <p>I have a simple web form which has a couple list boxes and a search button. When the button is clicked, it returns a DataSet. If the dataset contains records, I set the asp:label which is initially set to false to true, but this is not happening. If the dataset has records and the visible property is set to true,... | [
{
"answer_id": 534078,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 0,
"selected": false,
"text": "<ul>\n<li>You just need runat=\"server\" on the label itself; though Visible should default to True. </li>\n<li>Make sure yo... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I have a simple web form which has a couple list boxes and a search button. When the button is clicked, it returns a DataSet. If the dataset contains records, I set the asp:label which is initially set to false to true, but this is not happening. If the dataset has records and the visible property is set to true, the l... | If I'm not mistaken, your label should exist on an updatepanel, because as far as the static HTML page is concerned, the one and only time that your current label exists, it's set to be not visible. You would have to reload the whole page to make it visible again. |
534,054 | <p><em>Edit : Accepted Chris Holmes response, but always ready to refactor if someone come up with a better way! Thanks!</em></p>
<p>Doing some winforms with MVP what is the best way to pass an entity to another view.</p>
<p>Let say I have a <code>CustomerSearchView/Presenter</code>, on doubleClick I want to show the... | [
{
"answer_id": 534092,
"author": "Simon Laroche",
"author_id": 33318,
"author_profile": "https://Stackoverflow.com/users/33318",
"pm_score": 1,
"selected": false,
"text": "<p>How about:</p>\n\n<pre><code>//In CustomerSearchPresenter\nvar presenter = new CustomerEditPresenter();\nvar cust... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7419/"
] | *Edit : Accepted Chris Holmes response, but always ready to refactor if someone come up with a better way! Thanks!*
Doing some winforms with MVP what is the best way to pass an entity to another view.
Let say I have a `CustomerSearchView/Presenter`, on doubleClick I want to show the `CustomerEditView/Presenter`. I do... | I don't know exactly how you are showing your views, so it's a bit difficult to give you specific advice here. This is how I've done this sort of thing before:
What we did was have the CustomerSearchViewPresenter fire an event like OpenCustomer(customerId). (That is assuming that your search view only has a few piece... |
534,062 | <p>I have an Excel sheet with first names in Column A and surnames in Column B. I want to create a third Column C that contains the first character from the first name and adds it to the surname, creating <em>first initial + surname</em>.</p>
<pre><code>First Name Last Name Combined Name
John Smith ... | [
{
"answer_id": 534068,
"author": "Ian Jacobs",
"author_id": 22818,
"author_profile": "https://Stackoverflow.com/users/22818",
"pm_score": 7,
"selected": true,
"text": "<pre><code>=CONCATENATE(LEFT(A1,1), B1)\n</code></pre>\n\n<p>Assuming A1 holds 1st names; B1 Last names</p>\n"
},
{
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an Excel sheet with first names in Column A and surnames in Column B. I want to create a third Column C that contains the first character from the first name and adds it to the surname, creating *first initial + surname*.
```
First Name Last Name Combined Name
John Smith jsmith
```
How c... | ```
=CONCATENATE(LEFT(A1,1), B1)
```
Assuming A1 holds 1st names; B1 Last names |
534,072 | <p>While refactoring some C# classes, I've run into classes that implement IDisposable.</p>
<p>Without thinking, I have created partial class files for each class that implements IDisposable interface.</p>
<p>E.g.) For Stamper.cs -> Stamper.cs + Stamper.Dispose.cs
where <strong>Stamper.cs</strong> contains actual log... | [
{
"answer_id": 534087,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, too far. Whats wrong with just sticking a #Region around the code and folding it so you cant see it? </p>\n"
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4035/"
] | While refactoring some C# classes, I've run into classes that implement IDisposable.
Without thinking, I have created partial class files for each class that implements IDisposable interface.
E.g.) For Stamper.cs -> Stamper.cs + Stamper.Dispose.cs
where **Stamper.cs** contains actual logic for stamping
and **Stamper... | It seems about as arbitrary as creating a partial class for constructor logic. Now I have to look at two files to grock that class. Partial classes are only really worth it for designer stuff... |
534,081 | <p>I have an x64 project in VS2008 that needs to include an old legacy library written in Fortran years ago. I do not have the source and cannot recompile it. The function names in the .lib are prepended with an underscore, but the x64 projects only use fastcall reference which does not want to recognize stdcall or cde... | [
{
"answer_id": 534124,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 1,
"selected": false,
"text": "<p>What language is your x64 project in? You should be able to specify the calling convention in your extern definition ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64757/"
] | I have an x64 project in VS2008 that needs to include an old legacy library written in Fortran years ago. I do not have the source and cannot recompile it. The function names in the .lib are prepended with an underscore, but the x64 projects only use fastcall reference which does not want to recognize stdcall or cdecl ... | Names with prepended underscores are used by C linkage, so if your implementation language is C++ (is it?), you should use this declaration
```
extern "C" {
int foo();
float bar();
}
```
It should also use \_\_cdecl, although I'm not sure about that. |
534,102 | <p>I've got two Access databases that share linked tables. They are deployed together in a directory and accessed via code in a Word form.</p>
<p>How can I make sure that the links are preserved when the two databases are copied (together) to a different folder? Since I'm not "opening" the database, per se (it's being... | [
{
"answer_id": 534257,
"author": "Russ Cam",
"author_id": 1831,
"author_profile": "https://Stackoverflow.com/users/1831",
"pm_score": 0,
"selected": false,
"text": "<p>Are you referring to updating the links within your Word form, or the linked table links between your Access databases?<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335036/"
] | I've got two Access databases that share linked tables. They are deployed together in a directory and accessed via code in a Word form.
How can I make sure that the links are preserved when the two databases are copied (together) to a different folder? Since I'm not "opening" the database, per se (it's being accessed ... | **Update 14APR2009**
I found that the previous answer I gave here was erroneous, so I updated it with new code.
**How to proceed**
* Copy the code below to a VBA module.
* From code or from the *Immediate* window in the VBA IDE, simply type:
```
RefreshLinksToPath Application.CurrentProject.Path
```
This will now ... |
534,119 | <p>So, I killed the build today by checking in a config file. It knows where the server is (think SQL server or the like), and I've been working against the server which runs on my box. Normally, or rather, under other circumstances, we'd run against the central server. The daily build, of course, didn't find 'my' s... | [
{
"answer_id": 534139,
"author": "JMD",
"author_id": 56793,
"author_profile": "https://Stackoverflow.com/users/56793",
"pm_score": 2,
"selected": false,
"text": "<p>One method I've used is to have two versions of the config file, and have the installer script pull the correct version.</p... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/235914/"
] | So, I killed the build today by checking in a config file. It knows where the server is (think SQL server or the like), and I've been working against the server which runs on my box. Normally, or rather, under other circumstances, we'd run against the central server. The daily build, of course, didn't find 'my' server,... | What you can do is have a default config file that stays unchanged, unless some new config is added. Then you have a different file that overrides the default file's configs.
```
config.Default.xml
config.User.xml
```
Only config.Default.xml is source controlled. config.User.xml contains only the configurations that... |
534,121 | <p>I run a website (sorta like a social network) that I wrote myself. I allow the members to send comments to each other. In the comment; i take the comment and then call this line before saving it in db..</p>
<pre><code>$com = htmlentities($com);
</code></pre>
<p>When I want to display it; I call this piece of code.... | [
{
"answer_id": 534136,
"author": "levand",
"author_id": 3044,
"author_profile": "https://Stackoverflow.com/users/3044",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, this is a problem. A lot of sites solve it by only allowing their own custom markup in user fields.</p>\n\n<p>But if ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64758/"
] | I run a website (sorta like a social network) that I wrote myself. I allow the members to send comments to each other. In the comment; i take the comment and then call this line before saving it in db..
```
$com = htmlentities($com);
```
When I want to display it; I call this piece of code..
```
$com = html_entity_... | First: [`htmlentities`](http://www.php.net/htmlentities) or just [`htmlspecialchars`](http://www.php.net/htmlspecialchars) should be used for escaping strings that you embed into HTML. You shouldn't use it for escaping string when you insert them into a SQL query - Use [`mysql_real_escape_string`](http://www.php.net/my... |
534,159 | <p>I know this question sounds rather vague so I will make it more clear with an example:</p>
<pre><code>$var = 'bar';
$bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()');
</code></pre>
<p>This is what I want to do. How would you do it? I could off course use eval() like th... | [
{
"answer_id": 534165,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 9,
"selected": true,
"text": "<p>Put the classname into a variable first:</p>\n\n<pre><code>$classname=$var.'Class';\n\n$bar=new $classname(\"xyz\");\n<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35197/"
] | I know this question sounds rather vague so I will make it more clear with an example:
```
$var = 'bar';
$bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()');
```
This is what I want to do. How would you do it? I could off course use eval() like this:
```
$var = 'bar';
eva... | Put the classname into a variable first:
```
$classname=$var.'Class';
$bar=new $classname("xyz");
```
This is often the sort of thing you'll see wrapped up in a Factory pattern.
See [Namespaces and dynamic language features](http://php.net/manual/en/language.namespaces.dynamic.php) for further details. |
534,183 | <p>So I have this very simply SDL application I want to be able to pass to my friend without having him download a whole bunch of SDL packages.</p>
<p>how can I go about this? I was told to use this line to compile:
(note that I use ubuntu linux and so does my friend, and that this application compiles and runs withou... | [
{
"answer_id": 534200,
"author": "yungchin",
"author_id": 25756,
"author_profile": "https://Stackoverflow.com/users/25756",
"pm_score": 2,
"selected": false,
"text": "<p>You should get rid of the -B, I think (this changes the search path, see man g++, and thus you can't find your librari... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64038/"
] | So I have this very simply SDL application I want to be able to pass to my friend without having him download a whole bunch of SDL packages.
how can I go about this? I was told to use this line to compile:
(note that I use ubuntu linux and so does my friend, and that this application compiles and runs without the "-Wl... | In the long run your best bet would be to figure out how to build .debs and then your friend's system's package management can take care of installing all the dependencies needed. If you want to distribute the packages more widely, using the platform's native packaging system as intended will save you and your users a ... |
534,191 | <p>Is it possible to invoke a method when the initial state is entered when using the <a href="http://github.com/rubyist/aasm/tree/master" rel="nofollow noreferrer">AASM</a> Gem? I'd like the <code>spam_check</code> method to get called when a comment is submitted, but it doesn't seem to work.</p>
<pre><code>class Com... | [
{
"answer_id": 534200,
"author": "yungchin",
"author_id": 25756,
"author_profile": "https://Stackoverflow.com/users/25756",
"pm_score": 2,
"selected": false,
"text": "<p>You should get rid of the -B, I think (this changes the search path, see man g++, and thus you can't find your librari... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] | Is it possible to invoke a method when the initial state is entered when using the [AASM](http://github.com/rubyist/aasm/tree/master) Gem? I'd like the `spam_check` method to get called when a comment is submitted, but it doesn't seem to work.
```
class Comment < ActiveRecord::Base
include AASM
aasm_column :state... | In the long run your best bet would be to figure out how to build .debs and then your friend's system's package management can take care of installing all the dependencies needed. If you want to distribute the packages more widely, using the platform's native packaging system as intended will save you and your users a ... |
534,199 | <p>I haven't gotten my head wrapped around Spring yet, so correct me if this question doesn't make sense...</p>
<p>I have a PropertyPlaceholderConfigurer</p>
<pre><code><bean id="rdbmPropertiesPlacholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<p... | [
{
"answer_id": 534235,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 6,
"selected": true,
"text": "<p>Using this notation lets you specify multiple files:</p>\n\n<pre><code> <bean id=\"rdbmPropertiesPlacholder\" clas... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8092/"
] | I haven't gotten my head wrapped around Spring yet, so correct me if this question doesn't make sense...
I have a PropertyPlaceholderConfigurer
```
<bean id="rdbmPropertiesPlacholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<property name="location" value=... | Using this notation lets you specify multiple files:
```
<bean id="rdbmPropertiesPlacholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<property name="locations">
<list>
<value>classpath:/properties/rdbm.properties</value>
<valu... |
534,201 | <p>Currently we use gcov with our testing suite for Linux C++ application and it does a good job at measuring line coverage. </p>
<p>Can gcov produce function/method coverage report in addition to line coverage?</p>
<p>Looking at the parameters gcov accepts I do not think it is possible, but I may be missing somethin... | [
{
"answer_id": 534259,
"author": "VolkA",
"author_id": 25472,
"author_profile": "https://Stackoverflow.com/users/25472",
"pm_score": 4,
"selected": true,
"text": "<p>I guess what you mean is the -f option, which will give you the percentage of lines covered per function. There is an inte... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2586/"
] | Currently we use gcov with our testing suite for Linux C++ application and it does a good job at measuring line coverage.
Can gcov produce function/method coverage report in addition to line coverage?
Looking at the parameters gcov accepts I do not think it is possible, but I may be missing something. Or, probably, ... | I guess what you mean is the -f option, which will give you the percentage of lines covered per function. There is an interesting article about gcov at [Dr. Dobb's](http://www.ddj.com/development-tools/184401989) which might be helpful. If "man gcov" doesn't show the -f flag, check if you have a reasobably recent versi... |
534,208 | <p>I'm attempting to call a javascript function (in our code) from a silverlight control. I'm attempting to call the function via:</p>
<p><code>HtmlPage.Window.Invoke("showPopup", new string[] { "http://www.example.com" });</code></p>
<p>and I get the error "Failed to Invoke: showPopup"</p>
<p>I can call <code>HtmlP... | [
{
"answer_id": 534216,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure your script is fully loaded before trying to invoke functions from it.</p>\n"
},
{
"answer_id":... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17917/"
] | I'm attempting to call a javascript function (in our code) from a silverlight control. I'm attempting to call the function via:
`HtmlPage.Window.Invoke("showPopup", new string[] { "http://www.example.com" });`
and I get the error "Failed to Invoke: showPopup"
I can call `HtmlPage.Window.Invoke("alert", new string[]{... | Aha! I figured it out. Our app uses an iframe, so the rendered html looks something like this
```
<html>
<head></head>
<body>
Stuff
<iframe>
<html>
<head></head>
<body>Other Stuff</body>
</html>
</iframe>
<body>
</html>
```
And the Silverlight control in question is in the iframe. The problem... |
534,217 | <p>In Oracle 10g, I have this SQL:</p>
<pre><code>select dog.id as dogId from CANINES dog order by dog.codename asc
</code></pre>
<p>which returns:</p>
<pre><code>id
--
204
203
206
923
</code></pre>
<p>I want to extend this query to determine the oracle rownum of a dog.id in this resultset.</p>
<p>I have tried</p>... | [
{
"answer_id": 534231,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 2,
"selected": false,
"text": "<p>If you're after the unique identifier of each row in the table you need ROWID, not ROWNUM.</p>\n\n<p>ROWNUM is a pseu... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62255/"
] | In Oracle 10g, I have this SQL:
```
select dog.id as dogId from CANINES dog order by dog.codename asc
```
which returns:
```
id
--
204
203
206
923
```
I want to extend this query to determine the oracle rownum of a dog.id in this resultset.
I have tried
```
select rownum from
(select dog.id as dogId from CANIN... | I suspect what you want is to use an analytic function (RANK, `DENSE_RANK`, or `ROW_NUMBER`), i.e.
```
SELECT rnk
FROM (select dog.id as dogId,
ROW_NUMBER() OVER( ORDER BY dog.codename ASC ) rnk
from CANINES dog )
WHERE dogId = 206
```
If the ID column in the CANINES table were not unique... |
534,224 | <p>The userid that is the identity of the application pool is also in the Farm Administrators group.</p>
<p><strong>Is that a bad thing?</strong> </p>
<p>We started seeing some weird permission errors after this change was made (that userid was added to the farm admin group).</p>
| [
{
"answer_id": 534231,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 2,
"selected": false,
"text": "<p>If you're after the unique identifier of each row in the table you need ROWID, not ROWNUM.</p>\n\n<p>ROWNUM is a pseu... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54775/"
] | The userid that is the identity of the application pool is also in the Farm Administrators group.
**Is that a bad thing?**
We started seeing some weird permission errors after this change was made (that userid was added to the farm admin group). | I suspect what you want is to use an analytic function (RANK, `DENSE_RANK`, or `ROW_NUMBER`), i.e.
```
SELECT rnk
FROM (select dog.id as dogId,
ROW_NUMBER() OVER( ORDER BY dog.codename ASC ) rnk
from CANINES dog )
WHERE dogId = 206
```
If the ID column in the CANINES table were not unique... |
534,240 | <p>I need, if possible, a t-sql query that, returning the values from an arbitrary table, also returns a incremental integer column with value = 1 for the first row, 2 for the second, and so on.</p>
<p>This column does not actually resides in any table, and must be strictly incremental, because the ORDER BY clause cou... | [
{
"answer_id": 534255,
"author": "Misko",
"author_id": 61523,
"author_profile": "https://Stackoverflow.com/users/61523",
"pm_score": 3,
"selected": false,
"text": "<p>Try ROW_NUMBER()</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms186734.aspx\" rel=\"noreferrer\">http://ms... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64763/"
] | I need, if possible, a t-sql query that, returning the values from an arbitrary table, also returns a incremental integer column with value = 1 for the first row, 2 for the second, and so on.
This column does not actually resides in any table, and must be strictly incremental, because the ORDER BY clause could sort th... | For SQL 2005 and up
```
SELECT ROW_NUMBER() OVER( ORDER BY SomeColumn ) AS 'rownumber',*
FROM YourTable
```
for 2000 you need to do something like this
```
SELECT IDENTITY(INT, 1,1) AS Rank ,VALUE
INTO #Ranks FROM YourTable WHERE 1=0
INSERT INTO #Ranks
SELECT SomeColumn FROM YourTable
ORDER BY SomeColumn
SE... |
534,241 | <p>I have a piece of code that brings the window under the cursor to the foreground using the SetForegroundWindow API for WinXP. I have been testing it for Vista but the API seems to no longer do the job correctly. </p>
<p>AllowSetForeground did not help, my process is a background process.</p>
<p>What can I use to ... | [
{
"answer_id": 534272,
"author": "newgre",
"author_id": 62459,
"author_profile": "https://Stackoverflow.com/users/62459",
"pm_score": 3,
"selected": false,
"text": "<p>Try the following code and see if it works for you:</p>\n\n<pre><code>SetWindowPos(WndHandle,HWND_TOPMOST,0,0,0,0,SWP_NO... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64773/"
] | I have a piece of code that brings the window under the cursor to the foreground using the SetForegroundWindow API for WinXP. I have been testing it for Vista but the API seems to no longer do the job correctly.
AllowSetForeground did not help, my process is a background process.
What can I use to accomplish this? | Try the following code and see if it works for you:
```
SetWindowPos(WndHandle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
SetWindowPos(WndHandle,HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
``` |
534,261 | <p>Basically the problem is that each time the assembly version changes (i.e. the user installs a new version of the application) all their settings are reset the the defaults (or more accurately a new user.config file is created in a folder with a different version number as the name)</p>
<p>How can I keep the same s... | [
{
"answer_id": 534335,
"author": "Markus Olsson",
"author_id": 2114,
"author_profile": "https://Stackoverflow.com/users/2114",
"pm_score": 9,
"selected": true,
"text": "<p>ApplicationSettingsBase has a <a href=\"http://msdn.microsoft.com/en-us/library/system.configuration.applicationsett... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23822/"
] | Basically the problem is that each time the assembly version changes (i.e. the user installs a new version of the application) all their settings are reset the the defaults (or more accurately a new user.config file is created in a folder with a different version number as the name)
How can I keep the same settings wh... | ApplicationSettingsBase has a [method called Upgrade](http://msdn.microsoft.com/en-us/library/system.configuration.applicationsettingsbase.upgrade.aspx) which migrates all settings from the previous version.
In order to run the merge whenever you publish a new version of your application you can define a boolean flag... |
534,300 | <p>I code a .getJSon, It does the job but I get IE to asked to download the file. Here is the code</p>
<pre><code><script type="text/javascript">
$(function() {
$('#id').click(function() {
var dateReport = "01/01/2009";
$.getJSON('/Report/SendReport', { date: dateReport},
fun... | [
{
"answer_id": 534359,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 3,
"selected": true,
"text": "<p>Try adding the <code>event.preventDefault();</code> on the click event:</p>\n\n<pre><code>$(function() {\n $('#i... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1154/"
] | I code a .getJSon, It does the job but I get IE to asked to download the file. Here is the code
```
<script type="text/javascript">
$(function() {
$('#id').click(function() {
var dateReport = "01/01/2009";
$.getJSON('/Report/SendReport', { date: dateReport},
function(response) {
... | Try adding the `event.preventDefault();` on the click event:
```
$(function() {
$('#id').click(function(event) {
var dateReport = "01/01/2009";
event.preventDefault(); // added this
$.getJSON('/Report/SendReport', { date: dateReport},
function(response) {
... |
534,307 | <p>How do you change the default face which Emacs uses to style text on a per-mode basis?</p>
<p>For example, say that I am already happy with the face customizations that I have, which include a default fixed-width font. However, in one particular mode (<code>markdown-mode.el</code>, say), I want the default font to ... | [
{
"answer_id": 534961,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 6,
"selected": true,
"text": "<p>How about something like this:</p>\n\n<pre><code>(add-hook 'markdown-mode-hook (lambda () (variable-pitch-mode t))\n</cod... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you change the default face which Emacs uses to style text on a per-mode basis?
For example, say that I am already happy with the face customizations that I have, which include a default fixed-width font. However, in one particular mode (`markdown-mode.el`, say), I want the default font to be variable-width.
I... | How about something like this:
```
(add-hook 'markdown-mode-hook (lambda () (variable-pitch-mode t))
```
You can then customize the `variable-pitch` face, and the other faces in the buffer will inherit from this instead of the default face.
Read the docs for `buffer-face-mode` for more customization details. (BufFa... |
534,329 | <p>I was thinking, method names and their calls seem to create a DSL in your code, by wrapping up the generic stuff and naming it appropriately for what you're trying to achieve.</p>
<p>You know, so it's easy to reason about what the following means</p>
<pre><code>if (a.isSubReportOf(b) || b.isSubReportOf(a)) {
/... | [
{
"answer_id": 534343,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 1,
"selected": false,
"text": "<p>You could ask alternately if DSL's should be replaced with well thought out class, variable and methods names. I hav... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2362/"
] | I was thinking, method names and their calls seem to create a DSL in your code, by wrapping up the generic stuff and naming it appropriately for what you're trying to achieve.
You know, so it's easy to reason about what the following means
```
if (a.isSubReportOf(b) || b.isSubReportOf(a)) {
// do stuff
}
```
bu... | I think you are referring what Martin Fowler (and maybe others) call an Internal DSL. Read [this](http://www.martinfowler.com/bliki/DomainSpecificLanguage.html). |
534,330 | <p>Let's say I have a datePicker called "foobar":</p>
<pre><code><g:datePicker name="foobar" value="${new Date()}" precision="day" />
</code></pre>
<p>How do I read the submitted value of this date-picker?</p>
<p>One way which works but has some unwanted side-effects is the following:</p>
<pre><code>def newOb... | [
{
"answer_id": 534997,
"author": "tcurdt",
"author_id": 33165,
"author_profile": "https://Stackoverflow.com/users/33165",
"pm_score": -1,
"selected": false,
"text": "<p>You still need to know the format though</p>\n\n<pre><code>def newObject = new SomeClassName()\nnewObject.foobar = Date... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58394/"
] | Let's say I have a datePicker called "foobar":
```
<g:datePicker name="foobar" value="${new Date()}" precision="day" />
```
How do I read the submitted value of this date-picker?
One way which works but has some unwanted side-effects is the following:
```
def newObject = new SomeClassName(params)
println "value=" ... | Reading the g:datePicker value became a lot easier in Grails 1.2 (see [release notes](http://www.grails.org/1.2+Release+Notes)):
>
> **Better Date parsing**
>
>
> If you submit a date from a
> tag,
> obtaining the Date object is now as
> simple as looking it up from the
> params object by name (eg. params.foo
>... |
534,363 | <p>For some reason on my page my SiteMapPath disappears.</p>
<p>Site structure:</p>
<pre><code>WebApp
-Default.aspx
-> Reports\
----Default.aspx
----MyReport.aspx
</code></pre>
<p>Web.sitemap</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteM... | [
{
"answer_id": 535495,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Entity Framework supports only a subset of the sql functionality available (partly to remain compatible over a rang... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37055/"
] | For some reason on my page my SiteMapPath disappears.
Site structure:
```
WebApp
-Default.aspx
-> Reports\
----Default.aspx
----MyReport.aspx
```
Web.sitemap
```
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Default.aspx" title... | Entity Framework supports only a subset of the sql functionality available (partly to remain compatible over a range of providers). However, even LINQ-to-SQL (which supports a lot more SQL-Server specific constructs, such as UDFs) doesn't support full-text AFAIK.
I believe you need to use a stored procedure / udf. The... |
534,364 | <p>Ok, a really simple question but I am too thick to figure it out. I want to get the difference between two times. For example, "1:07" (1 minute and 7 seconds) and "3:01" (3 minutes and 1 second). It will only be ever minutes and seconds. I have been trying to make use of this:</p>
<pre><code>function timeDiff($firs... | [
{
"answer_id": 534410,
"author": "Anders S",
"author_id": 54007,
"author_profile": "https://Stackoverflow.com/users/54007",
"pm_score": 3,
"selected": false,
"text": "<p>This should give you the difference between the two times in seconds.</p>\n\n<pre><code>$firstTime = '1:07';\n$secondT... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | Ok, a really simple question but I am too thick to figure it out. I want to get the difference between two times. For example, "1:07" (1 minute and 7 seconds) and "3:01" (3 minutes and 1 second). It will only be ever minutes and seconds. I have been trying to make use of this:
```
function timeDiff($firstTime,$lastTim... | **You can't use strtotime as it will interpret MM:SS as HH:MM** - that's why you are getting higher values than expected.
You could simply prepend your MM:SS values with '00:' to make them look like HH:MM:SS.
*Note however that strtotime, if just given HH:MM:SS, will give a timestamp for **today**, which is fine for ... |
534,405 | <p>I have a tabbar based app.</p>
<p>I build 2 views, one in portrait and another in landscape mode in the Interface Builder.</p>
<p>Now, I wanna something like the iPod App. I wanna the landscape view to be fullscreen, and hide the tabbar & the status bar.</p>
<p>I make to work the basic of this:</p>
<pre><cod... | [
{
"answer_id": 536536,
"author": "Gcoop",
"author_id": 65040,
"author_profile": "https://Stackoverflow.com/users/65040",
"pm_score": 2,
"selected": false,
"text": "<p>You can hide the status bar by calling</p>\n\n<pre><code>setStatusBarHidden:(BOOL)\n</code></pre>\n\n<p>on a UIApplicatio... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53185/"
] | I have a tabbar based app.
I build 2 views, one in portrait and another in landscape mode in the Interface Builder.
Now, I wanna something like the iPod App. I wanna the landscape view to be fullscreen, and hide the tabbar & the status bar.
I make to work the basic of this:
```
- (void)willRotateToInterfaceOrientat... | Look at Apple's "AlternateViews" sample code.
The basic idea is that you can detect the physical orientation of the device with notifications, and then activate a new view controller "modally" and have it request the full screen. You disable interface rotation by having shouldAutorotate... return YES only for one orie... |
534,415 | <p>We have several old ASP and PHP web applications which use SQL Server Authentication. Periodically, all the applications lose the ability to connect to our SQL Server 2000 database server, getting access denied.</p>
<p>Corresponding to roughly the same times, we are getting</p>
<pre><code>1115 Cannot generate SSP... | [
{
"answer_id": 536536,
"author": "Gcoop",
"author_id": 65040,
"author_profile": "https://Stackoverflow.com/users/65040",
"pm_score": 2,
"selected": false,
"text": "<p>You can hide the status bar by calling</p>\n\n<pre><code>setStatusBarHidden:(BOOL)\n</code></pre>\n\n<p>on a UIApplicatio... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24954/"
] | We have several old ASP and PHP web applications which use SQL Server Authentication. Periodically, all the applications lose the ability to connect to our SQL Server 2000 database server, getting access denied.
Corresponding to roughly the same times, we are getting
```
1115 Cannot generate SSPI Context SQLSTATE HY0... | Look at Apple's "AlternateViews" sample code.
The basic idea is that you can detect the physical orientation of the device with notifications, and then activate a new view controller "modally" and have it request the full screen. You disable interface rotation by having shouldAutorotate... return YES only for one orie... |
534,421 | <p>I have a CToolbar and within it I have a button with style BTNS_BUTTON|BTNS_DROPDOWN. I would like to make it a split button, so the left side of the button is a button, and the right side has a drop down menu. </p>
<p>To complete this, I create the button then I call ::SendMessage like so:</p>
<pre><code>::SendMe... | [
{
"answer_id": 536536,
"author": "Gcoop",
"author_id": 65040,
"author_profile": "https://Stackoverflow.com/users/65040",
"pm_score": 2,
"selected": false,
"text": "<p>You can hide the status bar by calling</p>\n\n<pre><code>setStatusBarHidden:(BOOL)\n</code></pre>\n\n<p>on a UIApplicatio... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24841/"
] | I have a CToolbar and within it I have a button with style BTNS\_BUTTON|BTNS\_DROPDOWN. I would like to make it a split button, so the left side of the button is a button, and the right side has a drop down menu.
To complete this, I create the button then I call ::SendMessage like so:
```
::SendMessage( hwndForButto... | Look at Apple's "AlternateViews" sample code.
The basic idea is that you can detect the physical orientation of the device with notifications, and then activate a new view controller "modally" and have it request the full screen. You disable interface rotation by having shouldAutorotate... return YES only for one orie... |
534,424 | <p><em>With reference to <a href="https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment">this programming game</a> I am currently building.</em></p>
<p>I am using WPF to animate canvases, and I am using the <code>BeginAnimation</code> method to translate (move) a c... | [
{
"answer_id": 534475,
"author": "Andy Mikula",
"author_id": 58114,
"author_profile": "https://Stackoverflow.com/users/58114",
"pm_score": 3,
"selected": true,
"text": "<p>Assuming you're rotating clockwise from 12 o'clock, your new x-coordinate will be:</p>\n\n<pre><code>sin(130) * 200 ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | *With reference to [this programming game](https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment) I am currently building.*
I am using WPF to animate canvases, and I am using the `BeginAnimation` method to translate (move) a canvas across another canvas.
With the ... | Assuming you're rotating clockwise from 12 o'clock, your new x-coordinate will be:
```
sin(130) * 200 = 153 + original x-coordinate
```
And your new y-coordinate will be
```
cos(130) * 200 = -129 + original y-coordinate (assuming negative 'y' is down)
```
As below, note that in C#, for example, `sin` and `cos` ta... |
534,426 | <p>I can't get PsExec to work. It keeps copying my installer into system32 (where it won't launch). Does anyone know how to copy from the local to the remote computer to a directory that isn't system32? My PsExec command line is </p>
<pre><code>psexec \\000.00.00.000 -f -u DOMAIN\meuser -p testpwd -c ..\Installer\test... | [
{
"answer_id": 534445,
"author": "Brandon",
"author_id": 63775,
"author_profile": "https://Stackoverflow.com/users/63775",
"pm_score": 1,
"selected": false,
"text": "<p>Can you XCOPY the installer to a certain place on the remote PC and then PSExec the installer? PSExec shouldn't actuall... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48552/"
] | I can't get PsExec to work. It keeps copying my installer into system32 (where it won't launch). Does anyone know how to copy from the local to the remote computer to a directory that isn't system32? My PsExec command line is
```
psexec \\000.00.00.000 -f -u DOMAIN\meuser -p testpwd -c ..\Installer\test.exe /S
```
... | Have you tried:
```
net use G: \\remotecomputer\droppoint mypassword /user:myuser@mydomain
xcopy installer G:
``` |
534,427 | <p>I have many different regex patterns automatically loaded everytime my greasemonkey script starts. 95% of this loaded memory isn't needed at any stage, so I would like to find a way to not even put that data into memory to begin with if I know it won't be used.</p>
<p>Take this a basic example:</p>
<pre><code> var... | [
{
"answer_id": 534442,
"author": "dave mankoff",
"author_id": 10093,
"author_profile": "https://Stackoverflow.com/users/10093",
"pm_score": 1,
"selected": false,
"text": "<p>Use a document.write() to include the data from a separate javascript file if and only if it's needed. </p>\n"
}... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63523/"
] | I have many different regex patterns automatically loaded everytime my greasemonkey script starts. 95% of this loaded memory isn't needed at any stage, so I would like to find a way to not even put that data into memory to begin with if I know it won't be used.
Take this a basic example:
```
var patterns = [
{
... | The best way is if you could load data on demand via GM\_getResourceText+eval. The resource data defined in the metadata block will be downloaded on the userscript's first install.
Documentation: <http://wiki.greasespot.net/Metadata_block#.40resource>
You need to think how to store the data - maybe a resource per sit... |
534,438 | <p>This is sort of a follow-up to my question here: </p>
<p><a href="https://stackoverflow.com/questions/534045/asplabel-is-not-shown-when-visible-is-set-to-true">Asp:Label is not shown when visible is set to true?</a></p>
<p>In the above question, I had a few controls where the visibility was not being set to false ... | [
{
"answer_id": 534841,
"author": "teedyay",
"author_id": 15825,
"author_profile": "https://Stackoverflow.com/users/15825",
"pm_score": 0,
"selected": false,
"text": "<p>No, ImageButtons don't have AutoPostBack: they don't need them any more than regular buttons do.</p>\n\n<p>That behavio... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | This is sort of a follow-up to my question here:
[Asp:Label is not shown when visible is set to true?](https://stackoverflow.com/questions/534045/asplabel-is-not-shown-when-visible-is-set-to-true)
In the above question, I had a few controls where the visibility was not being set to false because they were not in an ... | Make sure that you have associated the Image Button to a PostBackTrigger on the UpdatePanel. If you are exporting to Excel using something similar to [Matt Berseth's method](http://mattberseth.com/blog/2007/04/export_gridview_to_excel_1.html), you have to have this trigger for the export to work.
```
<asp:PostBackTrig... |
534,439 | <p>I'm having a bit of trouble with the performance of a parameterized sql statement. The table i'm working with has ~150,000 records with each record having ~30 columns.</p>
<p>This statement executes in 3.5 seconds.</p>
<pre><code> Dim selectstring As String
selectstring = "SELECT * FROM LineInfo WHERE jobNu... | [
{
"answer_id": 534452,
"author": "geofftnz",
"author_id": 20122,
"author_profile": "https://Stackoverflow.com/users/20122",
"pm_score": 2,
"selected": false,
"text": "<p>Run SQL Profiler and check the actual SQL that's hitting the database. Take both queries and run them in Query Analyse... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm having a bit of trouble with the performance of a parameterized sql statement. The table i'm working with has ~150,000 records with each record having ~30 columns.
This statement executes in 3.5 seconds.
```
Dim selectstring As String
selectstring = "SELECT * FROM LineInfo WHERE jobNum=@jobnum and revisio... | Run SQL Profiler and check the actual SQL that's hitting the database. Take both queries and run them in Query Analyser / SQL Server Management studio with Show Execution Plan enabled and find where the time is being spent.
If the performance on the server is identical, then check your .NET code again. Is there any re... |
534,474 | <p>I need to change <code>wmode</code> of arbitrary flash objects to transparent from external js file to make sure they don't hide menus without using Jquery or similar libs.</p>
<p>In FF I use <code>getElementsByTagName("embed")</code> and set attribute. It seems to work well.</p>
<p>Specifically I'm having trouble... | [
{
"answer_id": 534493,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 2,
"selected": false,
"text": "<p>When you are using SWFObject to include the flash, there should be a parameter in the embedSWF method called 'params... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64106/"
] | I need to change `wmode` of arbitrary flash objects to transparent from external js file to make sure they don't hide menus without using Jquery or similar libs.
In FF I use `getElementsByTagName("embed")` and set attribute. It seems to work well.
Specifically I'm having trouble with `object` set by `swfObject` libra... | I've been successful with this little trick:
```
$("embed").attr("wmode", "opaque").wrap('<div>');
```
It effectively redraws the flash object, worked for me. |
534,511 | <p>When hovering over a span I would like to get the offsetLeft and offsetTop values so I can make something hover near it. When I do this I get 0 for both values. </p>
<p>What is a better way to tackle this? I am using jQuery. </p>
<p>Assume I am starting with (looped by server-side scripting):</p>
<pre><code><s... | [
{
"answer_id": 534526,
"author": "nickohrn",
"author_id": 59907,
"author_profile": "https://Stackoverflow.com/users/59907",
"pm_score": 5,
"selected": true,
"text": "<p>I think you should be able to do this:</p>\n\n<p><strong>HTML</strong></p>\n\n<pre><code><span class=\"get-close-to\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | When hovering over a span I would like to get the offsetLeft and offsetTop values so I can make something hover near it. When I do this I get 0 for both values.
What is a better way to tackle this? I am using jQuery.
Assume I am starting with (looped by server-side scripting):
```
<span onmouseover="hoverNearMe(th... | I think you should be able to do this:
**HTML**
```
<span class="get-close-to">some username</span><br />
```
**jQuery**
```
jQuery('.get-close-to').hover(function() {
var offset = jQuery(this).css('offset');
alert( 'Left: ' + offset.left + '\nTop: ' + offset.top );
});
``` |
534,512 | <p>I'm trying to learn how sockets works in C#. My idea was to program a simple http proxy:
Here's my code:</p>
<pre><code>using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
class Program
{
static void Main(st... | [
{
"answer_id": 534607,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 3,
"selected": true,
"text": "<p>1) Socket.Available returns zero if there is no data available in the buffer at the instant you call it. Socket... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I'm trying to learn how sockets works in C#. My idea was to program a simple http proxy:
Here's my code:
```
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
class Program
{
static void Main(string[] args)
... | 1) Socket.Available returns zero if there is no data available in the buffer at the instant you call it. Socket.Read will block (wait) for data to arrive if there is none available yet. So that's the difference. By calling Read, you make it wait for data. By examining Available, you don't make it wait. So if you happen... |
534,522 | <p>I distribute an Excel workbook to a number of users, and they are <em>supposed</em> to have a particular macro file pre-installed in their XLSTART folder.</p>
<p>If they don't have the macro installed correctly, and they send the workbook back to me, any formulas depending on it include the full path of the macro, ... | [
{
"answer_id": 534815,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 2,
"selected": true,
"text": "<p>Try the following:</p>\n\n<pre><code>Sub FormulaFindAndReplace(phrase As String)\n For Each Sheet_Select In ActiveWorkbo... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16306/"
] | I distribute an Excel workbook to a number of users, and they are *supposed* to have a particular macro file pre-installed in their XLSTART folder.
If they don't have the macro installed correctly, and they send the workbook back to me, any formulas depending on it include the full path of the macro, e.g.:
```
'C:\Do... | Try the following:
```
Sub FormulaFindAndReplace(phrase As String)
For Each Sheet_Select In ActiveWorkbook.Worksheets
Sheet_Select.Activate
Set Found_Link = Cells.Find(what:=phrase, After:=ActiveCell, _
LookIn:=xlFormulas, lookat:=xlPart, searchorder:=xlByRows, _
searchdirection:=xlNext, Matc... |
534,530 | <p>I have a search screen in a Visual Basic .Net App that has text boxes for:</p>
<ol>
<li>First Name Varchar(50)</li>
<li>Last Name Varchar(50)</li>
<li>Middle Name Varchar(50)</li>
<li>DOB DateTime</li>
<li>Home Phone Varchar(10)</li>
<li>Work Phone Varchar(10)</li>
</ol>
<p>How would I create a stored procedure i... | [
{
"answer_id": 534565,
"author": "KenJ",
"author_id": 64807,
"author_profile": "https://Stackoverflow.com/users/64807",
"pm_score": 0,
"selected": false,
"text": "<p>The quick way to do this would be something like</p>\n\n<p>Where (Last_Name Like @LastName + '%' OR @LastName IS NULL) and... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4067/"
] | I have a search screen in a Visual Basic .Net App that has text boxes for:
1. First Name Varchar(50)
2. Last Name Varchar(50)
3. Middle Name Varchar(50)
4. DOB DateTime
5. Home Phone Varchar(10)
6. Work Phone Varchar(10)
How would I create a stored procedure in SQL Server 2000 that would allow me to be able to search... | I use this pattern a lot:
```
Select Last_Name, First_Name, Mid_Name, DOB, Home_Phone, Work_Phone from dbo.tblClient
Where (@LastName is null or Last_Name Like '%'+ @LastName)
and (@FirstName is null or First_Name Like '%'+ @FirstName)
and (@HomePhone is null or Home_Phone Like '%'+ @HomePhone)
-- etc...
```
It will... |
534,531 | <p>I wan to place a VB.NET project under Git control in Windows (was previously under Visual Source Safe - long sad story of repository corruption, etc.). How should I set up the ignore file? The exclusions I'm thinking of using are:</p>
<ul>
<li>*.exe</li>
<li>*.pdb</li>
<li>*.manifest</li>
<li>*.xml</li>
<li>*.log (... | [
{
"answer_id": 534570,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "<p>Here's what I have for my C# projects:</p>\n\n<pre><code>ProjectName/bin\nProjectName/obj\n*.user\n*.suo\n_ReSharper.*... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64794/"
] | I wan to place a VB.NET project under Git control in Windows (was previously under Visual Source Safe - long sad story of repository corruption, etc.). How should I set up the ignore file? The exclusions I'm thinking of using are:
* \*.exe
* \*.pdb
* \*.manifest
* \*.xml
* \*.log (is Git case sensitive on Windows? Sho... | Here's what I have for my C# projects:
```
ProjectName/bin
ProjectName/obj
*.user
*.suo
_ReSharper.*
*.sln.cache
```
With the bin/obj directories gone, you don't need to exclude *all* EXEs, XML files etc - which is handy, as it means you still get to put in the ones you want :) (You might have sample XML files etc.) |
534,555 | <p>The original title here was
<strong>Workaround for SFINAE bug in VS2005 C++</strong></p>
<p>This is tentative use of SFINAE to make the equivalent for the is_pod template class that exists in TR1 (In VS2005 there's no TR1 yet). It should have its <em>value</em> member true when the template parameter is a POD type ... | [
{
"answer_id": 534748,
"author": "Dean Michael",
"author_id": 11274,
"author_profile": "https://Stackoverflow.com/users/11274",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure about the way you're trying to do SFINAE here, since <code>is_pod<T>::test(...)</code> will mat... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8999/"
] | The original title here was
**Workaround for SFINAE bug in VS2005 C++**
This is tentative use of SFINAE to make the equivalent for the is\_pod template class that exists in TR1 (In VS2005 there's no TR1 yet). It should have its *value* member true when the template parameter is a POD type (including primitive types an... | The biggest problem with your approach is you don't do SFINAE here - SFINAE only applies to parameter types and return type here.
However, of all the SFINAE situations in the standard, none applies to your situation. They are
* arrays of void, references, functions, or of invalid size
* type member that is not a type... |
534,558 | <p>I've got a silverlight listbox and I want to remove the colour change highlight that occurs when the user selects an item in the listbox.</p>
<p>By default when an item is selected it highlights the item a sort of light blue color.</p>
<p>How can I stop this from occuring?</p>
<p>As an side question, how do I cus... | [
{
"answer_id": 534810,
"author": "Peter McG",
"author_id": 57465,
"author_profile": "https://Stackoverflow.com/users/57465",
"pm_score": 5,
"selected": true,
"text": "<p>You can do this by customizing the existing Control Template for a ListBox Item. The easy way to do this is to fire u... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54794/"
] | I've got a silverlight listbox and I want to remove the colour change highlight that occurs when the user selects an item in the listbox.
By default when an item is selected it highlights the item a sort of light blue color.
How can I stop this from occuring?
As an side question, how do I customise this to any arbit... | You can do this by customizing the existing Control Template for a ListBox Item. The easy way to do this is to fire up Expression Blend, right click a ListBoxItem, go to Edit Control Parts (Template) and select Edit a Copy... then customize the Fill color of the fillColor and fillColor2 rectangles as required.
The Xam... |
534,572 | <p>I have an "Estate" entity, and this entity has a collection "EstateFeatures"(type:EstateFeature) and EstateFeature has a property "MyFeatureValue".</p>
<p><em>Note: These are the limited properties for the question. All Entities has an Id and all necesarry etc</em></p>
<p><strong>Estate</strong> </p>
<pre><code>I... | [
{
"answer_id": 534641,
"author": "RKitson",
"author_id": 16947,
"author_profile": "https://Stackoverflow.com/users/16947",
"pm_score": 1,
"selected": false,
"text": "<p>The code looks like you are passing in a list of FeaturesValueIds and want a List that has all of those features. If t... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51734/"
] | I have an "Estate" entity, and this entity has a collection "EstateFeatures"(type:EstateFeature) and EstateFeature has a property "MyFeatureValue".
*Note: These are the limited properties for the question. All Entities has an Id and all necesarry etc*
**Estate**
```
IList<EstateFeature> EstateFeatures;
```
**Esta... | You will need to make sure that you join MyFeatureValue one time for each feature that you want your Estate to have.
One way is to call .CreateAlias for each iteration, give it a unique alias then add expression "aliasX.Id"
```
foreach (var id in idCollection)
{
query = query.CreateAlias("MyFeatureValue", "featu... |
534,590 | <p>Is it possible to bulk upgrade (many at the same time) VS 2005 projects to VS 2008.</p>
<p>I know that I can open one at a time, however, I would like to select say 10 at a time to upgrade and add to a new solution.</p>
| [
{
"answer_id": 535642,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 1,
"selected": false,
"text": "<p>There is no automatic tool that I know of (unless some commercial solution has been developed recently). But i... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62572/"
] | Is it possible to bulk upgrade (many at the same time) VS 2005 projects to VS 2008.
I know that I can open one at a time, however, I would like to select say 10 at a time to upgrade and add to a new solution. | I recently came across the same problem and used a Windows Powershell script to get Visual Studio to do the upgrading for me using the [/upgrade](http://msdn.microsoft.com/en-us/library/w15a82ay.aspx) command line switch
```
$slnFiles = ls C:\source -Filter *.sln -Recurse
$devenv = "C:\Program Files (x86)\Microsoft V... |
534,608 | <p>I have a list of lists that looks like this:</p>
<pre><code>[['Tom', 'Dick'], ['Harry', 'John', 'Mike'], ['Bob']]
</code></pre>
<p>and I want to turn it into a dictionary where each key is a name and each value is a number corresponding to the position of its sublist in the list:</p>
<pre><code>{'Tom': 0, 'Dick':... | [
{
"answer_id": 534615,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 5,
"selected": true,
"text": "<pre><code>names_dict = dict((name,index)\n for index,lst in enumerate(names)\n f... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a list of lists that looks like this:
```
[['Tom', 'Dick'], ['Harry', 'John', 'Mike'], ['Bob']]
```
and I want to turn it into a dictionary where each key is a name and each value is a number corresponding to the position of its sublist in the list:
```
{'Tom': 0, 'Dick': 0, 'Harry': 1, 'John': 1, 'Mike': 1,... | ```
names_dict = dict((name,index)
for index,lst in enumerate(names)
for name in lst)
```
Example:
```
>>> names = [['Tom', 'Dick'], ['Harry', 'John', 'Mike'], ['Bob']]
>>> names_dict = dict((name,index)
... for index,lst in enumerate(names)
... ... |
534,629 | <p>I have a listbox with 20 colors. It looks something like this:</p>
<p>1:Red
2:Green
3:Blue
4:Orange
5:Red
6:Yellow
7:Orange
8:Red
9:Green
....</p>
<p>It gets the data from an ObjectDataSource which in turn gets it's data from a method which returns a datatable. I want a dropdown which basically has 2 items, Orde... | [
{
"answer_id": 534677,
"author": "teedyay",
"author_id": 15825,
"author_profile": "https://Stackoverflow.com/users/15825",
"pm_score": 2,
"selected": false,
"text": "<p>(I'm assuming you've already figured out how to bind the ListBox in the first place.)</p>\n\n<p>Set the property AutoPo... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I have a listbox with 20 colors. It looks something like this:
1:Red
2:Green
3:Blue
4:Orange
5:Red
6:Yellow
7:Orange
8:Red
9:Green
....
It gets the data from an ObjectDataSource which in turn gets it's data from a method which returns a datatable. I want a dropdown which basically has 2 items, Order By # and Order By... | You can add the sort expression to your ObjectDataSource as a Select parameter, you can define it like so:
```
<asp:ObjectDataSource
ID="ObjectDataSource1"
runat="server"
SelectMethod="SelectMethod"
TypeName="MyDataObject">
<asp:Parameter Direction="input" Type="stri... |
534,652 | <p>I have an entity Promotion, which has 3 simple fields (id, name, description) and all 3 will be mapped to DB. So far so good. Problem is with the 4th field, ruleModel, which is an instance of RuleModel and when constructed at runtime, it will contain object instances of a dozen other classes. I don't want to map Rul... | [
{
"answer_id": 563984,
"author": "Alan Mendelevich",
"author_id": 19546,
"author_profile": "https://Stackoverflow.com/users/19546",
"pm_score": 2,
"selected": false,
"text": "<p>amCharts <a href=\"http://amcharts.com/stock/\" rel=\"nofollow noreferrer\">Stock chart</a> is of the same bre... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/455772/"
] | I have an entity Promotion, which has 3 simple fields (id, name, description) and all 3 will be mapped to DB. So far so good. Problem is with the 4th field, ruleModel, which is an instance of RuleModel and when constructed at runtime, it will contain object instances of a dozen other classes. I don't want to map RuleMo... | amCharts [Stock chart](http://amcharts.com/stock/) is of the same breed. It's Flash based but you can easily use it with any server side engine. Not sure whether you are looking for web or windows solution though. |
534,657 | <pre><code>for (i = 0; i < document.checks.user.length; i++) //for all check boxes
{
if (document.checks.user[i].checked == true )
{
document.checks.submit();
return 0;
}
}
<body>
<form action="" method=POST name="checks" ID="Form2">
I have a bike:
<input type="checkbo... | [
{
"answer_id": 534698,
"author": "teedyay",
"author_id": 15825,
"author_profile": "https://Stackoverflow.com/users/15825",
"pm_score": -1,
"selected": false,
"text": "<p>jQuery is your friend:</p>\n\n<pre><code>$(\"input[type='checkbox']\").attr('checked', false);\n</code></pre>\n\n<p>(.... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | ```
for (i = 0; i < document.checks.user.length; i++) //for all check boxes
{
if (document.checks.user[i].checked == true )
{
document.checks.submit();
return 0;
}
}
<body>
<form action="" method=POST name="checks" ID="Form2">
I have a bike:
<input type="checkbox" name="user" value="Bik... | Use a loop control variable, and set it to 1 if length is undefined...
```
var len = document.checks.user.length;
if(len == undefined) len = 1;
for (i = 0; i < len; i++) //for all check boxes
```
Best regards... |
534,670 | <p>I need advice on how to return a limited set of data from an MVC controller.</p>
<p>Lets say I have a class that is constructed like so:</p>
<pre><code>public interface ICustomerExpose
{
string Name {get; set;}
string State {get; set;}
}
public interface ICustomer: ICustomerExpose
{
int Id {get; set;}
... | [
{
"answer_id": 534714,
"author": "Tim Jarvis",
"author_id": 10387,
"author_profile": "https://Stackoverflow.com/users/10387",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think that there is a wrapper in Winforms that wraps that dialog, it would be simple enough to create your o... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42620/"
] | I need advice on how to return a limited set of data from an MVC controller.
Lets say I have a class that is constructed like so:
```
public interface ICustomerExpose
{
string Name {get; set;}
string State {get; set;}
}
public interface ICustomer: ICustomerExpose
{
int Id {get; set;}
string SSN {get; set... | I don't think that there is a wrapper in Winforms that wraps that dialog, it would be simple enough to create your own dialog though, you need to call the SetAccessControl method from the FileInfo class, there is an example here
<http://msdn.microsoft.com/en-us/library/system.io.fileinfo.setaccesscontrol.aspx> |
534,690 | <p>Using the simple example below, what is the best way to return results from multiple tables using Linq to SQL?</p>
<p>Say I have two tables:</p>
<pre><code>Dogs: Name, Age, BreedId
Breeds: BreedId, BreedName
</code></pre>
<p>I want to return all dogs with their <code>BreedName</code>. I should get all dogs usi... | [
{
"answer_id": 534708,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 0,
"selected": false,
"text": "<p>Well, if you're returning Dogs, you'd do:</p>\n<pre><code>public IQueryable<Dog> GetDogsWithBreedNames()\n{\n... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2034/"
] | Using the simple example below, what is the best way to return results from multiple tables using Linq to SQL?
Say I have two tables:
```
Dogs: Name, Age, BreedId
Breeds: BreedId, BreedName
```
I want to return all dogs with their `BreedName`. I should get all dogs using something like this with no problems:
```... | I tend to go for this pattern:
```
public class DogWithBreed
{
public Dog Dog { get; set; }
public string BreedName { get; set; }
}
public IQueryable<DogWithBreed> GetDogsWithBreedNames()
{
var db = new DogDataContext(ConnectString);
var result = from d in db.Dogs
join b in db.Breeds... |
534,700 | <p>Okay, how would I do this?</p>
<pre><code>class Example(models.Model):
parent_example = models.ForeignKey(Example)
</code></pre>
<p>I want to have a model have a foreign key reference to itself. When I try to create this I get a django validation error that Example is not yet defined.</p>
| [
{
"answer_id": 534723,
"author": "Joe Holloway",
"author_id": 48837,
"author_profile": "https://Stackoverflow.com/users/48837",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, just do this:</p>\n\n<pre><code>class Example(models.Model):\n parent_example = models.ForeignKey('self')\n<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36680/"
] | Okay, how would I do this?
```
class Example(models.Model):
parent_example = models.ForeignKey(Example)
```
I want to have a model have a foreign key reference to itself. When I try to create this I get a django validation error that Example is not yet defined. | You should use
```
models.ForeignKey('self')
```
as mentioned [here](http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey). |
534,703 | <p>I'm no expert in audio, so if any of you folks are, I'd appreciate your insights on this.</p>
<p>My client has a handful of MP3 podcasts stored at a relatively high bit rate, and I'd like to be able to serve those files to her users at "different" bit rates depending on that user's credentials. (For example, if yo... | [
{
"answer_id": 534723,
"author": "Joe Holloway",
"author_id": 48837,
"author_profile": "https://Stackoverflow.com/users/48837",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, just do this:</p>\n\n<pre><code>class Example(models.Model):\n parent_example = models.ForeignKey('self')\n<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32129/"
] | I'm no expert in audio, so if any of you folks are, I'd appreciate your insights on this.
My client has a handful of MP3 podcasts stored at a relatively high bit rate, and I'd like to be able to serve those files to her users at "different" bit rates depending on that user's credentials. (For example, if you're an aut... | You should use
```
models.ForeignKey('self')
```
as mentioned [here](http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey). |
534,704 | <p>I'm coding an iPhone app that needs to make small HTTP requests to the Internet. Within our corp LAN, all HTTP traffic has to go through Squid. </p>
<p>The simulator is clearly capable of using a proxy - since Mobile Safari works. But, how do I get/set the proxy settings in code? </p>
<p>A bunch of the headers are... | [
{
"answer_id": 559872,
"author": "Alexandre L Telles",
"author_id": 66992,
"author_profile": "https://Stackoverflow.com/users/66992",
"pm_score": 3,
"selected": false,
"text": "<p>You can try using Proxifier: <a href=\"http://www.proxifier.com/mac/\" rel=\"noreferrer\">http://www.proxifi... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64827/"
] | I'm coding an iPhone app that needs to make small HTTP requests to the Internet. Within our corp LAN, all HTTP traffic has to go through Squid.
The simulator is clearly capable of using a proxy - since Mobile Safari works. But, how do I get/set the proxy settings in code?
A bunch of the headers are commented out fo... | To close this off. It looks like this is fixed in iOS4 SDK - the network stack on the simulator will use the Mac's proxy for any HTTP calls. |
534,718 | <p>There are certain predefined exceptions in Java, which, if thrown, report that something serious has happened and you'd better improve your code, than catching them in a catch block (if I have understood it correctly). But still I find many programs in which I have the following:</p>
<pre><code>} catch (IOException... | [
{
"answer_id": 534730,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>No, there's nothing wrong with catching <code>IOException</code> and <code>FileNotFoundException</code> - if you can ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] | There are certain predefined exceptions in Java, which, if thrown, report that something serious has happened and you'd better improve your code, than catching them in a catch block (if I have understood it correctly). But still I find many programs in which I have the following:
```
} catch (IOException e) {
...... | No, there's nothing wrong with catching `IOException` and `FileNotFoundException` - if you can genuinely *handle* those exceptions. That's the important bit - can you really proceed in the face of that exception? Sometimes you can - very often at the top level of a server, for example, where just because one request fa... |
534,724 | <p>Is there an Implode type function for SQL Server? </p>
<p>What I have is a list (in a SQL server table):</p>
<pre><code> Apple
Orange
Pear
Blueberry
</code></pre>
<p>and I want them to come out as </p>
<pre><code> Apple, Orange, Pear, Blueberry
</code></pre>
<p>I hope for the space and comma to be configurab... | [
{
"answer_id": 534739,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 4,
"selected": true,
"text": "<p>There are some questions related to this already on SO (search for PIVOT or UNPIVOT or GROUP_CONCAT), but a simple sol... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18196/"
] | Is there an Implode type function for SQL Server?
What I have is a list (in a SQL server table):
```
Apple
Orange
Pear
Blueberry
```
and I want them to come out as
```
Apple, Orange, Pear, Blueberry
```
I hope for the space and comma to be configurable but I can always replace it if it isn't...
Quick he... | There are some questions related to this already on SO (search for PIVOT or UNPIVOT or GROUP\_CONCAT), but a simple solution for SQL Server (using a trick with variable concatenation) for your stated problem:
```
DECLARE @str AS varchar(MAX)
DECLARE @separator AS varchar(50)
SET @separator = ', ' -- Here's your config... |
534,735 | <p>In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent</p>
<p>For example:</p>
<pre><code>#include <stdio.h>
void foo_bar( void )
{
static counter = 0;
printf("counter is %d\n",... | [
{
"answer_id": 534746,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 1,
"selected": false,
"text": "<p>I think that people generally stay away from internal static variables. I know strtok() uses one, or something lik... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] | In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent
For example:
```
#include <stdio.h>
void foo_bar( void )
{
static counter = 0;
printf("counter is %d\n", counter);
counter+... | This confusion usually comes about because the `static` keyword serves two purposes.
When used at file level, it controls the *visibility* of its object outside the compilation unit, not the *duration* of the object (visibility and duration are layman's terms I use during educational sessions, the ISO standard uses di... |
534,796 | <p>We're using a dataset to throw a small amount of data around amongst various nodes within our application.</p>
<p>The dataset is in an assembly by itself as it is reference from many other components. </p>
<p>The Visual Studio dataset tool has developed a strange habit of creating a new designer everytime a build ... | [
{
"answer_id": 576650,
"author": "Julian de Wit",
"author_id": 44894,
"author_profile": "https://Stackoverflow.com/users/44894",
"pm_score": 0,
"selected": false,
"text": "<p>I have had this problem once but don't remember exactly how I fixed it.</p>\n\n<p>I believe I did :</p>\n\n<ul>\n... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42975/"
] | We're using a dataset to throw a small amount of data around amongst various nodes within our application.
The dataset is in an assembly by itself as it is reference from many other components.
The Visual Studio dataset tool has developed a strange habit of creating a new designer everytime a build is done.
So, the... | Close your project. Edit the *project*.csproj file in XML mode. You will find an entry in the group that reads:
```
<None Include="*myDataSet*.xsd">
<SubType>Designer</SubType>
<Generator>MSDataSetGenerator</Generator>
<LastGenOutput>*myDataSet*1.Designer.cs</LastGenOutput>
</None>
```
Change the item to remov... |
534,807 | <p>I need to implement a Routing Table where there are a number of paramters.</p>
<p>For eg, i am stating five attributes in the incoming message below</p>
<pre><code>Customer Txn Group Txn Type Sender Priority Target
UTI CORP ONEOFF ABC LOW TRG1
UTI GOV ONEOFF ABC LOW TRG2... | [
{
"answer_id": 534825,
"author": "Stephan Eggermont",
"author_id": 35306,
"author_profile": "https://Stackoverflow.com/users/35306",
"pm_score": 0,
"selected": false,
"text": "<p>That depends on what is repeating and what could be empty. XML is not known for its efficient queryability, a... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64833/"
] | I need to implement a Routing Table where there are a number of paramters.
For eg, i am stating five attributes in the incoming message below
```
Customer Txn Group Txn Type Sender Priority Target
UTI CORP ONEOFF ABC LOW TRG1
UTI GOV ONEOFF ABC LOW TRG2
```
What is the be... | If you're loading it into memory, it doesn't really matter what form the XML takes - make it the easiest to read or write by hand, I would suggest. When you load it into memory, *then* you should transform it into an appropriate data structure. (The exact nature of the data structure would depend on the exact nature of... |
534,809 | <p>I'm trying to scale this but I'm a little green when it comes to creating JS functions. I managed to get this far on my own, but alas...</p>
<p>When a span gets a value of whatever (in this case, a city name), I want the select box to automatically match it. And I want to scale this by getting rid of all these else... | [
{
"answer_id": 534818,
"author": "Ionuț Staicu",
"author_id": 23810,
"author_profile": "https://Stackoverflow.com/users/23810",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe:</p>\n\n<pre><code>$('select#field1 option').removeAttr('selected');\nvar whereEvent = $('span#field2').html... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to scale this but I'm a little green when it comes to creating JS functions. I managed to get this far on my own, but alas...
When a span gets a value of whatever (in this case, a city name), I want the select box to automatically match it. And I want to scale this by getting rid of all these else if's.
``... | This is an option:
```
$(document).ready(function() {
$('select#field1 option').removeAttr('selected');
var whereEvent = $('span#field2').html();
var filter = 'select#field1 option[value=' + whereEvent + ']';
$(filter).attr('selected', 'true');
}
```
Or you could do:
```
$(documen... |
534,839 | <p>How do I create a GUID/UUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python?</p>
| [
{
"answer_id": 534847,
"author": "stuartd",
"author_id": 43846,
"author_profile": "https://Stackoverflow.com/users/43846",
"pm_score": 11,
"selected": true,
"text": "<blockquote>\n<p>The <a href=\"https://docs.python.org/3/library/uuid.html\" rel=\"noreferrer\">uuid module</a> provides i... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59180/"
] | How do I create a GUID/UUID in Python that is platform independent? I hear there is a method using ActivePython on Windows but it's Windows only because it uses COM. Is there a method using plain Python? | >
> The [uuid module](https://docs.python.org/3/library/uuid.html) provides immutable UUID objects (the UUID class) and the functions [`uuid1()`](https://docs.python.org/3/library/uuid.html#uuid.uuid1), [`uuid3()`](https://docs.python.org/3/library/uuid.html#uuid.uuid3), [`uuid4()`](https://docs.python.org/3/library/u... |
534,846 | <p>Background: I am using ASP.NET 2.0 (with C#) and the code below is
embedded in a DataGrid control.
I have the following in my .aspx file:</p>
<pre><code> <ASP:TEMPLATECOLUMN HeaderText="Includes CRS Statement?">
<ITEMTEMPLATE>
<asp:RadioButtonList id="rblSCIn... | [
{
"answer_id": 534850,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<pre><code>SelectedIndex='<%# 1 - Convert.ToInt32(...) %>\n</code></pre>\n\n<p>1 - 0 = 1; 1 - 1 = 0. Cases swapped ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52587/"
] | Background: I am using ASP.NET 2.0 (with C#) and the code below is
embedded in a DataGrid control.
I have the following in my .aspx file:
```
<ASP:TEMPLATECOLUMN HeaderText="Includes CRS Statement?">
<ITEMTEMPLATE>
<asp:RadioButtonList id="rblSCIncludesCRSStatement" runat="se... | ```
SelectedIndex='<%# 1 - Convert.ToInt32(...) %>
```
1 - 0 = 1; 1 - 1 = 0. Cases swapped :)
EDIT: There may well be a better way of handling the more general question - this was just the simple approach of solving the 1/0 swap :) |
534,855 | <p>Right now I have vector3 values represented as lists. is there a way to subtract 2 of these like vector3 values, like</p>
<pre><code>[2,2,2] - [1,1,1] = [1,1,1]
</code></pre>
<p>Should I use tuples?</p>
<p>If none of them defines these operands on these types, can I define it instead?</p>
<p>If not, should I cre... | [
{
"answer_id": 534862,
"author": "Andy Mikula",
"author_id": 58114,
"author_profile": "https://Stackoverflow.com/users/58114",
"pm_score": 3,
"selected": false,
"text": "<p>If you have two lists called 'a' and 'b', you can do: <code>[m - n for m,n in zip(a,b)]</code></p>\n"
},
{
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | Right now I have vector3 values represented as lists. is there a way to subtract 2 of these like vector3 values, like
```
[2,2,2] - [1,1,1] = [1,1,1]
```
Should I use tuples?
If none of them defines these operands on these types, can I define it instead?
If not, should I create a new vector3 class? | If this is something you end up doing frequently, and with different operations, you should probably create a class to handle cases like this, or better use some library like [Numpy](http://numpy.scipy.org/).
Otherwise, look for [list comprehensions](http://docs.python.org/tutorial/datastructures.html#list-comprehensi... |
534,859 | <p>I am working on an XSLT transformation to re-arrange XML blocks to validate NewsML files. Some of these files contains encoded characters (such as &amp; &quot; etc...). The problem is the XSLT transformation is converting these characters to their literal string (ie "and", "'"). This is causing problems. I ... | [
{
"answer_id": 534862,
"author": "Andy Mikula",
"author_id": 58114,
"author_profile": "https://Stackoverflow.com/users/58114",
"pm_score": 3,
"selected": false,
"text": "<p>If you have two lists called 'a' and 'b', you can do: <code>[m - n for m,n in zip(a,b)]</code></p>\n"
},
{
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on an XSLT transformation to re-arrange XML blocks to validate NewsML files. Some of these files contains encoded characters (such as & " etc...). The problem is the XSLT transformation is converting these characters to their literal string (ie "and", "'"). This is causing problems. I do not want ... | If this is something you end up doing frequently, and with different operations, you should probably create a class to handle cases like this, or better use some library like [Numpy](http://numpy.scipy.org/).
Otherwise, look for [list comprehensions](http://docs.python.org/tutorial/datastructures.html#list-comprehensi... |
534,860 | <p>Let's say I have an XML doc like this:</p>
<pre><code><books>
<book>1110</book>
<book>1111</book>
<book>1112</book>
<book>1113</book>
</books>
</code></pre>
<p>I'm trying to setup a condition that tests the value of the current node in the... | [
{
"answer_id": 534873,
"author": "Ben Blank",
"author_id": 46387,
"author_profile": "https://Stackoverflow.com/users/46387",
"pm_score": 6,
"selected": true,
"text": "<p>Using <code>.</code> can, indeed, refer to the current (or \"context\") node, but not the way you're using it here. I... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Let's say I have an XML doc like this:
```
<books>
<book>1110</book>
<book>1111</book>
<book>1112</book>
<book>1113</book>
</books>
```
I'm trying to setup a condition that tests the value of the current node in the `for-each`, but I'm doing something wrong:
```
<xsl:for-each select="/books/book">
... | Using `.` can, indeed, refer to the current (or "context") node, but not the way you're using it here. In XPath, `.[foo]` is not valid syntax — you need to use `self::node()[foo]` instead. Also, the `=` operator needs something to match against, in this case the `text()` selector to access the element's text contents:
... |
534,861 | <p>I have a C++ class that compiles fine on linux with gcc and on widows in visual studio. </p>
<p>boid.h:</p>
<pre><code>#ifndef BOID_CLASS_HEADER_DEFINES_H
#define BOID_CLASS_HEADER_DEFINES_H
#include "defines.h"
class Boid {
public:
// Initialize the boid with random position, heading direction and color
... | [
{
"answer_id": 534886,
"author": "vdsf",
"author_id": 358120,
"author_profile": "https://Stackoverflow.com/users/358120",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if you forgot to paste, but you have an unterminated #ifndef </p>\n\n<p>What's inside <em>defines.h</em> ?</p>\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/534861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29505/"
] | I have a C++ class that compiles fine on linux with gcc and on widows in visual studio.
boid.h:
```
#ifndef BOID_CLASS_HEADER_DEFINES_H
#define BOID_CLASS_HEADER_DEFINES_H
#include "defines.h"
class Boid {
public:
// Initialize the boid with random position, heading direction and color
Boid(float SceneRa... | Are you including the C++ header in a .m file?
.m files are treated as .c files with Objective-C extensions.
.mm files are treated as .cpp files with Objective-C extensions, then it's called Objective-C++
Just rename any .m file to .mm, right-click or ctrl-click and select rename on the file in Xcode. |
534,870 | <p>I've read the manual many times, I've scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused?</p>
<p>I can, using Zend_Form, make a form that validates and functions fine. What I cannot do it make a form that looks exactly like I want... | [
{
"answer_id": 534915,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 3,
"selected": false,
"text": "<p>Currently we've got the new and shiny <code>Zend\\Form</code> which is even more complex than the old component but also... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252/"
] | I've read the manual many times, I've scoured the posts offered by Google on the subject, I have even bought a couple of books that deal with ZF. Now, why am I still confused?
I can, using Zend\_Form, make a form that validates and functions fine. What I cannot do it make a form that looks exactly like I want it to lo... | Barrett Conrad's advice is what I would have suggested. Also, keep in mind that you don't need to use a form object to render your form.
One thing you could do is create a form in your view script that has elements with the same name as a form class.
Your HTML form:
```
<form action="/login/" method="post">
<fieldse... |
534,894 | <h3>Duplicate of: <a href="https://stackoverflow.com/questions/53844/how-can-i-evaluate-a-c-expression-dynamically">How can I evaluate a C# expression dynamically?</a></h3>
See also: <a href="https://stackoverflow.com/questions/4629/c-eval-equivalent">C# eval equivalent?</a>
<hr />
<p>How to evaluate expression. Maybe ... | [
{
"answer_id": 534903,
"author": "thinkbeforecoding",
"author_id": 47001,
"author_profile": "https://Stackoverflow.com/users/47001",
"pm_score": 2,
"selected": false,
"text": "<p>Not directly. C# contains no runtime compiler.\nThere is <a href=\"http://tirania.org/blog/archive/2008/Sep-1... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60200/"
] | ### Duplicate of: [How can I evaluate a C# expression dynamically?](https://stackoverflow.com/questions/53844/how-can-i-evaluate-a-c-expression-dynamically)
See also: [C# eval equivalent?](https://stackoverflow.com/questions/4629/c-eval-equivalent)
---
How to evaluate expression. Maybe like:
```
int a=1;
int b=3;
i... | You can take code, and using the CSharpCodeProvider write an Eval function that actually compiles your code into an in-memory assembly and then executes that code.
See this [CodeProject article](http://www.codeproject.com/KB/cs/evalcscode.aspx) for sample source. |
534,957 | <p>I've been researching TCP congestion control recently, however one question plagues me...</p>
<p>If I understand everything correctly, TCP will not send NEW data unless allowed by the cwnd (congestion window) and rwnd (the receiving side's window). In other words:</p>
<pre><code>if(flightSize < MIN(cwnd, rwnd)... | [
{
"answer_id": 535159,
"author": "Emil Sit",
"author_id": 55284,
"author_profile": "https://Stackoverflow.com/users/55284",
"pm_score": 0,
"selected": false,
"text": "<p>Request for clarification: are you considering a single packet loss? Or multiple losses within a window?</p>\n\n<p>In... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43522/"
] | I've been researching TCP congestion control recently, however one question plagues me...
If I understand everything correctly, TCP will not send NEW data unless allowed by the cwnd (congestion window) and rwnd (the receiving side's window). In other words:
```
if(flightSize < MIN(cwnd, rwnd))
{
// Send some new ... | I found the answer in the book "TCP/IP Illustrated, Volume 2", section 25.11, pages 842-844:
>
> [On a retransmission timeout] the next
> send sequence number (snd\_nxt) is set
> to the oldest unacknowledged sequence
> number (snd\_una). ... By moving
> snd\_nxt back, [TCP can begin to
> retransmit all unacknowl... |
534,963 | <p>I like the look of the link dialog here. It darkens the screen and is probably modal (although I haven't tested that I just assume it is). What's a quick and easy way of darkening the screen like that witha jQuery UI Dialog?</p>
| [
{
"answer_id": 534983,
"author": "Samantha Branham",
"author_id": 62590,
"author_profile": "https://Stackoverflow.com/users/62590",
"pm_score": 5,
"selected": true,
"text": "<p>The functionality you're talking about is provided by the <a href=\"http://wmd-editor.com/\" rel=\"noreferrer\"... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | I like the look of the link dialog here. It darkens the screen and is probably modal (although I haven't tested that I just assume it is). What's a quick and easy way of darkening the screen like that witha jQuery UI Dialog? | The functionality you're talking about is provided by the [WYSIWYM Markdown Editor](http://wmd-editor.com/)
To do it with jQuery UI's dialog, try this:
```
$("#something").dialog({ modal: true; });
<div id="something" title="modal dialog">
<p>Add your stuff here.</p>
</div>
```
It's not exactly the same by default... |
534,964 | <p>I am writing a simple proxy in Java. I am having trouble reading the entirety of a given request into a byte array. Specifically, in the following loop, the call to 'read' blocks even though the client has sent all the data that it will (that is, the end of stream is never reached). As I can't be sure that it is ... | [
{
"answer_id": 534970,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 3,
"selected": true,
"text": "<p>Typically in HTTP the <code>Content-Length</code> header indicates how much data you're supposed to read from the stream... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25381/"
] | I am writing a simple proxy in Java. I am having trouble reading the entirety of a given request into a byte array. Specifically, in the following loop, the call to 'read' blocks even though the client has sent all the data that it will (that is, the end of stream is never reached). As I can't be sure that it is time t... | Typically in HTTP the `Content-Length` header indicates how much data you're supposed to read from the stream. Basically it tells you how many bytes follow the double-newline (actually double-`\r\n`) that indicates the end of the HTTP headers. See [W3C](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13) f... |
534,977 | <p>I am trying to alter style at print-time:</p>
<p>Is there an event in javascript that you can listen for for when file>>print is called? What is it? Also - is there a handler for when printing is finished? What is it?</p>
<p>or if there is a better way to do this with some other means, such as style sheets, how... | [
{
"answer_id": 535007,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>IE has onbeforeprint and onafterprint</p>\n"
},
{
"answer_id": 535024,
"author": "danieltalsky",
"author_id... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13276/"
] | I am trying to alter style at print-time:
Is there an event in javascript that you can listen for for when file>>print is called? What is it? Also - is there a handler for when printing is finished? What is it?
or if there is a better way to do this with some other means, such as style sheets, how do you do that? | **Different Style Sheets**
You can specify a different stylesheet for printing.
```
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
```
**One Style Sheet**
As kodecraft mentioned, you can also put the styles into the... |
534,984 | <p>I have the following XAML. Let's say FruitList is a collection of Fruits, each of which has a collection of FruitSeeds. Is there a syntax to bind cbxFruitSeeds to a collection of FruitSeeds, depending on which Fruit is selected in cbxFruits?</p>
<pre><code><GridView>
<GridViewColumn Header="Fruits"&... | [
{
"answer_id": 535041,
"author": "Donnelle",
"author_id": 28074,
"author_profile": "https://Stackoverflow.com/users/28074",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like you're trying to do a cascading combobox.</p>\n\n<p><a href=\"https://stackoverflow.com/questions/202990... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following XAML. Let's say FruitList is a collection of Fruits, each of which has a collection of FruitSeeds. Is there a syntax to bind cbxFruitSeeds to a collection of FruitSeeds, depending on which Fruit is selected in cbxFruits?
```
<GridView>
<GridViewColumn Header="Fruits">
<GridViewColumn... | It looks like you're trying to do a cascading combobox.
[Is there really no way to follow up dataset parent relation in xaml binding?](https://stackoverflow.com/questions/202990/is-there-really-no-way-to-follow-up-dataset-parent-relation-in-xaml-binding) shows how to do a parent-child set up in xaml. |
534,989 | <p>I have a list of two-dimensional points and I want to obtain which of them fall within a semi-circle. </p>
<p>Originally, the target shape was a rectangle aligned with the x and y axis. So the current algorithm sorts the pairs by their X coord and binary searches to the first one that could fall within the rectan... | [
{
"answer_id": 535016,
"author": "Lance Roberts",
"author_id": 13295,
"author_profile": "https://Stackoverflow.com/users/13295",
"pm_score": 3,
"selected": false,
"text": "<p>First, translate & rotate the semi-circle so that one end is on the negative X-axis, and the other end is on ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64844/"
] | I have a list of two-dimensional points and I want to obtain which of them fall within a semi-circle.
Originally, the target shape was a rectangle aligned with the x and y axis. So the current algorithm sorts the pairs by their X coord and binary searches to the first one that could fall within the rectangle. Then it... | Checking whether a point is inside or outside a semi-circle (or a rectangle for that matter) is a constant-time operation.
Checking N points lie inside or outside a semi-circle or rectangle is O(N).
Sorting your N points is O(N\*lg(N)).
It is asymptotically faster to test all points sequentially than it is to sor... |
534,999 | <p>I saw this code in Erlang:</p>
<pre><code>[X-$0 || X<-someFun()]
</code></pre>
<p>In that line I found the <code>-$0</code> syntax very useful.</p>
<p>I read the code and estimated what it means, but I'm not quite sure: is it split all numbers?</p>
<p>I'd like to see the explanation or man page of that syntax... | [
{
"answer_id": 535400,
"author": "womble",
"author_id": 60003,
"author_profile": "https://Stackoverflow.com/users/60003",
"pm_score": 5,
"selected": true,
"text": "<p>What that code is doing is taking the output from <code>someFun()</code> (which needs to return a list), and for each ele... | 2009/02/11 | [
"https://Stackoverflow.com/questions/534999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59597/"
] | I saw this code in Erlang:
```
[X-$0 || X<-someFun()]
```
In that line I found the `-$0` syntax very useful.
I read the code and estimated what it means, but I'm not quite sure: is it split all numbers?
I'd like to see the explanation or man page of that syntax but I can't find it. Can anyone show me the right pag... | What that code is doing is taking the output from `someFun()` (which needs to return a list), and for each element in the list it is assigning the element's value to the variable `X` and then subtracting the ASCII value of the character `0` from that value. The resulting list is then the value of that whole expression.... |
535,004 | <p>I have a string containing the <a href="https://en.wikipedia.org/wiki/Unix_time" rel="noreferrer">UNIX Epoch time</a>, and I need to convert it to a Java Date object.</p>
<pre><code>String date = "1081157732";
DateFormat df = new SimpleDateFormat(""); // This line
try {
Date expiry = df.parse(date);
} catch (Par... | [
{
"answer_id": 535013,
"author": "tcurdt",
"author_id": 33165,
"author_profile": "https://Stackoverflow.com/users/33165",
"pm_score": 3,
"selected": false,
"text": "<pre><code>long timestamp = Long.parseLong(date)\nDate expiry = new Date(timestamp * 1000)\n</code></pre>\n"
},
{
"... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/264/"
] | I have a string containing the [UNIX Epoch time](https://en.wikipedia.org/wiki/Unix_time), and I need to convert it to a Java Date object.
```
String date = "1081157732";
DateFormat df = new SimpleDateFormat(""); // This line
try {
Date expiry = df.parse(date);
} catch (ParseException ex) {
ex.getStackTrace();
}
... | How about just:
```
Date expiry = new Date(Long.parseLong(date));
```
EDIT: as per [rde6173](https://stackoverflow.com/users/62195/rde6173)'s answer and taking a closer look at the input specified in the question , "1081157732" appears to be a seconds-based epoch value so you'd want to multiply the long from parseLo... |
535,020 | <p>PHP must track the amount of CPU time a particular script has used in order to enforce the max_execution_time limit. </p>
<p>Is there a way to get access to this inside of the script? I'd like to include some logging with my tests about how much CPU was burnt in the actual PHP (the time is not incremented when th... | [
{
"answer_id": 535033,
"author": "danieltalsky",
"author_id": 22452,
"author_profile": "https://Stackoverflow.com/users/22452",
"pm_score": 4,
"selected": false,
"text": "<p>The cheapest and dirtiest way to do it is simply make <code>microtime()</code> calls at places in your code you wa... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23524/"
] | PHP must track the amount of CPU time a particular script has used in order to enforce the max\_execution\_time limit.
Is there a way to get access to this inside of the script? I'd like to include some logging with my tests about how much CPU was burnt in the actual PHP (the time is not incremented when the script i... | On unixoid systems (and in php 7+ on Windows as well), you can use [getrusage](http://php.net/getrusage), like:
```
// Script start
$rustart = getrusage();
// Code ...
// Script end
function rutime($ru, $rus, $index) {
return ($ru["ru_$index.tv_sec"]*1000 + intval($ru["ru_$index.tv_usec"]/1000))
- ($rus["r... |
535,037 | <p>I've created a custom control using C#, .Net3.5, and Visual Studio 2008.</p>
<p>I'm then adding that control to another control by dragging it from the toolbox.</p>
<p>After doing this when I try to compile I get an error as follows:</p>
<pre><code>Error 1 Warning as Error: Field 'MyNamespace.MyControl._myCus... | [
{
"answer_id": 537272,
"author": "Chris Holmes",
"author_id": 62186,
"author_profile": "https://Stackoverflow.com/users/62186",
"pm_score": 2,
"selected": false,
"text": "<p>Have you adjusted the constructor of the custom control in any way? The default constructor for controls is a para... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | I've created a custom control using C#, .Net3.5, and Visual Studio 2008.
I'm then adding that control to another control by dragging it from the toolbox.
After doing this when I try to compile I get an error as follows:
```
Error 1 Warning as Error: Field 'MyNamespace.MyControl._myCustomControl' is never assigne... | Have you adjusted the constructor of the custom control in any way? The default constructor for controls is a parameterless one, and I know I've had trouble in the past when creating a constructor for my controls that requires parameters. In those cases I always provide two constructors. That way the parameterless one ... |
535,039 | <p>I have highly optimized piece of C++ and making even small changes in places far from hot spots can hit performance as much as 20%. After deeper investigation it turned out to be (probably) slightly different registers used in hot spots.
I can control inlineing with always_inline attribute, but can I control registe... | [
{
"answer_id": 535050,
"author": "Gregor Brandt",
"author_id": 62488,
"author_profile": "https://Stackoverflow.com/users/62488",
"pm_score": -1,
"selected": false,
"text": "<p>It depends on the processor you are using. Or should I say, yes you can with the register keyword, but this is ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61342/"
] | I have highly optimized piece of C++ and making even small changes in places far from hot spots can hit performance as much as 20%. After deeper investigation it turned out to be (probably) slightly different registers used in hot spots.
I can control inlineing with always\_inline attribute, but can I control register ... | If you really want to mess with the register alloation then you can force GCC to allocate local and global variables in certain registers.
You do this with a special variable declaration like this:
```
register int test_integer asm ("EBX");
```
Works for other architectures as well, just replace EBX with a target ... |
535,043 | <p>This is related to: <a href="https://stackoverflow.com/questions/309491/how-do-i-read-the-results-of-a-system-call-in-c">How do I read the results of a system() call in C++?</a></p>
<p>I am trying to do the exact the same thing only that my program needs to pass 'multiple parameters with spaces' to the command. I n... | [
{
"answer_id": 535046,
"author": "John T",
"author_id": 36457,
"author_profile": "https://Stackoverflow.com/users/36457",
"pm_score": -1,
"selected": false,
"text": "<p>I think <a href=\"http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx\" rel=\"nofollow noreferrer\">ShellExecu... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45216/"
] | This is related to: [How do I read the results of a system() call in C++?](https://stackoverflow.com/questions/309491/how-do-i-read-the-results-of-a-system-call-in-c)
I am trying to do the exact the same thing only that my program needs to pass 'multiple parameters with spaces' to the command. I need the command line ... | The lowest level Windows API function used by \_popen() and system() is CreateProcess().
However CreateProcess() is not that simple to use - especially when you want to get the process'es output or write to the process'es input.
CreateProcess() will definitely work with file names that contain space characters (as lo... |
535,047 | <p>I'm new to Rails and I'm aware it has things such as unit-testing built in. But I'm interested in doing some more simple tests that are equivalent to your "printf" in C. So I'm testing a login page I've written and want to trace the code to see what each line like my find methods are returning. I try outputting with... | [
{
"answer_id": 535051,
"author": "Abie",
"author_id": 53166,
"author_profile": "https://Stackoverflow.com/users/53166",
"pm_score": 1,
"selected": false,
"text": "<p>Are you familiar with ruby-debug?</p>\n\n<ol>\n<li>Install the <code>ruby-debug</code> gem.</li>\n<li><p>Start your server... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58521/"
] | I'm new to Rails and I'm aware it has things such as unit-testing built in. But I'm interested in doing some more simple tests that are equivalent to your "printf" in C. So I'm testing a login page I've written and want to trace the code to see what each line like my find methods are returning. I try outputting with "p... | I use puts statements all the time as well as the ruby debugger! It's great.
In rails you can do a couple things. I put "puts" in my code and when I run script/server at the command line, the output appears in my Terminal.app. I am running a Mac, but I am sure that there is a similar way to trace the activity of your... |
535,052 | <p>gawk doesn't seem to match six digit fields - or n digit fields using the {n,m} quantifiers</p>
<p>It does match [0-9][0-9][0-9][0-9][0-9][0-9] ok. </p>
<p>Doesn't seem to support \d\d\d\d\d\d either. </p>
<p>Do i need to turn on extended reg ex, or does it just not support that. </p>
<p>Tnx</p>
| [
{
"answer_id": 535075,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "<p>You need to specify the \"<code>--re-interval</code>\" (or \"<code>-W re-interval</code>\") flag to take advantage of... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | gawk doesn't seem to match six digit fields - or n digit fields using the {n,m} quantifiers
It does match [0-9][0-9][0-9][0-9][0-9][0-9] ok.
Doesn't seem to support \d\d\d\d\d\d either.
Do i need to turn on extended reg ex, or does it just not support that.
Tnx | You need to specify the "`--re-interval`" (or "`-W re-interval`") flag to take advantage of this behavior.
```
echo 12345 | gawk --re-interval '/[0-9]{5}/{print}{}'
12345
echo 12345 | gawk --re-interval '/[0-9]{6}/{print}{}'
<no output>
``` |
535,060 | <p>I want to enable NSZombies for my iPhone app.</p>
<p>I have read several articles online and I am still unsure of the exact procedure.</p>
<p>I know I have to set the Environment Variables, which I have done:</p>
<pre><code>NSZombieEnabled = YES
NSDebugEnabled = YES
NSDeallocateZombies = NO
</code></pre>
<p>I th... | [
{
"answer_id": 535298,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 4,
"selected": true,
"text": "<p>You don't have to include NSDebug.h or import any special frameworks to use NSZombies. Basically, turn 'em on in your... | 2009/02/11 | [
"https://Stackoverflow.com/questions/535060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48311/"
] | I want to enable NSZombies for my iPhone app.
I have read several articles online and I am still unsure of the exact procedure.
I know I have to set the Environment Variables, which I have done:
```
NSZombieEnabled = YES
NSDebugEnabled = YES
NSDeallocateZombies = NO
```
I think (I'm not sure), I have to import NSD... | You don't have to include NSDebug.h or import any special frameworks to use NSZombies. Basically, turn 'em on in your environment variables, and then, if you attempt to message a dealloc'd object, THEN you'll see something in your console, along the lines of:
`2009-02-10 21:17:08.546 MyApp[16926:20b] *** -[CFString _c... |