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
525,515
<p>I'm writing an app in Perl with several modules. I want to write some global constants that will be visible from everywhere, like this:</p> <pre><code>#Constants.pm $h0 = 0; $scale = 20; </code></pre> <p>And then use them without qualifying with <code>main::</code> or <code>Constants::</code> in several modules. H...
[ { "answer_id": 525568, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "https://Stackoverflow.com/users/1084", "pm_score": 3, "selected": true, "text": "<p>You can put this at the top of <code>Constants.pm</code>:</p>\n\n<pre><code>package main;\n</code></pre>\n\n<p>In t...
2009/02/08
[ "https://Stackoverflow.com/questions/525515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7224/" ]
I'm writing an app in Perl with several modules. I want to write some global constants that will be visible from everywhere, like this: ``` #Constants.pm $h0 = 0; $scale = 20; ``` And then use them without qualifying with `main::` or `Constants::` in several modules. However, if I write `use Constants;` in more than...
You can put this at the top of `Constants.pm`: ``` package main; ``` In this case all the variables you define will be in the `main` namespace: ``` $main::x ``` or if you're feeling brave: ``` package; ``` In this case all the variables you define will be in an empty namespace: ``` $::x ``` Note that using ...
525,534
<p>I'm trying to create a migration for a simple table that is just used as an enum. So I want to populate the table immediately with its values. I tried the following:</p> <pre><code>class CreateUserTypes &lt; ActiveRecord::Migration def self.up create_table :user_types do |t| t.column :type, :string ...
[ { "answer_id": 525536, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 1, "selected": false, "text": "<p>Try this</p>\n\n<pre><code>class CreateUserTypes &lt; ActiveRecord::Migration\n\n def self.up\n create_table :...
2009/02/08
[ "https://Stackoverflow.com/questions/525534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58521/" ]
I'm trying to create a migration for a simple table that is just used as an enum. So I want to populate the table immediately with its values. I tried the following: ``` class CreateUserTypes < ActiveRecord::Migration def self.up create_table :user_types do |t| t.column :type, :string t.timestamps ...
This is a combination of two answers already given, but this should work for you: ``` class CreateUserRoles < ActiveRecord::Migration def self.up create_table :user_roles do |t| t.string :role t.timestamps end UserRole.create :role => "System administrator" UserRole.create :role => "Simu...
525,559
<p>The problem is the following:</p> <p>You are given a set of positive integers { a1 , a2 , a3 , ... , an } in which there are no same numbers ( a1 exists only once ,a2 exists only once,...) eg A = {12 , 5 ,7 ,91 }. Question: Are there two disjoint subsets of A , A1 = { b1,b2,...,bm } and A2 = { c1,c2,...,ck} so t...
[ { "answer_id": 525653, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 2, "selected": false, "text": "<p>No problem, here's an <code>O(1)</code> solution.</p>\n\n<pre><code>A1 = {}; \nA2 = {};\nsum(A1) == sum(A2) /* == 0 */\n</c...
2009/02/08
[ "https://Stackoverflow.com/questions/525559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The problem is the following: You are given a set of positive integers { a1 , a2 , a3 , ... , an } in which there are no same numbers ( a1 exists only once ,a2 exists only once,...) eg A = {12 , 5 ,7 ,91 }. Question: Are there two disjoint subsets of A , A1 = { b1,b2,...,bm } and A2 = { c1,c2,...,ck} so that b1+b2+.....
No problem, here's an `O(1)` solution. ``` A1 = {}; A2 = {}; sum(A1) == sum(A2) /* == 0 */ ``` QED. --- Seriously, one optimization you can make (assuming that we're talking about positive numbers) is to only check sub-sets less or equal to `sum(A)/2`. For every element in `A` there are three options which makes...
525,576
<p>Git newbie here. Is there a way to synchronize two repositories, so that the current checked out files will be the latest version of all the changes?</p> <p>What I have is this:</p> <pre><code>Desktop Server ------- ------ Change_X Change_Y </code></pre> <p>And I would like to enter some "magic" ...
[ { "answer_id": 525596, "author": "SilentGhost", "author_id": 12855, "author_profile": "https://Stackoverflow.com/users/12855", "pm_score": 3, "selected": true, "text": "<p>it should be possible to create a post-commit hook that will update server's working copy on change (I did exactly t...
2009/02/08
[ "https://Stackoverflow.com/questions/525576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7581/" ]
Git newbie here. Is there a way to synchronize two repositories, so that the current checked out files will be the latest version of all the changes? What I have is this: ``` Desktop Server ------- ------ Change_X Change_Y ``` And I would like to enter some "magic" command, and then the changes are...
it should be possible to create a post-commit hook that will update server's working copy on change (I did exactly the same with mercurial, so i assume it would be possible with git too). so after you push, working copy will be updated automatically. create post-commit hook that will run `git up` or whatever equivalen...
525,583
<p>at the begining of my application i disable some buttons and according to some conditions these buttons became enabled. my problem is when the user clicks on a button then it does my action its color becomes gray and that when i make it disabled again. for more explanation:</p> <p>button.Enabled = false;</p> <p>i...
[ { "answer_id": 525591, "author": "ggf31416", "author_id": 38561, "author_profile": "https://Stackoverflow.com/users/38561", "pm_score": 0, "selected": false, "text": "<p>Change the color after disabling the button</p>\n" }, { "answer_id": 525594, "author": "krosenvold", "...
2009/02/08
[ "https://Stackoverflow.com/questions/525583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42782/" ]
at the begining of my application i disable some buttons and according to some conditions these buttons became enabled. my problem is when the user clicks on a button then it does my action its color becomes gray and that when i make it disabled again. for more explanation: button.Enabled = false; if(Condition) { bu...
I am not entirely sure I read your problem correctly, but It seems to me like maybe you want something like this: ``` button.Enabled = Condition; // Initial value // user clicked on button button.Enabled= false; ... do button's function ... button.Enabled = Condition ``` This should restore the state of the butto...
525,592
<p>What's the simplest way to do a find and replace for a given input string, say <code>abc</code>, and replace with another string, say <code>XYZ</code> in file <code>/tmp/file.txt</code>?</p> <p>I am writting an app and using IronPython to execute commands through SSH &mdash; but I don't know Unix that well and don'...
[ { "answer_id": 525602, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 7, "selected": false, "text": "<p>File manipulation isn't normally done by Bash, but by programs invoked by Bash, e.g.:</p>\n\n<pre><code>perl -pi -e 's/ab...
2009/02/08
[ "https://Stackoverflow.com/questions/525592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11194/" ]
What's the simplest way to do a find and replace for a given input string, say `abc`, and replace with another string, say `XYZ` in file `/tmp/file.txt`? I am writting an app and using IronPython to execute commands through SSH — but I don't know Unix that well and don't know what to look for. I have heard that Bash,...
The easiest way is to use sed (or perl): ```sh sed -i -e 's/abc/XYZ/g' /tmp/file.txt ``` Which will invoke sed to do an in-place edit due to the `-i` option. This can be called from bash. If you really really want to use just bash, then the following can work: ```sh while IFS='' read -r a; do echo "${a//abc/XY...
525,609
<p>I would like to write applications that use C++ and the Cocoa frameworks because Apple is not making Carbon 64-bit capable. C++ seems to be pretty vanilla in its implementation on Linux and Windows but on Mac OS X it seems like additional Apple specific pieces of code are required (like an Obj-C wrapper). It also se...
[ { "answer_id": 525624, "author": "fhe", "author_id": 4445, "author_profile": "https://Stackoverflow.com/users/4445", "pm_score": 4, "selected": false, "text": "<p>Yes, you can just use C++ (i.e. writing it in *.cpp files) and even mix C++ and Objective-C inside *.mm files (standard Objec...
2009/02/08
[ "https://Stackoverflow.com/questions/525609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40002/" ]
I would like to write applications that use C++ and the Cocoa frameworks because Apple is not making Carbon 64-bit capable. C++ seems to be pretty vanilla in its implementation on Linux and Windows but on Mac OS X it seems like additional Apple specific pieces of code are required (like an Obj-C wrapper). It also seems...
You cannot write a Cocoa application entirely in C++. Cocoa relies heavily on the late binding capabilities of Objective-C for many of its core technologies such as Key-Value Bindings, delegates (Cocoa style), and the target-action pattern. The late binding requirements make it *very* difficult to implement the Cocoa A...
525,615
<p>When you run:</p> <pre><code>rake db:migrate </code></pre> <p>the only files that are being processed are those in db/migrate/ right?</p> <p>Well since relationships such as one-to-one, one-to-many and many-to-many are defined in the in app/models/ , how does Rails enforce such relationships? After I do my migrat...
[ { "answer_id": 525619, "author": "Garry Shutler", "author_id": 6369, "author_profile": "https://Stackoverflow.com/users/6369", "pm_score": 4, "selected": true, "text": "<p>Quite simply it doesn't.</p>\n\n<p>It's due to having to support multiple databases. Some, such as sqlite, don't sup...
2009/02/08
[ "https://Stackoverflow.com/questions/525615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/58521/" ]
When you run: ``` rake db:migrate ``` the only files that are being processed are those in db/migrate/ right? Well since relationships such as one-to-one, one-to-many and many-to-many are defined in the in app/models/ , how does Rails enforce such relationships? After I do my migration and look at the generated dat...
Quite simply it doesn't. It's due to having to support multiple databases. Some, such as sqlite, don't support foreign keys. To add foreign keys you have to execute the raw SQL for them.
525,625
<p>I'm practicing for a competition (that's where <a href="https://stackoverflow.com/questions/502443/prime-numbers">my previous question</a> came from). I got the algorithm sorted out for the question, but I'm having some problems with the actual programming. It's a solo competition, so I really need to get this sorte...
[ { "answer_id": 525641, "author": "abelenky", "author_id": 34824, "author_profile": "https://Stackoverflow.com/users/34824", "pm_score": 1, "selected": false, "text": "<p>2D arrays are not accessed as Array[alpha,beta] in C++.</p>\n\n<p><strong>It is done as Array[alpha][beta].</strong></...
2009/02/08
[ "https://Stackoverflow.com/questions/525625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61393/" ]
I'm practicing for a competition (that's where [my previous question](https://stackoverflow.com/questions/502443/prime-numbers) came from). I got the algorithm sorted out for the question, but I'm having some problems with the actual programming. It's a solo competition, so I really need to get this sorted out before I...
2D arrays are not accessed as Array[alpha,beta] in C++. **It is done as Array[alpha][beta].**
525,635
<p><strong>Can a regular expression match whitespace <em>or</em> the start of a string?</strong></p> <p>I'm trying to replace currency the abbreviation GBP with a £ symbol. I could just match anything starting GBP, but I'd like to be a bit more conservative, and look for certain delimiters around it.</p> <pre><code>&...
[ { "answer_id": 525639, "author": "Motti", "author_id": 3848, "author_profile": "https://Stackoverflow.com/users/3848", "pm_score": 6, "selected": false, "text": "<p><code>\\b</code> is word boundary, which can be a white space, the beginning of a line or a non-alphanumeric symbol (<code>...
2009/02/08
[ "https://Stackoverflow.com/questions/525635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
**Can a regular expression match whitespace *or* the start of a string?** I'm trying to replace currency the abbreviation GBP with a £ symbol. I could just match anything starting GBP, but I'd like to be a bit more conservative, and look for certain delimiters around it. ``` >>> import re >>> text = u'GBP 5 Off when ...
Use the OR "`|`" operator: ``` >>> re.sub(r'(^|\W)GBP([\W\d])', u'\g<1>£\g<2>', text) u'\xa3 5 Off when you spend \xa375.00' ```
525,656
<p>I have a C# client and a java server. I have data object that go on the wire back and forth. Lets call them FooData.cs where everything is just a get and a set (no logic)</p> <pre><code>FooData data = new FooData(); data.Price = 10; data.Quantity = 20; </code></pre> <p>i have other derived fields that i want to ...
[ { "answer_id": 525671, "author": "krosenvold", "author_id": 23691, "author_profile": "https://Stackoverflow.com/users/23691", "pm_score": 1, "selected": false, "text": "<p>The way the question is written, the only real difference I can see is whether you pass the fooData instance in thro...
2009/02/08
[ "https://Stackoverflow.com/questions/525656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4653/" ]
I have a C# client and a java server. I have data object that go on the wire back and forth. Lets call them FooData.cs where everything is just a get and a set (no logic) ``` FooData data = new FooData(); data.Price = 10; data.Quantity = 20; ``` i have other derived fields that i want to use in the application but d...
(edit) What version of C# are you using? With C# 3.0 you could place the "logic" bits (calculations etc) in extension methods in a busines logic assembly, but still see them via the DTO - i.e. (data layer) ``` public class Foo { public int Bar {get;set;} } ``` (business layer) ``` static class FooExt { pub...
525,660
<p>Suppose we have these local variables:</p> <pre><code>int a = 0; int b = 1; int c = 2; int d = 3; </code></pre> <p>As far as I know, these will be allocated on the system stack, like this:</p> <pre><code>| | | 3 | d | 2 | c | 1 | b |_0_| a </code></pre> <p>Does this mean that in order to get the value of a, th...
[ { "answer_id": 525665, "author": "Christoph", "author_id": 48015, "author_profile": "https://Stackoverflow.com/users/48015", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Or am I missing something</p>\n</blockquote>\n\n<p>You're missing that the stack resides in regular m...
2009/02/08
[ "https://Stackoverflow.com/questions/525660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23684/" ]
Suppose we have these local variables: ``` int a = 0; int b = 1; int c = 2; int d = 3; ``` As far as I know, these will be allocated on the system stack, like this: ``` | | | 3 | d | 2 | c | 1 | b |_0_| a ``` Does this mean that in order to get the value of a, the values of d, c and b must first be popped out o...
The local variables on the stack are usually accessed relative to the so-called *frame pointer*, which points at the start of your stack frame. It would also be possible to do this relative to the stack pointer, but since this moves around during evaluation of expressions it is more difficult to keep track of. In prac...
525,677
<p>I've started a new project and have decided to make sure it builds cleanly with the /Wall option enabled. The only problem is not all 3rd party libraries (like boost) compile without warnings, so I've resorted to doing this in a shared header:</p> <pre><code>#pragma warning(push) #pragma warning(disable:4820) #pra...
[ { "answer_id": 525712, "author": "Assaf Lavie", "author_id": 11208, "author_profile": "https://Stackoverflow.com/users/11208", "pm_score": 7, "selected": true, "text": "<p>You can push/pop a low level of warning, like this:</p>\n\n<pre><code>#pragma warning(push, 0) \n\n#include &...
2009/02/08
[ "https://Stackoverflow.com/questions/525677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4086/" ]
I've started a new project and have decided to make sure it builds cleanly with the /Wall option enabled. The only problem is not all 3rd party libraries (like boost) compile without warnings, so I've resorted to doing this in a shared header: ``` #pragma warning(push) #pragma warning(disable:4820) #pragma warning(di...
You can push/pop a low level of warning, like this: ``` #pragma warning(push, 0) #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> // ... #pragma warning(pop) ``` But know that it's not possible to disable *all* warnings. For example, some linker warnings are impossible to turn off.
525,678
<p>I could do with a bit of guidance understanding the world of asp.net &amp; databases.</p> <p>There seems to be so many options I'm not really sure what to look into &amp; what to use in different situations.</p> <p>I've created websites that have used datasets in the past, but I never really understood what was go...
[ { "answer_id": 525731, "author": "E.J. Brennan", "author_id": 53686, "author_profile": "https://Stackoverflow.com/users/53686", "pm_score": 3, "selected": true, "text": "<p>There is tons of information available on the web for the pro's and con's of each method, but in a nutshell, going ...
2009/02/08
[ "https://Stackoverflow.com/questions/525678", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63869/" ]
I could do with a bit of guidance understanding the world of asp.net & databases. There seems to be so many options I'm not really sure what to look into & what to use in different situations. I've created websites that have used datasets in the past, but I never really understood what was going on or why I should or...
There is tons of information available on the web for the pro's and con's of each method, but in a nutshell, going in the following order: ``` sqlreader datasets Linq entity framework ``` You are going from fastest to slowest (in terms of raw performance) and least features and least complexity to most features and ...
525,681
<p>I need advice on this snippet</p> <pre><code>$text = preg_replace('|(A.*)?A(.*)C|', '$1foo$2bar', $text); </code></pre> <p>This will match ABC in "AB ABC D", and replace it with "AB fooBbar D"; as you can see this matches the "AB " part at the beginning as well, which I have to repeat in the replacement string wit...
[ { "answer_id": 525696, "author": "Zach Scrivena", "author_id": 20029, "author_profile": "https://Stackoverflow.com/users/20029", "pm_score": 1, "selected": false, "text": "<p>How about this:</p>\n\n<pre><code>$text = preg_replace('|A(\\S*)C|', 'foo$1bar', $text);\n</code></pre>\n\n<p>The...
2009/02/08
[ "https://Stackoverflow.com/questions/525681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7849/" ]
I need advice on this snippet ``` $text = preg_replace('|(A.*)?A(.*)C|', '$1foo$2bar', $text); ``` This will match ABC in "AB ABC D", and replace it with "AB fooBbar D"; as you can see this matches the "AB " part at the beginning as well, which I have to repeat in the replacement string with $1, in order not to lose...
As the question has been clarified, try this expression: ``` preg_replace('/(?:A)+(.+?)(?:C)+/', 'foo$1bar', $text) ``` An example: ``` $A = 'abc'; $B = '123'; $C = 'xyz'; $text = "$A$B$C $A$A$B$C $A$B$C$C"; echo preg_replace("/(?:$A)+(.+?)(?:$C)+/", 'foo$1bar', $text); ```
525,702
<p>Say I have table with two columns: Name, Age.</p> <p>I want to design a query that will return the names and ages sorted by age, but to also have an additional column which will run from 1 to N (the last row).</p> <p>So for a table with the following rows:</p> <pre><code>John, 28 Jim, 30 Mike, 28 </code></pre> <...
[ { "answer_id": 525707, "author": "E.J. Brennan", "author_id": 53686, "author_profile": "https://Stackoverflow.com/users/53686", "pm_score": 2, "selected": false, "text": "<p>Don't know about MySQL, but in SQL Server you do it this way:</p>\n\n<pre><code>SELECT Name, Age, ROW_NUMBER() OVE...
2009/02/08
[ "https://Stackoverflow.com/questions/525702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11208/" ]
Say I have table with two columns: Name, Age. I want to design a query that will return the names and ages sorted by age, but to also have an additional column which will run from 1 to N (the last row). So for a table with the following rows: ``` John, 28 Jim, 30 Mike, 28 ``` The following rows will be returned `...
In mysql you can: ``` SELECT Row,Name,Age FROM (SELECT @row := @row + 1 AS Row, Name,Age FROM table1 ) As derived1 ``` However , this next approach is generic (but you need to have unique values in one of the columns of the table , in this example I've used name but it could be any unique column) ``` select ran...
525,718
<p>I need to save a page from url - This page is in my own application - in html format. This html will then be send by email to a user. Any anyone knows how?</p>
[ { "answer_id": 525747, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 6, "selected": true, "text": "<p>Well, you'll have to do it at the server to be able to e-mail - so at worst, simply:</p>\n\n<pre><code>using(WebCli...
2009/02/08
[ "https://Stackoverflow.com/questions/525718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1154/" ]
I need to save a page from url - This page is in my own application - in html format. This html will then be send by email to a user. Any anyone knows how?
Well, you'll have to do it at the server to be able to e-mail - so at worst, simply: ``` using(WebClient client = new WebClient()) { string html = client.DownloadString(address); } ``` It might also be possible to do it *directly* within MVC - perhaps `RenderPartial`?
525,737
<p>I'm trying to create an iPhone application that is always in landscape mode, using the Utility application template. Here's what I did:</p> <ul> <li>Create a new iPhone application project, using the Utility Application template</li> <li>In Interface Builder, rotate all the views 90 degrees.</li> <li>In Interface ...
[ { "answer_id": 526063, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I was going to say that setting this key does not rotate your interface; you still need to lay out your content in landscap...
2009/02/08
[ "https://Stackoverflow.com/questions/525737", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175/" ]
I'm trying to create an iPhone application that is always in landscape mode, using the Utility application template. Here's what I did: * Create a new iPhone application project, using the Utility Application template * In Interface Builder, rotate all the views 90 degrees. * In Interface Builder, add a label to the m...
I was going to say that setting this key does not rotate your interface; you still need to lay out your content in landscape mode and do the appropriate rotation using CFAffineTransform - see "Launching in Landscape Mode" in iPhone OS Programming Guide. Going to find the reference for you, I found this comment: "To lau...
525,773
<p>How can I accept cookies in a python script?</p>
[ { "answer_id": 525781, "author": "Can Berk Güder", "author_id": 2119, "author_profile": "https://Stackoverflow.com/users/2119", "pm_score": 2, "selected": false, "text": "<p>You might want to look at <a href=\"http://docs.python.org/library/cookielib.html\" rel=\"nofollow noreferrer\">co...
2009/02/08
[ "https://Stackoverflow.com/questions/525773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I accept cookies in a python script?
Try this: ``` import urllib2 import cookielib jar = cookielib.FileCookieJar("cookies") opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) print "Currently have %d cookies" % len(jar) print "Getting page" response = opener.open("http://google.com") print response.headers print "Got page" print "Currentl...
525,797
<p>How to override or extend .net main classes. for example</p> <pre><code>public class String { public boolean contains(string str,boolean IgnoreCase){...} public string replace(string str,string str2,boolean IgnoreCase){...} } </code></pre> <p>after</p> <pre><code>string aa="this is a Sample"; if(aa.contai...
[ { "answer_id": 525806, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 2, "selected": false, "text": "<p>The String class is sealed, so you cannot extend it. If you want to add features you can either use extension m...
2009/02/08
[ "https://Stackoverflow.com/questions/525797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60200/" ]
How to override or extend .net main classes. for example ``` public class String { public boolean contains(string str,boolean IgnoreCase){...} public string replace(string str,string str2,boolean IgnoreCase){...} } ``` after ``` string aa="this is a Sample"; if(aa.contains("sample",false)) {...} ``` is it...
The String class is sealed so you can't inherit from it. Extension methods are your best bet. They have the same **feel** as instance methods without the cost of inheritance. ``` public static class Extensions { public static bool contains(this string source, bool ignoreCase) {... } } void Example { string str =...
525,803
<p>This is a C++ disaster, check out this code sample:</p> <pre><code>#include &lt;iostream&gt; void func(const int* shouldnotChange) { int* canChange = (int*) shouldnotChange; *canChange += 2; return; } int main() { int i = 5; func(&amp;i); std::cout &lt;&lt; i; return 0; } </code></pre...
[ { "answer_id": 525812, "author": "jalf", "author_id": 33213, "author_profile": "https://Stackoverflow.com/users/33213", "pm_score": 4, "selected": false, "text": "<p>By writing sane code. \nIf you write code you can't trust, then obviously your code won't be trustworthy.\nSimilar stupid ...
2009/02/08
[ "https://Stackoverflow.com/questions/525803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49217/" ]
This is a C++ disaster, check out this code sample: ``` #include <iostream> void func(const int* shouldnotChange) { int* canChange = (int*) shouldnotChange; *canChange += 2; return; } int main() { int i = 5; func(&i); std::cout << i; return 0; } ``` The output was 7! So, how can we mak...
Based on your edit, your question is "how can I trust 3rd party code not to be stupid?" The short answer is "you can't." If you don't have access to the source, or don't have time to inspect it, you can only trust the author to have written sane code. In your example, the author of the function declaration specificall...
525,815
<p>In common lisp I've noticed that I can write this: </p> <pre><code>(defun foo (&amp;key (a 1) (b 2) (c (+ a b))) (print (+ a b c))) </code></pre> <p>And when I call <code>(foo)</code>, <code>6</code> is printed. So the argument <code>c</code> can refer to values set for <code>a</code> and <code>b</code>. But I ca...
[ { "answer_id": 525822, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 2, "selected": false, "text": "<p>Not that way. But using Lisp reader tricks you can do:</p>\n\n<pre><code>(make-thing :a #1=1 :b #2=2 :c (+ #1# #2#))\...
2009/02/08
[ "https://Stackoverflow.com/questions/525815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3486/" ]
In common lisp I've noticed that I can write this: ``` (defun foo (&key (a 1) (b 2) (c (+ a b))) (print (+ a b c))) ``` And when I call `(foo)`, `6` is printed. So the argument `c` can refer to values set for `a` and `b`. But I can't seem to find a way to do something similar with `defstruct`. Something like: ``` ...
You can do this using `:constructor` option of `defstruct`. ``` CL-USER> (defstruct (thing (:constructor make-thing (&key a b (c (+ a b))))) a b c) THING CL-USER> (make-thing :a 1 :b 2) #S(THING :A 1 :B 2 :C 3) ``` For more info, see CLHS entry for [`defstruct`](http://www.lispworks....
525,816
<p>The following code shows what I expect in Firefox and Chrome: a small white square in a big green rectangle. I don't see the small square in IE7. How can I make it appear?</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;hea...
[ { "answer_id": 525834, "author": "Tom", "author_id": 20, "author_profile": "https://Stackoverflow.com/users/20", "pm_score": 3, "selected": true, "text": "<p>This should do what you want, and should work across the major browsers:</p>\n\n<pre><code>function start()\n{\n var g_Div = do...
2009/02/08
[ "https://Stackoverflow.com/questions/525816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21132/" ]
The following code shows what I expect in Firefox and Chrome: a small white square in a big green rectangle. I don't see the small square in IE7. How can I make it appear? ``` <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-...
This should do what you want, and should work across the major browsers: ``` function start() { var g_Div = document.getElementById("bigdiv"); var littleDiv = document.createElement('div'); littleDiv.style.background = 'rgb(255, 255, 255)'; littleDiv.style.width = '5px'; littleDiv.style.height = '5...
525,829
<p>I have a WinForms .NET app that, according to the Vista Task Manager with UAC enabled, runs with virtualization "Disabled" even though I do not recall adding a manifest with "asInvoker" to the app. VS.NET (this project has gone through all four versions of VS.NET) must have added the <strong>\Properties\app.manifest...
[ { "answer_id": 526028, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 3, "selected": true, "text": "<p>Maybe it is a win32 resource and therefore can't be seen by Reflector? You could see win32 resources with a win32 re...
2009/02/08
[ "https://Stackoverflow.com/questions/525829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/470/" ]
I have a WinForms .NET app that, according to the Vista Task Manager with UAC enabled, runs with virtualization "Disabled" even though I do not recall adding a manifest with "asInvoker" to the app. VS.NET (this project has gone through all four versions of VS.NET) must have added the **\Properties\app.manifest** file I...
Maybe it is a win32 resource and therefore can't be seen by Reflector? You could see win32 resources with a win32 resource editor like [this one](http://www.wilsonc.demon.co.uk/d10resourceeditor.htm).
525,832
<p>How can I detect that my .NET application has crashed, and then restart it?</p>
[ { "answer_id": 525835, "author": "Hosam Aly", "author_id": 41283, "author_profile": "https://Stackoverflow.com/users/41283", "pm_score": 1, "selected": false, "text": "<p>A possible solution is to create another process to monitor your application, and restart it if it is terminated:</p>...
2009/02/08
[ "https://Stackoverflow.com/questions/525832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41283/" ]
How can I detect that my .NET application has crashed, and then restart it?
Another solution (based on [this example](http://community.bartdesmet.net/blogs/bart/archive/2006/08/30/4366.aspx)) is to create a launcher that controls the application: ``` class LauncherProgram { static int count = 3; static void Main() { Launch(); Thread.Sleep(Timeout.Infinite); } ...
525,870
<p>Hi I am in the process of writing my first .net gui. I am wondering if there is some specific way I need to apply to my poco objects for them to be bindable to a usercontrol. I have a few objects but I seem to be unable to bind them to my usercontrol. </p> <p>I read somewhere that they need to implement IBindable b...
[ { "answer_id": 525878, "author": "David Schmitt", "author_id": 4918, "author_profile": "https://Stackoverflow.com/users/4918", "pm_score": 0, "selected": false, "text": "<p>With WPF you'll need <a href=\"http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged...
2009/02/08
[ "https://Stackoverflow.com/questions/525870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Hi I am in the process of writing my first .net gui. I am wondering if there is some specific way I need to apply to my poco objects for them to be bindable to a usercontrol. I have a few objects but I seem to be unable to bind them to my usercontrol. I read somewhere that they need to implement IBindable but I can't...
Which architecture? For 1-way binding, you don't need anything other than public properties - and maybe some `TypeConverter` implementations for any bespoke data types (`struct`s etc) For full 2-way binding, you'll need an eventing implementation - any of: * a "public event EventHandler FooChanged" for every propert...
525,872
<p>How do I echo one or more tab characters using a bash script? When I run this code</p> <pre><code>res=' 'x # res = "\t\tx" echo '['$res']' # expect [\t\tx] </code></pre> <p>I get this</p> <pre><code>res=[ x] # that is [&lt;space&gt;x] </code></pre>
[ { "answer_id": 525873, "author": "Johannes Weiss", "author_id": 55925, "author_profile": "https://Stackoverflow.com/users/55925", "pm_score": 10, "selected": true, "text": "<pre><code>echo -e ' \\t '\n</code></pre>\n\n<p>will echo 'space tab space newline' (<code>-e</code> means 'enable ...
2009/02/08
[ "https://Stackoverflow.com/questions/525872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52141/" ]
How do I echo one or more tab characters using a bash script? When I run this code ``` res=' 'x # res = "\t\tx" echo '['$res']' # expect [\t\tx] ``` I get this ``` res=[ x] # that is [<space>x] ```
``` echo -e ' \t ' ``` will echo 'space tab space newline' (`-e` means 'enable interpretation of backslash escapes'): ``` $ echo -e ' \t ' | hexdump -C 00000000 20 09 20 0a | . .| ```
525,882
<p>In normal condition, I can add schemas in the dbml file to empty database with code below.</p> <p>But now when I run this code, I take the error "Cannot drop database "test" because it is currently in use." How can I do it?</p> <pre><code>Dim db As New UI_Class.UIData If db.DatabaseExists Then ...
[ { "answer_id": 525944, "author": "simplyharsh", "author_id": 63841, "author_profile": "https://Stackoverflow.com/users/63841", "pm_score": 1, "selected": false, "text": "<p>It might happen as your SQL Server Management Studio (SSMS) must be holding it.</p>\n" }, { "answer_id": 41...
2009/02/08
[ "https://Stackoverflow.com/questions/525882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
In normal condition, I can add schemas in the dbml file to empty database with code below. But now when I run this code, I take the error "Cannot drop database "test" because it is currently in use." How can I do it? ``` Dim db As New UI_Class.UIData If db.DatabaseExists Then db.DeleteDatabase() ...
It might happen as your SQL Server Management Studio (SSMS) must be holding it.
525,894
<p>I have an ASP.Net MVC application that allows users to upload images. When I try to upload a really large file (400MB) I get an error.</p> <p>I assumed that my image processing code (home brew) was very inefficient, so I decided I would try using a third party library to handle the image processing parts.</p> <p>B...
[ { "answer_id": 525921, "author": "Assaf Lavie", "author_id": 11208, "author_profile": "https://Stackoverflow.com/users/11208", "pm_score": 0, "selected": false, "text": "<p>Where exactly does the exception originate from?</p>\n\n<p>AFAIK there's no 400MB-caliber limit to image sizes in A...
2009/02/08
[ "https://Stackoverflow.com/questions/525894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18107/" ]
I have an ASP.Net MVC application that allows users to upload images. When I try to upload a really large file (400MB) I get an error. I assumed that my image processing code (home brew) was very inefficient, so I decided I would try using a third party library to handle the image processing parts. Because I'm using ...
There can be memory limits configured in either the web.config or machine.config, or both. In web.config the section is: ``` <httpRuntime executionTimeout="3600" maxRequestLength="102400" /> ``` In machine.config the section can also be the httpRunTime section, similar to: ``` <httpRuntime executionTimeout="90"...
525,896
<p>QT4 designer doesnot accept '&amp;' reference and ' ' space character in signal/slot editor? As XML schema also doesn't support it ... is there any way to create a custom slot like onClickMyCustorSlot(const QStringList &amp;) using QT4 designer or editing th ui-xml</p> <p>-Himadri Sekhar</p>
[ { "answer_id": 592819, "author": "David Boddie", "author_id": 61047, "author_profile": "https://Stackoverflow.com/users/61047", "pm_score": 0, "selected": false, "text": "<p>Although many of the standard Qt classes have signals that use notation containing \"const\" and \"&amp;\", normal...
2009/02/08
[ "https://Stackoverflow.com/questions/525896", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
QT4 designer doesnot accept '&' reference and ' ' space character in signal/slot editor? As XML schema also doesn't support it ... is there any way to create a custom slot like onClickMyCustorSlot(const QStringList &) using QT4 designer or editing th ui-xml -Himadri Sekhar
Signals are generally stripped of all `&` and `const`. If you connect them in the code you have to use them the same way, in your example like this: ``` SIGNAL("onClickMyCustomSlot(QStringList)") ``` Pointers (\*), on the other hand, should stay in the signal name.
525,902
<p>I have a web report needs to return multiple products from different regions. The simplified query will be like:</p> <pre><code>Select ProductName, ProductPrice from Product where Region in (Region1, Region2, Region 3) </code></pre> <p>The regions are selected by users from UI. The result is bound to a datagrid....
[ { "answer_id": 525927, "author": "Matthew Doyle", "author_id": 53904, "author_profile": "https://Stackoverflow.com/users/53904", "pm_score": 0, "selected": false, "text": "<p>I think we may need a little more information about the queries and the loop you are using, but can you use AJAX?...
2009/02/08
[ "https://Stackoverflow.com/questions/525902", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
I have a web report needs to return multiple products from different regions. The simplified query will be like: ``` Select ProductName, ProductPrice from Product where Region in (Region1, Region2, Region 3) ``` The regions are selected by users from UI. The result is bound to a datagrid. It could be multiple regi...
Are you using SQL Server? If so, you can use the [`PIVOT` operator](http://msdn.microsoft.com/en-us/library/ms177410.aspx) to pivot on the region.
525,903
<p>This should be a fairly trivial problem. I'm trying to open an ofstream using a std::string (or std::wstring) and having problems getting this to work without a messy conversion.</p> <pre><code>std::string path = ".../file.txt"; ofstream output; output.open(path); </code></pre> <p>Ideally I don't want to have to...
[ { "answer_id": 525904, "author": "Frederick The Fool", "author_id": 32688, "author_profile": "https://Stackoverflow.com/users/32688", "pm_score": 4, "selected": true, "text": "<p>In the path string, use two dots instead of three.</p>\n\n<p>Also you may use 'c_str()' method on string to g...
2009/02/08
[ "https://Stackoverflow.com/questions/525903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18909/" ]
This should be a fairly trivial problem. I'm trying to open an ofstream using a std::string (or std::wstring) and having problems getting this to work without a messy conversion. ``` std::string path = ".../file.txt"; ofstream output; output.open(path); ``` Ideally I don't want to have to convert this by hand or i...
In the path string, use two dots instead of three. Also you may use 'c\_str()' method on string to get the underlying C string. ``` output.open(path.c_str()); ```
525,907
<p>How can I change the url of my images from this:</p> <p><a href="http://www.myOLDwebsite.com/" rel="nofollow noreferrer">http://www.myOLDwebsite.com/</a>**********.*** (i have gifs, jpgs, pngs)</p> <p>to this:</p> <p><a href="http://www.myNEWwebiste.com/somedirectory/" rel="nofollow noreferrer">http://www.myNEWwe...
[ { "answer_id": 525913, "author": "Charles Duffy", "author_id": 14122, "author_profile": "https://Stackoverflow.com/users/14122", "pm_score": 2, "selected": false, "text": "<p>Well, the easiest way is probably to use sed in in-place mode:</p>\n\n<pre><code>sed -ir \\\n 's@http://www[.]myO...
2009/02/08
[ "https://Stackoverflow.com/questions/525907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I change the url of my images from this: <http://www.myOLDwebsite.com/>\*\*\*\*\*\*\*\*\*\*.\*\*\* (i have gifs, jpgs, pngs) to this: <http://www.myNEWwebiste.com/somedirectory/>\*\*\*\*\*\*\*\*\*\*.\*\*\* Using REGexp text editor? Really thanks for your time []'s Mateus
Well, the easiest way is probably to use sed in in-place mode: ``` sed -ir \ 's@http://www[.]myOLDwebsite[.]com/@http://www.myNEWwebsite.com/subdirectory/@g' \ file1 file2 ... ``` If for some reason you need to actually interpret the HTML (rather than just do a simple string replacement), a quick script built arou...
525,926
<p>In Windows when you create a window, you must define a (c++)</p> <pre><code>LRESULT CALLBACK message_proc(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam); </code></pre> <p>to handle all the messages sent from the OS to the window, like keypresses and such.</p> <p>Im looking to do some reading on how the ...
[ { "answer_id": 525932, "author": "Mark Ingram", "author_id": 986, "author_profile": "https://Stackoverflow.com/users/986", "pm_score": 2, "selected": false, "text": "<p>It's totally and utterly different. That window procedure is 100% specific to the Windows OS. For linux, it will depend...
2009/02/08
[ "https://Stackoverflow.com/questions/525926", "https://Stackoverflow.com", "https://Stackoverflow.com/users/56763/" ]
In Windows when you create a window, you must define a (c++) ``` LRESULT CALLBACK message_proc(HWND Handle, UINT Message, WPARAM WParam, LPARAM LParam); ``` to handle all the messages sent from the OS to the window, like keypresses and such. Im looking to do some reading on how the same system works in Linux. Maybe...
In principle it is absolutely the same. However, it has nothing to do with communication with the OS (nor does it on win32, using user32.dll is entirely optional) A GUI application has an event loop somewhere, which processes messages from a queue at some level. There are a lot of libraries typically used to "hide" t...
525,953
<p>I am to build a SOA gui framework, and I'd like to autodetect services, and service dependencies from client modules. I have code such as this so far, which works using attributes, placed on class modules:</p> <pre><code>[ServiceProvider(typeof(DemoService3))] [ServiceConsumer(typeof(DemoService1))] </code></pre> ...
[ { "answer_id": 525985, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "<p>You will need to analyze the IL at the CLR level, not the C# level to figure this out.</p>\n\n<p>You should be able to le...
2009/02/08
[ "https://Stackoverflow.com/questions/525953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31387/" ]
I am to build a SOA gui framework, and I'd like to autodetect services, and service dependencies from client modules. I have code such as this so far, which works using attributes, placed on class modules: ``` [ServiceProvider(typeof(DemoService3))] [ServiceConsumer(typeof(DemoService1))] ``` I am wondering how I ca...
You will need to analyze the IL at the CLR level, not the C# level to figure this out. You should be able to leverage [Mono Cecil](http://www.mono-project.com/Cecil:FAQ) to pull this off.
525,957
<p>Does anyone use tuples in Ruby? If so, how may one implement a tuple? Ruby hashes are nice and work almost as well, but I'd really like to see something like the Tuple class in Python, where you can use <code>.</code> notation to find the value for which you are looking. I'm wanting this so that I can create an impl...
[ { "answer_id": 525981, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 7, "selected": true, "text": "<p><a href=\"http://www.ruby-doc.org/stdlib/libdoc/ostruct/rdoc/classes/OpenStruct.html\" rel=\"noreferrer\">OpenStruct</a>?</p...
2009/02/08
[ "https://Stackoverflow.com/questions/525957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone use tuples in Ruby? If so, how may one implement a tuple? Ruby hashes are nice and work almost as well, but I'd really like to see something like the Tuple class in Python, where you can use `.` notation to find the value for which you are looking. I'm wanting this so that I can create an implementation of ...
[OpenStruct](http://www.ruby-doc.org/stdlib/libdoc/ostruct/rdoc/classes/OpenStruct.html)? Brief example: ``` require 'ostruct' person = OpenStruct.new person.name = "John Smith" person.age = 70 person.pension = 300 puts person.name # -> "John Smith" puts person.age # -> 70 puts person.address # -> ...
525,961
<p>Is there an elegant way to align 3 elements left, center, and right on the same line?</p> <p>Right now I'm using 3 <code>&lt;div&gt;</code>'s all with width:33%;float:left; and it's not working too well.</p>
[ { "answer_id": 525969, "author": "Chris Ballance", "author_id": 1551, "author_profile": "https://Stackoverflow.com/users/1551", "pm_score": 0, "selected": false, "text": "<p>Float the first two left and float the third one right, while ensuring the widths will fit the line you are placin...
2009/02/08
[ "https://Stackoverflow.com/questions/525961", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there an elegant way to align 3 elements left, center, and right on the same line? Right now I'm using 3 `<div>`'s all with width:33%;float:left; and it's not working too well.
that works for me: ``` <html> <head> <style> div.fl { float: left; width: 33%; } div.fr { float: right; width: 33%; } </style> </head> <body> <div class="fl"> A </div> <div class="fl"> B </div> <div class="fr"> ...
525,978
<p>I am having problems getring a simple redirect statement to take effect on my Godaddy account. I have the following statements in my .htaccess file:</p> <pre><code>RewriteEngine On RewriteCond %{HTTP_HOST} ^www.mydomain.net$ [NC] RewriteRule ^(.*)$ http://mydomain.net/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^mydoma...
[ { "answer_id": 525984, "author": "Chris Ballance", "author_id": 1551, "author_profile": "https://Stackoverflow.com/users/1551", "pm_score": -1, "selected": false, "text": "<p>Put the first one last. Once it encounters a redirect match, it runs it and ignores the rest.</p>\n" }, { ...
2009/02/08
[ "https://Stackoverflow.com/questions/525978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am having problems getring a simple redirect statement to take effect on my Godaddy account. I have the following statements in my .htaccess file: ``` RewriteEngine On RewriteCond %{HTTP_HOST} ^www.mydomain.net$ [NC] RewriteRule ^(.*)$ http://mydomain.net/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^mydomain.net$ [NC] R...
> > **Per-directory Rewrites** > > When using the rewrite engine in `.htaccess` files the per-directory prefix (which always is the same for a specific directory) is automatically *removed* for the pattern matching and automatically *added* after the substitution has been done. > > – <http://httpd.apache.org/d...
525,986
<p>Since I have decided to let RC go while staying with Beta for now, I have no way of knowing whether a strongly typed <code>RedirectToAction</code> has been added. Has anybody tried it and is there a strongly typed <code>RedirectToAction</code> (and maybe <code>ActionLink</code>) in RC?</p>
[ { "answer_id": 525993, "author": "Chad Moran", "author_id": 25416, "author_profile": "https://Stackoverflow.com/users/25416", "pm_score": 5, "selected": true, "text": "<p>No, it doesn't.</p>\n\n<pre><code>protected RedirectToRouteResult RedirectToAction&lt;T&gt;(Expression&lt;Action&lt;T...
2009/02/08
[ "https://Stackoverflow.com/questions/525986", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62830/" ]
Since I have decided to let RC go while staying with Beta for now, I have no way of knowing whether a strongly typed `RedirectToAction` has been added. Has anybody tried it and is there a strongly typed `RedirectToAction` (and maybe `ActionLink`) in RC?
No, it doesn't. ``` protected RedirectToRouteResult RedirectToAction<T>(Expression<Action<T>> action, RouteValueDictionary values) where T : Controller { var body = action.Body as MethodCallExpression; if (body == null) { throw new ArgumentException("Expression must be a method call."); } ...
525,990
<p>What is the best way of adding a new object in the entity framework. The designer adds all these create methods, but to me it makes more sense to call new on an object. The generated CreateCustomer method e.g. could be called like this:</p> <pre><code>Customer c = context.CreateCustomer(System.Guid.NewGuid(), "Name...
[ { "answer_id": 526605, "author": "Andrew Peters", "author_id": 608, "author_profile": "https://Stackoverflow.com/users/608", "pm_score": 2, "selected": false, "text": "<p>You can absolutely use the second, more natural way. I'm not even sure of why the first way exists at all.</p>\n" }...
2009/02/08
[ "https://Stackoverflow.com/questions/525990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59086/" ]
What is the best way of adding a new object in the entity framework. The designer adds all these create methods, but to me it makes more sense to call new on an object. The generated CreateCustomer method e.g. could be called like this: ``` Customer c = context.CreateCustomer(System.Guid.NewGuid(), "Name")); context.A...
As Andrew says (up-voted), it's quite acceptable to use regular constructors. As for why the "Create" methods exist, I *believe* the intention is to make explicit which properties are required. If you use such methods, you can be assured that you have not forgotten to set any property which will throw an exception when...
525,992
<p>I am opening my blog page in my website. The problem is I can give a width to an iframe but the height should be dynamic so that there is no scrollbar in the iframe, and it looks like a single page...</p> <p>I have tried various JavaScript code to calculate the height of the content but all of them give an <em>acce...
[ { "answer_id": 526010, "author": "Gary Green", "author_id": 63523, "author_profile": "https://Stackoverflow.com/users/63523", "pm_score": -1, "selected": false, "text": "<p>Try using <code>scrolling=no</code> attribute on the iframe tag. Mozilla also has an <code>overflow-x</code> and <c...
2009/02/08
[ "https://Stackoverflow.com/questions/525992", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63700/" ]
I am opening my blog page in my website. The problem is I can give a width to an iframe but the height should be dynamic so that there is no scrollbar in the iframe, and it looks like a single page... I have tried various JavaScript code to calculate the height of the content but all of them give an *access denied per...
To directly answer your two subquestions: No, you cannot do this with Ajax, nor can you calculate it with PHP. What I have done in the past is use a trigger from the iframe'd page in `window.onload` (NOT `domready`, as it can take a while for images to load) to pass the page's body height to the parent. ``` <body onl...
526,030
<p>I am doing some socket programming in C, and trying to wrestle with byte order problems. My request (send) is fine but when I receive data my bytes are all out of order. I start with something like this:</p> <pre><code>char * aResponse= (char *)malloc(512); int total = recv(sock, aResponse, 511, 0); </code></pre> <p...
[ { "answer_id": 526036, "author": "CiNN", "author_id": 2566, "author_profile": "https://Stackoverflow.com/users/2566", "pm_score": 0, "selected": false, "text": "<p>the network byte order is big endian, so you need to convert it to little endian if you want it to make sense, but if it is ...
2009/02/08
[ "https://Stackoverflow.com/questions/526030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40825/" ]
I am doing some socket programming in C, and trying to wrestle with byte order problems. My request (send) is fine but when I receive data my bytes are all out of order. I start with something like this: ``` char * aResponse= (char *)malloc(512); int total = recv(sock, aResponse, 511, 0); ``` When dealing with this ...
Ok, there seems to be problems with what you are doing on two different levels. Part of the confusion here seems to stem for your use of pointers, what type of objects they point to, and then the interpretation of the encoding of the values in the memory pointed to by the pointer(s). The encoding of multi-byte entitie...
526,035
<p>Given the following HTML:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt; &lt;!-- Other elements here --&gt; &lt;div id="copyright"&gt;...
[ { "answer_id": 526039, "author": "Jack Sleight", "author_id": 39428, "author_profile": "https://Stackoverflow.com/users/39428", "pm_score": 2, "selected": false, "text": "<p>If you want it to \"stick\" to the bottom, regardless of the height of container, then absolute positioning is the...
2009/02/08
[ "https://Stackoverflow.com/questions/526035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
Given the following HTML: ```html <div id="container"> <!-- Other elements here --> <div id="copyright"> Copyright Foo web designs </div> </div> ``` I would like `#copyright` to stick to the bottom of `#container`. Can I achieve this without using absolute positioning?
The flexbox approach! --------------------- In [supported browsers](http://caniuse.com/#feat=flexbox), you can use the following: [**Example Here**](http://jsfiddle.net/bv1rs8s1/) ```css .parent { display: flex; flex-direction: column; } .child { margin-top: auto; } ``` ```css .parent { height: 100px; ...
526,037
<p>I'm trying to figure out how to open the system preferred editor for a given file.</p> <p>Say, we have a file manager, written in Java. User goes to folder and sees the list of files. And, for example, there is a file <code>Icon.jpg</code>. User double clicks on the filename and file opens in system's preferred edi...
[ { "answer_id": 526069, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 2, "selected": false, "text": "<p>This isn't cross-platform, but on Mac OS X you can do</p>\n\n<pre><code>Runtime.getRuntime().exec(\"open filename...
2009/02/08
[ "https://Stackoverflow.com/questions/526037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63912/" ]
I'm trying to figure out how to open the system preferred editor for a given file. Say, we have a file manager, written in Java. User goes to folder and sees the list of files. And, for example, there is a file `Icon.jpg`. User double clicks on the filename and file opens in system's preferred editor (i.e. Gimp). The ...
Seems that if you can't use `java.awt.Desktop` you have to distinguish between the OSes: Windows: ``` RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL <file.ext> ``` Linux: ``` edit <file.ext> ``` Mac: ``` open <file.ext> ``` HTH. Obviously, that is not very portable...
526,070
<p>Today, I noticed that when I cast a double that is greater than the maximum possible integer to an integer, I get -2147483648. Similarly, when I cast a double that is less than the minimum possible integer, I also get -2147483648. </p> <p>Is this behavior defined for all platforms?<br> What is the best way to de...
[ { "answer_id": 526086, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 0, "selected": false, "text": "<p>I am not sure about this but I think it may be possible to \"turn on\" floating point exceptions for under/overfl...
2009/02/08
[ "https://Stackoverflow.com/questions/526070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Today, I noticed that when I cast a double that is greater than the maximum possible integer to an integer, I get -2147483648. Similarly, when I cast a double that is less than the minimum possible integer, I also get -2147483648. Is this behavior defined for all platforms? What is the best way to detect this unde...
When casting floats to integers, overflow causes undefined behavior. From the C99 spec, section *6.3.1.4 Real floating and integer*: > > When a finite value of real floating type is converted to an integer type other than `_Bool`, the fractional part is discarded (i.e., the value is truncated toward zero). If the val...
526,074
<p>I have created a activity that is only meant to be launched from a link (using a intent filter.) I do not want this activity to have a GUI - I just want it to start a service and put a notification in the bar. I have tried to put the intent filter for the link in my service, but that does not work. Is there a better...
[ { "answer_id": 527228, "author": "Reto Meier", "author_id": 822, "author_profile": "https://Stackoverflow.com/users/822", "pm_score": 5, "selected": true, "text": "<p>Your best bet would seem to be using a <code>BroadcastReceiver</code>. You can create a new BroadcastReceiver that listen...
2009/02/08
[ "https://Stackoverflow.com/questions/526074", "https://Stackoverflow.com", "https://Stackoverflow.com/users/764272/" ]
I have created a activity that is only meant to be launched from a link (using a intent filter.) I do not want this activity to have a GUI - I just want it to start a service and put a notification in the bar. I have tried to put the intent filter for the link in my service, but that does not work. Is there a better th...
Your best bet would seem to be using a `BroadcastReceiver`. You can create a new BroadcastReceiver that listens for the Intent to trigger your notification and start your service like this: ``` public class MyIntentReceiver extends BroadcastReceiver { @Override public void onReceive(Context _context, Intent _...
526,082
<p>What's the point of using the <code>set!</code> assignment operator in scheme? Why not just <code>rebind</code> a variable to a new value using <code>define</code>?</p> <pre><code>&gt; (define x 100) &gt; (define (value-of-x) x) ;; value-of-x closes over "x" &gt; x 100 &gt; (value-of-x) 100 &gt; (set! x (+ x 1)) &g...
[ { "answer_id": 526100, "author": "kmkaplan", "author_id": 50902, "author_profile": "https://Stackoverflow.com/users/50902", "pm_score": 2, "selected": false, "text": "<p>When you use lexical bindings you do <em>not</em> <code>define</code> them:</p>\n\n<pre><code>(let ((x 1))\n (set! x ...
2009/02/08
[ "https://Stackoverflow.com/questions/526082", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618/" ]
What's the point of using the `set!` assignment operator in scheme? Why not just `rebind` a variable to a new value using `define`? ``` > (define x 100) > (define (value-of-x) x) ;; value-of-x closes over "x" > x 100 > (value-of-x) 100 > (set! x (+ x 1)) > x 101 > (value-of-x) 101 > (define x (+ x 1)) > x 102 > (value...
Though both `define` and `set!` will redefine a value when in the same scope, they do two different things when the scope is different. Here's an example: ``` (define x 3) (define (foo) (define x 4) x) (define (bar) (set! x 4) x) (foo) ; returns 4 x ; still 3 (bar) ; returns 4 x ; is now 4 ``` As ...
526,118
<p>I've got a problem that keeps coming up with normalized databases and was looking for the best solution.</p> <p>Suppose I've got an album information database. I want to setup the schema in a normalized fashion, so I setup two tables - albums, which has one listing for each album, and songs, which lists all songs ...
[ { "answer_id": 526127, "author": "Phil", "author_id": 62789, "author_profile": "https://Stackoverflow.com/users/62789", "pm_score": 0, "selected": false, "text": "<p>The join queries will ask the database to put the tables together, matching the ids and return a single table. That way th...
2009/02/08
[ "https://Stackoverflow.com/questions/526118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/60261/" ]
I've got a problem that keeps coming up with normalized databases and was looking for the best solution. Suppose I've got an album information database. I want to setup the schema in a normalized fashion, so I setup two tables - albums, which has one listing for each album, and songs, which lists all songs contained b...
I have difficulty seeing your point. What exactly do you mean by "how do you grab multiple albums at once in a single query"? What exactly do you have difficulties with? Intuitively I would say: ``` SELECT a.aid album_id, a.name album_name, s.sid song_id, s.name song_name, s.length song_length FRO...
526,125
<p>Here is the dictionary I have</p> <pre><code>propertyList = { "id": "int", "name": "char(40)", "team": "int", "realOwner": "int", "x": "int", "y": "int", "description": "char(255)", "port": "bool", "secret": "b...
[ { "answer_id": 526131, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "<p>For older versions of Python, the real question should be “why not?” — An unordered dictionary is usually implement...
2009/02/08
[ "https://Stackoverflow.com/questions/526125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1384652/" ]
Here is the dictionary I have ``` propertyList = { "id": "int", "name": "char(40)", "team": "int", "realOwner": "int", "x": "int", "y": "int", "description": "char(255)", "port": "bool", "secret": "bool", "dea...
For older versions of Python, the real question should be “why not?” — An unordered dictionary is usually implemented as a [hash table](http://en.wikipedia.org/wiki/Hash_table) where the order of elements is well-defined but not immediately obvious ([the Python documentation used to state this](https://docs.python.org/...
526,132
<p>Currently the way <code>/usr/sbin/alsa</code> in Debian knows the processes using the sound card looks like:</p> <pre><code>echo $( \ lsof +D /dev -F rt \ | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ &amp;&amp; type == "tCHR" {print pid}' \ | cut -c 2- \ | uniq \ ) </code></pre> <p>Which is ...
[ { "answer_id": 526239, "author": "jfsantos", "author_id": 62695, "author_profile": "https://Stackoverflow.com/users/62695", "pm_score": 4, "selected": false, "text": "<p>There is an answer for this question on the <a href=\"https://web.archive.org/web/20090201162847/http://alsa.opensrc.o...
2009/02/08
[ "https://Stackoverflow.com/questions/526132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4534/" ]
Currently the way `/usr/sbin/alsa` in Debian knows the processes using the sound card looks like: ``` echo $( \ lsof +D /dev -F rt \ | awk '/^p/ {pid=$1} /^t/ {type=$1} /^r0x(74|e)..$/ && type == "tCHR" {print pid}' \ | cut -c 2- \ | uniq \ ) ``` Which is rather ugly and depends on `lsof`. I am looki...
You start a lot of processes here. Instead you can try doing in a similar way to the lsof script you posted... but replacing lsof by a shell for loop: If you want to avoid launching lots of grep processes, start only one: ``` #!/bin/sh for i in /proc/[0-9]*/fd/* do echo ${i%/fd/*} $(readlink $i) done | grep -q /d...
526,133
<p>Yet another argument with a friend of mine. Consider this code:</p> <pre><code>class User &lt; ActiveRecord::Base has_many :groups def in_group?(group) groups.include?(group) end end class Group &lt; ActiveRecord::Base has_many :members def add_user(user) members &lt;&lt; user end end </code...
[ { "answer_id": 526187, "author": "nakajima", "author_id": 39589, "author_profile": "https://Stackoverflow.com/users/39589", "pm_score": 3, "selected": true, "text": "<p>I totally agree that these methods should not be added. It's not the job of models to create other related objects. Tha...
2009/02/08
[ "https://Stackoverflow.com/questions/526133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45652/" ]
Yet another argument with a friend of mine. Consider this code: ``` class User < ActiveRecord::Base has_many :groups def in_group?(group) groups.include?(group) end end class Group < ActiveRecord::Base has_many :members def add_user(user) members << user end end ``` My opinion is that these m...
I totally agree that these methods should not be added. It's not the job of models to create other related objects. That's the job of the association proxy. I'd also beware of overriding association proxy behaviors, since you're liable to see some strange side effects due to the way the proxies are implemented.
526,143
<pre><code>SELECT tblIssue.SYMB, tblIssue.[PRCE], tblIssue.[Shareholder] FROM tblIssue </code></pre> <p>I am trying to pull the symb and price for the maximum number of shareholder per symb. For example, I would have only 1 line for ASN where the price would be $60.62.</p> <pre> SYMB Price Shareholder ASN $0.00 ...
[ { "answer_id": 526180, "author": "Quassnoi", "author_id": 55159, "author_profile": "https://Stackoverflow.com/users/55159", "pm_score": 0, "selected": false, "text": "<p>In Oracle:</p>\n\n<pre><code>SELECT symb, price\nFROM (\n SELECT symb, price, ROW_NUMBER() OVER (PARTITION BY symb OR...
2009/02/08
[ "https://Stackoverflow.com/questions/526143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` SELECT tblIssue.SYMB, tblIssue.[PRCE], tblIssue.[Shareholder] FROM tblIssue ``` I am trying to pull the symb and price for the maximum number of shareholder per symb. For example, I would have only 1 line for ASN where the price would be $60.62. ``` SYMB Price Shareholder ASN $0.00 0 ASN $0.00 51 ASN $...
A correlated subquery seems the easiest (if I understand your problem): ``` select symb, price, shareholder from issue i where price = ( select max(price) from issue where symb = i.symb) ``` which produces: ``` ASN 61 231 ASNL 0 101 ASR 37 13 ```
526,157
<p>Is there a simple built-in way to take an ordered list of <code>IEnumerable</code>s and return a single <code>IEnumerable</code> which yields, in order, all the elements in the first, then the second, and so on.</p> <p>I could certainly write my own, but I wanted to know whether there was already a way to accomplis...
[ { "answer_id": 526160, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 6, "selected": true, "text": "<p>Try SelectMany.</p>\n\n<pre><code>IEnumerable&lt;int&gt; Collapse(IEnumerable&lt;IEnumerable&lt;int&gt;&gt; e){\n retur...
2009/02/08
[ "https://Stackoverflow.com/questions/526157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44743/" ]
Is there a simple built-in way to take an ordered list of `IEnumerable`s and return a single `IEnumerable` which yields, in order, all the elements in the first, then the second, and so on. I could certainly write my own, but I wanted to know whether there was already a way to accomplish this seemingly useful task bef...
Try SelectMany. ``` IEnumerable<int> Collapse(IEnumerable<IEnumerable<int>> e){ return e.SelectMany(x => x ); } ``` The purpose of this function is to flatten a group of IEnumerable<IEnumerable<T>> into an IEnumerable<T>. The returned data will preserve the original order.
526,167
<p>As part of my application, I'm putting together a set of small Dom nodes that are not shown all at once. I'm storing them in an internal array. The user can invoke their display in which case I reparent them to the div that is used to display them. That's all well and good. But when it's time to replace all of th...
[ { "answer_id": 526160, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 6, "selected": true, "text": "<p>Try SelectMany.</p>\n\n<pre><code>IEnumerable&lt;int&gt; Collapse(IEnumerable&lt;IEnumerable&lt;int&gt;&gt; e){\n retur...
2009/02/08
[ "https://Stackoverflow.com/questions/526167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494/" ]
As part of my application, I'm putting together a set of small Dom nodes that are not shown all at once. I'm storing them in an internal array. The user can invoke their display in which case I reparent them to the div that is used to display them. That's all well and good. But when it's time to replace all of them wit...
Try SelectMany. ``` IEnumerable<int> Collapse(IEnumerable<IEnumerable<int>> e){ return e.SelectMany(x => x ); } ``` The purpose of this function is to flatten a group of IEnumerable<IEnumerable<T>> into an IEnumerable<T>. The returned data will preserve the original order.
526,173
<p>Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let):</p> <pre><code> (if some-cond ((exp1) (exp2) (exp3)) ; multi ex...
[ { "answer_id": 526183, "author": "Phil", "author_id": 62789, "author_profile": "https://Stackoverflow.com/users/62789", "pm_score": 2, "selected": false, "text": "<p>There are already macros for the expanded version. This book is really good: <a href=\"http://www.gigamonkeys.com/book/\" ...
2009/02/08
[ "https://Stackoverflow.com/questions/526173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is this just a bit of historical cruft left over from the 1950s or is there some reason syntactically why multi-expression bodies of (if) forms require (progn)? Why can't you wrap the multiple expressions in a set of parentheses like with (let): ``` (if some-cond ((exp1) (exp2) (exp3)) ; multi exp "then" ...
Common Lisp is not perfect because it is perfect, it is perfect because it is perfectable. The whole language is built upon 25 [special operators](http://www.gigamonkeys.com/book/the-special-operators.html); `if` is one of those, `progn` is another. `if` provides just the basic mechanism of testing a condition, then ...
526,179
<p>I'm aware that you can get session variables using <code>request.session['variable_name']</code>, but there doesn't seem to be a way to grab the session id as a variable in a similar way. Is this documented anywhere? I can't find it.</p>
[ { "answer_id": 526194, "author": "che", "author_id": 7806, "author_profile": "https://Stackoverflow.com/users/7806", "pm_score": 5, "selected": false, "text": "<p>Django sessions save their key in a cookie. At least its middleware extracts it like this:</p>\n\n<pre><code>from django.conf...
2009/02/08
[ "https://Stackoverflow.com/questions/526179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/326176/" ]
I'm aware that you can get session variables using `request.session['variable_name']`, but there doesn't seem to be a way to grab the session id as a variable in a similar way. Is this documented anywhere? I can't find it.
``` request.session.session_key ``` Note the key will only exist if there is a session, no key, no session. You can use this to test if a session exists. If you want to create a session, call create.
526,200
<p>On my webpage I want to able to present tabular data and give the user the possibility to copy it directly into excel. This however doesn't work, all of the data is pasted in one cell:</p> <pre><code>&lt;table&gt; &lt;tr&gt;&lt;td&gt;Column 1&lt;/td&gt;&lt;td&gt;Column 2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;Da...
[ { "answer_id": 526204, "author": "grapefrukt", "author_id": 914, "author_profile": "https://Stackoverflow.com/users/914", "pm_score": 3, "selected": false, "text": "<p>It's no big deal, if you want them to degrade to tables, use tables. This whole no-tables-deal is about proper semantics...
2009/02/08
[ "https://Stackoverflow.com/questions/526200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35197/" ]
On my webpage I want to able to present tabular data and give the user the possibility to copy it directly into excel. This however doesn't work, all of the data is pasted in one cell: ``` <table> <tr><td>Column 1</td><td>Column 2</td></tr> <tr><td>Data 1.1</td><td>Data 2.1</td></tr> <tr><td>Data 1.2</td><td>Data 2.2<...
It's no big deal, if you want them to degrade to tables, use tables. This whole no-tables-deal is about proper semantics, not avoiding them altogether. If you consider your data to belong in a table put it in one. *But do expect me to come after you with a pitchfork if you use tables for formatting ;)*
526,233
<p>Is there any other reasoning other than the timeout setting in the web.config not being used? It might be the default timeout of 30 minutes but it is definitely less than 30 minutes.</p> <pre><code> &lt;authentication mode="Forms"&gt; &lt;forms timeout="50000000" loginUrl="content/login.aspx"/&gt; ...
[ { "answer_id": 526248, "author": "meandmycode", "author_id": 63751, "author_profile": "https://Stackoverflow.com/users/63751", "pm_score": 1, "selected": false, "text": "<p>Probably related to Session timeout, you can change the timeout of the users session in the web.config, inside the ...
2009/02/08
[ "https://Stackoverflow.com/questions/526233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32372/" ]
Is there any other reasoning other than the timeout setting in the web.config not being used? It might be the default timeout of 30 minutes but it is definitely less than 30 minutes. ``` <authentication mode="Forms"> <forms timeout="50000000" loginUrl="content/login.aspx"/> </authentication> ``` ...
The ASP.NET authentication timeout can be set in the web.config file (as you've shown in your question), however, this can also be set in code. Do you have any areas of your C# code that explicitly set the forms timeout value? If so, the setting in code will override the web.config setting. Another possibility is the ...
526,243
<p>When I dynamically load content into a div and fadeIn (or show or slideDown), the fonts don't look very clear in IE. The fonts of the preloaded contents look just fine, however.</p> <p>I hove noticed this happening with scriptaculous in IE also.</p> <p>Does anyone have any ideas?</p> <p>No problems in Firefox.</...
[ { "answer_id": 526247, "author": "Matt Howell", "author_id": 2321, "author_profile": "https://Stackoverflow.com/users/2321", "pm_score": 1, "selected": false, "text": "<p>Try setting a background color on your div. IE is very weird about opacity issues (or fading in, in this case), and ...
2009/02/08
[ "https://Stackoverflow.com/questions/526243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63938/" ]
When I dynamically load content into a div and fadeIn (or show or slideDown), the fonts don't look very clear in IE. The fonts of the preloaded contents look just fine, however. I hove noticed this happening with scriptaculous in IE also. Does anyone have any ideas? No problems in Firefox. Thanks!
This will work in v1.3: ``` $('#foo').fadeOut(function() { if (! $.support.opacity) { this.style.removeAttribute('filter'); } }); ``` In earlier versions, you'd need to do: ``` $('#foo').fadeOut(function() { if ($.browser.msie) { this.style.removeAttribute('filter'); } }); ```
526,255
<p>I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less unlikely (a more likely) object. I am wondering if you would have any suggestions, preferably an existing python module th...
[ { "answer_id": 526262, "author": "Aaron Maenpaa", "author_id": 2603, "author_profile": "https://Stackoverflow.com/users/2603", "pm_score": 1, "selected": false, "text": "<p>The simplest thing to do is to use random.choice (which uses a uniform distribution) and vary the frequency of occu...
2009/02/08
[ "https://Stackoverflow.com/questions/526255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49985/" ]
I have a bunch of keys that each have an unlikeliness variable. I want to randomly choose one of these keys, yet I want it to be more unlikely for unlikely (key, values) to be chosen than a less unlikely (a more likely) object. I am wondering if you would have any suggestions, preferably an existing python module that ...
[This activestate recipe](http://code.activestate.com/recipes/117241/) gives an easy-to-follow approach, specifically the version in the comments that doesn't require you to pre-normalize your weights: ``` import random def weighted_choice(items): """items is a list of tuples in the form (item, weight)""" wei...
526,267
<p>If you have a property:</p> <pre><code>public class Fred { public string UserName { set { userName=value; } } } </code></pre> <p>how do you use Rhino Mocks to check that</p> <pre><code>fred= new Fred(); fred.UserName="Jim"; </code></pre> <p>is called.</p> <pre><code>Expect.Call(m...
[ { "answer_id": 526293, "author": "bendewey", "author_id": 37881, "author_profile": "https://Stackoverflow.com/users/37881", "pm_score": 3, "selected": true, "text": "<p>You should just be able to do a verify all on the property set</p>\n\n<pre><code>[TestClass]\npublic class FredTests\n{...
2009/02/08
[ "https://Stackoverflow.com/questions/526267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you have a property: ``` public class Fred { public string UserName { set { userName=value; } } } ``` how do you use Rhino Mocks to check that ``` fred= new Fred(); fred.UserName="Jim"; ``` is called. ``` Expect.Call(mockFred.UserName).SetPropertyWithArgument("Jim"); ``` does...
You should just be able to do a verify all on the property set ``` [TestClass] public class FredTests { [TestMethod] public void TestFred() { var mocker = new MockRepository(); var fredMock = mocker.DynamicMock<IFred>(); fredMock.UserName = "Name"; // the last call is actua...
526,294
<p>My HTML code is just dividing the pages into two columns, 65%,35% respectively.</p> <pre><code>&lt;div style="float : left; width :65%; height:auto;background-color:#FDD017;"&gt; &lt;div id="response"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="float : left; width :35%;height:auto; background-color:#FDD017;...
[ { "answer_id": 526298, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 0, "selected": false, "text": "<p>I recommend you wrap them both in an outer div with the desired background color.</p>\n" }, { "answer_id": 526303...
2009/02/08
[ "https://Stackoverflow.com/questions/526294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44984/" ]
My HTML code is just dividing the pages into two columns, 65%,35% respectively. ``` <div style="float : left; width :65%; height:auto;background-color:#FDD017;"> <div id="response"> </div> </div> <div style="float : left; width :35%;height:auto; background-color:#FDD017;"> <div id="note"> </div> </div> ...
Wrap them in a containing div with the background color applied to it, and have a clearing div after the 'columns'. ``` <div style="background-color: yellow;"> <div style="float: left;width: 65%;">column a</div> <div style="float: right;width: 35%;">column b</div> <div style="clear: both;"></div> </div> ``` --...
526,306
<p>I it was possible to do this in Active Record, but is this feasible with Linq to SQL?</p>
[ { "answer_id": 526404, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 0, "selected": false, "text": "<p>You can if you use stored procedures or views to retrieve your data. The ORDER BY can then be in the stored proc ...
2009/02/08
[ "https://Stackoverflow.com/questions/526306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59452/" ]
I it was possible to do this in Active Record, but is this feasible with Linq to SQL?
You can always add a property to the data-context / entities objects in a partial class file: ``` partial class MyDataContext { public IOrderedQueryable<Foo> FoosByName { get {return Foos.OrderBy(foo=>foo.Name);} } } ``` Then any queries started from `FoosByName` will be pre-ordered (but still compos...
526,329
<p>I'm familiar with and use <code>shutdown</code> in Linux, and typically just do</p> <p><code>&gt; shutdown -h now</code></p> <p>But is there a way to stop shutdown from happening, say if I aim to shutdown 10 minutes from now and then in 5 minutes' time I discover I really don't want to shut down?</p>
[ { "answer_id": 526330, "author": "skiphoppy", "author_id": 18103, "author_profile": "https://Stackoverflow.com/users/18103", "pm_score": 6, "selected": true, "text": "<p>You can use &nbsp;<code>ps</code>&nbsp; to find the shutdown process and abort it, for example with <code>ps|grep shut...
2009/02/08
[ "https://Stackoverflow.com/questions/526329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9908/" ]
I'm familiar with and use `shutdown` in Linux, and typically just do `> shutdown -h now` But is there a way to stop shutdown from happening, say if I aim to shutdown 10 minutes from now and then in 5 minutes' time I discover I really don't want to shut down?
You can use  `ps`  to find the shutdown process and abort it, for example with `ps|grep shutdown`. Alternate and less eyeball-intensive versions of this: ``` pkill shutdown killall shutdown kill `cat /var/run/shutdown.pid` ```
526,347
<p>How do you get the rendered height of an element?</p> <p>Let's say you have a <code>&lt;div&gt;</code> element with some content inside. This content inside is going to stretch the height of the <code>&lt;div&gt;</code>. How do you get the "rendered" height when you haven't explicitly set the height. Obviously, I t...
[ { "answer_id": 526352, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 10, "selected": false, "text": "<p>Try one of:</p>\n\n<pre><code>var h = document.getElementById('someDiv').clientHeight;\nvar h = document.getElementByI...
2009/02/08
[ "https://Stackoverflow.com/questions/526347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36590/" ]
How do you get the rendered height of an element? Let's say you have a `<div>` element with some content inside. This content inside is going to stretch the height of the `<div>`. How do you get the "rendered" height when you haven't explicitly set the height. Obviously, I tried: ``` var h = document.getElementById(...
It should just be ``` $('#someDiv').height(); ``` with jQuery. This retrieves the height of the first item in the wrapped set as a number. Trying to use ``` .style.height ``` only works if you have set the property in the first place. Not very useful!
526,351
<p>I heard that some languages go from interpreted to compiled by "unrolling the interpreter loop".</p> <p>Let's say I have the following pseudo-c-code interpreter for an ast tree.</p> <pre><code>int interpret(node) { switch(node) { case PLUS: return interpret(child(0))+interpret(child(1)); ...
[ { "answer_id": 526374, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "<p>I'm slightly confused. I don't think 'unrolling the loop' is the right term here. Even if you refactor the code to not ...
2009/02/08
[ "https://Stackoverflow.com/questions/526351", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57757/" ]
I heard that some languages go from interpreted to compiled by "unrolling the interpreter loop". Let's say I have the following pseudo-c-code interpreter for an ast tree. ``` int interpret(node) { switch(node) { case PLUS: return interpret(child(0))+interpret(child(1)); case MINUS: ...
"Unrolling a loop" normally means replacing a repetition with a sequence of actions. The loop: ``` for (int i = 0; i < 4; ++i) { a[i] = b[i] + c[i]; } ``` would unroll into the equivalent: ``` a[0] = b[0] + c[0]; a[1] = b[1] + c[1]; a[2] = b[2] + c[2]; a[3] = b[3] + c[3]; ``` It appears to me that whoever was...
526,375
<p>I have had no trouble getting the sockets working with localips, but once I made the code change to use public ips, I've consistently gotten java.net.ConnectException.</p> <p>I am using the port 8084, which as far as I know, is not used elsewhere In the command prompt, netstat -a | grep 8084 shows: File STDIN: TC...
[ { "answer_id": 526417, "author": "Brandon", "author_id": 63775, "author_profile": "https://Stackoverflow.com/users/63775", "pm_score": 5, "selected": true, "text": "<p>What type of router? Don't forget that even though a port may be open on your router, you need to have your router <stro...
2009/02/08
[ "https://Stackoverflow.com/questions/526375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have had no trouble getting the sockets working with localips, but once I made the code change to use public ips, I've consistently gotten java.net.ConnectException. I am using the port 8084, which as far as I know, is not used elsewhere In the command prompt, netstat -a | grep 8084 shows: File STDIN: TCP user-9114...
What type of router? Don't forget that even though a port may be open on your router, you need to have your router **Forward** port 8084 to the destination computer's internal IP, otherwise because of Network Address Translation (NAT) the router/firewall doesn't know what to do with the traffic once it gets there. For...
526,397
<p>Alright, so I'm working on programming my own installer in C#, and what I'd like to do is something along the lines of put the files in the .exe, so I can do File.Copy(file, filedir);</p> <p>Or, if this isn't possible, is there another way of doing what I am attempting to do?</p>
[ { "answer_id": 526411, "author": "Ray Booysen", "author_id": 42124, "author_profile": "https://Stackoverflow.com/users/42124", "pm_score": 2, "selected": false, "text": "<p>I'm guessing here, but if you are trying to store resources in your application before compilation, you can in the ...
2009/02/08
[ "https://Stackoverflow.com/questions/526397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63830/" ]
Alright, so I'm working on programming my own installer in C#, and what I'd like to do is something along the lines of put the files in the .exe, so I can do File.Copy(file, filedir); Or, if this isn't possible, is there another way of doing what I am attempting to do?
I wouldn't code my own installer, but if you truely want to embed files into your assembly you could use strongly typed resources. In the properties dialog of your project open up the "Resources" tab and then add your file. You'll then be able to get the file using: ``` ProjectNamespace.Properties.Resources.MyFile ``...
526,400
<p>I had an exam a couple of days ago and today the Instructor gave us the key answer of the exam.</p> <p>One of the questions was</p> <blockquote> <pre><code>for ( j = 9; j &gt;= 1; j-- ) </code></pre> <p>Count the Number of operations</p> </blockquote> <p>The result was 20.</p> <p>Can anyone explain how he g...
[ { "answer_id": 526412, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "<p>Well, in the first iteration, <code>j</code> is set to <code>9</code>. After that, each iteration basically execut...
2009/02/08
[ "https://Stackoverflow.com/questions/526400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I had an exam a couple of days ago and today the Instructor gave us the key answer of the exam. One of the questions was > > > ``` > for ( j = 9; j >= 1; j-- ) > > ``` > > Count the Number of operations > > > The result was 20. Can anyone explain how he gets 20 operations from that?
20 operations: ``` set j = 9 check if j(9) >= 1 set j to 8 check if j(8) >= 1 set j to 7 check if j(7) >= 1 set j to 6 check if j(6) >= 1 set j to 5 check if j(5) >= 1 set j to 4 check if j(4) >= 1 set j to 3 check if j(3) >= 1 set j to 2 check if j(2) >= 1 set j to 1 check if j(1)>=1 set j to 0 check if j(0)>=1 ``` ...
526,406
<p>Following on from my previous question, <em><a href="https://stackoverflow.com/questions/508727/python-time-to-age">Python time to age</a></em>, I have now come across a problem regarding the timezone, and it turns out that it's not always going to be "+0200". So when strptime tries to parse it as such, it throws up...
[ { "answer_id": 526436, "author": "David Z", "author_id": 56541, "author_profile": "https://Stackoverflow.com/users/56541", "pm_score": 1, "selected": false, "text": "<p>As far as I know, <code>strptime()</code> doesn't recognize numeric time zone codes. If you know that the string is alw...
2009/02/08
[ "https://Stackoverflow.com/questions/526406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32933/" ]
Following on from my previous question, *[Python time to age](https://stackoverflow.com/questions/508727/python-time-to-age)*, I have now come across a problem regarding the timezone, and it turns out that it's not always going to be "+0200". So when strptime tries to parse it as such, it throws up an exception. I tho...
> > New in version 2.6. > > > For a naive object, the %z and %Z > format codes are replaced by empty > strings. > > > It looks like this is implemented only in >= 2.6, and I think you have to manually parse it. I can't see another solution than to remove the time zone data: ``` from datetime import timedelta...
526,438
<p>When outputting user input, do you only use <code>htmlspecialchars()</code> or are there are functions/actions/methods you also run? I'm looking for something that will also deal with XSS.</p> <p>I'm wondering if I should write a function that escapes user input on output or just use <code>htmlspecialchars()</code>...
[ { "answer_id": 526442, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 4, "selected": true, "text": "<p>I usually use </p>\n\n<pre><code>htmlspecialchars($var, ENT_QUOTES) \n</code></pre>\n\n<p>on input fields. I create...
2009/02/08
[ "https://Stackoverflow.com/questions/526438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
When outputting user input, do you only use `htmlspecialchars()` or are there are functions/actions/methods you also run? I'm looking for something that will also deal with XSS. I'm wondering if I should write a function that escapes user input on output or just use `htmlspecialchars()`. I'm looking for the generic ca...
I usually use ``` htmlspecialchars($var, ENT_QUOTES) ``` on input fields. I created a method that does this because i use that a lot and it makes the code shorter and more readable.
526,449
<p>I am new to JQuery but I've started by making a list creator essentially. I have an empty list and an input field and a link for the user to add elements to the list. When I add something, I would like it to be hidden at first and then show up dynamically using JQuery. Currently, it adds it to the list but it sets t...
[ { "answer_id": 526467, "author": "simplyharsh", "author_id": 63841, "author_profile": "https://Stackoverflow.com/users/63841", "pm_score": 0, "selected": false, "text": "<p>try using </p>\n\n<blockquote>\n <p>(\".theclass\").css(\"display\", \"inline {or your desired value}\");</p>\n</b...
2009/02/08
[ "https://Stackoverflow.com/questions/526449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20471/" ]
I am new to JQuery but I've started by making a list creator essentially. I have an empty list and an input field and a link for the user to add elements to the list. When I add something, I would like it to be hidden at first and then show up dynamically using JQuery. Currently, it adds it to the list but it sets the ...
I'm not exactly sure why your adding the extra calls to show/hide. When you add an item it will show it. Please explain further as to why you need to do the show/hide. If you absolutely have to. ``` $('a#addstep').click(function() { if ( $('#step').val().length > 0 ) { $('<li />') ...
526,457
<p>I have a simple model that is defined as:</p> <pre><code>class Article(models.Model): slug = models.SlugField(max_length=50, unique=True) title = models.CharField(max_length=100, unique=False) </code></pre> <p>and the form:</p> <pre><code>class ArticleForm(ModelForm): class Meta: model = Arti...
[ { "answer_id": 526477, "author": "simplyharsh", "author_id": 63841, "author_profile": "https://Stackoverflow.com/users/63841", "pm_score": 2, "selected": false, "text": "<p>All i can guess is that you are getting an object to fill a form, and trying to save it again. </p>\n\n<p>Try using...
2009/02/08
[ "https://Stackoverflow.com/questions/526457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/53687/" ]
I have a simple model that is defined as: ``` class Article(models.Model): slug = models.SlugField(max_length=50, unique=True) title = models.CharField(max_length=100, unique=False) ``` and the form: ``` class ArticleForm(ModelForm): class Meta: model = Article ``` The validation here fails w...
I don't think you are actually updating an existing article, but instead creating a new one, presumably with more or less the same content, especially the slug, and thus you will get an error. It is a bit strange that you don't get better error reporting, but also I do not know what the rest of your view looks like. W...
526,458
<p>I'm trying to write an application that responds whenever the Shift key is pressed, no matter what application currently has focus.</p> <p>I tried this with <code>SetWindowsHookEx()</code> and with <code>GetKeyboardState()</code>, but both of these only work when the application's window has focus. I need it to wor...
[ { "answer_id": 526463, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 1, "selected": false, "text": "<p>Setup a CBT hook look here <a href=\"http://www.codeproject.com/KB/DLL/keyboardhook.aspx\" rel=\"nofollow norefer...
2009/02/08
[ "https://Stackoverflow.com/questions/526458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33225/" ]
I'm trying to write an application that responds whenever the Shift key is pressed, no matter what application currently has focus. I tried this with `SetWindowsHookEx()` and with `GetKeyboardState()`, but both of these only work when the application's window has focus. I need it to work globally. How do I do this?
None of the provided answers helped me solve my problem, but I found the answer myself. Here it is. Using `SetWindowsHookEx()` with `WH_KEYBOARD_LL` was the correct approach. However, the other parameters to `SetWindowsHookEx()` are unintuitive: * The last parameter, `dwThreadId`, needs to be 0. * The second-last par...
526,469
<p>I'm playing around with the <a href="http://www.nltk.org/" rel="noreferrer">Natural Language Toolkit</a> (NLTK).</p> <p>Its documentation (<a href="http://www.nltk.org/book" rel="noreferrer">Book</a> and <a href="http://nltk.googlecode.com/svn/trunk/doc/howto/index.html" rel="noreferrer">HOWTO</a>) are quite bulky ...
[ { "answer_id": 526485, "author": "Mat", "author_id": 42974, "author_profile": "https://Stackoverflow.com/users/42974", "pm_score": 5, "selected": false, "text": "<p>Here's my own practical example for the benefit of anyone else looking this question up (excuse the sample text, it was the...
2009/02/08
[ "https://Stackoverflow.com/questions/526469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
I'm playing around with the [Natural Language Toolkit](http://www.nltk.org/) (NLTK). Its documentation ([Book](http://www.nltk.org/book) and [HOWTO](http://nltk.googlecode.com/svn/trunk/doc/howto/index.html)) are quite bulky and the examples are sometimes slightly advanced. Are there any good but basic examples of u...
Here's my own practical example for the benefit of anyone else looking this question up (excuse the sample text, it was the first thing I found on [Wikipedia](http://en.wikipedia.org/wiki/Mr_Blobby)): ``` import nltk import pprint tokenizer = None tagger = None def init_nltk(): global tokenizer global tagger...
526,474
<p>I am writing a (my first) C++ class on top of some code written in C, but I can only get the C++ to compile by declaring the C functions in a extern block. My project uses autotools; is there any way to automate this process so I don't have to maintain two header files?</p>
[ { "answer_id": 526480, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 3, "selected": true, "text": "<p>Yes create wrapper header files which include your C header files like so...</p>\n\n<pre><code>//Wrapper.h\n#ifdef...
2009/02/08
[ "https://Stackoverflow.com/questions/526474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63963/" ]
I am writing a (my first) C++ class on top of some code written in C, but I can only get the C++ to compile by declaring the C functions in a extern block. My project uses autotools; is there any way to automate this process so I don't have to maintain two header files?
Yes create wrapper header files which include your C header files like so... ``` //Wrapper.h #ifdef __cplusplus extern "C" { #include "Actual.h" } #else #include "Actual.h" #endif //Use.cpp #include "Wrapper.h" int main() { return 0; } //Use.c #include "Wrapper.h" /*or #include "Actual.h" */ int main(...
526,512
<p>I'm trying to debug URL rewriting on a hosted site, where I don't have access to <code>vhost.conf</code> and so can't set up a rewrite log. How else can I debug rules that aren't working?</p> <p>This is the rule I'm trying to straighten out, if anyone has any insight:</p> <pre><code>RewriteRule ^([^/]+)\.([^/]+)$...
[ { "answer_id": 526517, "author": "chaos", "author_id": 47529, "author_profile": "https://Stackoverflow.com/users/47529", "pm_score": 3, "selected": true, "text": "<p>Why wouldn't it loop? xslt.php has dots but no slashes. Try changing your options to [L,NS].</p>\n\n<p>Edit: Ah, I see. ...
2009/02/08
[ "https://Stackoverflow.com/questions/526512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46387/" ]
I'm trying to debug URL rewriting on a hosted site, where I don't have access to `vhost.conf` and so can't set up a rewrite log. How else can I debug rules that aren't working? This is the rule I'm trying to straighten out, if anyone has any insight: ``` RewriteRule ^([^/]+)\.([^/]+)$ xslt.php [L] ``` What I expect...
Why wouldn't it loop? xslt.php has dots but no slashes. Try changing your options to [L,NS]. Edit: Ah, I see. What you're missing is that [L] terminates all rewriting for this request, but a subrequest is still generated that gets its own rewrite pass. [NS] suppresses that pass.
526,520
<p>I have a <code>UINavigationController</code> into which I push several views. Inside <code>viewDidLoad</code> for one of these views I want to set the <code>self.navigationItem.backBarButtonItem</code> to a custom view (based on a custom image). I don't know why, but it doesn't seem to work. Instead, I get the stand...
[ { "answer_id": 529673, "author": "Travis", "author_id": 4284, "author_profile": "https://Stackoverflow.com/users/4284", "pm_score": 5, "selected": true, "text": "<p>I'm fairly certain that the <code>backBarButtonItem</code> is a read-only property. Instead of modifying the <code>backBar...
2009/02/08
[ "https://Stackoverflow.com/questions/526520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54380/" ]
I have a `UINavigationController` into which I push several views. Inside `viewDidLoad` for one of these views I want to set the `self.navigationItem.backBarButtonItem` to a custom view (based on a custom image). I don't know why, but it doesn't seem to work. Instead, I get the standard "back" button. ``` UIButton *ba...
I'm fairly certain that the `backBarButtonItem` is a read-only property. Instead of modifying the `backBarButtonItem`, try setting a custom `leftBarButtonItem` and hide the `backBarButtonItem`: ``` self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Prout" style:UIBarButtonItemStyleDone t...
526,524
<p>How to get the time from a Chronometer? I tried getText, getFormat, getBase, etc, but none of them could work.</p> <p>Example code snippet:</p> <pre><code>Chronometer t = (Chronometer)findViewById(R.id.toptime); long time = SystemClock.elapsedRealtime()-t.getBase(); Log.d(null,"Was: "+time); //time is not the prop...
[ { "answer_id": 526604, "author": "nyenyec", "author_id": 35112, "author_profile": "https://Stackoverflow.com/users/35112", "pm_score": 8, "selected": true, "text": "<p>If you look at the source of the Chronometer class, you'll see that it doesn't store the elapsed time in a field and it ...
2009/02/08
[ "https://Stackoverflow.com/questions/526524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/764272/" ]
How to get the time from a Chronometer? I tried getText, getFormat, getBase, etc, but none of them could work. Example code snippet: ``` Chronometer t = (Chronometer)findViewById(R.id.toptime); long time = SystemClock.elapsedRealtime()-t.getBase(); Log.d(null,"Was: "+time); //time is not the proper time for some reas...
If you look at the source of the Chronometer class, you'll see that it doesn't store the elapsed time in a field and it calculates it internally every time it needs to update the display. However it's relatively easy to do the same in your own code: ``` long elapsedMillis = SystemClock.elapsedRealtime() - chronometer...
526,526
<p>I'm trying to create a simple, small and basic javascript framework just for learning purposes. But the thing is that i'm allready stuck at the very basics.</p> <p>I'm trying to do something like this:</p> <pre><code>$('testdiv').testFunction(); </code></pre> <p>And the code i've written for that:</p> <pre><code...
[ { "answer_id": 526536, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 2, "selected": false, "text": "<p>To get the behavior you're expecting, you need the <code>$</code> function to return an object with a method named <code>test...
2009/02/08
[ "https://Stackoverflow.com/questions/526526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a simple, small and basic javascript framework just for learning purposes. But the thing is that i'm allready stuck at the very basics. I'm trying to do something like this: ``` $('testdiv').testFunction(); ``` And the code i've written for that: ``` var elementID; var smallFramework = { $:...
To get the behavior you're expecting, you need the `$` function to return an object with a method named `testFunction`. Try: ``` var smallFramework = // an object for namespacing { $:function(id) // the core function - returns an object wrapping the id { return { // return an object literal ...
526,530
<p>Say I have a role entity and a site entity. Now there are many roles to one site, so on the Role class there is a Site property that represents that relationship. If I wanted the roles for a site I would do this:</p> <pre><code>Site.Roles.Load() </code></pre> <p>Problems is, since the Site property on the Role c...
[ { "answer_id": 526561, "author": "Chad Moran", "author_id": 25416, "author_profile": "https://Stackoverflow.com/users/25416", "pm_score": 2, "selected": true, "text": "<p>Accessing it will load it. If you want it to load it explicitly there should be an .Include() method on the object q...
2009/02/08
[ "https://Stackoverflow.com/questions/526530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21691/" ]
Say I have a role entity and a site entity. Now there are many roles to one site, so on the Role class there is a Site property that represents that relationship. If I wanted the roles for a site I would do this: ``` Site.Roles.Load() ``` Problems is, since the Site property on the Role class isn't a collection but ...
Accessing it will load it. If you want it to load it explicitly there should be an .Include() method on the object query. ``` db.Sites.Include("Role").ToList(); ``` [Here's some documentation](http://msdn.microsoft.com/en-us/library/bb738708.aspx)
526,540
<p>I have a standard WinForms TextBox and I want to insert text at the cursor's position in the text. How can I get the cursor's position?</p> <p>Thanks</p>
[ { "answer_id": 526543, "author": "David Morton", "author_id": 45916, "author_profile": "https://Stackoverflow.com/users/45916", "pm_score": 4, "selected": false, "text": "<p>You want to check the <code>SelectionStart</code> property of the <code>TextBox</code>. </p>\n" }, { "answ...
2009/02/08
[ "https://Stackoverflow.com/questions/526540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a standard WinForms TextBox and I want to insert text at the cursor's position in the text. How can I get the cursor's position? Thanks
Regardless of whether any text is selected, the [SelectionStart](http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.selectionstart.aspx) property represents the index into the text where you caret sits. So you can use [String.Insert](http://msdn.microsoft.com/en-us/library/system.string.insert.asp...
526,548
<p>I have a website design that includes text input fields that look like this:</p> <p><a href="http://img401.imageshack.us/img401/4453/picture1ts2.png" rel="nofollow noreferrer">Input Field http://img401.imageshack.us/img401/4453/picture1ts2.png</a></p> <p>I'm wondering what the best solution for creating this input...
[ { "answer_id": 526560, "author": "Keith Donegan", "author_id": 37418, "author_profile": "https://Stackoverflow.com/users/37418", "pm_score": 0, "selected": false, "text": "<p>I have done this a few times. I have the background image inside a div and use css to position the input field ac...
2009/02/08
[ "https://Stackoverflow.com/questions/526548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
I have a website design that includes text input fields that look like this: [Input Field http://img401.imageshack.us/img401/4453/picture1ts2.png](http://img401.imageshack.us/img401/4453/picture1ts2.png) I'm wondering what the best solution for creating this input field is. One idea I have is to always have a div ar...
I'd do it this way: ``` <style type="text/css"> div.custom { background:url(/images/input-bkg-w173.gif) no-repeat; padding:8px 5px 4px 5px; } div.custom input { background-color: #fff; border:none; font-size:10px; } </style> <div class="custom"><input type="text" class="custom" size="12" /></div> ...
526,555
<p>I'm building an XML Deserializer for a project and I run across this type of code situation fairly often:</p> <pre><code>var myVariable = ParseNDecimal(xml.Element("myElement")) == null ? 0 : ParseNDecimal(xml.Element("myElement")).Value; </code></pre> <p>Is there a better way to write this state...
[ { "answer_id": 526567, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 4, "selected": true, "text": "<p>You can use extension method:</p>\n\n<pre><code>public static T TryGetValue&lt;T&gt;( this XmlElement element ) {\n if (...
2009/02/08
[ "https://Stackoverflow.com/questions/526555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63973/" ]
I'm building an XML Deserializer for a project and I run across this type of code situation fairly often: ``` var myVariable = ParseNDecimal(xml.Element("myElement")) == null ? 0 : ParseNDecimal(xml.Element("myElement")).Value; ``` Is there a better way to write this statement? EDIT : Perhaps I sh...
You can use extension method: ``` public static T TryGetValue<T>( this XmlElement element ) { if ( null == element ) return default(T); return (T)element.Value; } ... ... var myVariable = xml.Element("myElement").TryGetValue<decimal>(); ``` **EDIT:** The "universal" solution: ``` static class Program { ...
526,556
<p>It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings back together with <code>str_split</code> to make new simple array. However I never know if the join pattern isn't als...
[ { "answer_id": 526570, "author": "phihag", "author_id": 35070, "author_profile": "https://Stackoverflow.com/users/35070", "pm_score": 3, "selected": false, "text": "<p>A non-recursive solution (but order-destroying):</p>\n\n<pre><code>function flatten($ar) {\n $toflat = array($ar);\n ...
2009/02/08
[ "https://Stackoverflow.com/questions/526556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46866/" ]
It's probably beginner question but I'm going through documentation for longer time already and I can't find any solution. I thought I could use implode for each dimension and then put those strings back together with `str_split` to make new simple array. However I never know if the join pattern isn't also in values an...
[Use `array_walk_recursive`](http://php.net/manual/en/function.array-walk-recursive.php) ``` <?php $aNonFlat = array( 1, 2, array( 3, 4, 5, array( 6, 7 ), 8, 9, ), 10, 11 ); $objTmp = (object) array('aFlat' => arr...
526,559
<p>Hey all, I am trying to test if the argument passed into my function is a class name so that I may compare it to other classes using instanceof.</p> <p>For example:</p> <pre><code>function foo(class1, class2) { // Test to see if the parameter is a class. if(class1 is a class) { //do some kind of class co...
[ { "answer_id": 526575, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 2, "selected": false, "text": "<p>JavaScript does not have classes. It has functions which, when used with <code>new</code>, can be used to produce object inst...
2009/02/08
[ "https://Stackoverflow.com/questions/526559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/62610/" ]
Hey all, I am trying to test if the argument passed into my function is a class name so that I may compare it to other classes using instanceof. For example: ``` function foo(class1, class2) { // Test to see if the parameter is a class. if(class1 is a class) { //do some kind of class comparison. if(clas...
There is really no such thing as a "class" in javascript -- everything but primitives are an object. Even functions are objects. instanceof DOES work with functions though. Check out this [link](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/instanceof_Operator). ``` functi...
526,564
<pre>uint x = uint.MaxValue - 100;</pre> <p>The above line causes visual studio to report "The operation overflows at compile time in checked mode"</p> <p>I'm obviously missing something. Any ideas what?</p>
[ { "answer_id": 526584, "author": "JoelFan", "author_id": 16012, "author_profile": "https://Stackoverflow.com/users/16012", "pm_score": 1, "selected": false, "text": "<p>It may be implicity converting the uint.MaxValue to <strong>signed</strong> because you are subtracting a constant whic...
2009/02/08
[ "https://Stackoverflow.com/questions/526564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42975/" ]
``` uint x = uint.MaxValue - 100; ``` The above line causes visual studio to report "The operation overflows at compile time in checked mode" I'm obviously missing something. Any ideas what?
this error is being reported by the C# frontend used by the VS refactoring tool. When you go ahead and compile it using the actual compiler the error disappears!
526,576
<p>I just wanted to know how can we escape an SQL query (string) in Ruby to prevent SQL Injection. please note I am not using Rails framework.</p> <p>Thanks.</p>
[ { "answer_id": 526629, "author": "greyfade", "author_id": 33345, "author_profile": "https://Stackoverflow.com/users/33345", "pm_score": 4, "selected": false, "text": "<p>If possible, use the Ruby DBI module, and instead of trying to quote your strings, use parametrized prepared queries, ...
2009/02/08
[ "https://Stackoverflow.com/questions/526576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I just wanted to know how can we escape an SQL query (string) in Ruby to prevent SQL Injection. please note I am not using Rails framework. Thanks.
If possible, use the Ruby DBI module, and instead of trying to quote your strings, use parametrized prepared queries, like this: ``` dbh = DBI.connect("DBI:Mysql:test:localhost", "testuser", "testpass") sth = dbh.prepare("INSERT INTO people (id, name, height) VALUES(?, ?, ?)") File.open("people.txt", "r") do |f| f.e...
526,641
<p>And what do you put in your View?</p> <p>A recent <a href="http://www.hanselman.com/blog/IPrincipalUserModelBinderInASPNETMVCForEasierTesting.aspx" rel="noreferrer">blog</a> from <a href="http://www.hanselman.com/blog" rel="noreferrer">Scott Hanselman</a> about using a special model binder for easier testing led me...
[ { "answer_id": 526657, "author": "Trevor de Koekkoek", "author_id": 41783, "author_profile": "https://Stackoverflow.com/users/41783", "pm_score": 5, "selected": true, "text": "<p>In MVC (at least this flavor of it), one of the controller's responsibilities is to prepare the data for the ...
2009/02/08
[ "https://Stackoverflow.com/questions/526641", "https://Stackoverflow.com", "https://Stackoverflow.com/users/909/" ]
And what do you put in your View? A recent [blog](http://www.hanselman.com/blog/IPrincipalUserModelBinderInASPNETMVCForEasierTesting.aspx) from [Scott Hanselman](http://www.hanselman.com/blog) about using a special model binder for easier testing led me to think about the following: What do you put in your controller ...
In MVC (at least this flavor of it), one of the controller's responsibilities is to prepare the data for the view. So I think it is perfectly acceptable to prepare a specific model for the views consumption that implies it will be used in a drop-down. In this case the controller is just making it easier for the view an...
526,660
<p>Here's the situation:</p> <p>I just started my first C++ class. I know nothing about C++ and despite this being the an intro to C++ class, the teacher has taught pretty much NO syntax for the language, just logic that we already know.</p> <p>Now he gave us a program description and said, "write it, lol." I underst...
[ { "answer_id": 526663, "author": "Rob Kennedy", "author_id": 33732, "author_profile": "https://Stackoverflow.com/users/33732", "pm_score": 4, "selected": false, "text": "<p>It's complaining about <code>main</code> being undefined, and it's right. C and C++ require a <em>standalone</em> f...
2009/02/08
[ "https://Stackoverflow.com/questions/526660", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here's the situation: I just started my first C++ class. I know nothing about C++ and despite this being the an intro to C++ class, the teacher has taught pretty much NO syntax for the language, just logic that we already know. Now he gave us a program description and said, "write it, lol." I understand the logic fin...
It's complaining about `main` being undefined, and it's right. C and C++ require a *standalone* function named `main` which returns `int`. It is not sufficient to have a *class* with a method named `main`; the compiler only cares about the standalone one. Another thing to remember is that the default visibility for me...
526,666
<p>I have a small application that I'm developing, that I may want to give/sell to others. I want to persist some settings, and create an admin interface to modify them. What would be the best way to store them away? A DB table seems like overkill for the 10-20 settings I'll have, and I want the retrieval of these s...
[ { "answer_id": 526672, "author": "Ólafur Waage", "author_id": 22459, "author_profile": "https://Stackoverflow.com/users/22459", "pm_score": 2, "selected": false, "text": "<p>PHP has functions to read .ini files.</p>\n\n<p><a href=\"http://is2.php.net/manual/en/function.parse-ini-file.php...
2009/02/08
[ "https://Stackoverflow.com/questions/526666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/57698/" ]
I have a small application that I'm developing, that I may want to give/sell to others. I want to persist some settings, and create an admin interface to modify them. What would be the best way to store them away? A DB table seems like overkill for the 10-20 settings I'll have, and I want the retrieval of these setting...
I often use PHP's [`parse_ini_file`](http://us2.php.net/function.parse-ini-file) for this. So if you write an .ini file with this: ``` ; This is a sample configuration file ; Comments start with ';', as in php.ini [first_section] one = 1 five = 5 animal = BIRD [second_section] path = "/usr/local/bin" URL = "http://...
526,711
<p>I'm trying to connect to an API that uses a self-signed SSL certificate. I'm doing so using .NET's HttpWebRequest and HttpWebResponse objects. And I'm getting an exception that:</p> <blockquote> <p>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</p> </b...
[ { "answer_id": 526730, "author": "Dominic Scheirlinck", "author_id": 10831, "author_profile": "https://Stackoverflow.com/users/10831", "pm_score": 7, "selected": false, "text": "<p>Turns out, if you just want to disable certificate validation altogether, you can change the ServerCertific...
2009/02/08
[ "https://Stackoverflow.com/questions/526711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10831/" ]
I'm trying to connect to an API that uses a self-signed SSL certificate. I'm doing so using .NET's HttpWebRequest and HttpWebResponse objects. And I'm getting an exception that: > > The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. > > > I understand what...
@Domster: that works, but you might want to enforce a bit of security by checking if the certificate hash matches what you expect. So an expanded version looks a bit like this (based on some live code we're using): ``` static readonly byte[] apiCertHash = { 0xZZ, 0xYY, ....}; /// <summary> /// Somewhere in your appli...
526,718
<p>Does anyone know how to figure out search time for a binary search tree(i.e. worst-case, best-case, and average-case)?</p>
[ { "answer_id": 526724, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 5, "selected": false, "text": "<p>For a non-self-balancing tree (possible but unusual for a search tree), worst case is O(n), which is for the degenera...
2009/02/08
[ "https://Stackoverflow.com/questions/526718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Does anyone know how to figure out search time for a binary search tree(i.e. worst-case, best-case, and average-case)?
For a non-self-balancing tree (possible but unusual for a search tree), worst case is O(n), which is for the degenerate binary tree (a linked list). In this case, you have to search, on average, half the list before finding your desired element. Best case is O(log2 n) for a perfectly balanced tree, since you cut the ...
526,728
<p>I need to calculate the time complexity of the following code:</p> <pre><code>for (i = 1; i &lt;= n; i++) { for(j = 1; j &lt;= i; j++) { // Some code } } </code></pre> <p>Is it <em>O(n^2)</em>?</p>
[ { "answer_id": 526732, "author": "Chris Bunch", "author_id": 422, "author_profile": "https://Stackoverflow.com/users/422", "pm_score": 4, "selected": false, "text": "<p>Indeed, it is O(n^2). See also a very similar example with the same runtime <a href=\"https://stackoverflow.com/questio...
2009/02/09
[ "https://Stackoverflow.com/questions/526728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63995/" ]
I need to calculate the time complexity of the following code: ``` for (i = 1; i <= n; i++) { for(j = 1; j <= i; j++) { // Some code } } ``` Is it *O(n^2)*?
Yes, nested loops are one way to quickly get a big O notation. Typically (but not always) one loop nested in another will cause O(n²). Think about it, the inner loop is executed i times, *for each value of i*. The outer loop is executed n times. thus you see a pattern of execution like this: 1 + 2 + 3 + 4 + ... + n ...
526,733
<p>I'm trying to create a new plugin to package my latest project. I'm trying to have this plugin depend on the maven-dependency-plugin to copy all my projects dependencies.</p> <p>I've added this dependency to my plugin's pom, but I can't get it to execute.</p> <p>I have this annotation in my plugins main Mojo:</p>...
[ { "answer_id": 549846, "author": "Matthew McCullough", "author_id": 56039, "author_profile": "https://Stackoverflow.com/users/56039", "pm_score": 5, "selected": false, "text": "<p>Use the <a href=\"https://github.com/TimMoore/mojo-executor\" rel=\"noreferrer\">Maven Mojo executor</a> by ...
2009/02/09
[ "https://Stackoverflow.com/questions/526733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48234/" ]
I'm trying to create a new plugin to package my latest project. I'm trying to have this plugin depend on the maven-dependency-plugin to copy all my projects dependencies. I've added this dependency to my plugin's pom, but I can't get it to execute. I have this annotation in my plugins main Mojo: ``` @execute goal="o...
Use the [Maven Mojo executor](https://github.com/TimMoore/mojo-executor) by Don Brown of Atlassian fame to run any other arbitrary plugin. > > The Mojo Executor provides a way to to > execute other Mojos (plugins) within a > Maven 2 plugin, allowing you to easily > create Maven 2 plugins that are > composed of ot...
526,734
<p>I am running an msi installer in silent mode and caching logs in the specific file. The following is the command i need to execute.</p> <p><code>C:\Program Files\ My Installer\Setup.exe /s /v "/qn /lv %TEMP%\log_silent.log"</code></p> <p>I used:</p> <pre><code>subprocess.Popen(['C:\Program Files\ My Installer\Se...
[ { "answer_id": 526771, "author": "paprika", "author_id": 61815, "author_profile": "https://Stackoverflow.com/users/61815", "pm_score": 2, "selected": false, "text": "<p>The problem is that you effectively supply Setup.exe with only one argument. Don't think in terms of the shell, the st...
2009/02/09
[ "https://Stackoverflow.com/questions/526734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577336/" ]
I am running an msi installer in silent mode and caching logs in the specific file. The following is the command i need to execute. `C:\Program Files\ My Installer\Setup.exe /s /v "/qn /lv %TEMP%\log_silent.log"` I used: ``` subprocess.Popen(['C:\Program Files\ My Installer\Setup.exe', '/s /v "/qn /lv %TEMP%\log_sil...
The problem is very subtle. You're executing the program directly. It gets: ``` argv[0] = "C:\Program Files\ My Installer\Setup.exe" argv[1] = /s /v "/qn /lv %TEMP%\log_silent.log" ``` Whereas it should be: ``` argv[1] = "/s" argv[2] = "/v" argv[3] = "/qn" argv[4] = "/lv %TEMP%\log_silent.log" ``` In other words...
526,736
<p>In the last year and a bit of working on my team's code base I have noticed a steady progression of naming conventions.</p> <p>For example, there are a lot of classes that are named to express that they are a class that helps you do something.</p> <p>Here's the ones I've spotted:</p> <pre><code>MyClassUtil MyClas...
[ { "answer_id": 526746, "author": "David Morton", "author_id": 45916, "author_profile": "https://Stackoverflow.com/users/45916", "pm_score": 2, "selected": false, "text": "<p>All of the names of classes you've given above indicate to me a striking departure from object-oriented principles...
2009/02/09
[ "https://Stackoverflow.com/questions/526736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39532/" ]
In the last year and a bit of working on my team's code base I have noticed a steady progression of naming conventions. For example, there are a lot of classes that are named to express that they are a class that helps you do something. Here's the ones I've spotted: ``` MyClassUtil MyClassFactory MyClassHelper MyCla...
They don't seem like fads... all these names hint at the purpose of the class, and those purposes are different. With programming, it's all in the name, and they should be chosen very carefully. The variety doesn't need to be escaped. The names vary because the purposes of the classes vary. **MyClassUtil** -Some utili...
526,742
<p>Simple question, but for some reason I couldn't find the exact answer on Google:</p> <p>I have a fresh Ubuntu install on Slicehost, and would like to make a public directory in my home dir for a simple website containing a bunch of static HTML files. How do I do this? Is it just a matter of typing <code>mkdir publi...
[ { "answer_id": 526760, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 2, "selected": false, "text": "<p>You need to use <a href=\"http://httpd.apache.org/docs/1.3/mod/mod_userdir.html\" rel=\"nofollow noreferrer\">mod_userd...
2009/02/09
[ "https://Stackoverflow.com/questions/526742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38146/" ]
Simple question, but for some reason I couldn't find the exact answer on Google: I have a fresh Ubuntu install on Slicehost, and would like to make a public directory in my home dir for a simple website containing a bunch of static HTML files. How do I do this? Is it just a matter of typing `mkdir public_html` and set...
Assuming you've already installed apache, do the following: ``` sudo a2enmod userdir sudo service apache2 reload ``` The first command enables the userdir apache mod, which does exactly what you want. The second reloads apache configurations so that it starts using the new configuration. To install apache2: ``` s...
526,743
<p>I am developing a simple platform game in Java using BlueJ.</p> <p>Over the next few weeks I will be posting a few questions asking for help with this project as am not very proficient at programming. So I hope I don't become annoying and I would be very grateful if you can kindly help me.</p> <p>In my game I have...
[ { "answer_id": 526772, "author": "John Gardner", "author_id": 13687, "author_profile": "https://Stackoverflow.com/users/13687", "pm_score": 2, "selected": false, "text": "<p>To help you do your homework:</p>\n\n<pre><code> // if the player goes out of bounds, the game is over\n if (p...
2009/02/09
[ "https://Stackoverflow.com/questions/526743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63666/" ]
I am developing a simple platform game in Java using BlueJ. Over the next few weeks I will be posting a few questions asking for help with this project as am not very proficient at programming. So I hope I don't become annoying and I would be very grateful if you can kindly help me. In my game I have a gameOver metho...
To get you started: 1. Think about how you might get the player's current position. 2. Think about what makes the player fall (there should be some method/class that implements gravity and falling?) 3. Check the player's position as they fall against the boundries of your world. If they're outside the boundries, it's ...
526,745
<p>I've been experimenting with ASP.Net MVC, and have come across a problem that is probably not specifically MVC related. But I cannot get the authentication in the default MVC application (the one created by the wizard when you create a new MVC project) to work properly under IIS 7 on Windows 7.</p> <p>If I run unde...
[ { "answer_id": 1539547, "author": "Nick Larsen", "author_id": 178082, "author_profile": "https://Stackoverflow.com/users/178082", "pm_score": 3, "selected": true, "text": "<p>I got this problem as well running under medium trust. The process that creates the database requires at least H...
2009/02/09
[ "https://Stackoverflow.com/questions/526745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10223/" ]
I've been experimenting with ASP.Net MVC, and have come across a problem that is probably not specifically MVC related. But I cannot get the authentication in the default MVC application (the one created by the wizard when you create a new MVC project) to work properly under IIS 7 on Windows 7. If I run under the Visu...
I got this problem as well running under medium trust. The process that creates the database requires at least High trust. You can check this by looking in your Web.Config for ``` <trust level="TrustLevel" /> ``` If there is no trust specified in your Web.Config, try adding it and set it to either Full or High. If ...