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
102,631
<p>I have had thoughts of trying to write a simple crawler that might crawl and produce a list of its findings for our NPO's websites and content.</p> <p>Does anybody have any thoughts on how to do this? Where do you point the crawler to get started? How does it send back its findings and still keep crawling? How does...
[ { "answer_id": 102665, "author": "whatsisname", "author_id": 8159, "author_profile": "https://Stackoverflow.com/users/8159", "pm_score": 0, "selected": false, "text": "<p>Use wget, do a recursive web suck, which will dump all the files onto your harddrive, then write another script to go...
2008/09/19
[ "https://Stackoverflow.com/questions/102631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have had thoughts of trying to write a simple crawler that might crawl and produce a list of its findings for our NPO's websites and content. Does anybody have any thoughts on how to do this? Where do you point the crawler to get started? How does it send back its findings and still keep crawling? How does it know w...
You'll be reinventing the wheel, to be sure. But here's the basics: * A list of unvisited URLs - seed this with one or more starting pages * A list of visited URLs - so you don't go around in circles * A set of rules for URLs you're not interested in - so you don't index the whole Internet Put these in persistent sto...
102,690
<p>This question comes out of the discussion on <a href="https://stackoverflow.com/questions/101825/whats-the-best-way-of-using-a-pair-triple-etc-of-values-as-one-value-in-c">tuples</a>.</p> <p>I started thinking about the hash code that a tuple should have. What if we will accept KeyValuePair class as a tuple? It do...
[ { "answer_id": 102757, "author": "Dan Blair", "author_id": 1327, "author_profile": "https://Stackoverflow.com/users/1327", "pm_score": 0, "selected": false, "text": "<p>I don't have the book reference anymore, and I'll have to find it just to confirm, but I thought the default base hash ...
2008/09/19
[ "https://Stackoverflow.com/questions/102690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2351099/" ]
This question comes out of the discussion on [tuples](https://stackoverflow.com/questions/101825/whats-the-best-way-of-using-a-pair-triple-etc-of-values-as-one-value-in-c). I started thinking about the hash code that a tuple should have. What if we will accept KeyValuePair class as a tuple? It doesn't override the Ge...
It seems that I have a clue now. I thought KeyValuePair is a reference type, but it is not, it is a struct. And so it uses ValueType.GetHashCode() method. MSDN for it says: "One or more fields of the derived type is used to calculate the return value". If you will take a real reference type as a "tuple-provider" you'...
102,720
<p>I just finished a medium sized web site and one thing I noticed about my css organization was that I have a lot of hard coded colour values throughout. This obviously isn't great for maintainability. Generally, when I design a site I pick 3-5 main colours for a theme. I end up setting some default values for para...
[ { "answer_id": 102791, "author": "JeeBee", "author_id": 17832, "author_profile": "https://Stackoverflow.com/users/17832", "pm_score": 0, "selected": false, "text": "<p>You could have a colours.css file with just the colours/images for each tag in.\nThen you can change the colours just by...
2008/09/19
[ "https://Stackoverflow.com/questions/102720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12529/" ]
I just finished a medium sized web site and one thing I noticed about my css organization was that I have a lot of hard coded colour values throughout. This obviously isn't great for maintainability. Generally, when I design a site I pick 3-5 main colours for a theme. I end up setting some default values for paragraphs...
That's exactly what you should do. The more centralized you can make your css, the easier it will be to make changes in the future. And let's be serious, you will want to change colors in the future. You should almost never hard-code any css into your html, it should **all** be in the css. Also, something I have ...
102,742
<p>Like many of you, I use ReSharper to speed up the development process. When you use it to override the equality members of a class, the code-gen it produces for <code>GetHashCode()</code> looks like:</p> <pre class="lang-cs prettyprint-override"><code> public override int GetHashCode() { unchecked ...
[ { "answer_id": 102878, "author": "Nick Johnson", "author_id": 12030, "author_profile": "https://Stackoverflow.com/users/12030", "pm_score": 8, "selected": true, "text": "<p>Probably because 397 is a prime of sufficient size to cause the result variable to overflow and mix the bits of the...
2008/09/19
[ "https://Stackoverflow.com/questions/102742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
Like many of you, I use ReSharper to speed up the development process. When you use it to override the equality members of a class, the code-gen it produces for `GetHashCode()` looks like: ```cs public override int GetHashCode() { unchecked { int result = (Key != null ? Key.GetHashC...
Probably because 397 is a prime of sufficient size to cause the result variable to overflow and mix the bits of the hash somewhat, providing a better distribution of hash codes. There's nothing particularly special about 397 that distinguishes it from other primes of the same magnitude.
102,759
<p>Everyone has accidentally forgotten the <code>WHERE</code> clause on a <code>DELETE</code> query and blasted some un-backed up data once or twice. I was pondering that problem, and I was wondering if the solution I came up with is practical.</p> <p>What if, in place of actual <code>DELETE</code> queries, the appli...
[ { "answer_id": 102809, "author": "Ken Ray", "author_id": 12253, "author_profile": "https://Stackoverflow.com/users/12253", "pm_score": 1, "selected": false, "text": "<p>You could set up a view on that table that selects WHERE to_be_deleted != 1, and all of your normal selects are done on...
2008/09/19
[ "https://Stackoverflow.com/questions/102759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16034/" ]
Everyone has accidentally forgotten the `WHERE` clause on a `DELETE` query and blasted some un-backed up data once or twice. I was pondering that problem, and I was wondering if the solution I came up with is practical. What if, in place of actual `DELETE` queries, the application and maintenance scripts did something...
That is fine if you want to do that, but it seems like a lot of work. How many people are manually changing the database? It should be very few, especially if your users have an app to work with. When I work on the production db I put EVERYTHING I do in a transaction so if I mess up I can rollback. Just having a stand...
102,850
<p>Doesn't work with other modules, but to give an example. I installed Text::CSV_XS with a CPAN setting:</p> <pre><code>'makepl_arg' =&gt; q[PREFIX=~/lib], </code></pre> <p>When I try running a test.pl script:</p> <blockquote> <p>$ perl test.pl</p> </blockquote> <pre><code>#!/usr/bin/perl use lib "/homes/foobar...
[ { "answer_id": 103018, "author": "Frosty", "author_id": 7476, "author_profile": "https://Stackoverflow.com/users/7476", "pm_score": 2, "selected": false, "text": "<p>Try this instead:</p>\n\n<pre><code>'makepl_arg' =&gt; q[PREFIX=~/]\n</code></pre>\n\n<p>PREFIX sets the base for all the ...
2008/09/19
[ "https://Stackoverflow.com/questions/102850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10523/" ]
Doesn't work with other modules, but to give an example. I installed Text::CSV\_XS with a CPAN setting: ``` 'makepl_arg' => q[PREFIX=~/lib], ``` When I try running a test.pl script: > > $ perl test.pl > > > ``` #!/usr/bin/perl use lib "/homes/foobar/lib/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi"; ...
Personally I would suggest to use [local::lib](http://search.cpan.org/dist/local-lib/). :)
102,881
<p>I am running some queries to track down a problem with our backup logs and would like to display datetime fields in 24-hour military time. Is there a simple way to do this? I've tried googling and could find nothing.</p>
[ { "answer_id": 102906, "author": "Nick Craver", "author_id": 13249, "author_profile": "https://Stackoverflow.com/users/13249", "pm_score": 0, "selected": false, "text": "<p>It's not oracle that determines the display of the date, it's the tool you're using to run queries. What are you u...
2008/09/19
[ "https://Stackoverflow.com/questions/102881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
I am running some queries to track down a problem with our backup logs and would like to display datetime fields in 24-hour military time. Is there a simple way to do this? I've tried googling and could find nothing.
``` select to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual; ``` Give the time in 24 hour format. More options are described [here](http://www.oradev.com/oracle_date_format.jsp).
102,964
<p>I have a Java bean like this:</p> <pre><code>class Person { int age; String name; } </code></pre> <p>I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages.</p> <p>The code to generate ...
[ { "answer_id": 103009, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>It's a bit hacky, but in your controller code you could just create a dummy Person object with the total in it!</p>\n\n<p>H...
2008/09/19
[ "https://Stackoverflow.com/questions/102964", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
I have a Java bean like this: ``` class Person { int age; String name; } ``` I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages. The code to generate the table rows will look somethin...
***Note:*** I tried combining answers to make a comprehensive list. I mentioned names where appropriate to give credit where it is due. There are many ways to solve this problem, with pros/cons associated with each: **Pure JSP Solution** As ScArcher2 mentioned above, a very easy and simple solution to the problem is...
103,000
<p>I need to retrieve a record from a database, display it on a web page (I'm using ASP.NET) but store the ID (primary key) from that record somewhere so I can go back to the database later with that ID (perhaps to do an update).</p> <p>I know there are probably a few ways to do this, such as storing the ID in ViewSta...
[ { "answer_id": 103024, "author": "Chris James", "author_id": 3193, "author_profile": "https://Stackoverflow.com/users/3193", "pm_score": -1, "selected": false, "text": "<pre><code>Session[\"MyId\"]=myval;\n</code></pre>\n\n<p>It would be a little safer and essentially offers the same mec...
2008/09/19
[ "https://Stackoverflow.com/questions/103000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4605/" ]
I need to retrieve a record from a database, display it on a web page (I'm using ASP.NET) but store the ID (primary key) from that record somewhere so I can go back to the database later with that ID (perhaps to do an update). I know there are probably a few ways to do this, such as storing the ID in ViewState or a hi...
It depends. Do you care if anyone sees the record id? If you do then both hidden fields and viewstate are not suitable; you need to store it in session state, or encrypt viewstate. Do you care if someone submits the form with a bogus id? If you do then you can't use a hidden field (and you need to look at CSRF protec...
103,005
<p>Here is my situation:</p> <p>Table one contains a set of data that uses an id for an unique identifier. This table has a one to many relationship with about 6 other tables such that.</p> <p>Given Table 1 with Id of 001: Table 2 might have 3 rows with foreign key: 001 Table 3 might have 12 rows with foreign key: 0...
[ { "answer_id": 103044, "author": "Forgotten Semicolon", "author_id": 1960, "author_profile": "https://Stackoverflow.com/users/1960", "pm_score": 2, "selected": false, "text": "<p>LEFT OUTER JOIN Tables2-N on Table1</p>\n\n<pre><code>SELECT Table1.*, Table2.*, Table3.*, Table4.*, Table5.*...
2008/09/19
[ "https://Stackoverflow.com/questions/103005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2246765/" ]
Here is my situation: Table one contains a set of data that uses an id for an unique identifier. This table has a one to many relationship with about 6 other tables such that. Given Table 1 with Id of 001: Table 2 might have 3 rows with foreign key: 001 Table 3 might have 12 rows with foreign key: 001 Table 4 might h...
LEFT OUTER JOIN Tables2-N on Table1 ``` SELECT Table1.*, Table2.*, Table3.*, Table4.*, Table5.* FROM Table1 LEFT OUTER JOIN Table2 ON Table1.ID = Table2.ID LEFT OUTER JOIN Table3 ON Table1.ID = Table3.ID LEFT OUTER JOIN Table4 ON Table1.ID = Table4.ID LEFT OUTER JOIN Table5 ON Table1.ID = Table5.ID WHERE (CRITERIA) `...
103,006
<p>I've got a CSV file containing latitude and longitude values, such as:</p> <blockquote> <p>"25°36'55.57""E","45°39'12.52""N"</p> </blockquote> <p>Anyone have a quick and simple piece of C# code to convert this to double values?</p> <p>Thanks</p>
[ { "answer_id": 103057, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 5, "selected": true, "text": "<p>If you mean C# code to do this:</p>\n\n<p>result = 25 + (36 / 60) + (55.57 / 3600)</p>\n\n<p>First you'll need to parse the ex...
2008/09/19
[ "https://Stackoverflow.com/questions/103006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5932/" ]
I've got a CSV file containing latitude and longitude values, such as: > > "25°36'55.57""E","45°39'12.52""N" > > > Anyone have a quick and simple piece of C# code to convert this to double values? Thanks
If you mean C# code to do this: result = 25 + (36 / 60) + (55.57 / 3600) First you'll need to parse the expression with Regex or some other mechanism and split it into the individual parts. Then: ``` String hour = "25"; String minute = "36"; String second = "55.57"; Double result = (hour) + (minute) / 60 + (second) ...
103,016
<p>When you pipe two process and kill the one at the "output" of the pipe, the first process used to receive the "Broken Pipe" signal, which usually terminated it aswell. E.g. running</p> <pre><code>$&gt; do_something_intensive | less </code></pre> <p>and then exiting <em>less</em> used to return you immediately to a...
[ { "answer_id": 103079, "author": "Daniel Papasian", "author_id": 7548, "author_profile": "https://Stackoverflow.com/users/7548", "pm_score": 3, "selected": false, "text": "<p>Well, if there is an attempt to write to a pipe after the reader has gone away, a SIGPIPE signal gets generated. ...
2008/09/19
[ "https://Stackoverflow.com/questions/103016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15304/" ]
When you pipe two process and kill the one at the "output" of the pipe, the first process used to receive the "Broken Pipe" signal, which usually terminated it aswell. E.g. running ``` $> do_something_intensive | less ``` and then exiting *less* used to return you immediately to a responsive shell, on a SuSE8 or for...
Thanks for your advices, the solution is getting closer... According to the manpage of tcsh, "non-login shells inherit the terminate behavior from their parents. Other signals have the values which the shell inherited from its parent." Which suggest my *terminal* is actually the root of the problem ... if it ignored ...
103,034
<p>I'm having an odd problem with my vs debugger. When running my program under the vs debugger, the debugger does not break on an unhandled exception. Instead control is returned to VS as if the program exited normally. If I look in the output tab, There is a first-chance exeption listed just before the thread term...
[ { "answer_id": 103049, "author": "hova", "author_id": 2170, "author_profile": "https://Stackoverflow.com/users/2170", "pm_score": 0, "selected": false, "text": "<p>There are two checkboxes in the \"Exceptions...\" box, I usually have to have them both checked to get it to break on unhand...
2008/09/19
[ "https://Stackoverflow.com/questions/103034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18978/" ]
I'm having an odd problem with my vs debugger. When running my program under the vs debugger, the debugger does not break on an unhandled exception. Instead control is returned to VS as if the program exited normally. If I look in the output tab, There is a first-chance exeption listed just before the thread terminatio...
If you're on a 64-bit OS, there's a pretty good chance you're being bitten by an OS-level behavior that causes exceptions to disappear. The most reliable way to reproduce it is to make a new WinForm application that simply throws an exception in OnLoad; it will appear to not get thrown. Take a look at these: 1. Visual...
103,136
<p>I am trying to execute some stored procedures in groovy way. I am able to do it quite easily by using straight JDBC but this does not seem in the spirit of Grails.</p> <p>I am trying to call the stored procedure as:</p> <pre><code>sql.query( "{call web_GetCityStateByZip(?,?,?,?,?)}",[params.postalcode, sql.out(j...
[ { "answer_id": 107518, "author": "Internet Friend", "author_id": 18037, "author_profile": "https://Stackoverflow.com/users/18037", "pm_score": 1, "selected": false, "text": "<p>This is still unanswered, so I did a bit of digging although I don't fully understand the problem. The followin...
2008/09/19
[ "https://Stackoverflow.com/questions/103136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to execute some stored procedures in groovy way. I am able to do it quite easily by using straight JDBC but this does not seem in the spirit of Grails. I am trying to call the stored procedure as: ``` sql.query( "{call web_GetCityStateByZip(?,?,?,?,?)}",[params.postalcode, sql.out(java.sql.Types.VARCHAR)...
This is still unanswered, so I did a bit of digging although I don't fully understand the problem. The following turned up from the Groovy source, perhaps it's of some help: This line seems to be the origin of the exception: <http://groovy.codehaus.org/xref/groovy/sql/Sql.html#1173> This would seem to indicate that ...
103,157
<p>Can someone please remind me how to create a .Net class from an XML file?<br></p> <p>I would prefer the batch commands, or a way to integrate it into the shell.<br></p> <p>Thanks!</p>
[ { "answer_id": 103191, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 0, "selected": false, "text": "<p>You might be able to use the xsd.exe tool to generate a class, otherwise you probably have to implement a cust...
2008/09/19
[ "https://Stackoverflow.com/questions/103157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14484/" ]
Can someone please remind me how to create a .Net class from an XML file? I would prefer the batch commands, or a way to integrate it into the shell. Thanks!
The below batch will create a .Net **Class** from **XML** in the current directory. So... XML -> XSD -> VB (Feel free to substitute CS for Language) Create a **Convert2Class.Bat** in the %UserProfile%\SendTo directory. Then copy/save the below: ``` @Echo off Set XsdExePath="C:\Program Files\Microsoft Visual St...
103,177
<p>How do you enumerate the fields of a certificate help in a store. Specifically, I am trying to enumerate the fields of personal certificates issued to the logged on user.</p>
[ { "answer_id": 103228, "author": "Duncan Smart", "author_id": 1278, "author_profile": "https://Stackoverflow.com/users/1278", "pm_score": 1, "selected": false, "text": "<p>See <a href=\"http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509store.aspx\"...
2008/09/19
[ "https://Stackoverflow.com/questions/103177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do you enumerate the fields of a certificate help in a store. Specifically, I am trying to enumerate the fields of personal certificates issued to the logged on user.
See <http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509store.aspx> ``` using System.Security.Cryptography.X509Certificates; ... var store = new X509Store(StoreName.My); foreach(var cert in store.Certificates) ... ```
103,179
<p>I know I can specify one for each form, or for the root form and then it'll cascade through to all of the children forms, but I'd like to have a way of overriding the default Java Coffee Cup for all forms even those I might forget.</p> <p>Any suggestions?</p>
[ { "answer_id": 103223, "author": "Andreas Bakurov", "author_id": 7400, "author_profile": "https://Stackoverflow.com/users/7400", "pm_score": 0, "selected": false, "text": "<p>Extend the JDialog class (for example name it MyDialog) and set the icon in constructor. Then all dialogs should ...
2008/09/19
[ "https://Stackoverflow.com/questions/103179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
I know I can specify one for each form, or for the root form and then it'll cascade through to all of the children forms, but I'd like to have a way of overriding the default Java Coffee Cup for all forms even those I might forget. Any suggestions?
You can make the root form (by which I assume you mean `JFrame`) be your own subclass of `JFrame`, and put standard functionality in its constructor, such as: ``` this.setIconImage(STANDARD_ICON); ``` You can bundle other standard stuff in here too, such as memorizing the frame's window metrics as a user preference,...
103,203
<p>We recently had a security audit and it exposed several weaknesses in the systems that are in place here. One of the tasks that resulted from it is that we need to update our partner credentials system make it more secure. </p> <p>The "old" way of doing things was to generate a (bad) password, give it to the part...
[ { "answer_id": 103648, "author": "delfuego", "author_id": 16414, "author_profile": "https://Stackoverflow.com/users/16414", "pm_score": 0, "selected": false, "text": "<p>I'm unclear why transmitting the passwords over SSL -- via HTTPS -- is being considered \"insecure\" by your audit tea...
2008/09/19
[ "https://Stackoverflow.com/questions/103203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12662/" ]
We recently had a security audit and it exposed several weaknesses in the systems that are in place here. One of the tasks that resulted from it is that we need to update our partner credentials system make it more secure. The "old" way of doing things was to generate a (bad) password, give it to the partner with an ...
### Password Generation As far as encoding a password for transmission, the only encoding that will truly add security is encryption. Using Base-64 or hexadecimal isn't for security, but just to be able to include it in a text format like XML. Entropy is used to measure password quality. So, choosing each bit with a ...
103,261
<p>I recently inherited an old visual basic 6/ crystal reports project which connects to a sql server database. The error message I get (Error# -2147191803 A String is required here) when I attempt to run the project seems to be narrowed down to the .Printout command in the following code: </p> <pre> 'Login ...
[ { "answer_id": 103346, "author": "Arthur Miller", "author_id": 13085, "author_profile": "https://Stackoverflow.com/users/13085", "pm_score": 1, "selected": false, "text": "<p>What is the value of your selected variable?</p>\n\n<p>Table.SetLogOnInfo ConnName, DBName, user, pass<br />\n<st...
2008/09/19
[ "https://Stackoverflow.com/questions/103261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18853/" ]
I recently inherited an old visual basic 6/ crystal reports project which connects to a sql server database. The error message I get (Error# -2147191803 A String is required here) when I attempt to run the project seems to be narrowed down to the .Printout command in the following code: ``` 'Login to databas...
What is the value of your selected variable? Table.SetLogOnInfo ConnName, DBName, user, pass **DomainName = selected** 'Set parameter Fields If it is not a string, then that might be the problem. Crystal expects a string variable and when it doesn't receive what it expects, it throws errors.
103,280
<p>If by some miracle a segfault occurs in our program, I want to catch the SIGSEGV and let the user (possibly a GUI client) know with a single return code that a serious problem has occurred. At the same time I would like to display information on the command line to show which signal was caught.</p> <p>Today our si...
[ { "answer_id": 103553, "author": "fizzer", "author_id": 18167, "author_profile": "https://Stackoverflow.com/users/18167", "pm_score": 0, "selected": false, "text": "<p>Write a launcher program to run your program and report abnormal exit code to the user.</p>\n" }, { "answer_id":...
2008/09/19
[ "https://Stackoverflow.com/questions/103280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11698/" ]
If by some miracle a segfault occurs in our program, I want to catch the SIGSEGV and let the user (possibly a GUI client) know with a single return code that a serious problem has occurred. At the same time I would like to display information on the command line to show which signal was caught. Today our signal handle...
This [table](http://docs.oracle.com/cd/E19963-01/html/821-1601/gen-61908.html#gen-95948) lists all of the functions that POSIX guarantees to be async-signal-safe and so can be called from a signal handler. By using the 'write' command from this table, the following relatively "ugly" solution hopefully will do the tric...
103,281
<p>At the beginning of each PHP page I open up the connection to MySQL, use it throughout the page and close it at the end of the page. However, I often redirect in the middle of the page to another page and so in those cases the connection does not be closed. I understand that this is not bad for performance of the we...
[ { "answer_id": 103293, "author": "David McLaughlin", "author_id": 3404, "author_profile": "https://Stackoverflow.com/users/3404", "pm_score": 5, "selected": true, "text": "<p>From: <a href=\"http://us3.php.net/manual/en/mysqli.close.php\" rel=\"noreferrer\">http://us3.php.net/manual/en/m...
2008/09/19
[ "https://Stackoverflow.com/questions/103281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
At the beginning of each PHP page I open up the connection to MySQL, use it throughout the page and close it at the end of the page. However, I often redirect in the middle of the page to another page and so in those cases the connection does not be closed. I understand that this is not bad for performance of the web s...
From: <http://us3.php.net/manual/en/mysqli.close.php> > > "Open connections (and similar resources) are automatically destroyed at the end of script execution. However, you should still close or free all connections, result sets and statement handles as soon as they are no longer required. This will help return resou...
103,298
<p>From managed C++, I am calling an unmanaged C++ method which returns a double. How can I convert this double into a managed string?</p>
[ { "answer_id": 103350, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 2, "selected": false, "text": "<p>C++ is definitely not my strongest skillset. Misread the question, but this should convert to a std::string, not e...
2008/09/19
[ "https://Stackoverflow.com/questions/103298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18170/" ]
From managed C++, I am calling an unmanaged C++ method which returns a double. How can I convert this double into a managed string?
I assume something like ``` (gcnew System::Double(d))->ToString() ```
103,312
<p>How can I test for the <code>EOF</code> flag in R? </p> <p>For example:</p> <pre><code>f &lt;- file(fname, "rb") while (???) { a &lt;- readBin(f, "int", n=1) } </code></pre>
[ { "answer_id": 103396, "author": "Ben Hoffstein", "author_id": 4482, "author_profile": "https://Stackoverflow.com/users/4482", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:readlines\" rel=\"noreferrer\">readLines</a> fu...
2008/09/19
[ "https://Stackoverflow.com/questions/103312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I test for the `EOF` flag in R? For example: ``` f <- file(fname, "rb") while (???) { a <- readBin(f, "int", n=1) } ```
The [readLines](http://wiki.r-project.org/rwiki/doku.php?id=rdoc:base:readlines) function will return a zero-length value when it reaches the EOF.
103,316
<p>In bash, environmental variables will tab-expand correctly when placed after an echo command, for example:</p> <pre><code>echo $HOME </code></pre> <p>But after cd or cat, bash places a \ before the $ sign, like so:</p> <pre><code>cd \$HOME </code></pre> <p>If I use a variable as the second argument to a command,...
[ { "answer_id": 103463, "author": "Brent ", "author_id": 3764, "author_profile": "https://Stackoverflow.com/users/3764", "pm_score": 2, "selected": false, "text": "<p>For the second instance, you can press ESC before tab to solve it.</p>\n\n<p>I don't know the solution to your problem, bu...
2008/09/19
[ "https://Stackoverflow.com/questions/103316", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14102/" ]
In bash, environmental variables will tab-expand correctly when placed after an echo command, for example: ``` echo $HOME ``` But after cd or cat, bash places a \ before the $ sign, like so: ``` cd \$HOME ``` If I use a variable as the second argument to a command, it won't expand at all: ``` cp somefile $HOM `...
Try ***complete -r cd*** to remove the special programmatic completion function that many Linux distributions install for the `cd` command. The function adds searching a list of of directories specified in the CDPATH variable to tab completions for `cd`, but at the expense of breaking the default completion behavior. ...
103,325
<p>Given this XML, what XPath returns all elements whose <code>prop</code> attribute contains <code>Foo</code> (the first three nodes):</p> <pre><code>&lt;bla&gt; &lt;a prop="Foo1"/&gt; &lt;a prop="Foo2"/&gt; &lt;a prop="3Foo"/&gt; &lt;a prop="Bar"/&gt; &lt;/bla&gt; </code></pre>
[ { "answer_id": 103364, "author": "toddk", "author_id": 17640, "author_profile": "https://Stackoverflow.com/users/17640", "pm_score": 3, "selected": false, "text": "<p>Have you tried something like:</p>\n\n<p>//a[contains(@prop, \"Foo\")]</p>\n\n<p>I've never used the contains function be...
2008/09/19
[ "https://Stackoverflow.com/questions/103325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
Given this XML, what XPath returns all elements whose `prop` attribute contains `Foo` (the first three nodes): ``` <bla> <a prop="Foo1"/> <a prop="Foo2"/> <a prop="3Foo"/> <a prop="Bar"/> </bla> ```
``` //a[contains(@prop,'Foo')] ``` Works if I use this XML to get results back. ``` <bla> <a prop="Foo1">a</a> <a prop="Foo2">b</a> <a prop="3Foo">c</a> <a prop="Bar">a</a> </bla> ``` Edit: Another thing to note is that while the XPath above will return the correct answer for that particular xml, if you want ...
103,382
<p>I'm using managed c++ to implement a method that returns a string. I declare the method in my header file using the following signature:</p> <pre><code>String^ GetWindowText() </code></pre> <p>However, when I'm using this method from C#, the signature is:</p> <pre><code>string GetWindowTextW(); </code></pre> <p>...
[ { "answer_id": 103398, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 3, "selected": true, "text": "<p>To get around the preprocessor hackery of the Windows header files, declare it like this:</p>\n\n<pre><code>#undef GetWindowTe...
2008/09/19
[ "https://Stackoverflow.com/questions/103382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15157/" ]
I'm using managed c++ to implement a method that returns a string. I declare the method in my header file using the following signature: ``` String^ GetWindowText() ``` However, when I'm using this method from C#, the signature is: ``` string GetWindowTextW(); ``` How do I get rid of the extra "W" at the end of t...
To get around the preprocessor hackery of the Windows header files, declare it like this: ``` #undef GetWindowText String^ GetWindowText() ``` Note that, if you actually use the Win32 or MFC `GetWindowText()` routines in your code, you'll need to either redefine the macro or call them as `GetWindowTextW()`.
103,389
<p>Does anyone know why in Oracle 11g when you do a Count(1) with more than one natural join it does a cartesian join and throws the count way off?</p> <p>Such as </p> <pre><code>SELECT Count(1) FROM record NATURAL join address NATURAL join person WHERE status=1 AND code = 1 AND state = 'TN' </code></pre> <p>This pu...
[ { "answer_id": 103467, "author": "Tony Andrews", "author_id": 18747, "author_profile": "https://Stackoverflow.com/users/18747", "pm_score": 2, "selected": false, "text": "<p>If it happens exactly as you say then it <strong>must</strong> be an optimiser bug, you should report it to Oracle...
2008/09/19
[ "https://Stackoverflow.com/questions/103389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12969/" ]
Does anyone know why in Oracle 11g when you do a Count(1) with more than one natural join it does a cartesian join and throws the count way off? Such as ``` SELECT Count(1) FROM record NATURAL join address NATURAL join person WHERE status=1 AND code = 1 AND state = 'TN' ``` This pulls back like 3 million rows when...
My advice would be to NOT use NATURAL JOIN. Explicitly define your join conditions to avoid confusion and "hidden bugs". Here is the [official NATURAL JOIN Oracle documentation](http://68.142.116.68/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#sthref9907) and [more discussion](http://awads.net/wp/2006/03/20...
103,407
<p>When attempting to call functions in <code>math.h</code>, I'm getting link errors like the following </p> <pre><code>undefined reference to sqrt </code></pre> <p>But I'm doing a <code>#include &lt;math.h&gt;</code><br> I'm using gcc and compiling as follows:</p> <pre><code>gcc -Wall -D_GNU_SOURCE blah.c -o blah ...
[ { "answer_id": 103411, "author": "FreeMemory", "author_id": 2132, "author_profile": "https://Stackoverflow.com/users/2132", "pm_score": 2, "selected": false, "text": "<p>You need to link the math library explicitly. Add <code>-lm</code> to the flags you're passing to gcc so that the link...
2008/09/19
[ "https://Stackoverflow.com/questions/103407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2132/" ]
When attempting to call functions in `math.h`, I'm getting link errors like the following ``` undefined reference to sqrt ``` But I'm doing a `#include <math.h>` I'm using gcc and compiling as follows: ``` gcc -Wall -D_GNU_SOURCE blah.c -o blah ``` Why can't the linker find the definition for `sqrt`?
Add -lm to the command when you call gcc: gcc -Wall -D\_GNU\_SOURCE blah.c -o blah -lm This will tell the linker to link with the math library. Including math.h will tell the compiler that the math functions like sqrt() exist, but they are defined in a separate library, which the linker needs to pack with your exec...
103,460
<p>I need to get the name of the machine my .NET app is running on. What is the best way to do this?</p>
[ { "answer_id": 103468, "author": "Billy Jo", "author_id": 3447, "author_profile": "https://Stackoverflow.com/users/3447", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx\" rel=\"nofollow noreferrer\"><cod...
2008/09/19
[ "https://Stackoverflow.com/questions/103460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14101/" ]
I need to get the name of the machine my .NET app is running on. What is the best way to do this?
Whilst others have already said that the [System.Environment.MachineName](http://msdn.microsoft.com/en-us/library/system.environment.machinename.aspx) returns you the name of the machine, beware... That property is only returning the NetBIOS name (and only if your application has EnvironmentPermissionAccess.Read permi...
103,489
<p>Below is the code I use to build an HTML table on the fly (using JSON data received from the server).</p> <p>I display an animated pleasewait (.gif) graphic while the data is loading. However, the graphic freezes while the JavaScript function is building the table. At first, I was just happy to make this happen (di...
[ { "answer_id": 103527, "author": "Jim", "author_id": 8427, "author_profile": "https://Stackoverflow.com/users/8427", "pm_score": 2, "selected": false, "text": "<p>What you are doing is building a string, and then parsing it all at once upon insertion. What about creating an actual table...
2008/09/19
[ "https://Stackoverflow.com/questions/103489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2755/" ]
Below is the code I use to build an HTML table on the fly (using JSON data received from the server). I display an animated pleasewait (.gif) graphic while the data is loading. However, the graphic freezes while the JavaScript function is building the table. At first, I was just happy to make this happen (display the ...
You basically want to set up your loops so they yield to other threads every so often. Here is some example code from [this article](http://www.julienlecomte.net/blog/2007/10/28/) on the topic of running CPU intensive operations without freezing your UI: ``` function doSomething (progressFn [, additional arguments]) {...
103,508
<p>I'm using start.jar and stop.jar to stop and start my jetty instance. I restart by calling stop.jar, then start.jar. The problem is, if I don't sleep long enough between stop.jar and start.jar I start getting these random ClassNotFoundExceptions and the application doesn't work correctly.</p> <p>Sleeping for a long...
[ { "answer_id": 103550, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Did you try JFGI?\nSetting up Ant task that could do the work for you?</p>\n\n<p>This blog post details how to setup target...
2008/09/19
[ "https://Stackoverflow.com/questions/103508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm using start.jar and stop.jar to stop and start my jetty instance. I restart by calling stop.jar, then start.jar. The problem is, if I don't sleep long enough between stop.jar and start.jar I start getting these random ClassNotFoundExceptions and the application doesn't work correctly. Sleeping for a longer period ...
Can you write a shell script that does something like this after calling shutdown and before calling startup? ``` LISTEN_PORT = `netstat -vatn | grep LISTEN| grep 8080 | wc -l ` while [$LISTEN_PORT -ne 0] ; do sleep 1 LISTEN_PORT = `netstat -vatn | grep LISTEN| grep 8080 | wc -l ` done ```
103,512
<p>I've heard that the <code>static_cast</code> function should be preferred to C-style or simple function-style casting. Is this true? Why?</p>
[ { "answer_id": 103529, "author": "prakash", "author_id": 123, "author_profile": "https://Stackoverflow.com/users/123", "pm_score": 3, "selected": false, "text": "<p>static_cast, aside from manipulating pointers to classes, can also be used to perform conversions explicitly defined in cla...
2008/09/19
[ "https://Stackoverflow.com/questions/103512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11575/" ]
I've heard that the `static_cast` function should be preferred to C-style or simple function-style casting. Is this true? Why?
The main reason is that classic C casts make no distinction between what we call `static_cast<>()`, `reinterpret_cast<>()`, `const_cast<>()`, and `dynamic_cast<>()`. These four things are completely different. A `static_cast<>()` is usually safe. There is a valid conversion in the language, or an appropriate construct...
103,516
<p>Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the...
[ { "answer_id": 103538, "author": "Steve Cooper", "author_id": 6722, "author_profile": "https://Stackoverflow.com/users/6722", "pm_score": 0, "selected": false, "text": "<p>Is your dev machine Win64? I've had problems with win64 builds of apps that go away if you set the build platform to...
2008/09/19
[ "https://Stackoverflow.com/questions/103516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12281/" ]
Using c#, VS2005, and .NET 2.0. (XP 32 bit) This is a Winforms app that gets called by a VBA addin (.xla) via Interop libraries. This app has been around for a while and works fine when the assembly is compiled and executed anywhere other than my dev machine. On dev it crashes hard (in debugger and just running the obj...
I've had problems in this scenario with Office 2003 in the past. Some things that have helped: * Installing Office 2003 Service Pack 2 stopped some crashes that happened when closing Excel. * Installing Office 2003 Service Pack 3 fixes a bug with using XP styles in a VSTO2005 application (not your case here) * Running...
103,532
<p>If you need to open a SqlConnection before issuing queries, can you simply handle all non-Open ConnectionStates in the same way? For example:</p> <pre><code> if (connection.State != ConnectionState.Open) { connection.Open(); } </code></pre> <p>I read somewhere that for ConnectionState.Broken th...
[ { "answer_id": 103832, "author": "Joe", "author_id": 13087, "author_profile": "https://Stackoverflow.com/users/13087", "pm_score": 3, "selected": false, "text": "<p>This isn't directly answering your question, but the best practice is to open and close a connection for every access to th...
2008/09/19
[ "https://Stackoverflow.com/questions/103532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/815/" ]
If you need to open a SqlConnection before issuing queries, can you simply handle all non-Open ConnectionStates in the same way? For example: ``` if (connection.State != ConnectionState.Open) { connection.Open(); } ``` I read somewhere that for ConnectionState.Broken the connection needs to be cl...
<http://msdn.microsoft.com/en-us/library/system.data.connectionstate.aspx> Broken connection state does need to be closed and reopened before eligible for continued use. Edit: Unfortunately closing a closed connection will balk as well. You'll need to test the ConnectionState before acting on an unknown connection. P...
103,560
<p>I have an ASP.net application that works fine in the development environment but in the production environment throws the following exception when clicking a link that performs a postback. Any ideas?</p> <blockquote> <p>Invalid postback or callback argument. Event validation is enabled using in configurat...
[ { "answer_id": 103599, "author": "azamsharp", "author_id": 3797, "author_profile": "https://Stackoverflow.com/users/3797", "pm_score": 0, "selected": false, "text": "<p>It seems that the data/controls on the page are changed when the postback occurs. What happens if you turn off the even...
2008/09/19
[ "https://Stackoverflow.com/questions/103560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3111/" ]
I have an ASP.net application that works fine in the development environment but in the production environment throws the following exception when clicking a link that performs a postback. Any ideas? > > Invalid postback or callback argument. > Event validation is enabled using > > in configuration or <%@ Page > ...
Problem description: This is one the common issues that a lot of ASP.NET beginners face, post, and ask about. Typically, they post the error message as below and seek for resolution without sharing much about what they were trying to do. [ArgumentException: Invalid postback or callback argument. Event validation is e...
103,561
<p>I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probably only deal with a couple of methods/...
[ { "answer_id": 104311, "author": "ripper234", "author_id": 11236, "author_profile": "https://Stackoverflow.com/users/11236", "pm_score": -1, "selected": false, "text": "<p>I would guess that it can't (seems a too-specific need).</p>\n" }, { "answer_id": 168262, "author": "ale...
2008/09/19
[ "https://Stackoverflow.com/questions/103561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3262/" ]
I am taking on a maintenance team and would like to introduce tools like FxCop and StyleCop to help improve the code and introduce the developers to better programming techniques and standards. Since we are maintaining code and not making significant enhancements, we will probably only deal with a couple of methods/rou...
I am using FxCopCmd.exe (FxCop 1.36) as an external tool with various command line parameters, including this one: ``` /types:<type list> [Short form: /t:<type list>] Analyze only these types and members. ```
103,575
<p>I am trying to validate the WPF form against an object. The validation fires when I type something in the textbox lose focus come back to the textbox and then erase whatever I have written. But if I just load the WPF application and tab off the textbox without writing and erasing anything from the textbox, then it i...
[ { "answer_id": 103641, "author": "cranley", "author_id": 10308, "author_profile": "https://Stackoverflow.com/users/10308", "pm_score": 4, "selected": false, "text": "<p>Unfortunately this is by design. WPF validation only fires if the value in the control has changed. </p>\n\n<p>Unbeli...
2008/09/19
[ "https://Stackoverflow.com/questions/103575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
I am trying to validate the WPF form against an object. The validation fires when I type something in the textbox lose focus come back to the textbox and then erase whatever I have written. But if I just load the WPF application and tab off the textbox without writing and erasing anything from the textbox, then it is n...
If you're not adverse to putting a bit of logic in your code behind, you can handle the actual *LostFocus* event with something like this: **.xaml** ``` <TextBox LostFocus="TextBox_LostFocus" .... ``` --- **.xaml.cs** ``` private void TextBox_LostFocus(object sender, RoutedEventArgs e) { ((Control)sender).Ge...
103,576
<p>I'm trying a very basic XPath on <a href="http://pastebin.com/f14a20a30" rel="noreferrer">this xml</a> (same as below), and it doesn't find anything. I'm trying both .NET and <a href="http://www.xmlme.com/XpathTool.aspx" rel="noreferrer">this website</a>, and XPaths such as <code>//PropertyGroup</code>, <code>/Prope...
[ { "answer_id": 103626, "author": "Pseudo Masochist", "author_id": 8529, "author_profile": "https://Stackoverflow.com/users/8529", "pm_score": 1, "selected": false, "text": "<p>Your issue is with the namespace (xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"). You're receiv...
2008/09/19
[ "https://Stackoverflow.com/questions/103576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I'm trying a very basic XPath on [this xml](http://pastebin.com/f14a20a30) (same as below), and it doesn't find anything. I'm trying both .NET and [this website](http://www.xmlme.com/XpathTool.aspx), and XPaths such as `//PropertyGroup`, `/PropertyGroup` and `//MSBuildCommunityTasksPath` are simply not working for me (...
You can add namespaces in your code and all that, but you can effectively wildcard the namespace. Try the following XPath idiom. ``` //*[local-name()='PropertyGroup'] //*[local-name()='MSBuildCommunityTasksPath'] ``` name() usually works as well, as in: ``` //*[name()='PropertyGroup'] //*[name()='MSBuildCommunityTa...
103,583
<p>This is written in PHP, but it's really language agnostic.</p> <pre><code>try { try { $issue = new DM_Issue($core-&gt;db-&gt;escape_string($_GET['issue'])); } catch(DM_Exception $e) { throw new Error_Page($tpl, ERR_NOT_FOUND, $e-&gt;getMessage()); } } catch(Error_Page $e) { ...
[ { "answer_id": 103625, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 2, "selected": false, "text": "<p>I think you'd be better off not nesting. If you expect multiple exception types, have multiple catches.</p>\n\n<pre><co...
2008/09/19
[ "https://Stackoverflow.com/questions/103583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
This is written in PHP, but it's really language agnostic. ``` try { try { $issue = new DM_Issue($core->db->escape_string($_GET['issue'])); } catch(DM_Exception $e) { throw new Error_Page($tpl, ERR_NOT_FOUND, $e->getMessage()); } } catch(Error_Page $e) { die($e); } ``` Is ...
You're using Exceptions for page logic, and I personally think that's not a good thing. Exceptions should be used to signal when bad or unexpected things happen, not to control the output of an error page. If you want to generate an error page based on Exceptions, consider using [set\_exception\_handler](http://www.php...
103,593
<p>I have:</p> <pre><code>&lt;?php $file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!"); if ($_POST["lastname"] &lt;&gt; "") { fwrite($file,$_POST["lastname"]."\n"); } fclose($file); ?&gt; </code></pre> <p>but it overwrites the beginning of the file. How do I make it insert?</p>
[ { "answer_id": 103609, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 6, "selected": true, "text": "<p>I'm not entirely sure of your question - do you want to write data and not have it over-write the beginning of an existing...
2008/09/19
[ "https://Stackoverflow.com/questions/103593", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have: ``` <?php $file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!"); if ($_POST["lastname"] <> "") { fwrite($file,$_POST["lastname"]."\n"); } fclose($file); ?> ``` but it overwrites the beginning of the file. How do I make it insert?
I'm not entirely sure of your question - do you want to write data and not have it over-write the beginning of an existing file, or write new data to the start of an existing file, keeping the existing content after it? **To insert text without over-writing the beginning of the file**, you'll have to open it for appen...
103,598
<p>Why was the <code>arguments.callee.caller</code> property deprecated in JavaScript?</p> <p>It was added and then deprecated in JavaScript, but it was omitted altogether by ECMAScript. Some browser (Mozilla, IE) have always supported it and don't have any plans on the map to remove support. Others (Safari, Opera) ...
[ { "answer_id": 103961, "author": "Zach", "author_id": 9128, "author_profile": "https://Stackoverflow.com/users/9128", "pm_score": 5, "selected": false, "text": "<p>It is better to use <strong>named functions</strong> than arguments.callee:</p>\n\n<pre><code> function foo () {\n ... f...
2008/09/19
[ "https://Stackoverflow.com/questions/103598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15992/" ]
Why was the `arguments.callee.caller` property deprecated in JavaScript? It was added and then deprecated in JavaScript, but it was omitted altogether by ECMAScript. Some browser (Mozilla, IE) have always supported it and don't have any plans on the map to remove support. Others (Safari, Opera) have adopted support fo...
Early versions of JavaScript did not allow named function expressions, and because of that we could not make a recursive function expression: ``` // This snippet will work: function factorial(n) { return (!(n>1))? 1 : factorial(n-1)*n; } [1,2,3,4,5].map(factorial); // But this snippet will not: [1,2,3,4,5]...
103,616
<p>I have an Apex class (controller) originally developed under Developer Edition and need to upload it to production which is Enterprise Edition.</p> <p>The upload fails with following message</p> <pre><code>classes/RenewalController.cls(RenewalController):An error occurred on your page. package.xml(RenewalControll...
[ { "answer_id": 177263, "author": "Dima Malenko", "author_id": 2586, "author_profile": "https://Stackoverflow.com/users/2586", "pm_score": 2, "selected": true, "text": "<p>Controller class may reference other custom SalesForce objects like pages. If controller is uploaded before these obj...
2008/09/19
[ "https://Stackoverflow.com/questions/103616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2586/" ]
I have an Apex class (controller) originally developed under Developer Edition and need to upload it to production which is Enterprise Edition. The upload fails with following message ``` classes/RenewalController.cls(RenewalController):An error occurred on your page. package.xml(RenewalController):An object 'Renewa...
Controller class may reference other custom SalesForce objects like pages. If controller is uploaded before these objects *Save error: An error occurred on your page.* is reported. Correct order of uploading of custom components should be used.
103,622
<p>We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it will start and run without issues. But i...
[ { "answer_id": 103830, "author": "kulakli", "author_id": 11131, "author_profile": "https://Stackoverflow.com/users/11131", "pm_score": 0, "selected": false, "text": "<p>Using Minimem (<a href=\"http://minimem.kerkia.net/\" rel=\"nofollow noreferrer\">http://minimem.kerkia.net/</a>) for t...
2008/09/19
[ "https://Stackoverflow.com/questions/103622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11051/" ]
We have a java program that requires a large amount of heap space - we start it with (among other command line arguments) the argument -Xmx1500m, which specifies a maximum heap space of 1500 MB. When starting this program on a Windows XP box that has been freshly rebooted, it will start and run without issues. But if t...
Agree with Torlack, a lot of this is because other DLLs are getting loaded and go into certain spots, breaking up the amount of memory you can get for the VM in one big chunk. You can do some work on WinXP if you have more than 3G of memory to get some of the windows stuff moved around, look up PAE here: <http://www.m...
103,630
<p>Is it possible to use an <a href="http://en.wikipedia.org/wiki/ASP.NET" rel="noreferrer">ASP.NET</a> web.sitemap with a jQuery <a href="http://users.tpg.com.au/j_birch/plugins/superfish/" rel="noreferrer">Superfish</a> menu? </p> <p>If not, are there any standards based browser agnostic plugins available that work...
[ { "answer_id": 103789, "author": "Smallinov", "author_id": 8897, "author_profile": "https://Stackoverflow.com/users/8897", "pm_score": 0, "selected": false, "text": "<p>The SiteMapDataSource control should be able to bind to any hierarchical data bound control. I'm not familiar with supe...
2008/09/19
[ "https://Stackoverflow.com/questions/103630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3742/" ]
Is it possible to use an [ASP.NET](http://en.wikipedia.org/wiki/ASP.NET) web.sitemap with a jQuery [Superfish](http://users.tpg.com.au/j_birch/plugins/superfish/) menu? If not, are there any standards based browser agnostic plugins available that work with the web.sitemap file?
I found this question while looking for the same answer... everyone *says* it's possible but no-one gives the actual solution! I seem to have it working now so thought I'd post my findings... Things I needed: * [Superfish](http://users.tpg.com.au/j_birch/plugins/superfish/#download) which also includes a version of [...
103,633
<p><a href="http://en.wikibooks.org/wiki/Combinatorics/Subsets_of_a_set-The_Binomial_Coefficient" rel="nofollow noreferrer">Pascal's rule</a> on counting the subset's of a set works great, when the set contains unique entities.</p> <p>Is there a modification to this rule for when the set contains duplicate items?</p> ...
[ { "answer_id": 103651, "author": "Dima", "author_id": 13313, "author_profile": "https://Stackoverflow.com/users/13313", "pm_score": 2, "selected": false, "text": "<p>A set only contains unique items. If there are duplicates, then it is no longer a set.</p>\n" }, { "answer_id": 1...
2008/09/19
[ "https://Stackoverflow.com/questions/103633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13824/" ]
[Pascal's rule](http://en.wikibooks.org/wiki/Combinatorics/Subsets_of_a_set-The_Binomial_Coefficient) on counting the subset's of a set works great, when the set contains unique entities. Is there a modification to this rule for when the set contains duplicate items? For instance, when I try to find the count of the ...
It looks like you want to know how many sub-multi-sets have, say, 3 elements. The math for this gets very tricky, very quickly. The idea is that you want to add together all of the combinations of ways to get there. So you have C(3,4) = 4 ways of doing it with no duplicated elements. B can be repeated twice in C(1,3) =...
103,654
<p>In several modern programming languages (including C++, Java, and C#), the language allows <a href="http://en.wikipedia.org/wiki/Integer_overflow" rel="noreferrer">integer overflow</a> to occur at runtime without raising any kind of error condition.</p> <p>For example, consider this (contrived) C# method, which doe...
[ { "answer_id": 103670, "author": "David Hill", "author_id": 1181217, "author_profile": "https://Stackoverflow.com/users/1181217", "pm_score": 5, "selected": false, "text": "<p>I think performance is a pretty good reason. If you consider every instruction in a typical program that increm...
2008/09/19
[ "https://Stackoverflow.com/questions/103654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12484/" ]
In several modern programming languages (including C++, Java, and C#), the language allows [integer overflow](http://en.wikipedia.org/wiki/Integer_overflow) to occur at runtime without raising any kind of error condition. For example, consider this (contrived) C# method, which does not account for the possibility of o...
In C#, it was a question of performance. Specifically, out-of-box benchmarking. When C# was new, Microsoft was hoping a lot of C++ developers would switch to it. They knew that many C++ folks thought of C++ as being fast, especially faster than languages that "wasted" time on automatic memory management and the like. ...
103,725
<p>I'm working on a project that generates PDFs that can contain fairly complex math and science formulas. The text is rendered in Times New Roman, which has pretty good Unicode coverage, but not complete. We have a system in place to swap in a more Unicode complete font for code points that don't have a glyph in TNR ...
[ { "answer_id": 103795, "author": "Stephen Deken", "author_id": 7154, "author_profile": "https://Stackoverflow.com/users/7154", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://www.freetype.org/\" rel=\"nofollow noreferrer\">FreeType</a> is a library that can read TrueType f...
2008/09/19
[ "https://Stackoverflow.com/questions/103725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19074/" ]
I'm working on a project that generates PDFs that can contain fairly complex math and science formulas. The text is rendered in Times New Roman, which has pretty good Unicode coverage, but not complete. We have a system in place to swap in a more Unicode complete font for code points that don't have a glyph in TNR (lik...
Here's a pass at it using c# and the windows API. ``` [DllImport("gdi32.dll")] public static extern uint GetFontUnicodeRanges(IntPtr hdc, IntPtr lpgs); [DllImport("gdi32.dll")] public extern static IntPtr SelectObject(IntPtr hDC, IntPtr hObject); public struct FontRange { public UInt16 Low; public UInt16 Hig...
103,765
<p>Here's the situation: I have a label's text set, immediately followed by a response.redirect() call as follows (this is just an example, but I believe it describes my situation accurately):</p> <p>aspx:</p> <pre><code>&lt;asp:Label runat="server" Text="default text" /&gt; </code></pre> <p>Code-behind (code called...
[ { "answer_id": 103813, "author": "Orion Adrian", "author_id": 7756, "author_profile": "https://Stackoverflow.com/users/7756", "pm_score": 1, "selected": false, "text": "<p>ASP and ASP.Net are inherently stateless unless state is explicitly specified. Normally between PostBacks informatio...
2008/09/19
[ "https://Stackoverflow.com/questions/103765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13578/" ]
Here's the situation: I have a label's text set, immediately followed by a response.redirect() call as follows (this is just an example, but I believe it describes my situation accurately): aspx: ``` <asp:Label runat="server" Text="default text" /> ``` Code-behind (code called on an onclick event): ``` Label.Text ...
After a redirect you will loose any state information associated to your controls. If you simply want the page to refresh, remove the redirect. After the code has finished executing, the page will refresh and any state will be kept. Behind the scenes, this works because ASP.NET writes the state information to a hidden...
103,829
<p>Given the following:</p> <pre><code>declare @a table ( pkid int, value int ) declare @b table ( otherID int, value int ) insert into @a values (1, 1000) insert into @a values (1, 1001) insert into @a values (2, 1000) insert into @a values (2, 1001) insert into @a values (2, 1002) insert into @b ...
[ { "answer_id": 103910, "author": "Cruachan", "author_id": 7315, "author_profile": "https://Stackoverflow.com/users/7315", "pm_score": 0, "selected": false, "text": "<p>Several ways of doing this, but a simple one is to create a union view as</p>\n\n<pre><code>create view qryMyUinion as\n...
2008/09/19
[ "https://Stackoverflow.com/questions/103829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4068/" ]
Given the following: ``` declare @a table ( pkid int, value int ) declare @b table ( otherID int, value int ) insert into @a values (1, 1000) insert into @a values (1, 1001) insert into @a values (2, 1000) insert into @a values (2, 1001) insert into @a values (2, 1002) insert into @b values (-1, 100...
Probably not the cheapest way to do it: ``` SELECT a.pkId,b.otherId FROM (SELECT a.pkId,CHECKSUM_AGG(DISTINCT a.value) as 'ValueHash' FROM @a a GROUP BY a.pkId) a INNER JOIN (SELECT b.otherId,CHECKSUM_AGG(DISTINCT b.value) as 'ValueHash' FROM @b b GROUP BY b.otherId) b ON a.ValueHash = b.ValueHash ``` You ca...
103,844
<p>List Comprehension for me seems to be like the opaque block of granite that regular expressions are for me. I need pointers.</p> <p>Say, I have a 2D list:</p> <pre><code>li = [[0,1,2],[3,4,5],[6,7,8]] </code></pre> <p>I would like to merge this either into one long list</p> <pre><code>li2 = [0,1,2,3,4,5,6,7,8] <...
[ { "answer_id": 103873, "author": "joeld", "author_id": 19104, "author_profile": "https://Stackoverflow.com/users/19104", "pm_score": 0, "selected": false, "text": "<pre><code>import itertools\nitertools.flatten( li )\n</code></pre>\n" }, { "answer_id": 103883, "author": "Eli ...
2008/09/19
[ "https://Stackoverflow.com/questions/103844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/577/" ]
List Comprehension for me seems to be like the opaque block of granite that regular expressions are for me. I need pointers. Say, I have a 2D list: ``` li = [[0,1,2],[3,4,5],[6,7,8]] ``` I would like to merge this either into one long list ``` li2 = [0,1,2,3,4,5,6,7,8] ``` or into a string with separators: ``` ...
Like so: ``` [ item for innerlist in outerlist for item in innerlist ] ``` Turning that directly into a string with separators: ``` ','.join(str(item) for innerlist in outerlist for item in innerlist) ``` Yes, the order of 'for innerlist in outerlist' and 'for item in innerlist' is correct. Even though the "body"...
103,918
<p>I am trying to install the ibm_db gem so that I can access DB2 from Ruby. When I try:</p> <pre><code>sudo gem install ibm_db </code></pre> <p>I get the following request for clarification:</p> <pre> Select which gem to install for your platform (i486-linux) 1. ibm_db 0.10.0 (ruby) 2. ibm_db 0.10.0 (mswin32) 3...
[ { "answer_id": 104102, "author": "John Topley", "author_id": 1450, "author_profile": "https://Stackoverflow.com/users/1450", "pm_score": 1, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>sudo gem install --platform ruby ibm_db\n</code></pre>\n\n<p>Note that you can get help o...
2008/09/19
[ "https://Stackoverflow.com/questions/103918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122/" ]
I am trying to install the ibm\_db gem so that I can access DB2 from Ruby. When I try: ``` sudo gem install ibm_db ``` I get the following request for clarification: ``` Select which gem to install for your platform (i486-linux) 1. ibm_db 0.10.0 (ruby) 2. ibm_db 0.10.0 (mswin32) 3. ibm_db 0.9.5 (mswin32) 4. ib...
You can use a 'here document'. That is: ``` sudo gem install ibm_db <<heredoc 1 heredoc ``` What's between the \<\<\SOMETHING and SOMETHING gets inputted as entry to the previous command (somewhat like ruby's own heredocuments). The 1 there alone, of course, is the selection of the "ibm\_db 0.10.0 (ruby)" platform...
103,919
<p>I want to store the current URL in a session variable to reference the previous visited page.</p> <p>If I store every URL (via a before_filter on ApplicationController), also actions which end in a redirect (create, update, etc) are considered as last visited page.</p> <p>Is there a way to tell Rails only to execu...
[ { "answer_id": 103954, "author": "William Yeung", "author_id": 16371, "author_profile": "https://Stackoverflow.com/users/16371", "pm_score": 0, "selected": false, "text": "<p>Can be a bit more specific? I cant get your question- by template you means render :view, the layout? or only whe...
2008/09/19
[ "https://Stackoverflow.com/questions/103919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11231/" ]
I want to store the current URL in a session variable to reference the previous visited page. If I store every URL (via a before\_filter on ApplicationController), also actions which end in a redirect (create, update, etc) are considered as last visited page. Is there a way to tell Rails only to execute a function if...
Not sure why `@performed_redirect` isn't working, you can see that it does exist and have the desired values by calling the actions on this test controller: ``` class RedirController < ApplicationController after_filter :redir_raise def raise_true redirect_to :action => :whatever end def raise_false ...
103,938
<p>I've been doing code review (mostly using tools like FindBugs) of one of our pet projects and FindBugs marked following code as erroneous (pseudocode):</p> <pre><code>Connection conn = dataSource.getConnection(); try{ PreparedStatement stmt = conn.prepareStatement(); //initialize the statement stmt.exe...
[ { "answer_id": 103994, "author": "neu242", "author_id": 13365, "author_profile": "https://Stackoverflow.com/users/13365", "pm_score": 5, "selected": false, "text": "<p>I've had problems with unclosed ResultSets in Oracle, even though the connection was closed. The error I got was </p>\n...
2008/09/19
[ "https://Stackoverflow.com/questions/103938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7918/" ]
I've been doing code review (mostly using tools like FindBugs) of one of our pet projects and FindBugs marked following code as erroneous (pseudocode): ``` Connection conn = dataSource.getConnection(); try{ PreparedStatement stmt = conn.prepareStatement(); //initialize the statement stmt.execute(); Re...
One problem with ONLY closing the connection and not the result set, is that if your connection management code is using connection pooling, the `connection.close()` would just put the connection back in the pool. Additionally, some database have a cursor resource on the server that will not be freed properly unless it...
103,945
<p>I've implemented a custom item renderer that I'm using with a combobox on a flex project I'm working on. It displays and icon and some text for each item. The only problem is that when the text is long the width of the menu is not being adjusted properly and the text is being truncated when displayed. I've tried twe...
[ { "answer_id": 104165, "author": "Herms", "author_id": 1409, "author_profile": "https://Stackoverflow.com/users/1409", "pm_score": 1, "selected": false, "text": "<p>Just a random thought (no clue if this will help):</p>\n\n<p>Try setting the parent HBox and the Label's widths to 100%. T...
2008/09/19
[ "https://Stackoverflow.com/questions/103945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2327/" ]
I've implemented a custom item renderer that I'm using with a combobox on a flex project I'm working on. It displays and icon and some text for each item. The only problem is that when the text is long the width of the menu is not being adjusted properly and the text is being truncated when displayed. I've tried tweaki...
Just a random thought (no clue if this will help): Try setting the parent HBox and the Label's widths to 100%. That's generally fixed any problems I've run into that were similar.
103,976
<p>How can you programmatically set the parameters for a subreport? For the top-level report, you can do the following:</p> <pre> reportViewer.LocalReport.SetParameters ( new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter("ParameterA", "Test"), ...
[ { "answer_id": 108859, "author": "John Hoven", "author_id": 1907, "author_profile": "https://Stackoverflow.com/users/1907", "pm_score": 1, "selected": false, "text": "<p>Add the parameter to the parent report and set the sub report parameter value from the parent report (in the actual re...
2008/09/19
[ "https://Stackoverflow.com/questions/103976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10834/" ]
How can you programmatically set the parameters for a subreport? For the top-level report, you can do the following: ``` reportViewer.LocalReport.SetParameters ( new Microsoft.Reporting.WebForms.ReportParameter[] { new Microsoft.Reporting.WebForms.ReportParameter("ParameterA", "Test"), new Mic...
Add the parameter to the parent report and set the sub report parameter value from the parent report (in the actual report definition). This is what I've read. Let me know if it works for you.
103,980
<p>I'm working on a document "wizard" for the company that I work for. It's a .dot file with a header consisting of some text and some form fields, and a lot of VBA code. The body of the document is pulled in as an OLE object from a separate .doc file.</p> <p>Currently, this is being done as a <code>Shape</code>, rath...
[ { "answer_id": 104116, "author": "GSerg", "author_id": 11683, "author_profile": "https://Stackoverflow.com/users/11683", "pm_score": 3, "selected": true, "text": "<p>InlineShape is treated as a letter. Hence, the same technique.</p>\n\n<pre><code>ThisDocument.Range(15).InlineShapes.AddPi...
2008/09/19
[ "https://Stackoverflow.com/questions/103980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13894/" ]
I'm working on a document "wizard" for the company that I work for. It's a .dot file with a header consisting of some text and some form fields, and a lot of VBA code. The body of the document is pulled in as an OLE object from a separate .doc file. Currently, this is being done as a `Shape`, rather than an `InlineSha...
InlineShape is treated as a letter. Hence, the same technique. ``` ThisDocument.Range(15).InlineShapes.AddPicture "1.gif" ```
103,989
<p>I need to implement an in-memory tuple-of-strings matching feature in C. There will be large list of tuples associated with different actions and a high volume of events to be matched against the list.</p> <p>List of tuples:</p> <pre><code>("one", "four") ("one") ("three") ("four", "five") ("six") </code></pr...
[ { "answer_id": 104151, "author": "freespace", "author_id": 8297, "author_profile": "https://Stackoverflow.com/users/8297", "pm_score": 1, "selected": false, "text": "<p>I don't know of any classical or right way to do this, so here is what I would do :P</p>\n\n<p>It looks like you want t...
2008/09/19
[ "https://Stackoverflow.com/questions/103989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7223/" ]
I need to implement an in-memory tuple-of-strings matching feature in C. There will be large list of tuples associated with different actions and a high volume of events to be matched against the list. List of tuples: ``` ("one", "four") ("one") ("three") ("four", "five") ("six") ``` event ("one", "two", "three...
If you only have a small number of possible tuple values it would make sense to write some sort of hashing function which could turn them into integer indexes for quick searching. If there are < 32 values you could do something with bitmasks: ``` unsigned int hash(char *value){...} typedef struct _tuple { unsign...
104,022
<p>I'm currently using <code>.resx</code> files to manage my server side resources for .NET.</p> <p>the application that I am dealing with also allows developers to plugin JavaScript into various event handlers for client side validation, etc.. What is the best way for me to localize my JavaScript messages and strings...
[ { "answer_id": 104051, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 2, "selected": false, "text": "<p>I would use an object/array notation:</p>\n\n<pre><code>var phrases={};\nphrases['fatalError'] ='On ...
2008/09/19
[ "https://Stackoverflow.com/questions/104022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7215/" ]
I'm currently using `.resx` files to manage my server side resources for .NET. the application that I am dealing with also allows developers to plugin JavaScript into various event handlers for client side validation, etc.. What is the best way for me to localize my JavaScript messages and strings? Ideally, I would ...
A basic JavaScript object is an associative array, so it can easily be used to store key/value pairs. So using [JSON](http://www.json.org), you could create an object for each string to be localized like this: ``` var localizedStrings={ confirmMessage:{ 'en/US':'Are you sure?', 'fr/FR':'Est-ce que ...
104,055
<p>I know how to use rpm to list the contents of a package (<code>rpm -qpil package.rpm</code>). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?</p>
[ { "answer_id": 104087, "author": "Thomi", "author_id": 1304, "author_profile": "https://Stackoverflow.com/users/1304", "pm_score": 5, "selected": false, "text": "<p>I don't think you can list the contents of a package using yum, but if you have the .rpm file on your local system (as will...
2008/09/19
[ "https://Stackoverflow.com/questions/104055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I know how to use rpm to list the contents of a package (`rpm -qpil package.rpm`). However, this requires knowing the location of the .rpm file on the filesystem. A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?
There is a package called `yum-utils` that builds on YUM and contains a tool called `repoquery` that can do this. ``` $ repoquery --help | grep -E "list\ files" -l, --list list files in this package/group ``` Combined into one example: ``` $ repoquery -l time /usr/bin/time /usr/share/doc/time-1.7 /usr...
104,063
<p>I noticed in another post, someone had done something like:</p> <pre><code>double d = 3.1415; int i = Convert.ToInt32(Math.Floor(d)); </code></pre> <p>Why did they use the convert function, rather than:</p> <pre><code>double d = 3.1415; int i = (int)d; </code></pre> <p>which has an implicit floor and convert.</p...
[ { "answer_id": 104180, "author": "NotDan", "author_id": 3291, "author_profile": "https://Stackoverflow.com/users/3291", "pm_score": 1, "selected": false, "text": "<p>You can use Convert when you have a string that you want to convert to an int </p>\n\n<pre><code>int i = Convert.ToInt32(\...
2008/09/19
[ "https://Stackoverflow.com/questions/104063", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15261/" ]
I noticed in another post, someone had done something like: ``` double d = 3.1415; int i = Convert.ToInt32(Math.Floor(d)); ``` Why did they use the convert function, rather than: ``` double d = 3.1415; int i = (int)d; ``` which has an implicit floor and convert. Also, more concerning, I noticed in some productio...
Casting to int is implicit truncation, not implicit flooring: ``` double d = -3.14; int i = (int)d; // i == -3 ``` I choose Math.Floor or Math.Round to make my intentions more explicit.
104,066
<p>I have two insert statements, almost exactly the same, which run in two different schemas on the same Oracle instance. What the insert statement looks like doesn't matter - I'm looking for a troubleshooting strategy here.</p> <p>Both schemas have 99% the same structure. A few columns have slightly different names, ...
[ { "answer_id": 104103, "author": "Eddie Awad", "author_id": 17273, "author_profile": "https://Stackoverflow.com/users/17273", "pm_score": 3, "selected": true, "text": "<p>Use the <a href=\"http://docs.oracle.com/cd/B19306_01/server.102/b14211/sqltrace.htm#g33356\" rel=\"nofollow noreferr...
2008/09/19
[ "https://Stackoverflow.com/questions/104066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16247/" ]
I have two insert statements, almost exactly the same, which run in two different schemas on the same Oracle instance. What the insert statement looks like doesn't matter - I'm looking for a troubleshooting strategy here. Both schemas have 99% the same structure. A few columns have slightly different names, other than...
Use the [SQL Trace facility and TKPROF](http://docs.oracle.com/cd/B19306_01/server.102/b14211/sqltrace.htm#g33356).
104,068
<p>Let's say we have the following method declaration:</p> <pre><code>Public Function MyMethod(ByVal param1 As Integer, _ Optional ByVal param2 As Integer = 0, _ Optional ByVal param3 As Integer = 1) As Integer Return param1 + param2 + param3 End Function </code></pre> <p>How does VB.NET make the optiona...
[ { "answer_id": 104094, "author": "John Rudy", "author_id": 14048, "author_profile": "https://Stackoverflow.com/users/14048", "pm_score": 3, "selected": false, "text": "<p>Contrary to popular belief, optional parameters do appear to be CLS-compliant. (However, my primary check for this wa...
2008/09/19
[ "https://Stackoverflow.com/questions/104068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14048/" ]
Let's say we have the following method declaration: ``` Public Function MyMethod(ByVal param1 As Integer, _ Optional ByVal param2 As Integer = 0, _ Optional ByVal param3 As Integer = 1) As Integer Return param1 + param2 + param3 End Function ``` How does VB.NET make the optional parameters work within t...
Interestingly, this is the decompiled C# code, obtained via reflector. ``` public int MyMethod(int param1, [Optional, DefaultParameterValue(0)] int param2, [Optional, DefaultParameterValue(1)] int param3) { return ((param1 + param2) + param3); } ``` Notice the Optional and...
104,158
<p>I came across this recently, up until now I have been happily overriding the equality operator (<strong>==</strong>) and/or <strong>Equals</strong> method in order to see if two references types actually contained the same <strong>data</strong> (i.e. two different instances that look the same).</p> <p>I have been us...
[ { "answer_id": 104178, "author": "Paul Shannon", "author_id": 11503, "author_profile": "https://Stackoverflow.com/users/11503", "pm_score": 2, "selected": false, "text": "<p>For complex objects that will yield specific comparisons then implementing IComparable and defining the comparison...
2008/09/19
[ "https://Stackoverflow.com/questions/104158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832/" ]
I came across this recently, up until now I have been happily overriding the equality operator (**==**) and/or **Equals** method in order to see if two references types actually contained the same **data** (i.e. two different instances that look the same). I have been using this even more since I have been getting mor...
It looks like you're coding in C#, which has a method called Equals that your class should implement, should you want to compare two objects using some other metric than "are these two pointers (because object handles are just that, pointers) to the same memory address?". I grabbed some sample code from [here](http://...
104,184
<p>There is a case where a map will be constructed, and once it is initialized, it will never be modified again. It will however, be accessed (via get(key) only) from multiple threads. Is it safe to use a <code>java.util.HashMap</code> in this way?</p> <p>(Currently, I'm happily using a <code>java.util.concurrent.Co...
[ { "answer_id": 104251, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://www.docjar.com/html/api/java/util/HashMap.java.html\" rel=\"nofollow noreferrer\">http://www.docjar.com/...
2008/09/19
[ "https://Stackoverflow.com/questions/104184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3093/" ]
There is a case where a map will be constructed, and once it is initialized, it will never be modified again. It will however, be accessed (via get(key) only) from multiple threads. Is it safe to use a `java.util.HashMap` in this way? (Currently, I'm happily using a `java.util.concurrent.ConcurrentHashMap`, and have n...
Your idiom is safe **if and only if** the reference to the `HashMap` is *safely published*. Rather than anything relating the internals of `HashMap` itself, *safe publication* deals with how the constructing thread makes the reference to the map visible to other threads. Basically, the only possible race here is betwe...
104,223
<p>I have noticed that cURL in PHP returns different data when told to output to a file via <code>CURLOPT_FILE</code> as it does when told to send the output to a string via <code>CURLOPT_RETURNTRANSFER</code>.</p> <p><code>_RETURNTRANSFER</code> seems to strip newlines and extra white space as if parsing it for displ...
[ { "answer_id": 104750, "author": "p4bl0", "author_id": 12043, "author_profile": "https://Stackoverflow.com/users/12043", "pm_score": 0, "selected": false, "text": "<p>I didn't try to reproduce the \"bug\" (I think we can consider this as a bug if it is the actual behavior), but maybe you...
2008/09/19
[ "https://Stackoverflow.com/questions/104223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1536217/" ]
I have noticed that cURL in PHP returns different data when told to output to a file via `CURLOPT_FILE` as it does when told to send the output to a string via `CURLOPT_RETURNTRANSFER`. `_RETURNTRANSFER` seems to strip newlines and extra white space as if parsing it for display as standard HTML code. `_FILE` on the ot...
Turns out, the error is not in what was being returned, but in the way I was going about parsing it. \r\n is not parsed the way I expected when put in single quotes, switching to double quotes solved my problem. I was not aware that this made a difference inside function calls like that. This works just fine:`$cresult...
104,224
<p>I'm working on a WPF application that sometimes exhibits odd problems and appears to <em>hang</em> in the UI. It is inconsistent, it happens in different pages, but it happens often enough that it is a big problem. I should mention that it is not a true hang as described below.</p> <p>My first thought was that th...
[ { "answer_id": 104272, "author": "Bob King", "author_id": 6897, "author_profile": "https://Stackoverflow.com/users/6897", "pm_score": 4, "selected": true, "text": "<p>Try removing the borderless behavior of your window and see if that helps. Also, are you BeginInvoke()'ing or Invoke()'in...
2008/09/19
[ "https://Stackoverflow.com/questions/104224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/312/" ]
I'm working on a WPF application that sometimes exhibits odd problems and appears to *hang* in the UI. It is inconsistent, it happens in different pages, but it happens often enough that it is a big problem. I should mention that it is not a true hang as described below. My first thought was that the animations of som...
Try removing the borderless behavior of your window and see if that helps. Also, are you BeginInvoke()'ing or Invoke()'ing any long running operations? Another thing to look at: When you break into your code, try looking at threads other than your main thread. One of them may be blocking the UI thread.
104,230
<p>Situation: A PHP application with multiple installable modules creates a new table in database for each, in the style of mod_A, mod_B, mod_C etc. Each has the column section_id.</p> <p>Now, I am looking for all entries for a specific section_id, and I'm hoping there's another way besides "Select * from mod_a, mod_b...
[ { "answer_id": 104257, "author": "borjab", "author_id": 16206, "author_profile": "https://Stackoverflow.com/users/16206", "pm_score": 1, "selected": false, "text": "<p>What about?</p>\n\n<pre><code>SELECT * FROM mod_a WHERE section_id=value\nUNION ALL\nSELECT * FROM mod_b WHERE section_i...
2008/09/19
[ "https://Stackoverflow.com/questions/104230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4224/" ]
Situation: A PHP application with multiple installable modules creates a new table in database for each, in the style of mod\_A, mod\_B, mod\_C etc. Each has the column section\_id. Now, I am looking for all entries for a specific section\_id, and I'm hoping there's another way besides "Select \* from mod\_a, mod\_b, ...
If the tables are changing over time, you can inline code gen your solution in an SP (pseudo code - you'll have to fill in): ``` SET @sql = '' DECLARE CURSOR FOR SELECT t.[name] AS TABLE_NAME FROM sys.tables t WHERE t.[name] LIKE 'SOME_PATTERN_TO_IDENTIFY_THE_TABLES' ``` -- or this ``` DECLARE CURSOR FOR SELECT t....
104,235
<p>What is the syntax and which namespace/class needs to be imported? Give me sample code if possible. It would be of great help.</p>
[ { "answer_id": 104262, "author": "MagicKat", "author_id": 8505, "author_profile": "https://Stackoverflow.com/users/8505", "pm_score": 5, "selected": false, "text": "<p>Put the following where you need it:</p>\n\n<pre><code>System.Diagnostics.Debugger.Break();\n</code></pre>\n" }, { ...
2008/09/19
[ "https://Stackoverflow.com/questions/104235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13432/" ]
What is the syntax and which namespace/class needs to be imported? Give me sample code if possible. It would be of great help.
Put the following where you need it: ``` System.Diagnostics.Debugger.Break(); ```
104,238
<p>I'm having an issue with my regex.</p> <p>I want to capture &lt;% some stuff %> and i need what's inside the &lt;% and the %></p> <p>This regex works quite well for that.</p> <pre><code>$matches = preg_split("/&lt;%[\s]*(.*?)[\s]*%&gt;/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); </code></pr...
[ { "answer_id": 104295, "author": "e-satis", "author_id": 9951, "author_profile": "https://Stackoverflow.com/users/9951", "pm_score": 4, "selected": true, "text": "<p>In your case, it's better to use preg_match with its additional parameter and parenthesis:</p>\n\n<pre><code>preg_match(\"...
2008/09/19
[ "https://Stackoverflow.com/questions/104238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
I'm having an issue with my regex. I want to capture <% some stuff %> and i need what's inside the <% and the %> This regex works quite well for that. ``` $matches = preg_split("/<%[\s]*(.*?)[\s]*%>/i",$markup,-1,(PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)); ``` I also want to catch `&amp;% some stuff %&amp...
In your case, it's better to use preg\_match with its additional parameter and parenthesis: ``` preg_match("#((?:<|&lt;)%)([\s]*(?:[^ø]*)[\s]*?)(%(?:>|&gt;))#i",$markup, $out); print_r($out); Array ( [0] => <% your stuff %> [1] => <% [2] => your stuff [3] => %> ) ``` By the way, check this online to...
104,254
<p>I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the <code>java.io.Console</code> class to manage output and, more importantly, user input.</p> <p>The problem is that <code>System.console()</code> returns <code>null</code> when an application is run "through" Eclipse. Ec...
[ { "answer_id": 104391, "author": "perimosocordiae", "author_id": 10601, "author_profile": "https://Stackoverflow.com/users/10601", "pm_score": 2, "selected": false, "text": "<p>As far as I can tell, there is no way to get a Console object from Eclipse. I'd just make sure that console !=...
2008/09/19
[ "https://Stackoverflow.com/questions/104254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19147/" ]
I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the `java.io.Console` class to manage output and, more importantly, user input. The problem is that `System.console()` returns `null` when an application is run "through" Eclipse. Eclipse run the program on a background proce...
I assume you want to be able to use step-through debugging from Eclipse. You can just run the classes externally by setting the built classes in the bin directories on the JRE classpath. ``` java -cp workspace\p1\bin;workspace\p2\bin foo.Main ``` You can debug using the remote debugger and taking advantage of the cl...
104,267
<p>in short: <strong>is there any way to find the current directory full path of a xul application?</strong></p> <p>long explanation:</p> <p>I would like to open some html files in a xul browser application. The path to the html files should be set programmatically from the xul application. The html files reside outs...
[ { "answer_id": 104950, "author": "rec", "author_id": 14022, "author_profile": "https://Stackoverflow.com/users/14022", "pm_score": 3, "selected": true, "text": "<p>I found a workaround: <a href=\"http://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO\" rel=\"nofollow noreferrer\">ht...
2008/09/19
[ "https://Stackoverflow.com/questions/104267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14022/" ]
in short: **is there any way to find the current directory full path of a xul application?** long explanation: I would like to open some html files in a xul browser application. The path to the html files should be set programmatically from the xul application. The html files reside outside the folder of my xul appli...
I found a workaround: <http://developer.mozilla.org/en/Code_snippets/File_I%2F%2FO> i cannot exactly open a file using a relative path "../../index.html" but i can get the app directory and work with that. ``` var DIR_SERVICE = new Components.Constructor("@mozilla.org/file/directory_service;1", "nsIProperties"); var ...
104,292
<p>I'm getting the following error when trying to build my app using Team Foundation Build:</p> <blockquote> <p>C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1682,9): error MSB3554: Cannot write to the output file "obj\Release\Company.Redacted.BlahBlah.Localization.Subsystems. Startup_Shutdown_P...
[ { "answer_id": 104302, "author": "DevelopingChris", "author_id": 1220, "author_profile": "https://Stackoverflow.com/users/1220", "pm_score": 0, "selected": false, "text": "<p>you have to checkout the build script file, from the source control explorer, and get your elbows dirty replacing...
2008/09/19
[ "https://Stackoverflow.com/questions/104292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
I'm getting the following error when trying to build my app using Team Foundation Build: > > C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1682,9): error MSB3554: Cannot write to the output file "obj\Release\Company.Redacted.BlahBlah.Localization.Subsystems. > Startup\_Shutdown\_Processing.Startup...
You need to edit the build working directory of your Build Agent so that the begging path is a little smaller. To edit the build agent, right click on the "Builds" node and select "Manage Build Agents..." I personally use something like c:\bw\$(BuildDefinitionId). $(BuildDefinitionId) translates into the id of the bui...
104,293
<p>I'm getting a 404 error when trying to run another web service on an IIS 6 server which is also running Sharepoint 2003. I'm pretty sure this is an issue with sharepoint taking over IIS configuration. Is there a way to make a certain web service or web site be ignored by whatever Sharepoint is doing?</p>
[ { "answer_id": 104340, "author": "kemiller2002", "author_id": 1942, "author_profile": "https://Stackoverflow.com/users/1942", "pm_score": 0, "selected": false, "text": "<p>you'll have to go into the SharePoint admin console and explicitely allow that web application to run on on the same...
2008/09/19
[ "https://Stackoverflow.com/questions/104293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8852/" ]
I'm getting a 404 error when trying to run another web service on an IIS 6 server which is also running Sharepoint 2003. I'm pretty sure this is an issue with sharepoint taking over IIS configuration. Is there a way to make a certain web service or web site be ignored by whatever Sharepoint is doing?
I found the command line solution. ``` STSADM.EXE -o addpath -url http://localhost/<your web service/app> -type exclusion ```
104,322
<p>How do you install Boost on MacOS? Right now I can't find bjam for the Mac.</p>
[ { "answer_id": 104389, "author": "dies", "author_id": 19170, "author_profile": "https://Stackoverflow.com/users/19170", "pm_score": 8, "selected": true, "text": "<p>Download <a href=\"https://www.macports.org/\" rel=\"noreferrer\">MacPorts</a>, and run the following command:</p>\n\n<pre>...
2008/09/19
[ "https://Stackoverflow.com/questions/104322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
How do you install Boost on MacOS? Right now I can't find bjam for the Mac.
Download [MacPorts](https://www.macports.org/), and run the following command: ``` sudo port install boost ```
104,323
<p>I am quite new to JavaScript libraries. I wanted to replace my current code with jQuery. My current code looks like this:</p> <pre><code>var req; function createRequest() { var key = document.getElementById("key"); var keypressed = document.getElementById("keypressed"); keypressed.value = key.value; va...
[ { "answer_id": 104343, "author": "Wes P", "author_id": 13611, "author_profile": "https://Stackoverflow.com/users/13611", "pm_score": 2, "selected": false, "text": "<p>I don't think jQuery implements a timeout function, but plain old javascript does it rather nicely :)</p>\n" }, { ...
2008/09/19
[ "https://Stackoverflow.com/questions/104323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am quite new to JavaScript libraries. I wanted to replace my current code with jQuery. My current code looks like this: ``` var req; function createRequest() { var key = document.getElementById("key"); var keypressed = document.getElementById("keypressed"); keypressed.value = key.value; var url = "/My_S...
``` $.get(url, {}, callback); ``` should do the trick. Your callback could be simplified like this: ``` function callback(content){ $('#decimal').val(content); } ``` Or even shorter: ``` $.get(url, {}, function(content){ $('#decimal').val(content); }); ``` And all in all I think this should work: ``` f...
104,330
<p>I have a table with a "Date" column, and I would like to do a query that does the following:</p> <p>If the date is a <strong>Monday</strong>, <strong>Tuesday</strong>, <strong>Wednesday</strong>, or <strong>Thursday</strong>, the displayed date should be shifted up by 1 day, as in <pre>DATEADD(day, 1, [Date])</pre>...
[ { "answer_id": 104357, "author": "Nick Berardi", "author_id": 17, "author_profile": "https://Stackoverflow.com/users/17", "pm_score": 0, "selected": false, "text": "<p>you need to create a SQL Function that does this transformation for you. </p>\n" }, { "answer_id": 104362, ...
2008/09/19
[ "https://Stackoverflow.com/questions/104330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10675/" ]
I have a table with a "Date" column, and I would like to do a query that does the following: If the date is a **Monday**, **Tuesday**, **Wednesday**, or **Thursday**, the displayed date should be shifted up by 1 day, as in ``` DATEADD(day, 1, [Date]) ``` On the other hand, if it is a **Friday**, the displayed date s...
Here is how I would do it. I do recommend a function like above if you will be using this in other places. ``` CASE WHEN DATEPART(dw, [Date]) IN (2,3,4,5) THEN DATEADD(d, 1, [Date]) WHEN DATEPART(dw, [Date]) = 6 THEN DATEADD(d, 3, [Date]) ELSE [Date] END AS [ConvertedDate] ```
104,339
<p>I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result.</p> <p>First version looked like this:</p> <pre><code>if([elementName compare:@"companyName"] == 0) [character setCorporationName:currentElementText]; else if([elementName compare...
[ { "answer_id": 104584, "author": "Bradley Harris", "author_id": 10503, "author_profile": "https://Stackoverflow.com/users/10503", "pm_score": 2, "selected": false, "text": "<p>The most common refactoring suggested for eliminating if-else or switch statements is introducing polymorphism (...
2008/09/19
[ "https://Stackoverflow.com/questions/104339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18590/" ]
I'm doing some Objective-C programming that involves parsing an NSXmlDocument and populating an objects properties from the result. First version looked like this: ``` if([elementName compare:@"companyName"] == 0) [character setCorporationName:currentElementText]; else if([elementName compare:@"corporationID"] ==...
I hope you'll all forgive me for going out on a limb here, but I would like to address the more general question of parsing XML documents in Cocoa without the need of if-else statements. The question as originally stated assigns the current element text to an instance variable of the character object. As jmah pointed o...
104,363
<p>I'm trying to upgrade a package using yum on Fedora 8. The package is <code>elfutils</code>. Here's what I have installed locally:</p> <pre><code>$ yum info elfutils Installed Packages Name : elfutils Arch : x86_64 Version: 0.130 Release: 3.fc8 Size : 436 k Repo : installed Summary: A collection of utilitie...
[ { "answer_id": 104479, "author": "ethyreal", "author_id": 18159, "author_profile": "https://Stackoverflow.com/users/18159", "pm_score": 1, "selected": false, "text": "<p>i know this seems silly but did you try removing it and reinstalling?</p>\n\n<pre><code>yum remove elfutils\n</code></...
2008/09/19
[ "https://Stackoverflow.com/questions/104363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I'm trying to upgrade a package using yum on Fedora 8. The package is `elfutils`. Here's what I have installed locally: ``` $ yum info elfutils Installed Packages Name : elfutils Arch : x86_64 Version: 0.130 Release: 3.fc8 Size : 436 k Repo : installed Summary: A collection of utilities and DSOs to handle comp...
OK, I figured it out. I needed to upgrade the `fedora-release` package. That allowed me to see all of the updated packages. Thanks to ethyreal for pointing me to the Yum upgrade FAQ.
104,420
<p>How do I generate all the permutations of a list? For example:</p> <pre><code>permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] </code></pre>
[ { "answer_id": 104426, "author": "Ricardo Reyes", "author_id": 3399, "author_profile": "https://Stackoverflow.com/users/3399", "pm_score": 5, "selected": false, "text": "<p>This solution implements a generator, to avoid holding all the permutations on memory:</p>\n\n<pre><code>def permut...
2008/09/19
[ "https://Stackoverflow.com/questions/104420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3399/" ]
How do I generate all the permutations of a list? For example: ``` permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] ```
Use [`itertools.permutations`](https://docs.python.org/3/library/itertools.html#itertools.permutations) from the **standard library**: ``` import itertools list(itertools.permutations([1, 2, 3])) ``` --- Adapted from [here](http://code.activestate.com/recipes/252178/) is a demonstration of how `itertools.permutatio...
104,439
<p>The Eclipse projects are all stored in the Eclipse Foundation CVS servers. Using the source is a great way to debug your code and to figure out how to do new things. </p> <p>Unfortunately in a large software project like BIRT, it can be difficult to know which projects and versions are required for a particular ...
[ { "answer_id": 104426, "author": "Ricardo Reyes", "author_id": 3399, "author_profile": "https://Stackoverflow.com/users/3399", "pm_score": 5, "selected": false, "text": "<p>This solution implements a generator, to avoid holding all the permutations on memory:</p>\n\n<pre><code>def permut...
2008/09/19
[ "https://Stackoverflow.com/questions/104439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5412/" ]
The Eclipse projects are all stored in the Eclipse Foundation CVS servers. Using the source is a great way to debug your code and to figure out how to do new things. Unfortunately in a large software project like BIRT, it can be difficult to know which projects and versions are required for a particular build. So wha...
Use [`itertools.permutations`](https://docs.python.org/3/library/itertools.html#itertools.permutations) from the **standard library**: ``` import itertools list(itertools.permutations([1, 2, 3])) ``` --- Adapted from [here](http://code.activestate.com/recipes/252178/) is a demonstration of how `itertools.permutatio...
104,458
<p>How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify <code>&lt;ItemStyle&gt;</code>, you can't seem to specify a style for each individual control.</p> <p>Is there some sort of work around?</p>
[ { "answer_id": 104502, "author": "Andrew Burgess", "author_id": 12096, "author_profile": "https://Stackoverflow.com/users/12096", "pm_score": 4, "selected": false, "text": "<p>It seems the best way to do this is to create a new CssClass. ASP.NET translates CheckBoxList into a table stru...
2008/09/19
[ "https://Stackoverflow.com/questions/104458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12096/" ]
How can styles be applied to CheckBoxList ListItems. Unlike other controls, such as the Repeater where you can specify `<ItemStyle>`, you can't seem to specify a style for each individual control. Is there some sort of work around?
You can add Attributes to ListItems programmatically as follows. Say you've got a CheckBoxList and you are adding ListItems. You can add Attributes along the way. ``` ListItem li = new ListItem("Richard Byrd", "11"); li.Selected = false; li.Attributes.Add("Style", "color: red;"); CheckBoxList1.Items.Add(li); ``` Th...
104,485
<p>I'm trying to skin HTML output which I don't have control over. One of the elements is a <code>div</code> with a <code>style="overflow: auto"</code> attribute.<br> Is there a way in CSS to force that <code>div</code> to use <code>overflow: hidden;</code>?</p>
[ { "answer_id": 104497, "author": "17 of 26", "author_id": 2284, "author_profile": "https://Stackoverflow.com/users/2284", "pm_score": 0, "selected": false, "text": "<p>As far as I know, styles on the actual HTML elements override anything you can do in separate CSS style.</p>\n\n<p>You c...
2008/09/19
[ "https://Stackoverflow.com/questions/104485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4898/" ]
I'm trying to skin HTML output which I don't have control over. One of the elements is a `div` with a `style="overflow: auto"` attribute. Is there a way in CSS to force that `div` to use `overflow: hidden;`?
You can add `!important` to the end of your style, like this: ```css element { overflow: hidden !important; } ``` This is something you should not rely on normally, but in your case that's the best option. Changing the value in Javascript strays from the best practice of separating markup, presentation, and beha...
104,487
<p>Right now I'm doing something like this:</p> <pre><code>RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php </code></pre> <p>I would much rather have one rules that would do the same thing for each url, so I don't have to keep adding them every time I add a new file.</p> <p>Also, I like to...
[ { "answer_id": 104573, "author": "Gabriel Ross", "author_id": 10751, "author_profile": "https://Stackoverflow.com/users/10751", "pm_score": 3, "selected": true, "text": "<p>Try:</p>\n\n<p>RewriteRule ^/?(\\w+)/?$ $1.php</p>\n\n<p>the $1 is the content of the first captured string in brac...
2008/09/19
[ "https://Stackoverflow.com/questions/104487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15000/" ]
Right now I'm doing something like this: ``` RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php ``` I would much rather have one rules that would do the same thing for each url, so I don't have to keep adding them every time I add a new file. Also, I like to match things like '/config/new' ...
Try: RewriteRule ^/?(\w+)/?$ $1.php the $1 is the content of the first captured string in brackets. The brackets around the 2nd slash are not needed. edit: For the other match, try this: RewriteRule ^/?(\w+)/(\w+)/?$ $1\_$2.php
104,516
<p>In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces.</p> <p>In PHP 5, it <em>is</em> possible to actually make ...
[ { "answer_id": 104556, "author": "boxxar", "author_id": 15732, "author_profile": "https://Stackoverflow.com/users/15732", "pm_score": 6, "selected": false, "text": "<p>I would do the following:</p>\n\n<pre><code>$string = &lt;&lt;&lt; heredoc\nplain text and now a function: %s\nheredoc;\...
2008/09/19
[ "https://Stackoverflow.com/questions/104516", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9330/" ]
In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces. In PHP 5, it *is* possible to actually make function calls wit...
I would not use HEREDOC at all for this, personally. It just doesn't make for a good "template building" system. All your HTML is locked down in a string which has several disadvantages * No option for WYSIWYG * No code completion for HTML from IDEs * Output (HTML) locked to logic files * You end up having to use hack...
104,520
<p>I have been seriously disappointed with WPF validation system. Anyway! How can I validate the complete form by clicking the "button"? </p> <p>For some reason everything in WPF is soo complicated! I can do the validation in 1 line of code in ASP.NET which requires like 10-20 lines of code in WPF!!</p> <p>I can do t...
[ { "answer_id": 104957, "author": "adriaanp", "author_id": 12230, "author_profile": "https://Stackoverflow.com/users/12230", "pm_score": 2, "selected": false, "text": "<p>I would suggest to look at the IDataErrorInfo interface on your business object. Also have a look at this article: <a ...
2008/09/19
[ "https://Stackoverflow.com/questions/104520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3797/" ]
I have been seriously disappointed with WPF validation system. Anyway! How can I validate the complete form by clicking the "button"? For some reason everything in WPF is soo complicated! I can do the validation in 1 line of code in ASP.NET which requires like 10-20 lines of code in WPF!! I can do this using my own ...
A WPF application should disable the button to submit a form iff the entered data is not valid. You can achieve this by implementing the [IDataErrorInfo](http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx) interface on your business object, using Bindings with [`ValidatesOnDataErrors`](ht...
104,525
<p>We have a warm sql backup. full backup nightly, txn logs shipped every so often during the day and restored. I need to move the data files to another disk. These DB's are in a "warm backup" state (such that I can't unmark them as read-only - "Error 5063: Database '&lt;dbname>' is in warm standby. A warm-standby d...
[ { "answer_id": 104762, "author": "boes", "author_id": 17746, "author_profile": "https://Stackoverflow.com/users/17746", "pm_score": 3, "selected": true, "text": "<p>The only solution I know is to create a complete backup of your active database and restore this backup to a copy of the da...
2008/09/19
[ "https://Stackoverflow.com/questions/104525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10235/" ]
We have a warm sql backup. full backup nightly, txn logs shipped every so often during the day and restored. I need to move the data files to another disk. These DB's are in a "warm backup" state (such that I can't unmark them as read-only - "Error 5063: Database '<dbname>' is in warm standby. A warm-standby database i...
The only solution I know is to create a complete backup of your active database and restore this backup to a copy of the database in a 'warm backup' state. First create a backup from the active db: ``` backup database activedb to disk='somefile' ``` Then restore the backup on another sql server. If needed you can us...
104,568
<p>Is there any way that my script can retrieve metadata values that are declared in its own header? I don't see anything promising in the API, except perhaps <code>GM_getValue()</code>. That would of course involve a special name syntax. I have tried, for example: <code>GM_getValue("@name")</code>.</p> <p>The motivat...
[ { "answer_id": 104814, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 4, "selected": true, "text": "<p><strong>This answer is out of date :</strong> As of Greasemonkey 0.9.16 (Feb 2012) please see <a href=\"https://stackover...
2008/09/19
[ "https://Stackoverflow.com/questions/104568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14749/" ]
Is there any way that my script can retrieve metadata values that are declared in its own header? I don't see anything promising in the API, except perhaps `GM_getValue()`. That would of course involve a special name syntax. I have tried, for example: `GM_getValue("@name")`. The motivation here is to avoid redundant s...
**This answer is out of date :** As of Greasemonkey 0.9.16 (Feb 2012) please see [Brock's answer](https://stackoverflow.com/a/10475344/1820) regarding `GM_info` --- Yes. A very simple example is: ``` var metadata=<> // ==UserScript== // @name Reading metadata // @namespace http://www.afunamatata.com/...
104,587
<p>Everywhere I look always the same explanation pop ups.<br/> Configure the view resolver.</p> <pre><code>&lt;bean id="viewMappings" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"&gt; &lt;property name="basename" value="views" /&gt; &lt;/bean&gt; </code></pre> <p>And then put a fil...
[ { "answer_id": 105481, "author": "Craig Day", "author_id": 5193, "author_profile": "https://Stackoverflow.com/users/5193", "pm_score": 4, "selected": true, "text": "<p>ResourceBundleViewResolver uses the key/vals in views.properties to create view beans (actually created in an internal a...
2008/09/19
[ "https://Stackoverflow.com/questions/104587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024/" ]
Everywhere I look always the same explanation pop ups. Configure the view resolver. ``` <bean id="viewMappings" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="views" /> </bean> ``` And then put a file in the classpath named view.properties with ...
ResourceBundleViewResolver uses the key/vals in views.properties to create view beans (actually created in an internal application context). The name of the view bean in your example will be "logout" and it will be a bean of type JstlView. JstlView has an attribute called URL which will be set to "WEB-INF/jsp/logout.js...
104,601
<p>I want to do a <code>Response.Redirect("MyPage.aspx")</code> but have it open in a new browser window. I've done this before without using the JavaScript register script method. I just can't remember how?</p>
[ { "answer_id": 104653, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 3, "selected": false, "text": "<p>This is not possible with Response.Redirect as it happens on the server side and cannot direct your browser to take ...
2008/09/19
[ "https://Stackoverflow.com/questions/104601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to do a `Response.Redirect("MyPage.aspx")` but have it open in a new browser window. I've done this before without using the JavaScript register script method. I just can't remember how?
I just found the answer and it works :) You need to add the following to your server side link/button: ``` OnClientClick="aspnetForm.target ='_blank';" ``` My entire button code looks something like: ``` <asp:LinkButton ID="myButton" runat="server" Text="Click Me!" OnClick="myButton_Click" ...
104,603
<p>Is there a way to iterate (through foreach preferably) over a collection using reflection? I'm iterating over the properties in an object using reflection, and when the program gets to a type that is a collection, I'd like it to iterate over the contents of the collection and be able to access the objects in the co...
[ { "answer_id": 104655, "author": "Adam Driscoll", "author_id": 13688, "author_profile": "https://Stackoverflow.com/users/13688", "pm_score": 0, "selected": false, "text": "<p>When your using reflection you aren't necessarily using an instance of that object. You would have to create an i...
2008/09/19
[ "https://Stackoverflow.com/questions/104603", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12999/" ]
Is there a way to iterate (through foreach preferably) over a collection using reflection? I'm iterating over the properties in an object using reflection, and when the program gets to a type that is a collection, I'd like it to iterate over the contents of the collection and be able to access the objects in the collec...
I had this issue, but instead of using reflection, i ended up just checking if it was IEnumerable. All collections implement that. ``` if (item is IEnumerable) { foreach (object o in (item as IEnumerable)) { } } else { // reflect over item } ```
104,612
<p>I want to copy a live production database into my local development database. Is there a way to do this without locking the production database?</p> <p>I'm currently using:</p> <pre class="lang-none prettyprint-override"><code>mysqldump -u root --password=xxx -h xxx my_db1 | mysql -u root --password=xxx -h localh...
[ { "answer_id": 104628, "author": "John Millikin", "author_id": 3560, "author_profile": "https://Stackoverflow.com/users/3560", "pm_score": 10, "selected": true, "text": "<p>Does the <code>--lock-tables=false</code> option work?</p>\n<p>According to the <a href=\"https://dev.mysql.com/doc...
2008/09/19
[ "https://Stackoverflow.com/questions/104612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13009/" ]
I want to copy a live production database into my local development database. Is there a way to do this without locking the production database? I'm currently using: ```none mysqldump -u root --password=xxx -h xxx my_db1 | mysql -u root --password=xxx -h localhost my_db1 ``` But it's locking each table as it runs.
Does the `--lock-tables=false` option work? According to the [man page](https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_lock-tables), if you are dumping InnoDB tables you can use the `--single-transaction` option: ```none --lock-tables, -l Lock all tables before dumping them. The tables are l...
104,618
<p>I've been trying to get into F# on and off for a while but I keep getting put off. Why?</p> <p>Because no matter which 'beginners' resource I try to look at I see very simple examples that start using the operator <code>-&gt;</code>.</p> <p>However, nowhere have I found as yet that provides a clear simple explana...
[ { "answer_id": 104744, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 4, "selected": false, "text": "<p>It basically means \"maps to\". Read it that way or as \"is transformed into\" or something like that.</p>\n\n<p>So,...
2008/09/19
[ "https://Stackoverflow.com/questions/104618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17516/" ]
I've been trying to get into F# on and off for a while but I keep getting put off. Why? Because no matter which 'beginners' resource I try to look at I see very simple examples that start using the operator `->`. However, nowhere have I found as yet that provides a clear simple explanation of what this operator means...
'->' is not an operator. It appears in the F# syntax in a number of places, and its meaning depends on how it is used as part of a larger construct. Inside a type, '->' describes function types as people have described above. For example ``` let f : int -> int = ... ``` says that 'f' is a function that takes an int...
104,747
<p>I have a members table in MySQL</p> <pre><code>CREATE TABLE `members` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(65) collate utf8_unicode_ci NOT NULL, `order` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB; </code></pre> <p>And I would like to let users ...
[ { "answer_id": 104788, "author": "sebastiaan", "author_id": 5018, "author_profile": "https://Stackoverflow.com/users/5018", "pm_score": 2, "selected": false, "text": "<p>Since you already automatically increment the id for each new member, you can order by id.</p>\n" }, { "answer...
2008/09/19
[ "https://Stackoverflow.com/questions/104747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19217/" ]
I have a members table in MySQL ``` CREATE TABLE `members` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(65) collate utf8_unicode_ci NOT NULL, `order` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB; ``` And I would like to let users order the members how they...
You can do the SELECT as part of the INSERT, such as: ``` INSERT INTO members SELECT 0, "new member", max(`order`)+1 FROM members; ``` Keep in mind that you are going to want to have an index on the `order` column to make the SELECT part optimized. In addition, you might want to reconsider the tinyint for order, un...
104,791
<p>The SQL-LDR documentation states that you need to do a convetional Path Load:</p> <blockquote> <p>When you want to apply SQL functions to data fields. SQL functions are not available during a direct path load</p> </blockquote> <p>I have TimeStamp data stored in a CSV file that I'm loading with SQL-LDR by des...
[ { "answer_id": 104783, "author": "blowdart", "author_id": 2525, "author_profile": "https://Stackoverflow.com/users/2525", "pm_score": 0, "selected": false, "text": "<p>A little more information please; do you want to log IPs or lock access via IP? Both those functions are built into IIS ...
2008/09/19
[ "https://Stackoverflow.com/questions/104791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
The SQL-LDR documentation states that you need to do a convetional Path Load: > > When you want to apply SQL functions > to data fields. SQL functions are not > available during a direct path load > > > I have TimeStamp data stored in a CSV file that I'm loading with SQL-LDR by describing the fields as such: `...
As blowdart said, simple IP Address logging is handled by IIS already. Simply right-click on the Website in Internet Information Services (IIS) Manager tool, go to the Web Site tab, and check the Enable Logging box. You can customize what information is logged also. If you want to restrict the site or even a folder o...
104,797
<p>What is the best way to create a webservice for accepting an image. The image might be quite big and I do not want to change the default receive size for the web application. I have written one that accepts a binary image but that I feel that there has to be a better alternative.</p>
[ { "answer_id": 104902, "author": "core", "author_id": 11574, "author_profile": "https://Stackoverflow.com/users/11574", "pm_score": 3, "selected": true, "text": "<p>Where does this image \"live?\" Is it accessible in the local file system or on the web? If so, I would suggest having your...
2008/09/19
[ "https://Stackoverflow.com/questions/104797", "https://Stackoverflow.com", "https://Stackoverflow.com/users/403/" ]
What is the best way to create a webservice for accepting an image. The image might be quite big and I do not want to change the default receive size for the web application. I have written one that accepts a binary image but that I feel that there has to be a better alternative.
Where does this image "live?" Is it accessible in the local file system or on the web? If so, I would suggest having your WebService accepting a URI (can be a URL or a local file) and opening it as a Stream, then using a StreamReader to read the contents of it. Example (but wrap the exceptions in FaultExceptions, and ...
104,803
<p>I've got a (mostly) working plugin developed, but since its function is directly related to the project it processes, how do you develop unit and integration tests for the plugin. The best idea I've had is to create an integration test project for the plugin that uses the plugin during its lifecycle and has tests t...
[ { "answer_id": 105259, "author": "Brian Matthews", "author_id": 1969, "author_profile": "https://Stackoverflow.com/users/1969", "pm_score": 4, "selected": true, "text": "<p>You need to use the <a href=\"http://maven.apache.org/shared/maven-plugin-testing-harness/\" rel=\"noreferrer\">mav...
2008/09/19
[ "https://Stackoverflow.com/questions/104803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17008/" ]
I've got a (mostly) working plugin developed, but since its function is directly related to the project it processes, how do you develop unit and integration tests for the plugin. The best idea I've had is to create an integration test project for the plugin that uses the plugin during its lifecycle and has tests that ...
You need to use the [maven-plugin-testing-harness](http://maven.apache.org/shared/maven-plugin-testing-harness/), ``` <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-plugin-testing-harness</artifactId> <version>1.1</version> <scope>test</scope> </depe...
104,844
<p>I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks.</p>
[ { "answer_id": 104882, "author": "Doug T.", "author_id": 8123, "author_profile": "https://Stackoverflow.com/users/8123", "pm_score": 3, "selected": true, "text": "<p>The following works great for printing with the win32api from C++</p>\n\n<pre><code>char szPrinterName[255];\nunsigned lon...
2008/09/19
[ "https://Stackoverflow.com/questions/104844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8117/" ]
I'm looking for a way to find the name of the Windows default printer using unmanaged C++ (found plenty of .NET examples, but no success unmanaged). Thanks.
The following works great for printing with the win32api from C++ ``` char szPrinterName[255]; unsigned long lPrinterNameLength; GetDefaultPrinter( szPrinterName, &lPrinterNameLength ); HDC hPrinterDC; hPrinterDC = CreateDC("WINSPOOL\0", szPrinterName, NULL, NULL); ``` In the future instead of googling "unmanaged" t...
104,850
<p>I want to try to convert a string to a Guid, but I don't want to rely on catching exceptions (</p> <ul> <li>for performance reasons - exceptions are expensive</li> <li>for usability reasons - the debugger pops up </li> <li>for design reasons - the expected is not exceptional</li> </ul> <p>In other words the code:<...
[ { "answer_id": 104893, "author": "Michael Burr", "author_id": 12711, "author_profile": "https://Stackoverflow.com/users/12711", "pm_score": 2, "selected": false, "text": "<p>Run the potential GUID though a RegEx or some custom code that does a sanity check to ensure the strig at least l...
2008/09/19
[ "https://Stackoverflow.com/questions/104850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12597/" ]
I want to try to convert a string to a Guid, but I don't want to rely on catching exceptions ( * for performance reasons - exceptions are expensive * for usability reasons - the debugger pops up * for design reasons - the expected is not exceptional In other words the code: ``` public static Boolean TryStrToGuid(Str...
**Performance Benchmarks** ``` Catch exception: 10,000 good: 63,668 ticks 10,000 bad: 6,435,609 ticks Regex Pre-Screen: 10,000 good: 637,633 ticks 10,000 bad: 717,894 ticks COM Interop CLSIDFromString 10,000 good: 126,120 ticks 10,000 bad: 23,134 ticks ``` **COM Intertop (Fastest) ...
104,872
<p>I'm working on a <code>PHP</code> application that links into the <code>Protx VSP Direct payment gateway</code>. To handle "3D Secure" requests from the credit card processing company, I need to forward the user to a different website, mimicking a form that has been posted. I'm trying to use the <code>cURL</code> li...
[ { "answer_id": 104887, "author": "neu242", "author_id": 13365, "author_profile": "https://Stackoverflow.com/users/13365", "pm_score": 3, "selected": true, "text": "<p>The 3D Secure API doesn't allow you to do the request in the background. You need to forward the user to the 3D secure s...
2008/09/19
[ "https://Stackoverflow.com/questions/104872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19232/" ]
I'm working on a `PHP` application that links into the `Protx VSP Direct payment gateway`. To handle "3D Secure" requests from the credit card processing company, I need to forward the user to a different website, mimicking a form that has been posted. I'm trying to use the `cURL` libraries, but seem to have hit a prob...
The 3D Secure API doesn't allow you to do the request in the background. You need to forward the user to the 3D secure site. Use javascript to automatically submit your form. Here's what our provider suggests: ``` <html> <head> <title>Processing your request...</title> </head> <body OnLoad="OnL...
104,918
<p>My question is related to the command pattern, where we have the following abstraction (C# code) :</p> <pre><code>public interface ICommand { void Execute(); } </code></pre> <p>Let's take a simple concrete command, which aims to delete an entity from our application. A <code>Person</code> instance, for example...
[ { "answer_id": 104934, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": false, "text": "<p>In the constructor and stored as fields.</p>\n\n<p>You will also want to eventually make your ICommands serializable ...
2008/09/19
[ "https://Stackoverflow.com/questions/104918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4687/" ]
My question is related to the command pattern, where we have the following abstraction (C# code) : ``` public interface ICommand { void Execute(); } ``` Let's take a simple concrete command, which aims to delete an entity from our application. A `Person` instance, for example. I'll have a `DeletePersonCommand`,...
You'll need to associate the parameters with the command object, either by constructor or setter injection (or equivalent). Perhaps something like this: ``` public class DeletePersonCommand: ICommand { private Person personToDelete; public DeletePersonCommand(Person personToDelete) { this.perso...