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 |
|---|---|---|---|---|---|---|
159,339 | <p>I'm not sure if the term's actually "Array Addition". </p>
<p>I'm trying to understand what does the following line do:</p>
<pre><code>int var[2 + 1] = {2, 1};
</code></pre>
<p>How is that different from <code>int var[3]</code>?</p>
<p>I've been using Java for several years, so I'd appreciate if explained using ... | [
{
"answer_id": 159352,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>How is that different from <code>int var[3]</code>?</p>\n</blockquote>\n\n<p>In no way that I can ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24280/"
] | I'm not sure if the term's actually "Array Addition".
I'm trying to understand what does the following line do:
```
int var[2 + 1] = {2, 1};
```
How is that different from `int var[3]`?
I've been using Java for several years, so I'd appreciate if explained using Java-friendly words.
Edit: Thousands of thanks to ... | It's not different. C++ allows expressions (even non-constant expressions) in the subscripts of array declarations (with some limitations; anything other than the initial subscript on a multi-dimensional array must be constant).
```
int var[]; // illegal
int var[] = {2,1}; // automatically sized to 2
int var[3] = {2... |
159,359 | <p>I know we cannot do this at class level but at method level we can always do this. </p>
<pre><code>var myList=new List<string> // or something else like this
</code></pre>
<p>This question came to my mind since wherever we declare variable like this. We always provide the type information at the RHS of the e... | [
{
"answer_id": 159401,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": false,
"text": "<p>The compiler guys just didn't implement the support.</p>\n\n<p>It's entirely compiler magic, and the compiler does... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22858/"
] | I know we cannot do this at class level but at method level we can always do this.
```
var myList=new List<string> // or something else like this
```
This question came to my mind since wherever we declare variable like this. We always provide the type information at the RHS of the expression. So compiler doesn't n... | There are technical issues with implementing this feature. The common cases seem simple but the tougher cases (e.g., fields referencing other fields in chains or cycles, expressions which contain anonymous types) are not.
See Eric Lippert's blog for an in-depth explanation: [Why no var on fields?](http://blogs.msdn.co... |
159,373 | <p>Using .Net 3.0 and VS2005. </p>
<p>The objects in question are consumed from a WCF service then serialized back into XML for a legacy API. So rather than serializing the TestObject, it was serializing .TestObject which was missing the [XmlRoot] attribute; however, all the [Xml*] attributes for the child elements we... | [
{
"answer_id": 177169,
"author": "hurst",
"author_id": 10991,
"author_profile": "https://Stackoverflow.com/users/10991",
"pm_score": -1,
"selected": true,
"text": "<p>I found someone who provides a means to solve this situation:</p>\n\n<p><a href=\"http://www.request-response.com/blog/Pe... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24279/"
] | Using .Net 3.0 and VS2005.
The objects in question are consumed from a WCF service then serialized back into XML for a legacy API. So rather than serializing the TestObject, it was serializing .TestObject which was missing the [XmlRoot] attribute; however, all the [Xml\*] attributes for the child elements were in the... | I found someone who provides a means to solve this situation:
[Matevz Gacnik's Weblog](http://www.request-response.com/blog/PermaLink,guid,efa4e231-ddf1-48f4-9a26-54363e799d42.aspx)
Using that approach of `XmlAttributeOverrides`, I wrote the following:
```
private static XmlSerializer GetOverridedSerializer()
... |
159,393 | <p>I want to create a script that parses or makes sense of apache's error log to see what the most recent error was. I was wondering if anyone out there has something that does this or has any ideas where to start?</p>
| [
{
"answer_id": 159452,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 5,
"selected": true,
"text": "<p>There are a few things to consider first:</p>\n\n<ol>\n<li>Firstly, your PHP user may not have access to Apache's log ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] | I want to create a script that parses or makes sense of apache's error log to see what the most recent error was. I was wondering if anyone out there has something that does this or has any ideas where to start? | There are a few things to consider first:
1. Firstly, your PHP user may not have access to Apache's log files.
2. Secondly, PHP and Apache aren't going to tell you where said log file is,
3. Lastly, Apache log files can get quite large.
However, if none of these apply, you can use the normal file reading commands to ... |
159,423 | <p>I'm currently writing a simple .sh script to parse an Exim log file for strings matching " o' ". Currently, when viewing output.txt, all that is there is a 0 printed on every line(606 lines). I'm guessing my logic is wrong, as awk does not throw any errors.</p>
<p>Here is my code(updated for concatenation and count... | [
{
"answer_id": 159450,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "<p><code>+</code> means numerical addition in awk. If you want to concatenate, just place the constants and/or expressions sepa... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2153/"
] | I'm currently writing a simple .sh script to parse an Exim log file for strings matching " o' ". Currently, when viewing output.txt, all that is there is a 0 printed on every line(606 lines). I'm guessing my logic is wrong, as awk does not throw any errors.
Here is my code(updated for concatenation and counter issues)... | There is no real need for the grep here. Let awk select the matching lines for you (and fixing your concatenation bug as per ΤΖΩΤΖΙΟΥ):
```
awk '/o'\''/ {
line = "> ";
for(i = 20; i <= 33; i++) {
line = line " " $i;
}
print line;
}' /var/log/ex... |
159,456 | <p>I have a database in the following format:</p>
<pre><code> ID TYPE SUBTYPE COUNT MONTH
1 A Z 1 7/1/2008
1 A Z 3 7/1/2008
2 B C 2 7/2/2008
1 A Z 3 7/2/2008
</code></pre>
<p>Can I use SQL to convert it i... | [
{
"answer_id": 159488,
"author": "Bob Probst",
"author_id": 12424,
"author_profile": "https://Stackoverflow.com/users/12424",
"pm_score": 3,
"selected": false,
"text": "<pre><code>select id,\nsum(case when type = 'A' and subtype = 'Z' then [count] else 0 end) as A_Z,\nsum(case when type ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23133/"
] | I have a database in the following format:
```
ID TYPE SUBTYPE COUNT MONTH
1 A Z 1 7/1/2008
1 A Z 3 7/1/2008
2 B C 2 7/2/2008
1 A Z 3 7/2/2008
```
Can I use SQL to convert it into this:
```
ID A_Z ... | SQL Server 2005 offers a very useful PIVOT and UNPIVOT operator which allow you to make this code maintenance-free using PIVOT and some code generation/dynamic SQL
```
/*
CREATE TABLE [dbo].[stackoverflow_159456](
[ID] [int] NOT NULL,
[TYPE] [char](1) NOT NULL,
[SUBTYPE] [char](1) NOT NULL,
[COUNT] [in... |
159,469 | <p>Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities.</p>
<pre><code>@MappedSuperclass
public abstract class Swab implements ISwab {
...
private Collection<SwabAccounts> accounts;
...
}
@Entity
@Table(name="switches")
@DiscriminatorColumn(name="type")
@Discriminator... | [
{
"answer_id": 162898,
"author": "Nicolas",
"author_id": 1730,
"author_profile": "https://Stackoverflow.com/users/1730",
"pm_score": 1,
"selected": false,
"text": "<p>According to the error message and what I figure from your code, the error seems to be in the persistence.xml file, can y... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22763/"
] | Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities.
```
@MappedSuperclass
public abstract class Swab implements ISwab {
...
private Collection<SwabAccounts> accounts;
...
}
@Entity
@Table(name="switches")
@DiscriminatorColumn(name="type")
@DiscriminatorValue(value="DMS500")... | define this entity in class tag inside the persistence.xml |
159,506 | <p>Can I programatically set the position of a WPF ListBox's scrollbar? By default, I want it to go in the center.</p>
| [
{
"answer_id": 159525,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": -1,
"selected": false,
"text": "<p>I don't think ListBoxes have that, but ListViews have the <a href=\"http://msdn.microsoft.com/en-us/library/system.wi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | Can I programatically set the position of a WPF ListBox's scrollbar? By default, I want it to go in the center. | To move the vertical scroll bar in a ListBox do the following:
1. Name your list box (x:Name="myListBox")
2. Add Loaded event for the Window (Loaded="Window\_Loaded")
3. Implement Loaded event using method: ScrollToVerticalOffset
Here is a working sample:
XAML:
```
<Window x:Class="ListBoxScrollPosition.Views.Main... |
159,523 | <p>When I call <code>Response.Redirect(someUrl)</code> I get the following HttpException:</p>
<blockquote>
<p>Cannot redirect after HTTP headers have been sent.</p>
</blockquote>
<p>Why do I get this? And how can I fix this issue?</p>
| [
{
"answer_id": 159529,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "<p>A Redirect can only happen if the first line in an HTTP message is \"<code>HTTP/1.x 3xx Redirect Reason</code>\".</p>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23886/"
] | When I call `Response.Redirect(someUrl)` I get the following HttpException:
>
> Cannot redirect after HTTP headers have been sent.
>
>
>
Why do I get this? And how can I fix this issue? | According to the MSDN documentation for `Response.Redirect(string url)`, it will throw an HttpException when "a redirection is attempted after the HTTP headers have been sent". Since `Response.Redirect(string url)` uses the Http "Location" response header (<http://en.wikipedia.org/wiki/HTTP_headers#Responses>), calling... |
159,541 | <p>I'm running a Django site using the fastcgi interface to nginx. However, some pages are being served truncated (i.e. the page source just stops, sometimes in the middle of a tag). How do I fix this (let me know what extra information is needed, and I'll post it)</p>
<p>Details:</p>
<p>I'm using flup, and spawning ... | [
{
"answer_id": 159819,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>What fastcgi interface are you using and how. Is it flup? If yes, paste the way you spawn the server and how i... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2933/"
] | I'm running a Django site using the fastcgi interface to nginx. However, some pages are being served truncated (i.e. the page source just stops, sometimes in the middle of a tag). How do I fix this (let me know what extra information is needed, and I'll post it)
Details:
I'm using flup, and spawning the fastcgi serve... | Check your error logs for "Permission denied" errors writing to `.../nginx/tmp/...` files. Nginx will work fine unless it needs temporary space, and that typically happens at 32K boundaries. If you find these errors, make sure the tmp directory is writable by the user nginx runs as. |
159,554 | <p>I'm looking for a built-in function/extended function in T-SQL for string manipulation similar to the <code>String.Format</code> method in .NET.</p>
| [
{
"answer_id": 159579,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>Raw t-sql is limited to CHARINDEX(), PATINDEX(), REPLACE(), and SUBSTRING() for string manipulation. But with sql ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking for a built-in function/extended function in T-SQL for string manipulation similar to the `String.Format` method in .NET. | If you are using SQL Server 2012 and above, you can use `FORMATMESSAGE`. eg.
```
DECLARE @s NVARCHAR(50) = 'World';
DECLARE @d INT = 123;
SELECT FORMATMESSAGE('Hello %s, %d', @s, @d)
-- RETURNS 'Hello World, 123'
```
---
More examples from MSDN: [FORMATMESSAGE](https://learn.microsoft.com/en-us/sql/t-sql/functions/... |
159,567 | <p>How do I parse the first, middle, and last name out of a fullname field with SQL? </p>
<p>I need to try to match up on names that are not a direct match on full name. I'd like to be able to take the full name field and break it up into first, middle and last name. </p>
<p>The data does not include any prefixes or... | [
{
"answer_id": 159595,
"author": "Josh Millard",
"author_id": 13600,
"author_profile": "https://Stackoverflow.com/users/13600",
"pm_score": 3,
"selected": false,
"text": "<p>Unless you have very, very well-behaved data, this is a non-trivial challenge. A naive approach would be to token... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/73794/"
] | How do I parse the first, middle, and last name out of a fullname field with SQL?
I need to try to match up on names that are not a direct match on full name. I'd like to be able to take the full name field and break it up into first, middle and last name.
The data does not include any prefixes or suffixes. The mid... | Here is a self-contained example, with easily manipulated test data.
With this example, if you have a name with more than three parts, then all the "extra" stuff will get put in the LAST\_NAME field. An exception is made for specific strings that are identified as "titles", such as "DR", "MRS", and "MR".
If the midd... |
159,590 | <p>I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems.</p>
<p>So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a common recur... | [
{
"answer_id": 159619,
"author": "Chris Shaffer",
"author_id": 6744,
"author_profile": "https://Stackoverflow.com/users/6744",
"pm_score": 5,
"selected": false,
"text": "<p>Strive to make your recursive call <a href=\"http://en.wikipedia.org/wiki/Tail_recursion\" rel=\"noreferrer\">Tail ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems.
So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a common recursion appro... | Usually, I replace a recursive algorithm by an iterative algorithm by pushing the parameters that would normally be passed to the recursive function onto a stack. In fact, you are replacing the program stack by one of your own.
```js
var stack = [];
stack.push(firstObject);
// while not empty
while (stack.length) {
... |
159,594 | <p>I've organized my code hierarchically and I find myself crawling up the tree using code like the following.</p>
<pre><code>File clientFolder = task.getActionPlan().getClientFile().getClient().getDocumentsFolder();
</code></pre>
<p>I'm not drilling down into the <code>task</code> object; I'm drilling up to its pare... | [
{
"answer_id": 159608,
"author": "Bill",
"author_id": 14547,
"author_profile": "https://Stackoverflow.com/users/14547",
"pm_score": 0,
"selected": false,
"text": "<p><strong>The biggest flag in the world.</strong> </p>\n\n<p>You cannot check easily if any of those invokations returns a n... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | I've organized my code hierarchically and I find myself crawling up the tree using code like the following.
```
File clientFolder = task.getActionPlan().getClientFile().getClient().getDocumentsFolder();
```
I'm not drilling down into the `task` object; I'm drilling up to its parents, so I don't think I'm losing anyt... | the flag is red, and it says two things in **bold**:
* to follow the chain it is necessary for the calling code to know the entire tree structure, which is not good encapsulation, and
* if the hierarchy ever changes you will have a lot of code to edit
and one thing in parentheses:
* use a property, i.e. task.ActionP... |
159,598 | <p>This snippet works well if I try to write in a user directory but as soon as I try to write in Program Files, it just executes silently and the file has not been copied (no exception). If I try to copy the file in C:\ or in C:\Windows I catch an UnauthorizedAccessException.</p>
<p>Do you know another way to get the... | [
{
"answer_id": 159605,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Don't write in the Program Files folder.</strong></p>\n\n<p>That's a big no-no, and will especially cause p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24291/"
] | This snippet works well if I try to write in a user directory but as soon as I try to write in Program Files, it just executes silently and the file has not been copied (no exception). If I try to copy the file in C:\ or in C:\Windows I catch an UnauthorizedAccessException.
Do you know another way to get the permissio... | If you are running under Vista then the system just redirects writes to the program files folder, this is done so old program that keep their configuration in the program directory will continue to work when the user is not an Admin (or UAC is enabled).
All you have to do is add a manifest to your program that specify... |
159,599 | <p>I have a .net project that has a web reference to a service. I would like to update that web reference as part of every build. Is that possible?</p>
| [
{
"answer_id": 159617,
"author": "azamsharp",
"author_id": 3797,
"author_profile": "https://Stackoverflow.com/users/3797",
"pm_score": 1,
"selected": false,
"text": "<p>Also, when you are deploying your webservices on production make sure that they are set as Dynamic and not static. </p>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15903/"
] | I have a .net project that has a web reference to a service. I would like to update that web reference as part of every build. Is that possible? | You can use MSBuild script with a task that calls [wsdl.exe](http://msdn.microsoft.com/en-us/library/7h3ystb6(VS.80).aspx)
```
<Target Name="UpdateWebReference">
<Message Text="Updating Web Reference..."/>
<Exec Command="wsdl.exe /o "$(OutDir)" /n "$(WebServiceNamespace)" "$(PathToWe... |
159,615 | <p>When running command-line queries in MySQL you can optionally use '<strong>\G</strong>' as a statement terminator, and instead of the result set columns being listed horizontally across the screen, it will list each column vertically, which the corresponding data to the right. Is there a way to the same or a similar... | [
{
"answer_id": 161151,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 3,
"selected": true,
"text": "<p>I don't think such an option is available with the DB2 command line client. See <a href=\"http://www.dbforums.com/showthread... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8636/"
] | When running command-line queries in MySQL you can optionally use '**\G**' as a statement terminator, and instead of the result set columns being listed horizontally across the screen, it will list each column vertically, which the corresponding data to the right. Is there a way to the same or a similar thing with the ... | I don't think such an option is available with the DB2 command line client. See <http://www.dbforums.com/showthread.php?t=708079> for some suggestions. For a more general set of information about the DB2 command line client you might check out the IBM DeveloperWorks article [DB2's Command Line Processor and Scripting](... |
159,704 | <p>What options are there for serialization when returning instances of custom classes from a WebService?</p>
<p>We have some classes with a number of child collection class properties as well as other properties that may or may not be set depending on usage. These objects are returned from an ASP.NET .asmx WebServic... | [
{
"answer_id": 159811,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <code>System.Runtime.Serialization.Json.</code><a href=\"http://pietschsoft.com/post/2008/02/NET-35-J... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4299/"
] | What options are there for serialization when returning instances of custom classes from a WebService?
We have some classes with a number of child collection class properties as well as other properties that may or may not be set depending on usage. These objects are returned from an ASP.NET .asmx WebService decorated... | If you don't use code-generated classes, you can decorate your properties with the [ScriptIgnoreAttribute](http://msdn.microsoft.com/en-us/library/system.web.script.serialization.scriptignoreattribute.aspx) to tell the serializer to ignore certain properties. Xml serialization has a similar attribute.
Of course, you c... |
159,705 | <p>I am checking whether the new name already exists or not.</p>
<p>Code 1</p>
<pre><code>if(cmbxExistingGroups.Properties.Items.Cast<string>().ToList().Exists(txt => txt==txtNewGroup.Text.Trim())) {
MessageBox.Show("already exists.", "Add new group");
}
</code></pre>
<p>Otherwise I could have... | [
{
"answer_id": 159724,
"author": "jeffm",
"author_id": 1544,
"author_profile": "https://Stackoverflow.com/users/1544",
"pm_score": 4,
"selected": false,
"text": "<p>I appreciate the cleverness of the first sample (assuming it works), but the second one is a lot easier for the next person... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22858/"
] | I am checking whether the new name already exists or not.
Code 1
```
if(cmbxExistingGroups.Properties.Items.Cast<string>().ToList().Exists(txt => txt==txtNewGroup.Text.Trim())) {
MessageBox.Show("already exists.", "Add new group");
}
```
Otherwise I could have written:
Code 2
```
foreach(var str in ... | I appreciate the cleverness of the first sample (assuming it works), but the second one is a lot easier for the next person who has to maintain the code to figure out. |
159,720 | <p>Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:</p>
<pre class="lang-cs prettyprint-override"><code>// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()
</code></pre>
<p>In Python, I have seen the above but I have also... | [
{
"answer_id": 159745,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 11,
"selected": true,
"text": "<p>See Python <a href=\"https://www.python.org/dev/peps/pep-0008/#function-and-variable-names\" rel=\"noreferrer\">PEP 8: F... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:
```cs
// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()
```
In Python, I have seen the above but I have also seen underscores being used:
```py
# python example
this_is... | See Python [PEP 8: Function and Variable Names](https://www.python.org/dev/peps/pep-0008/#function-and-variable-names):
>
> Function names should be [lowercase, with words separated by underscores](https://en.wikipedia.org/wiki/Snake_case) as necessary to improve readability.
>
>
> Variable names follow the same co... |
159,769 | <p>I have a complex query with group by and order by clause and I need a sorted row number (1...2...(n-1)...n) returned with every row. Using a ROWNUM (value is assigned to a row after it passes the predicate phase of the query but before the query does any sorting or aggregation) gives me a non-sorted list (4...567...... | [
{
"answer_id": 159779,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": true,
"text": "<p>Is there a reason that you can't just do</p>\n\n<pre><code>SELECT rownum, a.* \n FROM (<<your complex query i... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4235/"
] | I have a complex query with group by and order by clause and I need a sorted row number (1...2...(n-1)...n) returned with every row. Using a ROWNUM (value is assigned to a row after it passes the predicate phase of the query but before the query does any sorting or aggregation) gives me a non-sorted list (4...567...123... | Is there a reason that you can't just do
```
SELECT rownum, a.*
FROM (<<your complex query including GROUP BY and ORDER BY>>) a
``` |
159,821 | <p>In an app I'm working on, I have a plain style UITableView that can contain a section containing zero rows. I want to be able to scroll to this section using scrollToRowAtIndexPath:atScrollPosition:animated: but I get an error when I try to scroll to this section due to the lack of child rows.</p>
<p>Apple's calend... | [
{
"answer_id": 159854,
"author": "Mark Bessey",
"author_id": 17826,
"author_profile": "https://Stackoverflow.com/users/17826",
"pm_score": -1,
"selected": false,
"text": "<p>I think a blank row is probably the only way to go there. Is it possible to redesign the UI such that the \"empty\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17188/"
] | In an app I'm working on, I have a plain style UITableView that can contain a section containing zero rows. I want to be able to scroll to this section using scrollToRowAtIndexPath:atScrollPosition:animated: but I get an error when I try to scroll to this section due to the lack of child rows.
Apple's calendar applica... | UPDATE: Looks like this bug is fixed in iOS 3.0. You can use the following `NSIndexPath` to scroll to a section containing 0 rows:
```
[NSIndexPath indexPathForRow:NSNotFound inSection:section]
```
I'll leave my original workaround here for anyone still maintaining a project using the 2.x SDK.
---
Found a decent w... |
159,842 | <p>Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector.</p>
<p>If I would like to separate the JavaScript from markup into different files is there still a way to evaluate my JavaScript file so the angle bracket percents are interpolated ... | [
{
"answer_id": 159865,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "<p>No, you'll need to refactor your JavaScript to accept that information as parameters.</p>\n\n<p>So, instead of </p>\n\n<pr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4521/"
] | Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector.
If I would like to separate the JavaScript from markup into different files is there still a way to evaluate my JavaScript file so the angle bracket percents are interpolated before reachin... | If you want to evaluate `<% code blocks %>` as ASP.NET code in a JavaScript file, you can just put the JavaScript in an ASPX file and reference it from a SCRIPT element.
`script.js.aspx`:
```
function hideElements()
{ <% foreach(var elementId in Request.QueryString["hide"].Split(',') { %>
jQuery('#' + <%= element... |
159,853 | <p>I have some local changes to an open source project which uses Subversion as its source control. (I do not have commit access on the original project repository.)</p>
<p>My change adds a file, but this file is not included in the output of "svn diff". (It may be worth noting that the new file is a binary, not pla... | [
{
"answer_id": 159866,
"author": "Mark Roddy",
"author_id": 9940,
"author_profile": "https://Stackoverflow.com/users/9940",
"pm_score": 0,
"selected": false,
"text": "<p>If you're building a patch, you might want to use plain old 'diff' with the --new-file option which treats the missing... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17732/"
] | I have some local changes to an open source project which uses Subversion as its source control. (I do not have commit access on the original project repository.)
My change adds a file, but this file is not included in the output of "svn diff". (It may be worth noting that the new file is a binary, not plain text.)
H... | The fact that your file is binary is exactly why it is not displayed I'm afraid. Subversion's diff command only does textual diffs/patches (even though Subversion internally can handle binary file differences efficiently between versions). |
159,856 | <p>I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework.</p>
<p>In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error:</p>
<... | [
{
"answer_id": 162689,
"author": "gyrolf",
"author_id": 23772,
"author_profile": "https://Stackoverflow.com/users/23772",
"pm_score": 3,
"selected": true,
"text": "<p>Create a separate config file for log4net with root element log4net.</p>\n\n<p>In TestFixtureSetup create a FileInfo obje... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24174/"
] | I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework.
In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error:
```
System.Con... | Create a separate config file for log4net with root element log4net.
In TestFixtureSetup create a FileInfo object for this config file and give it as argument to log4net.Config.XmlConfigurator.Configure( ). |
159,864 | <p>I'm working on a control to tie together the view from one ListView to another so that when the master ListView is scrolled, the child ListView view is updated to match. </p>
<p>So far I've been able to get the child ListViews to update their view when the master scrollbar buttons are clicked. The problem is that... | [
{
"answer_id": 166063,
"author": "Yuval Peled",
"author_id": 20257,
"author_profile": "https://Stackoverflow.com/users/20257",
"pm_score": 0,
"selected": false,
"text": "<p>A naive solution to your problem can be handling the paint message in the parent list view and checking if the link... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1314/"
] | I'm working on a control to tie together the view from one ListView to another so that when the master ListView is scrolled, the child ListView view is updated to match.
So far I've been able to get the child ListViews to update their view when the master scrollbar buttons are clicked. The problem is that when clicki... | I wanted to do the same thing, and after searching around I found your code here, which helped, but of course didn't solve the problem. But after playing around with it, I have found a solution.
The key came when I realized that since the scroll buttons work, that you can use that to make the slider work. In other wor... |
159,886 | <p>I've seen this is various codebases, and wanted to know if this generally frowned upon or not.</p>
<p>For example:</p>
<pre><code>public class MyClass
{
public int Id;
public MyClass()
{
Id = new Database().GetIdFor(typeof(MyClass));
}
}
</code></pre>
| [
{
"answer_id": 159894,
"author": "Franci Penov",
"author_id": 17028,
"author_profile": "https://Stackoverflow.com/users/17028",
"pm_score": 1,
"selected": false,
"text": "<p>The only problem I can think of with this approach is that any errors from the DB initialization will be propagate... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] | I've seen this is various codebases, and wanted to know if this generally frowned upon or not.
For example:
```
public class MyClass
{
public int Id;
public MyClass()
{
Id = new Database().GetIdFor(typeof(MyClass));
}
}
``` | There are several reasons this is not generally considered good design some of which like causing difficult unit testing and difficulty of handling errors have already been mentioned.
The main reason I would choose not to do so is that your object and the data access layer are now very tightly coupled which means that... |
159,914 | <p>Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML?</p>
<p>I have a '<em>User Profile</em>' form where I want to disable part of it for a '<em>Non-Premium</em>' member, but want the user to see what is behind the form and place a '<em>Call to Action</em>' on to... | [
{
"answer_id": 159962,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 6,
"selected": false,
"text": "<p>Add this to your HTML:</p>\n\n<pre><code><div id=\"darkLayer\" class=\"darkClass\" style=\"display:none\"></d... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8534/"
] | Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML?
I have a '*User Profile*' form where I want to disable part of it for a '*Non-Premium*' member, but want the user to see what is behind the form and place a '*Call to Action*' on top of it.
Does anybody know an ... | You might try the jQuery [BlockUI](http://malsup.com/jquery/block/) plugin. It's quite flexible and is very easy to use, if you don't mind the dependency on jQuery. It supports [element-level](http://malsup.com/jquery/block/#element) blocking as well an overlay message, which seems to be what you need.
The code to use... |
159,924 | <p>I'm slowly moving all of my <code>LAMP websites</code> from <code>mysql_</code> functions to <code>PDO</code> functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following:</p>
<pre><code>foreach ($database->query("SELECT * FROM widgets") as... | [
{
"answer_id": 159967,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 3,
"selected": false,
"text": "<p>According to the <a href=\"http://ca3.php.net/manual/en/pdo.query.php\" rel=\"nofollow noreferrer\">PHP documentation... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | I'm slowly moving all of my `LAMP websites` from `mysql_` functions to `PDO` functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following:
```
foreach ($database->query("SELECT * FROM widgets") as $results)
{
echo $results["widget_name"];
}
```... | Here is an example for using PDO to connect to a DB, to tell it to throw Exceptions instead of php errors (will help with your debugging), and using parameterised statements instead of substituting dynamic values into the query yourself (highly recommended):
```
// connect to PDO
$pdo = new PDO("mysql:host=localhost;d... |
159,934 | <p>How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offspring. I would be i... | [
{
"answer_id": 159968,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 4,
"selected": true,
"text": "<p>Well, this is a \"normal\" one-to-many relationship and the method you suggest is the classical one for solving it.</p>\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] | How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offspring. I would be inclined... | Well, this is a "normal" one-to-many relationship and the method you suggest is the classical one for solving it.
Note that two tables are denormalized (I can't point out exactly where the superkey-is-not-well-should-be-subset-of-other-key-fsck-I-forgot part is, but I'm pretty sure it's there somewhere); the intuitive... |
159,950 | <p>How do I change the system-wide short date format in Ubuntu? For example, Thunderbird is showing dates in the DD/MM/YY format, and I would like to change it to MM/DD/YY or YYYY-MM-DD.</p>
<p>The best information I can find so far is in this thread:</p>
<p><a href="http://ubuntuforums.org/showthread.php?t=193916" ... | [
{
"answer_id": 160036,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 1,
"selected": false,
"text": "<p>Thunderbird uses the system's date format, and that format depends on the system's locale settings. You have two options:</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24311/"
] | How do I change the system-wide short date format in Ubuntu? For example, Thunderbird is showing dates in the DD/MM/YY format, and I would like to change it to MM/DD/YY or YYYY-MM-DD.
The best information I can find so far is in this thread:
<http://ubuntuforums.org/showthread.php?t=193916>
Edit: I want to change th... | * Install and launch "dconf Editor", navigate to com -> canonical -> indicator -> datetime.
* Set the value of `time-format` to `custom`.
* Customize the Time & Date format by editing the value of `custom-time-format`, e.g. set it to `%Y-%m-%d %H:%M:%S` for "2017-12-31 23:59:59" format.
* Re-login to see effect of the ... |
159,978 | <p>What are differences between declaring a method in a base type "<code>virtual</code>" and then overriding it in a child type using the "<code>override</code>" keyword as opposed to simply using the "<code>new</code>" keyword when declaring the matching method in the child type? </p>
| [
{
"answer_id": 159993,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 9,
"selected": true,
"text": "<p>The \"new\" keyword doesn't override, it signifies a new method that has nothing to do with the base class method. </p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9898/"
] | What are differences between declaring a method in a base type "`virtual`" and then overriding it in a child type using the "`override`" keyword as opposed to simply using the "`new`" keyword when declaring the matching method in the child type? | The "new" keyword doesn't override, it signifies a new method that has nothing to do with the base class method.
```
public class Foo
{
public bool DoSomething() { return false; }
}
public class Bar : Foo
{
public new bool DoSomething() { return true; }
}
public class Test
{
public static void Main ()... |
159,990 | <p>I've done some Python but have just now starting to use Ruby<br>
I could use a good explanation of the difference between "self" in these two languages. </p>
<p><strong>Obvious on first glance:</strong><br>
Self is not a keyword in Python, but there is a "self-like" value no matter what you call it.<br>
Python met... | [
{
"answer_id": 160017,
"author": "interstar",
"author_id": 8482,
"author_profile": "https://Stackoverflow.com/users/8482",
"pm_score": 3,
"selected": false,
"text": "<p>Well, I don't know much about Ruby. But the obvious point about Python's \"self\" is that it's not a \"keyword\" ...it'... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2242/"
] | I've done some Python but have just now starting to use Ruby
I could use a good explanation of the difference between "self" in these two languages.
**Obvious on first glance:**
Self is not a keyword in Python, but there is a "self-like" value no matter what you call it.
Python methods receive self as an exp... | Python is designed to support more than just object-oriented programming. Preserving the same interface between methods and functions lets the two styles interoperate more cleanly.
Ruby was built from the ground up to be object-oriented. Even the literals are objects (evaluate 1.class and you get Fixnum). The language... |
160,009 | <p>I went to all the documentation, also I went to the IRC channel (BTW a great community) and they told me that is not possible to create a model and limit choices in a field where the 'current user' is in a ForeignKey.
I will try to explain this with an example:</p>
<pre><code>class Project(models.Model):
name = m... | [
{
"answer_id": 160035,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": -1,
"selected": false,
"text": "<p>Hmmm, I don't fully understand your question. But if you can't do it when you declare the model maybe you can achieve the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16342/"
] | I went to all the documentation, also I went to the IRC channel (BTW a great community) and they told me that is not possible to create a model and limit choices in a field where the 'current user' is in a ForeignKey.
I will try to explain this with an example:
```
class Project(models.Model):
name = models.CharFiel... | Use threadlocals if you want to get **current** user that edits this model. Threadlocals middleware puts current user into process-wide variable. Take this middleware
```
from threading import local
_thread_locals = local()
def get_current_user():
return getattr(getattr(_thread_locals, 'user', None),'id',None)
c... |
160,022 | <p>Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name value pairs of a ResourceManager through reflection, or something... | [
{
"answer_id": 160054,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 2,
"selected": false,
"text": "<p>I think you can use something like <a href=\"http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getmanif... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] | Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name value pairs of a ResourceManager through reflection, or something?
*... | You can use the ResourceSet to do that, only it loads all the data into memory if you enumerate it. Here y'go:
```
// At startup.
ResourceManager mgr = Resources.ResourceManager;
List<string> keys = new List<string>();
ResourceSet set = mgr.GetResourceSet(CultureInfo.CurrentCulture, true, true);
f... |
160,030 | <p>Is there a macro that does it? Which DTE objects to use?</p>
| [
{
"answer_id": 160039,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 2,
"selected": false,
"text": "<p>I don't know what DTE functions to use, but you could very simply record a macro that could pretty much do it:</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20310/"
] | Is there a macro that does it? Which DTE objects to use? | (This is not quite what you're asking for, but almost:)
You can put a breakpoint on **every member function of a class** in Visual Studio by bringing up the *New Breakpoint* dialog and entering:
```
CMyClass::*
```
See <http://blogs.msdn.com/b/habibh/archive/2009/09/10/class-breakpoint-how-to-set-a-breakpoint-on-a-... |
160,045 | <p>Is there a way to place a watch on variable and only have Visual Studio break when that value changes?</p>
<p>It would make it so much easier to find tricky state issues.</p>
<p>Can this be done?</p>
<p>Breakpoint conditions still need a breakpoint set, and I'd rather set a watch and let Visual Studio set the bre... | [
{
"answer_id": 160048,
"author": "Oskar",
"author_id": 5472,
"author_profile": "https://Stackoverflow.com/users/5472",
"pm_score": 2,
"selected": false,
"text": "<p>Right click on the breakpoint works fine for me (though mostly I am using it for conditional breakpoints on specific variab... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | Is there a way to place a watch on variable and only have Visual Studio break when that value changes?
It would make it so much easier to find tricky state issues.
Can this be done?
Breakpoint conditions still need a breakpoint set, and I'd rather set a watch and let Visual Studio set the breakpoints at state change... | In the Visual Studio 2005 menu:
*Debug* -> *New Breakpoint* -> *New Data Breakpoint*
Enter:
```
&myVariable
``` |
160,051 | <p>I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" user. I have to be able to join against t... | [
{
"answer_id": 160062,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 0,
"selected": false,
"text": "<p>Since the primary user is a function of the computer and the user I would tend to go with your approach of having the prima... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9617/"
] | I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" user. I have to be able to join against the pr... | Option 3, though it may feel strange, is the closest to what you want to model. You'd do something like:
```
User {
UserId
PRIMARY KEY (UserId)
}
Computer {
ComputerId, PrimaryUserId
PRIMARY KEY (UserId)
FOREIGN KEY (ComputerId, PrimaryUserId)
REFERENCES Computer_User (ComputerId, UserId)
... |
160,104 | <p>I've been using this long command:</p>
<pre><code>svn st | awk '/\?/ {print $2}' | xargs svn add
</code></pre>
<p>Similarly, to svn rm files I accidentally deleted with normal rm with :</p>
<pre><code>svn st | awk '/\!/ {print $2}' | xargs svn rm --force
</code></pre>
<p>I guess I can write a bash function to do... | [
{
"answer_id": 160177,
"author": "Brandon DuRette",
"author_id": 17834,
"author_profile": "https://Stackoverflow.com/users/17834",
"pm_score": 3,
"selected": false,
"text": "<p>I use a generalization of the command line that you run, called <code>svnapply.sh</code>. I did not write it, b... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13200/"
] | I've been using this long command:
```
svn st | awk '/\?/ {print $2}' | xargs svn add
```
Similarly, to svn rm files I accidentally deleted with normal rm with :
```
svn st | awk '/\!/ {print $2}' | xargs svn rm --force
```
I guess I can write a bash function to do these two, but I'd prefer an interactive add/rm ... | I use a generalization of the command line that you run, called `svnapply.sh`. I did not write it, but I don't remember where I found it. Hopefully, the original author will forgive me for reposting it here:
```
#!/bin/bash
#
# Applies arbitrary commands to any svn status. e.g.
#
# Delete all non-svn files (escape the... |
160,141 | <p>C# novice here, when the int 'max' below is 0 I get a divide by zero error, I can see why this happens but how should I handle this when max is 0? position is also an int.</p>
<pre><code> private void SetProgressBar(string text, int position, int max)
{
try
{
int percent = (100 * ... | [
{
"answer_id": 160146,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 4,
"selected": false,
"text": "<pre><code>int percent = 0\nif (max != 0) percent = (100*position) / max\n</code></pre>\n"
},
{
"answer_id": 160148,... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | C# novice here, when the int 'max' below is 0 I get a divide by zero error, I can see why this happens but how should I handle this when max is 0? position is also an int.
```
private void SetProgressBar(string text, int position, int max)
{
try
{
int percent = (100 * position) / ma... | ```
int percent = 0
if (max != 0) percent = (100*position) / max
``` |
160,144 | <p>How can I find the XY coordinates of an HTML element (DIV) from JavaScript if they were not explicitly set?</p>
| [
{
"answer_id": 160155,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 3,
"selected": false,
"text": "<p>That can be tricky depending on browser and version. I would suggest using <a href=\"http://jquery.com\" rel=\"noreferre... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I find the XY coordinates of an HTML element (DIV) from JavaScript if they were not explicitly set? | Here's how I do it:
```
// Based on: http://www.quirksmode.org/js/findpos.html
var getCumulativeOffset = function (obj) {
var left, top;
left = top = 0;
if (obj.offsetParent) {
do {
left += obj.offsetLeft;
top += obj.offsetTop;
} while (obj = obj.offsetParent);
... |
160,147 | <p>Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so:</p>
<pre><code>class A {
public:
A(const B& b): mB(b) { };
private:
B mB;
};
</code></pre>
<p>Is there a way to catch exceptions that might ... | [
{
"answer_id": 160163,
"author": "Mark Bessey",
"author_id": 17826,
"author_profile": "https://Stackoverflow.com/users/17826",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see how you'd do that with initializer-list syntax, but I'm also a bit sceptical that you'll be able to do ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] | Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so:
```
class A {
public:
A(const B& b): mB(b) { };
private:
B mB;
};
```
Is there a way to catch exceptions that might be thrown by mB's copy-constru... | Have a read of <http://weseetips.wordpress.com/tag/exception-from-constructor-initializer-list/>)
Edit: After more digging, these are called "Function try blocks".
I confess I didn't know this either until I went looking. You learn something every day! I don't know if this is an indictment of how little I get to use ... |
160,162 | <p>I'm trying to commit to an SVN server hosted on my school's network. I have installed SVN 1.5.2 with binaries downloaded from CollabNet <a href="http://www.collab.net/downloads/community/" rel="nofollow noreferrer">here</a>. The error reported is:</p>
<pre><code>svn: Commit failed (details follow):
svn: MKACTIVITY ... | [
{
"answer_id": 160366,
"author": "Zed",
"author_id": 19202,
"author_profile": "https://Stackoverflow.com/users/19202",
"pm_score": 0,
"selected": false,
"text": "<p>Not all forms of accessing a repository allow all forms of access. If you checked out your code via a read-only method, yo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10140/"
] | I'm trying to commit to an SVN server hosted on my school's network. I have installed SVN 1.5.2 with binaries downloaded from CollabNet [here](http://www.collab.net/downloads/community/). The error reported is:
```
svn: Commit failed (details follow):
svn: MKACTIVITY of '/opensvn/cs598r/!svn/act/defe271c-f33b-4851-a70... | Since you can commit from other machines, and your team members can commit but not from your machine, I'd say it's probably an issue with your subversion client. I'd suggest you uninstall the client you have, then install the version that's being run on the server just to be safe. |
160,175 | <p>If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have
$f->{$x}{$y}, I want something like</p>
<pre><code>foreach ($x, $y) (deep_keys %{$f})
{
}
</code></pre>
<p>instead of </p>
<pre><code>foreac... | [
{
"answer_id": 160210,
"author": "Axeman",
"author_id": 11289,
"author_profile": "https://Stackoverflow.com/users/11289",
"pm_score": 1,
"selected": false,
"text": "<p>It's easy enough if all you want to do is operate on values, but if you want to operate on keys, you need specifications... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14167/"
] | If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have
$f->{$x}{$y}, I want something like
```
foreach ($x, $y) (deep_keys %{$f})
{
}
```
instead of
```
foreach $x (keys %f)
{
foreach $y (... | Here's an option. This works for arbitrarily deep hashes:
```
sub deep_keys_foreach
{
my ($hashref, $code, $args) = @_;
while (my ($k, $v) = each(%$hashref)) {
my @newargs = defined($args) ? @$args : ();
push(@newargs, $k);
if (ref($v) eq 'HASH') {
deep_keys_foreach($v, $co... |
160,204 | <p>I'm a Linux guy and I'm used to copying directory trees with <code>cp -a</code>. OS X doesn't have <code>-a</code> option on <code>cp</code>... but it does have the <code>ditto</code> command. I'm reading the man on <code>ditto</code> now, but is there anything I should specifically be looking out for?</p>
| [
{
"answer_id": 160242,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 0,
"selected": false,
"text": "<p>As j04t pointed out that should be <code>cp -pR</code></p>\n\n<p><strike>On OS X, you would do</p>\n\n<pre><code>cp -dRL s... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601671/"
] | I'm a Linux guy and I'm used to copying directory trees with `cp -a`. OS X doesn't have `-a` option on `cp`... but it does have the `ditto` command. I'm reading the man on `ditto` now, but is there anything I should specifically be looking out for? | According to the **cp** man page **cp -a** is the same as **cp -dpR** which is
```
-p = preserve mode,ownership,timestamps
-R = recursive
-d = no dereference and preserve links
```
The OS X equivalent would be
**cp -pPR**
```
-p = preserve
-R = recursive
-P = no symbolic links are followed -- can be added but this... |
160,214 | <p>I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code:</p>
<pre><code> protected override void OnItemDrag(ItemDragEventArgs e)
{
base.OnItemDrag(e);
ListViewItem item = e.Item as ListViewItem;
s... | [
{
"answer_id": 160235,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": 0,
"selected": false,
"text": "<p>Subitems are only ordered by column index unluckily. So you'd have to access them like:</p>\n\n<pre><code>protected ov... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053/"
] | I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code:
```
protected override void OnItemDrag(ItemDragEventArgs e)
{
base.OnItemDrag(e);
ListViewItem item = e.Item as ListViewItem;
string val = ite... | The key of the `ListViewSubItem` is the `Name` property as described [here](http://msdn.microsoft.com/en-us/library/1x4396ba.aspx).
Setting the Name equal to the column name, would allow you to index into the SubItems by the name of the column.
And some code as an example
`ListViewItem myListViewItem = new ListView... |
160,216 | <p>I'd like something like this:</p>
<pre><code>each[i_, {1,2,3},
Print[i]
]
</code></pre>
<p>Or, more generally, to destructure arbitrary stuff in the list you're looping over, like:</p>
<pre><code>each[{i_, j_}, {{1,10}, {2,20}, {3,30}},
Print[i*j]
]
</code></pre>
<p>Usually you want to use <code>Map</code> o... | [
{
"answer_id": 160219,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": false,
"text": "<p>The built-in <code>Scan</code> basically does this, though it's uglier:</p>\n\n<pre>\n Scan[Print[#]&, {1,2,3}]\n</pre... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | I'd like something like this:
```
each[i_, {1,2,3},
Print[i]
]
```
Or, more generally, to destructure arbitrary stuff in the list you're looping over, like:
```
each[{i_, j_}, {{1,10}, {2,20}, {3,30}},
Print[i*j]
]
```
Usually you want to use `Map` or other purely functional constructs and eschew a non-functi... | Thanks to [Pillsy](https://stackoverflow.com/users/85467/pillsy) and [Leonid Shifrin](https://stackoverflow.com/users/565518/leonid-shifrin), here's what I'm now using:
```
SetAttributes[each, HoldAll]; (* each[pattern, list, body] *)
each[pat_, lst_List, bod_] := (* converts pattern ... |
160,218 | <p>I'm personally an advocate of the <a href="https://en.wikipedia.org/wiki/%3F:" rel="nofollow noreferrer">ternary operator</a>: <code>() ? : </code></p>
<p>I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often.</p>
<p>What... | [
{
"answer_id": 160221,
"author": "John Mulder",
"author_id": 2242,
"author_profile": "https://Stackoverflow.com/users/2242",
"pm_score": 4,
"selected": false,
"text": "<p>In my mind, it only makes sense to use the ternary operator in cases where an expression is needed.</p>\n\n<p>In othe... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21804/"
] | I'm personally an advocate of the [ternary operator](https://en.wikipedia.org/wiki/%3F:): `() ? :`
I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often.
What are your feelings on it? What interesting code have you seen u... | Use it for **simple expressions only**:
```
int a = (b > 10) ? c : d;
```
**Don't chain or nest** ternary operators as it hard to read and confusing:
```
int a = b > 10 ? c < 20 ? 50 : 80 : e == 2 ? 4 : 8;
```
Moreover, when using ternary operator, consider formatting the code in a way that improves readability:
... |
160,233 | <p>I tried this in mysql:</p>
<pre><code>mysql> alter table region drop column country_id;
</code></pre>
<p>And got this:</p>
<pre><code>ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to
'./product/region' (errno: 150)
</code></pre>
<p>Any ideas? Foreign key stuff?</p>
| [
{
"answer_id": 160261,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 0,
"selected": false,
"text": "<p>I'd guess foreign key constraint problem. Is country_id used as a foreign key in another table?</p>\n\n<p>I'm not DB gur... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601671/"
] | I tried this in mysql:
```
mysql> alter table region drop column country_id;
```
And got this:
```
ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to
'./product/region' (errno: 150)
```
Any ideas? Foreign key stuff? | You usually get this error if your tables use the InnoDB engine. In that case you would have to drop the foreign key, and then do the alter table and drop the column.
But the tricky part is that you can't drop the foreign key using the column name, but instead you would have to find the name used to index it. To find ... |
160,245 | <p>I'm trying:</p>
<pre><code>import commands
print commands.getoutput("ps -u 0")
</code></pre>
<p>But it doesn't work on os x.
os instead of commands gives the same output:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND</p>
<p>nothing more</p>
| [
{
"answer_id": 160271,
"author": "jmissao",
"author_id": 20883,
"author_profile": "https://Stackoverflow.com/users/20883",
"pm_score": 0,
"selected": false,
"text": "<p>It works if you use os instead of commands:</p>\n\n<pre><code>import os\nprint os.system(\"ps -u 0\")\n</code></pre>\n"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] | I'm trying:
```
import commands
print commands.getoutput("ps -u 0")
```
But it doesn't work on os x.
os instead of commands gives the same output:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
nothing more | This works on Mac OS X 10.5.5. Note the capital **-U** option. Perhaps that's been your problem.
```
import subprocess
ps = subprocess.Popen("ps -U 0", shell=True, stdout=subprocess.PIPE)
print ps.stdout.read()
ps.stdout.close()
ps.wait()
```
Here's the Python version
```
Python 2.5.2 (r252:60911, Feb 22 2008, 07:5... |
160,250 | <p>Just that, if you embed an icon:</p>
<pre><code>[Embed(source='icons/checkmark.png')]
private static var CheckMark:Class;
</code></pre>
<p>You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method:</p>
<pre><code>var btn:Button = new Button();
btn... | [
{
"answer_id": 160952,
"author": "Buns of Aluminum",
"author_id": 24246,
"author_profile": "https://Stackoverflow.com/users/24246",
"pm_score": 3,
"selected": true,
"text": "<p>This is the only answer I could find that seemed close: <a href=\"http://blog.xsive.co.nz/archives/234\" rel=\"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16258/"
] | Just that, if you embed an icon:
```
[Embed(source='icons/checkmark.png')]
private static var CheckMark:Class;
```
You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method:
```
var btn:Button = new Button();
btn.setStyle("icon", CheckMark);
```
B... | This is the only answer I could find that seemed close: [Dynamic Icons](http://blog.xsive.co.nz/archives/234) [(example with View Source)](http://blog.xsive.co.nz/flex_source/button_icon_drawing/ButtonTest.html)
His solution involves a custom "DynamicIcon" class which is used in the button's icon setting, and a custom... |
160,298 | <p>This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.</p>
<p>In Python, it's worth mentioning that the problem is somewhat related to <a href="https://stackoverflow.com/questions/773/how-do-i-use-pythons-... | [
{
"answer_id": 160552,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 2,
"selected": false,
"text": "<p>check <a href=\"http://docs.djangoproject.com/en/dev//ref/templates/builtins/#regroup\" rel=\"nofollow noreferrer\">regr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | This is a part algorithm-logic question (how to do it), part implementation question (how to do it best!). I'm working with Django, so I thought I'd share with that.
In Python, it's worth mentioning that the problem is somewhat related to [how-do-i-use-pythons-itertoolsgroupby](https://stackoverflow.com/questions/773/... | Have you tried sorting the list first? The algorithm you proposed should work, albeit with lots of database hits.
```
import itertools
cars = [
{'car': 'X2', 'mods': [1,2]},
{'car': 'Y2', 'mods': [2]},
{'car': 'W2', 'mods': [1]},
{'car': 'X1', 'mods': [1,2]},
{'car': 'W1', 'mods': [1]},
{'car'... |
160,304 | <p>I am using sybase database to query the daily transaction report. I had subquery within my script. </p>
<p>Here as it goes:</p>
<pre><code>SELECT orders.accountid ,items.x,etc
(SELECT charges.mistotal FROM charges where items.id = charges.id)
FROM items,orders
WHERE date = '2008-10-02'
</code></pre>
<p>Here I am ... | [
{
"answer_id": 160322,
"author": "Manuel Ferreria",
"author_id": 4749,
"author_profile": "https://Stackoverflow.com/users/4749",
"pm_score": 2,
"selected": false,
"text": "<p>Under what criteria you choose to select the 25.00 instead of the 7.5?</p>\n\n<p>If its related to the maximum va... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14752/"
] | I am using sybase database to query the daily transaction report. I had subquery within my script.
Here as it goes:
```
SELECT orders.accountid ,items.x,etc
(SELECT charges.mistotal FROM charges where items.id = charges.id)
FROM items,orders
WHERE date = '2008-10-02'
```
Here I am getting the error message as:
> ... | ```
SELECT TOP 1 *
FROM dbo.YourTable
ORDER BY Col DESC
```
In your case, I guess that would be
```
SELECT TOP 1 charges.mistotal
FROM charges where items.id = charges.id
ORDER BY charges.mistotal DESC
``` |
160,315 | <p>I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup.</p>
<p>Unfortunately, there is no obvi... | [
{
"answer_id": 160346,
"author": "Rodrick Chapman",
"author_id": 3927,
"author_profile": "https://Stackoverflow.com/users/3927",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know much about Java (mostly code in C#) but what about having a small loader program written in C or som... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15255/"
] | I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup.
Unfortunately, there is no obvious way to... | ```
public class LockingKeyDemo {
static Toolkit kit = Toolkit.getDefaultToolkit();
public static void main(String[] args) {
System.out.println("caps lock2 = "
+ kit.getLockingKeyState(KeyEvent.VK_CAPS_LOCK));
}
}
``` |
160,318 | <p>The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations.</p>
<p>Something more like the Settlers series.</p>
<p>Let's assume I don't want any graphics at the moment, <strong>that</strong> I think I can mana... | [
{
"answer_id": 160349,
"author": "Zarkonnen",
"author_id": 15255,
"author_profile": "https://Stackoverflow.com/users/15255",
"pm_score": 2,
"selected": false,
"text": "<p>I'm fairly certain you only want to have one thread executing the game logic. Having multiple threads won't speed up ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | The kind of simulation game that I have in mind is the kind where you have things to build in various locations and workers/transporters that connect such locations.
Something more like the Settlers series.
Let's assume I don't want any graphics at the moment, **that** I think I can manage.
So my doubts are the foll... | The normal approach does not use threading at all, but rather implements entities as state-machines. Then your mainloop looks like this:
```
while( 1 )
{
foreach( entity in entlist )
{
entity->update();
}
render();
}
``` |
160,370 | <p>In svn, I have a branch which was created, say at revision 22334. Commits were then made on the branch.</p>
<p>How do I get a list of all files that were changed on the branch compared to what's on the trunk? I do not want to see files that were changed on the trunk between when the branch was created and "now".</p... | [
{
"answer_id": 160395,
"author": "andy",
"author_id": 21482,
"author_profile": "https://Stackoverflow.com/users/21482",
"pm_score": 7,
"selected": true,
"text": "<p>This will do it I think:</p>\n\n<pre><code>svn diff -r 22334:HEAD --summarize <url of the branch>\n</code></pre>\n"
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601671/"
] | In svn, I have a branch which was created, say at revision 22334. Commits were then made on the branch.
How do I get a list of all files that were changed on the branch compared to what's on the trunk? I do not want to see files that were changed on the trunk between when the branch was created and "now". | This will do it I think:
```
svn diff -r 22334:HEAD --summarize <url of the branch>
``` |
160,373 | <pre><code>Function FillAdminAccount() As Boolean
FillAdminAccount = True
Try
SQLconn.ConnectionString = "connect timeout=9999999;" & _
"data source=" & DefaultIserver & ";" & _
"initial catalog=" & Defau... | [
{
"answer_id": 160396,
"author": "oglester",
"author_id": 2017,
"author_profile": "https://Stackoverflow.com/users/2017",
"pm_score": 1,
"selected": false,
"text": "<p>Could it be </p>\n\n<pre><code>as varchar) as 'userpassword'\n</code></pre>\n\n<p>should be </p>\n\n<pre><code>...as v... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21963/"
] | ```
Function FillAdminAccount() As Boolean
FillAdminAccount = True
Try
SQLconn.ConnectionString = "connect timeout=9999999;" & _
"data source=" & DefaultIserver & ";" & _
"initial catalog=" & DefaultIdBase & "; " & _
... | NEVER store actual passwords in the db. Now it looks like your passwords *might* not quite be plain text because of the convert/cast operations, but you still have a problem. At very least any encryption used is easily reversible, and if your sql server ever ends up on a different machine from the application then pass... |
160,382 | <p>I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant.<br>
For exemple:</p>
<pre><code>Label l = new Label("Cat");
</code></pre>
<p>Would become:</p>
<pre><code>Label l = new Label(Constants.CAT);
</code></pre>
<p>And in <cod... | [
{
"answer_id": 160407,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": false,
"text": "<p>Eclipse does do this automatically. Right-click the file, choose \"Source\", then \"Externalize strings\"</p>\n\n<p>... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1406/"
] | I have a rather big number of source files that I need parse and extract all string literals and put them in a file as play old java constant.
For exemple:
```
Label l = new Label("Cat");
```
Would become:
```
Label l = new Label(Constants.CAT);
```
And in `Constants.java` I would have:
```
public final stati... | To complete Peter Kelley answer, you might consider for eclipse IDE the **AST** solution.
You might then write an AST program which parse your source code and does what you want.
A full example is available in this [eclipse corner article](http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_... |
160,391 | <p>I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid.</p>
<p>I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions.</p>
<p>So far it's all working as I expect. I've got some custo... | [
{
"answer_id": 163728,
"author": "Joel B Fant",
"author_id": 22211,
"author_profile": "https://Stackoverflow.com/users/22211",
"pm_score": 1,
"selected": false,
"text": "<p>According to the <a href=\"http://msdn.microsoft.com/en-us/library/ms742521.aspx\" rel=\"nofollow noreferrer\">Data... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] | I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid.
I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions.
So far it's all working as I expect. I've got some custom IValueConverter... | The binding problem comes from the default style for ListBoxItem. By default when applying styles to elements WPF looks for the default styles and applies each property that is not specifically set in the custom style from the default style. Refer to [this great blog post](http://www.interact-sw.co.uk/iangblog/2007/02/... |
160,453 | <p>I have two tables: <code>foos</code> and <code>bars</code>, and there is a many-to-one relationship between them: each <code>foo</code> can have many <code>bars</code>. I also have a view <code>foobars</code>, which joins these two tables (its query is like <code>select foo.*, bar.id from foos, bars where bar.foo_id... | [
{
"answer_id": 160598,
"author": "Bob Probst",
"author_id": 12424,
"author_profile": "https://Stackoverflow.com/users/12424",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think new.foo_id is correct in the context of a delete.</p>\n\n<p>Shouldn't it be DELETE FROM bars WHERE foo... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19922/"
] | I have two tables: `foos` and `bars`, and there is a many-to-one relationship between them: each `foo` can have many `bars`. I also have a view `foobars`, which joins these two tables (its query is like `select foo.*, bar.id from foos, bars where bar.foo_id=foo.id`).
EDIT: You would not be wrong if you said that there... | Rysiek, if I understood correctly, you have text column in `foos` table that is parsed to extract foreign keys pointing to `bars` table. This approach to building relations may be justified in some cases, however almost every guide/tutorial to database programming would discourage doing so. Why not use standard foreign... |
160,467 | <p>I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as:</p>
<pre><code>Seq.Group
</code></pre>
<p>In the SQL source behind the view, the field names are encased in square brackets...</p>
<pre><code>SELECT Table._Gr... | [
{
"answer_id": 160487,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": 1,
"selected": false,
"text": "<p>Just guessing here: did you try escaping the dot? Something like \"[Seq\\.Group]\"?</p>\n"
},
{
"answer_id": 1... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3469/"
] | I need to create an ODBC link from an Access 2003 (Jet) database to a SQL Server hosted view which contains aliased field names containing periods such as:
```
Seq.Group
```
In the SQL source behind the view, the field names are encased in square brackets...
```
SELECT Table._Group AS [Seq.Group]
```
...so SQL Se... | Although I didn't technically end up escaping the dot, your suggestion actually *did* make me realize another alternative. While wondering how I would "pass" the escape code to the "SQL" server, it dawned on me: Why not use a "SQL Pass-Through Query" instead of an ODBC linked table? Since I only need read access to the... |
160,494 | <pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GenericCount
{
class Program
{
static int Count1<T>(T a) where T : IEnumerable<T>
{
return a.Count();
}
static void Main(string[] args)
{
... | [
{
"answer_id": 160516,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 0,
"selected": false,
"text": "<p>Your generic constraint is wrong. You cannot enforce it to implement IEnumerabl<T></p>\n"
},
{
"ans... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GenericCount
{
class Program
{
static int Count1<T>(T a) where T : IEnumerable<T>
{
return a.Count();
}
static void Main(string[] args)
{
List<str... | You want this
```
static int Count1<T>(IEnumerable<T> a)
{
return a.Count();
}
``` |
160,519 | <p>Can this be done w/ linqtosql?</p>
<pre><code>SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime
FROM Incidents
GROUP BY City
</code></pre>
| [
{
"answer_id": 160524,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 2,
"selected": false,
"text": "<p>LINQ to SQL makes good use of partial classes to extend designer generated code. I think you will typically find... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3396/"
] | Can this be done w/ linqtosql?
```
SELECT City, SUM(DATEDIFF(minute,StartDate,Completed)) AS Downtime
FROM Incidents
GROUP BY City
``` | It is in part to support scenarios (WebForms, WinForms, LINQ-to-SQL, etc) mixing generated code with programmer code.
There are more reasons to use it. For example, if you have big classes in large, unwieldy files, but the classes have groups of logically related methods, partial classes may be an option to make your ... |
160,532 | <p>I want to export the contents of several tables from MSAccess2003.
The tables contain unicode Japanese characters.
I want to store them as tilde delimited text files.</p>
<p>I can do this manually using File/Export and, in the 'Advanced' dialog selecting tilde as Field Delimiter and the Unicode as the Code Page.</... | [
{
"answer_id": 161017,
"author": "Richard A",
"author_id": 24355,
"author_profile": "https://Stackoverflow.com/users/24355",
"pm_score": 0,
"selected": false,
"text": "<p>I've got part of the answer:</p>\n\n<p>I'm writing a schema.ini file with VBA, then doing my TransferText. This is cr... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24355/"
] | I want to export the contents of several tables from MSAccess2003.
The tables contain unicode Japanese characters.
I want to store them as tilde delimited text files.
I can do this manually using File/Export and, in the 'Advanced' dialog selecting tilde as Field Delimiter and the Unicode as the Code Page.
I can stor... | I have eventually solved this. (I am now using Access 2007 but had the same problems as with Access 2003.)
First, what didn't work:
TransferText would only make the Header Row unicode and tilde delimited, even with a correctly formatted schema.ini. (No, I didn't put it all on one line, that was just a formatting issu... |
160,534 | <p>I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY.</p>
<p>I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table.</p>
<p>Thats what I need, maybe someone can help me ou... | [
{
"answer_id": 160547,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 6,
"selected": true,
"text": "<pre><code>$(function() {\n $(\"table#mytable td\").mouseover(function() {\n //The onmouseover code\n }).cli... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] | I need to get the "td" element of a table. I do not have the ability to add a mouseover or onclick event to the "td" element, so I need to add them with JQUERY.
I need JQUERY to add the mouseover and onclick event to the all "td" elements in the table.
Thats what I need, maybe someone can help me out? | ```
$(function() {
$("table#mytable td").mouseover(function() {
//The onmouseover code
}).click(function() {
//The onclick code
});
});
``` |
160,550 | <p>I thought people would be working on little code projects together, but I don't see them, so here's an easy one:</p>
<p>Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that zip codes keep getting is... | [
{
"answer_id": 160583,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 7,
"selected": true,
"text": "<p><strong>Javascript Regex Literal</strong>:</p>\n\n<p>US Zip Codes: <code>/(^\\d{5}$)|(^\\d{5}-\\d{4}$)/</code></p>\n\n<p... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2910/"
] | I thought people would be working on little code projects together, but I don't see them, so here's an easy one:
Code that validates a valid US Zip Code. I know there are ZIP code databases out there, but there are still uses, like web pages, quick validation, and also the fact that zip codes keep getting issued, so y... | **Javascript Regex Literal**:
US Zip Codes: `/(^\d{5}$)|(^\d{5}-\d{4}$)/`
```
var isValidZip = /(^\d{5}$)|(^\d{5}-\d{4}$)/.test("90210");
```
Some countries use [Postal Codes](http://en.wikipedia.org/wiki/Postal_code), which would fail this pattern. |
160,555 | <p>Here's the situation:
I'm developing a simple application with the following structure:</p>
<ul>
<li>FormMain (startup point)</li>
<li>FormNotification</li>
<li>CompleFunctions</li>
</ul>
<p>Right?</p>
<p>Well, in <strong>FormMain</strong> I have the following function:</p>
<pre><code>private void DoItInNewThrea... | [
{
"answer_id": 160564,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "<p>You aren't allowed to make WinForms calls from other threads. Look at BeginInvoke in the form -- you can call a deleg... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | Here's the situation:
I'm developing a simple application with the following structure:
* FormMain (startup point)
* FormNotification
* CompleFunctions
Right?
Well, in **FormMain** I have the following function:
```
private void DoItInNewThread(ParameterizedThreadStart pParameterizedThreadStart, object pParameters,... | Almost every GUI library is designed to only allow calls that change the GUI to be made in a single thread designated for that purpose (called the UI thread). If you are in another thread, you are required to arrange for the call to change the GUI to be made in the UI thread. In .NET, the way to do that is to call Invo... |
160,557 | <p>I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). </p>
<pre><code>select validity_Y label=2008
select validity_M label=08
select validity_D label=08
</code></pre>
<p>This part gets repeated a lot throughout the test case. I'd like to reduce it by ... | [
{
"answer_id": 160564,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "<p>You aren't allowed to make WinForms calls from other threads. Look at BeginInvoke in the form -- you can call a deleg... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] | I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day).
```
select validity_Y label=2008
select validity_M label=08
select validity_D label=08
```
This part gets repeated a lot throughout the test case. I'd like to reduce it by defining my custom action ... | Almost every GUI library is designed to only allow calls that change the GUI to be made in a single thread designated for that purpose (called the UI thread). If you are in another thread, you are required to arrange for the call to change the GUI to be made in the UI thread. In .NET, the way to do that is to call Invo... |
160,587 | <p>I'm using <code>Console.WriteLine()</code> from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here?</p>
<p>I can reproduce it by creating a WPF application in VS 2008, and simply a... | [
{
"answer_id": 160597,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 7,
"selected": false,
"text": "<p>Right click on the project, \"Properties\", \"Application\" tab, change \"Output Type\" to \"Console Application\", and t... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18505/"
] | I'm using `Console.WriteLine()` from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here?
I can reproduce it by creating a WPF application in VS 2008, and simply adding `Console.Write... | You'll have to create a Console window manually before you actually call any Console.Write methods. That will init the Console to work properly without changing the project type (which for WPF application won't work).
Here's a complete source code example, of how a ConsoleManager class might look like, and how it can ... |
160,604 | <p>I'm trying to combine a list of functions like so.</p>
<p>I have this:</p>
<pre><code>Func<int, bool>[] criteria = new Func<int, bool>[3];
criteria[0] = i => i % 2 == 0;
criteria[1] = i => i % 3 == 0;
criteria[2] = i => i % 5 == 0;
</code></pre>
<p>And I want this:</p>
<pre><code>Func<int... | [
{
"answer_id": 160661,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 3,
"selected": true,
"text": "<p>This was a guess, as I know little about this stuff, but this seems to fix it:</p>\n\n<pre><code>Func<int, bool>[] c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] | I'm trying to combine a list of functions like so.
I have this:
```
Func<int, bool>[] criteria = new Func<int, bool>[3];
criteria[0] = i => i % 2 == 0;
criteria[1] = i => i % 3 == 0;
criteria[2] = i => i % 5 == 0;
```
And I want this:
```
Func<int, bool>[] predicates = new Func<int, bool>[3];
predicates[0] = i => ... | This was a guess, as I know little about this stuff, but this seems to fix it:
```
Func<int, bool>[] criteria = new Func<int, bool>[3];
criteria[0] = i => i % 2 == 0;
criteria[1] = i => i % 3 == 0;
criteria[2] = i => i % 5 == 0;
Expression<Func<int, bool>>[] results = new Expression<Func<int, bool>>[criteria.Length... |
160,608 | <p>I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the <code>.git</code> repository directory. There are at least three methods I know of:</p>
<ol>
<li><code>git clone</code> followed by removing the <code>.git</code> repository directory.</li>
<li><a hr... | [
{
"answer_id": 160620,
"author": "jperras",
"author_id": 5570,
"author_profile": "https://Stackoverflow.com/users/5570",
"pm_score": 5,
"selected": false,
"text": "<p>From the <a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-checkout-index.html\" rel=\"noreferrer\" title=\"G... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] | I've been wondering whether there is a good "git export" solution that creates a copy of a tree without the `.git` repository directory. There are at least three methods I know of:
1. `git clone` followed by removing the `.git` repository directory.
2. [`git checkout-index`](http://www.kernel.org/pub/software/scm/git/... | Probably the simplest way to achieve this is with [`git archive`](https://git-scm.com/docs/git-archive). If you really need just the expanded tree you can do something like this.
```
git archive master | tar -x -C /somewhere/else
```
Most of the time that I need to 'export' something from git, I want a compressed ar... |
160,611 | <p>I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overridden the configLocations as follows:</p>
<pre><code>protected St... | [
{
"answer_id": 160627,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you're not specifying a database name to connect to, should go something like </p>\n\n<pre><code>jdbc... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] | I'm trying to unit test (JUnit) a DAO i've created. I'm using Spring as my framework, my DAO (JdbcPackageDAO) extends SimpleJdbcDaoSupport. The testing class (JdbcPackageDAOTest) extends AbstractTransactionalDataSourceSpringContextTests. I've overridden the configLocations as follows:
```
protected String[] getConfigL... | In order to have HSQLDB register itself, you need to access its jdbcDriver class. You can do this the same way as in this [example](http://hsqldb.org/doc/guide/running-chapt.html#rgc_connecting_db).
```
Class.forName("org.hsqldb.jdbcDriver");
```
It triggers static initialization of jdbcDriver class, which is:
```
... |
160,614 | <p>I have a Dynamic Data website built in Visual Studio 2008 using .NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine:</p>
<blockquote>
<p>Server Error in '/FlixManagerWeb'
Application.
------------------------------------------------------... | [
{
"answer_id": 160627,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 2,
"selected": false,
"text": "<p>It looks like you're not specifying a database name to connect to, should go something like </p>\n\n<pre><code>jdbc... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2762/"
] | I have a Dynamic Data website built in Visual Studio 2008 using .NET 3.5 SP1. The site works OK on my Vista machine, but I get the following error when running it on a Windows XP machine:
>
> Server Error in '/FlixManagerWeb'
> Application.
> -------------------------------------------------------------------------... | In order to have HSQLDB register itself, you need to access its jdbcDriver class. You can do this the same way as in this [example](http://hsqldb.org/doc/guide/running-chapt.html#rgc_connecting_db).
```
Class.forName("org.hsqldb.jdbcDriver");
```
It triggers static initialization of jdbcDriver class, which is:
```
... |
160,633 | <p>Why are flat text files the state of the art for representing source code?</p>
<p>Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created.</p>
<p>It seems to me that some form of XML or binary data could represent lots of ideas that are very difficult to t... | [
{
"answer_id": 160646,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 8,
"selected": true,
"text": "<ul>\n<li>you can diff them</li>\n<li>you can merge them</li>\n<li>anyone can edit them</li>\n<li>they are simple and ea... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8643/"
] | Why are flat text files the state of the art for representing source code?
Sure - the preprocessor and compiler need to see a flat file representation of the file, but that's easily created.
It seems to me that some form of XML or binary data could represent lots of ideas that are very difficult to track, otherwise.
... | * you can diff them
* you can merge them
* anyone can edit them
* they are simple and easy to deal with
* they are universally accessible to thousands of tools |
160,666 | <p>I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this:</p>
<pre><code><img src="whatever.jpeg" width="100%" height="100%" />
</code></pre>
<p>It just stretches the image and messes up the aspect rat... | [
{
"answer_id": 160674,
"author": "Franci Penov",
"author_id": 17028,
"author_profile": "https://Stackoverflow.com/users/17028",
"pm_score": 2,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><img src=\"whatever.jpeg\" width=\"100%\" height=\"auto\" />\n</code></pre>\n"
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] | I'd like to have an HTML page which displays a single PNG or JPEG image. I want the image to take up the whole screen but when I do this:
```
<img src="whatever.jpeg" width="100%" height="100%" />
```
It just stretches the image and messes up the aspect ratio. How do I solve this so the image has the correct aspect ... | Here's a quick function that will adjust the height or width to 100% depending on which is bigger. Tested in FF3, IE7 & Chrome
```
<html>
<head>
<script>
function resizeToMax(id){
myImage = new Image()
var img = document.getElementById(id);
myImage.src = img.src;
if(myImage.width > myImage.height){
... |
160,697 | <p>I personally like the <em>exclusive or</em>, <code>^</code>, operator when it makes sense in the context of boolean checks because of its conciseness. I much prefer to write</p>
<pre><code>if (boolean1 ^ boolean2)
{
//do it
}
</code></pre>
<p>than</p>
<pre><code>if((boolean1 && !boolean2) || (boolean2 ... | [
{
"answer_id": 160700,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 9,
"selected": true,
"text": "<p>You can simply use <code>!=</code> instead.</p>\n"
},
{
"answer_id": 160701,
"author": "Dre",
"author_id": 2... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17123/"
] | I personally like the *exclusive or*, `^`, operator when it makes sense in the context of boolean checks because of its conciseness. I much prefer to write
```
if (boolean1 ^ boolean2)
{
//do it
}
```
than
```
if((boolean1 && !boolean2) || (boolean2 && !boolean1))
{
//do it
}
```
but I often get confused look... | You can simply use `!=` instead. |
160,724 | <p>I'm working on a Google App Engine project. </p>
<p>My app is working and looking correct locally, but when I try to upload images in an image directory, they're not being displayed at appspot.</p>
<p>As a little troubleshoot, I put a HTML page in "/images/page2.html" and I can load that page at the appspot, but m... | [
{
"answer_id": 165503,
"author": "JJ.",
"author_id": 9106,
"author_profile": "https://Stackoverflow.com/users/9106",
"pm_score": 2,
"selected": false,
"text": "<p>I'll bet your problem is that you're using Windows. </p>\n\n<p>If that's the case, I believe you need a preceding slash for y... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1179/"
] | I'm working on a Google App Engine project.
My app is working and looking correct locally, but when I try to upload images in an image directory, they're not being displayed at appspot.
As a little troubleshoot, I put a HTML page in "/images/page2.html" and I can load that page at the appspot, but my pages don't dis... | I'll bet your problem is that you're using Windows.
If that's the case, I believe you need a preceding slash for your static\_dir value. |
160,726 | <p>I have been thinking a lot about unit testing and how to improve the readability of the unit tests. I thought why not give a character to the classes in the unit test to clarify what they do. </p>
<p>Here is a simple unit test that I wrote: </p>
<pre><code>[TestFixture]
public class when_dave_transfers_money_f... | [
{
"answer_id": 160738,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "<p>How about a private helper method in the test fixture</p>\n\n<pre><code>private Dave GetDave_With_Wamu_And_Woodforest_Accou... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] | I have been thinking a lot about unit testing and how to improve the readability of the unit tests. I thought why not give a character to the classes in the unit test to clarify what they do.
Here is a simple unit test that I wrote:
```
[TestFixture]
public class when_dave_transfers_money_from_wamu_account_to_t... | How about a private helper method in the test fixture
```
private Dave GetDave_With_Wamu_And_Woodforest_AccountsHookedUp()
``` |
160,737 | <p>I would like to create a Crystal Reports report using pre-existing LINQ classes that live in a different project than where the report lives. I can't find a way to do this. I'm using VS2008.</p>
<p>Whenever I expand the "Project Data" tree, I see only classes in my current project. The "History" tree shows me th... | [
{
"answer_id": 160738,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 2,
"selected": false,
"text": "<p>How about a private helper method in the test fixture</p>\n\n<pre><code>private Dave GetDave_With_Wamu_And_Woodforest_Accou... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to create a Crystal Reports report using pre-existing LINQ classes that live in a different project than where the report lives. I can't find a way to do this. I'm using VS2008.
Whenever I expand the "Project Data" tree, I see only classes in my current project. The "History" tree shows me the last 5 clas... | How about a private helper method in the test fixture
```
private Dave GetDave_With_Wamu_And_Woodforest_AccountsHookedUp()
``` |
160,742 | <p>I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this:</p>
<pre><code>using System;
public class ClassName
{
public double TheFunction(double input)
{
// user enter... | [
{
"answer_id": 160745,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "<p>\"{{\" and \"}}\"</p>\n"
},
{
"answer_id": 160747,
"author": "John Millikin",
"author_id": 3560,
... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4797/"
] | I'm trying to generate some code at runtime where I put in some boiler-plate stuff and the user is allowed to enter the actual working code. My boiler-plate code looks something like this:
```
using System;
public class ClassName
{
public double TheFunction(double input)
{
// user entered code here
... | Escape them by doubling them up:
```
string s = String.Format("{{ hello to all }}");
Console.WriteLine(s); //prints '{ hello to all }'
```
From <http://msdn.microsoft.com/en-us/netframework/aa569608.aspx#Question1> |
160,848 | <p>Does the compiler optimize out any multiplications by 1? That is, consider:</p>
<pre><code>int a = 1;
int b = 5 * a;
</code></pre>
<p>Will the expression 5 * a be optimized into just 5? If not, will it if a is defined as:</p>
<pre><code>const int a = 1;
</code></pre>
| [
{
"answer_id": 160850,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 5,
"selected": true,
"text": "<p>It will pre-calculate any constant expressions when it compiles, including string concatenation. Without the <strong><... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16942/"
] | Does the compiler optimize out any multiplications by 1? That is, consider:
```
int a = 1;
int b = 5 * a;
```
Will the expression 5 \* a be optimized into just 5? If not, will it if a is defined as:
```
const int a = 1;
``` | It will pre-calculate any constant expressions when it compiles, including string concatenation. Without the **`const`** it will be left alone.
Your first example compiles to this IL:
```
.maxstack 2
.locals init ([0] int32, [1] int32)
ldc.i4.1 //load 1
stloc.0 //store in 1st local variable
ldc.i4.5 //load 5
... |
160,859 | <p>I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you.</p>
| [
{
"answer_id": 160884,
"author": "Dan Lenski",
"author_id": 20789,
"author_profile": "https://Stackoverflow.com/users/20789",
"pm_score": 1,
"selected": false,
"text": "<p>Where have you seen the phrase used?</p>\n\n<p>\"Binding\" in Python generally refers to the process by which a vari... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15073/"
] | I understand what are lambda functions in Python, but I can't find what is the meaning of "lambda binding" by searching the Python docs.
A link to read about it would be great.
A trivial explained example would be even better.
Thank you. | First, a general definition:
>
> When a program or function statement
> is executed, the current values of
> formal parameters are saved (on the
> stack) and within the scope of the
> statement, they are bound to the
> values of the actual arguments made in
> the call. When the statement is
> exited, the origi... |
160,876 | <p>I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails:</p>
<pre><code>$s = new IO::Socket::INET(
PeerAddr => 'stackoverflow.com',
PeerPort => 80,
Proto => 'tcp... | [
{
"answer_id": 160907,
"author": "oz10",
"author_id": 14069,
"author_profile": "https://Stackoverflow.com/users/14069",
"pm_score": -1,
"selected": false,
"text": "<p>Make sure that you have the statement </p>\n\n<pre><code>use IO::Socket::INET;\n</code></pre>\n\n<p>At the beginning of y... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1265/"
] | I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails:
```
$s = new IO::Socket::INET(
PeerAddr => 'stackoverflow.com',
PeerPort => 80,
Proto => 'tcp',
);
die "Error: $!\n... | From a quick look, the following code from IO::Socket::INET
```
sub _get_addr {
my($sock,$addr_str, $multi) = @_;
my @addr;
if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
(undef, undef, undef, undef, @addr) = gethostbyname($addr_str);
} else {
my $h = inet_aton($addr_str);
pu... |
160,881 | <p>So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects.</p>
<p><i>Outside</i> of writing a custom build Task (which I am not against) does anyone have any suggestions on how b... | [
{
"answer_id": 160907,
"author": "oz10",
"author_id": 14069,
"author_profile": "https://Stackoverflow.com/users/14069",
"pm_score": -1,
"selected": false,
"text": "<p>Make sure that you have the statement </p>\n\n<pre><code>use IO::Socket::INET;\n</code></pre>\n\n<p>At the beginning of y... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18471/"
] | So this is a question for anyone who has had to integrate the building/compilation of legacy projects/code in a Team Build/MSBuild environment - specifically, Visual Basic 6 applications/projects.
*Outside* of writing a custom build Task (which I am not against) does anyone have any suggestions on how best to integrat... | From a quick look, the following code from IO::Socket::INET
```
sub _get_addr {
my($sock,$addr_str, $multi) = @_;
my @addr;
if ($multi && $addr_str !~ /^\d+(?:\.\d+){3}$/) {
(undef, undef, undef, undef, @addr) = gethostbyname($addr_str);
} else {
my $h = inet_aton($addr_str);
pu... |
160,889 | <p>Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?</p>
<p>One example:</p>
<p>I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matc... | [
{
"answer_id": 160895,
"author": "Swaroop C H",
"author_id": 4869,
"author_profile": "https://Stackoverflow.com/users/4869",
"pm_score": 2,
"selected": false,
"text": "<p>Have you looked at <a href=\"http://pyparsing.wikispaces.com/\" rel=\"nofollow noreferrer\">PyParsing</a>?</p>\n\n<p>... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24382/"
] | Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes?
One example:
I have to get all href tags, their corresponding text and some other text based on a different regex.
So I have 3 expressions and would like to tokenize the line and extract tokens of text matching every expres... | If you're specifically after parsing links out of web-pages, then Perl's [WWW::Mechanize](http://search.cpan.org/perldoc?WWW::Mechanize) module will figure things out for you in a very elegant fashion. Here's a sample program that grabs the first page of Stack Overflow and parses out all the links, printing their text ... |
160,890 | <p>I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method:</p>
<pre><code>Random.nextInt(74)
</code></pre>
<p>I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured Goog... | [
{
"answer_id": 160910,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "<p>Same as C, you would do</p>\n\n<pre><code>#include <time.h>\n#include <stdlib.h>\n...\nsrand(time(NULL));\nint ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6044/"
] | I'm a Java head mainly, and I want a way to generate a pseudo-random number between 0 and 74. In Java I would use the method:
```
Random.nextInt(74)
```
I'm not interested in a discussion about seeds or true randomness, just how you accomplish the same task in Objective-C. I've scoured Google, and there just seems t... | You should use the `arc4random_uniform()` function. It uses a superior algorithm to `rand`. You don't even need to set a seed.
```
#include <stdlib.h>
// ...
// ...
int r = arc4random_uniform(74);
```
The `arc4random` man page:
>
>
> ```
> NAME
> arc4random, arc4random_stir, arc4random_addrandom -- arc4 rand... |
160,905 | <p>I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.</p>
<p>Here's my models.py:</p>
<pre><code>class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max... | [
{
"answer_id": 160916,
"author": "John Millikin",
"author_id": 3560,
"author_profile": "https://Stackoverflow.com/users/3560",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>I've tried adding the TechInline class to the inlines list, but that causes a</p>\n \n <p>'TechInL... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/736/"
] | I'm working on what I think is a pretty standard django site, but am having trouble getting my admin section to display the proper fields.
Here's my models.py:
```
class Tech(models.Model):
name = models.CharField(max_length = 30)
class Project(models.Model):
title = models.CharField(max_length = 50)
tec... | >
> I've tried adding the TechInline class to the inlines list, but that causes a
>
>
> 'TechInLine' not defined
>
>
>
Is that a straight copy-paste? It looks like you just made a typo -- try `TechInline` instead of `TechInLine`.
If your syncdb didn't create the proper table, you can do it manually. Execute thi... |
160,923 | <p>I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line. </p>
<p>Something like:</p>
<pre><code>FooBar := Foo(Bar);
SimulateBreakP... | [
{
"answer_id": 160993,
"author": "Joeri Sebrechts",
"author_id": 20980,
"author_profile": "https://Stackoverflow.com/users/20980",
"pm_score": 6,
"selected": true,
"text": "<p>To trigger the debugger from code (supposedly, I don't have a copy of delphi handy to try):</p>\n\n<pre><code>as... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/255/"
] | I am pretty sure I have seen this before, but I haven't found out / remembered how to do it. I want to have a line of code that when executed from the Delphi debugger I want the debugger to pop-up like there was a break point on that line.
Something like:
```
FooBar := Foo(Bar);
SimulateBreakPoint; // Cause break po... | To trigger the debugger from code (supposedly, I don't have a copy of delphi handy to try):
```
asm int 3 end;
```
See this page:
<http://17slon.com/blogs/gabr/2008/03/debugging-with-lazy-breakpoints.html> |
160,924 | <p>Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this:</p>
<pre><code>jeremy@jeremy-desktop:~$ ps aux | grep firefox
jeremy 7451 25.0 27.4 170536 65680 ? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox
jeremy 7578 0.0 0.3 3004 768 pts/0 S+ ... | [
{
"answer_id": 160926,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 10,
"selected": true,
"text": "<pre><code>pkill firefox\n</code></pre>\n\n<p>More information: <a href=\"http://linux.about.com/library/cmd/blcmdl1_pkill.ht... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] | Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do this:
```
jeremy@jeremy-desktop:~$ ps aux | grep firefox
jeremy 7451 25.0 27.4 170536 65680 ? Sl 22:39 1:18 /usr/lib/firefox-3.0.1/firefox
jeremy 7578 0.0 0.3 3004 768 pts/0 S+ 22:44 0:00... | ```
pkill firefox
```
More information: <http://linux.about.com/library/cmd/blcmdl1_pkill.htm> |
160,930 | <p>How can I check if a given number is even or odd in C?</p>
| [
{
"answer_id": 160934,
"author": "Jarod Elliott",
"author_id": 1061,
"author_profile": "https://Stackoverflow.com/users/1061",
"pm_score": 3,
"selected": false,
"text": "<p>I'd say just divide it by 2 and if there is a 0 remainder, it's even, otherwise it's odd.</p>\n\n<p>Using the modul... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24391/"
] | How can I check if a given number is even or odd in C? | Use the modulo (%) operator to check if there's a remainder when dividing by 2:
```
if (x % 2) { /* x is odd */ }
```
A few people have criticized my answer above stating that using x & 1 is "faster" or "more efficient". I do not believe this to be the case.
Out of curiosity, I created two trivial test case progra... |
160,954 | <p>I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database. </p>
<p>database.yml looks like</p>
<pre><code>development:
adapter: postgresql
database: blah blah
...
oracle_db:
adapter: oracle
database: blah bl... | [
{
"answer_id": 160989,
"author": "James Baker",
"author_id": 9365,
"author_profile": "https://Stackoverflow.com/users/9365",
"pm_score": 3,
"selected": true,
"text": "<p>I believe this might have to do with your model name, rather than your connection. The Rails convention is that model... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15046/"
] | I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database.
database.yml looks like
```
development:
adapter: postgresql
database: blah blah
...
oracle_db:
adapter: oracle
database: blah blah
```
My models whi... | I believe this might have to do with your model name, rather than your connection. The Rails convention is that model class names are CamelCase, while the files they reside in are lowercase+underscore.
The "LegacyModel" class should therefore be in `models/legacy_model.rb`. Your statement about `"require 'LegacyDataCl... |
160,960 | <p>I have a function that takes a struct, and I'm trying to store its variables in array:</p>
<pre><code>int detect_prm(Param prm) {
int prm_arr[] = {prm.field1, prm.field2, prm.field3};
return 0;
}
</code></pre>
<p>But with <code>gcc -Wall -ansi -pedantic-errors -Werror</code> I get the following error:</p>
<b... | [
{
"answer_id": 160969,
"author": "Mike Thompson",
"author_id": 2754,
"author_profile": "https://Stackoverflow.com/users/2754",
"pm_score": 5,
"selected": true,
"text": "<p>This is illegal in C. Initializer lists must be constant compile time expressions. Do the following instead:</p>\n\n... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160960",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9628/"
] | I have a function that takes a struct, and I'm trying to store its variables in array:
```
int detect_prm(Param prm) {
int prm_arr[] = {prm.field1, prm.field2, prm.field3};
return 0;
}
```
But with `gcc -Wall -ansi -pedantic-errors -Werror` I get the following error:
>
> initializer element is not computable ... | This is illegal in C. Initializer lists must be constant compile time expressions. Do the following instead:
```
int prm_arr[3];
prm_arr[0] = prm.field1;
prm_arr[1] = prm.field2;
prm_arr[2] = prm.field3;
``` |
160,970 | <p>If I have two variables:</p>
<pre><code>Object obj;
String methodName = "getName";
</code></pre>
<p>Without knowing the class of <code>obj</code>, how can I call the method identified by <code>methodName</code> on it?</p>
<p>The method being called has no parameters, and a <code>String</code> return value. It's <... | [
{
"answer_id": 160976,
"author": "Owen",
"author_id": 11442,
"author_profile": "https://Stackoverflow.com/users/11442",
"pm_score": 8,
"selected": false,
"text": "<p>Use <a href=\"http://java.sun.com/docs/books/tutorial/reflect/member/methodInvocation.html\" rel=\"noreferrer\">method inv... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] | If I have two variables:
```
Object obj;
String methodName = "getName";
```
Without knowing the class of `obj`, how can I call the method identified by `methodName` on it?
The method being called has no parameters, and a `String` return value. It's *a getter for a Java bean*. | Coding from the hip, it would be something like:
```
java.lang.reflect.Method method;
try {
method = obj.getClass().getMethod(methodName, param1.class, param2.class, ..);
} catch (SecurityException e) { ... }
catch (NoSuchMethodException e) { ... }
```
The parameters identify the very specific method you need (i... |
160,974 | <p>Basically I have the following class:</p>
<pre><code>class StateMachine {
...
StateMethod stateA();
StateMethod stateB();
...
};
</code></pre>
<p>The methods stateA() and stateB() should be able return pointers to stateA() and stateB().
How to typedef the StateMethod?</p>
| [
{
"answer_id": 161000,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 2,
"selected": false,
"text": "<p>My philosophy is don't use raw member function pointers. I don't even really know how to do what you want using ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1692070/"
] | Basically I have the following class:
```
class StateMachine {
...
StateMethod stateA();
StateMethod stateB();
...
};
```
The methods stateA() and stateB() should be able return pointers to stateA() and stateB().
How to typedef the StateMethod? | [GotW #57](http://www.gotw.ca/gotw/057.htm) says to use a proxy class with an implicit conversion for this very purpose.
```
struct StateMethod;
typedef StateMethod (StateMachine:: *FuncPtr)();
struct StateMethod
{
StateMethod( FuncPtr pp ) : p( pp ) { }
operator FuncPtr() { return p; }
FuncPtr p;
};
class Sta... |
160,995 | <p>I tried this XAML:</p>
<pre><code><Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" />
</code></pre>
<p>And this C#:</p>
<pre><code>private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs ... | [
{
"answer_id": 161025,
"author": "Michael Brown",
"author_id": 14359,
"author_profile": "https://Stackoverflow.com/users/14359",
"pm_score": 5,
"selected": true,
"text": "<p>Sliders swallow the MouseDown Events (similar to the button).</p>\n\n<p>You can register for the PreviewMouseDown ... | 2008/10/02 | [
"https://Stackoverflow.com/questions/160995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23939/"
] | I tried this XAML:
```
<Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" />
```
And this C#:
```
private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
sliderMouseDown = true;
}
private voi... | Sliders swallow the MouseDown Events (similar to the button).
You can register for the PreviewMouseDown and PreviewMouseUp events which get fired before the slider has a chance to handle them. |
161,003 | <p>I'm in the early phases of developing a brand spanking new site with Spring + Tiles. The site needs dynamically generated breadcrumbs.</p>
<p>What I mean by dynamic is that the user may reach a certain site from multiple starting points. If I have views for Customers, Orders and Products, the user could reach a Pro... | [
{
"answer_id": 161034,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you just use a session variable that stores the trail? Each view would only have to either append itsel... | 2008/10/02 | [
"https://Stackoverflow.com/questions/161003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15114/"
] | I'm in the early phases of developing a brand spanking new site with Spring + Tiles. The site needs dynamically generated breadcrumbs.
What I mean by dynamic is that the user may reach a certain site from multiple starting points. If I have views for Customers, Orders and Products, the user could reach a Product direc... | Why don't you just use a session variable that stores the trail? Each view would only have to either append itself to the variable or reset the variable in case of the 'root' views. The code to append it and the code to show it would always be the same and could go in a generic library, you just would call it with a fl... |
161,022 | <p>I have some styles applied to html for example </p>
<pre><code><body style="background: #C3DAF9;">
</code></pre>
<p>and when I use forms authentication it is ignored. If I put the style into an external .css file then it works. </p>
<p>This doesn't seem like normal behaviour to me. </p>
| [
{
"answer_id": 161062,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 0,
"selected": false,
"text": "<p>That's weird. I've experienced this problem but the other way around: when I use external style sheets the external styl... | 2008/10/02 | [
"https://Stackoverflow.com/questions/161022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24395/"
] | I have some styles applied to html for example
```
<body style="background: #C3DAF9;">
```
and when I use forms authentication it is ignored. If I put the style into an external .css file then it works.
This doesn't seem like normal behaviour to me. | Solved the problem. I'm not sure I understand why it happened but here is the offending code;
```
if (User.Identity.IsAuthenticated) {
if (User.Identity is BookingIdentity) {
BookingIdentity id = (BookingIdentity) User.Identity;
Response.Write("<p/>UserName: " + id.Name);
}
}
```
Removing th... |
161,027 | <p>Let's say I am modelling a process that involves a conversation or exchnage between two actors. For this example, I'll use something easily understandable:-</p>
<ol>
<li>Supplier creates a price list,</li>
<li>Buyer chooses some items to buy and sends a Purchase Order,</li>
<li>Supplier receives the purchase order... | [
{
"answer_id": 161062,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 0,
"selected": false,
"text": "<p>That's weird. I've experienced this problem but the other way around: when I use external style sheets the external styl... | 2008/10/02 | [
"https://Stackoverflow.com/questions/161027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14663/"
] | Let's say I am modelling a process that involves a conversation or exchnage between two actors. For this example, I'll use something easily understandable:-
1. Supplier creates a price list,
2. Buyer chooses some items to buy and sends a Purchase Order,
3. Supplier receives the purchase order and sends the goods.
4. S... | Solved the problem. I'm not sure I understand why it happened but here is the offending code;
```
if (User.Identity.IsAuthenticated) {
if (User.Identity is BookingIdentity) {
BookingIdentity id = (BookingIdentity) User.Identity;
Response.Write("<p/>UserName: " + id.Name);
}
}
```
Removing th... |
161,030 | <p>In .NET is there a way to enable Assembly.Load tracing? I know while running under the debugger it gives you a nice message like "Loaded 'assembly X'" but I want to get a log of the assembly loads of my running application outside the debugger, preferably intermingled with my Debug/Trace log messages. </p>
<p>I'm t... | [
{
"answer_id": 161035,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 5,
"selected": true,
"text": "<p>Get the AppDomain for your application and attach to the AssemblyLoad event.</p>\n\n<p>Example (C#): </p>\n\n<pre><c... | 2008/10/02 | [
"https://Stackoverflow.com/questions/161030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12784/"
] | In .NET is there a way to enable Assembly.Load tracing? I know while running under the debugger it gives you a nice message like "Loaded 'assembly X'" but I want to get a log of the assembly loads of my running application outside the debugger, preferably intermingled with my Debug/Trace log messages.
I'm tracing out... | Get the AppDomain for your application and attach to the AssemblyLoad event.
Example (C#):
```
AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoad);
``` |
161,048 | <p>I am trying to send an email from a site I am building, but it ends up in the yahoo spam folder. It is the email that sends credentials. What can I do to legitimize it?</p>
<pre><code>$header = "From: site <sales@site.com>\r\n";
$header .= "To: $name <$email>\r\n";
$header .= "Subject: $subject\r\n";
$h... | [
{
"answer_id": 161052,
"author": "T Percival",
"author_id": 954,
"author_profile": "https://Stackoverflow.com/users/954",
"pm_score": 3,
"selected": false,
"text": "<ul>\n<li>Don't use HTML in your email.</li>\n<li>Send it via a legitimate mail server with a static IP and reverse-DNS (PT... | 2008/10/02 | [
"https://Stackoverflow.com/questions/161048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3800/"
] | I am trying to send an email from a site I am building, but it ends up in the yahoo spam folder. It is the email that sends credentials. What can I do to legitimize it?
```
$header = "From: site <sales@site.com>\r\n";
$header .= "To: $name <$email>\r\n";
$header .= "Subject: $subject\r\n";
$header .= "Reply-To: site <... | In addition to Ted Percival's suggestions, you could try using [PHPMailer](http://phpmailer.codeworxtech.com/index.php?pg=phpmailer) to create the emails for you rather than manually building the headers. I've used this class extensively and not had any trouble with email being rejected as spam by Yahoo, or anyone else... |