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 |
|---|---|---|---|---|---|---|
445,428 | <p>I am trying to use jQuery's ajax functionality to update data from a web form (ASP.NET MVC). Part of the data comes from a text area, and while is not a huge amount of data, can easily be more than 2 KB.</p>
<p>It seems that jQuery ajax puts all data into the query string, hence causing IIS to reject the URL, henc... | [
{
"answer_id": 445440,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 3,
"selected": false,
"text": "<p>Yes; according to <a href=\"http://docs.jquery.com/Ajax\" rel=\"noreferrer\">jQuery's documentation</a>, you can use <c... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/691/"
] | I am trying to use jQuery's ajax functionality to update data from a web form (ASP.NET MVC). Part of the data comes from a text area, and while is not a huge amount of data, can easily be more than 2 KB.
It seems that jQuery ajax puts all data into the query string, hence causing IIS to reject the URL, hence breaking ... | use [$.post](http://docs.jquery.com/Ajax/jQuery.post)
e.g
```
$.post(someUrl, { textData: $('#someInput').val() } );
```
$.post is just a simple wrapper around $.ajax.
```
$.ajax({ type :"post",
data : { textData: $('#someInput').val() },
url : someUrl
});
``` |
445,431 | <p>Anyone know if it possible at run-time to know how many pixels high an asp.net gridview is?</p>
<p>I have a gridview on the left of my page. On the right side, I populate with random images that vary in height and I would like to (as close as possible) match the total height of the gridview with the sum total heigh... | [
{
"answer_id": 445440,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 3,
"selected": false,
"text": "<p>Yes; according to <a href=\"http://docs.jquery.com/Ajax\" rel=\"noreferrer\">jQuery's documentation</a>, you can use <c... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53686/"
] | Anyone know if it possible at run-time to know how many pixels high an asp.net gridview is?
I have a gridview on the left of my page. On the right side, I populate with random images that vary in height and I would like to (as close as possible) match the total height of the gridview with the sum total heights of the ... | use [$.post](http://docs.jquery.com/Ajax/jQuery.post)
e.g
```
$.post(someUrl, { textData: $('#someInput').val() } );
```
$.post is just a simple wrapper around $.ajax.
```
$.ajax({ type :"post",
data : { textData: $('#someInput').val() },
url : someUrl
});
``` |
445,452 | <p>Is it possible to apply / create a YUI Button by using an element's class name and not by id. I have to generate a list of buttons then transform it to a YUI button. </p>
<p>[Update]</p>
<p>By the way, I'm trying to apply the button in an anchor tag. So it will be a link button.</p>
<p>[Update:Code]</p>
<p>Ok so... | [
{
"answer_id": 445467,
"author": "Walter Rumsby",
"author_id": 1654,
"author_profile": "https://Stackoverflow.com/users/1654",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to use the <a href=\"http://developer.yahoo.com/yui/docs/YAHOO.widget.Button.html#config_srcelem... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40538/"
] | Is it possible to apply / create a YUI Button by using an element's class name and not by id. I have to generate a list of buttons then transform it to a YUI button.
[Update]
By the way, I'm trying to apply the button in an anchor tag. So it will be a link button.
[Update:Code]
Ok so here's the code. I have a loop... | Looks like I've solved it myself. But I'm not sure if this is the best solution. I generated unique ids then create the buttons.
```
var i = 0;
$(".system-button").each(function(i,b){
var button = new YAHOO.widget.Button($(b).attr('id','system-button'+i).attr('id'));
i++;
});
```
And oh yes, I use JQu... |
445,455 | <p>According to google and some other sources (e.g., <a href="http://www.enterprisedt.com/publications/oracle/result_set.html" rel="noreferrer">http://www.enterprisedt.com/publications/oracle/result_set.html</a>), if I want to call a stored-function that returns a ref cursor, I need to write something like this in orde... | [
{
"answer_id": 445925,
"author": "martsraits",
"author_id": 55036,
"author_profile": "https://Stackoverflow.com/users/55036",
"pm_score": 4,
"selected": true,
"text": "<p>Constant <code>OracleTypes.CURSOR</code> is -10. Quite ugly solution but you can just write -10 there or create your ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36071/"
] | According to google and some other sources (e.g., <http://www.enterprisedt.com/publications/oracle/result_set.html>), if I want to call a stored-function that returns a ref cursor, I need to write something like this in order to access the ResultSet:
```
String query = "begin ? := sp_get_stocks(?); end;";
CallableStat... | Constant `OracleTypes.CURSOR` is -10. Quite ugly solution but you can just write -10 there or create your own constant which value is -10. |
445,471 | <p>The following throws an <code>InvalidCastException</code>.</p>
<pre><code>IEnumerable<int> list = new List<int>() { 1 };
IEnumerable<long> castedList = list.Cast<long>();
Console.WriteLine(castedList.First());
</code></pre>
<p>Why?</p>
<p>I'm using Visual Studio 2008 SP1.</p>
| [
{
"answer_id": 445497,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 7,
"selected": true,
"text": "<p>That's very odd! There's a blog post <a href=\"http://blogs.msdn.com/ed_maurer/archive/2008/02/16/breaking-change-in-l... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45914/"
] | The following throws an `InvalidCastException`.
```
IEnumerable<int> list = new List<int>() { 1 };
IEnumerable<long> castedList = list.Cast<long>();
Console.WriteLine(castedList.First());
```
Why?
I'm using Visual Studio 2008 SP1. | That's very odd! There's a blog post [here](http://blogs.msdn.com/ed_maurer/archive/2008/02/16/breaking-change-in-linq-queries-using-explicitly-typed-range-variables.aspx) that describes how the behaviour of `Cast<T>()` was changed between .NET 3.5 and .NET 3.5 SP1, but it still doesn't explain the InvalidCastException... |
445,475 | <p>In my opinion, a class should provide a well defined abstraction and no private members should be modified without the knowledge of class. But when I checked the "auto_ptr" (or any other smart pointer), this rule is violated. Please see the following code</p>
<pre><code>class Foo{
public:
Foo(){}
};
int main(in... | [
{
"answer_id": 445489,
"author": "Pyry Jahkola",
"author_id": 26981,
"author_profile": "https://Stackoverflow.com/users/26981",
"pm_score": 2,
"selected": false,
"text": "<p>No, there's no way to completely prohibit such bad usage in C++.</p>\n\n<p>As a general rule, the user of any libr... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50419/"
] | In my opinion, a class should provide a well defined abstraction and no private members should be modified without the knowledge of class. But when I checked the "auto\_ptr" (or any other smart pointer), this rule is violated. Please see the following code
```
class Foo{
public:
Foo(){}
};
int main(int argc, char*... | There are two desirable properties a smart pointer should have:
1. The raw pointer can be retrieved (e.g. for passing to legacy library functions)
2. The raw pointer cannot be retrieved (to prevent double-delete)
**Obviously, these properties are contradictory and cannot be realised at the same time!** Even Boost's `... |
445,487 | <p>I am having a problem with SWF File. I have a SWF File on my HTML page and i need to link it to another HTML i used but the anchor is not working. Any one can help me. How to link a SWF file.
Thanks</p>
| [
{
"answer_id": 445615,
"author": "Jason Miesionczek",
"author_id": 18811,
"author_profile": "https://Stackoverflow.com/users/18811",
"pm_score": 0,
"selected": false,
"text": "<p>Here is a link to a blog post about how to navigate to a url through flash:</p>\n\n<p><a href=\"http://www.gr... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50190/"
] | I am having a problem with SWF File. I have a SWF File on my HTML page and i need to link it to another HTML i used but the anchor is not working. Any one can help me. How to link a SWF file.
Thanks | You can use SWFObject to add a *flashvar* like this:
```
<script type="text/javascript">
var flashvars = {};
flashvars.targetURL = "http://www.stackoverflow.com";
var params = {};
var attributes = {};
swfobject.embedSWF("myflashmovie.swf", "myAlternativeContent", "800", "600", "9.0.0", false, flash... |
445,488 | <p>i have some xml with math ml inside, and i would like to find some free tools preferably online which i can use to validate and if possible even edit math ml.</p>
<p>Anyone knows of any good tools which i can use to do this?
Thanks.</p>
<h2>Edit:</h2>
<p>Does firefox 3.03 natively support MathML? I can't get some... | [
{
"answer_id": 445615,
"author": "Jason Miesionczek",
"author_id": 18811,
"author_profile": "https://Stackoverflow.com/users/18811",
"pm_score": 0,
"selected": false,
"text": "<p>Here is a link to a blog post about how to navigate to a url through flash:</p>\n\n<p><a href=\"http://www.gr... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38124/"
] | i have some xml with math ml inside, and i would like to find some free tools preferably online which i can use to validate and if possible even edit math ml.
Anyone knows of any good tools which i can use to do this?
Thanks.
Edit:
-----
Does firefox 3.03 natively support MathML? I can't get some equations to show u... | You can use SWFObject to add a *flashvar* like this:
```
<script type="text/javascript">
var flashvars = {};
flashvars.targetURL = "http://www.stackoverflow.com";
var params = {};
var attributes = {};
swfobject.embedSWF("myflashmovie.swf", "myAlternativeContent", "800", "600", "9.0.0", false, flash... |
445,490 | <p>What is the equivalent of a 'friend' keyword in C Sharp?</p>
<p>How do I use the 'internal' keyword?</p>
<p>I have read that 'internal' keyword is a replacement for 'friend' in C#.</p>
<p>I am using a DLL in my C# project that I have the source code for and yet I do not want to modify the existing code. I have in... | [
{
"answer_id": 445505,
"author": "johnc",
"author_id": 5302,
"author_profile": "https://Stackoverflow.com/users/5302",
"pm_score": 3,
"selected": false,
"text": "<ol>\n<li><p><a href=\"http://msdn.microsoft.com/en-us/library/7c5ka91b(VS.80).aspx\" rel=\"nofollow noreferrer\"><code>intern... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54760/"
] | What is the equivalent of a 'friend' keyword in C Sharp?
How do I use the 'internal' keyword?
I have read that 'internal' keyword is a replacement for 'friend' in C#.
I am using a DLL in my C# project that I have the source code for and yet I do not want to modify the existing code. I have inherited the class and I ... | 1. You can use the keyword access modifier [`internal`](http://msdn.microsoft.com/en-us/library/7c5ka91b.aspx) to declare a type or type member as accessible to code in the same assembly only.
2. You can use the [`InternalsVisibleToAttribute`](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.inte... |
445,500 | <p>I think my question is somewhat similar to <a href="https://stackoverflow.com/questions/258590/how-do-i-import-svn-branches-rooted-in-different-directories-into-git-using-git-s" title="How do I import svn branches rooted in different directories into git using git-svn?">CaptainPicard's</a> but dissimilar enough that... | [
{
"answer_id": 445537,
"author": "Emil Sit",
"author_id": 55284,
"author_profile": "https://Stackoverflow.com/users/55284",
"pm_score": 0,
"selected": false,
"text": "<p>You can specify git svn init with a svn url of your choosing, including pointing at a particular branch or even part o... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1357024/"
] | I think my question is somewhat similar to [CaptainPicard's](https://stackoverflow.com/questions/258590/how-do-i-import-svn-branches-rooted-in-different-directories-into-git-using-git-s "How do I import svn branches rooted in different directories into git using git-svn?") but dissimilar enough that I feel compelled to... | In `git svn` commands, you can only use the asterisk wildcard to specify all members of a directory (`directoryname/*`) and not filename variations (`fileprefix*`). That may change in the future if `git svn` is revised to make use of SVN's new merge tracking.
Because Git only stores a pointer to a commit for each bran... |
445,519 | <p>The code snippet below changes the data validation state of a cell and runs when the Excel-2003 worksheet is unprotected. However, when I protect the work sheet the macro doesn't run and raises a run-time error</p>
<blockquote>
<p>Run-time error '-2147417848 (80010108)':</p>
<p>Method 'Add' of object 'Valida... | [
{
"answer_id": 447247,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 5,
"selected": true,
"text": "<p>If I understand the question correctly, you will be the one protecting the sheet. If that is the case, you can use the f... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] | The code snippet below changes the data validation state of a cell and runs when the Excel-2003 worksheet is unprotected. However, when I protect the work sheet the macro doesn't run and raises a run-time error
>
> Run-time error '-2147417848 (80010108)':
>
>
> Method 'Add' of object 'Validation' failed
>
>
>
I... | If I understand the question correctly, you will be the one protecting the sheet. If that is the case, you can use the following VBA:
```
myWorksheet.Protect contents:=True, userinterfaceonly:=True
```
The key part here is "userinterfaceonly:=true". When a worksheet is protected with this flag set, VBA macros are st... |
445,524 | <p>I have a databound list view and can set all the column widths manually except for the last. The data length of the last field varies greatly. The last column needs to expand to handle the width of the data and if greater scroll. I have tried setting the width of the last column to some very large number, but tha... | [
{
"answer_id": 445527,
"author": "Jobo",
"author_id": 51915,
"author_profile": "https://Stackoverflow.com/users/51915",
"pm_score": 0,
"selected": false,
"text": "<p>You could try using % instead of pixels and perhaps allocate 60% to the last column whilest the remaining 40% could be use... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] | I have a databound list view and can set all the column widths manually except for the last. The data length of the last field varies greatly. The last column needs to expand to handle the width of the data and if greater scroll. I have tried setting the width of the last column to some very large number, but that driv... | Because your header goes off the page, I assume that your headers are center- or right- aligned. Left-align the header to make it stay put (you can add padding on the left to fake a centered or right-aligned header).
Use Width="Auto" to make the width of the column expand based on the widest item in the column.
Examp... |
445,550 | <p>I would like to write this as a user defined function:</p>
<pre><code>private double Score(Story s){
DateTime now = DateTime.Now;
TimeSpan elapsed = now.Subtract(s.PostedOn);
double daysAgo = elapsed.TotalDays;
... | [
{
"answer_id": 445552,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 3,
"selected": true,
"text": "<p>You can, but if you're using SQL Server 2000, you'll have to pass in the value of \"now\"--UDFs can't generate any non-d... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to write this as a user defined function:
```
private double Score(Story s){
DateTime now = DateTime.Now;
TimeSpan elapsed = now.Subtract(s.PostedOn);
double daysAgo = elapsed.TotalDays;
return s.Vo... | You can, but if you're using SQL Server 2000, you'll have to pass in the value of "now"--UDFs can't generate any non-deterministic values themselves [in SQL Server 2000](http://wardyit.com/blog/blog/archive/2006/02/15/84.aspx).
This untested stab at it might be close:
```
CREATE FUNCTION dbo.GetStoryScore (
@Now ... |
445,570 | <p>I want to compile the following line of code from <a href="http://code.google.com/p/enhsim" rel="noreferrer">http://code.google.com/p/enhsim</a>:</p>
<pre><code>enh::eout << enh::setw(26);
</code></pre>
<p>gcc gives the following error:</p>
<pre><code>error: no match for 'operator<<' in 'enh::eout <... | [
{
"answer_id": 445574,
"author": "unistudent",
"author_id": 54883,
"author_profile": "https://Stackoverflow.com/users/54883",
"pm_score": 2,
"selected": false,
"text": "<p>My guess is that <code>EnhSimOutput& operator<< (setw& p);</code> passes by non-const reference, but t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36103/"
] | I want to compile the following line of code from <http://code.google.com/p/enhsim>:
```
enh::eout << enh::setw(26);
```
gcc gives the following error:
```
error: no match for 'operator<<' in 'enh::eout << enh::setw(26)'
```
But the `EnhSimOutput` class (of which `enh::eout` is an instance) does declare:
```
Enh... | The value `enh::setw(26);` is an *rvalue* . Actually, temporaries like that are rvalues. Rvalues have special properties. One of them is that their address can't be taken (`&enh::setw(26);` is illegal), and they can't generally bind to references to non-const (some temporaries *can* bind to references to non-const, but... |
445,594 | <p>I'm attempting to learn a little more about handling sockets and network connections in SBCL; so I wrote a simple wrapper for HTTP. Thus far, it merely makes a stream and performs a request to ultimately get the header data and page content of a website.</p>
<p>Until now, it has worked at somewhat decently. Nothing... | [
{
"answer_id": 445712,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 2,
"selected": false,
"text": "<p>Here's a possibility: </p>\n\n<p>HTTP/1.0 defines the sequence CR LF as the end-of-line marker.</p>\n\n<p>The <code... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13293/"
] | I'm attempting to learn a little more about handling sockets and network connections in SBCL; so I wrote a simple wrapper for HTTP. Thus far, it merely makes a stream and performs a request to ultimately get the header data and page content of a website.
Until now, it has worked at somewhat decently. Nothing to brag h... | A few things. First, to your concern about the 400 errors you are getting back, a few possibilities come to mind:
* "Host:" isn't actually a valid header field in HTTP/1.0, and depending on how fascist the web server you are contacting is about standards, it would reject this as a bad request based on the protocol you... |
445,606 | <p>Say that I have two resources, Project and Task. A Project can have many Tasks; A Task belongs to one Project. Also say that I have Task nested under Project in routes.rb:</p>
<pre><code>map.resources :projects do |project|
project.resources :tasks
end
</code></pre>
<p>Can one programmatically discover this rela... | [
{
"answer_id": 445901,
"author": "allesklar",
"author_id": 19893,
"author_profile": "https://Stackoverflow.com/users/19893",
"pm_score": 0,
"selected": false,
"text": "<p>Your code above determines the relationship for the routes and helps generate the right helpers to create paths and s... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52283/"
] | Say that I have two resources, Project and Task. A Project can have many Tasks; A Task belongs to one Project. Also say that I have Task nested under Project in routes.rb:
```
map.resources :projects do |project|
project.resources :tasks
end
```
Can one programmatically discover this relationship? Basically, I nee... | Routing will not help you as this is only meant to be used the other way around.
What you can do is aliasing the relationship with :parent:
```
class Task
belongs_to :project
alias :project :parent
end
```
And then use this relationship to detect if a parent object is available:
```
if object.respond_to?(:par... |
445,619 | <p>Given:</p>
<pre><code>/images: list of all images
/images/{imageId}: specific image
/feed/{feedId}: potentially huge list of some images (not all of them)
</code></pre>
<p>How would you query if a particular feed contains a particular image without downloading the full list? Put another way, how would you check wh... | [
{
"answer_id": 445707,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 1,
"selected": false,
"text": "<p>What's wrong with this?</p>\n\n<pre><code>HEAD /images/id\n</code></pre>\n\n<p>It's unclear what \"feed\" means, but ass... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14731/"
] | Given:
```
/images: list of all images
/images/{imageId}: specific image
/feed/{feedId}: potentially huge list of some images (not all of them)
```
How would you query if a particular feed contains a particular image without downloading the full list? Put another way, how would you check whether a resource state con... | There's nothing "un-RESTful" about:
```
/feed/{feedId}?contains={imageURI}[,{imageURI}]
```
It returns the subset as specified. The resource, /feed/{feedid}, is a list resource containing a list of images. How is the resource returned with the contains query any different?
The URI is unique, and returns the appropr... |
445,658 | <p>I have a data object with three fields, A, B and C. The problem is that the user can set any of them because:</p>
<p>A * B = C</p>
<p>So if a user starts off by setting A & B, C will be calculated. but then if a user set C, A gets recalculated, so there is an implicit anchoring that is happening based off the... | [
{
"answer_id": 445690,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": true,
"text": "<p>So your rules are:</p>\n\n<pre><code>A = C / B\nB = C / A\nC = A * B\n</code></pre>\n\n<p>What you'd need to do is remember ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | I have a data object with three fields, A, B and C. The problem is that the user can set any of them because:
A \* B = C
So if a user starts off by setting A & B, C will be calculated. but then if a user set C, A gets recalculated, so there is an implicit anchoring that is happening based off the last field that the ... | So your rules are:
```
A = C / B
B = C / A
C = A * B
```
What you'd need to do is remember the last **two** fields that the user entered, and from that, calculate the third. Therefore if they entered A and then B, then you calculate C. If they then change C, then recalculate A, and so on.
If you want to code it wit... |
445,695 | <p>which is better ???</p>
<pre><code>public class Order
{
private double _price;
private double _quantity;
public double TotalCash
{
get
{
return _price * _quantity;
}
}
</code></pre>
<p>or</p>
<pre><code>public class Order
{
private double _totalCash;
private double _price;
... | [
{
"answer_id": 445703,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": 0,
"selected": false,
"text": "<p>I'll put a calculation on a read-only get or a set.</p>\n\n<p>I'm of the opinion that a property should behave like it h... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | which is better ???
```
public class Order
{
private double _price;
private double _quantity;
public double TotalCash
{
get
{
return _price * _quantity;
}
}
```
or
```
public class Order
{
private double _totalCash;
private double _price;
private double _quantity;
private ... | There are tradeoffs. If the calculations simple and does not take a long time, then put it in the get. It makes your life easier, because you don't have to worry about doing the check in every set that total price is dependant on, which could lead to mistakes.
If the calculation takes a lot of time, then you could als... |
445,700 | <p>I'm currently working through the excercises in 'The C Programming Language'. Here's one of my solutions: </p>
<pre><code>int c;
while ((c=getchar()) != EOF) {
if (c == ' ') {
while ((c = getchar()) == ' ')
{} // do nothing?
putchar(' ');
}
putchar(c);
}
</code></pre>
<p>I found some solutions... | [
{
"answer_id": 445713,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think the procedure is, but your formatting is pretty weird. There's nothing wrong with:</p>\n\n<pre><code>/* E... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm currently working through the excercises in 'The C Programming Language'. Here's one of my solutions:
```
int c;
while ((c=getchar()) != EOF) {
if (c == ' ') {
while ((c = getchar()) == ' ')
{} // do nothing?
putchar(' ');
}
putchar(c);
}
```
I found some solutions [here](http://users.power... | Not at all - I believe you'll find do-nothing loops like these in K&R, so that's about as official as it gets.
It's a matter of personal preference, but I prefer my do-nothing loops like this:
```
while(something());
```
Others prefer the semicolon to go on a separate line, to reinforce the fact that it's a loop:
... |
445,702 | <p>I have a template class where I want to use objects of that class (along with the parameterized type) inside a map. So far this is the solution that I've been able to arrive at:</p>
<pre><code>class IStatMsg;
template <typename T>
class ITier
{
public:
// Methods
ITier(TierType oType) : o_Type(oType... | [
{
"answer_id": 445724,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>Line 60 does not access a depending name. What you use is <code>ITier<T></code> of which the compil... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55305/"
] | I have a template class where I want to use objects of that class (along with the parameterized type) inside a map. So far this is the solution that I've been able to arrive at:
```
class IStatMsg;
template <typename T>
class ITier
{
public:
// Methods
ITier(TierType oType) : o_Type(oType){};
virtual ~IT... | Line 60 does not access a depending name. What you use is `ITier<T>` of which the compiler knows it's a template given an argument. Instead of `typename` you want to use `typedef` ;)
Line 64 *does* access the depending name `iterator` which is a type-name, so you have to put `typename` before `std::map`. I put the two... |
445,705 | <p>Sorry for the simple question but I feel like there's a smarter way to do this:</p>
<pre><code>if ([txtFldTo.text length]>0){
//do something
}
else {
//do something else
}
</code></pre>
<p>where txtFldTo is an IBOutlet UITextField connected to a text field on the interface.</p>
| [
{
"answer_id": 445727,
"author": "Ryan Townshend",
"author_id": 24707,
"author_profile": "https://Stackoverflow.com/users/24707",
"pm_score": 3,
"selected": true,
"text": "<p>Something like this should suffice.</p>\n\n<p>if([[textfield text] length] > 0)</p>\n"
},
{
"answer_id": ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | Sorry for the simple question but I feel like there's a smarter way to do this:
```
if ([txtFldTo.text length]>0){
//do something
}
else {
//do something else
}
```
where txtFldTo is an IBOutlet UITextField connected to a text field on the interface. | Something like this should suffice.
if([[textfield text] length] > 0) |
445,774 | <p>Quick (and hopefully easy) question: I need to trigger a download of a PDF file that's generated by a PHP file. I can do this:</p>
<pre><code><a href="download.php">Download</a>
</code></pre>
<p>but should I be doing this another way? Javascript maybe? The above works but the window shows "Loading..... | [
{
"answer_id": 445790,
"author": "Al W",
"author_id": 50011,
"author_profile": "https://Stackoverflow.com/users/50011",
"pm_score": 2,
"selected": false,
"text": "<p>fake it by using an onclick event handler to show a spinning gif</p>\n\n<pre><code><a href=\"download.php\" onclick=\"S... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | Quick (and hopefully easy) question: I need to trigger a download of a PDF file that's generated by a PHP file. I can do this:
```
<a href="download.php">Download</a>
```
but should I be doing this another way? Javascript maybe? The above works but the window shows "Loading..." until the download starts. I'd like to... | **EDIT**
Yes javascript, something like:
```
<a href="download.php" onclick="this.innerHTML='Downloading..'; downloadPdf(this);">Download</a>
```
If you need to actually understand when the download is started you probably need to call an iframe and then use the "onload" event on it.. for example:
```
// javascrip... |
445,782 | <p>So I got asked today what was the best way to find the closes match within a collection.</p>
<p>For example, you've got an array like this:</p>
<pre><code>1, 3, 8, 10, 13, ...
</code></pre>
<p>What number is closest to 4?</p>
<p>Collection is numerical, unordered and can be anything. Same with the number to matc... | [
{
"answer_id": 445802,
"author": "Al W",
"author_id": 50011,
"author_profile": "https://Stackoverflow.com/users/50011",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDITED = in the for loop</strong></p>\n\n<pre><code>int Closest(int val, int[] arr)\n{\n int index = 0;\n fo... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11388/"
] | So I got asked today what was the best way to find the closes match within a collection.
For example, you've got an array like this:
```
1, 3, 8, 10, 13, ...
```
What number is closest to 4?
Collection is numerical, unordered and can be anything. Same with the number to match.
Lets see what we can come up with, f... | 11 bytes in J:
```
C=:0{]/:|@-
```
Examples:
```
>> a =: 1 3 8 10 13
>> 4 C a
3
>> 11 C a
10
>> 12 C a
13
```
my breakdown for the layman:
```
0{ First element of
] the right argument
/: sorted by
| absolute value
@ of
- subtraction
``` |
445,815 | <p>I'm using a powerbook (osx 10.5) and recently downloaded and installed FFTW 3.2 (<a href="http://www.fftw.org/fftw2_doc/fftw_2.html" rel="noreferrer">link text</a>). I've been able to compile and run some simple programs based on the online tutorial using the terminal:</p>
<pre><code>g++ main.cpp -lfftw3 -lm
</code... | [
{
"answer_id": 445846,
"author": "robottobor",
"author_id": 10184,
"author_profile": "https://Stackoverflow.com/users/10184",
"pm_score": 3,
"selected": false,
"text": "<p>Did you set these options for the target?</p>\n\n<p>Under \"Linking->Other Linker Flags\" add: \"-L/path/to/library ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using a powerbook (osx 10.5) and recently downloaded and installed FFTW 3.2 ([link text](http://www.fftw.org/fftw2_doc/fftw_2.html)). I've been able to compile and run some simple programs based on the online tutorial using the terminal:
```
g++ main.cpp -lfftw3 -lm
```
However, I can't get the same program to c... | To link to a .a library like this in Xcode you need to:
* Double-click on your target or application in Xcode to open the Info window
* Switch to the "Build" tab
* Add -lfftw3 to "Other Linker Flags" (under "Linking")
* Add the path to your library to the "Library Search Paths" (under "Search Paths"). In your case thi... |
445,827 | <h2>Example Problem:</h2>
<h3>Entities:</h3>
<ul>
<li>User contains name and a list of friends (User references)</li>
<li>Blog Post contains title, content, date and Writer (User)</li>
</ul>
<h3>Requirement:</h3>
<p>I want a page that displays the title and a link to the blog of the last 10 posts by a user's friend. I... | [
{
"answer_id": 446471,
"author": "Nick Johnson",
"author_id": 12030,
"author_profile": "https://Stackoverflow.com/users/12030",
"pm_score": 4,
"selected": false,
"text": "<p>If you look at how the SQL solution you provided will be executed, it will go basically like this:</p>\n\n<ol>\n<l... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37575/"
] | Example Problem:
----------------
### Entities:
* User contains name and a list of friends (User references)
* Blog Post contains title, content, date and Writer (User)
### Requirement:
I want a page that displays the title and a link to the blog of the last 10 posts by a user's friend. I would also like the abilit... | This topic is covered in a Google io talk:
<http://code.google.com/events/io/sessions/BuildingScalableComplexApps.html>
Basically the Google team suggest using list properties and what they call relational index entities, an example application can be found here: <http://pubsub-test.appspot.com/> |
445,836 | <p>I've just noticed that <code>tidy_repair_string()</code> is removing my non-breaking spaces from empty elements causing my table to collapse. Basically I've put in:</p>
<blockquote>
<p><code><td>&nbsp;</td></code></p>
</blockquote>
<p>and HTML Tidy is stripping them out to:</p>
<pre><code><t... | [
{
"answer_id": 445847,
"author": "Epitaph",
"author_id": 48725,
"author_profile": "https://Stackoverflow.com/users/48725",
"pm_score": 0,
"selected": false,
"text": "<p>You could try the following:</p>\n\n<p><code>$myString = str_replace(\" \", \"&nbsp;&nbsp;\", $someText);</cod... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | I've just noticed that `tidy_repair_string()` is removing my non-breaking spaces from empty elements causing my table to collapse. Basically I've put in:
>
> `<td> </td>`
>
>
>
and HTML Tidy is stripping them out to:
```
<td> </td>
```
which may or may not be some Unicode break but either way it's collaps... | Apply this style, then you do not need to put content in the "empty" cells:
td { [empty-cells](http://www.w3schools.com/Css/pr_tab_empty-cells.asp): show; } |
445,850 | <p>I want to submit a with using jquery as below;</p>
<pre><code>$("#formid").submit();
</code></pre>
<p>Its working perfect in all browsers except IE6.</p>
<p>How to make it work in IE6 ??</p>
| [
{
"answer_id": 445926,
"author": "Sophie Alpert",
"author_id": 49485,
"author_profile": "https://Stackoverflow.com/users/49485",
"pm_score": 2,
"selected": false,
"text": "<p>You could try <code>$(\"#formid\").trigger(\"submit\")</code>, though I doubt it'll give you a different result.<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45261/"
] | I want to submit a with using jquery as below;
```
$("#formid").submit();
```
Its working perfect in all browsers except IE6.
How to make it work in IE6 ?? | You probably have an `<input name="submit" />` somewhere in your form, which overwrites the function "submit" of the form in IE.
**Edit:**
I have tested in some other browsers. The latest versions of all major browsers seem to be affected by this issue.
* IE - all versions
* Firefox 4+
* Chrome at least since versi... |
445,856 | <p>I have an employee table called <code>ID_EMPLOYEE_MASTER</code> with the fields</p>
<pre><code>EMP_CODE,
EMP_NAME,
EMP_JOIN_DATE,
EMP_STATUS,
EMP_BASIC,
EMP_ACCOUNT,
EMP_BANK
</code></pre>
<p>I want to query all the employees whose status is 'P' ie..PRESENT,THEIR BANK ACCOUNT ie.. EMP_ACCOUNT, THEIR BASIC ie EMP_B... | [
{
"answer_id": 448547,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 3,
"selected": false,
"text": "<p>ROWNUM is assigned as rows are retrieved, before the ORDER BY is applied. So they won't come out in the sequence you ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an employee table called `ID_EMPLOYEE_MASTER` with the fields
```
EMP_CODE,
EMP_NAME,
EMP_JOIN_DATE,
EMP_STATUS,
EMP_BASIC,
EMP_ACCOUNT,
EMP_BANK
```
I want to query all the employees whose status is 'P' ie..PRESENT,THEIR BANK ACCOUNT ie.. EMP\_ACCOUNT, THEIR BASIC ie EMP\_BASIC,THEIR NAME ie.. EMP\_NAME, the... | ROWNUM is assigned as rows are retrieved, before the ORDER BY is applied. So they won't come out in the sequence you want. There are a couple of different tricks you can use.
(1) Nested queries
```
SELECT <your long expression here> FROM (
SELECT *
FROM id_employee_master
ORDER BY emp_join_date
)
```
The ... |
445,871 | <p>Yes I want to read a simple a logfile into a TStringList and that is easy done with LoadFromFile. But the problem is that the file can be already opened by another program at the same time so an exception may appear. I have tried to use:</p>
<pre><code>FileMode := fmShareCompat;
</code></pre>
<p>But it won't work.... | [
{
"answer_id": 445877,
"author": "Drejc",
"author_id": 6482,
"author_profile": "https://Stackoverflow.com/users/6482",
"pm_score": 5,
"selected": true,
"text": "<p>Try <em>LoadFromStream</em> and do something like:</p>\n\n<pre><code>fileStream := TFileStream.Create(aFileName, fmShareDeny... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55007/"
] | Yes I want to read a simple a logfile into a TStringList and that is easy done with LoadFromFile. But the problem is that the file can be already opened by another program at the same time so an exception may appear. I have tried to use:
```
FileMode := fmShareCompat;
```
But it won't work.
I have also tried to use... | Try *LoadFromStream* and do something like:
```
fileStream := TFileStream.Create(aFileName, fmShareDenyNone);
myTStringList.LoadFromStream(fileStream);
fileStream.Free();
``` |
445,879 | <p>I wish to use the Tomcat install/deploy tasks from catalina-ant.jar to deploy a webapp to a remote app server.</p>
<p>After installing Ant using the instructions <a href="http://209.85.173.132/search?q=cache:zKE-ov3_l-kJ:www.asceticmonk.com/blog/%3Fp%3D388+installation+of+ant+on+osx&hl=en&ct=clnk&cd=1&a... | [
{
"answer_id": 445881,
"author": "luapyad",
"author_id": 39578,
"author_profile": "https://Stackoverflow.com/users/39578",
"pm_score": 7,
"selected": true,
"text": "<p>You can control the amount in variable <code>mouse-wheel-scroll-amount</code> (in mwheel.el).</p>\n\n<p>EDIT: E.g. Add \... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18265/"
] | I wish to use the Tomcat install/deploy tasks from catalina-ant.jar to deploy a webapp to a remote app server.
After installing Ant using the instructions [found here](http://209.85.173.132/search?q=cache:zKE-ov3_l-kJ:www.asceticmonk.com/blog/%3Fp%3D388+installation+of+ant+on+osx&hl=en&ct=clnk&cd=1&gl=us), my ant fold... | You can control the amount in variable `mouse-wheel-scroll-amount` (in mwheel.el).
EDIT: E.g. Add
`(setq mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control) . nil)))`
to your .emacs for 1 line at a time.
I also have `(setq mouse-wheel-progressive-speed nil)` in my .emacs which I think is nicer behaviour. |
445,883 | <p>I have the following requirement</p>
<p>I have a Employee class:</p>
<pre><code>public class Employee
{
public int ID{get; set;}
public string EmpFName{get; set;}
public string EmpLName { get; set; }
}
</code></pre>
<p>I want to do something like this when creating values</p>
<pre><code>var Emp = new... | [
{
"answer_id": 445886,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>You're already nearly there. This code should work:</p>\n\n<pre><code>var emp = new List<Employee>\n{\n new E... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following requirement
I have a Employee class:
```
public class Employee
{
public int ID{get; set;}
public string EmpFName{get; set;}
public string EmpLName { get; set; }
}
```
I want to do something like this when creating values
```
var Emp = new List<Employee>[]{
new Empl... | You're already nearly there. This code should work:
```
var emp = new List<Employee>
{
new Employee{ID=1, EmpFname="matt", EmpLName="Cook"},
new Employee{ID=2, EmpFname="mary", EmpLname="John"}
};
```
The features involved here are implicit typing, object initializers and collection initializers. All of them... |
445,891 | <p>I am working with ASP.Net MVC. When I keep the css inside the Views folder, its not loading the CSS. Can anybody help me regarding this issue?</p>
| [
{
"answer_id": 445957,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>Updated: nope, it looks like that is blocked (404); you'll have to keep them outside, it seems. This makes sense, ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working with ASP.Net MVC. When I keep the css inside the Views folder, its not loading the CSS. Can anybody help me regarding this issue? | I like a css file per View folder, just for organization. That way I can work with html and the corresponding css in the same directory instead of having a big css file.
Here is how I do it:
First made a "Style controller" which is going to merge all files into one:
```
public class StyleController : Controller
{
... |
445,893 | <p>I need to resize a window larger than screen resolution or size of desktop, programmatically & preferably also manually.</p>
<p>Since MS-Windows XP/Vista disallows a window size larger than screen, does anybody have any ideas to work around this limitation?</p>
<p>I trying to make pan effect on a laptop to giv... | [
{
"answer_id": 445955,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": -1,
"selected": false,
"text": "<p>For the specific case of needing a more screen-friendly view of the MSDN, or on any other site (like StackOverflow) that... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to resize a window larger than screen resolution or size of desktop, programmatically & preferably also manually.
Since MS-Windows XP/Vista disallows a window size larger than screen, does anybody have any ideas to work around this limitation?
I trying to make pan effect on a laptop to give me more space to wo... | If you would like to resize a window that you do not own (and without using any kind of hook), you can use the Windows SetWindowPos API with the SWP\_NOSENDCHANGING (0x0400) flag set:
```
BOOL WINAPI SetWindowPos(
__in HWND hWnd,
__in_opt HWND hWndInsertAfter,
__in int X,
__in int Y,
__in int cx,
... |
445,898 | <p>i have this block of xslt if-else case and was wondering if there's a way for me to do straight comparison with unicode character? </p>
<p>Something along the lines of the code shown below? Or does xslt have some built in function which i can use for this purpose? i.e. change the unicode into html entities and comp... | [
{
"answer_id": 445920,
"author": "Robert MacLean",
"author_id": 53236,
"author_profile": "https://Stackoverflow.com/users/53236",
"pm_score": 2,
"selected": true,
"text": "<p>Unity is NOT a way to dynamically load modules. You could look at the Microsoft Extensibility Framework to dynami... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38124/"
] | i have this block of xslt if-else case and was wondering if there's a way for me to do straight comparison with unicode character?
Something along the lines of the code shown below? Or does xslt have some built in function which i can use for this purpose? i.e. change the unicode into html entities and compare via th... | Unity is NOT a way to dynamically load modules. You could look at the Microsoft Extensibility Framework to dynamically load modules, which I hear is great.
Personally I built a similar system and used an article on CodeProject for guideance, but I can't find it now. I did find this (which is similar) and shows how to ... |
445,899 | <p>Do you know about a library that allows us to generate UI by just stating that it should be generated?</p>
<p>I think there must be a person who have implemented a mechanism allowing us to transform code like this:</p>
<pre><code>class Main {
@Command
int add(int a, int b) {
return a+b;
}
}
</c... | [
{
"answer_id": 445907,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": false,
"text": "<p>I have lost count of how many times I've seen variations of this implemented over the years. The common theme is ann... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1764/"
] | Do you know about a library that allows us to generate UI by just stating that it should be generated?
I think there must be a person who have implemented a mechanism allowing us to transform code like this:
```
class Main {
@Command
int add(int a, int b) {
return a+b;
}
}
```
into, say, a dialo... | Have you looked at [Naked Objects](http://www.nakedobjects.org/home/index.shtml)? |
445,909 | <p>I am new to Fluent NHibernate and have been unable to figure out how to map composite keys.</p>
<p>How can I do this? What approach do I need to take?</p>
| [
{
"answer_id": 446076,
"author": "James Gregory",
"author_id": 27206,
"author_profile": "https://Stackoverflow.com/users/27206",
"pm_score": 6,
"selected": false,
"text": "<p>There's a <code>CompositeId</code> method.</p>\n\n<pre><code>public class EntityMap : ClassMap<Entity>\n{\n... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52727/"
] | I am new to Fluent NHibernate and have been unable to figure out how to map composite keys.
How can I do this? What approach do I need to take? | There's a `CompositeId` method.
```
public class EntityMap : ClassMap<Entity>
{
public EntityMap()
{
CompositeId()
.KeyProperty(x => x.Something)
.KeyReference(x => x.SomethingElse);
}
}
``` |
445,910 | <p>i write program that parse text with regular expression. Regular expression should be obtained from user. I deside to use glob syntax for user input, and convert glob string to the regular expression internally. For example: </p>
<pre><code>"foo.? bar*"
</code></pre>
<p>should be converted to </p>
<pre><code>"^.... | [
{
"answer_id": 445954,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://jakarta.apache.org/oro/\" rel=\"nofollow noreferrer\">Jakarta ORO</a> has an <a href=\"http://jakarta.apa... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42371/"
] | i write program that parse text with regular expression. Regular expression should be obtained from user. I deside to use glob syntax for user input, and convert glob string to the regular expression internally. For example:
```
"foo.? bar*"
```
should be converted to
```
"^.*foo\.\w\bar\w+.*"
```
Somehow, i n... | no need for incomplete or unreliable hacks. there's a function included with python for this
```
>>> import fnmatch
>>> fnmatch.translate( '*.foo' )
'.*\\.foo$'
>>> fnmatch.translate( '[a-z]*.txt' )
'[a-z].*\\.txt$'
``` |
445,915 | <p>I have the class and struct shown below. If I serialize the class as
is using xmlserializer I get: </p>
<p>< Test><br>
< TestNumber1 >5< /TestNumber1 ><br>
< InnerTest / ><br>
< /Test > </p>
<p>what is the easiest way to make InnerTest serialise properly
(preferably using xmlserializer) with ... | [
{
"answer_id": 445928,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I've never done it myself, but I suspect you just need to implement the <a href=\"http://msdn.microsoft.com/en-us/lib... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the class and struct shown below. If I serialize the class as
is using xmlserializer I get:
< Test>
< TestNumber1 >5< /TestNumber1 >
< InnerTest / >
< /Test >
what is the easiest way to make InnerTest serialise properly
(preferably using xmlserializer) with out giving the Number property a
sett... | As Jon Skeet quite correctly says, you'll need to use `IXmlSerializable` with the `XmlSerializer` if you don't want to have a public get/set for the properties because it's designed to work in a partial-trust environment so won't access any data that you couldn't have accessed anyway (to answer his last part - yes, som... |
445,916 | <p>I am using paging on a <code>GridView</code> that is tied to a <code>List<Employee></code>. But this code does not work. What is the correct way? I am not using an <code>ObjectDataSource</code>.</p>
<pre><code>protected void myGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
List<Employee... | [
{
"answer_id": 445928,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I've never done it myself, but I suspect you just need to implement the <a href=\"http://msdn.microsoft.com/en-us/lib... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using paging on a `GridView` that is tied to a `List<Employee>`. But this code does not work. What is the correct way? I am not using an `ObjectDataSource`.
```
protected void myGV_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
List<Employee> p = ReturnEmplColl();
GridView1.DataSource = p.Pag... | As Jon Skeet quite correctly says, you'll need to use `IXmlSerializable` with the `XmlSerializer` if you don't want to have a public get/set for the properties because it's designed to work in a partial-trust environment so won't access any data that you couldn't have accessed anyway (to answer his last part - yes, som... |
445,942 | <p>Client-side code submits an object (in the POST request body) or query string (if using GET method) via ajax request to a python cgi script. Please note that the object/query string parameters are <strong>not</strong> coming from a</p>
<pre><code><form> or <isindex>.
</code></pre>
<p>How can I retrieve... | [
{
"answer_id": 445999,
"author": "codeape",
"author_id": 3571,
"author_profile": "https://Stackoverflow.com/users/3571",
"pm_score": 3,
"selected": false,
"text": "<p>You use the cgi.FieldStorage class. Example CGI script:</p>\n\n<pre><code>#! /usr/bin/python\n\nimport cgi\nfrom os impor... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Client-side code submits an object (in the POST request body) or query string (if using GET method) via ajax request to a python cgi script. Please note that the object/query string parameters are **not** coming from a
```
<form> or <isindex>.
```
How can I retrieve these parameters from within the server-side pytho... | You use the cgi.FieldStorage class. Example CGI script:
```
#! /usr/bin/python
import cgi
from os import environ
import cgitb
cgitb.enable()
print "Content-type: text/plain"
print
print "REQUEST_METHOD:", environ["REQUEST_METHOD"]
print "Values:"
f = cgi.FieldStorage()
for k in f.keys():
print "%s: %s" % (k, f.g... |
445,956 | <p>I have an Entity with a OneToOne relation that is fetched lazily:</p>
<pre><code>@Entity
public class Person {
@Id
private Integer id;
@Column(length=60)
private String address;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="idProvince")
private Province province;
}
</code></pre>
<... | [
{
"answer_id": 445971,
"author": "stunti",
"author_id": 54949,
"author_profile": "https://Stackoverflow.com/users/54949",
"pm_score": 1,
"selected": false,
"text": "<p>I would say try to use an OO framework (zend framework, cakephp, symphony) and create a configuration (xml based) to tel... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] | I have an Entity with a OneToOne relation that is fetched lazily:
```
@Entity
public class Person {
@Id
private Integer id;
@Column(length=60)
private String address;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="idProvince")
private Province province;
}
```
This is the test I do, t... | please check the following url
<http://ellislab.com/forums/viewthread/67697/> |
445,967 | <p>It's easy to set <code>CssClass</code> in the code-behind, but this runs the risk of overwriting existing classes.</p>
<p>I need to set certain elements to <code>ReadOnly = true;</code> and I'd like to apply a style as a visual cue that the item cannot be altered...easy enough:</p>
<pre class="lang-cs prettyprint-... | [
{
"answer_id": 445989,
"author": "Al W",
"author_id": 50011,
"author_profile": "https://Stackoverflow.com/users/50011",
"pm_score": 0,
"selected": false,
"text": "<p>Can you make your own custom classes? Derive from the ASP.NET Button and add a propert for Read only. Somewhere...probab... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40934/"
] | It's easy to set `CssClass` in the code-behind, but this runs the risk of overwriting existing classes.
I need to set certain elements to `ReadOnly = true;` and I'd like to apply a style as a visual cue that the item cannot be altered...easy enough:
```cs
.CssClass += " ReadOnlyStyle";
```
But at times I will *also... | I've taken AnthonyWJones original code and amended it so that it works no matter what scenario:
```
static class WebControlsExtensions
{
public static void AddCssClass(this WebControl control, string cssClass)
{
List<string> classes = control.CssClass.Split(new char[] { ' ' }, StringSp... |
445,976 | <p>We are using log4net and want to specify it's configuration in an external config file (as we have done with other sections). To do this we have changed the log4net section in the App.config to:</p>
<pre class="lang-xml prettyprint-override"><code>...
<section name="log4net"
type="log4net.Config.Log4NetCon... | [
{
"answer_id": 445988,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 8,
"selected": true,
"text": "<p>Do you have the following attribute in your <code>AssemblyInfo.cs</code> file: </p>\n\n<pre><code>[assembly: log4net... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10784/"
] | We are using log4net and want to specify it's configuration in an external config file (as we have done with other sections). To do this we have changed the log4net section in the App.config to:
```xml
...
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
...
<log4net co... | Do you have the following attribute in your `AssemblyInfo.cs` file:
```
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
```
and code like this at the start of each class that requires logging functionality:
```
private static readonly ILog log =
LogManager.GetLogger(System.... |
445,984 | <p>I got an anonymous type inside a List anBook:</p>
<pre><code>var anBook=new []{
new {Code=10, Book ="Harry Potter"},
new {Code=11, Book="James Bond"}
};
</code></pre>
<p>Is to possible to convert it to a List with the following definition of clearBook:</p>
<pre><code>public class ClearBook
{
int Code;
string... | [
{
"answer_id": 446010,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "<p>Well, you could use:</p>\n\n<pre><code>var list = anBook.Select(x => new ClearBook {\n Code = x.Co... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] | I got an anonymous type inside a List anBook:
```
var anBook=new []{
new {Code=10, Book ="Harry Potter"},
new {Code=11, Book="James Bond"}
};
```
Is to possible to convert it to a List with the following definition of clearBook:
```
public class ClearBook
{
int Code;
string Book;
}
```
by using direct conve... | Well, you could use:
```
var list = anBook.Select(x => new ClearBook {
Code = x.Code, Book = x.Book}).ToList();
```
but no, there is no direct conversion support. Obviously you'll need to add accessors, etc. (don't make the fields public) - I'd guess:
```
public int Code { get; set; }
public string B... |
445,985 | <p>I have 2 related database tables which in simplified form look like this</p>
<pre><code>Product(
product_id,
name
)
ProductSpecs(
spec_id,
product_id,
name,
value
)
</code></pre>
<p>Foreign key is set via product_id field and ProductSpecs table has a unique constraint on (product_id, name) pair.</p>
... | [
{
"answer_id": 1057560,
"author": "Grokys",
"author_id": 6448,
"author_profile": "https://Stackoverflow.com/users/6448",
"pm_score": 2,
"selected": false,
"text": "<p>I have been having this same problem. I came up with a hack to work around it, which seems to work for me: I manually exe... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19546/"
] | I have 2 related database tables which in simplified form look like this
```
Product(
product_id,
name
)
ProductSpecs(
spec_id,
product_id,
name,
value
)
```
Foreign key is set via product\_id field and ProductSpecs table has a unique constraint on (product\_id, name) pair.
Now in my ASP.NET MVC applic... | Yes, for some reason, Linq to SQL perform all deletes as the last thing. And there is no way to change that.
Or maybe there is. I haven't looked into the codegen DataContext to see if we can override something there.
You can call SubmitChanges() as many times you want. My workaround when I need to delete as the first... |
445,990 | <p>This questions is prompted by <a href="https://stackoverflow.com/questions/444638/strange-hashmap-put-behaviour#444757">strange HashMap.put() behaviour</a></p>
<p>I think I understand why <code>Map<K,V>.put</code> takes a <code>K</code> but <code>Map<K,V>.get</code> takes an <code>Object</code>, it seem... | [
{
"answer_id": 446005,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, but it all comes down to the comparing algorithm and how far to take the conversions. For example, what do you want to... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18573/"
] | This questions is prompted by [strange HashMap.put() behaviour](https://stackoverflow.com/questions/444638/strange-hashmap-put-behaviour#444757)
I think I understand why `Map<K,V>.put` takes a `K` but `Map<K,V>.get` takes an `Object`, it seems not doing so will break too much existing code.
Now we get into a very er... | Here is the source from Long.java
```
public boolean equals(Object obj) {
if (obj instanceof Long) {
return value == ((Long)obj).longValue();
}
return false;
}
```
I.e. it needs to be a Long type to be equal. I think the key difference between:
```
long l = 42L
int i = 42;
l == i
```
and your ... |
445,993 | <p>I am trying to set up a query for my dataset in C# using a variable for the filter. For example I am trying to only display a specific account number and his balance, with a local variable being the account number used as a filter for that exact one. Am I going about this the wrong way?</p>
<p>I am in no stretch of... | [
{
"answer_id": 446048,
"author": "Oliver Friedrich",
"author_id": 44532,
"author_profile": "https://Stackoverflow.com/users/44532",
"pm_score": -1,
"selected": false,
"text": "<p>You could just use the variable to generate your SQL-Query dynamically, but beware of SQL-Injection - be real... | 2009/01/15 | [
"https://Stackoverflow.com/questions/445993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55342/"
] | I am trying to set up a query for my dataset in C# using a variable for the filter. For example I am trying to only display a specific account number and his balance, with a local variable being the account number used as a filter for that exact one. Am I going about this the wrong way?
I am in no stretch of the imagi... | When you setup your dataset query you can do something like this;
```
SELECT Name FROM TableNames WHERE Name = @Variable
```
Have a look at [this link for more info](http://www.codeproject.com/KB/database/sql_in_csharp.aspx)
It might be worth having a look into SQL injection attack too, [click here](http://www.code... |
446,003 | <p>Let's say I have a resource file which exports <code>mc1</code> with 4 frames in it. I would like to create a new <code>MovieClip</code> and insert frames like this:</p>
<pre><code>mc2:flash.display.MovieClip = new flash.display.MovieClip()
mc1.gotoAndStop(2);
mc2.gotoAndStop(1);
mc2.currentFrame = mc1.currenctFra... | [
{
"answer_id": 446084,
"author": "grapefrukt",
"author_id": 914,
"author_profile": "https://Stackoverflow.com/users/914",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not aware of a convenient way to do what you're trying to do. Your example won't work because currentFrame is a read... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42188/"
] | Let's say I have a resource file which exports `mc1` with 4 frames in it. I would like to create a new `MovieClip` and insert frames like this:
```
mc2:flash.display.MovieClip = new flash.display.MovieClip()
mc1.gotoAndStop(2);
mc2.gotoAndStop(1);
mc2.currentFrame = mc1.currenctFrame
mc1.gotoAndStop(1);
mc2.gotoAndSt... | Without the Flash IDE, there is little point in using gotoAndStop() etc.
As you can't add your different assets on different frames, you should add them all as layers using addChild(assetToAdd) and set all but one to visible = false. Then add a simple function like this:
```
function showFrame(num:int):void
{
for... |
446,013 | <p>I have a COM Callable Wrapper that I'm using from a VB6 program, but the program won't receive COM events unless the CCW is registered. Otherwise, the CCW works fine, just no events until I remove the program's manifest file and register the CCW using "regasm /tlb /codebase theccw.dll". This is in WinXP SP3.</p>
<p... | [
{
"answer_id": 446084,
"author": "grapefrukt",
"author_id": 914,
"author_profile": "https://Stackoverflow.com/users/914",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not aware of a convenient way to do what you're trying to do. Your example won't work because currentFrame is a read... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16387/"
] | I have a COM Callable Wrapper that I'm using from a VB6 program, but the program won't receive COM events unless the CCW is registered. Otherwise, the CCW works fine, just no events until I remove the program's manifest file and register the CCW using "regasm /tlb /codebase theccw.dll". This is in WinXP SP3.
What coul... | Without the Flash IDE, there is little point in using gotoAndStop() etc.
As you can't add your different assets on different frames, you should add them all as layers using addChild(assetToAdd) and set all but one to visible = false. Then add a simple function like this:
```
function showFrame(num:int):void
{
for... |
446,015 | <p>I need to execute aspnet_compiler from a bat file that I maintain to automate the publishing of a ASP.NET application from within CruiseControl.NET.</p>
<p>aspnet_compiler runs fine if I manually open the Visual Studio Command Prompt, but doesn't run if I open a normal cmd.exe.</p>
<p>What steps should I take to m... | [
{
"answer_id": 446024,
"author": "codeape",
"author_id": 3571,
"author_profile": "https://Stackoverflow.com/users/3571",
"pm_score": 1,
"selected": false,
"text": "<p>Near the top of your batch file:</p>\n\n<pre><code>CALL \"C:\\Program Files\\Microsoft Visual Studio 8\\VC\\vcvarsall.bat... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2812/"
] | I need to execute aspnet\_compiler from a bat file that I maintain to automate the publishing of a ASP.NET application from within CruiseControl.NET.
aspnet\_compiler runs fine if I manually open the Visual Studio Command Prompt, but doesn't run if I open a normal cmd.exe.
What steps should I take to make aspnet\_com... | For Visual Studio 2008:
```
call "%VS90COMNTOOLS%\vsvars32.bat"
``` |
446,017 | <p>I am wondering what the popular or best way to organise your build assets and source code within a project is?</p>
| [
{
"answer_id": 446031,
"author": "Xian",
"author_id": 4642,
"author_profile": "https://Stackoverflow.com/users/4642",
"pm_score": 3,
"selected": false,
"text": "<p>for example, I use the following for my .Net style projects;</p>\n\n<pre><code>/build/reports - reports and logs from the b... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4642/"
] | I am wondering what the popular or best way to organise your build assets and source code within a project is? | Personaly I use
```
/client/projectname/trunk/source/Solution Name.sln
/client/projectname/trunk/source/Project.One
/client/projectname/trunk/source/Project.Two
/client/projectname/trunk/source/Project.Three
/client/projectname/trunk/source/SQL/
/client/projectname/trunk/source/SQL/SomeScript.sql
/client/projectname/t... |
446,026 | <p>Variations of this question have been asked, but I'm still unable to get my stylesheets to load correctly when my templates are rendered.</p>
<p>I'm attempting to serve static media from the Django process during development - which is strongly discouraged in production, I'm aware. I'll post my configuration and my... | [
{
"answer_id": 446116,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 1,
"selected": false,
"text": "<p>I've got a couple of ideas, I don't know which one of them is working for me :)</p>\n\n<blockquote>\n <p>Make sure to u... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10583/"
] | Variations of this question have been asked, but I'm still unable to get my stylesheets to load correctly when my templates are rendered.
I'm attempting to serve static media from the Django process during development - which is strongly discouraged in production, I'm aware. I'll post my configuration and my template,... | I just had to figure this out myself.
settings.py:
```
MEDIA_ROOT = 'C:/Server/Projects/project_name/static/'
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'
```
urls.py:
```
from django.conf import settings
...
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.vie... |
446,052 | <p>If I have a Python script that requires at least a particular
version of Python, what is the correct way to fail gracefully
when an earlier version of Python is used to launch the script?</p>
<p>How do I get control early enough to issue an error message
and exit?</p>
<p>For example, I have a program that uses the... | [
{
"answer_id": 446061,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 8,
"selected": true,
"text": "<p>You can test using <code>eval</code>:</p>\n\n<pre><code>try:\n eval(\"1 if True else 2\")\nexcept SyntaxError:\n # doesn'... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | If I have a Python script that requires at least a particular
version of Python, what is the correct way to fail gracefully
when an earlier version of Python is used to launch the script?
How do I get control early enough to issue an error message
and exit?
For example, I have a program that uses the ternery operator... | You can test using `eval`:
```
try:
eval("1 if True else 2")
except SyntaxError:
# doesn't have ternary
```
Also, `with` *is* available in Python 2.5, just add `from __future__ import with_statement`.
EDIT: to get control early enough, you could split it into different `.py` files and check compatibility in the... |
446,060 | <p>I want to put two <code><div></code>s next to each other. The right <code><div></code> is about 200px; and the left <code><div></code> must fill up the rest of the screen width? How can I do this?</p>
| [
{
"answer_id": 446068,
"author": "falstro",
"author_id": 46991,
"author_profile": "https://Stackoverflow.com/users/46991",
"pm_score": 5,
"selected": false,
"text": "<p>Unfortunately, this is not a trivial thing to solve for the general case. The easiest thing would be to add a css-style... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40676/"
] | I want to put two `<div>`s next to each other. The right `<div>` is about 200px; and the left `<div>` must fill up the rest of the screen width? How can I do this? | You can use **[flexbox](https://devdocs.io/css/css_flexible_box_layout)** to lay out your items:
```css
#parent {
display: flex;
}
#narrow {
width: 200px;
background: lightblue;
/* Just so it's visible */
}
#wide {
flex: 1;
/* Grow to rest of container */
background: lightgreen;
/* Just so ... |
446,073 | <p>I have a little problem and I'm hopping that you can help me solve this annoying issue.</p>
<p>I need to use an iFrame in an administration panel to let users use the selection service, and in the HTML I have:</p>
<pre><code><iframe scrolling="yes" runat="server" title="Par Selection" id="iFrame"
frameborde... | [
{
"answer_id": 446090,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": -1,
"selected": false,
"text": "<p>This seems like a case where you can take advantage of URL encoding to hide the &, bypassing XML encoding. & ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28004/"
] | I have a little problem and I'm hopping that you can help me solve this annoying issue.
I need to use an iFrame in an administration panel to let users use the selection service, and in the HTML I have:
```
<iframe scrolling="yes" runat="server" title="Par Selection" id="iFrame"
frameborder="0" enableviewstate="t... | The presense of the & is actually correct there. Most browsers are forgiving enough not to choke on just seeing & there, but it's technically not correct. |
446,108 | <p>Please tell me how to check regular expression for no blank space b/w text.</p>
| [
{
"answer_id": 446165,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know if it is the regular expression you are looking for but, <code>[:space:]</code> will match any whitespace char... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please tell me how to check regular expression for no blank space b/w text. | If you mean "What's the reqular expression to check there is no white space in a string", the following pattern will work:
```
^[\S]*$
```
This will find any string that only contains non-white space (spaces, new lines, tabs, etc). |
446,126 | <p>Here's a sample string which I want do a regex on</p>
<pre><code>101-nocola_conte_-_fuoco_fatuo_(koop_remix)
</code></pre>
<p>The first digit in "101" is the disc number and the next 2 digits are the track numbers. How do I match the track numbers and ignore the disc number (first digit)?</p>
| [
{
"answer_id": 446131,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 2,
"selected": false,
"text": "<p>Something like</p>\n\n<pre><code>/^\\d(\\d\\d)/\n</code></pre>\n\n<p>Would match one digit at the start of the string,... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's a sample string which I want do a regex on
```
101-nocola_conte_-_fuoco_fatuo_(koop_remix)
```
The first digit in "101" is the disc number and the next 2 digits are the track numbers. How do I match the track numbers and ignore the disc number (first digit)? | Do you mean that you don't mind what the disk number is, but you want to match, say, track number 01 ?
In perl you would match it like so: "^[0-9]01.\*"
or more simply "^.01.\*" - which means that you don't even mind if the first char is not a digit. |
446,153 | <p>I'd like to generate uniformly distributed random integers over a given range. The interpreted language I'm using has a builtin fast random number generator that returns a floating point number in the range 0 (inclusive) to 1 (inclusive). Unfortunately this means that I can't use the <a href="https://stackoverflow.c... | [
{
"answer_id": 446190,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": -1,
"selected": false,
"text": "<p>I don't see why the <code>+ 1</code> is needed. If the random number generator delivers a uniform distribution of value... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41338/"
] | I'd like to generate uniformly distributed random integers over a given range. The interpreted language I'm using has a builtin fast random number generator that returns a floating point number in the range 0 (inclusive) to 1 (inclusive). Unfortunately this means that I can't use the [standard solution seen in another ... | Presumably you are desperately interested in speed, or else you would just suck up the conditional test with every RNG call. Any other alternative is probably going to be slower than the branch anyway...
...unless you know exactly what the internal structure of the RNG is. Particularly, what are its return values? If ... |
446,179 | <p>In my Global.asax.cs file in RegisterRoutes method, I put</p>
<pre><code>routes.MapRoute("messages",
"Message/{id}",
new { controller = "Archive", action = "Message", id = 0 });
</code></pre>
<p>Then I created this controller: </p>
<pre><code>namespace TestingApp.Controllers
{
public class ArchiveCo... | [
{
"answer_id": 446287,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": true,
"text": "<p>Try defining your specific route before the Default one:</p>\n\n<pre><code>routes.MapRoute(\n \"messages\",\n ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | In my Global.asax.cs file in RegisterRoutes method, I put
```
routes.MapRoute("messages",
"Message/{id}",
new { controller = "Archive", action = "Message", id = 0 });
```
Then I created this controller:
```
namespace TestingApp.Controllers
{
public class ArchiveController : Controller
{
p... | Try defining your specific route before the Default one:
```
routes.MapRoute(
"messages",
"Message/{id}",
new { controller = "Archive", action = "Message", id = 0 });
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" });
``` |
446,196 | <p>What is the most preferred and easiest way to do pagination in ASP.NET MVC? I.e. what is the easiest way to break up a list into several browsable pages.</p>
<p>As an example lets say I get a list of elements from a database/gateway/repository like this:</p>
<pre><code>public ActionResult ListMyItems()
{
List... | [
{
"answer_id": 446232,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 8,
"selected": true,
"text": "<p>Well, what is the data source? Your action could take a few defaulted arguments, i.e.</p>\n\n<pre><code>ActionResul... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3713/"
] | What is the most preferred and easiest way to do pagination in ASP.NET MVC? I.e. what is the easiest way to break up a list into several browsable pages.
As an example lets say I get a list of elements from a database/gateway/repository like this:
```
public ActionResult ListMyItems()
{
List<Item> list = ItemDB.G... | Well, what is the data source? Your action could take a few defaulted arguments, i.e.
```
ActionResult Search(string query, int startIndex, int pageSize) {...}
```
defaulted in the routes setup so that startIndex is 0 and pageSize is (say) 20:
```
routes.MapRoute("Search", "Search/{query}/{startIndex}",
... |
446,205 | <p>Can I continue to use an multimap iterator even after a call to multimap::erase()? For example:</p>
<pre><code>Blah::iterator iter;
for ( iter = mm.begin();
iter != mm.end();
iter ++ )
{
if ( iter->second == something )
{
mm.erase( iter );
}
}
</code></pre>
<p>Should this be exp... | [
{
"answer_id": 446212,
"author": "Igor Semenov",
"author_id": 11401,
"author_profile": "https://Stackoverflow.com/users/11401",
"pm_score": 1,
"selected": false,
"text": "<p>C++ Standard 23.1.2.8:</p>\n\n<blockquote>\n <p>The insert members shall not affect the validity of iterators and... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13022/"
] | Can I continue to use an multimap iterator even after a call to multimap::erase()? For example:
```
Blah::iterator iter;
for ( iter = mm.begin();
iter != mm.end();
iter ++ )
{
if ( iter->second == something )
{
mm.erase( iter );
}
}
```
Should this be expected to run correctly, or is ... | <http://www.sgi.com/tech/stl/Multimap.html>
```
Multimap has the important property that inserting a new element
into a multimap does not invalidate iterators that point to existing
elements. Erasing an element from a multimap also does not invalidate
any iterators, except, of course, for iterators that actually point... |
446,209 | <p>What are the possible return values from the following command?</p>
<pre><code>import sys
print sys.platform
</code></pre>
<p>I know there is a lot of possibilities, so I'm mainly interested in the "main" ones (Windows, Linux, Mac OS)</p>
| [
{
"answer_id": 446210,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 6,
"selected": true,
"text": "<p>Mac OS X (10.4, 10.5, 10.7, 10.8):</p>\n\n<pre><code>darwin\n</code></pre>\n\n<p>Linux (2.6 kernel):</p>\n\n<pre><code>linux2\n<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | What are the possible return values from the following command?
```
import sys
print sys.platform
```
I know there is a lot of possibilities, so I'm mainly interested in the "main" ones (Windows, Linux, Mac OS) | Mac OS X (10.4, 10.5, 10.7, 10.8):
```
darwin
```
Linux (2.6 kernel):
```
linux2
```
Windows XP 32 bit:
```
win32
```
Versions in brackets have been checked - other/newer versions are likely to be the same. |
446,218 | <p>I have created this program:</p>
<pre><code>//Includes....
int main()
{
ifstream readfile("File.txt");
string str;
while(1)
{
getline(readfile,str);
system("cls");
Sleep(10000);
}
}
</code></pre>
<p>It's just a program that reads every 10 seconds a line from the file "File.txt"</p>... | [
{
"answer_id": 446254,
"author": "Schildmeijer",
"author_id": 148909,
"author_profile": "https://Stackoverflow.com/users/148909",
"pm_score": 1,
"selected": false,
"text": "<p>Platform dependent. But I think you are using windows because of the \"cls\" command.\nWhy cant you just start a... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have created this program:
```
//Includes....
int main()
{
ifstream readfile("File.txt");
string str;
while(1)
{
getline(readfile,str);
system("cls");
Sleep(10000);
}
}
```
It's just a program that reads every 10 seconds a line from the file "File.txt"
I want to make it work on ba... | If this was UNIX you would run the program from the shell with an ampersand "&" after the program name. |
446,222 | <p>Using Python 2.5, I have some text in stored in a unicode object:</p>
<blockquote>
<p>Dinis e Isabel, uma difı´cil relac¸a˜o
conjugal e polı´tica</p>
</blockquote>
<p>This appears to be <a href="http://www.unicode.org/reports/tr15/#Decomposition" rel="noreferrer">decomposed Unicode</a>. Is there a generic way ... | [
{
"answer_id": 446255,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I can't really give you a definitive answer to your question because I never tried that. But there is a <a href=\"http://do... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1002/"
] | Using Python 2.5, I have some text in stored in a unicode object:
>
> Dinis e Isabel, uma difı´cil relac¸a˜o
> conjugal e polı´tica
>
>
>
This appears to be [decomposed Unicode](http://www.unicode.org/reports/tr15/#Decomposition). Is there a generic way in Python to reverse the decomposition, so I end up with:
... | I think you are looking for this:
```
>>> import unicodedata
>>> print unicodedata.normalize("NFC",u"c\u0327")
ç
``` |
446,244 | <p>I have a Git repository (originally CVS, then SVN, now Git) containing a Rails project that has been deployed on Linux for a while now. Everything seems to run fine.</p>
<p>Now that I've converted to git, I see that <strong>many of my files in the repository contain <a href="http://en.wikipedia.org/wiki/Newline" r... | [
{
"answer_id": 470783,
"author": "davitenio",
"author_id": 50765,
"author_profile": "https://Stackoverflow.com/users/50765",
"pm_score": 4,
"selected": true,
"text": "<p>If it is ok for you to rewrite your repository's history (see <a href=\"http://www.kernel.org/pub/software/scm/git/doc... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13216/"
] | I have a Git repository (originally CVS, then SVN, now Git) containing a Rails project that has been deployed on Linux for a while now. Everything seems to run fine.
Now that I've converted to git, I see that **many of my files in the repository contain [`CRLF`](http://en.wikipedia.org/wiki/Newline) line endings**. I'... | If it is ok for you to rewrite your repository's history (see [problems with rewriting history](http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#problems-With-rewriting-history)) you could use git filter-branch to convert CRLF to LF:
```
git filter-branch --tree-filter 'find . -path './.git' -prune -o ... |
446,262 | <p>I am sorting a GridView bind to a ananymous type.</p>
<pre><code>protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
List<object> lb = (List<object>)ReturnAnony(); // Not working
// ?? What to write here
}
object ReturnAnony()
{
var anony = // I create the ananymous t... | [
{
"answer_id": 446281,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 2,
"selected": true,
"text": "<p>Not really sure what you want.</p>\n\n<p>If you are going to create a List that is typed to anonymous type, you can use a ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am sorting a GridView bind to a ananymous type.
```
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
List<object> lb = (List<object>)ReturnAnony(); // Not working
// ?? What to write here
}
object ReturnAnony()
{
var anony = // I create the ananymous type and return
ret... | Not really sure what you want.
If you are going to create a List that is typed to anonymous type, you can use a currying function to help you:
```
public List<T> makeAList<T>(T x)
{
var l = new List<T>();
l.Add(x);
return l;
}
```
Is that what you want?
Otherwise, you cannot reference the anonymous ty... |
446,268 | <p>Some of our projects call for default Visual Studio tab options (width 4; keep tabs); some call for width 3; use spaces. Don't ask.</p>
<p>Rather than set these globally, is there anyway in which I could set this on a per-solution or per-project or even (emacs-style) per-file?</p>
<p>Visual Studio 2005 and 2008.</... | [
{
"answer_id": 696526,
"author": "ljubomir",
"author_id": 11506,
"author_profile": "https://Stackoverflow.com/users/11506",
"pm_score": 2,
"selected": false,
"text": "<p>I have a similar problem: my new project needs to be set up with <strong>keep tabs</strong>, while my other projects a... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] | Some of our projects call for default Visual Studio tab options (width 4; keep tabs); some call for width 3; use spaces. Don't ask.
Rather than set these globally, is there anyway in which I could set this on a per-solution or per-project or even (emacs-style) per-file?
Visual Studio 2005 and 2008. | The most convenient solution I know is to create a set of Visual Studio macros to switch to the settings you want.
Go to `Tools > Macros > Macros IDE`. There, in the tree on the left, right-click `MyMacros` and choose `Add > Add Module`. Give the module a name such as `TabSize`. Within this module, create subs to chan... |
446,269 | <p>From <a href="http://items.sjbach.com/319/configuring-vim-right" rel="noreferrer">http://items.sjbach.com/319/configuring-vim-right</a> I got that you were supposed to be able to use <kbd>Space</kbd> as the mapleader in vim. I've tried but it does not seem to work. Anyone who have made it work? </p>
<p>Tried:</p>
... | [
{
"answer_id": 446293,
"author": "Zsolt Botykai",
"author_id": 11621,
"author_profile": "https://Stackoverflow.com/users/11621",
"pm_score": 8,
"selected": true,
"text": "<p>Try the following instead:</p>\n\n<pre><code>let mapleader=\" \"\n</code></pre>\n\n<p>And remember to write the fo... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42793/"
] | From <http://items.sjbach.com/319/configuring-vim-right> I got that you were supposed to be able to use `Space` as the mapleader in vim. I've tried but it does not seem to work. Anyone who have made it work?
Tried:
```
let mapleader = <space>
``` | Try the following instead:
```
let mapleader=" "
```
And remember to write the following line before that, to make sure spacebar doesn't have any mapping beforehand:
```
nnoremap <SPACE> <Nop>
``` |
446,272 | <p>The following PL/SQL will not execute and simply returns 'Invalid Argument' as an error. I've gone as far as commenting out eavery line one by one and I can vary the error I receive but I cannot get the proc to run as I cannot identify where the error lies and it may well lie in permissions or the executing user b... | [
{
"answer_id": 446310,
"author": "tuinstoel",
"author_id": 43901,
"author_profile": "https://Stackoverflow.com/users/43901",
"pm_score": 0,
"selected": false,
"text": "<p>You can download SQL Developer and use its debugger (it is free). </p>\n\n<p>See here: <a href=\"http://www.oracle.co... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27412/"
] | The following PL/SQL will not execute and simply returns 'Invalid Argument' as an error. I've gone as far as commenting out eavery line one by one and I can vary the error I receive but I cannot get the proc to run as I cannot identify where the error lies and it may well lie in permissions or the executing user but an... | For this particular problem it is because the schema\_name speccs\_web\_test is not in upper case. SPECCS\_WEB\_TEST is fine and the proc is now running ;) |
446,276 | <p>I just read about the <a href="http://www.fastformat.org/" rel="noreferrer">FastFormat C++ i/o formatting library</a>, and it seems too good to be true: Faster even than printf, typesafe, and with what I consider a pleasing interface:</p>
<pre><code>// prints: "This formats the remaining arguments based on their or... | [
{
"answer_id": 446918,
"author": "Tom",
"author_id": 40620,
"author_profile": "https://Stackoverflow.com/users/40620",
"pm_score": 0,
"selected": false,
"text": "<p>If you look in detail at his performance benchmark page, you'll notice that good old C <code>printf</code>-family functions... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | I just read about the [FastFormat C++ i/o formatting library](http://www.fastformat.org/), and it seems too good to be true: Faster even than printf, typesafe, and with what I consider a pleasing interface:
```
// prints: "This formats the remaining arguments based on their order - in this case we put 1 before zero, f... | Found one "catch", though for most people it will *never* manifest. From the project page:
>
> **Atomic operation.** It doesn't write out statement elements one at a time, like the IOStreams, so has no atomicity issues
>
>
>
The only way I can see this happening is if it buffers the whole `write()` call's output ... |
446,285 | <p>I have an input field where both regular text and sprintf tags can be entered.</p>
<p>Example: <code>some text here. %1$s done %2$d times</code></p>
<p>How do I validate the sprintf parts so its not possible them wrong like <code>%$1s</code> ?
The text is utf-8 and as far as I know regex only match latin-1 charact... | [
{
"answer_id": 446378,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 2,
"selected": false,
"text": "<p>The UTF-8 modifier is not necessary unless you use UTF-8 in your pattern. And beside that the <a href=\"http://www.php.ne... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52025/"
] | I have an input field where both regular text and sprintf tags can be entered.
Example: `some text here. %1$s done %2$d times`
How do I validate the sprintf parts so its not possible them wrong like `%$1s` ?
The text is utf-8 and as far as I know regex only match latin-1 characters.
www.regular-expressions.info does... | This is what I ended up with, and its working.
```
// Always use server validation even if you have JS validation
if (!isset($_POST['input']) || empty($_POST['input'])) {
// Do stuff
} else {
$matches = explode(' ',$_POST['input']);
$validInput = true;
foreach ($matches as $m) {
// Check if a slice contai... |
446,289 | <p>I'm working with a publishing system that uses custom tags. These are interpreted on the server. The problem is, that they cause big problems with Opera, when viewed locally (custom tags are not interpreted).</p>
<p>Opera is handling these tags differently from other browser. It looks like it is closing the tag at ... | [
{
"answer_id": 446343,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>I use opera for more than 5 years. It is the browser that approaches the standard the best. Most of the sites that... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22920/"
] | I'm working with a publishing system that uses custom tags. These are interpreted on the server. The problem is, that they cause big problems with Opera, when viewed locally (custom tags are not interpreted).
Opera is handling these tags differently from other browser. It looks like it is closing the tag at the end of... | This seems to be fixed in [Opera 10](http://www.opera.com/browser/next/). So I guess it was not a feature. |
446,296 | <p>I need a binary search algorithm that is compatible with the C++ STL containers, something like <code>std::binary_search</code> in the standard library's <code><algorithm></code> header, but I need it to return the iterator that points at the result, not a simple boolean telling me if the element exists.</p>
... | [
{
"answer_id": 446313,
"author": "Luc Hermitte",
"author_id": 15934,
"author_profile": "https://Stackoverflow.com/users/15934",
"pm_score": 3,
"selected": false,
"text": "<p>You should have a look at <code>std::equal_range</code>. It will return a pair of iterators to the range of all re... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | I need a binary search algorithm that is compatible with the C++ STL containers, something like `std::binary_search` in the standard library's `<algorithm>` header, but I need it to return the iterator that points at the result, not a simple boolean telling me if the element exists.
(On a side note, what the hell was ... | There is no such functions, but you can write a simple one using [`std::lower_bound`](http://en.cppreference.com/w/cpp/algorithm/lower_bound), [`std::upper_bound`](http://en.cppreference.com/w/cpp/algorithm/upper_bound) or [`std::equal_range`](http://en.cppreference.com/w/cpp/algorithm/equal_range).
A simple implement... |
446,303 | <p>I am getting a little confused and need some help please. Take these two classes</p>
<pre><code>public class Comment
{
public string Message {get; set;}
public DateTime Created {get; set;}
}
public class Post
{
public int PostId {get; set;}
public string Content {get; set;}
public IList<C... | [
{
"answer_id": 446330,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>Ordered by <em>which</em> comment date? the first? the last? You cuold try:</p>\n\n<pre><code>orderby p.Comments.Ma... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am getting a little confused and need some help please. Take these two classes
```
public class Comment
{
public string Message {get; set;}
public DateTime Created {get; set;}
}
public class Post
{
public int PostId {get; set;}
public string Content {get; set;}
public IList<Comment> Comments {... | Ordered by *which* comment date? the first? the last? You cuold try:
```
orderby p.Comments.Max(x=>x.Created)
```
for example.
Also - your `Single` suggests you expect **exactly** one row, in which case there isn't much point sorting it. Do you mean `First()` ?
---
Or do you mean that you want to sort the `Commen... |
446,320 | <p><strong>EDIT:</strong> Oops - as rightly pointed out, there'd be no way to know whether the constructor for the class in question is sensitive to when or how many times it is called, or whether the object's state is changed during the method, so it would have to be created from scratch each time. Ignore the Dictiona... | [
{
"answer_id": 446340,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 4,
"selected": true,
"text": "<p>How should the C# compiler know that it's \"the same\" dictionary every time? You explicitly create a new dictionary... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | **EDIT:** Oops - as rightly pointed out, there'd be no way to know whether the constructor for the class in question is sensitive to when or how many times it is called, or whether the object's state is changed during the method, so it would have to be created from scratch each time. Ignore the Dictionary and just cons... | How should the C# compiler know that it's "the same" dictionary every time? You explicitly create a new dictionary every time. C# does not support static local variables, so you have to use a field. There's nothing wrong with that, even if no other method uses the field.
It would be bad if the C# compiler did things l... |
446,322 | <p>I have inherited a very old database that needs some data to be updated. Each row ha a column with a UniqueID that looks like C0042-45-39612. The last 3 numbers of the code are the category Id (in this case 612). </p>
<p>I need to do an update that targets only certain categories and I'm using this SQL statement</p... | [
{
"answer_id": 617327,
"author": "user74207",
"author_id": 74207,
"author_profile": "https://Stackoverflow.com/users/74207",
"pm_score": 4,
"selected": false,
"text": "<p>Joe90 - I have to say that in my experience, I can't agree that managing lots of local resource files scattered throu... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23230/"
] | I have inherited a very old database that needs some data to be updated. Each row ha a column with a UniqueID that looks like C0042-45-39612. The last 3 numbers of the code are the category Id (in this case 612).
I need to do an update that targets only certain categories and I'm using this SQL statement
```
UPDATE ... | I kept on looking for guidelines, and found this in [MSDN](http://msdn.microsoft.com/en-us/library/ms227427.aspx):
>
> **Choosing Between Global and Local Resource Files**
>
>
> You can use any combination of global
> and local resource files in the Web
> application. Generally, you add
> resources to a global reso... |
446,354 | <p>I'm passing in a bunch of key-value pairs as parameters to a XSL (date -> "20th January", author -> "Dominic Rodger", ...).</p>
<p>These are referenced in some XML I'm parsing - the XML looks like this:</p>
<pre><code><element datasource="date" />
</code></pre>
<p>At present, I can't work out how to get 20t... | [
{
"answer_id": 446435,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": -1,
"selected": false,
"text": "<p>How about</p>\n\n<pre><code><xsl:template match=\"date-element\">\n <xsl:text>${date}</xsl:text&... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20972/"
] | I'm passing in a bunch of key-value pairs as parameters to a XSL (date -> "20th January", author -> "Dominic Rodger", ...).
These are referenced in some XML I'm parsing - the XML looks like this:
```
<element datasource="date" />
```
At present, I can't work out how to get 20th January out of these except with a ho... | **Here is one possible solution**, however I'd recommend grouping all parameters in a separate XML file and accessing them with the [**`document()`**](http://www.w3.org/TR/xslt#function-document) function:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/... |
446,359 | <p>I am pretty <em>confused</em> about the <strong>ASP.NET MVC</strong> project architecture.
In ASP.NET WebForm I am normally for small to medium size project using following Project pattern</p>
<p><strong>DAL <-- communicate through <em>DTO/reader/dataset</em> -- > BL <--> UI</strong> </p>
<p>I think in MVC ... | [
{
"answer_id": 447084,
"author": "Ali Ersöz",
"author_id": 4215,
"author_profile": "https://Stackoverflow.com/users/4215",
"pm_score": 1,
"selected": false,
"text": "<p>I've already started to a ASP.Net MVC project. In my architecture, layers almost like yours.</p>\n\n<p>There is an Enti... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37571/"
] | I am pretty *confused* about the **ASP.NET MVC** project architecture.
In ASP.NET WebForm I am normally for small to medium size project using following Project pattern
**DAL <-- communicate through *DTO/reader/dataset* -- > BL <--> UI**
I think in MVC application should be like
**DAL <-- communicate through *DTO... | Comparing traditional 3 tier **ASP.NET Web App** to **ASP.NET MVC**, the following becomes the corresponding elements:
**Business Logic Layer** and **Data Access Layer** together is the **Model**
**ASPX** file is the **View**
**Code-behind** (ASPX.CS) is the **Controller**
Have a look at these links for more discu... |
446,376 | <p>I use struts-html to generate forms fields. </p>
<p>For example: </p>
<pre><code><%@ taglib prefix="html" uri="/WEB-INF/taglibs/struts-html.tld" %>
<html:text property="email" styleId="email" size="44"/>
</code></pre>
<p>generates:</p>
<pre><code><input type="text" name="email" size="44" value=""... | [
{
"answer_id": 446387,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 0,
"selected": false,
"text": "<p><code>input</code> tags don't have to be closed in HTML, so I'm guessing Struts doesn't know you're trying to generate X... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I use struts-html to generate forms fields.
For example:
```
<%@ taglib prefix="html" uri="/WEB-INF/taglibs/struts-html.tld" %>
<html:text property="email" styleId="email" size="44"/>
```
generates:
```
<input type="text" name="email" size="44" value="" id="email">
```
As shown above the generated input tag ... | Can you not just use [`<html:xhtml/>`](http://struts.apache.org/1.x/struts-taglib/tlddoc/html/xhtml.html)?
>
> Using this tag in a page tells all other html taglib tags to render themselves as XHTML 1.0
>
>
>
Alternatively you could use `<html:html xhtml="true">`. |
446,380 | <p>When trying to replace the content of an XML file in C#.NET with a snippet like this:</p>
<pre><code>string file = Path.GetTempFileName(); // pretend this is a real file
string tmpFile = Path.GetTempFileName();
using (var writer = XmlWriter.Create(File.Create(tmpFile)))
{
writer.WriteStartElement("root");
... | [
{
"answer_id": 446395,
"author": "Christoffer Soop",
"author_id": 51016,
"author_profile": "https://Stackoverflow.com/users/51016",
"pm_score": 4,
"selected": true,
"text": "<p>For some reason the XmlWriter class evidently does not dispose the underlying stream for the temporary file. Pu... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51016/"
] | When trying to replace the content of an XML file in C#.NET with a snippet like this:
```
string file = Path.GetTempFileName(); // pretend this is a real file
string tmpFile = Path.GetTempFileName();
using (var writer = XmlWriter.Create(File.Create(tmpFile)))
{
writer.WriteStartElement("root");
for (int i = 0... | For some reason the XmlWriter class evidently does not dispose the underlying stream for the temporary file. Putting the stream in a "using" clause of its own makes sure the stream is closed correctly. Changing the code to
```
string file = Path.GetTempFileName(); // pretend this is a real file
string tmpFile = Path.G... |
446,390 | <p>How to detect IIS version using C#?</p>
<p>Update:
I meant from a winapp (actually the scenario is developing a custom installer that wants to check the version of the installed IIS to call the appropriate api's)</p>
| [
{
"answer_id": 446400,
"author": "Igal Tabachnik",
"author_id": 8205,
"author_profile": "https://Stackoverflow.com/users/8205",
"pm_score": 6,
"selected": true,
"text": "<p>You can get this information from the <code>SERVER_SOFTWARE</code> variable. It will return the following:</p>\n\n<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25240/"
] | How to detect IIS version using C#?
Update:
I meant from a winapp (actually the scenario is developing a custom installer that wants to check the version of the installed IIS to call the appropriate api's) | You can get this information from the `SERVER_SOFTWARE` variable. It will return the following:
`Microsoft-IIS/5.0 (Windows 2000)`
`Microsoft-IIS/5.1 (Windows XP)`
`Microsoft-IIS/6.0 (Windows 2003 Server)`
etc.
If you're using ASP.NET, you can get this string via
```
Request.ServerVariables["SERVER_SOFTWARE"... |
446,399 | <p>Is it just me who find the following code intrinsically backwards?</p>
<p>I am using <a href="http://blog.pengoworks.com/index.cfm/2007/10/26/jQuery-Understanding-the-chain" rel="nofollow noreferrer">this posting</a> as a reference.</p>
<pre><code>// create the inner div
var $inner = $("<div>inner</div>... | [
{
"answer_id": 446409,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 1,
"selected": false,
"text": "<p>not really, it all depends what you wish to chain afterwards, using appendTo gives you access to the new element rather... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54556/"
] | Is it just me who find the following code intrinsically backwards?
I am using [this posting](http://blog.pengoworks.com/index.cfm/2007/10/26/jQuery-Understanding-the-chain) as a reference.
```
// create the inner div
var $inner = $("<div>inner</div>")
// append it to a new outer div
.appendTo("<div>outer</div>... | You can do it the other way too:
```
$('body').append('<div>outer</div>').append('<div>inner<div>');
```
but that will leave you at `body`
To end up at `inner` you'd need to:
```
$('body').append('<div>outer</div>').append('<div>inner<div>')
.find('div:contains(inner)');
``` |
446,405 | <p>Consider I have the following text in a <code>UILabel</code> (a long line of dynamic text):</p>
<blockquote>
<p>Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such as seeking cover behind dumpsters, pillars, cars, rubble, and other objects. </p>
</... | [
{
"answer_id": 446864,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>You can implement <code>TableViewController's</code> <code>(UITableViewCell *)tableView:cellForRowAtIndexPath</code> meth... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49739/"
] | Consider I have the following text in a `UILabel` (a long line of dynamic text):
>
> Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such as seeking cover behind dumpsters, pillars, cars, rubble, and other objects.
>
>
>
I want to resize the `UILab... | `sizeWithFont constrainedToSize:lineBreakMode:` is the method to use. An example of how to use it is below:
```
//Calculate the expected size based on the font and linebreak mode of your label
// FLT_MAX here simply means no constraint in height
CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);
CGSize expectedLabel... |
446,422 | <p>How can I access dynamically properties from a generated LINQ class ?</p>
<p>Cause I would like to be able to customize the displayed table columns
where Partner is the LINQ Class generated from a SQL Server Database Table.</p>
<pre><code><table class="grid">
<thead>
<tr>
<% foreach ... | [
{
"answer_id": 446448,
"author": "Sander",
"author_id": 2928,
"author_profile": "https://Stackoverflow.com/users/2928",
"pm_score": 2,
"selected": false,
"text": "<p>I believe the following will accomplish what you want:</p>\n\n<pre><code>p.GetType().GetProperty(c.Name).GetValue(p)\n</co... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55390/"
] | How can I access dynamically properties from a generated LINQ class ?
Cause I would like to be able to customize the displayed table columns
where Partner is the LINQ Class generated from a SQL Server Database Table.
```
<table class="grid">
<thead>
<tr>
<% foreach (Column c in (IEnumerable)ViewData["column... | Reflection is a pretty good fit here, but really - everything is known at compile time. So it's possible to specify everything at design time.
```
public class DataItem
{
string Title {get;set;}
object Value {get;set;}
}
public interface IDataItems
{
IEnumerable<DataItem> Items()
}
//suppose LINQ gives you thi... |
446,423 | <p>I have the bad luck of having to downport some ActionScript 3 code to ActionScript 2 and I have a problem with detecting when the mouse leaves the stage.</p>
<p>In ActionScript 3 there is an event called <code>Event.MOUSE_LEAVE</code>, which can be used to detect when the mouse leaves the stage, but there is no equ... | [
{
"answer_id": 446512,
"author": "grapefrukt",
"author_id": 914,
"author_profile": "https://Stackoverflow.com/users/914",
"pm_score": 3,
"selected": false,
"text": "<p>I have not found a reliable way to do this in AS2 (on some browsers you even keep getting mouse updates when the mouse i... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1109/"
] | I have the bad luck of having to downport some ActionScript 3 code to ActionScript 2 and I have a problem with detecting when the mouse leaves the stage.
In ActionScript 3 there is an event called `Event.MOUSE_LEAVE`, which can be used to detect when the mouse leaves the stage, but there is no equivalent in ActionScri... | Using math to estimate when the mouse *will be* out of bounds:
--------------------------------------------------------------
(An implementation along the lines of Theo's 3rd option.)
```
// Stage rollout detection:
private var mouse_dx:Number;
private var mouse_dy:Number;
private function detectMouseOutOfBounds ():... |
446,439 | <p>We are getting this error on starting tomcat (both as a service and via command line):</p>
<pre><code>This release of Apache Tomcat was packaged to run on J2SE 5.0
or later. It can be run on earlier JVMs by downloading and
installing a compatibility package from the Apache Tomcat
binary download page.
</code></pre>... | [
{
"answer_id": 446450,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 1,
"selected": false,
"text": "<p>You can configure a different version of Java in the start.bat file. The same goes for the service (but in a diff... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48310/"
] | We are getting this error on starting tomcat (both as a service and via command line):
```
This release of Apache Tomcat was packaged to run on J2SE 5.0
or later. It can be run on earlier JVMs by downloading and
installing a compatibility package from the Apache Tomcat
binary download page.
```
We have the version w... | You only have the exe version and not the bat files, because you've downloaded the Windows Installer and not the zip file. The bat files are only included in the zip file. You can download the zip and copy the bat files to the bin directory. No need to uninstall.
I bet that you have a PATH problem. Check if there is a... |
446,454 | <p>I'm writing an user-driven app with several zones to it. I want to allow users to customise their messaging settings so they only get emails on the parts and actions they care about. I've drawn up the following <code>Class</code>:</p>
<pre><code>class EmailSetting(models.Model):
user = models.ForeignKey(User, r... | [
{
"answer_id": 446582,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 1,
"selected": false,
"text": "<p>Well here's how I did it:</p>\n\n<pre><code>def get_users(key, default):\n if not default:\n return [es.user for ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12870/"
] | I'm writing an user-driven app with several zones to it. I want to allow users to customise their messaging settings so they only get emails on the parts and actions they care about. I've drawn up the following `Class`:
```
class EmailSetting(models.Model):
user = models.ForeignKey(User, related_name="%(class)s_re... | I changed your related name on the user field, as I don't think you want to refer to an EmailSetting with "user" in the name.
```
def get_users(key, default):
if default:
return User.objects.exclude(emailsetting__key=key, emailsetting__value=False)
else:
return User.objects.filter(emailsetting_... |
446,456 | <p>What is everyone's recommendations on where to place database objects (tables, procs, views etc.) for a custom add-on
to another application's database? </p>
<p>Should they be kept separated like so:</p>
<pre><code>ErpInventoryAccountingWare.dbo
CustomIntegratedPortal.dbo
</code></pre>
<p>Or, could the add-ons o... | [
{
"answer_id": 446661,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": true,
"text": "<p>If you put them in a different database, a backup of just the application's database will miss them, s... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44572/"
] | What is everyone's recommendations on where to place database objects (tables, procs, views etc.) for a custom add-on
to another application's database?
Should they be kept separated like so:
```
ErpInventoryAccountingWare.dbo
CustomIntegratedPortal.dbo
```
Or, could the add-ons objects be placed in the same data... | If you put them in a different database, a backup of just the application's database will miss them, so it presents a gotcha for operational maintenance of the application.
On SQL Server 2005, making your own schema will help prevent namespace pollution should the application's developer decide to add a table with a n... |
446,467 | <p>I have a small AJAX application, written in PHP that I did not secure from the start. I would like some recommendations on how to now secure the app, things to implement and check for. I have not found any exhaustive guides on google, and hope that some can be recommended.</p>
<p>It is a small application that conn... | [
{
"answer_id": 446531,
"author": "Gerrit",
"author_id": 5976,
"author_profile": "https://Stackoverflow.com/users/5976",
"pm_score": 0,
"selected": false,
"text": "<p>You're looking for the ultimate security manual? Send me a copy when you find it!</p>\n\n<p>The short checklist: </p>\n\n<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I have a small AJAX application, written in PHP that I did not secure from the start. I would like some recommendations on how to now secure the app, things to implement and check for. I have not found any exhaustive guides on google, and hope that some can be recommended.
It is a small application that connects to an... | If you are talking about securing the app (as opposed to the server/ environment it is on - which I am not really qualified to address) then I would consider the following:
1. Ensure any user inputs are parsed/cleaned to ensure they can't do things such as [SQL injection attacks](http://www.unixwiz.net/techtips/sql-in... |
446,468 | <p>I have the following code:</p>
<pre><code>var emp = new List<Employee>
{
new Employee{ID=1, EmpFname="matt", EmpLName="Cook"},
new Employee{ID=2, EmpFname="mary", EmpLname="John"}
};
</code></pre>
<p>How do I sort emp by EmpLName and bind it to a GridView? How do I specify asc or desc?</p>
| [
{
"answer_id": 446531,
"author": "Gerrit",
"author_id": 5976,
"author_profile": "https://Stackoverflow.com/users/5976",
"pm_score": 0,
"selected": false,
"text": "<p>You're looking for the ultimate security manual? Send me a copy when you find it!</p>\n\n<p>The short checklist: </p>\n\n<... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following code:
```
var emp = new List<Employee>
{
new Employee{ID=1, EmpFname="matt", EmpLName="Cook"},
new Employee{ID=2, EmpFname="mary", EmpLname="John"}
};
```
How do I sort emp by EmpLName and bind it to a GridView? How do I specify asc or desc? | If you are talking about securing the app (as opposed to the server/ environment it is on - which I am not really qualified to address) then I would consider the following:
1. Ensure any user inputs are parsed/cleaned to ensure they can't do things such as [SQL injection attacks](http://www.unixwiz.net/techtips/sql-in... |
446,483 | <p>This was mentioned in my other question and I thought it might be useful to add it to the record. In the following program, which, if any, of the locally defined delegates are cached between calls to the Work method instead of being created from scratch each time?</p>
<pre><code>namespace Example
{
class Dummy
... | [
{
"answer_id": 446499,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Based on what Reflector shows, the last two (<code>a4</code> and <code>dummyAgeMatch</code>) are cached by the MS C#3.... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | This was mentioned in my other question and I thought it might be useful to add it to the record. In the following program, which, if any, of the locally defined delegates are cached between calls to the Work method instead of being created from scratch each time?
```
namespace Example
{
class Dummy
{
... | Based on what Reflector shows, the last two (`a4` and `dummyAgeMatch`) are cached by the MS C#3.0 compiler (in fields called "CS$<>9\_CachedAnonymousMethodDelegate5" and "CS$<>9\_CachedAnonymousMethodDelegate6" in my particular build).
These ones *can* be cached, whereas obviously the others depend on captured variabl... |
446,498 | <p>I'm using standard Delphi constants DayMonday, etc and I want to convert them to localized strings (eg "Lundi"). Is there a simple RTL or VCL call for this?</p>
| [
{
"answer_id": 446535,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 4,
"selected": true,
"text": "<p>You can get different locale settings by: </p>\n\n<pre><code>var\n fs : TFormatSettings;\n x : string;\nbegin\n ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | I'm using standard Delphi constants DayMonday, etc and I want to convert them to localized strings (eg "Lundi"). Is there a simple RTL or VCL call for this? | You can get different locale settings by:
```
var
fs : TFormatSettings;
x : string;
begin
GetLocaleFormatSettings(GetThreadlocale, fs);
x:= FormatDateTime('%mmmm', Now, fs);
// etc..
end;
```
GetThreadLocale gives the current LCID but you can use another number yourself.
TFormatSettings record:
```
TFo... |
446,502 | <p>Well I'm not a huge framework guy but I've been liking what I've been hearing about the whole MVC movement so I thought I'd try to create a simple application in my language of choice (PHP)</p>
<p>So I guess the question is: where did I go wrong? I know there is a lot of debate as to how fat the controller/model s... | [
{
"answer_id": 446601,
"author": "Michał Niedźwiedzki",
"author_id": 2169,
"author_profile": "https://Stackoverflow.com/users/2169",
"pm_score": 5,
"selected": false,
"text": "<p>First, you are doing pretty well on keeping things separated. It pays back in the future, so don't give up.</... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | Well I'm not a huge framework guy but I've been liking what I've been hearing about the whole MVC movement so I thought I'd try to create a simple application in my language of choice (PHP)
So I guess the question is: where did I go wrong? I know there is a lot of debate as to how fat the controller/model should be so... | First, you are doing pretty well on keeping things separated. It pays back in the future, so don't give up.
The database layout (or even database itself) is irrelevant to the essence of MVC. It happens to be relational database in most cases, however MVC does not require it explicitly (you can use XML storage or some ... |
446,518 | <p>I am using an SVN repository for my web development work. I have a development site set up which holds a checkout of the repository.</p>
<p>I have set up an SVN post-commit hook so that whenever a commit is made to the repository the development site is updated: </p>
<pre><code>cd /home/www/dev_ssl
/usr/bin/svn ... | [
{
"answer_id": 446572,
"author": "Jonathan Lonowski",
"author_id": 15031,
"author_profile": "https://Stackoverflow.com/users/15031",
"pm_score": 5,
"selected": true,
"text": "<p>You might use <strong><code>svnlook dirs-changed</code></strong> and <strong><code>svn up -N</code></strong> t... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55402/"
] | I am using an SVN repository for my web development work. I have a development site set up which holds a checkout of the repository.
I have set up an SVN post-commit hook so that whenever a commit is made to the repository the development site is updated:
```
cd /home/www/dev_ssl
/usr/bin/svn up
```
This works fin... | You might use **`svnlook dirs-changed`** and **`svn up -N`** to update only the contents of each folder changed:
```
cd /home/www/dev_ssl
svnlook dirs-changed [REPOS] -r [REV] | xargs /usr/bin/svn up -N
```
Or, if per-file might be better for you (using `sed` to strip action characters):
```
svnlook changed [REPOS]... |
446,522 | <p>I need to set the properties of a class using reflection.</p>
<p>I have a <code>Dictionary<string,string></code> with property names and string values.</p>
<p>Inside a reflection loop, I need to convert the string value to the appropriate property type while setting the value for each property. Some of these... | [
{
"answer_id": 446550,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Checking for Nullable types is easy, int? is actually <code>System.Nullable<System.Int32></code>.\nSo you just check ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29443/"
] | I need to set the properties of a class using reflection.
I have a `Dictionary<string,string>` with property names and string values.
Inside a reflection loop, I need to convert the string value to the appropriate property type while setting the value for each property. Some of these property types are nullable types... | 1. One way to do this is:
```
type.GetGenericTypeDefinition() == typeof(Nullable<>)
```
2. Just set is as per any other reflection code:
```
propertyInfo.SetValue(yourObject, yourValue);
``` |
446,533 | <p>Some texts on ASP.NET MVC state that "there are no runat server tags", even this MSDN article says this, when, right above that statement there is a code example with a runat server tag in the HEAD element:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/magazine/cc337884.aspx" rel="noreferrer">http://msdn.mi... | [
{
"answer_id": 446549,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>They don't mean that you can't use runat=\"server\", but rather that it not necessary to use server-side controls, g... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | Some texts on ASP.NET MVC state that "there are no runat server tags", even this MSDN article says this, when, right above that statement there is a code example with a runat server tag in the HEAD element:
* <http://msdn.microsoft.com/en-us/magazine/cc337884.aspx>
And on StackOverflow conversations I read
>
> "Th... | If you use a runat="server" tag on ANY element, such as a DIV it will render that code as a separate **method** in the compiled page.
If you're converting 'legacy' code its a good idea to remove all runat tags right up front otherwise you end up in a situation where code like the following gives you an error.
```
<% ... |
446,536 | <p>I am updating the code on a daily basis and commit all changes in each case so there is the new code available on server all the time. </p>
<p>What I would like to simplify is build automation and version control. Currently I build a project and edit it's name version (Project Name vx.x.x) each time the the boss ne... | [
{
"answer_id": 446587,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": "<p>I'm in the process of automating this myself. Still exploring options, but this seems to be simple and reliable:</p>... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I am updating the code on a daily basis and commit all changes in each case so there is the new code available on server all the time.
What I would like to simplify is build automation and version control. Currently I build a project and edit it's name version (Project Name vx.x.x) each time the the boss needs it whi... | First, don't try to use [SVN keyword substitution](http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html) to do this. If you put the $rev$ keyword inside a file and enable keyword substitution with the svn:keywords property, you will not get what you want. You will get the last revision that affec... |
446,539 | <p>In the past, I have not really used namespaces, but in this project I am using SourceSafe which requires a project, which puts everything in namespaces...</p>
<p>In the past, I have just been able to make a public static class in the App_Code folder and access it frorm anywhere in my application, but now I cant see... | [
{
"answer_id": 446555,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 2,
"selected": true,
"text": "<p>Either you include the namespace with a using directive:</p>\n\n<pre><code>using Personnel_Database.App_Code;\n// now you ca... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777/"
] | In the past, I have not really used namespaces, but in this project I am using SourceSafe which requires a project, which puts everything in namespaces...
In the past, I have just been able to make a public static class in the App\_Code folder and access it frorm anywhere in my application, but now I cant seem to do t... | Either you include the namespace with a using directive:
```
using Personnel_Database.App_Code;
// now you can use everything that is inside the Personnel_Database.App_Code namespace
namespace Personnel_Database
{
...
```
Or you use the fully quallified name of the utils class (including its namespace), e.g:
```
... |
446,570 | <p>I have a custom .NET addin for an application and I am trying to create configSections for the addin's config file. The trouble is I am not able to read that section If load the configuration using the OpenMapperExeConfiguration/OpenExeConfiguration.</p>
<p>Here is my config file(MyTest.dll.config)</p>
<pre><code>... | [
{
"answer_id": 446611,
"author": "Romias",
"author_id": 7720,
"author_profile": "https://Stackoverflow.com/users/7720",
"pm_score": -1,
"selected": false,
"text": "<p>The exception itself has the property StackTrace... so you just need return the ToString( ).</p>\n\n<p>But I belive your ... | 2009/01/15 | [
"https://Stackoverflow.com/questions/446570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a custom .NET addin for an application and I am trying to create configSections for the addin's config file. The trouble is I am not able to read that section If load the configuration using the OpenMapperExeConfiguration/OpenExeConfiguration.
Here is my config file(MyTest.dll.config)
```
<configuration>
<co... | Unless I'm very much mistaken, you need to know which thread triggered the exception in order to use the Visual Studio debugger's call stack view, which is obviously the catch-22 situation you're in at the moment.
One thing I would try is to see if you can get the debugger to break when the exception is thrown (using ... |