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 |
|---|---|---|---|---|---|---|
432,600 | <p>How can I write a custom <code>IEnumerator<T></code> implementation which needs to maintain some state and still get to use iterator blocks to simplify it? The best I can come up with is something like this:</p>
<pre><code>public class MyEnumerator<T> : IEnumerator<T> {
private IEnumerator<... | [
{
"answer_id": 432616,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>Why do you want to write an iterator class? The whole point of an iterator block is so you don't have to...</p>\n\n... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] | How can I write a custom `IEnumerator<T>` implementation which needs to maintain some state and still get to use iterator blocks to simplify it? The best I can come up with is something like this:
```
public class MyEnumerator<T> : IEnumerator<T> {
private IEnumerator<T> _enumerator;
public int Position {get; ... | Why do you want to write an iterator class? The whole point of an iterator block is so you don't have to...
i.e.
```
public IEnumerator<T> GetEnumerator() {
int position = 0; // state
while(whatever) {
position++;
yield return ...something...;
}
}
```
If you add more context (i,e, why th... |
432,610 | <p>Is there something I need to do to get System.Net working with Microsoft Visual C# 2008 Express Edition? I can't seem to get any web type controls or classes to work at all.. the below WebClient example always throws the exception "<strong>Unable to connect to the remote server</strong>".. and consequently I can't g... | [
{
"answer_id": 432623,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": false,
"text": "<p>(<strong>update</strong> - I meant <code>proxycfg</code>, not <code>httpcfg</code>; <code>proxycfg -u</code> will ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48923/"
] | Is there something I need to do to get System.Net working with Microsoft Visual C# 2008 Express Edition? I can't seem to get any web type controls or classes to work at all.. the below WebClient example always throws the exception "**Unable to connect to the remote server**".. and consequently I can't get the WebBrowse... | (**update** - I meant `proxycfg`, not `httpcfg`; `proxycfg -u` will do the import)
First, there is nothing special about "express" here. Second, contoso is a dummy url.
What OS are you on? And do you go through a proxy server? If so, you might need to configure the OS's http stack - `proxycfg` will do the job on XP, ... |
432,653 | <p>I've got this page which has a lot of data I don't need, as I've already clicked on it, but it repeats often so I have to visually look for blue. I realized this could be more efficient, and asked a CSS friend if I could set the element to hidden based on whether or not the containing link has been visited. Appare... | [
{
"answer_id": 432694,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 2,
"selected": false,
"text": "<p>1.You could use the a:visited css selector.</p>\n\n<pre><code>a:visited{\n display:none;\n}\n</code></pre>\n\n<p>And i... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got this page which has a lot of data I don't need, as I've already clicked on it, but it repeats often so I have to visually look for blue. I realized this could be more efficient, and asked a CSS friend if I could set the element to hidden based on whether or not the containing link has been visited. Apparently ... | 1.You could use the a:visited css selector.
```
a:visited{
display:none;
}
```
And it will hide visited links (at least in firefox).
2.If you want to remove the div and li above that, you would probably need to use a cookie and remember what links the user clicked.
So :
when a user clicks a link, put that li... |
432,658 | <p>There has to be a simple explanation for this.</p>
<p>I have a parent <code><div></code> tag containing a number of child divs that need to be hidden depending on their class. Problem is, I can't even seem to get a handle to my parent div. What on earth is the problem here? I'm going out of my gourd.</p>
... | [
{
"answer_id": 432663,
"author": "tanathos",
"author_id": 51295,
"author_profile": "https://Stackoverflow.com/users/51295",
"pm_score": 4,
"selected": true,
"text": "<p>The id of your div is wrong. In the html it must be <code>dasummary</code>, not <code>#dasummary</code>, so you can gra... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15609/"
] | There has to be a simple explanation for this.
I have a parent `<div>` tag containing a number of child divs that need to be hidden depending on their class. Problem is, I can't even seem to get a handle to my parent div. What on earth is the problem here? I'm going out of my gourd.
The jQuery code (snippet) looks li... | The id of your div is wrong. In the html it must be `dasummary`, not `#dasummary`, so you can grab it by jQuery with `$("#dasummary")` |
432,713 | <p>So I am trying to serve large files via a PHP script, they are not in a web accessible directory, so this is the best way I can figure to provide access to them.</p>
<p>The only way I could think of off the bat to serve this file is by loading it into memory (fopen, fread, ect.), setting the header data to the prop... | [
{
"answer_id": 432725,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 6,
"selected": true,
"text": "<p>You don't need to read the whole thing - just enter a loop reading it in, say, 32Kb chunks and sending it as output. Be... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366/"
] | So I am trying to serve large files via a PHP script, they are not in a web accessible directory, so this is the best way I can figure to provide access to them.
The only way I could think of off the bat to serve this file is by loading it into memory (fopen, fread, ect.), setting the header data to the proper MIME ty... | You don't need to read the whole thing - just enter a loop reading it in, say, 32Kb chunks and sending it as output. Better yet, use [fpassthru](http://php.net/fpassthru) which does much the same thing for you....
```
$name = 'mybigfile.zip';
$fp = fopen($name, 'rb');
// send the right headers
header("Content-Type: a... |
432,721 | <p>I am using JavaScript, jQuery and PHP. How do I limit the JavaScript function to execute once?</p>
<p>My MainJQuery file has Ajax. display.php execute for a while:</p>
<pre><code>....
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: function(data){
$("#response").html(da... | [
{
"answer_id": 432732,
"author": "andyk",
"author_id": 26721,
"author_profile": "https://Stackoverflow.com/users/26721",
"pm_score": 0,
"selected": false,
"text": "<p>Try disabling the Ajax trigger (link, button, etc.) after a successful call.</p>\n\n<p>Example of a trigger:</p>\n\n<pre>... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I am using JavaScript, jQuery and PHP. How do I limit the JavaScript function to execute once?
My MainJQuery file has Ajax. display.php execute for a while:
```
....
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: function(data){
$("#response").html(data);
//Here ... | In jQuery you can use the `.one()` function to bind a method that will execute only once. For example,
```
$("#someAnchorId").one("click", function(){
//Ajax method here
});
```
See [jQuery one help topic](http://docs.jquery.com/Events/one#typedatafn). |
432,729 | <p>I admit, I don't know too much about javascript, mostly I just "steal and modify" from Javascript.com and Dynamic Drive.<br>
I've run across a few scripts that call two .js files </p>
<pre><code><script type="text/javascript" src="lib/prototype.js">
</script>
<script type="text/javascript" src="sr... | [
{
"answer_id": 432738,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": false,
"text": "<p>It's often good to separate code with different concerns. Those two files might come from different places. Say prototype i... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53458/"
] | I admit, I don't know too much about javascript, mostly I just "steal and modify" from Javascript.com and Dynamic Drive.
I've run across a few scripts that call two .js files
```
<script type="text/javascript" src="lib/prototype.js">
</script>
<script type="text/javascript" src="src/aptabs.js">
</script>
``... | It's actually better performance wise to have them both in the same file- Depending on how your site is architected. The principle is to reduce the number of http requests, as each one carries some overhead.
That said, that's something best left to the very end of production. During development it's easier to have ev... |
432,784 | <p>I'm designing a site with a fixed repeated background but can't work out why it has one problem.</p>
<p>If you load the site in a small window, then scroll right, the background doesn't carry on and the background colour show's instead.</p>
<p>Any ideas?</p>
<p>Site is: <a href="http://new.focalpix.co.uk/" rel="n... | [
{
"answer_id": 432804,
"author": "rejj",
"author_id": 53867,
"author_profile": "https://Stackoverflow.com/users/53867",
"pm_score": 0,
"selected": false,
"text": "<p>you have defined body background: url in style.css line 13, but also defined rules for body background in the rule startin... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] | I'm designing a site with a fixed repeated background but can't work out why it has one problem.
If you load the site in a small window, then scroll right, the background doesn't carry on and the background colour show's instead.
Any ideas?
Site is: <http://new.focalpix.co.uk/>
CSS for the background is:
```
body ... | Try the following CSS:
```
body, html {
color:#fff;
background: #000 url(http://media.focalpix.co.uk/img/gradbackground.png) fixed repeat-x;
text-align:center;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstre... |
432,793 | <p>I have got my own custom UIViewController, which contains a UIScrollView with an UIImageView as it's subview. I would like to make the image to auto rotate when device orientation changes, but it doesn't seem to be working...</p>
<p>In the header file, I've got;</p>
<pre><code>@interface MyViewController : UIView... | [
{
"answer_id": 432802,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 1,
"selected": false,
"text": "<p>To make this kind of thing work in my application, I had to override</p>\n\n<pre><code>- (void) didRotateFromInterf... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53866/"
] | I have got my own custom UIViewController, which contains a UIScrollView with an UIImageView as it's subview. I would like to make the image to auto rotate when device orientation changes, but it doesn't seem to be working...
In the header file, I've got;
```
@interface MyViewController : UIViewController <UIScrollVi... | This may not be the right answer for you, because you don't specify the context that the UIViewController's in, but I just found an important gotcha in the Apple documentation that explains the similar problem I'm having.
>
> Tab bar controllers support a portrait
> orientation by default and do not
> rotate to a l... |
432,809 | <p>Let's say you have two tables, "Users" and "UserRoles". Here's how the two tables are structured (table - columns):</p>
<p>Users - UserID (int)</p>
<p>UserRoles - UserID (int), Role (string)</p>
<p>What I want is for my "User" class in my domain to have an IList of roles. How do I construct my Fluent NHibernate... | [
{
"answer_id": 432822,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>I beleive it would be</p>\n\n<pre><code>public User()\n {\n Id(x => x.UserID);\n HasMany<UserRoles>(x => ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | Let's say you have two tables, "Users" and "UserRoles". Here's how the two tables are structured (table - columns):
Users - UserID (int)
UserRoles - UserID (int), Role (string)
What I want is for my "User" class in my domain to have an IList of roles. How do I construct my Fluent NHibernate mapping to achieve this? | What you're looking for is a of a set of elements, which in standard hbm mapping is:
```
<set name="Roles" table="UserRoles">
<key column="UserID" />
<element column="Role" />
</set>
```
For Fluent NHibernate you can map this like so:
```
HasMany<string>(x => x.Roles)
.AsElement("Role");
```
You may need to... |
432,814 | <p>I'm using an application that embeds IE control to show content. I change that content to contain a <code><div contentEditable="True">Hello World</div></code> element. This works well and I can edit the content of this div, but pressing Enter is rejected with a beep.</p>
<p>When I add a textarea element... | [
{
"answer_id": 432822,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>I beleive it would be</p>\n\n<pre><code>public User()\n {\n Id(x => x.UserID);\n HasMany<UserRoles>(x => ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46635/"
] | I'm using an application that embeds IE control to show content. I change that content to contain a `<div contentEditable="True">Hello World</div>` element. This works well and I can edit the content of this div, but pressing Enter is rejected with a beep.
When I add a textarea element to that page the Enter key works... | What you're looking for is a of a set of elements, which in standard hbm mapping is:
```
<set name="Roles" table="UserRoles">
<key column="UserID" />
<element column="Role" />
</set>
```
For Fluent NHibernate you can map this like so:
```
HasMany<string>(x => x.Roles)
.AsElement("Role");
```
You may need to... |
432,818 | <p>I'm writing my first Java project.</p>
<p>I was wondering if it's possible to style the Swing components (set a background color, remove the borders from the buttons, etc.)</p>
| [
{
"answer_id": 432831,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 2,
"selected": false,
"text": "<p>It's certainly possible to do significant customisations because that is what the different look and feel options d... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21613/"
] | I'm writing my first Java project.
I was wondering if it's possible to style the Swing components (set a background color, remove the borders from the buttons, etc.) | If it's as simple as just changing the font, the background, the borders etc. Swing can do all these by default. I.e. for a JButton:
```
JButton aButton ...
aButton.setBackground(new Color(...));
aButton.setForeground(new Color(...));
aButton.setFont(new Font(...));
aButton.setBorder(null);
```
Have a look a... |
432,825 | <p>please i need come help i have a form of check boxes i want to save the name and value of the boxes that registered user selects into a table ,now i have registered users information saved in a table ,how the table that saves the registered users selection is to be created to have a relation with the table of users... | [
{
"answer_id": 432846,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 1,
"selected": false,
"text": "<p>You might like to reword your question so it's easier to read, here's what I think you meant:</p>\n\n<blockquote>\n <p>How ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | please i need come help i have a form of check boxes i want to save the name and value of the boxes that registered user selects into a table ,now i have registered users information saved in a table ,how the table that saves the registered users selection is to be created to have a relation with the table of users????... | Let's say you have table of users like this:
```
**users**
------------------------------
userid username etc...
1 billy ...
2 joe ...
```
Now you have to create table like this:
```
**users_checkboxes**
------------------------------
id user_id name value
1 1 newsletter... |
432,826 | <p>I came across a strange behaviour when doing some regular expressions in JavaScript today (Firefox 3 on Windows Vista).</p>
<pre><code>var str = "format_%A";
var format = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(str);
console.log(format); // ["format_%A", "%A"]
console.log(format[0]); // "format_undefined"
cons... | [
{
"answer_id": 432843,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 1,
"selected": false,
"text": "<p>Seems like <code>%A</code> somehow translates into the string <code>undefined</code>.</p>\n\n<p>Try escaping the <co... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I came across a strange behaviour when doing some regular expressions in JavaScript today (Firefox 3 on Windows Vista).
```
var str = "format_%A";
var format = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(str);
console.log(format); // ["format_%A", "%A"]
console.log(format[0]); // "format_undefined"
console.log(format[1]);... | This is because console.log() works like printf(). The first argument to console.log() is actually a format string which may be followed with additional arguments. %A is a placeholder. For example:
```
console.log("My name is %A", "John"); // My name is "John"
```
See [console.log() documentation](http://getfirebug.... |
432,829 | <p>Here's what I'm trying to do. I'm querying an XML file using LINQ to XML, which gives me an IEnumerable<code><T</code>> object, where T is my "Village" class, filled with the results of this query. Some results are duplicated, so I would like to perform a Distinct() on the IEnumerable object, like so:</p>
<pre><... | [
{
"answer_id": 432836,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 7,
"selected": true,
"text": "<p>The problem is with your <code>GetHashCode</code>. You should alter it to return the hash code of <code>AllianceName</code> ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2661653/"
] | Here's what I'm trying to do. I'm querying an XML file using LINQ to XML, which gives me an IEnumerable`<T`> object, where T is my "Village" class, filled with the results of this query. Some results are duplicated, so I would like to perform a Distinct() on the IEnumerable object, like so:
```
public IEnumerable<Vill... | The problem is with your `GetHashCode`. You should alter it to return the hash code of `AllianceName` instead.
```
int IEqualityComparer<Village>.GetHashCode(Village obj)
{
return obj.AllianceName.GetHashCode();
}
```
The thing is, if `Equals` returns `true`, the objects should have the same hash code which is n... |
432,832 | <p>Could you please explain me, what is the different between API functions <code>AllocConsole</code> and <code>AttachConsole(-1)</code> ? I mean if <code>AttachConsole</code> gets <code>ATTACH_PARENT_PROCESS(DWORD)-1</code>.</p>
| [
{
"answer_id": 432866,
"author": "Matthias van der Vlies",
"author_id": 53702,
"author_profile": "https://Stackoverflow.com/users/53702",
"pm_score": 0,
"selected": false,
"text": "<p>It has been a while since I used the winapi, but I looked up <a href=\"http://msdn.microsoft.com/en-us/l... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41956/"
] | Could you please explain me, what is the different between API functions `AllocConsole` and `AttachConsole(-1)` ? I mean if `AttachConsole` gets `ATTACH_PARENT_PROCESS(DWORD)-1`. | Well, the fundamental difference is:
* `AllocConsole()` will create a new console (and attach to it)
* `AttachConsole( ATTACH_PARENT_PROCESS /* -1 */)` will not create a new console, it will attach to the existing console of the parent process.
In the first case you get a whole new console window, in the second case,... |
432,842 | <p>How do you get the <a href="http://en.wikipedia.org/wiki/Exclusive_or" rel="noreferrer">logical xor</a> of two variables in Python?</p>
<p>For example, I have two variables that I expect to be strings. I want to test that only one of them contains a True value (is not None or the empty string):</p>
<pre><code>str1... | [
{
"answer_id": 432844,
"author": "Zach Hirsch",
"author_id": 50773,
"author_profile": "https://Stackoverflow.com/users/50773",
"pm_score": 9,
"selected": false,
"text": "<p>You can always use the definition of xor to compute it from other logical operations:</p>\n\n<pre><code>(a and not ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50773/"
] | How do you get the [logical xor](http://en.wikipedia.org/wiki/Exclusive_or) of two variables in Python?
For example, I have two variables that I expect to be strings. I want to test that only one of them contains a True value (is not None or the empty string):
```
str1 = raw_input("Enter string one:")
str2 = raw_inpu... | If you're already normalizing the inputs to booleans, then != is xor.
```
bool(a) != bool(b)
``` |
432,849 | <p>I'm interested in people's opinions on the pros and cons, or downright "hell no's" on designing websites in the browser, and moving away from Photoshop, Fireworks, etc.</p>
<p>I've been designing a relaunch for my website, and trying it out in the browser, and I'm not looking back. </p>
<p>For example (I use a 960... | [
{
"answer_id": 432860,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 3,
"selected": true,
"text": "<p>Are you saying you make wireframes of pages in the browser (by HTML/CSS) first and then apply a design? That's what I do (and... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53875/"
] | I'm interested in people's opinions on the pros and cons, or downright "hell no's" on designing websites in the browser, and moving away from Photoshop, Fireworks, etc.
I've been designing a relaunch for my website, and trying it out in the browser, and I'm not looking back.
For example (I use a 960px grid with 12 c... | Are you saying you make wireframes of pages in the browser (by HTML/CSS) first and then apply a design? That's what I do (and 37Signals [follows that thought](http://www.37signals.com/svn/posts/1061-why-we-skip-photoshop) too).
In my opinion it's good for developers to make static wireframes without touching Photosho... |
432,895 | <p>I have an ASP.NET RegularExpressionValidator that checks file extensions. Is there a quick way I can tell it to ignore the case of the extension without having to explicitly add the upper case variants to my validation expression?</p>
<pre><code>ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx... | [
{
"answer_id": 432898,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>Server-side, \"(?i)\" can be used, but this doesn't work client-side. See <a href=\"http://web.archive.org/web/2010... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] | I have an ASP.NET RegularExpressionValidator that checks file extensions. Is there a quick way I can tell it to ignore the case of the extension without having to explicitly add the upper case variants to my validation expression?
```
ValidationExpression="([^.]+[.](jpg|jpeg|gif|png|wpf|doc|docx|xls|xlsx ...
``` | Server-side, "(?i)" can be used, but this doesn't work client-side. See [here](http://web.archive.org/web/20100502214444/http://reflectedthought.com/thecoder/archive/2007/11/25/regularexpressionvalidator_ignore_case.aspx) for more discussion and workaround.
i.e. "...(?i)(jpg|jpeg|gif|png|wpf|..." |
432,913 | <p>I have a LINQ to SQL model setup - however in my app there are certain places where I want "friendly" column names for example:</p>
<p>"NameFirst" to be "First Name"
"AgencyName" to be "Agency"</p>
<p>Just looking for suggestions on where the best place/technique to create these mappings would be - without changin... | [
{
"answer_id": 432918,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Well, for most table use, you'd need <code>[DisplayName(...)]</code>, but this isn't easy to do without messing wi... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53873/"
] | I have a LINQ to SQL model setup - however in my app there are certain places where I want "friendly" column names for example:
"NameFirst" to be "First Name"
"AgencyName" to be "Agency"
Just looking for suggestions on where the best place/technique to create these mappings would be - without changing the model. Thes... | Well, for most table use, you'd need `[DisplayName(...)]`, but this isn't easy to do without messing with the partial classes. However, if you just want it available, you could declare your own attribute against the class, and add it there:
```
[MyDisplayName("NameFirst", "First Name")]
[MyDisplayName("AgencyName", "A... |
432,925 | <p>What I want to do is trigger a function from an extension/GM Script once a page in FireFox reloads/refreshes...</p>
<p>Picture this:</p>
<ol>
<li>I goto a webpage that asks for a username and password.</li>
<li>My code populates these values and submits the credentials</li>
<li>The webpage reloads and brings up a ... | [
{
"answer_id": 432941,
"author": "rkj",
"author_id": 37086,
"author_profile": "https://Stackoverflow.com/users/37086",
"pm_score": 0,
"selected": false,
"text": "<p>I do not think there is any way of preserving you JavaScript through refreshing the page in browser - it then loads it all ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53884/"
] | What I want to do is trigger a function from an extension/GM Script once a page in FireFox reloads/refreshes...
Picture this:
1. I goto a webpage that asks for a username and password.
2. My code populates these values and submits the credentials
3. The webpage reloads and brings up a page asking me to enter a pre-de... | *I've updated my answer to reflect your updated question below.*
As [rjk](https://stackoverflow.com/questions/432925/actions-on-page-reload-refresh-in-javascript#432941) mentioned, you can use the `onbeforeunload` event to perform an action when the page refreshes.
Here is a solution that should work with some potent... |
432,937 | <p>This has always bugged me. Perhaps someone with some hardcore knowledge of .NET internals can explain it to me.</p>
<p>Suppose I define an enum as follows:</p>
<pre><code>public enum Foo
{
Eenie = 1,
Meenie = 2,
Miney = 3,
Moe = 4
}
</code></pre>
<p>Now, also suppose that somewhere in my code, I have ... | [
{
"answer_id": 432942,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>If they are range checked, how would you have <code>[Flags]</code> enums and combine them using bitwise or? </p>\n\n<p>An e... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47580/"
] | This has always bugged me. Perhaps someone with some hardcore knowledge of .NET internals can explain it to me.
Suppose I define an enum as follows:
```
public enum Foo
{
Eenie = 1,
Meenie = 2,
Miney = 3,
Moe = 4
}
```
Now, also suppose that somewhere in my code, I have the following code:
```
int bar ... | The issue was performance. It is quite simple to have a checked enum for normal enums such as Color
```
enum Color {
Red,
Blue
}
```
The problem though is for enum's which are used as bit flags.
```
enum Property {
IsFirst = 0x1,
IsDefault = 0x2,
IsLastAccessed = 0x4
}
```
Having to do a bitwise check ... |
432,954 | <p>Is there anyway I can create a not in clause like I would have in SQL Server in <em>Linq to Entities</em>?</p>
| [
{
"answer_id": 433027,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 4,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>from p in db.Products\nwhere !theBadCategories.Contains(p.Category)\nselect p;\n</code></pre>\... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432954",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11755/"
] | Is there anyway I can create a not in clause like I would have in SQL Server in *Linq to Entities*? | If you are using an in-memory collection as your filter, it's probably best to use the negation of Contains(). Note that this can fail if the list is too long, in which case you will need to choose another strategy (see below for using a strategy for a fully DB-oriented query).
```
var exceptionList = new List<stri... |
432,985 | <p>I have a design issue that I would appreciate some input on.</p>
<p>I would like to make an calendar event system based on the following 4 tables:</p>
<p>tb_events</p>
<p>id,
date,
summary,</p>
<hr>
<p>tb_group</p>
<p>id,
name,
parent,
lineage,</p>
<hr>
<p>tb_course</p>
<p>id,
name,</p>
<hr>
<p>tb_staff</... | [
{
"answer_id": 433068,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 2,
"selected": true,
"text": "<p>If you do the naive approach of using 3 joins, you may get a huge performance hit. Ayende has some examples of using <... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17510/"
] | I have a design issue that I would appreciate some input on.
I would like to make an calendar event system based on the following 4 tables:
tb\_events
id,
date,
summary,
---
tb\_group
id,
name,
parent,
lineage,
---
tb\_course
id,
name,
---
tb\_staff
id,
name,
email,
---
The event class is currently set up... | If you do the naive approach of using 3 joins, you may get a huge performance hit. Ayende has some examples of using [MultiCriteria](http://ayende.com/Blog/archive/2007/05/20/NHibernate-Multi-Criteria.aspx) to bring performance back in line.
You can also go the subclasses route, if it makes sense. |
432,990 | <p>I'm on the final stretch of my first simple iPhone application. I'm building an "about" view, with credits/info/etc.</p>
<p>I am failing on the simplest thing: how can I embed hyperlinks into the text? I'm current using a UIView with a UILabel for the text.</p>
<p>I've looked on here, and the sample apps, but not ... | [
{
"answer_id": 433046,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 5,
"selected": true,
"text": "<p>Yep, use a UIWebView and put static HTML in it.</p>\n\n<p>Like so:</p>\n\n<pre><code>[myWebView loadHTMLString:@\"&l... | 2009/01/11 | [
"https://Stackoverflow.com/questions/432990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15290/"
] | I'm on the final stretch of my first simple iPhone application. I'm building an "about" view, with credits/info/etc.
I am failing on the simplest thing: how can I embed hyperlinks into the text? I'm current using a UIView with a UILabel for the text.
I've looked on here, and the sample apps, but not got anywhere. Sho... | Yep, use a UIWebView and put static HTML in it.
Like so:
```
[myWebView loadHTMLString:@"<html><head></head><body style=\"font-family: sans-serif;\"> .... </body></html>" baseURL:nil];
``` |
433,030 | <p>I got the code of a former employee. There are many calls to methods like:</p>
<pre><code>foo(val,...);
</code></pre>
<p>where </p>
<pre><code>void foo(String s,...) {
...
}
</code></pre>
<p>and val is an int.</p>
<p>Of course, I get an error.</p>
<p>As a workaround I pass ""+val to foo. I wonder if there is... | [
{
"answer_id": 433034,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, no. Without modifying the method definition, that's the quickest and easiest way to do it.</p>\n"
},
... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12860/"
] | I got the code of a former employee. There are many calls to methods like:
```
foo(val,...);
```
where
```
void foo(String s,...) {
...
}
```
and val is an int.
Of course, I get an error.
As a workaround I pass ""+val to foo. I wonder if there is a better way. | depending on the different types that are supposed to be passed as parameter, you could either accept an object and call .toString()
```
void foo(Object o){
String s=o.toString();
...
}
```
or overload foo for specific types
```
void foo(String s) {
...
}
void foo(int i){
foo(Integer.toString(i);
}
``... |
433,044 | <p>In a similar vain to the c# extension topic on SO It would be great if we could pull together a whole host of useful jQuery function extensions.</p>
<p><strong>Please Note the idea is to have short snippets of code not full blown well known plugins or ui widgets</strong></p>
| [
{
"answer_id": 433051,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 4,
"selected": true,
"text": "<pre><code>// Allows chainable logging\n// USAGE: $('#someDiv').hide().log('div hidden').addClass('someClass');\n// Demo : ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6440/"
] | In a similar vain to the c# extension topic on SO It would be great if we could pull together a whole host of useful jQuery function extensions.
**Please Note the idea is to have short snippets of code not full blown well known plugins or ui widgets** | ```
// Allows chainable logging
// USAGE: $('#someDiv').hide().log('div hidden').addClass('someClass');
// Demo : http://jsbin.com/odeke
jQuery.log = jQuery.fn.log = function (msg) {
if ( window.console && window.console.log ) {
console.log("%s: %o", msg, this);
}
return this;
};
``` |
433,057 | <p>I've deployed a C#.net 2.0 application to a Windows XP SP2 machine and during certain events a lot of the form controls turn to red X's. (Buttons, labels, etc...). I've pasted one of the procedures below that causes the problem. Since I can't reproduce it on the development machine, I can only guess that the problem... | [
{
"answer_id": 433092,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>Shot in the dark. How does ShowPleaseWait work? Does it try and touch any of the controls that are currently display... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've deployed a C#.net 2.0 application to a Windows XP SP2 machine and during certain events a lot of the form controls turn to red X's. (Buttons, labels, etc...). I've pasted one of the procedures below that causes the problem. Since I can't reproduce it on the development machine, I can only guess that the problem is... | The red cross is normally drawn by the .NET framework itself when you access a UI control from another thread than the UI thread.
Maybe there is an a cross-thread call inside of ShowPleaseWait or SearchExistingPersons. (Please post the code for those routines.)
The cross is also displayed when a resource is not avail... |
433,087 | <p>So, if you download a fresh Seaside image and run WAKom startOn: 80, then your fresh seaside respons on localhost/seaside/</p>
<p>This /seaside-folder annoys me, as I want to publish on <a href="http://www.seasidehosting.st" rel="nofollow noreferrer">seasidehosting</a>.</p>
<p>So! How do I remove this part of the ... | [
{
"answer_id": 433176,
"author": "nes1983",
"author_id": 52573,
"author_profile": "https://Stackoverflow.com/users/52573",
"pm_score": 1,
"selected": false,
"text": "<p>Aha! I found it in the seasidehosting faq. There it states: </p>\n\n<blockquote>\n <p>Go to the Seaside configuration ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52573/"
] | So, if you download a fresh Seaside image and run WAKom startOn: 80, then your fresh seaside respons on localhost/seaside/
This /seaside-folder annoys me, as I want to publish on [seasidehosting](http://www.seasidehosting.st).
So! How do I remove this part of the URL?
I want my app to be reachable under myapp.seasid... | Simply execute:
```
WADispatcher default setName: ''
``` |
433,105 | <p>When I used to program embedded systems and early 8/16-bit PCs (6502, 68K, 8086) I had a pretty good handle on exacly how long (in nanoseconds or microseconds) each instruction took to execute. Depending on family, one (or four) cycles equated to one "memory fetch", and without caches to worry about, you could guess... | [
{
"answer_id": 433113,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 3,
"selected": false,
"text": "<p>It's not that simple. The timing for your two instructions won't help you gauge performance of a larger set of inst... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | When I used to program embedded systems and early 8/16-bit PCs (6502, 68K, 8086) I had a pretty good handle on exacly how long (in nanoseconds or microseconds) each instruction took to execute. Depending on family, one (or four) cycles equated to one "memory fetch", and without caches to worry about, you could guess ti... | Modern processors such as Core 2 Duo that you mention are both *superscalar* and *pipelined*. They have multiple execution units per core and are actually working on more than one instruction at a time per core; this is the superscalar part. The pipelined part means that there is a latency from when an instruction is r... |
433,162 | <p>I have some stuff in settings.py that I'd like to be able to access from a template, but I can't figure out how to do it. I already tried</p>
<pre><code>{{CONSTANT_NAME}}
</code></pre>
<p>but that doesn't seem to work. Is this possible?</p>
| [
{
"answer_id": 433209,
"author": "bchhun",
"author_id": 48500,
"author_profile": "https://Stackoverflow.com/users/48500",
"pm_score": 9,
"selected": false,
"text": "<p>If it's a value you'd like to have for every request & template, using a <a href=\"https://docs.djangoproject.com/en... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | I have some stuff in settings.py that I'd like to be able to access from a template, but I can't figure out how to do it. I already tried
```
{{CONSTANT_NAME}}
```
but that doesn't seem to work. Is this possible? | Django provides access to certain, frequently-used settings constants to the template such as `settings.MEDIA_URL` and some of the language settings if you use django's built in generic views or pass in a context instance keyword argument in the `render_to_response` shortcut function. Here's an example of each case:
`... |
433,164 | <p>Please consider the following scenario:</p>
<pre><code>
map(T,S*) & GetMap(); //Forward decleration
map(T, S*) T2pS = GetMap();
for(map(T, S*)::iterator it = T2pS.begin(); it != T2pS.end(); ++it)
{
if(it->second != NULL)
{
delete it->second;
it->second = NULL;
}
T2pS.erase(it);
... | [
{
"answer_id": 433183,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://en.wikibooks.org/wiki/C%2B%2B_Programming/STL#Iteration_over_a_Container\" rel=\"nofollow noreferrer\">Se... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46418/"
] | Please consider the following scenario:
```
map(T,S*) & GetMap(); //Forward decleration
map(T, S*) T2pS = GetMap();
for(map(T, S*)::iterator it = T2pS.begin(); it != T2pS.end(); ++it)
{
if(it->second != NULL)
{
delete it->second;
it->second = NULL;
}
T2pS.erase(it);
//In VS2005, ... | Yes, if you erase an iterator, that iterator gets a so-called *singular value*, which means it doesn't belong to any container anymore. You can't increment, decrement or read it out/write to it anymore. The correct way to do that loop is:
```
for(map<T, S*>::iterator it = T2pS.begin(); it != T2pS.end(); T2pS.erase(it+... |
433,188 | <p>When a caller is higher in the stack, what does this mean? For example, lets say I start a program, a form loads up (we'll call this a), then this form calls another form (b). The called form will be at the top of the stack, so if this form called form a, will this be a caller higher in the stack making a call to so... | [
{
"answer_id": 433199,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>You need to distinguish between the object making the call (if any), the target of the call, and the method being cal... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | When a caller is higher in the stack, what does this mean? For example, lets say I start a program, a form loads up (we'll call this a), then this form calls another form (b). The called form will be at the top of the stack, so if this form called form a, will this be a caller higher in the stack making a call to somet... | I think you have the wrong impression of the call stack. The call stach is just a "list" of the functions that have been called. When ou have a call chain like you describe, a calls b which calls a, your stack is just:
```
a.second
b.first
a.first
```
You can't really call "down" to something. You make another call,... |
433,194 | <p>I write a lot of short throwaway programs, and one of the things I find myself doing repeatedly is typing out code like</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main(void){
}
</code></pre>
<p>To save some tendon hits I was wondering if it was possible to insert a simple template abov... | [
{
"answer_id": 433234,
"author": "Tom Dunham",
"author_id": 6402,
"author_profile": "https://Stackoverflow.com/users/6402",
"pm_score": 5,
"selected": true,
"text": "<p>Put somthing like this in <code>.emacs</code></p>\n\n<pre><code>(define-skeleton c-throwaway\n \"Throwaway C skeleton\... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45620/"
] | I write a lot of short throwaway programs, and one of the things I find myself doing repeatedly is typing out code like
```
#include <stdio.h>
#include <stdlib.h>
int main(void){
}
```
To save some tendon hits I was wondering if it was possible to insert a simple template above whenever I create a buffer with the ... | Put somthing like this in `.emacs`
```
(define-skeleton c-throwaway
"Throwaway C skeleton"
nil
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"\n"
"int main(void){\n"
"\n"
"}\n")
```
And eval (`C-x C-e`) it. That'll give you a
function (`c-throwaway`) that inserts your template.
To get this insertin... |
433,195 | <p>I've been thinking about batch reads and writes in a RESTful environment, and I think I've come to the realization that I have broader questions about HTTP caching. (Below I use commas (",") to delimit multiple record IDs, but that detail is not particular to the discussion.)</p>
<p>I started with this problem:</p... | [
{
"answer_id": 433206,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": false,
"text": "<p>HTTP protocol supports a request type called \"If-Modified-Since\" which basically allows the caching server to ask the... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I've been thinking about batch reads and writes in a RESTful environment, and I think I've come to the realization that I have broader questions about HTTP caching. (Below I use commas (",") to delimit multiple record IDs, but that detail is not particular to the discussion.)
I started with this problem:
1. Single `G... | Cache servers are supposed to invalidate the entity referred to by the URI on receipt of a PUT (but as you've noticed, this doesn't cover all cases).
Aside from this you could use cache control headers on your responses to limit or prevent caching, and try to process request headers that ask if the URI has been modif... |
433,203 | <p>How do I add/subtract/etc. time values in Ruby? For example, how would I add the following times?</p>
<p>00:00:59 + 00:01:43 + 00:20:15 = ?</p>
| [
{
"answer_id": 10820666,
"author": "David",
"author_id": 429886,
"author_profile": "https://Stackoverflow.com/users/429886",
"pm_score": 0,
"selected": false,
"text": "<p>Kind of ugly, but you could use DateTime.parse(each_interval) & calculate the number of seconds in each. Like thi... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32154/"
] | How do I add/subtract/etc. time values in Ruby? For example, how would I add the following times?
00:00:59 + 00:01:43 + 00:20:15 = ? | Use ActiveSupport, which has a ton of built-in date extensions.
```
require 'active_support/core_ext'
t1 = "#{Date.today} 00:00:59".to_time
t2 = "#{Date.today} 00:01:43".to_time
t3 = "#{Date.today} 00:20:15".to_time
t1.since(t2.seconds_since_midnight+t3.seconds_since_midnight)
```
or, if you don't care about the dat... |
433,211 | <p>I'm currently writing a quick solution for Euler Problem #4 where one must find the largest palindromic number from the product of two 3-digit numbers.</p>
<p>To identify if a number is palindromic, you would obviously compare a reverse of the number with the original.</p>
<p><strong>Since C# doesn't have a built ... | [
{
"answer_id": 433227,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 1,
"selected": false,
"text": "<pre><code>public static String Reverse(string input) {\n var length = input.Length;\n var buffer = new char[length];\n... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | I'm currently writing a quick solution for Euler Problem #4 where one must find the largest palindromic number from the product of two 3-digit numbers.
To identify if a number is palindromic, you would obviously compare a reverse of the number with the original.
**Since C# doesn't have a built in String.Reverse() met... | I think it might be faster to do the comparison in-place. If you reverse the string, you've got to:
1. Instantiate a new string object (or StringBuffer object)
2. Copy the data (in reverse) from the first string to the new string
3. Do your comparison.
If you perform the comparison in place, you do only the last step... |
433,218 | <p>Spy++ is a tool for windows that let the user spy on windows attributes, child windows and the message that it will process. It is handy utility to debugging UI related code.</p>
| [
{
"answer_id": 433383,
"author": "Terry G Lorber",
"author_id": 809,
"author_profile": "https://Stackoverflow.com/users/809",
"pm_score": 1,
"selected": false,
"text": "<p>I've seen a \"spy\" feature from <a href=\"http://www.froglogic.com/pg?id=Products&category=squish&sub=overv... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5999/"
] | Spy++ is a tool for windows that let the user spy on windows attributes, child windows and the message that it will process. It is handy utility to debugging UI related code. | Back then, i tested my middle mouse button using a tool called `xev`. It creates a new window, which you can send events (by clicking on it, or pressing buttons) which are catched and printed on stdout. According to a comment by jpalecek, it can also be used to watch other windows, instead of a new one. The following w... |
433,220 | <p>I have a question concerning this code which I want to run on QNX:</p>
<pre><code>class ConcreteThread : public Thread
{
public:
ConcreteThread(int test)
{
testNumber = test;
}
void *start_routine()
{
for(int i = 0; i < 10; i++)
{
sleep(1);
c... | [
{
"answer_id": 433269,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 3,
"selected": true,
"text": "<p>Note 1: If you only have 1 processor the code can only be done sequentially no matter how many threads you create. E... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a question concerning this code which I want to run on QNX:
```
class ConcreteThread : public Thread
{
public:
ConcreteThread(int test)
{
testNumber = test;
}
void *start_routine()
{
for(int i = 0; i < 10; i++)
{
sleep(1);
cout << testNumber... | Note 1: If you only have 1 processor the code can only be done sequentially no matter how many threads you create. Each thread is given a slice of processor time before it is swapped out for the next threads.
Note 2: If the main thread exits pthreads will kill all child threads before they have a chance to execute.
N... |
433,221 | <p>I originally had an array[1..1000] that was defined as a global variable.
But now I need that to be n, not 1000 and I don't find out n until later.
I know what n is before I fill the array up but I need it to be global therefore need a way to define the size of a global array at run time.</p>
<p>Context is filling ... | [
{
"answer_id": 433311,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 8,
"selected": true,
"text": "<p>As of Delphi 4, Delphi supports <strong>dynamic arrays</strong>. You can modify their sizes at run time and they wil... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53915/"
] | I originally had an array[1..1000] that was defined as a global variable.
But now I need that to be n, not 1000 and I don't find out n until later.
I know what n is before I fill the array up but I need it to be global therefore need a way to define the size of a global array at run time.
Context is filling an array w... | As of Delphi 4, Delphi supports **dynamic arrays**. You can modify their sizes at run time and they will retain the data you stored in other elements at the old size. They can hold elements of any homogeneous type, including records and other arrays. You can declare a dynamic array the same as you declare normal, "stat... |
433,251 | <p>This is easy for non-inlines. Just override the following in the your admin.py AdminOptions:</p>
<pre><code>def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'photo':
kwargs['widget'] = AdminImageWidget()
return db_field.formfield(**kwargs)
return super(NewsOptions,sel... | [
{
"answer_id": 434129,
"author": "Carl Meyer",
"author_id": 3207,
"author_profile": "https://Stackoverflow.com/users/3207",
"pm_score": 5,
"selected": true,
"text": "<p>It works exactly the same way. The TabularInline and StackedInline classes also have a formfield_for_dbfield method, a... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45955/"
] | This is easy for non-inlines. Just override the following in the your admin.py AdminOptions:
```
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'photo':
kwargs['widget'] = AdminImageWidget()
return db_field.formfield(**kwargs)
return super(NewsOptions,self).formfield_f... | It works exactly the same way. The TabularInline and StackedInline classes also have a formfield\_for\_dbfield method, and you override it the same way in your subclass. |
433,261 | <p>I'm having an annoying problem with my iPhone app. Whenever I set the optimization level to something other than "None", I get computation errors. This only happens in when building for the iPhone SDK (the iPhone Simulator is always fine).</p>
<p>I wouldn't mind disabling optimizations in release mode, but the ap... | [
{
"answer_id": 433271,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": true,
"text": "<p>Yes, that's entirely possible. GCC has an <a href=\"http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9936/"
] | I'm having an annoying problem with my iPhone app. Whenever I set the optimization level to something other than "None", I get computation errors. This only happens in when building for the iPhone SDK (the iPhone Simulator is always fine).
I wouldn't mind disabling optimizations in release mode, but the application is... | Yes, that's entirely possible. GCC has an [attribute](http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes) for that:
```
/* disable optimization for this function */
void my_function(void) __attribute__((optimize(0)));
void my_function(void) {
/* ... */
}
```
Sets the optimization lev... |
433,263 | <p>I couldnt able to mock the protected varibale defined in the superclass.i could able to mock the protected method in superclass but couldnt to mock the protected variable in to the subclass ,wherein am writing the testcase for subclass,Please if anybody out there has any soluton for it .please reply.</p>
<p>Thanks
... | [
{
"answer_id": 1020701,
"author": "Rogério",
"author_id": 2326914,
"author_profile": "https://Stackoverflow.com/users/2326914",
"pm_score": 1,
"selected": false,
"text": "<p><b>All</b> mocking tools only mock methods.</p>\n\n<p>JMockit also has utility methods that provide access to non-... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I couldnt able to mock the protected varibale defined in the superclass.i could able to mock the protected method in superclass but couldnt to mock the protected variable in to the subclass ,wherein am writing the testcase for subclass,Please if anybody out there has any soluton for it .please reply.
Thanks
Shashi | You can do this using the `Deencapsulation.setField` method. For example:
```
@Test public void staticVarOverride() {
MyClass myClass = new MyClass();
Deencapsulation.setField(MyClass.class, "myStatic", 2);
// Assertions, verifications go here.
}
```
This will set the value of the static variable `myStat... |
433,264 | <p>I want to use an existing <strong>user</strong> and <strong>user group</strong> table that the forums use. I would prefer not to have to add any additional tables (other than what the forum already has).</p>
<p>I will be using MS SQL.</p>
<p>The forums are PHP which is why I want the .net site to handle all of the... | [
{
"answer_id": 1020701,
"author": "Rogério",
"author_id": 2326914,
"author_profile": "https://Stackoverflow.com/users/2326914",
"pm_score": 1,
"selected": false,
"text": "<p><b>All</b> mocking tools only mock methods.</p>\n\n<p>JMockit also has utility methods that provide access to non-... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469/"
] | I want to use an existing **user** and **user group** table that the forums use. I would prefer not to have to add any additional tables (other than what the forum already has).
I will be using MS SQL.
The forums are PHP which is why I want the .net site to handle all of the logic. The forum will use its own PHP logi... | You can do this using the `Deencapsulation.setField` method. For example:
```
@Test public void staticVarOverride() {
MyClass myClass = new MyClass();
Deencapsulation.setField(MyClass.class, "myStatic", 2);
// Assertions, verifications go here.
}
```
This will set the value of the static variable `myStat... |
433,274 | <p>I've run into a really strange bug, that I'm hoping someone can explain. I have a simple <code>std::vector<V3x></code>, where <code>V3x</code> is a 3d vector (the linear algebra kind.) The following code causes a <code>std::length_error</code> exception to be thrown:</p>
<pre><code>std::vector<V3x> vert... | [
{
"answer_id": 433309,
"author": "Dustin Getz",
"author_id": 20003,
"author_profile": "https://Stackoverflow.com/users/20003",
"pm_score": 0,
"selected": false,
"text": "<p>posted code is correct and you can assume that std::vector has no bugs. replicate the exception in the purest poss... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1370/"
] | I've run into a really strange bug, that I'm hoping someone can explain. I have a simple `std::vector<V3x>`, where `V3x` is a 3d vector (the linear algebra kind.) The following code causes a `std::length_error` exception to be thrown:
```
std::vector<V3x> vertices;
int vertexCount = computeVertexCount();
vertices.resi... | The value 3435973836 is significant. In hex, that's 0xcccccccc. That's the value assigned to local variables in Debug mode by the stack frame initialization code. When you see it back while debugging, you'd say "ah, variable not initialized". Maybe that gets you a bit closer to solving this.
You mention DLL. That's re... |
433,276 | <p>I want to split a directory from a large Subversion repository to a repository of its own, and keep the history of the files in that directory.</p>
<p>I tried the regular way of doing it first</p>
<pre><code>svnadmin dump /path/to/repo > largerepo.dump
cat largerepo.dump | svndumpfilter include my/directory >... | [
{
"answer_id": 433304,
"author": "ng.",
"author_id": 21896,
"author_profile": "https://Stackoverflow.com/users/21896",
"pm_score": 2,
"selected": false,
"text": "<p>Why not replicate the entire repository, dump it in to a new one. Then branch out the trunk, delete the head and merge the ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40657/"
] | I want to split a directory from a large Subversion repository to a repository of its own, and keep the history of the files in that directory.
I tried the regular way of doing it first
```
svnadmin dump /path/to/repo > largerepo.dump
cat largerepo.dump | svndumpfilter include my/directory >mydir.dump
```
but that ... | This problem occurs when one of the directories/files included by svndumpfilter originally was copied or moved from a section of the tree that is not being included.
To solve the problem use this script: [svndumpfilter3](http://furius.ca/pubcode/pub/conf/bin/svndumpfilter3.html) |
433,291 | <p>What is the current status of TagLib# (TagLib sharp)?</p>
<p>The official homepage www.taglib-sharp.com (link removed due to the NSFW nature of the new site that's parked at that address. -BtL) doesn't exist anymore!</p>
<p>I've found the project on <a href="http://www.ohloh.net/p/5598" rel="nofollow noreferrer">o... | [
{
"answer_id": 3944191,
"author": "Hewins",
"author_id": 477024,
"author_profile": "https://Stackoverflow.com/users/477024",
"pm_score": 2,
"selected": false,
"text": "<p>Looks like it moved here: <a href=\"http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html\" rel... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50890/"
] | What is the current status of TagLib# (TagLib sharp)?
The official homepage www.taglib-sharp.com (link removed due to the NSFW nature of the new site that's parked at that address. -BtL) doesn't exist anymore!
I've found the project on [ohloh](http://www.ohloh.net/p/5598) where the old homepage is still linked. Also ... | The page at Novell (<http://www.novell.com/products/linuxpackages/opensuse11.1/taglib-sharp.html>) is no longer updated.
The source code is now hosted at <https://github.com/mono/taglib-sharp> and the best way to install and use the latest version is using NuGet. Open the Package Manager Console in Visual Studio and ... |
433,294 | <p>I have a following model:</p>
<pre><code>class Car(models.Model):
make = models.CharField(max_length=40)
mileage_limit = models.IntegerField()
mileage = models.IntegerField()
</code></pre>
<p>I want to select all cars where mileage is less than mileage_limit, so in SQL it would be something like:</p>
<pr... | [
{
"answer_id": 433321,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 4,
"selected": true,
"text": "<p>You can't do this right now without custom SQL. The django devs are working on an F() function that would make i... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26592/"
] | I have a following model:
```
class Car(models.Model):
make = models.CharField(max_length=40)
mileage_limit = models.IntegerField()
mileage = models.IntegerField()
```
I want to select all cars where mileage is less than mileage\_limit, so in SQL it would be something like:
```
select * from car where m... | You can't do this right now without custom SQL. The django devs are working on an F() function that would make it possible: [#7210 - F() syntax, design feedback required.](http://groups.google.com/group/django-developers/browse_thread/thread/c8cff7e5e16c692a#) |
433,302 | <p>I've got a multidimensional associative array which includes an elements like</p>
<pre><code>$data["status"]
$data["response"]["url"]
$data["entry"]["0"]["text"]
</code></pre>
<p>I've got a strings like:</p>
<pre><code>$string = 'data["status"]';
$string = 'data["response"]["url"]';
$string = 'data["entry"]["0"][... | [
{
"answer_id": 433313,
"author": "MattBelanger",
"author_id": 655,
"author_profile": "https://Stackoverflow.com/users/655",
"pm_score": 0,
"selected": false,
"text": "<p>You would access them like:</p>\n\n<pre><code>print $$string;\n</code></pre>\n"
},
{
"answer_id": 433316,
... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6305/"
] | I've got a multidimensional associative array which includes an elements like
```
$data["status"]
$data["response"]["url"]
$data["entry"]["0"]["text"]
```
I've got a strings like:
```
$string = 'data["status"]';
$string = 'data["response"]["url"]';
$string = 'data["entry"]["0"]["text"]';
```
How can I convert the... | Quick and dirty:
```
echo eval('return $'. $string . ';');
```
Of course the input string would need to be be sanitized first.
If you don't like quick and dirty... then this will work too and it doesn't require eval which makes even me cringe.
It does, however, make assumptions about the string format:
```
<?php... |
433,312 | <p>The black lines are awful, how can I get rid of them? I want only the colored surfaces.</p>
| [
{
"answer_id": 433560,
"author": "Ian Hopkinson",
"author_id": 19172,
"author_profile": "https://Stackoverflow.com/users/19172",
"pm_score": 4,
"selected": false,
"text": "<p>The shading command is your friend:</p>\n\n<p>shading flat - gives you the surface without mesh lines</p>\n\n<p>s... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | The black lines are awful, how can I get rid of them? I want only the colored surfaces. | Another choice is to set the *edgeColor* and/or *lineStyle* properties of the surface handle object to *none*.
```
>> hSurf = surf(X,Y,Z,'EdgeColor','none','LineStyle','none','FaceLighting','phong');
``` |
433,326 | <p>Usually when I plot in <a href="http://en.wikipedia.org/wiki/MATLAB" rel="noreferrer">MATLAB</a>, it always draws on the same figure. How do I make it draw in a new figure? </p>
<p>I know it is pretty elementary, but I'm not finding it using Google Search.</p>
| [
{
"answer_id": 433330,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 7,
"selected": true,
"text": "<pre><code>figure;\nplot(something);\n</code></pre>\n\n<p>or</p>\n\n<pre><code>figure(2);\nplot(something);\n..... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | Usually when I plot in [MATLAB](http://en.wikipedia.org/wiki/MATLAB), it always draws on the same figure. How do I make it draw in a new figure?
I know it is pretty elementary, but I'm not finding it using Google Search. | ```
figure;
plot(something);
```
or
```
figure(2);
plot(something);
...
figure(3);
plot(something else);
...
```
etc. |
433,337 | <p>How can I set the maximum amount of characters in a <code>UITextField</code> on the iPhone SDK when I load up a <code>UIView</code>?</p>
| [
{
"answer_id": 433402,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 4,
"selected": false,
"text": "<p>You can't do this directly - <code>UITextField</code> has no <em>maxLength</em> attribute, but you can set the <code>UIT... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] | How can I set the maximum amount of characters in a `UITextField` on the iPhone SDK when I load up a `UIView`? | While the `UITextField` class has no max length property, it's relatively simple to get this functionality by setting the text field's `delegate` and implementing the following delegate method:
**Objective-C**
```
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementStrin... |
433,358 | <p>What is the code formating option to indent as:</p>
<pre><code>Log.w(TAG, String.format(
"Upgrading database from version %s to %s which will destroy all old data",
oldVersion, newVersion));
</code></pre>
<p>instead of as:</p>
<p>Log
.w(
TAG,
String
.format(
"Upgrading database from versi... | [
{
"answer_id": 433380,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think I've touched my indentation settings and they sure format it like you'd want it to (just tried it). Maybe you... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | What is the code formating option to indent as:
```
Log.w(TAG, String.format(
"Upgrading database from version %s to %s which will destroy all old data",
oldVersion, newVersion));
```
instead of as:
Log
.w(
TAG,
String
.format(
"Upgrading database from version %s to %s which will destroy all old data",... | I don't think you'll get what you want in the first block, as `Log.w(` and `String.format(` are probably governed by the same formatting rules.
However, you can go to Window->Preferences->Java->Code Style->Formatter and choose to edit. The setting you want to change is on the Line Wrapping tab. If you set Function Cal... |
433,371 | <p>Maths101 question - does anyone know how to calculate an ellipse (width/height) that will enclose a given rectangle. Obviously there is no single ellipse - I'm after an algorithm that will give me various width/height combinations - or perhaps the smallest area of ellipse? It's for a GUI, so an aesthetically pleasin... | [
{
"answer_id": 433426,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 5,
"selected": false,
"text": "<p>If you give your ellipse the same aspect ratio as the rectangle, you can work on the basis that what you want is a circle... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21207/"
] | Maths101 question - does anyone know how to calculate an ellipse (width/height) that will enclose a given rectangle. Obviously there is no single ellipse - I'm after an algorithm that will give me various width/height combinations - or perhaps the smallest area of ellipse? It's for a GUI, so an aesthetically pleasing r... | The equation for a ellipse centered in the origin is
```
(x/A)^2 + (y/B)^2 = 1
```
Now if you want to enclose a rectangle of MxN with a eclipse you can move its center to the origin of coordinates. The top right coordinates are `(M/2,N/2)`, replacing in the ellipse equation you have a formula you can use to solve B ... |
433,372 | <p>I would like to use <code>Dictionary</code> as <code>TKey</code> in another <code>Dictionary</code>. Something similar to python. I tried this but it gives me errors.</p>
<pre><code>Dictionary<Dictionary<string, string>, int> dict = new Dictionary<Dictionary<string, string>, int>();
Dicti... | [
{
"answer_id": 433381,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 2,
"selected": false,
"text": "<p>It's because the \"dict[\"abc\"] is not dictionary, but \"string\".</p>\n\n<p>The correct, what you asked is:</p>\n\n<pre>... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25587/"
] | I would like to use `Dictionary` as `TKey` in another `Dictionary`. Something similar to python. I tried this but it gives me errors.
```
Dictionary<Dictionary<string, string>, int> dict = new Dictionary<Dictionary<string, string>, int>();
Dictionary<string, string> dict2 = new Dictionary<string, string>();
dict2["... | What error is it giving you? Is it complaining about your missing bracket on line 4?
Line 4 looks like it should be:
```
dict[dict["abc"]] = 20;
```
However, you probably mean this, since "abc" is not a key of dict:
```
dict[dict2["abc"]] = 20;
```
But `dict2["abc"]` is a `string`, when the key of dict is suppos... |
433,379 | <p>I'm trying to deploy to a slicehost slice using this config/deploy/production.rb file. I'm clueless & haven't used capistrano before now. Here are the steps I followed. Sorry but I'm completely new to capistrano. It keeps asking for my password (have set up passwordless SSH), and throwing this error: </p>
<... | [
{
"answer_id": 433387,
"author": "Rob",
"author_id": 3542,
"author_profile": "https://Stackoverflow.com/users/3542",
"pm_score": 0,
"selected": false,
"text": "<p><strong>\"SocketError: getaddrinfo: Name or service not known\"</strong> implies some sort of problem resolving or connecting... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33287/"
] | I'm trying to deploy to a slicehost slice using this config/deploy/production.rb file. I'm clueless & haven't used capistrano before now. Here are the steps I followed. Sorry but I'm completely new to capistrano. It keeps asking for my password (have set up passwordless SSH), and throwing this error:
```
(SocketError... | I think the problem would be either
* It can't resolve your hostname
* You typo wrong `domain` value
Just in case, have you tried to set the `domain` value to be your server's IP address instead? |
433,388 | <p>I've got a book on python recently and it's got a chapter on Regex, there's a section of code which I can't really understand. Can someone explain exactly what's going on here (this section is on Regex groups)?</p>
<pre><code>>>> my_regex = r'(?P<zip>Zip:\s*\d\d\d\d\d)\s*(State:\s*\w\w)'
>>>... | [
{
"answer_id": 433416,
"author": "tristan",
"author_id": 53933,
"author_profile": "https://Stackoverflow.com/users/53933",
"pm_score": 2,
"selected": false,
"text": "<p>The <strong>search</strong> method will return an object containing the results of your regex pattern. </p>\n\n<p><stro... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | I've got a book on python recently and it's got a chapter on Regex, there's a section of code which I can't really understand. Can someone explain exactly what's going on here (this section is on Regex groups)?
```
>>> my_regex = r'(?P<zip>Zip:\s*\d\d\d\d\d)\s*(State:\s*\w\w)'
>>> addrs = "Zip: 10010 State: NY"
>>> y ... | regex definition:
```
(?P<zip>...)
```
Creates a named group "zip"
```
Zip:\s*
```
Match "Zip:" and zero or more whitespace characters
```
\d
```
Match a digit
```
\w
```
Match a word character [A-Za-z0-9\_]
```
y.groupdict('zip')
```
The groupdict method returns a dictionary with named groups as keys an... |
433,392 | <p>How do I use prepared statements in SQlite in Android?</p>
| [
{
"answer_id": 436162,
"author": "jasonhudgins",
"author_id": 24590,
"author_profile": "https://Stackoverflow.com/users/24590",
"pm_score": 6,
"selected": true,
"text": "<p>I use prepared statements in Android all the time, it's quite simple:</p>\n<pre class=\"lang-java prettyprint-overr... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | How do I use prepared statements in SQlite in Android? | I use prepared statements in Android all the time, it's quite simple:
```java
SQLiteDatabase db = dbHelper.getWritableDatabase();
SQLiteStatement stmt = db.compileStatement("INSERT INTO Country (code) VALUES (?)");
stmt.bindString(1, "US");
stmt.executeInsert();
``` |
433,406 | <p>I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them.</p>
<p>Is there a way to do that?</p>
<p>I am familiar with the methods in Java Runtime object, but its not clear what they really deliver. </p>
... | [
{
"answer_id": 433473,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 4,
"selected": true,
"text": "<p>Try this ones:</p>\n\n<pre><code>MemoryMXBean mem = ManagementFactory.getMemoryMXBean();\nmem.getHeapMemoryUsage... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | I am trying to find out programatically the max permgen and max heap size with which a the JVM for my program has been invoked, not what is currently available to them.
Is there a way to do that?
I am familiar with the methods in Java Runtime object, but its not clear what they really deliver.
Alternatively, is the... | Try this ones:
```
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
mem.getHeapMemoryUsage().getUsed();
mem.getNonHeapMemoryUsage().getUsed();
```
But they only offer snapshot data, not a cummulated value. |
433,409 | <p>I want to get hold of the mouse position in a timeout callback.</p>
<p>As far as I can tell, this can't be done directly. One work around might be to set an onmousemove event on document.body and to save this position, fetching later. This would be rather expensive however, and isn't the cleanest of approaches.</p>... | [
{
"answer_id": 433422,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>The direct answer is <strong>no</strong> but as you correctly say, you can attach events to everything and poll accordingly... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47741/"
] | I want to get hold of the mouse position in a timeout callback.
As far as I can tell, this can't be done directly. One work around might be to set an onmousemove event on document.body and to save this position, fetching later. This would be rather expensive however, and isn't the cleanest of approaches. | I think you'll have to do the same thing as @Oli, but then if you're using jQuery, it would be much more easier.
<http://docs.jquery.com/Tutorials:Mouse_Position>
```
<script type="text/javascript">
jQuery(document).ready(function(){
$().mousemove(function(e){
$('#status').html(e.pageX +', '+ e.pageY);
});
}... |
433,437 | <p>i have an sql query that selects a bunch of data. I would also like to get the number of records selected by the query (before i limit it). All the examples i have seen of the count statment duplicated the select. My select statment is about 50 lines long and i would rarther not duplicate it.</p>
<p>Thanks</p>
| [
{
"answer_id": 433460,
"author": "Deniss Kozlovs",
"author_id": 53948,
"author_profile": "https://Stackoverflow.com/users/53948",
"pm_score": 1,
"selected": false,
"text": "<p>Yes.\n<a href=\"http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows\" rel=\"no... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i have an sql query that selects a bunch of data. I would also like to get the number of records selected by the query (before i limit it). All the examples i have seen of the count statment duplicated the select. My select statment is about 50 lines long and i would rarther not duplicate it.
Thanks | Your question would be easier to answer if you could give us an example SQL statement, however, from what you have said so far, the following should be correct:
```
Select Columns, Count(Distinct Value) From Table Where x=y Group By Columns
``` |
433,450 | <p>What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++).</p>
<p>Also, what is a leaky abstraction?</p>
<p>Thanks</p>
| [
{
"answer_id": 433476,
"author": "Jasper Bekkers",
"author_id": 31486,
"author_profile": "https://Stackoverflow.com/users/31486",
"pm_score": 3,
"selected": false,
"text": "<p>A fluent interface a term Eric Evans coined and it's just another name for method chaining. Martin Fowler wrote ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++).
Also, what is a leaky abstraction?
Thanks | A fluent interface is an API that allows you to write code that reads more or less like normal English. For example:
```
Find.All.Questions(Where.IsAnswered == true);
```
Method-chaining is usually used as part of the implementation, but there is more to it than that. To quote [Fowler](http://martinfowler.com/bliki/... |
433,461 | <p>As I am currently doing <a href="https://stackoverflow.com/questions/409087/creating-a-web-server-in-pure-c">this project</a> in only C, I've up untill this point only used my webserver as a single threaded application. However, I dont want that anymore! So I have the following code that handles my Work.</p>
<pre><... | [
{
"answer_id": 433480,
"author": "alxp",
"author_id": 19513,
"author_profile": "https://Stackoverflow.com/users/19513",
"pm_score": 0,
"selected": false,
"text": "<p>Check the return value of fork(). If it is zero, you are the child process, and you can exit() after doing your work. If i... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39106/"
] | As I am currently doing [this project](https://stackoverflow.com/questions/409087/creating-a-web-server-in-pure-c) in only C, I've up untill this point only used my webserver as a single threaded application. However, I dont want that anymore! So I have the following code that handles my Work.
```
void BeginListen()
{... | I'm not a 100% sure what it is that you're trying to do, buy off the top of my head, I'd prefer to do the fork after the accept, and simply exit() when you're done. Keep in mind though, that you need to react to the SIGCHLD signal when the child process exits, otherwise you'll have a ton of zombie-processes hanging aro... |
433,490 | <p>If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours"<br/>
<b></p>
<ol>
<li>Storing it as DB table with columns ID and Name, and deal with it using queries and joins.</... | [
{
"answer_id": 433564,
"author": "Simon",
"author_id": 20048,
"author_profile": "https://Stackoverflow.com/users/20048",
"pm_score": 3,
"selected": false,
"text": "<p>I tend to go for the database option as this enables easy querying with meaningful data (i.e. names rather than ID's).</p... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours"
1. Storing it as DB table with columns ID and Name, and deal with it using queries and joins.
2. Storing it as Enum and... | Generally you should only use enumeration where there is a clear set of items that will not change, e.g. primary colours, or continent names. Otherwise lookup tables with appropriately implemented foreign keys are pretty much always the best option.
There is a possible variation on the lookup table option where you po... |
433,493 | <p>I have long recognized that any set of whitespace in an HTML file will only be displayed as a single space. For instance, this:</p>
<pre><code><p>Hello. Hello. Hello. Hello. Hello.</p>
</code></pre>
<p>displays as:</p>
<p>Hello. Hello. Hello. Hello. ... | [
{
"answer_id": 433499,
"author": "Chris Farmer",
"author_id": 404,
"author_profile": "https://Stackoverflow.com/users/404",
"pm_score": 2,
"selected": false,
"text": "<p>It's in the HTML spec. It's the part about inter-word spaces being rendered as an ASCII space.</p>\n\n<p><a href=\"ht... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219/"
] | I have long recognized that any set of whitespace in an HTML file will only be displayed as a single space. For instance, this:
```
<p>Hello. Hello. Hello. Hello. Hello.</p>
```
displays as:
Hello. Hello. Hello. Hello. Hello.
This is perfectly fine, as if you need multiple spaces of pr... | Spaces are compacted in HTML because there's a distinction between how HTML is formatted and how it should be rendered. Consider a page like this:
```
<html>
<body>
<a href="mylink">A link</a>
</body>
</html>
```
If the HTML was indented using spaces for example, the link would be preceded by several... |
433,518 | <p>I am trying to make a form move (using the titlebar) from a button click.</p>
<p>I thought this would be simple using SendMessage:</p>
<pre><code>Const WM_LBUTTONDOWN As Integer = &H201
Button1.Capture = False
Cursor.Position = Me.Location + New Size(50, 8)
SendMessage(Me.Handle, WM_LBUTTONDOWN, CType(1, Int... | [
{
"answer_id": 433538,
"author": "P Daddy",
"author_id": 36388,
"author_profile": "https://Stackoverflow.com/users/36388",
"pm_score": 3,
"selected": true,
"text": "<p>You would need <code>WM_</code><strong><code>NC</code></strong><code>LBUTTONDOWN</code> (and pass <code>HTCAPTION</code>... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1500/"
] | I am trying to make a form move (using the titlebar) from a button click.
I thought this would be simple using SendMessage:
```
Const WM_LBUTTONDOWN As Integer = &H201
Button1.Capture = False
Cursor.Position = Me.Location + New Size(50, 8)
SendMessage(Me.Handle, WM_LBUTTONDOWN, CType(1, IntPtr), IntPtr.Zero)
```
... | You would need `WM_`**`NC`**`LBUTTONDOWN` (and pass `HTCAPTION` as `wParam`). I'm still not entirely sure this would accomplish what you're trying to do, though.
Typically, the way to allow the user to move your form when clicking somewhere other than the title bar is to process the `WM_NCHITTEST` message and return `... |
433,523 | <p>Problem 1:</p>
<p>I have a simple winforms app and I want to DataBind my Person.Name property to a textbox. Name is of type StringField. I originally defined the Name property as String. The data binding works great on value types such as String. I would like the StringField.Value property to be the default propert... | [
{
"answer_id": 433531,
"author": "Rune Grimstad",
"author_id": 30366,
"author_profile": "https://Stackoverflow.com/users/30366",
"pm_score": 0,
"selected": false,
"text": "<p>You can hade the StringField by mapping the Name property to the Name.Value field internally in your class.</p>\n... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85900/"
] | Problem 1:
I have a simple winforms app and I want to DataBind my Person.Name property to a textbox. Name is of type StringField. I originally defined the Name property as String. The data binding works great on value types such as String. I would like the StringField.Value property to be the default property of Strin... | You could create an implicit operator overload. Then you can create `StringField` from strings like this:
```
StringField field = "value of new object";
string value=(string)field;
```
Know that this creates a new `StringField` object. I wouldn't necessarily advice you to do this.
```
[System.Diagnostics.DebuggerDi... |
433,524 | <p>I have an automatically generated XML file for the game that I run. It however apparently has an error.</p>
<p>The file is at: <a href="http://woarl.com/myXML.xml" rel="nofollow noreferrer">http://woarl.com/myXML.xml</a></p>
<p>And the error is apparently at line 520, here are lines 519-521</p>
<pre><code><typ... | [
{
"answer_id": 433530,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": true,
"text": "<p>The file is incomplete.</p>\n\n<p>When downloaded through the browser, it ends not like you shown, but like this:</... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I have an automatically generated XML file for the game that I run. It however apparently has an error.
The file is at: <http://woarl.com/myXML.xml>
And the error is apparently at line 520, here are lines 519-521
```
<type>Academy</type>
<typeid>23</typeid>
<completion>4</completion>
```
Any ideas as to what the e... | The file is incomplete.
When downloaded through the browser, it ends not like you shown, but like this:
```
<city>
<id>8</id>
<name>Breisgau</name>
<xpos>58</xpos>
<ypos>934</ypos>
<continent>Rayti</continent>
<continentid>3</continentid>
<size>52297</size>
<port>0</port>
... |
433,526 | <p>I've got a problem with inheritance and generics.
This is the code that illustrates my problem:</p>
<pre><code>namespace TestApplication
{
public class MyClass<T>
{
private T field;
public MyClass(T field)
{
this.field = field;
}
}
public class MyI... | [
{
"answer_id": 433545,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 5,
"selected": true,
"text": "<p>You can only cast from a base class to a derived class if the object is actually of type derived class. I mean, you can't ca... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49048/"
] | I've got a problem with inheritance and generics.
This is the code that illustrates my problem:
```
namespace TestApplication
{
public class MyClass<T>
{
private T field;
public MyClass(T field)
{
this.field = field;
}
}
public class MyIntClass : MyClass<in... | You can only cast from a base class to a derived class if the object is actually of type derived class. I mean, you can't cast an instance of base (`MyClass<int>`) to `MyIntClass`. You can, however cast it if it was actually of type `MyIntClass` stored as an `MyClass<int>` instance.
```
MyClass<int> foo = new MyIntCla... |
433,528 | <p>I am unable to define a relationship between paper and author. Is it possible to define one?</p>
<pre><code><xsd:complextype name="Researcher'>
</xsd:complextype>
<xsd:complexType name = "Paper" >
<xsd:extension base = " Researcher " >
</xsd:extension>
</xsd:complexTyp... | [
{
"answer_id": 437430,
"author": "Michael Mathews",
"author_id": 21242,
"author_profile": "https://Stackoverflow.com/users/21242",
"pm_score": 0,
"selected": false,
"text": "<p>It does seem to be a duplicate question.</p>\n\n<p>I think of things in terms of \"is a\" or \"has a\" relation... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am unable to define a relationship between paper and author. Is it possible to define one?
```
<xsd:complextype name="Researcher'>
</xsd:complextype>
<xsd:complexType name = "Paper" >
<xsd:extension base = " Researcher " >
</xsd:extension>
</xsd:complexType>
<xsd:complexType name = "Author">
<xsd... | I assume you want a 'paper' to have an 'author'. The way I do this in my schemas is to have a list of authors and a list of papers. Something like this:
```
<papers>
<authorlist>
<author>Bob Barr</author>
<author>Ron Paul</author>
<author>Ralph Nader</author>
</authorlist>
<paperlist>
<paper>
... |
433,539 | <p>I am trying to subclass NSOutlineView. Here is my code:</p>
<p>OutlineViewSublcass.h:</p>
<pre><code>#import <Cocoa/Cocoa.h>
@interface OutlineViewSubclass : NSOutlineView {
}
@end
</code></pre>
<p>OutlineViewSubclass.m:</p>
<pre><code>#import "OutlineViewSubclass.h"
@implementation OutlineViewSubclass... | [
{
"answer_id": 433596,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 7,
"selected": true,
"text": "<p>Cocoa controls implement the NSCoding protocol for unarchiving from a nib. Instead of initializing the object u... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53839/"
] | I am trying to subclass NSOutlineView. Here is my code:
OutlineViewSublcass.h:
```
#import <Cocoa/Cocoa.h>
@interface OutlineViewSubclass : NSOutlineView {
}
@end
```
OutlineViewSubclass.m:
```
#import "OutlineViewSubclass.h"
@implementation OutlineViewSubclass
- (id)initWithFrame:(NSRect)frame
{
self = [... | Cocoa controls implement the NSCoding protocol for unarchiving from a nib. Instead of initializing the object using initWithFrame: and then setting the attributes, the initWithCoder: method takes responsibility for setting up the control when it's loaded using the serialized attributes configured by Interface Builder. ... |
433,570 | <p>I have a classical many to many scenario with three tables (students, courses, and third StudentsCourses assignment table).</p>
<p>I'm using EF in my new project and EF designer doesn't create third table.
I need to select all cources along with number of students assigned to it.
Using plain SQL is very straightfor... | [
{
"answer_id": 471011,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>The EF designer hides the table. It's still there, but it just creates the assocation for you, so you can just reference stu... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430254/"
] | I have a classical many to many scenario with three tables (students, courses, and third StudentsCourses assignment table).
I'm using EF in my new project and EF designer doesn't create third table.
I need to select all cources along with number of students assigned to it.
Using plain SQL is very straightforward:
```... | The EF designer hides the table. It's still there, but it just creates the assocation for you, so you can just reference students from courses or vice versa. |
433,591 | <p>Why does the <a href="http://msdn.microsoft.com/en-us/library/fa0ab757.aspx" rel="nofollow noreferrer">new operator</a> exist in modern languages such as C# and Java? Is it purely a self documenting code feature, or does it serve any actual purpose?</p>
<p>For instance the following example:</p>
<pre><code>Class1 ... | [
{
"answer_id": 433611,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 1,
"selected": false,
"text": "<p>The new operator allocates the memory for the object(s), which is it's purpose; as you say it also self documents ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19100/"
] | Why does the [new operator](http://msdn.microsoft.com/en-us/library/fa0ab757.aspx) exist in modern languages such as C# and Java? Is it purely a self documenting code feature, or does it serve any actual purpose?
For instance the following example:
```
Class1 obj = new Class1();
Class1 foo()
{
return new Class1(... | 1. It's a self documenting feature.
2. It's a way to make it possible to name a method "Class1" in some other class |
433,595 | <p>A while ago, I asked a <a href="https://stackoverflow.com/questions/395995/when-should-i-use-and-can-it-always-be-replaced-with-parentheses">question about $</a>, and got useful answers -- in fact, I thought I understood how to use it.</p>
<p>It seems I was wrong :(</p>
<p>This example shows up in a tutorial:</p>
... | [
{
"answer_id": 433706,
"author": "Tom Lokhorst",
"author_id": 2597,
"author_profile": "https://Stackoverflow.com/users/2597",
"pm_score": 5,
"selected": true,
"text": "<p>The <code>$</code> is used here because it has lower precedence than normal function application.\nAnother way to wri... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] | A while ago, I asked a [question about $](https://stackoverflow.com/questions/395995/when-should-i-use-and-can-it-always-be-replaced-with-parentheses), and got useful answers -- in fact, I thought I understood how to use it.
It seems I was wrong :(
This example shows up in a tutorial:
```
instance Monad [] where
... | The `$` is used here because it has lower precedence than normal function application.
Another way to write this code is like so:
```
instance Monad [] where
xs >>= f = (concat . map f) xs
```
The idea here is to first construct a function (`concat . map f`) and then apply it to its argument (`xs`). As shown, thi... |
433,621 | <p>In a Grails domain class, how do I set the constraint for a String field so that its MySQL column type is TEXT or LONGTEXT?</p>
<p>So far my best approach is to set the constraint's size:</p>
<pre><code>myTextField(size:0..65535)
</code></pre>
<p>which results in TEXT</p>
<pre><code>myTextField(size:0..21474836... | [
{
"answer_id": 433779,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 8,
"selected": true,
"text": "<p>You can declare that in the mapping closure of your Domain class:</p>\n\n<pre><code>static mapping = {\n m... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | In a Grails domain class, how do I set the constraint for a String field so that its MySQL column type is TEXT or LONGTEXT?
So far my best approach is to set the constraint's size:
```
myTextField(size:0..65535)
```
which results in TEXT
```
myTextField(size:0..2147483646)
```
results in LONGTEXT (2147483646 = 2... | You can declare that in the mapping closure of your Domain class:
```
static mapping = {
myTextField type: 'text'
}
```
(See [ORM DSL Documentation](http://grails.org/doc/latest/guide/single.html#ormdsl)) |
433,627 | <p>I have two JSON objects with the same structure and I want to concat them together using Javascript. Is there an easy way to do this?</p>
| [
{
"answer_id": 433645,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 4,
"selected": false,
"text": "<p>One solution is to use a list/array:</p>\n\n<pre><code>var first_json = {\"name\":\"joe\", \"age\":27};\nvar second_json... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27294/"
] | I have two JSON objects with the same structure and I want to concat them together using Javascript. Is there an easy way to do this? | Based on your description in the comments, you'd simply do an array concat:
```
var jsonArray1 = [{'name': "doug", 'id':5}, {'name': "dofug", 'id':23}];
var jsonArray2 = [{'name': "goud", 'id':1}, {'name': "doaaug", 'id':52}];
jsonArray1 = jsonArray1.concat(jsonArray2);
// jsonArray1 = [{'name': "doug", 'id':5}, {'nam... |
433,628 | <p>I'm a junior student in IT. I am facing a problem with the output of the program.
The idea of the program is that I should use functions to read an array of 10 elements, then get the average of the elements, then get the the max and min. I've got the max and min right but the average is showing weird stuff. Please ... | [
{
"answer_id": 433642,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>This line is probably the problem:</p>\n\n<pre><code>avg = total /size-1;\n</code></pre>\n\n<p>You probably want to in... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm a junior student in IT. I am facing a problem with the output of the program.
The idea of the program is that I should use functions to read an array of 10 elements, then get the average of the elements, then get the the max and min. I've got the max and min right but the average is showing weird stuff. Please chec... | It is skipping the first input number because of the '\n' in the scanf() string. To fix it, remove the '\n' from the scanf string, like this:
```
scanf("%d", &a[i]);
``` |
433,632 | <p>I want to be able to pass something into an SQL query to determine if I want to select only the ones where a certain column is null. If I was just building a query string instead of using bound variables, I'd do something like:</p>
<pre><code>if ($search_undeleted_only)
{
$sqlString .= " AND deleted_on IS NULL... | [
{
"answer_id": 433685,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 3,
"selected": true,
"text": "<p>Yes; a related trick is if you have X potential filters, some of them optional, is to have the template say <code>\" A... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3333/"
] | I want to be able to pass something into an SQL query to determine if I want to select only the ones where a certain column is null. If I was just building a query string instead of using bound variables, I'd do something like:
```
if ($search_undeleted_only)
{
$sqlString .= " AND deleted_on IS NULL";
}
```
but ... | Yes; a related trick is if you have X potential filters, some of them optional, is to have the template say `" AND ( ?=-1 OR some_field = ? ) "`, and create a special function that wraps the execute call and binds all the second ?s. (in this case, -1 is a special value meaning 'ignore this filter').
Update from Paul T... |
433,643 | <p>What's the best practice to handle errors if using objects?</p>
<p><strong>A)</strong> Before the method of object is called and not even getting to execute method if there's some error, or</p>
<p><strong>B)</strong> Just pass parameters and perform error checking in method itself, returning error code or somethin... | [
{
"answer_id": 433663,
"author": "moo",
"author_id": 23107,
"author_profile": "https://Stackoverflow.com/users/23107",
"pm_score": 3,
"selected": true,
"text": "<p>If you're using OO, you might as well use Exceptions. My answer is a mix of both A and B:</p>\n\n<pre><code>class DatabaseCo... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53948/"
] | What's the best practice to handle errors if using objects?
**A)** Before the method of object is called and not even getting to execute method if there's some error, or
**B)** Just pass parameters and perform error checking in method itself, returning error code or something.
Please pick your option and short descr... | If you're using OO, you might as well use Exceptions. My answer is a mix of both A and B:
```
class DatabaseConnectionException extends Exception {}
class Database {
public function connect($user, $pass, $db) {
//Connection stuff.
if($baduser) {
throw new DatabaseConnectionException('U... |
433,654 | <p>You can skin a RadioButton in Flex by setting the following values in CSS:</p>
<pre><code>upSkin: Embed(...);
overSkin: Embed(...);
ownSkin: Embed(...);
disabledSkin: Embed(...);
selectedUpSkin: Embed(...);
selectedOverSkin: Embed(...);
selectedDownSkin: Embed(...);
selectedDisabledSkin: Embed(...);
</code></pre>
... | [
{
"answer_id": 433671,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 1,
"selected": false,
"text": "<p>If its standard CSS, you can use the following. I'm assuming the styles are classes, if they're IDs replace the . with ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] | You can skin a RadioButton in Flex by setting the following values in CSS:
```
upSkin: Embed(...);
overSkin: Embed(...);
ownSkin: Embed(...);
disabledSkin: Embed(...);
selectedUpSkin: Embed(...);
selectedOverSkin: Embed(...);
selectedDownSkin: Embed(...);
selectedDisabledSkin: Embed(...);
```
But, it will still dis... | Try this:
```
ClassReference(null);
``` |
433,662 | <p>I am sorry all - I am not here to blame Python. This is just a reflection on whether what I believe is right. Being a Python devotee for two years, I have been writing only small apps and singing Python's praises wherever I go. I recently had the chance to read Django's code, and have started wondering if Python rea... | [
{
"answer_id": 433675,
"author": "hasen",
"author_id": 35364,
"author_profile": "https://Stackoverflow.com/users/35364",
"pm_score": 2,
"selected": false,
"text": "<p>If what the code is doing becomes mysterious for some reason .. there should either be comments or the function names sho... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am sorry all - I am not here to blame Python. This is just a reflection on whether what I believe is right. Being a Python devotee for two years, I have been writing only small apps and singing Python's praises wherever I go. I recently had the chance to read Django's code, and have started wondering if Python really... | The code fragment you present is fairly atypical (which might also because you probably made it up):
* you wouldn't normally have an instance variable (self.c) that is a floating point number at some point, and a string at a different point. It should be either a number or a string all the time.
* you normally don't b... |
433,668 | <p>How can I do the following in C#? What is the right way to write the first line of this code snippet?</p>
<pre><code>using KVP<K, V> = System.Collections.Generic.KeyValuePair<K, V>;
class C { KVP<int, string> x; }
</code></pre>
| [
{
"answer_id": 433676,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "<p>You can't, basically. You can only use fixed aliases, such as:</p>\n\n<pre><code>using Foo = System.Collections.Gen... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | How can I do the following in C#? What is the right way to write the first line of this code snippet?
```
using KVP<K, V> = System.Collections.Generic.KeyValuePair<K, V>;
class C { KVP<int, string> x; }
``` | You can't, basically. You can only use fixed aliases, such as:
```
using Foo = System.Collections.Generic.KeyValuePair<int, string>;
class C { Foo x; }
``` |
433,669 | <p>The following shows the structure of some data I have (format: a list of lists)</p>
<pre><code>data =
[
[1,2008-12-01],
[1,2008-12-01],
[2,2008-12-01]
... (the lists continue)
]
</code></pre>
<p>The dates range from 2008-12-01 to 2008-12-25.</p>
<p>The first field identifies a user by id, the second fie... | [
{
"answer_id": 433679,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "<p>Your result is a dictionary, right?</p>\n\n<pre><code>{ userNumber: setOfDays }\n</code></pre>\n\n<p>How about this to g... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51181/"
] | The following shows the structure of some data I have (format: a list of lists)
```
data =
[
[1,2008-12-01],
[1,2008-12-01],
[2,2008-12-01]
... (the lists continue)
]
```
The dates range from 2008-12-01 to 2008-12-25.
The first field identifies a user by id, the second field (a date field) shows when this... | Your result is a dictionary, right?
```
{ userNumber: setOfDays }
```
How about this to get started.
```
from collections import defaultdict
visits = defaultdict(set)
for user, date in someList:
visits[user].add(date)
```
This gives you a dictionary with a set of dates on which they visited.
```
counts = de... |
433,670 | <p>Say I'm interested in the source for one particular Linux utility, like <code>factor</code>. Where can I find the source code for that utility?</p>
| [
{
"answer_id": 433677,
"author": "joschi",
"author_id": 49505,
"author_profile": "https://Stackoverflow.com/users/49505",
"pm_score": 2,
"selected": false,
"text": "<p>Usually you'll find the source code on the website of the program if it is open source. In this case <a href=\"http://ww... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | Say I'm interested in the source for one particular Linux utility, like `factor`. Where can I find the source code for that utility? | What I did was type
```
man factor
```
and went to the bottom and found 'GNU coreutils 6.10'. So I googled 'coreutils' and... found the site joschi just linked to. |
433,678 | <p>Is it normal to modify setter arguments? Let's imagine that we have setString method. And we really want to keep a trimmed form of the string. So a string with trailing spaces is invalid, but we don't want to throw an exception.</p>
<p>What's the best solution? To trim the value in the setter e.g.</p>
<pre><code>p... | [
{
"answer_id": 433680,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": true,
"text": "<p>Yes. After all, setters are designed for these kind of things! To control and sanitize the values written to fields ;)</p>\n... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53907/"
] | Is it normal to modify setter arguments? Let's imagine that we have setString method. And we really want to keep a trimmed form of the string. So a string with trailing spaces is invalid, but we don't want to throw an exception.
What's the best solution? To trim the value in the setter e.g.
```
public void setString(... | Yes. After all, setters are designed for these kind of things! To control and sanitize the values written to fields ;) |
433,682 | <p>I'm trying to convert a struct to a char array to send over the network. However, I get some weird output from the char array when I do.</p>
<pre><code>#include <stdio.h>
struct x
{
int x;
} __attribute__((packed));
int main()
{
struct x a;
a.x=127;
char *b = (char *)&a;
int i;
for (... | [
{
"answer_id": 433691,
"author": "Rowland Shaw",
"author_id": 50447,
"author_profile": "https://Stackoverflow.com/users/50447",
"pm_score": 3,
"selected": false,
"text": "<p>char is a signed type; so with two's complement, 0x80 is -128 for an 8-bit integer (i.e. a byte)</p>\n"
},
{
... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37205/"
] | I'm trying to convert a struct to a char array to send over the network. However, I get some weird output from the char array when I do.
```
#include <stdio.h>
struct x
{
int x;
} __attribute__((packed));
int main()
{
struct x a;
a.x=127;
char *b = (char *)&a;
int i;
for (i=0; i<4; i++)
print... | The `x` format specifier by itself says that the argument is an `int`, and since the number is negative, `printf` requires eight characters to show all four non-zero bytes of the `int`-sized value. The `0` modifier tells to pad the output with zeros, and the `2` modifier says that the *minimum* output should be two cha... |
433,700 | <p>I'm admittedly a straight-C newbie, but this has got me stumped. I'm working on a linked list implementation for practice, and I'm getting a segfault by simply adding a variable to the split_node function:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node {
... | [
{
"answer_id": 433705,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 5,
"selected": true,
"text": "<p>You need to dynamically allocate your nodes (using malloc).</p>\n\n<p>As you have it, your new node is declared on the s... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27512/"
] | I'm admittedly a straight-C newbie, but this has got me stumped. I'm working on a linked list implementation for practice, and I'm getting a segfault by simply adding a variable to the split\_node function:
```
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Node {
struct Node *child;
char *... | You need to dynamically allocate your nodes (using malloc).
As you have it, your new node is declared on the stack. When the split function returns, that new node is no longer valid memory.
Adding a variable causes a segfault because that variable changes the layout of the stack causing slightly different behavior wh... |
433,711 | <p>Studying C#, my books are showing me classes for readin files. I've found 2 that are very similar and the Visual Studio debugger doesn't show an obvious difference between the two.</p>
<p>code: </p>
<pre><code>FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
FileStream fs = File.Open(path, F... | [
{
"answer_id": 433714,
"author": "Brian Rasmussen",
"author_id": 38206,
"author_profile": "https://Stackoverflow.com/users/38206",
"pm_score": 5,
"selected": true,
"text": "<p>The latter is just a factory which returns an instance of <code>FileStream</code>. I.e. they do the same. </p>\n... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | Studying C#, my books are showing me classes for readin files. I've found 2 that are very similar and the Visual Studio debugger doesn't show an obvious difference between the two.
code:
```
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
FileStream fs = File.Open(path, FileMode.Open, FileAcce... | The latter is just a factory which returns an instance of `FileStream`. I.e. they do the same.
Here's the implementation for `Open()`:
```
public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share) {
return new FileStream(path, mode, access, share);
}
``` |
433,718 | <p>I have a bash script to upload some files to my webserver. The problem is that it seems to assume that when they get to the webserver they are missing the final 4kb of the file.</p>
<p>On my computer the file is listed as 8kb (rounded up because blocks are 4kb) yet only 4kb are uploaded.</p>
<p>Here's the funny/co... | [
{
"answer_id": 433730,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like your FTP program is reading \"quit\" immediately after starting the \"put\" but before letting it finish.</... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I have a bash script to upload some files to my webserver. The problem is that it seems to assume that when they get to the webserver they are missing the final 4kb of the file.
On my computer the file is listed as 8kb (rounded up because blocks are 4kb) yet only 4kb are uploaded.
Here's the funny/confusing part, thi... | The last put command is probably still transmitting data (over passive connection) when the client exits. BYE is just an alias for quit so it won't help, but maybe you could try adding some other command between the put and quit, for example ls.
Or if no firewalls forbid, setting up the session the active mode would m... |
433,724 | <p>I've written some integration tests that I'd like to run against a copy of my prod database before I push to production. This lets me test all of my routes are still correct, all of the pages render without errors and some of the multipage workflows work as expected.</p>
<p>When I run the integration tests it drops... | [
{
"answer_id": 433785,
"author": "aivarsak",
"author_id": 53698,
"author_profile": "https://Stackoverflow.com/users/53698",
"pm_score": 3,
"selected": true,
"text": "<p>Integration tests calls db:test:prepare which calls db:test:clone_structure which calls db:structure:dump and db:test:p... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16779/"
] | I've written some integration tests that I'd like to run against a copy of my prod database before I push to production. This lets me test all of my routes are still correct, all of the pages render without errors and some of the multipage workflows work as expected.
When I run the integration tests it drops the datab... | Integration tests calls db:test:prepare which calls db:test:clone\_structure which calls db:structure:dump and db:test:purge
You can write your own task
```
namespace :your_namespace do
Rake::TestTask.new(:integration => "db:migrate(if you want") do |t|
t.libs << "test"
t.pattern = 'test/integration/**/*_t... |
433,743 | <p>I have an input field on my page where the user will type in the number of text inputs they want to create. The action for the button is:</p>
<pre><code>int num_flds = int.Parse(a_fld.Text);
for (int i = 0; i < num_flds; i++)
{
TextBox tmp = new TextBox();
tmp.ID = "answer_box" + i;
tmp.Width = Unit.... | [
{
"answer_id": 433762,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 1,
"selected": false,
"text": "<p>Well it depends on what way you look at it.</p>\n\n<p>You can <a href=\"http://jcooney.net/archive/2007/11/26/55358.aspx\" r... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49887/"
] | I have an input field on my page where the user will type in the number of text inputs they want to create. The action for the button is:
```
int num_flds = int.Parse(a_fld.Text);
for (int i = 0; i < num_flds; i++)
{
TextBox tmp = new TextBox();
tmp.ID = "answer_box" + i;
tmp.Width = Unit.Pixel(300);
a... | Well it depends on what way you look at it.
You can [extend and build plugins](http://jcooney.net/archive/2007/11/26/55358.aspx) for management studio but you can also use the [visual studio shell](http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx) as the base for new applications (altho I don't think thi... |
433,752 | <p>I'm working on a test framework in Perl. As part of the tests, I may need to add precondition or postcondition checks for any given test, but not necessarily for all of them. What I've got so far is something like:</p>
<pre><code>eval "&verify_precondition_TEST$n";
print $@ if $@;
</code></pre>
<p>Unfortunatel... | [
{
"answer_id": 433780,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 5,
"selected": false,
"text": "<pre><code>Package::Name->can('function')\n</code></pre>\n\n<p>or</p>\n\n<pre><code>*Package::Name::function{CODE}\n\n# ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] | I'm working on a test framework in Perl. As part of the tests, I may need to add precondition or postcondition checks for any given test, but not necessarily for all of them. What I've got so far is something like:
```
eval "&verify_precondition_TEST$n";
print $@ if $@;
```
Unfortunately, this outputs "Undefined sub... | With defined:
```
if (eval "defined(&verify_precondition_TEST$n)") {
eval "&verify_precondition_TEST$n";
print $@ if $@;
}
else {
print "verify_precondition_TEST$n does not exist\n";
}
```
**EDIT:** hmm, I only thought of eval as it was in the question but with symbolic references brought up with Leon Ti... |
433,761 | <p>How do you implement a context menu triggered by a long click or tap on a ListActivity that is using the built in layouts and a ListAdapter?</p>
| [
{
"answer_id": 436821,
"author": "pupeno",
"author_id": 6068,
"author_profile": "https://Stackoverflow.com/users/6068",
"pm_score": 7,
"selected": true,
"text": "<p>On the onCreate method call <a href=\"http://developer.android.com/reference/android/app/Activity.html#registerForContextMe... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | How do you implement a context menu triggered by a long click or tap on a ListActivity that is using the built in layouts and a ListAdapter? | On the onCreate method call [registerForContextMenu](http://developer.android.com/reference/android/app/Activity.html#registerForContextMenu(android.view.View)) like this:
```
registerForContextMenu(getListView());
```
and then populate the menu on [onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo me... |
433,771 | <p>There can be several instances of my service on the same computer, each of them on a different port.</p>
<p>How can I retrieve the port number from which the current request came through to differentiate them?</p>
<p>To clarify, if client is calling the following method:</p>
<pre><code>class OrdersService : Marsh... | [
{
"answer_id": 437558,
"author": "Kevin Albrecht",
"author_id": 10475,
"author_profile": "https://Stackoverflow.com/users/10475",
"pm_score": 2,
"selected": false,
"text": "<p>Compojure seems to be getting the most buzz right now. Not necessarily indicative of quality, but the one with ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There can be several instances of my service on the same computer, each of them on a different port.
How can I retrieve the port number from which the current request came through to differentiate them?
To clarify, if client is calling the following method:
```
class OrdersService : MarshalByRefObject
{
public v... | Compojure seems to be getting the most buzz right now. Not necessarily indicative of quality, but the one with the most eyes will probably evolve the fastest. |
433,774 | <p>In Java I can write a really basic JSP <code>index.jsp</code> like so:</p>
<p><code><% request.getRequestDispatcher("/home.action").forward(request, response); %></code></p>
<p>The effect of this is that a user requesting <code>index.jsp</code> (or just the containing directory assuming <code>index.jsp</code... | [
{
"answer_id": 433794,
"author": "Deniss Kozlovs",
"author_id": 53948,
"author_profile": "https://Stackoverflow.com/users/53948",
"pm_score": -1,
"selected": false,
"text": "<p>You can use like:</p>\n\n<pre><code>header (\"Location: /path/\");\nexit;\n</code></pre>\n\n<p>The exit is need... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1654/"
] | In Java I can write a really basic JSP `index.jsp` like so:
`<% request.getRequestDispatcher("/home.action").forward(request, response); %>`
The effect of this is that a user requesting `index.jsp` (or just the containing directory assuming `index.jsp` is a default document for the directory) will see `home.action` w... | If you are concerned about CURL availability then you could use `file_get_contents()` and streams. Setting up a function like:
```
function forward($location, $vars = array())
{
$file ='http://'.$_SERVER['HTTP_HOST']
.substr($_SERVER['REQUEST_URI'],0,strrpos($_SERVER['REQUEST_URI'], '/')+1)
.$location;
... |
433,795 | <p>I like that in PHP I can do the following</p>
<pre><code>$myInteger++;
$myString += 'more text';
</code></pre>
<p>With Python I must do the following</p>
<pre><code>myInteger = myInteger + 1
myString = myString + "more text"
</code></pre>
<p>Is there a better way to add or append to a variable in Python?</p>
| [
{
"answer_id": 433803,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 6,
"selected": true,
"text": "<p>Python doesn't have the increment (++) and decrement (--) operators, but it does have the += operator (and -=, etc.) so ... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | I like that in PHP I can do the following
```
$myInteger++;
$myString += 'more text';
```
With Python I must do the following
```
myInteger = myInteger + 1
myString = myString + "more text"
```
Is there a better way to add or append to a variable in Python? | Python doesn't have the increment (++) and decrement (--) operators, but it does have the += operator (and -=, etc.) so you can do this:
```
myInteger += 1
myString += "more text"
``` |
433,798 | <p>Consider type like this one</p>
<pre><code>public interface IHaveGenericMethod
{
T1 Method<T1>(T1 parm);
T2 Method<T1,T2>(T1 parm);
int Method2(int parm);
}
</code></pre>
<p>How do I get a methodInfo for its methods?
for a regular non-generic method, like method2, I can go with</p>
<pre><code... | [
{
"answer_id": 433825,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "<p>Well, they <em>are</em> types - of sorts:</p>\n\n<pre><code> foreach (var method in typeof(IHaveGenericMethod).G... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13163/"
] | Consider type like this one
```
public interface IHaveGenericMethod
{
T1 Method<T1>(T1 parm);
T2 Method<T1,T2>(T1 parm);
int Method2(int parm);
}
```
How do I get a methodInfo for its methods?
for a regular non-generic method, like method2, I can go with
```
typeof(IHaveGenericMethod).GetMethod("methodName... | Well, they *are* types - of sorts:
```
foreach (var method in typeof(IHaveGenericMethod).GetMethods())
{
Console.WriteLine(method.Name);
if (method.IsGenericMethodDefinition)
{
foreach (Type type in method.GetGenericArguments())
{
Console.WriteLin... |
433,802 | <p>OK, I'm designing a site and thought I'd stick some jQuery in as I really need so js experience.</p>
<p>Page with my problem is here: <a href="http://new.focalpix.co.uk/moreinfo.php" rel="nofollow noreferrer">http://new.focalpix.co.uk/moreinfo.php</a></p>
<p>JS in question is:</p>
<pre><code>$(document).ready(fun... | [
{
"answer_id": 433812,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 3,
"selected": false,
"text": "<p>You should be using the <a href=\"http://docs.jquery.com/Effects/slideToggle\" rel=\"nofollow noreferrer\">.slideToggle(... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] | OK, I'm designing a site and thought I'd stick some jQuery in as I really need so js experience.
Page with my problem is here: <http://new.focalpix.co.uk/moreinfo.php>
JS in question is:
```
$(document).ready(function(){
$(".answer").css("display","none");
$("#maincontent a.animate").click(function() {
... | First, I'd suggest the following structure for your faq's:
```
<div id="faq">
<div class="qa" id="faq_greenandflies">
<span class="q">What is <a href="#faq_greenandflies">green and flies</a></span>
<div class="a">
Super Pickle!
</div>
</div>
<div class="qa" id="faq_redandbadforteeth">
<span... |
433,832 | <p>The Flex compiler can compile "pure AS3" SWF files that don't contain any Flex Component bytecode. So,</p>
<p>Would it be possible to create a custom component framework (used in place of the Flex Framework), that can still be visually laid out using MXML (read: markup), and compiled down to a SWF without any depen... | [
{
"answer_id": 434458,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 2,
"selected": false,
"text": "<p>There are two different compilers: one that is used for compiling ActionScript code to AVM bytecode and another (m... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53303/"
] | The Flex compiler can compile "pure AS3" SWF files that don't contain any Flex Component bytecode. So,
Would it be possible to create a custom component framework (used in place of the Flex Framework), that can still be visually laid out using MXML (read: markup), and compiled down to a SWF without any dependencies on... | Yes, it's possible. Your MXML files are essentially just a different way to specify classes. You can see what mxml files boil down to by compiling your project and providing `-compiler.keep-generated-actionscript=true` to `mxmlc`.
bar.mxml:
```
<?xml version="1.0" encoding="utf-8"?>
<flash:Sprite xmlns:flash="flash.d... |
433,833 | <pre><code> for (int i = 0; i < 200; i++)
{
Control control = new Control();
control = new CheckBox();
Size size = control.Size;
Point point = new Point(20, 22);
control.Location = point;
int width = size.Width + 5;
... | [
{
"answer_id": 433835,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Is this winforms? A first point: you don't need the <code>new Control()</code> each time (you simly discard it any... | 2009/01/11 | [
"https://Stackoverflow.com/questions/433833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
for (int i = 0; i < 200; i++)
{
Control control = new Control();
control = new CheckBox();
Size size = control.Size;
Point point = new Point(20, 22);
control.Location = point;
int width = size.Width + 5;
i += widt... | Is this winforms? A first point: you don't need the `new Control()` each time (you simly discard it anyway when you `new CheckBox()`. How exactly do you want the layout to appear? Can you describe it a bit more please?
I imagine `TableLayoutPanel` might be a reasonable start...
```
[STAThread]
static void Main() {
... |