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 |
|---|---|---|---|---|---|---|
399,286 | <p>Can anybody provide some instruction on how to setup a war file to show a favicon.ico in the browser address bar?</p>
| [
{
"answer_id": 399335,
"author": "neesh",
"author_id": 43864,
"author_profile": "https://Stackoverflow.com/users/43864",
"pm_score": 3,
"selected": false,
"text": "<p>This might be different in different application servers. For tomcat, the favicon comes from the directory your root cont... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6218/"
] | Can anybody provide some instruction on how to setup a war file to show a favicon.ico in the browser address bar? | You can also use the following HTML markup in your HTML:
```
<link rel="icon" type="image/gif" href="/img/image.gif">
```
Most newer browsers should support it and I think it's generally a more clean way since you can use any image type/name/location you want. |
399,291 | <p>Curious as to 99.95% uptime REALLY means; Is it really going to go down 7 minutes a month? Please post your longest/average uptimes on EC2, thanks.</p>
| [
{
"answer_id": 399684,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 5,
"selected": true,
"text": "<p>Usually uptime is calculated in a yearly basis. So if you have a Service Level Agreement for 99.95% this means:</p>... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1263/"
] | Curious as to 99.95% uptime REALLY means; Is it really going to go down 7 minutes a month? Please post your longest/average uptimes on EC2, thanks. | Usually uptime is calculated in a yearly basis. So if you have a Service Level Agreement for 99.95% this means:
```
365 * 0.0005 = 0.1825 days or 4.38 hours
```
If during a year of service there is an outage and your system is down for more than that, then you are liable for compensation.
As of your question, I hav... |
399,311 | <p>I please for your help.</p>
<p>I apologize for my English, it is still learning. I do one application in GUI in Java. I have one problem. </p>
<p>In this application I have an ArrayList that I want to meet with data.</p>
<p>User clicks on the button and data from JTextfield shall be placed in Arraylist. </p>
<p>... | [
{
"answer_id": 399342,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 2,
"selected": false,
"text": "<p>Just use ArrayList.add(arraytext), not ArrayList.add(0, arraytext). You don't really care what position it ends up ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I please for your help.
I apologize for my English, it is still learning. I do one application in GUI in Java. I have one problem.
In this application I have an ArrayList that I want to meet with data.
User clicks on the button and data from JTextfield shall be placed in Arraylist.
When they do so, it is inserted... | Just use ArrayList.add(arraytext), not ArrayList.add(0, arraytext). You don't really care what position it ends up in, do you?
Replace
```
int posl=arlist.size();
if(arlist.isEmpty()||posl==1){
arlist.add(0,arraytext);
}
if(!arlist.isEmpty()&& posl>1){
arlist.add(posl-1, cele_jmeno); ... |
399,312 | <p>I encountered this term <em>Hindley-Milner</em>, and I'm not sure if grasp what it means.</p>
<p>I've read the following posts:</p>
<ul>
<li>Steve Yegge - <a href="http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html" rel="noreferrer">Dynamic Languages Strike Back</a></li>
<li>Steve Yegge - <a ... | [
{
"answer_id": 399354,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": "<p>You may be able to find the original papers using Google Scholar or CiteSeer -- or your local university library. T... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46090/"
] | I encountered this term *Hindley-Milner*, and I'm not sure if grasp what it means.
I've read the following posts:
* Steve Yegge - [Dynamic Languages Strike Back](http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html)
* Steve Yegge - [The Pinocchio Problem](http://steve-yegge.blogspot.com/2007/01/... | Hindley-Milner is a **type system** discovered independently by Roger Hindley (who was looking at logic) and later by Robin Milner (who was looking at programming languages). The advantages of Hindley-Milner are
* It supports **polymorphic** functions; for example, a function that can give you the length of the list i... |
399,314 | <p>My product opens a web browser and points it at an HTML file containing a local Flash application. How do I detect programmatically whether this file loaded successfully and if not what exception was thrown? Is there a way to do this using Javascript?</p>
<p>Checking externally whether the file exists on disk is no... | [
{
"answer_id": 399378,
"author": "Gili",
"author_id": 14731,
"author_profile": "https://Stackoverflow.com/users/14731",
"pm_score": 5,
"selected": true,
"text": "<p>Answering my own question: <a href=\"https://sourceforge.net/forum/message.php?msg_id=5929756\" rel=\"noreferrer\">https://... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14731/"
] | My product opens a web browser and points it at an HTML file containing a local Flash application. How do I detect programmatically whether this file loaded successfully and if not what exception was thrown? Is there a way to do this using Javascript?
Checking externally whether the file exists on disk is not enough b... | Answering my own question: <https://sourceforge.net/forum/message.php?msg_id=5929756>
1. Define a Javascript function that should be invoked if Flash loaded.
2. Invoke this method from the top of your Flash file.
3. Use a timer to detect if the callback is never invoked.
4. Prefer invoking Javascript functions from Fl... |
399,332 | <p>I'm doing a bookmarking system and looking for the fastest (easiest) way to retrieve a page's title with PHP. </p>
<p>It would be nice to have something like <code>$title = page_title($url)</code></p>
| [
{
"answer_id": 399341,
"author": "alex",
"author_id": 31671,
"author_profile": "https://Stackoverflow.com/users/31671",
"pm_score": 3,
"selected": false,
"text": "<p>Regex? </p>\n\n<p>Use <a href=\"http://au2.php.net/curl\" rel=\"nofollow noreferrer\">cURL</a> to get the $htmlSource vari... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm doing a bookmarking system and looking for the fastest (easiest) way to retrieve a page's title with PHP.
It would be nice to have something like `$title = page_title($url)` | ```
<?php
function page_title($url) {
$fp = file_get_contents($url);
if (!$fp)
return null;
$res = preg_match("/<title>(.*)<\/title>/siU", $fp, $title_matches);
if (!$res)
return null;
// Clean up title: remove EOL's and excessive whitespace.
... |
399,340 | <p>I always try to do the following:</p>
<pre><code><label><input type="checkbox" /> Some text</label>
</code></pre>
<p>or</p>
<pre><code><label for="idOfField"><input type="checkbox" id="idOfField" /> Some text</label>
</code></pre>
<p>My question is related to the label tag, sp... | [
{
"answer_id": 399350,
"author": "FryGuy",
"author_id": 28776,
"author_profile": "https://Stackoverflow.com/users/28776",
"pm_score": 5,
"selected": true,
"text": "<p>I think it's probably more a factor that people don't know about the <label> tag. I didn't, until this post.</p>\n"... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I always try to do the following:
```
<label><input type="checkbox" /> Some text</label>
```
or
```
<label for="idOfField"><input type="checkbox" id="idOfField" /> Some text</label>
```
My question is related to the label tag, specifically on a checkbox.
Most websites (I would say >40%) don't use the `<label>` t... | I think it's probably more a factor that people don't know about the <label> tag. I didn't, until this post. |
399,348 | <p>In Joomla:</p>
<pre><code>$mainframe->getCfg('lang');
</code></pre>
<p>will return "english" (i think this is a default value), anyone can tell me where defined it? </p>
<p>Can I change it?</p>
| [
{
"answer_id": 400133,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 1,
"selected": false,
"text": "<p>It's what you configure in the Language Manager.</p>\n"
},
{
"answer_id": 401009,
"author": "jlleblanc",
"a... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In Joomla:
```
$mainframe->getCfg('lang');
```
will return "english" (i think this is a default value), anyone can tell me where defined it?
Can I change it? | It's what you configure in the Language Manager. |
399,352 | <p>My app will be full screen, but I am having trouble finding the document that explains how to change the status bar properties.</p>
<p>How can I change the status bar properties?</p>
| [
{
"answer_id": 399371,
"author": "dancavallaro",
"author_id": 42891,
"author_profile": "https://Stackoverflow.com/users/42891",
"pm_score": 6,
"selected": true,
"text": "<p><code>[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]</code> should hide the status bar. Is ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46865/"
] | My app will be full screen, but I am having trouble finding the document that explains how to change the status bar properties.
How can I change the status bar properties? | `[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO]` should hide the status bar. Is that what you want?
edit: You could also add the following to `Info.plist`:
```
<key>UIStatusBarHidden</key>
<true />
``` |
399,353 | <p>Say I have a thread that keeps running in the background to figure if a URL is accessible. If the URL is not accessible, the application need to show a modal dialog box. Things cannot go on if the URL is down. If I simply do a MessageBox.show from inside the thread, that message box will not be modal. ShowDialog won... | [
{
"answer_id": 399362,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 2,
"selected": false,
"text": "<p>You may want to use Control.Invoke (or this.Invoke)</p>\n\n<pre><code>private void backgroundWorker1_DoWork(object... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Say I have a thread that keeps running in the background to figure if a URL is accessible. If the URL is not accessible, the application need to show a modal dialog box. Things cannot go on if the URL is down. If I simply do a MessageBox.show from inside the thread, that message box will not be modal. ShowDialog won't ... | You may want to use Control.Invoke (or this.Invoke)
```
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) {
this.Invoke(new MessageBoxDelegate(ShowMessage), "Title", "MEssage", MessageBoxButtons.OK, MessageBoxIcon.Information); }
```
That will make it modal to the UI thread. |
399,356 | <pre><code>.section .data
astring: .asciz "11010101"
format: .asciz "%d\n"
.section .text
.globl _start
_start:
xorl %ecx, %ecx
movb astring(%ecx,1), %al
movzbl %al, %eax
pushl %eax
pushl $format
call printf
addl $8, %esp
movl $1, %eax
movl $0, %ebx
int $0x80
</code></pre>
<p>Suppose I wanna break the .asciz s... | [
{
"answer_id": 399363,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 3,
"selected": true,
"text": "<p>Change the conversion specifier for <a href=\"http://linux.die.net/man/3/printf\" rel=\"nofollow noreferrer\"><cod... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45963/"
] | ```
.section .data
astring: .asciz "11010101"
format: .asciz "%d\n"
.section .text
.globl _start
_start:
xorl %ecx, %ecx
movb astring(%ecx,1), %al
movzbl %al, %eax
pushl %eax
pushl $format
call printf
addl $8, %esp
movl $1, %eax
movl $0, %ebx
int $0x80
```
Suppose I wanna break the .asciz string 1101011 and ge... | Change the conversion specifier for [`printf`](http://linux.die.net/man/3/printf) from `%d` to `%c` to print the character instead of its ascii value. |
399,359 | <p>My issue is that sometimes a piece of JavaScript (often Google Analytics) may take a very long time to load, although it's not important to the HTML be ready to be "traversed and manipulated". If I were to use the following code:</p>
<pre><code>$(document).ready(function () {
$("p").text("The DOM is now loaded ... | [
{
"answer_id": 399427,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": false,
"text": "<p>Have you tried loading Google analytics from within the ready function? Here's a <a href=\"http://unixpapa.com/js/d... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | My issue is that sometimes a piece of JavaScript (often Google Analytics) may take a very long time to load, although it's not important to the HTML be ready to be "traversed and manipulated". If I were to use the following code:
```
$(document).ready(function () {
$("p").text("The DOM is now loaded and can be man... | Google has actually released what they're calling [Asynchronous Tracking](http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html):
```
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = doc... |
399,370 | <p>I'm embedding a Flash video into an HTML and would like the user to have to click it to begin playing. According to the <a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701" rel="nofollow noreferrer">Adobe <code><object></code> / <code><embed></code> element documentation</a>, ther... | [
{
"answer_id": 401077,
"author": "fenomas",
"author_id": 10651,
"author_profile": "https://Stackoverflow.com/users/10651",
"pm_score": 5,
"selected": true,
"text": "<p>A couple of wires are crossed here. The various <code>autoplay</code> settings that you're working with only affect whet... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37522/"
] | I'm embedding a Flash video into an HTML and would like the user to have to click it to begin playing. According to the [Adobe `<object>` / `<embed>` element documentation](http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701), there are variety of methods to do this:
1) Add a Flash parameter inside the ... | A couple of wires are crossed here. The various `autoplay` settings that you're working with only affect whether the SWF's root timeline starts out paused or not. So if your SWF had a timeline animation, or if it had an embedded video on the root timeline, then these settings would do what you're after.
However, the S... |
399,396 | <p>I'm writing a rake task that does some DB work outside of Rails/ActiveRecord.</p>
<p>Is there a way to get the DB connection info (host, username, password, DB name) for the current environment as defined in <code>database.yml</code>?</p>
<p>I'd like to get it so I can use it to connect like this...</p>
<pre><cod... | [
{
"answer_id": 399411,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 9,
"selected": true,
"text": "<p>From within rails you can create a configuration object and obtain the necessary information from it:</p>\n\n<pre>... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I'm writing a rake task that does some DB work outside of Rails/ActiveRecord.
Is there a way to get the DB connection info (host, username, password, DB name) for the current environment as defined in `database.yml`?
I'd like to get it so I can use it to connect like this...
```
con = Mysql.real_connect("host", "use... | From within rails you can create a configuration object and obtain the necessary information from it:
```
config = Rails.configuration.database_configuration
host = config[Rails.env]["host"]
database = config[Rails.env]["database"]
username = config[Rails.env]["username"]
password = config[Rails.env]["password"]... |
399,401 | <p>I have a hibernate mapping as follows:</p>
<p>
</p>
<pre><code><hibernate-mapping>
<class name="kochman.elie.data.types.InvoiceTVO" table="INVOICE">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="date" column=... | [
{
"answer_id": 399420,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried assigning the type?</p>\n\n<pre><code><property name=\"adminFee\" column=\"ADMIN_FEE\" type=\"float\... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23249/"
] | I have a hibernate mapping as follows:
```
<hibernate-mapping>
<class name="kochman.elie.data.types.InvoiceTVO" table="INVOICE">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="date" column="INVOICE_DATE"/>
<property name="customerId" colu... | I would use an integer type (int, long). Never any funny issues with those as long you can avoid overflows. |
399,447 | <p>I have a site in rails and want to have site-wide settings. One part of my app can notify the admin by SMS if a specific event happens. This is an example of a feature that I want configurable via the site-wide settings.</p>
<p>So I was thinking I should have a Setting model or something. It needs to be a model bec... | [
{
"answer_id": 399560,
"author": "JGeiser",
"author_id": 35121,
"author_profile": "https://Stackoverflow.com/users/35121",
"pm_score": 2,
"selected": false,
"text": "<p>Odds are good you don't need a singleton. It's unfortunate that one of the worst design habits to come out of the patte... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9191/"
] | I have a site in rails and want to have site-wide settings. One part of my app can notify the admin by SMS if a specific event happens. This is an example of a feature that I want configurable via the site-wide settings.
So I was thinking I should have a Setting model or something. It needs to be a model because I wan... | I am not sure I'd waste the database/ActiveRecord/Model overhead for such a basic need. This data is relatively static (I am assuming) and on the fly calculations aren't necessary (including database lookups).
Having said that, I'd recommend you define a YAML file with your site-wide settings and define an initialize... |
399,452 | <p>I am using the pimpl idiom and want to reference one of the methods of the forward declared class. Below isn't exactly what I'm doing but uses the same concepts.</p>
<pre><code>template< typename Class, void (Class::*Method)(void) >
struct Call
{
Call( Class* c )
: m_c(c)
{ }
void operator()( v... | [
{
"answer_id": 399515,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 0,
"selected": false,
"text": "<p>It can't compile B::bar() because class B is undefined. But I think you are leaving too much out of the question. A... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28817/"
] | I am using the pimpl idiom and want to reference one of the methods of the forward declared class. Below isn't exactly what I'm doing but uses the same concepts.
```
template< typename Class, void (Class::*Method)(void) >
struct Call
{
Call( Class* c )
: m_c(c)
{ }
void operator()( void )
{
(m_c... | You cannot forward declare a member function. I think the reason is that, when you call the function on a pointer to B, the compiler has to pass the this pointer to that method. But it doesn't know the precise class hierarchy of B yet. So possible adjustments of that pointer (due to the method being virtual, for exampl... |
399,459 | <p>Hi I'm looking for some help in mapping the following tables to a hibernate mapping file:
<a href="http://barry-jones.com/temp/sch2.jpg" rel="nofollow noreferrer">schema image http://barry-jones.com/temp/sch2.jpg</a></p>
<p>I'm trying to fill the localCalandarGroups List with related localCalendarGroups when loadin... | [
{
"answer_id": 399799,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": true,
"text": "<p>The first thing I would suggest you is using IList instead of List for mapping the localCalendarGroups associatio... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17510/"
] | Hi I'm looking for some help in mapping the following tables to a hibernate mapping file:
[schema image http://barry-jones.com/temp/sch2.jpg](http://barry-jones.com/temp/sch2.jpg)
I'm trying to fill the localCalandarGroups List with related localCalendarGroups when loading my userVOs. I'm using a intermediary table(us... | The first thing I would suggest you is using IList instead of List for mapping the localCalendarGroups association in your domain classes. This will enable lazy loading the collection. And here's the mapping file for the UserVO class:
```
<class name="UserVO" table="tb_users">
<id name="id" column="id">
<g... |
399,488 | <p>Below is a macro to save multiple sheets to different csv files BUT it keeps renaming and saving the original workbook, how to stop this.</p>
<pre><code>Private Sub CommandButton1_Click()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
Dim myName As ... | [
{
"answer_id": 399540,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": false,
"text": "<p><code>\nActiveWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat Application.DisplayAlerts = Fals... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Below is a macro to save multiple sheets to different csv files BUT it keeps renaming and saving the original workbook, how to stop this.
```
Private Sub CommandButton1_Click()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
Dim myName As String
myName ... | `ActiveWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat Application.DisplayAlerts = False`
If you are not writing anything on the workbook, why are you trying to save it? |
399,490 | <p>I have some rails models which don't need any persistence, however I'd like rails to think the model actually has attributes x, y, z so when calling methods like to_json in the controller I get them included for free.</p>
<p>For example,</p>
<pre><code>class ModelWithoutTableColumns << ActiveRecord::Base
de... | [
{
"answer_id": 399496,
"author": "J Cooper",
"author_id": 38803,
"author_profile": "https://Stackoverflow.com/users/38803",
"pm_score": 2,
"selected": false,
"text": "<p>Just don't inherit from ActiveRecord::Base</p>\n\n<p>Edit: Have you tried passing options to to_json, like :methods pe... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46758/"
] | I have some rails models which don't need any persistence, however I'd like rails to think the model actually has attributes x, y, z so when calling methods like to\_json in the controller I get them included for free.
For example,
```
class ModelWithoutTableColumns << ActiveRecord::Base
def x
return "Custom stuf... | Sounds like you want ActiveModel. Check out <http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/> for a great walkthrough by Yehuda Katz. Specifically the section called "Serialization" for your `to_json` requirements. |
399,508 | <p>I'm updating the <code>src</code> attribute of an <code><img></code> tag in javascript. After I've done this, I need to get the new height of its parent <code><div></code> so that I can update the size of other elements on the page. If I retrieve the parent's <code>offsetHeight</code> property directly... | [
{
"answer_id": 399513,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 3,
"selected": true,
"text": "<p>You might need to wait for the image to finish loading before the height is available. In your sample code, se... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36388/"
] | I'm updating the `src` attribute of an `<img>` tag in javascript. After I've done this, I need to get the new height of its parent `<div>` so that I can update the size of other elements on the page. If I retrieve the parent's `offsetHeight` property directly after updating the image's `src`, however, I get the height ... | You might need to wait for the image to finish loading before the height is available. In your sample code, setting the "src" attribute will load the image (b.jpg) asynchronously so you may want to attach an "onload" hander on that element to be notified when it's finished loading and rendering. |
399,527 | <p>With the Cocoa framework how can I parse @"2008-12-29T00:27:42-08:00" into an NSDate object? The standard <code>-dateWithString:</code> doesn't like it.</p>
| [
{
"answer_id": 399547,
"author": "Peter Hosey",
"author_id": 30461,
"author_profile": "https://Stackoverflow.com/users/30461",
"pm_score": 3,
"selected": false,
"text": "<p>If you only need to handle the ISO 8601 format (of which that string is an example), you might try <a href=\"http:/... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36170/"
] | With the Cocoa framework how can I parse @"2008-12-29T00:27:42-08:00" into an NSDate object? The standard `-dateWithString:` doesn't like it. | You can use [NSDateFormatter](http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW5) to parse dates:
```
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM... |
399,530 | <p>I'm new to iPhone development, and multiple views (xib or nib) are really confusing me. This is what i'm trying to achieve...</p>
<ol>
<li>View with Tab Bar (Tab 1, Tab 2, Tab 3)</li>
<li>Tab 2 View (Navigation Controller)
2.1 Selecting Table Row will show a View with cell details
2.2 Add button on the navigation b... | [
{
"answer_id": 399547,
"author": "Peter Hosey",
"author_id": 30461,
"author_profile": "https://Stackoverflow.com/users/30461",
"pm_score": 3,
"selected": false,
"text": "<p>If you only need to handle the ISO 8601 format (of which that string is an example), you might try <a href=\"http:/... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49739/"
] | I'm new to iPhone development, and multiple views (xib or nib) are really confusing me. This is what i'm trying to achieve...
1. View with Tab Bar (Tab 1, Tab 2, Tab 3)
2. Tab 2 View (Navigation Controller)
2.1 Selecting Table Row will show a View with cell details
2.2 Add button on the navigation bar will show a seri... | You can use [NSDateFormatter](http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW5) to parse dates:
```
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM... |
399,532 | <p>How can I grab something like ^MM (CTRL + M + M) in .NET, using C#?</p>
| [
{
"answer_id": 399548,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": 1,
"selected": false,
"text": "<p>This is just a guess, you could store the key and key modifiers on each key stroke and then next time through check the... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50069/"
] | How can I grab something like ^MM (CTRL + M + M) in .NET, using C#? | Here's a way to do it:
```
bool mSeenCtrlM;
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
if (keyData == (Keys.Control | Keys.M)) {
mSeenCtrlM = !mSeenCtrlM;
if (!mSeenCtrlM) {
MessageBox.Show("yada");
}
return true;
}
mSeenCtrlM = false;
return base.ProcessCmdKe... |
399,538 | <p>I'm building a C++ application and need to use PDCurses on Windows. I'm compiling with VC++ from MS VS 2005 and I'm getting a link error.</p>
<blockquote>
<pre><code> error LNK2019: unresolved external
symbol __imp__GetKeyState@4 referenced
in function __get_key_count
</code></pre>
</blockquote>
<p>There are 11 ... | [
{
"answer_id": 399668,
"author": "DavidK",
"author_id": 31394,
"author_profile": "https://Stackoverflow.com/users/31394",
"pm_score": 3,
"selected": true,
"text": "<p>GetKeyState() is a Windows function in \"user32.dll\", so you need to be sure you're linking against \"user32.lib\". You ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14069/"
] | I'm building a C++ application and need to use PDCurses on Windows. I'm compiling with VC++ from MS VS 2005 and I'm getting a link error.
>
>
> ```
> error LNK2019: unresolved external
> symbol __imp__GetKeyState@4 referenced
> in function __get_key_count
>
> ```
>
>
There are 11 errors all with the same erro... | GetKeyState() is a Windows function in "user32.dll", so you need to be sure you're linking against "user32.lib". You may also need to make sure it comes after the PDCurses library in the list of linker libraries, too. |
399,567 | <p>I seem to have a problem with this SQL query:</p>
<pre><code>SELECT * FROM appts
WHERE timeStart >='$timeStart'
AND timeEnd <='$timeEnd'
AND dayappt='$boatdate'
</code></pre>
<p>The time is formatted as military time. The logistics is that a boat rental can be reserved at 7am til 1pm or 9am til 1pm or 9am... | [
{
"answer_id": 399577,
"author": "Shane Delmore",
"author_id": 50031,
"author_profile": "https://Stackoverflow.com/users/50031",
"pm_score": 4,
"selected": true,
"text": "<p>The correct check would look like this:</p>\n\n<pre><code>SELECT * FROM appts \nWHERE timeStart <='$timeEnd' \n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47301/"
] | I seem to have a problem with this SQL query:
```
SELECT * FROM appts
WHERE timeStart >='$timeStart'
AND timeEnd <='$timeEnd'
AND dayappt='$boatdate'
```
The time is formatted as military time. The logistics is that a boat rental can be reserved at 7am til 1pm or 9am til 1pm or 9am til 5pm. If there is an appt wi... | The correct check would look like this:
```
SELECT * FROM appts
WHERE timeStart <='$timeEnd'
AND timeEnd >='$timeStart'
AND dayappt='$boatdate'
```
Other good explanations have been given but I'll go ahead and update it with an alternative explanation of how I visualize this myself. Most people are looking for ea... |
399,572 | <p>The HtmlObject provides all the necessary functionality to register managed event handlers for script and DOM events, but what if the class you need to listen to doesn't exist as a DOM element, but a scripting variable (referenced via ScriptObject) instead? </p>
| [
{
"answer_id": 399577,
"author": "Shane Delmore",
"author_id": 50031,
"author_profile": "https://Stackoverflow.com/users/50031",
"pm_score": 4,
"selected": true,
"text": "<p>The correct check would look like this:</p>\n\n<pre><code>SELECT * FROM appts \nWHERE timeStart <='$timeEnd' \n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5988/"
] | The HtmlObject provides all the necessary functionality to register managed event handlers for script and DOM events, but what if the class you need to listen to doesn't exist as a DOM element, but a scripting variable (referenced via ScriptObject) instead? | The correct check would look like this:
```
SELECT * FROM appts
WHERE timeStart <='$timeEnd'
AND timeEnd >='$timeStart'
AND dayappt='$boatdate'
```
Other good explanations have been given but I'll go ahead and update it with an alternative explanation of how I visualize this myself. Most people are looking for ea... |
399,582 | <p>I have a Grails application with a JSP page (I'm porting a legacy JSP application). For some reason, the page renders completely blank. Looking at the HTTP headers I see it's 200 with a content length of 0.</p>
<pre><code>HTTP/1.1 200 OK
Content-Language: en-US
Content-Type: text/html; charset=iso-8859-1
Expires: T... | [
{
"answer_id": 399577,
"author": "Shane Delmore",
"author_id": 50031,
"author_profile": "https://Stackoverflow.com/users/50031",
"pm_score": 4,
"selected": true,
"text": "<p>The correct check would look like this:</p>\n\n<pre><code>SELECT * FROM appts \nWHERE timeStart <='$timeEnd' \n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24396/"
] | I have a Grails application with a JSP page (I'm porting a legacy JSP application). For some reason, the page renders completely blank. Looking at the HTTP headers I see it's 200 with a content length of 0.
```
HTTP/1.1 200 OK
Content-Language: en-US
Content-Type: text/html; charset=iso-8859-1
Expires: Thu, 01 Jan 197... | The correct check would look like this:
```
SELECT * FROM appts
WHERE timeStart <='$timeEnd'
AND timeEnd >='$timeStart'
AND dayappt='$boatdate'
```
Other good explanations have been given but I'll go ahead and update it with an alternative explanation of how I visualize this myself. Most people are looking for ea... |
399,594 | <p>I've been using ReSharper for the past months and, advertising aside, I can't see myself coding without it. Since I love living on the bleeding "What the hell just went wrong" edge, I decided to try my luck w/ the latest ReSharper 4.5 nightly builds. It's all nice.</p>
<p>However, I've noticed that the using direct... | [
{
"answer_id": 399608,
"author": "Jon",
"author_id": 50079,
"author_profile": "https://Stackoverflow.com/users/50079",
"pm_score": 4,
"selected": true,
"text": "<p>As Scott proceeds to discover in his post, there is <strong>no runtime difference</strong> between these two cases. Therefor... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40164/"
] | I've been using ReSharper for the past months and, advertising aside, I can't see myself coding without it. Since I love living on the bleeding "What the hell just went wrong" edge, I decided to try my luck w/ the latest ReSharper 4.5 nightly builds. It's all nice.
However, I've noticed that the using directives group... | As Scott proceeds to discover in his post, there is **no runtime difference** between these two cases. Therefore, it does **not** serve the purpose of lazy loading references.
If you read the comments in Scott's blog all the way to the end, you will also see that the developer who passed this rumor to Scott (Mike Brow... |
399,595 | <p>I may be missing something here because I thought this might be really easy but...</p>
<p>Using Flex, how can you tell when a ComboBox is open? I do find the open and close events that this component dispatches can be flaky so I'm looking for something a little more solid - it's probably staring me in the face.</p... | [
{
"answer_id": 399851,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 0,
"selected": false,
"text": "<p>The designers probably thought it was enough with the open and close events.</p>\n\n<p>EDIT: I'll clarify that. Looking for... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | I may be missing something here because I thought this might be really easy but...
Using Flex, how can you tell when a ComboBox is open? I do find the open and close events that this component dispatches can be flaky so I'm looking for something a little more solid - it's probably staring me in the face. | How about checking either the existence or the visibility of the dropDown component?
The dropDown is a component of type ListBase, and can be accessed through the `dropDown` property. So maybe something like this (I didn't have time to test this myself):
```
if (myComboBox.dropDown != null && myComboBox.dropDown.visi... |
399,606 | <p>I wonder if anyone here has any experience with mercurial running on Ubuntu? I've been playing with it all morning and love everything I've seen so far.</p>
<p>The one problem I though is when I do a merge and conflicts are detected, it doesn't automatically bring the file up in the command line editor to allow me ... | [
{
"answer_id": 399637,
"author": "Ted Naleid",
"author_id": 8912,
"author_profile": "https://Stackoverflow.com/users/8912",
"pm_score": 2,
"selected": false,
"text": "<p>What commands are you using, and what does your ~/.hgrc look like? If you're using the fetch extension, it should be ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37196/"
] | I wonder if anyone here has any experience with mercurial running on Ubuntu? I've been playing with it all morning and love everything I've seen so far.
The one problem I though is when I do a merge and conflicts are detected, it doesn't automatically bring the file up in the command line editor to allow me to resolve... | You probably need to define your merge tool in ~/.hgrc:
```
[ui]
merge = vimdiff
``` |
399,616 | <p>For a scripting utility I need to be able to record a series of keyboard and mouse events that occur when an application has focus. The second part is being able to later send those events to the active window.</p>
<p>I do not need to worry about menus or tracking the identifier of which window receives input.</p>
... | [
{
"answer_id": 399626,
"author": "diciu",
"author_id": 2811,
"author_profile": "https://Stackoverflow.com/users/2811",
"pm_score": 1,
"selected": false,
"text": "<p>For tapping mouse events, see <a href=\"https://web.archive.org/web/20200103161752/http://osxbook.com/book/bonus/chapter2/a... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1043/"
] | For a scripting utility I need to be able to record a series of keyboard and mouse events that occur when an application has focus. The second part is being able to later send those events to the active window.
I do not need to worry about menus or tracking the identifier of which window receives input.
I know how to... | The first thing i will tell you is that you *CAN'T* do this without the user enabling support for assitive devices in the accessability control panel. It's some kind of security built into OSX.
Here is a code snippit I am using in one of my applications to do this:
```
//this method calls a carbon method to attach a ... |
399,648 | <p>If I am assigning an event handler at runtime and it is in a spot that can be called multiple times, what is the recommended practice to prevent multiple assignments of the same handler to the same event.</p>
<pre><code>object.Event += MyFunction
</code></pre>
<p>Adding this in a spot that will be called more than... | [
{
"answer_id": 399662,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 2,
"selected": false,
"text": "<p>I tend to add an event handler in a path that's executed once, for example in a constructor.</p>\n"
},
{
"answer... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I am assigning an event handler at runtime and it is in a spot that can be called multiple times, what is the recommended practice to prevent multiple assignments of the same handler to the same event.
```
object.Event += MyFunction
```
Adding this in a spot that will be called more than once will execute the han... | Baget is right about using an explicitly implemented event (although there's a mixture there of explicit interface implementation and the full event syntax). You can probably get away with this:
```
private EventHandler foo;
public event EventHandler Foo
{
add
{
// First try to remove the handler, the... |
399,669 | <p>I'm using Subversion 1.4.6, and I cannot upgrade to version 1.5 right now.</p>
<p>The situation:</p>
<ol>
<li><p>The trunk has a lot of structural changes (i.e. moving files around, mostly).</p></li>
<li><p>I have a branch that was recently merged from the trunk, but before the major changes.</p></li>
</ol>
<p>Wh... | [
{
"answer_id": 399701,
"author": "Stefan",
"author_id": 48003,
"author_profile": "https://Stackoverflow.com/users/48003",
"pm_score": 7,
"selected": true,
"text": "<p>Is there something that prevents you from merging all revisions on trunk since the last merge?</p>\n\n<pre><code>svn merg... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11515/"
] | I'm using Subversion 1.4.6, and I cannot upgrade to version 1.5 right now.
The situation:
1. The trunk has a lot of structural changes (i.e. moving files around, mostly).
2. I have a branch that was recently merged from the trunk, but before the major changes.
What is the best way to merge the trunk to the branch?
... | Is there something that prevents you from merging all revisions on trunk since the last merge?
```
svn merge -rLastRevisionMergedFromTrunkToBranch:HEAD url/of/trunk path/to/branch/wc
```
should work just fine. At least if you want to merge all changes on trunk to your branch. |
399,674 | <p>How can I read Authorization header information from a REST based WCF service?</p>
| [
{
"answer_id": 399755,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 3,
"selected": false,
"text": "<p>You are trying to read the http header.</p>\n\n<pre><code>OperationContext.Current.OutgoingMessageProperties\nor\nOperat... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27052/"
] | How can I read Authorization header information from a REST based WCF service? | Actually since you ask for a REST based WCF service I think you should use
```
WebOperationContext.Current.IncomingRequest.Headers
```
in order to get the HTTP headers in the request. |
399,719 | <p>So, I'm trying to use ADO.NET to stream a file data stored in an image column in a SQL Compact database.</p>
<p>To do this, I wrote a DataReaderStream class that takes a data reader, opened for sequential access, and represents it as a stream, redirecting calls to Read(...) on the stream to IDataReader.GetBytes(...... | [
{
"answer_id": 401599,
"author": "Scott Wisniewski",
"author_id": 1737192,
"author_profile": "https://Stackoverflow.com/users/1737192",
"pm_score": 1,
"selected": false,
"text": "<p>I contacted Microsoft (through the SQL Compact Blog) and they confirmed the bug, and suggested I use OLEDB... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737192/"
] | So, I'm trying to use ADO.NET to stream a file data stored in an image column in a SQL Compact database.
To do this, I wrote a DataReaderStream class that takes a data reader, opened for sequential access, and represents it as a stream, redirecting calls to Read(...) on the stream to IDataReader.GetBytes(...).
One "w... | Actually, I decided to fix the problem by just not storing blobs in the database to begin with.
This eliminates the problem (I can stream data from a file), and also fixes some issues I might have run into with Sql Compact's 4 GB size limit. |
399,734 | <p>I have a script that calls an application that requires user input, e.g. run app that requires user to type in 'Y' or 'N'.<br>
How can I get the shell script not to ask the user for the input but rather use the value from a predefined variable in the script?</p>
<p>In my case there will be two questions that requir... | [
{
"answer_id": 399736,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 5,
"selected": true,
"text": "<p>You can pipe in whatever text you'd like on stdin and it will be just the same as having the user type it themse... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a script that calls an application that requires user input, e.g. run app that requires user to type in 'Y' or 'N'.
How can I get the shell script not to ask the user for the input but rather use the value from a predefined variable in the script?
In my case there will be two questions that require input. | You can pipe in whatever text you'd like on stdin and it will be just the same as having the user type it themselves. For example to simulating typing "Y" just use:
```
echo "Y" | myapp
```
or using a shell variable:
```
echo $ANSWER | myapp
```
There is also a unix command called "yes" that outputs a continuous ... |
399,740 | <p>Have a interface </p>
<pre><code>class abc {
public:
virtual int foo() = 0;
...
}
class concrete1: public abc {
public:
int foo() {
..
}
class concrete2 : public abc {
public:
int foo() {
..
}
}
</code></pre>
<p>Now in my main program I need to construct classes based upon a value of a variable </p>... | [
{
"answer_id": 399742,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>You are looking for <a href=\"http://en.wikipedia.org/wiki/Factory_method_pattern\" rel=\"nofollow norefe... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | Have a interface
```
class abc {
public:
virtual int foo() = 0;
...
}
class concrete1: public abc {
public:
int foo() {
..
}
class concrete2 : public abc {
public:
int foo() {
..
}
}
```
Now in my main program I need to construct classes based upon a value of a variable
```
abc *a;
if (var == 1)
a... | You are looking for <http://en.wikipedia.org/wiki/Factory_method_pattern> |
399,791 | <p>I recently installed my video script to a new server but I am seeing that it will start to convert 1 video (via mencoder) then before finishing it, it will try and convery another, and another, so it will be trying to convert 4+ videos at the same time causing the server to shut down. The script developer said:</p>
... | [
{
"answer_id": 399796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Use some sort of lock. For example, use file locking on a directory so only one process at a time can use the resource.</p... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I recently installed my video script to a new server but I am seeing that it will start to convert 1 video (via mencoder) then before finishing it, it will try and convery another, and another, so it will be trying to convert 4+ videos at the same time causing the server to shut down. The script developer said:
"It co... | Use [PHP Semaphores](http://in.php.net/sem)
===========================================
You can use a shared counting Semaphore in PHP, and implement a queue with a cap on the no. of parallel executions. Semaphores are always the most recommended method for any form of concurrency control.
Using this you can easily c... |
399,792 | <p>It seems that </p>
<pre><code>if (x=y) { .... }
</code></pre>
<p>instead of</p>
<pre><code>if (x==y) { ... }
</code></pre>
<p>is a root of many evils.</p>
<p>Why don't <em>all</em> compilers <em>mark it as error</em> instead of a configurable warning?</p>
<p>I'm interested in finding out cases where the const... | [
{
"answer_id": 399800,
"author": "lImbus",
"author_id": 32490,
"author_profile": "https://Stackoverflow.com/users/32490",
"pm_score": 5,
"selected": false,
"text": "<p>One useful construct is for example:</p>\n<pre><code>char *pBuffer;\nif (pBuffer = malloc(100))\n{\n // Continue to w... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18275/"
] | It seems that
```
if (x=y) { .... }
```
instead of
```
if (x==y) { ... }
```
is a root of many evils.
Why don't *all* compilers *mark it as error* instead of a configurable warning?
I'm interested in finding out cases where the construct `if (x=y)` is useful. | Most of the time, compilers try very hard to remain backward compatible.
Changing their behavior in this matter to throw errors will break existing legitimate code, and even starting to throw warnings about it will cause problems with automatic systems that keep track of code by automatically compiling it and checking... |
399,798 | <pre><code> string str1 = "12345ABC...\\...ABC100000";
// Hypothetically huge string of 100000 + Unicode Chars
str1 = str1.Replace("1", string.Empty);
str1 = str1.Replace("22", string.Empty);
str1 = str1.Replace("656", string.Empty);
str1 = str1.Replace("77ABC", string.Empty);
// ... this replace anti-pattern ... | [
{
"answer_id": 399805,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>StringBuilder: <a href=\"http://msdn.microsoft.com/en-us/library/2839d5h5.aspx\" rel=\"nofollow noreferrer\">http://msdn.mi... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46100/"
] | ```
string str1 = "12345ABC...\\...ABC100000";
// Hypothetically huge string of 100000 + Unicode Chars
str1 = str1.Replace("1", string.Empty);
str1 = str1.Replace("22", string.Empty);
str1 = str1.Replace("656", string.Empty);
str1 = str1.Replace("77ABC", string.Empty);
// ... this replace anti-pattern might h... | *All* characters in a .NET string are "unicode chars". Do you mean they're non-ascii? That shouldn't make any odds - unless you run into composition issues, e.g. an "e + acute accent" not being replaced when you try to replace an "e acute".
You could try using a regular expression with [`Regex.Replace`](http://msdn.mi... |
399,815 | <p>I'm working on an Eclipse RCP application. Today I experienced some troubles when displaying images in the context menu. What I wanted to do is to add a column to my table containing images of stars for representing a user rating. On Windows, this causes some problems, since the star images are squeezed up on the le... | [
{
"answer_id": 399901,
"author": "eljenso",
"author_id": 30316,
"author_profile": "https://Stackoverflow.com/users/30316",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe this is simply a bug, in which case there would be no real answer to your question.</p>\n\n<p>Look if someone has... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50109/"
] | I'm working on an Eclipse RCP application. Today I experienced some troubles when displaying images in the context menu. What I wanted to do is to add a column to my table containing images of stars for representing a user rating. On Windows, this causes some problems, since the star images are squeezed up on the left ... | When SWT-images have not shown up for me it has been because:
* I've used capital letters in the image filename, but not in the source code. Works on Windows, not Linux.
* I've tried to run a x64 version of SWT before it was supported.
* I've used VNC. Not sure why it doesn't work, color depth problems?
* I've used Ub... |
399,822 | <p>I am trying to use NVelocity templates in a .Net application: using a template to output results to a file. It all seems to work fine except for the fact that the output is never fully overwritten. If my file is 100 characters long and the template only renders 20 characters, the last 80 characters are never altered... | [
{
"answer_id": 427963,
"author": "Andrew",
"author_id": 5662,
"author_profile": "https://Stackoverflow.com/users/5662",
"pm_score": 2,
"selected": false,
"text": "<p>I think the solution is to change the <code>FileMode.OpenOrCreate</code> to simply <code>FileMode.Create</code> in the fir... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22360/"
] | I am trying to use NVelocity templates in a .Net application: using a template to output results to a file. It all seems to work fine except for the fact that the output is never fully overwritten. If my file is 100 characters long and the template only renders 20 characters, the last 80 characters are never altered!
... | I think the solution is to change the `FileMode.OpenOrCreate` to simply `FileMode.Create` in the first line
From the MSDN Article on [System.IO.FileMode](http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx "MSDN System.IO.FileMode")..
>
> **FileMode.Create**
> Specifies that the operating system should ... |
399,826 | <p>I have 3 buttons in a form. One of them is the submit button. How can I make it the default button to be clicked when I press the enter key. Is there a property for this?</p>
| [
{
"answer_id": 399839,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 4,
"selected": true,
"text": "<p>There is a property for the form: defaultbutton.</p>\n\n<pre><code><form runat=\"server\" defaultbutton=\"myButton\">\n..... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] | I have 3 buttons in a form. One of them is the submit button. How can I make it the default button to be clicked when I press the enter key. Is there a property for this? | There is a property for the form: defaultbutton.
```
<form runat="server" defaultbutton="myButton">
...
</form>
```
It is first time implemented in ASP.NET 2.0. |
399,850 | <p>What compiler warning level do you recommend for different C/C++ compilers?</p>
<p>gcc and g++ will let you get away with a lot on the default level. I find the best warning level for me is '-Wall'. And I always try to remove fix the code for the warnings it generates. (Even the silly ones about using parenthesi... | [
{
"answer_id": 399855,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "<p>I tend to use <code>-Wall</code> (because everyone does make bugs, nobody is perfect) , but i don't use ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What compiler warning level do you recommend for different C/C++ compilers?
gcc and g++ will let you get away with a lot on the default level. I find the best warning level for me is '-Wall'. And I always try to remove fix the code for the warnings it generates. (Even the silly ones about using parenthesis for logical... | This is a set of extra-paranoid flags I'm using for C++ code:
```
-g -O -Wall -Weffc++ -pedantic \
-pedantic-errors -Wextra -Waggregate-return -Wcast-align \
-Wcast-qual -Wchar-subscripts -Wcomment -Wconversion \
-Wdisabled-optimization \
-Werror -Wfloat-equal -Wformat -Wformat=2 \
-Wforma... |
399,867 | <p>I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript library/plugin to handle some preview functionality.</p>
<p>I've got a script running to update some text in a dom eleme... | [
{
"answer_id": 399877,
"author": "Tuxified",
"author_id": 49792,
"author_profile": "https://Stackoverflow.com/users/49792",
"pm_score": 4,
"selected": false,
"text": "<p>I think so.. it's possible to 'bind' custom events, like(from: <a href=\"http://docs.jquery.com/Events/bind#typedatafn... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] | I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript library/plugin to handle some preview functionality.
I've got a script running to update some text in a dom element from a ... | Take a look at this:
(reprinted from the expired blog page <http://jamiethompson.co.uk/web/2008/06/17/publish-subscribe-with-jquery/> based on the archived version at <http://web.archive.org/web/20130120010146/http://jamiethompson.co.uk/web/2008/06/17/publish-subscribe-with-jquery/>)
---
Publish / Subscribe With jQu... |
399,907 | <p>I'm writing a sparse matrix class in C++ in which every row and column are arrays of linked lists from a class I created (aptly named: LinkedList).</p>
<p>I want to write a class that is a "smart" pointer to one cell in this matrix.</p>
<p>In that class, let say <code>LIPointer</code>, I will implement a <code>++<... | [
{
"answer_id": 399899,
"author": "Nolte",
"author_id": 48036,
"author_profile": "https://Stackoverflow.com/users/48036",
"pm_score": 0,
"selected": false,
"text": "<p>You are going to want to read up on \"Unit Testing\" in a generic sense and then try and apply them to PHP.</p>\n\n<p>The... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49500/"
] | I'm writing a sparse matrix class in C++ in which every row and column are arrays of linked lists from a class I created (aptly named: LinkedList).
I want to write a class that is a "smart" pointer to one cell in this matrix.
In that class, let say `LIPointer`, I will implement a `++` operator function for moving in ... | I have used [phpsh](http://www.phpsh.org/) in the past and found it very useful. Once you start it you will need to `chdir()` to where your files are and then obviously `require()` any files containing functions you need to test. You can then just test your function calls by typing them into the shell e.g. `var_dump(so... |
399,932 | <p>So, I have been working on this domain name regular expression. So far, it seems to pick up domain names with SLDs and TLDs (with the optional ccTLD), but there is duplication of the TLD listing. Can this be refactored any further?</p>
<pre><code>params[:domain_name].downcase.strip.match(/^[a-z0-9\-]{2,63}
\.((a[cd... | [
{
"answer_id": 399945,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know enough about domain names probably. But why is domains like \"foo.info.com\" matched? It seems that the domain... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40644/"
] | So, I have been working on this domain name regular expression. So far, it seems to pick up domain names with SLDs and TLDs (with the optional ccTLD), but there is duplication of the TLD listing. Can this be refactored any further?
```
params[:domain_name].downcase.strip.match(/^[a-z0-9\-]{2,63}
\.((a[cdefgilmnoqrstuw... | Please, please, please *don't* use a fixed and horribly complicated regex like this to match for known domain names.
The list of TLDs is *not* static, particularly with ICANN looking at a streamlined process for new gTLDs. Even the list of ccTLDs changes sometimes!
Have a look at the list available from <http://publi... |
399,942 | <p>In the following code, g++ gives this error :
1.cpp: In member function <code>void W::test()':
1.cpp:6: error:</code>int F::glob' is private
1.cpp:19: error: within this context</p>
<p>But, shouldn't the globally declared
variable 'glob' be used here, instead
of the "private" "glob"?</p>
<pre><code> #include <... | [
{
"answer_id": 399947,
"author": "Marc",
"author_id": 27947,
"author_profile": "https://Stackoverflow.com/users/27947",
"pm_score": 2,
"selected": false,
"text": "<p>You can try using <code>::glob--;</code> instead. This way you tell the compiler to use the global namespace.</p>\n"
},
... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49560/"
] | In the following code, g++ gives this error :
1.cpp: In member function `void W::test()':
1.cpp:6: error:`int F::glob' is private
1.cpp:19: error: within this context
But, shouldn't the globally declared
variable 'glob' be used here, instead
of the "private" "glob"?
```
#include <iostream.h>
int glob;
cla... | Variables and functions are accessed using scoping rules, not visbility rules. Because `F::glob` is the `glob` in the scope of `W::test()`, it is used. However, `W::test()` does not have access to `F::glob`, and an error results. The compiler does *not* check for `::glob` because something else preceeds it in scope "pr... |
399,972 | <p>I'm setting up a new 64 bit machine to run as a build server. When I try to load my NUnit test assembly into NUnit GUI I get the following error.</p>
<p>There is nothing obvious missing, all the dependencies seem to be present. All the DLLs are compiled for the x86 platform.</p>
<p>Using NUnit 2.4.7. I have trie... | [
{
"answer_id": 399981,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 2,
"selected": false,
"text": "<p>Activate the Fusion log with <a href=\"http://msdn.microsoft.com/en-us/library/e74a18c4.aspx\" rel=\"nofollow noref... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44950/"
] | I'm setting up a new 64 bit machine to run as a build server. When I try to load my NUnit test assembly into NUnit GUI I get the following error.
There is nothing obvious missing, all the dependencies seem to be present. All the DLLs are compiled for the x86 platform.
Using NUnit 2.4.7. I have tried upgrading to 2.4.... | The solution was to build the test project for "AnyCPU" instead of 32-bit. I can work around the restriction that made us use 32 bit.
Thank you David and Joe90 for the suggestions. I've certainly learned a couple of new things. fuslogvw.exe is awesome, I didn't previously know it existed. |
399,975 | <p>I am new to Excel macros. I have some columns with headings scattered in many sheets. I would like to type a heading in some column which has the cursor and have the column with that heading copy-pasted to the column with the cursor. </p>
<p>Is it possible to do this by recording a macro? How? If not, how do I do i... | [
{
"answer_id": 400138,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Does the heading appear many times across the different sheets? If not, then I would suggest using a simple if statement </... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34596/"
] | I am new to Excel macros. I have some columns with headings scattered in many sheets. I would like to type a heading in some column which has the cursor and have the column with that heading copy-pasted to the column with the cursor.
Is it possible to do this by recording a macro? How? If not, how do I do it programm... | Here are a few notes on code to copy a found column.
```
Dim ws As Worksheet
Dim r As Range
Dim CopyTo As String
'You must run the code from a suitable active cell '
strFind = ActiveCell.Value
'Assumes the column data will be written into the next row down '
CopyTo = ActiveCell.Offset(1, 0).Address
'Look at each wor... |
399,991 | <p>When I pass the options in the program (a computational biology experiment) I usually pass them through a .py file.<br>
So I have this .py file that reads like:</p>
<pre><code>starting_length=9
starting_cell_size=1000
LengthofExperiments=5000000
</code></pre>
<p>Then I execute the file and get the data. Since the ... | [
{
"answer_id": 400040,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 5,
"selected": true,
"text": "<pre>\nvinko@mithril$ more a.py\n\ndef foo(a):\n print a\n\nvinko@mithril$ more b.py\n\nimport a\nimport inspect\n\n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46634/"
] | When I pass the options in the program (a computational biology experiment) I usually pass them through a .py file.
So I have this .py file that reads like:
```
starting_length=9
starting_cell_size=1000
LengthofExperiments=5000000
```
Then I execute the file and get the data. Since the program is all on my machin... | ```
vinko@mithril$ more a.py
def foo(a):
print a
vinko@mithril$ more b.py
import a
import inspect
a.foo(89)
print inspect.getsource(a.foo)
vinko@mithril$ python b.py
89
def foo(a):
print a
``` |
400,050 | <p>Using Python, how would I go about reading in (be from a string, file or url) a mathematical expression (1 + 1 is a good start) and executing it? </p>
<p>Aside from grabbing a string, file or url I have no idea of where to start with this.</p>
| [
{
"answer_id": 400060,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 2,
"selected": false,
"text": "<p>If you are receiving an expression as a string you'll need to parse it into its operators and operands and then process t... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1384652/"
] | Using Python, how would I go about reading in (be from a string, file or url) a mathematical expression (1 + 1 is a good start) and executing it?
Aside from grabbing a string, file or url I have no idea of where to start with this. | Because python supports some algebraic forms, you could do:
```
eval("1 + 1")
```
But this allows the input to execute about anything defined in your env:
```
eval("__import__('sys').exit(1)")
```
Also, if you want to support something python doesn't support, the approach fails:
```
x³ + y² + c
----------- = 0
... |
400,051 | <p>I have a basic test web form with a DataList and a DetailsView and two XmlDataSource components for each of them.</p>
<p>The binding of the DataList to the underlying XML document was easy to set up, but I'm struggling with getting the DetailsView hooked up. The idea is that there is a master/details relationship b... | [
{
"answer_id": 400060,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 2,
"selected": false,
"text": "<p>If you are receiving an expression as a string you'll need to parse it into its operators and operands and then process t... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2732/"
] | I have a basic test web form with a DataList and a DetailsView and two XmlDataSource components for each of them.
The binding of the DataList to the underlying XML document was easy to set up, but I'm struggling with getting the DetailsView hooked up. The idea is that there is a master/details relationship between the... | Because python supports some algebraic forms, you could do:
```
eval("1 + 1")
```
But this allows the input to execute about anything defined in your env:
```
eval("__import__('sys').exit(1)")
```
Also, if you want to support something python doesn't support, the approach fails:
```
x³ + y² + c
----------- = 0
... |
400,094 | <p>There are many debugging option available, but it says you need to compile Perl with
-DDEBUGGER option. How do we do that on Windows with ActivePerl.</p>
<p>Also, I had this problem of out of memory with Perl. I was reading a XML file with 5 lines but the second line was way way too big, (the file size was 4.3Mb) ... | [
{
"answer_id": 400095,
"author": "juan",
"author_id": 1782,
"author_profile": "https://Stackoverflow.com/users/1782",
"pm_score": 0,
"selected": false,
"text": "<p>ASP.NET MVC is just a different model than classic ASP.NET, an extension if you will.</p>\n\n<p>From <a href=\"http://dotnet... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There are many debugging option available, but it says you need to compile Perl with
-DDEBUGGER option. How do we do that on Windows with ActivePerl.
Also, I had this problem of out of memory with Perl. I was reading a XML file with 5 lines but the second line was way way too big, (the file size was 4.3Mb) for 5 line... | If your developers have not yet worked on any solutions using a Model-View-Controller concept, they will find that the ASP.Net MVC Framework will have **quite a bit of a steep learning curve**.
This is because it's not built on the usual code behind and .aspx physical pages that you normally use in a Web-Forms applica... |
400,097 | <p>I'm currently using NHibernate as my data access layer, using Fluent NHibernate to create the mapping files for me. I have two classes, TripItem and TripItemAttributeValue, which have a many-to-many relation between them.</p>
<p>The mapping is as follows:</p>
<pre><code>public class TripItemMap : ClassMap<TripI... | [
{
"answer_id": 406838,
"author": "kͩeͣmͮpͥ ͩ",
"author_id": 26479,
"author_profile": "https://Stackoverflow.com/users/26479",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure how you do it with Fluent NHibernate but you need to set the Cascade option on the bag (<code>TripItems... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50145/"
] | I'm currently using NHibernate as my data access layer, using Fluent NHibernate to create the mapping files for me. I have two classes, TripItem and TripItemAttributeValue, which have a many-to-many relation between them.
The mapping is as follows:
```
public class TripItemMap : ClassMap<TripItem2>
{
public TripI... | @efdee
I was having the same problem and spent almost two days on this. I had a many to many relationship and the link table wasn't being updated either. I'm new to NHibernate, just trying to learn it so take everything I say with a grain of salt.
Well it turned out that it's not Fluent NHibernate, nor the mapping, b... |
400,099 | <p>I'm trying to get a WCF Client assembly deploy in SQL 2005. This means I need to create/register the dependencies for my WCF Client, which are:</p>
<ul>
<li>System.Runtime.Serialization</li>
<li>System.Web</li>
<li>System.ServiceModel</li>
</ul>
<p>With this script:</p>
<pre><code>CREATE ASSEMBLY System_Runtime_S... | [
{
"answer_id": 400363,
"author": "Sailing Judo",
"author_id": 42620,
"author_profile": "https://Stackoverflow.com/users/42620",
"pm_score": 0,
"selected": false,
"text": "<p>This seems to solve this issue for other people..</p>\n\n<blockquote>\n <p>I just tried this exact same statement... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5555/"
] | I'm trying to get a WCF Client assembly deploy in SQL 2005. This means I need to create/register the dependencies for my WCF Client, which are:
* System.Runtime.Serialization
* System.Web
* System.ServiceModel
With this script:
```
CREATE ASSEMBLY System_Runtime_Serialization FROM 'C:\Windows\Microsoft.NET\Framework... | OK, figured this out:
I think this happens because I'm on a 64-bit system. I was trying to add the 32-bit version of System.Web to a 64-bit SQL Server (and I think the 32-bit version indeed references the 64-bit version).
Anyway, for reference the working code is below:
```
CREATE ASSEMBLY System_Runtime_Serializati... |
400,100 | <p>I have a Linq to Entities query like this one:</p>
<pre><code>var results = from r in entities.MachineRevision
where r.Machine.IdMachine == pIdMachine
&& r.Category == (int)pCategory
select r;
</code></pre>
<p>Usually, I use the code below to check if some resul... | [
{
"answer_id": 400105,
"author": "NikolaiDante",
"author_id": 39643,
"author_profile": "https://Stackoverflow.com/users/39643",
"pm_score": 0,
"selected": false,
"text": "<p>try using</p>\n\n<pre><code>IENumerable<MachineRevision> results = from r in entities.MachineRevision\n...\n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29544/"
] | I have a Linq to Entities query like this one:
```
var results = from r in entities.MachineRevision
where r.Machine.IdMachine == pIdMachine
&& r.Category == (int)pCategory
select r;
```
Usually, I use the code below to check if some results are returned:
```
if (results.... | **EDIT**: Based on your update, the error may be related to an enum in your entity class. See this [blog entry](http://gmontrone.com/problem-with-casting-enums-in-linq-to-entities/) for more information and a work-around. I'm leaving my original answer as an improvement on your query syntax.
Try doing the selection of... |
400,113 | <p>I'm looking for a best way to implement common Windows keyboard shortcuts (for example <kbd>Ctrl</kbd>+<kbd>F</kbd>, <kbd>Ctrl</kbd>+<kbd>N</kbd>) in my <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="noreferrer">Windows Forms</a> application in C#.</p>
<p>The application has a main form which hosts many ... | [
{
"answer_id": 400119,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "<p>The best way is to use menu mnemonics, i.e. to have menu entries in your main form that get assigned the keyboard ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5290/"
] | I'm looking for a best way to implement common Windows keyboard shortcuts (for example `Ctrl`+`F`, `Ctrl`+`N`) in my [Windows Forms](http://en.wikipedia.org/wiki/Windows_Forms) application in C#.
The application has a main form which hosts many child forms (one at a time). When a user hits `Ctrl`+`F`, I'd like to show... | You probably forgot to set the form's [KeyPreview](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx) property to True. Overriding the [ProcessCmdKey()](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.processcmdkey.aspx) method is the generic solution:
```
protected... |
400,116 | <p>What is the purpose of <code>__builtin_offsetof</code> operator (or <code>_FOFF</code> operator in Symbian) in C++?</p>
<p>In addition what does it return? Pointer? Number of bytes?</p>
| [
{
"answer_id": 400127,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 5,
"selected": true,
"text": "<p>It's a builtin provided by the GCC compiler to implement the <code>offsetof</code> macro that is specifie... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16177/"
] | What is the purpose of `__builtin_offsetof` operator (or `_FOFF` operator in Symbian) in C++?
In addition what does it return? Pointer? Number of bytes? | It's a builtin provided by the GCC compiler to implement the `offsetof` macro that is specified by the C and C++ Standard:
[GCC - offsetof](http://gcc.gnu.org/onlinedocs/gcc/Offsetof.html#Offsetof)
It returns the offset in bytes that a member of a POD struct/union is at.
Sample:
```
struct abc1 { int a, b, c; };
u... |
400,130 | <p>Let's say I have a class that implements the <strong>IDisposable</strong> interface. Something like this:</p>
<p><img src="https://farm4.static.flickr.com/3199/3149605015_f090f20185_o.png" alt="http://www.flickr.com/photos/garthof/3149605015/"></p>
<p><strong>MyClass</strong> uses some unmanaged resources, hence t... | [
{
"answer_id": 400145,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 3,
"selected": false,
"text": "<p>Async methods usually have a callback allowing you to do do some action upon completition. If this is your cas... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679/"
] | Let's say I have a class that implements the **IDisposable** interface. Something like this:

**MyClass** uses some unmanaged resources, hence the *Dispose()* method from **IDisposable** releases those... | So, my idea is to keep how many *AsyncDoSomething()* are pending to complete, and only dispose when this count reaches to zero. My initial approach is:
```
public class MyClass : IDisposable {
private delegate void AsyncDoSomethingCaller();
private delegate void AsyncDoDisposeCaller();
private int pendin... |
400,140 | <p>What's a good way to ensure that a temp file is deleted if my application closes or crashes? Ideally, I would like to obtain a temp file, use it, and then forget about it.</p>
<p>Right now, I keep a list of my temp files and delete them with an EventHandler that's triggered on Application.ApplicationExit.</p>
<p>Is ... | [
{
"answer_id": 400178,
"author": "csl",
"author_id": 21028,
"author_profile": "https://Stackoverflow.com/users/21028",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not primarily a C# programmer, but in C++ I'd use <a href=\"https://en.wikipedia.org/wiki/Resource_acquisition_is_initi... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17413/"
] | What's a good way to ensure that a temp file is deleted if my application closes or crashes? Ideally, I would like to obtain a temp file, use it, and then forget about it.
Right now, I keep a list of my temp files and delete them with an EventHandler that's triggered on Application.ApplicationExit.
Is there a better ... | Nothing is guaranteed if the process is killed prematurely, however, I use "`using`" to do this..
```
using System;
using System.IO;
sealed class TempFile : IDisposable
{
string path;
public TempFile() : this(System.IO.Path.GetTempFileName()) { }
public TempFile(string path)
{
if (string.IsNul... |
400,146 | <p>I've got a couple of ASP.Net Usercontrols that I am using in different locations of my new website. These usercontrols had links like this : </p>
<pre><code><a href="daily/panchang/"></a>
</code></pre>
<p>If the usercontrol is used in pages in various subdirectories the relative path just doesn't work... | [
{
"answer_id": 400153,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 2,
"selected": false,
"text": "<p>Be careful though because every element that has <code>runat=\"server\"</code> will be 'serialized' and stored in... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] | I've got a couple of ASP.Net Usercontrols that I am using in different locations of my new website. These usercontrols had links like this :
```
<a href="daily/panchang/"></a>
```
If the usercontrol is used in pages in various subdirectories the relative path just doesn't work, and I don't want to provide my full w... | I won't say whether it's an elegant solution, I'll just point out an alterantive within System.Web:
```
<a href="<%= VirtualPathUtility.ToAbsolute("~/daily/panchang/") %>">
``` |
400,167 | <p>I want to move the form title, icon and close, and help buttons from left side to right side (change the layout).</p>
<p>I moved the form controls manually to keep background image but now I want to change the form title.</p>
<p>When I set rightToLeft property to yes and rightToLeftLayout to true in the form prope... | [
{
"answer_id": 400174,
"author": "Blounty",
"author_id": 33944,
"author_profile": "https://Stackoverflow.com/users/33944",
"pm_score": 2,
"selected": false,
"text": "<p>BackgroundImage, Opacity, TransparencyKey, and the painting events are not supported when RightToLeftLayout is set to y... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42782/"
] | I want to move the form title, icon and close, and help buttons from left side to right side (change the layout).
I moved the form controls manually to keep background image but now I want to change the form title.
When I set rightToLeft property to yes and rightToLeftLayout to true in the form properties the backgro... | To further Blounty's answer, the MSDN specs clearly state that BackgroundImage, Opacity and others aren't supported when using RightToLeftLayout:
[<http://msdn.microsoft.com/en-us/library/system.windows.forms.form.righttoleftlayout(vs.80).aspx>](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.rightto... |
400,180 | <p>I'm trying to create a Shared Addin using VS 2008 for Office XP (Excel to be precise). However, after creating the project in Visual studio and changing the references to Office XP (apart from Extensibility which I don't seem to be able to find a copy for office xp) and adding excel.exe to the references as well. I ... | [
{
"answer_id": 401091,
"author": "Øyvind Skaar",
"author_id": 49194,
"author_profile": "https://Stackoverflow.com/users/49194",
"pm_score": 0,
"selected": false,
"text": "<p>You need the PIAs installed as a prerequisite. Does the addin install at all, or fail at installation? An add-in m... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6414/"
] | I'm trying to create a Shared Addin using VS 2008 for Office XP (Excel to be precise). However, after creating the project in Visual studio and changing the references to Office XP (apart from Extensibility which I don't seem to be able to find a copy for office xp) and adding excel.exe to the references as well. I now... | I found the problem with this in the end.
The problem came from a KB entry [908002](http://support.microsoft.com/kb/908002). Unfortunatley, to run the fix you need Visual Studio 2005 and Office 2003 installed otherwise it won't deploy the fix and so I had glossed over this quite a few times. In the end I found an old ... |
400,181 | <p>I've faced strange problem. While user change of check box input element on form produces adequate event programmatic change don't. How should I face this challenge? Code following:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<... | [
{
"answer_id": 400217,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 1,
"selected": false,
"text": "<p>In this case you should not code logic in the event handler function itself. You should place any such logic in ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2313/"
] | I've faced strange problem. While user change of check box input element on form produces adequate event programmatic change don't. How should I face this challenge? Code following:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www... | It's impossible to track object's state within javascript language as it could be done in Objective-C (KVO). Nor it possible using DOM features - DOM do not fire events on every property change - instead it only fires events on certain user actions: mouse clicks, key presses, or page life cycle and their derivatives.
... |
400,197 | <p>I have done jQuery and Ajax, but I am not able to get the response into a Div element. This is the code:</p>
<p><strong>Index.html</strong></p>
<pre><code>$.ajax({
type:"POST",
url: "ajax.php",
data:"id="+id ,
success: function(html){
$("#response").html(data);
}
});
</code></pre>
<p>I... | [
{
"answer_id": 400232,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 7,
"selected": true,
"text": "<p>You can use <code>.filter</code> on a jQuery object that was created from the response:</p>\n\n<pre><code>success: funct... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I have done jQuery and Ajax, but I am not able to get the response into a Div element. This is the code:
**Index.html**
```
$.ajax({
type:"POST",
url: "ajax.php",
data:"id="+id ,
success: function(html){
$("#response").html(data);
}
});
```
It is receiving the response to my `<div id="re... | You can use `.filter` on a jQuery object that was created from the response:
```
success: function(data){
//Create jQuery object from the response HTML.
var $response=$(data);
//Query the jQuery object for the values
var oneval = $response.filter('#one').text();
var subval = $response.filter('#sub... |
400,212 | <p>How do I copy text to the clipboard (multi-browser)?</p>
<p>Related: <em><a href="https://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard">How does Trello access the user's clipboard?</a></em></p>
| [
{
"answer_id": 400244,
"author": "Stormenet",
"author_id": 2090,
"author_profile": "https://Stackoverflow.com/users/2090",
"pm_score": 3,
"selected": false,
"text": "<p>As far as I know that only works in Internet Explorer.</p>\n\n<p>See also <em><a href=\"http://www.dynamic-tools.n... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264/"
] | How do I copy text to the clipboard (multi-browser)?
Related: *[How does Trello access the user's clipboard?](https://stackoverflow.com/questions/17527870/how-does-trello-access-the-users-clipboard)* | Overview
========
There are three primary browser APIs for copying to the clipboard:
1. [Async Clipboard API](https://www.w3.org/TR/clipboard-apis/#async-clipboard-api) `[navigator.clipboard.writeText]`
* Text-focused portion available in [Chrome 66 (March 2018)](https://developers.google.com/web/updates/2018/03/cl... |
400,235 | <p>I'm trying to get to grips with Java ME development for the Pocket PC. I'm running the NSIcom CrE-ME emulator and building my application with NetBeans 6.5.</p>
<p>The application is based around three tab panels, each of which have Swing components. The contents Swing components are updated at various points in th... | [
{
"answer_id": 400709,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>OK, I've finally found out that apparently this is all I need:</p>\n\n<pre><code>this.tableSurvey = new JTable(new DefaultT... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to get to grips with Java ME development for the Pocket PC. I'm running the NSIcom CrE-ME emulator and building my application with NetBeans 6.5.
The application is based around three tab panels, each of which have Swing components. The contents Swing components are updated at various points in the applicat... | OK, I've finally found out that apparently this is all I need:
```
this.tableSurvey = new JTable(new DefaultTableModel(data, columnNames));
this.scrollPaneSurvey.setViewportView(this.tableSurvey);
this.scrollPaneSurvey.validate();
```
Can anyone explain why using the code below instead of the setViewportView(... |
400,246 | <p>Haven't seen many Geneva related questions yet, I have posted this question in the <a href="http://social.msdn.microsoft.com/Forums/en-US/Geneva/threads/" rel="noreferrer">Geneva Forum</a> as well...</p>
<p>I'm working on a scenario where we have a win forms app with a wide installbase, which will be issuing freque... | [
{
"answer_id": 400381,
"author": "Yossi Dahan",
"author_id": 43541,
"author_profile": "https://Stackoverflow.com/users/43541",
"pm_score": 4,
"selected": true,
"text": "<p>This is almost embarrassing, but thanks to Dominick Baier on the forum I no now realise I've missed a huge point (I ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43541/"
] | Haven't seen many Geneva related questions yet, I have posted this question in the [Geneva Forum](http://social.msdn.microsoft.com/Forums/en-US/Geneva/threads/) as well...
I'm working on a scenario where we have a win forms app with a wide installbase, which will be issuing frequent calls to various services hosted by... | This is almost embarrassing, but thanks to Dominick Baier on the forum I no now realise I've missed a huge point (I knew it didn't make sense! honestly! :-) ) -
A token gets retrieved once per service proxy, assuming it hadn't expired, and so all I needed to do is to reuse the same proxy, which I planned to do anyway... |
400,255 | <p>Is there any way to get around the Oracle 10g limitation of 1000 items in a static IN clause? I have a comma delimited list of many of IDs that I want to use in an IN clause, Sometimes this list can exceed 1000 items, at which point Oracle throws an error. The query is similar to this...</p>
<pre><code>select * ... | [
{
"answer_id": 400260,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 8,
"selected": true,
"text": "<p>Put the values in a temporary table and then do a select where id in (select id from temptable)</p>\n"
},
{
... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24908/"
] | Is there any way to get around the Oracle 10g limitation of 1000 items in a static IN clause? I have a comma delimited list of many of IDs that I want to use in an IN clause, Sometimes this list can exceed 1000 items, at which point Oracle throws an error. The query is similar to this...
```
select * from table1 where... | Put the values in a temporary table and then do a select where id in (select id from temptable) |
400,256 | <p>How can i draw a box in css? I want a box like the green one used to display the number of answers to a question in stackoverflow?</p>
| [
{
"answer_id": 400265,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>Use any element – e.g. a <code>div</code>, make sure it's displayed as a block-level element (i.e. <code>display: ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20894/"
] | How can i draw a box in css? I want a box like the green one used to display the number of answers to a question in stackoverflow? | CSS:
```
.answerbox
{
height: 150px; /*Specify Height*/
width: 150px; /*Specify Width*/
border: 1px solid black; /*Add 1px solid border, use any color you want*/
background-color: green; /*Add a background color to the box*/
text-align:center; /*Align the text to the center*/
}
```
HTML:
`<div class="answerbox">4 ... |
400,257 | <p>I'm using an API that requires me to pass a function pointer as a callback. I'm trying to use this API from my class but I'm getting compilation errors. </p>
<p>Here is what I did from my constructor:</p>
<pre><code>m_cRedundencyManager->Init(this->RedundencyManagerCallBack);
</code></pre>
<p>This doesn't c... | [
{
"answer_id": 400261,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>What argument does <code>Init</code> take? What is the new error message?</p>\n\n<p>Method pointers in C++ are a b... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33030/"
] | I'm using an API that requires me to pass a function pointer as a callback. I'm trying to use this API from my class but I'm getting compilation errors.
Here is what I did from my constructor:
```
m_cRedundencyManager->Init(this->RedundencyManagerCallBack);
```
This doesn't compile - I get the following error:
>... | That doesn't work because a member function pointer cannot be handled like a normal function pointer, because it expects a "this" object argument.
Instead you can pass a static member function as follows, which are like normal non-member functions in this regard:
```
m_cRedundencyManager->Init(&CLoggersInfra::Callba... |
400,276 | <p>I´m trying to make a regular expression to match a whitespace and so far I´m doing this:</p>
<pre><code>Powered[\s]*[bB]y.*MyBB
</code></pre>
<p>I know it should work because I've tried it with Regex Buddy and it says it does but when I try to run it with Eclipse it marks an error saying it's not a valid escape se... | [
{
"answer_id": 400305,
"author": "Raymond Roestenburg",
"author_id": 50142,
"author_profile": "https://Stackoverflow.com/users/50142",
"pm_score": 2,
"selected": false,
"text": "<p>A '\\' identifies an escape character in java, so you need to escape it if you want to use it on it's own. ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28586/"
] | I´m trying to make a regular expression to match a whitespace and so far I´m doing this:
```
Powered[\s]*[bB]y.*MyBB
```
I know it should work because I've tried it with Regex Buddy and it says it does but when I try to run it with Eclipse it marks an error saying it's not a valid escape sequence and it automaticall... | Exactly what do you mean with using a regular expression in Eclipse? Are you trying to do a search-and-replace in the IDE, or are you trying to use a regex in your Java code?
If you want to use a regex in Java code, generate a Java source code snippet on the Use tab in RegexBuddy, and paste that into your code.
If yo... |
400,283 | <p>I want to filter values from database based on date.</p>
<p>Date in a database contains values like this: 2008-12-28 18:00:00. And my class has a DateTime variable depending on which I want to filter. Ideally it would work like this:
<code>myBindingSource.Filter = "DATE(myDateField) = myDateTime.Date"</code> + adju... | [
{
"answer_id": 400344,
"author": "DCNYAM",
"author_id": 30419,
"author_profile": "https://Stackoverflow.com/users/30419",
"pm_score": 0,
"selected": false,
"text": "<p>Is myDateField the name of the field in the dataset? I think you want an expression like this:</p>\n\n<pre><code>myBind... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50173/"
] | I want to filter values from database based on date.
Date in a database contains values like this: 2008-12-28 18:00:00. And my class has a DateTime variable depending on which I want to filter. Ideally it would work like this:
`myBindingSource.Filter = "DATE(myDateField) = myDateTime.Date"` + adjusting myDateTime.Date... | The getSqlDate function is not needed. You can use String.Format() to format dates:
```
String.Format("{0:yyyy-MM-dd} 00:00:00", myDateTime)
```
OR
```
myDateTime.Date.ToString("yyyy-MM-dd") + " 00:00:00"
```
You could filter the binding source like this:
```
myBindingSource.Filter = String.Format("myDateField >... |
400,288 | <p>I'm looking for an algorithm to efficiently place all-day/multi-day event banners, much like the month view in Outlook or Google Calendar. I have a number of events with a begin and end date, ordered by increasing begin (and then end) date (or any other order you please, I'm gathering events from a database table). ... | [
{
"answer_id": 400445,
"author": "Wes P",
"author_id": 13611,
"author_profile": "https://Stackoverflow.com/users/13611",
"pm_score": 0,
"selected": false,
"text": "<p>I think in a situation like this, you're much better off making sure your data is organized properly first and then rende... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50175/"
] | I'm looking for an algorithm to efficiently place all-day/multi-day event banners, much like the month view in Outlook or Google Calendar. I have a number of events with a begin and end date, ordered by increasing begin (and then end) date (or any other order you please, I'm gathering events from a database table). I w... | Here is a high-level sketch of one possible solution (using day-of-week integers instead of full-blown dates). This interface:
```
public interface IEvent {
public abstract int getFirst(); // first day of event
public abstract int getLast(); // last day of event
public abstract int getLength(); // tota... |
400,314 | <p>I have a VB background and I'm converting to C# for my new job. I'm also trying to get better at .NET in general. I've seen the keyword "T" used a lot in samples people post. What does the "T" mean in C#? For example:</p>
<pre><code>public class SomeBase<T> where T : SomeBase<T>, new()
</code></pre>... | [
{
"answer_id": 400321,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 1,
"selected": false,
"text": "<p>It means \"any class\". It could be \"B\", \"A\", whatever. I think T is used because of \"Template\"</p>\n"
},
... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] | I have a VB background and I'm converting to C# for my new job. I'm also trying to get better at .NET in general. I've seen the keyword "T" used a lot in samples people post. What does the "T" mean in C#? For example:
```
public class SomeBase<T> where T : SomeBase<T>, new()
```
What does `T` do? Why would I want to... | It's a symbol for a [generic type parameter](http://msdn.microsoft.com/en-us/library/512aeb7t.aspx). It could just as well be something else, for example:
```
public class SomeBase<GenericThingy> where GenericThingy : SomeBase<GenericThingy>, new()
```
Only T is the default one used and encouraged by Microsoft. |
400,330 | <p>While attempting to use the following code, I am receiving the following error : Already working for different url, error code 155000.</p>
<pre><code>string targetPath = @"C:\Documents and Settings\Admin\My Documents\CPM Creator\"; //" for prettify
client.Authentication.DefaultCredentials = new NetworkCredential... | [
{
"answer_id": 400321,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 1,
"selected": false,
"text": "<p>It means \"any class\". It could be \"B\", \"A\", whatever. I think T is used because of \"Template\"</p>\n"
},
... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | While attempting to use the following code, I am receiving the following error : Already working for different url, error code 155000.
```
string targetPath = @"C:\Documents and Settings\Admin\My Documents\CPM Creator\"; //" for prettify
client.Authentication.DefaultCredentials = new NetworkCredential("guestUser", ... | It's a symbol for a [generic type parameter](http://msdn.microsoft.com/en-us/library/512aeb7t.aspx). It could just as well be something else, for example:
```
public class SomeBase<GenericThingy> where GenericThingy : SomeBase<GenericThingy>, new()
```
Only T is the default one used and encouraged by Microsoft. |
400,346 | <p>Does anyone know how to disable an ASP.NET validator using JavaScript?
I'm using javascript style.display = 'none' to disable parts of a web page. However these disabled parts have asp.net validators that are still firing and I need to disable then without doing a round trip to the server.
Thanks.</p>
| [
{
"answer_id": 400353,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 7,
"selected": true,
"text": "<p>Use this snippet:</p>\n\n<pre><code>function doSomething()\n{\n var myVal = document.getElementById('myValidatorC... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47036/"
] | Does anyone know how to disable an ASP.NET validator using JavaScript?
I'm using javascript style.display = 'none' to disable parts of a web page. However these disabled parts have asp.net validators that are still firing and I need to disable then without doing a round trip to the server.
Thanks. | Use this snippet:
```
function doSomething()
{
var myVal = document.getElementById('myValidatorClientID');
ValidatorEnable(myVal, false);
}
``` |
400,359 | <p>Let's say that I have written a custom e-mail management application for the company that I work for. It reads e-mails from the company's support account and stores cleaned-up, plain text versions of them in a database, doing other neat things like associating it with customer accounts and orders in the process. Whe... | [
{
"answer_id": 400387,
"author": "Ole",
"author_id": 49540,
"author_profile": "https://Stackoverflow.com/users/49540",
"pm_score": 3,
"selected": true,
"text": "<p>You could try to check if a newline has been inserted to keep the line length below a maximum (aka hard wrap): Just check fo... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32187/"
] | Let's say that I have written a custom e-mail management application for the company that I work for. It reads e-mails from the company's support account and stores cleaned-up, plain text versions of them in a database, doing other neat things like associating it with customer accounts and orders in the process. When a... | You could try to check if a newline has been inserted to keep the line length below a maximum (aka hard wrap): Just check for the longest line in the text. Then, for any given line, you append the first word of the following line to it. If the resulting line exceeds the maximum length, the line break probably was a har... |
400,364 | <h3>The Problem</h3>
<p>What is the proper way to check for the <code>foo</code> parameter in the following url's querystring using asp.net? Is this even possible?</p>
<pre><code>http://example.com?bar=3&foo
</code></pre>
<p>I have tried checking <code>Request["foo"]</code> as well as <code>Request.Query... | [
{
"answer_id": 400370,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 3,
"selected": false,
"text": "<p>You get null because the <code>foo</code> parameter doesn't have a value with it.</p>\n\n<p>...What's the problem... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208/"
] | ### The Problem
What is the proper way to check for the `foo` parameter in the following url's querystring using asp.net? Is this even possible?
```
http://example.com?bar=3&foo
```
I have tried checking `Request["foo"]` as well as `Request.QueryString["foo"]` and I get `null` for both. I have also tried populating... | You can use `null` as the key for the `NameValueCollection` and it will give you a comma-delimited list of parameter names that don't have values.
For `http://example.com?bar=3&foo` you would use `Request.QueryString[null]` and it would retrieve `foo`.
If you have more than one parameter name without a value, it will... |
400,395 | <p>Using xaml ( wpf ) I'm trying to get rid of the line under the tab control as show in the "Illustration A" below so that it ends up looking like "Illustration B":</p>
<p>Illustration A</p>
<p><a href="http://www.arulerforwindows.com/images/peskylinea.png">http://www.arulerforwindows.com/images/peskylinea.png</a></... | [
{
"answer_id": 400601,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 2,
"selected": false,
"text": "<p>Using <a href=\"http://www.sellsbrothers.com/tools/#ShowMeTheTemplate\" rel=\"nofollow noreferrer\">ShowMeTheTemplate</a> I... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18735/"
] | Using xaml ( wpf ) I'm trying to get rid of the line under the tab control as show in the "Illustration A" below so that it ends up looking like "Illustration B":
Illustration A
<http://www.arulerforwindows.com/images/peskylinea.png>
Illustration B
<http://www.arulerforwindows.com/images/peskylineb.png>
The line s... | Using [ShowMeTheTemplate](http://www.sellsbrothers.com/tools/#ShowMeTheTemplate) I found out part of the style, it's on the TabItem. There is a lot more in the default control template you may be interested in setting up if you override it.
```
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selec... |
400,407 | <p>I am writing a web server application in C# and using StreamReader class to read from an underlying NetworkStream:</p>
<pre><code> NetworkStream ns = new NetworkStream(clientSocket);
StreamReader sr = new StreamReader(ns);
String request = sr.ReadLine();
</code></pre>
<p>This code is prone to DoS attacks because... | [
{
"answer_id": 400419,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>You would have to use the <code>Read(char[], int, int)</code> overload (which does limit the length) and do your ow... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50191/"
] | I am writing a web server application in C# and using StreamReader class to read from an underlying NetworkStream:
```
NetworkStream ns = new NetworkStream(clientSocket);
StreamReader sr = new StreamReader(ns);
String request = sr.ReadLine();
```
This code is prone to DoS attacks because if the attacker never dis... | You would have to use the `Read(char[], int, int)` overload (which does limit the length) and do your own end-of-line detection; shouldn't be too tricky.
For a slightly lazy version (that uses the single-characted reading version):
```
static IEnumerable<string> ReadLines(string path, int maxLineLength)
{
StringB... |
400,413 | <p>I've got a simple asmx web service that just needs to log some information to a transactional database. However it is timing out for the client. The call to update the database just calls 1 stored procedure and I don't beleive it could be optimized further for better performance. I've been reduced to just logging... | [
{
"answer_id": 400419,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "<p>You would have to use the <code>Read(char[], int, int)</code> overload (which does limit the length) and do your ow... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50186/"
] | I've got a simple asmx web service that just needs to log some information to a transactional database. However it is timing out for the client. The call to update the database just calls 1 stored procedure and I don't beleive it could be optimized further for better performance. I've been reduced to just logging the r... | You would have to use the `Read(char[], int, int)` overload (which does limit the length) and do your own end-of-line detection; shouldn't be too tricky.
For a slightly lazy version (that uses the single-characted reading version):
```
static IEnumerable<string> ReadLines(string path, int maxLineLength)
{
StringB... |
400,421 | <p>In VB6 code, I have the following:</p>
<pre><code>dim I as Long
I = Weekday(Now, vbFriday)
</code></pre>
<p>I want the equivalent in C#. Can any one help?</p>
| [
{
"answer_id": 400426,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "<p>You mean the <a href=\"http://msdn.microsoft.com/en-us/library/system.datetime.dayofweek.aspx\" rel=\"nofollow nor... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299/"
] | In VB6 code, I have the following:
```
dim I as Long
I = Weekday(Now, vbFriday)
```
I want the equivalent in C#. Can any one help? | ```
public static int Weekday(DateTime dt, DayOfWeek startOfWeek)
{
return (dt.DayOfWeek - startOfWeek + 7) % 7;
}
```
This can be called using:
```
DateTime dt = DateTime.Now;
Console.WriteLine(Weekday(dt, DayOfWeek.Friday));
```
The above outputs:
```
4
```
as Tuesday is 4 days after Friday. |
400,428 | <p>I can't seem to get my head around this one. I'm using HttpWebRequest to try and send some data out to another site. I'm attempting to figure out the best way to get our firewalls configured, but I'm at a loss. By watching the NetMon trace, it appears as though it's ignoring what I tell it; the HTTP headers I see go... | [
{
"answer_id": 400474,
"author": "Wes P",
"author_id": 13611,
"author_profile": "https://Stackoverflow.com/users/13611",
"pm_score": 0,
"selected": false,
"text": "<p>I've done <code>HttpWebRequest</code> calls over SSL and have never run into this problem. The only thing I can see that... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212/"
] | I can't seem to get my head around this one. I'm using HttpWebRequest to try and send some data out to another site. I'm attempting to figure out the best way to get our firewalls configured, but I'm at a loss. By watching the NetMon trace, it appears as though it's ignoring what I tell it; the HTTP headers I see go ou... | Your problem appears to be the proxy server between your ASP.NET server and the remote server. You can try not using the proxy server (wr.Proxy = null), but that may be required for your network setup.
I'd recommend talking to whoever is responsible for the network where your server is and seeing if the proxy supports... |
400,432 | <p>I have this <code>If</code> condition in VB6 </p>
<pre><code>If ( X AND ( 2 ^ Y)) Then
a = a + " 1"
Else
a = a + " 0"
</code></pre>
<p>I want the same equivalent in C# </p>
<p>I tried doing like </p>
<pre><code>if ( X && ( 2 ^ Y)) // ERROR: && can not be used between int to int
a = a +... | [
{
"answer_id": 400440,
"author": "Stefan",
"author_id": 48003,
"author_profile": "https://Stackoverflow.com/users/48003",
"pm_score": 0,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>if ( 1 & ( 2 ^ 1))\n a = a + \"1\";\nelse\n a= a+ \"0\";\n</code></pre>\n"
},
{
"ans... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299/"
] | I have this `If` condition in VB6
```
If ( X AND ( 2 ^ Y)) Then
a = a + " 1"
Else
a = a + " 0"
```
I want the same equivalent in C#
I tried doing like
```
if ( X && ( 2 ^ Y)) // ERROR: && can not be used between int to int
a = a + "1";
else
a = a + "0";
```
but this thing is giving me an error.
... | **Note**: This answer has been heavily edited due to lack of information in original question. This version of the answer is now based on the updated question with enough information. For history, check the edit log.
Two things:
* `&&` is used between Boolean expressions, to determine the logical AND-value
* `^` in C... |
400,464 | <p>The following code loads a gig, clears out the gigs acts collection and then adds a new act.</p>
<pre><code> Data.LinqToSQL.Gig dbGig = DBContext.Gigs.Where(x => x.ID == myGigID).SingleOrDefault();
//Remove all references to the current acts
if(dbGig.Acts!=null) {
... | [
{
"answer_id": 400486,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you never actually associate the new act with any gig - is that what is missing?</p>\n\n<pre><code>dbGig.Act... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46616/"
] | The following code loads a gig, clears out the gigs acts collection and then adds a new act.
```
Data.LinqToSQL.Gig dbGig = DBContext.Gigs.Where(x => x.ID == myGigID).SingleOrDefault();
//Remove all references to the current acts
if(dbGig.Acts!=null) {
DBContext.Act... | Try opening a fresh DBContext at the beginning of this block. If you're using the same context for the first and second run, it won't see the inserted record the second time around. Resetting the context should force it to see the latest rows in the table. |
400,475 | <p>I want a hyperlink on my main page to launch an HTML help page in a new browser window. However I want the new window to only have an address bar, i.e. not have a menu, toolbars or status bar, and better still not even have an editable address bar. </p>
<p>I have seen this done on quite a few sites but can't figu... | [
{
"answer_id": 400478,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": false,
"text": "<pre><code><SCRIPT LANGUAGE=\"javascript\">\n<!--\nwindow.open ('titlepage.html', 'newwindow', config='heigh... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24039/"
] | I want a hyperlink on my main page to launch an HTML help page in a new browser window. However I want the new window to only have an address bar, i.e. not have a menu, toolbars or status bar, and better still not even have an editable address bar.
I have seen this done on quite a few sites but can't figure out what ... | To expand a little on what ocdecio has above, you can place the `window.open` call a function accessed from your various hyperlinks, allowing different links to pop up new windows by passing in a different argument to the function.
```
<a href="#" onclick="openWindow('faq.html');">FAQ</a>
<a href="#" onclick="openWind... |
400,495 | <p>How can I retuen a Object from a web service:</p>
<p>[WebMethod]
public DataSet GetVendors(string Database)
{
SqlConnection sqlConn = new SqlConnection();</p>
<pre><code> sqlConn.ConnectionString = GetConnString(Database);
// build query
string strSQL = @" SELEC... | [
{
"answer_id": 400523,
"author": "Wes P",
"author_id": 13611,
"author_profile": "https://Stackoverflow.com/users/13611",
"pm_score": 2,
"selected": true,
"text": "<p>If I'm interpreting your question properly, populate an object on your end with your information in the <code>DataSet</cod... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49971/"
] | How can I retuen a Object from a web service:
[WebMethod]
public DataSet GetVendors(string Database)
{
SqlConnection sqlConn = new SqlConnection();
```
sqlConn.ConnectionString = GetConnString(Database);
// build query
string strSQL = @" SELECT [No_] AS [VendorNo],
... | If I'm interpreting your question properly, populate an object on your end with your information in the `DataSet` and set your return type to `object`. Or just return the object you populate as that object. |
400,522 | <p>I'm trying to match the parts of a version number (Major.Minor.Build.Revision) with C# regular expressions. However, I'm pretty new to writing Regex and even using Expresso is proving to be a little difficult. Right now, I have this:</p>
<pre><code>(?<Major>\d*)\.(?<Minor>\d*)\.(?<Build>\d*)\.(?&l... | [
{
"answer_id": 400534,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 5,
"selected": true,
"text": "<pre><code>(?<Major>\\d*)\\.(?<Minor>\\d*)(\\.(?<Build>\\d*)(\\.(?<Revision>\\d*))?)?\n</c... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31516/"
] | I'm trying to match the parts of a version number (Major.Minor.Build.Revision) with C# regular expressions. However, I'm pretty new to writing Regex and even using Expresso is proving to be a little difficult. Right now, I have this:
```
(?<Major>\d*)\.(?<Minor>\d*)\.(?<Build>\d*)\.(?<Revision>\d*)
```
This works, b... | ```
(?<Major>\d*)\.(?<Minor>\d*)(\.(?<Build>\d*)(\.(?<Revision>\d*))?)?
```
Makes the third and fourth parts optional. |
400,552 | <p>I can't seem to find a .NET answer to this problem, which I would have thought would be fairly common.<br>
What is the best pattern for unit testing an asynchronous method?</p>
<p>Obviously I need to call the method and then see if the callback fires, but is there a better way than simply sleeping for a bit and the... | [
{
"answer_id": 400578,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 4,
"selected": true,
"text": "<p>I typically use an anonymous delegate and a waithandle. FOr example I have a function in my presenter called SetRemoteTa... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50204/"
] | I can't seem to find a .NET answer to this problem, which I would have thought would be fairly common.
What is the best pattern for unit testing an asynchronous method?
Obviously I need to call the method and then see if the callback fires, but is there a better way than simply sleeping for a bit and then checking ... | I typically use an anonymous delegate and a waithandle. FOr example I have a function in my presenter called SetRemoteTableName. When the name is set, it also raises an event. I want to test that event, which is raised asynchronously. The test looks like this:
```
[TestMethod]
[WorkItem(244)]
[Description("Ensures cal... |
400,557 | <p>How can i convert this to a decimal in SQL? Below is the equation and i get the answer as 78 (integer) but the real answer is 78.6 (with a decimal) so i need to show this as otherwise the report won't tally up to 100%</p>
<pre><code>(100 * [TotalVisit1]/[TotalVisits]) AS Visit1percent
</code></pre>
| [
{
"answer_id": 400571,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 1,
"selected": false,
"text": "<p>At least in MySQL (if it helps), if you want to use float numbers you had to use a type float field, not the regul... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can i convert this to a decimal in SQL? Below is the equation and i get the answer as 78 (integer) but the real answer is 78.6 (with a decimal) so i need to show this as otherwise the report won't tally up to 100%
```
(100 * [TotalVisit1]/[TotalVisits]) AS Visit1percent
``` | ```
convert(decimal(5,2),(100 * convert(float,[TotalVisit1])/convert(float,[TotalVisits]))) AS Visit1percent
```
Ugly, but it works. |
400,562 | <p>I have a table where one column has duplicate records but other columns are distinct. so something like this</p>
<p>Code SubCode version status</p>
<p>1234 D1 1 A</p>
<p>1234 D1 0 P</p>
<p>1234 DA 1 A</p>
<p>1234 DB 1 P</p>
... | [
{
"answer_id": 400596,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": "<p>In your select, add a where clause that reads:</p>\n\n<pre><code>Select [stuff]\nFrom Table T\nWhere Exists\n ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table where one column has duplicate records but other columns are distinct. so something like this
Code SubCode version status
1234 D1 1 A
1234 D1 0 P
1234 DA 1 A
1234 DB 1 P
5678 BB 1 A
5678 BB 0 P
5678 BP 1 A
5678 BJ 1 A
0987 HH 1 A
So in the above table. subcode and Version are unique values whe... | ```
INSERT theTempTable (Code)
SELECT t.Code
FROM theTable t
LEFT OUTER JOIN theTable subT ON (t.Code = subT.Code AND subT.status <> 'A')
WHERE subT.Code IS NULL
GROUP BY t.Code
```
This should do the trick. The logic is a little tricky, but I'll do my best to explain how it is derived.
The outer join comb... |
400,565 | <p>I'm currently trying to modify some HttpWebRequest functions, but I can't do it through inheritance because HttpWebRequest has no public constructors (besides the deserialization constructor). Is there a workaround to do this?</p>
<p>My objective is to code something like the example below, but this class objects m... | [
{
"answer_id": 400579,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 3,
"selected": true,
"text": "<p>Unless you can trick the serialization constructor to do your bidding, then no, there is no way.</p>\n\n<p>The cons... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | I'm currently trying to modify some HttpWebRequest functions, but I can't do it through inheritance because HttpWebRequest has no public constructors (besides the deserialization constructor). Is there a workaround to do this?
My objective is to code something like the example below, but this class objects must inheri... | Unless you can trick the serialization constructor to do your bidding, then no, there is no way.
The constructors of that class are internal, so you have no way of calling them. |
400,566 | <p>Does anyone know of existing code that lets you draw fully justified text in Java2D?</p>
<p>For example, if I said, <code>drawString("sample text here", x, y, width)</code>, is there an existing library that could figure out how much of that text fits within the width, do some inter-character spacing to make the te... | [
{
"answer_id": 400676,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 5,
"selected": true,
"text": "<p>Although not the most elegant nor robust solution, here's an method that will take the <a href=\"http://java.sun.com/jav... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | Does anyone know of existing code that lets you draw fully justified text in Java2D?
For example, if I said, `drawString("sample text here", x, y, width)`, is there an existing library that could figure out how much of that text fits within the width, do some inter-character spacing to make the text look good, and aut... | Although not the most elegant nor robust solution, here's an method that will take the [`Font`](http://java.sun.com/javase/6/docs/api/java/awt/Font.html) of the current [`Graphics`](http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html) object and obtain its [`FontMetrics`](http://java.sun.com/javase/6/docs/api/... |
400,567 | <p>Our ssl certificate recently expired, so we were issued a new one by the CA. Unfortunately, when biztalk uses this certificate to access a server, the server rejects it, giving us a 403.17 error (Expired or not yet valid). </p>
<p>So I checked the dates of the certificate and it seems okay. But to really check if t... | [
{
"answer_id": 400676,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 5,
"selected": true,
"text": "<p>Although not the most elegant nor robust solution, here's an method that will take the <a href=\"http://java.sun.com/jav... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526/"
] | Our ssl certificate recently expired, so we were issued a new one by the CA. Unfortunately, when biztalk uses this certificate to access a server, the server rejects it, giving us a 403.17 error (Expired or not yet valid).
So I checked the dates of the certificate and it seems okay. But to really check if the certifi... | Although not the most elegant nor robust solution, here's an method that will take the [`Font`](http://java.sun.com/javase/6/docs/api/java/awt/Font.html) of the current [`Graphics`](http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html) object and obtain its [`FontMetrics`](http://java.sun.com/javase/6/docs/api/... |
400,575 | <p>I'm not quite sure when selecting only a certain number of rows would be better than simply making a more specific select statement. I have a feeling I'm missing something pretty straight forward but I can't figure it out. I have less than 6 months experience with any SQL and it's been cursory at that so I'm sorry... | [
{
"answer_id": 400587,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 2,
"selected": false,
"text": "<p>Custom paging, typically.</p>\n"
},
{
"answer_id": 400604,
"author": "EvilTeach",
"author_id": 773... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33911/"
] | I'm not quite sure when selecting only a certain number of rows would be better than simply making a more specific select statement. I have a feeling I'm missing something pretty straight forward but I can't figure it out. I have less than 6 months experience with any SQL and it's been cursory at that so I'm sorry if t... | I know of two common uses:
Paging : be sure to specify an ordering. If an ordering isn't specified, many db implementations use whatever is convenient for executing the query. This "optimal" ordering behavior could give very unpredictable results.
```
SELECT top 10 CustomerName
FROM Customer
WHERE CustomerID > 200 --... |
400,616 | <p>Like every other web developer on the planet, I have an issue with users double clicking the submit button on my forms. My understanding is that the conventional way to handle this issue, is to disable the button immediately after the first click, however when I do this, <strong>it doesn't post</strong>.</p>
<p>I ... | [
{
"answer_id": 400633,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 2,
"selected": false,
"text": "<p>\"Disabling\" HTML controls doesn't always produce consistent behavior in all major browsers. So I try to stay away from d... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29043/"
] | Like every other web developer on the planet, I have an issue with users double clicking the submit button on my forms. My understanding is that the conventional way to handle this issue, is to disable the button immediately after the first click, however when I do this, **it doesn't post**.
I did do some research on ... | I think you're just missing this tag:
```
UseSubmitBehavior="false"
```
Try it like this:
```
<asp:Button ID="btnUpdate" runat="server" UseSubmitBehavior="false" OnClientClick="if(Page_ClientValidate()) { this.disabled = true; } else {return false;}" Text = "Update" CssClass="button" OnClick="btnUpdate_Click" Valid... |
400,631 | <p>How can I place a banner on webpage with one application to all pages of a website?</p>
| [
{
"answer_id": 400641,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": 0,
"selected": false,
"text": "<p>Well, hopefully you would have designed the website so that if you need to change something globally, you can just ed... | 2008/12/30 | [
"https://Stackoverflow.com/questions/400631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How can I place a banner on webpage with one application to all pages of a website? | One way of doing this is to put your banner into a file, then include that one on each of your other pages. This way, you only have to change the code in one place to update the banner site-wide.
So, a PHP example would be:
```
banner.inc.php:
<?php
// echo out banner here...
?>
```
Then, on your other pages:
``... |