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 |
|---|---|---|---|---|---|---|
415,520 | <p>I'm learning Servlets programming, using Apache Tomcat 6 on a Ubuntu 8.10 machine, and I'm running with a very annoying issue -- apparently, related to caching.</p>
<p>This is what I'm doing: I write a servlet, put it in a nice directory structure and deploy it using the Tomcat Web Application Manager. It works as ... | [
{
"answer_id": 415541,
"author": "Adeel Ansari",
"author_id": 42769,
"author_profile": "https://Stackoverflow.com/users/42769",
"pm_score": 2,
"selected": false,
"text": "<p>Under your TOMCAT_HOME/conf/, you will find a file named Context.xml. The content would look like below,</p>\n\n<p... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm learning Servlets programming, using Apache Tomcat 6 on a Ubuntu 8.10 machine, and I'm running with a very annoying issue -- apparently, related to caching.
This is what I'm doing: I write a servlet, put it in a nice directory structure and deploy it using the Tomcat Web Application Manager. It works as expected. ... | Under your TOMCAT\_HOME/conf/, you will find a file named Context.xml. The content would look like below,
```
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/classes</WatchedResource>
</Context>
```
Both lines are uncomment... |
415,550 | <p>I know very little about JavaScript but despite this I'm trying to cobble something together on my wordpress blog. It's not working, and I don't know how to resolve it, and hey, that's what StackOverflow is for, right?</p>
<p>Firstly, the error message is:</p>
<pre><code>Error: element.dispatchEvent is not a funct... | [
{
"answer_id": 415626,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": false,
"text": "<p>There is a nasty trick many libraries do that I've taken a distinct liking to, and it looks like prototype is one ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31038/"
] | I know very little about JavaScript but despite this I'm trying to cobble something together on my wordpress blog. It's not working, and I don't know how to resolve it, and hey, that's what StackOverflow is for, right?
Firstly, the error message is:
```
Error: element.dispatchEvent is not a function
Source File: http... | Thanks for the suggestions all. In the end I think Kent's explanation was the closest, which basically amounted to "Prototype is broken". (Sorry if I'm summarizing you incorrectly :)
As for the `jQuery.noConflict` option - I already mentioned this in the question. It makes a difference *when* you run this method, and ... |
415,571 | <p>Given two tables, one for workers and one for tasks completed by workers,</p>
<pre><code>CREATE TABLE IF NOT EXISTS `workers` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `workers` (`id`) VALUES
(1);
CREATE TABLE IF NOT EXISTS `tasks` (
`id` int(11) NOT NULL,
`worker_id` int(11) NOT NULL,
... | [
{
"answer_id": 415577,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>I'm trying to get the number of tasks each worker has with each status code.</p>\n</blockquote... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51928/"
] | Given two tables, one for workers and one for tasks completed by workers,
```
CREATE TABLE IF NOT EXISTS `workers` (
`id` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `workers` (`id`) VALUES
(1);
CREATE TABLE IF NOT EXISTS `tasks` (
`id` int(11) NOT NULL,
`worker_id` int(11) NOT NULL,
`status` int(... | ```
SELECT w.*,
SUM(t1.status = 1) AS status_1_count,
SUM(t1.status = 2) AS status_2_count
FROM workers w
LEFT JOIN tasks t1 ON w.id = t1.worker_id AND t1.status IN (1, 2)
GROUP BY w.id
ORDER BY w.id;
``` |
415,580 | <p>It is my understanding that the <code>java.regex</code> package does not have support for named groups (<a href="http://www.regular-expressions.info/named.html" rel="noreferrer">http://www.regular-expressions.info/named.html</a>) so can anyone point me towards a third-party library that does?</p>
<p>I've looked at ... | [
{
"answer_id": 415635,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 9,
"selected": true,
"text": "<p>(<strong>Update</strong>: <strong>August 2011</strong>)</p>\n\n<p>As <a href=\"https://stackoverflow.com/users/50260/geofflan... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/444/"
] | It is my understanding that the `java.regex` package does not have support for named groups (<http://www.regular-expressions.info/named.html>) so can anyone point me towards a third-party library that does?
I've looked at [jregex](http://jregex.sourceforge.net/) but its last release was in 2002 and it didn't work for ... | (**Update**: **August 2011**)
As [geofflane](https://stackoverflow.com/users/50260/geofflane) mentions in [his answer](https://stackoverflow.com/questions/415580/regex-named-groups-in-java/7033467#7033467), [Java 7 now support named groups](http://download.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#grou... |
415,602 | <p>I am attempting to set a value in a textarea field using jquery with the following code:</p>
<pre><code>$("textarea#ExampleMessage").attr("value", result.exampleMessage);
</code></pre>
<p>The issue is, once this code executes, it is not altering the text in the textarea?</p>
<p>However when performing an <code>al... | [
{
"answer_id": 415609,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 11,
"selected": true,
"text": "<p>Have you tried val?</p>\n\n<pre><code>$(\"textarea#ExampleMessage\").val(result.exampleMessage);\n</code></pre>\n"
},... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41211/"
] | I am attempting to set a value in a textarea field using jquery with the following code:
```
$("textarea#ExampleMessage").attr("value", result.exampleMessage);
```
The issue is, once this code executes, it is not altering the text in the textarea?
However when performing an `alert($("textarea#ExampleMessage").attr(... | Have you tried val?
```
$("textarea#ExampleMessage").val(result.exampleMessage);
``` |
415,620 | <p>I'm developing an Windows Forms application that requires me to call a separate program to perform a task. The program is a console application and I need to redirect standard output from the console to a TextBox in my program. </p>
<p>I have no problem executing the program from my application, but I don't know ... | [
{
"answer_id": 415655,
"author": "Mark Maxham",
"author_id": 49737,
"author_profile": "https://Stackoverflow.com/users/49737",
"pm_score": 7,
"selected": true,
"text": "<p>This works for me:</p>\n\n<pre><code>void RunWithRedirect(string cmdPath)\n{\n var proc = new Process();\n pro... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm developing an Windows Forms application that requires me to call a separate program to perform a task. The program is a console application and I need to redirect standard output from the console to a TextBox in my program.
I have no problem executing the program from my application, but I don't know how to redir... | This works for me:
```
void RunWithRedirect(string cmdPath)
{
var proc = new Process();
proc.StartInfo.FileName = cmdPath;
// set up output redirection
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.EnableRaisingEvents = true;
proc.Start... |
415,629 | <p>If I have a CSS class which I <em>only</em> ever apply to form elements, eg:</p>
<pre><code><form class="myForm">
</code></pre>
<p>Which of these two jQuery selectors is most efficient, and why?</p>
<pre><code>a) $('form.myForm')
b) $('.myForm')
</code></pre>
| [
{
"answer_id": 415648,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": false,
"text": "<blockquote>\n <p><strong>Edit</strong>: The results below are for jQuery 1.2.6, probably in Firefox 3.5. Speed improvements ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | If I have a CSS class which I *only* ever apply to form elements, eg:
```
<form class="myForm">
```
Which of these two jQuery selectors is most efficient, and why?
```
a) $('form.myForm')
b) $('.myForm')
``` | As redsquare already mentioned, the selection algorithm changed in later jQuery versions (partly due to getElementsByClassName support). Additionally, I tested this with the most recent jQuery version to date (v1.6) and also added a test for document.getElementsByClassName for comparison (works at least in Firefox 4 an... |
415,649 | <p>I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file?</p>
| [
{
"answer_id": 415675,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 2,
"selected": false,
"text": "<p>Disabling the textfield part of a spinner control is a usability disaster. Please don’t do it. Some of us really <em>want... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] | I am learning Jsf.Is there any method for making the spinners read only?I should change the value only using spinners and not directly typing the number.Can i implement that by setting attribute in the spinners.tld file? | With JSF2.0, you could write your [own spinner JSF component](http://weblogs.java.net/blog/driscoll/archive/2008/11/jsf_20_writing_1.html) except that, instead of using:
```
<h:inputText id="number" value="#{compositeComponent.attrs.value}"/>
```
(which is a [read-write input box](http://www.roseindia.net/jsf/input... |
415,654 | <p>I'm trying to use Expression.Dynamic() to build an assignment operation... I want to use this to selectively offer value type semantics to certain custom type instances in my language. I can't do this with a "static" (?) Expression because I don't know what the actual type is (I need the MetaObject instance and its ... | [
{
"answer_id": 415761,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>Can you clarify the exact scenario? I'm very familiar with <code>Expression</code>, and passably familiar with usi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/630/"
] | I'm trying to use Expression.Dynamic() to build an assignment operation... I want to use this to selectively offer value type semantics to certain custom type instances in my language. I can't do this with a "static" (?) Expression because I don't know what the actual type is (I need the MetaObject instance and its Lim... | I think you basically have 2 options. In either one though you should be using a custom binder instead of a subclass of OperationBinder. This is because you're not performing a cross-language operation. Instead you're implementing a part of your language semantics but just want the good DLR stuff. You should sub class ... |
415,677 | <p>I want to pipe the output of a "template" file into MySQL, the file having variables like <code>${dbName}</code> interspersed. What is the command line utility to replace these instances and dump the output to standard output?</p>
<p>The input file is considered to be safe, but faulty substitution definiti... | [
{
"answer_id": 415693,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 3,
"selected": false,
"text": "<p>If you are open to using <a href=\"http://en.wikipedia.org/wiki/Perl\" rel=\"nofollow noreferrer\">Perl</a>, that... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2567/"
] | I want to pipe the output of a "template" file into MySQL, the file having variables like `${dbName}` interspersed. What is the command line utility to replace these instances and dump the output to standard output?
The input file is considered to be safe, but faulty substitution definitions could exist. Performing th... | Update
------
Here is a solution from [yottatsa](https://stackoverflow.com/a/11050943/1322463) on a similar question that only does replacement for variables like $VAR or ${VAR}, and is a brief one-liner
```
i=32 word=foo envsubst < template.txt
```
Of course if *i* and *word* are in your environment, then it is ju... |
415,692 | <p>I have two forms in my rails app. They both exist in separate tabs and I when I submit one form I want the data in the other form to be saved as well. How should I do that? Or Is there a better way of doing this instead of using two separate forms? Is there a better way to spread a long form into multiple tabs and w... | [
{
"answer_id": 415731,
"author": "Eli",
"author_id": 27580,
"author_profile": "https://Stackoverflow.com/users/27580",
"pm_score": 4,
"selected": true,
"text": "<p>You can expand a single form to cover all elements of both forms. </p>\n\n<p>This is perfectly ok, as long as the form tags... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44916/"
] | I have two forms in my rails app. They both exist in separate tabs and I when I submit one form I want the data in the other form to be saved as well. How should I do that? Or Is there a better way of doing this instead of using two separate forms? Is there a better way to spread a long form into multiple tabs and when... | You can expand a single form to cover all elements of both forms.
This is perfectly ok, as long as the form tags fit validly into the X/HTML.
```
<form action='action1'>
<!-- All elements from both forms, plus tabs, etc. -->
</form>
```
The only thing to consider is if there will ever be another form inside th... |
415,766 | <p>I called this function once per frame and it took my FPS from >400 to 33. Why?</p>
<pre><code>sw blt(const PtRect *dstRect, Texture *src, const PtRect *srcRect, RenderDevice::bltFlags flags=RenderDevice::bltDefault)
{
assert(src);
GL_Texture *glsrc = dynamic_cast<GL_Texture*>(src);
if (glsrc == 0)... | [
{
"answer_id": 415789,
"author": "Ronny Vindenes",
"author_id": 30352,
"author_profile": "https://Stackoverflow.com/users/30352",
"pm_score": 2,
"selected": false,
"text": "<p>Hard to say without more details, potential problems could be using a too large texture, causing software fallba... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I called this function once per frame and it took my FPS from >400 to 33. Why?
```
sw blt(const PtRect *dstRect, Texture *src, const PtRect *srcRect, RenderDevice::bltFlags flags=RenderDevice::bltDefault)
{
assert(src);
GL_Texture *glsrc = dynamic_cast<GL_Texture*>(src);
if (glsrc == 0)
return -1;
... | For performance you should load your textures in an init function and use a list to display then later on the main render function, for example:
```
// Generate texture object ID
glGenTextures(1, img);
glBindTexture(GL_TEXTURE_2D, img);
// Set Texture mapping parameters
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S... |
415,768 | <p>This is more general question then language-specific, altho I bumped into this problem while playing with python ncurses module. I needed to display locale characters and have them recognized as characters, so I just quickly monkey-patched few functions / methods from curses module. </p>
<p>This was what I call a f... | [
{
"answer_id": 415806,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>I would say don't.</p>\n\n<p>Each monkey patch should be an exception and marked (for example with a //HACK commen... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] | This is more general question then language-specific, altho I bumped into this problem while playing with python ncurses module. I needed to display locale characters and have them recognized as characters, so I just quickly monkey-patched few functions / methods from curses module.
This was what I call a fast and ug... | Don't!
======
Especially with free software, you have all the possibilities out there to get your changes into the main distribution. But if you have a weakly documented hack in your local copy you'll never be able to ship the product and upgrading to the next version of curses (security updates anyone) will be very h... |
415,801 | <p>This error message is being presented, any suggestions?</p>
<blockquote>
<p>Allowed memory size of 33554432 bytes exhausted (tried to allocate
43148176 bytes) in php</p>
</blockquote>
| [
{
"answer_id": 415818,
"author": "Rik Heywood",
"author_id": 4012,
"author_profile": "https://Stackoverflow.com/users/4012",
"pm_score": 6,
"selected": false,
"text": "<p>Your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51950/"
] | This error message is being presented, any suggestions?
>
> Allowed memory size of 33554432 bytes exhausted (tried to allocate
> 43148176 bytes) in php
>
>
> | If your script is **expected** to allocate that big amount of memory, then you can increase the memory limit by adding this line to your php file
```
ini_set('memory_limit', '44M');
```
where `44M` is the amount you expect to be consumed.
**However**, most of time this error message means that **the script is doing... |
415,804 | <p>I want to provide feed in my merb application. After reading wikipedia, <a href="https://stackoverflow.com/questions/347504/providing-rss-and-atom-feeds-do-we-need-both-or-has-rss-won">RSSvsAtom</a> and seeing that StackOverflow uses it, I think I will use Atom. What library should I use? I have found <a href="http:... | [
{
"answer_id": 415818,
"author": "Rik Heywood",
"author_id": 4012,
"author_profile": "https://Stackoverflow.com/users/4012",
"pm_score": 6,
"selected": false,
"text": "<p>Your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37086/"
] | I want to provide feed in my merb application. After reading wikipedia, [RSSvsAtom](https://stackoverflow.com/questions/347504/providing-rss-and-atom-feeds-do-we-need-both-or-has-rss-won) and seeing that StackOverflow uses it, I think I will use Atom. What library should I use? I have found [rAtom](http://ratom.rubyfor... | If your script is **expected** to allocate that big amount of memory, then you can increase the memory limit by adding this line to your php file
```
ini_set('memory_limit', '44M');
```
where `44M` is the amount you expect to be consumed.
**However**, most of time this error message means that **the script is doing... |
415,821 | <p>I wrote a module for Joomla! 1.5 which shows the pictures (banners) with the most clicks. Now I want to show this list scrolling on the home-site. With "marquee" there is a break after the last picture.
I've found an advice which said I'll have to create a div-container with overflow: hidden and a second div with ja... | [
{
"answer_id": 415818,
"author": "Rik Heywood",
"author_id": 4012,
"author_profile": "https://Stackoverflow.com/users/4012",
"pm_score": 6,
"selected": false,
"text": "<p>Your script is using too much memory. This can often happen in PHP if you have a loop that has run out of control and... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wrote a module for Joomla! 1.5 which shows the pictures (banners) with the most clicks. Now I want to show this list scrolling on the home-site. With "marquee" there is a break after the last picture.
I've found an advice which said I'll have to create a div-container with overflow: hidden and a second div with javas... | If your script is **expected** to allocate that big amount of memory, then you can increase the memory limit by adding this line to your php file
```
ini_set('memory_limit', '44M');
```
where `44M` is the amount you expect to be consumed.
**However**, most of time this error message means that **the script is doing... |
415,854 | <p>I have a class which expects a LPCTSTR.</p>
<p>When i call :
new CFileImageLoader(_T("Splash02.png"))
OR
new CFileImageLoader("Splash02.png")</p>
<p>both don't work.
Why ?
I'm new to cpp...
Thanks
Jonathan d.</p>
| [
{
"answer_id": 415867,
"author": "Stefan",
"author_id": 48003,
"author_profile": "https://Stackoverflow.com/users/48003",
"pm_score": 0,
"selected": false,
"text": "<p>\"both don't work\" - could you maybe be a tiny, tiny little bit more specific?</p>\n\n<p>If you compile with _UNICODE d... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a class which expects a LPCTSTR.
When i call :
new CFileImageLoader(\_T("Splash02.png"))
OR
new CFileImageLoader("Splash02.png")
both don't work.
Why ?
I'm new to cpp...
Thanks
Jonathan d. | This issue is a combination of C++ issues and Windows specific issues.
C++ defines two types of strings, regular and wide. A regular string looks like:
```
const char *str = "regular string";
```
while a wide string looks like:
```
const wchar_t *wstr = L"wide string";
```
With just standard C++, you have to dec... |
415,860 | <p>I'm working on an embedded C project that depends on some external HW. I wish to stub out the code accessing these parts, so I can simulate the system without using any HW. Until now I have used some macros but this forces me to change a little on my production code, which I would like to avoid.</p>
<h2>Example:</h... | [
{
"answer_id": 415899,
"author": "Gerhard",
"author_id": 34989,
"author_profile": "https://Stackoverflow.com/users/34989",
"pm_score": 4,
"selected": true,
"text": "<p>I just make two files ActualDriver.c and StubDriver.c containing exactly the same function names. By making two builds l... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36986/"
] | I'm working on an embedded C project that depends on some external HW. I wish to stub out the code accessing these parts, so I can simulate the system without using any HW. Until now I have used some macros but this forces me to change a little on my production code, which I would like to avoid.
Example:
--------
```... | I just make two files ActualDriver.c and StubDriver.c containing exactly the same function names. By making two builds linking the production code against the different objects there is no naming conflicts. This way the production code contains no testing or conditional code. |
415,862 | <p>I have a table named <em>visiting</em> that looks like this:</p>
<pre><code>id | visitor_id | visit_time
-------------------------------------
1 | 1 | 2009-01-06 08:45:02
2 | 1 | 2009-01-06 08:58:11
3 | 1 | 2009-01-06 09:08:23
4 | 1 | 2009-01-06 21:55:23
5 | 1 | ... | [
{
"answer_id": 415882,
"author": "Beau Simensen",
"author_id": 50453,
"author_profile": "https://Stackoverflow.com/users/50453",
"pm_score": 0,
"selected": false,
"text": "<p>One or both of these may work? However, both will end up giving you more columns in the result than you are askin... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45607/"
] | I have a table named *visiting* that looks like this:
```
id | visitor_id | visit_time
-------------------------------------
1 | 1 | 2009-01-06 08:45:02
2 | 1 | 2009-01-06 08:58:11
3 | 1 | 2009-01-06 09:08:23
4 | 1 | 2009-01-06 21:55:23
5 | 1 | 2009-01-06 22:03:35
... | The question is slightly ambiguous because you're making the assumption or requiring that the hours are going to start at a set point, i.e. a natural query would also indicate that there's a result record of (1,2) for all the visits between the hour of 08:58 and 09:58. You would have to "tell" your query that the start... |
415,863 | <p>I need some ideas on how I can best solve this problem.</p>
<p>I have a JBoss Seam application running on JBoss 4.3.3
What a small portion of this application does is generate an html and a pdf document based on an Open Office template.</p>
<p>The files that are generated I put inside /tmp/ on the filesystem.
I ha... | [
{
"answer_id": 416003,
"author": "adilei",
"author_id": 50291,
"author_profile": "https://Stackoverflow.com/users/50291",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure I have a complete grasp of what you are trying to achieve, but I'll give it a try anyway:</p>\n\n<p>My assumpti... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37298/"
] | I need some ideas on how I can best solve this problem.
I have a JBoss Seam application running on JBoss 4.3.3
What a small portion of this application does is generate an html and a pdf document based on an Open Office template.
The files that are generated I put inside /tmp/ on the filesystem.
I have tried with Sys... | Not sure how you are generating your PDFs, but if possible, skip the disk IO all together, stash the PDF content in a `byte[]` and flush it out to the user in a servlet setting the mime type to `application/pdf`\* that responds to a URL which is specified by a link in your client or dynamically set in a `<div>` by java... |
415,866 | <p>I'm starting to love Lambda expressions but I'm struggling to pass this wall:</p>
<pre><code>public class CompanyWithEmployees {
public CompanyWithEmployees() { }
public Company CompanyInfo { get; set; }
public List<Person> Employees { get; set; }
}
</code></pre>
<p>My search:</p>
<pre><code>Lis... | [
{
"answer_id": 415880,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Because you want to check for existance, perhaps try:</p>\n\n<pre><code>ces = companiesWithEmployees\n .Find... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28004/"
] | I'm starting to love Lambda expressions but I'm struggling to pass this wall:
```
public class CompanyWithEmployees {
public CompanyWithEmployees() { }
public Company CompanyInfo { get; set; }
public List<Person> Employees { get; set; }
}
```
My search:
```
List<CompanyWithEmployees> companiesWithEmploy... | Because you want to check for existance, perhaps try:
```
ces = companiesWithEmployees
.Find(x => x.Employees
.Find(y => y.ParID == person.ParID) != null);
```
This will check for any `Person` with the same `ParID`; if you mean the same `Person` instance (reference), then `Contains` should suffice:
... |
415,868 | <p>I want to use a PHP variable in JavaScript. How is it possible?</p>
| [
{
"answer_id": 415885,
"author": "Gary Willoughby",
"author_id": 13227,
"author_profile": "https://Stackoverflow.com/users/13227",
"pm_score": 6,
"selected": false,
"text": "<p>You can print the PHP variable into your javascript while your page is created.</p>\n\n<pre><code><script ty... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38172/"
] | I want to use a PHP variable in JavaScript. How is it possible? | You can print the PHP variable into your javascript while your page is created.
```
<script type="text/javascript">
var MyJSStringVar = "<?php Print($MyPHPStringVar); ?>";
var MyJSNumVar = <?php Print($MyPHPNumVar); ?>;
</script>
```
Of course this is for *simple* variables and not objects. |
415,905 | <p>I would like to set a maximum execution time for sql queries like set_time_limit() in php. How can I do ?</p>
| [
{
"answer_id": 10245832,
"author": "Rafa",
"author_id": 279564,
"author_profile": "https://Stackoverflow.com/users/279564",
"pm_score": 3,
"selected": false,
"text": "<p>You can find the answer on this other S.O. question:</p>\n<p><a href=\"https://stackoverflow.com/questions/4794747\">M... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to set a maximum execution time for sql queries like set\_time\_limit() in php. How can I do ? | I thought it has been around a little longer, but according to [this](http://mysqlserverteam.com/server-side-select-statement-timeouts/),
>
> MySQL 5.7.4 introduces the ability to set server side execution time limits, specified in milliseconds, for top level read-only SELECT statements.
>
>
>
```sql
SELECT
/*+ ... |
415,907 | <p>I'm using Drools (for the first time) to express some rules and it has been working really well so far. However I've been given a new condition that I'm not able to express in the rules language very clearly.</p>
<p>Essentially I need to perform an action on the players account if they have an outstanding balance o... | [
{
"answer_id": 416074,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 0,
"selected": false,
"text": "<p>What about <code>($deduction->amountInPence * 4)</code>? I think, the <code>-></code> should be a <code>.... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43850/"
] | I'm using Drools (for the first time) to express some rules and it has been working really well so far. However I've been given a new condition that I'm not able to express in the rules language very clearly.
Essentially I need to perform an action on the players account if they have an outstanding balance on there ac... | yes as you guessed, you need to put an explicit "and" inside the "not" pattern to join them together.
The only time you don't need the "and" is at the top level:
eg
```
when Foo() Bar()
```
Doesn't require a an "and"
but this is implicitly the same as
```
when Foo() and Bar()
```
So your solution seems corr... |
415,910 | <p>I'm trying to use slime from CVS (2009-01-05) but keep getting this error:</p>
<pre>
LOAD: A file with name
/usr/share/common-lisp/source/slime/swank-loader.lisp does not exist
</pre>
<p>I've stripped my .emacs down to just:</p>
<pre><code>(setq inferior-lisp-program "/usr/bin/clisp")
(add-to-list 'l... | [
{
"answer_id": 421438,
"author": "huaiyuan",
"author_id": 16240,
"author_profile": "https://Stackoverflow.com/users/16240",
"pm_score": 3,
"selected": true,
"text": "<p>Have you purged the slime pkg you installed via apt-get? It looks like emacs is still reading the old site-specific co... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8590/"
] | I'm trying to use slime from CVS (2009-01-05) but keep getting this error:
```
LOAD: A file with name
/usr/share/common-lisp/source/slime/swank-loader.lisp does not exist
```
I've stripped my .emacs down to just:
```
(setq inferior-lisp-program "/usr/bin/clisp")
(add-to-list 'load-path "/home/ssm/lisp... | Have you purged the slime pkg you installed via apt-get? It looks like emacs is still reading the old site-specific configuration setup by apt-get. Try starting emacs with the -Q option, which prevents loading of site-specific (as well as user specific) customization, and see if the problem still occur. |
415,920 | <p>I basically need to know how to import SQL code into Access. I've tried one way but that requires me to do one table and one value at a time which takes a lot of time.</p>
<p>Can anyone help?</p>
| [
{
"answer_id": 416079,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 0,
"selected": false,
"text": "<p>SQL code? Or data? \"one table and one value\" makes me think it's the latter. If so, I'd suggest dumping the data o... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I basically need to know how to import SQL code into Access. I've tried one way but that requires me to do one table and one value at a time which takes a lot of time.
Can anyone help? | Well, some days ago I needed to shift data from an Access database to SQL (reverse of what you're doing). I found it simpler to write a simple script that would read data from my access database and insert it into SQL.
I don't think doing what you need to do is any different.
I don't know if it will help, but I posti... |
415,925 | <p>Greetings,</p>
<p>As I am beginning with RDF building, I came along ns0pred here and there.
I am assuming ns means no subject and pred means predicate. Not sure on the zero other then a false boolean value.</p>
<pre><code><rdf:Description rdf:about="http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest"&g... | [
{
"answer_id": 416065,
"author": "Ash",
"author_id": 31128,
"author_profile": "https://Stackoverflow.com/users/31128",
"pm_score": 2,
"selected": false,
"text": "<p>I know nothing about RDF's but it looks like ns0pred actually means 'name space 0', in xml you can define any namespace you... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Greetings,
As I am beginning with RDF building, I came along ns0pred here and there.
I am assuming ns means no subject and pred means predicate. Not sure on the zero other then a false boolean value.
```
<rdf:Description rdf:about="http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest">
<ns0pred:label xmlns:ns0... | I know nothing about RDF's but it looks like ns0pred actually means 'name space 0', in xml you can define any namespace you want, in your example above you could have written
```
<rdf:Description rdf:about="http://localhost:8890/dataspace/test3/wiki/testWiki/MyTest">
<myPrefix:label xmlns:myPrefix="http://www.w3.o... |
415,926 | <p>As you know doing Cross Domain XMLHTTP requests is not allowed for security reasons under Internet Explorer.</p>
<p>I have a WebBrowser Control and I'm using <code>DocumentText</code> instead of <code>Navigate</code> to a URL. Since the current domain is <code>about:blank</code> when the page tries to do a request ... | [
{
"answer_id": 420751,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>I don't understand on which domain you don't have access to the Javascript...\nHave you tried using the <strong>sc... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40322/"
] | As you know doing Cross Domain XMLHTTP requests is not allowed for security reasons under Internet Explorer.
I have a WebBrowser Control and I'm using `DocumentText` instead of `Navigate` to a URL. Since the current domain is `about:blank` when the page tries to do a request to itself or other domain I'm getting `Acce... | I found a dirty workaround, load a local HTML (c:\temp\temp.html) and then modify the content of it via javascript.
After this point there is no more CrossDomain restrictions however using document.write causing other nasty problems such as JQuery `.ready` functions won't work. |
415,934 | <p>I have a xml given below:</p>
<pre><code><root title="الصفحة الرئيسة">
<item title="الصفحة الرئيسة" itemuri="tcm:8-29-4" ShowInNav="True" type="sg" pageuri="tcm:8-10592-64" sLink="/ara/index.aspx">
<item title="من نحن" itemuri="tcm:8-779-4" ShowInNav="True" type="sg" pageuri="tcm:8-9934-64" ... | [
{
"answer_id": 415947,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 0,
"selected": false,
"text": "<p>Have a look at <a href=\"http://www.exslt.org/math/functions/max/math.max.template.xsl\" rel=\"nofollow noreferrer\">this</a>. ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30394/"
] | I have a xml given below:
```
<root title="الصفحة الرئيسة">
<item title="الصفحة الرئيسة" itemuri="tcm:8-29-4" ShowInNav="True" type="sg" pageuri="tcm:8-10592-64" sLink="/ara/index.aspx">
<item title="من نحن" itemuri="tcm:8-779-4" ShowInNav="True" type="sg" pageuri="tcm:8-9934-64" navorder="00500" sLink="/ara/... | **Below is the XSLT 1.0 code of two possible solutions**.
**A third solution** is to use [**EXSLT**](http://exslt.org).
**A fourth solution** is to use the `maximum` template of **[FXSL](http://fxsl.sf.net)**.
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method=... |
415,955 | <p>This is an XML schema question.</p>
<p>I know that <code>xsd:all</code> element can't appear in a sequence (must be the top level element of its type).</p>
<p>That is, I cannot use the following:</p>
<pre><code><xsd:complexType name="Application">
<xsd:sequence>
<xsd:element ref="... | [
{
"answer_id": 416011,
"author": "Yossi Dahan",
"author_id": 43541,
"author_profile": "https://Stackoverflow.com/users/43541",
"pm_score": 4,
"selected": false,
"text": "<p>If I understand your request you are right on track, the only thing you're missing is maxOccurs=\"unbounded\" on yo... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51338/"
] | This is an XML schema question.
I know that `xsd:all` element can't appear in a sequence (must be the top level element of its type).
That is, I cannot use the following:
```
<xsd:complexType name="Application">
<xsd:sequence>
<xsd:element ref="Name"></xsd:element>
<xsd:all>
<xsd:element ref="ADD"></... | If I understand your request you are right on track, the only thing you're missing is maxOccurs="unbounded" on your choice.
I created the following schema:
```
<?xml version="1.0"?>
<xs:schema targetNamespace="http://someNamespace" xmlns="http://someNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:eleme... |
415,962 | <p>I am working on an application. That application should get the resume from the users, so that I need a code to verify whether a file exists or not.</p>
<p>I'm using ASP.NET / C#.</p>
| [
{
"answer_id": 415973,
"author": "James Ogden",
"author_id": 3198,
"author_profile": "https://Stackoverflow.com/users/3198",
"pm_score": 4,
"selected": false,
"text": "<p>To test whether a file exists in .NET, you can use</p>\n\n<pre><code>System.IO.File.Exists (String)\n</code></pre>\n"... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on an application. That application should get the resume from the users, so that I need a code to verify whether a file exists or not.
I'm using ASP.NET / C#. | You can determine whether a specified file exists using the `Exists` method of the `File` class in the `System.IO` namespace:
```
bool System.IO.File.Exists(string path)
```
You can find the [documentation here on MSDN](http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx).
**Example:**
```
using Sys... |
415,967 | <p>I often make a collection field unmodifiable before returning it from a getter method:</p>
<pre><code>private List<X> _xs;
....
List<X> getXs(){
return Collections.unmodifiableList(_xs);
}
</code></pre>
<p>But I can't think of a convenient way of doing that if the X above is itself a List:</p>
<pre>... | [
{
"answer_id": 415976,
"author": "Chii",
"author_id": 17335,
"author_profile": "https://Stackoverflow.com/users/17335",
"pm_score": 2,
"selected": false,
"text": "<p>unfortunately, there is no easy way to get deep const-ness in java. you would have to hack around it by always making sure... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18573/"
] | I often make a collection field unmodifiable before returning it from a getter method:
```
private List<X> _xs;
....
List<X> getXs(){
return Collections.unmodifiableList(_xs);
}
```
But I can't think of a convenient way of doing that if the X above is itself a List:
```
private List<List<Y>> _yLists;
.....
List<L... | The best I could come up with uses [ForwardingList from Google Collections](http://google-collections.googlecode.com/svn/trunk/javadoc/index.html?http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/package-summary.html). Comments are welcome.
```
private static <T> List<List<T>> unmodi... |
415,969 | <p>In JavaScript nested functions are very useful: closures, private methods and what have you..</p>
<p>What are nested PHP functions for? Does anyone use them and what for?</p>
<p>Here's a small investigation I did</p>
<pre><code><?php
function outer( $msg ) {
function inner( $msg ) {
echo 'inner: '.... | [
{
"answer_id": 416025,
"author": "Martijn Laarman",
"author_id": 47020,
"author_profile": "https://Stackoverflow.com/users/47020",
"pm_score": 8,
"selected": true,
"text": "<p>There is none basically. I've always treated this as a side effect of the parser.</p>\n<p>Eran Galperin is mista... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12161/"
] | In JavaScript nested functions are very useful: closures, private methods and what have you..
What are nested PHP functions for? Does anyone use them and what for?
Here's a small investigation I did
```
<?php
function outer( $msg ) {
function inner( $msg ) {
echo 'inner: '.$msg.' ';
}
echo 'outer... | There is none basically. I've always treated this as a side effect of the parser.
Eran Galperin is mistaken in thinking that these functions are somehow private. They are simply undeclared until `outer()` is run. They are also not privately scoped; they do pollute the global scope, albeit delayed. And as a callback, t... |
415,991 | <p>I need some help with the follow:</p>
<p>I have just read on this tutorial:
<a href="http://www.asp.net/LEARN/mvc/tutorial-13-cs.aspx" rel="nofollow noreferrer">http://www.asp.net/LEARN/mvc/tutorial-13-cs.aspx</a></p>
<p>and followed the example given for the "good solution". However, I encountered a problem afte... | [
{
"answer_id": 416080,
"author": "Giraffe",
"author_id": 50136,
"author_profile": "https://Stackoverflow.com/users/50136",
"pm_score": 0,
"selected": false,
"text": "<p>You can use a parameter in the constructor to pass it in:</p>\n\n<pre><code>public ApplicationController(string movieCa... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need some help with the follow:
I have just read on this tutorial:
<http://www.asp.net/LEARN/mvc/tutorial-13-cs.aspx>
and followed the example given for the "good solution". However, I encountered a problem after i made some modifications to the abstract class ApplicationController.
The original constructor was:
... | If you need Dynamic Menu In asp.net with following things.
* Gets rendered from database.
* Admin can change the name of the menu by simply updating the database table. For example Office org to My Org. etc.
* You don't want to hard code the redirection url for any menu click.(i.e. entry of url also in database).
* Si... |
415,995 | <p>Quoting from the <a href="http://msdn.microsoft.com/en-us/library/system.valuetype.aspx" rel="nofollow noreferrer">MSDN Link for ValueType Class</a></p>
<blockquote>
<p>In cases where it is necessary for a value type to behave like an object, a wrapper that makes the value type look like a reference object is alloca... | [
{
"answer_id": 416021,
"author": "Frederick The Fool",
"author_id": 32688,
"author_profile": "https://Stackoverflow.com/users/32688",
"pm_score": 1,
"selected": false,
"text": "<p>Yes that understanding is correct.</p>\n\n<p>These objects are no different from 'regular' objects in the CL... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40981/"
] | Quoting from the [MSDN Link for ValueType Class](http://msdn.microsoft.com/en-us/library/system.valuetype.aspx)
>
> In cases where it is necessary for a value type to behave like an object, a wrapper that makes the value type look like a reference object is allocated on the heap, and the value type's value is copied ... | The wrapper is a "box"; re garbage collection of boxes - there is **no** difference as far as the grabage collector is concerned. A box is collected with exactly the same rules and treatment as any other object.
however, if a value-type overrides a method (such as `ToString()`), it is not necessary to box it to call t... |
415,996 | <p>I have a string with markup in it which I need to find using Java.</p>
<p>eg.</p>
<pre><code>string = abc<B>def</B>ghi<B>j</B>kl
desired output..
segment [n] = start, end
segment [1] = 4, 6
segment [2] = 10, 10
</code></pre>
| [
{
"answer_id": 416006,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 4,
"selected": true,
"text": "<p>Regular expressions should work wonderfully for this. </p>\n\n<p>Refer to your JavaDoc for </p>\n\n<ul>\n<li>java.la... | 2009/01/06 | [
"https://Stackoverflow.com/questions/415996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/352728/"
] | I have a string with markup in it which I need to find using Java.
eg.
```
string = abc<B>def</B>ghi<B>j</B>kl
desired output..
segment [n] = start, end
segment [1] = 4, 6
segment [2] = 10, 10
``` | Regular expressions should work wonderfully for this.
Refer to your JavaDoc for
* java.langString.split()
* java.util.regex package
* java.util.Scanner
Note: StringTokenizer is not what you want since it splits around *characters*, not strings - the string delim is a list of characters, any one of which will split... |
416,027 | <p>I've been playing with idea to make a script to generate 2-characters words from a given set of characters in my language. However, as I am not into re-inventing the wheel, do you know about such a script publicly available for C#?</p>
| [
{
"answer_id": 416043,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not sure if I understood your question correctly, but this might help:</p>\n\n<pre><code>List<string> GetWords(IEn... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21209/"
] | I've been playing with idea to make a script to generate 2-characters words from a given set of characters in my language. However, as I am not into re-inventing the wheel, do you know about such a script publicly available for C#? | I'm not sure if I understood your question correctly, but this might help:
```
List<string> GetWords(IEnumberable<char> characters) {
char[] chars = characters.Distinct().ToArray();
List<string> words = new List<string>(chars.Length*chars.Length);
foreach (char i in chars)
foreach (char j in chars)
... |
416,081 | <p>I have an HTML element with a large collection of unordered lists contained within it. I need to clone this element to place elsewhere on the page with different styles added (this is simple enough using jQuery). </p>
<pre><code>$("#MainConfig").clone(false).appendTo($("#smallConfig"));
</code></pre>
<p>The probl... | [
{
"answer_id": 416175,
"author": "Salty",
"author_id": 50548,
"author_profile": "https://Stackoverflow.com/users/50548",
"pm_score": 4,
"selected": false,
"text": "<pre><code>$(\"#MainConfig\")\n .clone(false)\n .find(\"ul,li\")\n .removeAttr(\"id\")\n .appendTo($(\"#smallCon... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32021/"
] | I have an HTML element with a large collection of unordered lists contained within it. I need to clone this element to place elsewhere on the page with different styles added (this is simple enough using jQuery).
```
$("#MainConfig").clone(false).appendTo($("#smallConfig"));
```
The problem, however, is that all th... | If you need a way to reference the list items after you've cloned them, you must use classes, not IDs. Change all id="..." to class="..."
If you are dealing with legacy code or something and can't change the IDs to classes, you must remove the id attributes before appending.
```
$("#MainConfig").clone(false).find("*"... |
416,088 | <p>I have this legacy database for which I'm building a custom viewer using Linq to Sql.</p>
<p>Now some of the fields in a table can have the value NULL.
Using normal databinding in a DataTemplate (typed for the Class generated by the ORM Designer)</p>
<pre><code><TextBlock Text="{Binding Path=columnX}"/>
... | [
{
"answer_id": 416141,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 0,
"selected": false,
"text": "<p>Right click on the DBML file, click View code. Add a <code>partial class</code> for the table you want to work with. Add a ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | I have this legacy database for which I'm building a custom viewer using Linq to Sql.
Now some of the fields in a table can have the value NULL.
Using normal databinding in a DataTemplate (typed for the Class generated by the ORM Designer)
```
<TextBlock Text="{Binding Path=columnX}"/>
```
If columnX has value ... | The binding class has a property called ***TargetNullValue*** that can be used to substitute something else if the binding returns a NULL value. Your example becomes:-
```
<TextBlock Text="{Binding Path=columnX, TargetNullValue=My Substitute Text}"/>
```
There is another property of the Binding class that is also us... |
416,094 | <p>The following Html works great for me in FireFox or IE7/8 (with or without the Style Tag)</p>
<pre><code><!-- Deliberately no DocType to induce Quirks Mode -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
Input.quirks
{
margin: 1p... | [
{
"answer_id": 416318,
"author": "Ferdinand Beyer",
"author_id": 34855,
"author_profile": "https://Stackoverflow.com/users/34855",
"pm_score": 4,
"selected": true,
"text": "<p>The main difference between \"Quirks\" and \"Standards Compliance\" mode is a different \"box model\" which resu... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11356/"
] | The following Html works great for me in FireFox or IE7/8 (with or without the Style Tag)
```
<!-- Deliberately no DocType to induce Quirks Mode -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
Input.quirks
{
margin: 1px 0px 1px 0px;
border: sol... | The main difference between "Quirks" and "Standards Compliance" mode is a different "box model" which results in different ways of calculating sizes based on width/height, padding, margin and border settings. In Standard Compliance mode, the effective width and height of a box is calculated by adding all these paramete... |
416,108 | <p>Does the iPhone support garbage collection? If it does, then what are the alternate ways to perform the operations that are performaed using <code>+alloc</code> and <code>-init</code> combination:</p>
<pre><code>NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
UIImage *originalImage = [[UIImage ... | [
{
"answer_id": 416118,
"author": "Stephen Darlington",
"author_id": 2998,
"author_profile": "https://Stackoverflow.com/users/2998",
"pm_score": 3,
"selected": false,
"text": "<p>No, garbage collection is not supported on the iPhone currently. You need to use <code>alloc</code>/<code>rele... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49739/"
] | Does the iPhone support garbage collection? If it does, then what are the alternate ways to perform the operations that are performaed using `+alloc` and `-init` combination:
```
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
UIImage *originalImage = [[UIImage alloc] initWithData:data];
detailVie... | No. Garbage collection is too large an overhead for the limited battery life etc. on the device.
You must program always with an `alloc/release` pattern in mind.
```
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
...
[xmlParser release];
```
or (not suitable for every situation)
```
NSXMLPars... |
416,112 | <p>When i try to specify an absolute path for the generated files using</p>
<pre><code>someTemplate.RenderToFile("c:\\tmp\\filename.ext");
</code></pre>
<p>I'm getting the following error</p>
<p>Error 263 Running transformation: System.Runtime.InteropServices.COMException (0x80004005): There is already a file of t... | [
{
"answer_id": 416291,
"author": "Oleg Sych",
"author_id": 49858,
"author_profile": "https://Stackoverflow.com/users/49858",
"pm_score": 2,
"selected": true,
"text": "<p>Vitor,</p>\n\n<p>Are you using Template.RenderToFile method from <a href=\"http://www.codeplex.com/t4toolbox\" rel=\"n... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1842864/"
] | When i try to specify an absolute path for the generated files using
```
someTemplate.RenderToFile("c:\\tmp\\filename.ext");
```
I'm getting the following error
Error 263 Running transformation: System.Runtime.InteropServices.COMException (0x80004005): There is already a file of the same name in this folder.
even ... | Vitor,
Are you using Template.RenderToFile method from [T4Toolbox](http://www.codeplex.com/t4toolbox)? If yes, this method currently doesn't support saving files to a different folder. This has been on my to-do list for a while. What are you generating, anyway? |
416,116 | <p>I want to develop a web application (no frameworks) mixing java with groovy. I am using the IDE Netbeans with the plugin.</p>
<p>If I start a new Java SE project and add a groovy class, it works with no problems.. but when I create a new java EE project and add a groovy class it can't compile and shows me the follo... | [
{
"answer_id": 416291,
"author": "Oleg Sych",
"author_id": 49858,
"author_profile": "https://Stackoverflow.com/users/49858",
"pm_score": 2,
"selected": true,
"text": "<p>Vitor,</p>\n\n<p>Are you using Template.RenderToFile method from <a href=\"http://www.codeplex.com/t4toolbox\" rel=\"n... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37190/"
] | I want to develop a web application (no frameworks) mixing java with groovy. I am using the IDE Netbeans with the plugin.
If I start a new Java SE project and add a groovy class, it works with no problems.. but when I create a new java EE project and add a groovy class it can't compile and shows me the following error... | Vitor,
Are you using Template.RenderToFile method from [T4Toolbox](http://www.codeplex.com/t4toolbox)? If yes, this method currently doesn't support saving files to a different folder. This has been on my to-do list for a while. What are you generating, anyway? |
416,139 | <p>I've a tree control with checkboxes that uses the control from <a href="http://www.sephiroth.it/file_detail.php?id=151#" rel="noreferrer">http://www.sephiroth.it/file_detail.php?id=151#</a></p>
<p>Somehow I can't get the control to update when I change the dataProvider (i.e. by clicking a checkbox) the only way I c... | [
{
"answer_id": 417252,
"author": "inferis",
"author_id": 51998,
"author_profile": "https://Stackoverflow.com/users/51998",
"pm_score": 5,
"selected": true,
"text": "<p>I've found the Tree control a little touchy in Flex. The way I ended up forcing a redraw was to disconnect the dataProvi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40939/"
] | I've a tree control with checkboxes that uses the control from <http://www.sephiroth.it/file_detail.php?id=151#>
Somehow I can't get the control to update when I change the dataProvider (i.e. by clicking a checkbox) the only way I can get it to update is to use the scrollbar. How do I force the update? I've tried all ... | I've found the Tree control a little touchy in Flex. The way I ended up forcing a redraw was to disconnect the dataProvider and reconnect it, then force validation, something a bit like this :
```
private function forceRedraw(tree:Tree, dataProvider:Object):void
{
var scrollPosition:Number = tree.verticalScrollPos... |
416,143 | <p>I have this command that I run everyday via cron:</p>
<pre><code>find /home/get/public_html/videos -daystart -maxdepth 0
-mtime +1 -type f -name "*.flv" |xargs rm -f
</code></pre>
<p>The problem is that it doesn't delete the .flv files in a directory that are 1 or more days old.</p>
<p>How can I correct the abo... | [
{
"answer_id": 416155,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": "<p>It's better to use -print0 on find and -0 in xargs in case one file has an uncommon name.</p>\n\n<p>Also, you want... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | I have this command that I run everyday via cron:
```
find /home/get/public_html/videos -daystart -maxdepth 0
-mtime +1 -type f -name "*.flv" |xargs rm -f
```
The problem is that it doesn't delete the .flv files in a directory that are 1 or more days old.
How can I correct the above command?
EDIT: Paul - the comm... | It's better to use -print0 on find and -0 in xargs in case one file has an uncommon name.
Also, you want to use -maxdepth 1 to actually find something in the specified directory.
-maxdepth 0 means it'll only find in the directories listed in the command line, it won't check the contents of those directories. |
416,160 | <p>While developing my app I have come to realize that the majority of my app crashes have arisen from poor memory management.</p>
<p>I understand I can print or log retain counts through NSLog (@"retain count is:%d",[myInstance retainCount]);</p>
<p>But isn't there a better, less manual method? Possibly a visual rep... | [
{
"answer_id": 416169,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 4,
"selected": true,
"text": "<p>Use the Leaks and Object Allocation tools through XCode.</p>\n\n<pre><code>Run > Start with Performance Tool > ...\n<... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51420/"
] | While developing my app I have come to realize that the majority of my app crashes have arisen from poor memory management.
I understand I can print or log retain counts through NSLog (@"retain count is:%d",[myInstance retainCount]);
But isn't there a better, less manual method? Possibly a visual representation of yo... | Use the Leaks and Object Allocation tools through XCode.
```
Run > Start with Performance Tool > ...
``` |
416,161 | <p>I am really trying to show what htmlentities gives me, but it doesn't give & euro; for the € character.</p>
<p>I am trying</p>
<pre><code>echo htmlentities(htmlentities("LISBOA-VIENA DESDE 99€ TAXAS INCLUÍDAS, RESERVE JÁ",ENT_COMPAT,ISO-8859-1),ENT_COMPAT,ISO-8859-1);
echo '<br>';
echo htmlentiti... | [
{
"answer_id": 416196,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 3,
"selected": false,
"text": "<p>Use <code>ISO-8859-15</code> instead of <code>ISO-8859-1</code>.</p>\n\n<p><code>ISO-8859-15 (ISO Latin 9)</code... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] | I am really trying to show what htmlentities gives me, but it doesn't give & euro; for the € character.
I am trying
```
echo htmlentities(htmlentities("LISBOA-VIENA DESDE 99€ TAXAS INCLUÍDAS, RESERVE JÁ",ENT_COMPAT,ISO-8859-1),ENT_COMPAT,ISO-8859-1);
echo '<br>';
echo htmlentities(htmlentities("LISBOA-VIENA D... | This is discussed [here](http://www.cs.tut.fi/~jkorpela/html/euro.html); it seems € (`€`) works often. |
416,162 | <pre><code>ClassA* pa = NULL;
ClassA* pb = NULL;
void assignObject(ClassA* pa, ClassB* pb)
{
pa = new ClassA;
pb = new ClassB;
}
</code></pre>
<p>What will be the value of <code>pa</code> and <code>pb</code> after executing the function?</p>
<p>EDIT
how to pass as pointer is the return if pa,pb is NULL</p>
| [
{
"answer_id": 416168,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 0,
"selected": false,
"text": "<p>NULL, because you're passing the pointers in by value.</p>\n"
},
{
"answer_id": 416174,
"author": "mmx",
"a... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | ```
ClassA* pa = NULL;
ClassA* pb = NULL;
void assignObject(ClassA* pa, ClassB* pb)
{
pa = new ClassA;
pb = new ClassB;
}
```
What will be the value of `pa` and `pb` after executing the function?
EDIT
how to pass as pointer is the return if pa,pb is NULL | As pointed out in other answers - both will still be NULL after the call. However, there are two possible solutions to this problem:
1) **references**
```
void assignObject(ClassA*& pa, ClassB*& pb)
{
pa = new ClassA;
pb = new ClassB;
}
ClassA* pa = NULL;
ClassA* pb = NULL;
assignObject(pa, pb); // both will... |
416,182 | <p>I am writing a high performance parser, and it seems to me that <code>Int32.Parse</code> can be too slow. I wrote a simple version that assumes correct input, and it's performing much better. So should I create my own version instead? Or is there another faster method already available?</p>
<p>My method is like thi... | [
{
"answer_id": 416188,
"author": "Zach Hirsch",
"author_id": 50773,
"author_profile": "https://Stackoverflow.com/users/50773",
"pm_score": 3,
"selected": false,
"text": "<p>Have you profiled your code yet to determine that ParseInt32 is actually the bottleneck? I wouldn't replace somethi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | I am writing a high performance parser, and it seems to me that `Int32.Parse` can be too slow. I wrote a simple version that assumes correct input, and it's performing much better. So should I create my own version instead? Or is there another faster method already available?
My method is like this:
```
// parse simp... | If your parsing a format of which you know to be valid numbers, you can indeed write a faster custom parser. I've written a Double.Parse function for the same purpose once. And it faster to begin with the least significant digit. That way you can just increment the power of the digit your parsing.
I've created a quick... |
416,183 | <p>In Java, the idiomatic way to declare critical sections in the code is the following:</p>
<pre><code>private void doSomething() {
// thread-safe code
synchronized(this) {
// thread-unsafe code
}
// thread-safe code
}
</code></pre>
<p>Almost all blocks synchronize on <code>this</code>, but is there a p... | [
{
"answer_id": 416198,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 6,
"selected": false,
"text": "<p>I try to avoid synchronizing on <code>this</code> because that would allow everybody from the outside who had a reference... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] | In Java, the idiomatic way to declare critical sections in the code is the following:
```
private void doSomething() {
// thread-safe code
synchronized(this) {
// thread-unsafe code
}
// thread-safe code
}
```
Almost all blocks synchronize on `this`, but is there a particular reason for this? Are there o... | First, note that the following code snippets are identical.
```
public void foo() {
synchronized (this) {
// do something thread-safe
}
}
```
and:
```
public synchronized void foo() {
// do something thread-safe
}
```
do **exactly the same thing**. No preference for either one of them except f... |
416,185 | <p>I`m using SWFObject for flash player on my webpage.
Player as usual has buttons like Play, Stop, Pause etc.
I need to catch moment, when my user click on any button and i need to execute some JS-function in this time.
Sorry for my english and thanks a lot in advance.
P.S. I dont have sources of my swf file.</p>
| [
{
"answer_id": 416204,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 2,
"selected": false,
"text": "<p>AFAIK, this is done via the <code>getURL()</code> function. You need to define the following in the action script of... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52005/"
] | I`m using SWFObject for flash player on my webpage.
Player as usual has buttons like Play, Stop, Pause etc.
I need to catch moment, when my user click on any button and i need to execute some JS-function in this time.
Sorry for my english and thanks a lot in advance.
P.S. I dont have sources of my swf file. | AFAIK, this is done via the `getURL()` function. You need to define the following in the action script of the flash file:
```
this.onClick = function(){
getURL("javascript:yourFunctionName();");
};
```
This means you can't just take any flash file and make it call JS functions, it must be defined within the fla... |
416,208 | <p>Is there a way in JPA to map a collection of Enums within the Entity class? Or the only solution is to wrap Enum with another domain class and use it to map the collection?</p>
<pre><code>@Entity
public class Person {
public enum InterestsEnum {Books, Sport, etc... }
//@???
Collection<InterestsEnum&... | [
{
"answer_id": 416235,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 0,
"selected": false,
"text": "<p>Collections in JPA refer to one-to-many or many-to-many relationships and they can only contain other entities. Sorry, ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42512/"
] | Is there a way in JPA to map a collection of Enums within the Entity class? Or the only solution is to wrap Enum with another domain class and use it to map the collection?
```
@Entity
public class Person {
public enum InterestsEnum {Books, Sport, etc... }
//@???
Collection<InterestsEnum> interests;
}
``... | using Hibernate you can do
```
@ElementCollection(targetElement = InterestsEnum.class)
@JoinTable(name = "tblInterests", joinColumns = @JoinColumn(name = "personID"))
@Column(name = "interest", nullable = false)
@Enumerated(EnumType.STRING)
Collection<InterestsEnum> interests;
``` |
416,214 | <p>In excel workbook I am trying to copy data from sheet1 to sheet2 with a condition, IF((Sheet1!B2:B80=Sheet2!A2:A80),Sheet2!D2) i am not getting the result.please help me solve this.</p>
<p>I am trying to copy from sheet1 to sheet2 with a condition if the the value in sheet 1,column B is equal to the value in sheet... | [
{
"answer_id": 416229,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 1,
"selected": false,
"text": "<p>Try do <strong>debug it step by step</strong>. What happens, if you change your formula in:</p>\n\n<pre><code>=IF((Sheet... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In excel workbook I am trying to copy data from sheet1 to sheet2 with a condition, IF((Sheet1!B2:B80=Sheet2!A2:A80),Sheet2!D2) i am not getting the result.please help me solve this.
I am trying to copy from sheet1 to sheet2 with a condition if the the value in sheet 1,column B is equal to the value in sheet2 column A ... | Try do **debug it step by step**. What happens, if you change your formula in:
```
=IF((Sheet1!B2:B3=Sheet2!A2:A3),Sheet2!D2)
```
?
Or
```
=IF((Sheet1!B2:B3=Sheet2!A2:A3),"the same values")
```
Maybe not all the values are really exactly the same in columns A and B. Or D2 doesn't contain what you expect. |
416,220 | <p>I'm writing a semi-generic form plugin using jQuery in order to speed up the development of the project I'm working on.</p>
<p>The plan is that a <a href="http://jtemplates.tpython.com/" rel="nofollow noreferrer">jTemplates</a> template contains the fields, my plugin looks through the template to find any required ... | [
{
"answer_id": 416340,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 2,
"selected": false,
"text": "<p>I have found that in order to prevent the default action for an [enter] or [tab] key event you have to listen for the key... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I'm writing a semi-generic form plugin using jQuery in order to speed up the development of the project I'm working on.
The plan is that a [jTemplates](http://jtemplates.tpython.com/) template contains the fields, my plugin looks through the template to find any required multi-lingual resources, requests them from the... | Set the `autocomplete` attribute in your text fields to `off`:
```
opts.coreElement.find('input[type=text]').each(function() {
$(this).attr('autocomplete', 'off');
});
```
This works for all the major browsers (Safari, Firefox, IE). |
416,221 | <p>I'm getting this error... What is puzzling me is the fact that i do not have any type of security enabled for the page i'm invoking...</p>
<pre><code>WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);
</code></pre>
<p>When i access directly to the page ( on ie ) it works fi... | [
{
"answer_id": 416340,
"author": "meouw",
"author_id": 12161,
"author_profile": "https://Stackoverflow.com/users/12161",
"pm_score": 2,
"selected": false,
"text": "<p>I have found that in order to prevent the default action for an [enter] or [tab] key event you have to listen for the key... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32037/"
] | I'm getting this error... What is puzzling me is the fact that i do not have any type of security enabled for the page i'm invoking...
```
WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);
```
When i access directly to the page ( on ie ) it works fine, with the WebClient it'... | Set the `autocomplete` attribute in your text fields to `off`:
```
opts.coreElement.find('input[type=text]').each(function() {
$(this).attr('autocomplete', 'off');
});
```
This works for all the major browsers (Safari, Firefox, IE). |
416,237 | <p>Can a string be used as array index in C?</p>
<p>Ex:
String Corresponding value
"ONE" 1
"TWO" 2
"FIVE" 5
"TEN" 10</p>
<p>When a string in the above list is passed to the function, the function must return the corresponding value indicated above. Can this be achieved by declaring a const... | [
{
"answer_id": 416249,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 4,
"selected": false,
"text": "<p>It might compile, but it won't work.</p>\n\n<p>It's not entirely clear what you're trying to achieve. I think you want a... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can a string be used as array index in C?
Ex:
String Corresponding value
"ONE" 1
"TWO" 2
"FIVE" 5
"TEN" 10
When a string in the above list is passed to the function, the function must return the corresponding value indicated above. Can this be achieved by declaring a constant array with string as index
```
int *x;
x... | It might compile, but it won't work.
It's not entirely clear what you're trying to achieve. I think you want an [associative array](http://en.wikipedia.org/wiki/Associative_array), in which case you should find a library implementation of one.
If you're looking for something more like an [enumerated type](http://en.w... |
416,241 | <p>Has anyone had any luck with querying/changing SPNs on a Windows domain? Most of the hits on Google are SQL related: I can't find any information on how to do this myself. The most important things would be to query to SPN configuration and check for duplicates.</p>
<p>According to Arnout I made the following code:... | [
{
"answer_id": 416421,
"author": "Arnout",
"author_id": 3496,
"author_profile": "https://Stackoverflow.com/users/3496",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like this information is stored in the <code>servicePrincipalName</code> AD attribute. See <a href=\"http://blogs.... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24064/"
] | Has anyone had any luck with querying/changing SPNs on a Windows domain? Most of the hits on Google are SQL related: I can't find any information on how to do this myself. The most important things would be to query to SPN configuration and check for duplicates.
According to Arnout I made the following code:
```
stat... | It looks like this information is stored in the `servicePrincipalName` AD attribute. See [this page](http://blogs.technet.com/tristank/archive/2006/05/08/spns-r-fn.aspx) for more info, in particular the "Search using LDIFDE" section. |
416,263 | <p>I have two ASP.NET dropdownlist controls on a page. The first calls back to the server and obtains an array which is returned to the client and used to populate the second dropdownlist via javascript.
However if I make a selection in the second (and newly populated) dropdownlist and then do a postback the selection ... | [
{
"answer_id": 416282,
"author": "annakata",
"author_id": 13018,
"author_profile": "https://Stackoverflow.com/users/13018",
"pm_score": 0,
"selected": false,
"text": "<p>I'm guessing that \"you aren't doing things the asp.net way\". </p>\n\n<p>It seems likely to me that if your javascrip... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47036/"
] | I have two ASP.NET dropdownlist controls on a page. The first calls back to the server and obtains an array which is returned to the client and used to populate the second dropdownlist via javascript.
However if I make a selection in the second (and newly populated) dropdownlist and then do a postback the selection and... | You're correct in stating that you don't have the ViewState right, which is why the values aren't populated when you post the data back to the server.
I would **strongly** recommend that you migrate to using the [Cascading Drop Down](http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDow... |
416,265 | <p>There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array... | [
{
"answer_id": 416307,
"author": "Jonathan C Dickinson",
"author_id": 24064,
"author_profile": "https://Stackoverflow.com/users/24064",
"pm_score": 1,
"selected": false,
"text": "<p>It is a huge undertaking. I wrote the starts of an IL reader and it had a pretty good amount of opcodes im... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array (o... | I just wrote an extension method to get a more understandable list of instructions using GetILAsByteArray. It's quite simple, the API is like:
```
public static IList<Instruction> GetInstructions (this MethodBase self);
```
You can read more about the implementation in my [blog post](http://evain.net/blog/articles/2... |
416,273 | <p>I'm learning about POSIX threads right now, but I guess this is just a general question on multithreading, so I hope that anyone can help me. I have this example from the book that I am working on which demonstrates a race condition:</p>
<pre><code>void *thread_main(void *thread_number) {
printf("In thread numb... | [
{
"answer_id": 416296,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "<p>First, a race condition is a bad thing. This program should <em>not</em> work as you expect. A race condition means th... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm learning about POSIX threads right now, but I guess this is just a general question on multithreading, so I hope that anyone can help me. I have this example from the book that I am working on which demonstrates a race condition:
```
void *thread_main(void *thread_number) {
printf("In thread number %d.\n", *(i... | First off the \*(int \*)thread\_number is pointer stuff - when you just had thread\_number the 'strange numbers' were the pointer addresses to the 'i' from the *main* function (and unless I'm mistaken, they should all have been the same number for a single run of the program (so each of the 10 threads should have had t... |
416,314 | <p>I am using a windows service and i want to print a .html page when the service will start. I am using this code and it's printing well. But a print dialog box come, how do i print without the print dialog box?</p>
<pre><code>public void printdoc(string document)
{
Process printjob = new Process();
printjob.... | [
{
"answer_id": 416414,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>In windows service the Microsoft web browser control is not working. I had used that code it's working fine in windows app... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using a windows service and i want to print a .html page when the service will start. I am using this code and it's printing well. But a print dialog box come, how do i print without the print dialog box?
```
public void printdoc(string document)
{
Process printjob = new Process();
printjob.StartInfo.File... | Here's the Holy Grail.
Taking advantage of StaTaskScheduler (taken from Parallel Extension Extras ([release on Code Gallery](http://code.msdn.microsoft.com/ParExtSamples/Release/ProjectReleases.aspx?ReleaseId=4179))).
Features: waits for the printing completion, doesn't show print settings, hopefully reliable.
Limit... |
416,322 | <p>Today I came across a problem where someone had accidentally committed a proj.user file to the SVN repository. When i came to update, it obviously caused issues. </p>
<p>It got me wondering if there was any way that you can block certain file extensions to be committed to the repository.</p>
<p>I do realise there ... | [
{
"answer_id": 416333,
"author": "andrewrk",
"author_id": 432,
"author_profile": "https://Stackoverflow.com/users/432",
"pm_score": 0,
"selected": false,
"text": "<p>In SVN, you add files to the repository manually. Thus it does not make sense to have a file extension block list. You can... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | Today I came across a problem where someone had accidentally committed a proj.user file to the SVN repository. When i came to update, it obviously caused issues.
It got me wondering if there was any way that you can block certain file extensions to be committed to the repository.
I do realise there is an ignore list... | Yes, in general there are two ways. Either create commit-hooks (which is probably not what you want to do), or, more easily, add the svn:ignore property to your directory. Since properties are maintained along with the project, this will effect everyone. For instance, to ignore `*.user` files, you could add this to the... |
416,345 | <p>I'm currently refactoring/tidying up some old C code used in a C++ project, and regularly see functions such as:</p>
<pre><code>int f(void)
</code></pre>
<p>which I would tend to write as:</p>
<pre><code>int f()
</code></pre>
<p>Is there any reason not to replace (void) with () throughout the codebase in order to im... | [
{
"answer_id": 416354,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 8,
"selected": true,
"text": "<p>In C, the declaration <code>int f(void)</code> means a function returning int that takes no parameters. The declaratio... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22564/"
] | I'm currently refactoring/tidying up some old C code used in a C++ project, and regularly see functions such as:
```
int f(void)
```
which I would tend to write as:
```
int f()
```
Is there any reason not to replace (void) with () throughout the codebase in order to improve consistency, or is there a subtle diffe... | In C, the declaration `int f(void)` means a function returning int that takes no parameters. The declaration `int f()` means a function returning int that takes any number of parameters. Thus, if you have a function that takes no parameters in C, the former is the correct prototype.
In C++, I believe `int f(void)` is ... |
416,351 | <p>I have a bash script that runs a simulation program written in Fortran 90, and all output is redirected to a file. If the program finishes without problems, I set a success parameter. The code looks something like this:</p>
<pre>
#!/bin/bash
...
echo -n "Running program..."
./sim_program >& file && success="true"
i... | [
{
"answer_id": 416427,
"author": "user51568",
"author_id": 51568,
"author_profile": "https://Stackoverflow.com/users/51568",
"pm_score": 1,
"selected": false,
"text": "<p>I believe your error message is written on stderr. You need to redirect it to /dev/null.</p>\n\n<p>./sim_program 2>/d... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51634/"
] | I have a bash script that runs a simulation program written in Fortran 90, and all output is redirected to a file. If the program finishes without problems, I set a success parameter. The code looks something like this:
```
#!/bin/bash
...
echo -n "Running program..."
./sim_program >& file && success="true"
if [ $suc... | That error message is probably going to stderr.
Try putting this at the start of your script:
```
#!/bin/bash
exec 2> /dev/null
```
and anything send to stderr will go to the null device rather than your terminal. |
416,363 | <p>I am looking at an asp.net 2 web application that I am maintaining (but did not write).</p>
<p>Some things that should happen on the page loading do not, but only sometimes, and it seems to be if you are using Firefox 3 inside a VM. JQuery and asp.net Ajax are used.</p>
<p>The important function that should run ev... | [
{
"answer_id": 416385,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 1,
"selected": false,
"text": "<p>According to this <a href=\"http://www.tvidesign.co.uk/blog/sys.application.add_load-in-Firefox-3.aspx\" rel=\"no... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5599/"
] | I am looking at an asp.net 2 web application that I am maintaining (but did not write).
Some things that should happen on the page loading do not, but only sometimes, and it seems to be if you are using Firefox 3 inside a VM. JQuery and asp.net Ajax are used.
The important function that should run every time (but doe... | Try this:
```
<script type="text/javascript">
//<![CDATA[
$(document).ready(ImportantFunction);
$(document).ready(Otherstuff);
$(document).ready(MoreStuff);
//]]>
</script>
```
Put the call to `Sys.Application.add_load` in the body of `ImportantFunction`, i.e in your .js file:
```
function importantFunction()
{
... |
416,368 | <p>Is there a better way of doing this ?</p>
<pre><code>SELECT
(SELECT count(*) FROM `tbl` WHERE `status` = 0) as 'text1',
(SELECT count(*) FROM `tbl` WHERE `status` > 0) as 'text2'
</code></pre>
<p>text1 and text2 are headers.</p>
| [
{
"answer_id": 416391,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 3,
"selected": true,
"text": "<p>How about</p>\n\n<pre><code>select sum(if(status=0,1,0)) as zeros, \n sum(if(status>0,1,0)) as greater \nfrom ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52025/"
] | Is there a better way of doing this ?
```
SELECT
(SELECT count(*) FROM `tbl` WHERE `status` = 0) as 'text1',
(SELECT count(*) FROM `tbl` WHERE `status` > 0) as 'text2'
```
text1 and text2 are headers. | How about
```
select sum(if(status=0,1,0)) as zeros,
sum(if(status>0,1,0)) as greater
from tbl;
```
Might not necessarily be better, but it's a useful idiom to have in your mental arsenal! |
416,377 | <p>Given Wikipedia's discussion of <a href="http://en.wikipedia.org/wiki/Factorial#Double_factorial" rel="nofollow noreferrer">Double Factorial</a>s, can anyone suggest where I might find a bignum version of this for Perl, or else suggest how it might be written? </p>
| [
{
"answer_id": 416413,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 3,
"selected": true,
"text": "<p>Perl will handle whatever your C compiler can handle, for anything bigger you should be using <a href=\"http://perldoc.perl.or... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/426/"
] | Given Wikipedia's discussion of [Double Factorial](http://en.wikipedia.org/wiki/Factorial#Double_factorial)s, can anyone suggest where I might find a bignum version of this for Perl, or else suggest how it might be written? | Perl will handle whatever your C compiler can handle, for anything bigger you should be using [Math::BigInt](http://perldoc.perl.org/Math/BigInt.html).
I would recommend you read [perlnumber](http://perldoc.perl.org/perlnumber.html).
A definition for the double factorial (in perl golf):
```
sub f{$_[0]&&$_[0]>=2?$_[... |
416,401 | <p>In a project have been involved in I needed to render tables with columns of a specific width with only one HTML line per table row (no wrapping). I need each table cell to have a padding of 1 pixel at the top and bottom and 2 pixels at the left and right. The best way I can come up with that works <em>cross browser... | [
{
"answer_id": 416442,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": -1,
"selected": false,
"text": "<p>You should not need to nest a div within each table cell. The following should achieve the same affect.</p>\n\n<pre><code... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1142/"
] | In a project have been involved in I needed to render tables with columns of a specific width with only one HTML line per table row (no wrapping). I need each table cell to have a padding of 1 pixel at the top and bottom and 2 pixels at the left and right. The best way I can come up with that works *cross browser* is t... | Unfortunately table elements do not respect overflow, so you will need to apply that to a child element.
edit: I may have spoken too soon, as I can create this effect in FF using `max-width` and I've discovered [this thing](http://www.blakems.com/archives/000077.html) which might work for IE. You learn something every... |
416,406 | <p>I <a href="https://stackoverflow.com/questions/411837/finding-clusters-of-mass-in-a-matrix-bitmap#411855">half-answered a question about finding clusters of mass in a bitmap</a>. I say half-answered because I left it in a condition where I had all the points in the bitmap sorted by mass and left it to the reader to ... | [
{
"answer_id": 416426,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "<p>This sounds like color quantization, where you reduce the number of colors in an image. One way would be to plot t... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44639/"
] | I [half-answered a question about finding clusters of mass in a bitmap](https://stackoverflow.com/questions/411837/finding-clusters-of-mass-in-a-matrix-bitmap#411855). I say half-answered because I left it in a condition where I had all the points in the bitmap sorted by mass and left it to the reader to filter the lis... | Just so you know, you are asking for a solution to an [ill-posed](http://en.wikipedia.org/wiki/Ill-posed) problem: no definitive solution exists. That's fine...it just makes it more fun. Your problem is ill-posed mostly because you don't know how many clusters you want. Clustering is one of the key areas of machine lea... |
416,425 | <p>In Javascript I have defined a regular expression and now a user is typing in a string. I want to tell him if his string still could match the RegExp if he continues typing or if he's already on the wrong way. For instance:</p>
<pre><code>var re = /a*b/;
"a".isPrefixOf( re ); // true
"x".isPrefixOf( re ); // false... | [
{
"answer_id": 416444,
"author": "danivalentin",
"author_id": 52016,
"author_profile": "https://Stackoverflow.com/users/52016",
"pm_score": -1,
"selected": false,
"text": "<p>First you define your regular expression as:\nvar re = new RegExp(/^(regexp here)$/);</p>\n\n<p>on the onKeypres... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52023/"
] | In Javascript I have defined a regular expression and now a user is typing in a string. I want to tell him if his string still could match the RegExp if he continues typing or if he's already on the wrong way. For instance:
```
var re = /a*b/;
"a".isPrefixOf( re ); // true
"x".isPrefixOf( re ); // false
```
How cou... | People seem to be splitting evenly on how they interpret this question, so I'll demonstrate the concept with a Java example.
```
import java.util.regex.*;
public class Test
{
public static void main(String[] args) throws Exception
{
tryMatch("^a*b+$", "a", "ab", "abc");
}
public static void tryMatch(Str... |
416,432 | <p>I am evaluating options for efficient data storage in Java. The data set is time stamped data values with a named primary key. e.g.</p>
<pre><code>Name: A|B|C:D
Value: 124
TimeStamp: 01/06/2009 08:24:39,223
</code></pre>
<p>Could be a stock price at a given point in time, so it is, I suppose, a classic time series... | [
{
"answer_id": 416570,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": false,
"text": "<p>Hibernate (or any JPA solution) is the wrong tool for this job.</p>\n\n<p>JPA/Hibernate isn't a lightweight solution. I... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43786/"
] | I am evaluating options for efficient data storage in Java. The data set is time stamped data values with a named primary key. e.g.
```
Name: A|B|C:D
Value: 124
TimeStamp: 01/06/2009 08:24:39,223
```
Could be a stock price at a given point in time, so it is, I suppose, a classic time series data pattern. However, I ... | I would look at a [column oriented database](http://en.wikipedia.org/wiki/Column-oriented_DBMS "Column Oriented Database"). It would be great for this sort of application |
416,436 | <p>I have a simulation that reads large binary data files that we create (10s to 100s of GB). We use binary for speed reasons. These files are system dependent, converted from text files on each system that we run, so I'm not concerned about portability. The files currently are many instances of a POD struct, writte... | [
{
"answer_id": 416448,
"author": "mmmmmmmm",
"author_id": 44086,
"author_profile": "https://Stackoverflow.com/users/44086",
"pm_score": 2,
"selected": false,
"text": "<p>An identifier for the type of the file would be useful if you will have other structures written to binary files later... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2298/"
] | I have a simulation that reads large binary data files that we create (10s to 100s of GB). We use binary for speed reasons. These files are system dependent, converted from text files on each system that we run, so I'm not concerned about portability. The files currently are many instances of a POD struct, written with... | In my experience, second-guessing the data you'll need is invariably wasted time. What's important is to structure your *metadata* in a way that is extensible. For XML files, that's straightforward, but binary files require a bit more thought.
I tend to store metadata in a structure at the END of the file, not the beg... |
416,438 | <p>Is there a way to test if a regular expression "contains" another regular expression?<br/>
For example:<br/></p>
<pre><code>RegEX1 = "a.*b";
RegEx2 = "a1.*b";
</code></pre>
<p>RegEX1 "contains" RegEX2.<br/><br/>
As far as I know - this can't be done, am I wrong?
<hr/>
OK, joel.neely has shown that it can be done (... | [
{
"answer_id": 416483,
"author": "joel.neely",
"author_id": 3525,
"author_profile": "https://Stackoverflow.com/users/3525",
"pm_score": 4,
"selected": true,
"text": "<p>Yes.</p>\n\n<p><a href=\"http://www.w3.org/People/cmsmcq/2005/abdxsp.unicode.html\" rel=\"noreferrer\">This paper</a> c... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48317/"
] | Is there a way to test if a regular expression "contains" another regular expression?
For example:
```
RegEX1 = "a.*b";
RegEx2 = "a1.*b";
```
RegEX1 "contains" RegEX2.
As far as I know - this can't be done, am I wrong?
---
OK, joel.neely has shown that it can be done (haven't read it yet...) academically. ... | Yes.
[This paper](http://www.w3.org/People/cmsmcq/2005/abdxsp.unicode.html) contains a detailed discussion of the topic (see section 4.4). |
416,440 | <p>I am starting a new project with PHP and MySQL which is roughly the following:</p>
<p>Every minute I get a list of to-do transactions from an API from different users. </p>
<p>Example: </p>
<pre><code>user1 send $1 to user2
userx send $2 to usera
userw send $0.50 to user2
etc..
</code></pre>
<p>Lets say user1 w... | [
{
"answer_id": 416453,
"author": "Ali",
"author_id": 49153,
"author_profile": "https://Stackoverflow.com/users/49153",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest processing each transaction when the request for that transaction is received.</p>\n\n<p>I.E Bob clicks a '... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am starting a new project with PHP and MySQL which is roughly the following:
Every minute I get a list of to-do transactions from an API from different users.
Example:
```
user1 send $1 to user2
userx send $2 to usera
userw send $0.50 to user2
etc..
```
Lets say user1 wants to send $1 to user2. There are two ... | If you want to do it using the bare minimum variance from your current technology stack you're on the right track. Essentially you're re-creating a bare bones MQ or job server.
Minimum features you need for job/task/transaction queue are:
* the job (user1 send $2 to user2)
* the state (ready, out for processing, erro... |
416,451 | <p>I have a .mbm file that I copy to my device using this line in the .pkg file</p>
<pre><code>"$(EPOCROOT)epoc32\data\z\resource\apps\MyApp.mbm" -"!:\resource\apps\MyApp.mbm"
</code></pre>
<p>Then in the draw function of my container I do this..</p>
<pre><code>_LIT(KMBMFile , "\\resource\\apps\\MyApp.mbm" );
CFbsBi... | [
{
"answer_id": 416628,
"author": "adam",
"author_id": 33604,
"author_profile": "https://Stackoverflow.com/users/33604",
"pm_score": 2,
"selected": false,
"text": "<p>I have solved this problem so will post answer here for future lookers..</p>\n\n<p>Create an MBM file in your MMP file usi... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33604/"
] | I have a .mbm file that I copy to my device using this line in the .pkg file
```
"$(EPOCROOT)epoc32\data\z\resource\apps\MyApp.mbm" -"!:\resource\apps\MyApp.mbm"
```
Then in the draw function of my container I do this..
```
_LIT(KMBMFile , "\\resource\\apps\\MyApp.mbm" );
CFbsBitmap* iBitmap;
iBitmap->Load(KMBMFil... | You were dereferencing an uninitialized pointer, you could also use this:
```
// remember to include the EIK environemnt include file
#include <eikenv.h>
_LIT(KMBMFile , "\\resource\\apps\\MyApp.mbm" );
CFbsBitmap* iBitmap;
iBitmap = iEikonEnv->CreateBitmapL( KMBMFile, 0 );
gc.BitBlt( Rect().iTl, iBitmap );
``` |
416,454 | <p>What's the best way to keep a collection-object (List in example) in a Key/Value situation, where the key is a ID and the value is a collection of a type T?</p>
<p>Is this the only option or is there a better solution/another collection for this in .NET 3.5?</p>
<pre><code>var x = new Dictionary<int, List<ty... | [
{
"answer_id": 416531,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 0,
"selected": false,
"text": "<p>I have no idea if this is what you need but I'll have chop at it.</p>\n\n<pre><code>public Dictionary<int,List<T&g... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52031/"
] | What's the best way to keep a collection-object (List in example) in a Key/Value situation, where the key is a ID and the value is a collection of a type T?
Is this the only option or is there a better solution/another collection for this in .NET 3.5?
```
var x = new Dictionary<int, List<type>>();
``` | This is a good solution and will work quite well - you are effectively using a dictionary object of { key = int, value = 4 byte reference }.
When you retrieve a value by the key you will get back the reference to the `List<T>` on the heap and be able to use it. This will be a very efficent and compact solution to your... |
416,456 | <p>In VB6, I was told that when testing for an empty string, it would be much faster to check this by verifying the length of the string by using :</p>
<pre><code>If Len("ABC") = 0 then 'fast
</code></pre>
<p>or</p>
<pre><code>If LenB("ABC") = 0 then 'even faster
</code></pre>
<p>instead of:</p>
<pre><code>If "ABC... | [
{
"answer_id": 416469,
"author": "Tom Anderson",
"author_id": 13502,
"author_profile": "https://Stackoverflow.com/users/13502",
"pm_score": 1,
"selected": false,
"text": "<p>You should use:</p>\n\n<pre><code>If (\"Value\").Length > 0 Then\n\nEnd If\n</code></pre>\n"
},
{
"answ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45402/"
] | In VB6, I was told that when testing for an empty string, it would be much faster to check this by verifying the length of the string by using :
```
If Len("ABC") = 0 then 'fast
```
or
```
If LenB("ABC") = 0 then 'even faster
```
instead of:
```
If "ABC" = "" then 'slower
```
Do you know by any chance if this ... | I don't exactly the syntax for VB but in C# you can use the String static method `IsNullOrEmpty`:
```
String.IsNullOrEmpty("ABC")
```
When you are debugging this method, it will check on the .Length of the parameter. Checking on Length is always faster because on String compare, the compiler must create a new object... |
416,457 | <p>I am trying to define a WCF contract that returns an interface, something like below:</p>
<pre><code>[ServiceContract]
public interface IMyContracts
{
[OperationContract]
IMyInterface GetData(string request);
}
</code></pre>
<p>To get this to work I think my interface (<code>IMyInterface</code>) would have... | [
{
"answer_id": 421657,
"author": "Krzysztof Kozmic",
"author_id": 13163,
"author_profile": "https://Stackoverflow.com/users/13163",
"pm_score": 5,
"selected": true,
"text": "<p>AFAIK, the problem is not with serialization but with the fact that you're returning abstract entity (an interf... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30132/"
] | I am trying to define a WCF contract that returns an interface, something like below:
```
[ServiceContract]
public interface IMyContracts
{
[OperationContract]
IMyInterface GetData(string request);
}
```
To get this to work I think my interface (`IMyInterface`) would have to implement `ISerializable` to ensu... | AFAIK, the problem is not with serialization but with the fact that you're returning abstract entity (an interface). Abstraction is an OO concept, not SOA concept. So, your client's wcf stack may not know what to do with the class behind the interface. What if the client does not know the class behind the interface. Cl... |
416,464 | <p>I want to know if it is possible to end a for loop in C++ when an ending condition (different from the reacheing right number of iterations) is verified. For instance:</p>
<pre><code>for (int i = 0; i < maxi; ++i)
for (int j = 0; j < maxj; ++j)
// But if i == 4 < maxi AND j == 3 < maxj,
... | [
{
"answer_id": 416486,
"author": "Dynite",
"author_id": 16177,
"author_profile": "https://Stackoverflow.com/users/16177",
"pm_score": 1,
"selected": false,
"text": "<p>You can use labels, something along the lines of:</p>\n\n<pre><code>Outer:\nfor(...)\n{\n Inner:\n for(...)\n {... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25418/"
] | I want to know if it is possible to end a for loop in C++ when an ending condition (different from the reacheing right number of iterations) is verified. For instance:
```
for (int i = 0; i < maxi; ++i)
for (int j = 0; j < maxj; ++j)
// But if i == 4 < maxi AND j == 3 < maxj,
// then jump out of t... | You can use the `return` keyword: move the nested loop into a subroutine, invoke the subroutine to run the nested loops, and 'return' from the subroutine to exit [all] the loops. |
416,468 | <p>Weird behavior when mixing loading of assemblies using <code>Assembly.LoadFrom</code> and <code>Assembly.Load</code>:</p>
<p>I have encountered a weird behavior when loading assemblies with <code>Assembly.LoadFrom</code> and later on with <code>Assembly.Load</code>.
I am loading an assembly using <code>Assembly.Load... | [
{
"answer_id": 416480,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": true,
"text": "<p>That's not weird. As per the documentation, loading with Load and LoadFrom will place the assemblies in different co... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1596/"
] | Weird behavior when mixing loading of assemblies using `Assembly.LoadFrom` and `Assembly.Load`:
I have encountered a weird behavior when loading assemblies with `Assembly.LoadFrom` and later on with `Assembly.Load`.
I am loading an assembly using `Assembly.LoadFrom`, where the assembly is located in a folder, which is... | That's not weird. As per the documentation, loading with Load and LoadFrom will place the assemblies in different contexts. [This](http://blogs.msdn.com/suzcook/archive/2003/09/19/loadfile-vs-loadfrom.aspx) might help.
>
> 1. Any explanation why the CLR ignores the already loaded assembly?
>
>
>
Because they're i... |
416,473 | <p>My coworker is new to C# and didn't know about the coalesce operator. So, I saw him write a line of code like this:</p>
<pre><code>string foo = "" + str;
</code></pre>
<p>The idea being that if str is null, this expression would return an empty string. Of course, that could be rewritten as this:</p>
<pre><code>... | [
{
"answer_id": 416499,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 4,
"selected": true,
"text": "<p>IMO, it is much better to clearly define such logic i.e. don't use string concatenation to avoid null string and use condition... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | My coworker is new to C# and didn't know about the coalesce operator. So, I saw him write a line of code like this:
```
string foo = "" + str;
```
The idea being that if str is null, this expression would return an empty string. Of course, that could be rewritten as this:
```
string foo = str ?? "";
```
And I fee... | IMO, it is much better to clearly define such logic i.e. don't use string concatenation to avoid null string and use conditional statement or ?? operator.
Regarding other comments:
>
> there is also a performance benefit to
> using the null-coalescing operator,
> since no concatenation need take place
> (and, the... |
416,500 | <p>I have six string variables say str11, str12, str13, str21, str21 and str23.</p>
<p>I need to compare combination of these variables.</p>
<p>The combinations I have to check is str11 -- str12 -- str13 as one group and str21 -- str22 -- str23 as other group. I have to compare these two groups.</p>
<p>Now I'm in co... | [
{
"answer_id": 416518,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 3,
"selected": false,
"text": "<p>Splitting the comparison into three if statements is definitely not necessary. You could also simply do an AND w... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40614/"
] | I have six string variables say str11, str12, str13, str21, str21 and str23.
I need to compare combination of these variables.
The combinations I have to check is str11 -- str12 -- str13 as one group and str21 -- str22 -- str23 as other group. I have to compare these two groups.
Now I'm in confusion which method sho... | I’d test individually.
Is “AB” “CD” “EF” equal to “ABC” “DE” “F”?
Me thinks not.
P.S. If it is, then it’s a VERY special case, and if you decide to code it that way (as a concatenated comparison) then comment the hell out of it. |
416,522 | <p>Both <code>System.Timers.Timer</code> and <code>System.Threading.Timer</code> fire at intervals that are considerable different from the requested ones.
For example:</p>
<pre><code>new System.Timers.Timer(1000d / 20);
</code></pre>
<p>yields a timer that fires 16 times per second, not 20.</p>
<p>To be sure that t... | [
{
"answer_id": 416546,
"author": "robertpnl",
"author_id": 52031,
"author_profile": "https://Stackoverflow.com/users/52031",
"pm_score": 1,
"selected": false,
"text": "<p>There's a lot of reasons that the timer frequencies off. Example with the hardware, the same thread is busy with anot... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52041/"
] | Both `System.Timers.Timer` and `System.Threading.Timer` fire at intervals that are considerable different from the requested ones.
For example:
```
new System.Timers.Timer(1000d / 20);
```
yields a timer that fires 16 times per second, not 20.
To be sure that there are no side-effects from too long event handlers, ... | Well, I'm getting different number up to 100 Hz actually, with some big deviations, but in most cases closer to the requested number (running XP SP3 with most recent .NET SPs).
The System.Timer.Timer is implemented using System.Threading.Timer, so this explains why you see same results. I suppose that the timer is im... |
416,524 | <p>I know that if an IP falls outside the Subnet Mask + Local IP rules, it will be only reachable through an Gateway. The problem is that I don't know how to obtain the local IP address, neither the local subnet mask, programatically using .NET.
Any of you can help me?</p>
<p>I will use this information to squeeze the... | [
{
"answer_id": 416579,
"author": "Perry Neal",
"author_id": 44633,
"author_profile": "https://Stackoverflow.com/users/44633",
"pm_score": 1,
"selected": false,
"text": "<p>This will get you the host name and the IP address. I'm assuming you know the IPs in your LAN so you should be able... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | I know that if an IP falls outside the Subnet Mask + Local IP rules, it will be only reachable through an Gateway. The problem is that I don't know how to obtain the local IP address, neither the local subnet mask, programatically using .NET.
Any of you can help me?
I will use this information to squeeze the maximum p... | You can use the classes inside the System.Net.NetworkInformation namespace (introduced in .NET 2.0):
```
NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface iface in interfaces)
{
IPInterfaceProperties properties = iface.GetIPProper... |
416,528 | <p>I need help with the following SQL command.</p>
<p>I have 2 tables:</p>
<p>Table Weighings with columns:</p>
<ul>
<li>WeighingId</li>
<li>FileId</li>
<li>MyDateTime</li>
</ul>
<p>Table Files with columns:</p>
<ul>
<li>FileId</li>
<li>Name</li>
</ul>
<p>Table Weighings contains information when a specified file... | [
{
"answer_id": 416534,
"author": "Rockcoder",
"author_id": 5290,
"author_profile": "https://Stackoverflow.com/users/5290",
"pm_score": 2,
"selected": false,
"text": "<pre><code>SELECT F.Name, \n MAX(W.MyDateTime) AS MaxMyDateTime\nFROM Files F INNER JOIN Weighings W ON W.FileId = F... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20353/"
] | I need help with the following SQL command.
I have 2 tables:
Table Weighings with columns:
* WeighingId
* FileId
* MyDateTime
Table Files with columns:
* FileId
* Name
Table Weighings contains information when a specified file has been weighed. I need to make a list of last weighings of individual files, grouped ... | ```
SELECT F.Name,
MAX(W.MyDateTime) AS MaxMyDateTime
FROM Files F INNER JOIN Weighings W ON W.FileId = F.FileId
GROUP BY F.Name
ORDER BY F.Name
``` |
416,540 | <p>Is there a way in Java to have a map where the type parameter of a value is tied to the type parameter of a key? What I want to write is something like the following:</p>
<pre><code>public class Foo {
// This declaration won't compile - what should it be?
private static Map<Class<T>, T> defaultV... | [
{
"answer_id": 416592,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 2,
"selected": false,
"text": "<p>No, you can't do it directly. You'll need to write a wrapper class around <code>Map<Class, Object></code> to ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13065/"
] | Is there a way in Java to have a map where the type parameter of a value is tied to the type parameter of a key? What I want to write is something like the following:
```
public class Foo {
// This declaration won't compile - what should it be?
private static Map<Class<T>, T> defaultValues;
// These two m... | You're not trying to implement Joshua Bloch's typesafe hetereogeneous container pattern are you? Basically:
>
>
> ```
> public class Favorites {
> private Map<Class<?>, Object> favorites =
> new HashMap<Class<?>, Object>();
>
> public <T> void setFavorite(Class<T> klass, T thing) {
> favorites.put(klass... |
416,548 | <p>Let's say I have some XML like this</p>
<pre><code><channel>
<item>
<title>This is title 1</title>
</item>
</channel>
</code></pre>
<p>The code below does what I want in that it outputs the title as a string</p>
<pre><code>$xml = simplexml_load_string($xmlstring);
echo ... | [
{
"answer_id": 416636,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 8,
"selected": true,
"text": "<p><strong>Typecast the SimpleXMLObject to a string:</strong></p>\n\n<pre><code>$foo = array( (string) $xml->chan... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | Let's say I have some XML like this
```
<channel>
<item>
<title>This is title 1</title>
</item>
</channel>
```
The code below does what I want in that it outputs the title as a string
```
$xml = simplexml_load_string($xmlstring);
echo $xml->channel->item->title;
```
Here's my problem. The code below doesn... | **Typecast the SimpleXMLObject to a string:**
```
$foo = array( (string) $xml->channel->item->title );
```
The above code internally calls `__toString()` on the SimpleXMLObject. This method is not publicly available, as it interferes with the mapping scheme of the SimpleXMLObject, but it can still be invoked in the ... |
416,553 | <p>I'm customizing the product view page and I need to show the user's name.
How do I access the account information of the current user (if he's logged in) to get Name etc. ?</p>
| [
{
"answer_id": 416582,
"author": "Ali",
"author_id": 49153,
"author_profile": "https://Stackoverflow.com/users/49153",
"pm_score": -1,
"selected": false,
"text": "<p>I don't know this off the top of my head, but look in the file which shows the user's name, etc in the header of the page ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1228206/"
] | I'm customizing the product view page and I need to show the user's name.
How do I access the account information of the current user (if he's logged in) to get Name etc. ? | Found under "app/code/core/Mage/Page/Block/Html/Header.php":
```
public function getWelcome()
{
if (empty($this->_data['welcome'])) {
if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', Mage::getSingleton(... |
416,564 | <p>I have inherited some majorly spaghetti code (combination C#/VB) that I'm trying to understand here.</p>
<p>This appears to be a really weird situation where there are two successive calls to fire events to a remote object, which is being done by calling the DynamicInvoke method of a delegate, of the form:</p>
<pr... | [
{
"answer_id": 416692,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 2,
"selected": false,
"text": "<p>DynamicInvoke is definately a synchronous operation. The problem though is that the delegate it points to make not be... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7850/"
] | I have inherited some majorly spaghetti code (combination C#/VB) that I'm trying to understand here.
This appears to be a really weird situation where there are two successive calls to fire events to a remote object, which is being done by calling the DynamicInvoke method of a delegate, of the form:
```
delegate1.Dyn... | DynamicInvoke is definately a synchronous operation. The problem though is that the delegate it points to make not be synchronous. For instance the following code will call Console.WriteLine() in an asynchronous fashion.
```
Action write = () => Console.WriteLine("foo");
Action del1 = () => { ThreadPool.QueueUserWorkI... |
416,565 | <p>Wow, it's hard to find a simple explanation to this topic. A simple many-to-many relationship.</p>
<p>Three tables, tableA, tableB and a junction tableA_B. </p>
<p>I know how to set up the relationship, with keys and all, but I get a little confused when time comes to perform INSERT, UPDATE and DELETE queries....<... | [
{
"answer_id": 416630,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 1,
"selected": false,
"text": "<pre><code>SELECT *\nFROM a\nWHERE id IN (SELECT aid FROM ab WHERE bid = 1234)\n</code></pre>\n\n<p>or</p>\n\n<pre><code>SE... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52045/"
] | Wow, it's hard to find a simple explanation to this topic. A simple many-to-many relationship.
Three tables, tableA, tableB and a junction tableA\_B.
I know how to set up the relationship, with keys and all, but I get a little confused when time comes to perform INSERT, UPDATE and DELETE queries....
Basically, what... | The first thing I would do is recommend using an ORM like [Linq-To-Sql](http://msdn.microsoft.com/en-us/library/bb425822.aspx) or [NHibernate](http://www.hibernate.org/343.html) which will give you object representations of your data-model which make it much simpler to handle complex things like many-to-many CRUD opera... |
416,593 | <p><strong>Intention: To display the busy/Wait cursor for the duration that the children of the node are populated.</strong></p>
<p>Seems to be hidden in WPF. I remember having some kind of event in Winforms Tree Control where you could subscribe to - to achieve this.</p>
<p>Currently I have a TreeView which has a nu... | [
{
"answer_id": 416927,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit -</strong> The only way to accomplish this would be to make a class derived from TreeViewItem and override the... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | **Intention: To display the busy/Wait cursor for the duration that the children of the node are populated.**
Seems to be hidden in WPF. I remember having some kind of event in Winforms Tree Control where you could subscribe to - to achieve this.
Currently I have a TreeView which has a number of listviews tied to its ... | The ItemContainerGenerator will start generating after the Expanded event, so you can use that to set the Cursor, and set it back once [ItemContainerGenerator.StatusChanged](http://msdn.microsoft.com/en-us/library/system.windows.controls.itemcontainergenerator.statuschanged(VS.85).aspx) fires to indicate that your chil... |
416,616 | <p>I know it sounds weird but I am required to put a wrapping try catch block to every method to catch all exceptions. We have thousands of methods and I need to do it in an automated way. What do you suggest?</p>
<p>I am planning to parse all cs files and detect methods and insert a try catch block with an applicatio... | [
{
"answer_id": 416624,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 5,
"selected": false,
"text": "<p>DONT DO IT. There is no good reason for pokemon (\"gotta catch em all\")error handling. </p>\n\n<p>EDIT: After a few... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35012/"
] | I know it sounds weird but I am required to put a wrapping try catch block to every method to catch all exceptions. We have thousands of methods and I need to do it in an automated way. What do you suggest?
I am planning to parse all cs files and detect methods and insert a try catch block with an application. Can you... | I had to do something kinda sorta similar (add something to a lot of lines of code); I used regex.
I would create a regex script that found the beginning of each function and insert the try catch block right after the beginning. I would then create another regex script to find the end of the function (by finding the b... |
416,619 | <p>In IB it is easy to bind a label or text field to some controller's keyPath.</p>
<p>The NSDockTile (available via [[NSApp dockTile] setBadgeLabel:@"123"]) doesn't appear in IB, and I cannot figure out how to programmatically bind its "badgeLabel" property like you might bind a label/textfield/table column.</p>
<p>... | [
{
"answer_id": 416693,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 2,
"selected": false,
"text": "<p>If NSDockTile does support bindings, you can use the method <code>bind:toObject:withKeyPath:options:</code> to... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36170/"
] | In IB it is easy to bind a label or text field to some controller's keyPath.
The NSDockTile (available via [[NSApp dockTile] setBadgeLabel:@"123"]) doesn't appear in IB, and I cannot figure out how to programmatically bind its "badgeLabel" property like you might bind a label/textfield/table column.
Any ideas? | NSDockTile doesn't have any bindings, so your controller will have to update the dock tile manually. You could do this using KVO which would have the same effect as binding it.
Create a context as a global:
```
static void* MyContext=(void*)@"MyContext";
```
Then, in your init method:
```
[objectYouWantToWatch a... |
416,625 | <p>This has bugged me for a long time.</p>
<p>99% of the time, the GROUP BY clause is an exact copy of the SELECT clause, minus the aggregate functions (MAX, SUM, etc.).<br />
This breaks the Don't Repeat Yourself principle.</p>
<p>When can the GROUP BY clause not contain an exact copy of the SELECT clause minus the ag... | [
{
"answer_id": 416647,
"author": "Mark Bostleman",
"author_id": 22355,
"author_profile": "https://Stackoverflow.com/users/22355",
"pm_score": 1,
"selected": false,
"text": "<p>Actually, wouldn't that be 100% of the time? Is there a case in which you can have a (non-aggregate) column in ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7211/"
] | This has bugged me for a long time.
99% of the time, the GROUP BY clause is an exact copy of the SELECT clause, minus the aggregate functions (MAX, SUM, etc.).
This breaks the Don't Repeat Yourself principle.
When can the GROUP BY clause not contain an exact copy of the SELECT clause minus the aggregate functions?... | I tend to agree with you - this is one of many cases where SQL should have slightly smarter defaults to save us all some typing. For example, imagine if this were legal:
```
Select ClientName, InvoiceAmount, Sum(PaymentAmount) Group By *
```
where "\*" meant "all the non-aggregate fields". If everybody knew that's h... |
416,646 | <p>How should I initiate a delete action from my view?</p>
<p>Creating a new form-tag for each entity just doesn't seem right :-)</p>
<pre><code><% foreach (var subscriber in group.Subscribers) { %>
<tr>
<td><%= subscriber.Email %></td>
<td><%= Ht... | [
{
"answer_id": 416657,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 4,
"selected": true,
"text": "<p>I normally use checkboxes on the side of the items. Then I can have action links (buttons, whatever) that apply an ... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45467/"
] | How should I initiate a delete action from my view?
Creating a new form-tag for each entity just doesn't seem right :-)
```
<% foreach (var subscriber in group.Subscribers) { %>
<tr>
<td><%= subscriber.Email %></td>
<td><%= Html.ActionLink("[edit]", "edit", "subscriber", new {id=subscr... | I normally use checkboxes on the side of the items. Then I can have action links (buttons, whatever) that apply an action to the selected items (such as delete). |
416,651 | <p>Consider two iterator methods with the same bodies:</p>
<pre><code>public static IEnumerable<int> It1() {
...
}
public static IEnumerator<int> It2() {
...
}
</code></pre>
<p>Is there any circumstance where calling <code>It2</code> is different from calling <code>It1.GetEnumerator()</code>?</... | [
{
"answer_id": 416682,
"author": "casperOne",
"author_id": 50776,
"author_profile": "https://Stackoverflow.com/users/50776",
"pm_score": 3,
"selected": false,
"text": "<p>As noted, you can't <code>foreach</code> over an <code>IEnumerator<T></code>. Because of that, it makes it dif... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] | Consider two iterator methods with the same bodies:
```
public static IEnumerable<int> It1() {
...
}
public static IEnumerator<int> It2() {
...
}
```
Is there any circumstance where calling `It2` is different from calling `It1.GetEnumerator()`?
Is there ever a good reason to define an iterator as `IEnume... | You would do this if you wanted to take charge of writing the `IEnumerable<T>` wrapper class.
Let's say that you have a class that you want to do enumeration on, infinitely:
```
public class EveryDateInTheFuture : IEnumerable<DateTime>
{
public EveryDateInTheFuture() { this.StartDate = DateTime.Today; }
publ... |
416,691 | <p>I'm looking for a way to (preferably) strongly type a master page from a user control which is found in a content page that uses the master page.</p>
<p>Sadly, you can't use this in a user control:</p>
<pre><code><%@ MasterType VirtualPath="~/Masters/Whatever.master" %>
</code></pre>
<p>I'm trying to access... | [
{
"answer_id": 416719,
"author": "Sergio",
"author_id": 32037,
"author_profile": "https://Stackoverflow.com/users/32037",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tryed Page.FindControl(\"name\") on the usercontrol?</p>\n"
},
{
"answer_id": 416721,
"author": "Da... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/396/"
] | I'm looking for a way to (preferably) strongly type a master page from a user control which is found in a content page that uses the master page.
Sadly, you can't use this in a user control:
```
<%@ MasterType VirtualPath="~/Masters/Whatever.master" %>
```
I'm trying to access a property of the master page from the... | Try `Page.Master`.
```
Whatever whatev = (Whatever)Page.Master;
```
You'll have to make sure you add the proper `using` statements to the top of your file, or qualify the Master page type inline.
One potential gotcha is if this control is used by a different page whose master page is NOT the same type. This would o... |
416,740 | <p>I have two tables, tblEntities and tblScheduling.</p>
<p>tblEntities:</p>
<pre><code>EntityID ShortName Active
1 Dirtville 1
2 Goldtown 1
3 Blackston 0
4 Cornfelt 1
5 Vick 1
</code></pre>
<p>tblScheduling:</p>
<... | [
{
"answer_id": 416761,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 4,
"selected": true,
"text": "<p>Try this... Join conditions are evaluated to produce the intermediate Join result set, and then, (for an outer j... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22164/"
] | I have two tables, tblEntities and tblScheduling.
tblEntities:
```
EntityID ShortName Active
1 Dirtville 1
2 Goldtown 1
3 Blackston 0
4 Cornfelt 1
5 Vick 1
```
tblScheduling:
```
ScheduleID EntityID SchedulingYear... | Try this... Join conditions are evaluated to produce the intermediate Join result set, and then, (for an outer join), all the rows from the "Outer" side are added back in before moving on... Where conditions are evaluated after all joins are done...
```
SELECT E.EntityID, E.ShortName, S.ScheduleID
FROM tblEntities E... |
416,752 | <p>I'm using Zend_Form to output a set group of checkboxes:</p>
<pre><code><label style="white-space: nowrap;"><input type="checkbox" name="user_group[]" id="user_group-20" value="20">This Group</label>
</code></pre>
<p>With a normal HTTP Post these values are passed as an array, but when I'm somewh... | [
{
"answer_id": 416770,
"author": "Ali",
"author_id": 49153,
"author_profile": "https://Stackoverflow.com/users/49153",
"pm_score": 0,
"selected": false,
"text": "<p>You can have a javascript variable which stores the number of checkboxes that are emitted, i.e in the <code><head></c... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/204/"
] | I'm using Zend\_Form to output a set group of checkboxes:
```
<label style="white-space: nowrap;"><input type="checkbox" name="user_group[]" id="user_group-20" value="20">This Group</label>
```
With a normal HTTP Post these values are passed as an array, but when I'm somewhat stumped on how to grab all the values us... | You could use the checked selector to grab only the selected ones (negating the need to know the count or to iterate over them all yourself):
```
$("input[name='user_group[]']:checked")
```
With those checked items, you can either create a collection of those values or do something to the collection:
```
var values... |
416,760 | <p>I'm currently working on a hobby project, written in Java, containing about two different JFrames with about 3-4 JPanels each. The problem I'm facing is that I'm not so sure how to handle the interaction with my controller and different view classes.</p>
<p>For instance, I've an article by Sun on <a href="http://ja... | [
{
"answer_id": 416789,
"author": "Markus Lausberg",
"author_id": 39062,
"author_profile": "https://Stackoverflow.com/users/39062",
"pm_score": 1,
"selected": true,
"text": "<p>The controller can implement ActionListener and contains a List of ActionListeners.</p>\n\n<p>The controller you... | 2009/01/06 | [
"https://Stackoverflow.com/questions/416760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52057/"
] | I'm currently working on a hobby project, written in Java, containing about two different JFrames with about 3-4 JPanels each. The problem I'm facing is that I'm not so sure how to handle the interaction with my controller and different view classes.
For instance, I've an article by Sun on [Java App. design with MVC](... | The controller can implement ActionListener and contains a List of ActionListeners.
The controller you have to add to the The 3-4 top panels action listener.
Now you can add any ActionListener you want to the controller action listener list.
```
public void addListener(ActionListener listener)
{
mActionListeners.a... |